@globus/sdk 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core/authorization/index.js +50 -6
- 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 +50 -6
- 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/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/search-index.d.ts +13 -7
- 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 +1 -1
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.0";
|
|
75
75
|
|
|
76
76
|
// src/core/info/index.ts
|
|
77
77
|
var VERSION2 = VERSION;
|
|
@@ -991,6 +991,41 @@ var TokenLookup = class {
|
|
|
991
991
|
}, []);
|
|
992
992
|
return entries.filter(isToken);
|
|
993
993
|
}
|
|
994
|
+
/**
|
|
995
|
+
* Add a token to the storage.
|
|
996
|
+
*/
|
|
997
|
+
add(token2) {
|
|
998
|
+
const created = Date.now();
|
|
999
|
+
const expires = created + token2.expires_in * 1e3;
|
|
1000
|
+
getStorage().set(`${this.#manager.storageKeyPrefix}${token2.resource_server}`, {
|
|
1001
|
+
...token2,
|
|
1002
|
+
/**
|
|
1003
|
+
* Add metadata to the token to track when it was created and when it expires.
|
|
1004
|
+
*/
|
|
1005
|
+
__metadata: {
|
|
1006
|
+
created,
|
|
1007
|
+
expires
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
if ("other_tokens" in token2) {
|
|
1011
|
+
token2.other_tokens?.forEach((t) => {
|
|
1012
|
+
this.add(t);
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Determines whether or not a stored token is expired.
|
|
1018
|
+
* @param token The token to check.
|
|
1019
|
+
* @param augment An optional number of milliseconds to add to the current time when checking the expiration.
|
|
1020
|
+
* @returns `true` if the token is expired, `false` if it is not expired, and `undefined` if the expiration status cannot be determined
|
|
1021
|
+
* based on the token's metadata. This can happen if the token is missing the `__metadata` field or the `expires` field.
|
|
1022
|
+
*/
|
|
1023
|
+
static isTokenExpired(token2, augment = 0) {
|
|
1024
|
+
if (!token2 || !token2.__metadata || typeof token2.__metadata.expires !== "number") {
|
|
1025
|
+
return void 0;
|
|
1026
|
+
}
|
|
1027
|
+
return Date.now() + augment >= token2.__metadata.expires;
|
|
1028
|
+
}
|
|
994
1029
|
};
|
|
995
1030
|
|
|
996
1031
|
// src/core/authorization/AuthorizationManager.ts
|
|
@@ -1129,7 +1164,7 @@ var AuthorizationManager = class {
|
|
|
1129
1164
|
* Retrieve the Globus Auth token managed by the instance.
|
|
1130
1165
|
*/
|
|
1131
1166
|
getGlobusAuthToken() {
|
|
1132
|
-
const entry = getStorage().get(`${this.storageKeyPrefix}
|
|
1167
|
+
const entry = getStorage().get(`${this.storageKeyPrefix}${RESOURCE_SERVERS.AUTH}`);
|
|
1133
1168
|
return entry ? JSON.parse(entry) : null;
|
|
1134
1169
|
}
|
|
1135
1170
|
#checkAuthorizationState() {
|
|
@@ -1181,6 +1216,10 @@ var AuthorizationManager = class {
|
|
|
1181
1216
|
}
|
|
1182
1217
|
/**
|
|
1183
1218
|
* Initiate the login process by redirecting to the Globus Auth login page.
|
|
1219
|
+
*
|
|
1220
|
+
* **IMPORTANT**: This method will reset the instance state before initiating the login process,
|
|
1221
|
+
* including clearing all tokens from storage. If you need to maintain the current state,
|
|
1222
|
+
* use the `AuthorizationManager.prompt` method.
|
|
1184
1223
|
*/
|
|
1185
1224
|
async login(options = { additionalParams: {} }) {
|
|
1186
1225
|
log("debug", "AuthorizationManager.login");
|
|
@@ -1188,6 +1227,14 @@ var AuthorizationManager = class {
|
|
|
1188
1227
|
const transport = this.#buildTransport({ params: options?.additionalParams });
|
|
1189
1228
|
await transport.send();
|
|
1190
1229
|
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Prompt the user to authenticate with Globus Auth.
|
|
1232
|
+
*/
|
|
1233
|
+
async prompt(options) {
|
|
1234
|
+
log("debug", "AuthorizationManager.prompt");
|
|
1235
|
+
const transport = this.#buildTransport(options);
|
|
1236
|
+
await transport.send();
|
|
1237
|
+
}
|
|
1191
1238
|
/**
|
|
1192
1239
|
* This method will attempt to complete the PKCE protocol flow.
|
|
1193
1240
|
*/
|
|
@@ -1279,10 +1326,7 @@ var AuthorizationManager = class {
|
|
|
1279
1326
|
* consumers to add tokens to storage if necessary.
|
|
1280
1327
|
*/
|
|
1281
1328
|
addTokenResponse = (token2) => {
|
|
1282
|
-
|
|
1283
|
-
if ("other_tokens" in token2) {
|
|
1284
|
-
token2.other_tokens?.forEach(this.addTokenResponse);
|
|
1285
|
-
}
|
|
1329
|
+
this.tokens.add(token2);
|
|
1286
1330
|
this.#checkAuthorizationState();
|
|
1287
1331
|
};
|
|
1288
1332
|
/**
|