@auth0/auth0-spa-js 2.15.0 → 2.17.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/README.md +1 -1
- package/dist/auth0-spa-js.development.js +59 -24
- package/dist/auth0-spa-js.development.js.map +1 -1
- package/dist/auth0-spa-js.production.esm.js +1 -1
- package/dist/auth0-spa-js.production.esm.js.map +1 -1
- package/dist/auth0-spa-js.production.js +1 -1
- package/dist/auth0-spa-js.production.js.map +1 -1
- package/dist/lib/auth0-spa-js.cjs.js +60 -24
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/Auth0Client.d.ts +21 -0
- package/dist/typings/constants.d.ts +6 -0
- package/dist/typings/global.d.ts +21 -0
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Auth0Client.ts +114 -29
- package/src/constants.ts +7 -0
- package/src/global.ts +22 -0
- package/src/index.ts +1 -1
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ npm install @auth0/auth0-spa-js
|
|
|
30
30
|
From the CDN:
|
|
31
31
|
|
|
32
32
|
```html
|
|
33
|
-
<script src="https://cdn.auth0.com/js/auth0-spa-js/2.
|
|
33
|
+
<script src="https://cdn.auth0.com/js/auth0-spa-js/2.17/auth0-spa-js.production.js"></script>
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### Configure Auth0
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
var e = new Error(message);
|
|
16
16
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
17
17
|
};
|
|
18
|
-
var version = "2.
|
|
18
|
+
var version = "2.17.0";
|
|
19
19
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
20
20
|
const DEFAULT_POPUP_CONFIG_OPTIONS = {
|
|
21
21
|
timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
const MISSING_REFRESH_TOKEN_ERROR_MESSAGE = "Missing Refresh Token";
|
|
28
28
|
const INVALID_REFRESH_TOKEN_ERROR_MESSAGE = "invalid refresh token";
|
|
29
29
|
const USER_BLOCKED_ERROR_MESSAGE = "user is blocked";
|
|
30
|
+
const MFA_STEP_UP_ERROR_DESCRIPTION = "Multifactor authentication required";
|
|
30
31
|
const DEFAULT_SCOPE = "openid profile email";
|
|
31
32
|
const DEFAULT_SESSION_CHECK_EXPIRY_DAYS = 1;
|
|
32
33
|
const DEFAULT_AUTH0_CLIENT = {
|
|
@@ -7715,29 +7716,60 @@
|
|
|
7715
7716
|
return;
|
|
7716
7717
|
}
|
|
7717
7718
|
const lockKey = buildGetTokenSilentlyLockKey(this.options.clientId, getTokenOptions.authorizationParams.audience || "default");
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7719
|
+
try {
|
|
7720
|
+
return await this.lockManager.runWithLock(lockKey, 5e3, (async () => {
|
|
7721
|
+
if (cacheMode !== "off") {
|
|
7722
|
+
const entry = await this._getEntryFromCache({
|
|
7723
|
+
scope: getTokenOptions.authorizationParams.scope,
|
|
7724
|
+
audience: getTokenOptions.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
7725
|
+
clientId: this.options.clientId
|
|
7726
|
+
});
|
|
7727
|
+
if (entry) {
|
|
7728
|
+
return entry;
|
|
7729
|
+
}
|
|
7727
7730
|
}
|
|
7731
|
+
const authResult = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(getTokenOptions) : await this._getTokenFromIFrame(getTokenOptions);
|
|
7732
|
+
const {id_token: id_token, token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = authResult;
|
|
7733
|
+
return Object.assign(Object.assign({
|
|
7734
|
+
id_token: id_token,
|
|
7735
|
+
token_type: token_type,
|
|
7736
|
+
access_token: access_token
|
|
7737
|
+
}, oauthTokenScope ? {
|
|
7738
|
+
scope: oauthTokenScope
|
|
7739
|
+
} : null), {
|
|
7740
|
+
expires_in: expires_in
|
|
7741
|
+
});
|
|
7742
|
+
}));
|
|
7743
|
+
} catch (error) {
|
|
7744
|
+
if (this._isInteractiveError(error) && this.options.interactiveErrorHandler === "popup") {
|
|
7745
|
+
return await this._handleInteractiveErrorWithPopup(getTokenOptions);
|
|
7728
7746
|
}
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7747
|
+
throw error;
|
|
7748
|
+
}
|
|
7749
|
+
}
|
|
7750
|
+
_isInteractiveError(error) {
|
|
7751
|
+
return error instanceof MfaRequiredError || error instanceof GenericError && this._isIframeMfaError(error);
|
|
7752
|
+
}
|
|
7753
|
+
_isIframeMfaError(error) {
|
|
7754
|
+
return error.error === "login_required" && error.error_description === MFA_STEP_UP_ERROR_DESCRIPTION;
|
|
7755
|
+
}
|
|
7756
|
+
async _handleInteractiveErrorWithPopup(options) {
|
|
7757
|
+
try {
|
|
7758
|
+
await this.loginWithPopup({
|
|
7759
|
+
authorizationParams: options.authorizationParams
|
|
7739
7760
|
});
|
|
7740
|
-
|
|
7761
|
+
const entry = await this._getEntryFromCache({
|
|
7762
|
+
scope: options.authorizationParams.scope,
|
|
7763
|
+
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
7764
|
+
clientId: this.options.clientId
|
|
7765
|
+
});
|
|
7766
|
+
if (!entry) {
|
|
7767
|
+
throw new GenericError("interactive_handler_cache_miss", "Token not found in cache after interactive authentication");
|
|
7768
|
+
}
|
|
7769
|
+
return entry;
|
|
7770
|
+
} catch (error) {
|
|
7771
|
+
throw error;
|
|
7772
|
+
}
|
|
7741
7773
|
}
|
|
7742
7774
|
async getTokenWithPopup() {
|
|
7743
7775
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -7844,9 +7876,12 @@
|
|
|
7844
7876
|
}));
|
|
7845
7877
|
} catch (e) {
|
|
7846
7878
|
if (e.error === "login_required") {
|
|
7847
|
-
this.
|
|
7848
|
-
|
|
7849
|
-
|
|
7879
|
+
const shouldSkipLogoutForMfaStepUp = e instanceof GenericError && this._isIframeMfaError(e) && this.options.interactiveErrorHandler === "popup";
|
|
7880
|
+
if (!shouldSkipLogoutForMfaStepUp) {
|
|
7881
|
+
this.logout({
|
|
7882
|
+
openUrl: false
|
|
7883
|
+
});
|
|
7884
|
+
}
|
|
7850
7885
|
}
|
|
7851
7886
|
throw e;
|
|
7852
7887
|
}
|