@auth0/auth0-spa-js 2.1.3 → 2.3.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 +24 -3
- 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 +24 -3
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/Auth0Client.d.ts +41 -1
- package/dist/typings/TokenExchange.d.ts +71 -0
- package/dist/typings/global.d.ts +2 -0
- package/dist/typings/scope.d.ts +6 -0
- package/dist/typings/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/Auth0Client.ts +84 -2
- package/src/TokenExchange.ts +75 -0
- package/src/api.ts +11 -2
- package/src/global.ts +2 -0
- package/src/scope.ts +6 -0
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ npm install @auth0/auth0-spa-js
|
|
|
29
29
|
From the CDN:
|
|
30
30
|
|
|
31
31
|
```html
|
|
32
|
-
<script src="https://cdn.auth0.com/js/auth0-spa-js/2.
|
|
32
|
+
<script src="https://cdn.auth0.com/js/auth0-spa-js/2.3/auth0-spa-js.production.js"></script>
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Configure Auth0
|
|
@@ -540,7 +540,7 @@
|
|
|
540
540
|
exports.default = SuperTokensLock;
|
|
541
541
|
}));
|
|
542
542
|
var Lock = unwrapExports(browserTabsLock);
|
|
543
|
-
var version = "2.
|
|
543
|
+
var version = "2.3.0";
|
|
544
544
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
545
545
|
const DEFAULT_POPUP_CONFIG_OPTIONS = {
|
|
546
546
|
timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
@@ -840,7 +840,13 @@
|
|
|
840
840
|
}
|
|
841
841
|
async function oauthToken(_a, worker) {
|
|
842
842
|
var {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData} = _a, options = __rest(_a, [ "baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData" ]);
|
|
843
|
-
const
|
|
843
|
+
const isTokenExchange = options.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
844
|
+
const allParams = Object.assign(Object.assign(Object.assign({}, options), isTokenExchange && audience && {
|
|
845
|
+
audience: audience
|
|
846
|
+
}), isTokenExchange && scope && {
|
|
847
|
+
scope: scope
|
|
848
|
+
});
|
|
849
|
+
const body = useFormData ? createQueryParams(allParams) : JSON.stringify(allParams);
|
|
844
850
|
return await getJSON(`${baseUrl}/oauth/token`, timeout, audience || "default", scope, {
|
|
845
851
|
method: "POST",
|
|
846
852
|
body: body,
|
|
@@ -1819,7 +1825,13 @@
|
|
|
1819
1825
|
throw new GenericError("login_required", "The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");
|
|
1820
1826
|
}
|
|
1821
1827
|
const authorizeTimeout = options.timeoutInSeconds || this.options.authorizeTimeoutInSeconds;
|
|
1822
|
-
|
|
1828
|
+
let eventOrigin;
|
|
1829
|
+
try {
|
|
1830
|
+
eventOrigin = new URL(this.domainUrl).origin;
|
|
1831
|
+
} catch (_a) {
|
|
1832
|
+
eventOrigin = this.domainUrl;
|
|
1833
|
+
}
|
|
1834
|
+
const codeResult = await runIframe(url, eventOrigin, authorizeTimeout);
|
|
1823
1835
|
if (stateIn !== codeResult.state) {
|
|
1824
1836
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
1825
1837
|
}
|
|
@@ -1951,6 +1963,15 @@
|
|
|
1951
1963
|
decodedToken: decodedToken
|
|
1952
1964
|
});
|
|
1953
1965
|
}
|
|
1966
|
+
async exchangeToken(options) {
|
|
1967
|
+
return this._requestToken({
|
|
1968
|
+
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
1969
|
+
subject_token: options.subject_token,
|
|
1970
|
+
subject_token_type: options.subject_token_type,
|
|
1971
|
+
scope: getUniqueScopes(options.scope, this.scope),
|
|
1972
|
+
audience: options.audience || this.options.authorizationParams.audience
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1954
1975
|
}
|
|
1955
1976
|
class User {}
|
|
1956
1977
|
async function createAuth0Client(options) {
|