Repository navigation
fix(auth): keep old clients connected across scope changes #10298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliusmarminge
merged 13 commits into
t3code/auth-terminal-read-scope
from
t3code/auth-legacy-scope-compat
Oct 7, 2026
+870
−127
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a3d8753
feat(auth): keep existing credentials working across the scope split
juliusmarminge d8ba325
fix(auth): tolerate legacy clients without expanding grants
juliusmarminge 96a00d7
fix(auth): preserve legacy permission errors and access updates
juliusmarminge 113c8a7
fix(auth): preserve compatible scope responses for reusable dev pairing
juliusmarminge 8e57dcd
fix(auth): retain legacy error fields in v2 RPC authorization
juliusmarminge 9691817
fix(auth): honor exact mobile maintenance permissions
juliusmarminge 03d04df
fix(auth): honor exact and legacy grants in client dispatch
juliusmarminge 7642b0c
test(auth): supply the streamed action correlation id
juliusmarminge 34ba864
test(auth): use current session-store layer helpers
juliusmarminge 760836e
feat(auth): explain permission changes to clients with legacy grants
juliusmarminge d6d6d68
style(auth): format session compatibility imports
juliusmarminge e2447ac
fix(auth): reject empty grants before token issuance
juliusmarminge fe220d7
fix(web): persist permission notice action dismissals
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { useAtomValue } from "@effect/atom-react"; | ||
| import { sessionHasLegacyPermissions } from "@t3tools/contracts"; | ||
| import { Atom } from "effect/reactivity"; | ||
| import * as SecureStore from "expo-secure-store"; | ||
| import { useEffect, useMemo, useRef, useState } from "react"; | ||
| import { Alert } from "react-native"; | ||
|
|
||
| import { useEnvironments } from "../state/environments"; | ||
| import { environmentSession } from "../state/session"; | ||
|
|
||
| const storageKey = "t3code.permission-update.v1"; | ||
| const dismissedThisLaunch = new Set<string>(); | ||
| const shownThisLaunch = new Set<string>(); | ||
|
|
||
| export function PermissionUpdateNotice() { | ||
| const { environments } = useEnvironments(); | ||
| const [dismissed, setDismissed] = useState<ReadonlySet<string> | null>(null); | ||
| const showing = useRef(false); | ||
| const affected = useAtomValue( | ||
| useMemo( | ||
| () => | ||
| Atom.make((get) => | ||
| environments.filter(({ environmentId }) => { | ||
| const session = get(environmentSession.sessionStateAtom(environmentId)); | ||
| return ( | ||
| session._tag === "Success" && | ||
| !session.waiting && | ||
| sessionHasLegacyPermissions(session.value) | ||
| ); | ||
| }), | ||
| ), | ||
| [environments], | ||
| ), | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| let active = true; | ||
| void SecureStore.getItemAsync(storageKey) | ||
| .then((raw) => { | ||
| const value: unknown = raw === null ? [] : JSON.parse(raw); | ||
| if (active) | ||
| setDismissed( | ||
| new Set( | ||
| Array.isArray(value) | ||
| ? value.filter((id): id is string => typeof id === "string") | ||
| : [], | ||
| ), | ||
| ); | ||
| }) | ||
| .catch(() => { | ||
| if (active) setDismissed(new Set()); | ||
| }); | ||
| return () => { | ||
| active = false; | ||
| }; | ||
| }, []); | ||
|
|
||
| useEffect(() => { | ||
| if (dismissed === null || showing.current) return; | ||
| const environment = affected.find( | ||
| ({ environmentId }) => !dismissed.has(environmentId) && !shownThisLaunch.has(environmentId), | ||
| ); | ||
| if (!environment) return; | ||
| showing.current = true; | ||
| shownThisLaunch.add(environment.environmentId); | ||
| const dismiss = () => { | ||
| dismissedThisLaunch.add(environment.environmentId); | ||
| const next = new Set([...dismissed, ...dismissedThisLaunch]); | ||
| // Keep notices serial when several environments have old grants. | ||
| showing.current = false; | ||
| setDismissed(next); | ||
| void SecureStore.setItemAsync(storageKey, JSON.stringify([...next])).catch(() => { | ||
| // Remember for this launch even if persistent storage is unavailable. | ||
| }); | ||
| }; | ||
| Alert.alert( | ||
| `Permissions have changed for ${environment.label}`, | ||
| "This connection still uses the old permissions, so some actions may no longer be available. Pair again using a new link with the permissions you need.", | ||
| [{ text: "Got it", onPress: dismiss }], | ||
| { cancelable: false }, | ||
| ); | ||
| }, [affected, dismissed]); | ||
| return null; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
macroscopeapp[bot] marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.