/** * Privy Expo Auth Provider — React Native implementation of AuthProvider. * * Uses @privy-io/expo instead of @privy-io/react-auth. * Uses ReactNativeSessionManager instead of WebSessionManager. * * IMPORTANT — Expo/RN consumers must: * 1. Install polyfills: fast-text-encoding, react-native-get-random-values * 2. Install @privy-io/expo, @privy-io/expo-native-extensions * 3. Call ReactNativeSessionManager.configure({ storage, atob }) at startup * 4. Call setPlatform({ ... }) from @pooflabs/web at startup * 5. Wrap their app tree with PrivyProvider from @privy-io/expo * 6. Create this provider and pass the Privy hooks/methods via setPrivyMethods() * * Unlike the web PrivyWalletProvider which renders a hidden React DOM tree * to host Privy's React context, this provider expects the RN app itself * to render and then bridge the hooks via setPrivyMethods(). */ import type { EVMTransaction, SolTransaction, TransactionResult, AuthProvider, User, SetOptions } from '@pooflabs/core'; import { PublicKey, Connection, Transaction, VersionedTransaction } from '@solana/web3.js'; export interface PrivyExpoMethods { /** Whether Privy SDK is fully initialized. */ isReady: boolean; /** Whether the user is authenticated. */ isAuthenticated: boolean; /** The user object from usePrivy(). */ user: any; /** Trigger Privy login UI. Returns the user on success. */ login: () => Promise; /** Log out from Privy. */ logout: () => Promise; /** Get an access token from Privy. */ getAccessToken: () => Promise; /** Get the Privy identity token. */ getIdentityToken: () => Promise; /** * Get the embedded Solana wallet provider. * Comes from useEmbeddedSolanaWallet(). */ getWalletProvider: () => Promise<{ address: string; signMessage: (message: Uint8Array) => Promise<{ signature: Uint8Array; }>; signTransaction: (transaction: Transaction | VersionedTransaction) => Promise<{ signedTransaction: Uint8Array; }>; signAndSendTransaction: (transaction: Transaction | VersionedTransaction, connection: Connection) => Promise<{ signature: string; }>; } | null>; } export declare class PrivyExpoProvider implements AuthProvider { private networkUrl; private privyMethods; private appId; constructor(appId: string, networkUrl?: string | null); /** * Bridge Privy hooks from the app's React tree into this provider. * * Call this from a component rendered inside : * ```tsx * const privy = usePrivy(); * const wallet = useEmbeddedSolanaWallet(); * const { getAccessToken } = usePrivy(); * const { getIdentityToken } = useIdentityToken(); * * useEffect(() => { * provider.setPrivyMethods({ * isReady: privy.isReady, * isAuthenticated: !!privy.user, * user: privy.user, * login: privy.login, * logout: privy.logout, * getAccessToken, * getIdentityToken, * getWalletProvider: async () => { * if (!wallet.wallets[0]) return null; * const provider = await wallet.wallets[0].getProvider(); * return { * address: wallet.wallets[0].address, * signMessage: provider.signMessage, * signTransaction: provider.signTransaction, * signAndSendTransaction: provider.signAndSendTransaction, * }; * }, * }); * }, [privy.isReady, privy.user, wallet.wallets]); * ``` */ setPrivyMethods(methods: PrivyExpoMethods): void; login(): Promise; runTransaction(_evmTransactionData?: EVMTransaction, solTransactionData?: SolTransaction, options?: SetOptions): Promise; signMessage(message: string): Promise; signTransaction(transaction: Transaction | VersionedTransaction): Promise; signAndSubmitTransaction(transaction: Transaction | VersionedTransaction, feePayer?: PublicKey): Promise; restoreSession(): Promise; logout(): Promise; getNativeMethods(): Promise; private createSession; private getWalletOrThrow; private signAndSubmitInternal; private getRpcUrl; private ensureReady; }