@privy-io/react-auth 1.62.0 → 1.63.0-beta-20240501173029

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 CHANGED
@@ -3,10 +3,13 @@ import { ExternalProvider, StaticJsonRpcProvider, Web3Provider, TransactionRespo
3
3
  import { CountryCode } from 'libphonenumber-js/min';
4
4
  import { AbstractProvider } from 'web3-core';
5
5
  import EventEmitter from 'eventemitter3';
6
+ import { PasskeyAuthenticateInputType } from '@privy-io/public-api';
6
7
  import { TypedMessage as TypedMessage$1, MessageTypes as MessageTypes$1 } from '@metamask/eth-sig-util';
7
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
9
  import { TurnstileProps } from '@marsidev/react-turnstile';
9
10
  import { Store, EIP6963ProviderDetail } from 'mipd';
11
+ import * as _simplewebauthn_types from '@simplewebauthn/types';
12
+ import { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
10
13
  import { FetchOptions } from 'ofetch';
11
14
 
12
15
  /**
@@ -244,8 +247,9 @@ type WalletSetRecoveryPasswordRequestDataType = {
244
247
  type WalletRecoverRequestDataType = {
245
248
  address: string;
246
249
  accessToken: string;
247
- mfaCode?: string;
250
+ mfaCode?: string | PasskeyAuthenticateInputType['authenticator_response'];
248
251
  mfaMethod?: MfaMethod;
252
+ relyingParty?: string;
249
253
  recoveryPassword?: string;
250
254
  recoveryMethod?: 'user-passcode' | 'google-drive';
251
255
  recoveryAccessToken?: string;
@@ -261,8 +265,9 @@ type WalletConnectRequestDataType = {
261
265
  };
262
266
  type WalletRpcRequestDataType = {
263
267
  accessToken: string;
264
- mfaCode?: string;
268
+ mfaCode?: string | PasskeyAuthenticateInputType['authenticator_response'];
265
269
  mfaMethod?: MfaMethod;
270
+ relyingParty?: string;
266
271
  address: string;
267
272
  request: RpcRequestType;
268
273
  };
@@ -286,6 +291,10 @@ type MfaSubmitEnrollmentRequestDataType = {
286
291
  accessToken: string;
287
292
  method: 'totp';
288
293
  code: string;
294
+ } | {
295
+ accessToken: string;
296
+ method: 'passkey';
297
+ credentialIds: string[];
289
298
  };
290
299
  type MfaUnenrollRequestDataType = {
291
300
  accessToken: string;
@@ -298,15 +307,17 @@ type FarcasterSignerInitRequestDataType = {
298
307
  address: string;
299
308
  hdWalletIndex: number | null;
300
309
  accessToken: string;
301
- mfaCode: string | null;
310
+ mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'] | null;
302
311
  mfaMethod: string | null;
312
+ relyingParty: string;
303
313
  };
304
314
  type FarcasterSubmitCastRequestDataType = {
305
315
  address: string;
306
316
  hdWalletIndex: number | null;
307
317
  accessToken: string;
308
- mfaCode: string | null;
318
+ mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'] | null;
309
319
  mfaMethod: string | null;
320
+ relyingParty: string;
310
321
  payload: any;
311
322
  fid: bigint;
312
323
  };
@@ -314,8 +325,9 @@ type FarcasterRemoveCastRequestDataType = {
314
325
  address: string;
315
326
  hdWalletIndex: number | null;
316
327
  accessToken: string;
317
- mfaCode: string | null;
328
+ mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'] | null;
318
329
  mfaMethod: string | null;
330
+ relyingParty: string;
319
331
  payload: any;
320
332
  fid: bigint;
321
333
  };
@@ -323,8 +335,9 @@ type FarcasterReactToCastRequestDataType = {
323
335
  address: string;
324
336
  hdWalletIndex: number | null;
325
337
  accessToken: string;
326
- mfaCode: string | null;
338
+ mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'] | null;
327
339
  mfaMethod: string | null;
340
+ relyingParty?: string;
328
341
  payload: any;
329
342
  fid: bigint;
330
343
  };
@@ -332,8 +345,9 @@ type FarcasterLinkRequestDataType = {
332
345
  address: string;
333
346
  hdWalletIndex: number | null;
334
347
  accessToken: string;
335
- mfaCode: string | null;
348
+ mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'] | null;
336
349
  mfaMethod: string | null;
350
+ relyingParty?: string;
337
351
  payload: any;
338
352
  fid: bigint;
339
353
  };
@@ -796,6 +810,7 @@ interface ResponseCustomJwtAccount {
796
810
  interface ResponsePasskeyAccount {
797
811
  type: 'passkey';
798
812
  credential_id: string;
813
+ enrolled_in_mfa: boolean;
799
814
  authenticator_name?: string;
800
815
  created_with_device?: string;
801
816
  created_with_os?: string;
@@ -1024,6 +1039,21 @@ declare class PrivyClient {
1024
1039
  logout(): Promise<void>;
1025
1040
  startAuthFlow<T extends AuthFlow>(authFlow: T): T;
1026
1041
  initMfaSmsVerification(): Promise<void>;
1042
+ initMfaPasskeyVerification(): Promise<{
1043
+ challenge: string;
1044
+ allowCredentials: {
1045
+ id: string;
1046
+ type: "public-key";
1047
+ transports: AuthenticatorTransport[];
1048
+ }[];
1049
+ timeout: number | undefined;
1050
+ extensions: {
1051
+ appid: string | undefined;
1052
+ credProps: boolean | undefined;
1053
+ hmacCreateSecret: boolean | undefined;
1054
+ };
1055
+ userVerification: UserVerificationRequirement;
1056
+ }>;
1027
1057
  unlinkEmail(address: string): Promise<User>;
1028
1058
  acceptTerms(): Promise<User>;
1029
1059
  unlinkPhone(phoneNumber: string): Promise<User>;
@@ -1118,7 +1148,7 @@ type MoonpaySignResponse = {
1118
1148
  };
1119
1149
 
1120
1150
  declare const SUPPORTED_OAUTH_PROVIDERS: readonly ["google", "discord", "twitter", "github", "spotify", "tiktok", "linkedin", "apple"];
1121
- declare const SUPPORTED_MFA_METHODS: readonly ["sms", "totp"];
1151
+ declare const SUPPORTED_MFA_METHODS: readonly ["sms", "totp", "passkey"];
1122
1152
  type MfaMethod = (typeof SUPPORTED_MFA_METHODS)[number];
1123
1153
  /**
1124
1154
  * Supported OAuth providers. Can be `'google'`, `'discord'`, `'twitter'`, `'github'`, `'spotify'`,
@@ -1450,6 +1480,8 @@ interface Farcaster {
1450
1480
  interface Passkey {
1451
1481
  /** The passkey credential ID */
1452
1482
  credentialId: string;
1483
+ /** Whether or not this passkey can be used for MFA */
1484
+ enrolledInMfa: boolean;
1453
1485
  /** The type of authenticator holding the passkey */
1454
1486
  authenticatorName?: string;
1455
1487
  /** Metadata about the device that registered the passkey */
@@ -2521,6 +2553,13 @@ interface PrivyInterface {
2521
2553
  secret: string;
2522
2554
  authUrl: string;
2523
2555
  }>;
2556
+ /**
2557
+ * Initiate the enrollment flow for Passkey MFA for the current user.
2558
+ *
2559
+ * @returns {@link void} The TOTP Auth Url is used to encode
2560
+ * into a QR Code for the user to scane.
2561
+ */
2562
+ initEnrollmentWithPasskey: () => Promise<void>;
2524
2563
  /**
2525
2564
  * Submit the MFA code to complete SMS enrollment process.
2526
2565
  *
@@ -2540,6 +2579,15 @@ interface PrivyInterface {
2540
2579
  submitEnrollmentWithTotp: (meta: {
2541
2580
  mfaCode: string;
2542
2581
  }) => Promise<void>;
2582
+ /**
2583
+ * Submit the passkey to complete the enrollment process.
2584
+ *
2585
+ * @param meta {@link {credentialIds: string[]}} The passkey credentialIds to enroll in MFA.
2586
+ * @returns Promise for the MFA code submission.
2587
+ */
2588
+ submitEnrollmentWithPasskey: (meta: {
2589
+ credentialIds: string[];
2590
+ }) => Promise<void>;
2543
2591
  /**
2544
2592
  * Triggers the MFA verification flow if the user has an MFA method enrolled.
2545
2593
  *
@@ -2552,7 +2600,7 @@ interface PrivyInterface {
2552
2600
  * @param mfaMethod {@link MfaMethod} The available MFA method to trigger for the current user.
2553
2601
  * @returns Promise for sending the MFA code to the user's device.
2554
2602
  */
2555
- init: (mfaMethod: MfaMethod) => Promise<void>;
2603
+ init: (mfaMethod: MfaMethod) => Promise<void | PublicKeyCredentialRequestOptionsJSON>;
2556
2604
  /**
2557
2605
  * Submit the MFA code for the current user. This will attempt to complete the MFA flow.
2558
2606
  *
@@ -2568,7 +2616,7 @@ interface PrivyInterface {
2568
2616
  * @param mfaCode {string} The MFA code to submit.
2569
2617
  * @returns Promise for the MFA code submission.
2570
2618
  */
2571
- submit: (mfaMethod: MfaMethod, mfaCode: string) => Promise<void>;
2619
+ submit: (mfaMethod: MfaMethod, mfaCode: string | PublicKeyCredentialRequestOptionsJSON) => Promise<void>;
2572
2620
  /**
2573
2621
  * Cancel the MFA flow for the current user. If there is no pending MFA verification,
2574
2622
  * this function is a no-op.
@@ -2720,8 +2768,8 @@ declare function useWallets(): UseWalletsInterface;
2720
2768
  */
2721
2769
  declare function useMfa(): {
2722
2770
  promptMfa: () => Promise<void>;
2723
- init: (mfaMethod: "sms" | "totp") => Promise<void>;
2724
- submit: (mfaMethod: "sms" | "totp", mfaCode: string) => Promise<void>;
2771
+ init: (mfaMethod: "sms" | "totp" | "passkey") => Promise<void | _simplewebauthn_types.PublicKeyCredentialRequestOptionsJSON>;
2772
+ submit: (mfaMethod: "sms" | "totp" | "passkey", mfaCode: string | _simplewebauthn_types.PublicKeyCredentialRequestOptionsJSON) => Promise<void>;
2725
2773
  cancel: () => void;
2726
2774
  };
2727
2775
 
@@ -2738,34 +2786,6 @@ declare function useMfa(): {
2738
2786
  * @returns closeMfaEnrollmentModal - closes the MFA enrollment modal
2739
2787
  *
2740
2788
  * @example
2741
- * const {initEnrollment} = useMfaEnrollment();
2742
- *
2743
- * <button
2744
- * onClick={() => {
2745
- * initEnrollment(
2746
- * 'sms',
2747
- * { phoneNumber: '<user-phone-number>' },
2748
- * );
2749
- * }}
2750
- * >
2751
- * Enroll in SMS MFA
2752
- * </button>
2753
- *
2754
- * @example
2755
- * const {submitEnrollment} = useMfaEnrollment();
2756
- *
2757
- * <button
2758
- * onClick={() => {
2759
- * submitEnrollment(
2760
- * 'sms',
2761
- * { phoneNumber: '<user-phone-number>', mfaCode: '<user-mfa-code>' },
2762
- * );
2763
- * }}
2764
- * >
2765
- * Enroll in SMS MFA
2766
- * </button>
2767
- *
2768
- * @example
2769
2789
  * const {unenrollWithSms} = useMfaEnrollment();
2770
2790
  *
2771
2791
  * <button
@@ -2795,6 +2815,7 @@ declare function useMfaEnrollment(): {
2795
2815
  secret: string;
2796
2816
  authUrl: string;
2797
2817
  }>;
2818
+ initEnrollmentWithPasskey: () => Promise<void>;
2798
2819
  submitEnrollmentWithSms: (meta: {
2799
2820
  phoneNumber: string;
2800
2821
  mfaCode: string;
@@ -2802,8 +2823,12 @@ declare function useMfaEnrollment(): {
2802
2823
  submitEnrollmentWithTotp: (meta: {
2803
2824
  mfaCode: string;
2804
2825
  }) => Promise<void>;
2826
+ submitEnrollmentWithPasskey: (meta: {
2827
+ credentialIds: string[];
2828
+ }) => Promise<void>;
2805
2829
  unenrollWithSms: () => Promise<void>;
2806
2830
  unenrollWithTotp: () => Promise<void>;
2831
+ unenrollWithPasskey: () => Promise<void>;
2807
2832
  showMfaEnrollmentModal: () => void;
2808
2833
  closeMfaEnrollmentModal: () => void;
2809
2834
  };