@globus/sdk 5.2.0 → 5.4.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.
Files changed (41) hide show
  1. package/dist/cjs/core/authorization/index.js +10 -5
  2. package/dist/cjs/core/authorization/index.js.map +2 -2
  3. package/dist/cjs/core/info/index.js +1 -1
  4. package/dist/cjs/core/info/index.js.map +1 -1
  5. package/dist/cjs/index.js +104 -15
  6. package/dist/cjs/index.js.map +4 -4
  7. package/dist/cjs/services/globus-connect-server/client.js +1 -1
  8. package/dist/cjs/services/globus-connect-server/client.js.map +1 -1
  9. package/dist/esm/core/authorization/AuthorizationManager.d.ts +2 -1
  10. package/dist/esm/core/authorization/AuthorizationManager.d.ts.map +1 -1
  11. package/dist/esm/core/authorization/AuthorizationManager.js +1 -0
  12. package/dist/esm/core/authorization/AuthorizationManager.js.map +1 -1
  13. package/dist/esm/core/authorization/RedirectTransport.d.ts +8 -0
  14. package/dist/esm/core/authorization/RedirectTransport.d.ts.map +1 -1
  15. package/dist/esm/core/authorization/RedirectTransport.js +6 -1
  16. package/dist/esm/core/authorization/RedirectTransport.js.map +1 -1
  17. package/dist/esm/core/authorization/TokenManager.d.ts +1 -0
  18. package/dist/esm/core/authorization/TokenManager.d.ts.map +1 -1
  19. package/dist/esm/core/authorization/TokenManager.js +3 -0
  20. package/dist/esm/core/authorization/TokenManager.js.map +1 -1
  21. package/dist/esm/core/info/version.d.ts +1 -1
  22. package/dist/esm/core/info/version.js +1 -1
  23. package/dist/esm/package.json +1 -1
  24. package/dist/esm/services/auth/index.d.ts +1 -0
  25. package/dist/esm/services/auth/index.d.ts.map +1 -1
  26. package/dist/esm/services/auth/index.js +1 -0
  27. package/dist/esm/services/auth/index.js.map +1 -1
  28. package/dist/esm/services/auth/service/identities/consents.js +1 -1
  29. package/dist/esm/services/auth/service/identities/consents.js.map +1 -1
  30. package/dist/esm/services/auth/service/identities/index.js +2 -2
  31. package/dist/esm/services/auth/service/identities/index.js.map +1 -1
  32. package/dist/esm/services/auth/service/oauth2/token.d.ts +14 -0
  33. package/dist/esm/services/auth/service/oauth2/token.d.ts.map +1 -1
  34. package/dist/esm/services/auth/service/oauth2/token.js.map +1 -1
  35. package/dist/esm/services/auth/utils.d.ts +24 -0
  36. package/dist/esm/services/auth/utils.d.ts.map +1 -0
  37. package/dist/esm/services/auth/utils.js +122 -0
  38. package/dist/esm/services/auth/utils.js.map +1 -0
  39. package/dist/umd/globus.production.js +2 -2
  40. package/dist/umd/globus.production.js.map +4 -4
  41. 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 = "5.2.0";
74
+ var VERSION = "5.4.0";
75
75
 
76
76
  // src/core/info/index.ts
77
77
  var VERSION2 = VERSION;
@@ -140,7 +140,8 @@ __export(auth_exports, {
140
140
  isGlobusAuthTokenResponse: () => isGlobusAuthTokenResponse,
141
141
  isRefreshToken: () => isRefreshToken,
142
142
  isToken: () => isToken,
143
- oauth2: () => oauth2_exports
143
+ oauth2: () => oauth2_exports,
144
+ utils: () => utils_exports
144
145
  });
145
146
 
146
147
  // src/services/auth/config.ts
