@privy-io/react-auth 1.3.1-beta.3 → 1.4.0-beta.2
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/index.d.ts +108 -323
- package/dist/index.js +60 -60
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,242 +1,155 @@
|
|
|
1
|
-
import { AxiosResponse, AxiosRequestConfig } from 'axios';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { Web3Provider } from '@ethersproject/providers';
|
|
4
3
|
import { AbstractProvider } from 'web3-core';
|
|
5
4
|
|
|
6
5
|
declare const SUPPORTED_WALLET_TYPES: readonly ["metamask", "coinbase_wallet", "wallet_connect"];
|
|
7
6
|
declare type WalletType = typeof SUPPORTED_WALLET_TYPES[number];
|
|
7
|
+
/** @ignore */
|
|
8
8
|
interface LinkMetadata {
|
|
9
|
-
/**
|
|
9
|
+
/** Account type, most commonly useful when filtering through linkedAccounts */
|
|
10
10
|
type: 'wallet' | 'email' | 'google_oauth' | 'twitter_oauth' | 'discord_oauth';
|
|
11
|
-
/** Datetime when this
|
|
11
|
+
/** Datetime when this account was linked to the user. */
|
|
12
12
|
verifiedAt: Date;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Object representation of a user's wallet.
|
|
16
|
+
*/
|
|
14
17
|
interface Wallet {
|
|
15
|
-
/**
|
|
18
|
+
/** The wallet address. */
|
|
16
19
|
address: string;
|
|
17
|
-
/** Chain type of the wallet address */
|
|
20
|
+
/** Chain type of the wallet address. */
|
|
18
21
|
chainType: 'ethereum' | 'solana';
|
|
19
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* @experimental
|
|
24
|
+
* DO NOT USE: This feature is under active development.
|
|
20
25
|
*
|
|
21
26
|
* The chain ID of the active connected wallet, if used to verify in the current session.
|
|
22
27
|
* Only present for the active wallet.
|
|
23
28
|
*
|
|
24
29
|
* e.g. testnet, mainnet, goerli */
|
|
25
30
|
chainId?: string;
|
|
26
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* @experimental
|
|
33
|
+
* DO NOT USE: This feature is under active development.
|
|
34
|
+
*
|
|
27
35
|
* The wallet type of the active connected wallet, if used to verify in the current session.
|
|
28
36
|
* Only present for the active wallet.
|
|
29
37
|
*/
|
|
30
38
|
walletType?: WalletType;
|
|
31
39
|
}
|
|
40
|
+
/** Object representation of a user's email. */
|
|
32
41
|
interface Email {
|
|
33
|
-
/**
|
|
42
|
+
/** The email address. */
|
|
34
43
|
address: string;
|
|
35
44
|
}
|
|
45
|
+
/** Object representation of a user's Google account. */
|
|
36
46
|
interface Google {
|
|
47
|
+
/** The `sub` claim from the Google-issued JWT for this account. */
|
|
37
48
|
subject: string;
|
|
49
|
+
/** The email associated with the Google account. */
|
|
38
50
|
email: string;
|
|
51
|
+
/** The name associated with the Google account. */
|
|
39
52
|
name: string | null;
|
|
40
53
|
}
|
|
54
|
+
/** Object representation of a user's Twitter account. */
|
|
41
55
|
interface Twitter {
|
|
56
|
+
/** The `sub` claim from the Twitter-issued JWT for this account. */
|
|
42
57
|
subject: string;
|
|
58
|
+
/** The username associated with the Twitter account. */
|
|
43
59
|
username: string | null;
|
|
60
|
+
/** The name associated with the Twitter account. */
|
|
44
61
|
name: string | null;
|
|
45
62
|
}
|
|
63
|
+
/** Object representation of a user's Discord account. */
|
|
46
64
|
interface Discord {
|
|
65
|
+
/** The `sub` claim from the Discord-issued JWT for this account. */
|
|
47
66
|
subject: string;
|
|
67
|
+
/** The username associated with the Discord account. */
|
|
48
68
|
username: string | null;
|
|
69
|
+
/** The email associated with the Discord account. */
|
|
49
70
|
email: string | null;
|
|
50
71
|
}
|
|
72
|
+
/** Object representation of a user's email, with additional metadata for advanced use cases. */
|
|
51
73
|
interface EmailWithMetadata extends LinkMetadata, Email {
|
|
74
|
+
/** Denotes that this is an email account. */
|
|
52
75
|
type: 'email';
|
|
53
76
|
}
|
|
77
|
+
/** Object representation of a user's wallet, with additional metadata for advanced use cases. */
|
|
54
78
|
interface WalletWithMetadata extends LinkMetadata, Wallet {
|
|
79
|
+
/** Denotes that this is a wallet account. */
|
|
55
80
|
type: 'wallet';
|
|
56
81
|
}
|
|
82
|
+
/** Object representation of a user's Google Account, with additional metadata for advanced use cases. */
|
|
57
83
|
interface GoogleOAuthWithMetadata extends LinkMetadata, Google {
|
|
84
|
+
/** Denotes that this is a Google account. */
|
|
58
85
|
type: 'google_oauth';
|
|
59
86
|
}
|
|
87
|
+
/** Object representation of a user's Twitter Account, with additional metadata for advanced use cases. */
|
|
60
88
|
interface TwitterOAuthWithMetadata extends LinkMetadata, Twitter {
|
|
89
|
+
/** Denotes that this is a Twitter account. */
|
|
61
90
|
type: 'twitter_oauth';
|
|
62
91
|
}
|
|
92
|
+
/** Object representation of a user's Discord Account, with additional metadata for advanced use cases. */
|
|
63
93
|
interface DiscordOAuthWithMetadata extends LinkMetadata, Discord {
|
|
94
|
+
/** Denotes that this is a Discord account. */
|
|
64
95
|
type: 'discord_oauth';
|
|
65
96
|
}
|
|
66
97
|
interface User {
|
|
67
|
-
/** The Privy DID for the user. If you need to store
|
|
68
|
-
* about a user, you can use this DID to reference
|
|
98
|
+
/** The Privy-issued DID for the user. If you need to store additional information
|
|
99
|
+
* about a user, you can use this DID to reference them. */
|
|
69
100
|
id: string;
|
|
70
|
-
/**
|
|
101
|
+
/** The datetime of when the user was created. */
|
|
71
102
|
createdAt: Date;
|
|
72
|
-
/** The email
|
|
103
|
+
/** The user's email address, if they have linked one. It cannot be linked to another user. */
|
|
73
104
|
email?: Email;
|
|
74
|
-
/** The wallet
|
|
105
|
+
/** The user's wallet address, if they have linked one. It cannot be linked to another user. */
|
|
75
106
|
wallet?: Wallet;
|
|
76
|
-
/** The
|
|
107
|
+
/** The user's Google account, if they have linked one. It cannot be linked to another user. */
|
|
77
108
|
google?: Google;
|
|
78
|
-
/** The
|
|
109
|
+
/** The user's Twitter account, if they have linked one. It cannot be linked to another user. */
|
|
79
110
|
twitter?: Twitter;
|
|
80
|
-
/** The
|
|
111
|
+
/** The user's Discord account, if they have linked one. It cannot be linked to another user. */
|
|
81
112
|
discord?: Discord;
|
|
82
|
-
/** The list of accounts associated with this user.
|
|
83
|
-
*
|
|
113
|
+
/** The list of accounts associated with this user. Each account contains additional metadata
|
|
114
|
+
* that may be helpful for advanced use cases. */
|
|
84
115
|
linkedAccounts: Array<WalletWithMetadata | EmailWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata>;
|
|
85
116
|
}
|
|
86
|
-
interface AppSettings {
|
|
87
|
-
id?: string;
|
|
88
|
-
name?: string;
|
|
89
|
-
verificationKey?: string;
|
|
90
|
-
logoUrl?: string;
|
|
91
|
-
theme?: 'System' | 'Light' | 'Dark' | string;
|
|
92
|
-
accentColor?: string;
|
|
93
|
-
createdAt?: Date;
|
|
94
|
-
updatedAt?: Date;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
interface DefaultsType {
|
|
98
|
-
baseURL: string;
|
|
99
|
-
timeout: number;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* A raw http handler for making requests to the Privy API. It requires a Session
|
|
103
|
-
* object, which is used for fetching and including any tokens that are required
|
|
104
|
-
* for requests.
|
|
105
|
-
*/
|
|
106
|
-
declare class Http {
|
|
107
|
-
private appId;
|
|
108
|
-
private session;
|
|
109
|
-
private defaults;
|
|
110
|
-
constructor(appId: string, session: Session, defaults: DefaultsType);
|
|
111
|
-
get<T = any, R = AxiosResponse<T>, D = any>(path: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
112
|
-
post<T = any, R = AxiosResponse<T>, D = any>(path: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
113
|
-
delete<T = any, R = AxiosResponse<T>, D = any>(path: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
114
|
-
private buildConfig;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
interface ResponseEmailAccount {
|
|
118
|
-
type: 'email';
|
|
119
|
-
address: string;
|
|
120
|
-
verified_at: number;
|
|
121
|
-
}
|
|
122
|
-
interface ResponseEthereumAccount {
|
|
123
|
-
type: 'wallet';
|
|
124
|
-
address: string;
|
|
125
|
-
chain_type: 'ethereum';
|
|
126
|
-
verified_at: number;
|
|
127
|
-
}
|
|
128
|
-
interface ResponseOAuthGoogle {
|
|
129
|
-
type: 'google_oauth';
|
|
130
|
-
subject: string;
|
|
131
|
-
email: string;
|
|
132
|
-
name: string | null;
|
|
133
|
-
verified_at: number;
|
|
134
|
-
}
|
|
135
|
-
interface ResponseOAuthTwitter {
|
|
136
|
-
type: 'twitter_oauth';
|
|
137
|
-
subject: string;
|
|
138
|
-
username: string | null;
|
|
139
|
-
name: string | null;
|
|
140
|
-
verified_at: number;
|
|
141
|
-
}
|
|
142
|
-
interface ResponseOAuthDiscord {
|
|
143
|
-
type: 'discord_oauth';
|
|
144
|
-
subject: string;
|
|
145
|
-
username: string | null;
|
|
146
|
-
email: string | null;
|
|
147
|
-
verified_at: number;
|
|
148
|
-
}
|
|
149
|
-
declare type LinkedAccountsType = Array<ResponseEmailAccount | ResponseEthereumAccount | ResponseOAuthGoogle | ResponseOAuthTwitter | ResponseOAuthDiscord>;
|
|
150
|
-
interface GetCurrentUserResponse {
|
|
151
|
-
id: string;
|
|
152
|
-
created_at: number;
|
|
153
|
-
linked_accounts: LinkedAccountsType;
|
|
154
|
-
}
|
|
155
117
|
|
|
156
118
|
/**
|
|
157
|
-
*
|
|
158
|
-
* as well as a valid user object for streamlining.
|
|
119
|
+
* Properties to initialize the {@link PrivyProvider}.
|
|
159
120
|
*/
|
|
160
|
-
interface
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
refresh_token: string | null;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* `Session` represents the session lifecycle of the login. It manages token
|
|
167
|
-
* storage, refresh, and deletion.
|
|
168
|
-
*/
|
|
169
|
-
declare class Session {
|
|
170
|
-
private destroyOnce;
|
|
171
|
-
private refreshOnce;
|
|
172
|
-
private authenticateOnce;
|
|
173
|
-
api?: Http;
|
|
174
|
-
constructor();
|
|
175
|
-
get token(): string | null;
|
|
176
|
-
get refreshToken(): string | null;
|
|
121
|
+
interface PrivyProviderProps {
|
|
122
|
+
/** Your Privy App ID, which can be retrieved from the Privy console. */
|
|
123
|
+
appId: string;
|
|
177
124
|
/**
|
|
178
|
-
*
|
|
179
|
-
* credentials consist of:
|
|
180
|
-
*
|
|
181
|
-
* 1. Access token
|
|
182
|
-
* 2. Refresh token
|
|
183
|
-
*
|
|
184
|
-
* @returns true if we have what appear to be valid credentials, false otherwise.
|
|
125
|
+
* @experimental DO NOT USE: This feature is under active development.
|
|
185
126
|
*/
|
|
186
|
-
|
|
127
|
+
showSocials?: boolean;
|
|
187
128
|
/**
|
|
188
|
-
*
|
|
189
|
-
* expired or expiring soon.
|
|
129
|
+
* An optional callback that will execute once a `login` call successfully completes.
|
|
190
130
|
*
|
|
191
|
-
*
|
|
131
|
+
* You may access the `user` object corresponding to the authenticated user within this callback.
|
|
192
132
|
*/
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
|
|
196
|
-
* @returns Promise<User>
|
|
197
|
-
*/
|
|
198
|
-
authenticate(authFlow: AuthFlow): Promise<User | null>;
|
|
199
|
-
/**
|
|
200
|
-
* Renews the auth token using the refresh token.
|
|
201
|
-
* @return Promise<User> if successful with a logged-in user, Promise<null> otherwise.
|
|
202
|
-
*/
|
|
203
|
-
refresh(): Promise<User | null>;
|
|
204
|
-
/**
|
|
205
|
-
* Destroy the session.
|
|
206
|
-
*/
|
|
207
|
-
destroy(): Promise<void>;
|
|
208
|
-
private _authenticate;
|
|
209
|
-
private _refresh;
|
|
210
|
-
private _destroy;
|
|
211
|
-
private destroyLocalState;
|
|
212
|
-
private storeToken;
|
|
213
|
-
private storeRefreshToken;
|
|
133
|
+
onSuccess?: (user: User) => void;
|
|
134
|
+
/** @ignore */
|
|
135
|
+
children: React.ReactNode;
|
|
214
136
|
}
|
|
215
|
-
|
|
216
|
-
declare type AuthMeta = {
|
|
217
|
-
[key: string]: any;
|
|
218
|
-
};
|
|
219
137
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
138
|
+
* Passes the Privy authentication context to your React components.
|
|
139
|
+
*
|
|
140
|
+
* This should wrap any components that will to use the Privy SDK via the {@link usePrivy} hook. As an example:
|
|
141
|
+
*
|
|
142
|
+
* ```typescript
|
|
143
|
+
* // At your application root (e.g. `_app.tsx` in NextJS):
|
|
144
|
+
* import {PrivyProvider} from '@privy-io/react-auth';
|
|
145
|
+
*
|
|
146
|
+
* <PrivyProvider appId="APP_ID_FROM_CONSOLE" onSuccess={() => console.log('Success!')}>
|
|
147
|
+
* <Component {...pageProps} />
|
|
148
|
+
* </PrivyProvider>
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
225
151
|
*/
|
|
226
|
-
|
|
227
|
-
api?: Http;
|
|
228
|
-
/**
|
|
229
|
-
* Any meta information necessary for the auth flow, that may also need to be
|
|
230
|
-
* shared out to things like frontend components for displaying state of the
|
|
231
|
-
* auth flow
|
|
232
|
-
*/
|
|
233
|
-
meta: AuthMeta;
|
|
234
|
-
/**
|
|
235
|
-
* Should handle the actual authentication step. An preconditions must be
|
|
236
|
-
* addressed prior to calling
|
|
237
|
-
*/
|
|
238
|
-
authenticate(): Promise<ValidSessionResponse>;
|
|
239
|
-
}
|
|
152
|
+
declare const PrivyProvider: (props: PrivyProviderProps) => JSX.Element;
|
|
240
153
|
|
|
241
154
|
declare global {
|
|
242
155
|
interface Window {
|
|
@@ -252,127 +165,22 @@ interface EIP1193Provider {
|
|
|
252
165
|
removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => any;
|
|
253
166
|
}
|
|
254
167
|
|
|
255
|
-
declare class PrivyConnector {
|
|
256
|
-
private ethProvider;
|
|
257
|
-
walletType: WalletType | null;
|
|
258
|
-
constructor();
|
|
259
|
-
getEthereumProvider: () => EIP1193Provider;
|
|
260
|
-
initialize(): void;
|
|
261
|
-
destroy(): void;
|
|
262
|
-
/**
|
|
263
|
-
* Connects to the wallet.
|
|
264
|
-
*
|
|
265
|
-
* @param showPrompt if true, prompts the user for a connection when no connection can be automatically re-established.
|
|
266
|
-
* @param walletType? the wallet type to connect to. If not provided, defaults to the walletType that the connector was initialized with.
|
|
267
|
-
* @returns {string | null} EIP-55 mixed-case checksum-encoded address of connected wallet or null if user does not connect.
|
|
268
|
-
*/
|
|
269
|
-
connect(options: {
|
|
270
|
-
showPrompt: boolean;
|
|
271
|
-
}): Promise<string | null>;
|
|
272
|
-
private isConnected;
|
|
273
|
-
private promptConnection;
|
|
274
|
-
/**
|
|
275
|
-
* The currently connected EIP-155 chain id. E.g., `1` for Ethereum mainnet.
|
|
276
|
-
*
|
|
277
|
-
* @returns {string} The EIP-155 chain id.
|
|
278
|
-
*/
|
|
279
|
-
chainId(): Promise<string>;
|
|
280
|
-
/**
|
|
281
|
-
* The currently connected address.
|
|
282
|
-
*
|
|
283
|
-
* @returns {string | null} EIP-55 mixed-case checksum-encoded address or null if not connected.
|
|
284
|
-
*/
|
|
285
|
-
address(): Promise<string | null>;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
declare class PrivyClient {
|
|
289
|
-
private api;
|
|
290
|
-
private appId;
|
|
291
|
-
private session;
|
|
292
|
-
authFlow?: AuthFlow;
|
|
293
|
-
connector: PrivyConnector;
|
|
294
|
-
/**
|
|
295
|
-
* Creates a new Privy client.
|
|
296
|
-
* @param options Initialization options.
|
|
297
|
-
*/
|
|
298
|
-
constructor(options: {
|
|
299
|
-
/**
|
|
300
|
-
* The URL of the Privy API. Defaults to `https://api.privy.io/v0`.
|
|
301
|
-
*/
|
|
302
|
-
apiURL?: string;
|
|
303
|
-
/**
|
|
304
|
-
* The app id from your console
|
|
305
|
-
*/
|
|
306
|
-
appId: string;
|
|
307
|
-
/**
|
|
308
|
-
* Time in milliseconds after which to timeout requests to the API and KMS. Defaults to `10000` (10 seconds).
|
|
309
|
-
*/
|
|
310
|
-
timeout?: number;
|
|
311
|
-
});
|
|
312
|
-
authenticate(): Promise<User | null>;
|
|
313
|
-
logout(): Promise<void>;
|
|
314
|
-
startAuthFlow(authFlow: AuthFlow): void;
|
|
315
|
-
/** DATA METHODS */
|
|
316
|
-
/**
|
|
317
|
-
* Fetches the currently authenticed user from the API or
|
|
318
|
-
* returns null if the user is not authenticated.
|
|
319
|
-
*
|
|
320
|
-
* This will refresh the user's access token and rotate
|
|
321
|
-
* the refresh token if needed.
|
|
322
|
-
*
|
|
323
|
-
* @returns Promise<User | null>
|
|
324
|
-
*/
|
|
325
|
-
getAuthenticatedUser(): Promise<User | null>;
|
|
326
|
-
/**
|
|
327
|
-
* Grab the Privy access token for the currently logged in user.
|
|
328
|
-
*
|
|
329
|
-
* If the token is expired or expiring soon, this will attempt to
|
|
330
|
-
* first refresh the access token to ensure that the token is active.
|
|
331
|
-
*
|
|
332
|
-
* @returns Promise<string | null>
|
|
333
|
-
*/
|
|
334
|
-
getAccessToken(): Promise<string | null>;
|
|
335
|
-
getAppSettings(): Promise<AppSettings>;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
interface PrivyProviderProps {
|
|
339
|
-
/** Your app id, taken from the Privy console. */
|
|
340
|
-
appId: string;
|
|
341
|
-
/**
|
|
342
|
-
* onSuccess is run when an auth (`login`) or linking (`linkEmail` or `linkWallet`)
|
|
343
|
-
* action is completed successfully.
|
|
344
|
-
*/
|
|
345
|
-
showSocials?: boolean;
|
|
346
|
-
onSuccess?: (user: User) => void;
|
|
347
|
-
children: React.ReactNode;
|
|
348
|
-
}
|
|
349
168
|
/**
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
* ```typescript
|
|
353
|
-
* // At your application root:
|
|
354
|
-
* import {PrivyProvider} from '@privy-io/react-auth';
|
|
355
|
-
*
|
|
356
|
-
* <PrivyProvider appId="APP_ID_FROM_CONSOLE" onSuccess={() => console.log('Success!')}>
|
|
357
|
-
* <Component {...pageProps} />
|
|
358
|
-
* </PrivyProvider>
|
|
359
|
-
* ```
|
|
169
|
+
* Allows you to manage the user's current authentication state and access their linked accounts.
|
|
170
|
+
* You can access the fields and methods documented here via the {@link usePrivy} hook.
|
|
360
171
|
*/
|
|
361
|
-
declare const PrivyProvider: (props: PrivyProviderProps) => JSX.Element;
|
|
362
|
-
|
|
363
172
|
interface PrivyInterface {
|
|
364
173
|
/**
|
|
365
|
-
* Check whether the PrivyProvider is ready to be used.
|
|
366
|
-
* be true before
|
|
174
|
+
* Check whether the `PrivyProvider` is ready to be used. You should wait for this to
|
|
175
|
+
* be true before using values such as `authenticated` and `user`.
|
|
367
176
|
*/
|
|
368
177
|
ready: boolean;
|
|
369
178
|
/**
|
|
370
|
-
* True if the user is authenticated, false
|
|
371
|
-
*
|
|
372
|
-
*
|
|
179
|
+
* True if the user is authenticated, false otherwise.
|
|
180
|
+
*
|
|
181
|
+
* You should always check that `ready` is true before using this value. Otherwise,
|
|
182
|
+
* the value may outdated while the Privy client fetches fresh tokens.
|
|
373
183
|
*
|
|
374
|
-
* Note: this value should be checked in conjunction with `ready` - otherwise
|
|
375
|
-
* the value may incorrectly show authentication state while proper setup is completed.
|
|
376
184
|
*/
|
|
377
185
|
authenticated: boolean;
|
|
378
186
|
/**
|
|
@@ -380,76 +188,53 @@ interface PrivyInterface {
|
|
|
380
188
|
*/
|
|
381
189
|
user: User | null;
|
|
382
190
|
/**
|
|
383
|
-
* Opens the Privy login modal and
|
|
191
|
+
* Opens the Privy login modal and prompts the user to login.
|
|
384
192
|
*/
|
|
385
193
|
login: () => void;
|
|
386
194
|
/**
|
|
387
|
-
*
|
|
195
|
+
* For users who are authenticated, opens the Privy modal and prompts the user to link an email.
|
|
388
196
|
*/
|
|
389
197
|
linkEmail: () => void;
|
|
390
198
|
/**
|
|
391
|
-
*
|
|
199
|
+
* For users who are authenticated, opens the Privy modal and prompts the user to link a wallet.
|
|
392
200
|
*/
|
|
393
201
|
linkWallet: () => void;
|
|
394
202
|
/**
|
|
395
|
-
* Log the current user out
|
|
396
|
-
*
|
|
203
|
+
* Log the current user out and clears their authentication state. `authenticated` will become false, `user` will become null, and the Privy Auth tokens will be deleted from the browser's local storage.
|
|
204
|
+
*
|
|
205
|
+
* You may await this call to take an action once logout is complete (e.g. redirecting to a specific page).
|
|
397
206
|
*/
|
|
398
207
|
logout: () => Promise<void>;
|
|
399
208
|
/**
|
|
400
|
-
* Get the Privy access token.
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
209
|
+
* Get the Privy access token ([JWT](https://jwt.io/)) for an authenticated user. Returns null for an unauthenticated user.
|
|
210
|
+
*
|
|
211
|
+
* You may use this token to authorize requests sent from your frontend, and can validate it in your backend against your app's Privy verification key.
|
|
212
|
+
*
|
|
213
|
+
* This will automatically attempt to refresh the session if the token is expired or about to expire.
|
|
404
214
|
*/
|
|
405
215
|
getAccessToken: () => Promise<string | null>;
|
|
406
|
-
getEthereumProvider: () => EIP1193Provider;
|
|
407
|
-
getEthersProvider: () => Web3Provider;
|
|
408
|
-
getWeb3jsProvider: () => AbstractProvider;
|
|
409
|
-
}
|
|
410
|
-
declare const usePrivy: () => PrivyInterface;
|
|
411
|
-
|
|
412
|
-
declare abstract class PrivyError extends Error {
|
|
413
216
|
/**
|
|
414
|
-
*
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* Original Error object, it the error originated client-side.
|
|
217
|
+
* Get an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193)-compatible provider from the user's wallet, if the user has connected one.
|
|
218
|
+
*
|
|
219
|
+
* You may then use the Ethereum Javascript API syntax to send JSON-RPC requests to the user's wallet.
|
|
419
220
|
*/
|
|
420
|
-
|
|
221
|
+
getEthereumProvider: () => EIP1193Provider;
|
|
421
222
|
/**
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
223
|
+
*
|
|
224
|
+
* Get an [ethers.js](https://docs.ethers.io/v5/)-compatible provider from the user's wallet, if the user has connected one.
|
|
225
|
+
*
|
|
425
226
|
*/
|
|
426
|
-
|
|
427
|
-
toString(): string;
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Issues with the Privy api.
|
|
431
|
-
*/
|
|
432
|
-
declare class PrivyApiError extends PrivyError {
|
|
433
|
-
type: string;
|
|
227
|
+
getEthersProvider: () => Web3Provider;
|
|
434
228
|
/**
|
|
435
|
-
*
|
|
229
|
+
* Get a [web3.js](https://web3js.readthedocs.io/en/v1.8.0/)-compatible provider from the user's wallet, if the user has connected one.
|
|
436
230
|
*/
|
|
437
|
-
|
|
438
|
-
constructor(type: string, status: number | null, message: string, cause?: unknown);
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Issues with the Privy client.
|
|
442
|
-
*/
|
|
443
|
-
declare class PrivyClientError extends PrivyError {
|
|
444
|
-
type: string;
|
|
445
|
-
constructor(message: string, cause?: unknown);
|
|
231
|
+
getWeb3jsProvider: () => AbstractProvider;
|
|
446
232
|
}
|
|
447
233
|
/**
|
|
448
|
-
*
|
|
234
|
+
* [React Hook](https://reactjs.org/docs/hooks-intro.html) that allows you to manage the user's current authentication state and access their linked accounts.
|
|
235
|
+
*
|
|
236
|
+
* You should use this hook to access the Privy SDK from within your React components and custom hooks.
|
|
449
237
|
*/
|
|
450
|
-
declare
|
|
451
|
-
type: string;
|
|
452
|
-
constructor(message: string, cause?: unknown);
|
|
453
|
-
}
|
|
238
|
+
declare const usePrivy: () => PrivyInterface;
|
|
454
239
|
|
|
455
|
-
export { Discord, DiscordOAuthWithMetadata, Email, EmailWithMetadata, Google, GoogleOAuthWithMetadata,
|
|
240
|
+
export { Discord, DiscordOAuthWithMetadata, Email, EmailWithMetadata, Google, GoogleOAuthWithMetadata, PrivyInterface, PrivyProvider, PrivyProviderProps, Twitter, TwitterOAuthWithMetadata, User, Wallet, WalletWithMetadata, usePrivy };
|