@getpassage/react-native
Version:
Passage React Native SDK for mobile authentication
24 lines (23 loc) • 981 B
JavaScript
import { useContext } from "react";
import { PassageContext } from "./Provider";
/**
* Hook to access the Passage context and methods
*
* @returns {PassageContextValue} Object containing:
* - initialize: Initialize Passage with publishable key and configuration
* - open: Open the Passage modal (requires initialization first)
* - close: Close the Passage modal
* - getData: Get stored session data and prompts
* - connect: Connect to Passage in headless mode
* - disconnect: Disconnect from Passage
* - completeRecording: Complete the current recording session with status 'done'
* - captureRecordingData: Capture current HTML and screenshot, send as result (not done)
* - onWebviewChange: Set a callback for when webview changes between ui and automation
*/
export const usePassage = () => {
const context = useContext(PassageContext);
if (!context) {
throw new Error("usePassage must be used within a PassageProvider");
}
return context;
};