@auth0/auth0-react 2.13.0 → 2.15.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/auth0-context.d.ts +55 -1
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +32 -17
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +15 -7
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +32 -17
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -1
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/auth0-context.tsx +63 -1
- package/src/auth0-provider.tsx +4 -0
- package/src/index.tsx +24 -0
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, PopupOpenError, AuthenticationError, MissingRefreshTokenError, GenericError, UseDpopNonceError, type FetcherConfig, RedirectConnectAccountOptions, ConnectAccountRedirectResult, ResponseType, ConnectError, type InteractiveErrorHandler, 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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,KAAK,aAAa,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,YAAY,EACZ,YAAY,EACZ,KAAK,uBAAuB,EAC5B,0BAA0B,EAC1B,qBAAqB,EACrB,mBAAmB,EAEnB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAErB,QAAQ,EACR,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Auth0",
|
|
3
3
|
"name": "@auth0/auth0-react",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.15.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.
|
|
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.
|
|
98
|
+
"@auth0/auth0-spa-js": "^2.16.0"
|
|
99
99
|
}
|
|
100
100
|
}
|
package/src/auth0-context.tsx
CHANGED
|
@@ -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
|
/**
|
package/src/auth0-provider.tsx
CHANGED
|
@@ -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
|
@@ -35,6 +35,7 @@ export {
|
|
|
35
35
|
MfaRequiredError,
|
|
36
36
|
PopupCancelledError,
|
|
37
37
|
PopupTimeoutError,
|
|
38
|
+
PopupOpenError,
|
|
38
39
|
AuthenticationError,
|
|
39
40
|
MissingRefreshTokenError,
|
|
40
41
|
GenericError,
|
|
@@ -44,8 +45,31 @@ export {
|
|
|
44
45
|
ConnectAccountRedirectResult,
|
|
45
46
|
ResponseType,
|
|
46
47
|
ConnectError,
|
|
48
|
+
type InteractiveErrorHandler,
|
|
47
49
|
CustomTokenExchangeOptions,
|
|
48
50
|
TokenEndpointResponse,
|
|
49
51
|
ClientConfiguration,
|
|
52
|
+
// MFA Types
|
|
53
|
+
type MfaApiClient,
|
|
54
|
+
type Authenticator,
|
|
55
|
+
type MfaFactorType,
|
|
56
|
+
type EnrollParams,
|
|
57
|
+
type EnrollOtpParams,
|
|
58
|
+
type EnrollSmsParams,
|
|
59
|
+
type EnrollVoiceParams,
|
|
60
|
+
type EnrollEmailParams,
|
|
61
|
+
type EnrollPushParams,
|
|
62
|
+
type EnrollmentResponse,
|
|
63
|
+
type ChallengeAuthenticatorParams,
|
|
64
|
+
type ChallengeResponse,
|
|
65
|
+
type VerifyParams,
|
|
66
|
+
type EnrollmentFactor,
|
|
67
|
+
// MFA Errors
|
|
68
|
+
MfaError,
|
|
69
|
+
MfaListAuthenticatorsError,
|
|
70
|
+
MfaEnrollmentError,
|
|
71
|
+
MfaChallengeError,
|
|
72
|
+
MfaVerifyError,
|
|
73
|
+
MfaEnrollmentFactorsError,
|
|
50
74
|
} from '@auth0/auth0-spa-js';
|
|
51
75
|
export { OAuthError } from './errors';
|