feat(auth): notify hosts when an interactive code is exchanged - #291
Open
danielroe wants to merge 2 commits into
Open
feat(auth): notify hosts when an interactive code is exchanged#291danielroe wants to merge 2 commits into
danielroe wants to merge 2 commits into
Conversation
|
@danielroe is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an onTrusted callback to createInteractiveAuth so host UIs that render their own OTP banner/notice can reliably retract it after a successful interactive code exchange (after the rotated code is printed), without re-triggering on connect-time trust via static/remote tokens.
Changes:
- Extend
CreateInteractiveAuthOptionswithonTrusted({ session, authToken }). - Invoke
onTrustedafterprintBanner()in the interactiveanonymous:devframe:auth:exchangehandler when the exchange succeeds. - Update API snapshot, docs, and add a new test covering the callback behavior.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/snapshots/tsnapi/devframe/recipes/interactive-auth.snapshot.d.ts | Updates public API snapshot to include the new onTrusted option. |
| packages/devframe/src/recipes/interactive-auth.ts | Adds the onTrusted option and triggers it after a successful exchange. |
| packages/devframe/src/recipes/tests/interactive-auth.test.ts | Adds a test for onTrusted behavior during exchange. |
| docs/content/4.helpers/3.interactive-auth.md | Documents the new onTrusted option and its intended timing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| auth.onConnect(peer, session) | ||
| ``` | ||
|
|
||
| An exchange rotates the code and prints the new one, and `onTrusted` fires after that, so a host retracting a sticky notice drops that follow-up too and calls `printBanner()` when it next wants a code on screen. |
Comment on lines
+141
to
+143
| const banners: { code: string, url: string }[] = [] | ||
| const trusted: { authToken: string }[] = [] | ||
| const { server, host, port } = await startAuthenticatedServer(banners, false, info => trusted.push(info)) |
5 tasks
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
createInteractiveAuthlets a host render the OTP banner itself viabanner(and now we can configure this in vite devtools with vitejs/devtools#548)... now, it would be very useful to be able to hide a custom notice once the user has actually authenticated
effectively we'd do something like this:
this adds an
onTrustedcallback that only fires for interactive code exchange, and after the token rotates, to avoid re-triggering a notice.