Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"typescript": "^5.7.2"
},
"dependencies": {
"@authorizerdev/authorizer-js": "3.3.0-rc.0",
"@authorizerdev/authorizer-js": "^3.3.0-rc.1",
"@storybook/preset-scss": "^1.0.3",
"validator": "^13.11.0"
}
Expand Down
38 changes: 38 additions & 0 deletions src/components/AuthorizerBasicAuthLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,40 @@ export const AuthorizerBasicAuthLogin: FC<{
}
}, [formData.password]);

// Passkey autofill (WebAuthn conditional mediation): when the browser and the
// user's device support it, discoverable passkeys are offered inline in the
// email/username field's autofill dropdown. Best-effort and silent - the
// explicit "Sign in with a passkey" button remains the primary path, and any
// unsupported/cancelled/aborted ceremony is ignored. Started once on mount
// and aborted on unmount.
useEffect(() => {
let active = true;
authorizerRef
.loginWithPasskeyAutofill()
.then(({ data, errors }) => {
if (!active || (errors && errors.length) || !data) {
return;
}
setAuthData({
user: data.user || null,
token: data,
config,
loading: false,
});
if (onLogin) {
onLogin(data);
}
})
.catch(() => {
// Autofill is best-effort; ignore unsupported/cancelled ceremonies.
});
return () => {
active = false;
authorizerRef.cancelPasskeyAutofill();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

if (totpData.is_screen_visible) {
return (
<AuthorizerTOTPScanner
Expand Down Expand Up @@ -238,6 +272,10 @@ export const AuthorizerBasicAuthLogin: FC<{
}`}
placeholder={getEmailPhonePlaceholder(config)}
type="text"
// Enables WebAuthn passkey autofill: browsers offer discoverable
// passkeys inline in this field's autofill dropdown. Paired with
// the loginWithPasskeyAutofill() ceremony started on mount below.
autoComplete="username webauthn"
value={formData.email_or_phone_number || ''}
onChange={e =>
onInputChange('email_or_phone_number', e.target.value)
Expand Down
Loading