@auth0/auth0-react 2.13.0 → 2.14.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/index.d.ts CHANGED
@@ -3,6 +3,6 @@ export { default as useAuth0 } from './use-auth0';
3
3
  export { default as withAuth0, WithAuth0Props } from './with-auth0';
4
4
  export { default as withAuthenticationRequired, WithAuthenticationRequiredOptions, } from './with-authentication-required';
5
5
  export { default as Auth0Context, Auth0ContextInterface, initialContext, LogoutOptions, RedirectLoginOptions, } from './auth0-context';
6
- export { AuthorizationParams, PopupLoginOptions, PopupConfigOptions, GetTokenWithPopupOptions, LogoutUrlOptions, CacheLocation, GetTokenSilentlyOptions, IdToken, User, ICache, InMemoryCache, LocalStorageCache, Cacheable, TimeoutError, MfaRequiredError, PopupCancelledError, PopupTimeoutError, AuthenticationError, MissingRefreshTokenError, GenericError, UseDpopNonceError, type FetcherConfig, RedirectConnectAccountOptions, ConnectAccountRedirectResult, ResponseType, ConnectError, CustomTokenExchangeOptions, TokenEndpointResponse, ClientConfiguration, } from '@auth0/auth0-spa-js';
6
+ export { AuthorizationParams, PopupLoginOptions, PopupConfigOptions, GetTokenWithPopupOptions, LogoutUrlOptions, CacheLocation, GetTokenSilentlyOptions, IdToken, User, ICache, InMemoryCache, LocalStorageCache, Cacheable, TimeoutError, MfaRequiredError, PopupCancelledError, PopupTimeoutError, AuthenticationError, MissingRefreshTokenError, GenericError, UseDpopNonceError, type FetcherConfig, RedirectConnectAccountOptions, ConnectAccountRedirectResult, ResponseType, ConnectError, CustomTokenExchangeOptions, TokenEndpointResponse, ClientConfiguration, type MfaApiClient, type Authenticator, type MfaFactorType, type EnrollParams, type EnrollOtpParams, type EnrollSmsParams, type EnrollVoiceParams, type EnrollEmailParams, type EnrollPushParams, type EnrollmentResponse, type ChallengeAuthenticatorParams, type ChallengeResponse, type VerifyParams, type EnrollmentFactor, MfaError, MfaListAuthenticatorsError, MfaEnrollmentError, MfaChallengeError, MfaVerifyError, MfaEnrollmentFactorsError, } from '@auth0/auth0-spa-js';
7
7
  export { OAuthError } from './errors';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,OAAO,IAAI,0BAA0B,EACrC,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,OAAO,EACP,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,KAAK,aAAa,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,oBAAoB,EACpB,QAAQ,EACR,gB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
  {
2
2
  "author": "Auth0",
3
3
  "name": "@auth0/auth0-react",
4
- "version": "2.13.0",
4
+ "version": "2.14.0",
5
5
  "description": "Auth0 SDK for React Single Page Applications (SPA)",
6
6
  "keywords": [
7
7
  "auth0",
@@ -58,7 +58,7 @@
58
58
  "@testing-library/jest-dom": "6.9.1",
59
59
  "@testing-library/react": "16.3.2",
60
60
  "@types/jest": "^29.5.14",
61
- "@types/react": "19.2.11",
61
+ "@types/react": "19.2.14",
62
62
  "@types/react-dom": "19.2.3",
63
63
  "@typescript-eslint/eslint-plugin": "^8.36.0",
64
64
  "@typescript-eslint/parser": "^8.36.0",
@@ -95,6 +95,6 @@
95
95
  "react-dom": "^16.11.0 || ^17 || ^18 || ~19.0.1 || ~19.1.2 || ^19.2.1"
96
96
  },
97
97
  "dependencies": {
98
- "@auth0/auth0-spa-js": "^2.14.0"
98
+ "@auth0/auth0-spa-js": "^2.15.0"
99
99
  }
100
100
  }
@@ -13,7 +13,8 @@ import {
13
13
  RedirectConnectAccountOptions,
14
14
  ConnectAccountRedirectResult,
15
15
  CustomTokenExchangeOptions,
16
- TokenEndpointResponse
16
+ TokenEndpointResponse,
17
+ type MfaApiClient
17
18
  } from '@auth0/auth0-spa-js';
18
19
  import { createContext } from 'react';
19
20
  import { AuthState, initialAuthState } from './auth-state';
@@ -308,6 +309,60 @@ export interface Auth0ContextInterface<TUser extends User = User>
308
309
  * containing the domain and clientId.
309
310
  */
310
311
  getConfiguration: Auth0Client['getConfiguration'];
