@globus/sdk 4.2.0 → 4.3.1
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/dist/cjs/core/authorization/index.js +54 -8
- package/dist/cjs/core/authorization/index.js.map +2 -2
- package/dist/cjs/core/info/index.js +1 -1
- package/dist/cjs/core/info/index.js.map +1 -1
- package/dist/cjs/index.js +54 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/services/globus-connect-server/client.js +1 -1
- package/dist/cjs/services/globus-connect-server/client.js.map +1 -1
- package/dist/esm/core/authorization/AuthorizationManager.d.ts +8 -0
- package/dist/esm/core/authorization/AuthorizationManager.d.ts.map +1 -1
- package/dist/esm/core/authorization/AuthorizationManager.js +17 -6
- package/dist/esm/core/authorization/AuthorizationManager.js.map +1 -1
- package/dist/esm/core/authorization/RedirectTransport.d.ts.map +1 -1
- package/dist/esm/core/authorization/RedirectTransport.js +6 -2
- package/dist/esm/core/authorization/RedirectTransport.js.map +1 -1
- package/dist/esm/core/authorization/TokenLookup.d.ts +46 -11
- package/dist/esm/core/authorization/TokenLookup.d.ts.map +1 -1
- package/dist/esm/core/authorization/TokenLookup.js +40 -0
- package/dist/esm/core/authorization/TokenLookup.js.map +1 -1
- package/dist/esm/core/info/version.d.ts +1 -1
- package/dist/esm/core/info/version.js +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/services/auth/types.d.ts +19 -0
- package/dist/esm/services/auth/types.d.ts.map +1 -1
- package/dist/esm/services/search/service/query.d.ts +1 -1
- package/dist/esm/services/search/service/query.d.ts.map +1 -1
- package/dist/esm/services/search/service/search-index.d.ts +13 -16
- package/dist/esm/services/search/service/search-index.d.ts.map +1 -1
- package/dist/esm/services/search/service/search-index.js.map +1 -1
- package/dist/umd/globus.production.js +2 -2
- package/dist/umd/globus.production.js.map +3 -3
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -71,7 +71,7 @@ function toString(info2) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// src/core/info/version.ts
|
|
74
|
-
var VERSION = "4.
|
|
74
|
+
var VERSION = "4.3.1";
|
|
75
75
|
|
|
76
76
|
// src/core/info/index.ts
|
|
77
77
|
var VERSION2 = VERSION;
|
|
@@ -867,7 +867,7 @@ var RedirectTransport = class _RedirectTransport {
|
|
|
867
867
|
async send() {
|
|
868
868
|
const verifier = generateCodeVerifier();
|
|
869
869
|
const challenge = await generateCodeChallenge(verifier);
|
|
870
|
-
const state = generateState();
|
|
870
|
+
const state = this.#options.params?.["state"] ?? generateState();
|
|
871
871
|
sessionStorage.setItem(KEYS.PKCE_CODE_VERIFIER, verifier);
|
|
872
872
|
sessionStorage.setItem(KEYS.PKCE_STATE, state);
|
|
873
873
|
const params = {
|
|
@@ -902,7 +902,9 @@ var RedirectTransport = class _RedirectTransport {
|
|
|
902
902
|
const verifier = sessionStorage.getItem(KEYS.PKCE_CODE_VERIFIER);
|
|
903
903
|
resetPKCE();
|
|
904
904
|
if (params.get("state") !== state) {
|
|
905
|
-
throw new Error(
|
|
905
|
+
throw new Error(
|
|
906
|
+
'Invalid State. The received "state" parameter does not match the expected state.'
|
|
907
|
+
);
|
|
906
908
|
}
|
|
907
909
|
if (!verifier) {
|
|
908
910
|
throw new Error("Invalid Code Verifier");
|
|
@@ -991,6 +993,41 @@ var TokenLookup = class {
|
|
|
991
993
|
}, []);
|
|
992
994
|
return entries.filter(isToken);
|
|
993
995
|
}
|
|
996
|
+
/**
|
|
997
|
+
* Add a token to the storage.
|
|
998
|
+
*/
|
|
999
|
+
add(token2) {
|
|
1000
|
+
const created = Date.now();
|
|
1001
|
+
const expires = created + token2.expires_in * 1e3;
|
|
1002
|
+
getStorage().set(`${this.#manager.storageKeyPrefix}${token2.resource_server}`, {
|
|
1003
|
+
...token2,
|
|
1004
|
+
/**
|
|
1005
|
+
* Add metadata to the token to track when it was created and when it expires.
|
|
1006
|
+
*/
|
|
1007
|
+
__metadata: {
|
|
1008
|
+
created,
|
|
1009
|
+
expires
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
if ("other_tokens" in token2) {
|
|
1013
|
+
token2.other_tokens?.forEach((t) => {
|
|
1014
|
+
this.add(t);
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Determines whether or not a stored token is expired.
|
|
1020
|
+
* @param token The token to check.
|
|
1021
|
+
* @param augment An optional number of milliseconds to add to the current time when checking the expiration.
|
|
1022
|
+
* @returns `true` if the token is expired, `false` if it is not expired, and `undefined` if the expiration status cannot be determined
|
|
1023
|
+
* based on the token's metadata. This can happen if the token is missing the `__metadata` field or the `expires` field.
|
|
1024
|
+
*/
|
|
1025
|
+
static isTokenExpired(token2, augment = 0) {
|
|
1026
|
+
if (!token2 || !token2.__metadata || typeof token2.__metadata.expires !== "number") {
|
|
1027
|
+
return void 0;
|
|
1028
|
+
}
|
|
1029
|
+
return Date.now() + augment >= token2.__metadata.expires;
|
|
1030
|
+
}
|
|
994
1031
|
};
|
|
995
1032
|
|
|
996
1033
|
// src/core/authorization/AuthorizationManager.ts
|
|
@@ -1129,7 +1166,7 @@ var AuthorizationManager = class {
|
|
|
1129
1166
|
* Retrieve the Globus Auth token managed by the instance.
|
|
1130
1167
|
*/
|
|
1131
1168
|
getGlobusAuthToken() {
|
|
1132
|
-
const entry = getStorage().get(`${this.storageKeyPrefix}
|
|
1169
|
+
const entry = getStorage().get(`${this.storageKeyPrefix}${RESOURCE_SERVERS.AUTH}`);
|
|
1133
1170
|
return entry ? JSON.parse(entry) : null;
|
|
1134
1171
|
}
|
|
1135
1172
|
#checkAuthorizationState() {
|
|
@@ -1181,6 +1218,10 @@ var AuthorizationManager = class {
|
|
|
1181
1218
|
}
|
|
1182
1219
|
/**
|
|
1183
1220
|
* Initiate the login process by redirecting to the Globus Auth login page.
|
|
1221
|
+
*
|
|
1222
|
+
* **IMPORTANT**: This method will reset the instance state before initiating the login process,
|
|
1223
|
+
* including clearing all tokens from storage. If you need to maintain the current state,
|
|
1224
|
+
* use the `AuthorizationManager.prompt` method.
|
|
1184
1225
|
*/
|
|
1185
1226
|
async login(options = { additionalParams: {} }) {
|
|
1186
1227
|
log("debug", "AuthorizationManager.login");
|
|
@@ -1188,6 +1229,14 @@ var AuthorizationManager = class {
|
|
|
1188
1229
|
const transport = this.#buildTransport({ params: options?.additionalParams });
|
|
1189
1230
|
await transport.send();
|
|
1190
1231
|
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Prompt the user to authenticate with Globus Auth.
|
|
1234
|
+
*/
|
|
1235
|
+
async prompt(options) {
|
|
1236
|
+
log("debug", "AuthorizationManager.prompt");
|
|
1237
|
+
const transport = this.#buildTransport(options);
|
|
1238
|
+
await transport.send();
|
|
1239
|
+
}
|
|
1191
1240
|
/**
|
|
1192
1241
|
* This method will attempt to complete the PKCE protocol flow.
|
|
1193
1242
|
*/
|
|
@@ -1279,10 +1328,7 @@ var AuthorizationManager = class {
|
|
|
1279
1328
|
* consumers to add tokens to storage if necessary.
|
|
1280
1329
|
*/
|
|
1281
1330
|
addTokenResponse = (token2) => {
|
|
1282
|
-
|
|
1283
|
-
if ("other_tokens" in token2) {
|
|
1284
|
-
token2.other_tokens?.forEach(this.addTokenResponse);
|
|
1285
|
-
}
|
|
1331
|
+
this.tokens.add(token2);
|
|
1286
1332
|
this.#checkAuthorizationState();
|
|
1287
1333
|
};
|
|
1288
1334
|
/**
|