Passkeys Playground
This is a playground for the webauthn wrapper library. Nothing here is sent to any server, everything runs locally.
Registration
If enabled, the device attestation and clientData will be provided as base64 encoded binary data. Note that this may impact the authenticator information available or the UX depending on the platform.
Browser-side registration code:
await client.register({{registration.options}})
Will result in the following JSON to be sent to the server.
{{registration.json ?? '...'}}
Server-side verification code:
await server.verifyRegistration(registration, {challenge: "{{registration.options.challenge}}", origin: "{{origin}}"})
Resulting into:
{{registration.result ?? '...'}}
At this point, you should store the `credential` and associate it with the user account. You will need it later to verify authentication attempts.
Authentication
Browser-side authentication code:
webauthn.authenticate({{authentication.options}})
Will result in the following JSON to be sent to the server.
{{authentication.json ?? '...'}}
Server-side code to verify the authentication:
const credentialKey = { id: "{{registration?.result?.credential?.id ?? '...'}}", publicKey: "{{registration?.result?.credential?.publicKey ?? '...'}}", algorithm: "{{registration?.result?.credential?.algorithm ?? '...'}}" } const expected = { challenge: "{{authentication?.options.challenge ?? '...'}}", origin: "{{origin}}", userVerified: {{authentication?.options?.userVerification === 'required'}}, counter: -1 } const verified = await server.verifyAuthentication(res, credentialKey, expected)
⚠️ In this demo, verification will only work if the same passkey as the one previoulsy registered is used. Information is not persisted.
Resulting into:
{{authentication.result ?? '...'}}
Signature validation
This part is mainly for debugging purposes or validation.
The public key created during registration.
{{parsedAuthData}}
{{parsedClientData}}
signature = sign(algorithm, publicKey, authenticatorData + sha256(clientData))