@turnkey/react-wallet-kit 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.MD +112 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.mjs +420 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -0
- package/dist/components/auth/Action.d.ts +10 -0
- package/dist/components/auth/Action.d.ts.map +1 -0
- package/dist/components/auth/Action.js +76 -0
- package/dist/components/auth/Action.js.map +1 -0
- package/dist/components/auth/Action.mjs +97 -0
- package/dist/components/auth/Action.mjs.map +1 -0
- package/dist/components/auth/Email.d.ts +6 -0
- package/dist/components/auth/Email.d.ts.map +1 -0
- package/dist/components/auth/Email.js +73 -0
- package/dist/components/auth/Email.js.map +1 -0
- package/dist/components/auth/Email.mjs +95 -0
- package/dist/components/auth/Email.mjs.map +1 -0
- package/dist/components/auth/OAuth.d.ts +10 -0
- package/dist/components/auth/OAuth.d.ts.map +1 -0
- package/dist/components/auth/OAuth.js +42 -0
- package/dist/components/auth/OAuth.js.map +1 -0
- package/dist/components/auth/OAuth.mjs +46 -0
- package/dist/components/auth/OAuth.mjs.map +1 -0
- package/dist/components/auth/OTP.d.ts +19 -0
- package/dist/components/auth/OTP.d.ts.map +1 -0
- package/dist/components/auth/OTP.js +204 -0
- package/dist/components/auth/OTP.js.map +1 -0
- package/dist/components/auth/OTP.mjs +288 -0
- package/dist/components/auth/OTP.mjs.map +1 -0
- package/dist/components/auth/OrSeparator.d.ts +2 -0
- package/dist/components/auth/OrSeparator.d.ts.map +1 -0
- package/dist/components/auth/OrSeparator.js +20 -0
- package/dist/components/auth/OrSeparator.js.map +1 -0
- package/dist/components/auth/OrSeparator.mjs +18 -0
- package/dist/components/auth/OrSeparator.mjs.map +1 -0
- package/dist/components/auth/Passkey.d.ts +7 -0
- package/dist/components/auth/Passkey.d.ts.map +1 -0
- package/dist/components/auth/Passkey.js +26 -0
- package/dist/components/auth/Passkey.js.map +1 -0
- package/dist/components/auth/Passkey.mjs +22 -0
- package/dist/components/auth/Passkey.mjs.map +1 -0
- package/dist/components/auth/Phone.d.ts +6 -0
- package/dist/components/auth/Phone.d.ts.map +1 -0
- package/dist/components/auth/Phone.js +67 -0
- package/dist/components/auth/Phone.js.map +1 -0
- package/dist/components/auth/Phone.mjs +93 -0
- package/dist/components/auth/Phone.mjs.map +1 -0
- package/dist/components/auth/Wallet.d.ts +30 -0
- package/dist/components/auth/Wallet.d.ts.map +1 -0
- package/dist/components/auth/Wallet.js +408 -0
- package/dist/components/auth/Wallet.js.map +1 -0
- package/dist/components/auth/Wallet.mjs +509 -0
- package/dist/components/auth/Wallet.mjs.map +1 -0
- package/dist/components/auth/index.d.ts +2 -0
- package/dist/components/auth/index.d.ts.map +1 -0
- package/dist/components/auth/index.js +327 -0
- package/dist/components/auth/index.js.map +1 -0
- package/dist/components/auth/index.mjs +540 -0
- package/dist/components/auth/index.mjs.map +1 -0
- package/dist/components/design/Buttons.d.ts +26 -0
- package/dist/components/design/Buttons.d.ts.map +1 -0
- package/dist/components/design/Buttons.js +79 -0
- package/dist/components/design/Buttons.js.map +1 -0
- package/dist/components/design/Buttons.mjs +71 -0
- package/dist/components/design/Buttons.mjs.map +1 -0
- package/dist/components/design/Failure.d.ts +9 -0
- package/dist/components/design/Failure.d.ts.map +1 -0
- package/dist/components/design/Failure.js +33 -0
- package/dist/components/design/Failure.js.map +1 -0
- package/dist/components/design/Failure.mjs +34 -0
- package/dist/components/design/Failure.mjs.map +1 -0
- package/dist/components/design/Inputs.d.ts +9 -0
- package/dist/components/design/Inputs.d.ts.map +1 -0
- package/dist/components/design/Inputs.js +113 -0
- package/dist/components/design/Inputs.js.map +1 -0
- package/dist/components/design/Inputs.mjs +108 -0
- package/dist/components/design/Inputs.mjs.map +1 -0
- package/dist/components/design/Lottie/Dynamic.d.ts +2 -0
- package/dist/components/design/Lottie/Dynamic.d.ts.map +1 -0
- package/dist/components/design/Lottie/Dynamic.js +9 -0
- package/dist/components/design/Lottie/Dynamic.js.map +1 -0
- package/dist/components/design/Lottie/Dynamic.mjs +27 -0
- package/dist/components/design/Lottie/Dynamic.mjs.map +1 -0
- package/dist/components/design/Lottie/Wrapper.d.ts +8 -0
- package/dist/components/design/Lottie/Wrapper.d.ts.map +1 -0
- package/dist/components/design/Lottie/Wrapper.js +26 -0
- package/dist/components/design/Lottie/Wrapper.js.map +1 -0
- package/dist/components/design/Lottie/Wrapper.mjs +43 -0
- package/dist/components/design/Lottie/Wrapper.mjs.map +1 -0
- package/dist/components/design/Spinners.d.ts +9 -0
- package/dist/components/design/Spinners.d.ts.map +1 -0
- package/dist/components/design/Spinners.js +38 -0
- package/dist/components/design/Spinners.js.map +1 -0
- package/dist/components/design/Spinners.mjs +37 -0
- package/dist/components/design/Spinners.mjs.map +1 -0
- package/dist/components/design/Success.d.ts +8 -0
- package/dist/components/design/Success.d.ts.map +1 -0
- package/dist/components/design/Success.js +82 -0
- package/dist/components/design/Success.js.map +1 -0
- package/dist/components/design/Success.mjs +86 -0
- package/dist/components/design/Success.mjs.map +1 -0
- package/dist/components/design/Svg.d.ts +10 -0
- package/dist/components/design/Svg.d.ts.map +1 -0
- package/dist/components/design/Svg.js +156 -0
- package/dist/components/design/Svg.js.map +1 -0
- package/dist/components/design/Svg.mjs +153 -0
- package/dist/components/design/Svg.mjs.map +1 -0
- package/dist/components/export/Export.d.ts +9 -0
- package/dist/components/export/Export.d.ts.map +1 -0
- package/dist/components/export/Export.js +140 -0
- package/dist/components/export/Export.js.map +1 -0
- package/dist/components/export/Export.mjs +178 -0
- package/dist/components/export/Export.mjs.map +1 -0
- package/dist/components/export/ExportWarning.d.ts +12 -0
- package/dist/components/export/ExportWarning.d.ts.map +1 -0
- package/dist/components/export/ExportWarning.js +87 -0
- package/dist/components/export/ExportWarning.js.map +1 -0
- package/dist/components/export/ExportWarning.mjs +113 -0
- package/dist/components/export/ExportWarning.mjs.map +1 -0
- package/dist/components/import/Import.d.ts +14 -0
- package/dist/components/import/Import.d.ts.map +1 -0
- package/dist/components/import/Import.js +226 -0
- package/dist/components/import/Import.js.map +1 -0
- package/dist/components/import/Import.mjs +328 -0
- package/dist/components/import/Import.mjs.map +1 -0
- package/dist/components/sign/Message.d.ts +17 -0
- package/dist/components/sign/Message.d.ts.map +1 -0
- package/dist/components/sign/Message.js +127 -0
- package/dist/components/sign/Message.js.map +1 -0
- package/dist/components/sign/Message.mjs +145 -0
- package/dist/components/sign/Message.mjs.map +1 -0
- package/dist/components/user/LinkWallet.d.ts +8 -0
- package/dist/components/user/LinkWallet.d.ts.map +1 -0
- package/dist/components/user/LinkWallet.js +102 -0
- package/dist/components/user/LinkWallet.js.map +1 -0
- package/dist/components/user/LinkWallet.mjs +162 -0
- package/dist/components/user/LinkWallet.mjs.map +1 -0
- package/dist/components/user/RemoveEmail.d.ts +11 -0
- package/dist/components/user/RemoveEmail.d.ts.map +1 -0
- package/dist/components/user/RemoveEmail.js +101 -0
- package/dist/components/user/RemoveEmail.js.map +1 -0
- package/dist/components/user/RemoveEmail.mjs +122 -0
- package/dist/components/user/RemoveEmail.mjs.map +1 -0
- package/dist/components/user/RemoveOAuthProvider.d.ts +11 -0
- package/dist/components/user/RemoveOAuthProvider.d.ts.map +1 -0
- package/dist/components/user/RemoveOAuthProvider.js +106 -0
- package/dist/components/user/RemoveOAuthProvider.js.map +1 -0
- package/dist/components/user/RemoveOAuthProvider.mjs +129 -0
- package/dist/components/user/RemoveOAuthProvider.mjs.map +1 -0
- package/dist/components/user/RemovePasskey.d.ts +11 -0
- package/dist/components/user/RemovePasskey.d.ts.map +1 -0
- package/dist/components/user/RemovePasskey.js +109 -0
- package/dist/components/user/RemovePasskey.js.map +1 -0
- package/dist/components/user/RemovePasskey.mjs +132 -0
- package/dist/components/user/RemovePasskey.mjs.map +1 -0
- package/dist/components/user/RemovePhoneNumber.d.ts +11 -0
- package/dist/components/user/RemovePhoneNumber.d.ts.map +1 -0
- package/dist/components/user/RemovePhoneNumber.js +101 -0
- package/dist/components/user/RemovePhoneNumber.js.map +1 -0
- package/dist/components/user/RemovePhoneNumber.mjs +122 -0
- package/dist/components/user/RemovePhoneNumber.mjs.map +1 -0
- package/dist/components/user/UpdateEmail.d.ts +8 -0
- package/dist/components/user/UpdateEmail.d.ts.map +1 -0
- package/dist/components/user/UpdateEmail.js +139 -0
- package/dist/components/user/UpdateEmail.js.map +1 -0
- package/dist/components/user/UpdateEmail.mjs +186 -0
- package/dist/components/user/UpdateEmail.mjs.map +1 -0
- package/dist/components/user/UpdatePhoneNumber.d.ts +8 -0
- package/dist/components/user/UpdatePhoneNumber.d.ts.map +1 -0
- package/dist/components/user/UpdatePhoneNumber.js +136 -0
- package/dist/components/user/UpdatePhoneNumber.js.map +1 -0
- package/dist/components/user/UpdatePhoneNumber.mjs +187 -0
- package/dist/components/user/UpdatePhoneNumber.mjs.map +1 -0
- package/dist/components/user/UpdateUserName.d.ts +11 -0
- package/dist/components/user/UpdateUserName.d.ts.map +1 -0
- package/dist/components/user/UpdateUserName.js +112 -0
- package/dist/components/user/UpdateUserName.js.map +1 -0
- package/dist/components/user/UpdateUserName.mjs +139 -0
- package/dist/components/user/UpdateUserName.mjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/dist/providers/TurnkeyProvider.d.ts +8 -0
- package/dist/providers/TurnkeyProvider.d.ts.map +1 -0
- package/dist/providers/TurnkeyProvider.js +35 -0
- package/dist/providers/TurnkeyProvider.js.map +1 -0
- package/dist/providers/TurnkeyProvider.mjs +33 -0
- package/dist/providers/TurnkeyProvider.mjs.map +1 -0
- package/dist/providers/client/Hook.d.ts +3 -0
- package/dist/providers/client/Hook.d.ts.map +1 -0
- package/dist/providers/client/Hook.js +14 -0
- package/dist/providers/client/Hook.js.map +1 -0
- package/dist/providers/client/Hook.mjs +12 -0
- package/dist/providers/client/Hook.mjs.map +1 -0
- package/dist/providers/client/Provider.d.ts +39 -0
- package/dist/providers/client/Provider.d.ts.map +1 -0
- package/dist/providers/client/Provider.js +2489 -0
- package/dist/providers/client/Provider.js.map +1 -0
- package/dist/providers/client/Provider.mjs +4744 -0
- package/dist/providers/client/Provider.mjs.map +1 -0
- package/dist/providers/client/Types.d.ts +524 -0
- package/dist/providers/client/Types.d.ts.map +1 -0
- package/dist/providers/client/Types.js +9 -0
- package/dist/providers/client/Types.js.map +1 -0
- package/dist/providers/client/Types.mjs +7 -0
- package/dist/providers/client/Types.mjs.map +1 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/modal/Hook.d.ts +3 -0
- package/dist/providers/modal/Hook.d.ts.map +1 -0
- package/dist/providers/modal/Hook.js +14 -0
- package/dist/providers/modal/Hook.js.map +1 -0
- package/dist/providers/modal/Hook.mjs +12 -0
- package/dist/providers/modal/Hook.mjs.map +1 -0
- package/dist/providers/modal/Provider.d.ts +21 -0
- package/dist/providers/modal/Provider.d.ts.map +1 -0
- package/dist/providers/modal/Provider.js +37 -0
- package/dist/providers/modal/Provider.js.map +1 -0
- package/dist/providers/modal/Provider.mjs +48 -0
- package/dist/providers/modal/Provider.mjs.map +1 -0
- package/dist/providers/modal/Root.d.ts +7 -0
- package/dist/providers/modal/Root.d.ts.map +1 -0
- package/dist/providers/modal/Root.js +258 -0
- package/dist/providers/modal/Root.js.map +1 -0
- package/dist/providers/modal/Root.mjs +263 -0
- package/dist/providers/modal/Root.mjs.map +1 -0
- package/dist/providers/theme/Overrides.d.ts +18 -0
- package/dist/providers/theme/Overrides.d.ts.map +1 -0
- package/dist/providers/theme/Overrides.js +35 -0
- package/dist/providers/theme/Overrides.js.map +1 -0
- package/dist/providers/theme/Overrides.mjs +37 -0
- package/dist/providers/theme/Overrides.mjs.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/types/base.d.ts +79 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/types/base.js +19 -0
- package/dist/types/base.js.map +1 -0
- package/dist/types/base.mjs +19 -0
- package/dist/types/base.mjs.map +1 -0
- package/dist/utils.d.ts +72 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +211 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +307 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TurnkeySDKClientBase, TurnkeyClientMethods, Wallet, StamperType, WalletAccount } from "@turnkey/core";
|
|
3
|
+
import type { OAuthProviders, Session, v1AddressFormat, v1HashFunction, v1PayloadEncoding, v1SignRawPayloadResult, v1User, v1WalletAccountParams } from "@turnkey/sdk-types";
|
|
4
|
+
import type { TurnkeyProviderConfig, ExportType, AuthState, ClientState } from "../../types/base";
|
|
5
|
+
export interface ClientContextType extends TurnkeyClientMethods {
|
|
6
|
+
httpClient: TurnkeySDKClientBase | undefined;
|
|
7
|
+
session: Session | undefined;
|
|
8
|
+
allSessions?: Record<string, Session> | undefined;
|
|
9
|
+
clientState: ClientState | undefined;
|
|
10
|
+
authState: AuthState;
|
|
11
|
+
config?: TurnkeyProviderConfig | undefined;
|
|
12
|
+
user: v1User | undefined;
|
|
13
|
+
wallets: Wallet[];
|
|
14
|
+
/**
|
|
15
|
+
* Refreshes the user details.
|
|
16
|
+
*
|
|
17
|
+
* - This function fetches the latest user details for the current session (or optionally for a specific user/organization if provided)
|
|
18
|
+
* and updates the `user` state variable in the provider.
|
|
19
|
+
* - If a `stampWith` parameter is provided, it will use that stamper to fetch the user details (supports Passkey, ApiKey, or Wallet stampers).
|
|
20
|
+
* - Automatically handles error reporting via the configured callbacks.
|
|
21
|
+
* - Typically used after authentication, user profile updates, or linking/unlinking authenticators to ensure the provider state is up to date.
|
|
22
|
+
* - If no user is found, the state will not be updated.
|
|
23
|
+
*
|
|
24
|
+
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
25
|
+
* @returns A promise that resolves when the user details are successfully refreshed and state is updated.
|
|
26
|
+
* @throws {TurnkeyError} If the client is not initialized or if there is an error refreshing the user details.
|
|
27
|
+
*/
|
|
28
|
+
refreshUser(params?: {
|
|
29
|
+
stampWith?: StamperType | undefined;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Refreshes the wallets state for the current user session.
|
|
33
|
+
*
|
|
34
|
+
* - This function fetches the latest list of wallets associated with the current session or user,
|
|
35
|
+
* and updates the `wallets` state variable in the provider.
|
|
36
|
+
* - If a `stampWith` parameter is provided, it will use that stamper to fetch the wallets
|
|
37
|
+
* (supports Passkey, ApiKey, or Wallet stampers for granular authentication control).
|
|
38
|
+
* - Automatically handles error reporting via the configured callbacks.
|
|
39
|
+
* - Typically used after wallet creation, import, export, account changes, or authentication
|
|
40
|
+
* to ensure the provider state is up to date.
|
|
41
|
+
* - If no wallets are found, the state will be set to an empty array.
|
|
42
|
+
*
|
|
43
|
+
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
44
|
+
* @returns A promise that resolves when the wallets are successfully refreshed and state is updated.
|
|
45
|
+
* @throws {TurnkeyError} If the client is not initialized or if there is an error refreshing the wallets.
|
|
46
|
+
*/
|
|
47
|
+
refreshWallets(params?: {
|
|
48
|
+
stampWith?: StamperType | undefined;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Handles the login or sign-up flow.
|
|
52
|
+
*
|
|
53
|
+
* - This function opens a modal with the AuthComponent, allowing the user to log in or sign up using any enabled authentication method (Passkey, Wallet, OTP, or OAuth).
|
|
54
|
+
* - It automatically determines available authentication methods based on the current provider configuration and proxy settings.
|
|
55
|
+
* - The modal-driven flow guides the user through the appropriate authentication steps, including social login if enabled.
|
|
56
|
+
* - After successful authentication, the provider state is updated and all relevant session, user, and wallet data are refreshed.
|
|
57
|
+
* - This function is typically used to trigger authentication from a UI button or navigation event.
|
|
58
|
+
*
|
|
59
|
+
* @returns A void promise.
|
|
60
|
+
*/
|
|
61
|
+
handleLogin(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Handles the Google OAuth flow.
|
|
64
|
+
*
|
|
65
|
+
* - This function initiates the Google OAuth flow by redirecting the user to the Google authorization page or opening it in a popup window.
|
|
66
|
+
* - It supports both "popup" and "redirect" flows, determined by the `openInPage` parameter.
|
|
67
|
+
* - 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.
|
|
68
|
+
* - Constructs the Google OAuth URL with all required parameters, including client ID, redirect URI, response type, scope, nonce, and state.
|
|
69
|
+
* - The `state` parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic.
|
|
70
|
+
* - If `openInPage` is true, the current page is redirected to the Google OAuth URL and the function returns a promise that resolves on redirect or times out after 5 minutes.
|
|
71
|
+
* - If `openInPage` is false, a popup window is opened for the OAuth flow, and the function returns a promise that resolves when the flow completes or rejects if the window is closed or times out.
|
|
72
|
+
* - On successful authentication, the function either calls the provided `onOauthSuccess` callback, triggers the `onOauthRedirect` callback from provider callbacks, or completes the OAuth flow internally by calling `completeOauth`.
|
|
73
|
+
* - Handles all error cases, including missing configuration, popup failures, and timeouts, and throws a `TurnkeyError` with appropriate error codes.
|
|
74
|
+
*
|
|
75
|
+
* @param params.clientId - The Google Client ID to use (defaults to the client ID from configuration).
|
|
76
|
+
* @param params.openInPage - Whether to open the OAuth flow in the current page (redirect) or a popup window (default: false).
|
|
77
|
+
* @param params.additionalState - Additional key-value pairs to include in the OAuth state parameter for custom tracking or logic.
|
|
78
|
+
* @param params.onOauthSuccess - Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName }`).
|
|
79
|
+
*
|
|
80
|
+
* onOauthSuccess params:
|
|
81
|
+
* - oidcToken: The OIDC token received from the OAuth flow.
|
|
82
|
+
* - providerName: The name of the OAuth provider ("google").
|
|
83
|
+
*
|
|
84
|
+
* @returns A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.
|
|
85
|
+
* @throws {TurnkeyError} If the configuration is not ready, required parameters are missing, or if there is an error initiating or completing the OAuth flow.
|
|
86
|
+
*/
|
|
87
|
+
handleGoogleOauth(params?: {
|
|
88
|
+
clientId?: string;
|
|
89
|
+
additionalState?: Record<string, string>;
|
|
90
|
+
openInPage?: boolean;
|
|
91
|
+
onOauthSuccess?: (params: {
|
|
92
|
+
oidcToken: string;
|
|
93
|
+
providerName: string;
|
|
94
|
+
}) => any;
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Handles the Apple OAuth flow.
|
|
98
|
+
*
|
|
99
|
+
* - This function initiates the Apple OAuth flow by either redirecting the user to the Apple authorization page or opening it in a popup window.
|
|
100
|
+
* - The flow type is determined by the `openInPage` parameter: if true, the current page is redirected; if false (default), a popup window is used.
|
|
101
|
+
* - 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.
|
|
102
|
+
* - Constructs the Apple OAuth URL with all required parameters, including client ID, redirect URI, response type, response mode, nonce, and state.
|
|
103
|
+
* - The `state` parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic.
|
|
104
|
+
* - If `openInPage` is true, the function redirects and returns a promise that resolves on redirect or times out after 5 minutes.
|
|
105
|
+
* - 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.
|
|
106
|
+
* - On successful authentication, the function either calls the provided `onOauthSuccess` callback, triggers the `onOauthRedirect` callback from provider callbacks, or completes the OAuth flow internally by calling `completeOauth`.
|
|
107
|
+
* - Handles all error cases, including missing configuration, popup failures, and timeouts, and throws a `TurnkeyError` with appropriate error codes.
|
|
108
|
+
*
|
|
109
|
+
* @param params.clientId - The Apple Client ID to use (defaults to the client ID from configuration).
|
|
110
|
+
* @param params.openInPage - Whether to open the OAuth flow in the current page (redirect) or a popup window (default: false).
|
|
111
|
+
* @param params.additionalState - Additional key-value pairs to include in the OAuth state parameter for custom tracking or logic.
|
|
112
|
+
* @param params.onOauthSuccess - Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName }`).
|
|
113
|
+
*
|
|
114
|
+
* onOauthSuccess params:
|
|
115
|
+
* - oidcToken: The OIDC token received from the OAuth flow.
|
|
116
|
+
* - providerName: The name of the OAuth provider ("apple").
|
|
117
|
+
*
|
|
118
|
+
* @returns A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.
|
|
119
|
+
* @throws {TurnkeyError} If the configuration is not ready, required parameters are missing, or if there is an error initiating or completing the OAuth flow.
|
|
120
|
+
*/
|
|
121
|
+
handleAppleOauth(params?: {
|
|
122
|
+
clientId?: string;
|
|
123
|
+
additionalState?: Record<string, string>;
|
|
124
|
+
openInPage?: boolean;
|
|
125
|
+
onOauthSuccess?: (params: {
|
|
126
|
+
oidcToken: string;
|
|
127
|
+
providerName: string;
|
|
128
|
+
}) => any;
|
|
129
|
+
}): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Handles the Facebook OAuth flow.
|
|
132
|
+
*
|
|
133
|
+
* - This function initiates the Facebook OAuth flow by either redirecting the user to the Facebook authorization page or opening it in a popup window.
|
|
134
|
+
* - The flow type is determined by the `openInPage` parameter: if true, the current page is redirected; if false (default), a popup window is used.
|
|
135
|
+
* - 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.
|
|
136
|
+
* - Uses PKCE (Proof Key for Code Exchange) for enhanced security, generating a code verifier and challenge for the Facebook OAuth flow.
|
|
137
|
+
* - Constructs the Facebook OAuth URL with all required parameters, including client ID, redirect URI, response type, code challenge, nonce, and state.
|
|
138
|
+
* - The `state` parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic.
|
|
139
|
+
* - If `openInPage` is true, the function redirects and returns a promise that resolves on redirect or times out after 5 minutes.
|
|
140
|
+
* - 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.
|
|
141
|
+
* - On successful authentication, the function either calls the provided `onOauthSuccess` callback, triggers the `onOauthRedirect` callback from provider callbacks, or completes the OAuth flow internally by calling `completeOauth`.
|
|
142
|
+
* - Handles all error cases, including missing configuration, popup failures, and timeouts, and throws a `TurnkeyError` with appropriate error codes.
|
|
143
|
+
*
|
|
144
|
+
* @param params.clientId - The Facebook Client ID to use (defaults to the client ID from configuration).
|
|
145
|
+
* @param params.openInPage - Whether to open the OAuth flow in the current page (redirect) or a popup window (default: false).
|
|
146
|
+
* @param params.additionalState - Additional key-value pairs to include in the OAuth state parameter for custom tracking or logic.
|
|
147
|
+
* @param params.onOauthSuccess - Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName }`).
|
|
148
|
+
*
|
|
149
|
+
* onOauthSuccess params:
|
|
150
|
+
* - oidcToken: The OIDC token received from the OAuth flow.
|
|
151
|
+
* - providerName: The name of the OAuth provider ("facebook").
|
|
152
|
+
*
|
|
153
|
+
* @returns A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.
|
|
154
|
+
* @throws {TurnkeyError} If the configuration is not ready, required parameters are missing, or if there is an error initiating or completing the OAuth flow.
|
|
155
|
+
*/
|
|
156
|
+
handleFacebookOauth(params?: {
|
|
157
|
+
clientId?: string;
|
|
158
|
+
additionalState?: Record<string, string>;
|
|
159
|
+
openInPage?: boolean;
|
|
160
|
+
onOauthSuccess?: (params: {
|
|
161
|
+
oidcToken: string;
|
|
162
|
+
providerName: string;
|
|
163
|
+
}) => any;
|
|
164
|
+
}): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Handles the export flow.
|
|
167
|
+
*
|
|
168
|
+
* - This function opens a modal with the ExportComponent for exporting a wallet or private key.
|
|
169
|
+
* - Uses Turnkey's export iframe flow to securely export wallet or private key material.
|
|
170
|
+
* - The export process encrypts the exported bundle to a target public key, which is generated and managed inside the iframe for maximum security.
|
|
171
|
+
* - A request is made to the Turnkey API to export the wallet or private key, encrypted to the target public key.
|
|
172
|
+
* - The resulting export bundle is injected into the iframe, where it is decrypted and displayed to the user.
|
|
173
|
+
* - Supports both full wallet exports (ExportType.Wallet) and single private key exports (ExportType.PrivateKey).
|
|
174
|
+
* - If a custom iframe URL is used, a target public key can be provided explicitly.
|
|
175
|
+
* - Optionally allows specifying the stamper to use for the export (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet) for granular authentication control.
|
|
176
|
+
* - The modal-driven UI ensures the user is guided through the export process and can securely retrieve their exported material.
|
|
177
|
+
*
|
|
178
|
+
* @param params.walletId - The ID of the wallet to export.
|
|
179
|
+
* @param params.exportType - The type of export to perform (ExportType.Wallet or ExportType.PrivateKey).
|
|
180
|
+
* @param params.targetPublicKey - The target public key to encrypt the export bundle to (required for custom iframe flows).
|
|
181
|
+
* @param params.stampWith - The stamper to use for the export (Passkey, ApiKey, or Wallet).
|
|
182
|
+
*
|
|
183
|
+
* @returns A void promise.
|
|
184
|
+
*/
|
|
185
|
+
handleExport(params: {
|
|
186
|
+
walletId: string;
|
|
187
|
+
exportType: ExportType;
|
|
188
|
+
targetPublicKey?: string;
|
|
189
|
+
stampWith?: StamperType | undefined;
|
|
190
|
+
}): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* Handles the import flow.
|
|
193
|
+
*
|
|
194
|
+
* - This function opens a modal with the ImportComponent for importing a wallet.
|
|
195
|
+
* - Supports importing wallets using an encrypted bundle, with optional default accounts or custom account parameters.
|
|
196
|
+
* - Allows users to specify default wallet accounts (address formats or account params) to pre-fill the import form.
|
|
197
|
+
* - Supports customizing the duration of the success page shown after a successful import.
|
|
198
|
+
* - Allows specifying the stamper to use for the import (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet) for granular authentication control.
|
|
199
|
+
* - Ensures the imported wallet is added to the user's wallet list and the provider state is refreshed.
|
|
200
|
+
*
|
|
201
|
+
* @param params.defaultWalletAccounts - array of default wallet accounts (v1AddressFormat[] or v1WalletAccountParams[]) to pre-fill the import form.
|
|
202
|
+
* @param params.successPageDuration - duration (in ms) for the success page after import (default: 0, no success page).
|
|
203
|
+
* @param params.stampWith - parameter to specify the stamper to use for the import (Passkey, ApiKey, or Wallet).
|
|
204
|
+
*
|
|
205
|
+
* @returns A promise that resolves to the new wallet's ID.
|
|
206
|
+
*/
|
|
207
|
+
handleImport(params?: {
|
|
208
|
+
defaultWalletAccounts?: v1AddressFormat[] | v1WalletAccountParams[];
|
|
209
|
+
successPageDuration?: number | undefined;
|
|
210
|
+
stampWith?: StamperType | undefined;
|
|
211
|
+
}): Promise<string>;
|
|
212
|
+
/**
|
|
213
|
+
* Handles the update user name flow.
|
|
214
|
+
*
|
|
215
|
+
* - This function opens a modal with the UpdateUserName component for updating and verifying the user's name.
|
|
216
|
+
* - If a userName is provided, it will directly update the user name without showing the modal.
|
|
217
|
+
* - Uses updateUserName under the hood to perform the update and automatically refreshes the user details state after a successful update.
|
|
218
|
+
* - Optionally displays a success page after the update, with customizable duration.
|
|
219
|
+
* - Supports passing a custom title and subtitle for the modal UI.
|
|
220
|
+
* - Handles all error cases and throws a TurnkeyError with appropriate error codes.
|
|
221
|
+
*
|
|
222
|
+
* @param params.userName - parameter to specify the new user name.
|
|
223
|
+
* @param params.title - title for the modal.
|
|
224
|
+
* @param params.subTitle - subtitle for the modal.
|
|
225
|
+
* @param params.successPageDuration - duration (in ms) for the success page after update (default: 0, no success page).
|
|
226
|
+
* @param params.stampWith - parameter to specify the stamper to use for the update (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
227
|
+
*
|
|
228
|
+
* @returns A promise that resolves to the userId of the user that was changed.
|
|
229
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, or if there is an error updating the user name.
|
|
230
|
+
*/
|
|
231
|
+
handleUpdateUserEmail(params?: {
|
|
232
|
+
email?: string;
|
|
233
|
+
title?: string;
|
|
234
|
+
subTitle?: string;
|
|
235
|
+
successPageDuration?: number | undefined;
|
|
236
|
+
}): Promise<string>;
|
|
237
|
+
/**
|
|
238
|
+
* Handles the update user phone number flow.
|
|
239
|
+
*
|
|
240
|
+
* - This function opens a modal with the UpdatePhoneNumber component for updating and verifying the user's phone number.
|
|
241
|
+
* - If a phoneNumber is provided, it will directly send an OTP request to the user and display the OTP verification modal.
|
|
242
|
+
* - Supports both manual entry and pre-filled phone numbers, as well as custom modal titles and subtitles.
|
|
243
|
+
* - Uses the updatePhoneNumberContinue helper to manage the OTP flow, verification, and update logic.
|
|
244
|
+
* - After successful verification and update, the user details state is refreshed and an optional success page can be shown.
|
|
245
|
+
* - Supports customizing the duration of the success page after update.
|
|
246
|
+
* - Throws a TurnkeyError if the client is not initialized, no active session is found, SMS OTP is not enabled, or if there is an error updating the phone number.
|
|
247
|
+
*
|
|
248
|
+
* @param params.phoneNumber - parameter to specify the new phone number.
|
|
249
|
+
* @param params.formattedPhone - parameter to specify the formatted phone number.
|
|
250
|
+
* @param params.title - title for the modal.
|
|
251
|
+
* @param params.subTitle - subtitle for the modal.
|
|
252
|
+
* @param params.successPageDuration - duration for the success page (default: 0, no success page).
|
|
253
|
+
*
|
|
254
|
+
* @returns A promise that resolves to the userId of the user that was changed.
|
|
255
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, SMS OTP is not enabled, or if there is an error updating the phone number.
|
|
256
|
+
*/
|
|
257
|
+
handleUpdateUserPhoneNumber(params?: {
|
|
258
|
+
phoneNumber?: string;
|
|
259
|
+
formattedPhone?: string;
|
|
260
|
+
title?: string;
|
|
261
|
+
subTitle?: string;
|
|
262
|
+
successPageDuration?: number | undefined;
|
|
263
|
+
}): Promise<string>;
|
|
264
|
+
/**
|
|
265
|
+
* Handles the update user email flow.
|
|
266
|
+
*
|
|
267
|
+
* - This function opens a modal with the UpdateEmail component for updating and verifying the user's email address.
|
|
268
|
+
* - If an email is provided, it will immediately send an OTP request to the user and display the OTP verification modal.
|
|
269
|
+
* - Supports both manual entry and pre-filled email addresses, as well as custom modal titles and subtitles.
|
|
270
|
+
* - Uses the updateEmailContinue helper to manage the OTP flow, verification, and update logic.
|
|
271
|
+
* - After successful verification and update, the user details state is refreshed and an optional success page can be shown.
|
|
272
|
+
* - Supports customizing the duration of the success page after update.
|
|
273
|
+
* - Handles all error cases and throws a TurnkeyError with appropriate error codes.
|
|
274
|
+
*
|
|
275
|
+
* @param params.email - parameter to specify the new email address.
|
|
276
|
+
* @param params.title - title for the modal.
|
|
277
|
+
* @param params.subTitle - subtitle for the modal.
|
|
278
|
+
* @param params.successPageDuration - duration (in ms) for the success page after update (default: 0, no success page).
|
|
279
|
+
* @param params.stampWith - parameter to specify the stamper to use for the update (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
280
|
+
*
|
|
281
|
+
* @returns A promise that resolves to the userId of the user that was changed.
|
|
282
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, or if there is an error updating the email.
|
|
283
|
+
*/
|
|
284
|
+
handleUpdateUserName: (params?: {
|
|
285
|
+
userName?: string;
|
|
286
|
+
title?: string;
|
|
287
|
+
subTitle?: string;
|
|
288
|
+
successPageDuration?: number | undefined;
|
|
289
|
+
stampWith?: StamperType | undefined;
|
|
290
|
+
}) => Promise<string>;
|
|
291
|
+
/**
|
|
292
|
+
* Handles the add user email flow.
|
|
293
|
+
*
|
|
294
|
+
* - This function opens a modal with the UpdateEmail component, using a modified title and flow for adding and verifying the user's email address.
|
|
295
|
+
* - If an email is provided, it will immediately send an OTP request to the user and display the OTP verification modal.
|
|
296
|
+
* - Supports both manual entry and pre-filled email addresses, as well as custom modal titles and subtitles.
|
|
297
|
+
* - Uses the addEmailContinue helper to manage the OTP flow, verification, and update logic.
|
|
298
|
+
* - After successful verification and update, the user details state is refreshed and an optional success page can be shown.
|
|
299
|
+
* - Supports customizing the duration of the success page after update.
|
|
300
|
+
* - Handles all error cases and throws a TurnkeyError with appropriate error codes.
|
|
301
|
+
*
|
|
302
|
+
* @param params.email - parameter to specify the new email address.
|
|
303
|
+
* @param params.title - title for the modal (defaults to "Connect an email" if the user does not have an email).
|
|
304
|
+
* @param params.subTitle - subtitle for the modal.
|
|
305
|
+
* @param params.successPageDuration - duration (in ms) for the success page after update (default: 0, no success page).
|
|
306
|
+
*
|
|
307
|
+
* @returns A promise that resolves to the userId of the user that was changed.
|
|
308
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, or if there is an error adding the email.
|
|
309
|
+
*/
|
|
310
|
+
handleAddEmail: (params?: {
|
|
311
|
+
email?: string;
|
|
312
|
+
title?: string;
|
|
313
|
+
subTitle?: string;
|
|
314
|
+
successPageDuration?: number | undefined;
|
|
315
|
+
}) => Promise<string>;
|
|
316
|
+
/**
|
|
317
|
+
* Handles the add phone number flow.
|
|
318
|
+
*
|
|
319
|
+
* - This function opens a modal with the UpdatePhoneNumber component for adding and verifying the user's phone number.
|
|
320
|
+
* - If a phone number is provided, it will immediately send an OTP request to the user and display the OTP verification modal.
|
|
321
|
+
* - Supports both manual entry and pre-filled phone numbers, as well as custom modal titles and subtitles.
|
|
322
|
+
* - Uses the addPhoneNumberContinue helper to manage the OTP flow, verification, and update logic.
|
|
323
|
+
* - After successful verification and update, the user details state is refreshed and an optional success page can be shown.
|
|
324
|
+
* - Supports customizing the duration of the success page after update.
|
|
325
|
+
* - Handles all error cases and throws a TurnkeyError with appropriate error codes.
|
|
326
|
+
*
|
|
327
|
+
* @param params.phoneNumber - parameter to specify the new phone number.
|
|
328
|
+
* @param params.formattedPhone - parameter to specify the formatted phone number.
|
|
329
|
+
* @param params.title - title for the modal.
|
|
330
|
+
* @param params.subTitle - subtitle for the modal.
|
|
331
|
+
* @param params.successPageDuration - duration (in ms) for the success page after update (default: 0, no success page).
|
|
332
|
+
*
|
|
333
|
+
* @returns A promise that resolves to the userId of the user that was changed.
|
|
334
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, or if there is an error adding the phone number.
|
|
335
|
+
*/
|
|
336
|
+
handleAddPhoneNumber(params?: {
|
|
337
|
+
phoneNumber?: string;
|
|
338
|
+
formattedPhone?: string;
|
|
339
|
+
title?: string;
|
|
340
|
+
subTitle?: string;
|
|
341
|
+
successPageDuration?: number | undefined;
|
|
342
|
+
}): Promise<string>;
|
|
343
|
+
/**
|
|
344
|
+
* Handles the addition of an OAuth provider for the user.
|
|
345
|
+
*
|
|
346
|
+
* - This function opens a modal-driven flow for linking a new OAuth provider (Google, Apple, or Facebook) to the user's account.
|
|
347
|
+
* - It supports all enabled OAuth providers as defined in the configuration and dynamically triggers the appropriate OAuth flow.
|
|
348
|
+
* - Uses the handleGoogleOauth, handleAppleOauth, and handleFacebookOauth functions to initiate the provider-specific OAuth authentication process.
|
|
349
|
+
* - After successful authentication, the provider is linked to the user's account and a success page is shown.
|
|
350
|
+
* - Automatically refreshes the user details state after linking to ensure the latest provider list is available in the provider.
|
|
351
|
+
* - Optionally allows specifying the stamper to use for the addition (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet) for granular authentication control.
|
|
352
|
+
* - Handles all error cases and throws a TurnkeyError with appropriate error codes.
|
|
353
|
+
*
|
|
354
|
+
* @param params.providerName - The name of the OAuth provider to add (OAuthProviders.GOOGLE, OAuthProviders.APPLE, OAuthProviders.FACEBOOK).
|
|
355
|
+
* @param params.stampWith - parameter to specify the stamper to use for the addition (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
356
|
+
*
|
|
357
|
+
* @returns A void promise.
|
|
358
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, or if there is an error adding the provider.
|
|
359
|
+
*/
|
|
360
|
+
handleAddOauthProvider(params: {
|
|
361
|
+
providerName: OAuthProviders;
|
|
362
|
+
stampWith?: StamperType | undefined;
|
|
363
|
+
}): Promise<void>;
|
|
364
|
+
/**
|
|
365
|
+
* Handles the removal of an OAuth provider.
|
|
366
|
+
*
|
|
367
|
+
* - This function opens a modal with the RemoveOAuthProvider component, allowing the user to confirm and remove an OAuth provider (such as Google, Apple, or Facebook) from their account.
|
|
368
|
+
* - It supports specifying the provider ID to remove, as well as optional modal title and subtitle for custom UI messaging.
|
|
369
|
+
* - After successful removal, the user details state is refreshed to reflect the updated list of linked OAuth providers.
|
|
370
|
+
* - Optionally, a callback can be provided to handle successful removal, receiving the updated list of provider IDs.
|
|
371
|
+
* - Supports customizing the duration of the success page shown after removal.
|
|
372
|
+
* - Allows specifying the stamper to use for the removal (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet) for granular authentication control.
|
|
373
|
+
* - Handles all error cases and throws a TurnkeyError with appropriate error codes.
|
|
374
|
+
*
|
|
375
|
+
* @param params.providerId - The ID of the OAuth provider to remove (as found in the user's provider list).
|
|
376
|
+
* @param params.title - title for the modal.
|
|
377
|
+
* @param params.subTitle - subtitle for the modal.
|
|
378
|
+
* @param params.successPageDuration - duration (in ms) for the success page after removal (default: 0, no success page).
|
|
379
|
+
* @param params.stampWith - parameter to specify the stamper to use for the removal (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
380
|
+
*
|
|
381
|
+
* @returns A promise that resolves to an array of provider IDs that were removed.
|
|
382
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, or if there is an error removing the provider.
|
|
383
|
+
*/
|
|
384
|
+
handleRemoveOauthProvider(params: {
|
|
385
|
+
providerId: string;
|
|
386
|
+
title?: string;
|
|
387
|
+
subTitle?: string;
|
|
388
|
+
successPageDuration?: number | undefined;
|
|
389
|
+
stampWith?: StamperType | undefined;
|
|
390
|
+
}): Promise<string[]>;
|
|
391
|
+
/**
|
|
392
|
+
* Handles the addition of a passkey (authenticator) for the user.
|
|
393
|
+
*
|
|
394
|
+
* - This function opens a modal-driven flow for adding a new passkey authenticator (WebAuthn/FIDO2) to the user's account.
|
|
395
|
+
* - If a `name` or `displayName` is provided, those will be used for the passkey metadata; otherwise, defaults are generated based on the website and timestamp.
|
|
396
|
+
* - The passkey is created and linked to the specified user (by `userId`) or the current session's user if not provided.
|
|
397
|
+
* - After successful addition, a success page is shown for the specified duration (or skipped if `successPageDuration` is 0).
|
|
398
|
+
* - Supports stamping the request with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`) for granular authentication control.
|
|
399
|
+
* - Automatically refreshes the user details state after successful addition to ensure the latest authenticators list is available in the provider.
|
|
400
|
+
* - Handles all error cases and throws a `TurnkeyError` with appropriate error codes.
|
|
401
|
+
*
|
|
402
|
+
* @param params.name - internal name for the passkey (for backend or developer reference).
|
|
403
|
+
* @param params.displayName - display name for the passkey (shown to the user in the UI).
|
|
404
|
+
* @param params.userId - user ID to add the passkey for a specific user (defaults to current session's userId).
|
|
405
|
+
* @param params.successPageDuration - duration (in ms) for the success page after addition (default: 0, no success page).
|
|
406
|
+
* @param params.stampWith - parameter to stamp the request with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
|
|
407
|
+
*
|
|
408
|
+
* @returns A promise that resolves to the user's updated passkeys.
|
|
409
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, or if there is an error adding the passkey.
|
|
410
|
+
*/
|
|
411
|
+
handleAddPasskey(params?: {
|
|
412
|
+
name?: string;
|
|
413
|
+
displayName?: string;
|
|
414
|
+
userId?: string;
|
|
415
|
+
successPageDuration?: number | undefined;
|
|
416
|
+
stampWith?: StamperType | undefined;
|
|
417
|
+
}): Promise<string[]>;
|
|
418
|
+
/**
|
|
419
|
+
* Handles the removal of a passkey (authenticator) for the user.
|
|
420
|
+
*
|
|
421
|
+
* - This function opens a modal with the RemovePasskey component, allowing the user to confirm and remove a passkey authenticator from their account.
|
|
422
|
+
* - It supports specifying the authenticator ID to remove, as well as optional modal title and subtitle for custom UI messaging.
|
|
423
|
+
* - After successful removal, the user details state is refreshed to reflect the updated list of authenticators.
|
|
424
|
+
* - Supports customizing the duration of the success page shown after removal.
|
|
425
|
+
* - Allows specifying the stamper to use for the removal (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet) for granular authentication control.
|
|
426
|
+
* - Handles all error cases and throws a TurnkeyError with appropriate error codes.
|
|
427
|
+
*
|
|
428
|
+
* @param params.authenticatorId - The ID of the authenticator (passkey) to remove.
|
|
429
|
+
* @param params.userId - user ID to remove the passkey for a specific user (defaults to current session's userId).
|
|
430
|
+
* @param params.title - title for the modal.
|
|
431
|
+
* @param params.subTitle - subtitle for the modal.
|
|
432
|
+
* @param params.successPageDuration - duration (in ms) for the success page after removal (default: 0, no success page).
|
|
433
|
+
* @param params.stampWith - parameter to specify the stamper to use for the removal (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
434
|
+
*
|
|
435
|
+
* @returns A promise that resolves to an array of authenticator IDs that were removed.
|
|
436
|
+
* @throws {TurnkeyError} If the client is not initialized, no active session is found, or if there is an error removing the passkey.
|
|
437
|
+
*/
|
|
438
|
+
handleRemovePasskey(params: {
|
|
439
|
+
authenticatorId: string;
|
|
440
|
+
userId?: string;
|
|
441
|
+
title?: string;
|
|
442
|
+
subTitle?: string;
|
|
443
|
+
successPageDuration?: number | undefined;
|
|
444
|
+
stampWith?: StamperType | undefined;
|
|
445
|
+
}): Promise<string[]>;
|
|
446
|
+
/**
|
|
447
|
+
* Handles the signing of a message by displaying a modal for user interaction.
|
|
448
|
+
*
|
|
449
|
+
* - This function opens a modal with the SignMessageModal component, prompting the user to review and approve the message signing request.
|
|
450
|
+
* - Supports signing with any wallet account managed by Turnkey, including externally linked wallets.
|
|
451
|
+
* - Allows for optional overrides of the encoding and hash function used for the payload, enabling advanced use cases or compatibility with specific blockchains.
|
|
452
|
+
* - Optionally displays a subtext in the modal for additional context or instructions to the user.
|
|
453
|
+
* - Returns a promise that resolves to a `v1SignRawPayloadResult` object containing the signed message, signature, and metadata.
|
|
454
|
+
*
|
|
455
|
+
* @param params.message - The message to sign.
|
|
456
|
+
* @param params.walletAccount - The wallet account to use for signing.
|
|
457
|
+
* @param params.encoding - encoding for the payload (defaults to the proper encoding for the account type).
|
|
458
|
+
* @param params.hashFunction - hash function to use (defaults to the appropriate function for the account type).
|
|
459
|
+
* @param params.addEthereumPrefix - whether to add the Ethereum prefix to the message (default: false).
|
|
460
|
+
* @param params.subText - subtext to display in the modal.
|
|
461
|
+
* @param params.successPageDuration - duration in seconds to display the success page after signing.
|
|
462
|
+
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
463
|
+
* @returns A promise that resolves to a `v1SignRawPayloadResult` object containing the signed message.
|
|
464
|
+
* @throws {TurnkeyError} If the client is not initialized or if there is an error during the signing process.
|
|
465
|
+
*/
|
|
466
|
+
handleSignMessage(params: {
|
|
467
|
+
message: string;
|
|
468
|
+
walletAccount: WalletAccount;
|
|
469
|
+
encoding?: v1PayloadEncoding;
|
|
470
|
+
hashFunction?: v1HashFunction;
|
|
471
|
+
addEthereumPrefix?: boolean;
|
|
472
|
+
subText?: string;
|
|
473
|
+
successPageDuration?: number | undefined;
|
|
474
|
+
stampWith?: StamperType | undefined;
|
|
475
|
+
}): Promise<v1SignRawPayloadResult>;
|
|
476
|
+
/**
|
|
477
|
+
* Handles the linking of an external wallet account to the user's Turnkey account.
|
|
478
|
+
*
|
|
479
|
+
* - This function opens a modal with the LinkWalletModal component, allowing the user to select and connect an external wallet provider (such as MetaMask, Phantom, etc.).
|
|
480
|
+
* - It fetches the list of available wallet providers (for all supported chains) and passes them to the modal for user selection.
|
|
481
|
+
* - After a successful wallet connection, the provider state is refreshed to include the newly linked wallet account.
|
|
482
|
+
* - Optionally, a success page is shown for the specified duration after linking (default: 2000ms).
|
|
483
|
+
* - Supports both Ethereum and Solana wallet providers, and can be extended to additional chains as supported by Turnkey.
|
|
484
|
+
* - Handles all error cases and throws a TurnkeyError with appropriate error codes if the client is not initialized or no active session is found.
|
|
485
|
+
*
|
|
486
|
+
* @param params.successPageDuration - duration (in ms) for the success page after linking (default: 2000ms).
|
|
487
|
+
*
|
|
488
|
+
* @returns A void promise.
|
|
489
|
+
* @throws {TurnkeyError} If the client is not initialized or if no active session is found.
|
|
490
|
+
*/
|
|
491
|
+
handleLinkExternalWallet(params?: {
|
|
492
|
+
successPageDuration?: number | undefined;
|
|
493
|
+
}): Promise<void>;
|
|
494
|
+
/**
|
|
495
|
+
* Handles the removal of a user's email address from their Turnkey account.
|
|
496
|
+
*
|
|
497
|
+
* - This function opens a modal with the RemoveUserEmail component, allowing the user to confirm and remove their email address.
|
|
498
|
+
*
|
|
499
|
+
* @param params.userId - The user ID to remove the email for (defaults to current session's userId).
|
|
500
|
+
* @param params.successPageDuration - duration (in ms) for the success page after removal (default: 0, no success page).
|
|
501
|
+
* @param params.stampWith - parameter to specify the stamper to use for the removal (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
502
|
+
*/
|
|
503
|
+
handleRemoveUserEmail(params?: {
|
|
504
|
+
userId?: string;
|
|
505
|
+
successPageDuration?: number | undefined;
|
|
506
|
+
stampWith?: StamperType | undefined;
|
|
507
|
+
}): Promise<string>;
|
|
508
|
+
/**
|
|
509
|
+
* Handles the removal of a user's phone number from their Turnkey account.
|
|
510
|
+
*
|
|
511
|
+
* - This function opens a modal with the RemoveUserPhoneNumber component, allowing the user to confirm and remove their phone number.
|
|
512
|
+
*
|
|
513
|
+
* @param params.userId - The user ID to remove the phone number for (defaults to current session's userId).
|
|
514
|
+
* @param params.successPageDuration - duration (in ms) for the success page after removal (default: 0, no success page).
|
|
515
|
+
* @param params.stampWith - parameter to specify the stamper to use for the removal (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
516
|
+
*/
|
|
517
|
+
handleRemoveUserPhoneNumber(params?: {
|
|
518
|
+
userId?: string;
|
|
519
|
+
successPageDuration?: number | undefined;
|
|
520
|
+
stampWith?: StamperType | undefined;
|
|
521
|
+
}): Promise<string>;
|
|
522
|
+
}
|
|
523
|
+
export declare const ClientContext: import("react").Context<ClientContextType | undefined>;
|
|
524
|
+
//# sourceMappingURL=Types.d.ts.map
|
|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,CAAC,IAAI,CAAC,CAAC;IAElB;;;;;;;;OAQG;IACH,qBAAqB,CAAC,MAAM,CAAC,EAAE;QAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACzC,SAAS,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;KACrC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB;;;;;;;;OAQG;IACH,2BAA2B,CAAC,MAAM,CAAC,EAAE;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACzC,SAAS,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;KACrC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,wDAEzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.js","sources":["../../../src/providers/client/Types.tsx"],"sourcesContent":[null],"names":["ClientContext","createContext","undefined"],"mappings":";;;;;MAikBaA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAGC,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACxCC,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.mjs","sources":["../../../src/providers/client/Types.tsx"],"sourcesContent":[null],"names":["ClientContext","createContext","undefined"],"mappings":";;;IAikBaA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAGC,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACxCC,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hook.d.ts","sourceRoot":"","sources":["../../../src/providers/modal/Hook.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,QAAQ,QAAO,gBAI3B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var Provider = require('./Provider.js');
|
|
6
|
+
|
|
7
|
+
const useModal = () => {
|
|
8
|
+
const context = react.useContext(Provider.ModalContext);
|
|
9
|
+
if (!context) throw new Error("useModal must be used within ModalProvider");
|
|
10
|
+
return context;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.useModal = useModal;
|
|
14
|
+
//# sourceMappingURL=Hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hook.js","sources":["../../../src/providers/modal/Hook.tsx"],"sourcesContent":[null],"names":["useModal","context","useContext","ModalContext","Error"],"mappings":";;;;;;AAKaA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAQ,GAAGA,CAAuB,CAAA,CAAA,CAAA,CAAA,CAAA;AAC7C,CAAA,CAAA,MAAMC,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAGC,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAACC,qBAAY,CAAC;CACxC,CAAA,CAAA,CAAA,CAAA,CAAI,CAACF,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,MAAM,CAAIG,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA4C,CAAC;AAC3E,CAAA,CAAA,OAAOH,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAChB,CAAA;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { ModalContext } from './Provider.mjs';
|
|
4
|
+
|
|
5
|
+
var useModal = function useModal() {
|
|
6
|
+
var context = useContext(ModalContext);
|
|
7
|
+
if (!context) throw new Error("useModal must be used within ModalProvider");
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useModal };
|
|
12
|
+
//# sourceMappingURL=Hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hook.mjs","sources":["../../../src/providers/modal/Hook.tsx"],"sourcesContent":[null],"names":["useModal","context","useContext","ModalContext","Error"],"mappings":";;;;IAKaA,CAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAXA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAQA,CAA0B,CAAA,CAAA;AAC7C,CAAA,CAAA,IAAMC,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAGC,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAACC,YAAY,CAAC;CACxC,CAAA,CAAA,CAAA,CAAA,CAAI,CAACF,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,MAAM,CAAIG,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA4C,CAAC;AAC3E,CAAA,CAAA,OAAOH,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAChB,CAAA;;"}
|