UNPKG

@getpassage/react-native

Version:

Passage React Native SDK for mobile authentication

120 lines (119 loc) 4.56 kB
import type { WebViewMessageEvent } from "react-native-webview"; import type { WebView } from "react-native-webview"; import type { PassageSuccessData, PassageErrorData } from "./types"; interface WebViewRefs { ui: WebView | null; automation: WebView | null; } interface ScreenshotAccessors { getCurrentScreenshot: () => string | null; getPreviousScreenshot: () => string | null; } interface CaptureImageFunction { (): Promise<string | null>; } export declare class RemoteControlManager { private static instance; private socket; private isConnected; private commandQueue; private intentToken; private onSuccess?; private onError?; private onDataComplete?; private onPromptComplete?; private socketUrl; private apiUrl; private webUrl; private cookieDomains; private globalJavascript; private userAgent; private integrationUrl; private webViewRefs; private screenshotAccessors; private captureImageFunction; private sessionSuccess; private isNavigatingRef; private onConfigurationUpdated?; private currentCommand; private navigationPromiseResolve; private pageDataPromise; private onWebViewSwitch?; private currentWebViewType; private hasReceivedFirstCommand; private currentUserActionRequired; private lastUserActionCommand; private lastInjectScript; private lastInjectScriptCommandId; private lastInjectScriptCommand; private userActionThrottleTimer; private userActionThrottleStartTime; private pendingUserActionRequired; private currentImageUri; private constructor(); static getInstance(): RemoteControlManager; setWebViewRefs(refs: WebViewRefs | null): void; setScreenshotAccessors(accessors: ScreenshotAccessors | null): void; setCaptureImageFunction(captureImageFn: CaptureImageFunction | null): void; private captureImageAfterInteraction; setCurrentImage(imageUri: string | null): void; private navigateToIntegrationUrl; private initializeWebViews; setWebViewSwitchCallback(callback: ((type: "ui" | "automation") => void) | null): void; getUserAgent(): string; getGlobalJavascript(): string; getRecordFlag(): boolean; completeRecording(data?: any): Promise<void>; captureRecordingData(data?: any): Promise<void>; private shouldReinjectScript; private checkAndReinjectScript; private checkAndApplyJWTFlags; handleNavigationComplete(url: string): void; private getClientUserAgent; setConfigurationCallback(callback: ((config: { userAgent: string; integrationUrl?: string; }) => void) | null): void; private switchToUIWebView; private switchToAutomationWebView; private getActiveWebView; handleLoadStart(webViewType: "ui" | "automation"): void; handleLoadEnd(webViewType: "ui" | "automation"): void; handleLoadError(error: any, webViewType: "ui" | "automation"): void; fetchConfiguration(apiUrl: string, intentToken: string): Promise<boolean>; connect(socketUrl: string, socketNamespace?: string, intentToken?: string, callbacks?: { onSuccess?: (data: PassageSuccessData) => void; onError?: (error: PassageErrorData) => void; onDataComplete?: (data: any) => void; onPromptComplete?: (prompt: any) => void; }, apiUrl?: string, webUrl?: string): Promise<void>; connectHeadless(socketUrl: string, socketNamespace: string | undefined, intentToken: string, callbacks?: { onMessage?: (message: any) => void; onError?: (error: PassageErrorData) => void; onClose?: () => void; }, apiUrl?: string, webUrl?: string): Promise<void>; private throttleUserActionChange; private applyUserActionChange; private setupEventHandlers; private handleCommand; private handleNavigate; private wrapScriptForExecution; private handleScriptExecution; private handleDone; private navigateToConnectUrl; private getCurrentUrl; private getPageData; private sendSuccess; private sendError; private sendDone; private handleWaitForInteractionResult; private formatInteractionData; private sendResult; sendBrowserState(url: string, webViewType: "ui" | "automation"): Promise<void>; private processCommandQueue; emitModalExit(): Promise<void>; disconnect(): void; handleSendPageDataRequest(commandId: string): void; handleWebViewMessage(event: WebViewMessageEvent, webViewType: "ui" | "automation"): Promise<void>; } export {};