import { AuthenticatorAssertionResponseJSON, AuthenticatorAttestationResponseJSON, Base64URLString, PublicKeyCredentialDescriptorJSON, PublicKeyCredentialUserEntityJSON, } from "@simplewebauthn/types"; export interface AuthenticationExtensionsLargeBlobOutputs { // - true if, and only if, the created credential supports storing large blobs. Only present in registration outputs. supported?: boolean; // - The opaque byte string that was associated with the credential identified by rawId. Only valid if read was true. blob?: Base64URLString; // - A boolean that indicates that the contents of write were successfully stored on the authenticator, associated with the specified credential. written?: boolean; } type JSONString = string; export interface AuthenticationExtensionsClientOutputsJSON { largeBlob?: AuthenticationExtensionsLargeBlobOutputs; } // step 1 request challenge export interface CredentialCreationOptionsRequest { displayName: string; } // step 2 post passkey registration result + decryption password + exchange key export interface RegistrationResponseJSON { id: Base64URLString; rawId: Base64URLString; response: AuthenticatorAttestationResponseJSON; authenticatorAttachment?: AuthenticatorAttachment; clientExtensionResults: AuthenticationExtensionsClientOutputsJSON; type: PublicKeyCredentialType; } export interface AuthenticationResponseJSON { id: Base64URLString; rawId: Base64URLString; response: AuthenticatorAssertionResponseJSON; authenticatorAttachment?: AuthenticatorAttachment; clientExtensionResults: AuthenticationExtensionsClientOutputsJSON; type: PublicKeyCredentialType; } /** * creation options */ export interface PublicKeyCredentialCreationOptionsJSON { rp: PublicKeyCredentialRpEntity; user: PublicKeyCredentialUserEntityJSON; challenge: Base64URLString; pubKeyCredParams: PublicKeyCredentialParameters[]; timeout?: number; excludeCredentials?: PublicKeyCredentialDescriptorJSON[]; authenticatorSelection?: AuthenticatorSelectionCriteria; attestation?: AttestationConveyancePreference; extensions?: AuthenticationExtensionsClientInputs; } /** * verify options */ export interface PublicKeyCredentialRequestOptionsJSON { challenge: Base64URLString; timeout?: number; rpId?: string; allowCredentials?: PublicKeyCredentialDescriptorJSON[]; userVerification?: UserVerificationRequirement; extensions?: AuthenticationExtensionsClientInputs; } export interface State { id: string; state: string; type: "passkey" | "password"; } export type ProgressCallback = (percent: number) => void; export type WalletCreateCallback = (wallet: { state: State; password: string; }) => void; export type NewWalletCreateOptions = { progressCallback?: ProgressCallback; walletCreateCallback?: WalletCreateCallback; }; export type NewWalletCreateData = { displayName: string; attr?: JSONString; }; /** * Authenticate interface */ export interface PasskeyAuthenticate { create( options: Pick< PublicKeyCredentialCreationOptionsJSON, | "rp" | "user" | "challenge" | "timeout" | "pubKeyCredParams" | "authenticatorSelection" >, ): Promise; get( options: Omit, ): Promise; } export interface PasswordAuthenticate { requestPassword(): Promise; } export enum WalletType { Passkey = "passkey", Password = "password", } export type EmbeddedWalletConfig = { state: string; //{ id: v4(), state: walletState, type: "passkey" } }; export type ExternalWalletConfig = { address: string; type: string; }; export type PasskeyWalletConfig = { displayName: string; attr?: JSONString; } & EmbeddedWalletConfig; export interface WalletManagerState { handle?: string; majorWalletState?: PasskeyWalletConfig; externalWalletState?: ExternalWalletConfig; sessionKeyState?: PasskeyWalletConfig; timestamp: number; credentialId?: string; address?: string; } export enum ENV { PROD = "prod", DEV = "dev", BETA = "beta", PRE = "pre", ALPHA = "alpha", }