@lifeready/core 8.0.5 → 8.0.7

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.
@@ -659,6 +659,18 @@
659
659
  });
660
660
  });
661
661
  }
662
+ function assert_xor(options) {
663
+ var keys = Object.keys(options);
664
+ if (keys.length != 2) {
665
+ throw new KcBadLogicException('You must provide exactly 2 fields in the argument.');
666
+ }
667
+ if (options[keys[0]] != null && options[keys[1]] != null) {
668
+ throw new KcBadLogicException("You can not specify both " + keys[0] + " and " + keys[1]);
669
+ }
670
+ if (options[keys[0]] == null && options[keys[1]] == null) {
671
+ throw new KcBadLogicException("You must specify either " + keys[0] + " and " + keys[1]);
672
+ }
673
+ }
662
674
 
663
675
  // Ref: https://stackoverflow.com/questions/59735280/angular-8-moment-error-cannot-call-a-namespace-moment
664
676
  var moment = moment___namespace;
@@ -3890,6 +3902,7 @@
3890
3902
  (function (LinkTypeField) {
3891
3903
  LinkTypeField["HARD"] = "HARD";
3892
3904
  LinkTypeField["SOFT"] = "SOFT";
3905
+ LinkTypeField["REFERENCE"] = "REFERENCE";
3893
3906
  })(exports.LinkTypeField || (exports.LinkTypeField = {}));
3894
3907
  (function (PlanStateField) {
3895
3908
  PlanStateField["TRIALLING"] = "TRIALLING";
@@ -7776,19 +7789,29 @@
7776
7789
  // ------------------------------------------------------------------------------
7777
7790
  ItemService.prototype.prepareParentDirectory = function (options, newKey) {
7778
7791
  return __awaiter(this, void 0, void 0, function () {
7779
- var wrappingKey, _d;
7792
+ var directoryId, linkType, wrappingKeyId, wrappingKey, _d;
7780
7793
  return __generator(this, function (_e) {
7781
7794
  switch (_e.label) {
7782
- case 0: return [4 /*yield*/, this.getDirectoryKey(options.directoryId, options.wrappingKeyId)];
7783
- case 1:
7795
+ case 0:
7796
+ directoryId = options.directoryId, linkType = options.linkType, wrappingKeyId = options.wrappingKeyId;
7797
+ if (!(linkType == exports.LinkTypeField.REFERENCE)) return [3 /*break*/, 1];
7798
+ if (wrappingKeyId) {
7799
+ throw new KcBadArgumentException('Do not specify wrappingKeyId when link type is REFERENCE.');
7800
+ }
7801
+ return [2 /*return*/, {
7802
+ directoryId: directoryId,
7803
+ linkType: linkType,
7804
+ }];
7805
+ case 1: return [4 /*yield*/, this.getDirectoryKey(directoryId, wrappingKeyId)];
7806
+ case 2:
7784
7807
  wrappingKey = _e.sent();
7785
7808
  _d = {
7786
- directoryId: options.directoryId,
7809
+ directoryId: directoryId,
7787
7810
  wrappingKeyId: wrappingKey.id
7788
7811
  };
7789
7812
  return [4 /*yield*/, this.keyGraph.wrapKey(wrappingKey, newKey)];
7790
- case 2: return [2 /*return*/, (_d.wrappedKey = _e.sent(),
7791
- _d.linkType = options.linkType,
7813
+ case 3: return [2 /*return*/, (_d.wrappedKey = _e.sent(),
7814
+ _d.linkType = linkType,
7792
7815
  _d)];
7793
7816
  }
7794
7817
  });
@@ -7965,23 +7988,7 @@
7965
7988
  case 0: return [4 /*yield*/, this.keyFactory.createKey()];
7966
7989
  case 1:
7967
7990
  fileKey = _d.sent();
7968
- return [4 /*yield*/, Promise.all(options.parentDirectories.map(function (t) { return __awaiter(_this, void 0, void 0, function () {
7969
- var _d, directoryId, wrappingKeyId, wrappedKey;
7970
- return __generator(this, function (_e) {
7971
- switch (_e.label) {
7972
- case 0: return [4 /*yield*/, this.prepareParentDirectory(t, fileKey)];
7973
- case 1:
7974
- _d = _e.sent(), directoryId = _d.directoryId, wrappingKeyId = _d.wrappingKeyId, wrappedKey = _d.wrappedKey;
7975
- // remap from ParentDirectoryInput to FileParentDirectoryInput
7976
- // TODO the server should really just use wrappedKey instead of wrappedFileKey
7977
- return [2 /*return*/, {
7978
- directoryId: directoryId,
7979
- wrappingKeyId: wrappingKeyId,
7980
- wrappedFileKey: wrappedKey,
7981
- }];
7982
- }
7983
- });
7984
- }); }))];
7991
+ return [4 /*yield*/, Promise.all(options.parentDirectories.map(function (t) { return _this.prepareParentDirectory(t, fileKey); }))];
7985
7992
  case 2:
7986
7993
  parentDirectories = _d.sent();
7987
7994
  return [4 /*yield*/, this.prepareCreateFileState(fileKey, options)];
@@ -10298,7 +10305,7 @@
10298
10305
  })
10299
10306
  ], exports.ɵm);
10300
10307
 
10301
- var ScenarioQuery = gqlTyped(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"], ["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"])));
10308
+ var ScenarioQuery = gqlTyped(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as directory.keyId. It's here so we can detect\n # when the directory key has been rotated.\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as file.keyId. It's here so we can detect\n # when the file key has been rotated.\n itemKey {\n id\n }\n file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"], ["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as directory.keyId. It's here so we can detect\n # when the directory key has been rotated.\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as file.keyId. It's here so we can detect\n # when the file key has been rotated.\n itemKey {\n id\n }\n file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"])));
10302
10309
  var SharedScenarioQuery = gqlTyped(templateObject_2$h || (templateObject_2$h = __makeTemplateObject(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"], ["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));
10303
10310
  var templateObject_1$m, templateObject_2$h;
10304
10311
 
@@ -10320,6 +10327,8 @@
10320
10327
  _this.encryptionService = encryptionService;
10321
10328
  _this.prepareAddReceiverDirectory = _this.prepareReceiverDirectory;
10322
10329
  _this.prepareUpdateReceiverDirectory = _this.prepareReceiverDirectory;
10330
+ _this.prepareAddReceiverFile = _this.prepareReceiverFile;
10331
+ _this.prepareUpdateReceiverFile = _this.prepareReceiverFile;
10323
10332
  return _this;
10324
10333
  }
10325
10334
  // Scenarios
@@ -10770,74 +10779,139 @@
10770
10779
  });
10771
10780
  });
10772
10781
  };
