@privy-io/react-auth 1.80.0 → 1.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-5ZCXUOSH.js +118 -0
- package/dist/esm/chunk-5ZCXUOSH.js +118 -0
- package/dist/esm/index.js +354 -480
- package/dist/esm/ui.js +139 -0
- package/dist/index.d.ts +12 -1887
- package/dist/index.js +364 -490
- package/dist/types-ed6781aa.d.ts +1894 -0
- package/dist/ui.d.ts +28 -0
- package/dist/ui.js +139 -0
- package/package.json +20 -6
|
@@ -0,0 +1,1894 @@
|
|
|
1
|
+
import { TypedMessage as TypedMessage$1, MessageTypes as MessageTypes$1 } from '@metamask/eth-sig-util';
|
|
2
|
+
import { ExternalProvider, StaticJsonRpcProvider, Web3Provider } from '@ethersproject/providers';
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
|
+
import { PasskeyAuthenticateInputType } from '@privy-io/public-api';
|
|
5
|
+
import { CountryCode } from 'libphonenumber-js/min';
|
|
6
|
+
import { ReactElement } from 'react';
|
|
7
|
+
import { Hex } from 'viem';
|
|
8
|
+
import { AbstractProvider } from 'web3-core';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* These types are fully compatible with WAGMI chain types, in case
|
|
12
|
+
* we need interop in the future.
|
|
13
|
+
*/
|
|
14
|
+
type RpcUrls = {
|
|
15
|
+
http: readonly string[];
|
|
16
|
+
webSocket?: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
type NativeCurrency = {
|
|
19
|
+
name: string;
|
|
20
|
+
/** 2-6 characters long */
|
|
21
|
+
symbol: string;
|
|
22
|
+
decimals: number;
|
|
23
|
+
};
|
|
24
|
+
type BlockExplorer = {
|
|
25
|
+
name: string;
|
|
26
|
+
url: string;
|
|
27
|
+
};
|
|
28
|
+
/** A subset of WAGMI's chain type
|
|
29
|
+
* https://github.com/wagmi-dev/references/blob/6aea7ee9c65cfac24f33173ab3c98176b8366f05/packages/chains/src/types.ts#L8
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
*
|
|
33
|
+
* override the RPC URL for a chain
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { mainnet } from 'viem/chains';
|
|
37
|
+
*
|
|
38
|
+
* const mainnetOverride: Chain = {
|
|
39
|
+
* ...mainnet,
|
|
40
|
+
* rpcUrls: {
|
|
41
|
+
* ...mainnet.rpcUrls,
|
|
42
|
+
* privyWalletOverride: {
|
|
43
|
+
* http: [INSERT_MAINNET_OVERRIDE_URL],
|
|
44
|
+
* },
|
|
45
|
+
* },
|
|
46
|
+
* };
|
|
47
|
+
*
|
|
48
|
+
* ```
|
|
49
|
+
* or
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { mainnet } from 'viem/chains';
|
|
52
|
+
* import { addRpcUrlOverrideToChain } from '@privy-io/react-auth';
|
|
53
|
+
*
|
|
54
|
+
* const mainnetOverride = addRpcUrlOverrideToChain(mainnet, INSERT_MAINNET_OVERRIDE_URL);
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
type Chain = {
|
|
59
|
+
/** Id in number form */
|
|
60
|
+
id: number;
|
|
61
|
+
/** Human readable name */
|
|
62
|
+
name: string;
|
|
63
|
+
/** Internal network name */
|
|
64
|
+
network?: string;
|
|
65
|
+
/** Currency used by chain */
|
|
66
|
+
nativeCurrency: NativeCurrency;
|
|
67
|
+
/** Collection of block explorers */
|
|
68
|
+
blockExplorers?: {
|
|
69
|
+
[key: string]: BlockExplorer;
|
|
70
|
+
default: BlockExplorer;
|
|
71
|
+
};
|
|
72
|
+
/** Collection of RPC endpoints */
|
|
73
|
+
rpcUrls: {
|
|
74
|
+
[key: string]: RpcUrls;
|
|
75
|
+
default: RpcUrls;
|
|
76
|
+
} | {
|
|
77
|
+
[key: string]: RpcUrls;
|
|
78
|
+
default: RpcUrls;
|
|
79
|
+
/** @optional Allows you to override the RPC url for this chain */
|
|
80
|
+
privyWalletOverride: RpcUrls;
|
|
81
|
+
};
|
|
82
|
+
/** Flag for test networks */
|
|
83
|
+
testnet?: boolean;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* RPC configuration for wallets.
|
|
87
|
+
*/
|
|
88
|
+
type RpcConfig = {
|
|
89
|
+
/**
|
|
90
|
+
* Mapping of chainId to RPC URL. Overrides Privy default RPC URLs that are shared across projects. Set your own RPC URLs
|
|
91
|
+
* to avoid rate limits or other throughput bottlenecks.
|
|
92
|
+
*
|
|
93
|
+
* Do not provide an RPC URL that can serve multiple networks. You should only provide RPC URLs that are speciifc to the
|
|
94
|
+
* chain ID you'd like to override.
|
|
95
|
+
*/
|
|
96
|
+
rpcUrls?: {
|
|
97
|
+
[key: number]: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Mapping between `walletClientType`s to the length of time after which RPC requests will timeout for that
|
|
101
|
+
* `walletClientType`.
|
|
102
|
+
*
|
|
103
|
+
* By default, all RPC requests through Privy will timeout after 2 mins (120000 ms). Use this object to
|
|
104
|
+
* override the RPC timeout in ms for specific` walletClientType`s, e.g. 'safe', in order to extend or
|
|
105
|
+
* shorten the timeout duration.
|
|
106
|
+
*/
|
|
107
|
+
rpcTimeouts?: {
|
|
108
|
+
[key in WalletClientType]?: number;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
type WalletCreateRequestDataType = {
|
|
113
|
+
accessToken: string;
|
|
114
|
+
recoveryPassword?: string;
|
|
115
|
+
recoveryMethod?: UserRecoveryMethod;
|
|
116
|
+
recoveryAccessToken?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Will be deprecated in a future release, use `recoveryPassword` instead
|
|
119
|
+
* @deprecated
|
|
120
|
+
*/
|
|
121
|
+
recoveryPin?: string;
|
|
122
|
+
};
|
|
123
|
+
type SolanaWalletCreateRequestDataType = {
|
|
124
|
+
accessToken: string;
|
|
125
|
+
/**
|
|
126
|
+
* If a user has an existing Ethereum embedded wallet when creating the Solana embedded wallet, that address
|
|
127
|
+
* MUST be passed in this field. Our iframe will use this address to derive the Solana embedded wallet from the
|
|
128
|
+
* same entropy as the Ethereum wallet.
|
|
129
|
+
*
|
|
130
|
+
* If no address is passed here, our iframe assumes that the user has no existing Ethereum wallet and will create
|
|
131
|
+
* a new set of entropy for Solana.
|
|
132
|
+
*/
|
|
133
|
+
ethereumAddress?: string;
|
|
134
|
+
};
|
|
135
|
+
type WalletImportRequestDataType = {
|
|
136
|
+
accessToken: string;
|
|
137
|
+
privateKey: string;
|
|
138
|
+
};
|
|
139
|
+
type WalletSetRecoveryRequestDataType = {
|
|
140
|
+
accessToken: string;
|
|
141
|
+
address: string;
|
|
142
|
+
recoveryMethod: UserRecoveryMethod;
|
|
143
|
+
recoveryPassword?: string;
|
|
144
|
+
recoveryAccessToken?: string;
|
|
145
|
+
};
|
|
146
|
+
type WalletRecoverRequestDataType = {
|
|
147
|
+
address: string;
|
|
148
|
+
imported?: boolean;
|
|
149
|
+
accessToken: string;
|
|
150
|
+
mfaCode?: string | PasskeyAuthenticateInputType['authenticator_response'];
|
|
151
|
+
mfaMethod?: MfaMethod;
|
|
152
|
+
relyingParty?: string;
|
|
153
|
+
recoveryPassword?: string;
|
|
154
|
+
recoveryMethod?: UserRecoveryMethod | 'privy';
|
|
155
|
+
recoveryAccessToken?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Will be deprecated in a future release, use `recoveryPassword` instead
|
|
158
|
+
* @deprecated
|
|
159
|
+
*/
|
|
160
|
+
recoveryPin?: string;
|
|
161
|
+
};
|
|
162
|
+
type WalletConnectRequestDataType = {
|
|
163
|
+
accessToken: string;
|
|
164
|
+
address: string;
|
|
165
|
+
};
|
|
166
|
+
type WalletRpcRequestDataType = {
|
|
167
|
+
accessToken: string;
|
|
168
|
+
mfaCode?: string | PasskeyAuthenticateInputType['authenticator_response'];
|
|
169
|
+
mfaMethod?: MfaMethod;
|
|
170
|
+
relyingParty?: string;
|
|
171
|
+
requesterAppId?: string;
|
|
172
|
+
address: string;
|
|
173
|
+
request: EthereumRpcRequestType;
|
|
174
|
+
};
|
|
175
|
+
type SolanaWalletConnectRequestDataType = {
|
|
176
|
+
publicKey: string;
|
|
177
|
+
accessToken: string;
|
|
178
|
+
};
|
|
179
|
+
type SolanaWalletRecoverRequestDataType = {
|
|
180
|
+
publicKey: string;
|
|
181
|
+
accessToken: string;
|
|
182
|
+
};
|
|
183
|
+
type SolanaWalletRpcRequestDataType = {
|
|
184
|
+
accessToken: string;
|
|
185
|
+
publicKey: string;
|
|
186
|
+
request: SolanaRpcRequestType;
|
|
187
|
+
};
|
|
188
|
+
type MfaVerifyRequestDataType = {
|
|
189
|
+
accessToken: string;
|
|
190
|
+
};
|
|
191
|
+
type MfaInitEnrollmentRequestDataType = {
|
|
192
|
+
accessToken: string;
|
|
193
|
+
method: 'sms';
|
|
194
|
+
phoneNumber: string;
|
|
195
|
+
} | {
|
|
196
|
+
accessToken: string;
|
|
197
|
+
method: 'totp';
|
|
198
|
+
};
|
|
199
|
+
type MfaSubmitEnrollmentRequestDataType = {
|
|
200
|
+
accessToken: string;
|
|
201
|
+
method: 'sms';
|
|
202
|
+
code: string;
|
|
203
|
+
phoneNumber: string;
|
|
204
|
+
} | {
|
|
205
|
+
accessToken: string;
|
|
206
|
+
method: 'totp';
|
|
207
|
+
code: string;
|
|
208
|
+
} | {
|
|
209
|
+
accessToken: string;
|
|
210
|
+
method: 'passkey';
|
|
211
|
+
credentialIds: string[];
|
|
212
|
+
};
|
|
213
|
+
type MfaUnenrollRequestDataType = {
|
|
214
|
+
accessToken: string;
|
|
215
|
+
method: 'sms' | 'totp';
|
|
216
|
+
};
|
|
217
|
+
type MfaClearRequestDataType = {
|
|
218
|
+
userId: string;
|
|
219
|
+
};
|
|
220
|
+
type FarcasterSignerInitRequestDataType = {
|
|
221
|
+
address: string;
|
|
222
|
+
hdWalletIndex: number | null;
|
|
223
|
+
accessToken: string;
|
|
224
|
+
mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'] | null;
|
|
225
|
+
mfaMethod: string | null;
|
|
226
|
+
relyingParty: string;
|
|
227
|
+
};
|
|
228
|
+
type FarcasterSignRequestDataType = {
|
|
229
|
+
address: string;
|
|
230
|
+
hdWalletIndex: number | null;
|
|
231
|
+
accessToken: string;
|
|
232
|
+
mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'] | null;
|
|
233
|
+
mfaMethod: string | null;
|
|
234
|
+
relyingParty: string;
|
|
235
|
+
payload: {
|
|
236
|
+
hash: string;
|
|
237
|
+
};
|
|
238
|
+
fid: bigint;
|
|
239
|
+
};
|
|
240
|
+
type WalletCreateResponseDataType = {
|
|
241
|
+
address: string;
|
|
242
|
+
};
|
|
243
|
+
type WalletImportResponseDataType = {
|
|
244
|
+
address: string;
|
|
245
|
+
};
|
|
246
|
+
type WalletConnectResponseDataType = {
|
|
247
|
+
address: string;
|
|
248
|
+
};
|
|
249
|
+
type WalletRecoverResponseDataType = {
|
|
250
|
+
address: string;
|
|
251
|
+
};
|
|
252
|
+
type WalletSetRecoveryResponseDataType = {
|
|
253
|
+
address: string;
|
|
254
|
+
};
|
|
255
|
+
type WalletRpcResponseDataType = {
|
|
256
|
+
address: string;
|
|
257
|
+
response: EthereumRpcResponseType;
|
|
258
|
+
};
|
|
259
|
+
type SolanaWalletCreateResponseDataType = {
|
|
260
|
+
publicKey: string;
|
|
261
|
+
};
|
|
262
|
+
type SolanaWalletConnectResponseDataType = {
|
|
263
|
+
publicKey: string;
|
|
264
|
+
};
|
|
265
|
+
type SolanaWalletRecoverResponseDataType = {
|
|
266
|
+
publicKey: string;
|
|
267
|
+
};
|
|
268
|
+
type SolanaWalletRpcResponseDataType = {
|
|
269
|
+
publicKey: string;
|
|
270
|
+
response: SolanaRpcResponseType;
|
|
271
|
+
};
|
|
272
|
+
type MfaVerifyResponseDataType = Record<string, never>;
|
|
273
|
+
type MfaInitEnrollmentResponseDataType = {
|
|
274
|
+
method: string;
|
|
275
|
+
secret?: string;
|
|
276
|
+
authUrl?: string;
|
|
277
|
+
};
|
|
278
|
+
type MfaSubmitEnrollmentResponseDataType = Record<string, never>;
|
|
279
|
+
type MfaUnenrollResponseDataType = Record<string, never>;
|
|
280
|
+
type MfaClearResponseDataType = Record<string, never>;
|
|
281
|
+
type FarcasterSignerInitResponseDataType = PrivyFarcasterSignerInitResponse;
|
|
282
|
+
type FarcasterSignResponseDataType = {
|
|
283
|
+
hash: string;
|
|
284
|
+
signature: string;
|
|
285
|
+
};
|
|
286
|
+
declare const PrivyIframeErrorTypes: readonly ["error", "invalid_request_arguments", "wallet_not_on_device", "invalid_recovery_pin", "insufficient_funds", "missing_or_invalid_mfa", "mfa_verification_max_attempts_reached", "mfa_timeout", "twilio_verification_failed"];
|
|
287
|
+
type PrivyIframeErrorTypesType = (typeof PrivyIframeErrorTypes)[number];
|
|
288
|
+
interface EmbeddedWalletProxy {
|
|
289
|
+
create: (data: WalletCreateRequestDataType) => Promise<WalletCreateResponseDataType>;
|
|
290
|
+
import: (data: WalletImportRequestDataType) => Promise<WalletImportResponseDataType>;
|
|
291
|
+
connect: (data: WalletConnectRequestDataType) => Promise<WalletConnectResponseDataType>;
|
|
292
|
+
recover: (data: WalletRecoverRequestDataType) => Promise<WalletRecoverResponseDataType>;
|
|
293
|
+
setRecovery: (data: WalletSetRecoveryRequestDataType) => Promise<WalletSetRecoveryResponseDataType>;
|
|
294
|
+
rpc: (data: WalletRpcRequestDataType) => Promise<WalletRpcResponseDataType>;
|
|
295
|
+
createSolana: (data: SolanaWalletCreateRequestDataType) => Promise<SolanaWalletCreateResponseDataType>;
|
|
296
|
+
connectSolana: (data: SolanaWalletConnectRequestDataType) => Promise<SolanaWalletConnectResponseDataType>;
|
|
297
|
+
recoverSolana: (data: SolanaWalletRecoverRequestDataType) => Promise<SolanaWalletRecoverResponseDataType>;
|
|
298
|
+
rpcSolana: (data: SolanaWalletRpcRequestDataType) => Promise<SolanaWalletRpcResponseDataType>;
|
|
299
|
+
verifyMfa: (data: MfaVerifyRequestDataType) => Promise<MfaVerifyResponseDataType>;
|
|
300
|
+
initEnrollMfa: (data: MfaInitEnrollmentRequestDataType) => Promise<MfaInitEnrollmentResponseDataType>;
|
|
301
|
+
submitEnrollMfa: (data: MfaSubmitEnrollmentRequestDataType) => Promise<MfaSubmitEnrollmentResponseDataType>;
|
|
302
|
+
unenrollMfa: (data: MfaUnenrollRequestDataType) => Promise<MfaUnenrollResponseDataType>;
|
|
303
|
+
clearMfa: (data: MfaClearRequestDataType) => Promise<MfaClearResponseDataType>;
|
|
304
|
+
initFarcasterSigner: (data: FarcasterSignerInitRequestDataType) => Promise<FarcasterSignerInitResponseDataType>;
|
|
305
|
+
signFarcasterMessage: (data: FarcasterSignRequestDataType) => Promise<FarcasterSignResponseDataType>;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
declare abstract class PrivyError extends Error {
|
|
309
|
+
/**
|
|
310
|
+
* Privy error type.
|
|
311
|
+
*/
|
|
312
|
+
abstract type: string;
|
|
313
|
+
/**
|
|
314
|
+
* Original Error object, it the error originated client-side.
|
|
315
|
+
*/
|
|
316
|
+
cause?: Error;
|
|
317
|
+
/**
|
|
318
|
+
* An optional error code, often included in Privy API responses.
|
|
319
|
+
*/
|
|
320
|
+
privyErrorCode?: PrivyErrorCode;
|
|
321
|
+
/**
|
|
322
|
+
* @param type Privy error type.
|
|
323
|
+
* @param message Human-readable message.
|
|
324
|
+
* @param cause Source of this error.
|
|
325
|
+
*/
|
|
326
|
+
protected constructor(message: string, cause?: unknown, privyErrorCode?: PrivyErrorCode);
|
|
327
|
+
toString(): string;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The PrivyConnector instance threw an exception.
|
|
331
|
+
*/
|
|
332
|
+
declare class PrivyConnectorError extends PrivyError {
|
|
333
|
+
type: string;
|
|
334
|
+
constructor(message: string, cause?: unknown, privyErrorCode?: PrivyErrorCode);
|
|
335
|
+
}
|
|
336
|
+
declare enum PrivyErrorCode {
|
|
337
|
+
OAUTH_ACCOUNT_SUSPENDED = "oauth_account_suspended",
|
|
338
|
+
MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
|
|
339
|
+
MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id",
|
|
340
|
+
MISSING_OR_INVALID_TOKEN = "missing_or_invalid_token",
|
|
341
|
+
INVALID_DATA = "invalid_data",
|
|
342
|
+
INVALID_CAPTCHA = "invalid_captcha",
|
|
343
|
+
LINKED_TO_ANOTHER_USER = "linked_to_another_user",
|
|
344
|
+
CANNOT_LINK_MORE_OF_TYPE = "cannot_link_more_of_type",
|
|
345
|
+
FAILED_TO_LINK_ACCOUNT = "failed_to_link_account",
|
|
346
|
+
ALLOWLIST_REJECTED = "allowlist_rejected",
|
|
347
|
+
OAUTH_USER_DENIED = "oauth_user_denied",
|
|
348
|
+
OAUTH_UNEXPECTED = "oauth_unexpected",
|
|
349
|
+
UNKNOWN_AUTH_ERROR = "unknown_auth_error",
|
|
350
|
+
USER_EXITED_AUTH_FLOW = "exited_auth_flow",
|
|
351
|
+
USER_EXITED_LINK_FLOW = "exited_link_flow",
|
|
352
|
+
USER_EXITED_SET_PASSWORD_FLOW = "user_exited_set_password_flow",
|
|
353
|
+
MUST_BE_AUTHENTICATED = "must_be_authenticated",
|
|
354
|
+
UNKNOWN_CONNECT_WALLET_ERROR = "unknown_connect_wallet_error",
|
|
355
|
+
GENERIC_CONNECT_WALLET_ERROR = "generic_connect_wallet_error",
|
|
356
|
+
CLIENT_REQUEST_TIMEOUT = "client_request_timeout",
|
|
357
|
+
INVALID_CREDENTIALS = "invalid_credentials",
|
|
358
|
+
MISSING_MFA_CREDENTIALS = "missing_or_invalid_mfa",
|
|
359
|
+
UNKNOWN_MFA_ERROR = "unknown_mfa_error",
|
|
360
|
+
EMBEDDED_WALLET_ALREADY_EXISTS = "embedded_wallet_already_exists",
|
|
361
|
+
EMBEDDED_WALLET_NOT_FOUND = "embedded_wallet_not_found",
|
|
362
|
+
UNKNOWN_EMBEDDED_WALLET_ERROR = "unknown_embedded_wallet_error",
|
|
363
|
+
EMBEDDED_WALLET_PASSWORD_UNCONFIRMED = "embedded_wallet_password_unconfirmed",
|
|
364
|
+
EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS = "embedded_wallet_password_already_exists",
|
|
365
|
+
EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS = "embedded_wallet_recovery_already_exists",
|
|
366
|
+
TRANSACTION_FAILURE = "transaction_failure",
|
|
367
|
+
UNSUPPORTED_CHAIN_ID = "unsupported_chain_id",
|
|
368
|
+
NOT_SUPPORTED = "not_supported",
|
|
369
|
+
CAPTCHA_TIMEOUT = "captcha_timeout",
|
|
370
|
+
INVALID_MESSAGE = "invalid_message",
|
|
371
|
+
UNABLE_TO_SIGN = "unable_to_sign",
|
|
372
|
+
CAPTCHA_FAILURE = "captcha_failure",
|
|
373
|
+
CAPTCHA_DISABLED = "captcha_disabled",
|
|
374
|
+
SESSION_STORAGE_UNAVAILABLE = "session_storage_unavailable",
|
|
375
|
+
TOO_MANY_REQUESTS = "too_many_requests",
|
|
376
|
+
USER_LIMIT_REACHED = "max_accounts_reached",
|
|
377
|
+
DISALLOWED_LOGIN_METHOD = "disallowed_login_method",
|
|
378
|
+
PASSKEY_NOT_ALLOWED = "passkey_not_allowed",
|
|
379
|
+
USER_DOES_NOT_EXIST = "user_does_not_exist",
|
|
380
|
+
INSUFFICIENT_BALANCE = "insufficient_balance"
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
declare class WalletTimeoutError extends PrivyConnectorError {
|
|
384
|
+
type: string;
|
|
385
|
+
constructor();
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* A ProviderRpcError combines the necessary bits of the {PrivyError} with the
|
|
389
|
+
* EIP-compliant ProviderRpcError. This is meant to be a type around errors raised
|
|
390
|
+
* by the ethereum provider.
|
|
391
|
+
*/
|
|
392
|
+
declare class ProviderRpcError extends PrivyError {
|
|
393
|
+
type: string;
|
|
394
|
+
readonly code: number;
|
|
395
|
+
readonly data?: unknown;
|
|
396
|
+
constructor(message: string, code: number, data?: unknown);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
declare global {
|
|
400
|
+
interface Window {
|
|
401
|
+
ethereum?: any;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
type ProviderConnectInfo = {
|
|
405
|
+
chainId: string;
|
|
406
|
+
};
|
|
407
|
+
type OnConnectEventHandler = (connectInfo: ProviderConnectInfo) => void;
|
|
408
|
+
type OnDisconnectEventHandler = (error: ProviderRpcError) => void;
|
|
409
|
+
type OnChainChangedEventHandler = (chainId: string | number) => void;
|
|
410
|
+
type OnAccountsChangedEventHandler = (accounts: string[]) => void;
|
|
411
|
+
type ProviderMessage = {
|
|
412
|
+
type: string;
|
|
413
|
+
data: unknown;
|
|
414
|
+
};
|
|
415
|
+
type OnMessageEventHandler = (message: ProviderMessage) => void;
|
|
416
|
+
type EIP1193OnEventHandler = OnConnectEventHandler | OnDisconnectEventHandler | OnChainChangedEventHandler | OnAccountsChangedEventHandler | OnMessageEventHandler;
|
|
417
|
+
interface EIP1193Provider {
|
|
418
|
+
rpcTimeoutDuration?: number;
|
|
419
|
+
request: (request: {
|
|
420
|
+
method: string;
|
|
421
|
+
params?: Array<any> | undefined;
|
|
422
|
+
}) => Promise<any>;
|
|
423
|
+
on: (eventName: string, listener: EIP1193OnEventHandler) => any;
|
|
424
|
+
removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => any;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* @hidden
|
|
428
|
+
*
|
|
429
|
+
* The PrivyProxyProvider adds a middleware layer on top of the underlying wallet provider.
|
|
430
|
+
* */
|
|
431
|
+
declare class PrivyProxyProvider implements EIP1193Provider {
|
|
432
|
+
rpcTimeoutDuration: number;
|
|
433
|
+
walletProvider?: EIP1193Provider;
|
|
434
|
+
private _subscriptions;
|
|
435
|
+
constructor(walletProvider?: EIP1193Provider, rpcTimeoutDuration?: number);
|
|
436
|
+
on(eventName: string, listener: (...args: any[]) => void): any;
|
|
437
|
+
request(request: {
|
|
438
|
+
method: string;
|
|
439
|
+
params?: any[] | undefined;
|
|
440
|
+
}): Promise<any>;
|
|
441
|
+
removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => any;
|
|
442
|
+
walletTimeout: (error?: WalletTimeoutError, timeoutMs?: number) => Promise<string[]>;
|
|
443
|
+
setWalletProvider: (provider: EIP1193Provider) => void;
|
|
444
|
+
}
|
|
445
|
+
interface RequestArguments {
|
|
446
|
+
readonly method: string;
|
|
447
|
+
readonly params?: readonly unknown[] | object | any;
|
|
448
|
+
}
|
|
449
|
+
declare class Embedded1193Provider extends EventEmitter implements EIP1193Provider {
|
|
450
|
+
walletProxy: EmbeddedWalletProxy;
|
|
451
|
+
address: string;
|
|
452
|
+
provider: StaticJsonRpcProvider;
|
|
453
|
+
chainId: number;
|
|
454
|
+
rpcConfig: RpcConfig;
|
|
455
|
+
chains: Chain[];
|
|
456
|
+
rpcTimeoutDuration: number;
|
|
457
|
+
appId: string;
|
|
458
|
+
constructor(walletProxy: EmbeddedWalletProxy, address: string, rpcConfig: RpcConfig, chains: Chain[], appId: string, chainId?: number);
|
|
459
|
+
handleSendTransaction(args: RequestArguments): Promise<string>;
|
|
460
|
+
private handleSwitchEthereumChain;
|
|
461
|
+
private handlePersonalSign;
|
|
462
|
+
private handleSignedTypedData;
|
|
463
|
+
private handleEstimateGas;
|
|
464
|
+
request(args: RequestArguments): Promise<unknown>;
|
|
465
|
+
connect(): Promise<string | null>;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* @hidden
|
|
469
|
+
*
|
|
470
|
+
* Shim to convert to ethers-compatible ExternalProvider class.
|
|
471
|
+
*/
|
|
472
|
+
declare class AsExternalProvider extends PrivyProxyProvider implements ExternalProvider {
|
|
473
|
+
constructor(provider: EIP1193Provider);
|
|
474
|
+
isMetaMask?: boolean;
|
|
475
|
+
isStatus?: boolean;
|
|
476
|
+
host?: string;
|
|
477
|
+
path?: string;
|
|
478
|
+
sendAsync?: (request: {
|
|
479
|
+
method: string;
|
|
480
|
+
params?: Array<any>;
|
|
481
|
+
}, callback: (error: any, response: any) => void) => void;
|
|
482
|
+
send?: (request: {
|
|
483
|
+
method: string;
|
|
484
|
+
params?: Array<any>;
|
|
485
|
+
}, callback: (error: any, response: any) => void) => void;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
interface SolanaProvider {
|
|
489
|
+
request: (request: {
|
|
490
|
+
method: string;
|
|
491
|
+
params?: any;
|
|
492
|
+
}) => Promise<any>;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Accepted payment methods for the MoonPay fiat on-ramp.
|
|
497
|
+
*/
|
|
498
|
+
type MoonpayPaymentMethod = 'ach_bank_transfer' | 'credit_debit_card' | 'gbp_bank_transfer' | 'gbp_open_banking_payment' | 'mobile_wallet' | 'sepa_bank_transfer' | 'sepa_open_banking_payment' | 'pix_instant_payment' | 'yellow_card_bank_transfer';
|
|
499
|
+
type MoonpayUiConfig = {
|
|
500
|
+
accentColor?: string;
|
|
501
|
+
theme?: 'light' | 'dark';
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Cryptocurrency codes for the MoonPay fiat on-ramp. These codes
|
|
505
|
+
* follow the format {TOKEN_NAME}_{NETWORK_NAME}.
|
|
506
|
+
*/
|
|
507
|
+
type MoonpayCurrencyCode = 'AVAX_CCHAIN' | 'CELO_CELO' | 'CUSD_CELO' | 'DAI_ETHEREUM' | 'ETH_ETHEREUM' | 'ETH_ARBITRUM' | 'ETH_POLYGON' | 'ETH_BASE' | 'FIL_FVM' | 'MATIC_ETHEREUM' | 'MATIC_POLYGON' | 'USDC_ETHEREUM' | 'USDC_ARBITRUM' | 'USDC_OPTIMISM' | 'USDC_POLYGON' | 'USDC_BASE' | 'USDT_ETHEREUM' | 'USDT_POLYGON' | 'WETH_POLYGON' | 'WBTC_ETHEREUM' | 'BNB_BNB' | 'BNB_BSC';
|
|
508
|
+
/**
|
|
509
|
+
* Configuration parameter for the MoonPay fiat on-ramp.
|
|
510
|
+
*/
|
|
511
|
+
type MoonpayConfig = {
|
|
512
|
+
currencyCode?: MoonpayCurrencyCode;
|
|
513
|
+
quoteCurrencyAmount?: number;
|
|
514
|
+
paymentMethod?: MoonpayPaymentMethod;
|
|
515
|
+
uiConfig?: MoonpayUiConfig;
|
|
516
|
+
};
|
|
517
|
+
type MoonpaySignRequest = {
|
|
518
|
+
address: string;
|
|
519
|
+
config: MoonpayConfig;
|
|
520
|
+
useSandbox: boolean;
|
|
521
|
+
};
|
|
522
|
+
type MoonpaySignResponse = {
|
|
523
|
+
signedUrl: string;
|
|
524
|
+
externalTransactionId: string;
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
declare const SUPPORTED_OAUTH_PROVIDERS: readonly ["google", "discord", "twitter", "github", "spotify", "instagram", "tiktok", "linkedin", "apple"];
|
|
528
|
+
declare const SUPPORTED_RECOVERY_PROVIDERS: readonly ["google-drive", "icloud"];
|
|
529
|
+
declare const SUPPORTED_MFA_METHODS: readonly ["sms", "totp", "passkey"];
|
|
530
|
+
type MfaMethod = (typeof SUPPORTED_MFA_METHODS)[number];
|
|
531
|
+
/**
|
|
532
|
+
* Supported OAuth providers. Can be `'google'`, `'discord'`, `'twitter'`, `'github'`, `'spotify'`,
|
|
533
|
+
* `'instagram'`, `'tiktok'`, `'linkedin'`, or `'apple'`
|
|
534
|
+
*/
|
|
535
|
+
type OAuthProviderType = (typeof SUPPORTED_OAUTH_PROVIDERS)[number];
|
|
536
|
+
/**
|
|
537
|
+
* Supported OAuth providers for the recovery flow. Can be `'google-drive'`
|
|
538
|
+
*/
|
|
539
|
+
type RecoveryProviderType = (typeof SUPPORTED_RECOVERY_PROVIDERS)[number];
|
|
540
|
+
type LoginMethod = 'email' | 'sms' | 'siwe' | 'farcaster' | OAuthProviderType | 'passkey' | 'telegram' | 'custom' | `privy:${string}` | 'guest';
|
|
541
|
+
type LoginWithCode = {
|
|
542
|
+
/**
|
|
543
|
+
* One-time password _([OTP](https://en.wikipedia.org/wiki/One-time_password))_ that was sent to user during first login step
|
|
544
|
+
*/
|
|
545
|
+
code: string;
|
|
546
|
+
};
|
|
547
|
+
declare const EMBEDDED_WALLET_CLIENT_TYPES: readonly ["privy"];
|
|
548
|
+
type EmbeddedWalletClientType = (typeof EMBEDDED_WALLET_CLIENT_TYPES)[number];
|
|
549
|
+
declare const INJECTED_WALLET_CLIENT_TYPES: readonly ["metamask", "phantom", "brave_wallet", "rainbow", "uniswap_wallet_extension", "uniswap_extension", "rabby_wallet", "crypto.com_wallet_extension"];
|
|
550
|
+
type InjectedWalletClientType = (typeof INJECTED_WALLET_CLIENT_TYPES)[number];
|
|
551
|
+
declare const COINBASE_WALLET_CLIENT_TYPES: readonly ["coinbase_wallet", "coinbase_smart_wallet"];
|
|
552
|
+
type CoinbaseWalletClientType = (typeof COINBASE_WALLET_CLIENT_TYPES)[number];
|
|
553
|
+
type WalletConnectWalletClientType = (typeof WALLET_CONNECT_WALLET_CLIENT_TYPES)[number];
|
|
554
|
+
declare const UNKNOWN_WALLET_CLIENT_TYPES: readonly ["unknown"];
|
|
555
|
+
type UnknownWalletClientType = (typeof UNKNOWN_WALLET_CLIENT_TYPES)[number];
|
|
556
|
+
type WalletClientType = InjectedWalletClientType | CoinbaseWalletClientType | WalletConnectWalletClientType | EmbeddedWalletClientType | UnknownWalletClientType;
|
|
557
|
+
declare const SUPPORTED_CONNECTOR_TYPES: string[];
|
|
558
|
+
type ConnectorType = (typeof SUPPORTED_CONNECTOR_TYPES)[number];
|
|
559
|
+
/**
|
|
560
|
+
* Wallet metadata currently for internal use only
|
|
561
|
+
*/
|
|
562
|
+
type WalletBranding = {
|
|
563
|
+
name: string;
|
|
564
|
+
id: string;
|
|
565
|
+
icon?: string | EmbeddedSVG;
|
|
566
|
+
};
|
|
567
|
+
type LinkedAccountType = 'wallet' | 'email' | 'phone' | 'google_oauth' | 'twitter_oauth' | 'discord_oauth' | 'github_oauth' | 'spotify_oauth' | 'instagram_oauth' | 'tiktok_oauth' | 'linkedin_oauth' | 'apple_oauth' | 'custom_auth' | 'farcaster' | 'passkey' | 'telegram' | 'cross_app' | 'guest';
|
|
568
|
+
/** @ignore */
|
|
569
|
+
interface LinkMetadata {
|
|
570
|
+
/** Account type, most commonly useful when filtering through linkedAccounts */
|
|
571
|
+
type: LinkedAccountType;
|
|
572
|
+
/**
|
|
573
|
+
* @deprecated use `firstVerifiedAt` instead.
|
|
574
|
+
* Datetime when this account was linked to the user or created. */
|
|
575
|
+
verifiedAt: Date;
|
|
576
|
+
/** Datetime when this account was linked to the user. */
|
|
577
|
+
firstVerifiedAt: Date | null;
|
|
578
|
+
/** Datetime when this account was most recently used as a login/link method by the user. */
|
|
579
|
+
latestVerifiedAt: Date | null;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Legacy configuration for the Moonpay funding selection.
|
|
583
|
+
*
|
|
584
|
+
* @deprecated
|
|
585
|
+
*/
|
|
586
|
+
type MoonpayFundingConfig = {
|
|
587
|
+
config: MoonpayConfig;
|
|
588
|
+
provider?: 'moonpay';
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* Configuration for native funding amount.
|
|
592
|
+
*/
|
|
593
|
+
type NativeFundingConfig = {
|
|
594
|
+
chain?: Chain;
|
|
595
|
+
amount?: string;
|
|
596
|
+
} | {
|
|
597
|
+
chain?: Chain;
|
|
598
|
+
amount: string;
|
|
599
|
+
asset: {
|
|
600
|
+
erc20: Hex;
|
|
601
|
+
};
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* Optional configuration parameter for the fiat on-ramp.
|
|
605
|
+
*/
|
|
606
|
+
type FundWalletConfig = MoonpayFundingConfig | NativeFundingConfig;
|
|
607
|
+
/**
|
|
608
|
+
* Possible methods of user-driven recovery.
|
|
609
|
+
* This is set, per app, on the server.
|
|
610
|
+
*/
|
|
611
|
+
type UserRecoveryMethod = 'user-passcode' | RecoveryProviderType;
|
|
612
|
+
/**
|
|
613
|
+
* Object representation of a user's wallet.
|
|
614
|
+
*/
|
|
615
|
+
interface Wallet {
|
|
616
|
+
/** The wallet address. */
|
|
617
|
+
address: string;
|
|
618
|
+
/**
|
|
619
|
+
* Chain type of the wallet address.
|
|
620
|
+
*/
|
|
621
|
+
chainType: 'ethereum' | 'solana';
|
|
622
|
+
/**
|
|
623
|
+
* @deprecated Use `BaseConnectedWallet.chainId` instead.
|
|
624
|
+
*
|
|
625
|
+
* ```tsx
|
|
626
|
+
* const {wallets} = useWallets();
|
|
627
|
+
* // Replace wallets[0] with the wallet you'd like
|
|
628
|
+
* const chainId = wallets[0].chainId;
|
|
629
|
+
* console.log(chainId);
|
|
630
|
+
* // This will be the current chain ID of the wallet,
|
|
631
|
+
* // e.g. 'eip155:1' if the wallet is on mainnet
|
|
632
|
+
* ```
|
|
633
|
+
*
|
|
634
|
+
* Represents the CAIP-2 formatted chain ID of the wallet
|
|
635
|
+
* during the most recent verification during SIWE. May not
|
|
636
|
+
* be up to date with the current chain ID of the wallet.
|
|
637
|
+
*
|
|
638
|
+
* Embedded wallets do not complete SIWE since the user is
|
|
639
|
+
* already authenticated, and you should not use this field
|
|
640
|
+
* for the embedded wallet.
|
|
641
|
+
*
|
|
642
|
+
* e.g. eip155:1, eip155:5, eip155:137, etc.
|
|
643
|
+
*/
|
|
644
|
+
chainId?: string;
|
|
645
|
+
/**
|
|
646
|
+
* @deprecated Use `walletClientType` instead.
|
|
647
|
+
*/
|
|
648
|
+
walletClient: 'privy' | 'unknown';
|
|
649
|
+
/**
|
|
650
|
+
* The wallet client used for this wallet during the most recent verification.
|
|
651
|
+
*
|
|
652
|
+
* If the value is `privy`, then this is a privy embedded wallet.
|
|
653
|
+
*
|
|
654
|
+
* Other values include but are not limited to `metamask`, `rainbow`, `coinbase_wallet`, etc.
|
|
655
|
+
*/
|
|
656
|
+
walletClientType?: string;
|
|
657
|
+
/**
|
|
658
|
+
* The connector type used for this wallet during the most recent verification.
|
|
659
|
+
*
|
|
660
|
+
* This includes but is not limited to `injected`, `wallet_connect`, `coinbase_wallet`, `embedded`.
|
|
661
|
+
*/
|
|
662
|
+
connectorType?: string;
|
|
663
|
+
/**
|
|
664
|
+
* If this is a 'privy' embedded wallet, stores the recovery method:
|
|
665
|
+
*
|
|
666
|
+
* 1. 'privy': privy escrow of the recovery material
|
|
667
|
+
* 2. 'user-passcode': recovery protected by user-input passcode
|
|
668
|
+
*/
|
|
669
|
+
recoveryMethod?: 'privy' | UserRecoveryMethod;
|
|
670
|
+
/** Whether the wallet is imported. */
|
|
671
|
+
imported: boolean;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Object representation of metadata reported by a connected wallet from a wallet connector
|
|
675
|
+
*/
|
|
676
|
+
interface ConnectedWalletMetadata {
|
|
677
|
+
/** The wallet name (e.g. MetaMask). */
|
|
678
|
+
name: string;
|
|
679
|
+
/** The wallet RDNS, falls back to the wallet name if none is available. */
|
|
680
|
+
id: string;
|
|
681
|
+
/** The wallet logo */
|
|
682
|
+
icon?: string;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Object representation of a base connected wallet from a wallet connector.
|
|
686
|
+
*/
|
|
687
|
+
interface BaseConnectedWallet {
|
|
688
|
+
/** The wallet address. */
|
|
689
|
+
address: string;
|
|
690
|
+
/** The current chain ID with CAIP-2 formatting. */
|
|
691
|
+
chainId: string;
|
|
692
|
+
/** The first time this wallet was connected without break. */
|
|
693
|
+
connectedAt: number;
|
|
694
|
+
/**
|
|
695
|
+
* The wallet client where this key-pair is stored.
|
|
696
|
+
* e.g. metamask, rainbow, coinbase_wallet, etc.
|
|
697
|
+
*/
|
|
698
|
+
walletClientType: WalletClientType;
|
|
699
|
+
/**
|
|
700
|
+
* The connector used to initiate the connection with the wallet client.
|
|
701
|
+
* e.g. injected, wallet_connect, coinbase_wallet, etc.
|
|
702
|
+
*/
|
|
703
|
+
connectorType: ConnectorType;
|
|
704
|
+
/** Whether the wallet is imported. */
|
|
705
|
+
imported: boolean;
|
|
706
|
+
/**
|
|
707
|
+
* Metadata for the wallet.
|
|
708
|
+
*/
|
|
709
|
+
meta: ConnectedWalletMetadata;
|
|
710
|
+
/** Returns true if the wallet is connected, false otherwise */
|
|
711
|
+
isConnected: () => Promise<boolean>;
|
|
712
|
+
/**
|
|
713
|
+
* Switch the network chain to a specified ID.
|
|
714
|
+
* Note: The chainId must be a supported network: https://docs.privy.io/guide/frontend/embedded/networks
|
|
715
|
+
* Note: This will not update any existing provider instances, re-request `wallet.getEthersProvider` (e.g.)
|
|
716
|
+
* to get a provider with the updated chainId.
|
|
717
|
+
*
|
|
718
|
+
* @param targetChainId The specified chain ID to switch to, as a number or 0x prefixed string.
|
|
719
|
+
* @returns void
|
|
720
|
+
*/
|
|
721
|
+
switchChain: (targetChainId: `0x${string}` | number) => Promise<void>;
|
|
722
|
+
/** Helper methods to build providers for interfacing with this wallet. */
|
|
723
|
+
getEthereumProvider: () => Promise<EIP1193Provider>;
|
|
724
|
+
getEthersProvider: () => Promise<Web3Provider>;
|
|
725
|
+
getWeb3jsProvider: () => Promise<AbstractProvider>;
|
|
726
|
+
/**
|
|
727
|
+
* Perform personal_sign with the user's wallet.
|
|
728
|
+
*
|
|
729
|
+
* @param {string} message The message to sign.
|
|
730
|
+
* @returns {string} The resulting signature.
|
|
731
|
+
*/
|
|
732
|
+
sign: (message: string) => Promise<string>;
|
|
733
|
+
/**
|
|
734
|
+
* @experimental **Experimental**: This property is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
735
|
+
*
|
|
736
|
+
* Not all wallet clients support programmatic disconnects (e.g. MetaMask, Phantom).
|
|
737
|
+
* In kind, if the wallet's client does not support programmatic disconnects,
|
|
738
|
+
* this method will no-op.
|
|
739
|
+
*/
|
|
740
|
+
disconnect: () => void;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Object representation of a connected wallet.
|
|
744
|
+
*/
|
|
745
|
+
interface ConnectedWallet extends BaseConnectedWallet {
|
|
746
|
+
/** True if this wallet is linked to the authenticated user. False if it is not yet linked or
|
|
747
|
+
* the user has not yet authenticated. */
|
|
748
|
+
linked: boolean;
|
|
749
|
+
/** Login with this wallet or link this wallet to the authenticated user.
|
|
750
|
+
*
|
|
751
|
+
* Throws a PrivyClientError if the wallet is not connected.
|
|
752
|
+
*/
|
|
753
|
+
loginOrLink: () => Promise<void>;
|
|
754
|
+
/**
|
|
755
|
+
* Prompt the user to go through the funding flow and for the connected wallet.
|
|
756
|
+
*
|
|
757
|
+
* This will open the modal with a prompt for the user to select a funding method (if multiple are enabled).
|
|
758
|
+
*
|
|
759
|
+
* Once the user continues to the funding flow, Privy will display the funding status screen, and wait
|
|
760
|
+
* for the transaction to complete.
|
|
761
|
+
*
|
|
762
|
+
* Note: Even after a successful funding, funds can take a few minutes to arrive in the user's wallet.
|
|
763
|
+
*
|
|
764
|
+
* Privy currently supports funding via external wallets and Moonpay.
|
|
765
|
+
*
|
|
766
|
+
* @param {FundWalletConfig} fundWalletConfig Funding configuration to specify chain and funding amount (if enabled)
|
|
767
|
+
* **/
|
|
768
|
+
fund: (fundWalletConfig?: FundWalletConfig) => Promise<void>;
|
|
769
|
+
/** Unlink this wallet to the authenticated user. Throws a PrivyClientError if the user is not
|
|
770
|
+
* authenticated. */
|
|
771
|
+
unlink: () => Promise<void>;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Object representation of a connected Solana wallet for the user.
|
|
775
|
+
*/
|
|
776
|
+
interface ConnectedSolanaWallet {
|
|
777
|
+
/** The Solana wallet address (base58-encoded public key) */
|
|
778
|
+
address: string;
|
|
779
|
+
/** A method to create a SolanaProvider to make RPC requests, like 'signMessage' to the wallet. */
|
|
780
|
+
getProvider: () => Promise<SolanaProvider>;
|
|
781
|
+
/** The first time this wallet was connected. */
|
|
782
|
+
connectedAt: number;
|
|
783
|
+
/** The wallet client for the Solana wallet. Currently, only embedded wallets (`walletClientType`: 'privy') is supported. */
|
|
784
|
+
walletClientType: 'privy';
|
|
785
|
+
/** The connector type for the Solana wallet. Currently, only embedded wallets (`connectorType`: 'embedded') is supported. */
|
|
786
|
+
connectorType: 'embedded';
|
|
787
|
+
/** Branding metadata for the Solana wallet. */
|
|
788
|
+
meta: WalletBranding;
|
|
789
|
+
}
|
|
790
|
+
/** Object representation of a user's email. */
|
|
791
|
+
interface Email {
|
|
792
|
+
/** The email address. */
|
|
793
|
+
address: string;
|
|
794
|
+
}
|
|
795
|
+
/** Object representation of a user's phone number. */
|
|
796
|
+
interface Phone {
|
|
797
|
+
/** The phone number. */
|
|
798
|
+
number: string;
|
|
799
|
+
}
|
|
800
|
+
/** Object representation of a user's Google account. */
|
|
801
|
+
interface Google {
|
|
802
|
+
/** The `sub` claim from the Google-issued JWT for this account. */
|
|
803
|
+
subject: string;
|
|
804
|
+
/** The email associated with the Google account. */
|
|
805
|
+
email: string;
|
|
806
|
+
/** The name associated with the Google account. */
|
|
807
|
+
name: string | null;
|
|
808
|
+
}
|
|
809
|
+
/** Object representation of a user's Twitter account. */
|
|
810
|
+
interface Twitter {
|
|
811
|
+
/** The `sub` claim from the Twitter-issued JWT for this account. */
|
|
812
|
+
subject: string;
|
|
813
|
+
/** The username associated with the Twitter account. */
|
|
814
|
+
username: string | null;
|
|
815
|
+
/** The name associated with the Twitter account. */
|
|
816
|
+
name: string | null;
|
|
817
|
+
/** The profile picture URL associated with the Twitter account.
|
|
818
|
+
* Note that the Twitter image URL returned is appended with `_normal`
|
|
819
|
+
* to return a 48x48px image. In order to retrieve the original-sized image,
|
|
820
|
+
* remove the `_normal` from the URL as specified in the Twitter API docs:
|
|
821
|
+
* https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/user-profile-images-and-banners
|
|
822
|
+
*/
|
|
823
|
+
profilePictureUrl: string | null;
|
|
824
|
+
}
|
|
825
|
+
/** Object representation of a user's Discord account. */
|
|
826
|
+
interface Discord {
|
|
827
|
+
/** The `sub` claim from the Discord-issued JWT for this account. */
|
|
828
|
+
subject: string;
|
|
829
|
+
/** The username associated with the Discord account. */
|
|
830
|
+
username: string | null;
|
|
831
|
+
/** The email associated with the Discord account. */
|
|
832
|
+
email: string | null;
|
|
833
|
+
}
|
|
834
|
+
/** Object representation of a user's Github account. */
|
|
835
|
+
interface Github {
|
|
836
|
+
/** The `sub` claim from the Github-issued JWT for this account. */
|
|
837
|
+
subject: string;
|
|
838
|
+
/** The username associated with the Github account. */
|
|
839
|
+
username: string | null;
|
|
840
|
+
/** The name associated with the Github account. */
|
|
841
|
+
name: string | null;
|
|
842
|
+
/** The email associated with the Github account. */
|
|
843
|
+
email: string | null;
|
|
844
|
+
}
|
|
845
|
+
/** Object representation of a user's Spotify account. */
|
|
846
|
+
interface Spotify {
|
|
847
|
+
/** The user id associated with the Spotify account. */
|
|
848
|
+
subject: string;
|
|
849
|
+
/** The email associated with the Spotify account. */
|
|
850
|
+
email: string | null;
|
|
851
|
+
/** The display name associated with the Spotify account. */
|
|
852
|
+
name: string | null;
|
|
853
|
+
}
|
|
854
|
+
/** Object representation of a user's Instagram account. */
|
|
855
|
+
interface Instagram {
|
|
856
|
+
/** The user id associated with the Instagram account. */
|
|
857
|
+
subject: string;
|
|
858
|
+
/** The username associated with the Instagram account. */
|
|
859
|
+
username: string | null;
|
|
860
|
+
}
|
|
861
|
+
/** Object representation of a user's Tiktok account. */
|
|
862
|
+
interface Tiktok {
|
|
863
|
+
/** The `sub` claim from the Tiktok-issued JWT for this account. */
|
|
864
|
+
subject: string;
|
|
865
|
+
/** The username associated with the Tiktok account. */
|
|
866
|
+
username: string | null;
|
|
867
|
+
/** The display name associated with the Tiktok account. */
|
|
868
|
+
name: string | null;
|
|
869
|
+
}
|
|
870
|
+
/** Object representation of a user's LinkedIn account. */
|
|
871
|
+
interface LinkedIn {
|
|
872
|
+
/** The `sub` claim from the LinkedIn-issued JWT for this account. */
|
|
873
|
+
subject: string;
|
|
874
|
+
/** The name associated with the LinkedIn account. */
|
|
875
|
+
name: string | null;
|
|
876
|
+
/** The email associated with the LinkedIn account. */
|
|
877
|
+
email: string | null;
|
|
878
|
+
/** The vanityName/profile URL associated with the LinkedIn account. */
|
|
879
|
+
vanityName: string | null;
|
|
880
|
+
}
|
|
881
|
+
/** Object representation of a user's Apple account. */
|
|
882
|
+
interface Apple {
|
|
883
|
+
/** The `sub` claim from the Apple-issued JWT for this account. */
|
|
884
|
+
subject: string;
|
|
885
|
+
/** The email associated with the Apple account. */
|
|
886
|
+
email: string;
|
|
887
|
+
}
|
|
888
|
+
interface CustomJwtAccount {
|
|
889
|
+
/** The user ID given by the custom auth provider */
|
|
890
|
+
customUserId: string;
|
|
891
|
+
}
|
|
892
|
+
interface Farcaster {
|
|
893
|
+
/** The Farcaster on-chain FID */
|
|
894
|
+
fid: number | null;
|
|
895
|
+
/** The Farcaster ethereum address that owns the FID */
|
|
896
|
+
ownerAddress: string;
|
|
897
|
+
/** The Farcaster protocol username */
|
|
898
|
+
username: string | null;
|
|
899
|
+
/** The Farcaster protocol display name */
|
|
900
|
+
displayName: string | null;
|
|
901
|
+
/** The Farcaster protocol bio */
|
|
902
|
+
bio: string | null;
|
|
903
|
+
/** The Farcaster protocol profile picture */
|
|
904
|
+
pfp: string | null;
|
|
905
|
+
/** The Farcaster protocol profile url */
|
|
906
|
+
url: string | null;
|
|
907
|
+
/** The public key of the signer, if set. This is not guaranteed to be valid, as the user can revoke the key at any time */
|
|
908
|
+
signerPublicKey: string | null;
|
|
909
|
+
}
|
|
910
|
+
interface Telegram {
|
|
911
|
+
/** The user ID that owns this Telegram account. */
|
|
912
|
+
telegramUserId: string;
|
|
913
|
+
/** The first name of the user . */
|
|
914
|
+
firstName: string | null;
|
|
915
|
+
/** The last name of the user . */
|
|
916
|
+
lastName: string | null;
|
|
917
|
+
/** The username associated with the Telegram account. */
|
|
918
|
+
username: string | null;
|
|
919
|
+
/** The url of the user's profile picture. */
|
|
920
|
+
photoUrl: string | null;
|
|
921
|
+
}
|
|
922
|
+
interface Passkey {
|
|
923
|
+
/** The passkey credential ID */
|
|
924
|
+
credentialId: string;
|
|
925
|
+
/** Whether or not this passkey can be used for MFA */
|
|
926
|
+
enrolledInMfa: boolean;
|
|
927
|
+
/** The type of authenticator holding the passkey */
|
|
928
|
+
authenticatorName?: string;
|
|
929
|
+
/** Metadata about the device that registered the passkey */
|
|
930
|
+
createdWithDevice?: string;
|
|
931
|
+
/** Metadata about the OS that registered the passkey */
|
|
932
|
+
createdWithOs?: string;
|
|
933
|
+
/** Metadata about the browser that registered the passkey */
|
|
934
|
+
createdWithBrowser?: string;
|
|
935
|
+
}
|
|
936
|
+
/** Metadata about the provider app for a cross-app account */
|
|
937
|
+
interface ProviderAppMetadata {
|
|
938
|
+
/** Privy app ID for the provider app. */
|
|
939
|
+
id: string;
|
|
940
|
+
/** Name for the provider app. */
|
|
941
|
+
name?: string;
|
|
942
|
+
/** Logo URL for the provider app. */
|
|
943
|
+
logoUrl?: string;
|
|
944
|
+
}
|
|
945
|
+
interface CrossAppAccount {
|
|
946
|
+
/** The user's embedded wallet address(es) from the provider app */
|
|
947
|
+
embeddedWallets: {
|
|
948
|
+
address: string;
|
|
949
|
+
}[];
|
|
950
|
+
smartWallets: {
|
|
951
|
+
address: string;
|
|
952
|
+
}[];
|
|
953
|
+
providerApp: ProviderAppMetadata;
|
|
954
|
+
subject: string;
|
|
955
|
+
}
|
|
956
|
+
/** Object representation of a user's email, with additional metadata for advanced use cases. */
|
|
957
|
+
interface EmailWithMetadata extends LinkMetadata, Email {
|
|
958
|
+
/** Denotes that this is an email account. */
|
|
959
|
+
type: 'email';
|
|
960
|
+
}
|
|
961
|
+
/** Object representation of a user's phone number, with additional metadata for advanced use cases. */
|
|
962
|
+
interface PhoneWithMetadata extends LinkMetadata, Phone {
|
|
963
|
+
/** Denotes that this is a phone account. */
|
|
964
|
+
type: 'phone';
|
|
965
|
+
}
|
|
966
|
+
/** Object representation of a user's wallet, with additional metadata for advanced use cases. */
|
|
967
|
+
interface WalletWithMetadata extends LinkMetadata, Wallet {
|
|
968
|
+
/** Denotes that this is a wallet account. */
|
|
969
|
+
type: 'wallet';
|
|
970
|
+
}
|
|
971
|
+
/** Object representation of a user's Google Account, with additional metadata for advanced use cases. */
|
|
972
|
+
interface GoogleOAuthWithMetadata extends LinkMetadata, Google {
|
|
973
|
+
/** Denotes that this is a Google account. */
|
|
974
|
+
type: 'google_oauth';
|
|
975
|
+
}
|
|
976
|
+
/** Object representation of a user's Twitter Account, with additional metadata for advanced use cases. */
|
|
977
|
+
interface TwitterOAuthWithMetadata extends LinkMetadata, Twitter {
|
|
978
|
+
/** Denotes that this is a Twitter account. */
|
|
979
|
+
type: 'twitter_oauth';
|
|
980
|
+
}
|
|
981
|
+
/** Object representation of a user's Discord Account, with additional metadata for advanced use cases. */
|
|
982
|
+
interface DiscordOAuthWithMetadata extends LinkMetadata, Discord {
|
|
983
|
+
/** Denotes that this is a Discord account. */
|
|
984
|
+
type: 'discord_oauth';
|
|
985
|
+
}
|
|
986
|
+
/** Object representation of a user's Github Account, with additional metadata for advanced use cases. */
|
|
987
|
+
interface GithubOAuthWithMetadata extends LinkMetadata, Github {
|
|
988
|
+
/** Denotes that this is a Github account. */
|
|
989
|
+
type: 'github_oauth';
|
|
990
|
+
}
|
|
991
|
+
/** Object representation of a user's Tiktok Account, with additional metadata for advanced use cases. */
|
|
992
|
+
interface SpotifyOAuthWithMetadata extends LinkMetadata, Spotify {
|
|
993
|
+
/** Denotes that this is a Tiktok account. */
|
|
994
|
+
type: 'spotify_oauth';
|
|
995
|
+
}
|
|
996
|
+
/** Object representation of a user's Instagram Account, with additional metadata for advanced use cases. */
|
|
997
|
+
interface InstagramOAuthWithMetadata extends LinkMetadata, Instagram {
|
|
998
|
+
/** Denotes that this is a Instagram account. */
|
|
999
|
+
type: 'instagram_oauth';
|
|
1000
|
+
}
|
|
1001
|
+
/** Object representation of a user's Tiktok Account, with additional metadata for advanced use cases. */
|
|
1002
|
+
interface TiktokOAuthWithMetadata extends LinkMetadata, Tiktok {
|
|
1003
|
+
/** Denotes that this is a Tiktok account. */
|
|
1004
|
+
type: 'tiktok_oauth';
|
|
1005
|
+
}
|
|
1006
|
+
/** Object representation of a user's LinkedIn Account, with additional metadata for advanced use cases. */
|
|
1007
|
+
interface LinkedInOAuthWithMetadata extends LinkMetadata, LinkedIn {
|
|
1008
|
+
/** Denotes that this is a LinkedIn account. */
|
|
1009
|
+
type: 'linkedin_oauth';
|
|
1010
|
+
}
|
|
1011
|
+
/** Object representation of a user's Apple Account, with additional metadata for advanced use cases. */
|
|
1012
|
+
interface AppleOAuthWithMetadata extends LinkMetadata, Apple {
|
|
1013
|
+
/** Denotes that this is a Apple account. */
|
|
1014
|
+
type: 'apple_oauth';
|
|
1015
|
+
}
|
|
1016
|
+
/** Object representation of a user's Custom JWT Account, with additional metadata for advanced use cases. */
|
|
1017
|
+
interface CustomJwtAccountWithMetadata extends LinkMetadata, CustomJwtAccount {
|
|
1018
|
+
/** Denotes that this is an custom account. */
|
|
1019
|
+
type: 'custom_auth';
|
|
1020
|
+
}
|
|
1021
|
+
/** Object representation of a user's Farcaster Account, with additional metadata for advanced use cases. */
|
|
1022
|
+
interface FarcasterWithMetadata extends LinkMetadata, Farcaster {
|
|
1023
|
+
/** Denotes that this is a Farcaster account. */
|
|
1024
|
+
type: 'farcaster';
|
|
1025
|
+
}
|
|
1026
|
+
/** Object representation of a user's Passkey Account, with additional metadata for advanced use cases. */
|
|
1027
|
+
interface PasskeyWithMetadata extends LinkMetadata, Passkey {
|
|
1028
|
+
/** Denotes that this is a Passkey account. */
|
|
1029
|
+
type: 'passkey';
|
|
1030
|
+
}
|
|
1031
|
+
/** Object representation of a user's Telegram Account, with additional metadata for advanced use cases. */
|
|
1032
|
+
interface TelegramWithMetadata extends LinkMetadata, Telegram {
|
|
1033
|
+
/** Denotes that this is a Telegram account. */
|
|
1034
|
+
type: 'telegram';
|
|
1035
|
+
}
|
|
1036
|
+
/** Object representation of a user's cross-app account, with additional metadata for advanced use cases. */
|
|
1037
|
+
interface CrossAppAccountWithMetadata extends LinkMetadata, CrossAppAccount {
|
|
1038
|
+
/** Denotes that this is a cross-app account */
|
|
1039
|
+
type: 'cross_app';
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Object representation of a user's linked accounts
|
|
1043
|
+
*/
|
|
1044
|
+
type LinkedAccountWithMetadata = WalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata | CrossAppAccountWithMetadata;
|
|
1045
|
+
interface User {
|
|
1046
|
+
/** The Privy-issued DID for the user. If you need to store additional information
|
|
1047
|
+
* about a user, you can use this DID to reference them. */
|
|
1048
|
+
id: string;
|
|
1049
|
+
/** The datetime of when the user was created. */
|
|
1050
|
+
createdAt: Date;
|
|
1051
|
+
/** The user's email address, if they have linked one. It cannot be linked to another user. */
|
|
1052
|
+
email?: Email;
|
|
1053
|
+
/** The user's phone number, if they have linked one. It cannot be linked to another user. */
|
|
1054
|
+
phone?: Phone;
|
|
1055
|
+
/** The user's most recently linked wallet, if they have linked at least one wallet.
|
|
1056
|
+
* It cannot be linked to another user.
|
|
1057
|
+
* This wallet is the wallet that will be used for transactions and signing if it is connected.
|
|
1058
|
+
**/
|
|
1059
|
+
wallet?: Wallet;
|
|
1060
|
+
/** The user's Google account, if they have linked one. It cannot be linked to another user. */
|
|
1061
|
+
google?: Google;
|
|
1062
|
+
/** The user's Twitter account, if they have linked one. It cannot be linked to another user. */
|
|
1063
|
+
twitter?: Twitter;
|
|
1064
|
+
/** The user's Discord account, if they have linked one. It cannot be linked to another user. */
|
|
1065
|
+
discord?: Discord;
|
|
1066
|
+
/** The user's Github account, if they have linked one. It cannot be linked to another user. */
|
|
1067
|
+
github?: Github;
|
|
1068
|
+
/** The user's Spotify account, if they have linked one. It cannot be linked to another user. */
|
|
1069
|
+
spotify?: Spotify;
|
|
1070
|
+
/** The user's Instagram account, if they have linked one. It cannot be linked to another user. */
|
|
1071
|
+
instagram?: Instagram;
|
|
1072
|
+
/** The user's Tiktok account, if they have linked one. It cannot be linked to another user. */
|
|
1073
|
+
tiktok?: Tiktok;
|
|
1074
|
+
/** The user's LinkedIn account, if they have linked one. It cannot be linked to another user. */
|
|
1075
|
+
linkedin?: LinkedIn;
|
|
1076
|
+
/** The user's Apple account, if they have linked one. It cannot be linked to another user. */
|
|
1077
|
+
apple?: Apple;
|
|
1078
|
+
/** The user's Farcaster account, if they have linked one. It cannot be linked to another user. */
|
|
1079
|
+
farcaster?: Farcaster;
|
|
1080
|
+
/** The user's Telegram account, if they have linked one. It cannot be linked to another user. */
|
|
1081
|
+
telegram?: Telegram;
|
|
1082
|
+
/** The list of accounts associated with this user. Each account contains additional metadata
|
|
1083
|
+
* that may be helpful for advanced use cases. */
|
|
1084
|
+
linkedAccounts: Array<LinkedAccountWithMetadata>;
|
|
1085
|
+
/** The list of MFA Methods associated with this user. */
|
|
1086
|
+
mfaMethods: Array<MfaMethod>;
|
|
1087
|
+
/**
|
|
1088
|
+
* Whether or not the user has explicitly accepted the Terms and Conditions
|
|
1089
|
+
* and/or Privacy Policy
|
|
1090
|
+
*/
|
|
1091
|
+
hasAcceptedTerms: boolean;
|
|
1092
|
+
/** Whether or not the user is a guest */
|
|
1093
|
+
isGuest: boolean;
|
|
1094
|
+
}
|
|
1095
|
+
type OAuthTokens = {
|
|
1096
|
+
/** The OAuth provider. */
|
|
1097
|
+
provider: OAuthProviderType;
|
|
1098
|
+
/** The OAuth access token. */
|
|
1099
|
+
accessToken: string;
|
|
1100
|
+
/** The number of seconds until the OAuth access token expires. */
|
|
1101
|
+
accessTokenExpiresInSeconds?: number;
|
|
1102
|
+
/** The OAuth refresh token. */
|
|
1103
|
+
refreshToken?: string;
|
|
1104
|
+
/** The number of seconds until the OAuth refresh token expires.
|
|
1105
|
+
* if the refresh token is present and this field is undefined, it is assumed
|
|
1106
|
+
* that the refresh token does not have an expiration date
|
|
1107
|
+
*/
|
|
1108
|
+
refreshTokenExpiresInSeconds?: number;
|
|
1109
|
+
/** The list of OAuth scopes the access token is approved for. */
|
|
1110
|
+
scopes?: string[];
|
|
1111
|
+
};
|
|
1112
|
+
type TelegramAuthConfiguration = {
|
|
1113
|
+
botId: string;
|
|
1114
|
+
botName: string;
|
|
1115
|
+
seamlessAuthEnabled: boolean;
|
|
1116
|
+
};
|
|
1117
|
+
type FundingMethod = 'moonpay' | 'coinbase-onramp' | 'external';
|
|
1118
|
+
type FundingConfig = {
|
|
1119
|
+
/** The recommended currency for the user to fund. Note: to begin with we default to the chain's native currency. */
|
|
1120
|
+
defaultRecommendedCurrency: {
|
|
1121
|
+
chain: string;
|
|
1122
|
+
};
|
|
1123
|
+
/** The recommended amount of the specified currency to fund, in human readable format (eg '0.1') */
|
|
1124
|
+
defaultRecommendedAmount: string;
|
|
1125
|
+
/** The list of funding methods enabled for the app */
|
|
1126
|
+
methods: FundingMethod[];
|
|
1127
|
+
/** Whether to prompt the user to fund upon embedded wallet creation */
|
|
1128
|
+
promptFundingOnWalletCreation: boolean;
|
|
1129
|
+
};
|
|
1130
|
+
type PrivyServerConfig = {
|
|
1131
|
+
id?: string;
|
|
1132
|
+
name?: string;
|
|
1133
|
+
verificationKey?: string;
|
|
1134
|
+
showWalletLoginFirst?: boolean;
|
|
1135
|
+
allowlistConfig: AllowlistConfig;
|
|
1136
|
+
walletAuth?: boolean;
|
|
1137
|
+
emailAuth?: boolean;
|
|
1138
|
+
smsAuth?: boolean;
|
|
1139
|
+
googleOAuth?: boolean;
|
|
1140
|
+
twitterOAuth?: boolean;
|
|
1141
|
+
discordOAuth?: boolean;
|
|
1142
|
+
githubOAuth?: boolean;
|
|
1143
|
+
spotifyOAuth?: boolean;
|
|
1144
|
+
instagramOAuth?: boolean;
|
|
1145
|
+
tiktokOAuth?: boolean;
|
|
1146
|
+
linkedinOAuth?: boolean;
|
|
1147
|
+
appleOAuth?: boolean;
|
|
1148
|
+
farcasterAuth?: boolean;
|
|
1149
|
+
passkeyAuth?: boolean;
|
|
1150
|
+
telegramAuth?: boolean;
|
|
1151
|
+
termsAndConditionsUrl: string | null;
|
|
1152
|
+
privacyPolicyUrl: string | null;
|
|
1153
|
+
requireUsersAcceptTerms?: boolean;
|
|
1154
|
+
createdAt?: Date;
|
|
1155
|
+
updatedAt?: Date;
|
|
1156
|
+
customApiUrl?: string | null;
|
|
1157
|
+
walletConnectCloudProjectId?: string | null;
|
|
1158
|
+
embeddedWalletConfig: EmbeddedWalletsConfig;
|
|
1159
|
+
fiatOnRampEnabled?: boolean;
|
|
1160
|
+
captchaEnabled?: boolean;
|
|
1161
|
+
captchaSiteKey: string;
|
|
1162
|
+
twitterOAuthOnMobileEnabled?: boolean;
|
|
1163
|
+
enforceWalletUis?: boolean;
|
|
1164
|
+
legacyWalletUiConfig?: boolean;
|
|
1165
|
+
/** May be deprecated from the server config in a future release */
|
|
1166
|
+
logoUrl?: string;
|
|
1167
|
+
/** May be deprecated from the server config in a future release */
|
|
1168
|
+
accentColor?: string;
|
|
1169
|
+
mfaMethods?: Array<MfaMethod>;
|
|
1170
|
+
telegramAuthConfiguration?: TelegramAuthConfiguration;
|
|
1171
|
+
fundingConfig?: FundingConfig;
|
|
1172
|
+
};
|
|
1173
|
+
type HexColor = `#${string}`;
|
|
1174
|
+
/**
|
|
1175
|
+
* Options to customize the display of transaction prices in the embedded wallet's transaction prompt.
|
|
1176
|
+
*/
|
|
1177
|
+
type PriceDisplayOptions = {
|
|
1178
|
+
primary: 'fiat-currency';
|
|
1179
|
+
secondary: 'native-token';
|
|
1180
|
+
} | {
|
|
1181
|
+
primary: 'native-token';
|
|
1182
|
+
secondary: null;
|
|
1183
|
+
};
|
|
1184
|
+
type WalletListEntry = 'metamask' | 'coinbase_wallet' | 'rainbow' | 'phantom' | 'zerion' | 'cryptocom' | 'uniswap' | 'okx_wallet' | 'detected_wallets' | 'wallet_connect' | 'rabby_wallet' | 'safe';
|
|
1185
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
1186
|
+
type LoginMethodOrderOption = 'email' | 'sms' | WalletListEntry | OAuthProviderType | 'farcaster' | 'telegram';
|
|
1187
|
+
type ExternalWalletsConfig = {
|
|
1188
|
+
/**
|
|
1189
|
+
* Options to configure connections to the Coinbase Wallet (browser extension wallet, mobile wallet, and
|
|
1190
|
+
* passkey-based smart wallet).
|
|
1191
|
+
*
|
|
1192
|
+
* @experimental This is an experimental config designed to give Privy developers a way to test the Coinbase Smart Wallet
|
|
1193
|
+
* ahead of its mainnet launch. The smart wallet currently only supports the Base Sepolia testnet. In kind, DO NOT use this
|
|
1194
|
+
* configuration in production as it will prevent users from using the Coinbase Wallet on networks other than Base Sepolia.
|
|
1195
|
+
*/
|
|
1196
|
+
coinbaseWallet?: {
|
|
1197
|
+
/**
|
|
1198
|
+
* Whether Coinbase wallet connections should prompt the smart wallet, the extension wallet, or intelligently decide between the two.
|
|
1199
|
+
* - If 'eoaOnly', Coinbase wallet connections will only prompt the Coinbase wallet browser extension or mobile app (an externally-owned account)
|
|
1200
|
+
* - If 'smartWalletOnly', Coinbase wallet connections will only prompt the Coinbase smart wallet and will not allow users to use the extension or mobile app.
|
|
1201
|
+
* DO NOT use this setting in production.
|
|
1202
|
+
* - If 'all', Coinbase wallet connections will prompt the Coinbase wallet browser extension if it is detected as installed, and will otherwise prompt the smart wallet.
|
|
1203
|
+
*/
|
|
1204
|
+
connectionOptions: 'all' | 'eoaOnly' | 'smartWalletOnly';
|
|
1205
|
+
};
|
|
1206
|
+
/**
|
|
1207
|
+
* Options to configure WalletConnect behavior.
|
|
1208
|
+
*
|
|
1209
|
+
* @experimental This may change in future releases
|
|
1210
|
+
*/
|
|
1211
|
+
walletConnect?: {
|
|
1212
|
+
/**
|
|
1213
|
+
* If disabled, stops WalletConnect from being initialized by the Privy SDK.
|
|
1214
|
+
*
|
|
1215
|
+
* WARNING: If you allow WalletConnect or WalletConnect-powered wallets, this will cause issues.
|
|
1216
|
+
*
|
|
1217
|
+
* Note that even if disabled, WalletConnect code may still be loaded in the browser. Defaults to true.
|
|
1218
|
+
*
|
|
1219
|
+
* @experimental This feature is very experimental and may break your wallet connector experience if you use external wallets.
|
|
1220
|
+
*/
|
|
1221
|
+
enabled: boolean;
|
|
1222
|
+
};
|
|
1223
|
+
};
|
|
1224
|
+
interface PrivyClientConfig {
|
|
1225
|
+
/** All UI and theme related configuration */
|
|
1226
|
+
appearance?: {
|
|
1227
|
+
/** Primary theme for the privy UI. This dictates the foreground and background colors within the UI.
|
|
1228
|
+
*
|
|
1229
|
+
* 'light' (default): The privy default light UI.
|
|
1230
|
+
* 'dark': The privy default dark UI.
|
|
1231
|
+
* custom hex code (i.e. '#13152F'): A custom background. This will generate the remainder of the foreground and
|
|
1232
|
+
* background colors for the UI by modulating the luminance of the passed color. This value should be _either_ dark
|
|
1233
|
+
* or light (<20% or >80% luminance), for accessibility. */
|
|
1234
|
+
theme?: 'light' | 'dark' | HexColor;
|
|
1235
|
+
/** Accent color for the privy UI.
|
|
1236
|
+
* Used for buttons, active borders, etc. This will generate light and dark variants.
|
|
1237
|
+
* This overrides the server setting `accent_color`. */
|
|
1238
|
+
accentColor?: HexColor;
|
|
1239
|
+
/** Logo for the main privy modal screen.
|
|
1240
|
+
* This can be a string (url) or an img / svg react element.
|
|
1241
|
+
* If passing an element, Privy will overwrite the `style` props, to ensure proper rendering.
|
|
1242
|
+
* This overrides the server setting `logo_url` */
|
|
1243
|
+
logo?: string | ReactElement;
|
|
1244
|
+
/**
|
|
1245
|
+
* Header text for the landing screen of the Privy login modal. We strongly recommend using a string
|
|
1246
|
+
* of length 35 or less. Strings longer than the width of the login modal will be ellipsified.
|
|
1247
|
+
*
|
|
1248
|
+
* Defaults to 'Log in or sign up'.
|
|
1249
|
+
*/
|
|
1250
|
+
landingHeader?: string;
|
|
1251
|
+
/**
|
|
1252
|
+
* Subtitle text for the landing screen of the Privy login modal.
|
|
1253
|
+
*
|
|
1254
|
+
* This text will renders below the logo and will be capped at 100 characters.
|
|
1255
|
+
*
|
|
1256
|
+
* Defaults to undefined.
|
|
1257
|
+
*/
|
|
1258
|
+
loginMessage?: string;
|
|
1259
|
+
/** Determines the order of the login options in the privy modal. If true, the wallet login will render above
|
|
1260
|
+
* social and email / sms login options.
|
|
1261
|
+
* This overrides the server setting `show_wallet_login_first` */
|
|
1262
|
+
showWalletLoginFirst?: boolean;
|
|
1263
|
+
/**
|
|
1264
|
+
* An array of {@link WalletListEntry wallet names} to configure the wallet buttons shown within
|
|
1265
|
+
* the `login`, `connectWallet`, and `linkWallet` modals. Privy will show buttons for each option
|
|
1266
|
+
* present in the list, in the order in which they are configured.
|
|
1267
|
+
*
|
|
1268
|
+
* On 'detected_wallets':
|
|
1269
|
+
* - This option serves as a fallback to include all wallets that detected by Privy, that might not be
|
|
1270
|
+
* individually configured in the `walletList`. Browser extension wallets that are not explicitly configured
|
|
1271
|
+
* in the `walletList` will fall into this category.
|
|
1272
|
+
* - If Privy detects a wallet, _and_ that wallet is configured within the `walletList` (e.g. 'metamask'),
|
|
1273
|
+
* the order of the wallet's explicit name (e.g. 'metamask') in the `walletList` will take priority
|
|
1274
|
+
* over the order of 'detected_wallets'.
|
|
1275
|
+
*
|
|
1276
|
+
* Defaults to ['detected_wallets', 'metamask', 'coinbase', 'rainbow', 'wallet_connect']
|
|
1277
|
+
*
|
|
1278
|
+
* @default ['detected_wallets', 'metamask', 'coinbase', 'rainbow', 'wallet_connect']
|
|
1279
|
+
*/
|
|
1280
|
+
walletList?: WalletListEntry[];
|
|
1281
|
+
};
|
|
1282
|
+
/**
|
|
1283
|
+
* Login methods for the privy modal.
|
|
1284
|
+
*
|
|
1285
|
+
* This parameter enables you to display a subset of the login methods specified in the developer dashboard. `loginMethods` cannot be an empty array if specified. The order of this array does not dictate order of the login methods in the UI.
|
|
1286
|
+
*
|
|
1287
|
+
* Note that any login method included in this parameter must also be enabled as a login method in the developer dashboard.
|
|
1288
|
+
*
|
|
1289
|
+
* If both `loginMethodsAndOrder` and `loginMethods` are defined, `loginMethodsAndOrder` will take precedence.
|
|
1290
|
+
*/
|
|
1291
|
+
loginMethods?: Array<'wallet' | 'email' | 'sms' | 'google' | 'twitter' | 'discord' | 'github' | 'linkedin' | 'spotify' | 'instagram' | 'tiktok' | 'apple' | 'farcaster' | 'telegram'>;
|
|
1292
|
+
/**
|
|
1293
|
+
* Login methods for the Privy modal. _This will override carefully designed defaults and should be used with caution._
|
|
1294
|
+
*
|
|
1295
|
+
* This parameter enables you to display a subset of the login methods specified in the developer dashboard. Login methods will be rendered in the order they appear in the array. The first 4 options specified in the `primary` list will render on the default screen of the login experience. Options in the `overflow` list will appear on the following screen.
|
|
1296
|
+
*
|
|
1297
|
+
* Note that any login method included in this parameter must also be enabled as a login method in the developer dashboard.
|
|
1298
|
+
*
|
|
1299
|
+
* If both `loginMethodsAndOrder` and `loginMethods` are defined, `loginMethodsAndOrder` will take precedence.
|
|
1300
|
+
*/
|
|
1301
|
+
loginMethodsAndOrder?: {
|
|
1302
|
+
primary: NonEmptyArray<LoginMethodOrderOption>;
|
|
1303
|
+
overflow?: Array<LoginMethodOrderOption>;
|
|
1304
|
+
};
|
|
1305
|
+
/** Options for internationalization of the privy modal */
|
|
1306
|
+
intl?: {
|
|
1307
|
+
/**
|
|
1308
|
+
* This property is used to configure formatting and validation for the phone number input
|
|
1309
|
+
* used when `phone` is enabled as a login method. Must be a valid
|
|
1310
|
+
* [two-leter ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) (e.g. 'US').
|
|
1311
|
+
* Defaults to 'US'.
|
|
1312
|
+
*
|
|
1313
|
+
* @default 'US'
|
|
1314
|
+
*/
|
|
1315
|
+
defaultCountry: CountryCode;
|
|
1316
|
+
};
|
|
1317
|
+
/**
|
|
1318
|
+
* This property is only required for apps that use a third-party authentication provider.
|
|
1319
|
+
*/
|
|
1320
|
+
customAuth?: {
|
|
1321
|
+
/**
|
|
1322
|
+
* If true, enable custom authentication integration.
|
|
1323
|
+
* This enables a JWT from a custom auth provider to be used to authenticate Privy embedded wallets.
|
|
1324
|
+
* Defaults to true.
|
|
1325
|
+
*
|
|
1326
|
+
* @default true
|
|
1327
|
+
*/
|
|
1328
|
+
enabled?: boolean;
|
|
1329
|
+
/**
|
|
1330
|
+
* A callback that returns the user's custom auth provider's access token as a string.
|
|
1331
|
+
* Can be left blank if using cookies to store and send access tokens
|
|
1332
|
+
*
|
|
1333
|
+
* @example
|
|
1334
|
+
* const {getAccessTokenSilently} = useAuth();
|
|
1335
|
+
*
|
|
1336
|
+
* <PrivyProvider
|
|
1337
|
+
* {...props}
|
|
1338
|
+
* config={{
|
|
1339
|
+
* customAuth: {
|
|
1340
|
+
* getCustomAccessToken: getAccessTokenSilently
|
|
1341
|
+
* },
|
|
1342
|
+
* }}
|
|
1343
|
+
* />
|
|
1344
|
+
*/
|
|
1345
|
+
getCustomAccessToken: () => Promise<string | undefined>;
|
|
1346
|
+
/**
|
|
1347
|
+
* Custom auth providers loading state
|
|
1348
|
+
*
|
|
1349
|
+
* @example
|
|
1350
|
+
* const {isLoading} = useAuth();
|
|
1351
|
+
*
|
|
1352
|
+
* <PrivyProvider
|
|
1353
|
+
* {...props}
|
|
1354
|
+
* config={{
|
|
1355
|
+
* customAuth: {
|
|
1356
|
+
* isLoading,
|
|
1357
|
+
* },
|
|
1358
|
+
* }}
|
|
1359
|
+
* />
|
|
1360
|
+
*/
|
|
1361
|
+
isLoading: boolean;
|
|
1362
|
+
};
|
|
1363
|
+
/** All legal configuration */
|
|
1364
|
+
legal?: {
|
|
1365
|
+
/** URL to the terms and conditions page for your application.
|
|
1366
|
+
* Rendered as a link in the privy modal footer.
|
|
1367
|
+
* This overrides the server setting `terms_and_conditions_url` */
|
|
1368
|
+
termsAndConditionsUrl?: string | null;
|
|
1369
|
+
/** URL to the privacy policy page for your application.
|
|
1370
|
+
* Rendered as a link in the privy modal footer.
|
|
1371
|
+
* This overrides the server setting `privacy_policy_url` */
|
|
1372
|
+
privacyPolicyUrl?: string | null;
|
|
1373
|
+
};
|
|
1374
|
+
walletConnectCloudProjectId?: string;
|
|
1375
|
+
/**
|
|
1376
|
+
* @deprecated use `supportedChains[number].rpcUrls.privyWalletOverride` instead.
|
|
1377
|
+
*
|
|
1378
|
+
* RPC overrides to customize RPC URLs and timeout durations.
|
|
1379
|
+
*/
|
|
1380
|
+
rpcConfig?: RpcConfig;
|
|
1381
|
+
/**
|
|
1382
|
+
* @deprecated use `supportedChains` instead.
|
|
1383
|
+
*
|
|
1384
|
+
*/
|
|
1385
|
+
additionalChains?: Chain[];
|
|
1386
|
+
/**
|
|
1387
|
+
* A list of supported chains, used to specify which chains should be used throughout the application.
|
|
1388
|
+
*
|
|
1389
|
+
* Calling `sendTransaction` or `switchChain` on an unsupported network will throw an error.
|
|
1390
|
+
*
|
|
1391
|
+
* For external wallets, if the wallet's current chain post-connection (during connect-only or siwe flows)
|
|
1392
|
+
* is not within the supported chains list, the user will be prompted to switch to the `defaultChain` (if set) or first supplied. If the chain
|
|
1393
|
+
* switching process does not fully succeed, the user will **not** be blocked from the application (and the wallet's current `chainId` can always
|
|
1394
|
+
* be observed and acted upon accordingly).
|
|
1395
|
+
*
|
|
1396
|
+
* For embedded wallets, the wallet will automatically default to the `defaultChain` (if set) or first supplied `supportedChain`.
|
|
1397
|
+
*/
|
|
1398
|
+
supportedChains?: Chain[];
|
|
1399
|
+
/**
|
|
1400
|
+
* When supplied, the `defaultChain` will be the default chain used throughout the application.
|
|
1401
|
+
*
|
|
1402
|
+
* For external wallets, it will be used if the user's wallet it not within the `supportedChains` (or default chains) list.
|
|
1403
|
+
*
|
|
1404
|
+
* For embedded wallets, it will be used upon initialization, when the user hasn't switched to another supported chain.
|
|
1405
|
+
*/
|
|
1406
|
+
defaultChain?: Chain;
|
|
1407
|
+
captchaEnabled?: boolean;
|
|
1408
|
+
/**
|
|
1409
|
+
* Options for connecting to external wallets like Coinbase Wallet, MetaMask, etc.
|
|
1410
|
+
*
|
|
1411
|
+
* @experimental This is an experimental config that is subject to breaking changes without a major version bump of the SDK.
|
|
1412
|
+
*/
|
|
1413
|
+
externalWallets?: ExternalWalletsConfig;
|
|
1414
|
+
/** All embedded wallets configuration */
|
|
1415
|
+
embeddedWallets?: {
|
|
1416
|
+
/**
|
|
1417
|
+
* Whether an embedded wallet should be created for the user on login. This overrides the
|
|
1418
|
+
* deprecated `createPrivyWalletOnLogin`.
|
|
1419
|
+
*
|
|
1420
|
+
* For `all-users`, the user will be prompted to create a Privy wallet after successfully
|
|
1421
|
+
* logging in. If they cancel or are visiting after this flag was put in place, they will be
|
|
1422
|
+
* prompted to create a wallet on their next login.
|
|
1423
|
+
*
|
|
1424
|
+
* For `users-without-wallets`, the user will be prompted to create a Privy wallet after\
|
|
1425
|
+
* successfully logging in, only if they do not currently have any wallet associated with their
|
|
1426
|
+
* user object - for example if they have linked an external wallet.
|
|
1427
|
+
*
|
|
1428
|
+
* For `off`, an embedded wallet is not created during login. You can always prompt the user to
|
|
1429
|
+
* create one manually with your app.
|
|
1430
|
+
*
|
|
1431
|
+
* Defaults to 'off'.
|
|
1432
|
+
*/
|
|
1433
|
+
createOnLogin?: EmbeddedWalletCreateOnLoginConfig;
|
|
1434
|
+
/**
|
|
1435
|
+
* @deprecated. Instead, use the server-driven configuration found in the Privy console: https://dashboard.privy.io/apps/YOUR_APP_ID/embedded. This client-side setting
|
|
1436
|
+
* is currently honored, but will be fully removed in a future release.
|
|
1437
|
+
*
|
|
1438
|
+
* If true, Privy will prompt users to create a password for their Privy embedded wallet.
|
|
1439
|
+
* If false, embedded wallets will be created without the need of password.
|
|
1440
|
+
*
|
|
1441
|
+
* Defaults to false.
|
|
1442
|
+
*/
|
|
1443
|
+
requireUserPasswordOnCreate?: boolean;
|
|
1444
|
+
/**
|
|
1445
|
+
* @deprecated. Instead, use the server-driven configuration found in the Privy console: https://dashboard.privy.io/apps/YOUR_APP_ID/embedded.
|
|
1446
|
+
* If true, Privy will not prompt or instantiate any UI for embedded wallet signatures and transactions.
|
|
1447
|
+
* If false, embedded wallet actions will raise a modal and require user confirmation to proceed.
|
|
1448
|
+
*
|
|
1449
|
+
* Defaults to false.
|
|
1450
|
+
*/
|
|
1451
|
+
noPromptOnSignature?: boolean;
|
|
1452
|
+
/**
|
|
1453
|
+
* @experimental
|
|
1454
|
+
*
|
|
1455
|
+
* **This setting is only honored when using the EIP-1193 Ethereum Provider to interface
|
|
1456
|
+
* with the embedded wallet, i.e. using `getEthereumProvider` or `getEthersProvider`.
|
|
1457
|
+
* This setting is only honored when used alongside `noPromptOnSignature: true`**
|
|
1458
|
+
*
|
|
1459
|
+
* If true, calls to `sendTransaction` will wait for the transaction to be confirmed before resolving.
|
|
1460
|
+
* If false, calls to `sendTransaction` will resolve once the transaction has been submitted.
|
|
1461
|
+
*
|
|
1462
|
+
* Defaults to true.
|
|
1463
|
+
*
|
|
1464
|
+
* @example
|
|
1465
|
+
* <PrivyProvider
|
|
1466
|
+
* config={{
|
|
1467
|
+
* embeddedWallets: {
|
|
1468
|
+
* noPromptOnSignature: true,
|
|
1469
|
+
* waitForTransactionConfirmation: false,
|
|
1470
|
+
* },
|
|
1471
|
+
* }}
|
|
1472
|
+
* >
|
|
1473
|
+
* {children}
|
|
1474
|
+
* </PrivyProvider>
|
|
1475
|
+
*/
|
|
1476
|
+
waitForTransactionConfirmation?: boolean;
|
|
1477
|
+
/**
|
|
1478
|
+
* Options to customize the display of transaction prices in the embedded wallet's transaction
|
|
1479
|
+
* prompt. You may configure a primary currency to emphasize, and a secondary currency to show
|
|
1480
|
+
* as subtext. Defaults to emphasizing the price in fiat currency, and showing the price in the native
|
|
1481
|
+
* token as subtext.
|
|
1482
|
+
*
|
|
1483
|
+
* You may either set:
|
|
1484
|
+
* - `{primary: 'fiat-currency', secondary: 'native-token'}` to emphasize fiat currency prices, showing native token
|
|
1485
|
+
* prices as subtext. This is the default.
|
|
1486
|
+
* - `{secondary: 'native-token', secondary: null}` to show native token prices only, with no subtext.
|
|
1487
|
+
*
|
|
1488
|
+
* Privy does not currently support:
|
|
1489
|
+
* - emphasizing native token prices over fiat currency prices
|
|
1490
|
+
* - showing prices only in fiat currency, without native token prices
|
|
1491
|
+
*
|
|
1492
|
+
*/
|
|
1493
|
+
priceDisplay?: PriceDisplayOptions;
|
|
1494
|
+
};
|
|
1495
|
+
/**
|
|
1496
|
+
* All multi-factor authentication configuration
|
|
1497
|
+
*/
|
|
1498
|
+
mfa?: {
|
|
1499
|
+
/**
|
|
1500
|
+
* If true, Privy will not prompt or instantiate any UI for MFA Verification. The developer
|
|
1501
|
+
* must handle MFA verification themselves.
|
|
1502
|
+
* If false, any action that requires MFA will raise a modal and require user to verify MFA
|
|
1503
|
+
* before proceeding.
|
|
1504
|
+
*
|
|
1505
|
+
* Defaults to false.
|
|
1506
|
+
*/
|
|
1507
|
+
noPromptOnMfaRequired?: boolean;
|
|
1508
|
+
};
|
|
1509
|
+
/**
|
|
1510
|
+
* @deprecated. Use `fundingMethodConfigurations -> moonpay -> useSandbox` instead.
|
|
1511
|
+
* Setting associated with fiat-on-ramp flows
|
|
1512
|
+
*/
|
|
1513
|
+
fiatOnRamp?: {
|
|
1514
|
+
/**
|
|
1515
|
+
* Determines whether to use the sandbox flow.
|
|
1516
|
+
*
|
|
1517
|
+
* Defaults to false.
|
|
1518
|
+
*/
|
|
1519
|
+
useSandbox?: boolean;
|
|
1520
|
+
};
|
|
1521
|
+
/**
|
|
1522
|
+
* Settings associated with funding methods
|
|
1523
|
+
*/
|
|
1524
|
+
fundingMethodConfig?: {
|
|
1525
|
+
moonpay: {
|
|
1526
|
+
/**
|
|
1527
|
+
* Determines whether to use the Moonpay sandbox flow.
|
|
1528
|
+
*
|
|
1529
|
+
* Defaults to false.
|
|
1530
|
+
*/
|
|
1531
|
+
useSandbox?: boolean;
|
|
1532
|
+
/**
|
|
1533
|
+
* Determines the payment method for each Moonpay transaction.
|
|
1534
|
+
*
|
|
1535
|
+
* Defaults to Moonpay's default.
|
|
1536
|
+
*/
|
|
1537
|
+
paymentMethod?: MoonpayPaymentMethod;
|
|
1538
|
+
/**
|
|
1539
|
+
* Determines the UI settings for each Moonpay transaction.
|
|
1540
|
+
*
|
|
1541
|
+
* Defaults to Moonpay's default.
|
|
1542
|
+
*/
|
|
1543
|
+
uiConfig?: MoonpayUiConfig;
|
|
1544
|
+
};
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
interface AllowlistConfig {
|
|
1548
|
+
errorTitle: string | null;
|
|
1549
|
+
errorDetail: string | null;
|
|
1550
|
+
errorCtaText: string | null;
|
|
1551
|
+
errorCtaLink: string | null;
|
|
1552
|
+
}
|
|
1553
|
+
type EmbeddedWalletCreateOnLoginConfig = 'users-without-wallets' | 'all-users' | 'off';
|
|
1554
|
+
interface EmbeddedWalletsConfig {
|
|
1555
|
+
createOnLogin: EmbeddedWalletCreateOnLoginConfig;
|
|
1556
|
+
requireUserOwnedRecoveryOnCreate: boolean;
|
|
1557
|
+
userOwnedRecoveryOptions: UserRecoveryMethod[];
|
|
1558
|
+
}
|
|
1559
|
+
type OtpFlowState = {
|
|
1560
|
+
status: 'initial';
|
|
1561
|
+
} | {
|
|
1562
|
+
status: 'error';
|
|
1563
|
+
error: Error | null;
|
|
1564
|
+
} | {
|
|
1565
|
+
status: 'sending-code';
|
|
1566
|
+
} | {
|
|
1567
|
+
status: 'awaiting-code-input';
|
|
1568
|
+
} | {
|
|
1569
|
+
status: 'submitting-code';
|
|
1570
|
+
} | {
|
|
1571
|
+
status: 'done';
|
|
1572
|
+
};
|
|
1573
|
+
/**
|
|
1574
|
+
* UI configuration object for the embedded wallet's Sign Message screen
|
|
1575
|
+
*/
|
|
1576
|
+
type SignMessageModalUIOptions = {
|
|
1577
|
+
/**
|
|
1578
|
+
* Title for the Sign Message screen. Defaults to 'Sign'.
|
|
1579
|
+
*/
|
|
1580
|
+
title?: string;
|
|
1581
|
+
/**
|
|
1582
|
+
* Description text for the Sign Message screen. Defaults to
|
|
1583
|
+
* 'Sign to continue'.
|
|
1584
|
+
*/
|
|
1585
|
+
description?: string;
|
|
1586
|
+
/**
|
|
1587
|
+
* Text for the CTA button on the Sign Message screen. Defaults to
|
|
1588
|
+
* 'Sign and Continue'
|
|
1589
|
+
*/
|
|
1590
|
+
buttonText?: string;
|
|
1591
|
+
/**
|
|
1592
|
+
* An icon to display on the Sign Message screen. Defaults to no icon.
|
|
1593
|
+
*/
|
|
1594
|
+
iconUrl?: string;
|
|
1595
|
+
};
|
|
1596
|
+
type MessageTypeProperty = {
|
|
1597
|
+
name: string;
|
|
1598
|
+
type: string;
|
|
1599
|
+
};
|
|
1600
|
+
type MessageTypes = {
|
|
1601
|
+
[additionalProperties: string]: MessageTypeProperty[];
|
|
1602
|
+
};
|
|
1603
|
+
/**
|
|
1604
|
+
* JSON Object that conforms to the EIP-712 [`TypedData JSON schema.`](https://eips.ethereum.org/EIPS/eip-712#specification-of-the-eth_signtypeddata-json-rpc)
|
|
1605
|
+
*
|
|
1606
|
+
*/
|
|
1607
|
+
type TypedMessage<T extends MessageTypes> = {
|
|
1608
|
+
types: T;
|
|
1609
|
+
primaryType: keyof T;
|
|
1610
|
+
domain: {
|
|
1611
|
+
name?: string;
|
|
1612
|
+
version?: string;
|
|
1613
|
+
chainId?: number;
|
|
1614
|
+
verifyingContract?: string;
|
|
1615
|
+
salt?: ArrayBuffer;
|
|
1616
|
+
};
|
|
1617
|
+
message: Record<string, unknown>;
|
|
1618
|
+
};
|
|
1619
|
+
/**
|
|
1620
|
+
* JSON Object that conforms to the EIP-712 [`TypedData JSON schema.`](https://eips.ethereum.org/EIPS/eip-712#specification-of-the-eth_signtypeddata-json-rpc)
|
|
1621
|
+
* See [`TypedMessage`](TypedMessage) for specs on the specific params of typedData.
|
|
1622
|
+
*/
|
|
1623
|
+
type SignTypedDataParams = TypedMessage<MessageTypes>;
|
|
1624
|
+
/**
|
|
1625
|
+
* UI customization object for additional transaction details. Will be shown
|
|
1626
|
+
* in an expandable accordion in the Send Transaction screen.
|
|
1627
|
+
*/
|
|
1628
|
+
type TransactionUIOptions = {
|
|
1629
|
+
/**
|
|
1630
|
+
* Title for the transaction details accordion within the
|
|
1631
|
+
* Send Transaction screen. Defaults to 'Details'.
|
|
1632
|
+
*/
|
|
1633
|
+
title?: string;
|
|
1634
|
+
/**
|
|
1635
|
+
* Action that the user is taking when sending this transaction. This
|
|
1636
|
+
* should be short (<4 words, e.g. 'Buy NFT'). Will be shown inside
|
|
1637
|
+
* the transaction details accordion in Send Transaction screen.
|
|
1638
|
+
*/
|
|
1639
|
+
action?: string;
|
|
1640
|
+
/**
|
|
1641
|
+
* If the transaction to be sent is a call to a smart contract, you may
|
|
1642
|
+
* use this object to fill in additional details about the contract being called.
|
|
1643
|
+
*/
|
|
1644
|
+
contractInfo?: ContractUIOptions;
|
|
1645
|
+
/**
|
|
1646
|
+
* @deprecated Use `description` in `SendTransactionModalUIOptions` instead.
|
|
1647
|
+
*/
|
|
1648
|
+
description?: string;
|
|
1649
|
+
/**
|
|
1650
|
+
* @deprecated Use `title` instead.
|
|
1651
|
+
*/
|
|
1652
|
+
actionDescription?: string;
|
|
1653
|
+
};
|
|
1654
|
+
/**
|
|
1655
|
+
* If the transaction to be sent is a call to a smart contract, you may use this
|
|
1656
|
+
* object to fill in additional details about the contract being called.
|
|
1657
|
+
*/
|
|
1658
|
+
type ContractUIOptions = {
|
|
1659
|
+
/**
|
|
1660
|
+
* URL with more information about the smart contract.
|
|
1661
|
+
*/
|
|
1662
|
+
url?: string;
|
|
1663
|
+
/**
|
|
1664
|
+
* Name of smart contract being called.
|
|
1665
|
+
*/
|
|
1666
|
+
name?: string;
|
|
1667
|
+
/**
|
|
1668
|
+
* URL for an image to show in the Send Transaction screen.
|
|
1669
|
+
*/
|
|
1670
|
+
imgUrl?: string;
|
|
1671
|
+
/**
|
|
1672
|
+
* Alt text for the image in the Send Transaction screen, if a
|
|
1673
|
+
* valid `imgUrl` is set.
|
|
1674
|
+
*/
|
|
1675
|
+
imgAltText?: string;
|
|
1676
|
+
/**
|
|
1677
|
+
* Size for the image in the Send Transaction screen, if a valid
|
|
1678
|
+
* `imgUrl` is set.
|
|
1679
|
+
*/
|
|
1680
|
+
imgSize?: 'sm' | 'lg';
|
|
1681
|
+
/**
|
|
1682
|
+
* @deprecated Use `description` in `SendTransactionModalUIOptions` instead.
|
|
1683
|
+
*/
|
|
1684
|
+
actionText?: string;
|
|
1685
|
+
};
|
|
1686
|
+
/**
|
|
1687
|
+
* UI customization object for the embedded wallet's Send Transaction screen
|
|
1688
|
+
*/
|
|
1689
|
+
type SendTransactionModalUIOptions = {
|
|
1690
|
+
/**
|
|
1691
|
+
* Text to display at top of Send Transaction screen. Defaults to
|
|
1692
|
+
* 'Review transaction' or 'Send (insert token symbol)' if transaction
|
|
1693
|
+
* is a simple token transfer.
|
|
1694
|
+
*/
|
|
1695
|
+
header?: string;
|
|
1696
|
+
/**
|
|
1697
|
+
* Description of the transaction being sent.
|
|
1698
|
+
*/
|
|
1699
|
+
description?: string;
|
|
1700
|
+
/**
|
|
1701
|
+
* Text to show on CTA button for Send Transaction screen. Defaults to
|
|
1702
|
+
* 'Submit'.
|
|
1703
|
+
*/
|
|
1704
|
+
buttonText?: string;
|
|
1705
|
+
/**
|
|
1706
|
+
* Details about the transaction that the user will send. Will be shown
|
|
1707
|
+
* in an accordion in the Send Transaction screen.
|
|
1708
|
+
*/
|
|
1709
|
+
transactionInfo?: TransactionUIOptions;
|
|
1710
|
+
/**
|
|
1711
|
+
* Text to display at top of Send Transaction Success screen. Defaults to
|
|
1712
|
+
* 'Transaction complete!' if transaction is successful.
|
|
1713
|
+
*/
|
|
1714
|
+
successHeader?: string;
|
|
1715
|
+
/**
|
|
1716
|
+
* Description of the transaction Success screen. Defaults to 'You're all set.'
|
|
1717
|
+
*/
|
|
1718
|
+
successDescription?: string;
|
|
1719
|
+
/**
|
|
1720
|
+
* @deprecated Use `header` instead.
|
|
1721
|
+
*/
|
|
1722
|
+
title?: string;
|
|
1723
|
+
/**
|
|
1724
|
+
* @deprecated Use `header` instead.
|
|
1725
|
+
*/
|
|
1726
|
+
modalTitle?: string;
|
|
1727
|
+
/**
|
|
1728
|
+
* @deprecated Use `transactionInfo.contractInfo` instead.
|
|
1729
|
+
*/
|
|
1730
|
+
senderInfo?: ContractUIOptions;
|
|
1731
|
+
};
|
|
1732
|
+
/**
|
|
1733
|
+
* Our external-facing `UnsignedTransactionRequest` type makes the `chainId` field optional,
|
|
1734
|
+
* matching ethers, wagmi, and a bunch of other libraries. However, our modal needs to be "aware"
|
|
1735
|
+
* of the transaction's `chainId` to ensure it does price conversion, quote labeling, etc. importantly.
|
|
1736
|
+
*
|
|
1737
|
+
* Thus, in the modal, we enforce a stricter type `UnsignedTransactionRequestWithChainId` which wraps
|
|
1738
|
+
* `UnsignedTransactionRequest` to make `chainId` required.
|
|
1739
|
+
*
|
|
1740
|
+
* If the developer does not set a `chainId` in their `UnsignedTransactionRequest`, we default to the embedded
|
|
1741
|
+
* provider's current `chainId` in `privy-provider.tsx` > `sendTransaction`
|
|
1742
|
+
*/
|
|
1743
|
+
type UnsignedTransactionRequestWithChainId = UnsignedTransactionRequest & {
|
|
1744
|
+
chainId: number;
|
|
1745
|
+
};
|
|
1746
|
+
type PrivyFarcasterSignerInitResponse = {
|
|
1747
|
+
public_key: string;
|
|
1748
|
+
status: 'pending_approval';
|
|
1749
|
+
signer_approval_url: string;
|
|
1750
|
+
} | {
|
|
1751
|
+
public_key: string;
|
|
1752
|
+
status: 'approved';
|
|
1753
|
+
fid: bigint;
|
|
1754
|
+
} | {
|
|
1755
|
+
public_key: string;
|
|
1756
|
+
status: 'revoked';
|
|
1757
|
+
};
|
|
1758
|
+
type PrefillLoginOptions = {
|
|
1759
|
+
type: 'email' | 'phone';
|
|
1760
|
+
value: string;
|
|
1761
|
+
};
|
|
1762
|
+
type RuntimeLoginOverridableOptions = {
|
|
1763
|
+
loginMethods?: PrivyClientConfig['loginMethods'];
|
|
1764
|
+
prefill?: PrefillLoginOptions;
|
|
1765
|
+
};
|
|
1766
|
+
type SetWalletRecoveryOptions = {};
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* We support a subset of the provider methods found here:
|
|
1770
|
+
*
|
|
1771
|
+
* https://ethereum.org/en/developers/docs/apis/json-rpc/#json-rpc-methods
|
|
1772
|
+
*
|
|
1773
|
+
* For now, we're focused on signing-related methods because the iframe (this code)
|
|
1774
|
+
* is the only place that has access to the private key and thus is the only one
|
|
1775
|
+
* who can create signatures. All other methods do not need the private key and
|
|
1776
|
+
* can therefore be implemented by clients of the iframe.
|
|
1777
|
+
*/
|
|
1778
|
+
|
|
1779
|
+
declare const SUPPORTED_ETHEREUM_RPC_METHODS: readonly ["eth_sign", "eth_populateTransactionRequest", "eth_signTransaction", "personal_sign", "eth_signTypedData_v4", "csw_signUserOperation"];
|
|
1780
|
+
type EthereumRpcMethodType = (typeof SUPPORTED_ETHEREUM_RPC_METHODS)[number];
|
|
1781
|
+
declare const SUPPORTED_SOLANA_RPC_METHODS: string[];
|
|
1782
|
+
type SolanaRpcMethodType = (typeof SUPPORTED_SOLANA_RPC_METHODS)[number];
|
|
1783
|
+
type Quantity = string | number | bigint;
|
|
1784
|
+
type UnsignedTransactionRequest = {
|
|
1785
|
+
from?: string;
|
|
1786
|
+
to?: string;
|
|
1787
|
+
nonce?: Quantity;
|
|
1788
|
+
gasLimit?: Quantity;
|
|
1789
|
+
gasPrice?: Quantity;
|
|
1790
|
+
data?: ArrayLike<number> | string;
|
|
1791
|
+
value?: Quantity;
|
|
1792
|
+
chainId?: number;
|
|
1793
|
+
type?: number;
|
|
1794
|
+
accessList?: Array<{
|
|
1795
|
+
address: string;
|
|
1796
|
+
storageKeys: Array<string>;
|
|
1797
|
+
}> | Array<[string, Array<string>]> | Record<string, Array<string>>;
|
|
1798
|
+
maxPriorityFeePerGas?: Quantity;
|
|
1799
|
+
maxFeePerGas?: Quantity;
|
|
1800
|
+
};
|
|
1801
|
+
type TransactionLog = {
|
|
1802
|
+
blockNumber: number;
|
|
1803
|
+
blockHash: string;
|
|
1804
|
+
transactionIndex: number;
|
|
1805
|
+
removed: boolean;
|
|
1806
|
+
address: string;
|
|
1807
|
+
data: string;
|
|
1808
|
+
topics: Array<string>;
|
|
1809
|
+
transactionHash: string;
|
|
1810
|
+
logIndex: number;
|
|
1811
|
+
};
|
|
1812
|
+
type TransactionReceipt = {
|
|
1813
|
+
to: string;
|
|
1814
|
+
from: string;
|
|
1815
|
+
contractAddress: string;
|
|
1816
|
+
transactionIndex: number;
|
|
1817
|
+
root?: string;
|
|
1818
|
+
logs: Array<TransactionLog>;
|
|
1819
|
+
logsBloom: string;
|
|
1820
|
+
blockHash: string;
|
|
1821
|
+
transactionHash: string;
|
|
1822
|
+
blockNumber: number;
|
|
1823
|
+
confirmations: number;
|
|
1824
|
+
byzantium: boolean;
|
|
1825
|
+
type: number;
|
|
1826
|
+
status?: number;
|
|
1827
|
+
gasUsed: string;
|
|
1828
|
+
cumulativeGasUsed: string;
|
|
1829
|
+
effectiveGasPrice?: string;
|
|
1830
|
+
};
|
|
1831
|
+
interface BaseEthereumRpcRequestType {
|
|
1832
|
+
method: EthereumRpcMethodType;
|
|
1833
|
+
}
|
|
1834
|
+
interface BaseSolanaRpcRequestType {
|
|
1835
|
+
method: SolanaRpcMethodType;
|
|
1836
|
+
}
|
|
1837
|
+
interface eth_populateTransactionRequest extends BaseEthereumRpcRequestType {
|
|
1838
|
+
method: 'eth_populateTransactionRequest';
|
|
1839
|
+
params: [UnsignedTransactionRequest];
|
|
1840
|
+
}
|
|
1841
|
+
interface eth_populateTransactionRequestResponse {
|
|
1842
|
+
method: 'eth_populateTransactionRequest';
|
|
1843
|
+
data: UnsignedTransactionRequest;
|
|
1844
|
+
}
|
|
1845
|
+
interface eth_signTransaction extends BaseEthereumRpcRequestType {
|
|
1846
|
+
method: 'eth_signTransaction';
|
|
1847
|
+
params: [UnsignedTransactionRequest];
|
|
1848
|
+
}
|
|
1849
|
+
interface eth_sign extends BaseEthereumRpcRequestType {
|
|
1850
|
+
method: 'eth_sign';
|
|
1851
|
+
params: [address: string, message: string];
|
|
1852
|
+
}
|
|
1853
|
+
interface eth_signResponse {
|
|
1854
|
+
method: 'eth_sign';
|
|
1855
|
+
data: string;
|
|
1856
|
+
}
|
|
1857
|
+
interface personal_sign extends BaseEthereumRpcRequestType {
|
|
1858
|
+
method: 'personal_sign';
|
|
1859
|
+
params: [string, string];
|
|
1860
|
+
}
|
|
1861
|
+
interface personal_signResponse {
|
|
1862
|
+
method: 'personal_sign';
|
|
1863
|
+
data: string;
|
|
1864
|
+
}
|
|
1865
|
+
interface eth_signTransactionResponse {
|
|
1866
|
+
method: 'eth_signTransaction';
|
|
1867
|
+
data: string;
|
|
1868
|
+
}
|
|
1869
|
+
interface eth_signTypedData_v4 extends BaseEthereumRpcRequestType {
|
|
1870
|
+
method: 'eth_signTypedData_v4';
|
|
1871
|
+
params: [string, TypedMessage$1<MessageTypes$1> | string];
|
|
1872
|
+
}
|
|
1873
|
+
interface eth_signTypedData_v4Response {
|
|
1874
|
+
method: 'eth_signTypedData_v4';
|
|
1875
|
+
data: string;
|
|
1876
|
+
}
|
|
1877
|
+
interface solana_signMessage extends BaseSolanaRpcRequestType {
|
|
1878
|
+
method: 'signMessage';
|
|
1879
|
+
params: {
|
|
1880
|
+
message: string;
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
interface solana_signMessageResponse {
|
|
1884
|
+
method: 'signMessage';
|
|
1885
|
+
data: {
|
|
1886
|
+
signature: string;
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
type EthereumRpcRequestType = eth_signTransaction | eth_populateTransactionRequest | eth_sign | personal_sign | eth_signTypedData_v4;
|
|
1890
|
+
type EthereumRpcResponseType = eth_signTransactionResponse | eth_populateTransactionRequestResponse | eth_signResponse | personal_signResponse | eth_signTypedData_v4Response;
|
|
1891
|
+
type SolanaRpcRequestType = solana_signMessage;
|
|
1892
|
+
type SolanaRpcResponseType = solana_signMessageResponse;
|
|
1893
|
+
|
|
1894
|
+
export { Google as $, ConnectedSolanaWallet as A, BaseConnectedWallet as B, Chain as C, UnsignedTransactionRequestWithChainId as D, Embedded1193Provider as E, FundWalletConfig as F, AsExternalProvider as G, TypedMessage as H, MessageTypes as I, MoonpayConfig as J, MoonpayCurrencyCode as K, LoginMethod as L, MoonpaySignRequest as M, MoonpayPaymentMethod as N, OAuthTokens as O, PrivyProxyProvider as P, Quantity as Q, RpcConfig as R, SetWalletRecoveryOptions as S, TransactionReceipt as T, User as U, TransactionLog as V, WalletClientType as W, NonEmptyArray as X, EmailWithMetadata as Y, PhoneWithMetadata as Z, WalletWithMetadata as _, ConnectorType as a, Twitter as a0, Discord as a1, Github as a2, LinkedIn as a3, Apple as a4, Tiktok as a5, Telegram as a6, CrossAppAccount as a7, GoogleOAuthWithMetadata as a8, TwitterOAuthWithMetadata as a9, DiscordOAuthWithMetadata as aa, GithubOAuthWithMetadata as ab, TiktokOAuthWithMetadata as ac, LinkedInOAuthWithMetadata as ad, AppleOAuthWithMetadata as ae, FarcasterWithMetadata as af, TelegramWithMetadata as ag, CrossAppAccountWithMetadata as ah, PasskeyWithMetadata as ai, Email as aj, Phone as ak, TransactionUIOptions as al, ContractUIOptions as am, NativeFundingConfig as an, MoonpayFundingConfig as ao, PriceDisplayOptions as ap, Farcaster as aq, Passkey as ar, LoginMethodOrderOption as as, ConnectedWalletMetadata as b, WalletBranding as c, WalletListEntry as d, ExternalWalletsConfig as e, EIP1193Provider as f, OAuthProviderType as g, MoonpaySignResponse as h, PrivyServerConfig as i, PrivyFarcasterSignerInitResponse as j, PrivyClientConfig as k, RuntimeLoginOverridableOptions as l, Wallet as m, SignMessageModalUIOptions as n, SignTypedDataParams as o, MfaMethod as p, UnsignedTransactionRequest as q, SendTransactionModalUIOptions as r, ConnectedWallet as s, PrivyIframeErrorTypesType as t, PrivyErrorCode as u, LinkedAccountWithMetadata as v, UserRecoveryMethod as w, FundingMethod as x, LoginWithCode as y, OtpFlowState as z };
|