Skip to content

feat(auth): notify hosts when an interactive code is exchanged - #291

Open
danielroe wants to merge 2 commits into
devframes:mainfrom
danielroe:feat/auth-trusted-hook
Open

feat(auth): notify hosts when an interactive code is exchanged#291
danielroe wants to merge 2 commits into
devframes:mainfrom
danielroe:feat/auth-trusted-hook

Conversation

@danielroe

@danielroe danielroe commented Aug 25, 2026

Copy link
Copy Markdown

createInteractiveAuth lets a host render the OTP banner itself via banner (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:

const auth = createInteractiveAuth(ctx, {
  banner: ({ code, url }) => { notice?.dismiss(); notice = ui.notify(code, { url }) },
  onTrusted: () => { notice?.dismiss(); notice = undefined },
})

this adds an onTrusted callback that only fires for interactive code exchange, and after the token rotates, to avoid re-triggering a notice.

Copilot AI lite review requested due to automatic review settings August 25, 2026 09:09
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

@danielroe is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CreateInteractiveAuthOptions with onTrusted({ session, authToken }).
  • Invoke onTrusted after printBanner() in the interactive anonymous:devframe:auth:exchange handler 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))
Copilot AI review requested due to automatic review settings August 25, 2026 09:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.

@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
devframe Ready Ready Preview Aug 25, 2026 9:40am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants