@0xkey-io/react-native-wallet-kit 0.1.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 +93 -0
- package/dist/hooks/use-0xkey.d.ts +3 -0
- package/dist/hooks/use-0xkey.d.ts.map +1 -0
- package/dist/hooks/use-0xkey.js +15 -0
- package/dist/hooks/use-0xkey.js.map +1 -0
- package/dist/hooks/use-0xkey.mjs +13 -0
- package/dist/hooks/use-0xkey.mjs.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/dist/providers/Types.d.ts +275 -0
- package/dist/providers/Types.d.ts.map +1 -0
- package/dist/providers/Types.js +9 -0
- package/dist/providers/Types.js.map +1 -0
- package/dist/providers/Types.mjs +7 -0
- package/dist/providers/Types.mjs.map +1 -0
- package/dist/providers/ZeroXKeyProvider.d.ts +39 -0
- package/dist/providers/ZeroXKeyProvider.d.ts.map +1 -0
- package/dist/providers/ZeroXKeyProvider.js +1846 -0
- package/dist/providers/ZeroXKeyProvider.js.map +1 -0
- package/dist/providers/ZeroXKeyProvider.mjs +1844 -0
- package/dist/providers/ZeroXKeyProvider.mjs.map +1 -0
- package/dist/providers/index.d.ts +4 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/tests/oauth-test.d.ts +2 -0
- package/dist/tests/oauth-test.d.ts.map +1 -0
- package/dist/typedoc-entry/index.d.ts +5 -0
- package/dist/typedoc-entry/index.d.ts.map +1 -0
- package/dist/types/base.d.ts +137 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/types/base.js +48 -0
- package/dist/types/base.js.map +1 -0
- package/dist/types/base.mjs +48 -0
- package/dist/types/base.mjs.map +1 -0
- package/dist/types/method-types.d.ts +102 -0
- package/dist/types/method-types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/oauth.d.ts +240 -0
- package/dist/utils/oauth.d.ts.map +1 -0
- package/dist/utils/oauth.js +340 -0
- package/dist/utils/oauth.js.map +1 -0
- package/dist/utils/oauth.mjs +319 -0
- package/dist/utils/oauth.mjs.map +1 -0
- package/dist/utils/timers.d.ts +73 -0
- package/dist/utils/timers.d.ts.map +1 -0
- package/dist/utils/timers.js +132 -0
- package/dist/utils/timers.js.map +1 -0
- package/dist/utils/timers.mjs +122 -0
- package/dist/utils/timers.mjs.map +1 -0
- package/dist/utils/utils.d.ts +27 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +37 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist/utils/utils.mjs +33 -0
- package/dist/utils/utils.mjs.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ZeroXKeySDKClientBase, ZeroXKeyClientMethods, Wallet, StamperType, ExportBundle } from "@0xkey-io/core";
|
|
3
|
+
import type { Session, v1User } from "@0xkey-io/sdk-types";
|
|
4
|
+
import type { ZeroXKeyProviderConfig, AuthState, ClientState } from "../types/base";
|
|
5
|
+
import type { ExportWalletParams, ExportPrivateKeyParams, ExportWalletAccountParams, ImportWalletParams, ImportPrivateKeyParams, HandleDiscordOauthParams, HandleXOauthParams, HandleGoogleOauthParams, HandleAppleOauthParams, HandleFacebookOauthParams } from "../types/method-types";
|
|
6
|
+
export interface ClientContextType extends Omit<ZeroXKeyClientMethods, "connectWalletAccount" | "fetchWalletProviders" | "disconnectWalletAccount" | "switchWalletAccountChain" | "loginWithWallet" | "signUpWithWallet" | "loginOrSignupWithWallet" | "exportWallet" | "exportPrivateKey" | "exportWalletAccount" | "importWallet" | "importPrivateKey" | "buildWalletLoginRequest"> {
|
|
7
|
+
/** @internal */
|
|
8
|
+
httpClient: ZeroXKeySDKClientBase | undefined;
|
|
9
|
+
/** @internal */
|
|
10
|
+
session: Session | undefined;
|
|
11
|
+
/** @internal */
|
|
12
|
+
allSessions?: Record<string, Session> | undefined;
|
|
13
|
+
/** @internal */
|
|
14
|
+
clientState: ClientState | undefined;
|
|
15
|
+
/** @internal */
|
|
16
|
+
authState: AuthState;
|
|
17
|
+
/** @internal */
|
|
18
|
+
config?: ZeroXKeyProviderConfig | undefined;
|
|
19
|
+
/** @internal */
|
|
20
|
+
user: v1User | undefined;
|
|
21
|
+
/** @internal */
|
|
22
|
+
wallets: Wallet[];
|
|
23
|
+
/**
|
|
24
|
+
* Export a wallet. Optionally decrypt and return the mnemonic directly.
|
|
25
|
+
*
|
|
26
|
+
* - By default, this function DECRYPTS and returns the mnemonic for convenience.
|
|
27
|
+
* - If `decrypt` is set to false, it returns the encrypted export bundle string instead.
|
|
28
|
+
* - When decrypting, this function generates a P-256 keypair internally,
|
|
29
|
+
* exports the wallet encrypted to the generated public key, then decrypts the bundle
|
|
30
|
+
* using the generated private key and returns the mnemonic string.
|
|
31
|
+
* - When `decrypt` is true, the provided `targetPublicKey` (if any) is ignored.
|
|
32
|
+
*
|
|
33
|
+
* @param params.walletId - The wallet ID to export.
|
|
34
|
+
* @param params.targetPublicKey - Optional; used only when `decrypt` is not set.
|
|
35
|
+
* @param params.organizationId - Optional organization ID override.
|
|
36
|
+
* @param params.stampWith - Optional stamper override.
|
|
37
|
+
* @param params.decrypt - Defaults to true. Set to false to receive the encrypted bundle.
|
|
38
|
+
*/
|
|
39
|
+
exportWallet(params: ExportWalletParams): Promise<ExportBundle>;
|
|
40
|
+
/**
|
|
41
|
+
* Export a private key. Optionally decrypt and return the raw private key.
|
|
42
|
+
*
|
|
43
|
+
* - By default, this function DECRYPTS and returns the raw private key (hex for EVM, base58 for Solana when `keyFormat` is "SOLANA").
|
|
44
|
+
* - If `decrypt` is false, the provider returns the encrypted export bundle string.
|
|
45
|
+
* - When decrypting, the provider generates a P-256 keypair, exports to the generated public key,
|
|
46
|
+
* decrypts locally, and returns the raw private key (hex for EVM, or base58 for Solana when `keyFormat` is "SOLANA").
|
|
47
|
+
*
|
|
48
|
+
* @param params.privateKeyId - The private key ID to export.
|
|
49
|
+
* @param params.targetPublicKey - Optional; used only when `decrypt` is not set.
|
|
50
|
+
* @param params.organizationId - Optional organization ID override.
|
|
51
|
+
* @param params.stampWith - Optional stamper override.
|
|
52
|
+
* @param params.decrypt - Defaults to true. Set to false to receive the encrypted bundle.
|
|
53
|
+
* @returns Raw private key (default) or encrypted bundle (when decrypt is false).
|
|
54
|
+
*/
|
|
55
|
+
exportPrivateKey(params: ExportPrivateKeyParams): Promise<ExportBundle>;
|
|
56
|
+
/**
|
|
57
|
+
* Export a wallet account. Optionally decrypt and return the raw private key.
|
|
58
|
+
*
|
|
59
|
+
* - By default, this function DECRYPTS and returns the raw private key (hex for EVM, base58 for Solana when `keyFormat` is "SOLANA").
|
|
60
|
+
* - If `decrypt` is false, the provider returns the encrypted export bundle string.
|
|
61
|
+
* - When decrypting, the provider generates a P-256 keypair, exports to the generated public key,
|
|
62
|
+
* decrypts locally, and returns the raw private key (hex for EVM, or base58 for Solana when `keyFormat` is "SOLANA").
|
|
63
|
+
*
|
|
64
|
+
* @param params.address - The account address to export.
|
|
65
|
+
* @param params.targetPublicKey - Optional; used only when `decrypt` is not set.
|
|
66
|
+
* @param params.organizationId - Optional organization ID override.
|
|
67
|
+
* @param params.stampWith - Optional stamper override.
|
|
68
|
+
* @param params.decrypt - Defaults to true. Set to false to receive the encrypted bundle.
|
|
69
|
+
* @returns Raw private key (default) or encrypted bundle (when decrypt is false).
|
|
70
|
+
*/
|
|
71
|
+
exportWalletAccount(params: ExportWalletAccountParams): Promise<ExportBundle>;
|
|
72
|
+
/**
|
|
73
|
+
* Import a wallet using a mnemonic.
|
|
74
|
+
*
|
|
75
|
+
* - The provider internally calls `initImportWallet` to retrieve an import bundle.
|
|
76
|
+
* - It encrypts the provided `mnemonic` to that bundle using HPKE and calls `client.importWallet`.
|
|
77
|
+
* - Optionally accepts `accounts` to pre-create wallet accounts; otherwise defaults may apply.
|
|
78
|
+
*
|
|
79
|
+
* @param params.mnemonic - Mnemonic phrase to import.
|
|
80
|
+
* @param params.walletName - Name for the new wallet.
|
|
81
|
+
* @param params.accounts - Optional accounts to pre-create.
|
|
82
|
+
* @param params.organizationId - Optional organization ID.
|
|
83
|
+
* @param params.userId - Optional user ID.
|
|
84
|
+
* @param params.stampWith - Optional stamper override.
|
|
85
|
+
* @returns The new wallet ID.
|
|
86
|
+
*/
|
|
87
|
+
importWallet(params: ImportWalletParams): Promise<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Import a private key by encrypting it to an import bundle internally.
|
|
90
|
+
*
|
|
91
|
+
* - The provider internally calls `initImportPrivateKey` to retrieve an import bundle.
|
|
92
|
+
* - It encrypts the provided `privateKey` to that bundle using HPKE and calls `client.importPrivateKey`.
|
|
93
|
+
* - `addressFormats` is required and determines the curve by default; `curve` can be provided to override.
|
|
94
|
+
*
|
|
95
|
+
* @param params.privateKey - The private key material to import (hex for EVM; base58 for Solana when `keyFormat` is "SOLANA").
|
|
96
|
+
* @param params.privateKeyName - A display name for the imported key.
|
|
97
|
+
* @param params.addressFormats - Address formats to derive and register.
|
|
98
|
+
* @param params.curve - Optional curve override.
|
|
99
|
+
* @param params.keyFormat - Optional source key encoding (default "HEXADECIMAL").
|
|
100
|
+
* @param params.organizationId - Optional organization ID.
|
|
101
|
+
* @param params.userId - Optional user ID.
|
|
102
|
+
* @param params.stampWith - Optional stamper override.
|
|
103
|
+
* @returns The new private key ID.
|
|
104
|
+
*/
|
|
105
|
+
importPrivateKey(params: ImportPrivateKeyParams): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Refreshes the user details.
|
|
108
|
+
*
|
|
109
|
+
* - This function fetches the latest user details for the current session (or optionally for a specific user/organization if provided)
|
|
110
|
+
* and updates the `user` state variable in the provider.
|
|
111
|
+
* - If a `stampWith` parameter is provided, it will use that stamper to fetch the user details (supports Passkey, ApiKey, or Wallet stampers).
|
|
112
|
+
* - Automatically handles error reporting via the configured callbacks.
|
|
113
|
+
* - Typically used after authentication, user profile updates, or linking/unlinking authenticators to ensure the provider state is up to date.
|
|
114
|
+
* - If no user is found, the state will not be updated.
|
|
115
|
+
*
|
|
116
|
+
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
117
|
+
* @returns A promise that resolves when the user details are successfully refreshed and state is updated.
|
|
118
|
+
* @throws {ZeroXKeyError} If the client is not initialized or if there is an error refreshing the user details.
|
|
119
|
+
*/
|
|
120
|
+
refreshUser: (params?: {
|
|
121
|
+
stampWith?: StamperType | undefined;
|
|
122
|
+
}) => Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Refreshes the wallets state for the current user session.
|
|
125
|
+
*
|
|
126
|
+
* - This function fetches the latest list of wallets associated with the current session or user,
|
|
127
|
+
* and updates the `wallets` state variable in the provider.
|
|
128
|
+
* - If a `stampWith` parameter is provided, it will use that stamper to fetch the wallets
|
|
129
|
+
* (supports Passkey, ApiKey, or Wallet stampers for granular authentication control).
|
|
130
|
+
* - Automatically handles error reporting via the configured callbacks.
|
|
131
|
+
* - Typically used after wallet creation, import, export, account changes, or authentication
|
|
132
|
+
* to ensure the provider state is up to date.
|
|
133
|
+
* - If no wallets are found, the state will be set to an empty array.
|
|
134
|
+
*
|
|
135
|
+
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
136
|
+
* @returns A promise that resolves when the wallets are successfully refreshed and state is updated.
|
|
137
|
+
* @throws {ZeroXKeyError} If the client is not initialized or if there is an error refreshing the wallets.
|
|
138
|
+
*/
|
|
139
|
+
refreshWallets: (params?: {
|
|
140
|
+
stampWith?: StamperType | undefined;
|
|
141
|
+
}) => Promise<Wallet[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Handles the Discord OAuth 2.0 flow.
|
|
144
|
+
*
|
|
145
|
+
* - This function initiates the OAuth 2.0 PKCE flow with Discord by opening the in-app browser and deep-linking back to the app.
|
|
146
|
+
* - On React Native, the flow always uses the in-app browser.
|
|
147
|
+
* - Generates a new ephemeral API key pair and uses its public key as part of the state and a cryptographic nonce to bind the OAuth session.
|
|
148
|
+
* - Creates a PKCE verifier/challenge pair, storing the verifier in `AsyncStorage` for later use in the token exchange.
|
|
149
|
+
* - Constructs the Discord OAuth URL with all required parameters, including client ID, redirect URI, response type, scope, PKCE code challenge, nonce, and state.
|
|
150
|
+
* - The `state` parameter encodes the provider name, flow type, ephemeral public key, and any additional key-value pairs provided in `additionalState`.
|
|
151
|
+
* - The flow resolves when the app is deep-linked back; it rejects if the in-app browser is closed or times out.
|
|
152
|
+
* - On receiving an authorization code, the function exchanges it for an OIDC token via the ZeroXKey proxy (`proxyOAuth2Authenticate`) using the PKCE verifier, redirect URI, and nonce.
|
|
153
|
+
* - 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`.
|
|
154
|
+
* - Handles error cases such as missing configuration, in-app browser failures, missing PKCE verifier, or ZeroXKey proxy failures, throwing a `ZeroXKeyError` with appropriate error codes.
|
|
155
|
+
*
|
|
156
|
+
* @param params.clientId - The Discord Client ID to use (defaults to the client ID from configuration).
|
|
157
|
+
* @param params.additionalState - Additional key-value pairs to include in the OAuth state parameter for tracking or custom logic.
|
|
158
|
+
* @param params.onOauthSuccess - Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName, publicKey }`).
|
|
159
|
+
*
|
|
160
|
+
* onOauthSuccess params:
|
|
161
|
+
* - oidcToken: The OIDC token issued by ZeroXKey after exchanging the auth code.
|
|
162
|
+
* - providerName: The name of the OAuth provider ("discord").
|
|
163
|
+
* - publicKey: The public key used for the OAuth flow.
|
|
164
|
+
*
|
|
165
|
+
* @returns A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.
|
|
166
|
+
* @throws {ZeroXKeyError} If the configuration is not ready, required parameters are missing, or if there is an error initiating or completing the OAuth flow.
|
|
167
|
+
*/
|
|
168
|
+
handleDiscordOauth: (params?: HandleDiscordOauthParams) => Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Handles the Twitter (X) OAuth 2.0 flow.
|
|
171
|
+
*
|
|
172
|
+
* - This function initiates the OAuth 2.0 PKCE flow with Twitter (X) by opening the in-app browser and deep-linking back to the app.
|
|
173
|
+
* - On React Native, the flow always uses the in-app browser.
|
|
174
|
+
* - Generates a new ephemeral API key pair and uses its public key as part of the state and a cryptographic nonce to bind the OAuth session.
|
|
175
|
+
* - Creates a PKCE verifier/challenge pair, storing the verifier in `AsyncStorage` for later use in the token exchange.
|
|
176
|
+
* - Constructs the Twitter (X) OAuth URL with all required parameters, including client ID, redirect URI, response type, scope, PKCE code challenge, nonce, and state.
|
|
177
|
+
* - The `state` parameter encodes the provider name, flow type, ephemeral public key, and any additional key-value pairs provided in `additionalState`.
|
|
178
|
+
* - The flow resolves when the app is deep-linked back; it rejects if the in-app browser is closed or times out.
|
|
179
|
+
* - On receiving an authorization code, the function exchanges it for an OIDC token via the ZeroXKey proxy (`proxyOAuth2Authenticate`) using the PKCE verifier, redirect URI, and nonce.
|
|
180
|
+
* - 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`.
|
|
181
|
+
* - Handles error cases such as missing configuration, in-app browser failures, missing PKCE verifier, or ZeroXKey proxy failures, throwing a `ZeroXKeyError` with appropriate error codes.
|
|
182
|
+
*
|
|
183
|
+
* @param params.clientId - The Twitter (X) Client ID to use (defaults to the client ID from configuration).
|
|
184
|
+
* @param params.additionalState - Additional key-value pairs to include in the OAuth state parameter for tracking or custom logic.
|
|
185
|
+
* @param params.onOauthSuccess - Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName, publicKey }`).
|
|
186
|
+
*
|
|
187
|
+
* onOauthSuccess params:
|
|
188
|
+
* - oidcToken: The OIDC token issued by ZeroXKey after exchanging the auth code.
|
|
189
|
+
* - providerName: The name of the OAuth provider ("twitter").
|
|
190
|
+
* - publicKey: The public key used for the OAuth flow.
|
|
191
|
+
*
|
|
192
|
+
* @returns A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.
|
|
193
|
+
* @throws {ZeroXKeyError} If the configuration is not ready, required parameters are missing, or if there is an error initiating or completing the OAuth flow.
|
|
194
|
+
*/
|
|
195
|
+
handleXOauth: (params?: HandleXOauthParams) => Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Handles the Google OAuth flow.
|
|
198
|
+
*
|
|
199
|
+
* - This function initiates the Google OAuth flow by opening the in-app browser and deep-linking back to the app.
|
|
200
|
+
* - On React Native, the flow always uses the in-app browser.
|
|
201
|
+
* - 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.
|
|
202
|
+
* - Constructs the Google OAuth URL with all required parameters, including client ID, redirect URI, response type, scope, nonce, and state.
|
|
203
|
+
* - The `state` parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic.
|
|
204
|
+
* - The flow resolves when the app is deep-linked back; it rejects if the in-app browser is closed or times out.
|
|
205
|
+
* - 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`.
|
|
206
|
+
* - Handles all error cases, including missing configuration, in-app browser failures, and timeouts, and throws a `ZeroXKeyError` with appropriate error codes.
|
|
207
|
+
*
|
|
208
|
+
* @param params.clientId - The Google Client ID to use (defaults to the client ID from configuration).
|
|
209
|
+
* @param params.additionalState - Additional key-value pairs to include in the OAuth state parameter for custom tracking or logic.
|
|
210
|
+
* @param params.onOauthSuccess - Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName, publicKey }`).
|
|
211
|
+
*
|
|
212
|
+
* onOauthSuccess params:
|
|
213
|
+
* - oidcToken: The OIDC token received from the OAuth flow.
|
|
214
|
+
* - providerName: The name of the OAuth provider ("google").
|
|
215
|
+
* - publicKey: The public key used for the OAuth flow.
|
|
216
|
+
*
|
|
217
|
+
* @returns A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.
|
|
218
|
+
* @throws {ZeroXKeyError} If the configuration is not ready, required parameters are missing, or if there is an error initiating or completing the OAuth flow.
|
|
219
|
+
*/
|
|
220
|
+
handleGoogleOauth: (params?: HandleGoogleOauthParams) => Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Handles the Apple OAuth flow.
|
|
223
|
+
*
|
|
224
|
+
* - This function initiates the Apple OAuth flow by opening the in-app browser and deep-linking back to the app.
|
|
225
|
+
* - On React Native, the flow always uses the in-app browser.
|
|
226
|
+
* - 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.
|
|
227
|
+
* - Constructs the Apple OAuth URL with all required parameters, including client ID, redirect URI, response type, response mode, nonce, and state.
|
|
228
|
+
* - The `state` parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic.
|
|
229
|
+
* - The flow resolves when the app is deep-linked back; it rejects if the in-app browser is closed or times out.
|
|
230
|
+
* - 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`.
|
|
231
|
+
* - Handles all error cases, including missing configuration, in-app browser failures, and timeouts, and throws a `ZeroXKeyError` with appropriate error codes.
|
|
232
|
+
*
|
|
233
|
+
* @param params.clientId - The Apple Client ID to use (defaults to the client ID from configuration).
|
|
234
|
+
* @param params.additionalState - Additional key-value pairs to include in the OAuth state parameter for custom tracking or logic.
|
|
235
|
+
* @param params.onOauthSuccess - Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName, publicKey }`).
|
|
236
|
+
*
|
|
237
|
+
* onOauthSuccess params:
|
|
238
|
+
* - oidcToken: The OIDC token received from the OAuth flow.
|
|
239
|
+
* - providerName: The name of the OAuth provider ("apple").
|
|
240
|
+
* - publicKey: The public key used for the OAuth flow.
|
|
241
|
+
*
|
|
242
|
+
* @returns A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.
|
|
243
|
+
* @throws {ZeroXKeyError} If the configuration is not ready, required parameters are missing, or if there is an error initiating or completing the OAuth flow.
|
|
244
|
+
*/
|
|
245
|
+
handleAppleOauth: (params?: HandleAppleOauthParams) => Promise<void>;
|
|
246
|
+
/**
|
|
247
|
+
* Handles the Facebook OAuth flow.
|
|
248
|
+
*
|
|
249
|
+
* - This function initiates the Facebook OAuth flow by opening the in-app browser and deep-linking back to the app.
|
|
250
|
+
* - On React Native, the flow always uses the in-app browser.
|
|
251
|
+
* - 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.
|
|
252
|
+
* - Uses PKCE (Proof Key for Code Exchange) for enhanced security, generating a code verifier and challenge for the Facebook OAuth flow.
|
|
253
|
+
* - Constructs the Facebook OAuth URL with all required parameters, including client ID, redirect URI, response type, code challenge, nonce, and state.
|
|
254
|
+
* - The `state` parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic.
|
|
255
|
+
* - The flow resolves when the app is deep-linked back; it rejects if the in-app browser is closed or times out.
|
|
256
|
+
* - 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`.
|
|
257
|
+
* - Handles all error cases, including missing configuration, in-app browser failures, and timeouts, and throws a `ZeroXKeyError` with appropriate error codes.
|
|
258
|
+
*
|
|
259
|
+
* @param params.clientId - The Facebook Client ID to use (defaults to the client ID from configuration).
|
|
260
|
+
* @param params.additionalState - Additional key-value pairs to include in the OAuth state parameter for custom tracking or logic.
|
|
261
|
+
* @param params.onOauthSuccess - Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName, publicKey }`).
|
|
262
|
+
*
|
|
263
|
+
* onOauthSuccess params:
|
|
264
|
+
* - oidcToken: The OIDC token received from the OAuth flow.
|
|
265
|
+
* - providerName: The name of the OAuth provider ("facebook").
|
|
266
|
+
* - publicKey: The public key used for the OAuth flow.
|
|
267
|
+
*
|
|
268
|
+
* @returns A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.
|
|
269
|
+
* @throws {ZeroXKeyError} If the configuration is not ready, required parameters are missing, or if there is an error initiating or completing the OAuth flow.
|
|
270
|
+
*/
|
|
271
|
+
handleFacebookOauth: (params?: HandleFacebookOauthParams) => Promise<void>;
|
|
272
|
+
}
|
|
273
|
+
/** @internal */
|
|
274
|
+
export declare const ClientContext: import("react").Context<ClientContextType | undefined>;
|
|
275
|
+
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../src/providers/Types.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.js","sources":["../../src/providers/Types.tsx"],"sourcesContent":[null],"names":["createContext"],"mappings":";;;;AAgVA;MACa,aAAa,GAAGA,mBAAa,CACxC,SAAS;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.mjs","sources":["../../src/providers/Types.tsx"],"sourcesContent":[null],"names":[],"mappings":";;AAgVA;MACa,aAAa,GAAG,aAAa,CACxC,SAAS;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { type ZeroXKeyCallbacks, type ZeroXKeyProviderConfig } from "../types/base";
|
|
3
|
+
/**
|
|
4
|
+
* @inline
|
|
5
|
+
*/
|
|
6
|
+
interface ZeroXKeyProviderProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
config: ZeroXKeyProviderConfig;
|
|
9
|
+
callbacks?: ZeroXKeyCallbacks | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Provides ZeroXKey client authentication, session management, wallet operations, and user profile management
|
|
13
|
+
* for the React Native Wallet Kit SDK. This context provider encapsulates all core authentication flows (Passkey, OTP, OAuth),
|
|
14
|
+
* session lifecycle (creation, expiration, refresh), wallet import/export, and user profile updates (email, phone, name).
|
|
15
|
+
*
|
|
16
|
+
* The provider automatically initializes the ZeroXKey client, fetches configuration (including proxy auth config if needed),
|
|
17
|
+
* and synchronizes session and authentication state. It exposes a comprehensive set of methods for authentication flows,
|
|
18
|
+
* wallet management, and user profile operations, as well as UI handlers for modal-driven flows.
|
|
19
|
+
*
|
|
20
|
+
* Features:
|
|
21
|
+
* - Passkey, OTP (Email/SMS), and OAuth (Google, Apple, Facebook, Discord, X) authentication and sign-up flows.
|
|
22
|
+
* - React Native-specific OAuth: opens an in-app browser (Custom Tabs/Safari View Controller) and deep-links back via the configured app scheme.
|
|
23
|
+
* - Session management: creation, expiration scheduling, refresh, and clearing.
|
|
24
|
+
* - Wallet management: fetch, import, export, account management.
|
|
25
|
+
* - User profile management: email, phone, name, OAuth provider, and passkey linking/removal.
|
|
26
|
+
* - Error handling and callback integration for custom error and event responses.
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* Wrap your application with `ZeroXKeyProvider` to enable authentication and wallet features via context.
|
|
30
|
+
*
|
|
31
|
+
* @param config - The ZeroXKey provider configuration object.
|
|
32
|
+
* @param children - React children to be rendered within the provider.
|
|
33
|
+
* @param callbacks - Optional callbacks for error handling and session events.
|
|
34
|
+
*
|
|
35
|
+
* @returns A React context provider exposing authentication, wallet, and user management methods and state.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ZeroXKeyProvider: React.FC<ZeroXKeyProviderProps>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=ZeroXKeyProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZeroXKeyProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ZeroXKeyProvider.tsx"],"names":[],"mappings":"AAgFA,OAAO,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAC;AA0B5E,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAI5B,MAAM,eAAe,CAAC;AAuBvB;;GAEG;AACH,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,SAAS,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAk/F5D,CAAC"}
|