onTokens, it generates PKCE, state, and nonce, exchanges the code, and returns the tokens together with any encryption keys from the callback fragment. The keys stay in the browser; only the authorization code and PKCE verifier are sent to the token endpoint.
state and nonce. Verify the id_token with verifyJwt from @ave-id/sdk, or on your server, before trusting its claims. Profile and email fields in tokens.user depend on the granted scopes.
To persist tokens and keys, pass the response to AveSession:
Presentations
All four return promises. Await them before using the returned controls.
onTokens flow, onError receives popup_blocked, and the user can allow popups and try again.
Options
string
required
Your app’s client ID from devs.aveid.net.
string
required
A callback URL registered for your app. It must be identical during authorization and exchange.
string
default:"\"openid profile email\""
Space-separated scopes, including an encryption scope such as
e2ee:symmetric or e2ee:asymmetric.HTMLElement
Element for the inline iframe. Required by
mountAveEmbed; makes startAveAuth render inline.string
default:"\"https://aveid.net\""
Ave origin.
string
default:"\"dark\""
Sign-in theme.
number | string
Inline iframe dimensions, or popup window dimensions in pixels.
Record<string, string>
Extra sign-in parameters, such as
{ prompt: "select_account" } for a switch-account button.(tokens: AveTokenResponse) => void
Receives the token response with merged encryption keys. Takes precedence over
onSuccess.({ redirectUrl }) => void
Receives the callback URL for an exchange your app performs itself.
({ error, message }) => void
Called when sign-in fails.
() => void
Called once when the user dismisses the flow. Completing or failing a flow does not also call it.
Handling the callback yourself
ProvideonSuccess instead of onTokens when your app exchanges the code, for example on a server with a client secret. Public clients must generate and persist their own PKCE verifier, state, and nonce.
redirectUrl carries the encryption keys in its fragment. Navigating to it lets your callback page read them with mergeAppEncryptionFromUrl. If a sheet or inline embed needs a popup that the browser blocks, it redirects the current page to Ave instead, so persisted callback state must survive that navigation.
Security
- Each embed accepts messages only from its configured Ave origin and from its own iframe or popup, so simultaneous flows stay separate. If you listen for
messageevents yourself, check bothevent.originandevent.source. - Call
destroy()orclose()when your component unmounts to remove the frame and its listeners. - Do not load the embed inside a sandboxed iframe that blocks passkeys or popups.
