@lifeready/core 8.0.6 → 8.0.8

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;
@@ -2959,6 +2971,24 @@
2959
2971
  },
2960
2972
  }),
2961
2973
  ]));
2974
+ this.registerProcessor('ScenarioReceiverFileNode', common.series([
2975
+ common.makeDecryptionProcessor({
2976
+ cipherFieldName: 'sharedCipherData',
2977
+ getKeyId: function (_a) {
2978
+ var field = _a.field;
2979
+ return field.sharedKey.id;
2980
+ },
2981
+ }),
2982
+ ]));
2983
+ this.registerProcessor('SharedScenarioReceiverNode', common.series([
2984
+ common.makeDecryptionProcessor({
2985
+ cipherFieldName: 'sharedCipherData',
2986
+ getKeyId: function (_a) {
2987
+ var field = _a.field;
2988
+ return field.sharedKey.id;
2989
+ },
2990
+ }),
2991
+ ]));
2962
2992
  this.registerProcessor('ScenarioApproverAssemblyNode', common.series([
2963
2993
  common.makeDecryptionProcessor({
2964
2994
  cipherFieldName: 'assemblyCipherData',
@@ -10293,7 +10323,7 @@
10293
10323
  })
10294
10324
  ], exports.ɵm);
10295
10325
 
10296
- 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}"])));
10326
+ 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}"])));
10297
10327
  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"])));
10298
10328
  var templateObject_1$m, templateObject_2$h;
10299
10329
 
@@ -10315,6 +10345,8 @@
10315
10345
  _this.encryptionService = encryptionService;
10316
10346
  _this.prepareAddReceiverDirectory = _this.prepareReceiverDirectory;
10317
10347
  _this.prepareUpdateReceiverDirectory = _this.prepareReceiverDirectory;
10348
+ _this.prepareAddReceiverFile = _this.prepareReceiverFile;
10349
+ _this.prepareUpdateReceiverFile = _this.prepareReceiverFile;
10318
10350
  return _this;
10319
10351
  }
10320
10352
  // Scenarios
@@ -10765,74 +10797,139 @@
10765
10797
  });
10766
10798
  });
10767
10799
  };
10768
- ScenarioService.prototype.prepareReceiverDirectory = function (options, receiverSharedKey, assemblyKey) {
10800
+ ScenarioService.prototype.prepareReceiverItem = function (options) {
10769
10801
  return __awaiter(this, void 0, void 0, function () {
10770
- var directoryKey, sharedCipherData, wrappedItemKey;
10802
+ var receiverItemOptions, receiverSharedKey, assemblyKey, directory, file, accessRole, ret, itemKey, wrappedItemKey, sharedCipherData, ret;
10771
10803
  return __generator(this, function (_a) {
10772
10804
  switch (_a.label) {
10773
10805
  case 0:
10774
- if (!(options.accessRole == exports.AccessRoleChoice.DENY)) return [3 /*break*/, 1];
10775
- // Cryptographic access to item is not required.
10776
- return [2 /*return*/, {
10777
- directoryId: options.directoryId,
10778
- accessRole: options.accessRole,
10779
- wrappedItemKey: null,
10780
- sharedCipherData: null,
10781
- }];
10782
- case 1: return [4 /*yield*/, this.itemService.getDirectoryKey(options.directoryId, options.directoryKeyId)];
10806
+ receiverItemOptions = options.receiverItemOptions, receiverSharedKey = options.receiverSharedKey, assemblyKey = options.assemblyKey, directory = options.directory, file = options.file;
10807
+ assert_xor({ directory: directory, file: file });
10808
+ accessRole = receiverItemOptions.accessRole;
10809
+ if (!(accessRole == exports.AccessRoleChoice.DENY)) return [3 /*break*/, 1];
10810
+ ret = {
10811
+ accessRole: accessRole,
10812
+ wrappedItemKey: null,
10813
+ sharedCipherData: null,
10814
+ };
10815
+ if (directory) {
10816
+ // Cryptographic access to item is not required.
10817
+ return [2 /*return*/, Object.assign(Object.assign({}, ret), { directoryId: directory.id })];
10818
+ }
10819
+ else {
10820
+ return [2 /*return*/, Object.assign(Object.assign({}, ret), { fileId: file.id })];
10821
+ }
10822
+ return [3 /*break*/, 9];
10823
+ case 1:
10824
+ itemKey = void 0;
10825
+ if (!directory) return [3 /*break*/, 3];
10826
+ return [4 /*yield*/, this.itemService.getDirectoryKey(directory.id, directory.keyId)];
10783
10827
  case 2:
10784
- directoryKey = _a.sent();
10785
- return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, options.sharedCipherDataClearJson || '')];
10786
- case 3:
10787
- sharedCipherData = _a.sent();
10788
- return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, directoryKey.jwk.toJSON(true))];
10828
+ itemKey = _a.sent();
10829
+ return [3 /*break*/, 5];
10830
+ case 3: return [4 /*yield*/, this.itemService.getFileKey(file.id, file.keyId)];
10789
10831
  case 4:
10832
+ itemKey = _a.sent();
10833
+ _a.label = 5;
10834
+ case 5: return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, itemKey.jwk.toJSON(true))];
10835
+ case 6:
10790
10836
  wrappedItemKey = _a.sent();
10837
+ return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, receiverItemOptions.sharedCipherDataClearJson || '')];
10838
+ case 7:
10839
+ sharedCipherData = _a.sent();
10791
10840
  return [4 /*yield*/, this.keyGraph.encryptToString(assemblyKey, wrappedItemKey)];
