Repository navigation
feat: add a confirmation step for magic links opened on another device - #189
Merged
Merged
Conversation
The verify screens in every binding now ask before approving a link opened on a device other than the one that requested it, and the client gains confirmMagicLink plus helpers to read the 409 the auth API returns in that case. Bearer mode sends the ephemeral token on the verify route when it holds one.
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.
Summary
Client and UI half of the magic link change in seamless-auth-api 0.19.0. A link opened on a device other than the one that asked for it now waits for the reader's approval.
@seamless-auth/clientclient.confirmMagicLink(token):POST /magic-link/verify/{token}/confirm, token encoded into its own path segment, empty JSON body so it takes a CORS preflight./magic-link/verify/:tokenis nowpreAuth, so bearer mode sends the ephemeral token when it holds one and nothing otherwise./magic-link/verify/:token/confirmisnone. Without that rule it would have fallen through to the defaultaccessrule.getMagicLinkConfirmation(error)(409 pluserror: 'confirmation_required', also nested underdetails; a device class it does not know reads asunknown),isMagicLinkConfirmationRequired,describeMagicLinkDevice,magicLinkConfirmationPrompt(locale formatted time, left out when it does not parse), andconfirmMagicLinkSignIn(confirms, then broadcasts on the tab channel in case the requesting tab is in this browser). Types:MagicLinkConfirmation,MagicLinkDeviceClass. Existing exports andMagicLinkOutcomeare unchanged.role="status""return to your other device" message and does not refresh or poll a session on this device. A refused confirmation shows arole="alert"and the buttons can be used again. Declining sends nothing and says the email can be ignored. Every other failure still shows "Failed to verify token". Accessible names are the same across bindings.minorfor client, react, angular, vue and svelte.patchfor react-native, which only changes its README.Checks (run locally, the fork runs no Actions)
Notes
@seamless-auth/types0.28.0 has no schema for the 409 body yet, soMagicLinkConfirmationandMagicLinkDeviceClasslive inpackages/client/src/flows/magicLink.tsfor now. They should become aliases once types publishes the schema.adapter: {}, notcredential: 'preAuth'. So the server adapter may not forward the ephemeral bearer in bearer mode unless it handles that separately.Release order
Part of the v0.19 security release (fells-code/seamless-auth-api#385), reviewed in a private fork. Compatible with the current auth API: the forwarded pre-auth credential and the confirm route are only used by API 0.19.0.