Skip to content

feat(credentials): add context.credentials WebAuthn virtual authenticator#40849

Merged
pavelfeldman merged 1 commit into
microsoft:mainfrom
pavelfeldman:feat-webauthn
May 16, 2026
Merged

feat(credentials): add context.credentials WebAuthn virtual authenticator#40849
pavelfeldman merged 1 commit into
microsoft:mainfrom
pavelfeldman:feat-webauthn

Conversation

@pavelfeldman
Copy link
Copy Markdown
Member

Summary

  • Adds BrowserContext.credentials — a flat, web-API-shaped namespace for seeding WebAuthn credentials and intercepting navigator.credentials.create/get ceremonies.
  • Implemented in userland via an injected script (server-side registry + ECDSA P-256 / CBOR / COSE; page-side override calls back through a binding). Works on Chromium, Firefox and WebKit with no per-browser code.
await context.credentials.create({ rpId: 'example.com' });
await context.credentials.get({ rpId });
await context.credentials.delete(id);
await context.credentials.setUserVerified(false);

Fixes #7276

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread docs/src/api/class-credentials.md Outdated
- `id` <[string]> Base64url-encoded credential id.
- `rpId` <[string]> Relying party id.
- `userHandle` <[string]> Base64url-encoded user handle.
- `privateKey` <[string]> PKCS#8 PEM-encoded private key.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should also support path

* since: v1.61
- returns: <[Object]>
* alias: VirtualCredential
- `id` <[string]> Base64url-encoded credential id.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should playwright encode it itself?

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

…ator

Adds a flat namespace on BrowserContext that intercepts the page's
navigator.credentials.create() / .get() calls and answers them with an
ES256 keypair Playwright owns. Implemented in userland via an injected
script + a binding, so it works on Chromium, Firefox and WebKit with no
per-browser code.

  const context = await browser.newContext({ credentials: true });
  await context.credentials.create({ rpId: 'example.com' });
  // page's navigator.credentials.get() now succeeds silently.

Verbs mirror navigator.credentials; no authenticator entity. Server-side
registry handles keypair generation, CBOR/COSE encoding of attestation
objects, and ECDSA signing of assertions. Pass id/userHandle/privateKey/
publicKey together to import a pre-registered credential.

Fixes: microsoft#7276
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

7099 passed, 1104 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 1"

4 flaky ⚠️ [chromium-library] › library/beforeunload.spec.ts:130 › should support dismissing the dialog multiple times `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:682 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-arm-node20`
⚠️ [firefox-page] › page/page-add-locator-handler.spec.ts:263 › should wait for hidden by default `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`

41952 passed, 850 skipped


Merge workflow run.

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.

[Feature] support WebAuthn

2 participants