@globus/sdk 3.0.0-alpha.8 → 3.0.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/cjs/index.d.ts +1 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +2 -1
- package/cjs/index.js.map +1 -1
- package/cjs/lib/core/authorization/AuthorizationManager.d.ts +66 -12
- package/cjs/lib/core/authorization/AuthorizationManager.d.ts.map +1 -1
- package/cjs/lib/core/authorization/AuthorizationManager.js +133 -30
- package/cjs/lib/core/authorization/AuthorizationManager.js.map +1 -1
- package/cjs/lib/core/authorization/Event.d.ts +6 -1
- package/cjs/lib/core/authorization/Event.d.ts.map +1 -1
- package/cjs/lib/core/authorization/Event.js +3 -0
- package/cjs/lib/core/authorization/Event.js.map +1 -1
- package/cjs/lib/core/authorization/RedirectTransport.d.ts +12 -1
- package/cjs/lib/core/authorization/RedirectTransport.d.ts.map +1 -1
- package/cjs/lib/core/authorization/RedirectTransport.js +23 -5
- package/cjs/lib/core/authorization/RedirectTransport.js.map +1 -1
- package/cjs/lib/core/authorization/TokenLookup.d.ts +6 -1
- package/cjs/lib/core/authorization/TokenLookup.d.ts.map +1 -1
- package/cjs/lib/core/authorization/TokenLookup.js +40 -5
- package/cjs/lib/core/authorization/TokenLookup.js.map +1 -1
- package/cjs/lib/core/authorization/tokens.d.ts +1 -0
- package/cjs/lib/core/authorization/tokens.d.ts.map +1 -1
- package/cjs/lib/core/authorization/tokens.js +3 -1
- package/cjs/lib/core/authorization/tokens.js.map +1 -1
- package/cjs/lib/core/errors.d.ts.map +1 -1
- package/cjs/lib/core/errors.js +8 -2
- package/cjs/lib/core/errors.js.map +1 -1
- package/cjs/lib/core/global.d.ts +8 -6
- package/cjs/lib/core/global.d.ts.map +1 -1
- package/cjs/lib/core/global.js +3 -0
- package/cjs/lib/core/global.js.map +1 -1
- package/cjs/lib/core/logger.d.ts +2 -2
- package/cjs/lib/core/logger.d.ts.map +1 -1
- package/cjs/lib/core/logger.js +3 -3
- package/cjs/lib/core/logger.js.map +1 -1
- package/cjs/lib/core/storage/local-storage.js +1 -1
- package/cjs/lib/core/storage/local-storage.js.map +1 -1
- package/cjs/lib/core/storage/memory.d.ts +1 -1
- package/cjs/lib/core/storage/memory.d.ts.map +1 -1
- package/cjs/lib/core/storage/memory.js +2 -2
- package/cjs/lib/core/storage/memory.js.map +1 -1
- package/cjs/lib/services/auth/config.d.ts +5 -1
- package/cjs/lib/services/auth/config.d.ts.map +1 -1
- package/cjs/lib/services/auth/config.js +8 -0
- package/cjs/lib/services/auth/config.js.map +1 -1
- package/cjs/lib/services/auth/index.d.ts +3 -16
- package/cjs/lib/services/auth/index.d.ts.map +1 -1
- package/cjs/lib/services/auth/index.js +13 -2
- package/cjs/lib/services/auth/index.js.map +1 -1
- package/cjs/lib/services/auth/service/oauth2/index.d.ts +3 -0
- package/cjs/lib/services/auth/service/oauth2/index.d.ts.map +1 -1
- package/cjs/lib/services/auth/service/oauth2/index.js +11 -1
- package/cjs/lib/services/auth/service/oauth2/index.js.map +1 -1
- package/cjs/lib/services/auth/service/oauth2/token.d.ts +19 -1
- package/cjs/lib/services/auth/service/oauth2/token.d.ts.map +1 -1
- package/cjs/lib/services/auth/service/oauth2/token.js +16 -1
- package/cjs/lib/services/auth/service/oauth2/token.js.map +1 -1
- package/cjs/lib/services/auth/types.d.ts +40 -12
- package/cjs/lib/services/auth/types.d.ts.map +1 -1
- package/cjs/lib/services/compute/config.d.ts +7 -0
- package/cjs/lib/services/compute/config.d.ts.map +1 -0
- package/cjs/lib/services/compute/config.js +16 -0
- package/cjs/lib/services/compute/config.js.map +1 -0
- package/cjs/lib/services/compute/index.d.ts +14 -0
- package/cjs/lib/services/compute/index.d.ts.map +1 -0
- package/cjs/lib/services/compute/index.js +18 -0
- package/cjs/lib/services/compute/index.js.map +1 -0
- package/cjs/lib/services/compute/service/endpoints.d.ts +24 -0
- package/cjs/lib/services/compute/service/endpoints.d.ts.map +1 -0
- package/cjs/lib/services/compute/service/endpoints.js +29 -0
- package/cjs/lib/services/compute/service/endpoints.js.map +1 -0
- package/cjs/lib/services/flows/config.d.ts +1 -1
- package/cjs/lib/services/flows/config.d.ts.map +1 -1
- package/cjs/lib/services/flows/config.js.map +1 -1
- package/cjs/lib/services/globus-connect-server/client.d.ts +443 -88
- package/cjs/lib/services/globus-connect-server/client.d.ts.map +1 -1
- package/cjs/lib/services/groups/config.d.ts +1 -1
- package/cjs/lib/services/groups/config.d.ts.map +1 -1
- package/cjs/lib/services/groups/config.js.map +1 -1
- package/cjs/lib/services/search/config.d.ts +1 -1
- package/cjs/lib/services/search/config.d.ts.map +1 -1
- package/cjs/lib/services/search/config.js.map +1 -1
- package/cjs/lib/services/timer/config.d.ts +1 -1
- package/cjs/lib/services/timer/config.d.ts.map +1 -1
- package/cjs/lib/services/timer/config.js.map +1 -1
- package/cjs/lib/services/transfer/config.d.ts +1 -1
- package/cjs/lib/services/transfer/config.d.ts.map +1 -1
- package/cjs/lib/services/transfer/config.js.map +1 -1
- package/cjs/lib/services/transfer/index.d.ts +1 -0
- package/cjs/lib/services/transfer/index.d.ts.map +1 -1
- package/cjs/lib/services/transfer/index.js +2 -1
- package/cjs/lib/services/transfer/index.js.map +1 -1
- package/cjs/lib/services/transfer/service/collection-bookmarks.d.ts +64 -0
- package/cjs/lib/services/transfer/service/collection-bookmarks.d.ts.map +1 -0
- package/cjs/lib/services/transfer/service/collection-bookmarks.js +59 -0
- package/cjs/lib/services/transfer/service/collection-bookmarks.js.map +1 -0
- package/cjs/lib/services/transfer/service/endpoint.d.ts +127 -13
- package/cjs/lib/services/transfer/service/endpoint.d.ts.map +1 -1
- package/cjs/lib/services/transfer/service/endpoint.js +40 -1
- package/cjs/lib/services/transfer/service/endpoint.js.map +1 -1
- package/cjs/lib/services/transfer/service/task.d.ts +1 -1
- package/cjs/lib/services/transfer/types.d.ts +215 -0
- package/cjs/lib/services/transfer/types.d.ts.map +1 -1
- package/cjs/lib/services/types.d.ts +4 -0
- package/cjs/lib/services/types.d.ts.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/lib/core/authorization/AuthorizationManager.d.ts +66 -12
- package/esm/lib/core/authorization/AuthorizationManager.d.ts.map +1 -1
- package/esm/lib/core/authorization/AuthorizationManager.js +134 -31
- package/esm/lib/core/authorization/AuthorizationManager.js.map +1 -1
- package/esm/lib/core/authorization/Event.d.ts +6 -1
- package/esm/lib/core/authorization/Event.d.ts.map +1 -1
- package/esm/lib/core/authorization/Event.js +3 -0
- package/esm/lib/core/authorization/Event.js.map +1 -1
- package/esm/lib/core/authorization/RedirectTransport.d.ts +12 -1
- package/esm/lib/core/authorization/RedirectTransport.d.ts.map +1 -1
- package/esm/lib/core/authorization/RedirectTransport.js +23 -5
- package/esm/lib/core/authorization/RedirectTransport.js.map +1 -1
- package/esm/lib/core/authorization/TokenLookup.d.ts +6 -1
- package/esm/lib/core/authorization/TokenLookup.d.ts.map +1 -1
- package/esm/lib/core/authorization/TokenLookup.js +41 -6
- package/esm/lib/core/authorization/TokenLookup.js.map +1 -1
- package/esm/lib/core/authorization/tokens.d.ts +1 -0
- package/esm/lib/core/authorization/tokens.d.ts.map +1 -1
- package/esm/lib/core/authorization/tokens.js +3 -1
- package/esm/lib/core/authorization/tokens.js.map +1 -1
- package/esm/lib/core/errors.d.ts.map +1 -1
- package/esm/lib/core/errors.js +8 -2
- package/esm/lib/core/errors.js.map +1 -1
- package/esm/lib/core/global.d.ts +8 -6
- package/esm/lib/core/global.d.ts.map +1 -1
- package/esm/lib/core/global.js +3 -0
- package/esm/lib/core/global.js.map +1 -1
- package/esm/lib/core/logger.d.ts +2 -2
- package/esm/lib/core/logger.d.ts.map +1 -1
- package/esm/lib/core/logger.js +3 -3
- package/esm/lib/core/logger.js.map +1 -1
- package/esm/lib/core/storage/local-storage.js +1 -1
- package/esm/lib/core/storage/local-storage.js.map +1 -1
- package/esm/lib/core/storage/memory.d.ts +1 -1
- package/esm/lib/core/storage/memory.d.ts.map +1 -1
- package/esm/lib/core/storage/memory.js +2 -2
- package/esm/lib/core/storage/memory.js.map +1 -1
- package/esm/lib/services/auth/config.d.ts +5 -1
- package/esm/lib/services/auth/config.d.ts.map +1 -1
- package/esm/lib/services/auth/config.js +8 -0
- package/esm/lib/services/auth/config.js.map +1 -1
- package/esm/lib/services/auth/index.d.ts +3 -16
- package/esm/lib/services/auth/index.d.ts.map +1 -1
- package/esm/lib/services/auth/index.js +10 -1
- package/esm/lib/services/auth/index.js.map +1 -1
- package/esm/lib/services/auth/service/oauth2/index.d.ts +3 -0
- package/esm/lib/services/auth/service/oauth2/index.d.ts.map +1 -1
- package/esm/lib/services/auth/service/oauth2/index.js +10 -0
- package/esm/lib/services/auth/service/oauth2/index.js.map +1 -1
- package/esm/lib/services/auth/service/oauth2/token.d.ts +19 -1
- package/esm/lib/services/auth/service/oauth2/token.d.ts.map +1 -1
- package/esm/lib/services/auth/service/oauth2/token.js +15 -0
- package/esm/lib/services/auth/service/oauth2/token.js.map +1 -1
- package/esm/lib/services/auth/types.d.ts +40 -12
- package/esm/lib/services/auth/types.d.ts.map +1 -1
- package/esm/lib/services/compute/config.d.ts +7 -0
- package/esm/lib/services/compute/config.d.ts.map +1 -0
- package/esm/lib/services/compute/config.js +13 -0
- package/esm/lib/services/compute/config.js.map +1 -0
- package/esm/lib/services/compute/index.d.ts +14 -0
- package/esm/lib/services/compute/index.d.ts.map +1 -0
- package/esm/lib/services/compute/index.js +14 -0
- package/esm/lib/services/compute/index.js.map +1 -0
- package/esm/lib/services/compute/service/endpoints.d.ts +24 -0
- package/esm/lib/services/compute/service/endpoints.d.ts.map +1 -0
- package/esm/lib/services/compute/service/endpoints.js +26 -0
- package/esm/lib/services/compute/service/endpoints.js.map +1 -0
- package/esm/lib/services/flows/config.d.ts +1 -1
- package/esm/lib/services/flows/config.d.ts.map +1 -1
- package/esm/lib/services/flows/config.js.map +1 -1
- package/esm/lib/services/globus-connect-server/client.d.ts +443 -88
- package/esm/lib/services/globus-connect-server/client.d.ts.map +1 -1
- package/esm/lib/services/groups/config.d.ts +1 -1
- package/esm/lib/services/groups/config.d.ts.map +1 -1
- package/esm/lib/services/groups/config.js.map +1 -1
- package/esm/lib/services/search/config.d.ts +1 -1
- package/esm/lib/services/search/config.d.ts.map +1 -1
- package/esm/lib/services/search/config.js.map +1 -1
- package/esm/lib/services/timer/config.d.ts +1 -1
- package/esm/lib/services/timer/config.d.ts.map +1 -1
- package/esm/lib/services/timer/config.js.map +1 -1
- package/esm/lib/services/transfer/config.d.ts +1 -1
- package/esm/lib/services/transfer/config.d.ts.map +1 -1
- package/esm/lib/services/transfer/config.js.map +1 -1
- package/esm/lib/services/transfer/index.d.ts +1 -0
- package/esm/lib/services/transfer/index.d.ts.map +1 -1
- package/esm/lib/services/transfer/index.js +1 -0
- package/esm/lib/services/transfer/index.js.map +1 -1
- package/esm/lib/services/transfer/service/collection-bookmarks.d.ts +64 -0
- package/esm/lib/services/transfer/service/collection-bookmarks.d.ts.map +1 -0
- package/esm/lib/services/transfer/service/collection-bookmarks.js +56 -0
- package/esm/lib/services/transfer/service/collection-bookmarks.js.map +1 -0
- package/esm/lib/services/transfer/service/endpoint.d.ts +127 -13
- package/esm/lib/services/transfer/service/endpoint.d.ts.map +1 -1
- package/esm/lib/services/transfer/service/endpoint.js +39 -0
- package/esm/lib/services/transfer/service/endpoint.js.map +1 -1
- package/esm/lib/services/transfer/service/task.d.ts +1 -1
- package/esm/lib/services/transfer/types.d.ts +215 -0
- package/esm/lib/services/transfer/types.d.ts.map +1 -1
- package/esm/lib/services/types.d.ts +4 -0
- package/esm/lib/services/types.d.ts.map +1 -1
- package/package.json +4 -3
- package/umd/globus.production.js +1 -1
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
var _AuthorizationManager_instances, _AuthorizationManager_transport, _AuthorizationManager_authenticated, _AuthorizationManager_checkAuthorizationState, _AuthorizationManager_bootstrapFromStorageState, _AuthorizationManager_emitAuthenticatedState, _AuthorizationManager_buildTransport;
|
|
1
|
+
var _AuthorizationManager_instances, _AuthorizationManager_transport, _AuthorizationManager_authenticated, _AuthorizationManager_silentRefreshTokens, _AuthorizationManager_checkAuthorizationState, _AuthorizationManager_bootstrapFromStorageState, _AuthorizationManager_emitAuthenticatedState, _AuthorizationManager_withOfflineAccess, _AuthorizationManager_buildTransport, _AuthorizationManager_revokeToken;
|
|
2
2
|
import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
-
import {
|
|
3
|
+
import { jwtDecode } from 'jwt-decode';
|
|
4
|
+
import { getAuthorizationEndpoint, getTokenEndpoint, isGlobusAuthTokenResponse, isRefreshToken, oauth2, } from '../../services/auth/index.js';
|
|
4
5
|
import { createStorage, getStorage } from '../storage/index.js';
|
|
5
6
|
import { log } from '../logger.js';
|
|
6
7
|
import { Event } from './Event.js';
|
|
7
8
|
import { RedirectTransport } from './RedirectTransport.js';
|
|
8
9
|
import { TokenLookup } from './TokenLookup.js';
|
|
9
10
|
import { isConsentRequiredError, isAuthorizationRequirementsError, } from '../errors.js';
|
|
11
|
+
const DEFAULT_CONFIGURATION = {
|
|
12
|
+
useRefreshTokens: false,
|
|
13
|
+
defaultScopes: 'openid profile email',
|
|
14
|
+
};
|
|
10
15
|
/**
|
|
11
16
|
* @experimental
|
|
12
17
|
*/
|
|
13
18
|
export class AuthorizationManager {
|
|
14
19
|
/**
|
|
15
|
-
* The `AuthorizationManager` is
|
|
20
|
+
* The `AuthorizationManager` is considered `authenticated` if it has a valid Globus Auth token.
|
|
16
21
|
* It does not necessarily mean that it has a valid token for a specific resource server.
|
|
17
22
|
*/
|
|
18
23
|
get authenticated() {
|
|
@@ -26,16 +31,22 @@ export class AuthorizationManager {
|
|
|
26
31
|
__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_emitAuthenticatedState).call(this);
|
|
27
32
|
}
|
|
28
33
|
constructor(configuration) {
|
|
34
|
+
var _a;
|
|
29
35
|
_AuthorizationManager_instances.add(this);
|
|
30
36
|
_AuthorizationManager_transport.set(this, void 0);
|
|
31
37
|
_AuthorizationManager_authenticated.set(this, false);
|
|
32
38
|
this.events = {
|
|
33
39
|
/**
|
|
34
40
|
* Emitted when the authenticated state changes.
|
|
41
|
+
* @event AuthorizationManager.events#authenticated
|
|
42
|
+
* @type {object}
|
|
43
|
+
* @property {boolean} isAuthenticated - Whether the `AuthorizationManager` is authenticated.
|
|
44
|
+
* @property {TokenResponse} [token] - The token response if the `AuthorizationManager` is authenticated.
|
|
35
45
|
*/
|
|
36
46
|
authenticated: new Event('authenticated'),
|
|
37
47
|
/**
|
|
38
48
|
* Emitted when the user revokes their authentication.
|
|
49
|
+
* @event AuthorizationManager.events#revoke
|
|
39
50
|
*/
|
|
40
51
|
revoke: new Event('revoke'),
|
|
41
52
|
};
|
|
@@ -45,9 +56,10 @@ export class AuthorizationManager {
|
|
|
45
56
|
* consumers to add tokens to storage if necessary.
|
|
46
57
|
*/
|
|
47
58
|
this.addTokenResponse = (token) => {
|
|
48
|
-
|
|
59
|
+
var _a;
|
|
60
|
+
getStorage().set(`${this.configuration.client}:${token.resource_server}`, token);
|
|
49
61
|
if ('other_tokens' in token) {
|
|
50
|
-
token.other_tokens.forEach(this.addTokenResponse);
|
|
62
|
+
(_a = token.other_tokens) === null || _a === void 0 ? void 0 : _a.forEach(this.addTokenResponse);
|
|
51
63
|
}
|
|
52
64
|
__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_checkAuthorizationState).call(this);
|
|
53
65
|
};
|
|
@@ -55,33 +67,84 @@ export class AuthorizationManager {
|
|
|
55
67
|
* @todo Add support for passing in an alternative storage mechanism.
|
|
56
68
|
*/
|
|
57
69
|
createStorage('localStorage');
|
|
58
|
-
if (!configuration.
|
|
59
|
-
throw new Error('You must provide a `
|
|
70
|
+
if (!configuration.client) {
|
|
71
|
+
throw new Error('You must provide a `client` for your application.');
|
|
60
72
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Inject the `openid`, `profile`, `email`, and `offline_access` scopes by default unless
|
|
75
|
+
* explicitly opted out of.
|
|
76
|
+
*/
|
|
77
|
+
const scopes = configuration.defaultScopes === false
|
|
78
|
+
? ''
|
|
79
|
+
: (_a = configuration.defaultScopes) !== null && _a !== void 0 ? _a : DEFAULT_CONFIGURATION.defaultScopes;
|
|
80
|
+
this.configuration = Object.assign(Object.assign({}, configuration), { scopes: `${configuration.scopes}${scopes ? ` ${scopes}` : ''}` });
|
|
66
81
|
this.tokens = new TokenLookup({
|
|
67
82
|
manager: this,
|
|
68
83
|
});
|
|
69
|
-
this.startSilentRenew();
|
|
70
|
-
}
|
|
71
|
-
startSilentRenew() {
|
|
72
|
-
log('debug', 'AuthorizationManager.startSilentRenew');
|
|
73
84
|
__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_bootstrapFromStorageState).call(this);
|
|
74
|
-
|
|
85
|
+
this.startSilentRefresh();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The user information decoded from the `id_token` (JWT) of the current Globus Auth token.
|
|
89
|
+
* This method can be used instead of `auth.oauth2.userinfo` to get the user information without an additional request.
|
|
90
|
+
*
|
|
91
|
+
* **IMPORTANT**: The `id_token` can only be processed if the `openid` scope is requested during the authorization process.
|
|
92
|
+
*
|
|
93
|
+
* Additionally, the `profile` and `email` scopes are required to get the full user information.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link https://docs.globus.org/api/auth/reference/#oidc_userinfo_endpoint}
|
|
96
|
+
*/
|
|
97
|
+
get user() {
|
|
98
|
+
const token = this.getGlobusAuthToken();
|
|
99
|
+
return token && token.id_token ? jwtDecode(token.id_token) : null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Start the silent refresh process for the instance.
|
|
103
|
+
* @todo Add interval support for the silent refresh.
|
|
104
|
+
*/
|
|
105
|
+
startSilentRefresh() {
|
|
106
|
+
log('debug', `AuthorizationManager.startSilentRefresh | useRefreshTokens=${this.configuration.useRefreshTokens}`);
|
|
107
|
+
/**
|
|
108
|
+
* Silent refresh is only supported when using refresh tokens.
|
|
109
|
+
*/
|
|
110
|
+
if (this.configuration.useRefreshTokens) {
|
|
111
|
+
__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_silentRefreshTokens).call(this);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Use the `refresh_token` attribute of a token to obtain a new access token.
|
|
116
|
+
* @param token The well-formed token with a `refresh_token` attribute.
|
|
117
|
+
*/
|
|
118
|
+
refreshToken(token) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
log('debug', `AuthorizationManager.refreshToken | resource_server=${token.resource_server}`);
|
|
121
|
+
try {
|
|
122
|
+
const response = yield (yield oauth2.token.refresh({
|
|
123
|
+
payload: {
|
|
124
|
+
client_id: this.configuration.client,
|
|
125
|
+
refresh_token: token.refresh_token,
|
|
126
|
+
grant_type: 'refresh_token',
|
|
127
|
+
},
|
|
128
|
+
})).json();
|
|
129
|
+
if (isGlobusAuthTokenResponse(response)) {
|
|
130
|
+
this.addTokenResponse(response);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
log('error', `AuthorizationManager.refreshToken | resource_server=${token.resource_server}`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
75
137
|
}
|
|
76
138
|
hasGlobusAuthToken() {
|
|
77
139
|
return this.getGlobusAuthToken() !== null;
|
|
78
140
|
}
|
|
79
141
|
getGlobusAuthToken() {
|
|
80
|
-
const entry = getStorage().get(`${this.configuration.
|
|
142
|
+
const entry = getStorage().get(`${this.configuration.client}:auth.globus.org`);
|
|
81
143
|
return entry ? JSON.parse(entry) : null;
|
|
82
144
|
}
|
|
83
145
|
/**
|
|
84
146
|
* Reset the authenticated state and clear all tokens from storage.
|
|
147
|
+
* This method **does not** emit the `revoke` event. If you need to emit the `revoke` event, use the `AuthorizationManager.revoke` method.
|
|
85
148
|
*/
|
|
86
149
|
reset() {
|
|
87
150
|
/**
|
|
@@ -94,6 +157,7 @@ export class AuthorizationManager {
|
|
|
94
157
|
* Initiate the login process by redirecting to the Globus Auth login page.
|
|
95
158
|
*/
|
|
96
159
|
login() {
|
|
160
|
+
log('debug', 'AuthorizationManager.login');
|
|
97
161
|
this.reset();
|
|
98
162
|
/**
|
|
99
163
|
* In the future, it's possible that we may want to support different types of transports.
|
|
@@ -102,30 +166,38 @@ export class AuthorizationManager {
|
|
|
102
166
|
transport.send();
|
|
103
167
|
}
|
|
104
168
|
handleCodeRedirect() {
|
|
105
|
-
return __awaiter(this,
|
|
106
|
-
|
|
169
|
+
return __awaiter(this, arguments, void 0, function* (options = { shouldReplace: true }) {
|
|
170
|
+
log('debug', 'AuthorizationManager.handleCodeRedirect');
|
|
171
|
+
const response = yield __classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_buildTransport).call(this).getToken({
|
|
172
|
+
shouldReplace: options === null || options === void 0 ? void 0 : options.shouldReplace,
|
|
173
|
+
});
|
|
107
174
|
if (isGlobusAuthTokenResponse(response)) {
|
|
175
|
+
log('debug', `AuthorizationManager.handleCodeRedirect | response=${JSON.stringify(response)}`);
|
|
108
176
|
this.addTokenResponse(response);
|
|
109
|
-
this.authenticated = true;
|
|
110
177
|
}
|
|
111
178
|
});
|
|
112
179
|
}
|
|
113
|
-
/**
|
|
114
|
-
* @todo
|
|
115
|
-
*/
|
|
116
180
|
handleErrorResponse(response, execute = true) {
|
|
181
|
+
log('debug', `AuthorizationManager.handleErrorResponse | response=${JSON.stringify(response)} execute=${execute}`);
|
|
117
182
|
let handler = () => { };
|
|
118
183
|
if (isAuthorizationRequirementsError(response)) {
|
|
184
|
+
log('debug', 'AuthorizationManager.handleErrorResponse | error=AuthorizationRequirementsError');
|
|
119
185
|
handler = () => this.handleAuthorizationRequirementsError(response);
|
|
120
186
|
}
|
|
121
187
|
if (isConsentRequiredError(response)) {
|
|
188
|
+
log('debug', 'AuthorizationManager.handleErrorResponse | error=ConsentRequiredError');
|
|
122
189
|
handler = () => this.handleConsentRequiredError(response);
|
|
123
190
|
}
|
|
124
|
-
if (response
|
|
125
|
-
|
|
191
|
+
if ('code' in response && response['code'] === 'AuthenticationFailed') {
|
|
192
|
+
log('debug', 'AuthorizationManager.handleErrorResponse | error=AuthenticationFailed');
|
|
193
|
+
handler = () => this.revoke();
|
|
126
194
|
}
|
|
127
|
-
return execute ? handler() : handler;
|
|
195
|
+
return execute === true ? handler() : handler;
|
|
128
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Process a well-formed Authorization Requirements error response from a Globus service
|
|
199
|
+
* and redirect the user to the Globus Auth login page with the necessary parameters.
|
|
200
|
+
*/
|
|
129
201
|
handleAuthorizationRequirementsError(response) {
|
|
130
202
|
__classPrivateFieldSet(this, _AuthorizationManager_transport, __classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_buildTransport).call(this, {
|
|
131
203
|
params: {
|
|
@@ -138,20 +210,39 @@ export class AuthorizationManager {
|
|
|
138
210
|
}), "f");
|
|
139
211
|
__classPrivateFieldGet(this, _AuthorizationManager_transport, "f").send();
|
|
140
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Process a well-formed `ConsentRequired` error response from a Globus service
|
|
215
|
+
* and redirect the user to the Globus Auth login page with the necessary parameters.
|
|
216
|
+
*/
|
|
141
217
|
handleConsentRequiredError(response) {
|
|
142
218
|
__classPrivateFieldSet(this, _AuthorizationManager_transport, __classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_buildTransport).call(this, {
|
|
143
|
-
requested_scopes: response.required_scopes.join(' '),
|
|
219
|
+
requested_scopes: __classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_withOfflineAccess).call(this, response.required_scopes.join(' ')),
|
|
144
220
|
}), "f");
|
|
145
221
|
__classPrivateFieldGet(this, _AuthorizationManager_transport, "f").send();
|
|
146
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Call `AuthroizationManager.reset`, revoke all of the available tokns, and emit the `revoke` event.
|
|
225
|
+
* @emits AuthorizationManager.events#revoke
|
|
226
|
+
* @see AuthorizationManager.reset
|
|
227
|
+
*/
|
|
147
228
|
revoke() {
|
|
148
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
log('debug', 'AuthorizationManager.revoke');
|
|
231
|
+
const revocation = Promise.all(this.tokens.getAll().map(__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_revokeToken).bind(this)));
|
|
149
232
|
this.reset();
|
|
233
|
+
yield revocation;
|
|
150
234
|
yield this.events.revoke.dispatch();
|
|
151
235
|
});
|
|
152
236
|
}
|
|
153
237
|
}
|
|
154
|
-
_AuthorizationManager_transport = new WeakMap(), _AuthorizationManager_authenticated = new WeakMap(), _AuthorizationManager_instances = new WeakSet(),
|
|
238
|
+
_AuthorizationManager_transport = new WeakMap(), _AuthorizationManager_authenticated = new WeakMap(), _AuthorizationManager_instances = new WeakSet(), _AuthorizationManager_silentRefreshTokens = function _AuthorizationManager_silentRefreshTokens() {
|
|
239
|
+
log('debug', 'AuthorizationManager.#silentRefreshTokens');
|
|
240
|
+
this.tokens.getAll().forEach((token) => {
|
|
241
|
+
if (isRefreshToken(token)) {
|
|
242
|
+
this.refreshToken(token);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}, _AuthorizationManager_checkAuthorizationState = function _AuthorizationManager_checkAuthorizationState() {
|
|
155
246
|
log('debug', 'AuthorizationManager.#checkAuthorizationState');
|
|
156
247
|
if (this.hasGlobusAuthToken()) {
|
|
157
248
|
this.authenticated = true;
|
|
@@ -162,8 +253,8 @@ _AuthorizationManager_transport = new WeakMap(), _AuthorizationManager_authentic
|
|
|
162
253
|
__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_checkAuthorizationState).call(this);
|
|
163
254
|
});
|
|
164
255
|
}, _AuthorizationManager_emitAuthenticatedState = function _AuthorizationManager_emitAuthenticatedState() {
|
|
165
|
-
var _a;
|
|
166
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
var _a;
|
|
167
258
|
const isAuthenticated = this.authenticated;
|
|
168
259
|
const token = (_a = this.getGlobusAuthToken()) !== null && _a !== void 0 ? _a : undefined;
|
|
169
260
|
yield this.events.authenticated.dispatch({
|
|
@@ -171,7 +262,19 @@ _AuthorizationManager_transport = new WeakMap(), _AuthorizationManager_authentic
|
|
|
171
262
|
token,
|
|
172
263
|
});
|
|
173
264
|
});
|
|
265
|
+
}, _AuthorizationManager_withOfflineAccess = function _AuthorizationManager_withOfflineAccess(scopes) {
|
|
266
|
+
return `${scopes}${this.configuration.useRefreshTokens ? ' offline_access' : ''}`;
|
|
174
267
|
}, _AuthorizationManager_buildTransport = function _AuthorizationManager_buildTransport(overrides) {
|
|
175
|
-
|
|
268
|
+
var _a;
|
|
269
|
+
const scopes = __classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_withOfflineAccess).call(this, (_a = overrides === null || overrides === void 0 ? void 0 : overrides.requested_scopes) !== null && _a !== void 0 ? _a : this.configuration.scopes);
|
|
270
|
+
return new RedirectTransport(Object.assign({ client_id: this.configuration.client, authorization_endpoint: getAuthorizationEndpoint(), token_endpoint: getTokenEndpoint(), redirect_uri: this.configuration.redirect, requested_scopes: scopes }, overrides));
|
|
271
|
+
}, _AuthorizationManager_revokeToken = function _AuthorizationManager_revokeToken(token) {
|
|
272
|
+
log('debug', `AuthorizationManager.revokeToken | resource_server=${token.resource_server}`);
|
|
273
|
+
return oauth2.token.revoke({
|
|
274
|
+
payload: {
|
|
275
|
+
client_id: this.configuration.client,
|
|
276
|
+
token: token.access_token,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
176
279
|
};
|
|
177
280
|
//# sourceMappingURL=AuthorizationManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationManager.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/AuthorizationManager.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"AuthorizationManager.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/AuthorizationManager.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,MAAM,GACP,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAmB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,sBAAsB,EACtB,gCAAgC,GAGjC,MAAM,cAAc,CAAC;AAyBtB,MAAM,qBAAqB,GAAG;IAC5B,gBAAgB,EAAE,KAAK;IACvB,aAAa,EAAE,sBAAsB;CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAO/B;;;OAGG;IACH,IAAI,aAAa;QACf,OAAO,uBAAA,IAAI,2CAAe,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAI,aAAa,CAAC,KAAc;QAC9B,uBAAA,IAAI,uCAAkB,KAAK,MAAA,CAAC;QAC5B,uBAAA,IAAI,qFAAwB,MAA5B,IAAI,CAA0B,CAAC;IACjC,CAAC;IA8BD,YAAY,aAAgD;;;QAlD5D,kDAA+B;QAI/B,8CAAiB,KAAK,EAAC;QAoBvB,WAAM,GAAG;YACP;;;;;;eAM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AC;AACL,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @todo It would be nice to not `| any` here, but ideally callers do not need to
|
|
3
|
+
* fully type the payload to attach listeners.
|
|
4
|
+
*/
|
|
5
|
+
type ListenerCallback<P> = (payload?: P | any) => Promise<void> | void;
|
|
2
6
|
export declare class Event<EventName extends string, Payload extends unknown> {
|
|
3
7
|
#private;
|
|
4
8
|
readonly name: EventName;
|
|
5
9
|
constructor(name: EventName);
|
|
6
10
|
addListener(callback: ListenerCallback<Payload>): () => void;
|
|
7
11
|
removeListener(callback: ListenerCallback<Payload>): void;
|
|
12
|
+
clearListeners(): void;
|
|
8
13
|
dispatch(payload?: Payload): Promise<void>;
|
|
9
14
|
}
|
|
10
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/Event.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/Event.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEvE,qBAAa,KAAK,CAAC,SAAS,SAAS,MAAM,EAAE,OAAO,SAAS,OAAO;;IAGtD,QAAQ,CAAC,IAAI,EAAE,SAAS;gBAAf,IAAI,EAAE,SAAS;IAEpC,WAAW,CAAC,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC;IAK/C,cAAc,CAAC,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC;IAIlD,cAAc;IAIR,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO;CAGjC"}
|
|
@@ -12,6 +12,9 @@ export class Event {
|
|
|
12
12
|
removeListener(callback) {
|
|
13
13
|
__classPrivateFieldSet(this, _Event_callbacks, __classPrivateFieldGet(this, _Event_callbacks, "f").filter((cb) => cb !== callback), "f");
|
|
14
14
|
}
|
|
15
|
+
clearListeners() {
|
|
16
|
+
__classPrivateFieldSet(this, _Event_callbacks, [], "f");
|
|
17
|
+
}
|
|
15
18
|
dispatch(payload) {
|
|
16
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
20
|
yield Promise.all(__classPrivateFieldGet(this, _Event_callbacks, "f").map((callback) => callback(payload)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Event.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/Event.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Event.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/Event.ts"],"names":[],"mappings":";;AAMA,MAAM,OAAO,KAAK;IAGhB,YAAqB,IAAe;QAAf,SAAI,GAAJ,IAAI,CAAW;QAFpC,2BAA0C,EAAE,EAAC;IAEN,CAAC;IAExC,WAAW,CAAC,QAAmC;QAC7C,uBAAA,IAAI,wBAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,cAAc,CAAC,QAAmC;QAChD,uBAAA,IAAI,oBAAc,uBAAA,IAAI,wBAAW,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC,MAAA,CAAC;IACpE,CAAC;IAED,cAAc;QACZ,uBAAA,IAAI,oBAAc,EAAE,MAAA,CAAC;IACvB,CAAC;IAEK,QAAQ,CAAC,OAAiB;;YAC9B,MAAM,OAAO,CAAC,GAAG,CAAC,uBAAA,IAAI,wBAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;KAAA;CACF"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type IConfig from 'js-pkce/dist/IConfig';
|
|
2
2
|
import type IObject from 'js-pkce/dist/IObject';
|
|
3
|
+
export type GetTokenOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether or not the URL should be replaced after processing the token.
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
shouldReplace?: boolean;
|
|
9
|
+
};
|
|
3
10
|
export declare class RedirectTransport {
|
|
4
11
|
#private;
|
|
5
12
|
constructor(options: IConfig & {
|
|
@@ -9,6 +16,10 @@ export declare class RedirectTransport {
|
|
|
9
16
|
params?: IObject;
|
|
10
17
|
});
|
|
11
18
|
send(): void;
|
|
12
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Parse the current URL for the authorization code (`?code=...`) and exchange it for an access token when available.
|
|
21
|
+
* - When the URL is processed and exchanged for an access token, the page is redirected to the current URL without the `?code=...&state=...` parameters.
|
|
22
|
+
*/
|
|
23
|
+
getToken(options?: GetTokenOptions): Promise<import("js-pkce/dist/ITokenResponse").default | undefined>;
|
|
13
24
|
}
|
|
14
25
|
//# sourceMappingURL=RedirectTransport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedirectTransport.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/RedirectTransport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,qBAAa,iBAAiB;;gBAM1B,OAAO,EAAE,OAAO,GAAG;QACjB;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB;IAWH,IAAI;
|
|
1
|
+
{"version":3,"file":"RedirectTransport.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/RedirectTransport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,qBAAa,iBAAiB;;gBAM1B,OAAO,EAAE,OAAO,GAAG;QACjB;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB;IAWH,IAAI;IAIJ;;;OAGG;IACG,QAAQ,CAAC,OAAO,GAAE,eAAyC;CA+BlE"}
|
|
@@ -12,23 +12,41 @@ export class RedirectTransport {
|
|
|
12
12
|
send() {
|
|
13
13
|
window.location.replace(__classPrivateFieldGet(this, _RedirectTransport_pkce, "f").authorizeUrl(__classPrivateFieldGet(this, _RedirectTransport_params, "f")));
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse the current URL for the authorization code (`?code=...`) and exchange it for an access token when available.
|
|
17
|
+
* - When the URL is processed and exchanged for an access token, the page is redirected to the current URL without the `?code=...&state=...` parameters.
|
|
18
|
+
*/
|
|
15
19
|
getToken() {
|
|
16
|
-
return __awaiter(this,
|
|
20
|
+
return __awaiter(this, arguments, void 0, function* (options = { shouldReplace: true }) {
|
|
17
21
|
const url = new URL(window.location.href);
|
|
18
22
|
const params = new URLSearchParams(url.search);
|
|
23
|
+
/**
|
|
24
|
+
* If we don't have a `code` parameter, we can't exchange it for an access token.
|
|
25
|
+
*/
|
|
19
26
|
if (!params.get('code'))
|
|
20
27
|
return undefined;
|
|
21
28
|
const response = yield __classPrivateFieldGet(this, _RedirectTransport_pkce, "f").exchangeForAccessToken(url.toString());
|
|
22
|
-
params.delete('code');
|
|
23
|
-
params.delete('state');
|
|
24
|
-
url.search = params.toString();
|
|
25
29
|
/**
|
|
26
30
|
* Resets js-pkce state
|
|
27
31
|
* @see https://github.com/bpedroza/js-pkce/blob/master/src/PKCE.ts
|
|
28
32
|
*/
|
|
29
33
|
sessionStorage.removeItem('pkce_state');
|
|
30
34
|
sessionStorage.removeItem('pkce_code_verifier');
|
|
31
|
-
|
|
35
|
+
if (options.shouldReplace) {
|
|
36
|
+
/**
|
|
37
|
+
* Remove the `code` and `state` parameters from the URL.
|
|
38
|
+
*/
|
|
39
|
+
params.delete('code');
|
|
40
|
+
params.delete('state');
|
|
41
|
+
/**
|
|
42
|
+
* Update the URL with the new query string.
|
|
43
|
+
*/
|
|
44
|
+
url.search = params.toString();
|
|
45
|
+
/**
|
|
46
|
+
* Redirect the page to the new URL (without the `code` and `state` parameters)/
|
|
47
|
+
*/
|
|
48
|
+
window.location.replace(url);
|
|
49
|
+
}
|
|
32
50
|
return response;
|
|
33
51
|
});
|
|
34
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedirectTransport.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/RedirectTransport.ts"],"names":[],"mappings":";;AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"RedirectTransport.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/RedirectTransport.ts"],"names":[],"mappings":";;AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAY3B,MAAM,OAAO,iBAAiB;IAK5B,YACE,OAKC;QAVH,0CAAY;QAEZ,oCAAmB,EAAE,EAAC;QAUpB,MAAM,EAAE,MAAM,KAAgB,OAAO,EAAlB,MAAM,UAAK,OAAO,EAA/B,UAAqB,CAAU,CAAC;QACtC,uBAAA,IAAI,2BAAS,IAAI,IAAI,mBAChB,MAAM,EACT,MAAA,CAAC;QACH,uBAAA,IAAI,+CACC,MAAM,OACV,CAAC;IACJ,CAAC;IAED,IAAI;QACF,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,uBAAA,IAAI,+BAAM,CAAC,YAAY,CAAC,uBAAA,IAAI,iCAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACG,QAAQ;6DAAC,UAA2B,EAAE,aAAa,EAAE,IAAI,EAAE;YAC/D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC1C,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC/C;;eAEG;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;gBAAE,OAAO,SAAS,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,+BAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YACzE;;;eAGG;YACH,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;YACxC,cAAc,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;YAChD,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;gBAC1B;;mBAEG;gBACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACtB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBACvB;;mBAEG;gBACH,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC/B;;mBAEG;gBACH,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Token } from '../../services/auth/index.js';
|
|
2
1
|
import { AuthorizationManager } from './AuthorizationManager.js';
|
|
2
|
+
import type { Token } from '../../services/auth/types.js';
|
|
3
3
|
export declare class TokenLookup {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(options: {
|
|
@@ -8,5 +8,10 @@ export declare class TokenLookup {
|
|
|
8
8
|
get auth(): Token | null;
|
|
9
9
|
get transfer(): Token | null;
|
|
10
10
|
get flows(): Token | null;
|
|
11
|
+
get groups(): Token | null;
|
|
12
|
+
get search(): Token | null;
|
|
13
|
+
get timer(): Token | null;
|
|
14
|
+
get compute(): Token | null;
|
|
15
|
+
getAll(): Token[];
|
|
11
16
|
}
|
|
12
17
|
//# sourceMappingURL=TokenLookup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenLookup.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/TokenLookup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TokenLookup.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/TokenLookup.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1D,qBAAa,WAAW;;gBAGV,OAAO,EAAE;QAAE,OAAO,EAAE,oBAAoB,CAAA;KAAE;IAoBtD,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,CAEvB;IAED,IAAI,QAAQ,IAAI,KAAK,GAAG,IAAI,CAE3B;IAED,IAAI,KAAK,IAAI,KAAK,GAAG,IAAI,CAExB;IAED,IAAI,MAAM,IAAI,KAAK,GAAG,IAAI,CAEzB;IAED,IAAI,MAAM,IAAI,KAAK,GAAG,IAAI,CAEzB;IAED,IAAI,KAAK,IAAI,KAAK,GAAG,IAAI,CAExB;IAED,IAAI,OAAO,IAAI,KAAK,GAAG,IAAI,CAE1B;IAED,MAAM,IAAI,KAAK,EAAE;CAYlB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var _TokenLookup_instances, _TokenLookup_manager, _TokenLookup_getTokenForService;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { getStorage } from '../storage/index.js';
|
|
4
|
-
import { CONFIG } from '../../services/auth/index.js';
|
|
4
|
+
import { CONFIG, isToken } from '../../services/auth/index.js';
|
|
5
|
+
import { SERVICES } from '../global.js';
|
|
5
6
|
export class TokenLookup {
|
|
6
7
|
constructor(options) {
|
|
7
8
|
_TokenLookup_instances.add(this);
|
|
@@ -9,19 +10,53 @@ export class TokenLookup {
|
|
|
9
10
|
__classPrivateFieldSet(this, _TokenLookup_manager, options.manager, "f");
|
|
10
11
|
}
|
|
11
12
|
get auth() {
|
|
12
|
-
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this,
|
|
13
|
+
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this, SERVICES.AUTH);
|
|
13
14
|
}
|
|
14
15
|
get transfer() {
|
|
15
|
-
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this,
|
|
16
|
+
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this, SERVICES.TRANSFER);
|
|
16
17
|
}
|
|
17
18
|
get flows() {
|
|
18
|
-
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this,
|
|
19
|
+
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this, SERVICES.FLOWS);
|
|
20
|
+
}
|
|
21
|
+
get groups() {
|
|
22
|
+
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this, SERVICES.GROUPS);
|
|
23
|
+
}
|
|
24
|
+
get search() {
|
|
25
|
+
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this, SERVICES.SEARCH);
|
|
26
|
+
}
|
|
27
|
+
get timer() {
|
|
28
|
+
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this, SERVICES.TIMER);
|
|
29
|
+
}
|
|
30
|
+
get compute() {
|
|
31
|
+
return __classPrivateFieldGet(this, _TokenLookup_instances, "m", _TokenLookup_getTokenForService).call(this, SERVICES.COMPUTE);
|
|
32
|
+
}
|
|
33
|
+
getAll() {
|
|
34
|
+
const tokens = [
|
|
35
|
+
this.auth,
|
|
36
|
+
this.transfer,
|
|
37
|
+
this.flows,
|
|
38
|
+
this.groups,
|
|
39
|
+
this.search,
|
|
40
|
+
this.timer,
|
|
41
|
+
this.compute,
|
|
42
|
+
];
|
|
43
|
+
return tokens.filter(isToken);
|
|
19
44
|
}
|
|
20
45
|
}
|
|
21
46
|
_TokenLookup_manager = new WeakMap(), _TokenLookup_instances = new WeakSet(), _TokenLookup_getTokenForService = function _TokenLookup_getTokenForService(service) {
|
|
22
47
|
var _a;
|
|
23
48
|
const resourceServer = (_a = CONFIG.RESOURCE_SERVERS) === null || _a === void 0 ? void 0 : _a[service];
|
|
24
|
-
const raw = getStorage().get(`${__classPrivateFieldGet(this, _TokenLookup_manager, "f").configuration.
|
|
25
|
-
|
|
49
|
+
const raw = getStorage().get(`${__classPrivateFieldGet(this, _TokenLookup_manager, "f").configuration.client}:${resourceServer}`) || 'null';
|
|
50
|
+
let token = null;
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(raw);
|
|
53
|
+
if (isToken(parsed)) {
|
|
54
|
+
token = parsed;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
// no-op
|
|
59
|
+
}
|
|
60
|
+
return token;
|
|
26
61
|
};
|
|
27
62
|
//# sourceMappingURL=TokenLookup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenLookup.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/TokenLookup.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"TokenLookup.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/TokenLookup.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAA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,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF;yJAxDqB,OAAgB;;IAClC,MAAM,cAAc,GAAG,MAAA,MAAM,CAAC,gBAAgB,0CAAG,OAAO,CAAC,CAAC;IAC1D,MAAM,GAAG,GACP,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,uBAAA,IAAI,4BAAS,CAAC,aAAa,CAAC,MAAM,IAAI,cAAc,EAAE,CAAC,IAAI,MAAM,CAAC;IACxF,IAAI,KAAK,GAAiB,IAAI,CAAC;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACpB,KAAK,GAAG,MAAM,CAAC;QACjB,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,QAAQ;IACV,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Obtain the token string for the given scope.
|
|
3
3
|
* @param scope The scope string that will be used to look up the token.
|
|
4
4
|
* @returns The token string for the given scope or null if no token is found.
|
|
5
|
+
* @deprecated Use an `AuthorizationManager` instance to manage tokens.
|
|
5
6
|
*/
|
|
6
7
|
export declare function getTokenForScope(scope: string): string | null;
|
|
7
8
|
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/tokens.ts"],"names":[],"mappings":"AASA
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/tokens.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,iBAO7C"}
|
|
@@ -7,9 +7,11 @@ function isValidToken(check) {
|
|
|
7
7
|
* Obtain the token string for the given scope.
|
|
8
8
|
* @param scope The scope string that will be used to look up the token.
|
|
9
9
|
* @returns The token string for the given scope or null if no token is found.
|
|
10
|
+
* @deprecated Use an `AuthorizationManager` instance to manage tokens.
|
|
10
11
|
*/
|
|
11
12
|
export function getTokenForScope(scope) {
|
|
12
|
-
const
|
|
13
|
+
const storageValue = getStorage().get(scope);
|
|
14
|
+
const token = storageValue ? JSON.parse(storageValue) : null;
|
|
13
15
|
if (!token || !isValidToken(token)) {
|
|
14
16
|
return null;
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/tokens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,SAAS,YAAY,CAAC,KAAc;IAClC,MAAM,KAAK,GAAG,KAAc,CAAC;IAC7B,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,YAAY,GAAG,UAAU,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7D,IAAI,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/lib/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,6BAA8B,SAAQ,KAAK;IAC7C,IAAI,SAAmC;gBAEpC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAK7C;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,eAAe,CAExE;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,iBAAiB,CAAC;IACxB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/lib/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,6BAA8B,SAAQ,KAAK;IAC7C,IAAI,SAAmC;gBAEpC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAK7C;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,eAAe,CAExE;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,iBAAiB,CAAC;IACxB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,CAOlF;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,wBAAwB,EAAE;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,2BAA2B,EAAE,MAAM,EAAE,CAAC;QACtC,oBAAoB,EAAE,OAAO,CAAC;QAC9B,8BAA8B,EAAE,MAAM,EAAE,CAAC;KAC1C,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,8BAA8B,CAOxC"}
|
package/esm/lib/core/errors.js
CHANGED
|
@@ -10,9 +10,15 @@ export function isErrorWellFormed(test) {
|
|
|
10
10
|
return typeof test === 'object' && test !== null && 'code' in test && 'message' in test;
|
|
11
11
|
}
|
|
12
12
|
export function isConsentRequiredError(test) {
|
|
13
|
-
return isErrorWellFormed(test) &&
|
|
13
|
+
return (isErrorWellFormed(test) &&
|
|
14
|
+
test.code === 'ConsentRequired' &&
|
|
15
|
+
'required_scopes' in test &&
|
|
16
|
+
Array.isArray(test.required_scopes));
|
|
14
17
|
}
|
|
15
18
|
export function isAuthorizationRequirementsError(test) {
|
|
16
|
-
return isErrorWellFormed(test) &&
|
|
19
|
+
return (isErrorWellFormed(test) &&
|
|
20
|
+
'authorization_parameters' in test &&
|
|
21
|
+
typeof test.authorization_parameters === 'object' &&
|
|
22
|
+
test.authorization_parameters !== null);
|
|
17
23
|
}
|
|
18
24
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/lib/core/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IAGtD,YAAY,QAAgB,EAAE,KAAc;QAC1C,KAAK,EAAE,CAAC;QAHD,SAAI,GAAG,+BAA+B,CAAC;QAI9C,4EAA4E;QAC5E,IAAI,CAAC,OAAO,GAAG,4CAA4C,QAAQ,KAAK,KAAK,IAAI,CAAC;IACpF,CAAC;CACF;AAOD,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