UNPKG

@authsignal/browser

Version:

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

38 lines (37 loc) 1.75 kB
import { QrCodeChallengeResponse } from "./api/types/qr-code"; import { ChallengeState } from "./api/types/websocket"; import { AuthsignalResponse } from "./types"; type QrCodeOptions = { baseUrl: string; tenantId: string; enableLogging: boolean; }; export type ChallengeParams = { /** The action to be performed when the QR code is scanned. If track action is called, this must match the action passed to track. */ action: string; /** Custom data to be included in the challenge request. If track action is called, this must be omitted. */ custom?: Record<string, unknown>; /** Use REST API polling instead of WebSocket connection. Default: false */ polling?: boolean; /** The interval in milliseconds at which the QR code challenge will be polled. Default: 5 seconds (Only used when polling is true)*/ pollInterval?: number; /** The interval in milliseconds at which the QR code challenge will be refreshed. Default: 9 minutes */ refreshInterval?: number; /** A callback function that is called when the QR code challenge is refreshed. */ onRefresh?: (challengeId: string, expiresAt: string) => void; /** A callback function that is called when the state of the QR code challenge changes. */ onStateChange: (state: ChallengeState, accessToken?: string) => void; }; export declare class QrCode { private handler; private baseUrl; private tenantId; private enableLogging; constructor({ baseUrl, tenantId, enableLogging }: QrCodeOptions); challenge(params: ChallengeParams): Promise<AuthsignalResponse<QrCodeChallengeResponse>>; refresh({ custom }?: { custom?: Record<string, unknown>; }): Promise<void>; disconnect(): void; } export {};