@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
package/README.md
CHANGED
|
@@ -120,10 +120,10 @@ For other comprehensive examples, see the [EXAMPLES.md](https://github.com/auth0
|
|
|
120
120
|
|
|
121
121
|
Explore API Methods available in auth0-spa-js.
|
|
122
122
|
|
|
123
|
-
- [Configuration Options](https://auth0.github.io/auth0-spa-js/interfaces/
|
|
123
|
+
- [Configuration Options](https://auth0.github.io/auth0-spa-js/interfaces/Auth0ClientOptions.html)
|
|
124
124
|
|
|
125
|
-
- [Auth0Client](https://auth0.github.io/auth0-spa-js/classes/
|
|
126
|
-
- [createAuth0Client](https://auth0.github.io/auth0-spa-js/
|
|
125
|
+
- [Auth0Client](https://auth0.github.io/auth0-spa-js/classes/Auth0Client.html)
|
|
126
|
+
- [createAuth0Client](https://auth0.github.io/auth0-spa-js/functions/createAuth0Client.html)
|
|
127
127
|
|
|
128
128
|
## Feedback
|
|
129
129
|
|
|
@@ -472,7 +472,7 @@
|
|
|
472
472
|
exports.default = SuperTokensLock;
|
|
473
473
|
}));
|
|
474
474
|
var Lock = unwrapExports(browserTabsLock);
|
|
475
|
-
var version = "2.0.
|
|
475
|
+
var version = "2.0.2";
|
|
476
476
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
477
477
|
const DEFAULT_POPUP_CONFIG_OPTIONS = {
|
|
478
478
|
timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
@@ -547,20 +547,17 @@
|
|
|
547
547
|
function valueOrEmptyString(value, exclude = []) {
|
|
548
548
|
return value && !exclude.includes(value) ? value : "";
|
|
549
549
|
}
|
|
550
|
-
const
|
|
550
|
+
const parseAuthenticationResult = queryString => {
|
|
551
551
|
if (queryString.indexOf("#") > -1) {
|
|
552
|
-
queryString = queryString.
|
|
552
|
+
queryString = queryString.substring(0, queryString.indexOf("#"));
|
|
553
553
|
}
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
parsedQuery.expires_in = parseInt(parsedQuery.expires_in);
|
|
562
|
-
}
|
|
563
|
-
return parsedQuery;
|
|
554
|
+
const searchParams = new URLSearchParams(queryString);
|
|
555
|
+
return {
|
|
556
|
+
state: searchParams.get("state"),
|
|
557
|
+
code: searchParams.get("code") || undefined,
|
|
558
|
+
error: searchParams.get("error") || undefined,
|
|
559
|
+
error_description: searchParams.get("error_description") || undefined
|
|
560
|
+
};
|
|
564
561
|
};
|
|
565
562
|
const runIframe = (authorizeUrl, eventOrigin, timeoutInSeconds = DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) => new Promise(((res, rej) => {
|
|
566
563
|
const iframe = window.document.createElement("iframe");
|
|
@@ -1386,6 +1383,13 @@
|
|
|
1386
1383
|
code_challenge: code_challenge,
|
|
1387
1384
|
code_challenge_method: "S256"
|
|
1388
1385
|
});
|
|
1386
|
+
const patchOpenUrlWithOnRedirect = options => {
|
|
1387
|
+
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions = __rest(options, [ "openUrl", "onRedirect" ]);
|
|
1388
|
+
const result = Object.assign(Object.assign({}, originalOptions), {
|
|
1389
|
+
openUrl: openUrl === false || openUrl ? openUrl : onRedirect
|
|
1390
|
+
});
|
|
1391
|
+
return result;
|
|
1392
|
+
};
|
|
1389
1393
|
const lock = new Lock;
|
|
1390
1394
|
class Auth0Client {
|
|
1391
1395
|
constructor(options) {
|
|
@@ -1530,17 +1534,17 @@
|
|
|
1530
1534
|
}
|
|
1531
1535
|
async loginWithRedirect(options = {}) {
|
|
1532
1536
|
var _a;
|
|
1533
|
-
const {
|
|
1537
|
+
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl, fragment: fragment, appState: appState} = _b, urlOptions = __rest(_b, [ "openUrl", "fragment", "appState" ]);
|
|
1534
1538
|
const organizationId = ((_a = urlOptions.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
|
|
1535
|
-
const
|
|
1539
|
+
const _c = await this._prepareAuthorizeUrl(urlOptions.authorizationParams || {}), {url: url} = _c, transaction = __rest(_c, [ "url" ]);
|
|
1536
1540
|
this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, transaction), {
|
|
1537
1541
|
appState: appState
|
|
1538
1542
|
}), organizationId && {
|
|
1539
1543
|
organizationId: organizationId
|
|
1540
1544
|
}));
|
|
1541
1545
|
const urlWithFragment = fragment ? `${url}#${fragment}` : url;
|
|
1542
|
-
if (
|
|
1543
|
-
await
|
|
1546
|
+
if (openUrl) {
|
|
1547
|
+
await openUrl(urlWithFragment);
|
|
1544
1548
|
} else {
|
|
1545
1549
|
window.location.assign(urlWithFragment);
|
|
1546
1550
|
}
|
|
@@ -1550,7 +1554,7 @@
|
|
|
1550
1554
|
if (queryStringFragments.length === 0) {
|
|
1551
1555
|
throw new Error("There are no query params available for parsing.");
|
|
1552
1556
|
}
|
|
1553
|
-
const {state: state, code: code, error: error, error_description: error_description} =
|
|
1557
|
+
const {state: state, code: code, error: error, error_description: error_description} = parseAuthenticationResult(queryStringFragments.join(""));
|
|
1554
1558
|
const transaction = this.transactionManager.get();
|
|
1555
1559
|
if (!transaction) {
|
|
1556
1560
|
throw new Error("Invalid state");
|
|
@@ -1689,7 +1693,7 @@
|
|
|
1689
1693
|
return url + federatedQuery;
|
|
1690
1694
|
}
|
|
1691
1695
|
async logout(options = {}) {
|
|
1692
|
-
const {
|
|
1696
|
+
const _a = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _a, logoutOptions = __rest(_a, [ "openUrl" ]);
|
|
1693
1697
|
await this.cacheManager.clear();
|
|
1694
1698
|
this.cookieStorage.remove(this.orgHintCookieName, {
|
|
1695
1699
|
cookieDomain: this.options.cookieDomain
|
|
@@ -1699,9 +1703,9 @@
|
|
|
1699
1703
|
});
|
|
1700
1704
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
1701
1705
|
const url = this._buildLogoutUrl(logoutOptions);
|
|
1702
|
-
if (
|
|
1703
|
-
await
|
|
1704
|
-
} else {
|
|
1706
|
+
if (openUrl) {
|
|
1707
|
+
await openUrl(url);
|
|
1708
|
+
} else if (openUrl !== false) {
|
|
1705
1709
|
window.location.assign(url);
|
|
1706
1710
|
}
|
|
1707
1711
|
}
|
|
@@ -1742,7 +1746,7 @@
|
|
|
1742
1746
|
} catch (e) {
|
|
1743
1747
|
if (e.error === "login_required") {
|
|
1744
1748
|
this.logout({
|
|
1745
|
-
|
|
1749
|
+
openUrl: false
|
|
1746
1750
|
});
|
|
1747
1751
|
}
|
|
1748
1752
|
throw e;
|
|
@@ -1866,6 +1870,7 @@
|
|
|
1866
1870
|
exports.InMemoryCache = InMemoryCache;
|
|
1867
1871
|
exports.LocalStorageCache = LocalStorageCache;
|
|
1868
1872
|
exports.MfaRequiredError = MfaRequiredError;
|
|
1873
|
+
exports.MissingRefreshTokenError = MissingRefreshTokenError;
|
|
1869
1874
|
exports.PopupCancelledError = PopupCancelledError;
|
|
1870
1875
|
exports.PopupTimeoutError = PopupTimeoutError;
|
|
1871
1876
|
exports.TimeoutError = TimeoutError;
|