10773
- ScenarioService.prototype.prepareReceiverDirectory = function (options, receiverSharedKey, assemblyKey) {
10782
+ ScenarioService.prototype.prepareReceiverItem = function (options) {
10774
10783
  return __awaiter(this, void 0, void 0, function () {
10775
- var directoryKey, sharedCipherData, wrappedItemKey;
10784
+ var receiverItemOptions, receiverSharedKey, assemblyKey, directory, file, accessRole, ret, itemKey, wrappedItemKey, sharedCipherData, ret;
10776
10785
  return __generator(this, function (_a) {
10777
10786
  switch (_a.label) {
10778
10787
  case 0:
10779
- if (!(options.accessRole == exports.AccessRoleChoice.DENY)) return [3 /*break*/, 1];
10780
- // Cryptographic access to item is not required.
10781
- return [2 /*return*/, {
10782
- directoryId: options.directoryId,
10783
- accessRole: options.accessRole,
10784
- wrappedItemKey: null,
10785
- sharedCipherData: null,
10786
- }];
10787
- case 1: return [4 /*yield*/, this.itemService.getDirectoryKey(options.directoryId, options.directoryKeyId)];
10788
+ receiverItemOptions = options.receiverItemOptions, receiverSharedKey = options.receiverSharedKey, assemblyKey = options.assemblyKey, directory = options.directory, file = options.file;
10789
+ assert_xor({ directory: directory, file: file });
10790
+ accessRole = receiverItemOptions.accessRole;
10791
+ if (!(accessRole == exports.AccessRoleChoice.DENY)) return [3 /*break*/, 1];
10792
+ ret = {
10793
+ accessRole: accessRole,
10794
+ wrappedItemKey: null,
10795
+ sharedCipherData: null,
10796
+ };
10797
+ if (directory) {
10798
+ // Cryptographic access to item is not required.
10799
+ return [2 /*return*/, Object.assign(Object.assign({}, ret), { directoryId: directory.id })];
10800
+ }
10801
+ else {
10802
+ return [2 /*return*/, Object.assign(Object.assign({}, ret), { fileId: file.id })];
10803
+ }
10804
+ return [3 /*break*/, 9];
10805
+ case 1:
10806
+ itemKey = void 0;
10807
+ if (!directory) return [3 /*break*/, 3];
10808
+ return [4 /*yield*/, this.itemService.getDirectoryKey(directory.id, directory.keyId)];
10788
10809
  case 2:
10789
- directoryKey = _a.sent();
10790
- return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, options.sharedCipherDataClearJson || '')];
10791
- case 3:
10792
- sharedCipherData = _a.sent();
10793
- return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, directoryKey.jwk.toJSON(true))];
10810
+ itemKey = _a.sent();
10811
+ return [3 /*break*/, 5];
10812
+ case 3: return [4 /*yield*/, this.itemService.getFileKey(file.id, file.keyId)];
10794
10813
  case 4:
10814
+ itemKey = _a.sent();
10815
+ _a.label = 5;
10816
+ case 5: return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, itemKey.jwk.toJSON(true))];
10817
+ case 6:
10795
10818
  wrappedItemKey = _a.sent();
10819
+ return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, receiverItemOptions.sharedCipherDataClearJson || '')];
10820
+ case 7:
10821
+ sharedCipherData = _a.sent();
10796
10822
  return [4 /*yield*/, this.keyGraph.encryptToString(assemblyKey, wrappedItemKey)];