10792
- case 5:
10841
+ case 8:
10793
10842
  wrappedItemKey = _a.sent();
10794
- return [2 /*return*/, {
10795
- directoryId: options.directoryId,
10796
- accessRole: options.accessRole,
10797
- wrappedItemKey: wrappedItemKey,
10798
- sharedCipherData: sharedCipherData,
10799
- }];
10843
+ ret = {
10844
+ accessRole: accessRole,
10845
+ wrappedItemKey: wrappedItemKey,
10846
+ sharedCipherData: sharedCipherData,
10847
+ };
10848
+ if (directory) {
10849
+ return [2 /*return*/, Object.assign(Object.assign({}, ret), { directoryId: directory.id })];
10850
+ }
10851
+ else {
10852
+ return [2 /*return*/, Object.assign(Object.assign({}, ret), { fileId: file.id })];
10853
+ }
10854
+ _a.label = 9;
10855
+ case 9: return [2 /*return*/];
10800
10856
  }
10801
10857
  });
10802
10858
  });
10803
10859
  };
10860
+ ScenarioService.prototype.prepareReceiverDirectory = function (options, receiverSharedKey, assemblyKey) {
10861
+ return __awaiter(this, void 0, void 0, function () {
10862
+ return __generator(this, function (_a) {
10863
+ return [2 /*return*/, this.prepareReceiverItem({
10864
+ receiverItemOptions: options,
10865
+ receiverSharedKey: receiverSharedKey,
10866
+ assemblyKey: assemblyKey,
10867
+ directory: {
10868
+ id: options.directoryId,
10869
+ keyId: options.directoryKeyId,
10870
+ },
10871
+ })];
10872
+ });
10873
+ });
10874
+ };
10875
+ ScenarioService.prototype.prepareReceiverFile = function (options, receiverSharedKey, assemblyKey) {
10876
+ return __awaiter(this, void 0, void 0, function () {
10877
+ return __generator(this, function (_a) {
10878
+ return [2 /*return*/, this.prepareReceiverItem({
10879
+ receiverItemOptions: options,
10880
+ receiverSharedKey: receiverSharedKey,
10881
+ assemblyKey: assemblyKey,
10882
+ file: {
10883
+ id: options.fileId,
10884
+ keyId: options.fileKeyId,
10885
+ },
10886
+ })];
10887
+ });
10888
+ });
10889
+ };
10804
10890
  ScenarioService.prototype.prepareCreateReceiver = function (options, assemblyKey) {
10805
10891
  return __awaiter(this, void 0, void 0, function () {
10806
- var _a, sharedKey, mutationInput, addDirectories, _b;
10892
+ var _a, sharedKey, mutationInput, addDirectories, _b, addFiles, _c;
10807
10893
  var _this = this;
10808
- return __generator(this, function (_c) {
10809
- switch (_c.label) {
10894
+ return __generator(this, function (_d) {
10895
+ switch (_d.label) {
10810
10896
  case 0: return [4 /*yield*/, this.prepareCreateParticipant(options)];
10811
10897
  case 1:
10812
- _a = _c.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
10898
+ _a = _d.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
10813
10899
  _b = options.addDirectories;
10814
10900
  if (!_b) return [3 /*break*/, 3];
10815
10901
  return [4 /*yield*/, Promise.all(options.addDirectories.map(function (x) { return _this.prepareAddReceiverDirectory(x, sharedKey.key, assemblyKey); }))];
10816
10902
  case 2:
10817
- _b = (_c.sent());
10818
- _c.label = 3;
10903
+ _b = (_d.sent());
10904
+ _d.label = 3;
10819
10905
  case 3:
10820
10906
  addDirectories = _b;
10821
- return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories })];
10907
+ _c = options.addFiles;
10908
+ if (!_c) return [3 /*break*/, 5];
10909
+ return [4 /*yield*/, Promise.all(options.addFiles.map(function (x) { return _this.prepareAddReceiverFile(x, sharedKey.key, assemblyKey); }))];
10910
+ case 4:
10911
+ _c = (_d.sent());
10912
+ _d.label = 5;
10913
+ case 5:
10914
+ addFiles = _c;
10915
+ return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories,
10916
+ addFiles: addFiles })];
10822
10917
  }
10823
10918
  });
