UNPKG

@bynn-intelligence/agemin-sdk

Version:

agemin.com SDK for age verification

125 lines (124 loc) 3.43 kB
import { AgeminConfig, VerifyOptions } from '../types'; interface AgeminGlobalState { isInitializing: boolean; isVerifying: boolean; referenceId: string | null; verificationPromise: Promise<boolean> | null; verificationResolve: ((value: boolean) => void) | null; verificationReject: ((error: any) => void) | null; validationQueue: Promise<any>; instances: { [assetId: string]: Agemin; }; instanceCreationInProgress: { [assetId: string]: boolean; }; } declare global { interface Window { __AGEMIN__: AgeminGlobalState; } } export declare class Agemin { private static isVerificationActive; private config; private modal; private callbacks; constructor(config: AgeminConfig); /** * Start the verification process and return a promise that resolves when complete */ private verifyAndWait; /** * Start the verification process (legacy method that returns referenceId) */ verify(options?: VerifyOptions): string; /** * Close the verification modal/popup */ close(): void; /** * Get the reference ID */ getReferenceId(): string; /** * Check if verification is currently open */ isOpen(): boolean; /** * Validate existing session and launch verification if needed * @returns true if valid session exists, false if verification was launched */ validateSession(options?: VerifyOptions): Promise<boolean>; /** * Internal method that performs the actual validation */ private doValidateSession; /** * Get SDK version */ static get version(): string; /** * Check if browser is supported */ static isSupported(): boolean; /** * Check if verification is currently active */ static isVerificationInProgress(): boolean; /** * Get the active verification promise if one exists */ static getActiveVerificationPromise(): Promise<boolean> | null; /** * Get the instance for a specific assetId (create if needed) */ static getInstance(config?: AgeminConfig): Agemin; /** * Reset instances (useful for testing) * @param assetId - Optional: reset only a specific assetId's instance. If not provided, resets all. */ static reset(assetId?: string): void; private setupMessageListener; private buildVerificationUrl; private handleSuccess; private handleError; private handleCancel; private handleReady; private handleResize; private cleanup; private handleAppReady; private handleProgress; private handleStateChange; private handleUserAction; private appEventListeners; /** * Register a callback for when the app is ready */ onAppReady(callback: () => void): void; /** * Register a callback for progress updates */ onProgress(callback: (data: { percentage: number; stage?: string; message?: string; }) => void): void; /** * Register a callback for state changes */ onStateChange(callback: (data: { from: string; to: string; data?: any; }) => void): void; /** * Register a callback for user actions */ onUserAction(callback: (data: { type: string; target?: string; data?: any; }) => void): void; } export {};