10797
- case 5:
10823
+ case 8:
10798
10824
  wrappedItemKey = _a.sent();
10799
- return [2 /*return*/, {
10800
- directoryId: options.directoryId,
10801
- accessRole: options.accessRole,
10802
- wrappedItemKey: wrappedItemKey,
10803
- sharedCipherData: sharedCipherData,
10804
- }];
10825
+ ret = {
10826
+ accessRole: accessRole,
10827
+ wrappedItemKey: wrappedItemKey,
10828
+ sharedCipherData: sharedCipherData,
10829
+ };
10830
+ if (directory) {
10831
+ return [2 /*return*/, Object.assign(Object.assign({}, ret), { directoryId: directory.id })];
10832
+ }
10833
+ else {
10834
+ return [2 /*return*/, Object.assign(Object.assign({}, ret), { fileId: file.id })];
10835
+ }
10836
+ _a.label = 9;
10837
+ case 9: return [2 /*return*/];
10805
10838
  }
10806
10839
  });
10807
10840
  });
10808
10841
  };
10842
+ ScenarioService.prototype.prepareReceiverDirectory = function (options, receiverSharedKey, assemblyKey) {
10843
+ return __awaiter(this, void 0, void 0, function () {
10844
+ return __generator(this, function (_a) {
10845
+ return [2 /*return*/, this.prepareReceiverItem({
10846
+ receiverItemOptions: options,
10847
+ receiverSharedKey: receiverSharedKey,
10848
+ assemblyKey: assemblyKey,
10849
+ directory: {
10850
+ id: options.directoryId,
10851
+ keyId: options.directoryKeyId,
10852
+ },
10853
+ })];
10854
+ });
10855
+ });
10856
+ };
10857
+ ScenarioService.prototype.prepareReceiverFile = function (options, receiverSharedKey, assemblyKey) {
10858
+ return __awaiter(this, void 0, void 0, function () {
10859
+ return __generator(this, function (_a) {
10860
+ return [2 /*return*/, this.prepareReceiverItem({
10861
+ receiverItemOptions: options,
10862
+ receiverSharedKey: receiverSharedKey,
10863
+ assemblyKey: assemblyKey,
10864
+ file: {
10865
+ id: options.fileId,
10866
+ keyId: options.fileKeyId,
10867
+ },
10868
+ })];
10869
+ });
10870
+ });
10871
+ };
10809
10872
  ScenarioService.prototype.prepareCreateReceiver = function (options, assemblyKey) {
10810
10873
  return __awaiter(this, void 0, void 0, function () {
10811
- var _a, sharedKey, mutationInput, addDirectories, _b;
10874
+ var _a, sharedKey, mutationInput, addDirectories, _b, addFiles, _c;
10812
10875
  var _this = this;
10813
- return __generator(this, function (_c) {
10814
- switch (_c.label) {
10876
+ return __generator(this, function (_d) {
10877
+ switch (_d.label) {
10815
10878
  case 0: return [4 /*yield*/, this.prepareCreateParticipant(options)];
10816
10879
  case 1:
10817
- _a = _c.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
10880
+ _a = _d.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
10818
10881
  _b = options.addDirectories;
10819
10882
  if (!_b) return [3 /*break*/, 3];
10820
10883
  return [4 /*yield*/, Promise.all(options.addDirectories.map(function (x) { return _this.prepareAddReceiverDirectory(x, sharedKey.key, assemblyKey); }))];
10821
10884
  case 2:
10822
- _b = (_c.sent());
10823
- _c.label = 3;
10885
+ _b = (_d.sent());
10886
+ _d.label = 3;
10824
10887
  case 3:
10825
10888
  addDirectories = _b;
10826
- return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories })];
10889
+ _c = options.addFiles;
10890
+ if (!_c) return [3 /*break*/, 5];
10891
+ return [4 /*yield*/, Promise.all(options.addFiles.map(function (x) { return _this.prepareAddReceiverFile(x, sharedKey.key, assemblyKey); }))];
10892
+ case 4:
10893
+ _c = (_d.sent());
10894
+ _d.label = 5;
10895
+ case 5:
10896
+ addFiles = _c;
10897
+ return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories,
10898
+ addFiles: addFiles })];
10827
10899
  }
10828
10900
  });
