@privy-io/react-auth 3.4.1 → 3.5.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/dist/cjs/EmbeddedWalletConnectingScreen-D_YsihzO.js +27 -0
- package/dist/cjs/SignRequestScreen-MGUrxay9.js +1 -0
- package/dist/cjs/abstract-smart-wallets.js +1 -1
- package/dist/cjs/events-context-Dn0fJZ2h.js +1 -0
- package/dist/cjs/extended-chains.js +1 -1
- package/dist/cjs/farcaster.js +1 -1
- package/dist/cjs/frame-B2orQ_lK.js +1 -0
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/internal-context-CeWKmK5u.js +1 -0
- package/dist/cjs/internal.js +1 -0
- package/dist/cjs/smart-wallets-5q-XiLac.js +1 -0
- package/dist/cjs/smart-wallets.js +1 -1
- package/dist/cjs/solana.js +1 -1
- package/dist/cjs/ui.js +2 -2
- package/dist/cjs/use-export-wallet-C7R1A29C.js +2 -0
- package/dist/cjs/use-sign-with-user-signer-BtJVKMQr.js +1 -0
- package/dist/cjs/useActiveWallet-E94x91YD.js +1 -0
- package/dist/cjs/usePrivy-BEZb4Uky.js +1 -0
- package/dist/dts/events-context-DB3Pn5Hg.d.mts +328 -0
- package/dist/dts/events-context-DB3Pn5Hg.d.ts +328 -0
- package/dist/dts/extended-chains.d.mts +24 -2
- package/dist/dts/extended-chains.d.ts +24 -2
- package/dist/dts/farcaster.d.mts +1 -1
- package/dist/dts/farcaster.d.ts +1 -1
- package/dist/dts/index.d.mts +20 -332
- package/dist/dts/index.d.ts +20 -332
- package/dist/dts/internal.d.mts +44 -0
- package/dist/dts/internal.d.ts +44 -0
- package/dist/dts/smart-wallets.d.mts +1 -1
- package/dist/dts/smart-wallets.d.ts +1 -1
- package/dist/dts/solana.d.mts +31 -7
- package/dist/dts/solana.d.ts +31 -7
- package/dist/dts/{types-BF33BYgd.d.mts → types-C4KyGxEF.d.mts} +3 -3
- package/dist/dts/{types-BF33BYgd.d.ts → types-C4KyGxEF.d.ts} +3 -3
- package/dist/dts/ui.d.mts +1 -1
- package/dist/dts/ui.d.ts +1 -1
- package/dist/esm/EmbeddedWalletConnectingScreen-ilL_GaJO.mjs +25 -0
- package/dist/esm/SignRequestScreen-B3UhThlp.mjs +1 -0
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/events-context-CB7CF-OC.mjs +1 -0
- package/dist/esm/extended-chains.mjs +1 -1
- package/dist/esm/farcaster.mjs +1 -1
- package/dist/esm/frame-Dj70FEYB.mjs +1 -0
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/internal-context-eGSwROSk.mjs +1 -0
- package/dist/esm/internal.mjs +1 -0
- package/dist/esm/smart-wallets-DINPJbZr.mjs +1 -0
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/ui.mjs +2 -2
- package/dist/esm/use-export-wallet-CED1-6Km.mjs +1 -0
- package/dist/esm/use-sign-with-user-signer-DaTvrd5T.mjs +1 -0
- package/dist/esm/useActiveWallet-2NxrDpZU.mjs +1 -0
- package/dist/esm/usePrivy-DhsfOIjx.mjs +1 -0
- package/package.json +21 -7
- package/dist/cjs/SignRequestScreen-cAAtS6nl.js +0 -27
- package/dist/cjs/frame-8JZCzmCf.js +0 -1
- package/dist/cjs/internal-context-DNWjSiYq.js +0 -1
- package/dist/cjs/paths-B00ZrFQm.js +0 -1
- package/dist/cjs/privy-context-NMR-GjnL.js +0 -1
- package/dist/cjs/smart-wallets-65yy6DGK.js +0 -1
- package/dist/cjs/use-export-wallet-9ypqLaaB.js +0 -2
- package/dist/cjs/use-sign-with-user-signer-Q0_LRVtz.js +0 -1
- package/dist/cjs/useActiveWallet-CtNcsjJH.js +0 -1
- package/dist/cjs/usePrivy-dGz-b0SX.js +0 -1
- package/dist/esm/SignRequestScreen-cNZ56bAg.mjs +0 -25
- package/dist/esm/frame-Dh-xhHMG.mjs +0 -1
- package/dist/esm/internal-context-CfE_S5P-.mjs +0 -1
- package/dist/esm/paths-B891YjWw.mjs +0 -1
- package/dist/esm/privy-context-DDSW3jEM.mjs +0 -1
- package/dist/esm/smart-wallets-_lFo8N6W.mjs +0 -1
- package/dist/esm/use-export-wallet-E2KvvjYq.mjs +0 -1
- package/dist/esm/use-sign-with-user-signer-DVcbjNtZ.mjs +0 -1
- package/dist/esm/useActiveWallet-BLu2tB4S.mjs +0 -1
- package/dist/esm/usePrivy-DmWciddF.mjs +0 -1
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { Chain } from '@privy-io/js-sdk-core';
|
|
2
|
+
import { U as User, L as LoginMethod, a as LinkedAccountWithMetadata, P as PrivyErrorCode, B as BaseConnectedEthereumWallet, b as BaseConnectedSolanaWallet, W as Wallet, M as MfaMethod, c as UserRecoveryMethod, O as OAuthTokens, F as FundingMethod, S as SolanaChain } from './types-C4KyGxEF.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `CallbackError` optionally includes a second parameter with further error details.
|
|
6
|
+
*/
|
|
7
|
+
type CallbackError<Details extends Record<string, any> | undefined = undefined> = Details extends Record<string, any> ? (error: PrivyErrorCode, details: Details) => void : (error: PrivyErrorCode) => void;
|
|
8
|
+
interface PrivyEvents {
|
|
9
|
+
login: {
|
|
10
|
+
/**
|
|
11
|
+
* Callback that will execute once a `login` flow successfully completes.
|
|
12
|
+
* - If `config.embeddedWallets.createOnLogin` is set to 'off' or a wallet creation flow is not applicable,
|
|
13
|
+
* this will run after the user successfully authenticates.
|
|
14
|
+
* - If `config.embeddedWallets.createOnLogin` is set to 'users-without-wallets' or 'all-users',
|
|
15
|
+
* this will run after the user successfully authenticates _and_ creates their wallet (if applicable).
|
|
16
|
+
* - If a user is already authenticated, this will run immediately and the `wasAlreadyAuthenticated` flag will be set to `true`.
|
|
17
|
+
*
|
|
18
|
+
* @param params.user {@link User} the `user` oject corresponding to the authenticated user
|
|
19
|
+
* @param params.isNewUser {boolean} boolean flag indicating if this is the user's first time logging in to your app
|
|
20
|
+
* @param params.wasAlreadyAuthenticated {boolean} - boolean flag indicating whether the user entered the application already authenticated
|
|
21
|
+
* @param params.loginMethod {string} - the method used by the user to login
|
|
22
|
+
* @param params.loginAccount - the account corresponding to the loginMethod used
|
|
23
|
+
*/
|
|
24
|
+
onComplete?: (params: {
|
|
25
|
+
user: User;
|
|
26
|
+
isNewUser: boolean;
|
|
27
|
+
wasAlreadyAuthenticated: boolean;
|
|
28
|
+
loginMethod: LoginMethod | null;
|
|
29
|
+
loginAccount: LinkedAccountWithMetadata | null;
|
|
30
|
+
}) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Callback that will execute in the case of a non-successful login.
|
|
33
|
+
*
|
|
34
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
35
|
+
*/
|
|
36
|
+
onError?: CallbackError;
|
|
37
|
+
};
|
|
38
|
+
logout: {
|
|
39
|
+
/**
|
|
40
|
+
* Callback that will execute when a user successfully logs out.
|
|
41
|
+
*/
|
|
42
|
+
onSuccess?: () => void;
|
|
43
|
+
};
|
|
44
|
+
connectWallet: {
|
|
45
|
+
/**
|
|
46
|
+
* Callback that will execute once a successful `connectWallet` completes.
|
|
47
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
48
|
+
*
|
|
49
|
+
* @param params.wallet {@link BaseConnectedEthereumWallet | BaseConnectedSolanaWallet} the `wallet` object correspending to the connection
|
|
50
|
+
*/
|
|
51
|
+
onSuccess?: (params: {
|
|
52
|
+
wallet: BaseConnectedEthereumWallet | BaseConnectedSolanaWallet;
|
|
53
|
+
}) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Callback that will execute in the case of a non-successful wallet connection.
|
|
56
|
+
*
|
|
57
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
58
|
+
*/
|
|
59
|
+
onError?: CallbackError;
|
|
60
|
+
};
|
|
61
|
+
connectOrCreateWallet: {
|
|
62
|
+
/**
|
|
63
|
+
* Callback that will execute once a successful `connectWallet` completes.
|
|
64
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
65
|
+
*
|
|
66
|
+
* @param params.wallet {@link BaseConnectedEthereumWallet | BaseConnectedSolanaWallet} the `wallet` object correspending to the connection
|
|
67
|
+
*/
|
|
68
|
+
onSuccess?: (params: {
|
|
69
|
+
wallet: BaseConnectedEthereumWallet | BaseConnectedSolanaWallet;
|
|
70
|
+
}) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Callback that will execute in the case of a non-successful wallet connection.
|
|
73
|
+
*
|
|
74
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
75
|
+
*/
|
|
76
|
+
onError?: CallbackError;
|
|
77
|
+
};
|
|
78
|
+
createWallet: {
|
|
79
|
+
/**
|
|
80
|
+
* Callback that will execute once on a successful embedded wallet creation.
|
|
81
|
+
* This will run when `createWallet` is called manually, or when `config.embeddedWallets.createOnLogin` triggers
|
|
82
|
+
* an automatic wallet creation.
|
|
83
|
+
*
|
|
84
|
+
* @param params.wallet {@link BaseConnectedWallet}- the created `wallet` object
|
|
85
|
+
*/
|
|
86
|
+
onSuccess?: (params: {
|
|
87
|
+
wallet: Wallet;
|
|
88
|
+
}) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Callback that will execute in the case of a non-successful wallet creation.
|
|
91
|
+
*
|
|
92
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
93
|
+
*/
|
|
94
|
+
onError?: CallbackError;
|
|
95
|
+
};
|
|
96
|
+
linkAccount: {
|
|
97
|
+
/**
|
|
98
|
+
* Callback that will execute once on a successful linking of a new account/login method.
|
|
99
|
+
* This will run when any of the 'link' methods are called manually.
|
|
100
|
+
* @param params.user {@link User}- the user the account was linked to
|
|
101
|
+
* @param params.linkMethod {@link LoginMethod}- the type of linked account
|
|
102
|
+
* @param params.linkedAccount - the newly linked account
|
|
103
|
+
*/
|
|
104
|
+
onSuccess?: (params: {
|
|
105
|
+
user: User;
|
|
106
|
+
linkMethod: LoginMethod;
|
|
107
|
+
linkedAccount: LinkedAccountWithMetadata;
|
|
108
|
+
}) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Callback that will execute in the case of a non-successful account linking.
|
|
111
|
+
*
|
|
112
|
+
* @param error {PrivyErrorCode} - the corresponding error code
|
|
113
|
+
* @param details.linkMethod {LoginMethod} - the type of (attempted) linked account
|
|
114
|
+
*/
|
|
115
|
+
onError?: CallbackError<{
|
|
116
|
+
linkMethod: LoginMethod;
|
|
117
|
+
}>;
|
|
118
|
+
};
|
|
119
|
+
update: {
|
|
120
|
+
/**
|
|
121
|
+
* Callback that will execute once on a successful updating of an account.
|
|
122
|
+
* This will run when any of the 'updateAccount' methods are called manually.
|
|
123
|
+
* @param params.user {@link User}- the user the account was linked to
|
|
124
|
+
* @param params.updateMethod {@link LoginMethod}- the type of updated account
|
|
125
|
+
* @param params.updatedAccount - the newly updated account
|
|
126
|
+
*/
|
|
127
|
+
onSuccess?: (params: {
|
|
128
|
+
user: User;
|
|
129
|
+
updateMethod: LoginMethod;
|
|
130
|
+
updatedAccount: LinkedAccountWithMetadata;
|
|
131
|
+
}) => void;
|
|
132
|
+
/**
|
|
133
|
+
* Callback that will execute in the case of a non-successful account linking.
|
|
134
|
+
*
|
|
135
|
+
* @param error {PrivyErrorCode} - the corresponding error code
|
|
136
|
+
* @param details.linkMethod {LoginMethod} - the type of (attempted) linked account
|
|
137
|
+
*/
|
|
138
|
+
onError?: CallbackError<{
|
|
139
|
+
linkMethod: LoginMethod;
|
|
140
|
+
}>;
|
|
141
|
+
};
|
|
142
|
+
configureMfa: {
|
|
143
|
+
/**
|
|
144
|
+
* Callback that will execute when MFA is required to complete a given action.
|
|
145
|
+
* @param params.mfaMethods {@link MfaMethod[]} - List of MFA methods that the user can choose from
|
|
146
|
+
*/
|
|
147
|
+
onMfaRequired: (params: {
|
|
148
|
+
mfaMethods: MfaMethod[];
|
|
149
|
+
}) => void;
|
|
150
|
+
};
|
|
151
|
+
setWalletPassword: {
|
|
152
|
+
/**
|
|
153
|
+
* Callback that will execute once a successful `setWalletPassword` completes.
|
|
154
|
+
* @param params.wallet {@link Wallet}- the `wallet` object that the password was set for
|
|
155
|
+
*/
|
|
156
|
+
onSuccess?: (params: {
|
|
157
|
+
wallet: Wallet;
|
|
158
|
+
}) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Callback that will execute in the case of a non-successful setWalletPassword.
|
|
161
|
+
*
|
|
162
|
+
* @param params.error {PrivyErrorCode} - the corresponding error code
|
|
163
|
+
*/
|
|
164
|
+
onError?: CallbackError;
|
|
165
|
+
};
|
|
166
|
+
setWalletRecovery: {
|
|
167
|
+
/**
|
|
168
|
+
* Callback that will execute once a successful `setWalletRecovery` completes.
|
|
169
|
+
* @param params.method {@link UserRecoveryMethod} - the recovery method that was set
|
|
170
|
+
* @param params.wallet {@link Wallet}- the wallet object that the recovery was set for
|
|
171
|
+
*/
|
|
172
|
+
onSuccess?: (params: {
|
|
173
|
+
method: UserRecoveryMethod;
|
|
174
|
+
wallet: Wallet;
|
|
175
|
+
}) => void;
|
|
176
|
+
/**
|
|
177
|
+
* Callback that will execute in the case of a non-successful setWalletRecovery.
|
|
178
|
+
*
|
|
179
|
+
* @param params.error {PrivyErrorCode} - the corresponding error code
|
|
180
|
+
*/
|
|
181
|
+
onError?: CallbackError;
|
|
182
|
+
};
|
|
183
|
+
signMessage: {
|
|
184
|
+
/**
|
|
185
|
+
* Callback that will execute once a successful `signMessage` completes.
|
|
186
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
187
|
+
* @param params.signature - the signature (type string) of the embedded wallet used to sign message
|
|
188
|
+
*/
|
|
189
|
+
onSuccess?: (params: {
|
|
190
|
+
signature: string;
|
|
191
|
+
}) => void;
|
|
192
|
+
/**
|
|
193
|
+
* Callback that will execute in the case of a non-successful signMessage.
|
|
194
|
+
*
|
|
195
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
196
|
+
*/
|
|
197
|
+
onError?: CallbackError;
|
|
198
|
+
};
|
|
199
|
+
signTypedData: {
|
|
200
|
+
/**
|
|
201
|
+
* Callback that will execute once a successful `signTypedData` completes.
|
|
202
|
+
* @param params.signature - the signature (type string) of the embedded wallet used to sign
|
|
203
|
+
*/
|
|
204
|
+
onSuccess?: (params: {
|
|
205
|
+
signature: string;
|
|
206
|
+
}) => void;
|
|
207
|
+
/**
|
|
208
|
+
* Callback that will execute in the case of a non-successful signTypedData.
|
|
209
|
+
*
|
|
210
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
211
|
+
*/
|
|
212
|
+
onError?: CallbackError;
|
|
213
|
+
};
|
|
214
|
+
sendTransaction: {
|
|
215
|
+
/**
|
|
216
|
+
* Callback that will execute once a successful `sendTransaction` completes.
|
|
217
|
+
* This will not run for transactions with external wallets.
|
|
218
|
+
* @param an object with the transaction hash
|
|
219
|
+
*/
|
|
220
|
+
onSuccess?: (params: {
|
|
221
|
+
hash: `0x${string}`;
|
|
222
|
+
}) => void;
|
|
223
|
+
/**
|
|
224
|
+
* Callback that will execute in the case of a non-successful sendTransaction.
|
|
225
|
+
*
|
|
226
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
227
|
+
*/
|
|
228
|
+
onError?: CallbackError;
|
|
229
|
+
};
|
|
230
|
+
signTransaction: {
|
|
231
|
+
/**
|
|
232
|
+
* Callback that will execute once a successful `signTransaction` completes.
|
|
233
|
+
* This will not run for transactions with external wallets.
|
|
234
|
+
* @param an object with the transaction signature
|
|
235
|
+
*/
|
|
236
|
+
onSuccess?: (params: {
|
|
237
|
+
signature: `0x${string}`;
|
|
238
|
+
}) => void;
|
|
239
|
+
/**
|
|
240
|
+
* Callback that will execute in the case of a non-successful signTransaction.
|
|
241
|
+
*
|
|
242
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
243
|
+
*/
|
|
244
|
+
onError?: CallbackError;
|
|
245
|
+
};
|
|
246
|
+
accessToken: {
|
|
247
|
+
/**
|
|
248
|
+
* Callback that will execute when a user's access token is granted.
|
|
249
|
+
* @param params.accessToken - The user's access token
|
|
250
|
+
*/
|
|
251
|
+
onAccessTokenGranted: (params: {
|
|
252
|
+
accessToken: string;
|
|
253
|
+
}) => void;
|
|
254
|
+
/**
|
|
255
|
+
* Callback that will execute when a user's access token is removed.
|
|
256
|
+
*/
|
|
257
|
+
onAccessTokenRemoved: () => void;
|
|
258
|
+
};
|
|
259
|
+
oAuthAuthorization: {
|
|
260
|
+
/**
|
|
261
|
+
* Callback that will execute when a user successfully authorizes an OAuth flow.
|
|
262
|
+
*
|
|
263
|
+
* @param params.oAuthTokens {@link OAuthTokens} - the OAuth tokens returned from the OAuth provider:
|
|
264
|
+
* @param params.oAuthTokens.provider - {string} The OAuth provider type.
|
|
265
|
+
* @param params.oAuthTokens.accessToken - {string} The OAuth access token.
|
|
266
|
+
* @param params.oAuthTokens.accessTokenExpiresInSeconds - {number} (optional) The number of seconds until the OAuth access token expires.
|
|
267
|
+
* @param params.oAuthTokens.refreshToken - {string} (optional) The OAuth refresh token.
|
|
268
|
+
* @param params.oAuthTokens.refreshTokenExpiresInSeconds - {number} (optional) The number of seconds until the OAuth refresh token expires.
|
|
269
|
+
* if the refresh token is present and this field is undefined, it is assumed
|
|
270
|
+
* that the refresh token does not have an expiration date.
|
|
271
|
+
* @param params.oAuthTokens.scopes - {string[]} (optional) The list of OAuth scopes the access token is approved for.
|
|
272
|
+
*
|
|
273
|
+
* @param params.user {@link User} The authenticated user
|
|
274
|
+
*/
|
|
275
|
+
onOAuthTokenGrant: (params: {
|
|
276
|
+
oAuthTokens: OAuthTokens;
|
|
277
|
+
user: User;
|
|
278
|
+
}) => void;
|
|
279
|
+
};
|
|
280
|
+
fundWallet: {
|
|
281
|
+
/**
|
|
282
|
+
* Callback that will execute when a funding flow is exited. This fires when a user closes a funding flow modal, for any reason.
|
|
283
|
+
*
|
|
284
|
+
* @param params.address {string} The address of the wallet being funded
|
|
285
|
+
* @param params.chain {Chain} The chain of the wallet being funded
|
|
286
|
+
* @param params.fundingMethod {@link FundingMethod} The funding method associated with the flow at time of exit. If the user had not yet selected
|
|
287
|
+
* a recovery method, this will be null.
|
|
288
|
+
* @param params.balance {bigint} The value for the funded wallet at the point of user exit.
|
|
289
|
+
*/
|
|
290
|
+
onUserExited?: (params: {
|
|
291
|
+
address: string;
|
|
292
|
+
chain: Chain;
|
|
293
|
+
fundingMethod: FundingMethod | 'manual' | null;
|
|
294
|
+
balance: bigint | undefined;
|
|
295
|
+
}) => void;
|
|
296
|
+
};
|
|
297
|
+
fundSolanaWallet: {
|
|
298
|
+
/**
|
|
299
|
+
* Callback that will execute when a funding flow is exited. This fires when a user closes a funding flow modal, for any reason.
|
|
300
|
+
*
|
|
301
|
+
* @param params.address {string} The address of the wallet being funded
|
|
302
|
+
* @param params.fundingMethod {@link FundingMethod} The funding method associated with the flow at time of exit. If the user had not yet selected
|
|
303
|
+
* a recovery method, this will be null.
|
|
304
|
+
* @param params.balance {bigint} The value for the funded wallet at the point of user exit.
|
|
305
|
+
*/
|
|
306
|
+
onUserExited?: (params: {
|
|
307
|
+
address: string;
|
|
308
|
+
fundingMethod: FundingMethod | 'manual' | null;
|
|
309
|
+
chain: SolanaChain;
|
|
310
|
+
balance: bigint | undefined;
|
|
311
|
+
}) => void;
|
|
312
|
+
};
|
|
313
|
+
customAuth: {
|
|
314
|
+
/**
|
|
315
|
+
* Callback that will execute when Privy successfully exchanges a custom auth JWT for a Privy JWT
|
|
316
|
+
* @param params.user - The Privy user
|
|
317
|
+
*/
|
|
318
|
+
onAuthenticated: (params: {
|
|
319
|
+
user: User;
|
|
320
|
+
}) => void;
|
|
321
|
+
/**
|
|
322
|
+
* Callback that will execute when Privy detects a user is logged out from the third-party auth system, and correspondingly logs the user out.
|
|
323
|
+
*/
|
|
324
|
+
onUnauthenticated: () => void;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export type { CallbackError as C, PrivyEvents as P };
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { Chain } from '@privy-io/js-sdk-core';
|
|
2
|
+
import { U as User, L as LoginMethod, a as LinkedAccountWithMetadata, P as PrivyErrorCode, B as BaseConnectedEthereumWallet, b as BaseConnectedSolanaWallet, W as Wallet, M as MfaMethod, c as UserRecoveryMethod, O as OAuthTokens, F as FundingMethod, S as SolanaChain } from './types-C4KyGxEF.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `CallbackError` optionally includes a second parameter with further error details.
|
|
6
|
+
*/
|
|
7
|
+
type CallbackError<Details extends Record<string, any> | undefined = undefined> = Details extends Record<string, any> ? (error: PrivyErrorCode, details: Details) => void : (error: PrivyErrorCode) => void;
|
|
8
|
+
interface PrivyEvents {
|
|
9
|
+
login: {
|
|
10
|
+
/**
|
|
11
|
+
* Callback that will execute once a `login` flow successfully completes.
|
|
12
|
+
* - If `config.embeddedWallets.createOnLogin` is set to 'off' or a wallet creation flow is not applicable,
|
|
13
|
+
* this will run after the user successfully authenticates.
|
|
14
|
+
* - If `config.embeddedWallets.createOnLogin` is set to 'users-without-wallets' or 'all-users',
|
|
15
|
+
* this will run after the user successfully authenticates _and_ creates their wallet (if applicable).
|
|
16
|
+
* - If a user is already authenticated, this will run immediately and the `wasAlreadyAuthenticated` flag will be set to `true`.
|
|
17
|
+
*
|
|
18
|
+
* @param params.user {@link User} the `user` oject corresponding to the authenticated user
|
|
19
|
+
* @param params.isNewUser {boolean} boolean flag indicating if this is the user's first time logging in to your app
|
|
20
|
+
* @param params.wasAlreadyAuthenticated {boolean} - boolean flag indicating whether the user entered the application already authenticated
|
|
21
|
+
* @param params.loginMethod {string} - the method used by the user to login
|
|
22
|
+
* @param params.loginAccount - the account corresponding to the loginMethod used
|
|
23
|
+
*/
|
|
24
|
+
onComplete?: (params: {
|
|
25
|
+
user: User;
|
|
26
|
+
isNewUser: boolean;
|
|
27
|
+
wasAlreadyAuthenticated: boolean;
|
|
28
|
+
loginMethod: LoginMethod | null;
|
|
29
|
+
loginAccount: LinkedAccountWithMetadata | null;
|
|
30
|
+
}) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Callback that will execute in the case of a non-successful login.
|
|
33
|
+
*
|
|
34
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
35
|
+
*/
|
|
36
|
+
onError?: CallbackError;
|
|
37
|
+
};
|
|
38
|
+
logout: {
|
|
39
|
+
/**
|
|
40
|
+
* Callback that will execute when a user successfully logs out.
|
|
41
|
+
*/
|
|
42
|
+
onSuccess?: () => void;
|
|
43
|
+
};
|
|
44
|
+
connectWallet: {
|
|
45
|
+
/**
|
|
46
|
+
* Callback that will execute once a successful `connectWallet` completes.
|
|
47
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
48
|
+
*
|
|
49
|
+
* @param params.wallet {@link BaseConnectedEthereumWallet | BaseConnectedSolanaWallet} the `wallet` object correspending to the connection
|
|
50
|
+
*/
|
|
51
|
+
onSuccess?: (params: {
|
|
52
|
+
wallet: BaseConnectedEthereumWallet | BaseConnectedSolanaWallet;
|
|
53
|
+
}) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Callback that will execute in the case of a non-successful wallet connection.
|
|
56
|
+
*
|
|
57
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
58
|
+
*/
|
|
59
|
+
onError?: CallbackError;
|
|
60
|
+
};
|
|
61
|
+
connectOrCreateWallet: {
|
|
62
|
+
/**
|
|
63
|
+
* Callback that will execute once a successful `connectWallet` completes.
|
|
64
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
65
|
+
*
|
|
66
|
+
* @param params.wallet {@link BaseConnectedEthereumWallet | BaseConnectedSolanaWallet} the `wallet` object correspending to the connection
|
|
67
|
+
*/
|
|
68
|
+
onSuccess?: (params: {
|
|
69
|
+
wallet: BaseConnectedEthereumWallet | BaseConnectedSolanaWallet;
|
|
70
|
+
}) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Callback that will execute in the case of a non-successful wallet connection.
|
|
73
|
+
*
|
|
74
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
75
|
+
*/
|
|
76
|
+
onError?: CallbackError;
|
|
77
|
+
};
|
|
78
|
+
createWallet: {
|
|
79
|
+
/**
|
|
80
|
+
* Callback that will execute once on a successful embedded wallet creation.
|
|
81
|
+
* This will run when `createWallet` is called manually, or when `config.embeddedWallets.createOnLogin` triggers
|
|
82
|
+
* an automatic wallet creation.
|
|
83
|
+
*
|
|
84
|
+
* @param params.wallet {@link BaseConnectedWallet}- the created `wallet` object
|
|
85
|
+
*/
|
|
86
|
+
onSuccess?: (params: {
|
|
87
|
+
wallet: Wallet;
|
|
88
|
+
}) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Callback that will execute in the case of a non-successful wallet creation.
|
|
91
|
+
*
|
|
92
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
93
|
+
*/
|
|
94
|
+
onError?: CallbackError;
|
|
95
|
+
};
|
|
96
|
+
linkAccount: {
|
|
97
|
+
/**
|
|
98
|
+
* Callback that will execute once on a successful linking of a new account/login method.
|
|
99
|
+
* This will run when any of the 'link' methods are called manually.
|
|
100
|
+
* @param params.user {@link User}- the user the account was linked to
|
|
101
|
+
* @param params.linkMethod {@link LoginMethod}- the type of linked account
|
|
102
|
+
* @param params.linkedAccount - the newly linked account
|
|
103
|
+
*/
|
|
104
|
+
onSuccess?: (params: {
|
|
105
|
+
user: User;
|
|
106
|
+
linkMethod: LoginMethod;
|
|
107
|
+
linkedAccount: LinkedAccountWithMetadata;
|
|
108
|
+
}) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Callback that will execute in the case of a non-successful account linking.
|
|
111
|
+
*
|
|
112
|
+
* @param error {PrivyErrorCode} - the corresponding error code
|
|
113
|
+
* @param details.linkMethod {LoginMethod} - the type of (attempted) linked account
|
|
114
|
+
*/
|
|
115
|
+
onError?: CallbackError<{
|
|
116
|
+
linkMethod: LoginMethod;
|
|
117
|
+
}>;
|
|
118
|
+
};
|
|
119
|
+
update: {
|
|
120
|
+
/**
|
|
121
|
+
* Callback that will execute once on a successful updating of an account.
|
|
122
|
+
* This will run when any of the 'updateAccount' methods are called manually.
|
|
123
|
+
* @param params.user {@link User}- the user the account was linked to
|
|
124
|
+
* @param params.updateMethod {@link LoginMethod}- the type of updated account
|
|
125
|
+
* @param params.updatedAccount - the newly updated account
|
|
126
|
+
*/
|
|
127
|
+
onSuccess?: (params: {
|
|
128
|
+
user: User;
|
|
129
|
+
updateMethod: LoginMethod;
|
|
130
|
+
updatedAccount: LinkedAccountWithMetadata;
|
|
131
|
+
}) => void;
|
|
132
|
+
/**
|
|
133
|
+
* Callback that will execute in the case of a non-successful account linking.
|
|
134
|
+
*
|
|
135
|
+
* @param error {PrivyErrorCode} - the corresponding error code
|
|
136
|
+
* @param details.linkMethod {LoginMethod} - the type of (attempted) linked account
|
|
137
|
+
*/
|
|
138
|
+
onError?: CallbackError<{
|
|
139
|
+
linkMethod: LoginMethod;
|
|
140
|
+
}>;
|
|
141
|
+
};
|
|
142
|
+
configureMfa: {
|
|
143
|
+
/**
|
|
144
|
+
* Callback that will execute when MFA is required to complete a given action.
|
|
145
|
+
* @param params.mfaMethods {@link MfaMethod[]} - List of MFA methods that the user can choose from
|
|
146
|
+
*/
|
|
147
|
+
onMfaRequired: (params: {
|
|
148
|
+
mfaMethods: MfaMethod[];
|
|
149
|
+
}) => void;
|
|
150
|
+
};
|
|
151
|
+
setWalletPassword: {
|
|
152
|
+
/**
|
|
153
|
+
* Callback that will execute once a successful `setWalletPassword` completes.
|
|
154
|
+
* @param params.wallet {@link Wallet}- the `wallet` object that the password was set for
|
|
155
|
+
*/
|
|
156
|
+
onSuccess?: (params: {
|
|
157
|
+
wallet: Wallet;
|
|
158
|
+
}) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Callback that will execute in the case of a non-successful setWalletPassword.
|
|
161
|
+
*
|
|
162
|
+
* @param params.error {PrivyErrorCode} - the corresponding error code
|
|
163
|
+
*/
|
|
164
|
+
onError?: CallbackError;
|
|
165
|
+
};
|
|
166
|
+
setWalletRecovery: {
|
|
167
|
+
/**
|
|
168
|
+
* Callback that will execute once a successful `setWalletRecovery` completes.
|
|
169
|
+
* @param params.method {@link UserRecoveryMethod} - the recovery method that was set
|
|
170
|
+
* @param params.wallet {@link Wallet}- the wallet object that the recovery was set for
|
|
171
|
+
*/
|
|
172
|
+
onSuccess?: (params: {
|
|
173
|
+
method: UserRecoveryMethod;
|
|
174
|
+
wallet: Wallet;
|
|
175
|
+
}) => void;
|
|
176
|
+
/**
|
|
177
|
+
* Callback that will execute in the case of a non-successful setWalletRecovery.
|
|
178
|
+
*
|
|
179
|
+
* @param params.error {PrivyErrorCode} - the corresponding error code
|
|
180
|
+
*/
|
|
181
|
+
onError?: CallbackError;
|
|
182
|
+
};
|
|
183
|
+
signMessage: {
|
|
184
|
+
/**
|
|
185
|
+
* Callback that will execute once a successful `signMessage` completes.
|
|
186
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
187
|
+
* @param params.signature - the signature (type string) of the embedded wallet used to sign message
|
|
188
|
+
*/
|
|
189
|
+
onSuccess?: (params: {
|
|
190
|
+
signature: string;
|
|
191
|
+
}) => void;
|
|
192
|
+
/**
|
|
193
|
+
* Callback that will execute in the case of a non-successful signMessage.
|
|
194
|
+
*
|
|
195
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
196
|
+
*/
|
|
197
|
+
onError?: CallbackError;
|
|
198
|
+
};
|
|
199
|
+
signTypedData: {
|
|
200
|
+
/**
|
|
201
|
+
* Callback that will execute once a successful `signTypedData` completes.
|
|
202
|
+
* @param params.signature - the signature (type string) of the embedded wallet used to sign
|
|
203
|
+
*/
|
|
204
|
+
onSuccess?: (params: {
|
|
205
|
+
signature: string;
|
|
206
|
+
}) => void;
|
|
207
|
+
/**
|
|
208
|
+
* Callback that will execute in the case of a non-successful signTypedData.
|
|
209
|
+
*
|
|
210
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
211
|
+
*/
|
|
212
|
+
onError?: CallbackError;
|
|
213
|
+
};
|
|
214
|
+
sendTransaction: {
|
|
215
|
+
/**
|
|
216
|
+
* Callback that will execute once a successful `sendTransaction` completes.
|
|
217
|
+
* This will not run for transactions with external wallets.
|
|
218
|
+
* @param an object with the transaction hash
|
|
219
|
+
*/
|
|
220
|
+
onSuccess?: (params: {
|
|
221
|
+
hash: `0x${string}`;
|
|
222
|
+
}) => void;
|
|
223
|
+
/**
|
|
224
|
+
* Callback that will execute in the case of a non-successful sendTransaction.
|
|
225
|
+
*
|
|
226
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
227
|
+
*/
|
|
228
|
+
onError?: CallbackError;
|
|
229
|
+
};
|
|
230
|
+
signTransaction: {
|
|
231
|
+
/**
|
|
232
|
+
* Callback that will execute once a successful `signTransaction` completes.
|
|
233
|
+
* This will not run for transactions with external wallets.
|
|
234
|
+
* @param an object with the transaction signature
|
|
235
|
+
*/
|
|
236
|
+
onSuccess?: (params: {
|
|
237
|
+
signature: `0x${string}`;
|
|
238
|
+
}) => void;
|
|
239
|
+
/**
|
|
240
|
+
* Callback that will execute in the case of a non-successful signTransaction.
|
|
241
|
+
*
|
|
242
|
+
* @param params.error {@link PrivyErrorCode} - the corresponding error code
|
|
243
|
+
*/
|
|
244
|
+
onError?: CallbackError;
|
|
245
|
+
};
|
|
246
|
+
accessToken: {
|
|
247
|
+
/**
|
|
248
|
+
* Callback that will execute when a user's access token is granted.
|
|
249
|
+
* @param params.accessToken - The user's access token
|
|
250
|
+
*/
|
|
251
|
+
onAccessTokenGranted: (params: {
|
|
252
|
+
accessToken: string;
|
|
253
|
+
}) => void;
|
|
254
|
+
/**
|
|
255
|
+
* Callback that will execute when a user's access token is removed.
|
|
256
|
+
*/
|
|
257
|
+
onAccessTokenRemoved: () => void;
|
|
258
|
+
};
|
|
259
|
+
oAuthAuthorization: {
|
|
260
|
+
/**
|
|
261
|
+
* Callback that will execute when a user successfully authorizes an OAuth flow.
|
|
262
|
+
*
|
|
263
|
+
* @param params.oAuthTokens {@link OAuthTokens} - the OAuth tokens returned from the OAuth provider:
|
|
264
|
+
* @param params.oAuthTokens.provider - {string} The OAuth provider type.
|
|
265
|
+
* @param params.oAuthTokens.accessToken - {string} The OAuth access token.
|
|
266
|
+
* @param params.oAuthTokens.accessTokenExpiresInSeconds - {number} (optional) The number of seconds until the OAuth access token expires.
|
|
267
|
+
* @param params.oAuthTokens.refreshToken - {string} (optional) The OAuth refresh token.
|
|
268
|
+
* @param params.oAuthTokens.refreshTokenExpiresInSeconds - {number} (optional) The number of seconds until the OAuth refresh token expires.
|
|
269
|
+
* if the refresh token is present and this field is undefined, it is assumed
|
|
270
|
+
* that the refresh token does not have an expiration date.
|
|
271
|
+
* @param params.oAuthTokens.scopes - {string[]} (optional) The list of OAuth scopes the access token is approved for.
|
|
272
|
+
*
|
|
273
|
+
* @param params.user {@link User} The authenticated user
|
|
274
|
+
*/
|
|
275
|
+
onOAuthTokenGrant: (params: {
|
|
276
|
+
oAuthTokens: OAuthTokens;
|
|
277
|
+
user: User;
|
|
278
|
+
}) => void;
|
|
279
|
+
};
|
|
280
|
+
fundWallet: {
|
|
281
|
+
/**
|
|
282
|
+
* Callback that will execute when a funding flow is exited. This fires when a user closes a funding flow modal, for any reason.
|
|
283
|
+
*
|
|
284
|
+
* @param params.address {string} The address of the wallet being funded
|
|
285
|
+
* @param params.chain {Chain} The chain of the wallet being funded
|
|
286
|
+
* @param params.fundingMethod {@link FundingMethod} The funding method associated with the flow at time of exit. If the user had not yet selected
|
|
287
|
+
* a recovery method, this will be null.
|
|
288
|
+
* @param params.balance {bigint} The value for the funded wallet at the point of user exit.
|
|
289
|
+
*/
|
|
290
|
+
onUserExited?: (params: {
|
|
291
|
+
address: string;
|
|
292
|
+
chain: Chain;
|
|
293
|
+
fundingMethod: FundingMethod | 'manual' | null;
|
|
294
|
+
balance: bigint | undefined;
|
|
295
|
+
}) => void;
|
|
296
|
+
};
|
|
297
|
+
fundSolanaWallet: {
|
|
298
|
+
/**
|
|
299
|
+
* Callback that will execute when a funding flow is exited. This fires when a user closes a funding flow modal, for any reason.
|
|
300
|
+
*
|
|
301
|
+
* @param params.address {string} The address of the wallet being funded
|
|
302
|
+
* @param params.fundingMethod {@link FundingMethod} The funding method associated with the flow at time of exit. If the user had not yet selected
|
|
303
|
+
* a recovery method, this will be null.
|
|
304
|
+
* @param params.balance {bigint} The value for the funded wallet at the point of user exit.
|
|
305
|
+
*/
|
|
306
|
+
onUserExited?: (params: {
|
|
307
|
+
address: string;
|
|
308
|
+
fundingMethod: FundingMethod | 'manual' | null;
|
|
309
|
+
chain: SolanaChain;
|
|
310
|
+
balance: bigint | undefined;
|
|
311
|
+
}) => void;
|
|
312
|
+
};
|
|
313
|
+
customAuth: {
|
|
314
|
+
/**
|
|
315
|
+
* Callback that will execute when Privy successfully exchanges a custom auth JWT for a Privy JWT
|
|
316
|
+
* @param params.user - The Privy user
|
|
317
|
+
*/
|
|
318
|
+
onAuthenticated: (params: {
|
|
319
|
+
user: User;
|
|
320
|
+
}) => void;
|
|
321
|
+
/**
|
|
322
|
+
* Callback that will execute when Privy detects a user is logged out from the third-party auth system, and correspondingly logs the user out.
|
|
323
|
+
*/
|
|
324
|
+
onUnauthenticated: () => void;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export type { CallbackError as C, PrivyEvents as P };
|