@auth0/auth0-spa-js 2.19.0 → 2.19.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.
Files changed (58) hide show
  1. package/dist/auth0-spa-js.development.js +47 -26
  2. package/dist/auth0-spa-js.development.js.map +1 -1
  3. package/dist/auth0-spa-js.production.esm.js +1 -1
  4. package/dist/auth0-spa-js.production.esm.js.map +1 -1
  5. package/dist/auth0-spa-js.production.js +1 -1
  6. package/dist/auth0-spa-js.production.js.map +1 -1
  7. package/dist/auth0-spa-js.worker.development.js +7 -0
  8. package/dist/auth0-spa-js.worker.development.js.map +1 -1
  9. package/dist/auth0-spa-js.worker.production.js +1 -1
  10. package/dist/auth0-spa-js.worker.production.js.map +1 -1
  11. package/dist/lib/auth0-spa-js.cjs.js +47 -26
  12. package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
  13. package/dist/typings/Auth0Client.d.ts +476 -476
  14. package/dist/typings/Auth0Client.utils.d.ts +90 -90
  15. package/dist/typings/MyAccountApiClient.d.ts +92 -92
  16. package/dist/typings/TokenExchange.d.ts +77 -77
  17. package/dist/typings/api.d.ts +33 -33
  18. package/dist/typings/cache/cache-localstorage.d.ts +7 -7
  19. package/dist/typings/cache/cache-manager.d.ts +69 -69
  20. package/dist/typings/cache/cache-memory.d.ts +4 -4
  21. package/dist/typings/cache/index.d.ts +4 -4
  22. package/dist/typings/cache/key-manifest.d.ts +12 -12
  23. package/dist/typings/cache/shared.d.ts +68 -68
  24. package/dist/typings/constants.d.ts +58 -58
  25. package/dist/typings/dpop/dpop.d.ts +17 -17
  26. package/dist/typings/dpop/storage.d.ts +27 -27
  27. package/dist/typings/dpop/utils.d.ts +15 -15
  28. package/dist/typings/errors.d.ts +96 -96
  29. package/dist/typings/fetcher.d.ts +54 -54
  30. package/dist/typings/global.d.ts +826 -826
  31. package/dist/typings/http.d.ts +11 -11
  32. package/dist/typings/index.d.ts +24 -24
  33. package/dist/typings/jwt.d.ts +21 -21
  34. package/dist/typings/lock.d.ts +32 -32
  35. package/dist/typings/mfa/MfaApiClient.d.ts +225 -225
  36. package/dist/typings/mfa/MfaContextManager.d.ts +79 -79
  37. package/dist/typings/mfa/constants.d.ts +23 -23
  38. package/dist/typings/mfa/errors.d.ts +117 -117
  39. package/dist/typings/mfa/index.d.ts +4 -4
  40. package/dist/typings/mfa/types.d.ts +181 -181
  41. package/dist/typings/mfa/utils.d.ts +23 -23
  42. package/dist/typings/promise-utils.d.ts +2 -2
  43. package/dist/typings/scope.d.ts +35 -35
  44. package/dist/typings/storage.d.ts +26 -26
  45. package/dist/typings/transaction-manager.d.ts +33 -33
  46. package/dist/typings/utils.d.ts +36 -36
  47. package/dist/typings/version.d.ts +2 -2
  48. package/dist/typings/worker/token.worker.d.ts +1 -1
  49. package/dist/typings/worker/worker.types.d.ts +30 -27
  50. package/dist/typings/worker/worker.utils.d.ts +13 -13
  51. package/package.json +1 -1
  52. package/src/Auth0Client.ts +10 -0
  53. package/src/api.ts +15 -11
  54. package/src/cache/cache-manager.ts +28 -9
  55. package/src/version.ts +1 -1
  56. package/src/worker/token.worker.ts +6 -0
  57. package/src/worker/worker.types.ts +6 -1
  58. package/src/worker/worker.utils.ts +5 -1
