@auth0/auth0-spa-js 2.0.0 → 2.0.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.
- package/README.md +3 -3
- package/dist/auth0-spa-js.development.js +28 -23
- 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 +30 -23
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/Auth0Client.utils.d.ts +7 -1
- package/dist/typings/errors.d.ts +3 -0
- package/dist/typings/global.d.ts +26 -0
- package/dist/typings/index.d.ts +2 -2
- package/dist/typings/utils.d.ts +1 -1
- package/dist/typings/version.d.ts +1 -1
- package/package.json +5 -6
- package/src/Auth0Client.ts +13 -11
- package/src/Auth0Client.utils.ts +22 -1
- package/src/errors.ts +3 -0
- package/src/global.ts +28 -0
- package/src/index.ts +3 -2
- package/src/utils.ts +11 -14
- package/src/version.ts +1 -1
|
@@ -481,7 +481,7 @@ var browserTabsLock = createCommonjsModule((function(module, exports) {
|
|
|
481
481
|
|
|
482
482
|
var Lock = unwrapExports(browserTabsLock);
|
|
483
483
|
|
|
484
|
-
var version = "2.0.
|
|
484
|
+
var version = "2.0.2";
|
|
485
485
|
|
|
486
486
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
487
487
|
|
|
@@ -577,20 +577,17 @@ function valueOrEmptyString(value, exclude = []) {
|
|
|
577
577
|
return value && !exclude.includes(value) ? value : "";
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
-
const
|
|
580
|
+
const parseAuthenticationResult = queryString => {
|
|
581
581
|
if (queryString.indexOf("#") > -1) {
|
|
582
|
-
queryString = queryString.
|
|
582
|
+
queryString = queryString.substring(0, queryString.indexOf("#"));
|
|
583
583
|
}
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
parsedQuery.expires_in = parseInt(parsedQuery.expires_in);
|
|
592
|
-
}
|
|
593
|
-
return parsedQuery;
|
|
584
|
+
const searchParams = new URLSearchParams(queryString);
|
|
585
|
+
return {
|
|
586
|
+
state: searchParams.get("state"),
|
|
587
|
+
code: searchParams.get("code") || undefined,
|
|
588
|
+
error: searchParams.get("error") || undefined,
|
|
589
|
+
error_description: searchParams.get("error_description") || undefined
|
|
590
|
+
};
|
|
594
591
|
};
|
|
595
592
|
|
|
596
593
|
const runIframe = (authorizeUrl, eventOrigin, timeoutInSeconds = DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) => new Promise(((res, rej) => {
|
|
@@ -1484,6 +1481,14 @@ const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, no
|
|
|
1484
1481
|
code_challenge_method: "S256"
|
|
1485
1482
|
});
|
|
1486
1483
|
|
|
1484
|
+
const patchOpenUrlWithOnRedirect = options => {
|
|
1485
|
+
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions = __rest(options, [ "openUrl", "onRedirect" ]);
|
|
1486
|
+
const result = Object.assign(Object.assign({}, originalOptions), {
|
|
1487
|
+
openUrl: openUrl === false || openUrl ? openUrl : onRedirect
|
|
1488
|
+
});
|
|
1489
|
+
return result;
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1487
1492
|
const lock = new Lock;
|
|
1488
1493
|
|
|
1489
1494
|
class Auth0Client {
|
|
@@ -1629,17 +1634,17 @@ class Auth0Client {
|
|
|
1629
1634
|
}
|
|
1630
1635
|
async loginWithRedirect(options = {}) {
|
|
1631
1636
|
var _a;
|
|
1632
|
-
const {
|
|
1637
|
+
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl, fragment: fragment, appState: appState} = _b, urlOptions = __rest(_b, [ "openUrl", "fragment", "appState" ]);
|
|
1633
1638
|
const organizationId = ((_a = urlOptions.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
|
|
1634
|
-
const
|
|
1639
|
+
const _c = await this._prepareAuthorizeUrl(urlOptions.authorizationParams || {}), {url: url} = _c, transaction = __rest(_c, [ "url" ]);
|
|
1635
1640
|
this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, transaction), {
|
|
1636
1641
|
appState: appState
|
|
1637
1642
|
}), organizationId && {
|
|
1638
1643
|
organizationId: organizationId
|
|
1639
1644
|
}));
|
|
1640
1645
|
const urlWithFragment = fragment ? `${url}#${fragment}` : url;
|
|
1641
|
-
if (
|
|
1642
|
-
await
|
|
1646
|
+
if (openUrl) {
|
|
1647
|
+
await openUrl(urlWithFragment);
|
|
1643
1648
|
} else {
|
|
1644
1649
|
window.location.assign(urlWithFragment);
|
|
1645
1650
|
}
|
|
@@ -1649,7 +1654,7 @@ class Auth0Client {
|
|
|
1649
1654
|
if (queryStringFragments.length === 0) {
|
|
1650
1655
|
throw new Error("There are no query params available for parsing.");
|
|
1651
1656
|
}
|
|
1652
|
-
const {state: state, code: code, error: error, error_description: error_description} =
|
|
1657
|
+
const {state: state, code: code, error: error, error_description: error_description} = parseAuthenticationResult(queryStringFragments.join(""));
|
|
1653
1658
|
const transaction = this.transactionManager.get();
|
|
1654
1659
|
if (!transaction) {
|
|
1655
1660
|
throw new Error("Invalid state");
|
|
@@ -1788,7 +1793,7 @@ class Auth0Client {
|
|
|
1788
1793
|
return url + federatedQuery;
|
|
1789
1794
|
}
|
|
1790
1795
|
async logout(options = {}) {
|
|
1791
|
-
const {
|
|
1796
|
+
const _a = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _a, logoutOptions = __rest(_a, [ "openUrl" ]);
|
|
1792
1797
|
await this.cacheManager.clear();
|
|
1793
1798
|
this.cookieStorage.remove(this.orgHintCookieName, {
|
|
1794
1799
|
cookieDomain: this.options.cookieDomain
|
|
@@ -1798,9 +1803,9 @@ class Auth0Client {
|
|
|
1798
1803
|
});
|
|
1799
1804
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
1800
1805
|
const url = this._buildLogoutUrl(logoutOptions);
|
|
1801
|
-
if (
|
|
1802
|
-
await
|
|
1803
|
-
} else {
|
|
1806
|
+
if (openUrl) {
|
|
1807
|
+
await openUrl(url);
|
|
1808
|
+
} else if (openUrl !== false) {
|
|
1804
1809
|
window.location.assign(url);
|
|
1805
1810
|
}
|
|
1806
1811
|
}
|
|
@@ -1841,7 +1846,7 @@ class Auth0Client {
|
|
|
1841
1846
|
} catch (e) {
|
|
1842
1847
|
if (e.error === "login_required") {
|
|
1843
1848
|
this.logout({
|
|
1844
|
-
|
|
1849
|
+
openUrl: false
|
|
1845
1850
|
});
|
|
1846
1851
|
}
|
|
1847
1852
|
throw e;
|
|
@@ -1975,6 +1980,8 @@ exports.LocalStorageCache = LocalStorageCache;
|
|
|
1975
1980
|
|
|
1976
1981
|
exports.MfaRequiredError = MfaRequiredError;
|
|
1977
1982
|
|
|
1983
|
+
exports.MissingRefreshTokenError = MissingRefreshTokenError;
|
|
1984
|
+
|
|
1978
1985
|
exports.PopupCancelledError = PopupCancelledError;
|
|
1979
1986
|
|
|
1980
1987
|
exports.PopupTimeoutError = PopupTimeoutError;
|