UNPKG

expo-otp-retriever

Version:

Expo module for retrieving OTP codes on Android using Google's SMS Retriever API

61 lines 1.94 kB
import { Subscription } from 'expo-modules-core'; /** * Events emitted by the OTP Retriever module */ export declare enum OtpRetrieverEvents { OTP_RECEIVED = "otpReceived", OTP_TIMEOUT = "otpTimeout", OTP_ERROR = "otpError" } /** * Error codes that might be returned by the module */ export declare enum OtpRetrieverErrorCodes { LISTENER_ERROR = "LISTENER_ERROR", HASH_GENERATION_ERROR = "HASH_GENERATION_ERROR", UNSUPPORTED_PLATFORM = "UNSUPPORTED_PLATFORM", PLAY_SERVICES_UNAVAILABLE = "PLAY_SERVICES_UNAVAILABLE" } /** * Error object structure returned when an error occurs */ export interface OtpRetrieverError { code: OtpRetrieverErrorCodes; message: string; details?: any; } /** * Main class for OTP Retriever functionality */ declare class OtpRetriever { /** * Starts listening for OTP SMS messages * @param timeoutSeconds Optional timeout in seconds (default: 60) * @returns Promise that resolves when listening starts successfully */ startListener(timeoutSeconds?: number): Promise<void>; /** * Stops listening for OTP SMS messages * @returns Promise that resolves when listening stops successfully */ stopListener(): Promise<void>; /** * Generates an app signature hash needed for SMS OTP format * @returns Promise that resolves with the app hash string */ getAppHash(): Promise<string>; /** * Adds a listener for OTP events * @param eventName The event to listen for * @param listener The callback function * @returns Subscription object that can be used to remove the listener */ addListener(eventName: OtpRetrieverEvents, listener: (event: any) => void): Subscription; /** * Helper method to create standardized error objects */ private _createError; } declare const _default: OtpRetriever; export default _default; //# sourceMappingURL=index.d.ts.map