@auth0/auth0-spa-js 2.15.0 → 2.16.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 +49 -21
- 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 +49 -21
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/Auth0Client.d.ts +10 -0
- package/dist/typings/global.d.ts +21 -0
- package/dist/typings/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Auth0Client.ts +81 -26
- package/src/global.ts +22 -0
- 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.16/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.16.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
|
|
@@ -7715,29 +7715,57 @@
|
|
|
7715
7715
|
return;
|
|
7716
7716
|
}
|
|
7717
7717
|
const lockKey = buildGetTokenSilentlyLockKey(this.options.clientId, getTokenOptions.authorizationParams.audience || "default");
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7718
|
+
try {
|
|
7719
|
+
return await this.lockManager.runWithLock(lockKey, 5e3, (async () => {
|
|
7720
|
+
if (cacheMode !== "off") {
|
|
7721
|
+
const entry = await this._getEntryFromCache({
|
|
7722
|
+
scope: getTokenOptions.authorizationParams.scope,
|
|
7723
|
+
audience: getTokenOptions.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
7724
|
+
clientId: this.options.clientId
|
|
7725
|
+
});
|
|
7726
|
+
if (entry) {
|
|
7727
|
+
return entry;
|
|
7728
|
+
}
|
|
7727
7729
|
}
|
|
7730
|
+
const authResult = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(getTokenOptions) : await this._getTokenFromIFrame(getTokenOptions);
|
|
7731
|
+
const {id_token: id_token, token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = authResult;
|
|
7732
|
+
return Object.assign(Object.assign({
|
|
7733
|
+
id_token: id_token,
|
|
7734
|
+
token_type: token_type,
|
|
7735
|
+
access_token: access_token
|
|
7736
|
+
}, oauthTokenScope ? {
|
|
7737
|
+
scope: oauthTokenScope
|
|
7738
|
+
} : null), {
|
|
7739
|
+
expires_in: expires_in
|
|
7740
|
+
});
|
|
7741
|
+
}));
|
|
7742
|
+
} catch (error) {
|
|
7743
|
+
if (this._isInteractiveError(error) && this.options.interactiveErrorHandler === "popup") {
|
|
7744
|
+
return await this._handleInteractiveErrorWithPopup(getTokenOptions);
|
|
7728
7745
|
}
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7746
|
+
throw error;
|
|
7747
|
+
}
|
|
7748
|
+
}
|
|
7749
|
+
_isInteractiveError(error) {
|
|
7750
|
+
return error instanceof MfaRequiredError;
|
|
7751
|
+
}
|
|
7752
|
+
async _handleInteractiveErrorWithPopup(options) {
|
|
7753
|
+
try {
|
|
7754
|
+
await this.loginWithPopup({
|
|
7755
|
+
authorizationParams: options.authorizationParams
|
|
7739
7756
|
});
|
|
7740
|
-
|
|
7757
|
+
const entry = await this._getEntryFromCache({
|
|
7758
|
+
scope: options.authorizationParams.scope,
|
|
7759
|
+
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
7760
|
+
clientId: this.options.clientId
|
|
7761
|
+
});
|
|
7762
|
+
if (!entry) {
|
|
7763
|
+
throw new GenericError("interactive_handler_cache_miss", "Token not found in cache after interactive authentication");
|
|
7764
|
+
}
|
|
7765
|
+
return entry;
|
|
7766
|
+
} catch (error) {
|
|
7767
|
+
throw error;
|
|
7768
|
+
}
|
|
7741
7769
|
}
|
|
7742
7770
|
async getTokenWithPopup() {
|
|
7743
7771
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|