A small software authenticator for application tests.
It creates real ES256 signatures and browser-shaped registration and authentication responses. It is intended only for tests and must not be used to authenticate users in production.
The authenticator owns one credential. Reuse it across registration and authentication to model a browser authenticator, or create separate values to model unknown credentials.
Summary
Functions
Builds a valid signed authentication response.
Returns the stored credential corresponding to the authenticator.
Creates a deterministic authenticator.
Builds a valid none-attestation registration response.
Corrupts a signed response without requiring callers to understand its encoding.
Types
Functions
Builds a valid signed authentication response.
Required options are :challenge, :origin, and :rp_id. Scenario controls include
:flags, :sign_count, :credential_id, and :user_handle. The default counter is 1.
@spec credential( t(), keyword() ) :: ExSwan.Credential.t()
Returns the stored credential corresponding to the authenticator.
Use :sign_count, :credential_device_type, and :credential_backed_up to model
persisted state before authentication.
Creates a deterministic authenticator.
Options may replace :credential_id, :user_handle, or the 32-byte P-256
:private_key. Defaults are stable so snapshots and database assertions remain simple.
iex> authenticator = ExSwan.Test.Authenticator.new(user_handle: <<1, 2, 3>>)
iex> byte_size(authenticator.credential_id)
32
Builds a valid none-attestation registration response.
Required options are :challenge, :origin, and :rp_id. Useful scenario controls
include :flags, :sign_count, :credential_id, :client_extensions, and
:transports.
Corrupts a signed response without requiring callers to understand its encoding.
Currently supported mutations are :signature, :client_data, and :authenticator_data.