@auth0/auth0-spa-js 2.16.0 → 2.17.1

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.
@@ -187,9 +187,20 @@ export declare class Auth0Client {
187
187
  private _getTokenSilently;
188
188
  /**
189
189
  * Checks if an error should be handled by the interactive error handler.
190
- * Currently only handles mfa_required; extensible for future error types.
190
+ * Matches:
191
+ * - MfaRequiredError (refresh token path, error='mfa_required')
192
+ * - GenericError from iframe path (error='login_required',
193
+ * error_description='Multifactor authentication required')
194
+ * Extensible for future interactive error types.
191
195
  */
192
196
  private _isInteractiveError;
197
+ /**
198
+ * Checks if a login_required error from the iframe flow is actually
199
+ * an MFA step-up requirement. The /authorize endpoint returns
200
+ * error='login_required' with error_description='Multifactor authentication required'
201
+ * when MFA is needed but prompt=none prevents interaction.
202
+ */
203
+ private _isIframeMfaError;
193
204
  /**
194
205
  * Handles MFA errors by opening a popup to complete authentication,
195
206
  * then reads the resulting token from cache.
@@ -33,6 +33,12 @@ export declare const INVALID_REFRESH_TOKEN_ERROR_MESSAGE = "invalid refresh toke
33
33
  * @ignore
34
34
  */
35
35
  export declare const USER_BLOCKED_ERROR_MESSAGE = "user is blocked";
36
+ /**
37
+ * @ignore
38
+ * The error_description returned by the /authorize endpoint when MFA is required
39
+ * but prompt=none prevents interaction (iframe silent auth flow).
40
+ */
41
+ export declare const MFA_STEP_UP_ERROR_DESCRIPTION = "Multifactor authentication required";
36
42
  /**
37
43
  * @ignore
38
44
  */
@@ -5,7 +5,7 @@ export * from './global';
5
5
  /**
6
6
  * Asynchronously creates the Auth0Client instance and calls `checkSession`.
7
7
  *
8
- * **Note:** There are caveats to using this in a private browser tab, which may not silently authenticae
8
+ * **Note:** There are caveats to using this in a private browser tab, which may not silently authenticate
9
9
  * a user on page refresh. Please see [the checkSession docs](https://auth0.github.io/auth0-spa-js/classes/Auth0Client.html#checksession) for more info.
10
10
  *
11
11
  * @param options The client options
@@ -1,2 +1,2 @@
1
- declare const _default: "2.16.0";
1
+ declare const _default: "2.17.1";
2
2
  export default _default;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "@auth0/auth0-spa-js",
4
4
  "description": "Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE",
5
5
  "license": "MIT",
6
- "version": "2.16.0",
6
+ "version": "2.17.1",
7
7
  "main": "dist/lib/auth0-spa-js.cjs.js",
8
8
  "types": "dist/typings/index.d.ts",
9
9
  "module": "dist/auth0-spa-js.production.esm.js",
@@ -23,10 +23,10 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@auth0/auth0-auth-js": "^1.4.0",
27
- "browser-tabs-lock": "^1.2.15",
28
- "dpop": "^2.1.1",
29
- "es-cookie": "~1.3.2"
26
+ "@auth0/auth0-auth-js": "1.5.0",
27
+ "browser-tabs-lock": "1.3.0",
28
+ "dpop": "2.1.1",
29
+ "es-cookie": "1.3.2"
30
30
  },
31
31
  "scripts": {
32
32
  "dev": "rimraf dist && rollup -c --watch",
@@ -61,11 +61,10 @@
61
61
  "@rollup/plugin-commonjs": "^21.1.0",
62
62
  "@rollup/plugin-node-resolve": "^16.0.3",
63
63
  "@rollup/plugin-replace": "^4.0.0",
64
- "@types/cypress": "^1.1.3",
65
64
  "@types/jest": "^28.1.7",
66
65
  "@typescript-eslint/eslint-plugin-tslint": "^5.33.1",
67
66
  "@typescript-eslint/parser": "^5.33.1",
68
- "browserstack-cypress-cli": "1.36.2",
67
+ "browserstack-cypress-cli": "1.36.3",
69
68
  "cli-table": "^0.3.6",
70
69
  "concurrently": "^7.3.0",
71
70
  "cypress": "13.17.0",
@@ -94,7 +93,7 @@
94
93
  "rollup-plugin-terser": "^7.0.2",
95
94
  "rollup-plugin-typescript2": "^0.36.0",
96
95
  "rollup-plugin-visualizer": "^5.7.1",
97
- "rollup-plugin-web-worker-loader": "^1.6.1",
96
+ "rollup-plugin-web-worker-loader": "~1.6.1",
98
97
  "serve": "^14.0.1",
99
98
  "ts-jest": "^28.0.8",
100
99
  "tslib": "^2.4.0",
@@ -57,6 +57,7 @@ import {
57
57
  DEFAULT_POPUP_CONFIG_OPTIONS,
58
58
  DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS,
59
59
  MISSING_REFRESH_TOKEN_ERROR_MESSAGE,
60
+ MFA_STEP_UP_ERROR_DESCRIPTION,
60
61
  DEFAULT_SCOPE,
61
62
  DEFAULT_SESSION_CHECK_EXPIRY_DAYS,
62
63
  DEFAULT_AUTH0_CLIENT,
@@ -926,10 +927,29 @@ export class Auth0Client {
926
927
 
927
928
  /**
928
929
  * Checks if an error should be handled by the interactive error handler.
929
- * Currently only handles mfa_required; extensible for future error types.
930
+ * Matches:
931
+ * - MfaRequiredError (refresh token path, error='mfa_required')
932
+ * - GenericError from iframe path (error='login_required',
933
+ * error_description='Multifactor authentication required')
934
+ * Extensible for future interactive error types.
930
935
  */
931
- private _isInteractiveError(error: unknown): error is MfaRequiredError {
932
- return error instanceof MfaRequiredError;
936
+ private _isInteractiveError(
937
+ error: unknown
938
+ ): error is MfaRequiredError | GenericError {
939
+ return error instanceof MfaRequiredError || (error instanceof GenericError && this._isIframeMfaError(error));
940
+ }
941
+
942
+ /**
943
+ * Checks if a login_required error from the iframe flow is actually
944
+ * an MFA step-up requirement. The /authorize endpoint returns
945
+ * error='login_required' with error_description='Multifactor authentication required'
946
+ * when MFA is needed but prompt=none prevents interaction.
947
+ */
948
+ private _isIframeMfaError(error: GenericError): boolean {
949
+ return (
950
+ error.error === 'login_required' &&
951
+ error.error_description === MFA_STEP_UP_ERROR_DESCRIPTION
952
+ );
933
953
  }
934
954
 
935
955
  /**
@@ -1207,9 +1227,19 @@ export class Auth0Client {
1207
1227
  );
1208
1228
  } catch (e) {
1209
1229
  if (e.error === 'login_required') {
1210
- this.logout({
1211
- openUrl: false
1212
- });
1230
+ // When the login_required error is actually an MFA step-up requirement
1231
+ // and the interactive error handler is configured, skip logout so the
1232
+ // session is preserved for the popup flow.
1233
+ const shouldSkipLogoutForMfaStepUp =
1234
+ e instanceof GenericError &&
1235
+ this._isIframeMfaError(e) &&
1236
+ this.options.interactiveErrorHandler === 'popup';
1237
+
1238
+ if (!shouldSkipLogoutForMfaStepUp) {
1239
+ this.logout({
1240
+ openUrl: false
1241
+ });
1242
+ }
1213
1243
  }
1214
1244
  throw e;
1215
1245
  }
package/src/constants.ts CHANGED
@@ -46,6 +46,13 @@ export const INVALID_REFRESH_TOKEN_ERROR_MESSAGE = 'invalid refresh token';
46
46
  */
47
47
  export const USER_BLOCKED_ERROR_MESSAGE = 'user is blocked';
48
48
 
49
+ /**
50
+ * @ignore
51
+ * The error_description returned by the /authorize endpoint when MFA is required
52
+ * but prompt=none prevents interaction (iframe silent auth flow).
53
+ */
54
+ export const MFA_STEP_UP_ERROR_DESCRIPTION = 'Multifactor authentication required';
55
+
49
56
  /**
50
57
  * @ignore
51
58
  */
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@ export * from './global';
8
8
  /**
9
9
  * Asynchronously creates the Auth0Client instance and calls `checkSession`.
10
10
  *
11
- * **Note:** There are caveats to using this in a private browser tab, which may not silently authenticae
11
+ * **Note:** There are caveats to using this in a private browser tab, which may not silently authenticate
12
12
  * a user on page refresh. Please see [the checkSession docs](https://auth0.github.io/auth0-spa-js/classes/Auth0Client.html#checksession) for more info.
13
13
  *
14
14
  * @param options The client options
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '2.16.0';
1
+ export default '2.17.1';