Skip to content

feat: Add BrowserContext wrappers for virtual WebAuthn credentials - #111

Open
oliverandrich wants to merge 1 commit into
ftes:mainfrom
oliverandrich:feat/credentials
Open

oliverandrich wants to merge 1 commit into
ftes:mainfrom
oliverandrich:feat/credentials

Conversation

@oliverandrich

Copy link
Copy Markdown

Playwright 1.63 added context.credentials, a virtual WebAuthn authenticator per browser context.
playwright_ex already carries these credentials in the storage state, but has no wrapper for the API itself.

This adds four functions to PlaywrightEx.BrowserContext, one per protocol method:

  • credentials_install/2 installs the authenticator into the context.
  • credentials_create/3 seeds a credential for a relying party, generated or imported.
  • credentials_get/2 lists the credentials, optionally filtered by :id or :rp_id.
  • credentials_delete/3 removes a credential by id.

They follow the existing channel functions: NimbleOptions schemas, typespecs and links to the Playwright docs.
Returned credentials have the same shape as those in storage_state/2.

Why

I maintain Ithibati, a passkey library for Phoenix.
Its browser tests add a virtual authenticator over a raw CDP session today.
With these wrappers they can use Playwright's own authenticator instead.

Tests

Five tests in browser_context_test.exs:

  • seeding, filtering and deleting a credential
  • importing a known credential
  • a page registering a passkey after credentials_install/2
  • a seeded credential answering navigator.credentials.get(), with the sign count incremented
  • a page without credentials_install/2 keeping the browser's own WebAuthn

mix check passes.

Playwright 1.63 added a virtual WebAuthn authenticator per browser context.
These functions wrap its install, create, get and delete methods.
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.

1 participant