Skip to content

task(passkey): Implement POST /passkey/wraps - #21116

Open
nshirley wants to merge 1 commit into
mainfrom
FXA-13142-2
Open

task(passkey): Implement POST /passkey/wraps#21116
nshirley wants to merge 1 commit into
mainfrom
FXA-13142-2

Conversation

@nshirley

@nshirley nshirley commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Because

  • Passwordless Sync needs somewhere to store the envelope that lets a passkey unlock kB without a password.
  • A wrap is create-only: rotating kB invalidates it, so a stale one is replaced by deleting the passkey and re-enrolling, never by an update.

This pull request

  • Adds POST /passkey/wraps, one envelope per credential, behind a verified session token and the passwordlessSyncEnabled flag.
  • Pins each of the five envelope fields to its one legal v1 width, which the fixed-width BINARY columns would otherwise zero-pad on a short one.
  • Reports created: false on an identical repeat and 409s a different one, since there is no update path.
  • Records wrap_created / wrap_creation_failure through a guarded helper, so an audit write cannot 500 a committed wrap or mask the error that preceded it.

Issue that this pull request solves

Closes: FXA-13142

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on: packages/fxa-auth-server/lib/routes/passkey-wraps.ts
  • Suggested review order: route → swagger notes → unit spec → integration spec
  • Risky or complex parts: the auth tier. This takes a verified session, as passkey rename does, rather than the mfa:passkey scope registration and deletion take. Reasoning is in the handler JSDoc — the credential already cleared that bar at registration, and a wrap is inert without its PRF output.

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

@nshirley
nshirley changed the base branch from main to FXA-13142-1 August 27, 2026 18:30
@nshirley
nshirley force-pushed the FXA-13142-2 branch 2 times, most recently from 4879ede to fac0711 Compare August 31, 2026 19:18
@nshirley
nshirley changed the base branch from FXA-13142-1 to main August 31, 2026 19:18
@nshirley nshirley changed the title [draft/wip] Fxa 13142 pt 2 task(passkey): Implement POST /passkey/wraps Aug 31, 2026
@nshirley
nshirley force-pushed the FXA-13142-2 branch 7 times, most recently from 9a2999e to 103a29e Compare August 31, 2026 22:55
@nshirley
nshirley marked this pull request as ready for review August 31, 2026 23:20
@nshirley
nshirley requested a review from a team as a code owner August 31, 2026 23:20
Copilot AI balanced review requested due to automatic review settings August 31, 2026 23:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds create-only passkey wrap storage for passwordless Sync, protected by verified sessions and feature gating.

Changes:

  • Adds the validated, rate-limited, audited POST /passkey/wraps route.
  • Registers and documents the endpoint.
  • Adds unit and remote integration coverage.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/remote/passkey_wraps.in.spec.ts Tests end-to-end storage and failures.
lib/routes/passkeys.ts Exports the credential ID validator.
lib/routes/passkey-wraps.ts Implements the endpoint.
lib/routes/passkey-wraps.spec.ts Tests routing and validation.
lib/routes/index.js Registers the new route.
docs/swagger/passkey-wraps-api.ts Documents the API contract.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/fxa-auth-server/lib/routes/passkey-wraps.ts Outdated
Because:
- Passwordless Sync needs somewhere to store the envelope that lets a
  passkey unlock kB without a password.
- A wrap is create-only: rotating kB invalidates it, so a stale one is
  replaced by deleting the passkey and re-enrolling, never by an update.

This commit:
- Adds POST /passkey/wraps, one envelope per credential, behind a
  verified session token and the passwordlessSyncEnabled flag.
- Pins each of the five envelope fields to its one legal v1 width, which
  the fixed-width BINARY columns would otherwise zero-pad on a short one.
- Reports created:false on an identical repeat and 409s a different one,
  since there is no update path.
- Records wrap_created / wrap_creation_failure through a guarded helper,
  so an audit write cannot 500 a committed wrap or mask the error that
  preceded it.

Closes #FXA-13142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants