UNPKG

@getpassage/react-native

Version:

Passage React Native SDK for mobile authentication

224 lines (223 loc) 5.74 kB
export interface PassageConfig { /** * Web URL for the Passage web app UI * @default "https://ui.getpassage.ai" */ webUrl?: string; /** * API URL for backend API calls * @default "https://api.getpassage.ai" */ apiUrl?: string; /** * Socket server URL for remote control * @default "https://api.getpassage.ai" */ socketUrl?: string; /** * Socket namespace * @default "/ws" */ socketNamespace?: string; /** * Enable debug logging * @default false */ debug?: boolean; /** * Enable analytics tracking * @default true */ analytics?: boolean; } export interface PassagePrompt { identifier: string; prompt: string; integrationid: string; forceRefresh: boolean; } export interface PassageConnection { id: string; integrationId?: string; data?: any; sessionInfo?: { cookies: any[]; localStorage: any[]; sessionStorage: any[]; }; } export interface PassagePromptResponse { key: string; value: string; response?: any; } export interface PassageInitializeOptions { /** * Publishable key for authentication */ publishableKey: string; /** * Prompts to process after connection */ prompts?: PassagePrompt[]; /** * Callbacks */ onConnectionComplete?: (connection: PassageConnection) => void; onError?: (error: PassageErrorData) => void; onDataComplete?: (data: PassageDataResult) => void; onPromptComplete?: (prompt: PassagePromptResponse) => void; onExit?: (reason?: string) => void; } export interface PassageOpenOptions { /** * The intent token for authentication (optional - will use provider state if not provided) */ intentToken?: string; /** * Optional prompts to process after connection */ prompts?: PassagePrompt[]; /** * Called when the connection is successfully established */ onConnectionComplete?: (data: PassageSuccessData) => void; /** * Called when there's an error during connection */ onConnectionError?: (error: PassageErrorData) => void; /** * Called when data is complete */ onDataComplete?: (data: PassageDataResult) => void; /** * Called when a prompt is successfully processed */ onPromptComplete?: (prompt: PassagePromptResponse) => void; /** * Called when the user manually closes the modal before connection */ onExit?: (reason?: string) => void; /** * Called when the webview changes (ui or automation) */ onWebviewChange?: (webviewType: "ui" | "automation") => void; /** * Presentation style for the modal * @default "modal" */ presentationStyle?: "modal" | "fullScreen"; /** * Optional SDK session identifier to track automation state * If not provided, a new session will be generated */ sdkSession?: string; /** * Bottom margin for the modal (useful when record mode UI is visible) */ marginBottom?: number; } export interface PassageConnectOptions { /** * The intent token for authentication */ intentToken: string; /** * Called when a message is received from the websocket */ onMessage?: (message: any) => void; /** * Called when there's an error */ onError?: (error: PassageErrorData) => void; /** * Called when the connection is closed */ onClose?: () => void; } export interface PassageDataResult { /** * The data from the connection */ data?: any; /** * Prompts and their results */ prompts?: Array<{ prompt: string; results: any; }>; } export interface PassageContextValue { initialize: (options: PassageInitializeOptions) => Promise<void>; open: (options?: PassageOpenOptions) => Promise<void>; close: () => Promise<void>; getData: () => Promise<PassageDataResult>; connect: (options: PassageConnectOptions) => Promise<void>; disconnect: () => void; completeRecording: (data?: any) => Promise<void>; captureRecordingData: (data?: any) => Promise<void>; onWebviewChange: (callback: (webviewType: "ui" | "automation") => void) => void; } export interface PassageSuccessData { data?: any; pageData?: { cookies?: Array<{ name: string; value: string; domain: string; }>; localStorage?: Array<{ name: string; value: string; }>; sessionStorage?: Array<{ name: string; value: string; }>; html?: string; url?: string; screenshot?: string; }; sessionInfo?: { cookies: any[]; localStorage: any[]; sessionStorage: any[]; }; } export interface PassageErrorData { error: string; data?: any; } export interface RemoteCommand { id: string; type: "navigate" | "click" | "input" | "wait" | "done" | "injectScript"; args?: any; injectScript?: string; cookieDomains?: string[]; userActionRequired?: boolean; } export interface CommandResult { id: string; status: "success" | "error" | "done"; data?: any; pageData?: { cookies?: Array<{ name: string; value: string; domain: string; }>; localStorage?: Array<{ name: string; value: string; }>; sessionStorage?: Array<{ name: string; value: string; }>; html?: string; url?: string; screenshot?: string; }; error?: string; }