@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
|
@@ -18,7 +18,7 @@ typeof SuppressedError === "function" ? SuppressedError : function(error, suppre
|
|
|
18
18
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
var version = "2.
|
|
21
|
+
var version = "2.16.0";
|
|
22
22
|
|
|
23
23
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
24
24
|
|
|
@@ -8293,29 +8293,57 @@ class Auth0Client {
|
|
|
8293
8293
|
return;
|
|
8294
8294
|
}
|
|
8295
8295
|
const lockKey = buildGetTokenSilentlyLockKey(this.options.clientId, getTokenOptions.authorizationParams.audience || "default");
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8296
|
+
try {
|
|
8297
|
+
return await this.lockManager.runWithLock(lockKey, 5e3, (async () => {
|
|
8298
|
+
if (cacheMode !== "off") {
|
|
8299
|
+
const entry = await this._getEntryFromCache({
|
|
8300
|
+
scope: getTokenOptions.authorizationParams.scope,
|
|
8301
|
+
audience: getTokenOptions.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
8302
|
+
clientId: this.options.clientId
|
|
8303
|
+
});
|
|
8304
|
+
if (entry) {
|
|
8305
|
+
return entry;
|
|
8306
|
+
}
|
|
8305
8307
|
}
|
|
8308
|
+
const authResult = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(getTokenOptions) : await this._getTokenFromIFrame(getTokenOptions);
|
|
8309
|
+
const {id_token: id_token, token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = authResult;
|
|
8310
|
+
return Object.assign(Object.assign({
|
|
8311
|
+
id_token: id_token,
|
|
8312
|
+
token_type: token_type,
|
|
8313
|
+
access_token: access_token
|
|
8314
|
+
}, oauthTokenScope ? {
|
|
8315
|
+
scope: oauthTokenScope
|
|
8316
|
+
} : null), {
|
|
8317
|
+
expires_in: expires_in
|
|
8318
|
+
});
|
|
8319
|
+
}));
|
|
8320
|
+
} catch (error) {
|
|
8321
|
+
if (this._isInteractiveError(error) && this.options.interactiveErrorHandler === "popup") {
|
|
8322
|
+
return await this._handleInteractiveErrorWithPopup(getTokenOptions);
|
|
8306
8323
|
}
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8324
|
+
throw error;
|
|
8325
|
+
}
|
|
8326
|
+
}
|
|
8327
|
+
_isInteractiveError(error) {
|
|
8328
|
+
return error instanceof MfaRequiredError;
|
|
8329
|
+
}
|
|
8330
|
+
async _handleInteractiveErrorWithPopup(options) {
|
|
8331
|
+
try {
|
|
8332
|
+
await this.loginWithPopup({
|
|
8333
|
+
authorizationParams: options.authorizationParams
|
|
8317
8334
|
});
|
|
8318
|
-
|
|
8335
|
+
const entry = await this._getEntryFromCache({
|
|
8336
|
+
scope: options.authorizationParams.scope,
|
|
8337
|
+
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
8338
|
+
clientId: this.options.clientId
|
|
8339
|
+
});
|
|
8340
|
+
if (!entry) {
|
|
8341
|
+
throw new GenericError("interactive_handler_cache_miss", "Token not found in cache after interactive authentication");
|
|
8342
|
+
}
|
|
8343
|
+
return entry;
|
|
8344
|
+
} catch (error) {
|
|
8345
|
+
throw error;
|
|
8346
|
+
}
|
|
8319
8347
|
}
|
|
8320
8348
|
async getTokenWithPopup() {
|
|
8321
8349
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|