@privy-io/react-auth 1.87.0-beta-20240920184838 → 1.87.0-beta-20240923210930
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/getEmbeddedConnectedWallet.js +1 -0
- package/dist/cjs/index.js +3113 -0
- package/dist/cjs/internal-context.js +1 -0
- package/dist/cjs/smart-wallets.js +1 -0
- package/dist/cjs/solana.js +1 -0
- package/dist/cjs/ui.js +132 -0
- package/dist/cjs/useFundWallet.js +118 -0
- package/dist/cjs/useSolanaWallets.js +1 -0
- package/dist/cjs/useWallets.js +1 -0
- package/dist/dts/index.d.mts +2448 -0
- package/dist/{index.d.ts → dts/index.d.ts} +21 -8
- package/dist/dts/smart-wallets.d.mts +728 -0
- package/dist/{smart-wallets.d.ts → dts/smart-wallets.d.ts} +1 -1
- package/dist/dts/solana.d.mts +65 -0
- package/dist/{solana.d.ts → dts/solana.d.ts} +3 -3
- package/dist/{types-eaea6708.d.ts → dts/types.d.mts} +44 -1
- package/dist/dts/types.d.ts +2251 -0
- package/dist/dts/ui.d.mts +29 -0
- package/dist/{ui.d.ts → dts/ui.d.ts} +1 -1
- package/dist/esm/getEmbeddedConnectedWallet.mjs +1 -0
- package/dist/esm/index.mjs +3113 -0
- package/dist/esm/internal-context.mjs +1 -0
- package/dist/esm/smart-wallets.mjs +1 -0
- package/dist/esm/solana.mjs +1 -0
- package/dist/esm/ui.mjs +132 -0
- package/dist/esm/useFundWallet.mjs +118 -0
- package/dist/esm/useSolanaWallets.mjs +1 -0
- package/dist/esm/useWallets.mjs +1 -0
- package/package.json +58 -29
- package/dist/chunk-4ODVFLKF.js +0 -1
- package/dist/chunk-4RGQ4R3M.js +0 -118
- package/dist/chunk-E7B7OFUX.js +0 -3376
- package/dist/chunk-VGM5FGSZ.js +0 -1
- package/dist/esm/chunk-4ODVFLKF.js +0 -1
- package/dist/esm/chunk-4RGQ4R3M.js +0 -118
- package/dist/esm/chunk-E7B7OFUX.js +0 -3376
- package/dist/esm/chunk-VGM5FGSZ.js +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/smart-wallets.js +0 -1
- package/dist/esm/solana.js +0 -1
- package/dist/esm/ui.js +0 -142
- package/dist/index.js +0 -1
- package/dist/smart-wallets.js +0 -1
- package/dist/solana.js +0 -1
- package/dist/ui.js +0 -142
|
@@ -0,0 +1,2448 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { MouseEvent } from 'react';
|
|
3
|
+
import { C as Chain, W as WalletConnector, B as BaseConnectedEthereumWallet, a as RpcConfig, P as PrivyProxyProvider, E as Embedded1193Provider, b as WalletClientType, c as ConnectedWalletMetadata, d as ConnectorType, e as WalletListEntry, f as ExternalWalletsConfig, g as BaseConnectedWallet, S as SolanaWalletConnector, h as EIP1193Provider, U as User, O as OAuthTokens, i as OAuthProviderType, M as MoonpaySignRequest, j as MoonpaySignResponse, k as SmartWalletConfig, l as PrivyServerConfig, m as PrivyFarcasterSignerInitResponse, L as LoginMethod, n as SiweWalletMetadata, T as TelegramAuthResult, o as OAuthUserInfo, p as PrivyClientConfig, q as ConnectWalletModalOptions, r as LoginModalOptions, s as CreateWalletOptions, t as Wallet, u as SetWalletRecoveryOptions, v as SignMessageModalUIOptions, w as SignTypedDataParams, x as MfaMethod, y as UnsignedTransactionRequest, z as SendTransactionModalUIOptions, F as FundWalletConfig, A as TransactionReceipt, D as ConnectedWallet, G as PrivyIframeErrorTypesType, H as PrivyErrorCode, I as LinkedAccountWithMetadata, J as UserRecoveryMethod, K as FundingMethod, N as OAuthFlowState, Q as LoginWithCode, V as OtpFlowState, X as PasskeyFlowState, Y as SiweFlowState, Z as UnsignedTransactionRequestWithChainId, _ as CustomAuthFlowState } from './types.js';
|
|
4
|
+
export { ag as Apple, aq as AppleOAuthWithMetadata, $ as AsExternalProvider, aF as ConnectedSolanaWallet, ay as ContractUIOptions, aj as CrossAppAccount, at as CrossAppAccountWithMetadata, ad as Discord, am as DiscordOAuthWithMetadata, av as Email, a8 as EmailWithMetadata, aC as Farcaster, ar as FarcasterWithMetadata, ae as Github, an as GithubOAuthWithMetadata, ab as Google, ak as GoogleOAuthWithMetadata, af as LinkedIn, ap as LinkedInOAuthWithMetadata, aE as LoginMethodOrderOption, a1 as MessageTypes, a2 as MoonpayConfig, a3 as MoonpayCurrencyCode, aA as MoonpayFundingConfig, a4 as MoonpayPaymentMethod, az as NativeFundingConfig, a7 as NonEmptyArray, aD as Passkey, au as PasskeyWithMetadata, aw as Phone, a9 as PhoneWithMetadata, aB as PriceDisplayOptions, a5 as Quantity, ai as Telegram, as as TelegramWithMetadata, ah as Tiktok, ao as TiktokOAuthWithMetadata, a6 as TransactionLog, ax as TransactionUIOptions, ac as Twitter, al as TwitterOAuthWithMetadata, a0 as TypedMessage, aa as WalletWithMetadata } from './types.js';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import { TurnstileProps } from '@marsidev/react-turnstile';
|
|
7
|
+
import EventEmitter from 'eventemitter3';
|
|
8
|
+
import { Store, EIP6963ProviderDetail } from 'mipd';
|
|
9
|
+
import { Web3Provider, TransactionResponse } from '@ethersproject/providers';
|
|
10
|
+
import * as _simplewebauthn_types from '@simplewebauthn/types';
|
|
11
|
+
import { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
|
|
12
|
+
import * as _solana_wallet_adapter_base from '@solana/wallet-adapter-base';
|
|
13
|
+
import { SendTransactionOptions } from '@solana/wallet-adapter-base';
|
|
14
|
+
import * as _solana_web3_js from '@solana/web3.js';
|
|
15
|
+
import { Connection } from '@solana/web3.js';
|
|
16
|
+
import { AbstractProvider } from 'web3-core';
|
|
17
|
+
import { SupportedSolanaTransaction, SolanaTransactionReceipt } from './solana.js';
|
|
18
|
+
export { UseSolanaWalletsInterface, useSolanaWallets } from './solana.js';
|
|
19
|
+
import { SmartWalletType, PrivyCoinbaseOnRampInitInput, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampStatusResponse } from '@privy-io/public-api';
|
|
20
|
+
import { FetchOptions } from 'ofetch';
|
|
21
|
+
import '@metamask/eth-sig-util';
|
|
22
|
+
import 'libphonenumber-js/min';
|
|
23
|
+
import 'viem';
|
|
24
|
+
|
|
25
|
+
declare const DEFAULT_SUPPORTED_CHAINS: readonly [Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain];
|
|
26
|
+
|
|
27
|
+
interface ResponseEmailAccount {
|
|
28
|
+
type: 'email';
|
|
29
|
+
address: string;
|
|
30
|
+
verified_at: number;
|
|
31
|
+
first_verified_at: number | null;
|
|
32
|
+
latest_verified_at: number | null;
|
|
33
|
+
}
|
|
34
|
+
interface ResponsePhoneAccount {
|
|
35
|
+
type: 'phone';
|
|
36
|
+
phoneNumber: string;
|
|
37
|
+
verified_at: number;
|
|
38
|
+
first_verified_at: number | null;
|
|
39
|
+
latest_verified_at: number | null;
|
|
40
|
+
}
|
|
41
|
+
interface BaseResponseWalletAccount {
|
|
42
|
+
type: 'wallet';
|
|
43
|
+
address: string;
|
|
44
|
+
imported: boolean;
|
|
45
|
+
chain_type: 'ethereum' | 'solana';
|
|
46
|
+
chain_id?: string;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use `wallet_client_type` instead.
|
|
49
|
+
*/
|
|
50
|
+
wallet_client: 'privy' | 'unknown';
|
|
51
|
+
wallet_index: number | null;
|
|
52
|
+
wallet_client_type?: string;
|
|
53
|
+
connector_type?: string;
|
|
54
|
+
recovery_method?: 'privy' | 'user-passcode';
|
|
55
|
+
verified_at: number;
|
|
56
|
+
first_verified_at: number | null;
|
|
57
|
+
latest_verified_at: number | null;
|
|
58
|
+
}
|
|
59
|
+
interface ResponseEthereumAccount extends BaseResponseWalletAccount {
|
|
60
|
+
chain_type: 'ethereum';
|
|
61
|
+
}
|
|
62
|
+
interface ResponseSolanaAccount extends BaseResponseWalletAccount {
|
|
63
|
+
chain_type: 'solana';
|
|
64
|
+
}
|
|
65
|
+
interface ResponseSmartWalletAccount {
|
|
66
|
+
type: 'smart_wallet';
|
|
67
|
+
address: string;
|
|
68
|
+
smart_wallet_type: SmartWalletType;
|
|
69
|
+
verified_at: number;
|
|
70
|
+
first_verified_at: number | null;
|
|
71
|
+
latest_verified_at: number | null;
|
|
72
|
+
}
|
|
73
|
+
interface ResponseFarcasterAccount {
|
|
74
|
+
type: 'farcaster';
|
|
75
|
+
fid: number;
|
|
76
|
+
owner_address: string;
|
|
77
|
+
username: string | null;
|
|
78
|
+
display_name: string | null;
|
|
79
|
+
bio: string | null;
|
|
80
|
+
profile_picture_url: string | null;
|
|
81
|
+
homepage_url: string | null;
|
|
82
|
+
verified_at: number;
|
|
83
|
+
first_verified_at: number | null;
|
|
84
|
+
latest_verified_at: number | null;
|
|
85
|
+
signer_public_key: string | null;
|
|
86
|
+
}
|
|
87
|
+
interface ResponseOAuthGoogle {
|
|
88
|
+
type: 'google_oauth';
|
|
89
|
+
subject: string;
|
|
90
|
+
email: string;
|
|
91
|
+
name: string | null;
|
|
92
|
+
verified_at: number;
|
|
93
|
+
first_verified_at: number | null;
|
|
94
|
+
latest_verified_at: number | null;
|
|
95
|
+
}
|
|
96
|
+
interface ResponseOAuthTwitter {
|
|
97
|
+
type: 'twitter_oauth';
|
|
98
|
+
subject: string;
|
|
99
|
+
username: string | null;
|
|
100
|
+
name: string | null;
|
|
101
|
+
profile_picture_url: string | null;
|
|
102
|
+
verified_at: number;
|
|
103
|
+
first_verified_at: number | null;
|
|
104
|
+
latest_verified_at: number | null;
|
|
105
|
+
}
|
|
106
|
+
interface ResponseOAuthDiscord {
|
|
107
|
+
type: 'discord_oauth';
|
|
108
|
+
subject: string;
|
|
109
|
+
username: string | null;
|
|
110
|
+
email: string | null;
|
|
111
|
+
verified_at: number;
|
|
112
|
+
first_verified_at: number | null;
|
|
113
|
+
latest_verified_at: number | null;
|
|
114
|
+
}
|
|
115
|
+
interface ResponseOAuthGithub {
|
|
116
|
+
type: 'github_oauth';
|
|
117
|
+
subject: string;
|
|
118
|
+
username: string | null;
|
|
119
|
+
name: string | null;
|
|
120
|
+
email: string | null;
|
|
121
|
+
verified_at: number;
|
|
122
|
+
first_verified_at: number | null;
|
|
123
|
+
latest_verified_at: number | null;
|
|
124
|
+
}
|
|
125
|
+
interface ResponseOAuthSpotify {
|
|
126
|
+
type: 'spotify_oauth';
|
|
127
|
+
subject: string;
|
|
128
|
+
email: string | null;
|
|
129
|
+
name: string | null;
|
|
130
|
+
verified_at: number;
|
|
131
|
+
first_verified_at: number | null;
|
|
132
|
+
latest_verified_at: number | null;
|
|
133
|
+
}
|
|
134
|
+
interface ResponseOAuthInstagram {
|
|
135
|
+
type: 'instagram_oauth';
|
|
136
|
+
subject: string;
|
|
137
|
+
username: string | null;
|
|
138
|
+
verified_at: number;
|
|
139
|
+
first_verified_at: number | null;
|
|
140
|
+
latest_verified_at: number | null;
|
|
141
|
+
}
|
|
142
|
+
interface ResponseOAuthTiktok {
|
|
143
|
+
type: 'tiktok_oauth';
|
|
144
|
+
subject: string;
|
|
145
|
+
username: string | null;
|
|
146
|
+
name: string | null;
|
|
147
|
+
verified_at: number;
|
|
148
|
+
first_verified_at: number | null;
|
|
149
|
+
latest_verified_at: number | null;
|
|
150
|
+
}
|
|
151
|
+
interface ResponseOAuthLinkedIn {
|
|
152
|
+
type: 'linkedin_oauth';
|
|
153
|
+
subject: string;
|
|
154
|
+
name: string | null;
|
|
155
|
+
email: string | null;
|
|
156
|
+
vanity_name: string | null;
|
|
157
|
+
verified_at: number;
|
|
158
|
+
first_verified_at: number | null;
|
|
159
|
+
latest_verified_at: number | null;
|
|
160
|
+
}
|
|
161
|
+
interface ResponseOAuthApple {
|
|
162
|
+
type: 'apple_oauth';
|
|
163
|
+
subject: string;
|
|
164
|
+
email: string;
|
|
165
|
+
verified_at: number;
|
|
166
|
+
first_verified_at: number | null;
|
|
167
|
+
latest_verified_at: number | null;
|
|
168
|
+
}
|
|
169
|
+
interface ResponseCustomJwtAccount {
|
|
170
|
+
type: 'custom_auth';
|
|
171
|
+
custom_user_id: string;
|
|
172
|
+
verified_at: number;
|
|
173
|
+
first_verified_at: number | null;
|
|
174
|
+
latest_verified_at: number | null;
|
|
175
|
+
}
|
|
176
|
+
interface ResponsePasskeyAccount {
|
|
177
|
+
type: 'passkey';
|
|
178
|
+
credential_id: string;
|
|
179
|
+
enrolled_in_mfa: boolean;
|
|
180
|
+
authenticator_name?: string;
|
|
181
|
+
created_with_device?: string;
|
|
182
|
+
created_with_os?: string;
|
|
183
|
+
created_with_browser?: string;
|
|
184
|
+
verified_at: number;
|
|
185
|
+
first_verified_at: number | null;
|
|
186
|
+
latest_verified_at: number | null;
|
|
187
|
+
}
|
|
188
|
+
interface ResponseTelegramAccount {
|
|
189
|
+
type: 'telegram';
|
|
190
|
+
telegram_user_id: string;
|
|
191
|
+
first_name: string | null;
|
|
192
|
+
last_name: string | null;
|
|
193
|
+
username: string | null;
|
|
194
|
+
photo_url: string | null;
|
|
195
|
+
first_verified_at: number | null;
|
|
196
|
+
latest_verified_at: number | null;
|
|
197
|
+
}
|
|
198
|
+
interface ResponseCrossAppAccount {
|
|
199
|
+
type: 'cross_app';
|
|
200
|
+
subject: string;
|
|
201
|
+
embedded_wallets: {
|
|
202
|
+
address: string;
|
|
203
|
+
}[];
|
|
204
|
+
smart_wallets: {
|
|
205
|
+
address: string;
|
|
206
|
+
}[];
|
|
207
|
+
provider_app_id: string;
|
|
208
|
+
verified_at: number;
|
|
209
|
+
first_verified_at: number | null;
|
|
210
|
+
latest_verified_at: number | null;
|
|
211
|
+
}
|
|
212
|
+
type LinkedAccountsResponseType = Array<ResponseEmailAccount | ResponsePhoneAccount | ResponseEthereumAccount | ResponseSmartWalletAccount | ResponseSolanaAccount | ResponseOAuthGoogle | ResponseOAuthTwitter | ResponseOAuthDiscord | ResponseOAuthGithub | ResponseOAuthSpotify | ResponseOAuthInstagram | ResponseOAuthTiktok | ResponseOAuthLinkedIn | ResponseOAuthApple | ResponseCustomJwtAccount | ResponseFarcasterAccount | ResponsePasskeyAccount | ResponseTelegramAccount | ResponseCrossAppAccount>;
|
|
213
|
+
interface ResponseSmsMfaMethod {
|
|
214
|
+
type: 'sms';
|
|
215
|
+
verified_at: number;
|
|
216
|
+
}
|
|
217
|
+
type LinkedMfaMethodsResponseType = Array<ResponseSmsMfaMethod>;
|
|
218
|
+
interface GetCurrentUserResponse {
|
|
219
|
+
id: string;
|
|
220
|
+
is_guest: boolean;
|
|
221
|
+
created_at: number;
|
|
222
|
+
linked_accounts: LinkedAccountsResponseType;
|
|
223
|
+
mfa_methods: LinkedMfaMethodsResponseType;
|
|
224
|
+
has_accepted_terms: boolean;
|
|
225
|
+
oauth_tokens?: {
|
|
226
|
+
provider: string;
|
|
227
|
+
access_token: string;
|
|
228
|
+
access_token_expires_in_seconds?: number;
|
|
229
|
+
refresh_token?: string;
|
|
230
|
+
refresh_token_expires_in_seconds?: number;
|
|
231
|
+
scopes?: string[];
|
|
232
|
+
};
|
|
233
|
+
custom_metadata?: Record<string, string>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
interface DefaultsType {
|
|
237
|
+
baseURL: string;
|
|
238
|
+
timeout: number;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* A raw http handler for making requests to the Privy API. It requires a Session
|
|
242
|
+
* object, which is used for fetching and including any tokens that are required
|
|
243
|
+
* for requests.
|
|
244
|
+
*
|
|
245
|
+
* Should not be used for external requests, as we attach a good deal of metadata to requests.
|
|
246
|
+
*/
|
|
247
|
+
declare class Http {
|
|
248
|
+
fallbackApiUrl: string;
|
|
249
|
+
private appId;
|
|
250
|
+
private appClientId?;
|
|
251
|
+
private client;
|
|
252
|
+
private defaults;
|
|
253
|
+
private sdkVersion;
|
|
254
|
+
private baseFetch;
|
|
255
|
+
private clientAnalyticsId;
|
|
256
|
+
constructor({ appId, appClientId, client, defaults, }: {
|
|
257
|
+
appId: string;
|
|
258
|
+
appClientId?: string;
|
|
259
|
+
client: PrivyClient;
|
|
260
|
+
defaults: DefaultsType;
|
|
261
|
+
});
|
|
262
|
+
get<T = any>(path: string, config?: FetchOptions<'json'>): Promise<T>;
|
|
263
|
+
post<T = any, D = any>(path: string, data?: D, config?: FetchOptions<'json'>): Promise<T>;
|
|
264
|
+
delete<T = any>(path: string, config?: FetchOptions<'json'>): Promise<T>;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Valid /session and <>/authenticate calls will respond with a token
|
|
269
|
+
* as well as a valid user object for streamlining.
|
|
270
|
+
*/
|
|
271
|
+
interface ValidSessionResponse {
|
|
272
|
+
user: GetCurrentUserResponse;
|
|
273
|
+
token: string;
|
|
274
|
+
refresh_token: string | null;
|
|
275
|
+
identity_token?: string;
|
|
276
|
+
is_new_user?: boolean;
|
|
277
|
+
session_update_action?: 'set' | 'ignore' | 'clear';
|
|
278
|
+
oauth_tokens?: {
|
|
279
|
+
provider: string;
|
|
280
|
+
access_token: string;
|
|
281
|
+
access_token_expires_in_seconds?: number;
|
|
282
|
+
refresh_token?: string;
|
|
283
|
+
refresh_token_expires_in_seconds?: number;
|
|
284
|
+
scopes?: string[];
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
type AuthMeta = {
|
|
289
|
+
[key: string]: any;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* An auth flow is an encapsulation of the business logic required for a given
|
|
293
|
+
* authentication process. It requires at least one definitive `authenticate`
|
|
294
|
+
* method that does the final token handshaking with the API, but may also
|
|
295
|
+
* include any number of methods/API calls necessary to set up the state (e.g.
|
|
296
|
+
* sending an email before being able to do a passwordless code login)
|
|
297
|
+
*/
|
|
298
|
+
interface AuthFlow {
|
|
299
|
+
api?: Http;
|
|
300
|
+
/**
|
|
301
|
+
* Any meta information necessary for the auth flow, that may also need to be
|
|
302
|
+
* shared out to things like frontend components for displaying state of the
|
|
303
|
+
* auth flow
|
|
304
|
+
*/
|
|
305
|
+
meta: AuthMeta;
|
|
306
|
+
/**
|
|
307
|
+
* Handles the API authentication call(s) to log users in.
|
|
308
|
+
* Any preconditions must be addressed prior to calling
|
|
309
|
+
*/
|
|
310
|
+
authenticate(): Promise<ValidSessionResponse>;
|
|
311
|
+
/**
|
|
312
|
+
* Handles the API link call(s) to link new user accounts.
|
|
313
|
+
* Requires user to already be logged in when called.
|
|
314
|
+
* Any preconditions must be addressed prior to calling
|
|
315
|
+
*/
|
|
316
|
+
link(): Promise<GetCurrentUserResponse>;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
declare abstract class EthereumWalletConnector extends WalletConnector {
|
|
320
|
+
wallets: BaseConnectedEthereumWallet[];
|
|
321
|
+
chains: Chain[];
|
|
322
|
+
defaultChain: Chain;
|
|
323
|
+
rpcConfig: RpcConfig;
|
|
324
|
+
rpcTimeoutDuration: number;
|
|
325
|
+
chainType: "ethereum";
|
|
326
|
+
abstract proxyProvider: PrivyProxyProvider | Embedded1193Provider;
|
|
327
|
+
constructor(walletClientType: WalletClientType, chains: Chain[], defaultChain: Chain, rpcConfig: RpcConfig);
|
|
328
|
+
/**
|
|
329
|
+
* Builds a connected wallet object to be exposed to the developer. This object
|
|
330
|
+
* contains the address, chainId, and a few helper methods.
|
|
331
|
+
*
|
|
332
|
+
* Provider methods share the PrivyProxyProvider instance. This means that multiple
|
|
333
|
+
* wallets may share the same provider if one wallet was disconnected and another
|
|
334
|
+
* wallet was connected.
|
|
335
|
+
*
|
|
336
|
+
* A wallet is considered connected if it is present in the wallets array and is
|
|
337
|
+
* in a connected state.
|
|
338
|
+
*/
|
|
339
|
+
buildConnectedWallet(address: string, chainId: string, meta: ConnectedWalletMetadata, imported: boolean): BaseConnectedEthereumWallet;
|
|
340
|
+
/**
|
|
341
|
+
* Sync all accounts available via the provider if the wallet is connected.
|
|
342
|
+
*
|
|
343
|
+
* @param prefetchedAccounts - pass in an accounts array from eth_accounts if already fetched to avoid a repeated call
|
|
344
|
+
*/
|
|
345
|
+
syncAccounts(prefetchedAccounts?: string[]): Promise<void>;
|
|
346
|
+
/**
|
|
347
|
+
* Get the most recently connected wallet.
|
|
348
|
+
*/
|
|
349
|
+
getConnectedWallet(): Promise<BaseConnectedEthereumWallet | null>;
|
|
350
|
+
/**
|
|
351
|
+
* As a proxy for "connected", we call eth_accounts and consider the client
|
|
352
|
+
* connected if at least one account is returned.
|
|
353
|
+
*/
|
|
354
|
+
isConnected(): Promise<boolean>;
|
|
355
|
+
/**
|
|
356
|
+
* Perform personal_sign with the user's wallet.
|
|
357
|
+
*
|
|
358
|
+
* @param {string} message The message to sign.
|
|
359
|
+
* @returns {string} The resulting signature.
|
|
360
|
+
*/
|
|
361
|
+
sign(message: string): Promise<string>;
|
|
362
|
+
protected onAccountsChanged: (accounts: string[]) => void;
|
|
363
|
+
protected onChainChanged: (chainId: string) => void;
|
|
364
|
+
protected onDisconnect: () => void;
|
|
365
|
+
protected onConnect: () => void;
|
|
366
|
+
subscribeListeners(): void;
|
|
367
|
+
unsubscribeListeners(): void;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
declare class EmbeddedWalletConnector extends EthereumWalletConnector {
|
|
371
|
+
connectorType: ConnectorType;
|
|
372
|
+
walletIndex: number;
|
|
373
|
+
proxyProvider: Embedded1193Provider;
|
|
374
|
+
constructor({ provider, chains, defaultChain, rpcConfig, imported, walletIndex, }: {
|
|
375
|
+
provider: Embedded1193Provider;
|
|
376
|
+
chains: Chain[];
|
|
377
|
+
defaultChain: Chain;
|
|
378
|
+
rpcConfig: RpcConfig;
|
|
379
|
+
imported: boolean;
|
|
380
|
+
walletIndex: number;
|
|
381
|
+
});
|
|
382
|
+
initialize(): Promise<void>;
|
|
383
|
+
connect(options: {
|
|
384
|
+
chainId?: number;
|
|
385
|
+
}): Promise<BaseConnectedEthereumWallet | null>;
|
|
386
|
+
get walletBranding(): {
|
|
387
|
+
name: string;
|
|
388
|
+
icon: ({ ...props }: React.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
|
|
389
|
+
id: string;
|
|
390
|
+
};
|
|
391
|
+
disconnect(): void;
|
|
392
|
+
promptConnection(): Promise<void>;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
interface ConnectorManagerEvents {
|
|
396
|
+
walletsUpdated(): void;
|
|
397
|
+
connectorInitialized(): void;
|
|
398
|
+
}
|
|
399
|
+
declare class ConnectorManager extends EventEmitter<ConnectorManagerEvents> {
|
|
400
|
+
walletConnectors: WalletConnector[];
|
|
401
|
+
initialized: boolean;
|
|
402
|
+
private storedConnections;
|
|
403
|
+
private activeWallet?;
|
|
404
|
+
private privyAppId;
|
|
405
|
+
private privyAppLogo?;
|
|
406
|
+
private walletConnectCloudProjectId;
|
|
407
|
+
private rpcConfig;
|
|
408
|
+
private chains;
|
|
409
|
+
private defaultChain;
|
|
410
|
+
private store;
|
|
411
|
+
private walletList;
|
|
412
|
+
private shouldEnforceDefaultChainOnConnect;
|
|
413
|
+
private privyAppName;
|
|
414
|
+
private externalWalletConfig;
|
|
415
|
+
constructor(privyAppId: string, walletConnectCloudProjectId: string, rpcConfig: RpcConfig, chains: Chain[], defaultChain: Chain, store: Store, walletList: WalletListEntry[], shouldEnforceDefaultChainOnConnect: boolean, externalWalletConfig: Required<ExternalWalletsConfig>, privyAppName: string, privyAppLogo?: string);
|
|
416
|
+
/**
|
|
417
|
+
* The core wallets array that is exposed to developers. It builds
|
|
418
|
+
* the wallets away with the following logic:
|
|
419
|
+
*
|
|
420
|
+
* 1. Flatten all wallets from all connectors
|
|
421
|
+
* 2. Sorted by connectedAt
|
|
422
|
+
* 3. Active wallet is moved to front of array (if it exists)
|
|
423
|
+
*/
|
|
424
|
+
get wallets(): BaseConnectedWallet[];
|
|
425
|
+
/**
|
|
426
|
+
* Helper function to find a wallet connector by connector type and wallet client type.
|
|
427
|
+
*/
|
|
428
|
+
findWalletConnector(connectorType: ConnectorType, walletClientType: string): EthereumWalletConnector | null;
|
|
429
|
+
/**
|
|
430
|
+
* Helper function to find a solana wallet connector by connector type and wallet client type.
|
|
431
|
+
*/
|
|
432
|
+
findSolanaWalletConnector(connectorType: ConnectorType, walletClientType: string): SolanaWalletConnector | null;
|
|
433
|
+
/**
|
|
434
|
+
* Helper function to find all embedded HD wallet connectors with `connectorType: 'embedded'`.
|
|
435
|
+
* Does not include embedded imported wallet connectors, which have `connectorType: 'embedded_imported'`.
|
|
436
|
+
*/
|
|
437
|
+
findEmbeddedWalletConnectors(): EmbeddedWalletConnector[];
|
|
438
|
+
/**
|
|
439
|
+
* Creates a new wallet connector for the given connector type and wallet client type.
|
|
440
|
+
* If a connector already exists, it will be returned instead.
|
|
441
|
+
*/
|
|
442
|
+
createEthereumWalletConnector(connectorType: ConnectorType, walletClientType: string, providers?: {
|
|
443
|
+
eip6963InjectedProvider?: EIP6963ProviderDetail;
|
|
444
|
+
legacyInjectedProvider?: any;
|
|
445
|
+
}): Promise<EthereumWalletConnector | null>;
|
|
446
|
+
/**
|
|
447
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
448
|
+
* interfacing with wallets directly (wallets[0].getEthereumProvider()).
|
|
449
|
+
*
|
|
450
|
+
* Build an Ethereum provider for the most recently connected wallet.
|
|
451
|
+
*/
|
|
452
|
+
getEthereumProvider: () => EIP1193Provider;
|
|
453
|
+
/**
|
|
454
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
455
|
+
* interfacing with `wallets` directly.
|
|
456
|
+
*
|
|
457
|
+
* Performing personal_sign with the most recently connected wallet.
|
|
458
|
+
* If there is not a wallet connected, return null. Only supports signing with Ethereum
|
|
459
|
+
* wallets.
|
|
460
|
+
*/
|
|
461
|
+
activeWalletSign(message: string): Promise<string | null>;
|
|
462
|
+
/**
|
|
463
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
464
|
+
* interfacing with `wallets` directly.
|
|
465
|
+
*/
|
|
466
|
+
setActiveWallet(address: string): void;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* This should not be directly used by developers at the moment,
|
|
471
|
+
* so we doc-ignore it.
|
|
472
|
+
* @ignore
|
|
473
|
+
*
|
|
474
|
+
*/
|
|
475
|
+
declare class PrivyClient {
|
|
476
|
+
#private;
|
|
477
|
+
private appId;
|
|
478
|
+
private appClientId?;
|
|
479
|
+
private session;
|
|
480
|
+
private timeout;
|
|
481
|
+
api: Http;
|
|
482
|
+
clientAnalyticsId: string | null;
|
|
483
|
+
useServerCookies: boolean;
|
|
484
|
+
apiUrl: string;
|
|
485
|
+
fallbackApiUrl: string;
|
|
486
|
+
authFlow?: AuthFlow;
|
|
487
|
+
connectors?: ConnectorManager;
|
|
488
|
+
onStoreToken?: ((token: string | null) => void) | undefined;
|
|
489
|
+
onDeleteToken?: (() => void) | undefined;
|
|
490
|
+
/**
|
|
491
|
+
* Creates a new Privy client.
|
|
492
|
+
* @param options Initialization options.
|
|
493
|
+
*/
|
|
494
|
+
constructor(options: {
|
|
495
|
+
/**
|
|
496
|
+
* The URL of the Privy API. Defaults to `https://auth.privy.io`.
|
|
497
|
+
*/
|
|
498
|
+
apiUrl?: string;
|
|
499
|
+
/**
|
|
500
|
+
* The app id from your dashboard
|
|
501
|
+
*/
|
|
502
|
+
appId: string;
|
|
503
|
+
/**
|
|
504
|
+
* The app client id from your dashboard
|
|
505
|
+
*/
|
|
506
|
+
appClientId?: string;
|
|
507
|
+
/**
|
|
508
|
+
* Time in milliseconds after which to timeout requests to the API. Defaults to `10000` (10 seconds).
|
|
509
|
+
*/
|
|
510
|
+
timeout?: number;
|
|
511
|
+
});
|
|
512
|
+
/**
|
|
513
|
+
* ConnectorManager initialization is deferred because the input parameter may be overridden by the server
|
|
514
|
+
* config. We can set this once and only once. If it is set twice, event listeners will be created
|
|
515
|
+
* on the first ConnectorManager and are not re-created.
|
|
516
|
+
*/
|
|
517
|
+
initializeConnectorManager({ walletConnectCloudProjectId, rpcConfig, chains, defaultChain, store, walletList, shouldEnforceDefaultChainOnConnect, externalWalletConfig, appName, }: {
|
|
518
|
+
walletConnectCloudProjectId: string;
|
|
519
|
+
rpcConfig: RpcConfig;
|
|
520
|
+
chains: Chain[];
|
|
521
|
+
defaultChain: Chain;
|
|
522
|
+
store: Store;
|
|
523
|
+
walletList: WalletListEntry[];
|
|
524
|
+
shouldEnforceDefaultChainOnConnect: boolean;
|
|
525
|
+
externalWalletConfig: Required<ExternalWalletsConfig>;
|
|
526
|
+
appName: string;
|
|
527
|
+
}): void;
|
|
528
|
+
generateApi(): Http;
|
|
529
|
+
/**
|
|
530
|
+
* In the case of cookie-based auth, re-initialize the http client with the custom api url.
|
|
531
|
+
* @param customApiUrl the custom api url to use for cookie-based authFlow
|
|
532
|
+
*/
|
|
533
|
+
updateApiUrl(customApiUrl?: string | null): void;
|
|
534
|
+
authenticate(): Promise<{
|
|
535
|
+
user: User | null;
|
|
536
|
+
isNewUser?: boolean;
|
|
537
|
+
oAuthTokens?: OAuthTokens;
|
|
538
|
+
}>;
|
|
539
|
+
link(): Promise<{
|
|
540
|
+
user: User | null;
|
|
541
|
+
oAuthTokens: OAuthTokens | undefined;
|
|
542
|
+
}>;
|
|
543
|
+
storeProviderAccessToken(appId: string, providerAccessToken: string | null): void;
|
|
544
|
+
getProviderAccessToken(appId: string): string | null;
|
|
545
|
+
logout(): Promise<void>;
|
|
546
|
+
clearProviderAcccessTokens(user: User): void;
|
|
547
|
+
startAuthFlow<T extends AuthFlow>(authFlow: T): T;
|
|
548
|
+
initMfaSmsVerification(): Promise<void>;
|
|
549
|
+
initMfaPasskeyVerification(): Promise<{
|
|
550
|
+
challenge: string;
|
|
551
|
+
allowCredentials: {
|
|
552
|
+
id: string;
|
|
553
|
+
type: "public-key";
|
|
554
|
+
transports: AuthenticatorTransport[];
|
|
555
|
+
}[];
|
|
556
|
+
timeout: number | undefined;
|
|
557
|
+
extensions: {
|
|
558
|
+
appid: string | undefined;
|
|
559
|
+
credProps: boolean | undefined;
|
|
560
|
+
hmacCreateSecret: boolean | undefined;
|
|
561
|
+
};
|
|
562
|
+
userVerification: UserVerificationRequirement;
|
|
563
|
+
}>;
|
|
564
|
+
acceptTerms(): Promise<User>;
|
|
565
|
+
unlinkEmail(address: string): Promise<User>;
|
|
566
|
+
unlinkPhone(phoneNumber: string): Promise<User>;
|
|
567
|
+
unlinkEthereumWallet(address: string): Promise<User>;
|
|
568
|
+
unlinkSolanaWallet(address: string): Promise<User>;
|
|
569
|
+
unlinkOAuth(provider: OAuthProviderType | `privy:${string}`, subject: string): Promise<User>;
|
|
570
|
+
unlinkFarcaster(fid: number): Promise<User>;
|
|
571
|
+
unlinkTelegram(telegramUserId: string): Promise<User>;
|
|
572
|
+
unlinkPasskey(credentialId: string): Promise<User>;
|
|
573
|
+
createAnalyticsEvent({ eventName, payload, timestamp, options, }: {
|
|
574
|
+
eventName: string;
|
|
575
|
+
payload?: {
|
|
576
|
+
[key: string]: any;
|
|
577
|
+
};
|
|
578
|
+
timestamp?: Date;
|
|
579
|
+
options?: {
|
|
580
|
+
keepAlive?: boolean;
|
|
581
|
+
};
|
|
582
|
+
}): Promise<void>;
|
|
583
|
+
signMoonpayOnRampUrl(signRequestData: MoonpaySignRequest): Promise<MoonpaySignResponse>;
|
|
584
|
+
initCoinbaseOnRamp(input: PrivyCoinbaseOnRampInitInput): Promise<PrivyCoinbaseOnRampInitResponse>;
|
|
585
|
+
getCoinbaseOnRampStatus({ partnerUserId, }: {
|
|
586
|
+
partnerUserId: string;
|
|
587
|
+
}): Promise<PrivyCoinbaseOnRampStatusResponse>;
|
|
588
|
+
/** DATA METHODS */
|
|
589
|
+
/**
|
|
590
|
+
* Fetches the currently authenticed user from the API or
|
|
591
|
+
* returns null if the user is not authenticated.
|
|
592
|
+
*
|
|
593
|
+
* This will refresh the user's access token and rotate
|
|
594
|
+
* the refresh token if needed.
|
|
595
|
+
*
|
|
596
|
+
* @returns Promise<User | null>
|
|
597
|
+
*/
|
|
598
|
+
getAuthenticatedUser(): Promise<User | null>;
|
|
599
|
+
/**
|
|
600
|
+
* Grab the Privy access token for the currently logged in user. Verifies that the
|
|
601
|
+
* token has a valid signature, was issued by 'privy.io', and corresponds to the
|
|
602
|
+
* current app ID. If no valid token is found, this method will force a logout and return null.
|
|
603
|
+
*
|
|
604
|
+
* If the token is expired or expiring soon, this will attempt to
|
|
605
|
+
* first refresh the access token to ensure that the token is active. You can
|
|
606
|
+
* disable this behavior using `disableAutoRefresh`, although it is not
|
|
607
|
+
* recommended.
|
|
608
|
+
*
|
|
609
|
+
* @param disableAutoRefresh not recommended - optionally disable automatic
|
|
610
|
+
* token refresh when the token is
|
|
611
|
+
*
|
|
612
|
+
* @returns Promise<string | null>
|
|
613
|
+
*/
|
|
614
|
+
getAccessToken(options?: {
|
|
615
|
+
disableAutoRefresh?: boolean;
|
|
616
|
+
}): Promise<string | null>;
|
|
617
|
+
getSmartWalletsConfig(): Promise<SmartWalletConfig>;
|
|
618
|
+
getServerConfig(): Promise<PrivyServerConfig>;
|
|
619
|
+
getUsdTokenPrice(chain: Chain): Promise<number | undefined>;
|
|
620
|
+
getUsdPriceForSol(): Promise<number | undefined>;
|
|
621
|
+
requestFarcasterSignerStatus(publicKey: string): Promise<PrivyFarcasterSignerInitResponse>;
|
|
622
|
+
/**
|
|
623
|
+
* Get a short-lived token to start a new Privy session from the existing authenticated session.
|
|
624
|
+
*
|
|
625
|
+
* Rotates the access token and refresh token.
|
|
626
|
+
* Raises an exception if the current session was already forked from a previous session,
|
|
627
|
+
* or if the current session is not authenticated.
|
|
628
|
+
*
|
|
629
|
+
* @returns Promise<string>
|
|
630
|
+
*/
|
|
631
|
+
forkSession(): Promise<string>;
|
|
632
|
+
/**
|
|
633
|
+
* Headless method to authenticate a smart wallet via the Sign-In with Ethereum spec.
|
|
634
|
+
*
|
|
635
|
+
* @returns The user object.
|
|
636
|
+
*/
|
|
637
|
+
linkSmartWallet({ message, signature, smartWalletType, }: {
|
|
638
|
+
message: string;
|
|
639
|
+
signature: string;
|
|
640
|
+
smartWalletType: SmartWalletType;
|
|
641
|
+
}): Promise<User>;
|
|
642
|
+
/**
|
|
643
|
+
* Headless method to link a new wallet via the Sign-In with Ethereum spec.
|
|
644
|
+
*
|
|
645
|
+
* @returns The user object.
|
|
646
|
+
*/
|
|
647
|
+
linkWithSiwe({ message, signature, chainId, walletClientType, connectorType, }: {
|
|
648
|
+
message: string;
|
|
649
|
+
signature: string;
|
|
650
|
+
chainId: string;
|
|
651
|
+
walletClientType?: string;
|
|
652
|
+
connectorType?: string;
|
|
653
|
+
}): Promise<User>;
|
|
654
|
+
/**
|
|
655
|
+
*
|
|
656
|
+
*/
|
|
657
|
+
sendAccountTransferRequest({ nonce, account, accountType, externalWalletMetadata, telegramAuthResult, farcasterEmbeddedAddress, oAuthUserInfo, }: {
|
|
658
|
+
nonce: string;
|
|
659
|
+
account: string;
|
|
660
|
+
accountType: LoginMethod;
|
|
661
|
+
externalWalletMetadata?: SiweWalletMetadata;
|
|
662
|
+
telegramAuthResult?: TelegramAuthResult;
|
|
663
|
+
farcasterEmbeddedAddress?: string;
|
|
664
|
+
oAuthUserInfo?: OAuthUserInfo;
|
|
665
|
+
}): Promise<User>;
|
|
666
|
+
/**
|
|
667
|
+
* Headless method to link a new wallet via the Sign-In with Solana spec.
|
|
668
|
+
*
|
|
669
|
+
* @returns The user object.
|
|
670
|
+
*/
|
|
671
|
+
linkWithSiws({ message, signature, walletClientType, connectorType, }: {
|
|
672
|
+
message: string;
|
|
673
|
+
signature: string;
|
|
674
|
+
walletClientType?: string;
|
|
675
|
+
connectorType?: string;
|
|
676
|
+
}): Promise<User>;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
declare function getAccessToken(): Promise<string | null>;
|
|
680
|
+
/**
|
|
681
|
+
* Properties to initialize the {@link PrivyProvider}.
|
|
682
|
+
*/
|
|
683
|
+
interface PrivyProviderProps {
|
|
684
|
+
/** Your Privy App ID, which can be retrieved from the Privy dashboard. */
|
|
685
|
+
appId: string;
|
|
686
|
+
/** Your Privy App Client ID, which can be retrieved from the Privy dashboard. */
|
|
687
|
+
clientId?: string;
|
|
688
|
+
/**
|
|
689
|
+
* @deprecated. Use the `onSuccess` callback registered via the `useLogin` hook instead.
|
|
690
|
+
*
|
|
691
|
+
* An optional callback that will execute once a `login` call successfully completes.
|
|
692
|
+
*
|
|
693
|
+
* Within this callback, you can access:
|
|
694
|
+
* - the `user` object corresponding to the authenticated user
|
|
695
|
+
* - an `isNewUser` boolean flag indicating if this is the user's first time logging in to your app
|
|
696
|
+
*
|
|
697
|
+
*/
|
|
698
|
+
onSuccess?: (user: User, isNewUser: boolean) => void;
|
|
699
|
+
/**
|
|
700
|
+
* @deprecated use `config.embeddedWallets.createOnLogin` instead
|
|
701
|
+
*/
|
|
702
|
+
createPrivyWalletOnLogin?: boolean;
|
|
703
|
+
/**
|
|
704
|
+
* Client configuration options.
|
|
705
|
+
* Values here will override their server-configuration counterparts.
|
|
706
|
+
*/
|
|
707
|
+
config?: PrivyClientConfig;
|
|
708
|
+
/**
|
|
709
|
+
* @ignore
|
|
710
|
+
* @class
|
|
711
|
+
*/
|
|
712
|
+
children: react__default.ReactNode;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Passes the Privy authentication context to your React components.
|
|
716
|
+
*
|
|
717
|
+
* This should wrap any components that will to use the Privy SDK via the {@link usePrivy} hook. As an example:
|
|
718
|
+
*
|
|
719
|
+
* ```typescript
|
|
720
|
+
* // At your application root (e.g. `_app.tsx` in NextJS):
|
|
721
|
+
* import {PrivyProvider} from '@privy-io/react-auth';
|
|
722
|
+
*
|
|
723
|
+
* <PrivyProvider appId="APP_ID_FROM_DASHBOARD" onSuccess={() => console.log('Success!')}>
|
|
724
|
+
* <Component {...pageProps} />
|
|
725
|
+
* </PrivyProvider>
|
|
726
|
+
* ```
|
|
727
|
+
*
|
|
728
|
+
*/
|
|
729
|
+
declare const PrivyProvider: ({ config, ...props }: PrivyProviderProps) => JSX.Element;
|
|
730
|
+
|
|
731
|
+
type CaptchaProps = Partial<Pick<TurnstileProps, 'onUnsupported' | 'onError' | 'onSuccess' | 'onExpire' | 'onSubmit'>> & {
|
|
732
|
+
delayedExecution?: boolean;
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* Used to render an invisible captcha alongside important forms
|
|
736
|
+
*
|
|
737
|
+
* Notes:
|
|
738
|
+
* - **Only for internal use, or use with headless SDK** _(the Privy modal handles captchas internally with this component)_
|
|
739
|
+
* - Only one `<Captcha />` should be rendered at a time, since it injects/removes a global script
|
|
740
|
+
* - the state of the captcha workflow can be accessed using `useCaptcha`
|
|
741
|
+
* - wrapper around [marsidev/react-turnstile](https://github.com/marsidev/react-turnstile), _accepts same [props](https://docs.page/marsidev/react-turnstile/props)_
|
|
742
|
+
*/
|
|
743
|
+
declare const Captcha: (props: CaptchaProps) => react_jsx_runtime.JSX.Element | null;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Allows you to manage the user's current authentication state and access their linked accounts.
|
|
747
|
+
* You can access the fields and methods documented here via the {@link usePrivy} hook.
|
|
748
|
+
*/
|
|
749
|
+
interface PrivyInterface {
|
|
750
|
+
/**
|
|
751
|
+
* Check whether the `PrivyProvider` is ready to be used. You should wait for this to
|
|
752
|
+
* be true before using values such as `authenticated` and `user`.
|
|
753
|
+
*/
|
|
754
|
+
ready: boolean;
|
|
755
|
+
/**
|
|
756
|
+
* True if the user is authenticated, false otherwise.
|
|
757
|
+
*
|
|
758
|
+
* You should always check that `ready` is true before using this value. Otherwise,
|
|
759
|
+
* the value may outdated while the Privy client fetches fresh tokens.
|
|
760
|
+
*
|
|
761
|
+
*/
|
|
762
|
+
authenticated: boolean;
|
|
763
|
+
/**
|
|
764
|
+
* The user object, or null if the user is not authenticated.
|
|
765
|
+
*/
|
|
766
|
+
user: User | null;
|
|
767
|
+
/**
|
|
768
|
+
* Opens the Privy modal and prompts the user to connect a wallet.
|
|
769
|
+
* @param options.suggestedAddress {string} (optional) wallet address that you wish to prompt the user to explicitly connect, if included
|
|
770
|
+
*/
|
|
771
|
+
connectWallet: (options?: ConnectWalletModalOptions | MouseEvent<any, any>) => void;
|
|
772
|
+
/**
|
|
773
|
+
* Opens the Privy login modal and prompts the user to login.
|
|
774
|
+
* @param options.loginMethods {LoginMethod[]} custom login methods to display in the login modal. This will overwrite the value provider to the client config.
|
|
775
|
+
* @param options.prefill {PrefillLoginOptions} prefill the login modal with the provided email or phone number.
|
|
776
|
+
*/
|
|
777
|
+
login: (options?: LoginModalOptions | MouseEvent<any, any>) => void;
|
|
778
|
+
/**
|
|
779
|
+
* Opens the Privy login modal and prompts the user to login or connect a wallet.
|
|
780
|
+
*/
|
|
781
|
+
connectOrCreateWallet: () => void;
|
|
782
|
+
/**
|
|
783
|
+
* For users who are authenticated, opens the Privy modal and prompts the user to link an email.
|
|
784
|
+
* This will open the Privy Modal which will guide the user through this action.
|
|
785
|
+
*/
|
|
786
|
+
linkEmail: () => void;
|
|
787
|
+
/**
|
|
788
|
+
* For users who are authenticated, opens the Privy modal and prompts the user to link a phone number.
|
|
789
|
+
* This will open the Privy Modal which will guide the user through this action.
|
|
790
|
+
*/
|
|
791
|
+
linkPhone: () => void;
|
|
792
|
+
/**
|
|
793
|
+
* For users who are authenticated, opens the Privy modal and prompts the user to link a wallet.
|
|
794
|
+
* This will open the Privy Modal which will guide the user through this action.
|
|
795
|
+
*/
|
|
796
|
+
linkWallet: () => void;
|
|
797
|
+
/**
|
|
798
|
+
* For users who are authenticated, opens the Privy modal and prompts the user to link a Farcaster account.
|
|
799
|
+
* This will open the Privy Modal which will guide the user through this action.
|
|
800
|
+
*/
|
|
801
|
+
linkFarcaster: () => void;
|
|
802
|
+
/**
|
|
803
|
+
* For users who are authenticated, prompts the user to link a Google OAuth account.
|
|
804
|
+
* This will directly initiate the OAuth flow for Google.
|
|
805
|
+
*/
|
|
806
|
+
linkGoogle: () => void;
|
|
807
|
+
/**
|
|
808
|
+
* For users who are authenticated, prompts the user to link a Twitter OAuth account
|
|
809
|
+
* This will directly initiate the OAuth flow for Twitter.
|
|
810
|
+
*/
|
|
811
|
+
linkTwitter: () => void;
|
|
812
|
+
/**
|
|
813
|
+
* For users who are authenticated, prompts the user to link Discord OAuth account
|
|
814
|
+
* This will directly initiate the OAuth flow for Discord.
|
|
815
|
+
*/
|
|
816
|
+
linkDiscord: () => void;
|
|
817
|
+
/**
|
|
818
|
+
* For users who are authenticated, prompts the user to link Github OAuth account
|
|
819
|
+
* This will directly initiate the OAuth flow for Github.
|
|
820
|
+
*/
|
|
821
|
+
linkGithub: () => void;
|
|
822
|
+
/**
|
|
823
|
+
* For users who are authenticated, prompts the user to link Spotify OAuth account
|
|
824
|
+
* This will directly initiate the OAuth flow for Spotify.
|
|
825
|
+
*/
|
|
826
|
+
linkSpotify: () => void;
|
|
827
|
+
/**
|
|
828
|
+
* For users who are authenticated, prompts the user to link Instagram OAuth account
|
|
829
|
+
* This will directly initiate the OAuth flow for Instagram.
|
|
830
|
+
*/
|
|
831
|
+
linkInstagram: () => void;
|
|
832
|
+
/**
|
|
833
|
+
* For users who are authenticated, prompts the user to link Tiktok OAuth account
|
|
834
|
+
* This will directly initiate the OAuth flow for Tiktok.
|
|
835
|
+
*/
|
|
836
|
+
linkTiktok: () => void;
|
|
837
|
+
/**
|
|
838
|
+
* For users who are authenticated, prompts the user to link LinkedIn OAuth account
|
|
839
|
+
* This will directly initiate the OAuth flow for LinkedIn.
|
|
840
|
+
*/
|
|
841
|
+
linkLinkedIn: () => void;
|
|
842
|
+
/**
|
|
843
|
+
* For users who are authenticated, prompts the user to link Apple OAuth account
|
|
844
|
+
* This will directly initiate the OAuth flow for Apple.
|
|
845
|
+
*/
|
|
846
|
+
linkApple: () => void;
|
|
847
|
+
/**
|
|
848
|
+
* For users who are authenticated, prompts the user to link a Passkey account
|
|
849
|
+
* This will open the Privy Modal which will guide the user through this action.
|
|
850
|
+
*/
|
|
851
|
+
linkPasskey: () => void;
|
|
852
|
+
/**
|
|
853
|
+
* @experimental
|
|
854
|
+
* For users who are authenticated, prompts the user to link a Telegram account
|
|
855
|
+
* This will directly initiate the auth flow for Telegram.
|
|
856
|
+
*/
|
|
857
|
+
linkTelegram: () => void;
|
|
858
|
+
/**
|
|
859
|
+
* For users who are authenticated and have already linked an email address, prompts the user to update their email address.
|
|
860
|
+
* This will open the Privy Modal which will guide the user through this action.
|
|
861
|
+
*
|
|
862
|
+
*/
|
|
863
|
+
updateEmail: () => void;
|
|
864
|
+
/**
|
|
865
|
+
* For users who are authenticated and have already linked a phone number, prompts the user to update their phone number.
|
|
866
|
+
* This will open the Privy Modal which will guide the user through this action.
|
|
867
|
+
*/
|
|
868
|
+
updatePhone: () => void;
|
|
869
|
+
/**
|
|
870
|
+
* Log the current user out and clears their authentication state. `authenticated` will become false, `user` will become null, and the Privy Auth tokens will be deleted from the browser's local storage.
|
|
871
|
+
*
|
|
872
|
+
* You may await this call to take an action once logout is complete (e.g. redirecting to a specific page).
|
|
873
|
+
*/
|
|
874
|
+
logout: () => Promise<void>;
|
|
875
|
+
/**
|
|
876
|
+
* Get the Privy access token ([JWT](https://jwt.io/)) for an authenticated user. Returns null for an unauthenticated user.
|
|
877
|
+
*
|
|
878
|
+
* You may use this token to authorize requests sent from your frontend, and can validate it in your backend against your app's Privy verification key.
|
|
879
|
+
*
|
|
880
|
+
* This will automatically attempt to refresh the session if the token is expired or about to expire.
|
|
881
|
+
*
|
|
882
|
+
* @returns Promise for the user's access token as a string if they are authenticated, null if they are unauthenticated.
|
|
883
|
+
*/
|
|
884
|
+
getAccessToken: () => Promise<string | null>;
|
|
885
|
+
/**
|
|
886
|
+
* @deprecated **Deprecated**: This method will be deprecated and should be replaced by calling `getEthereumProvider`
|
|
887
|
+
* directly on the `ConnectedWallet` objects returned by the `useWallets` hook, e.g.
|
|
888
|
+
*
|
|
889
|
+
* ```tsx
|
|
890
|
+
* const {wallets} = useWallets();
|
|
891
|
+
* const provider = await wallets[0].getEthereumProvider();
|
|
892
|
+
* ```
|
|
893
|
+
*
|
|
894
|
+
*
|
|
895
|
+
* Gets an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193)-compatible provider from the user's wallet, if the user has connected one.
|
|
896
|
+
*
|
|
897
|
+
* You may then use the Ethereum Javascript API syntax to send JSON-RPC requests to the user's wallet.
|
|
898
|
+
*/
|
|
899
|
+
getEthereumProvider: () => EIP1193Provider;
|
|
900
|
+
/**
|
|
901
|
+
* @deprecated **Deprecated**: This method will be deprecated and should be replaced by calling `getEthersProvider`
|
|
902
|
+
* directly on the `ConnectedWallet` objects returned by the `useWallets` hook, e.g.
|
|
903
|
+
*
|
|
904
|
+
* ```tsx
|
|
905
|
+
* const {wallets} = useWallets();
|
|
906
|
+
* const provider = await wallets[0].getEthersProvider();
|
|
907
|
+
* ```
|
|
908
|
+
*
|
|
909
|
+
* Get an [ethers.js](https://docs.ethers.io/v5/)-compatible provider from the user's wallet, if the user has connected one.
|
|
910
|
+
*
|
|
911
|
+
*/
|
|
912
|
+
getEthersProvider: () => Web3Provider;
|
|
913
|
+
/**
|
|
914
|
+
* @deprecated **Deprecated**: This feature will be deprecated and should be replaced by calling `getWeb3jsProvider`
|
|
915
|
+
* directly on the `ConnectedWallet` objects returned by the `useWallets` hook, e.g.
|
|
916
|
+
*
|
|
917
|
+
* ```tsx
|
|
918
|
+
* const {wallets} = useWallets();
|
|
919
|
+
* const provider = await wallets[0].getWeb3jsProvider();
|
|
920
|
+
* ```
|
|
921
|
+
*
|
|
922
|
+
* Get a [web3.js](https://web3js.readthedocs.io/en/v1.8.0/)-compatible provider from the user's wallet, if the user has connected one.
|
|
923
|
+
*/
|
|
924
|
+
getWeb3jsProvider: () => AbstractProvider;
|
|
925
|
+
/**
|
|
926
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by the
|
|
927
|
+
* `useWallets` hook.
|
|
928
|
+
*
|
|
929
|
+
* Get the ConnectorManager object
|
|
930
|
+
* This shouldn't need to be used directly unless creating a plugin, like a WAGMI plugin
|
|
931
|
+
*/
|
|
932
|
+
walletConnectors: ConnectorManager | null;
|
|
933
|
+
/**
|
|
934
|
+
* Unlink an email account from a user, by passing the email address. Note that you can only unlink an email account if the user has at least one other account.
|
|
935
|
+
*
|
|
936
|
+
* @param address {string} email address to be unlinked
|
|
937
|
+
* @returns Promise for the {@link User} object after the provided email has been unlinked
|
|
938
|
+
*/
|
|
939
|
+
unlinkEmail: (address: string) => Promise<User>;
|
|
940
|
+
/**
|
|
941
|
+
* Unlink a phone account from a user, by passing the phone number. Note that you can only unlink a phone account if the user has at least one other account.
|
|
942
|
+
*
|
|
943
|
+
* @param phoneNumber {string} phone number to be unlinked
|
|
944
|
+
* @returns Promise for the {@link User} object after the provided phone number has been unlinked
|
|
945
|
+
*/
|
|
946
|
+
unlinkPhone: (phoneNumber: string) => Promise<User>;
|
|
947
|
+
/**
|
|
948
|
+
* Unlink a wallet account from a user, by passing the public address. Note that you can only unlink a wallet account if the user has at least one other account.
|
|
949
|
+
* If the unlinked wallet was the active one, and more wallets are linked to the user, then we attempt to make the most recently linked wallet active.
|
|
950
|
+
*
|
|
951
|
+
* @param address {string} wallet address to be unlinked
|
|
952
|
+
* @returns Promise for the {@link User} object after the provided wallet has been unlinked
|
|
953
|
+
*/
|
|
954
|
+
unlinkWallet: (address: string) => Promise<User>;
|
|
955
|
+
/**
|
|
956
|
+
* Unlink a Google social account from a user, by passing the google subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
957
|
+
*
|
|
958
|
+
* @param subject {string} google account's subject ID
|
|
959
|
+
* @returns Promise for the {@link User} object after the provided Google account has been unlinked
|
|
960
|
+
*/
|
|
961
|
+
unlinkGoogle: (subject: string) => Promise<User>;
|
|
962
|
+
/**
|
|
963
|
+
* Unlink a Twitter social account from a user, by passing the twitter subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
964
|
+
*
|
|
965
|
+
* @param subject {string} twitter account's subject ID
|
|
966
|
+
* @returns Promise for the {@link User} object after the provided Twitter account has been unlinked
|
|
967
|
+
*/
|
|
968
|
+
unlinkTwitter: (subject: string) => Promise<User>;
|
|
969
|
+
/**
|
|
970
|
+
* Unlink a Discord social account from a user, by passing the discord subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
971
|
+
*
|
|
972
|
+
* @param subject {string} discord account's subject ID
|
|
973
|
+
* @returns Promise for the {@link User} object after the provided Discord account has been unlinked
|
|
974
|
+
*/
|
|
975
|
+
unlinkDiscord: (subject: string) => Promise<User>;
|
|
976
|
+
/**
|
|
977
|
+
* Unlink a Github social account from a user, by passing the github subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
978
|
+
*
|
|
979
|
+
* @param subject {string} github account's subject ID
|
|
980
|
+
* @returns Promise for the {@link User} object after the provided Github account has been unlinked
|
|
981
|
+
*/
|
|
982
|
+
unlinkGithub: (subject: string) => Promise<User>;
|
|
983
|
+
/**
|
|
984
|
+
* Unlink a Spotify social account from a user, by passing the spotify subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
985
|
+
*
|
|
986
|
+
* @param subject {string} spotify account's subject ID
|
|
987
|
+
* @returns Promise for the {@link User} object after the provided Spotify account has been unlinked
|
|
988
|
+
*/
|
|
989
|
+
unlinkSpotify: (subject: string) => Promise<User>;
|
|
990
|
+
/**
|
|
991
|
+
* Unlink a Instagram social account from a user, by passing the instagram subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
992
|
+
*
|
|
993
|
+
* @param subject {string} instagram account's subject ID
|
|
994
|
+
* @returns Promise for the {@link User} object after the provided Instagram account has been unlinked
|
|
995
|
+
*/
|
|
996
|
+
unlinkInstagram: (subject: string) => Promise<User>;
|
|
997
|
+
/**
|
|
998
|
+
* Unlink a Tiktok social account from a user, by passing the tiktok subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
999
|
+
*
|
|
1000
|
+
* @param subject {string} tiktok account's subject ID
|
|
1001
|
+
* @returns Promise for the {@link User} object after the provided Tiktok account has been unlinked
|
|
1002
|
+
*/
|
|
1003
|
+
unlinkTiktok: (subject: string) => Promise<User>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Unlink a LinkedIn social account from a user, by passing the linkedin subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
1006
|
+
*
|
|
1007
|
+
* @param subject {string} linkedin account's subject ID
|
|
1008
|
+
* @returns Promise for the {@link User} object after the provided LinkedIn account has been unlinked
|
|
1009
|
+
*/
|
|
1010
|
+
unlinkLinkedIn: (subject: string) => Promise<User>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Unlink a Apple social account from a user, by passing the apple subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
1013
|
+
*
|
|
1014
|
+
* @param subject {string} apple account's subject ID
|
|
1015
|
+
* @returns Promise for the {@link User} object after the provided Apple account has been unlinked
|
|
1016
|
+
*/
|
|
1017
|
+
unlinkApple: (subject: string) => Promise<User>;
|
|
1018
|
+
/**
|
|
1019
|
+
* Unlink a cross-app account from a user, by passing the apple subject ID. Note that you can only unlink this account if the user has at least one other account.
|
|
1020
|
+
*
|
|
1021
|
+
* @param subject {string} apple account's subject ID
|
|
1022
|
+
* @returns Promise for the {@link User} object after the provided cross-app account has been unlinked
|
|
1023
|
+
*/
|
|
1024
|
+
unlinkCrossAppAccount: ({ subject }: {
|
|
1025
|
+
subject: string;
|
|
1026
|
+
}) => Promise<User>;
|
|
1027
|
+
/**
|
|
1028
|
+
* Unlink a Farcaster account from a user, by passing the FID. Note that you can only unlink a phone account if the user has at least one other account.
|
|
1029
|
+
*
|
|
1030
|
+
* @param fid {number} Farcaster ID
|
|
1031
|
+
* @returns Promise for the {@link User} object after the provided Farcaster account has been unlinked
|
|
1032
|
+
*/
|
|
1033
|
+
unlinkFarcaster: (fid: number) => Promise<User>;
|
|
1034
|
+
/**
|
|
1035
|
+
* @experimental
|
|
1036
|
+
* Unlink a Telegram account from a user, by passing the Telegram subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
1037
|
+
*
|
|
1038
|
+
* @param telegramUserId {string} Telegram user ID of the linked account
|
|
1039
|
+
* @returns Promise for the {@link User} object after the provided Telegram account has been unlinked
|
|
1040
|
+
*/
|
|
1041
|
+
unlinkTelegram: (telegramUserId: string) => Promise<User>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Unlink a Passkey account from a user, by passing the credential ID. Note that you can only unlink a passkey account if the user has at least one other account.
|
|
1044
|
+
*
|
|
1045
|
+
* @param credentialId {string} Passkey Credential ID
|
|
1046
|
+
* @returns Promise for the {@link User} object after the provided passkey account has been unlinked
|
|
1047
|
+
*/
|
|
1048
|
+
unlinkPasskey: (credentialId: string) => Promise<User>;
|
|
1049
|
+
/**
|
|
1050
|
+
* @deprecated **Deprecated**: This feature will be removed and behaves the same as connectWallet(). Instead, please
|
|
1051
|
+
* interact with the wallets array directly.
|
|
1052
|
+
*
|
|
1053
|
+
* Note that when you connect a new wallet, it becomes first in the wallets array.
|
|
1054
|
+
*/
|
|
1055
|
+
setActiveWallet: (address: string) => Promise<void>;
|
|
1056
|
+
/**
|
|
1057
|
+
* @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
1058
|
+
*
|
|
1059
|
+
* Get a short-lived, one-time-use token to start a new Privy session from the existing authenticated session. Raises an exception if the current session was already forked from a previous session.
|
|
1060
|
+
*/
|
|
1061
|
+
forkSession: () => Promise<string>;
|
|
1062
|
+
/**
|
|
1063
|
+
* Creates an embedded wallet for the current user.
|
|
1064
|
+
*
|
|
1065
|
+
* This method will error if the user already has an embedded wallet or if they
|
|
1066
|
+
* exit in the middle of the flow.
|
|
1067
|
+
*
|
|
1068
|
+
* If the `config.embeddedWallets.requireUserOwnedRecoveryOnCreate` property is set to true,
|
|
1069
|
+
* this will prompt the user to complete a recovery flow to secure the recovery
|
|
1070
|
+
* share of their embedded wallet.
|
|
1071
|
+
*
|
|
1072
|
+
* Otherwise (the default), Privy will secure the recovery share, and the embedded wallet
|
|
1073
|
+
* will be created without showing any UIs to the user.
|
|
1074
|
+
*
|
|
1075
|
+
* @returns Promise for the {@link Wallet} object for the newly created embedded wallet
|
|
1076
|
+
*/
|
|
1077
|
+
createWallet: (options?: CreateWalletOptions | MouseEvent<any, any>) => Promise<Wallet>;
|
|
1078
|
+
/**
|
|
1079
|
+
* @deprecated. Use `setWalletRecovery` instead.
|
|
1080
|
+
*
|
|
1081
|
+
* Set (or reset) a password on a wallet.
|
|
1082
|
+
*
|
|
1083
|
+
* This method will error if the user does not have an embedded wallet or if the user exits in the middle of the flow.
|
|
1084
|
+
*
|
|
1085
|
+
* @returns Promise for the {@link Wallet} object for the updated embedded wallet
|
|
1086
|
+
*/
|
|
1087
|
+
setWalletPassword: () => Promise<Wallet>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Prompt the user to enable wallet recovery. Current recovery options include password, Google Drive, and iCloud.
|
|
1090
|
+
*
|
|
1091
|
+
* This method will error if the user does not have an embedded wallet, if the user's
|
|
1092
|
+
* embedded wallet already has a cloud-based recovery set, or if the user exits in the middle of the flow.
|
|
1093
|
+
*
|
|
1094
|
+
* @returns Promise for the {@link Wallet} object for the updated embedded wallet
|
|
1095
|
+
*/
|
|
1096
|
+
setWalletRecovery: (o?: SetWalletRecoveryOptions) => Promise<Wallet>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Prompts a user to sign a message using their embedded wallet using EIP-191's `personal_sign`
|
|
1099
|
+
* method (0x45).
|
|
1100
|
+
*
|
|
1101
|
+
* This method will error if the user is not authenticated or does not have an embedded wallet.
|
|
1102
|
+
*
|
|
1103
|
+
* If the `config.embeddedWallets.noPromptOnSignature` property is set to true, the signature will
|
|
1104
|
+
* be computed without prompting the user. Otherwise (the default), Privy will show the user a modal
|
|
1105
|
+
* to prompt them for a signature. This can be customized via the {@link SignMessageModalUIOptions}.
|
|
1106
|
+
*
|
|
1107
|
+
* @param message {string} message to be signed
|
|
1108
|
+
* @param uiOptions {@link SignMessageModalUIOptions} (optional) UI options to customize the signature prompt modal
|
|
1109
|
+
* @param address {optional} address for the embedded wallet signing the message. You should ONLY set this parameter if using imported
|
|
1110
|
+
* embedded wallets or multiple HD embedded wallets for the same user. Defaults to the user's embedded wallet at HD index 0.
|
|
1111
|
+
* @returns Promise for the signature as a string
|
|
1112
|
+
*/
|
|
1113
|
+
signMessage: (message: string, uiOptions?: SignMessageModalUIOptions, address?: string) => Promise<string>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Prompts a user to sign a message using their embedded wallet using EIP-712's `eth_signTypedData_v4`.
|
|
1116
|
+
*
|
|
1117
|
+
* This method will error if the user is not authenticated or does not have an embedded wallet.
|
|
1118
|
+
*
|
|
1119
|
+
* @param message {SignTypedDataParams} typed data payload to be signed
|
|
1120
|
+
* @param uiOptions {@link SignMessageModalUIOptions} (optional) UI options to customize the signature prompt modal
|
|
1121
|
+
* @param address {optional} address for the embedded wallet signing the message. You should ONLY set this parameter if using imported
|
|
1122
|
+
* embedded wallets or multiple HD embedded wallets for the same user. Defaults to the user's embedded wallet at HD index 0.
|
|
1123
|
+
* @returns Promise for the signature as a string
|
|
1124
|
+
*/
|
|
1125
|
+
signTypedData: (typedData: SignTypedDataParams, uiOptions?: SignMessageModalUIOptions, address?: string) => Promise<string>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Function to control the visibility of the enrollment modal.
|
|
1128
|
+
*
|
|
1129
|
+
* @param show {boolean} controls the visibility of the enrollment modal.
|
|
1130
|
+
* @returns Promise for opening the enrollment modal.
|
|
1131
|
+
*/
|
|
1132
|
+
enrollInMfa: (show?: boolean) => void;
|
|
1133
|
+
/**
|
|
1134
|
+
* Initiate the enrollment flow for MFA for the current user.
|
|
1135
|
+
*
|
|
1136
|
+
* @param mfaMethod {@link MfaMethod} The MFA method to enroll for the current user.
|
|
1137
|
+
* @param meta {@link {phoneNumber: string}} The meta data needed to complete the MFA flow.
|
|
1138
|
+
* @returns Promise for enrolling the current user with the chosen MFA method.
|
|
1139
|
+
*/
|
|
1140
|
+
initEnrollmentWithSms: (meta: {
|
|
1141
|
+
phoneNumber: string;
|
|
1142
|
+
}) => Promise<void>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Initiate the enrollment flow for TOTP MFA for the current user.
|
|
1145
|
+
*
|
|
1146
|
+
* @returns {@link {secret: string; authUrl: string}} The TOTP Auth Url is used to encode
|
|
1147
|
+
* into a QR Code for the user to scane.
|
|
1148
|
+
*/
|
|
1149
|
+
initEnrollmentWithTotp: () => Promise<{
|
|
1150
|
+
secret: string;
|
|
1151
|
+
authUrl: string;
|
|
1152
|
+
}>;
|
|
1153
|
+
/**
|
|
1154
|
+
* Initiate the enrollment flow for Passkey MFA for the current user.
|
|
1155
|
+
*
|
|
1156
|
+
* @returns {@link void} The TOTP Auth Url is used to encode
|
|
1157
|
+
* into a QR Code for the user to scane.
|
|
1158
|
+
*/
|
|
1159
|
+
initEnrollmentWithPasskey: () => Promise<void>;
|
|
1160
|
+
/**
|
|
1161
|
+
* Submit the MFA code to complete SMS enrollment process.
|
|
1162
|
+
*
|
|
1163
|
+
* @param meta {@link {phoneNumber: string; mfaCode: string}} The MFA code and phone number to submit.
|
|
1164
|
+
* @returns Promise for the MFA code submission.
|
|
1165
|
+
*/
|
|
1166
|
+
submitEnrollmentWithSms: (meta: {
|
|
1167
|
+
phoneNumber: string;
|
|
1168
|
+
mfaCode: string;
|
|
1169
|
+
}) => Promise<void>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Submit the MFA code to complete TOTP enrollment process.
|
|
1172
|
+
*
|
|
1173
|
+
* @param meta {@link {mfaCode: string}} The MFA code.
|
|
1174
|
+
* @returns Promise for the MFA code submission.
|
|
1175
|
+
*/
|
|
1176
|
+
submitEnrollmentWithTotp: (meta: {
|
|
1177
|
+
mfaCode: string;
|
|
1178
|
+
}) => Promise<void>;
|
|
1179
|
+
/**
|
|
1180
|
+
* Submit the passkey to complete the enrollment process.
|
|
1181
|
+
*
|
|
1182
|
+
* @param meta {@link {credentialIds: string[]}} The passkey credentialIds to enroll in MFA.
|
|
1183
|
+
* @returns Promise for the MFA code submission.
|
|
1184
|
+
*/
|
|
1185
|
+
submitEnrollmentWithPasskey: (meta: {
|
|
1186
|
+
credentialIds: string[];
|
|
1187
|
+
}) => Promise<void>;
|
|
1188
|
+
/**
|
|
1189
|
+
* Triggers the MFA verification flow if the user has an MFA method enrolled.
|
|
1190
|
+
*
|
|
1191
|
+
* @returns Promise for triggering the MFA verification flow.
|
|
1192
|
+
*/
|
|
1193
|
+
promptMfa: () => Promise<void>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Initiate the MFA flow for the current user.
|
|
1196
|
+
*
|
|
1197
|
+
* @param mfaMethod {@link MfaMethod} The available MFA method to trigger for the current user.
|
|
1198
|
+
* @returns Promise for sending the MFA code to the user's device.
|
|
1199
|
+
*/
|
|
1200
|
+
init: (mfaMethod: MfaMethod) => Promise<void | PublicKeyCredentialRequestOptionsJSON>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Submit the MFA code for the current user. This will attempt to complete the MFA flow.
|
|
1203
|
+
*
|
|
1204
|
+
* This will reject if:
|
|
1205
|
+
* - The verification attempt failed
|
|
1206
|
+
* - The max number of verification attempts has been reached
|
|
1207
|
+
* - The MFA attempt timed out
|
|
1208
|
+
*
|
|
1209
|
+
* These errors can be caught and handled accordingly using the error helpers `errorIndicatesMfaVerificationFailed`,
|
|
1210
|
+
* `errorIndicatesMaxMfaRetries`, `errorIndicatesMfaTimeout` exported from 'react-auth'.
|
|
1211
|
+
*
|
|
1212
|
+
* @param method {@link MfaMethod} The MFA method to be used.
|
|
1213
|
+
* @param mfaCode {string} The MFA code to submit.
|
|
1214
|
+
* @returns Promise for the MFA code submission.
|
|
1215
|
+
*/
|
|
1216
|
+
submit: (mfaMethod: MfaMethod, mfaCode: string | PublicKeyCredentialRequestOptionsJSON) => Promise<void>;
|
|
1217
|
+
/**
|
|
1218
|
+
* Cancel the MFA flow for the current user. If there is no pending MFA verification,
|
|
1219
|
+
* this function is a no-op.
|
|
1220
|
+
*
|
|
1221
|
+
* Call this method instead of `submit` when a user has been prompted for
|
|
1222
|
+
* MFA but decides to exit the flow.
|
|
1223
|
+
*
|
|
1224
|
+
* @returns void.
|
|
1225
|
+
*/
|
|
1226
|
+
cancel: () => void;
|
|
1227
|
+
/**
|
|
1228
|
+
* Remove the MFA method for the current user.
|
|
1229
|
+
*
|
|
1230
|
+
* @param method {@link MfaMethod} The MFA method to remove for the current user.
|
|
1231
|
+
* @returns Promise for removing the MFA method for the current user.
|
|
1232
|
+
*/
|
|
1233
|
+
unenroll: (method: MfaMethod) => Promise<void>;
|
|
1234
|
+
/**
|
|
1235
|
+
* Prompts a user to send a transaction using their embedded wallet.
|
|
1236
|
+
*
|
|
1237
|
+
* This method will error if the user is not authenticated or does not have an ethereum embedded wallet.
|
|
1238
|
+
*
|
|
1239
|
+
* If no `chainId` is specified as part of the {@link UnsignedTransactionRequest}, Privy will default
|
|
1240
|
+
* to the embedded wallet's current chain ID.
|
|
1241
|
+
*
|
|
1242
|
+
* If the `config.embeddedWallets.noPromptOnSignature` property is set to true, the wallet will
|
|
1243
|
+
* attempt to send the transaction without prompting the user. Otherwise (the default), Privy
|
|
1244
|
+
* will show the user a modal to have them confirm the transaction. This can be customized via
|
|
1245
|
+
* the {@link SendTransactionModalUIOptions}.
|
|
1246
|
+
*
|
|
1247
|
+
* @param data {@link UnsignedTransactionRequest} transaction to be sent
|
|
1248
|
+
* @param uiOptions {@link SendTransactionModalUIOptions} (optional) UI options to customize the transaction request modal
|
|
1249
|
+
* @param fundWalletConfig {@link FundWalletConfig} (optional) Funding configuration to specify chain and funding amount (if enabled), in the case of insufficient funds
|
|
1250
|
+
* @param address {optional} address for the embedded wallet signing the message. You should ONLY set this parameter if using imported
|
|
1251
|
+
* embedded wallets or multiple HD embedded wallets for the same user. Defaults to the user's embedded wallet at HD index 0.
|
|
1252
|
+
* @returns Promise for the transaction's {@link TransactionReceipt}
|
|
1253
|
+
*/
|
|
1254
|
+
sendTransaction: (data: UnsignedTransactionRequest, uiOptions?: SendTransactionModalUIOptions, fundWalletConfig?: FundWalletConfig, address?: string) => Promise<TransactionReceipt>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Prompts a user to send a transaction using their embedded wallet.
|
|
1257
|
+
*
|
|
1258
|
+
* This method will error if the user is not authenticated or does not have a solana embedded wallet.
|
|
1259
|
+
*
|
|
1260
|
+
* If the `config.embeddedWallets.noPromptOnSignature` property is set to true, the wallet will attempt to send
|
|
1261
|
+
* the transaction without prompting the user. Otherwise (the default), Privy will show the user a modal to have
|
|
1262
|
+
* them confirm the transaction. This can be customized via the {@link SendTransactionModalUIOptions}.
|
|
1263
|
+
*
|
|
1264
|
+
* @param transaction {SupportedSolanaTransaction} transaction to be sent
|
|
1265
|
+
* @param connection {Connection} connection to the Solana network
|
|
1266
|
+
* @param uiOptions {@link SendTransactionModalUIOptions} (optional) UI options to customize the transaction request modal
|
|
1267
|
+
* @param transactionOptions {@link SendTransactionOptions} (optional) Transaction options to customize the transaction request
|
|
1268
|
+
*/
|
|
1269
|
+
sendSolanaTransaction: (transaction: SupportedSolanaTransaction, connection: Connection, uiOptions?: SendTransactionModalUIOptions, transactionOptions?: SendTransactionOptions) => Promise<SolanaTransactionReceipt>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Shows the user a Privy modal, from which they can copy their embedded wallet's private
|
|
1272
|
+
* key or seed phrase for easy export to another wallet client (e.g. MetaMask). The private key is loaded
|
|
1273
|
+
* on an iframe running on a separate domain from your app, meaning your app cannot access it.
|
|
1274
|
+
*
|
|
1275
|
+
* This method will error if the user is not authenticated or does not have an embedded wallet.
|
|
1276
|
+
* @param options {@link {address: string}} (optional) wallet address to export the private key for
|
|
1277
|
+
* @returns Promise that resolves once the user exits the modal
|
|
1278
|
+
*/
|
|
1279
|
+
exportWallet: (options?: {
|
|
1280
|
+
address: string;
|
|
1281
|
+
} | MouseEvent<any, any>) => Promise<void>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Check whether the Privy Modal is visible.
|
|
1284
|
+
*/
|
|
1285
|
+
isModalOpen: boolean;
|
|
1286
|
+
/**
|
|
1287
|
+
* The available mfa methods of this App
|
|
1288
|
+
*/
|
|
1289
|
+
mfaMethods: MfaMethod[];
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* [React Hook](https://reactjs.org/docs/hooks-intro.html) that allows you to manage the user's current authentication state and access their linked accounts.
|
|
1293
|
+
*
|
|
1294
|
+
* You should use this hook to access the Privy SDK from within your React components and custom hooks.
|
|
1295
|
+
*/
|
|
1296
|
+
declare const usePrivy: () => PrivyInterface;
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* Allows you to manage the user's currently connected wallets.
|
|
1300
|
+
* You can access the fields and methods documented here via the {@link useWallets} hook.
|
|
1301
|
+
*/
|
|
1302
|
+
interface UseWalletsInterface {
|
|
1303
|
+
/**
|
|
1304
|
+
* The user's connected wallets.
|
|
1305
|
+
*/
|
|
1306
|
+
wallets: ConnectedWallet[];
|
|
1307
|
+
ready: boolean;
|
|
1308
|
+
}
|
|
1309
|
+
declare function useWallets(): UseWalletsInterface;
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Use this hook to execute the MFA flow with Privy.
|
|
1313
|
+
*
|
|
1314
|
+
* @returns promptMfa - prompts the user to complete MFA verification
|
|
1315
|
+
* @returns init - starts the MFA verification flow
|
|
1316
|
+
* @returns submit - completes the MFA verification flow
|
|
1317
|
+
* @returns cancel - cancels the MFA verification flow
|
|
1318
|
+
* @returns mfaMethods - list of all available mfa methods
|
|
1319
|
+
*
|
|
1320
|
+
* @example
|
|
1321
|
+
* // MFA flow
|
|
1322
|
+
*
|
|
1323
|
+
* const MFAModal = ({ mfaMethods, isOpen, setIsOpen }: Props) => {
|
|
1324
|
+
* const {init, submit, cancel} = useMfa();
|
|
1325
|
+
* const [selectedMethod, setSelectedMethod] = useState(null)
|
|
1326
|
+
* const [mfaCode, setMfaCode] = useState('')
|
|
1327
|
+
*
|
|
1328
|
+
* const handleClose = () => {
|
|
1329
|
+
* cancel();
|
|
1330
|
+
* setIsOpen(false);
|
|
1331
|
+
* };
|
|
1332
|
+
*
|
|
1333
|
+
* return (
|
|
1334
|
+
* <Modal isOpen={isOpen} onClose={handleClose}>
|
|
1335
|
+
* // Capture the user's MFA code
|
|
1336
|
+
* {selectedMethod && (
|
|
1337
|
+
* <button
|
|
1338
|
+
* onClick={async () => {
|
|
1339
|
+
* await submit(selectedMethod, mfsCode)
|
|
1340
|
+
* setSelectedMethod(null)
|
|
1341
|
+
* setIsOpen(false)
|
|
1342
|
+
* }}
|
|
1343
|
+
* />
|
|
1344
|
+
* )}
|
|
1345
|
+
* {mfaMethods.map(method => (
|
|
1346
|
+
* <button
|
|
1347
|
+
* onClick={async () => {
|
|
1348
|
+
* await init(method);
|
|
1349
|
+
* setSelectedMethod(method)
|
|
1350
|
+
* }}
|
|
1351
|
+
* >
|
|
1352
|
+
* Choose {method} for MFA
|
|
1353
|
+
* </button>
|
|
1354
|
+
* ))}
|
|
1355
|
+
* </Modal>
|
|
1356
|
+
* )
|
|
1357
|
+
* };
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* // Error handling
|
|
1361
|
+
*
|
|
1362
|
+
* import {
|
|
1363
|
+
* errorIndicatesMfaVerificationFailed,
|
|
1364
|
+
* errorIndicatesMfaTimeout,
|
|
1365
|
+
* errorIndicatesMfaMaxAttempts
|
|
1366
|
+
* } from '@privy-io/react-auth';
|
|
1367
|
+
* const {submit} = useMfa();
|
|
1368
|
+
* const [errorState, setErrorState] = useState<string | null>(null);
|
|
1369
|
+
*
|
|
1370
|
+
* <button
|
|
1371
|
+
* onClick={async () => {
|
|
1372
|
+
* try {
|
|
1373
|
+
* submit('sms', '<user-mfa-code>');
|
|
1374
|
+
* }
|
|
1375
|
+
* catch (e) {
|
|
1376
|
+
* if (errorIndicatesMfaVerificationFailed(e)) {
|
|
1377
|
+
* setErrorState('Verification failed, resubmit.')
|
|
1378
|
+
* }
|
|
1379
|
+
* else if (errorIndicatesMfaMaxAttempts(e)) {
|
|
1380
|
+
* setErrorState('Max attempts reached, re-initialize MFA.')
|
|
1381
|
+
* }
|
|
1382
|
+
* else if (errorIndicatesMfaTimeout(e)) {
|
|
1383
|
+
* setErrorState('Timeout reached, re-initialize MFA.')
|
|
1384
|
+
* }
|
|
1385
|
+
* }}
|
|
1386
|
+
* >
|
|
1387
|
+
* {errorState ?? 'Verify SMS MFA Code'}
|
|
1388
|
+
* </button>
|
|
1389
|
+
*
|
|
1390
|
+
*/
|
|
1391
|
+
declare function useMfa(): {
|
|
1392
|
+
promptMfa: () => Promise<void>;
|
|
1393
|
+
init: (mfaMethod: MfaMethod) => Promise<void | _simplewebauthn_types.PublicKeyCredentialRequestOptionsJSON>;
|
|
1394
|
+
submit: (mfaMethod: MfaMethod, mfaCode: string | _simplewebauthn_types.PublicKeyCredentialRequestOptionsJSON) => Promise<void>;
|
|
1395
|
+
cancel: () => void;
|
|
1396
|
+
mfaMethods: ("sms" | "totp" | "passkey")[];
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Use this hook to enroll a user in MFA
|
|
1401
|
+
*
|
|
1402
|
+
* @returns initEnrollmentWithSms - starts the MFA enrollment flow for SMS
|
|
1403
|
+
* @returns initEnrollmentWithTotp - starts the MFA enrollment flow for TOTP
|
|
1404
|
+
* @returns submitEnrollmentWithSms - completes the MFA enrollment flow for SMS
|
|
1405
|
+
* @returns submitEnrollmentWithTotp - completes the MFA enrollment flow for TOTP
|
|
1406
|
+
* @returns unenrollWithSms - unenrolls the SMS MFA method
|
|
1407
|
+
* @returns unenrollWithTotp - unenrolls the TOTP MFA method
|
|
1408
|
+
* @returns showMfaEnrollmentModal - opens the MFA enrollment modal
|
|
1409
|
+
* @returns closeMfaEnrollmentModal - closes the MFA enrollment modal
|
|
1410
|
+
*
|
|
1411
|
+
* @example
|
|
1412
|
+
* const {unenrollWithSms} = useMfaEnrollment();
|
|
1413
|
+
*
|
|
1414
|
+
* <button
|
|
1415
|
+
* onClick={() => {
|
|
1416
|
+
* unenrollWithSms();
|
|
1417
|
+
* }}
|
|
1418
|
+
* >
|
|
1419
|
+
* Unenroll in SMS MFA
|
|
1420
|
+
* </button>
|
|
1421
|
+
*
|
|
1422
|
+
* @example
|
|
1423
|
+
* const {unenrollWithTotp} = useMfaEnrollment();
|
|
1424
|
+
*
|
|
1425
|
+
* <button
|
|
1426
|
+
* onClick={() => {
|
|
1427
|
+
* unenrollWithTotp();
|
|
1428
|
+
* }}
|
|
1429
|
+
* >
|
|
1430
|
+
* Unenroll in TOTP MFA
|
|
1431
|
+
* </button>
|
|
1432
|
+
*/
|
|
1433
|
+
declare function useMfaEnrollment(): {
|
|
1434
|
+
initEnrollmentWithSms: (meta: {
|
|
1435
|
+
phoneNumber: string;
|
|
1436
|
+
}) => Promise<void>;
|
|
1437
|
+
initEnrollmentWithTotp: () => Promise<{
|
|
1438
|
+
secret: string;
|
|
1439
|
+
authUrl: string;
|
|
1440
|
+
}>;
|
|
1441
|
+
initEnrollmentWithPasskey: () => Promise<void>;
|
|
1442
|
+
submitEnrollmentWithSms: (meta: {
|
|
1443
|
+
phoneNumber: string;
|
|
1444
|
+
mfaCode: string;
|
|
1445
|
+
}) => Promise<void>;
|
|
1446
|
+
submitEnrollmentWithTotp: (meta: {
|
|
1447
|
+
mfaCode: string;
|
|
1448
|
+
}) => Promise<void>;
|
|
1449
|
+
submitEnrollmentWithPasskey: (meta: {
|
|
1450
|
+
credentialIds: string[];
|
|
1451
|
+
}) => Promise<void>;
|
|
1452
|
+
unenrollWithSms: () => Promise<void>;
|
|
1453
|
+
unenrollWithTotp: () => Promise<void>;
|
|
1454
|
+
unenrollWithPasskey: () => Promise<void>;
|
|
1455
|
+
showMfaEnrollmentModal: () => void;
|
|
1456
|
+
closeMfaEnrollmentModal: () => void;
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1459
|
+
declare class PrivyIframeError extends Error {
|
|
1460
|
+
type: PrivyIframeErrorTypesType;
|
|
1461
|
+
constructor(type: PrivyIframeErrorTypesType, message: string);
|
|
1462
|
+
}
|
|
1463
|
+
declare function errorIndicatesMfaTimeout(error: unknown): error is PrivyIframeError;
|
|
1464
|
+
declare function errorIndicatesMfaVerificationFailed(error: unknown): error is PrivyIframeError;
|
|
1465
|
+
declare function errorIndicatesMaxMfaRetries(error: unknown): error is PrivyIframeError;
|
|
1466
|
+
|
|
1467
|
+
declare const VERSION = "__VERSION__";
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* `CallbackError` optionally includes a second parameter with further error details.
|
|
1471
|
+
*/
|
|
1472
|
+
type CallbackError<Details extends Record<string, any> | undefined = undefined> = Details extends Record<string, any> ? (error: PrivyErrorCode, details: Details) => void : (error: PrivyErrorCode) => void;
|
|
1473
|
+
interface PrivyEvents {
|
|
1474
|
+
login: {
|
|
1475
|
+
/**
|
|
1476
|
+
* Callback that will execute once a `login` flow successfully completes.
|
|
1477
|
+
* - If `config.embeddedWallets.createOnLogin` is set to 'off' or a wallet creation flow is not applicable,
|
|
1478
|
+
* this will run after the user successfully authenticates.
|
|
1479
|
+
* - If `config.embeddedWallets.createOnLogin` is set to 'users-without-wallets' or 'all-users',
|
|
1480
|
+
* this will run after the user successfully authenticates _and_ creates their wallet (if applicable).
|
|
1481
|
+
* - If a user is already authenticated, this will run immediately and the `wasAlreadyAuthenticated` flag will be set to `true`.
|
|
1482
|
+
*
|
|
1483
|
+
* @param user {@link User} the `user` oject corresponding to the authenticated user
|
|
1484
|
+
* @param isNewUser {boolean} boolean flag indicating if this is the user's first time logging in to your app
|
|
1485
|
+
* @param wasAlreadyAuthenticated {boolean} - boolean flag indicating whether the user entered the application already authenticated
|
|
1486
|
+
* @param loginMethod {string} - the method used by the user to login
|
|
1487
|
+
* @param loginAccount - the account corresponding to the loginMethod used
|
|
1488
|
+
*/
|
|
1489
|
+
onComplete?: (user: User, isNewUser: boolean, wasAlreadyAuthenticated: boolean, loginMethod: LoginMethod | null, loginAccount: LinkedAccountWithMetadata | null) => void;
|
|
1490
|
+
/**
|
|
1491
|
+
* @experimental
|
|
1492
|
+
*
|
|
1493
|
+
* Callback that will execute once a successful OAuth login flow completes.
|
|
1494
|
+
* This will only run in the case of an OAuth login flow.
|
|
1495
|
+
*
|
|
1496
|
+
* This will always be called before `onComplete` in the case of an OAuth login flow.
|
|
1497
|
+
* If you will be doing anything after the user is logged in (e.g. sending data to your API or redirecting to an authenticated route), you should wait for `onComplete` to run.
|
|
1498
|
+
*
|
|
1499
|
+
* @param oAuthTokens {@link OAuthTokens} - the OAuth tokens returned from the OAuth provider
|
|
1500
|
+
*/
|
|
1501
|
+
onOAuthLoginComplete?: (oAuthTokens: OAuthTokens) => void;
|
|
1502
|
+
/**
|
|
1503
|
+
* Callback that will execute in the case of a non-successful login.
|
|
1504
|
+
*
|
|
1505
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1506
|
+
*
|
|
1507
|
+
*/
|
|
1508
|
+
onError?: CallbackError;
|
|
1509
|
+
};
|
|
1510
|
+
logout: {
|
|
1511
|
+
/**
|
|
1512
|
+
* Callback that will execute when a user successfully logs out.
|
|
1513
|
+
*/
|
|
1514
|
+
onSuccess?: () => void;
|
|
1515
|
+
};
|
|
1516
|
+
connectWallet: {
|
|
1517
|
+
/**
|
|
1518
|
+
* Callback that will execute once a successful `connectWallet` completes.
|
|
1519
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
1520
|
+
*
|
|
1521
|
+
* @param wallet {@link BaseConnectedWallet} the `wallet` object correspending to the connection
|
|
1522
|
+
*/
|
|
1523
|
+
onSuccess?: (wallet: BaseConnectedWallet) => void;
|
|
1524
|
+
/**
|
|
1525
|
+
* Callback that will execute in the case of a non-successful wallet connection.
|
|
1526
|
+
*
|
|
1527
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1528
|
+
*/
|
|
1529
|
+
onError?: CallbackError;
|
|
1530
|
+
};
|
|
1531
|
+
createWallet: {
|
|
1532
|
+
/**
|
|
1533
|
+
* Callback that will execute once on a successful embedded wallet creation.
|
|
1534
|
+
* This will run when `createWallet` is called manually, or when `config.embeddedWallets.createOnLogin` triggers
|
|
1535
|
+
* an automatic wallet creation.
|
|
1536
|
+
*
|
|
1537
|
+
* @param wallet {@link BaseConnectedWallet}- the created `wallet` object
|
|
1538
|
+
*
|
|
1539
|
+
*/
|
|
1540
|
+
onSuccess?: (wallet: Wallet) => void;
|
|
1541
|
+
/**
|
|
1542
|
+
* Callback that will execute in the case of a non-successful wallet creation.
|
|
1543
|
+
*
|
|
1544
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1545
|
+
*
|
|
1546
|
+
*/
|
|
1547
|
+
onError?: CallbackError;
|
|
1548
|
+
};
|
|
1549
|
+
linkAccount: {
|
|
1550
|
+
/**
|
|
1551
|
+
* Callback that will execute once on a successful linking of a new account/login method.
|
|
1552
|
+
* This will run when any of the 'link' methods are called manually.
|
|
1553
|
+
* @param user {@link User}- the user the account was linked to
|
|
1554
|
+
* @param linkMethod {@link LoginMethod}- the type of linked account
|
|
1555
|
+
* @param linkedAccount - the newly linked account
|
|
1556
|
+
*/
|
|
1557
|
+
onSuccess?: (user: User, linkMethod: LoginMethod, linkedAccount: LinkedAccountWithMetadata) => void;
|
|
1558
|
+
/**
|
|
1559
|
+
* Callback that will execute in the case of a non-successful account linking.
|
|
1560
|
+
*
|
|
1561
|
+
* @param error {PrivyErrorCode} - the corresponding error code
|
|
1562
|
+
* @param details.linkMethod {LoginMethod} - the type of (attempted) linked account
|
|
1563
|
+
*
|
|
1564
|
+
*/
|
|
1565
|
+
onError?: CallbackError<{
|
|
1566
|
+
linkMethod: LoginMethod;
|
|
1567
|
+
}>;
|
|
1568
|
+
};
|
|
1569
|
+
configureMfa: {
|
|
1570
|
+
/**
|
|
1571
|
+
* Callback that will execute when MFA is required to complete a given action.
|
|
1572
|
+
* @param mfaMethods {@link MfaMethod[]} - List of MFA methods that the user can choose from
|
|
1573
|
+
*/
|
|
1574
|
+
onMfaRequired: (mfaMethods: MfaMethod[]) => void;
|
|
1575
|
+
};
|
|
1576
|
+
setWalletPassword: {
|
|
1577
|
+
/**
|
|
1578
|
+
* Callback that will execute once a successful `setWalletPassword` completes.
|
|
1579
|
+
* @param wallet {@link Wallet}- the `wallet` object that the password was set for
|
|
1580
|
+
*/
|
|
1581
|
+
onSuccess?: (wallet: Wallet) => void;
|
|
1582
|
+
/**
|
|
1583
|
+
* Callback that will execute in the case of a non-successful setWalletPassword.
|
|
1584
|
+
*
|
|
1585
|
+
* @param error {PrivyErrorCode} - the corresponding error code
|
|
1586
|
+
*/
|
|
1587
|
+
onError?: CallbackError;
|
|
1588
|
+
};
|
|
1589
|
+
setWalletRecovery: {
|
|
1590
|
+
/**
|
|
1591
|
+
* Callback that will execute once a successful `setWalletRecovery` completes.
|
|
1592
|
+
* @param wallet {@link Wallet}- the `walle]et` object that the recovery was set for
|
|
1593
|
+
*/
|
|
1594
|
+
onSuccess?: (method: UserRecoveryMethod, wallet: Wallet) => void;
|
|
1595
|
+
/**
|
|
1596
|
+
* Callback that will execute in the case of a non-successful setWalletRecovery.
|
|
1597
|
+
*
|
|
1598
|
+
* @param error {PrivyErrorCode} - the corresponding error code
|
|
1599
|
+
*/
|
|
1600
|
+
onError?: CallbackError;
|
|
1601
|
+
};
|
|
1602
|
+
signMessage: {
|
|
1603
|
+
/**
|
|
1604
|
+
* Callback that will execute once a successful `signMessage` completes.
|
|
1605
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
1606
|
+
* @param signature - the signature (type string) of the embedded wallet used to sign message
|
|
1607
|
+
*/
|
|
1608
|
+
onSuccess?: (signature: string) => void;
|
|
1609
|
+
/**
|
|
1610
|
+
* Callback that will execute in the case of a non-successful signMessage.
|
|
1611
|
+
*
|
|
1612
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1613
|
+
* */
|
|
1614
|
+
onError?: CallbackError;
|
|
1615
|
+
};
|
|
1616
|
+
signTypedData: {
|
|
1617
|
+
/**
|
|
1618
|
+
* Callback that will execute once a successful `signTypedData` completes.
|
|
1619
|
+
* @param signature - the signature (type string) of the embedded wallet used to sign
|
|
1620
|
+
*/
|
|
1621
|
+
onSuccess?: (signature: string) => void;
|
|
1622
|
+
/**
|
|
1623
|
+
* Callback that will execute in the case of a non-successful signTypedData.
|
|
1624
|
+
*
|
|
1625
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1626
|
+
* */
|
|
1627
|
+
onError?: CallbackError;
|
|
1628
|
+
};
|
|
1629
|
+
sendTransaction: {
|
|
1630
|
+
/**
|
|
1631
|
+
* Callback that will execute once a successful `sendTransaction` completes.
|
|
1632
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
1633
|
+
* @param response - the response (type TransactionResponse https://docs.ethers.org/v5/api/providers/types/#providers-TransactionResponse) from the successful transaction
|
|
1634
|
+
*/
|
|
1635
|
+
onSuccess?: (response: TransactionResponse) => void;
|
|
1636
|
+
/**
|
|
1637
|
+
* Callback that will execute in the case of a non-successful sendTransaction.
|
|
1638
|
+
*
|
|
1639
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1640
|
+
* */
|
|
1641
|
+
onError?: CallbackError;
|
|
1642
|
+
};
|
|
1643
|
+
sendSolanaTransaction: {
|
|
1644
|
+
/**
|
|
1645
|
+
* Callback that will execute once a successful `sendSolanaTransaction` completes.
|
|
1646
|
+
* This will not run in the case of a wallet-based authentication or link flow.
|
|
1647
|
+
* @param response - the response {@link https://solana-labs.github.io/solana-web3.js/types/ParsedTransactionMeta.html SolanaTransactionReceipt} from the successful transaction
|
|
1648
|
+
*/
|
|
1649
|
+
onSuccess?: (response: SolanaTransactionReceipt) => void;
|
|
1650
|
+
/**
|
|
1651
|
+
* Callback that will execute in the case of a non-successful sendTransaction.
|
|
1652
|
+
*
|
|
1653
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1654
|
+
* */
|
|
1655
|
+
onError?: CallbackError;
|
|
1656
|
+
};
|
|
1657
|
+
accessToken: {
|
|
1658
|
+
/**
|
|
1659
|
+
* Callback that will execute when a user's access token is granted.
|
|
1660
|
+
* @param accessToken - The user's access token
|
|
1661
|
+
*/
|
|
1662
|
+
onAccessTokenGranted: (accessToken: string) => void;
|
|
1663
|
+
/**
|
|
1664
|
+
* Callback that will execute when a user's access token is removed.
|
|
1665
|
+
*/
|
|
1666
|
+
onAccessTokenRemoved: () => void;
|
|
1667
|
+
};
|
|
1668
|
+
oAuthAuthorization: {
|
|
1669
|
+
/**
|
|
1670
|
+
* Callback that will execute when a user successfully authorizes an OAuth flow.
|
|
1671
|
+
*
|
|
1672
|
+
* @param oAuthTokens {@link OAuthTokens} - the OAuth tokens returned from the OAuth provider:
|
|
1673
|
+
* @param oAuthTokens.provider - {string} The OAuth provider type.
|
|
1674
|
+
* @param oAuthTokens.accessToken - {string} The OAuth access token.
|
|
1675
|
+
* @param oAuthTokens.accessTokenExpiresInSeconds - {number} (optional) The number of seconds until the OAuth access token expires.
|
|
1676
|
+
* @param oAuthTokens.refreshToken - {string} (optional) The OAuth refresh token.
|
|
1677
|
+
* @param oAuthTokens.refreshTokenExpiresInSeconds - {number} (optional) The number of seconds until the OAuth refresh token expires.
|
|
1678
|
+
* if the refresh token is present and this field is undefined, it is assumed
|
|
1679
|
+
* that the refresh token does not have an expiration date.
|
|
1680
|
+
* @param oAuthTokens.scopes - {string[]} (optional) The list of OAuth scopes the access token is approved for.
|
|
1681
|
+
*
|
|
1682
|
+
* @param o.user {@link User} (optional) The list of OAuth scopes the access token is approved for.
|
|
1683
|
+
*/
|
|
1684
|
+
onOAuthTokenGrant: (oAuthTokens: OAuthTokens, o: {
|
|
1685
|
+
user: User;
|
|
1686
|
+
}) => void;
|
|
1687
|
+
};
|
|
1688
|
+
fundWallet: {
|
|
1689
|
+
/**
|
|
1690
|
+
* Callback that will execute when a funding flow is exited. This fires when a user closes a funding flow modal, for any reason.
|
|
1691
|
+
*
|
|
1692
|
+
* @param fundingMethod {@link FundingMethod} The funding method associated with the flow at time of exit. If the user had not yet selected
|
|
1693
|
+
* @param balance {@link BigNumber} The value for the funded wallet at the point of user exit.
|
|
1694
|
+
* a recovery method, this will be null.
|
|
1695
|
+
*/
|
|
1696
|
+
onUserExited?: (o: {
|
|
1697
|
+
address: string;
|
|
1698
|
+
chain: Chain;
|
|
1699
|
+
fundingMethod: FundingMethod | 'manual' | null;
|
|
1700
|
+
balance: bigint | undefined;
|
|
1701
|
+
}) => void;
|
|
1702
|
+
};
|
|
1703
|
+
customAuth: {
|
|
1704
|
+
/**
|
|
1705
|
+
* Callback that will execute when Privy successfully exchanges a custom auth JWT for a Privy JWT
|
|
1706
|
+
* @param o.user - The Privy user
|
|
1707
|
+
*/
|
|
1708
|
+
onAuthenticated: (o: {
|
|
1709
|
+
user: User;
|
|
1710
|
+
}) => void;
|
|
1711
|
+
/**
|
|
1712
|
+
* Callback that will execute when Privy detects a user is logged out from the third-party auth system, and correspondingly logs the user out.
|
|
1713
|
+
*/
|
|
1714
|
+
onUnauthenticated: () => void;
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
/**
|
|
1719
|
+
* Use this hook to log the user in, and to attach callbacks
|
|
1720
|
+
* for successful `login`s, already-`authenticated` users, and
|
|
1721
|
+
* `login` errors.
|
|
1722
|
+
*
|
|
1723
|
+
* @param callbacks.onComplete {@link PrivyEvents} callback to execute for already- or newly-`authenticated` users
|
|
1724
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `login`.
|
|
1725
|
+
* @returns login - opens the Privy modal and prompts the user to login
|
|
1726
|
+
*/
|
|
1727
|
+
declare function useLogin(callbacks?: PrivyEvents['login']): {
|
|
1728
|
+
/**
|
|
1729
|
+
* Opens the Privy login modal and prompts the user to login.
|
|
1730
|
+
*/
|
|
1731
|
+
login: (options?: LoginModalOptions | react.MouseEvent<any, any>) => void;
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1734
|
+
/**
|
|
1735
|
+
* Use this hook to log the user out, and to attach a callback after a successful logout.
|
|
1736
|
+
*
|
|
1737
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute when a user successfully logs out.
|
|
1738
|
+
* @returns logout - logs the user out and clears their authentication state.
|
|
1739
|
+
*/
|
|
1740
|
+
declare function useLogout(callbacks?: PrivyEvents['logout']): {
|
|
1741
|
+
/**
|
|
1742
|
+
* Log the current user out and clears their authentication state. `authenticated` will become false, `user` will become null, and the Privy Auth tokens will be deleted from the browser's local storage.
|
|
1743
|
+
*/
|
|
1744
|
+
logout: () => Promise<void>;
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
type UseLoginWithOAuth = {
|
|
1748
|
+
/**
|
|
1749
|
+
* Redirect to a login page for the given OAuth provider without using Privy's UI
|
|
1750
|
+
*
|
|
1751
|
+
* @returns a Promise that resolves when the redirect _(using `window.assign`)_ is complete, or rejects if there was an error.
|
|
1752
|
+
*
|
|
1753
|
+
* @example
|
|
1754
|
+
* const {initOAuth} = useLoginWithOAuth()
|
|
1755
|
+
*
|
|
1756
|
+
* <Button onPress={() => initOAuth({ provider: 'google' })} /> *
|
|
1757
|
+
*/
|
|
1758
|
+
initOAuth: ({ provider }: {
|
|
1759
|
+
provider: OAuthProviderType;
|
|
1760
|
+
}) => Promise<void>;
|
|
1761
|
+
/**
|
|
1762
|
+
* Used to log users in via various OAuth providers without using Privy's UI
|
|
1763
|
+
*
|
|
1764
|
+
* @returns a Promise that resolves with the User if login was successful or rejects if there was an error.
|
|
1765
|
+
*
|
|
1766
|
+
* @example
|
|
1767
|
+
* const {loginWithOAuth} = useLoginWithOAuth()
|
|
1768
|
+
*
|
|
1769
|
+
* <Button onPress={loginWithOAuth} /> *
|
|
1770
|
+
*/
|
|
1771
|
+
loginWithOAuth: () => Promise<User | undefined>;
|
|
1772
|
+
/**
|
|
1773
|
+
* Indicates a headless OAuth flow is in progress
|
|
1774
|
+
*/
|
|
1775
|
+
loading: boolean;
|
|
1776
|
+
/**
|
|
1777
|
+
* The current state of the login with OAuth flow.
|
|
1778
|
+
*/
|
|
1779
|
+
state: OAuthFlowState;
|
|
1780
|
+
};
|
|
1781
|
+
/**
|
|
1782
|
+
* @experimental
|
|
1783
|
+
*
|
|
1784
|
+
* Use this hook to log the user in with an OAuth provider, without using any Privy UIs.
|
|
1785
|
+
*/
|
|
1786
|
+
declare const useLoginWithOAuth: (callbacks?: PrivyEvents["login"]) => UseLoginWithOAuth;
|
|
1787
|
+
|
|
1788
|
+
type SendCodeToEmail = {
|
|
1789
|
+
email: string;
|
|
1790
|
+
};
|
|
1791
|
+
type UseLoginWithEmail = {
|
|
1792
|
+
/**
|
|
1793
|
+
* Sends a one-time-passcode (OTP) to the user's email address.
|
|
1794
|
+
*
|
|
1795
|
+
* @param opts {@link SendCodeToEmail} options for sending the OTP
|
|
1796
|
+
* @param opts.email {string} the user's email address
|
|
1797
|
+
*
|
|
1798
|
+
* @returns a Promise that resolves if the OTP was successfully sent to the email,
|
|
1799
|
+
* or rejects if there was an error.
|
|
1800
|
+
*/
|
|
1801
|
+
sendCode: ({ email }: SendCodeToEmail) => Promise<void>;
|
|
1802
|
+
/**
|
|
1803
|
+
* Log a user in with a one-time-passcode (OTP) that has been sent to their
|
|
1804
|
+
* email address via {@link sendCode}
|
|
1805
|
+
*
|
|
1806
|
+
* For a single OTP, you may call this method up to a maximum of 5 times, to handle
|
|
1807
|
+
* errors where the user incorrectly enters the OTP in your UIs.
|
|
1808
|
+
*
|
|
1809
|
+
* After 5 attempts of {@link loginWithCode}, the existing OTP is no longer valid, and you
|
|
1810
|
+
* must request a new one for the user via {@link sendCode}
|
|
1811
|
+
*
|
|
1812
|
+
* @param opts {@link LoginWithCode} options for logging the user in with an OTP
|
|
1813
|
+
* @param opts.code {string} the OTP provided by the user
|
|
1814
|
+
*
|
|
1815
|
+
* @returns a Promise that resolves if the inputted OTP was valid, or rejects if there was an error.
|
|
1816
|
+
*/
|
|
1817
|
+
loginWithCode: ({ code }: LoginWithCode) => Promise<void>;
|
|
1818
|
+
/**
|
|
1819
|
+
* The current state of the login with Email flow.
|
|
1820
|
+
*/
|
|
1821
|
+
state: OtpFlowState;
|
|
1822
|
+
};
|
|
1823
|
+
/**
|
|
1824
|
+
* @experimental
|
|
1825
|
+
*
|
|
1826
|
+
* Use this hook to log the user in with email, without using any Privy UIs.
|
|
1827
|
+
*
|
|
1828
|
+
* @returns sendCode - {@link sendCode} sends a one-time-code to the user's email address.
|
|
1829
|
+
* @returns loginWithCode - {@link loginWithCode} - logs a user in with a one-time-code, maximum 5 attempts.
|
|
1830
|
+
* @returns state - {@link OtpFlowState} - the current state of the login with Email flow.
|
|
1831
|
+
*/
|
|
1832
|
+
declare const useLoginWithEmail: () => UseLoginWithEmail;
|
|
1833
|
+
|
|
1834
|
+
type UseLoginWithPasskey = {
|
|
1835
|
+
/**
|
|
1836
|
+
* Logs in a user with a passkey without using any Privy UIs.
|
|
1837
|
+
*
|
|
1838
|
+
* @returns a Promise that resolves if the passkey is valid, or rejects if there was an error.
|
|
1839
|
+
*/
|
|
1840
|
+
loginWithPasskey: () => Promise<void>;
|
|
1841
|
+
/**
|
|
1842
|
+
* State of the passkey flow.
|
|
1843
|
+
*/
|
|
1844
|
+
state: PasskeyFlowState;
|
|
1845
|
+
};
|
|
1846
|
+
/**
|
|
1847
|
+
* @experimental
|
|
1848
|
+
*
|
|
1849
|
+
* Use this hook to log the user in with passkey, without using any Privy UIs.
|
|
1850
|
+
*
|
|
1851
|
+
* @returns loginWithPasskey - {@link loginWithPasskey} - logs a user in with a passkey
|
|
1852
|
+
*/
|
|
1853
|
+
declare const useLoginWithPasskey: (callbacks?: PrivyEvents["login"]) => UseLoginWithPasskey;
|
|
1854
|
+
|
|
1855
|
+
type SendCodeToSms = {
|
|
1856
|
+
phoneNumber: string;
|
|
1857
|
+
};
|
|
1858
|
+
type UseLoginWithSms = {
|
|
1859
|
+
/**
|
|
1860
|
+
* Sends a one-time-passcode (OTP) to the user's phone number.
|
|
1861
|
+
*
|
|
1862
|
+
* @param opts {@link SendCodeToSms} options for sending the OTP
|
|
1863
|
+
* @param opts.phoneNumber {string} the user's phone number
|
|
1864
|
+
*
|
|
1865
|
+
* The phone number will ignore all non numerical values in the string except for the optional '+' first character for country code specification.
|
|
1866
|
+
* By default, the implicit phone number country code is +1/US. So any phone number inputted is default read as a US phone number.
|
|
1867
|
+
* Explicitly prepending a (+)1 to the phone number will do nothing, and the phone number will still be read and parsed as a US phone number.
|
|
1868
|
+
* If you are trying to send sms to a non (+1) phone number, you must append a +${countryCode} to the beginning of the input value.
|
|
1869
|
+
*
|
|
1870
|
+
* @returns a Promise that resolves if the OTP was successfully sent to the email,
|
|
1871
|
+
* or rejects if there was an error.
|
|
1872
|
+
*/
|
|
1873
|
+
sendCode: ({ phoneNumber }: SendCodeToSms) => Promise<void>;
|
|
1874
|
+
/**
|
|
1875
|
+
* Log a user in with a one-time-passcode (OTP) that has been sent to their
|
|
1876
|
+
* phone number via {@link sendCode}
|
|
1877
|
+
*
|
|
1878
|
+
* For a single OTP, you may call this method up to a maximum of 5 times, to handle
|
|
1879
|
+
* errors where the user incorrectly enters the OTP in your UIs.
|
|
1880
|
+
*
|
|
1881
|
+
* After 5 attempts of {@link loginWithCode}, the existing OTP is no longer valid, and you
|
|
1882
|
+
* must request a new one for the user via {@link sendCode}
|
|
1883
|
+
*
|
|
1884
|
+
* @param opts {@link LoginWithCode} options for logging the user in with an OTP
|
|
1885
|
+
* @param opts.code {string} the OTP provided by the user
|
|
1886
|
+
*
|
|
1887
|
+
* @returns a Promise that resolves if the inputted OTP was valid, or rejects if there was an error.
|
|
1888
|
+
*/
|
|
1889
|
+
loginWithCode: ({ code }: LoginWithCode) => Promise<void>;
|
|
1890
|
+
/**
|
|
1891
|
+
* The current state of the login with SMS flow.
|
|
1892
|
+
*/
|
|
1893
|
+
state: OtpFlowState;
|
|
1894
|
+
};
|
|
1895
|
+
/**
|
|
1896
|
+
* @experimental
|
|
1897
|
+
*
|
|
1898
|
+
* Use this hook to log the user in with sms, without using any Privy UIs.
|
|
1899
|
+
*
|
|
1900
|
+
* @returns sendCode - {@link sendCode} sends a one-time-code to the user's phone number.
|
|
1901
|
+
* @returns loginWithCode - {@link loginWithCode} - logs a user in with a one-time-code, maximum 5 attempts.
|
|
1902
|
+
* @returns state - {@link OtpFlowState} - the current state of the login with Email flow.
|
|
1903
|
+
*/
|
|
1904
|
+
declare const useLoginWithSms: () => UseLoginWithSms;
|
|
1905
|
+
|
|
1906
|
+
type UseLinkWithSiwe = {
|
|
1907
|
+
/**
|
|
1908
|
+
* Given an external wallet address and chain ID, creates a EIP-4361 message for signing.
|
|
1909
|
+
* To be used for a SIWE implementation without Privy UIs
|
|
1910
|
+
*
|
|
1911
|
+
* @param opts options for generating a SIWE message for
|
|
1912
|
+
* @param opts.address {string} EIP-55 mixed-case checksum-encoded address performing the signing.
|
|
1913
|
+
* @param opts.chainId {string} EIP-155 Chain ID to which the session is bound
|
|
1914
|
+
* @returns {string} EIP-4361 message for signing.
|
|
1915
|
+
*/
|
|
1916
|
+
generateSiweMessage: ({ address, chainId }: {
|
|
1917
|
+
address: string;
|
|
1918
|
+
chainId: string;
|
|
1919
|
+
}) => Promise<string>;
|
|
1920
|
+
/**
|
|
1921
|
+
* Link a new wallet to the authenticated user via the Sign-In with Ethereum spec.
|
|
1922
|
+
*
|
|
1923
|
+
* @param opts options for verifying a signature for a SIWE message
|
|
1924
|
+
* @param opts.signature {string} The EIP-191 signature corresponding to the message that the user had been given.
|
|
1925
|
+
* @param opts.message {string} EIP-4361 message for signing. Returned from the generateSiweMessage call
|
|
1926
|
+
* @param opts.chainId {string} EIP-155 Chain ID to which the session is bound
|
|
1927
|
+
* @param opts.walletClientType {string} (optional) the wallet client of the external wallet (ie. 'metamask', 'coinbase_wallet'). Defaults to null if not specified.
|
|
1928
|
+
* @param opts.connectorType {string} (optional) the method used to connect the wallet to the application (ie. 'injected', 'wallet_connect_v2'). Defaults to null if not specified.
|
|
1929
|
+
* @returns The user response object.
|
|
1930
|
+
*/
|
|
1931
|
+
linkWithSiwe: ({ signature, message, chainId, walletClientType, connectorType, }: {
|
|
1932
|
+
signature: string;
|
|
1933
|
+
message: string;
|
|
1934
|
+
chainId: string;
|
|
1935
|
+
walletClientType?: string;
|
|
1936
|
+
connectorType?: string;
|
|
1937
|
+
}) => Promise<void>;
|
|
1938
|
+
/**
|
|
1939
|
+
* The current state of the SIWE link operation
|
|
1940
|
+
*/
|
|
1941
|
+
state: SiweFlowState;
|
|
1942
|
+
};
|
|
1943
|
+
/**
|
|
1944
|
+
* @experimental
|
|
1945
|
+
*
|
|
1946
|
+
* Use this hook to link an ethereum wallet to a user, without using any Privy UIs.
|
|
1947
|
+
*
|
|
1948
|
+
* @returns generateSiweMessage - {@link generateSiweMessage} generates a SIWE message for a given EIP-55 wallet address and eip-155 chain ID.
|
|
1949
|
+
* @returns linkWithSiwe - {@link linkWithSiwe} - Links a wallet to a user via the signature created for the SIWE message.
|
|
1950
|
+
*/
|
|
1951
|
+
declare const useLinkWithSiwe: () => UseLinkWithSiwe;
|
|
1952
|
+
|
|
1953
|
+
/**
|
|
1954
|
+
* Use this hook to register your app's logic for prompting users to complete MFA.
|
|
1955
|
+
* When a user is required to complete MFA in order to use their embedded wallet,
|
|
1956
|
+
* Privy will invoke the logic you register here to have the user complete MFA.
|
|
1957
|
+
* This hook should be mounted somewhere towards the root of your application tree
|
|
1958
|
+
* so that it can handle MFA required events from the entire application.
|
|
1959
|
+
*
|
|
1960
|
+
* @param callbacks {@link PrivyEvents} callbacks to register your logic for
|
|
1961
|
+
* prompting users to complete MFA.
|
|
1962
|
+
* @param callbacks.onMfaRequired {@link PrivyEvents} Privy will invoke this callback
|
|
1963
|
+
* whenever the user is required to complete MFA. Pass in a function that will prompt
|
|
1964
|
+
* your user to complete MFA with Privy (using `useMfa`) and only returns once
|
|
1965
|
+
* MFA has been completed.
|
|
1966
|
+
* @param callbacks.onError {@link PrivyEvents} Privy will invoke this callback whenever
|
|
1967
|
+
* there is an error in the MFA flow. Use this callback to define logic around how
|
|
1968
|
+
* you'd like to handle these errors (e.g. showing a UI to the user).
|
|
1969
|
+
*
|
|
1970
|
+
* @example
|
|
1971
|
+
* const [mfaMethods, setMfaMethods] = useState([])
|
|
1972
|
+
* const [isMfaDialogOpen, setIsMfaDialogOpen] = useState(false)
|
|
1973
|
+
*
|
|
1974
|
+
* // Prompt user to select from their enabled MFA methods
|
|
1975
|
+
* useRegisterMfaListener({
|
|
1976
|
+
* onMfaRequired: async (methods) => {
|
|
1977
|
+
* setMfaMethods(methods)
|
|
1978
|
+
* setIsMfaDialogOpen(true);
|
|
1979
|
+
* },
|
|
1980
|
+
* });
|
|
1981
|
+
*
|
|
1982
|
+
* // Within MFA modal allow the user to select an MFA method
|
|
1983
|
+
* <MFAModal
|
|
1984
|
+
* mfaMethods={mfaMethods}
|
|
1985
|
+
* isOpen={isMfaDialogOpen}
|
|
1986
|
+
* setIsOpen={setIsMfaDialogOpen}
|
|
1987
|
+
* />
|
|
1988
|
+
*
|
|
1989
|
+
* See `useMfa` for how to execute the MFA flow within Privy in your App.
|
|
1990
|
+
*/
|
|
1991
|
+
declare function useRegisterMfaListener(callbacks: PrivyEvents['configureMfa']): void;
|
|
1992
|
+
|
|
1993
|
+
/**
|
|
1994
|
+
* Use this hook to link a new account to an authenticated user, and to attach
|
|
1995
|
+
* callbacks for success and errors.
|
|
1996
|
+
*
|
|
1997
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute after a successful account linkage
|
|
1998
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `link`.
|
|
1999
|
+
*
|
|
2000
|
+
* @returns linkEmail - opens the Privy modal and prompts the user to link an email address
|
|
2001
|
+
* @returns linkPhone - opens the Privy modal and prompts the user to link a phone number
|
|
2002
|
+
* @returns linkWallet - opens the Privy modal and prompts the user to link an external wallet
|
|
2003
|
+
* @returns linkGoogle - immediately redirects to Google login page and prompts the user to link their account
|
|
2004
|
+
* @returns linkApple - immediately redirects to Apple login page and prompts the user to link their account
|
|
2005
|
+
* @returns linkTwitter - immediately redirects to Twitter login page and prompts the user to link their account
|
|
2006
|
+
* @returns linkDiscord - immediately redirects to Discord login page and prompts the user to link their account
|
|
2007
|
+
* @returns linkGithub - immediately redirects to Github login page and prompts the user to link their account
|
|
2008
|
+
* @returns linkLinkedIn - immediately redirects to LinkedIn login page and prompts the user to link their account
|
|
2009
|
+
* @returns linkTikTok - immediately redirects to TikTok login page and prompts the user to link their account
|
|
2010
|
+
* @returns linkSpotify - immediately redirects to Spotify login page and prompts the user to link their account
|
|
2011
|
+
* @returns linkInstagram - immediately redirects to Instagram login page and prompts the user to link their account
|
|
2012
|
+
* @returns linkTelegram - immediately redirects to Telegram login page and prompts the user to link their account
|
|
2013
|
+
* @returns linkFarcaster - displays a QR code to sign in with Farcaster and prompts user to link their account
|
|
2014
|
+
*
|
|
2015
|
+
*/
|
|
2016
|
+
declare function useLinkAccount(callbacks?: PrivyEvents['linkAccount']): {
|
|
2017
|
+
linkEmail: () => void;
|
|
2018
|
+
linkPhone: () => void;
|
|
2019
|
+
linkWallet: () => void;
|
|
2020
|
+
linkGoogle: () => void;
|
|
2021
|
+
linkApple: () => void;
|
|
2022
|
+
linkTwitter: () => void;
|
|
2023
|
+
linkDiscord: () => void;
|
|
2024
|
+
linkGithub: () => void;
|
|
2025
|
+
linkLinkedIn: () => void;
|
|
2026
|
+
linkTiktok: () => void;
|
|
2027
|
+
linkSpotify: () => void;
|
|
2028
|
+
linkInstagram: () => void;
|
|
2029
|
+
linkFarcaster: () => void;
|
|
2030
|
+
linkTelegram: () => void;
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
/**
|
|
2034
|
+
* Use this hook to connect the user's external wallet, and to attach
|
|
2035
|
+
* callbacks after a user successfully connects their wallet, or if there
|
|
2036
|
+
* is an error during the connection attempt.
|
|
2037
|
+
*
|
|
2038
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute when a user successfully connects their wallet
|
|
2039
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute when a user attempts to connect their wallet, but there is an error
|
|
2040
|
+
* @returns connectWallet - opens the Privy modal and prompts the user to connect an external wallet
|
|
2041
|
+
*/
|
|
2042
|
+
declare function useConnectWallet(callbacks?: PrivyEvents['connectWallet']): {
|
|
2043
|
+
/**
|
|
2044
|
+
* Opens the Privy modal and prompts the user to connect a wallet.
|
|
2045
|
+
*/
|
|
2046
|
+
connectWallet: (options?: ConnectWalletModalOptions | react.MouseEvent<any, any>) => void;
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Use this hook to create a privy wallet for a user, and to attach a callback after successful wallet creation.
|
|
2051
|
+
*
|
|
2052
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute when a user successfully creates a privy wallet
|
|
2053
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `cresteWallet`.
|
|
2054
|
+
* @returns createWallet - creates a privy wallet for the user.
|
|
2055
|
+
*/
|
|
2056
|
+
declare function useCreateWallet(callbacks?: PrivyEvents['createWallet']): {
|
|
2057
|
+
/**
|
|
2058
|
+
* Creates an embedded wallet for the current user.
|
|
2059
|
+
*
|
|
2060
|
+
* This method will error if the user already has an embedded wallet
|
|
2061
|
+
*
|
|
2062
|
+
* If the `config.embeddedWallets.requireUserOwnedRecoveryOnCreate` property is set to true,
|
|
2063
|
+
* this will prompt the user to complete a recovery flow to secure
|
|
2064
|
+
* the recovery share of their embedded wallet.
|
|
2065
|
+
*
|
|
2066
|
+
* Otherwise (the default), Privy will secure the recovery share, and the embedded wallet
|
|
2067
|
+
* will be created without showing any UIs to the user.
|
|
2068
|
+
*
|
|
2069
|
+
* @returns Promise for the {@link Wallet} object for the newly created embedded wallet
|
|
2070
|
+
*/
|
|
2071
|
+
createWallet: (options?: CreateWalletOptions | react.MouseEvent<any, any>) => Promise<Wallet>;
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
/**
|
|
2075
|
+
* Method to fund a user's wallet via Privy's funding feature by inputting a valid wallet address.
|
|
2076
|
+
* You can access the fields and methods documented here via the {@link useFundWallet} hook.
|
|
2077
|
+
*/
|
|
2078
|
+
interface UseFundWalletInterface {
|
|
2079
|
+
/**
|
|
2080
|
+
* Prompt the user to go through the funding flow and for a specified wallet.
|
|
2081
|
+
*
|
|
2082
|
+
* This will open the modal with a prompt for the user to select a funding method (if multiple are enabled).
|
|
2083
|
+
*
|
|
2084
|
+
* Once the user continues to the funding flow, Privy will display the funding status screen, and wait
|
|
2085
|
+
* for the transaction to complete.
|
|
2086
|
+
*
|
|
2087
|
+
* Note: Even after a successful funding, funds can take a few minutes to arrive in the user's wallet.
|
|
2088
|
+
*
|
|
2089
|
+
* Privy currently supports funding via external wallets and Moonpay.
|
|
2090
|
+
*
|
|
2091
|
+
* @param address typed data payload to be signed
|
|
2092
|
+
* @param fundWalletConfig {@link FundWalletConfig} Funding configuration to specify chain and funding amount (if enabled)
|
|
2093
|
+
*/
|
|
2094
|
+
fundWallet: (address: string, fundWalletConfig?: FundWalletConfig) => Promise<void>;
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Hook to fund a wallet via Privy's fiat on-ramp integration given the wallet address.
|
|
2098
|
+
*
|
|
2099
|
+
* @param callbacks.onUserExited {@link PrivyEvents} Callback that will execute when a funding flow is exited. This fires when a user closes a funding flow modal, for any reason.
|
|
2100
|
+
* @returns fundWallet - function to on-ramp funds to any given wallet
|
|
2101
|
+
*/
|
|
2102
|
+
declare const useFundWallet: (callbacks?: PrivyEvents["fundWallet"]) => UseFundWalletInterface;
|
|
2103
|
+
|
|
2104
|
+
/**
|
|
2105
|
+
* Hook to headlessly connect a Coinbase Smart Wallet to a user.
|
|
2106
|
+
*/
|
|
2107
|
+
interface UseConnectCoinbaseSmartWalletInterface {
|
|
2108
|
+
/**
|
|
2109
|
+
* Method to headlessly connect a Coinbase Smart Wallet to a user.
|
|
2110
|
+
* @experimental
|
|
2111
|
+
*/
|
|
2112
|
+
connectCoinbaseSmartWallet: () => void;
|
|
2113
|
+
}
|
|
2114
|
+
declare const useConnectCoinbaseSmartWallet: () => UseConnectCoinbaseSmartWalletInterface;
|
|
2115
|
+
|
|
2116
|
+
/**
|
|
2117
|
+
* Hook to access to link and interact with cross-app accounts from a provider app.
|
|
2118
|
+
* You can access the fields and methods documented here via the {@link useCrossAppAccounts} hook.
|
|
2119
|
+
*/
|
|
2120
|
+
interface UseCrossAppAccountsInterface {
|
|
2121
|
+
/**
|
|
2122
|
+
* For users who are not authenticated, prompts the user to log into their account from another Privy app.
|
|
2123
|
+
* Once a user has logged into their account, you can request signatures and transactions from their embedded wallet
|
|
2124
|
+
* in the linked app.
|
|
2125
|
+
*
|
|
2126
|
+
* @param options.appId {string} the target Privy app ID from which the user should log into another Privy account
|
|
2127
|
+
*
|
|
2128
|
+
* @returns a Promise that resolves if the user successfully authenticates, or rejects if there was an error
|
|
2129
|
+
*/
|
|
2130
|
+
loginWithCrossAppAccount: ({ appId }: {
|
|
2131
|
+
appId: string;
|
|
2132
|
+
}) => Promise<User>;
|
|
2133
|
+
/**
|
|
2134
|
+
* For users who are authenticated, prompts the user to link their account from another Privy app to their account
|
|
2135
|
+
* within your app. Once a user has linked their account, you can request signatures and transactions from their embedded wallet
|
|
2136
|
+
* in the linked app.
|
|
2137
|
+
*
|
|
2138
|
+
* This will redirect the user to a page on the target Privy app ID where they can login and authorize access to your app.
|
|
2139
|
+
* @param options.appId {string} the target Privy app ID from which the user should link another Privy account
|
|
2140
|
+
*/
|
|
2141
|
+
linkCrossAppAccount: ({ appId }: {
|
|
2142
|
+
appId: string;
|
|
2143
|
+
}) => Promise<User>;
|
|
2144
|
+
/**
|
|
2145
|
+
* Unlink a cross-app account from a user, by passing the apple subject ID.
|
|
2146
|
+
* Note that you can only unlink this account if the user has at least one other account.
|
|
2147
|
+
*
|
|
2148
|
+
* @param options.subject {string} the OAuth subject of the account to be unlinked.
|
|
2149
|
+
*/
|
|
2150
|
+
unlinkCrossAppAccount: ({ subject }: {
|
|
2151
|
+
subject: string;
|
|
2152
|
+
}) => Promise<User>;
|
|
2153
|
+
/**
|
|
2154
|
+
* For users who have linked an account from another privy app, prompts the user to sign a message
|
|
2155
|
+
* with their embedded wallet from the linked privy app.
|
|
2156
|
+
*
|
|
2157
|
+
* This will redirect the user to a page on the target Privy app where they can sign the message.
|
|
2158
|
+
*
|
|
2159
|
+
*
|
|
2160
|
+
* @param message {string} the message to sign
|
|
2161
|
+
* @param options.address {string} the address of the embedded wallet from the linked privy app
|
|
2162
|
+
*/
|
|
2163
|
+
signMessage: (message: string, o: {
|
|
2164
|
+
address: string;
|
|
2165
|
+
}) => Promise<string>;
|
|
2166
|
+
/**
|
|
2167
|
+
* For users who have linked an account from another privy app, prompts the user to sign typed data
|
|
2168
|
+
* with their embedded wallet from the linked privy app.
|
|
2169
|
+
*
|
|
2170
|
+
* This will redirect the user to a page on the target Privy app where they can sign the message.
|
|
2171
|
+
*
|
|
2172
|
+
*
|
|
2173
|
+
* @param data {SignTypedDataParameters} the typed data to sign
|
|
2174
|
+
* @param options.address {string} the address of the embedded wallet from the linked privy app
|
|
2175
|
+
*/
|
|
2176
|
+
signTypedData: (data: SignTypedDataParams, o: {
|
|
2177
|
+
address: string;
|
|
2178
|
+
}) => Promise<string>;
|
|
2179
|
+
/**
|
|
2180
|
+
* For users who have linked an account from another privy app, prompts the user to send a
|
|
2181
|
+
* transaction with their embedded wallet from the linked privy app.
|
|
2182
|
+
*
|
|
2183
|
+
* This will redirect the user to a page on the target Privy app where they can sign the message.
|
|
2184
|
+
*
|
|
2185
|
+
*
|
|
2186
|
+
* @param tx {UnsignedTransactionRequestWithChainId} the transaction to send
|
|
2187
|
+
* @param options.address {string} the address of the embedded wallet from the linked privy app
|
|
2188
|
+
*/
|
|
2189
|
+
sendTransaction: (tx: UnsignedTransactionRequestWithChainId, o: {
|
|
2190
|
+
address: string;
|
|
2191
|
+
}) => Promise<string>;
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Hook to use cross-app accounts
|
|
2195
|
+
*
|
|
2196
|
+
* @experimental
|
|
2197
|
+
* @returns o.linkCrossAppAccount - method to link a user's account from a provider app
|
|
2198
|
+
* @returns o.signMessage - method sign a message with a user's embedded wallet from a provider app
|
|
2199
|
+
*/
|
|
2200
|
+
declare const useCrossAppAccounts: () => UseCrossAppAccountsInterface;
|
|
2201
|
+
|
|
2202
|
+
/**
|
|
2203
|
+
* Use this hook to send a transaction using the embedded wallet and to attach callbacks for success and errors.
|
|
2204
|
+
* Transactions sent from the embedded wallet using transaction functions from non-Privy libraries
|
|
2205
|
+
* will not trigger the callbacks.
|
|
2206
|
+
*
|
|
2207
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful transaction sent
|
|
2208
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `sendTransaction`
|
|
2209
|
+
* @returns sendTransaction - prompts the user send a transaction using their embedded wallet
|
|
2210
|
+
*/
|
|
2211
|
+
declare function useSendTransaction(callbacks?: PrivyEvents['sendTransaction']): {
|
|
2212
|
+
/**
|
|
2213
|
+
* Prompts a user to send a transaction using their embedded wallet.
|
|
2214
|
+
*/
|
|
2215
|
+
sendTransaction: (data: UnsignedTransactionRequest, uiOptions?: SendTransactionModalUIOptions, fundWalletConfig?: FundWalletConfig, address?: string) => Promise<TransactionReceipt>;
|
|
2216
|
+
};
|
|
2217
|
+
|
|
2218
|
+
/**
|
|
2219
|
+
* Use this hook to send a transaction using the embedded wallet and to attach callbacks for success and errors.
|
|
2220
|
+
* Transactions sent from the embedded wallet using transaction functions from non-Privy libraries
|
|
2221
|
+
* will not trigger the callbacks.
|
|
2222
|
+
*
|
|
2223
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful transaction sent
|
|
2224
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `sendSolanaTransaction`
|
|
2225
|
+
* @returns sendSolanaTransaction - prompts the user send a transaction using their embedded wallet
|
|
2226
|
+
*/
|
|
2227
|
+
declare function useSendSolanaTransaction(callbacks?: PrivyEvents['sendSolanaTransaction']): {
|
|
2228
|
+
/**
|
|
2229
|
+
* Prompts a user to send a transaction using their embedded wallet.
|
|
2230
|
+
*/
|
|
2231
|
+
sendSolanaTransaction: (transaction: SupportedSolanaTransaction, connection: _solana_web3_js.Connection, uiOptions?: SendTransactionModalUIOptions, transactionOptions?: _solana_wallet_adapter_base.SendTransactionOptions) => Promise<SolanaTransactionReceipt>;
|
|
2232
|
+
};
|
|
2233
|
+
|
|
2234
|
+
/**
|
|
2235
|
+
* Use this hook to set a password on the embedded wallet, and to attach callbacks
|
|
2236
|
+
* for successful `password set`s, and `password set` errors.
|
|
2237
|
+
* Note that the callbacks will only fire for explicit `setWalletPassword` calls from the Privy SDK.
|
|
2238
|
+
*
|
|
2239
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful password setting
|
|
2240
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `setWalletPassword` -- ie.
|
|
2241
|
+
* the user doesn't have an embedded wallet, the user already has a set password on the wallet, or the password flow is prematurely exited.
|
|
2242
|
+
* @returns setWalletPassword - opens the Privy modal and prompts the user to set a password on the embedded wallet
|
|
2243
|
+
*/
|
|
2244
|
+
declare function useSetWalletPassword(callbacks?: PrivyEvents['setWalletPassword']): {
|
|
2245
|
+
/**
|
|
2246
|
+
* Opens the Privy set password modal and prompts the user to set wallet password.
|
|
2247
|
+
*/
|
|
2248
|
+
setWalletPassword: () => Promise<Wallet>;
|
|
2249
|
+
};
|
|
2250
|
+
|
|
2251
|
+
/**
|
|
2252
|
+
* Use this hook to create a guest account
|
|
2253
|
+
*
|
|
2254
|
+
* @returns createGuestAccount - {@link createGuestAccount} creates a guest account
|
|
2255
|
+
*/
|
|
2256
|
+
declare function useGuestAccounts(): {
|
|
2257
|
+
createGuestAccount: () => Promise<User>;
|
|
2258
|
+
};
|
|
2259
|
+
|
|
2260
|
+
/**
|
|
2261
|
+
* Use this hook to set user-controlled recovery on the embedded wallet, and to attach callbacks
|
|
2262
|
+
* for successful `recovery set`s, and `recovery set` errors.
|
|
2263
|
+
* Note that the callbacks will only fire for explicit `setWalletRecovery` calls from the Privy SDK.
|
|
2264
|
+
*
|
|
2265
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful recovery setting
|
|
2266
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `setWalletRecovery` -- ie.
|
|
2267
|
+
* the user doesn't have an embedded wallet, the user already has a cloud-based recovery on the wallet, or the password flow is prematurely exited.
|
|
2268
|
+
* @returns setWalletRecovery - opens the Privy modal and prompts the user to set a password on the embedded wallet
|
|
2269
|
+
*/
|
|
2270
|
+
declare function useSetWalletRecovery(callbacks?: PrivyEvents['setWalletRecovery']): {
|
|
2271
|
+
/**
|
|
2272
|
+
* Opens the Privy set recovery modal and prompts the user to set wallet password.
|
|
2273
|
+
*/
|
|
2274
|
+
setWalletRecovery: (o?: SetWalletRecoveryOptions) => Promise<Wallet>;
|
|
2275
|
+
};
|
|
2276
|
+
|
|
2277
|
+
/**
|
|
2278
|
+
* Use this hook to sign a message using the embedded wallet, and to attach callbacks for success and errors.
|
|
2279
|
+
*
|
|
2280
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful message signature
|
|
2281
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `signMessage`
|
|
2282
|
+
* @returns signMessage - prompts the user to sign a message with their embedded wallet
|
|
2283
|
+
*/
|
|
2284
|
+
declare function useSignMessage(callbacks?: PrivyEvents['signMessage']): {
|
|
2285
|
+
/**
|
|
2286
|
+
* Prompts a user to sign a message using their embedded wallet.
|
|
2287
|
+
*/
|
|
2288
|
+
signMessage: (message: string, uiOptions?: SignMessageModalUIOptions, address?: string) => Promise<string>;
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
/**
|
|
2292
|
+
* Use this hook to sign typed data using the embedded wallet, and to attach callbacks for success and errors.
|
|
2293
|
+
*
|
|
2294
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful signature
|
|
2295
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `signTypedData`
|
|
2296
|
+
* @returns signTypedData - prompts the user to sign typed data with their embedded wallet
|
|
2297
|
+
*/
|
|
2298
|
+
declare function useSignTypedData(callbacks?: PrivyEvents['signTypedData']): {
|
|
2299
|
+
/**
|
|
2300
|
+
* Prompts a user to sign typed data using their embedded wallet.
|
|
2301
|
+
*/
|
|
2302
|
+
signTypedData: (typedData: SignTypedDataParams, uiOptions?: SignMessageModalUIOptions, address?: string) => Promise<string>;
|
|
2303
|
+
};
|
|
2304
|
+
|
|
2305
|
+
/**
|
|
2306
|
+
* Use this hook to check whether or not the Privy modal is currently visible.
|
|
2307
|
+
*
|
|
2308
|
+
* @returns isOpen - whether or not the Privy modal is visible
|
|
2309
|
+
*/
|
|
2310
|
+
declare const useModalStatus: () => {
|
|
2311
|
+
isOpen: boolean;
|
|
2312
|
+
};
|
|
2313
|
+
|
|
2314
|
+
/**
|
|
2315
|
+
* Use this hook to tap into access token grant and revoke events.
|
|
2316
|
+
*
|
|
2317
|
+
* @param callbacks.onAccessTokenGranted {@link PrivyEvents} callback to automatically execute when a user is granted an access token. This will be called when a user logs in, or when a user's access token is refreshed.
|
|
2318
|
+
* @param callbacks.onAccessTokenRemoved {@link PrivyEvents} callback to automatically execute when a user's access token is revoked.
|
|
2319
|
+
* @returns getAccessToken - returns the user's current access token
|
|
2320
|
+
*/
|
|
2321
|
+
declare function useToken(callbacks?: PrivyEvents['accessToken']): {
|
|
2322
|
+
getAccessToken: () => Promise<string | null>;
|
|
2323
|
+
};
|
|
2324
|
+
|
|
2325
|
+
type UseOAuthTokens = {
|
|
2326
|
+
/**
|
|
2327
|
+
* For users who are authenticated, prompts the user to reauthorize an OAuth account of the specified type.
|
|
2328
|
+
* This will directly initiate the OAuth flow for an already linked OAuth account.
|
|
2329
|
+
*/
|
|
2330
|
+
reauthorize: ({ provider }: {
|
|
2331
|
+
provider: OAuthProviderType;
|
|
2332
|
+
}) => Promise<void>;
|
|
2333
|
+
};
|
|
2334
|
+
/**
|
|
2335
|
+
* Use this hook to retrieve the user's OAuth tokens after any subsequent OAuth Authorization flow.
|
|
2336
|
+
* Ensure that this callback is mounted whenever your user undergoes a successful OAuth authorization flow to access the OAuth and Refresh tokens.
|
|
2337
|
+
*
|
|
2338
|
+
* @param callbacks.onOAuthTokenGrant {@link PrivyEvents} callback to automatically execute when a user is granted an OAuth token during an OAuth flow.
|
|
2339
|
+
*
|
|
2340
|
+
* @returns reauthorize.reauthorize {@link UseOAuthTokens} triggers the OAuth authorization fow for an existing account
|
|
2341
|
+
*/
|
|
2342
|
+
declare function useOAuthTokens(callbacks?: PrivyEvents['oAuthAuthorization']): UseOAuthTokens;
|
|
2343
|
+
|
|
2344
|
+
type UseCustomAuth = {
|
|
2345
|
+
/**
|
|
2346
|
+
* Object that indicates the status of Privy's custom auth flow.
|
|
2347
|
+
*
|
|
2348
|
+
* Possible values include: {
|
|
2349
|
+
* status: 'initial' | 'loading' | 'not-enabled' | 'done';
|
|
2350
|
+
* }
|
|
2351
|
+
* or {
|
|
2352
|
+
* status: 'error';
|
|
2353
|
+
* error: Error | null;
|
|
2354
|
+
* }
|
|
2355
|
+
*
|
|
2356
|
+
*/
|
|
2357
|
+
status: CustomAuthFlowState;
|
|
2358
|
+
};
|
|
2359
|
+
/**
|
|
2360
|
+
* Use this hook to check the Privy auth flow status for whenever third-party/custom auth is enabled.
|
|
2361
|
+
*
|
|
2362
|
+
* @returns status - auth flow/ JWT exchange status of the Privy user, if custom auth is enabled
|
|
2363
|
+
*/
|
|
2364
|
+
declare const useCustomAuth: (callbacks?: PrivyEvents["customAuth"]) => UseCustomAuth;
|
|
2365
|
+
|
|
2366
|
+
/**
|
|
2367
|
+
* @deprecated Use `useFarcasterSigner` instead.
|
|
2368
|
+
*/
|
|
2369
|
+
declare const useExperimentalFarcasterSigner: typeof useFarcasterSigner;
|
|
2370
|
+
/**
|
|
2371
|
+
* Use this hook to write to Farcaster. This hook is experimental and subject to change.
|
|
2372
|
+
*
|
|
2373
|
+
* @experimental
|
|
2374
|
+
*/
|
|
2375
|
+
declare function useFarcasterSigner(): {
|
|
2376
|
+
getFarcasterSignerPublicKey: () => Promise<Uint8Array>;
|
|
2377
|
+
signFarcasterMessage: (messageHash: Uint8Array) => Promise<Uint8Array>;
|
|
2378
|
+
requestFarcasterSignerFromWarpcast: () => Promise<void>;
|
|
2379
|
+
};
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* Allows you to override the RPC url for the given chain
|
|
2383
|
+
*
|
|
2384
|
+
* @param chain {@link Chain} chain you want to modify
|
|
2385
|
+
* @param rpcUrl {@type string} rpc url you want to use for this chain
|
|
2386
|
+
* @returns modified chain object
|
|
2387
|
+
*
|
|
2388
|
+
* @example
|
|
2389
|
+
*
|
|
2390
|
+
* ```ts
|
|
2391
|
+
* import { mainnet } from 'viem/chains';
|
|
2392
|
+
* import { addRpcUrlOverrideToChain } from '@privy-io/react-auth';
|
|
2393
|
+
*
|
|
2394
|
+
* const mainnetOverride = addRpcUrlOverrideToChain(mainnet, INSERT_MAINNET_OVERRIDE_URL);
|
|
2395
|
+
* ```
|
|
2396
|
+
*/
|
|
2397
|
+
declare function addRpcUrlOverrideToChain(chain: Chain, rpcUrl: string): {
|
|
2398
|
+
rpcUrls: {
|
|
2399
|
+
privyWalletOverride: {
|
|
2400
|
+
http: string[];
|
|
2401
|
+
};
|
|
2402
|
+
default: {
|
|
2403
|
+
http: readonly string[];
|
|
2404
|
+
webSocket?: readonly string[];
|
|
2405
|
+
};
|
|
2406
|
+
} | {
|
|
2407
|
+
privyWalletOverride: {
|
|
2408
|
+
http: string[];
|
|
2409
|
+
};
|
|
2410
|
+
default: {
|
|
2411
|
+
http: readonly string[];
|
|
2412
|
+
webSocket?: readonly string[];
|
|
2413
|
+
};
|
|
2414
|
+
};
|
|
2415
|
+
id: number;
|
|
2416
|
+
name: string;
|
|
2417
|
+
network?: string;
|
|
2418
|
+
nativeCurrency: {
|
|
2419
|
+
name: string;
|
|
2420
|
+
symbol: string;
|
|
2421
|
+
decimals: number;
|
|
2422
|
+
};
|
|
2423
|
+
blockExplorers?: {
|
|
2424
|
+
[key: string]: {
|
|
2425
|
+
name: string;
|
|
2426
|
+
url: string;
|
|
2427
|
+
};
|
|
2428
|
+
default: {
|
|
2429
|
+
name: string;
|
|
2430
|
+
url: string;
|
|
2431
|
+
};
|
|
2432
|
+
};
|
|
2433
|
+
testnet?: boolean;
|
|
2434
|
+
};
|
|
2435
|
+
|
|
2436
|
+
/**
|
|
2437
|
+
* Get the embedded wallet for the user if they have one.
|
|
2438
|
+
*
|
|
2439
|
+
* @param wallets {@link ConnectedWallet} the array of wallets fetched via {@link useWallets}
|
|
2440
|
+
* @returns the embedded wallet if it exists, otherwise null
|
|
2441
|
+
*/
|
|
2442
|
+
declare function getEmbeddedConnectedWallet(wallets: ConnectedWallet[]): ConnectedWallet | null;
|
|
2443
|
+
|
|
2444
|
+
declare const LoginModal: ({ open }: {
|
|
2445
|
+
open: boolean;
|
|
2446
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
2447
|
+
|
|
2448
|
+
export { type CallbackError, Captcha, ConnectWalletModalOptions, ConnectedWallet, ConnectorManager, CustomAuthFlowState, EIP1193Provider, EthereumWalletConnector, FundWalletConfig, LoginModal, LoginModalOptions, LoginWithCode, MfaMethod, OAuthFlowState, OAuthProviderType, OAuthTokens, OtpFlowState, PasskeyFlowState, PrivyClient, PrivyClientConfig, type PrivyEvents, type PrivyInterface, PrivyProvider, type PrivyProviderProps, PrivyProxyProvider, DEFAULT_SUPPORTED_CHAINS as SUPPORTED_CHAINS, type SendCodeToEmail, type SendCodeToSms, SendTransactionModalUIOptions, SignMessageModalUIOptions, SignTypedDataParams, SiweFlowState, SolanaTransactionReceipt, SupportedSolanaTransaction, TransactionReceipt, UnsignedTransactionRequest, type UseConnectCoinbaseSmartWalletInterface, type UseCustomAuth, type UseFundWalletInterface, type UseLoginWithEmail, type UseLoginWithPasskey, type UseLoginWithSms, type UseOAuthTokens, type UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletListEntry, addRpcUrlOverrideToChain, errorIndicatesMaxMfaRetries, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, getAccessToken, getEmbeddedConnectedWallet, useConnectCoinbaseSmartWallet, useConnectWallet, useCreateWallet, useCrossAppAccounts, useCustomAuth, useExperimentalFarcasterSigner, useFarcasterSigner, useFundWallet, useGuestAccounts, useLinkAccount, useLinkWithSiwe, useLogin, useLoginWithEmail, useLoginWithOAuth, useLoginWithPasskey, useLoginWithSms, useLogout, useMfa, useMfaEnrollment, useModalStatus, useOAuthTokens, usePrivy, useRegisterMfaListener, useSendSolanaTransaction, useSendTransaction, useSetWalletPassword, useSetWalletRecovery, useSignMessage, useSignTypedData, useToken, useWallets };
|