@lifeready/core 8.0.11 → 8.0.13

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 (32) hide show
  1. package/bundles/lifeready-core.umd.js +212 -45
  2. package/bundles/lifeready-core.umd.js.map +1 -1
  3. package/bundles/lifeready-core.umd.min.js +1 -1
  4. package/bundles/lifeready-core.umd.min.js.map +1 -1
  5. package/esm2015/lib/_common/exceptions.js +4 -1
  6. package/esm2015/lib/_common/index.js +3 -0
  7. package/esm2015/lib/_common/kc-lodash.js +11 -0
  8. package/esm2015/lib/api/lr-graphql/lr-graphql.service.js +2 -2
  9. package/esm2015/lib/api/lr-graphql/lr-merged-mutation.js +2 -2
  10. package/esm2015/lib/api/lr-graphql/lr-mutation.js +2 -2
  11. package/esm2015/lib/api/types/lr-graphql.types.js +1 -1
  12. package/esm2015/lib/auth/auth.service.js +12 -5
  13. package/esm2015/lib/key/key-graph.service.js +5 -5
  14. package/esm2015/lib/profile/profile-details.service.js +5 -5
  15. package/esm2015/lib/scenario/scenario.service.js +5 -1
  16. package/esm2015/lib/scenario/scenario.types.js +1 -1
  17. package/esm2015/lib/trusted-party/trusted-party.gql.private.js +25 -1
  18. package/esm2015/lib/trusted-party/trusted-party.service.js +95 -15
  19. package/esm2015/lib/trusted-party/trusted-party.types.js +1 -1
  20. package/fesm2015/lifeready-core.js +149 -28
  21. package/fesm2015/lifeready-core.js.map +1 -1
  22. package/lib/_common/exceptions.d.ts +1 -0
  23. package/lib/_common/index.d.ts +2 -0
  24. package/lib/_common/kc-lodash.d.ts +5 -0
  25. package/lib/api/types/lr-graphql.types.d.ts +1 -0
  26. package/lib/scenario/scenario.service.d.ts +59 -0
  27. package/lib/scenario/scenario.types.d.ts +2 -0
  28. package/lib/trusted-party/trusted-party.gql.private.d.ts +16 -0
  29. package/lib/trusted-party/trusted-party.service.d.ts +55 -11
  30. package/lib/trusted-party/trusted-party.types.d.ts +6 -2
  31. package/lifeready-core.metadata.json +1 -1
  32. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('apollo-angular'), require('@dagrejs/graphlib'), require('lodash'), require('node-jose'), require('@aws-amplify/auth/lib-esm/Auth'), require('graphql-tag'), require('moment'), require('@apollo/client/core'), require('@apollo/client/link/context'), require('@apollo/client/link/retry'), require('ngx-cookie-service'), require('graphql/language/printer'), require('@angular/common/http'), require('@aws-amplify/core'), require('@ng-idle/core'), require('@ng-idle/keepalive'), require('slip39'), require('@aws-amplify/auth')) :