10824
10919
  });
10825
10920
  };
10826
10921
  ScenarioService.prototype.prepareUpdateReceiver = function (options, assemblyKey, existingReceiver) {
10827
10922
  return __awaiter(this, void 0, void 0, function () {
10828
- var sharedKeyId, deleteDirectoriesOptions, updateDirectoriesOptions, _a, sharedKey, mutationInput, addDirectories, _b, updateDirectories;
10923
+ var sharedKeyId, deleteDirectoriesOptions, updateDirectoriesOptions, deleteFilesOptions, updateFilesOptions, _a, sharedKey, mutationInput, addDirectories, _b, addFiles, _c, updateDirectories, updateFiles;
10829
10924
  var _this = this;
10830
- return __generator(this, function (_c) {
10831
- switch (_c.label) {
10925
+ return __generator(this, function (_d) {
10926
+ switch (_d.label) {
10832
10927
  case 0:
10833
10928
  sharedKeyId = existingReceiver.sharedKey.id;
10834
10929
  deleteDirectoriesOptions = options.deleteDirectories || [];
10835
10930
  updateDirectoriesOptions = options.updateDirectories || [];
10931
+ deleteFilesOptions = options.deleteFiles || [];
10932
+ updateFilesOptions = options.updateFiles || [];
10836
10933
  // Fill in any missing update directories
10837
10934
  mapEdges(existingReceiver.receiverItems.receiverDirectories).forEach(function (existingDirectory) {
10838
10935
  if (deleteDirectoriesOptions.includes(existingDirectory.directory.id)) {
@@ -10844,44 +10941,86 @@
10844
10941
  updateDirectoriesOptions.push({
10845
10942
  accessRole: existingDirectory.accessRole,
10846
10943
  directoryId: existingDirectory.directory.id,
10944
+ directoryKeyId: existingDirectory.directory.keyId,
10847
10945
  sharedCipherDataClearJson: existingDirectory.sharedCipherDataClearJson,
10848
10946
  });
10849
10947
  });
10948
+ // Fill in any missing update directories
10949
+ mapEdges(existingReceiver.receiverItems.receiverFiles).forEach(function (existingFile) {
10950
+ if (deleteFilesOptions.includes(existingFile.file.id)) {
10951
+ return;
10952
+ }
10953
+ if (updateFilesOptions.find(function (x) { return x.fileId === existingFile.file.id; })) {
10954
+ return;
10955
+ }
10956
+ updateFilesOptions.push({
10957
+ accessRole: existingFile.accessRole,
10958
+ fileId: existingFile.file.id,
10959
+ fileKeyId: existingFile.file.keyId,
10960
+ sharedCipherDataClearJson: existingFile.sharedCipherDataClearJson,
10961
+ });
10962
+ });
10850
10963
  return [4 /*yield*/, this.prepareUpdateParticipant(options, sharedKeyId)];
10851
10964
  case 1:
10852
- _a = _c.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
10965
+ _a = _d.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
10853
10966
  _b = options.addDirectories;
10854
10967
  if (!_b) return [3 /*break*/, 3];
10855
10968
  return [4 /*yield*/, Promise.all(options.addDirectories.map(function (x) { return _this.prepareAddReceiverDirectory(x, sharedKey, assemblyKey); }))];
10856
10969
  case 2:
10857
- _b = (_c.sent());
10858
- _c.label = 3;
10970
+ _b = (_d.sent());
10971
+ _d.label = 3;
10859
10972
  case 3:
10860
10973
  addDirectories = _b;
10861
- return [4 /*yield*/, Promise.all(updateDirectoriesOptions.map(function (x) { return _this.prepareUpdateReceiverDirectory(x, sharedKey, assemblyKey); }))];
10974
+ _c = options.addFiles;
10975
+ if (!_c) return [3 /*break*/, 5];
10976
+ return [4 /*yield*/, Promise.all(options.addFiles.map(function (x) { return _this.prepareAddReceiverFile(x, sharedKey, assemblyKey); }))];
10862
10977
  case 4:
10863
- updateDirectories = _c.sent();
10978
+ _c = (_d.sent());
10979
+ _d.label = 5;
10980
+ case 5:
10981
+ addFiles = _c;
10982
+ return [4 /*yield*/, Promise.all(updateDirectoriesOptions.map(function (x) { return _this.prepareUpdateReceiverDirectory(x, sharedKey, assemblyKey); }))];
10983
+ case 6:
10984
+ updateDirectories = _d.sent();
10985
+ return [4 /*yield*/, Promise.all(updateFilesOptions.map(function (x) { return _this.prepareUpdateReceiverFile(x, sharedKey, assemblyKey); }))];
10986
+ case 7:
10987
+ updateFiles = _d.sent();
10864
10988
  return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories,
10865
- updateDirectories: updateDirectories, deleteDirectories: options.deleteDirectories })];
10989
+ addFiles: addFiles,
10990
+ updateDirectories: updateDirectories,
10991
+ updateFiles: updateFiles, deleteDirectories: options.deleteDirectories, deleteFiles: options.deleteFiles })];
10866
10992
  }
10867
10993
  });
10868
10994
  });
