@lifeready/core 8.0.6 → 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.
- package/bundles/lifeready-core.umd.js +168 -47
- package/bundles/lifeready-core.umd.js.map +1 -1
- package/bundles/lifeready-core.umd.min.js +1 -1
- package/bundles/lifeready-core.umd.min.js.map +1 -1
- package/esm2015/lib/_common/utils.js +14 -1
- package/esm2015/lib/api/types/lr-graphql.types.js +1 -1
- package/esm2015/lib/scenario/scenario.private.gql.js +11 -1
- package/esm2015/lib/scenario/scenario.service.js +101 -20
- package/esm2015/lib/scenario/scenario.types.js +1 -1
- package/fesm2015/lifeready-core.js +121 -19
- package/fesm2015/lifeready-core.js.map +1 -1
- package/lib/_common/utils.d.ts +1 -0
- package/lib/api/types/lr-graphql.types.d.ts +2 -2
- package/lib/scenario/scenario.service.d.ts +223 -0
- package/lib/scenario/scenario.types.d.ts +15 -3
- package/lifeready-core.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -10293,7 +10305,7 @@
|
|
|
10293
10305
|
})
|
|
10294
10306
|
], exports.ɵm);
|
|
10295
10307
|
|
|
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}"])));
|
|
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}"])));
|
|
10297
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"])));
|
|
10298
10310
|
var templateObject_1$m, templateObject_2$h;
|
|
10299
10311
|
|
|
@@ -10315,6 +10327,8 @@
|
|
|
10315
10327
|
_this.encryptionService = encryptionService;
|
|
10316
10328
|
_this.prepareAddReceiverDirectory = _this.prepareReceiverDirectory;
|
|
10317
10329
|
_this.prepareUpdateReceiverDirectory = _this.prepareReceiverDirectory;
|
|
10330
|
+
_this.prepareAddReceiverFile = _this.prepareReceiverFile;
|
|
10331
|
+
_this.prepareUpdateReceiverFile = _this.prepareReceiverFile;
|
|
10318
10332
|
return _this;
|
|
10319
10333
|
}
|
|
10320
10334
|
// Scenarios
|
|
@@ -10765,74 +10779,139 @@
|
|
|
10765
10779
|
});
|
|
10766
10780
|
});
|
|
10767
10781
|
};
|
|
10768
|
-
ScenarioService.prototype.
|
|
10782
|
+
ScenarioService.prototype.prepareReceiverItem = function (options) {
|
|
10769
10783
|
return __awaiter(this, void 0, void 0, function () {
|
|
10770
|
-
var
|
|
10784
|
+
var receiverItemOptions, receiverSharedKey, assemblyKey, directory, file, accessRole, ret, itemKey, wrappedItemKey, sharedCipherData, ret;
|
|
10771
10785
|
return __generator(this, function (_a) {
|
|
10772
10786
|
switch (_a.label) {
|
|
10773
10787
|
case 0:
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
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)];
|
|
10783
10809
|
case 2:
|
|
10784
|
-
|
|
10785
|
-
return [
|
|
10786
|
-
case 3:
|
|
10787
|
-
sharedCipherData = _a.sent();
|
|
10788
|
-
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)];
|
|
10789
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:
|
|
10790
10818
|
wrappedItemKey = _a.sent();
|
|
10819
|
+
return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, receiverItemOptions.sharedCipherDataClearJson || '')];
|
|
10820
|
+
case 7:
|
|
10821
|
+
sharedCipherData = _a.sent();
|
|
10791
10822
|
return [4 /*yield*/, this.keyGraph.encryptToString(assemblyKey, wrappedItemKey)];
|
|
10792
|
-
case
|
|
10823
|
+
case 8:
|
|
10793
10824
|
wrappedItemKey = _a.sent();
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
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*/];
|
|
10800
10838
|
}
|
|
10801
10839
|
});
|
|
10802
10840
|
});
|
|
10803
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
|
+
};
|
|
10804
10872
|
ScenarioService.prototype.prepareCreateReceiver = function (options, assemblyKey) {
|
|
10805
10873
|
return __awaiter(this, void 0, void 0, function () {
|
|
10806
|
-
var _a, sharedKey, mutationInput, addDirectories, _b;
|
|
10874
|
+
var _a, sharedKey, mutationInput, addDirectories, _b, addFiles, _c;
|
|
10807
10875
|
var _this = this;
|
|
10808
|
-
return __generator(this, function (
|
|
10809
|
-
switch (
|
|
10876
|
+
return __generator(this, function (_d) {
|
|
10877
|
+
switch (_d.label) {
|
|
10810
10878
|
case 0: return [4 /*yield*/, this.prepareCreateParticipant(options)];
|
|
10811
10879
|
case 1:
|
|
10812
|
-
_a =
|
|
10880
|
+
_a = _d.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
|
|
10813
10881
|
_b = options.addDirectories;
|
|
10814
10882
|
if (!_b) return [3 /*break*/, 3];
|
|
10815
10883
|
return [4 /*yield*/, Promise.all(options.addDirectories.map(function (x) { return _this.prepareAddReceiverDirectory(x, sharedKey.key, assemblyKey); }))];
|
|
10816
10884
|
case 2:
|
|
10817
|
-
_b = (
|
|
10818
|
-
|
|
10885
|
+
_b = (_d.sent());
|
|
10886
|
+
_d.label = 3;
|
|
10819
10887
|
case 3:
|
|
10820
10888
|
addDirectories = _b;
|
|
10821
|
-
|
|
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 })];
|
|
10822
10899
|
}
|
|
10823
10900
|
});
|
|
10824
10901
|
});
|
|
10825
10902
|
};
|
|
10826
10903
|
ScenarioService.prototype.prepareUpdateReceiver = function (options, assemblyKey, existingReceiver) {
|
|
10827
10904
|
return __awaiter(this, void 0, void 0, function () {
|
|
10828
|
-
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;
|
|
10829
10906
|
var _this = this;
|
|
10830
|
-
return __generator(this, function (
|
|
10831
|
-
switch (
|
|
10907
|
+
return __generator(this, function (_d) {
|
|
10908
|
+
switch (_d.label) {
|
|
10832
10909
|
case 0:
|
|
10833
10910
|
sharedKeyId = existingReceiver.sharedKey.id;
|
|
10834
10911
|
deleteDirectoriesOptions = options.deleteDirectories || [];
|
|
10835
10912
|
updateDirectoriesOptions = options.updateDirectories || [];
|
|
10913
|
+
deleteFilesOptions = options.deleteFiles || [];
|
|
10914
|
+
updateFilesOptions = options.updateFiles || [];
|
|
10836
10915
|
// Fill in any missing update directories
|
|
10837
10916
|
mapEdges(existingReceiver.receiverItems.receiverDirectories).forEach(function (existingDirectory) {
|
|
10838
10917
|
if (deleteDirectoriesOptions.includes(existingDirectory.directory.id)) {
|
|
@@ -10844,44 +10923,86 @@
|
|
|
10844
10923
|
updateDirectoriesOptions.push({
|
|
10845
10924
|
accessRole: existingDirectory.accessRole,
|
|
10846
10925
|
directoryId: existingDirectory.directory.id,
|
|
10926
|
+
directoryKeyId: existingDirectory.directory.keyId,
|
|
10847
10927
|
sharedCipherDataClearJson: existingDirectory.sharedCipherDataClearJson,
|
|
10848
10928
|
});
|
|
10849
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
|
+
});
|
|
10850
10945
|
return [4 /*yield*/, this.prepareUpdateParticipant(options, sharedKeyId)];
|
|
10851
10946
|
case 1:
|
|
10852
|
-
_a =
|
|
10947
|
+
_a = _d.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
|
|
10853
10948
|
_b = options.addDirectories;
|
|
10854
10949
|
if (!_b) return [3 /*break*/, 3];
|
|
10855
10950
|
return [4 /*yield*/, Promise.all(options.addDirectories.map(function (x) { return _this.prepareAddReceiverDirectory(x, sharedKey, assemblyKey); }))];
|
|
10856
10951
|
case 2:
|
|
10857
|
-
_b = (
|
|
10858
|
-
|
|
10952
|
+
_b = (_d.sent());
|
|
10953
|
+
_d.label = 3;
|
|
10859
10954
|
case 3:
|
|
10860
10955
|
addDirectories = _b;
|
|
10861
|
-
|
|
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); }))];
|
|
10862
10959
|
case 4:
|
|
10863
|
-
|
|
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();
|
|
10864
10970
|
return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories,
|
|
10865
|
-
|
|
10971
|
+
addFiles: addFiles,
|
|
10972
|
+
updateDirectories: updateDirectories,
|
|
10973
|
+
updateFiles: updateFiles, deleteDirectories: options.deleteDirectories, deleteFiles: options.deleteFiles })];
|
|
10866
10974
|
}
|
|
10867
10975
|
});
|
|
10868
10976
|
});
|
|
10869
10977
|
};
|
|
10870
10978
|
ScenarioService.prototype.prepareExistingReceiver = function (existingReceiver, assemblyKey) {
|
|
10871
10979
|
return __awaiter(this, void 0, void 0, function () {
|
|
10872
|
-
var updateDirectories;
|
|
10980
|
+
var updateDirectories, updateFiles;
|
|
10873
10981
|
return __generator(this, function (_a) {
|
|
10874
|
-
updateDirectories = mapEdges(existingReceiver.receiverItems.receiverDirectories).map(function (
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
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
|
+
});
|
|
10880
11000
|
// Fill it in with existing receiver.
|
|
10881
11001
|
return [2 /*return*/, this.prepareUpdateReceiver({
|
|
10882
11002
|
tpId: existingReceiver.tp.id,
|
|
10883
11003
|
sharedCipherDataClearJson: existingReceiver.sharedCipherDataClearJson,
|
|
10884
11004
|
updateDirectories: updateDirectories,
|
|
11005
|
+
updateFiles: updateFiles,
|
|
10885
11006
|
}, assemblyKey, existingReceiver)];
|
|
10886
11007
|
});
|
|
10887
11008
|
});
|