/** * This module provides a minimal shim to emulate the Web Authentication API implemented in browsers. This allows us to * write tests where we create and authenticate WebAuthn credentials that are verified on-chain. * * This implementation is inspired by software authenticators found in the Awesome WebAuthn list [1]. * * [1]: */ import type { BytesLike } from 'ethers'; /** * Returns the message that gets signed by the WebAuthn credentials. * * See */ export declare function encodeWebAuthnSigningMessage(clientData: { type: 'webauthn.get'; challenge: string; [key: string]: unknown; }, authenticatorData: BytesLike): Uint8Array; export interface CredentialCreationOptions { publicKey: PublicKeyCredentialCreationOptions; } export type UserVerificationRequirement = 'required' | 'preferred' | 'discouraged'; /** * Public key credetial creation options, restricted to a subset of options that this module supports. * See . */ export interface PublicKeyCredentialCreationOptions { rp: { id: string; name: string; }; user: { id: Uint8Array; displayName: string; name: string; }; challenge: Uint8Array; pubKeyCredParams: { type: 'public-key'; alg: number; }[]; attestation?: 'none'; userVerification?: Exclude; } export interface CredentialRequestOptions { publicKey: PublicKeyCredentialRequestOptions; } /** * Public key credetial request options, restricted to a subset of options that this module supports. * See . */ export interface PublicKeyCredentialRequestOptions { challenge: Uint8Array; rpId: string; allowCredentials: { type: 'public-key'; id: Uint8Array; }[]; userVerification?: Exclude; attestation?: 'none'; } /** * A created public key credential. See . */ export interface PublicKeyCredential { type: 'public-key'; id: string; rawId: ArrayBuffer; response: AuthenticatorResponse; } /** * The authenticator's response to a client’s request for the creation of a new public key credential. * See . */ export interface AuthenticatorAttestationResponse { clientDataJSON: ArrayBuffer; attestationObject: ArrayBuffer; } /** * The authenticator's response to a client’s request generation of a new authentication assertion given the WebAuthn Relying Party's challenge. * See . */ export interface AuthenticatorAssertionResponse { clientDataJSON: ArrayBuffer; authenticatorData: ArrayBuffer; signature: ArrayBuffer; userHandle: ArrayBuffer; } export declare class WebAuthnCredentials { #private; /** * This is a shim for `navigator.credentials.create` method. * See . * * @param options The public key credential creation options. * @returns A public key credential with an attestation response. */ create({ publicKey }: CredentialCreationOptions): PublicKeyCredential; /** * This is a shim for `navigator.credentials.get` method. * See . * * @param options The public key credential request options. * @returns A public key credential with an assertion response. */ get({ publicKey }: CredentialRequestOptions): PublicKeyCredential; }