@capagents/forgeqe 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_USE.md +435 -78
- package/README.md +21 -6
- package/THIRD_PARTY_NOTICES.md +210 -1
- package/dist/docs-site/CREDITS.md +6 -0
- package/dist/docs-site/architecture-map/index.html +1 -1
- package/dist/docs-site/docs/app-theme.css +100 -8
- package/dist/docs-site/docs/architecture/index.html +210 -214
- package/dist/docs-site/docs/area-api/index.html +350 -0
- package/dist/docs-site/docs/area-automated-tests/index.html +967 -0
- package/dist/docs-site/docs/area-browser/index.html +430 -0
- package/dist/docs-site/docs/area-data/index.html +605 -0
- package/dist/docs-site/docs/area-desktop/index.html +755 -0
- package/dist/docs-site/docs/area-mobile/index.html +631 -0
- package/dist/docs-site/docs/area-operations/index.html +1069 -0
- package/dist/docs-site/docs/area-pull-requests/index.html +208 -0
- package/dist/docs-site/docs/area-quality/index.html +365 -0
- package/dist/docs-site/docs/area-release/index.html +320 -0
- package/dist/docs-site/docs/area-setup/index.html +1192 -0
- package/dist/docs-site/docs/area-systems/index.html +207 -0
- package/dist/docs-site/docs/area-test-cases/index.html +694 -0
- package/dist/docs-site/docs/containers/index.html +97 -104
- package/dist/docs-site/docs/cost-architecture/index.html +108 -112
- package/dist/docs-site/docs/custom-agents-first-run/index.html +19 -23
- package/dist/docs-site/docs/desktop/index.html +172 -162
- package/dist/docs-site/docs/desktop-ci/index.html +26 -33
- package/dist/docs-site/docs/evidence/index.html +253 -257
- package/dist/docs-site/docs/feature-test-prompts/index.html +66 -70
- package/dist/docs-site/docs/get-started/index.html +495 -0
- package/dist/docs-site/docs/graphify/index.html +42 -46
- package/dist/docs-site/docs/guardrails/index.html +17 -21
- package/dist/docs-site/docs/index.html +17 -6729
- package/dist/docs-site/docs/mobile/index.html +155 -162
- package/dist/docs-site/docs/model-routing/index.html +44 -51
- package/dist/docs-site/docs/overview/index.html +176 -0
- package/dist/docs-site/docs/product-graph/index.html +52 -55
- package/dist/docs-site/docs/product-knowledge/index.html +11 -15
- package/dist/docs-site/docs/product-views/index.html +53 -57
- package/dist/docs-site/docs/reference/index.html +379 -0
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/docs-site/docs/using/index.html +480 -0
- package/dist/docs-site/docs/web-app/index.html +147 -93
- package/dist/docs-site/security/index.html +930 -0
- package/dist/docs-site/security/security-theme.css +161 -0
- package/dist/docs-site/security/security.js +1465 -0
- package/dist/docs-site/vendor/react-18.3.1.production.min.js +31 -0
- package/dist/docs-site/vendor/react-dom-18.3.1.production.min.js +267 -0
- package/dist/docs-site/vendor/reactflow-11.11.4.umd.js +10 -0
- package/dist/forgeqe.js +1902 -1895
- package/dist/web/THIRD_PARTY_NOTICES.md +0 -136
- package/dist/web/assets/Agent-CPhmZdFX.js +8 -0
- package/dist/web/assets/AgentWork-BXdN9xgi.js +2 -0
- package/dist/web/assets/ApiTests-Do3xLjfB.js +10 -0
- package/dist/web/assets/Browse-WVkJT6Bs.js +2 -0
- package/dist/web/assets/Chat-CDc9UcQX.js +3 -0
- package/dist/web/assets/CommandPalette-BAZm62lV.js +1 -0
- package/dist/web/assets/Compare-Br6n9T9L.js +1 -0
- package/dist/web/assets/Cost-BBUyBu3Y.js +1 -0
- package/dist/web/assets/Data-Ch2DPEWp.js +6 -0
- package/dist/web/assets/Desktop-Qzoq-cQv.js +1 -0
- package/dist/web/assets/DesktopReview-CF_jQYAM.js +1 -0
- package/dist/web/assets/Evidence-C72Lj5_Q.js +1 -0
- package/dist/web/assets/Explore-ObkEpUyS.js +2 -0
- package/dist/web/assets/Features-CQzNo_WP.js +1 -0
- package/dist/web/assets/Flags-0-RniPJm.js +2 -0
- package/dist/web/assets/Flaky-BPJvNLCA.js +1 -0
- package/dist/web/assets/Impact-CfccsL_k.js +3 -0
- package/dist/web/assets/Jobs-T6m4zhDy.js +5 -0
- package/dist/web/assets/KindPage-BDUvWe2p.js +6 -0
- package/dist/web/assets/Migration-Dqeh4x5u.js +2 -0
- package/dist/web/assets/PageAgent-DNjzIgeY.js +1 -0
- package/dist/web/assets/Product-nYV_scOV.js +7 -0
- package/dist/web/assets/Production-CGSbEWVa.js +1 -0
- package/dist/web/assets/Quality-BIypojZm.js +1 -0
- package/dist/web/assets/Readiness-BlRjwJRg.js +1 -0
- package/dist/web/assets/Record-v2KLI-_Z.js +1 -0
- package/dist/web/assets/Regression-B-jSt4Jz.js +5 -0
- package/dist/web/assets/RelationGraph-8J98lOVG.js +1 -0
- package/dist/web/assets/Reports-GI4u6SyW.js +2 -0
- package/dist/web/assets/Response-mhBThq2b.js +9 -0
- package/dist/web/assets/Responsive-DXu7Ra7K.js +3 -0
- package/dist/web/assets/RunDiff-D0SHDNp0.js +1 -0
- package/dist/web/assets/Runs-C1Gjdi9M.js +2 -0
- package/dist/web/assets/Settings-BGGeuvyF.js +21 -0
- package/dist/web/assets/Steps-D-YG0eJy.js +2 -0
- package/dist/web/assets/TestCases-DC4w77eQ.js +1 -0
- package/dist/web/assets/TestData-CvKWRVVV.js +2 -0
- package/dist/web/assets/TestDebt-D8YzN29_.js +1 -0
- package/dist/web/assets/TestManagement-C5cDCqrD.js +1 -0
- package/dist/web/assets/Tosca-BGUv3RiJ.js +3 -0
- package/dist/web/assets/WhatsNew-B_Gyuv8O.js +1 -0
- package/dist/web/assets/agents-C0Jg2pN8.js +1 -0
- package/dist/web/assets/coverage-BMP6ELFJ.js +5 -0
- package/dist/web/assets/dataParts-DbeCj9ga.js +3 -0
- package/dist/web/assets/diff-BStuTmsN.js +2 -0
- package/dist/web/assets/families-BBFFrUlo.js +1 -0
- package/dist/web/assets/filters-CnAMr286.js +1 -0
- package/dist/web/assets/fold-D_O_VZui.js +1 -0
- package/dist/web/assets/head-CRo48rPt.js +1 -0
- package/dist/web/assets/highlight-BcFZIf59.js +4 -0
- package/dist/web/assets/index-B3JsM7tv.js +64 -0
- package/dist/web/assets/index-CafApcbZ.css +2 -0
- package/dist/web/assets/input-CtzK50ZF.js +1 -0
- package/dist/web/assets/jsx-runtime-LKYXHABd.js +1 -0
- package/dist/web/assets/line-icons-rdF8DYDJ.js +1 -0
- package/dist/web/assets/logos-D4oVWzqa.js +1 -0
- package/dist/web/assets/palette-DAaGSao7.js +1 -0
- package/dist/web/assets/paletteCommands-Co-RlQ8q.js +1 -0
- package/dist/web/assets/parts-D357Wolo.js +1 -0
- package/dist/web/assets/productParts-B8oHRCJF.js +1 -0
- package/dist/web/assets/qualityParts-BLkmIfDY.js +1 -0
- package/dist/web/assets/recordTest-Cez2sDJO.js +1 -0
- package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/web/assets/route-BloYJWgw.js +1 -0
- package/dist/web/index.html +12 -6
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/BASAL.md +1 -1
- package/docs/DESKTOP.md +20 -1
- package/docs/EVIDENCE.md +1 -1
- package/docs/MOBILE.md +4 -4
- package/docs/PRODUCT_KNOWLEDGE.md +2 -0
- package/docs/WEB_APP.md +114 -51
- package/docs/user-guide.html +404 -81
- package/forgeqe.example.yaml +3 -3
- package/package.json +1 -1
- package/prompts/page-differs.md +1 -1
- package/prompts/requests-rule.md +1 -1
- package/prompts/test-reviewer.md +1 -1
- package/prompts/test-rules.md +3 -4
- package/skills/web-guidance/LICENSE +202 -0
- package/skills/web-guidance/SKILL.md +76 -0
- package/skills/web-guidance/UPSTREAM +67 -0
- package/skills/web-guidance/references/accessibility/accessibility.md +585 -0
- package/skills/web-guidance/references/accessibility/accessible-error-announcement.md +302 -0
- package/skills/web-guidance/references/accessibility/accessible-generated-content.md +41 -0
- package/skills/web-guidance/references/accessibility/respect-os-text-scale.md +127 -0
- package/skills/web-guidance/references/css/responsive-design.md +16 -0
- package/skills/web-guidance/references/forms/autofill-address-form.md +86 -0
- package/skills/web-guidance/references/forms/autofill-payment-form.md +142 -0
- package/skills/web-guidance/references/forms/autofill-sign-in-form.md +145 -0
- package/skills/web-guidance/references/forms/autofill-sign-up-form.md +155 -0
- package/skills/web-guidance/references/forms/forms.md +415 -0
- package/skills/web-guidance/references/forms/ime-safe-enter-submit.md +115 -0
- package/skills/web-guidance/references/forms/required-field-feedback.md +317 -0
- package/skills/web-guidance/references/forms/select-menu-interaction.md +310 -0
- package/skills/web-guidance/references/forms/slider.md +184 -0
- package/skills/web-guidance/references/forms/sms-otp-form.md +208 -0
- package/skills/web-guidance/references/forms/switch.md +60 -0
- package/skills/web-guidance/references/forms/validate-input-after-interaction.md +406 -0
- package/skills/web-guidance/references/performance/break-up-long-tasks.md +64 -0
- package/skills/web-guidance/references/performance/identify-heavy-scripts.md +69 -0
- package/skills/web-guidance/references/performance/identify-inp-causes.md +105 -0
- package/skills/web-guidance/references/performance/interaction-paint-timing.md +200 -0
- package/skills/web-guidance/references/performance/optimize-image-priority.md +73 -0
- package/skills/web-guidance/references/performance/performance.md +384 -0
- package/skills/web-guidance/references/privacy/privacy.md +247 -0
- package/skills/web-guidance/references/security/passkey-authentication.md +218 -0
- package/skills/web-guidance/references/security/passkey-management.md +310 -0
- package/skills/web-guidance/references/security/passkey-reauthentication.md +142 -0
- package/skills/web-guidance/references/security/passkey-registration.md +186 -0
- package/skills/web-guidance/references/security/passkeys.md +39 -0
- package/skills/web-guidance/references/security/sanitize-untrusted-html.md +105 -0
- package/skills/web-guidance/references/security/secure-external-subresources.md +202 -0
- package/skills/web-guidance/references/security/security.md +390 -0
- package/skills/web-guidance/references/security/trusted-types.md +141 -0
- package/skills/web-guidance/references/security/validate-origins.md +197 -0
- package/skills/web-guidance/references/security/verify-email-ownership.md +235 -0
- package/skills/web-guidance/references/ui-atoms/position-aware-tooltips.md +173 -0
- package/skills/web-guidance/references/ui-atoms/responsive-table.md +122 -0
- package/skills/web-guidance/references/ui-atoms/viewport-aware-dropdowns.md +178 -0
- package/skills/web-guidance/references/ui-behaviors/drag-and-drop.md +108 -0
- package/skills/web-guidance/references/ui-behaviors/light-dismiss-a-dialog.md +89 -0
- package/skills/web-guidance/references/ui-behaviors/motion.md +97 -0
- package/skills/web-guidance/references/ui-behaviors/platform-controls-dismiss-dialog.md +40 -0
- package/skills/web-guidance/references/ui-behaviors/prevent-page-scroll-under-modal-dialog.md +59 -0
- package/skills/web-guidance/references/ui-behaviors/search-hidden-content.md +141 -0
- package/skills/web-guidance/references/ui-behaviors/sortable-table.md +140 -0
- package/skills/web-guidance/references/ui-components/accordion.md +343 -0
- package/skills/web-guidance/references/ui-components/breadcrumbs.md +168 -0
- package/skills/web-guidance/references/ui-components/carousel.md +206 -0
- package/skills/web-guidance/references/ui-components/checkbox.md +144 -0
- package/skills/web-guidance/references/ui-components/dialog.md +218 -0
- package/skills/web-guidance/references/ui-components/hovercard.md +391 -0
- package/skills/web-guidance/references/ui-components/menu.md +415 -0
- package/skills/web-guidance/references/ui-components/navbar.md +281 -0
- package/skills/web-guidance/references/ui-components/navigation-drawer.md +429 -0
- package/skills/web-guidance/references/ui-components/persistent-toast-notifications.md +185 -0
- package/skills/web-guidance/references/ui-components/progress.md +181 -0
- package/skills/web-guidance/references/ui-components/spinner.md +179 -0
- package/skills/web-guidance/references/ui-components/tabs.md +371 -0
- package/skills/web-guidance/references/ui-components/toolbar.md +277 -0
- package/skills/web-guidance/references/user-experience/form-factor-adaptation.md +120 -0
- package/skills/web-guidance/references/user-experience/natural-interactions.md +155 -0
- package/skills/web-guidance/references/visual-design/color.md +43 -0
- package/skills/web-guidance/references/visual-design/dark-mode.md +350 -0
- package/dist/web/assets/AgentWork-DwAI0_Of.js +0 -2
- package/dist/web/assets/ApiTests-C0vFSHmM.js +0 -10
- package/dist/web/assets/Browse-5jfdtRc5.js +0 -2
- package/dist/web/assets/Chat-B3uhI94O.js +0 -3
- package/dist/web/assets/CommandPalette-D2J4nf5y.js +0 -1
- package/dist/web/assets/Compare-CN75w1p9.js +0 -1
- package/dist/web/assets/Cost-QoxyjR95.js +0 -1
- package/dist/web/assets/Data-BAvkcBVt.js +0 -6
- package/dist/web/assets/Desktop-BXdOIalN.js +0 -1
- package/dist/web/assets/DesktopReview-Bl2SrPP0.js +0 -1
- package/dist/web/assets/Evidence-BJ_I52CD.js +0 -1
- package/dist/web/assets/Explore-D9AuyTip.js +0 -2
- package/dist/web/assets/Features-CusGMDR9.js +0 -1
- package/dist/web/assets/Flags-CycGFuUP.js +0 -2
- package/dist/web/assets/Flaky-BcSzJogN.js +0 -1
- package/dist/web/assets/Impact-CJHnyZ21.js +0 -3
- package/dist/web/assets/Jobs-4xcFzEFo.js +0 -5
- package/dist/web/assets/KindPage-BielEIej.js +0 -6
- package/dist/web/assets/Migration-NwanKpJg.js +0 -2
- package/dist/web/assets/PageAgent-CNw4NXva.js +0 -1
- package/dist/web/assets/Product-DS3LJZ4P.js +0 -7
- package/dist/web/assets/Production-D3zsyNIS.js +0 -1
- package/dist/web/assets/Quality-Ctj2YpC4.js +0 -1
- package/dist/web/assets/Readiness-DGcRr_co.js +0 -1
- package/dist/web/assets/Record-Cc-wGe_Y.js +0 -1
- package/dist/web/assets/Regression-DcsbrRa1.js +0 -5
- package/dist/web/assets/Reports-BkCn0-Sf.js +0 -2
- package/dist/web/assets/Response-BP0UwQcW.js +0 -9
- package/dist/web/assets/Responsive-C8U7dumd.js +0 -3
- package/dist/web/assets/RunDiff-BhABuhF_.js +0 -1
- package/dist/web/assets/Runs-OwdWEYBv.js +0 -2
- package/dist/web/assets/Steps-BvzbQyoD.js +0 -2
- package/dist/web/assets/TestCases-CLq_6JA5.js +0 -1
- package/dist/web/assets/TestData-B0oKAhp6.js +0 -2
- package/dist/web/assets/TestDebt-8NLQ5YV_.js +0 -1
- package/dist/web/assets/TestManagement-2LYQ7vsN.js +0 -1
- package/dist/web/assets/Tosca-DfvMpPTG.js +0 -3
- package/dist/web/assets/WhatsNew-BGFNGwqN.js +0 -1
- package/dist/web/assets/families-DYlN5v0i.js +0 -1
- package/dist/web/assets/filters-faaSnoIq.js +0 -1
- package/dist/web/assets/fold-CUjwWAK3.js +0 -1
- package/dist/web/assets/frame-BLPdAXUq.js +0 -13
- package/dist/web/assets/head-CsTxBsO0.js +0 -1
- package/dist/web/assets/index-CxiCvGZq.js +0 -78
- package/dist/web/assets/index-dOIsrzhD.css +0 -2
- package/dist/web/assets/line-icons-CwZWt93L.js +0 -1
- package/dist/web/assets/logos-dGuc1jIM.js +0 -1
- package/dist/web/assets/markdown-BI3F-SJ1.js +0 -10
- package/dist/web/assets/paletteCommands-QJiCuUEr.js +0 -1
- package/dist/web/assets/parts-CdF1f7yS.js +0 -1
- package/dist/web/assets/productParts-hNLD9fN0.js +0 -1
- package/dist/web/assets/qualityParts-CT25lBWU.js +0 -1
- package/dist/web/assets/recordTest-P792aBUt.js +0 -1
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# Passkey Management
|
|
2
|
+
|
|
3
|
+
This guide details how to enable users to view, rename, and delete their registered passkeys while keeping saved credentials and user profile details synchronized between the server and the user's password managers using the Signal API.
|
|
4
|
+
|
|
5
|
+
## Server-Side Operations
|
|
6
|
+
|
|
7
|
+
Your backend database layer and endpoints MUST support common CRUD actions for registered credentials as well as updating user profile details. Decoupled from framework-specific libraries, the server exposes endpoints to:
|
|
8
|
+
|
|
9
|
+
1. **List all user credentials**: Fetch all `StoredPasskeyCredential` records matching the signed-in user's ID, and return them alongside the server's configured `rpId` and the user's `passkeyUserId` so the client never has to guess `rpId` from `window.location.hostname`. Ensure every credential `id` and user `passkeyUserId` is stored and returned as a valid unpadded Base64URL string (`[A-Za-z0-9_-]`, no `=` padding, and `length % 4 !== 1`)—including in prototype seed data and mock backends (for example, `Buffer.from('cred-1').toString('base64url')` or `'dGVzdC1jcmVkLTE'`, never arbitrary human-readable placeholders like `'passkey-1'` or `'cred_yubikey_01'`).
|
|
10
|
+
2. **Update credential names**: Accept a new custom nickname for a specific credential ID and persist the update on the server.
|
|
11
|
+
3. **Delete credentials**: Remove a specific credential ID from the database.
|
|
12
|
+
4. **Update user account details**: Accept updated `name` (username) and `displayName` values for the signed-in user's profile and return the updated user profile alongside the server's `rpId` and Base64URL `passkeyUserId` so the client can synchronize them with the passkey provider.
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
// Node.js routing example for credential CRUD and user profile rename
|
|
16
|
+
const RP_ID = 'example.com'; // Predefined server RP ID (example value; must match registration rp.id)
|
|
17
|
+
|
|
18
|
+
router.get('/api/credentials', checkUserAuthenticated, async (req, res) => {
|
|
19
|
+
const credentials = await db.findCredentialsByUserId(req.user.id);
|
|
20
|
+
return res.json({
|
|
21
|
+
rpId: RP_ID,
|
|
22
|
+
userId: req.user.passkeyUserId, // Valid unpadded Base64URL string
|
|
23
|
+
credentials,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
router.put('/api/credential/:id', checkUserAuthenticated, async (req, res) => {
|
|
28
|
+
const { id } = req.params;
|
|
29
|
+
const { name } = req.body;
|
|
30
|
+
const cred = await db.findCredentialById(id);
|
|
31
|
+
if (!cred || cred.passkeyUserId !== req.user.id) {
|
|
32
|
+
return res.status(404).json({ error: 'Credential not found.' });
|
|
33
|
+
}
|
|
34
|
+
cred.name = name;
|
|
35
|
+
await db.saveCredential(cred);
|
|
36
|
+
return res.json(cred);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
router.delete('/api/credential/:id', checkUserAuthenticated, async (req, res) => {
|
|
40
|
+
const { id } = req.params;
|
|
41
|
+
const cred = await db.findCredentialById(id);
|
|
42
|
+
if (!cred || cred.passkeyUserId !== req.user.id) {
|
|
43
|
+
return res.status(404).json({ error: 'Credential not found.' });
|
|
44
|
+
}
|
|
45
|
+
await db.deleteCredential(id);
|
|
46
|
+
return res.json({ success: true });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
router.put('/api/user', checkUserAuthenticated, async (req, res) => {
|
|
50
|
+
const { name, displayName } = req.body;
|
|
51
|
+
const updatedUser = await db.updateUser(req.user.id, { name, displayName });
|
|
52
|
+
return res.json({
|
|
53
|
+
...updatedUser,
|
|
54
|
+
rpId: RP_ID,
|
|
55
|
+
userId: updatedUser.passkeyUserId,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Client-Side Management UI
|
|
61
|
+
|
|
62
|
+
Render a dedicated settings panel allowing users to easily audit and manage their registered authentication options and account profile details:
|
|
63
|
+
|
|
64
|
+
1. **Display saved list**: Fetch list from your endpoint and render individual credential rows. If the response is empty, render a helpful empty-state message (e.g., "No passkeys found").
|
|
65
|
+
2. **Map AAGUID Metadata**: For each passkey, lookup its `aaguid` property against your local registry to render its provider details. See [Determine the passkey provider from AAGUID](#aaguid) section for more details.
|
|
66
|
+
3. **Per-Item UI Requirements**: Every row inside the list container MUST render:
|
|
67
|
+
* **Provider Icon**: AAGUID-derived image or data URI.
|
|
68
|
+
* **Provider/Custom Name**: AAGUID-derived name or user-renamed string.
|
|
69
|
+
* **Registration Date**: The database-persisted raw epoch timestamp `registeredAt` formatted to a human-readable date for client display.
|
|
70
|
+
* **Last Used Date**: The database-persisted raw epoch timestamp `lastUsedAt` formatted to a human-readable date (if present) for client display.
|
|
71
|
+
* **Rename Button**: Triggers a rename action to update the credential's custom nickname on the server (`PUT /api/credential/:id`). Note: Renaming an individual passkey's nickname is a server-side label change and does NOT invoke `signalCurrentUserDetails()`.
|
|
72
|
+
* **Delete Button**: Triggers deletion of the credential (`DELETE /api/credential/:id`) and synchronizes the remaining credential IDs via `signalAllAcceptedCredentials()`.
|
|
73
|
+
4. **User Account Rename UI**:
|
|
74
|
+
* Provide a control allowing the user to update their account username (`name`) or `displayName` (`PUT /api/user`), and immediately synchronize the updated user details with the password manager via `PublicKeyCredential.signalCurrentUserDetails()`.
|
|
75
|
+
5. **Conditional "Create Passkey" Button**:
|
|
76
|
+
* Offer a prominent "Create passkey" registration trigger button on the management page. Before rendering this UI element, the page MUST feature-detect capabilities using `PublicKeyCredential.getClientCapabilities()` to verify platform authenticator is supported. If passkeys are unsupported, hide this button and gracefully encourage standard MFA enrollments instead.
|
|
77
|
+
* Allow registering a security key by omitting `authenticatorSelection.authenticatorAttachment` on `navigator.credentials.create()` call.
|
|
78
|
+
|
|
79
|
+
## Signal API Synchronization
|
|
80
|
+
|
|
81
|
+
The Signal API lets the application communicate credential states to password managers, keeping the user's synced vaults and your backend database in lockstep.
|
|
82
|
+
|
|
83
|
+
> [!IMPORTANT]
|
|
84
|
+
> Browsers strictly validate Base64URL encoding and string length (`length % 4 !== 1`, characters strictly `[A-Za-z0-9_-]`, no `=` padding) in native code. Passing arbitrary human-readable placeholder or mock IDs (such as `'passkey-1'`, `'cred:01'`, or unencoded strings like `'cred_yubikey_01'`) throws `TypeError: Invalid base64url string for allAcceptedCredentialIds` on page load. Always encode mock/test IDs as genuine unpadded Base64URL strings (for example, `'dGVzdC1jcmVkLTE'` or `Buffer.from('cred-1').toString('base64url')`) and validate format before invoking the Signal API.
|
|
85
|
+
|
|
86
|
+
* **Use the Server-Provided `rpId` (DO NOT Use `window.location.hostname`)**:
|
|
87
|
+
* Always pass the `rpId` returned by your backend API (matching the `rp.id` used when registering passkeys). **DO NOT** derive `rpId` from `window.location.hostname` on the client: when credentials are registered to a registrable parent domain (for example, `example.com` while the settings page is served on `accounts.example.com`) or shared via Related Origin Requests (`/.well-known/webauthn`), `window.location.hostname` will not match the credential's RP ID, causing password manager synchronization to silently target the wrong RP ID or throw a `SecurityError`.
|
|
88
|
+
* **Feature Detection & Parameter Encoding Rule**:
|
|
89
|
+
* Always feature-detect Signal API methods before invoking them (`if (PublicKeyCredential.signalAllAcceptedCredentials)` and `if (PublicKeyCredential.signalCurrentUserDetails)`).
|
|
90
|
+
* All `userId` and credential ID parameters passed to Signal API methods (`signalAllAcceptedCredentials`, `signalCurrentUserDetails`) MUST be **valid unpadded Base64URL-encoded strings**. Validate `userId` and `allAcceptedCredentialIds` before calling the API so malformed IDs are skipped safely rather than throwing on load.
|
|
91
|
+
* **Initiating Page Load Sync**:
|
|
92
|
+
* The application MUST invoke `signalAllAcceptedCredentials()` automatically when the management page loads (for example, inside a `DOMContentLoaded` event listener, module initialization, or framework component mount hook such as `useEffect`).
|
|
93
|
+
* **Management Updates Sync**:
|
|
94
|
+
* The application MUST invoke `signalAllAcceptedCredentials()` immediately within your delete credential click handler post-fetch.
|
|
95
|
+
* The application MUST invoke `signalCurrentUserDetails()` immediately within your user account rename (`name` or `displayName`) click handler post-fetch.
|
|
96
|
+
* **Non-Fatal Error Handling (`console.warn`)**:
|
|
97
|
+
* Signal API calls perform passive background synchronization and MUST NOT break the UI or emit `console.error` when synchronization fails. Wrap Signal API calls in `try...catch` and log failures with `console.warn` instead of `console.error` so passive sync issues do not trigger Lighthouse Best Practices failures (`errors-in-console`) on page load.
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
// Client-side management synchronization ES module
|
|
101
|
+
import { listFetch, renameCredentialFetch, updateUserFetch, deleteFetch } from './api.js';
|
|
102
|
+
|
|
103
|
+
// Valid unpadded Base64URL: non-empty, [A-Za-z0-9_-] only, no '=' padding, length % 4 !== 1
|
|
104
|
+
function isValidBase64Url(value) {
|
|
105
|
+
return typeof value === 'string' &&
|
|
106
|
+
value.length > 0 &&
|
|
107
|
+
value.length % 4 !== 1 &&
|
|
108
|
+
/^[A-Za-z0-9_-]+$/.test(value);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function syncAcceptedCredentials(rpId, userId, currentCredentialsList) {
|
|
112
|
+
if (!window.PublicKeyCredential || !PublicKeyCredential.signalAllAcceptedCredentials) return;
|
|
113
|
+
const credentialIds = currentCredentialsList.map(c => c.id); // Array of Base64URL credential ID strings
|
|
114
|
+
if (!rpId || !isValidBase64Url(userId) || !credentialIds.every(isValidBase64Url)) {
|
|
115
|
+
console.warn('SignalAllAcceptedCredentials skipped: server rpId and valid unpadded Base64URL userId and credential IDs are required.');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
await PublicKeyCredential.signalAllAcceptedCredentials({
|
|
121
|
+
rpId, // Always use the server-provided rpId; DO NOT use window.location.hostname
|
|
122
|
+
userId, // Base64URL-encoded user ID from the server
|
|
123
|
+
allAcceptedCredentialIds: credentialIds
|
|
124
|
+
});
|
|
125
|
+
} catch (e) {
|
|
126
|
+
// Use console.warn instead of console.error so passive sync failures do not fail Lighthouse errors-in-console
|
|
127
|
+
console.warn('SignalAllAcceptedCredentials sync warning:', e);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function loadManagementPanel() {
|
|
132
|
+
const response = await listFetch();
|
|
133
|
+
const { rpId, userId, credentials } = await response.json();
|
|
134
|
+
|
|
135
|
+
renderUI(credentials);
|
|
136
|
+
// Sync accepted credentials on initial load using server-provided rpId and userId
|
|
137
|
+
await syncAcceptedCredentials(rpId, userId, credentials);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function performDelete(credentialId) {
|
|
141
|
+
const response = await deleteFetch(credentialId);
|
|
142
|
+
if (response.ok) {
|
|
143
|
+
const updatedResponse = await listFetch();
|
|
144
|
+
const { rpId, userId, credentials } = await updatedResponse.json();
|
|
145
|
+
|
|
146
|
+
renderUI(credentials);
|
|
147
|
+
// Sync remaining accepted credentials after deletion
|
|
148
|
+
await syncAcceptedCredentials(rpId, userId, credentials);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Renaming a passkey's nickname updates the server record only
|
|
153
|
+
async function performCredentialRename(credentialId, newCredentialName) {
|
|
154
|
+
const response = await renameCredentialFetch(credentialId, { name: newCredentialName });
|
|
155
|
+
if (response.ok) {
|
|
156
|
+
const updatedResponse = await listFetch();
|
|
157
|
+
const { credentials } = await updatedResponse.json();
|
|
158
|
+
renderUI(credentials);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Renaming the user's account username or displayName triggers signalCurrentUserDetails
|
|
163
|
+
async function performUserRename(updatedName, updatedDisplayName) {
|
|
164
|
+
const response = await updateUserFetch({ name: updatedName, displayName: updatedDisplayName });
|
|
165
|
+
if (response.ok && window.PublicKeyCredential && PublicKeyCredential.signalCurrentUserDetails) {
|
|
166
|
+
const { rpId, userId } = await response.json();
|
|
167
|
+
if (!rpId || !isValidBase64Url(userId)) {
|
|
168
|
+
console.warn('SignalCurrentUserDetails skipped: server rpId and valid unpadded Base64URL userId are required.');
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
await PublicKeyCredential.signalCurrentUserDetails({
|
|
173
|
+
rpId, // Always use the server-provided rpId; DO NOT use window.location.hostname
|
|
174
|
+
userId, // Base64URL-encoded user ID from the server
|
|
175
|
+
name: updatedName, // Updated username
|
|
176
|
+
displayName: updatedDisplayName // Updated display name
|
|
177
|
+
});
|
|
178
|
+
} catch (e) {
|
|
179
|
+
// Use console.warn instead of console.error for passive background sync
|
|
180
|
+
console.warn('SignalCurrentUserDetails sync warning:', e);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
window.addEventListener('DOMContentLoaded', loadManagementPanel);
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Determine the passkey provider from AAGUID {: #aaguid }
|
|
189
|
+
|
|
190
|
+
An AAGUID (Authenticator Attestation Globally Unique Identifier) is a 128-bit identifier that represents the model of the authenticator, not a specific instance. It is included in the authenticator data during passkey registration and can be used to determine which passkey provider (e.g. Google Password Manager, iCloud Keychain, 1Password) created a credential.
|
|
191
|
+
|
|
192
|
+
AAGUID should only be used to help users with passkey management. It can be modified unless cryptographically attested, which platform passkeys currently don't support.
|
|
193
|
+
|
|
194
|
+
### 1. AAGUID Registry
|
|
195
|
+
|
|
196
|
+
A community-maintained JSON mapping of AAGUIDs to provider names and icons is available at:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
https://raw.githubusercontent.com/passkeydeveloper/passkey-authenticator-aaguids/refs/heads/main/combined_aaguid.json
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Each entry has the following schema:
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"<aaguid-uuid>": {
|
|
207
|
+
"name": "Provider Name",
|
|
208
|
+
"icon_light": "data:image/png;base64,...",
|
|
209
|
+
"icon_dark": "data:image/png;base64,..."
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 2. Using AAGUID After Registration
|
|
215
|
+
|
|
216
|
+
After verifying a registration response, read the `aaguid` from the registration result and look it up against the registry to populate the credential's `name` and `providerIcon`:
|
|
217
|
+
|
|
218
|
+
Before looking up the AAGUID in the registry, check if it equals `'00000000-0000-0000-0000-000000000000'`. If so, skip the registry lookup and set `name` to a fallback (e.g. device name from user-agent, or "Unknown passkey provider") and `providerIcon` to `undefined`. Only look up the registry for non-zeroed AAGUIDs.
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
import aaguids from './aaguids.json' with { type: 'json' };
|
|
222
|
+
|
|
223
|
+
const { aaguid } = registrationInfo;
|
|
224
|
+
if (aaguid === '00000000-0000-0000-0000-000000000000') {
|
|
225
|
+
// use the device name as the passkey provider based on
|
|
226
|
+
// the information derived from the user agent string,
|
|
227
|
+
// or just say "Unknown passkey provider"
|
|
228
|
+
} else {
|
|
229
|
+
const provider = aaguids[aaguid];
|
|
230
|
+
const credential = {
|
|
231
|
+
// ...other fields
|
|
232
|
+
aaguid,
|
|
233
|
+
name: provider?.name || 'Unknown passkey provider',
|
|
234
|
+
providerIcon: provider?.icon_light,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Fallback Strategies
|
|
240
|
+
|
|
241
|
+
### Passkey feature detection fallback
|
|
242
|
+
|
|
243
|
+
Baseline status for the api.PublicKeyCredential.getClientCapabilities_static capability: Newly available. It's been Baseline since 2025-02-06.
|
|
244
|
+
Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), Firefox 135 (Feb 2025), and Safari 17.4 (Mar 2024).
|
|
245
|
+
|
|
246
|
+
Load `webauthn-polyfills` so `PublicKeyCredential.getClientCapabilities()` is available whenever `PublicKeyCredential` is supported:
|
|
247
|
+
|
|
248
|
+
```js
|
|
249
|
+
// With a bundler (`npm install webauthn-polyfills`):
|
|
250
|
+
import 'webauthn-polyfills';
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Without a bundler, serve the package from your own origin, or import it from a CDN such as `https://esm.sh/webauthn-polyfills@0.1.7` (pin the exact version). For third-party URLs, add Subresource Integrity: the `integrity` attribute on the `<script>` tag, or an import map's `integrity` field for `import` statements.
|
|
254
|
+
|
|
255
|
+
Before rendering the "Create passkey" button, call `PublicKeyCredential.getClientCapabilities()` to verify platform authenticator support, and hide the button when unsupported:
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
async function isPasskeySupported() {
|
|
259
|
+
if (!window.PublicKeyCredential || !PublicKeyCredential.getClientCapabilities) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
const capabilities = await PublicKeyCredential.getClientCapabilities();
|
|
264
|
+
return Boolean(capabilities.passkeyPlatformAuthenticator);
|
|
265
|
+
} catch {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const createButton = document.getElementById('create-passkey');
|
|
271
|
+
if (!(await isPasskeySupported())) {
|
|
272
|
+
createButton.hidden = true;
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Signal API Synchronization Fallback
|
|
277
|
+
|
|
278
|
+
Browser support for Web authentication signal methods: Limited availability.
|
|
279
|
+
Supported by: Chrome 132 (Jan 2025), Edge 132 (Jan 2025), and Safari 26 (Sep 2025).
|
|
280
|
+
Unsupported in: Firefox.
|
|
281
|
+
|
|
282
|
+
The WebAuthn Signal API (`webauthn-signals`) is a progressive enhancement that synchronizes server-side credential deletions and account profile updates with the user's password manager. Because synchronization communicates directly with the browser or OS passkey provider, no polyfill is available if your Baseline target does not support `webauthn-signals`. Gate calls behind static feature detection on `PublicKeyCredential` so unsupported browsers skip background synchronization safely while server-side passkey listing, renaming, deletion, and user profile updates continue to work normally without throwing browser exceptions:
|
|
283
|
+
|
|
284
|
+
```javascript
|
|
285
|
+
if (window.PublicKeyCredential && PublicKeyCredential.signalAllAcceptedCredentials) {
|
|
286
|
+
try {
|
|
287
|
+
await PublicKeyCredential.signalAllAcceptedCredentials({
|
|
288
|
+
rpId, // Server-provided RP ID (never window.location.hostname)
|
|
289
|
+
userId, // Valid unpadded Base64URL user ID
|
|
290
|
+
allAcceptedCredentialIds: credentialIds, // Valid unpadded Base64URL credential IDs
|
|
291
|
+
});
|
|
292
|
+
} catch (e) {
|
|
293
|
+
console.warn('SignalAllAcceptedCredentials sync warning:', e);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (window.PublicKeyCredential && PublicKeyCredential.signalCurrentUserDetails) {
|
|
298
|
+
try {
|
|
299
|
+
await PublicKeyCredential.signalCurrentUserDetails({
|
|
300
|
+
rpId, // Server-provided RP ID (never window.location.hostname)
|
|
301
|
+
userId, // Valid unpadded Base64URL user ID
|
|
302
|
+
name: updatedName,
|
|
303
|
+
displayName: updatedDisplayName,
|
|
304
|
+
});
|
|
305
|
+
} catch (e) {
|
|
306
|
+
console.warn('SignalCurrentUserDetails sync warning:', e);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Passkey Reauthentication
|
|
2
|
+
|
|
3
|
+
This delta-focused guide details how to implement step-up authentication or re-verification for a signed-in user before they perform sensitive account changes (e.g. passwords updates, financial transfers).
|
|
4
|
+
|
|
5
|
+
## Delta Flow Architecture
|
|
6
|
+
|
|
7
|
+
Unlike regular authentication, passkey reauthentication constrains passkey dialog prompts strictly to the logged-in user's pre-registered credentials to prevent account-mixing or passkey spoofing during active sessions.
|
|
8
|
+
|
|
9
|
+
## Server-Side
|
|
10
|
+
|
|
11
|
+
### Options Generation Delta
|
|
12
|
+
|
|
13
|
+
Create an endpoint that populates the allowed credentials parameters specifically for the active, known user:
|
|
14
|
+
|
|
15
|
+
**Constrain Credentials**: Populate the `allowCredentials` options array with specific `PublicKeyCredentialDescriptor` records mapping all registered credential IDs for the signed-in user. Leaving this empty or omitting it regresses to discoverable credentials, violating session safety.
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
// Node.js step-up options generation example
|
|
19
|
+
router.post("/api/reauth/options", enforceActiveSession, async (req, res) => {
|
|
20
|
+
const userPasskeys = await db.findCredentialsByUserId(req.user.id);
|
|
21
|
+
|
|
22
|
+
const options = {
|
|
23
|
+
challenge: serverGeneratedBase64UrlChallenge, // Random challenge stored in user session
|
|
24
|
+
rpId: "example.com",
|
|
25
|
+
// Enforce allowance strictly limited to the user's credentials list
|
|
26
|
+
allowCredentials: userPasskeys.map((cred) => ({
|
|
27
|
+
type: "public-key",
|
|
28
|
+
id: cred.id,
|
|
29
|
+
transports: cred.transports, // Speeds up resolution by indicating platform transports
|
|
30
|
+
})),
|
|
31
|
+
};
|
|
32
|
+
return res.json(options);
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Verification Endpoint Delta
|
|
37
|
+
|
|
38
|
+
Verify the assertion returned by the client:
|
|
39
|
+
|
|
40
|
+
**Verify Account Ownership**: The verification endpoint MUST explicitly verify that the resulting authenticated credential ID returned by the client resolves to a stored credential record whose associated user ID strictly matches the active signed-in user (`storedCredential.passkeyUserId === req.user.id`). If a valid passkey of a _different_ user is returned, authentication MUST be rejected immediately.
|
|
41
|
+
|
|
42
|
+
## Client-Side Flow Deltas
|
|
43
|
+
|
|
44
|
+
Applications choose from two reauthentication interfaces depending on the transaction UI:
|
|
45
|
+
|
|
46
|
+
### A. Button Flow (No Input Fields)
|
|
47
|
+
|
|
48
|
+
Trigger reauthentication when a user presses a "Verify Identity" or "Proceed with Transaction" button. When signaling an unknown credential on HTTP `404`, always pass `rpId: publicKey.rpId` from the server's request options—**DO NOT** derive `rpId` from `window.location.hostname` on the client.
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<button id="reauth-btn" data-testid="reauth-button">Confirm Transaction</button>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
let reauthAbortController = new AbortController();
|
|
56
|
+
|
|
57
|
+
async function triggerButtonReauth() {
|
|
58
|
+
// Abort any background suggestion flows to avoid passkey prompt collisions
|
|
59
|
+
reauthAbortController.abort();
|
|
60
|
+
reauthAbortController = new AbortController();
|
|
61
|
+
|
|
62
|
+
const optionsResponse = await fetch("/api/reauth/options", {
|
|
63
|
+
method: "POST",
|
|
64
|
+
});
|
|
65
|
+
const optionsJSON = await optionsResponse.json();
|
|
66
|
+
const publicKey =
|
|
67
|
+
PublicKeyCredential.parseRequestOptionsFromJSON(optionsJSON);
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const credential = await navigator.credentials.get({
|
|
71
|
+
publicKey,
|
|
72
|
+
signal: reauthAbortController.signal,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (credential) {
|
|
76
|
+
const encodedCredential = credential.toJSON();
|
|
77
|
+
const verifyResponse = await fetch("/api/reauth/verify", {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "Content-Type": "application/json" },
|
|
80
|
+
body: JSON.stringify(encodedCredential),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (verifyResponse.ok) {
|
|
84
|
+
showTransactionSuccessUI();
|
|
85
|
+
} else if (verifyResponse.status === 404 && PublicKeyCredential.signalUnknownCredential) {
|
|
86
|
+
await PublicKeyCredential.signalUnknownCredential({
|
|
87
|
+
rpId: publicKey.rpId, // Always use the server-provided rpId; DO NOT use window.location.hostname
|
|
88
|
+
credentialId: encodedCredential.id
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {
|
|
93
|
+
if (err.name === "NotAllowedError") {
|
|
94
|
+
console.log("User cancelled reauthentication.");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
document
|
|
100
|
+
.getElementById("reauth-btn")
|
|
101
|
+
.addEventListener("click", triggerButtonReauth);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Fallback Strategies
|
|
105
|
+
|
|
106
|
+
### Passkey feature detection fallback
|
|
107
|
+
|
|
108
|
+
Baseline status for the api.PublicKeyCredential.getClientCapabilities_static capability: Newly available. It's been Baseline since 2025-02-06.
|
|
109
|
+
Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), Firefox 135 (Feb 2025), and Safari 17.4 (Mar 2024).
|
|
110
|
+
|
|
111
|
+
Load `webauthn-polyfills` so `PublicKeyCredential.getClientCapabilities()` is available whenever `PublicKeyCredential` is supported:
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
// With a bundler (`npm install webauthn-polyfills`):
|
|
115
|
+
import 'webauthn-polyfills';
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Without a bundler, serve the package from your own origin, or import it from a CDN such as `https://esm.sh/webauthn-polyfills@0.1.7` (pin the exact version). For third-party URLs, add Subresource Integrity: the `integrity` attribute on the `<script>` tag, or an import map's `integrity` field for `import` statements.
|
|
119
|
+
|
|
120
|
+
### Signal API Synchronization Fallback
|
|
121
|
+
|
|
122
|
+
Browser support for Web authentication signal methods: Limited availability.
|
|
123
|
+
Supported by: Chrome 132 (Jan 2025), Edge 132 (Jan 2025), and Safari 26 (Sep 2025).
|
|
124
|
+
Unsupported in: Firefox.
|
|
125
|
+
|
|
126
|
+
The WebAuthn Signal API (`webauthn-signals`) is a progressive optimization used to keep password managers in sync with the server credential state.
|
|
127
|
+
|
|
128
|
+
- **Fallback Experience**: Gate calls behind `if (PublicKeyCredential.signalUnknownCredential)`. If unsupported, the background verification sync is bypassed gracefully without throwing browser exceptions.
|
|
129
|
+
|
|
130
|
+
### Easy JSON Serialization Fallback
|
|
131
|
+
|
|
132
|
+
Baseline status for the api.PublicKeyCredential.parseRequestOptionsFromJSON_static capability: Newly available. It's been Baseline since 2025-03-31.
|
|
133
|
+
Supported by: Chrome 129 (Sep 2024), Edge 129 (Sep 2024), Firefox 119 (Oct 2023), and Safari 18.4 (Mar 2025).
|
|
134
|
+
|
|
135
|
+
Load `webauthn-polyfills` so `PublicKeyCredential.parseRequestOptionsFromJSON()` and `PublicKeyCredential.prototype.toJSON()` are available whenever `PublicKeyCredential` is supported:
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
// With a bundler (`npm install webauthn-polyfills`):
|
|
139
|
+
import 'webauthn-polyfills';
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Without a bundler, serve the package from your own origin, or import it from a CDN such as `https://esm.sh/webauthn-polyfills@0.1.7` (pin the exact version). For third-party URLs, add Subresource Integrity: the `integrity` attribute on the `<script>` tag, or an import map's `integrity` field for `import` statements.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Passkey Registration
|
|
2
|
+
|
|
3
|
+
This guide details how to enable users to register a passkey for their account, providing a highly secure, phishing-resistant passwordless sign-in alternative.
|
|
4
|
+
|
|
5
|
+
## Database Requirements
|
|
6
|
+
|
|
7
|
+
To support passkey registrations, your database credential table must store the following fields:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
export interface StoredPasskeyCredential {
|
|
11
|
+
id: string; // Base64URL-encoded credential ID (unique lookup key)
|
|
12
|
+
passkeyUserId: string; // Associated application user ID
|
|
13
|
+
credentialPublicKey: string; // Base64URL-encoded public key used to verify assertion signatures
|
|
14
|
+
credentialType: "public-key";
|
|
15
|
+
credentialDeviceType: "singleDevice" | "multiDevice"; // Helps distinguish device-bound vs cloud-synced passkeys
|
|
16
|
+
credentialBackedUp: boolean; // Boolean backup state reported by the authenticator
|
|
17
|
+
aaguid: string; // Authenticator Attestation GUID
|
|
18
|
+
providerIcon?: string; // Provider icon derived from the AAGUID registry (dark or light theme URLs)
|
|
19
|
+
name: string; // Provider name derived from AAGUID registry
|
|
20
|
+
transports: string[]; // Array of transport names (e.g. 'internal', 'hybrid') necessary for exclusion options
|
|
21
|
+
lastUsedAt?: number; // Optional epoch timestamp of last sign-in
|
|
22
|
+
registeredAt: number; // Registration epoch timestamp
|
|
23
|
+
counter: number; // Authenticator sign-in signature counter used to prevent replay attacks
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Server-Side
|
|
28
|
+
|
|
29
|
+
### Options Generation
|
|
30
|
+
|
|
31
|
+
Create an endpoint that generates WebAuthn creation parameters. Rely on a vetted library per category standards instead of hand-rolling cryptography.
|
|
32
|
+
|
|
33
|
+
1. **Use the predefined RP ID**: Use the predefined proper RP ID as a constant string in `rp.id` so the client can pass `publicKey.rp.id` directly to Signal API calls.
|
|
34
|
+
2. **Create a secure Challenge**: Generate a high-entropy, cryptographically secure random buffer on the server, store it securely in the user's session, and encode it as Base64URL for options delivery.
|
|
35
|
+
3. **Avoid Duplicate Passkeys**: Map the user's existing pre-registered credential IDs to the `excludeCredentials` options array. This prevents the authenticator from registering duplicate credentials on the same passkey provider account.
|
|
36
|
+
4. **Enforce Discoverable Credentials**: Set `requireResidentKey: true` and `residentKey: "required"` in the `authenticatorSelection` options to request a discoverable credential, which is necessary for discoverable sign-ins.
|
|
37
|
+
5. **Configure User Verification**: Specify `userVerification: "preferred"` or `userVerification: "required"`. Many compliance use cases (e.g., finance, healthcare) require `'required'` to enforce user verification on creation.
|
|
38
|
+
6. **Determine Attachment Scope**:
|
|
39
|
+
- **Promotion Flow**: When proposing passkey creation right after standard password sign-ins or post-signup promotions, set `authenticatorAttachment: "platform"` to enforce platform authenticator and bypass external security key prompts.
|
|
40
|
+
- **Management Flow**: When called from a dedicated settings or security panel where external security keys are supported in addition to platform authenticator, omit the `authenticatorAttachment` property entirely.
|
|
41
|
+
- _Tip_: Accept a `promotion: boolean` request flag to conditionally handle both flows with a single endpoint.
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
// Options generation example
|
|
45
|
+
const options = {
|
|
46
|
+
challenge: serverGeneratedBase64UrlChallenge, // Cryptographically random challenge
|
|
47
|
+
rp: { id: "example.com", name: "Secure Application" },
|
|
48
|
+
user: {
|
|
49
|
+
id: userBase64UrlId, // Unique base64url string identifying the account
|
|
50
|
+
name: "user@example.com",
|
|
51
|
+
displayName: "Jane Doe",
|
|
52
|
+
},
|
|
53
|
+
pubKeyCredParams: [
|
|
54
|
+
{
|
|
55
|
+
type: "public-key",
|
|
56
|
+
alg: -7,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: "public-key",
|
|
60
|
+
alg: -257,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
excludeCredentials: userExistingCredentials.map((cred) => ({
|
|
64
|
+
type: "public-key",
|
|
65
|
+
id: cred.id,
|
|
66
|
+
transports: cred.transports,
|
|
67
|
+
})),
|
|
68
|
+
authenticatorSelection: {
|
|
69
|
+
residentKey: "required",
|
|
70
|
+
requireResidentKey: true,
|
|
71
|
+
userVerification: "preferred",
|
|
72
|
+
...(isPromotionFlow && { authenticatorAttachment: "platform" }),
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Verification
|
|
78
|
+
|
|
79
|
+
1. **Challenge Verification**: Securely verify the challenge against the expected session bound challenge.
|
|
80
|
+
2. **Verify User Presence**:
|
|
81
|
+
- Ensure that the User Present (UP) flag returned in the parsed authenticator data is `true` to confirm physical user presence at the time of creation.
|
|
82
|
+
3. **Relaxing Verification for 'preferred'**:
|
|
83
|
+
- When the creation options specified `userVerification: "preferred"`, the server-side verification call MUST be configured with `requireUserVerification: false`. Otherwise, authenticators that register without user verification (e.g., screen locks disabled) will trigger spurious server verification failures.
|
|
84
|
+
|
|
85
|
+
## Client-Side Logic
|
|
86
|
+
|
|
87
|
+
1. **Gate the UI on page load**:
|
|
88
|
+
- On page load, call `PublicKeyCredential.getClientCapabilities()` and **disable the "Create passkey" button** if `conditionalGet` or `passkeyPlatformAuthenticator` is not available.
|
|
89
|
+
2. **Invoke creation & Serialize**: Decode server options with `PublicKeyCredential.parseCreationOptionsFromJSON()` and pass the resulting configuration to `navigator.credentials.create()`.
|
|
90
|
+
- Call `credential.toJSON()` to encode the `AuthenticatorAttestationResponse` into a valid, JSON-serializable object before fetching the verification endpoint.
|
|
91
|
+
3. **Handle WebAuthn Exceptions**:
|
|
92
|
+
- `InvalidStateError`: A matching passkey already exists (matched by `excludeCredentials`).
|
|
93
|
+
- `NotAllowedError`: The user cancelled or timed out the authentication passkey dialog.
|
|
94
|
+
- `AbortError`: The operation has been aborted.
|
|
95
|
+
- `SecurityError`: Secure origins (HTTPS) or RP ID mismatch errors (configuration issues).
|
|
96
|
+
4. **Try/Catch Segregation for Signal API**:
|
|
97
|
+
- Wrap server verification `fetch()` call in a try/catch block. Call `PublicKeyCredential.signalUnknownCredential({ rpId: publicKey.rp.id, credentialId: encodedResponse.id })` (gated on `if (PublicKeyCredential.signalUnknownCredential)`) when the server verification fetch fails (any status `response.ok === false` or network throws).
|
|
98
|
+
- Always read `rpId` from `publicKey.rp.id` in the server's creation options. **DO NOT** derive `rpId` from `window.location.hostname` on the client, as the server's configured RP ID may be a registrable parent domain (such as `example.com` on `accounts.example.com`) or use Related Origin Requests.
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
// optionsFetch and registerVerifyFetch are app-defined HTTP methods
|
|
102
|
+
import { optionsFetch, registerVerifyFetch } from "./api.js";
|
|
103
|
+
|
|
104
|
+
async function registerPasskey(isPromotion = false) {
|
|
105
|
+
// Verify passkey capability and conditional UI are available
|
|
106
|
+
const capabilities = await PublicKeyCredential.getClientCapabilities();
|
|
107
|
+
if (
|
|
108
|
+
!capabilities.passkeyPlatformAuthenticator ||
|
|
109
|
+
!capabilities.conditionalGet
|
|
110
|
+
) {
|
|
111
|
+
// Hide "Create passkey" buttons and fall back to password flows instead
|
|
112
|
+
showStandardPasswordFallbackUI();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const creationOptionsJSON = await optionsFetch({ promotion: isPromotion });
|
|
117
|
+
const publicKey =
|
|
118
|
+
PublicKeyCredential.parseCreationOptionsFromJSON(creationOptionsJSON);
|
|
119
|
+
|
|
120
|
+
let credential;
|
|
121
|
+
try {
|
|
122
|
+
// passkey prompt execution
|
|
123
|
+
credential = await navigator.credentials.create({ publicKey });
|
|
124
|
+
} catch (err) {
|
|
125
|
+
if (err.name === "InvalidStateError") {
|
|
126
|
+
console.log("A passkey already exists for this account.");
|
|
127
|
+
alert("A passkey already exists for this account.");
|
|
128
|
+
} else if (err.name === "SecurityError") {
|
|
129
|
+
console.error("Configuration RP ID or Secure Context error.");
|
|
130
|
+
alert("Configuration RP ID or Secure Context error.");
|
|
131
|
+
} else if (err.name === "NotAllowedError") {
|
|
132
|
+
console.log("User cancelled the passkey dialog.");
|
|
133
|
+
} else if (err.name === "AbortError") {
|
|
134
|
+
console.log("The creation operation has been aborted.");
|
|
135
|
+
}
|
|
136
|
+
return; // Safe API exit, do not signal unknown for standard WebAuthn cancels
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Server Verification phase (Segregated Try/Catch)
|
|
140
|
+
const encodedResponse = credential.toJSON();
|
|
141
|
+
try {
|
|
142
|
+
const response = await registerVerifyFetch(encodedResponse);
|
|
143
|
+
if (!response.ok && PublicKeyCredential.signalUnknownCredential) {
|
|
144
|
+
// Server verification failed to verify/authenticate the credential (orphaned)
|
|
145
|
+
await PublicKeyCredential.signalUnknownCredential({
|
|
146
|
+
rpId: publicKey.rp.id, // Always use the server-provided rp.id; DO NOT use window.location.hostname
|
|
147
|
+
credentialId: encodedResponse.id, // Base64URL-encoded credential ID
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
} catch (serverErr) {
|
|
151
|
+
console.error("Server verification network failure:", serverErr);
|
|
152
|
+
if (PublicKeyCredential.signalUnknownCredential) {
|
|
153
|
+
await PublicKeyCredential.signalUnknownCredential({
|
|
154
|
+
rpId: publicKey.rp.id, // Always use the server-provided rp.id; DO NOT use window.location.hostname
|
|
155
|
+
credentialId: encodedResponse.id, // Base64URL-encoded credential ID
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Fallback Strategies
|
|
163
|
+
|
|
164
|
+
### Signal API Synchronization Fallback
|
|
165
|
+
|
|
166
|
+
Browser support for Web authentication signal methods: Limited availability.
|
|
167
|
+
Supported by: Chrome 132 (Jan 2025), Edge 132 (Jan 2025), and Safari 26 (Sep 2025).
|
|
168
|
+
Unsupported in: Firefox.
|
|
169
|
+
|
|
170
|
+
The WebAuthn Signal API (`webauthn-signals`) is a progressive optimization used to keep password managers in sync with the server credential state.
|
|
171
|
+
|
|
172
|
+
- **Fallback Experience**: If `PublicKeyCredential.signalUnknownCredential` is unsupported by the browser, the call MUST be bypassed safely via feature detection gating (`if (PublicKeyCredential.signalUnknownCredential)`), and the server-side verification simply logs the failure without triggering manager updates.
|
|
173
|
+
|
|
174
|
+
### Easy JSON Serialization Fallback
|
|
175
|
+
|
|
176
|
+
Baseline status for the api.PublicKeyCredential.parseCreationOptionsFromJSON_static capability: Newly available. It's been Baseline since 2025-03-31.
|
|
177
|
+
Supported by: Chrome 129 (Sep 2024), Edge 129 (Sep 2024), Firefox 119 (Oct 2023), and Safari 18.4 (Mar 2025).
|
|
178
|
+
|
|
179
|
+
Load `webauthn-polyfills` so `PublicKeyCredential.parseCreationOptionsFromJSON()` and `PublicKeyCredential.prototype.toJSON()` are available whenever `PublicKeyCredential` is supported:
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
// With a bundler (`npm install webauthn-polyfills`):
|
|
183
|
+
import 'webauthn-polyfills';
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Without a bundler, serve the package from your own origin, or import it from a CDN such as `https://esm.sh/webauthn-polyfills@0.1.7` (pin the exact version). For third-party URLs, add Subresource Integrity: the `integrity` attribute on the `<script>` tag, or an import map's `integrity` field for `import` statements.
|