mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-24 09:03:11 +00:00
WebAuthn platform passkeys: opt-in enrollment after a password login, a password-less sign-in that mints the same 14-day campaign-token, and revocation from the profile. The session is minted through Payload's public pieces (checkLoginPermission, addSessionToUser, getFieldsToSign, jwtSign) inside a transaction with an advisory lock, so a passkey login neither bypasses a lockout nor evicts the account's other sessions. The rpID is derived from NEXT_PUBLIC_SITE_URL and resolves to null when the request host disagrees, so previews never offer a ceremony the browser would refuse.
28 lines
827 B
TypeScript
28 lines
827 B
TypeScript
'use client'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { canUseCampaignBiometrics } from '@/lib/campaignWebAuthnSupport'
|
|
|
|
/**
|
|
* Whether this browser can run a platform ceremony, resolved after mount
|
|
* because the probe is async and the server cannot answer it. Starts `false` so
|
|
* nothing biometric renders during hydration on a device that has no
|
|
* authenticator; the cancellation guard is the reason this is shared rather than
|
|
* written per island (B40 has two).
|
|
*/
|
|
export const useCampaignBiometricsAvailable = (): boolean => {
|
|
const [available, setAvailable] = useState(false)
|
|
|
|
useEffect(() => {
|
|
let active = true
|
|
void canUseCampaignBiometrics().then((supported) => {
|
|
if (active) setAvailable(supported)
|
|
})
|
|
return () => {
|
|
active = false
|
|
}
|
|
}, [])
|
|
|
|
return available
|
|
}
|