UNPKG

@didtools/key-webauthn

Version:

Implements support to authenticate, authorize and verify blocks produced by webauthn/passkey compatible hardware authenticators and OS/software implementations.

39 lines (38 loc) 1.68 kB
import { AuthMethod, Cacao, VerifyOptions } from '@didtools/cacao'; export declare namespace WebauthnAuth { export type DIDSelector = (did1: string, did2: string) => Promise<string | undefined>; export function createDID(label: string | CredentialCreationOptions): Promise<string>; export function getAuthMethod(didOpts: { did?: string; dids?: Array<string>; selectDID?: DIDSelector; }): Promise<AuthMethod>; /** * Ask user to sign a random challenge * @returns {Promise<Array<string>>} Two potential DIDs */ export function probeDIDs(): Promise<Array<string>>; export function getVerifier(): { 'webauthn:p256': typeof verifyCacao; }; export interface AdditionalAuthenticatorData { authData: Uint8Array; clientDataJSON: Uint8Array; } /** * 1. Recreates cacao-challenge and message hash * 2. Verifies Signature of clientDataJSON * 3. Unpacks clientDataJSON and assert embedded hash against message hash */ function verifyCacao(cacao: Cacao, _: VerifyOptions): Promise<void>; /** * A simple approach to create a discoverable * credential with sane defaults. * @param {string} name username|email|user-alias * @param {string} displayName Human friendly identifier of credential, shown in OS-popups. * @param {string} rpname (RelayingPartyName) name of the app. * @returns {CredentialCreationOptions} An options object that can be passed to credentials.create(opts) */ export function p256CredentialCreateOptions(name?: string, displayName?: string, rpname?: string): CredentialCreationOptions; export {}; }