3
- typeof define === 'function' && define.amd ? define('@lifeready/core', ['exports', '@angular/core', 'apollo-angular', '@dagrejs/graphlib', 'lodash', 'node-jose', '@aws-amplify/auth/lib-esm/Auth', 'graphql-tag', 'moment', '@apollo/client/core', '@apollo/client/link/context', '@apollo/client/link/retry', 'ngx-cookie-service', 'graphql/language/printer', '@angular/common/http', '@aws-amplify/core', '@ng-idle/core', '@ng-idle/keepalive', 'slip39', '@aws-amplify/auth'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.lifeready = global.lifeready || {}, global.lifeready.core = {}), global.ng.core, global['apollo-angular'], global['@dagrejs/graphlib'], global.lodash, global['node-jose'], global['@aws-amplify/auth/lib-esm/Auth'], global['graphql-tag'], global.moment, global['@apollo/client/core'], global['@apollo/client/link/context'], global['@apollo/client/link/retry'], global['ngx-cookie-service'], global['graphql/language/printer'], global.ng.common.http, global['@aws-amplify/core'], global['@ng-idle/core'], global['@ng-idle/keepalive'], global.slip39, global['@aws-amplify/auth']));
5
- }(this, (function (exports, i0, i1, graphlib, _, nodeJose, i4, gql, moment_, core, context, retry, i2, gqlPrinter, i2$1, core$1, i3, i4$1, slip39, Auth) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('apollo-angular'), require('@dagrejs/graphlib'), require('node-jose'), require('@aws-amplify/auth/lib-esm/Auth'), require('graphql-tag'), require('moment'), require('lodash/cloneDeep'), require('lodash/isEqual'), require('lodash/keyBy'), require('lodash/omit'), require('@apollo/client/core'), require('@apollo/client/link/context'), require('@apollo/client/link/retry'), require('ngx-cookie-service'), require('graphql/language/printer'), require('@angular/common/http'), require('@aws-amplify/core'), require('@ng-idle/core'), require('@ng-idle/keepalive'), require('slip39'), require('@aws-amplify/auth')) :
3
+ typeof define === 'function' && define.amd ? define('@lifeready/core', ['exports', '@angular/core', 'apollo-angular', '@dagrejs/graphlib', 'node-jose', '@aws-amplify/auth/lib-esm/Auth', 'graphql-tag', 'moment', 'lodash/cloneDeep', 'lodash/isEqual', 'lodash/keyBy', 'lodash/omit', '@apollo/client/core', '@apollo/client/link/context', '@apollo/client/link/retry', 'ngx-cookie-service', 'graphql/language/printer', '@angular/common/http', '@aws-amplify/core', '@ng-idle/core', '@ng-idle/keepalive', 'slip39', '@aws-amplify/auth'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.lifeready = global.lifeready || {}, global.lifeready.core = {}), global.ng.core, global['apollo-angular'], global['@dagrejs/graphlib'], global['node-jose'], global['@aws-amplify/auth/lib-esm/Auth'], global['graphql-tag'], global.moment, global['lodash/cloneDeep'], global['lodash/isEqual'], null, global['lodash/omit'], global['@apollo/client/core'], global['@apollo/client/link/context'], global['@apollo/client/link/retry'], global['ngx-cookie-service'], global['graphql/language/printer'], global.ng.common.http, global['@aws-amplify/core'], global['@ng-idle/core'], global['@ng-idle/keepalive'], global.slip39, global['@aws-amplify/auth']));
5
+ }(this, (function (exports, i0, i1, graphlib, nodeJose, i4, gql, moment_, lodash$1, lodash$2, keyBy, lodash, core, context, retry, i2, gqlPrinter, i2$1, core$1, i3, i4$1, slip39, Auth) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -27,9 +27,11 @@
27
27
  }
28
28
 
29
29
  var graphlib__default = /*#__PURE__*/_interopDefaultLegacy(graphlib);
30
- var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
31
30
  var gql__default = /*#__PURE__*/_interopDefaultLegacy(gql);
32
31
  var moment___namespace = /*#__PURE__*/_interopNamespace(moment_);
32
+ var lodash__default$1 = /*#__PURE__*/_interopDefaultLegacy(lodash$1);
33
+ var lodash__default$2 = /*#__PURE__*/_interopDefaultLegacy(lodash$2);
34
+ var lodash__default = /*#__PURE__*/_interopDefaultLegacy(lodash);
33
35
  var Auth__default = /*#__PURE__*/_interopDefaultLegacy(Auth);
34
36
 
35
37
  /*! *****************************************************************************
@@ -357,6 +359,8 @@
357
359
  PayloadType["UINT_8_ARRAY"] = "UINT_8_ARRAY";
358
360
  })(PayloadType || (PayloadType = {}));
359
361
 
362
+ // This file is in the "lr-lodash" directory so that we can use the barrel file
363
+
360
364
  function handleApolloError(errors) {
361
365
  if (!errors || !errors.length)
362
366
  return;
@@ -364,6 +368,7 @@
364
368
  return new KcError({
365
369
  code: x.extensions && x.extensions.code,
366
370
  source: x.extensions && x.extensions.source,
371
+ data: x.extensions && lodash__default['default'](x.extensions, ['code', 'source']),
367
372
  message: x.message,
368
373
  debug: {
369
374
  locations: x.locations,
@@ -391,6 +396,7 @@
391
396
  this._type = 'KcError';
392
397
  this.code = options.code;
393
398
  this.source = options.source;
399
+ this.data = options.data;
394
400
  this.message = options.message;
395
401
  this.debug = options.debug;
396
402
  }
@@ -1954,7 +1960,7 @@
1954
1960
  }
1955
1961
  var node = {
1956
1962
  type: KeyGraphNodeType.Key,
1957
- data: ___default['default'].cloneDeep(key),
1963
+ data: lodash__default$1['default'](key),
1958
1964
  };
1959
1965
  this.graph.setNode(key.id, node);
1960
1966
  }
@@ -1977,7 +1983,7 @@
1977
1983
  }
1978
1984
  var edge = {
1979
1985
  type: KeyGraphEdgeType.KeyLink,
1980
- data: ___default['default'].cloneDeep(keyLink),
1986
+ data: lodash__default$1['default'](keyLink),
1981
1987
  };
1982
1988
  // Edge goes from wrapping key to wrapped key.
1983
1989
  this.graph.setEdge(keyLink.wrappingKeyId, keyLink.keyId, edge);
@@ -2001,7 +2007,7 @@
2001
2007
  }
2002
2008
  var edge = {
2003
2009
  type: KeyGraphEdgeType.PassKeyLink,
2004
- data: ___default['default'].cloneDeep(passKeyLink),
2010
+ data: lodash__default$1['default'](passKeyLink),
2005
2011
  };
2006
2012
  // Edge goes from wrapping key to wrapped key.
2007
2013
  this.graph.setEdge(passKeyLink.passKeyId, passKeyLink.keyId, edge);
@@ -3359,7 +3365,7 @@
3359
3365
  */
3360
3366
  LrMutation.prototype.select = function (fragments) {
3361
3367
  // Don't touch the original
3362
- var mutationDoc = _.cloneDeep(this.mutation);
3368
+ var mutationDoc = lodash__default$1['default'](this.mutation);
3363
3369
  var mutationNode = getMutation(mutationDoc);
3364
3370
  var fragmentMap = {};
3365
3371
  getFragments(fragments).forEach(function (fragment) {
@@ -3595,7 +3601,7 @@
3595
3601
  var fragments = getFragments(mutation);
3596
3602
  mergedFragments = __spread(mergedFragments, _this.renameFragmentDefinitions(fragments, prefix));
3597
3603
  });
3598
- var mergedMutation = _.cloneDeep(lrMergedMutationDoc);
3604
+ var mergedMutation = lodash__default$1['default'](lrMergedMutationDoc);
3599
3605
  var mutationNode = getMutation(mergedMutation);
3600
3606
  // Add in the mutation selections
3601
3607
  mutationNode.selectionSet.selections = selections;
@@ -3635,7 +3641,7 @@
3635
3641
  switch (_a.label) {
3636
3642
  case 0:
3637
3643
  // Make copies to avoid side effect.
3638
- options = _.cloneDeep(options);
3644
+ options = lodash__default$1['default'](options);
3639
3645
  includeKeyGraph = this.isIncludeKeyGraph(options.includeKeyGraph);
3640
3646
  if (includeKeyGraph) {
3641
3647
  operation = getQuery(options.query);
@@ -3695,7 +3701,7 @@
3695
3701
  switch (_a.label) {
3696
3702
  case 0:
3697
3703
  // Make copies to avoid side effect.
3698
- options = Object.assign(Object.assign({}, options), { mutation: _.cloneDeep(options.mutation) });
3704
+ options = Object.assign(Object.assign({}, options), { mutation: lodash__default$1['default'](options.mutation) });
3699
3705
  includeKeyGraph = this.isIncludeKeyGraph(options.includeKeyGraph);
3700
3706
  if (includeKeyGraph) {
3701
3707
  operation = getMutation(options.mutation);
@@ -3729,7 +3735,7 @@
3729
3735
  });
3730
3736
  };
3731
3737
  LrGraphQLService.prototype.statsSnapshot = function () {
3732
- return _.cloneDeep(this.stats);
3738
+ return lodash__default$1['default'](this.stats);
3733
3739
  };
3734
3740
  LrGraphQLService.prototype.addKeys = function (response) {
3735
3741
  if (response.data.keyGraph) {
@@ -6858,10 +6864,26 @@
6858
6864
  // Debug utilities
6859
6865
  // ------------------------------------------------------
6860
6866
  AuthService.prototype.debugLogin = function (username, password) {
6861
- // This will fail if debug is null. But when debug is null, this function
6862
- // should not be called.
6863
- this.kcConfig.debug.username = username;
6864
- return this.debugLoadUser(password);
6867
+ return __awaiter(this, void 0, void 0, function () {
6868
+ return __generator(this, function (_b) {
6869
+ switch (_b.label) {
6870
+ case 0:
6871
+ // This will fail if debug is null. But when debug is null, this function
6872
+ // should not be called.
6873
+ this.kcConfig.debug.username = username;
6874
+ // This mechanism only works in a browser session because it needs to set cookies etc.
6875
+ // But it sets the last_login field for the users which we need in some tests.
6876
+ return [4 /*yield*/, this.http
6877
+ .get(this.kcConfig.authUrl + "debug_only/users/login/?username=" + encodeURIComponent(username))
6878
+ .toPromise()];
6879
+ case 1:
6880
+ // This mechanism only works in a browser session because it needs to set cookies etc.
6881
+ // But it sets the last_login field for the users which we need in some tests.
6882
+ _b.sent();
6883
+ return [2 /*return*/, this.debugLoadUser(password)];
6884
+ }
6885
+ });
6886
+ });
6865
6887
  };
6866
6888
  AuthService.prototype.debugLoadUser = function (password) {
6867
6889
  return __awaiter(this, void 0, void 0, function () {
@@ -9921,7 +9943,7 @@
9921
9943
  oldValue: oldValue.value,
9922
9944
  });
9923
9945
  }
9924
- else if (!___default['default'].isEqual(newValue.value, oldValue.value)) {
9946
+ else if (!lodash__default$2['default'](newValue.value, oldValue.value)) {
9925
9947
  changes.push({
9926
9948
  field: field,
9927
9949
  id: oldValue.id,
@@ -9988,7 +10010,7 @@
9988
10010
  break;
9989
10011
  default: {
9990
10012
  var value = details[change.field];
9991
- if (___default['default'].isEqual(value, change.oldValue)) {
10013
+ if (lodash__default$2['default'](value, change.oldValue)) {
9992
10014
  hasChanged = true;
9993
10015
  details[change.field] = change.newValue;
9994
10016
  }
@@ -10024,7 +10046,7 @@
10024
10046
  property = property || { value: field, hasMultiple: false };
10025
10047
  property.values = property.values || [];
10026
10048
  if (property.values.length === 0 ||
10027
- property.values.every(function (x) { return !___default['default'].isEqual(field, x.value); })) {
10049
+ property.values.every(function (x) { return !lodash__default$2['default'](field, x.value); })) {
10028
10050
  property.values.push({
10029
10051
  id: label + "-" + new Date().getTime(),
10030
10052
  label: label,
@@ -10762,6 +10784,7 @@
10762
10784
  createClaimants = _b.sent();
10763
10785
  return [2 /*return*/, {
10764
10786
  enabled: options.enabled,
10787
+ inactiveSeconds: options.inactiveSeconds,
10765
10788
  createAssembly: createAssembly,
10766
10789
  createReceivers: createReceivers,
10767
10790
  createClaimants: createClaimants,
@@ -10864,6 +10887,7 @@
10864
10887
  return [2 /*return*/, {
10865
10888
  scenarioId: options.scenarioId,
10866
10889
  enabled: options.enabled,
10890
+ inactiveSeconds: options.inactiveSeconds,
10867
10891
  updateAssembly: updateAssembly,
10868
10892
  createReceivers: createReceivers,
10869
10893
  updateReceivers: updateReceivers,
@@ -10888,6 +10912,7 @@
10888
10912
  if (!(accessRole == exports.AccessRoleChoice.DENY)) return [3 /*break*/, 1];
10889
10913
  ret = {
10890
10914
  accessRole: accessRole,
10915
+ itemKeyId: null,
10891
10916
  wrappedItemKey: null,
10892
10917
  sharedCipherData: null,
10893
10918
  };
@@ -10921,6 +10946,7 @@
10921
10946
  wrappedItemKey = _a.sent();
10922
10947
  ret = {
10923
10948
  accessRole: accessRole,
10949
+ itemKeyId: itemKey.id,
10924
10950
  wrappedItemKey: wrappedItemKey,
10925
10951
  sharedCipherData: sharedCipherData,
10926
10952
  };
@@ -12093,7 +12119,9 @@
12093
12119
  var templateObject_1$q, templateObject_2$k, templateObject_3$h, templateObject_4$d, templateObject_5$b, templateObject_6$6, templateObject_7$5, templateObject_8$5, templateObject_9$5, templateObject_10$2, templateObject_11$1, templateObject_12$1;
12094
12120
 
12095
12121
  var TpCurrentUserSharedKeyQuery = gqlTyped(templateObject_1$r || (templateObject_1$r = __makeTemplateObject(["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"], ["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"])));
12096
- var templateObject_1$r;
12122
+ var DirectoryShareQuery = gqlTyped(templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\nquery DirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n }\n}\n"], ["\nquery DirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n }\n}\n"])));
12123
+ var FileShareQuery = gqlTyped(templateObject_3$i || (templateObject_3$i = __makeTemplateObject(["\nquery FileShareItemIdQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n }\n}\n"], ["\nquery FileShareItemIdQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n }\n}\n"])));
12124
+ var templateObject_1$r, templateObject_2$l, templateObject_3$i;
12097
12125
 
12098
12126
  exports.TrustedPartyService = /** @class */ (function (_super) {
12099
12127
  __extends(TrustedPartyService, _super);
@@ -12171,12 +12199,28 @@
12171
12199
  };
12172
12200
  TrustedPartyService.prototype.prepareCreateItemShareMutation = function (options) {
12173
12201
  return __awaiter(this, void 0, void 0, function () {
12174
- var itemId, itemKeyId, tpId, tpSharedKeyId, accessRole, isDirectory, shareType, itemKey, wrappingKey, wrappedKey;
12202
+ var itemId, itemKeyId, tpId, tpSharedKeyId, accessRole, isDirectory, shareType, itemKey, wrappingKey, wrappedItemKey;
12175
12203
  var _this = this;
12176
12204
  return __generator(this, function (_a) {
12177
12205
  switch (_a.label) {
12178
12206
  case 0:
12179
12207
  itemId = options.itemId, itemKeyId = options.itemKeyId, tpId = options.tpId, tpSharedKeyId = options.tpSharedKeyId, accessRole = options.accessRole, isDirectory = options.isDirectory, shareType = options.shareType;
12208
+ if (accessRole == exports.AccessRoleChoice.DENY) {
12209
+ if (itemKeyId || tpSharedKeyId) {
12210
+ throw new KcBadArgumentException('If accessRole is AccessRoleChoice.DENY, must not specify any of itemId, itemKeyId, or tpSharedKeyId parameters');
12211
+ }
12212
+ return [2 /*return*/, {
12213
+ input: {
12214
+ itemId: itemId,
12215
+ tpId: tpId,
12216
+ accessRole: accessRole,
12217
+ itemKeyId: null,
12218
+ wrappingKeyId: null,
12219
+ wrappedItemKey: null,
12220
+ shareType: shareType,
12221
+ },
12222
+ }];
12223
+ }
12180
12224
  return [4 /*yield*/, this.keyGraph.getKey(itemKeyId, function () { return isDirectory
12181
12225
  ? _this.itemService.getDirectoryKeyId(itemId)
12182
12226
  : _this.itemService.getFileKeyId(itemId); })];
@@ -12187,15 +12231,15 @@
12187
12231
  wrappingKey = _a.sent();
12188
12232
  return [4 /*yield*/, this.keyGraph.wrapKey(wrappingKey, itemKey.jwk)];
12189
12233
  case 3:
12190
- wrappedKey = _a.sent();
12234
+ wrappedItemKey = _a.sent();
12191
12235
  return [2 /*return*/, {
12192
12236
  input: {
12193
- id: itemId,
12237
+ itemId: itemId,
12194
12238
  tpId: tpId,
12195
12239
  accessRole: accessRole,
12196
- keyId: itemKey.id,
12240
+ itemKeyId: itemKey.id,
12197
12241
  wrappingKeyId: wrappingKey.id,
12198
- wrappedKey: wrappedKey,
12242
+ wrappedItemKey: wrappedItemKey,
12199
12243
  shareType: shareType,
12200
12244
  },
12201
12245
  }];
@@ -12212,11 +12256,18 @@
12212
12256
  };
12213
12257
  TrustedPartyService.prototype.updateDirectoryShareMutation = function (options) {
12214
12258
  return __awaiter(this, void 0, void 0, function () {
12215
- return __generator(this, function (_a) {
12216
- return [2 /*return*/, new LrMutation({
12217
- mutation: UpdateDirectoryShareMutation,
12218
- variables: this.prepareUpdateItemShareMutation(options),
12219
- })];
12259
+ var _a, _b;
12260
+ return __generator(this, function (_c) {
12261
+ switch (_c.label) {
12262
+ case 0:
12263
+ _a = LrMutation.bind;
12264
+ _b = {
12265
+ mutation: UpdateDirectoryShareMutation
12266
+ };
12267
+ return [4 /*yield*/, this.prepareUpdateItemShareMutation(Object.assign(Object.assign({}, options), { isDirectory: true }))];
12268
+ case 1: return [2 /*return*/, new (_a.apply(LrMutation, [void 0, (_b.variables = _c.sent(),
12269
+ _b)]))()];
12270
+ }
12220
12271
  });
12221
12272
  });
12222
12273
  };
@@ -12229,22 +12280,138 @@
12229
12280
  };
12230
12281
  TrustedPartyService.prototype.updateFileShareMutation = function (options) {
12231
12282
  return __awaiter(this, void 0, void 0, function () {
12232
- return __generator(this, function (_a) {
12233
- return [2 /*return*/, new LrMutation({
12234
- mutation: UpdateFileShareMutation,
12235
- variables: this.prepareUpdateItemShareMutation(options),
12236
- })];
12283
+ var _a, _b;
12284
+ return __generator(this, function (_c) {
12285
+ switch (_c.label) {
12286
+ case 0:
12287
+ _a = LrMutation.bind;
12288
+ _b = {
12289
+ mutation: UpdateFileShareMutation
12290
+ };
12291
+ return [4 /*yield*/, this.prepareUpdateItemShareMutation(Object.assign(Object.assign({}, options), { isDirectory: false }))];
12292
+ case 1: return [2 /*return*/, new (_a.apply(LrMutation, [void 0, (_b.variables = _c.sent(),
12293
+ _b)]))()];
12294
+ }
12237
12295
  });
12238
12296
  });
12239
12297
  };
12240
- TrustedPartyService.prototype.prepareUpdateItemShareMutation = function (options) {
12241
- var itemShareId = options.itemShareId, accessRole = options.accessRole;
12242
- return {
12243
- input: {
12298
+ TrustedPartyService.prototype.getDirectoryShare = function (itemShareId) {
12299
+ return this.lrGraphQL.query({
12300
+ query: DirectoryShareQuery,
12301
+ variables: {
12244
12302
  id: itemShareId,
12245
- accessRole: accessRole,
12246
12303
  },
12247
- };
12304
+ });
12305
+ };
12306
+ TrustedPartyService.prototype.getFileShare = function (itemShareId) {
12307
+ return this.lrGraphQL.query({
12308
+ query: FileShareQuery,
12309
+ variables: {
12310
+ id: itemShareId,
12311
+ },
12312
+ });
12313
+ };
12314
+ TrustedPartyService.prototype.prepareUpdateItemShareMutation = function (options) {
12315
+ return __awaiter(this, void 0, void 0, function () {
12316
+ var itemShareId, accessRole, isDirectory, itemId, itemKeyId, tpId, tpSharedKeyId, itemShare, getItemShare, itemKey, wrappingKey, wrappedItemKey;
12317
+ var _this = this;
12318
+ return __generator(this, function (_a) {
12319
+ switch (_a.label) {
12320
+ case 0:
12321
+ itemShareId = options.itemShareId, accessRole = options.accessRole, isDirectory = options.isDirectory, itemId = options.itemId, itemKeyId = options.itemKeyId, tpId = options.tpId, tpSharedKeyId = options.tpSharedKeyId;
12322
+ if (accessRole == exports.AccessRoleChoice.DENY) {
12323
+ if (itemId || itemKeyId || tpId || tpSharedKeyId) {
12324
+ throw new KcBadArgumentException('If accessRole is AccessRoleChoice.DENY, must not specify any of itemId, itemKeyId, tpId, or tpSharedKeyId parameters');
12325
+ }
12326
+ return [2 /*return*/, {
12327
+ input: {
12328
+ id: itemShareId,
12329
+ accessRole: accessRole,
12330
+ itemKeyId: null,
12331
+ wrappingKeyId: null,
12332
+ wrappedItemKey: null,
12333
+ },
12334
+ }];
12335
+ }
12336
+ getItemShare = function () { return __awaiter(_this, void 0, void 0, function () {
12337
+ return __generator(this, function (_a) {
12338
+ switch (_a.label) {
12339
+ case 0:
12340
+ if (!!itemShare) return [3 /*break*/, 4];
12341
+ if (!isDirectory) return [3 /*break*/, 2];
12342
+ return [4 /*yield*/, this.getDirectoryShare(itemShareId)];
12343
+ case 1:
12344
+ itemShare = (_a.sent())
12345
+ .directoryShare;
12346
+ return [3 /*break*/, 4];
12347
+ case 2: return [4 /*yield*/, this.getFileShare(itemShareId)];
12348
+ case 3:
12349
+ itemShare = (_a.sent()).fileShare;
12350
+ _a.label = 4;
12351
+ case 4: return [2 /*return*/, itemShare];
12352
+ }
12353
+ });
12354
+ }); };
12355
+ return [4 /*yield*/, this.keyGraph.getKey(itemKeyId, function () { return __awaiter(_this, void 0, void 0, function () {
12356
+ var itemId_, _a;
12357
+ return __generator(this, function (_b) {
12358
+ switch (_b.label) {
12359
+ case 0:
12360
+ _a = itemId;
12361
+ if (_a) return [3 /*break*/, 2];
12362
+ return [4 /*yield*/, getItemShare()];
12363
+ case 1:
12364
+ _a = (_b.sent()).item.id;
12365
+ _b.label = 2;
12366
+ case 2:
12367
+ itemId_ = _a;
12368
+ if (isDirectory) {
12369
+ return [2 /*return*/, this.itemService.getDirectoryKeyId(itemId_)];
12370
+ }
12371
+ else {
12372
+ return [2 /*return*/, this.itemService.getFileKeyId(itemId_)];
12373
+ }
12374
+ return [2 /*return*/];
12375
+ }
12376
+ });
12377
+ }); })];
12378
+ case 1:
12379
+ itemKey = _a.sent();
12380
+ return [4 /*yield*/, this.keyGraph.getKey(tpSharedKeyId, function () { return __awaiter(_this, void 0, void 0, function () {
12381
+ var tpId_, _a;
12382
+ return __generator(this, function (_b) {
12383
+ switch (_b.label) {
12384
+ case 0:
12385
+ _a = tpId;
12386
+ if (_a) return [3 /*break*/, 2];
12387
+ return [4 /*yield*/, getItemShare()];
12388
+ case 1:
12389
+ _a = (_b.sent()).tp.id;
12390
+ _b.label = 2;
12391
+ case 2:
12392
+ tpId_ = _a;
12393
+ return [4 /*yield*/, this.getTpCurrentUserSharedKey(tpId_)];
12394
+ case 3: return [2 /*return*/, (_b.sent()).sharedKey.id];
12395
+ }
12396
+ });
12397
+ }); })];
12398
+ case 2:
12399
+ wrappingKey = _a.sent();
12400
+ return [4 /*yield*/, this.keyGraph.wrapKey(wrappingKey, itemKey.jwk)];
12401
+ case 3:
12402
+ wrappedItemKey = _a.sent();
12403
+ return [2 /*return*/, {
12404
+ input: {
12405
+ id: itemShareId,
12406
+ accessRole: accessRole,
12407
+ itemKeyId: itemKey.id,
12408
+ wrappingKeyId: wrappingKey.id,
12409
+ wrappedItemKey: wrappedItemKey,
12410
+ },
12411
+ }];
12412
+ }
12413
+ });
12414
+ });
12248
12415
  };
12249
12416
  TrustedPartyService.prototype.deleteDirectoryShare = function (id) {
12250
12417
  return __awaiter(this, void 0, void 0, function () {
@@ -12678,9 +12845,9 @@
12678
12845
  ]; };
12679
12846
 
12680
12847
  var RequestUserDeleteMutation = gql__default['default'](templateObject_1$s || (templateObject_1$s = __makeTemplateObject(["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"], ["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"])));
12681
- var CancelUserDeleteMutation = gql__default['default'](templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"], ["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"])));
12682
- var LoginHistoryQuery = gql__default['default'](templateObject_3$i || (templateObject_3$i = __makeTemplateObject(["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"], ["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"])));
12683
- var templateObject_1$s, templateObject_2$l, templateObject_3$i;
12848
+ var CancelUserDeleteMutation = gql__default['default'](templateObject_2$m || (templateObject_2$m = __makeTemplateObject(["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"], ["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"])));
12849
+ var LoginHistoryQuery = gql__default['default'](templateObject_3$j || (templateObject_3$j = __makeTemplateObject(["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"], ["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"])));
12850
+ var templateObject_1$s, templateObject_2$m, templateObject_3$j;
12684
12851
 
12685
12852
  var UserService = /** @class */ (function () {
12686
12853
  function UserService(lrApollo) {