@@ -1,79 +1,79 @@
1
- import { MfaRequirements } from '../errors';
2
- /**
3
- * Represents the stored context for an MFA flow
4
- */
5
- export interface MfaContext {
6
- /** The OAuth scope for the original token request */
7
- scope?: string;
8
- /** The API audience for the original token request */
9
- audience?: string;
10
- /** MFA requirements from the mfa_required error (camelCase for TypeScript conventions) */
11
- mfaRequirements?: MfaRequirements;
12
- /** Timestamp when the context was created */
13
- createdAt: number;
14
- }
15
- /**
16
- * Manages MFA authentication contexts keyed by MFA token.
17
- *
18
- * When an mfa_required error occurs, the SDK stores the original request's
19
- * scope and audience. When the user later provides an MFA token for verification,
20
- * the SDK retrieves the matching context to complete the token exchange.
21
- *
22
- * This enables concurrent MFA flows without state conflicts.
23
- *
24
- * @example
25
- * ```typescript
26
- * const manager = new MfaContextManager();
27
- *
28
- * // Store context when mfa_required error occurs
29
- * manager.set('mfaTokenAbc', { scope: 'openid profile', audience: 'https://api.example.com' });
30
- *
31
- * // Retrieve context when user completes MFA
32
- * const context = manager.get('mfaTokenAbc');
33
- * // { scope: 'openid profile', audience: 'https://api.example.com', createdAt: ... }
34
- *
35
- * // Remove after successful verification
36
- * manager.remove('mfaTokenAbc');
37
- * ```
38
- */
39
- export declare class MfaContextManager {
40
- private contexts;
41
- private readonly ttlMs;
42
- /**
43
- * Creates a new MfaContextManager
44
- * @param ttlMs - Time-to-live for contexts in milliseconds (default: 10 minutes)
45
- */
46
- constructor(ttlMs?: number);
47
- /**
48
- * Stores an MFA context keyed by the MFA token.
49
- * Runs cleanup to remove expired entries before storing.
50
- *
51
- * @param mfaToken - The MFA token from the mfa_required error
52
- * @param context - The scope and audience from the original request
53
- */
54
- set(mfaToken: string, context: Omit<MfaContext, 'createdAt'>): void;
55
- /**
56
- * Retrieves the MFA context for a given token.
57
- * Returns undefined if the token is not found or has expired.
58
- *
59
- * @param mfaToken - The MFA token to look up
60
- * @returns The stored context, or undefined if not found/expired
61
- */
62
- get(mfaToken: string): MfaContext | undefined;
63
- /**
64
- * Removes an MFA context.
65
- * Should be called after successful MFA verification.
66
- *
67
- * @param mfaToken - The MFA token to remove
68
- */
69
- remove(mfaToken: string): void;
70
- /**
71
- * Removes all expired contexts from the Map.
72
- * Called automatically on every `set` operation.
73
- */
74
- private cleanup;
75
- /**
76
- * Returns the number of stored contexts
77
- */
78
- get size(): number;
79
- }
1
+ import { MfaRequirements } from '../errors';
2
+ /**
3
+ * Represents the stored context for an MFA flow
4
+ */
5
+ export interface MfaContext {
6
+ /** The OAuth scope for the original token request */
7
+ scope?: string;
8
+ /** The API audience for the original token request */
9
+ audience?: string;
10
+ /** MFA requirements from the mfa_required error (camelCase for TypeScript conventions) */
11
+ mfaRequirements?: MfaRequirements;
12
+ /** Timestamp when the context was created */
13
+ createdAt: number;
14
+ }
15
+ /**
16
+ * Manages MFA authentication contexts keyed by MFA token.
17
+ *
18
+ * When an mfa_required error occurs, the SDK stores the original request's
19
+ * scope and audience. When the user later provides an MFA token for verification,
20
+ * the SDK retrieves the matching context to complete the token exchange.
21
+ *
22
+ * This enables concurrent MFA flows without state conflicts.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const manager = new MfaContextManager();
27
+ *
28
+ * // Store context when mfa_required error occurs
29
+ * manager.set('mfaTokenAbc', { scope: 'openid profile', audience: 'https://api.example.com' });
30
+ *
31
+ * // Retrieve context when user completes MFA
32
+ * const context = manager.get('mfaTokenAbc');
33
+ * // { scope: 'openid profile', audience: 'https://api.example.com', createdAt: ... }
34
+ *
35
+ * // Remove after successful verification
36
+ * manager.remove('mfaTokenAbc');
37
+ * ```
38
+ */
39
+ export declare class MfaContextManager {
40
+ private contexts;
41
+ private readonly ttlMs;
42
+ /**
43
+ * Creates a new MfaContextManager
44
+ * @param ttlMs - Time-to-live for contexts in milliseconds (default: 10 minutes)
45
+ */
46
+ constructor(ttlMs?: number);
47
+ /**
48
+ * Stores an MFA context keyed by the MFA token.
49
+ * Runs cleanup to remove expired entries before storing.
50
+ *
51
+ * @param mfaToken - The MFA token from the mfa_required error
52
+ * @param context - The scope and audience from the original request
53
+ */
54
+ set(mfaToken: string, context: Omit<MfaContext, 'createdAt'>): void;
55
+ /**
56
+ * Retrieves the MFA context for a given token.
57
+ * Returns undefined if the token is not found or has expired.
58
+ *
59
+ * @param mfaToken - The MFA token to look up
60
+ * @returns The stored context, or undefined if not found/expired
61
+ */
62
+ get(mfaToken: string): MfaContext | undefined;
63
+ /**
64
+ * Removes an MFA context.
65
+ * Should be called after successful MFA verification.
66
+ *
67
+ * @param mfaToken - The MFA token to remove
68
+ */
69
+ remove(mfaToken: string): void;
70
+ /**
71
+ * Removes all expired contexts from the Map.
72
+ * Called automatically on every `set` operation.
73
+ */
74
+ private cleanup;
75
+ /**
76
+ * Returns the number of stored contexts
77
+ */
78
+ get size(): number;
79
+ }
@@ -1,23 +1,23 @@
1
- import type { MfaFactorType, OobChannel } from './types';
2
- /**
3
- * Mapping configuration for a factor type
4
- */
5
- export interface FactorMapping {
6
- authenticatorTypes: ['otp'] | ['oob'];
7
- oobChannels?: OobChannel[];
8
- }
9
- /**
10
- * Maps MFA factor types to auth-js enrollment parameters
11
- */
12
- export declare const FACTOR_MAPPING: Record<MfaFactorType, FactorMapping>;
13
- /**
14
- * MFA grant type constants for verification
15
- */
16
- export declare const MfaGrantTypes: {
17
- /** Grant type for OTP (TOTP) verification */
18
- readonly OTP: "http://auth0.com/oauth/grant-type/mfa-otp";
19
- /** Grant type for OOB (SMS, Email, Push) verification */
20
- readonly OOB: "http://auth0.com/oauth/grant-type/mfa-oob";
21
- /** Grant type for recovery code verification */
22
- readonly RECOVERY_CODE: "http://auth0.com/oauth/grant-type/mfa-recovery-code";
23
- };
1
+ import type { MfaFactorType, OobChannel } from './types';
2
+ /**
3
+ * Mapping configuration for a factor type
4
+ */
5
+ export interface FactorMapping {
6
+ authenticatorTypes: ['otp'] | ['oob'];
7
+ oobChannels?: OobChannel[];
8
+ }
9
+ /**
10
+ * Maps MFA factor types to auth-js enrollment parameters
11
+ */
12
+ export declare const FACTOR_MAPPING: Record<MfaFactorType, FactorMapping>;
13
+ /**
14
+ * MFA grant type constants for verification
15
+ */
16
+ export declare const MfaGrantTypes: {
17
+ /** Grant type for OTP (TOTP) verification */
18
+ readonly OTP: "http://auth0.com/oauth/grant-type/mfa-otp";
19
+ /** Grant type for OOB (SMS, Email, Push) verification */
20
+ readonly OOB: "http://auth0.com/oauth/grant-type/mfa-oob";
21
+ /** Grant type for recovery code verification */
22
+ readonly RECOVERY_CODE: "http://auth0.com/oauth/grant-type/mfa-recovery-code";
23
+ };
@@ -1,117 +1,117 @@
1
- import { MfaApiErrorResponse } from '@auth0/auth0-auth-js';
2
- import { GenericError } from '../errors';
3
- /**
4
- * Base class for MFA-related errors in auth0-spa-js.
5
- * Extends GenericError for unified error hierarchy across the SDK.
6
- */
7
- export declare class MfaError extends GenericError {
8
- constructor(error: string, error_description: string);
9
- static fromPayload({ error, error_description }: {
10
- error: string;
11
- error_description: string;
12
- }): MfaError;
13
- }
14
- /**
15
- * Error thrown when listing MFA authenticators fails.
16
- *
17
- * @example
18
- * ```typescript
19
- * try {
20
- * const authenticators = await mfa.getAuthenticators();
21
- * } catch (error) {
22
- * if (error instanceof MfaListAuthenticatorsError) {
23
- * console.log(error.error); // 'access_denied'
24
- * console.log(error.error_description); // 'Unauthorized'
25
- * }
26
- * }
27
- * ```
28
- */
29
- export declare class MfaListAuthenticatorsError extends MfaError {
30
- constructor(error: string, error_description: string);
31
- }
32
- /**
33
- * Error thrown when enrolling an MFA authenticator fails.
34
- *
35
- * @example
36
- * ```typescript
37
- * try {
38
- * const enrollment = await mfa.enroll({
39
- * authenticator_types: ['otp']
40
- * });
41
- * } catch (error) {
42
- * if (error instanceof MfaEnrollmentError) {
43
- * console.log(error.error); // 'invalid_phone_number'
44
- * console.log(error.error_description); // 'Invalid phone number format'
45
- * }
46
- * }
47
- * ```
48
- */
49
- export declare class MfaEnrollmentError extends MfaError {
50
- constructor(error: string, error_description: string);
51
- }
52
- /**
53
- * Error thrown when initiating an MFA challenge fails.
54
- *
55
- * @example
56
- * ```typescript
57
- * try {
58
- * const challenge = await mfa.challenge({
59
- * mfaToken: mfaToken,
60
- * challengeType: 'otp',
61
- * authenticatorId: 'otp|dev_123'
62
- * });
63
- * } catch (error) {
64
- * if (error instanceof MfaChallengeError) {
65
- * console.log(error.error); // 'too_many_attempts'
66
- * console.log(error.error_description); // 'Rate limit exceeded'
67
- * }
68
- * }
69
- * ```
70
- */
71
- export declare class MfaChallengeError extends MfaError {
72
- constructor(error: string, error_description: string);
73
- }
74
- /**
75
- * Error thrown when verifying an MFA challenge fails.
76
- *
77
- * @example
78
- * ```typescript
79
- * try {
80
- * const tokens = await mfa.verify({
81
- * mfaToken: mfaToken,
82
- * grant_type: 'http://auth0.com/oauth/grant-type/mfa-otp',
83
- * otp: '123456'
84
- * });
85
- * } catch (error) {
86
- * if (error instanceof MfaVerifyError) {
87
- * console.log(error.error); // 'invalid_otp' or 'context_not_found'
88
- * console.log(error.error_description); // Error details
89
- * }
90
- * }
91
- * ```
92
- */
93
- export declare class MfaVerifyError extends MfaError {
94
- constructor(error: string, error_description: string);
95
- }
96
- /**
97
- * Error thrown when getting enrollment factors fails.
98
- *
99
- * @example
100
- * ```typescript
101
- * try {
102
- * const factors = await mfa.getEnrollmentFactors(mfaToken);
103
- * } catch (error) {
104
- * if (error instanceof MfaEnrollmentFactorsError) {
105
- * console.log(error.error); // 'mfa_context_not_found'
106
- * console.log(error.error_description); // 'MFA context not found...'
107
- * }
108
- * }
109
- * ```
110
- */
111
- export declare class MfaEnrollmentFactorsError extends MfaError {
112
- constructor(error: string, error_description: string);
113
- }
114
- /**
115
- * Re-export MfaApiErrorResponse type for convenience
116
- */
117
- export type { MfaApiErrorResponse };
1
+ import { MfaApiErrorResponse } from '@auth0/auth0-auth-js';
2
+ import { GenericError } from '../errors';
3
+ /**
4
+ * Base class for MFA-related errors in auth0-spa-js.
5
+ * Extends GenericError for unified error hierarchy across the SDK.
6
+ */
7
+ export declare class MfaError extends GenericError {
8
+ constructor(error: string, error_description: string);
9
+ static fromPayload({ error, error_description }: {
10
+ error: string;
11
+ error_description: string;
12
+ }): MfaError;
13
+ }
14
+ /**
15
+ * Error thrown when listing MFA authenticators fails.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * try {
20
+ * const authenticators = await mfa.getAuthenticators();
21
+ * } catch (error) {
22
+ * if (error instanceof MfaListAuthenticatorsError) {
23
+ * console.log(error.error); // 'access_denied'
24
+ * console.log(error.error_description); // 'Unauthorized'
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ export declare class MfaListAuthenticatorsError extends MfaError {
30
+ constructor(error: string, error_description: string);
31
+ }
32
+ /**
33
+ * Error thrown when enrolling an MFA authenticator fails.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * try {
38
+ * const enrollment = await mfa.enroll({
39
+ * authenticator_types: ['otp']
40
+ * });
41
+ * } catch (error) {
42
+ * if (error instanceof MfaEnrollmentError) {
43
+ * console.log(error.error); // 'invalid_phone_number'
44
+ * console.log(error.error_description); // 'Invalid phone number format'
45
+ * }
46
+ * }
47
+ * ```
48
+ */
49
+ export declare class MfaEnrollmentError extends MfaError {
50
+ constructor(error: string, error_description: string);
51
+ }
52
+ /**
53
+ * Error thrown when initiating an MFA challenge fails.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * try {
58
+ * const challenge = await mfa.challenge({
59
+ * mfaToken: mfaToken,
60
+ * challengeType: 'otp',
61
+ * authenticatorId: 'otp|dev_123'
62
+ * });
63
+ * } catch (error) {
64
+ * if (error instanceof MfaChallengeError) {
65
+ * console.log(error.error); // 'too_many_attempts'
66
+ * console.log(error.error_description); // 'Rate limit exceeded'
67
+ * }
68
+ * }
69
+ * ```
70
+ */
71
+ export declare class MfaChallengeError extends MfaError {
72
+ constructor(error: string, error_description: string);
73
+ }
74
+ /**
75
+ * Error thrown when verifying an MFA challenge fails.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * try {
80
+ * const tokens = await mfa.verify({
81
+ * mfaToken: mfaToken,
82
+ * grant_type: 'http://auth0.com/oauth/grant-type/mfa-otp',
83
+ * otp: '123456'
84
+ * });
85
+ * } catch (error) {
86
+ * if (error instanceof MfaVerifyError) {
87
+ * console.log(error.error); // 'invalid_otp' or 'context_not_found'
88
+ * console.log(error.error_description); // Error details
89
+ * }
90
+ * }
91
+ * ```
92
+ */
93
+ export declare class MfaVerifyError extends MfaError {
94
+ constructor(error: string, error_description: string);
95
+ }
96
+ /**
97
+ * Error thrown when getting enrollment factors fails.
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * try {
102
+ * const factors = await mfa.getEnrollmentFactors(mfaToken);
103
+ * } catch (error) {
104
+ * if (error instanceof MfaEnrollmentFactorsError) {
105
+ * console.log(error.error); // 'mfa_context_not_found'
106
+ * console.log(error.error_description); // 'MFA context not found...'
107
+ * }
108
+ * }
109
+ * ```
110
+ */
111
+ export declare class MfaEnrollmentFactorsError extends MfaError {
112
+ constructor(error: string, error_description: string);
113
+ }
114
+ /**
115
+ * Re-export MfaApiErrorResponse type for convenience
116
+ */
117
+ export type { MfaApiErrorResponse };
@@ -1,4 +1,4 @@
1
- export { MfaApiClient } from './MfaApiClient';
2
- export { MfaContextManager } from './MfaContextManager';
3
- export type { MfaContext } from './MfaContextManager';
4
- export type { Authenticator, AuthenticatorType, OobChannel, MfaFactorType, EnrollBaseParams, EnrollParams, EnrollOtpParams, EnrollSmsParams, EnrollVoiceParams, EnrollEmailParams, EnrollPushParams, EnrollmentResponse, OtpEnrollmentResponse, OobEnrollmentResponse, ChallengeAuthenticatorParams, ChallengeResponse, VerifyParams, MfaGrantType, EnrollmentFactor } from './types';
1
+ export { MfaApiClient } from './MfaApiClient';
2
+ export { MfaContextManager } from './MfaContextManager';
3
+ export type { MfaContext } from './MfaContextManager';
4
+ export type { Authenticator, AuthenticatorType, OobChannel, MfaFactorType, EnrollBaseParams, EnrollParams, EnrollOtpParams, EnrollSmsParams, EnrollVoiceParams, EnrollEmailParams, EnrollPushParams, EnrollmentResponse, OtpEnrollmentResponse, OobEnrollmentResponse, ChallengeAuthenticatorParams, ChallengeResponse, VerifyParams, MfaGrantType, EnrollmentFactor } from './types';