10829
10901
  });
10830
10902
  };
10831
10903
  ScenarioService.prototype.prepareUpdateReceiver = function (options, assemblyKey, existingReceiver) {
10832
10904
  return __awaiter(this, void 0, void 0, function () {
10833
- var sharedKeyId, deleteDirectoriesOptions, updateDirectoriesOptions, _a, sharedKey, mutationInput, addDirectories, _b, updateDirectories;
10905
+ var sharedKeyId, deleteDirectoriesOptions, updateDirectoriesOptions, deleteFilesOptions, updateFilesOptions, _a, sharedKey, mutationInput, addDirectories, _b, addFiles, _c, updateDirectories, updateFiles;
10834
10906
  var _this = this;
10835
- return __generator(this, function (_c) {
10836
- switch (_c.label) {
10907
+ return __generator(this, function (_d) {
10908
+ switch (_d.label) {
10837
10909
  case 0:
10838
10910
  sharedKeyId = existingReceiver.sharedKey.id;
10839
10911
  deleteDirectoriesOptions = options.deleteDirectories || [];
10840
10912
  updateDirectoriesOptions = options.updateDirectories || [];
10913
+ deleteFilesOptions = options.deleteFiles || [];
10914
+ updateFilesOptions = options.updateFiles || [];
10841
10915
  // Fill in any missing update directories
10842
10916
  mapEdges(existingReceiver.receiverItems.receiverDirectories).forEach(function (existingDirectory) {
10843
10917
  if (deleteDirectoriesOptions.includes(existingDirectory.directory.id)) {
@@ -10849,44 +10923,86 @@
10849
10923
  updateDirectoriesOptions.push({
10850
10924
  accessRole: existingDirectory.accessRole,
10851
10925
  directoryId: existingDirectory.directory.id,
10926
+ directoryKeyId: existingDirectory.directory.keyId,
10852
10927
  sharedCipherDataClearJson: existingDirectory.sharedCipherDataClearJson,
10853
10928
  });
10854
10929
  });
10930
+ // Fill in any missing update directories
10931
+ mapEdges(existingReceiver.receiverItems.receiverFiles).forEach(function (existingFile) {
10932
+ if (deleteFilesOptions.includes(existingFile.file.id)) {
10933
+ return;
10934
+ }
10935
+ if (updateFilesOptions.find(function (x) { return x.fileId === existingFile.file.id; })) {
10936
+ return;
10937
+ }
10938
+ updateFilesOptions.push({
10939
+ accessRole: existingFile.accessRole,
10940
+ fileId: existingFile.file.id,
10941
+ fileKeyId: existingFile.file.keyId,
10942
+ sharedCipherDataClearJson: existingFile.sharedCipherDataClearJson,
10943
+ });
10944
+ });
10855
10945
  return [4 /*yield*/, this.prepareUpdateParticipant(options, sharedKeyId)];
10856
10946
  case 1:
10857
- _a = _c.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
10947
+ _a = _d.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
10858
10948
  _b = options.addDirectories;
10859
10949
  if (!_b) return [3 /*break*/, 3];
10860
10950
  return [4 /*yield*/, Promise.all(options.addDirectories.map(function (x) { return _this.prepareAddReceiverDirectory(x, sharedKey, assemblyKey); }))];
10861
10951
  case 2:
10862
- _b = (_c.sent());
10863
- _c.label = 3;
10952
+ _b = (_d.sent());
10953
+ _d.label = 3;
10864
10954
  case 3:
10865
10955
  addDirectories = _b;
10866
- return [4 /*yield*/, Promise.all(updateDirectoriesOptions.map(function (x) { return _this.prepareUpdateReceiverDirectory(x, sharedKey, assemblyKey); }))];
10956
+ _c = options.addFiles;
10957
+ if (!_c) return [3 /*break*/, 5];
10958
+ return [4 /*yield*/, Promise.all(options.addFiles.map(function (x) { return _this.prepareAddReceiverFile(x, sharedKey, assemblyKey); }))];
10867
10959
  case 4:
10868
- updateDirectories = _c.sent();
10960
+ _c = (_d.sent());
10961
+ _d.label = 5;
10962
+ case 5:
10963
+ addFiles = _c;
10964
+ return [4 /*yield*/, Promise.all(updateDirectoriesOptions.map(function (x) { return _this.prepareUpdateReceiverDirectory(x, sharedKey, assemblyKey); }))];
10965
+ case 6:
10966
+ updateDirectories = _d.sent();
10967
+ return [4 /*yield*/, Promise.all(updateFilesOptions.map(function (x) { return _this.prepareUpdateReceiverFile(x, sharedKey, assemblyKey); }))];
10968
+ case 7:
10969
+ updateFiles = _d.sent();
10869
10970
  return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories,
10870
- updateDirectories: updateDirectories, deleteDirectories: options.deleteDirectories })];
10971
+ addFiles: addFiles,
10972
+ updateDirectories: updateDirectories,
10973
+ updateFiles: updateFiles, deleteDirectories: options.deleteDirectories, deleteFiles: options.deleteFiles })];
10871
10974
  }
10872
10975
  });
10873
10976
  });