@@ -593,7 +594,7 @@ var getAll = function(identity_id, options = {}, sdkOptions) {
593
594
  {
594
595
  service: ID7,
595
596
  scope: SCOPES6.VIEW_IDENTITIES,
596
- path: `/identities/${identity_id}/consents`
597
+ path: `/v2/api/identities/${identity_id}/consents`
597
598
  },
598
599
  options,
599
600
  sdkOptions
@@ -606,7 +607,7 @@ var get = function(identity_id, options = {}, sdkOptions) {
606
607
  {
607
608
  service: ID7,
608
609
  scope: SCOPES6.VIEW_IDENTITIES,
609
- path: `/identities/${identity_id}`
610
+ path: `/v2/api/identities/${identity_id}`
610
611
  },
611
612
  options,
612
613
  sdkOptions
@@ -617,7 +618,7 @@ var getAll2 = function(options = {}, sdkOptions) {
617
618
  {
618
619
  service: ID7,
619
620
  scope: SCOPES6.VIEW_IDENTITIES,
620
- path: `/identities`
621
+ path: `/v2/api/identities`
621
622
  },
622
623
  options,
623
624
  sdkOptions
@@ -755,6 +756,89 @@ var userinfo = function(options, sdkOptions) {
755
756
  );
756
757
  };
757
758
 
759
+ // src/services/auth/utils.ts
760
+ var utils_exports = {};
761
+ __export(utils_exports, {
762
+ hasConsentForScope: () => hasConsentForScope,
763
+ splitScopeString: () => splitScopeString,
764
+ toScopeTree: () => toScopeTree
765
+ });
766
+ function splitScopeString(scope) {
767
+ const scopes = [];
768
+ let currentScope = "";
769
+ let openBrackets = 0;
770
+ scope.split("").forEach((char, i) => {
771
+ currentScope += char;
772
+ if (char === "[") {
773
+ openBrackets += 1;
774
+ }
775
+ if (char === "]") {
776
+ openBrackets -= 1;
777
+ }
778
+ if (char === " " && openBrackets === 0 || i === scope.length - 1 && currentScope) {
779
+ scopes.push(currentScope.trim());
780
+ currentScope = "";
781
+ }
782
+ });
783
+ return scopes;
784
+ }
785
+ function parseScope(s) {
786
+ let parsedScope = s;
787
+ const revocable = parsedScope.startsWith("*");
788
+ if (revocable) {
789
+ parsedScope = parsedScope.replace(/^\*\s*/, "");
790
+ }
791
+ let children = [];
792
+ const firstBracket = parsedScope.indexOf("[");
793
+ if (firstBracket === -1) {
794
+ return {
795
+ scope: parsedScope,
796
+ atomically_revocable: revocable,
797
+ children: []
798
+ };
799
+ }
800
+ const topLevelScope = parsedScope.slice(0, firstBracket);
801
+ const dependentScope = parsedScope.slice(firstBracket + 1, -1);
802
+ children = splitScopeString(dependentScope).map(parseScope);
803
+ return {
804
+ scope: topLevelScope,
805
+ atomically_revocable: revocable,
806
+ children
807
+ };
808
+ }
809
+ function toScopeTree(scope) {
810
+ return splitScopeString(scope).map(parseScope);
811
+ }
812
+ function hasConsentForScope(consents, scope) {
813
+ const tree = toScopeTree(scope);
814
+ function hasConsentEntry(leaf, path) {
815
+ const entry = consents.find(
816
+ (c) => c.scope_name === leaf.scope && /**
817
+ * If a `path` is provided, we need to make sure the entry is at the proper depth.
818
+ */
819
+ (path ? c.dependency_path.join(",") === [...path, c.id].join(",") : (
820
+ /**
821
+ * If there is no `path`, then the entry must be a "top-level" scope.
822
+ */
823
+ c.dependency_path.length === 1
824
+ ))
825
+ );
826
+ if (!entry) return false;
827
+ if (!leaf.children.length) return entry.status === "approved";
828
+ return leaf.children.every(
829
+ (s) => hasConsentEntry(
830
+ s,
831
+ /**
832
+ * If there is a `path`, make sure to pass it down to account for deeply nested scopes, otherwise
833
+ * the `entry` can be considered to "root".
834
+ */
835
+ path ? [...path, entry.id] : [entry.id]
836
+ )
837
+ );
838
+ }
839
+ return tree.every((l) => hasConsentEntry(l));
840
+ }
841
+
758
842
  // src/services/auth/index.ts
759
843
  var CONFIG = config_exports7;
760
844
  function getAuthorizationEndpoint() {
@@ -864,7 +948,7 @@ var RedirectTransport = class _RedirectTransport {
864
948
  * Parse the current URL for the authorization code (`?code=...`) and exchange it for an access token when available.
865
949
  * - When the URL is processed and exchanged for an access token, the page is redirected to the current URL without the `?code=...&state=...` parameters.
866
950
  */
867
- async getToken(options = { shouldReplace: true }) {
951
+ async getToken(options = { shouldReplace: true, includeConsentedScopes: false }) {
868
952
  const url2 = new URL(window.location.href);
869
953
  const params = new URLSearchParams(url2.search);
870
954
  if (params.get("error")) {
@@ -896,6 +980,9 @@ var RedirectTransport = class _RedirectTransport {
896
980
  grant_type: "authorization_code"
897
981
  };
898
982
  const response = await (await oauth2_exports.token.exchange({
983
+ query: options.includeConsentedScopes ? {
984
+ include_consented_scopes: true
985
+ } : void 0,
899
986
  payload
900
987
  })).json();
901
988
  if (options.shouldReplace) {
@@ -997,6 +1084,9 @@ var TokenManager = class {
997
1084
  });
998
1085
  }
999
1086
  }
1087
+ remove(token2) {
1088
+ this.#manager.storage.removeItem(`${this.#manager.storageKeyPrefix}${token2.resource_server}`);
1089
+ }
1000
1090
  /**
1001
1091
  * Determines whether or not a stored token is expired.
1002
1092
  * @param token The token to check.
@@ -1235,8 +1325,6 @@ var AuthorizationManager = class {
1235
1325
  scopes: scopesToRequest,
1236
1326
  ...overrides,
1237
1327
  params: {
1238
- // @todo @todo Decide if we want to include the `include_consented_scopes` parameter by default.
1239
- // include_consented_scopes: 'true',
1240
1328
  ...overrides?.params
1241
1329
  }
1242
1330
  });
@@ -1268,7 +1356,8 @@ var AuthorizationManager = class {
1268
1356
  async handleCodeRedirect(options = { shouldReplace: true, additionalParams: {} }) {
1269
1357
  log("debug", "AuthorizationManager.handleCodeRedirect");
1270
1358
  const response = await this.#buildTransport({ params: options?.additionalParams }).getToken({
1271
- shouldReplace: options?.shouldReplace
1359
+ shouldReplace: options?.shouldReplace,
1360
+ includeConsentedScopes: options?.includeConsentedScopes
1272
1361
  });
1273
1362
  if (isGlobusAuthTokenResponse(response)) {
1274
1363
  log(
@@ -1400,7 +1489,7 @@ __export(transfer_exports, {
1400
1489
  fileOperations: () => file_operations_exports,
1401
1490
  task: () => task_exports,
1402
1491
  taskSubmission: () => task_submission_exports,
1403
- utils: () => utils_exports
1492
+ utils: () => utils_exports2
1404
1493
  });
1405
1494
 
1406
1495
  // src/services/transfer/service/endpoint-search.ts
@@ -2170,8 +2259,8 @@ var getPauseInfo2 = function(task_id, options, sdkOptions) {
2170
2259
  };
2171
2260
 
2172
2261
  // src/services/transfer/utils.ts
2173
- var utils_exports = {};
2174
- __export(utils_exports, {
2262
+ var utils_exports2 = {};
2263
+ __export(utils_exports2, {
2175
2264
  getDomainFromEndpoint: () => getDomainFromEndpoint,
2176
2265
  isDirectory: () => isDirectory,
2177
2266
  isFileDocument: () => isFileDocument,
@@ -2618,7 +2707,7 @@ __export(globus_connect_server_exports, {
2618
2707
  roles: () => roles_exports,
2619
2708
  storageGateways: () => storage_gateways_exports,
2620
2709
  userCredentials: () => user_credentials_exports,
2621
- utils: () => utils_exports2,
2710
+ utils: () => utils_exports3,
2622
2711
  versioning: () => versioning_exports
2623
2712
  });
2624
2713
 
@@ -3182,8 +3271,8 @@ var info = function(configuration, options, sdkOptions) {
3182
3271
  };
3183
3272
 
3184
3273
  // src/services/globus-connect-server/utils.ts
3185
- var utils_exports2 = {};
3186
- __export(utils_exports2, {
3274
+ var utils_exports3 = {};
3275
+ __export(utils_exports3, {
3187
3276
  getEndpointIdFromURL: () => getEndpointIdFromURL,
3188
3277
  getGCSDomainFromURL: () => getGCSDomainFromURL
3189
3278
  });