Package: react-wallet-kit
Defined in: react-wallet-kit/src/providers/client/Types.tsx:283
Overview
Handles the Facebook OAuth flow.- This function initiates the Facebook OAuth flow by either redirecting the user to the Facebook authorization page or opening it in a popup window.
- The flow type is determined by the
openInPage
parameter: if true, the current page is redirected; if false (default), a popup window is used. - Generates a new ephemeral API key pair and uses its public key as the nonce for the OAuth request, ensuring cryptographic binding of the session.
- Uses PKCE (Proof Key for Code Exchange) for enhanced security, generating a code verifier and challenge for the Facebook OAuth flow.
- Constructs the Facebook OAuth URL with all required parameters, including client ID, redirect URI, response type, code challenge, nonce, and state.
- The
state
parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic. - If
openInPage
is true, the function redirects and returns a promise that resolves on redirect or times out after 5 minutes. - If
openInPage
is false, a popup window is opened and the function returns a promise that resolves when the flow completes, or rejects if the window is closed or times out. - On successful authentication, the function either calls the provided
onOauthSuccess
callback, triggers theonOauthRedirect
callback from provider callbacks, or completes the OAuth flow internally by callingcompleteOauth
. - Handles all error cases, including missing configuration, popup failures, and timeouts, and throws a
TurnkeyError
with appropriate error codes.
Parameters
Response
A successful response returns the following fields:A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.