@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
package/cjs/index.d.ts
CHANGED
|
@@ -60,4 +60,5 @@ export * as groups from './lib/services/groups/index.js';
|
|
|
60
60
|
export * as flows from './lib/services/flows/index.js';
|
|
61
61
|
export * as gcs from './lib/services/globus-connect-server/index.js';
|
|
62
62
|
export * as timer from './lib/services/timer/index.js';
|
|
63
|
+
export * as compute from './lib/services/compute/index.js';
|
|
63
64
|
//# sourceMappingURL=index.d.ts.map
|
package/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAOH,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,KAAK,MAAM,+BAA+B,CAAC;AACvD,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,KAAK,KAAK,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAOH,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,KAAK,MAAM,+BAA+B,CAAC;AACvD,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,KAAK,KAAK,MAAM,+BAA+B,CAAC;AACvD,OAAO,KAAK,OAAO,MAAM,iCAAiC,CAAC"}
|
package/cjs/index.js
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
* const result = await (await flows.flows.get("452bbea3-5e3b-45a5-af08-50179839a4e8")).json();
|
|
54
54
|
*/
|
|
55
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
-
exports.timer = exports.gcs = exports.flows = exports.groups = exports.search = exports.transfer = exports.auth = exports.authorization = exports.logger = void 0;
|
|
56
|
+
exports.compute = exports.timer = exports.gcs = exports.flows = exports.groups = exports.search = exports.transfer = exports.auth = exports.authorization = exports.logger = void 0;
|
|
57
57
|
const tslib_1 = require("tslib");
|
|
58
58
|
/// <reference types="@globus/types" />
|
|
59
59
|
/// <reference types="@globus/types/auth" />
|
|
@@ -68,4 +68,5 @@ exports.groups = tslib_1.__importStar(require("./lib/services/groups/index.js"))
|
|
|
68
68
|
exports.flows = tslib_1.__importStar(require("./lib/services/flows/index.js"));
|
|
69
69
|
exports.gcs = tslib_1.__importStar(require("./lib/services/globus-connect-server/index.js"));
|
|
70
70
|
exports.timer = tslib_1.__importStar(require("./lib/services/timer/index.js"));
|
|
71
|
+
exports.compute = tslib_1.__importStar(require("./lib/services/compute/index.js"));
|
|
71
72
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;;;;AAEH,uCAAuC;AACvC,4CAA4C;AAC5C,gDAAgD;AAChD,8CAA8C;AAE9C,uEAA+C;AAE/C,2FAAmE;AACnE,6EAAqD;AACrD,qFAA6D;AAC7D,iFAAyD;AACzD,iFAAyD;AACzD,+EAAuD;AACvD,6FAAqE;AACrE,+EAAuD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;;;;AAEH,uCAAuC;AACvC,4CAA4C;AAC5C,gDAAgD;AAChD,8CAA8C;AAE9C,uEAA+C;AAE/C,2FAAmE;AACnE,6EAAqD;AACrD,qFAA6D;AAC7D,iFAAyD;AACzD,iFAAyD;AACzD,+EAAuD;AACvD,6FAAqE;AACrE,+EAAuD;AACvD,mFAA2D"}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import type IConfig from 'js-pkce/dist/IConfig';
|
|
2
|
-
import { Token, TokenResponse } from '../../services/auth/index.js';
|
|
3
2
|
import { Event } from './Event.js';
|
|
3
|
+
import { GetTokenOptions } from './RedirectTransport.js';
|
|
4
4
|
import { TokenLookup } from './TokenLookup.js';
|
|
5
5
|
import { AuthorizationRequirementsError, ConsentRequiredError } from '../errors.js';
|
|
6
|
+
import type { JwtUserInfo, Token, TokenResponse, TokenWithRefresh } from '../../services/auth/types.js';
|
|
6
7
|
export type AuthorizationManagerConfiguration = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
client: IConfig['client_id'];
|
|
9
|
+
scopes: IConfig['requested_scopes'];
|
|
10
|
+
redirect: IConfig['redirect_uri'];
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
* @default DEFAULT_CONFIGURATION.useRefreshTokens
|
|
14
|
+
*/
|
|
15
|
+
useRefreshTokens?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
* @default DEFAULT_CONFIGURATION.defaultScopes
|
|
19
|
+
*/
|
|
20
|
+
defaultScopes?: string | false;
|
|
10
21
|
};
|
|
11
22
|
/**
|
|
12
23
|
* @experimental
|
|
@@ -15,7 +26,7 @@ export declare class AuthorizationManager {
|
|
|
15
26
|
#private;
|
|
16
27
|
configuration: AuthorizationManagerConfiguration;
|
|
17
28
|
/**
|
|
18
|
-
* The `AuthorizationManager` is
|
|
29
|
+
* The `AuthorizationManager` is considered `authenticated` if it has a valid Globus Auth token.
|
|
19
30
|
* It does not necessarily mean that it has a valid token for a specific resource server.
|
|
20
31
|
*/
|
|
21
32
|
get authenticated(): boolean;
|
|
@@ -27,6 +38,10 @@ export declare class AuthorizationManager {
|
|
|
27
38
|
events: {
|
|
28
39
|
/**
|
|
29
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.
|
|
30
45
|
*/
|
|
31
46
|
authenticated: Event<"authenticated", {
|
|
32
47
|
/**
|
|
@@ -38,30 +53,64 @@ export declare class AuthorizationManager {
|
|
|
38
53
|
}>;
|
|
39
54
|
/**
|
|
40
55
|
* Emitted when the user revokes their authentication.
|
|
56
|
+
* @event AuthorizationManager.events#revoke
|
|
41
57
|
*/
|
|
42
58
|
revoke: Event<"revoke", unknown>;
|
|
43
59
|
};
|
|
44
60
|
constructor(configuration: AuthorizationManagerConfiguration);
|
|
45
|
-
|
|
61
|
+
/**
|
|
62
|
+
* The user information decoded from the `id_token` (JWT) of the current Globus Auth token.
|
|
63
|
+
* This method can be used instead of `auth.oauth2.userinfo` to get the user information without an additional request.
|
|
64
|
+
*
|
|
65
|
+
* **IMPORTANT**: The `id_token` can only be processed if the `openid` scope is requested during the authorization process.
|
|
66
|
+
*
|
|
67
|
+
* Additionally, the `profile` and `email` scopes are required to get the full user information.
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://docs.globus.org/api/auth/reference/#oidc_userinfo_endpoint}
|
|
70
|
+
*/
|
|
71
|
+
get user(): JwtUserInfo | null;
|
|
72
|
+
/**
|
|
73
|
+
* Start the silent refresh process for the instance.
|
|
74
|
+
* @todo Add interval support for the silent refresh.
|
|
75
|
+
*/
|
|
76
|
+
startSilentRefresh(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Use the `refresh_token` attribute of a token to obtain a new access token.
|
|
79
|
+
* @param token The well-formed token with a `refresh_token` attribute.
|
|
80
|
+
*/
|
|
81
|
+
refreshToken(token: TokenWithRefresh): Promise<void>;
|
|
46
82
|
hasGlobusAuthToken(): boolean;
|
|
47
83
|
getGlobusAuthToken(): any;
|
|
48
84
|
/**
|
|
49
85
|
* Reset the authenticated state and clear all tokens from storage.
|
|
86
|
+
* This method **does not** emit the `revoke` event. If you need to emit the `revoke` event, use the `AuthorizationManager.revoke` method.
|
|
50
87
|
*/
|
|
51
88
|
reset(): void;
|
|
52
89
|
/**
|
|
53
90
|
* Initiate the login process by redirecting to the Globus Auth login page.
|
|
54
91
|
*/
|
|
55
92
|
login(): void;
|
|
56
|
-
handleCodeRedirect(
|
|
93
|
+
handleCodeRedirect(options?: {
|
|
94
|
+
shouldReplace: GetTokenOptions['shouldReplace'];
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Handle an error response from a Globus service in the context of this `AuthorizationManager`.
|
|
98
|
+
* This method will introspect the response and attempt to handle any errors that should result
|
|
99
|
+
* in some additional Globus Auth interaction.
|
|
100
|
+
* @param response - The error response from a Globus service.
|
|
101
|
+
* @param execute - Whether to execute the handler immediately or return a function that can be executed later.
|
|
102
|
+
*/
|
|
103
|
+
handleErrorResponse(response: Record<string, unknown>, execute?: true): void;
|
|
104
|
+
handleErrorResponse(response: Record<string, unknown>, execute?: false): () => void;
|
|
57
105
|
/**
|
|
58
|
-
*
|
|
106
|
+
* Process a well-formed Authorization Requirements error response from a Globus service
|
|
107
|
+
* and redirect the user to the Globus Auth login page with the necessary parameters.
|
|
59
108
|
*/
|
|
60
|
-
handleErrorResponse(response: {
|
|
61
|
-
code: unknown;
|
|
62
|
-
required_scopes?: unknown;
|
|
63
|
-
}, execute?: boolean): void | (() => void);
|
|
64
109
|
handleAuthorizationRequirementsError(response: AuthorizationRequirementsError): void;
|
|
110
|
+
/**
|
|
111
|
+
* Process a well-formed `ConsentRequired` error response from a Globus service
|
|
112
|
+
* and redirect the user to the Globus Auth login page with the necessary parameters.
|
|
113
|
+
*/
|
|
65
114
|
handleConsentRequiredError(response: ConsentRequiredError): void;
|
|
66
115
|
/**
|
|
67
116
|
* Add a Globus Auth token response to storage, if `other_tokens` are present they are also added.
|
|
@@ -69,6 +118,11 @@ export declare class AuthorizationManager {
|
|
|
69
118
|
* consumers to add tokens to storage if necessary.
|
|
70
119
|
*/
|
|
71
120
|
addTokenResponse: (token: Token | TokenResponse) => void;
|
|
121
|
+
/**
|
|
122
|
+
* Call `AuthroizationManager.reset`, revoke all of the available tokns, and emit the `revoke` event.
|
|
123
|
+
* @emits AuthorizationManager.events#revoke
|
|
124
|
+
* @see AuthorizationManager.reset
|
|
125
|
+
*/
|
|
72
126
|
revoke(): Promise<void>;
|
|
73
127
|
}
|
|
74
128
|
//# sourceMappingURL=AuthorizationManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationManager.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/AuthorizationManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthorizationManager.d.ts","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/AuthorizationManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAahD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,eAAe,EAAqB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAGL,8BAA8B,EAC9B,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,WAAW,EACX,KAAK,EACL,aA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;;OAGG;IACH,oCAAoC,CAAC,QAAQ,EAAE,8BAA8B;IAe7E;;;OAGG;IACH,0BAA0B,CAAC,QAAQ,EAAE,oBAAoB;IAOzD;;;;OAIG;IACH,gBAAgB,UAAW,KAAK,GAAG,aAAa,UAM9C;IAEF;;;;OAIG;IACG,MAAM;CAoBb"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _AuthorizationManager_instances, _AuthorizationManager_transport, _AuthorizationManager_authenticated, _AuthorizationManager_checkAuthorizationState, _AuthorizationManager_bootstrapFromStorageState, _AuthorizationManager_emitAuthenticatedState, _AuthorizationManager_buildTransport;
|
|
2
|
+
var _AuthorizationManager_instances, _AuthorizationManager_transport, _AuthorizationManager_authenticated, _AuthorizationManager_silentRefreshTokens, _AuthorizationManager_checkAuthorizationState, _AuthorizationManager_bootstrapFromStorageState, _AuthorizationManager_emitAuthenticatedState, _AuthorizationManager_withOfflineAccess, _AuthorizationManager_buildTransport, _AuthorizationManager_revokeToken;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.AuthorizationManager = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
+
const jwt_decode_1 = require("jwt-decode");
|
|
6
7
|
const index_js_1 = require("../../services/auth/index.js");
|
|
7
8
|
const index_js_2 = require("../storage/index.js");
|
|
8
9
|
const logger_js_1 = require("../logger.js");
|
|
@@ -10,12 +11,16 @@ const Event_js_1 = require("./Event.js");
|
|
|
10
11
|
const RedirectTransport_js_1 = require("./RedirectTransport.js");
|
|
11
12
|
const TokenLookup_js_1 = require("./TokenLookup.js");
|
|
12
13
|
const errors_js_1 = require("../errors.js");
|
|
14
|
+
const DEFAULT_CONFIGURATION = {
|
|
15
|
+
useRefreshTokens: false,
|
|
16
|
+
defaultScopes: 'openid profile email',
|
|
17
|
+
};
|
|
13
18
|
/**
|
|
14
19
|
* @experimental
|
|
15
20
|
*/
|
|
16
21
|
class AuthorizationManager {
|
|
17
22
|
/**
|
|
18
|
-
* The `AuthorizationManager` is
|
|
23
|
+
* The `AuthorizationManager` is considered `authenticated` if it has a valid Globus Auth token.
|
|
19
24
|
* It does not necessarily mean that it has a valid token for a specific resource server.
|
|
20
25
|
*/
|
|
21
26
|
get authenticated() {
|
|
@@ -29,16 +34,22 @@ class AuthorizationManager {
|
|
|
29
34
|
tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_emitAuthenticatedState).call(this);
|
|
30
35
|
}
|
|
31
36
|
constructor(configuration) {
|
|
37
|
+
var _a;
|
|
32
38
|
_AuthorizationManager_instances.add(this);
|
|
33
39
|
_AuthorizationManager_transport.set(this, void 0);
|
|
34
40
|
_AuthorizationManager_authenticated.set(this, false);
|
|
35
41
|
this.events = {
|
|
36
42
|
/**
|
|
37
43
|
* Emitted when the authenticated state changes.
|
|
44
|
+
* @event AuthorizationManager.events#authenticated
|
|
45
|
+
* @type {object}
|
|
46
|
+
* @property {boolean} isAuthenticated - Whether the `AuthorizationManager` is authenticated.
|
|
47
|
+
* @property {TokenResponse} [token] - The token response if the `AuthorizationManager` is authenticated.
|
|
38
48
|
*/
|
|
39
49
|
authenticated: new Event_js_1.Event('authenticated'),
|
|
40
50
|
/**
|
|
41
51
|
* Emitted when the user revokes their authentication.
|
|
52
|
+
* @event AuthorizationManager.events#revoke
|
|
42
53
|
*/
|
|
43
54
|
revoke: new Event_js_1.Event('revoke'),
|
|
44
55
|
};
|
|
@@ -48,9 +59,10 @@ class AuthorizationManager {
|
|
|
48
59
|
* consumers to add tokens to storage if necessary.
|
|
49
60
|
*/
|
|
50
61
|
this.addTokenResponse = (token) => {
|
|
51
|
-
|
|
62
|
+
var _a;
|
|
63
|
+
(0, index_js_2.getStorage)().set(`${this.configuration.client}:${token.resource_server}`, token);
|
|
52
64
|
if ('other_tokens' in token) {
|
|
53
|
-
token.other_tokens.forEach(this.addTokenResponse);
|
|
65
|
+
(_a = token.other_tokens) === null || _a === void 0 ? void 0 : _a.forEach(this.addTokenResponse);
|
|
54
66
|
}
|
|
55
67
|
tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_checkAuthorizationState).call(this);
|
|
56
68
|
};
|
|
@@ -58,33 +70,84 @@ class AuthorizationManager {
|
|
|
58
70
|
* @todo Add support for passing in an alternative storage mechanism.
|
|
59
71
|
*/
|
|
60
72
|
(0, index_js_2.createStorage)('localStorage');
|
|
61
|
-
if (!configuration.
|
|
62
|
-
throw new Error('You must provide a `
|
|
73
|
+
if (!configuration.client) {
|
|
74
|
+
throw new Error('You must provide a `client` for your application.');
|
|
63
75
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Inject the `openid`, `profile`, `email`, and `offline_access` scopes by default unless
|
|
78
|
+
* explicitly opted out of.
|
|
79
|
+
*/
|
|
80
|
+
const scopes = configuration.defaultScopes === false
|
|
81
|
+
? ''
|
|
82
|
+
: (_a = configuration.defaultScopes) !== null && _a !== void 0 ? _a : DEFAULT_CONFIGURATION.defaultScopes;
|
|
83
|
+
this.configuration = Object.assign(Object.assign({}, configuration), { scopes: `${configuration.scopes}${scopes ? ` ${scopes}` : ''}` });
|
|
69
84
|
this.tokens = new TokenLookup_js_1.TokenLookup({
|
|
70
85
|
manager: this,
|
|
71
86
|
});
|
|
72
|
-
this.startSilentRenew();
|
|
73
|
-
}
|
|
74
|
-
startSilentRenew() {
|
|
75
|
-
(0, logger_js_1.log)('debug', 'AuthorizationManager.startSilentRenew');
|
|
76
87
|
tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_bootstrapFromStorageState).call(this);
|
|
77
|
-
|
|
88
|
+
this.startSilentRefresh();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The user information decoded from the `id_token` (JWT) of the current Globus Auth token.
|
|
92
|
+
* This method can be used instead of `auth.oauth2.userinfo` to get the user information without an additional request.
|
|
93
|
+
*
|
|
94
|
+
* **IMPORTANT**: The `id_token` can only be processed if the `openid` scope is requested during the authorization process.
|
|
95
|
+
*
|
|
96
|
+
* Additionally, the `profile` and `email` scopes are required to get the full user information.
|
|
97
|
+
*
|
|
98
|
+
* @see {@link https://docs.globus.org/api/auth/reference/#oidc_userinfo_endpoint}
|
|
99
|
+
*/
|
|
100
|
+
get user() {
|
|
101
|
+
const token = this.getGlobusAuthToken();
|
|
102
|
+
return token && token.id_token ? (0, jwt_decode_1.jwtDecode)(token.id_token) : null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Start the silent refresh process for the instance.
|
|
106
|
+
* @todo Add interval support for the silent refresh.
|
|
107
|
+
*/
|
|
108
|
+
startSilentRefresh() {
|
|
109
|
+
(0, logger_js_1.log)('debug', `AuthorizationManager.startSilentRefresh | useRefreshTokens=${this.configuration.useRefreshTokens}`);
|
|
110
|
+
/**
|
|
111
|
+
* Silent refresh is only supported when using refresh tokens.
|
|
112
|
+
*/
|
|
113
|
+
if (this.configuration.useRefreshTokens) {
|
|
114
|
+
tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_silentRefreshTokens).call(this);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Use the `refresh_token` attribute of a token to obtain a new access token.
|
|
119
|
+
* @param token The well-formed token with a `refresh_token` attribute.
|
|
120
|
+
*/
|
|
121
|
+
refreshToken(token) {
|
|
122
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
(0, logger_js_1.log)('debug', `AuthorizationManager.refreshToken | resource_server=${token.resource_server}`);
|
|
124
|
+
try {
|
|
125
|
+
const response = yield (yield index_js_1.oauth2.token.refresh({
|
|
126
|
+
payload: {
|
|
127
|
+
client_id: this.configuration.client,
|
|
128
|
+
refresh_token: token.refresh_token,
|
|
129
|
+
grant_type: 'refresh_token',
|
|
130
|
+
},
|
|
131
|
+
})).json();
|
|
132
|
+
if ((0, index_js_1.isGlobusAuthTokenResponse)(response)) {
|
|
133
|
+
this.addTokenResponse(response);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
(0, logger_js_1.log)('error', `AuthorizationManager.refreshToken | resource_server=${token.resource_server}`);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
78
140
|
}
|
|
79
141
|
hasGlobusAuthToken() {
|
|
80
142
|
return this.getGlobusAuthToken() !== null;
|
|
81
143
|
}
|
|
82
144
|
getGlobusAuthToken() {
|
|
83
|
-
const entry = (0, index_js_2.getStorage)().get(`${this.configuration.
|
|
145
|
+
const entry = (0, index_js_2.getStorage)().get(`${this.configuration.client}:auth.globus.org`);
|
|
84
146
|
return entry ? JSON.parse(entry) : null;
|
|
85
147
|
}
|
|
86
148
|
/**
|
|
87
149
|
* Reset the authenticated state and clear all tokens from storage.
|
|
150
|
+
* This method **does not** emit the `revoke` event. If you need to emit the `revoke` event, use the `AuthorizationManager.revoke` method.
|
|
88
151
|
*/
|
|
89
152
|
reset() {
|
|
90
153
|
/**
|
|
@@ -97,6 +160,7 @@ class AuthorizationManager {
|
|
|
97
160
|
* Initiate the login process by redirecting to the Globus Auth login page.
|
|
98
161
|
*/
|
|
99
162
|
login() {
|
|
163
|
+
(0, logger_js_1.log)('debug', 'AuthorizationManager.login');
|
|
100
164
|
this.reset();
|
|
101
165
|
/**
|
|
102
166
|
* In the future, it's possible that we may want to support different types of transports.
|
|
@@ -105,30 +169,38 @@ class AuthorizationManager {
|
|
|
105
169
|
transport.send();
|
|
106
170
|
}
|
|
107
171
|
handleCodeRedirect() {
|
|
108
|
-
return tslib_1.__awaiter(this,
|
|
109
|
-
|
|
172
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (options = { shouldReplace: true }) {
|
|
173
|
+
(0, logger_js_1.log)('debug', 'AuthorizationManager.handleCodeRedirect');
|
|
174
|
+
const response = yield tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_buildTransport).call(this).getToken({
|
|
175
|
+
shouldReplace: options === null || options === void 0 ? void 0 : options.shouldReplace,
|
|
176
|
+
});
|
|
110
177
|
if ((0, index_js_1.isGlobusAuthTokenResponse)(response)) {
|
|
178
|
+
(0, logger_js_1.log)('debug', `AuthorizationManager.handleCodeRedirect | response=${JSON.stringify(response)}`);
|
|
111
179
|
this.addTokenResponse(response);
|
|
112
|
-
this.authenticated = true;
|
|
113
180
|
}
|
|
114
181
|
});
|
|
115
182
|
}
|
|
116
|
-
/**
|
|
117
|
-
* @todo
|
|
118
|
-
*/
|
|
119
183
|
handleErrorResponse(response, execute = true) {
|
|
184
|
+
(0, logger_js_1.log)('debug', `AuthorizationManager.handleErrorResponse | response=${JSON.stringify(response)} execute=${execute}`);
|
|
120
185
|
let handler = () => { };
|
|
121
186
|
if ((0, errors_js_1.isAuthorizationRequirementsError)(response)) {
|
|
187
|
+
(0, logger_js_1.log)('debug', 'AuthorizationManager.handleErrorResponse | error=AuthorizationRequirementsError');
|
|
122
188
|
handler = () => this.handleAuthorizationRequirementsError(response);
|
|
123
189
|
}
|
|
124
190
|
if ((0, errors_js_1.isConsentRequiredError)(response)) {
|
|
191
|
+
(0, logger_js_1.log)('debug', 'AuthorizationManager.handleErrorResponse | error=ConsentRequiredError');
|
|
125
192
|
handler = () => this.handleConsentRequiredError(response);
|
|
126
193
|
}
|
|
127
|
-
if (response
|
|
128
|
-
|
|
194
|
+
if ('code' in response && response['code'] === 'AuthenticationFailed') {
|
|
195
|
+
(0, logger_js_1.log)('debug', 'AuthorizationManager.handleErrorResponse | error=AuthenticationFailed');
|
|
196
|
+
handler = () => this.revoke();
|
|
129
197
|
}
|
|
130
|
-
return execute ? handler() : handler;
|
|
198
|
+
return execute === true ? handler() : handler;
|
|
131
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Process a well-formed Authorization Requirements error response from a Globus service
|
|
202
|
+
* and redirect the user to the Globus Auth login page with the necessary parameters.
|
|
203
|
+
*/
|
|
132
204
|
handleAuthorizationRequirementsError(response) {
|
|
133
205
|
tslib_1.__classPrivateFieldSet(this, _AuthorizationManager_transport, tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_buildTransport).call(this, {
|
|
134
206
|
params: {
|
|
@@ -141,21 +213,40 @@ class AuthorizationManager {
|
|
|
141
213
|
}), "f");
|
|
142
214
|
tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_transport, "f").send();
|
|
143
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Process a well-formed `ConsentRequired` error response from a Globus service
|
|
218
|
+
* and redirect the user to the Globus Auth login page with the necessary parameters.
|
|
219
|
+
*/
|
|
144
220
|
handleConsentRequiredError(response) {
|
|
145
221
|
tslib_1.__classPrivateFieldSet(this, _AuthorizationManager_transport, tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_buildTransport).call(this, {
|
|
146
|
-
requested_scopes: response.required_scopes.join(' '),
|
|
222
|
+
requested_scopes: tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_withOfflineAccess).call(this, response.required_scopes.join(' ')),
|
|
147
223
|
}), "f");
|
|
148
224
|
tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_transport, "f").send();
|
|
149
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Call `AuthroizationManager.reset`, revoke all of the available tokns, and emit the `revoke` event.
|
|
228
|
+
* @emits AuthorizationManager.events#revoke
|
|
229
|
+
* @see AuthorizationManager.reset
|
|
230
|
+
*/
|
|
150
231
|
revoke() {
|
|
151
232
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
(0, logger_js_1.log)('debug', 'AuthorizationManager.revoke');
|
|
234
|
+
const revocation = Promise.all(this.tokens.getAll().map(tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_revokeToken).bind(this)));
|
|
152
235
|
this.reset();
|
|
236
|
+
yield revocation;
|
|
153
237
|
yield this.events.revoke.dispatch();
|
|
154
238
|
});
|
|
155
239
|
}
|
|
156
240
|
}
|
|
157
241
|
exports.AuthorizationManager = AuthorizationManager;
|
|
158
|
-
_AuthorizationManager_transport = new WeakMap(), _AuthorizationManager_authenticated = new WeakMap(), _AuthorizationManager_instances = new WeakSet(),
|
|
242
|
+
_AuthorizationManager_transport = new WeakMap(), _AuthorizationManager_authenticated = new WeakMap(), _AuthorizationManager_instances = new WeakSet(), _AuthorizationManager_silentRefreshTokens = function _AuthorizationManager_silentRefreshTokens() {
|
|
243
|
+
(0, logger_js_1.log)('debug', 'AuthorizationManager.#silentRefreshTokens');
|
|
244
|
+
this.tokens.getAll().forEach((token) => {
|
|
245
|
+
if ((0, index_js_1.isRefreshToken)(token)) {
|
|
246
|
+
this.refreshToken(token);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}, _AuthorizationManager_checkAuthorizationState = function _AuthorizationManager_checkAuthorizationState() {
|
|
159
250
|
(0, logger_js_1.log)('debug', 'AuthorizationManager.#checkAuthorizationState');
|
|
160
251
|
if (this.hasGlobusAuthToken()) {
|
|
161
252
|
this.authenticated = true;
|
|
@@ -166,8 +257,8 @@ _AuthorizationManager_transport = new WeakMap(), _AuthorizationManager_authentic
|
|
|
166
257
|
tslib_1.__classPrivateFieldGet(this, _AuthorizationManager_instances, "m", _AuthorizationManager_checkAuthorizationState).call(this);
|
|
167
258
|
});
|
|
168
259
|
}, _AuthorizationManager_emitAuthenticatedState = function _AuthorizationManager_emitAuthenticatedState() {
|
|
169
|
-
var _a;
|
|
170
260
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
var _a;
|
|
171
262
|
const isAuthenticated = this.authenticated;
|
|
172
263
|
const token = (_a = this.getGlobusAuthToken()) !== null && _a !== void 0 ? _a : undefined;
|
|
173
264
|
yield this.events.authenticated.dispatch({
|
|
@@ -175,7 +266,19 @@ _AuthorizationManager_transport = new WeakMap(), _AuthorizationManager_authentic
|
|
|
175
266
|
token,
|
|
176
267
|
});
|
|
177
268
|
});
|
|
269
|
+
}, _AuthorizationManager_withOfflineAccess = function _AuthorizationManager_withOfflineAccess(scopes) {
|
|
270
|
+
return `${scopes}${this.configuration.useRefreshTokens ? ' offline_access' : ''}`;
|
|
178
271
|
}, _AuthorizationManager_buildTransport = function _AuthorizationManager_buildTransport(overrides) {
|
|
179
|
-
|
|
272
|
+
var _a;
|
|
273
|
+
const scopes = tslib_1.__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);
|
|
274
|
+
return new RedirectTransport_js_1.RedirectTransport(Object.assign({ client_id: this.configuration.client, authorization_endpoint: (0, index_js_1.getAuthorizationEndpoint)(), token_endpoint: (0, index_js_1.getTokenEndpoint)(), redirect_uri: this.configuration.redirect, requested_scopes: scopes }, overrides));
|
|
275
|
+
}, _AuthorizationManager_revokeToken = function _AuthorizationManager_revokeToken(token) {
|
|
276
|
+
(0, logger_js_1.log)('debug', `AuthorizationManager.revokeToken | resource_server=${token.resource_server}`);
|
|
277
|
+
return index_js_1.oauth2.token.revoke({
|
|
278
|
+
payload: {
|
|
279
|
+
client_id: this.configuration.client,
|
|
280
|
+
token: token.access_token,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
180
283
|
};
|
|
181
284
|
//# 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,2CAAuC;AAIvC,2DAMsC;AAEtC,kDAA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AE,CAAC;AACpF,CAAC,uFAEe,SAAuE;;IACrF,MAAM,MAAM,GAAG,+BAAA,IAAI,gFAAmB,MAAvB,IAAI,EACjB,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,gBAAgB,mCAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CACzD,CAAC;IAEF,OAAO,IAAI,wCAAiB,iBAC1B,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EACpC,sBAAsB,EAAE,IAAA,mCAAwB,GAAE,EAClD,cAAc,EAAE,IAAA,2BAAgB,GAAE,EAClC,YAAY,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,EACzC,gBAAgB,EAAE,MAAM,IACrB,SAAS,EAMZ,CAAC;AACL,CAAC,iFA6HY,KAAY;IACvB,IAAA,eAAG,EAAC,OAAO,EAAE,sDAAsD,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC5F,OAAO,iBAAM,CAAC,KAAK,CAAC,MAAM,CAAC;QACzB,OAAO,EAAE;YACP,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;YACpC,KAAK,EAAE,KAAK,CAAC,YAAY;SAC1B;KACF,CAAC,CAAC;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"}
|
|
@@ -15,6 +15,9 @@ class Event {
|
|
|
15
15
|
removeListener(callback) {
|
|
16
16
|
tslib_1.__classPrivateFieldSet(this, _Event_callbacks, tslib_1.__classPrivateFieldGet(this, _Event_callbacks, "f").filter((cb) => cb !== callback), "f");
|
|
17
17
|
}
|
|
18
|
+
clearListeners() {
|
|
19
|
+
tslib_1.__classPrivateFieldSet(this, _Event_callbacks, [], "f");
|
|
20
|
+
}
|
|
18
21
|
dispatch(payload) {
|
|
19
22
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
23
|
yield Promise.all(tslib_1.__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,MAAa,KAAK;IAGhB,YAAqB,IAAe;QAAf,SAAI,GAAJ,IAAI,CAAW;QAFpC,2BAA0C,EAAE,EAAC;IAEN,CAAC;IAExC,WAAW,CAAC,QAAmC;QAC7C,+BAAA,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,+BAAA,IAAI,oBAAc,+BAAA,IAAI,wBAAW,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC,MAAA,CAAC;IACpE,CAAC;IAED,cAAc;QACZ,+BAAA,IAAI,oBAAc,EAAE,MAAA,CAAC;IACvB,CAAC;IAEK,QAAQ,CAAC,OAAiB;;YAC9B,MAAM,OAAO,CAAC,GAAG,CAAC,+BAAA,IAAI,wBAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;KAAA;CACF;AArBD,sBAqBC"}
|
|
@@ -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"}
|
|
@@ -15,23 +15,41 @@ class RedirectTransport {
|
|
|
15
15
|
send() {
|
|
16
16
|
window.location.replace(tslib_1.__classPrivateFieldGet(this, _RedirectTransport_pkce, "f").authorizeUrl(tslib_1.__classPrivateFieldGet(this, _RedirectTransport_params, "f")));
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse the current URL for the authorization code (`?code=...`) and exchange it for an access token when available.
|
|
20
|
+
* - When the URL is processed and exchanged for an access token, the page is redirected to the current URL without the `?code=...&state=...` parameters.
|
|
21
|
+
*/
|
|
18
22
|
getToken() {
|
|
19
|
-
return tslib_1.__awaiter(this,
|
|
23
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (options = { shouldReplace: true }) {
|
|
20
24
|
const url = new URL(window.location.href);
|
|
21
25
|
const params = new URLSearchParams(url.search);
|
|
26
|
+
/**
|
|
27
|
+
* If we don't have a `code` parameter, we can't exchange it for an access token.
|
|
28
|
+
*/
|
|
22
29
|
if (!params.get('code'))
|
|
23
30
|
return undefined;
|
|
24
31
|
const response = yield tslib_1.__classPrivateFieldGet(this, _RedirectTransport_pkce, "f").exchangeForAccessToken(url.toString());
|
|
25
|
-
params.delete('code');
|
|
26
|
-
params.delete('state');
|
|
27
|
-
url.search = params.toString();
|
|
28
32
|
/**
|
|
29
33
|
* Resets js-pkce state
|
|
30
34
|
* @see https://github.com/bpedroza/js-pkce/blob/master/src/PKCE.ts
|
|
31
35
|
*/
|
|
32
36
|
sessionStorage.removeItem('pkce_state');
|
|
33
37
|
sessionStorage.removeItem('pkce_code_verifier');
|
|
34
|
-
|
|
38
|
+
if (options.shouldReplace) {
|
|
39
|
+
/**
|
|
40
|
+
* Remove the `code` and `state` parameters from the URL.
|
|
41
|
+
*/
|
|
42
|
+
params.delete('code');
|
|
43
|
+
params.delete('state');
|
|
44
|
+
/**
|
|
45
|
+
* Update the URL with the new query string.
|
|
46
|
+
*/
|
|
47
|
+
url.search = params.toString();
|
|
48
|
+
/**
|
|
49
|
+
* Redirect the page to the new URL (without the `code` and `state` parameters)/
|
|
50
|
+
*/
|
|
51
|
+
window.location.replace(url);
|
|
52
|
+
}
|
|
35
53
|
return response;
|
|
36
54
|
});
|
|
37
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedirectTransport.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/RedirectTransport.ts"],"names":[],"mappings":";;;;;AAAA,8DAA2B;
|
|
1
|
+
{"version":3,"file":"RedirectTransport.js","sourceRoot":"","sources":["../../../../../src/lib/core/authorization/RedirectTransport.ts"],"names":[],"mappings":";;;;;AAAA,8DAA2B;AAY3B,MAAa,iBAAiB;IAK5B,YACE,OAKC;QAVH,0CAAY;QAEZ,oCAAmB,EAAE,EAAC;QAUpB,MAAM,EAAE,MAAM,KAAgB,OAAO,EAAlB,MAAM,kBAAK,OAAO,EAA/B,UAAqB,CAAU,CAAC;QACtC,+BAAA,IAAI,2BAAS,IAAI,iBAAI,mBAChB,MAAM,EACT,MAAA,CAAC;QACH,+BAAA,IAAI,+CACC,MAAM,OACV,CAAC;IACJ,CAAC;IAED,IAAI;QACF,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,+BAAA,IAAI,+BAAM,CAAC,YAAY,CAAC,+BAAA,IAAI,iCAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACG,QAAQ;qEAAC,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,+BAAA,IAAI,+BAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YACzE;;;eAGG;YACH,cAAc,CAAC,UAAU,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