312
+
313
+ /**
314
+ * ```js
315
+ * const { mfa } = useAuth0();
316
+ * const authenticators = await mfa.getAuthenticators(mfaToken);
317
+ * ```
318
+ *
319
+ * MFA API client for Multi-Factor Authentication operations.
320
+ *
321
+ * Provides access to all MFA-related methods:
322
+ * - `getAuthenticators(mfaToken)` - List enrolled authenticators
323
+ * - `enroll(params)` - Enroll new authenticators (OTP, SMS, Voice, Email, Push)
324
+ * - `challenge(params)` - Initiate MFA challenges
325
+ * - `verify(params)` - Verify MFA challenges and complete authentication
326
+ * - `getEnrollmentFactors(mfaToken)` - Get available enrollment factors
327
+ *
328
+ * @example
329
+ * ```js
330
+ * const { mfa, getAccessTokenSilently } = useAuth0();
331
+ *
332
+ * try {
333
+ * await getAccessTokenSilently();
334
+ * } catch (error) {
335
+ * if (error.error === 'mfa_required') {
336
+ * // Check if enrollment is needed
337
+ * const factors = await mfa.getEnrollmentFactors(error.mfa_token);
338
+ *
339
+ * if (factors.length > 0) {
340
+ * // Enroll in OTP
341
+ * const enrollment = await mfa.enroll({
342
+ * mfaToken: error.mfa_token,
343
+ * factorType: 'otp'
344
+ * });
345
+ * console.log('QR Code:', enrollment.barcodeUri);
346
+ * }
347
+ *
348
+ * // Get authenticators and challenge
349
+ * const authenticators = await mfa.getAuthenticators(error.mfa_token);
350
+ * await mfa.challenge({
351
+ * mfaToken: error.mfa_token,
352
+ * challengeType: 'otp',
353
+ * authenticatorId: authenticators[0].id
354
+ * });
355
+ *
356
+ * // Verify with user's code
357
+ * const tokens = await mfa.verify({
358
+ * mfaToken: error.mfa_token,
359
+ * otp: userCode
360
+ * });
361
+ * }
362
+ * }
363
+ * ```
364
+ */
365
+ mfa: MfaApiClient;
311
366
  }
312
367
 
313
368
  /**
@@ -339,6 +394,13 @@ export const initialContext = {
339
394
  generateDpopProof: stub,
340
395
  createFetcher: stub,
341
396
  getConfiguration: stub,
397
+ mfa: {
398
+ getAuthenticators: stub,
399
+ enroll: stub,
400
+ challenge: stub,
401
+ verify: stub,
402
+ getEnrollmentFactors: stub,
403
+ } as unknown as MfaApiClient,
342
404
  };
343
405
 
344
406
  /**
@@ -355,6 +355,8 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
355
355
  [client]
356
356
  );
357
357
 
358
+ const mfa = useMemo(() => client.mfa, [client]);
359
+
358
360
  const contextValue = useMemo<Auth0ContextInterface<TUser>>(() => {
359
361
  return {
360
362
  ...state,
@@ -373,6 +375,7 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
373
375
  generateDpopProof,
374
376
  createFetcher,
375
377
  getConfiguration,
378
+ mfa,
376
379
  };
377
380
  }, [
378
381
  state,
@@ -391,6 +394,7 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
391
394
  generateDpopProof,
392
395
  createFetcher,
393
396
  getConfiguration,
397
+ mfa,
394
398
  ]);
395
399
 
396
400
  return <context.Provider value={contextValue}>{children}</context.Provider>;
package/src/index.tsx CHANGED
@@ -47,5 +47,27 @@ export {
47
47
  CustomTokenExchangeOptions,
48
48
  TokenEndpointResponse,
49
49
  ClientConfiguration,
50
+ // MFA Types
51
+ type MfaApiClient,
52
+ type Authenticator,
53
+ type MfaFactorType,
54
+ type EnrollParams,
55
+ type EnrollOtpParams,
56
+ type EnrollSmsParams,
57
+ type EnrollVoiceParams,
58
+ type EnrollEmailParams,
59
+ type EnrollPushParams,
60
+ type EnrollmentResponse,
61
+ type ChallengeAuthenticatorParams,
62
+ type ChallengeResponse,
63
+ type VerifyParams,
64
+ type EnrollmentFactor,
65
+ // MFA Errors
66
+ MfaError,
67
+ MfaListAuthenticatorsError,
68
+ MfaEnrollmentError,
69
+ MfaChallengeError,
70
+ MfaVerifyError,
71
+ MfaEnrollmentFactorsError,
50
72
  } from '@auth0/auth0-spa-js';
51
73
  export { OAuthError } from './errors';