10874
10977
  };
10875
10978
  ScenarioService.prototype.prepareExistingReceiver = function (existingReceiver, assemblyKey) {
10876
10979
  return __awaiter(this, void 0, void 0, function () {
10877
- var updateDirectories;
10980
+ var updateDirectories, updateFiles;
10878
10981
  return __generator(this, function (_a) {
10879
- updateDirectories = mapEdges(existingReceiver.receiverItems.receiverDirectories).map(function (receiverDirectory) { return ({
10880
- directoryId: receiverDirectory.directory.id,
10881
- directoryKeyId: receiverDirectory.directory.keyId,
10882
- accessRole: receiverDirectory.accessRole,
10883
- sharedCipherDataClearJson: receiverDirectory.sharedCipherDataClearJson,
10884
- }); });
10982
+ updateDirectories = mapEdges(existingReceiver.receiverItems.receiverDirectories).map(function (_a) {
10983
+ var accessRole = _a.accessRole, sharedCipherDataClearJson = _a.sharedCipherDataClearJson, directory = _a.directory;
10984
+ return ({
10985
+ accessRole: accessRole,
10986
+ sharedCipherDataClearJson: sharedCipherDataClearJson,
10987
+ directoryId: directory.id,
10988
+ directoryKeyId: directory.keyId,
10989
+ });
10990
+ });
10991
+ updateFiles = mapEdges(existingReceiver.receiverItems.receiverFiles).map(function (_a) {
10992
+ var accessRole = _a.accessRole, sharedCipherDataClearJson = _a.sharedCipherDataClearJson, file = _a.file;
10993
+ return ({
10994
+ accessRole: accessRole,
10995
+ sharedCipherDataClearJson: sharedCipherDataClearJson,
10996
+ fileId: file.id,
10997
+ fileKeyId: file.keyId,
10998
+ });
10999
+ });
10885
11000
  // Fill it in with existing receiver.
10886
11001
  return [2 /*return*/, this.prepareUpdateReceiver({
10887
11002
  tpId: existingReceiver.tp.id,
10888
11003
  sharedCipherDataClearJson: existingReceiver.sharedCipherDataClearJson,
10889
11004
  updateDirectories: updateDirectories,
11005
+ updateFiles: updateFiles,
10890
11006
  }, assemblyKey, existingReceiver)];
10891
11007
  });
10892
11008
  });
@@ -12064,6 +12180,27 @@
12064
12180
  });
12065
12181
  });
12066
12182
  };
12183
+ TrustedPartyService.prototype.deleteFileShare = function (id) {
12184
+ return __awaiter(this, void 0, void 0, function () {
12185
+ return __generator(this, function (_a) {
12186
+ return [2 /*return*/, this.mutate(this.deleteFileShareMutation(id))];
12187
+ });
12188
+ });
12189
+ };
12190
+ TrustedPartyService.prototype.deleteFileShareMutation = function (id) {
12191
+ return __awaiter(this, void 0, void 0, function () {
12192
+ return __generator(this, function (_a) {
12193
+ return [2 /*return*/, new LrMutation({
12194
+ mutation: DeleteFileShareMutation,
12195
+ variables: {
12196
+ input: {
12197
+ id: id,
12198
+ },
12199
+ },
12200
+ })];
12201
+ });
12202
+ });
12203
+ };
12067
12204
  TrustedPartyService.prototype.completeDetachedDirectoryShare = function (options) {
12068
12205
  return __awaiter(this, void 0, void 0, function () {
12069
12206
  return __generator(this, function (_a) {