10869
10995
  };
10870
10996
  ScenarioService.prototype.prepareExistingReceiver = function (existingReceiver, assemblyKey) {
10871
10997
  return __awaiter(this, void 0, void 0, function () {
10872
- var updateDirectories;
10998
+ var updateDirectories, updateFiles;
10873
10999
  return __generator(this, function (_a) {
10874
- updateDirectories = mapEdges(existingReceiver.receiverItems.receiverDirectories).map(function (receiverDirectory) { return ({
10875
- directoryId: receiverDirectory.directory.id,
10876
- directoryKeyId: receiverDirectory.directory.keyId,
10877
- accessRole: receiverDirectory.accessRole,
10878
- sharedCipherDataClearJson: receiverDirectory.sharedCipherDataClearJson,
10879
- }); });
11000
+ updateDirectories = mapEdges(existingReceiver.receiverItems.receiverDirectories).map(function (_a) {
11001
+ var accessRole = _a.accessRole, sharedCipherDataClearJson = _a.sharedCipherDataClearJson, directory = _a.directory;
11002
+ return ({
11003
+ accessRole: accessRole,
11004
+ sharedCipherDataClearJson: sharedCipherDataClearJson,
11005
+ directoryId: directory.id,
11006
+ directoryKeyId: directory.keyId,
11007
+ });
11008
+ });
11009
+ updateFiles = mapEdges(existingReceiver.receiverItems.receiverFiles).map(function (_a) {
11010
+ var accessRole = _a.accessRole, sharedCipherDataClearJson = _a.sharedCipherDataClearJson, file = _a.file;
11011
+ return ({
11012
+ accessRole: accessRole,
11013
+ sharedCipherDataClearJson: sharedCipherDataClearJson,
11014
+ fileId: file.id,
11015
+ fileKeyId: file.keyId,
11016
+ });
11017
+ });
10880
11018
  // Fill it in with existing receiver.
10881
11019
  return [2 /*return*/, this.prepareUpdateReceiver({
10882
11020
  tpId: existingReceiver.tp.id,
10883
11021
  sharedCipherDataClearJson: existingReceiver.sharedCipherDataClearJson,
10884
11022
  updateDirectories: updateDirectories,
11023
+ updateFiles: updateFiles,
10885
11024
  }, assemblyKey, existingReceiver)];
10886
11025
  });
10887
11026
  });