UNPKG

@authsignal/browser

Version:

<img width="1070" alt="Authsignal" src="https://raw.githubusercontent.com/authsignal/authsignal-browser/main/.github/images/authsignal.png">

58 lines (57 loc) 1.95 kB
import { AuthenticationResponseJSON, RegistrationResponseJSON, AuthenticatorAttachment, PublicKeyCredentialHint } from "@simplewebauthn/browser"; import { PasskeyApiClient } from "./api/passkey-api-client"; import { AuthsignalResponse } from "./types"; import { Authenticator } from "./api/types/shared"; type PasskeyOptions = { baseUrl: string; tenantId: string; anonymousId: string; onTokenExpired?: () => void; enableLogging: boolean; }; type SignUpParams = { token?: string; username?: string; displayName?: string; authenticatorAttachment?: AuthenticatorAttachment | null; hints?: PublicKeyCredentialHint[]; useAutoRegister?: boolean; useCookies?: boolean; }; type SignUpResponse = { token?: string; userAuthenticator?: Authenticator; registrationResponse?: RegistrationResponseJSON; }; type SignInParams = { autofill?: boolean; action?: string; token?: string; useCookies?: boolean; onVerificationStarted?: () => unknown; }; type SignInResponse = { isVerified: boolean; token?: string; userId?: string; userAuthenticatorId?: string; username?: string; displayName?: string; authenticationResponse?: AuthenticationResponseJSON; }; export declare class Passkey { api: PasskeyApiClient; private passkeyLocalStorageKey; private anonymousId; private cache; private enableLogging; constructor({ baseUrl, tenantId, anonymousId, onTokenExpired, enableLogging }: PasskeyOptions); signUp({ username, displayName, token, authenticatorAttachment, hints, useAutoRegister, useCookies, }: SignUpParams): Promise<AuthsignalResponse<SignUpResponse>>; signIn(params?: SignInParams): Promise<AuthsignalResponse<SignInResponse>>; isAvailableOnDevice({ userId }: { userId: string; }): Promise<boolean>; private storeCredentialAgainstDevice; private doesBrowserSupportConditionalCreate; } export {};