@lifeready/core 1.0.11 → 1.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 (36) hide show
  1. package/bundles/lifeready-core.umd.js +1017 -66
  2. package/bundles/lifeready-core.umd.js.map +1 -1
  3. package/bundles/lifeready-core.umd.min.js +2 -2
  4. package/bundles/lifeready-core.umd.min.js.map +1 -1
  5. package/esm2015/lib/api/types/lr-graphql.types.js +1 -1
  6. package/esm2015/lib/scenario/scenario.constants.js +2 -0
  7. package/esm2015/lib/scenario/scenario.controller.js +34 -0
  8. package/esm2015/lib/scenario/scenario.gql.js +72 -0
  9. package/esm2015/lib/scenario/scenario.gql.private.js +198 -0
  10. package/esm2015/lib/scenario/scenario.service.js +538 -0
  11. package/esm2015/lib/scenario/scenario.types.js +1 -0
  12. package/esm2015/lib/trusted-parties/tp-assembly.gql.private.js +22 -0
  13. package/esm2015/lib/trusted-parties/tp-assembly.js +96 -12
  14. package/esm2015/lib/trusted-parties/tp-assembly.types.js +1 -0
  15. package/esm2015/lib/trusted-parties/tp-password-reset.controller.js +4 -1
  16. package/esm2015/lib/trusted-parties/tp-password-reset.service.js +1 -1
  17. package/esm2015/lifeready-core.js +2 -1
  18. package/esm2015/public-api.js +4 -1
  19. package/fesm2015/lifeready-core.js +933 -12
  20. package/fesm2015/lifeready-core.js.map +1 -1
  21. package/lib/api/types/lr-graphql.types.d.ts +2 -0
  22. package/lib/scenario/scenario.constants.d.ts +1 -0
  23. package/lib/scenario/scenario.controller.d.ts +10 -0
  24. package/lib/scenario/scenario.gql.d.ts +62 -0
  25. package/lib/scenario/scenario.gql.private.d.ts +16 -0
  26. package/lib/scenario/scenario.service.d.ts +233 -0
  27. package/lib/scenario/scenario.types.d.ts +50 -0
  28. package/lib/trusted-parties/tp-assembly.d.ts +7 -36
  29. package/lib/trusted-parties/tp-assembly.gql.private.d.ts +5 -0
  30. package/lib/trusted-parties/tp-assembly.types.d.ts +38 -0
  31. package/lib/trusted-parties/tp-password-reset.controller.d.ts +2 -0
  32. package/lib/trusted-parties/tp-password-reset.service.d.ts +1 -1
  33. package/lifeready-core.d.ts +1 -0
  34. package/lifeready-core.metadata.json +1 -1
  35. package/package.json +1 -1
  36. package/public-api.d.ts +3 -0
@@ -5514,12 +5514,9 @@
5514
5514
  var TP_PASSWORD_RESET_SLIP39_PASSPHRASE = 'lifeready';
5515
5515
  var TP_PASSWORD_RESET_USERNAME_SUFFIX = '.tp_password_reset';
5516
5516
 
5517
- // export interface PrepareUpdateAssembly {
5518
- // subjectKeyId: string;
5519
- // subAssemblies: PrepareUpdateSubAssemblies;
5520
- // }
5521
- // export interface PrepareUpdateSubAssemblies {
5522
- // }
5517
+ var TpsKeysQuery = gqlTyped(templateObject_1$a || (templateObject_1$a = __makeTemplateObject(["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"], ["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"])));
5518
+ var templateObject_1$a;
5519
+
5523
5520
  var TpAssemblyController = /** @class */ (function () {
5524
5521
  function TpAssemblyController(injector) {
5525
5522
  this.keyFactory = injector.get(KeyFactoryService);
@@ -5527,6 +5524,7 @@
5527
5524
  this.encryptionService = injector.get(EncryptionService);
5528
5525
  this.keyGraph = injector.get(KeyGraphService);
5529
5526
  this.slip39Service = injector.get(Slip39Service);
5527
+ this.lrGraphQl = injector.get(exports.ɵb);
5530
5528
  }
5531
5529
  TpAssemblyController.prototype.recoverAssemblyKey = function (partials) {
5532
5530
  return __awaiter(this, void 0, void 0, function () {
@@ -5719,37 +5717,70 @@
5719
5717
  });
5720
5718
  });
5721
5719
  };
5720
+ TpAssemblyController.prototype.fillWrappingKeyId = function (input, tps) {
5721
+ var _this = this;
5722
+ // Fill in wrappingKeyId if not present
5723
+ input.forEach(function (sa) {
5724
+ sa.approverTps.forEach(function (approver) {
5725
+ if (!approver.wrappingKeyId) {
5726
+ var tp = tps.find(function (x) { return x.id === approver.tpId; });
5727
+ approver.wrappingKeyId = _this.getTpWrappingKeyId(tp);
5728
+ }
5729
+ });
5730
+ });
5731
+ };
5732
+ TpAssemblyController.prototype.getInputApprovers = function (input) {
5733
+ var tpIds = [];
5734
+ input.forEach(function (sa) {
5735
+ sa.approverTps.forEach(function (approver) {
5736
+ tpIds.push(approver.tpId);
5737
+ });
5738
+ });
5739
+ return tpIds;
5740
+ };
5722
5741
  TpAssemblyController.prototype.prepareCreate = function (input) {
5723
5742
  return __awaiter(this, void 0, void 0, function () {
5724
- var rootKey, subjectKey, rootKeyWrappedSubjectKey, _a, assemblyKey, rawAssemblyKey, assemblyKeyParams, assemblyInput, slipAssembly, createSubAssemblies;
5725
- return __generator(this, function (_b) {
5726
- switch (_b.label) {
5743
+ var rootKey, subjectKey, rootKeyWrappedSubjectKey, _a, assemblyKey, rawAssemblyKey, assemblyKeyParams, assemblyInput, slipAssembly, tpIds, tps, _b, createSubAssemblies;
5744
+ return __generator(this, function (_c) {
5745
+ switch (_c.label) {
5727
5746
  case 0: return [4 /*yield*/, this.keyService.getCurrentRootKey()];
5728
5747
  case 1:
5729
- rootKey = _b.sent();
5748
+ rootKey = _c.sent();
5730
5749
  return [4 /*yield*/, this.keyFactory.createKey()];
5731
5750
  case 2:
5732
- subjectKey = _b.sent();
5751
+ subjectKey = _c.sent();
5733
5752
  return [4 /*yield*/, this.keyGraph.wrapKey(rootKey, subjectKey)];
5734
5753
  case 3:
5735
- rootKeyWrappedSubjectKey = _b.sent();
5754
+ rootKeyWrappedSubjectKey = _c.sent();
5736
5755
  return [4 /*yield*/, this.prepareAssembly({
5737
5756
  rootKey: rootKey.jwk,
5738
5757
  subjectKey: subjectKey,
5739
5758
  })];
5740
5759
  case 4:
5741
- _a = _b.sent(), assemblyKey = _a.assemblyKey, rawAssemblyKey = _a.rawAssemblyKey, assemblyKeyParams = _a.assemblyKeyParams, assemblyInput = __rest(_a, ["assemblyKey", "rawAssemblyKey", "assemblyKeyParams"]);
5760
+ _a = _c.sent(), assemblyKey = _a.assemblyKey, rawAssemblyKey = _a.rawAssemblyKey, assemblyKeyParams = _a.assemblyKeyParams, assemblyInput = __rest(_a, ["assemblyKey", "rawAssemblyKey", "assemblyKeyParams"]);
5742
5761
  return [4 /*yield*/, this.prepareSlip39(input.createSubAssemblies, input.quorum, rawAssemblyKey)];
5743
5762
  case 5:
5744
- slipAssembly = _b.sent();
5763
+ slipAssembly = _c.sent();
5764
+ tpIds = this.getInputApprovers(input.createSubAssemblies);
5765
+ _b = mapEdges;
5766
+ return [4 /*yield*/, this.lrGraphQl.query({
5767
+ query: TpsKeysQuery,
5768
+ variables: {
5769
+ ids: tpIds,
5770
+ },
5771
+ })];
5772
+ case 6:
5773
+ tps = _b.apply(void 0, [(_c.sent()).tps]);
5774
+ // Fill in wrappingKeyId if not present
5775
+ this.fillWrappingKeyId(input.createSubAssemblies, tps);
5745
5776
  return [4 /*yield*/, this.prepareCreateSubAssemblies({
5746
5777
  input: input.createSubAssemblies,
5747
5778
  assemblyKeyParams: assemblyKeyParams,
5748
5779
  slipSubAssemblies: slipAssembly.subAssemblies,
5749
5780
  subjectKey: subjectKey,
5750
5781
  })];
5751
- case 6:
5752
- createSubAssemblies = _b.sent();
5782
+ case 7:
5783
+ createSubAssemblies = _c.sent();
5753
5784
  return [2 /*return*/, {
5754
5785
  assemblyKey: assemblyKey,
5755
5786
  mutationInput: Object.assign(Object.assign({}, assemblyInput), { singleReject: input.singleReject, quorum: input.quorum, subjectCipherData: '', // TODO make this a parameter
@@ -5759,53 +5790,109 @@
5759
5790
  });
5760
5791
  });
5761
5792
  };
5793
+ TpAssemblyController.prototype.getAssemblyApprovers = function (assembly) {
5794
+ var tpIds = [];
5795
+ // Find all TPs that belong to sub-assemblies
5796
+ mapEdges(assembly.subAssemblies).map(function (sa) {
5797
+ mapEdges(sa.approvers).forEach(function (approver) { return tpIds.push(approver.tp.id); });
5798
+ });
5799
+ return tpIds;
5800
+ };
5762
5801
  TpAssemblyController.prototype.prepareUpdate = function (input, assembly // TODO type this to only what we need.
5763
5802
  ) {
5764
5803
  return __awaiter(this, void 0, void 0, function () {
5765
- var rootKey, subjectKey, _a, assemblyKey, rawAssemblyKey, assemblyKeyParams, assemblyInput, slipAssembly, error_1, common, createSubAssemblies, updateSubAssemblies;
5766
- return __generator(this, function (_b) {
5767
- switch (_b.label) {
5804
+ var createSubAssembliesInput, updateSubAssembliesInput, deleteSubAssembliesInput, rootKey, subjectKey, _a, assemblyKey, rawAssemblyKey, assemblyKeyParams, assemblyInput, tpIds, tps, _b, slipAssembly, error_1, common, createSubAssemblies, updateSubAssemblies;
5805
+ return __generator(this, function (_c) {
5806
+ switch (_c.label) {
5768
5807
  case 0:
5769
5808
  input = Object.assign({ createSubAssemblies: [] }, input);
5809
+ createSubAssembliesInput = input.createSubAssemblies || [];
5810
+ updateSubAssembliesInput = input.updateSubAssemblies || [];
5811
+ deleteSubAssembliesInput = input.deleteSubAssemblies || [];
5812
+ // Must have at least one.
5813
+ if (createSubAssembliesInput.length === 0 &&
5814
+ updateSubAssembliesInput.length === 0 &&
5815
+ deleteSubAssembliesInput.length === 0) {
5816
+ throw new LrBadArgumentException('Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]');
5817
+ }
5770
5818
  return [4 /*yield*/, this.keyService.getCurrentRootKey()];
5771
5819
  case 1:
5772
- rootKey = _b.sent();
5820
+ rootKey = _c.sent();
5773
5821
  return [4 /*yield*/, this.keyGraph.getKey(assembly.subjectKey.id)];
5774
5822
  case 2:
5775
- subjectKey = _b.sent();
5823
+ subjectKey = _c.sent();
5776
5824
  return [4 /*yield*/, this.prepareAssembly({
5777
5825
  rootKey: rootKey.jwk,
5778
5826
  subjectKey: subjectKey.jwk,
5779
5827
  })];
5780
5828
  case 3:
5781
- _a = _b.sent(), assemblyKey = _a.assemblyKey, rawAssemblyKey = _a.rawAssemblyKey, assemblyKeyParams = _a.assemblyKeyParams, assemblyInput = __rest(_a, ["assemblyKey", "rawAssemblyKey", "assemblyKeyParams"]);
5782
- _b.label = 4;
5829
+ _a = _c.sent(), assemblyKey = _a.assemblyKey, rawAssemblyKey = _a.rawAssemblyKey, assemblyKeyParams = _a.assemblyKeyParams, assemblyInput = __rest(_a, ["assemblyKey", "rawAssemblyKey", "assemblyKeyParams"]);
5830
+ tpIds = this.getAssemblyApprovers(assembly).concat(this.getInputApprovers(createSubAssembliesInput), this.getInputApprovers(updateSubAssembliesInput));
5831
+ _b = mapEdges;
5832
+ return [4 /*yield*/, this.lrGraphQl.query({
5833
+ query: TpsKeysQuery,
5834
+ variables: {
5835
+ ids: tpIds,
5836
+ },
5837
+ })];
5783
5838
  case 4:
5784
- _b.trys.push([4, 6, , 7]);
5785
- return [4 /*yield*/, this.prepareSlip39((input.createSubAssemblies || []).concat(input.updateSubAssemblies || []), input.quorum, rawAssemblyKey)];
5839
+ tps = _b.apply(void 0, [(_c.sent()).tps]);
5840
+ // Auto fill the updateSubAssemblies with existing sub assemblies if they are not
5841
+ // explicitly deleted.
5842
+ mapEdges(assembly.subAssemblies).forEach(function (existing) {
5843
+ // Deleting existing, don't include it
5844
+ if (deleteSubAssembliesInput.includes(existing.id)) {
5845
+ return;
5846
+ }
5847
+ // Update already specified in the input
5848
+ if (updateSubAssembliesInput.some(function (sa) { return sa.id === existing.id; })) {
5849
+ return;
5850
+ }
5851
+ var approverTps = mapEdges(existing.approvers).map(function (approver) {
5852
+ return {
5853
+ tpId: approver.tp.id,
5854
+ sharedCipherDataClearJson: approver.sharedCipherDataClearJson,
5855
+ sharedCipherApprovalDataClearJson: approver.sharedCipherApprovalDataClearJson,
5856
+ };
5857
+ });
5858
+ updateSubAssembliesInput.push({
5859
+ id: existing.id,
5860
+ quorum: existing.quorum,
5861
+ singleReject: existing.singleReject,
5862
+ approverTps: approverTps,
5863
+ subjectCipherDataClearJson: existing.subjectCipherDataClearJson,
5864
+ });
5865
+ });
5866
+ // Fill in wrappingKeyId if not present
5867
+ this.fillWrappingKeyId(createSubAssembliesInput, tps);
5868
+ this.fillWrappingKeyId(updateSubAssembliesInput, tps);
5869
+ _c.label = 5;
5786
5870
  case 5:
5787
- slipAssembly = _b.sent();
5788
- return [3 /*break*/, 7];
5871
+ _c.trys.push([5, 7, , 8]);
5872
+ return [4 /*yield*/, this.prepareSlip39((createSubAssembliesInput || []).concat(updateSubAssembliesInput || []), input.quorum, rawAssemblyKey)];
5789
5873
  case 6:
5790
- error_1 = _b.sent();
5874
+ slipAssembly = _c.sent();
5875
+ return [3 /*break*/, 8];
5876
+ case 7:
5877
+ error_1 = _c.sent();
5791
5878
  // TODO this sometimes happens. Maybe missing await.
5792
5879
  console.log('Error while creating slip assembly', error_1);
5793
- return [3 /*break*/, 7];
5794
- case 7:
5880
+ return [3 /*break*/, 8];
5881
+ case 8:
5795
5882
  common = {
5796
5883
  assemblyKeyParams: assemblyKeyParams,
5797
5884
  subjectKey: subjectKey.jwk,
5798
5885
  };
5799
- return [4 /*yield*/, this.prepareCreateSubAssemblies(Object.assign(Object.assign({}, common), { input: input.createSubAssemblies,
5886
+ return [4 /*yield*/, this.prepareCreateSubAssemblies(Object.assign(Object.assign({}, common), { input: createSubAssembliesInput,
5800
5887
  // Need to match the slip sub assemblies to the input
5801
- slipSubAssemblies: slipAssembly.subAssemblies.slice(0, input.createSubAssemblies.length) }))];
5802
- case 8:
5803
- createSubAssemblies = _b.sent();
5804
- return [4 /*yield*/, this.prepareUpdateSubAssemblies(Object.assign(Object.assign({}, common), { input: input.updateSubAssemblies,
5805
- // Add an offset to the sub assemblies to skip the one that are created.
5806
- slipSubAssemblies: slipAssembly.subAssemblies.slice(input.createSubAssemblies.length), subAssemblies: assembly.subAssemblies }))];
5888
+ slipSubAssemblies: slipAssembly.subAssemblies.slice(0, createSubAssembliesInput.length) }))];
5807
5889
  case 9:
5808
- updateSubAssemblies = _b.sent();
5890
+ createSubAssemblies = _c.sent();
5891
+ return [4 /*yield*/, this.prepareUpdateSubAssemblies(Object.assign(Object.assign({}, common), { input: updateSubAssembliesInput,
5892
+ // Add an offset to the sub assemblies to skip the one that are created.
5893
+ slipSubAssemblies: slipAssembly.subAssemblies.slice(createSubAssembliesInput.length), subAssemblies: assembly.subAssemblies }))];
5894
+ case 10:
5895
+ updateSubAssemblies = _c.sent();
5809
5896
  return [2 /*return*/, {
5810
5897
  assemblyKey: assemblyKey,
5811
5898
  mutationInput: Object.assign(Object.assign({}, assemblyInput), { singleReject: input.singleReject, quorum: input.quorum, subjectCipherData: '', subjectKeyId: subjectKey.id, createSubAssemblies: createSubAssemblies,
@@ -5932,6 +6019,9 @@
5932
6019
  _this.slip39Passphrase = TP_PASSWORD_RESET_SLIP39_PASSPHRASE;
5933
6020
  return _this;
5934
6021
  }
6022
+ TpPasswordResetAssemblyController.prototype.getTpWrappingKeyId = function (tp) {
6023
+ return tp.currentUserSharedKey.userSharedKey.mkSharedKey.id;
6024
+ };
5935
6025
  return TpPasswordResetAssemblyController;
5936
6026
  }(TpAssemblyController));
5937
6027
  exports.ɵe.ɵprov = i0.ɵɵdefineInjectable({ factory: function TpPasswordResetAssemblyController_Factory() { return new exports.ɵe(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR)); }, token: exports.ɵe, providedIn: "root" });
@@ -6713,11 +6803,11 @@
6713
6803
  { type: LifeReadyAuthService }
6714
6804
  ]; };
6715
6805
 
6716
- var UserQuery = gql(templateObject_1$a || (templateObject_1$a = __makeTemplateObject(["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"], ["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"])));
6806
+ var UserQuery = gql(templateObject_1$b || (templateObject_1$b = __makeTemplateObject(["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"], ["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"])));
6717
6807
  var RequestUserDeleteMutation = gql(templateObject_2$8 || (templateObject_2$8 = __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"])));
6718
6808
  var CancelUserDeleteMutation = gql(templateObject_3$7 || (templateObject_3$7 = __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"])));
6719
6809
  var LoginHistoryQuery = gql(templateObject_4$6 || (templateObject_4$6 = __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"])));
6720
- var templateObject_1$a, templateObject_2$8, templateObject_3$7, templateObject_4$6;
6810
+ var templateObject_1$b, templateObject_2$8, templateObject_3$7, templateObject_4$6;
6721
6811
 
6722
6812
  var UserService = /** @class */ (function () {
6723
6813
  function UserService(lrApollo) {
@@ -6828,7 +6918,7 @@
6828
6918
 
6829
6919
  var KeyExchangeFields = "\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n}";
6830
6920
  var UserSharedKeyFields = "\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n pbk\n }\n mkReshareRequestCipher\n mkReshareResponseCipher\n mkReshareRequestSent\n mkReshareResponseSent\n";
6831
- var CurrentUserSharedKeyQuery = gql(templateObject_1$b || (templateObject_1$b = __makeTemplateObject(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ", "\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", ""], ["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ", "\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", ""])), UserSharedKeyFields, KeyGraphFragment);
6921
+ var CurrentUserSharedKeyQuery = gql(templateObject_1$c || (templateObject_1$c = __makeTemplateObject(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ", "\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", ""], ["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ", "\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", ""])), UserSharedKeyFields, KeyGraphFragment);
6832
6922
  var KeyExchangesQuery = gql(templateObject_2$9 || (templateObject_2$9 = __makeTemplateObject(["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ", "\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n", "\n"], ["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ", "\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n", "\n"])), KeyExchangeFields, KeyGraphFragment);
6833
6923
  var KeyExchangeQuery = gql(templateObject_3$8 || (templateObject_3$8 = __makeTemplateObject(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ", "\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n", "\n"], ["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ", "\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n", "\n"])), KeyExchangeFields, KeyGraphFragment);
6834
6924
  // Key graph is only available for authenticated users. This query
@@ -6837,7 +6927,7 @@
6837
6927
  var InitiateOtkMutation = gql(templateObject_5$6 || (templateObject_5$6 = __makeTemplateObject(["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n}\n", "\n}"], ["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n}\n", "\n}"])), KeyExchangeFields, FetchKeyGraphField);
6838
6928
  var RespondOtkMutation = gql(templateObject_6$5 || (templateObject_6$5 = __makeTemplateObject(["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"], ["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"])), KeyExchangeFields, UserSharedKeyFields);
6839
6929
  var CompleteOtkMutation = gql(templateObject_7$4 || (templateObject_7$4 = __makeTemplateObject(["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"], ["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"])), KeyExchangeFields, UserSharedKeyFields);
6840
- var templateObject_1$b, templateObject_2$9, templateObject_3$8, templateObject_4$7, templateObject_5$6, templateObject_6$5, templateObject_7$4;
6930
+ var templateObject_1$c, templateObject_2$9, templateObject_3$8, templateObject_4$7, templateObject_5$6, templateObject_6$5, templateObject_7$4;
6841
6931
 
6842
6932
  (function (OtkState) {
6843
6933
  OtkState["OTK_INITIATED"] = "OTK_INITIATED";
@@ -7507,7 +7597,7 @@
7507
7597
  { type: UserService }
7508
7598
  ]; };
7509
7599
 
7510
- var SendMessageMutation = gql(templateObject_1$c || (templateObject_1$c = __makeTemplateObject(["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"], ["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"])));
7600
+ var SendMessageMutation = gql(templateObject_1$d || (templateObject_1$d = __makeTemplateObject(["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"], ["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"])));
7511
7601
  var MessageQuery = gql(templateObject_2$a || (templateObject_2$a = __makeTemplateObject(["\n query Message($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ", "\n"], ["\n query Message($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ", "\n"])), KeyGraphFragment);
7512
7602
  var MessageService = /** @class */ (function () {
7513
7603
  function MessageService(lrApollo, keyGraph, encryptionService, keyExchangeService) {
@@ -7645,7 +7735,7 @@
7645
7735
  { type: EncryptionService },
7646
7736
  { type: KeyExchangeService }
7647
7737
  ]; };
7648
- var templateObject_1$c, templateObject_2$a;
7738
+ var templateObject_1$d, templateObject_2$a;
7649
7739
 
7650
7740
  function handleCognitoCallback(method) {
7651
7741
  return new Promise(function (resolve, reject) { return method(function (err, result) { return (err ? reject(err) : resolve(result)); }); });
@@ -7705,7 +7795,7 @@
7705
7795
  };
7706
7796
  };
7707
7797
 
7708
- var CreateLbopQuery = gql(templateObject_1$d || (templateObject_1$d = __makeTemplateObject(["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"], ["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"])));
7798
+ var CreateLbopQuery = gql(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"], ["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"])));
7709
7799
  var DeleteLbopQuery = gql(templateObject_2$b || (templateObject_2$b = __makeTemplateObject(["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"], ["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"])));
7710
7800
  var UpdateLbopQuery = gql(templateObject_3$9 || (templateObject_3$9 = __makeTemplateObject(["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"], ["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"])));
7711
7801
  var LbopQuery = gql(templateObject_4$8 || (templateObject_4$8 = __makeTemplateObject(["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"], ["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"])));
@@ -8132,7 +8222,7 @@
8132
8222
  { type: KeyGraphService },
8133
8223
  { type: PasswordService }
8134
8224
  ]; };
8135
- var templateObject_1$d, templateObject_2$b, templateObject_3$9, templateObject_4$8, templateObject_5$7;
8225
+ var templateObject_1$e, templateObject_2$b, templateObject_3$9, templateObject_4$8, templateObject_5$7;
8136
8226
 
8137
8227
  var RegisterService = /** @class */ (function () {
8138
8228
  function RegisterService(config, auth, http, keyFactory, encryptionService, passwordService) {
@@ -8496,7 +8586,7 @@
8496
8586
  });
8497
8587
  var GetRecordQuery = function (depth) {
8498
8588
  if (depth === void 0) { depth = DEFAULT_BREADCRUMB_DEPTH; }
8499
- return gql(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ", "\n ", "\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", "\n"], ["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ", "\n ", "\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", "\n"])), AccessFields, parentCategoriesField(depth), KeyGraphFragment);
8589
+ return gql(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ", "\n ", "\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", "\n"], ["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ", "\n ", "\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", "\n"])), AccessFields, parentCategoriesField(depth), KeyGraphFragment);
8500
8590
  };
8501
8591
  var CreateRecordContainerMutation = gql(templateObject_2$c || (templateObject_2$c = __makeTemplateObject(["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"], ["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"])));
8502
8592
  var CreateRecordMutation = gql(templateObject_3$a || (templateObject_3$a = __makeTemplateObject(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"], ["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"])));
@@ -8505,7 +8595,7 @@
8505
8595
  var DeleteRecordMutation = gql(templateObject_6$6 || (templateObject_6$6 = __makeTemplateObject(["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"], ["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"])));
8506
8596
  var CreateFileMutation = gql(templateObject_7$5 || (templateObject_7$5 = __makeTemplateObject(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"], ["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"])));
8507
8597
  var DeleteFileMutation = gql(templateObject_8$4 || (templateObject_8$4 = __makeTemplateObject(["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"], ["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"])));
8508
- var templateObject_1$e, templateObject_2$c, templateObject_3$a, templateObject_4$9, templateObject_5$8, templateObject_6$6, templateObject_7$5, templateObject_8$4;
8598
+ var templateObject_1$f, templateObject_2$c, templateObject_3$a, templateObject_4$9, templateObject_5$8, templateObject_6$6, templateObject_7$5, templateObject_8$4;
8509
8599
 
8510
8600
  (function (AccessLevel) {
8511
8601
  AccessLevel["Owner"] = "OWNER";
@@ -9927,7 +10017,7 @@
9927
10017
  }());
9928
10018
 
9929
10019
  var SharedContactCardFields = "\n id\n owner {\n id\n username\n }\n ownerKey {\n id\n }\n ownerCipherData\n receiver {\n id\n username\n }\n receiverKey {\n id\n }\n receiverCipherData\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherDataSig\n sharedCipherDataSigPxk {\n id\n }\n";
9930
- var UpdateOwnedContactCard = gql(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ", "\n }\n }\n}"], ["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ", "\n }\n }\n}"])), SharedContactCardFields);
10020
+ var UpdateOwnedContactCard = gql(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ", "\n }\n }\n}"], ["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ", "\n }\n }\n}"])), SharedContactCardFields);
9931
10021
  var SharedContactCardService = /** @class */ (function () {
9932
10022
  function SharedContactCardService(keyService, lrApollo, keyGraph, encryptionService) {
9933
10023
  this.keyService = keyService;
@@ -10034,10 +10124,10 @@
10034
10124
  { type: KeyGraphService },
10035
10125
  { type: EncryptionService }
10036
10126
  ]; };
10037
- var templateObject_1$f;
10127
+ var templateObject_1$g;
10038
10128
 
10039
10129
  var TrustedPartyProperties = "\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n " + SharedContactCardFields + "\n }\n myContactCard {\n " + SharedContactCardFields + "\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n sharedItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n " + KeyExchangeFields + "\n }\n " + UserSharedKeyFields + "\n }\n }";
10040
- var GetTrustedPartiesQuery = gql(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"], ["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"])), TrustedPartyProperties, KeyGraphField);
10130
+ var GetTrustedPartiesQuery = gql(templateObject_1$h || (templateObject_1$h = __makeTemplateObject(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"], ["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"])), TrustedPartyProperties, KeyGraphField);
10041
10131
  var GetAllTrustedPartiesQuery = gql(templateObject_2$d || (templateObject_2$d = __makeTemplateObject(["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"], ["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"])), TrustedPartyProperties, KeyExchangeFields, KeyExchangeFields, KeyGraphField);
10042
10132
  var GetTrustedPartyQuery = gql(templateObject_3$b || (templateObject_3$b = __makeTemplateObject(["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ", "\n }\n ", "\n}"], ["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ", "\n }\n ", "\n}"])), TrustedPartyProperties, KeyGraphField);
10043
10133
  var DeclineTrustedPartyInvitationMutation = gql(templateObject_4$a || (templateObject_4$a = __makeTemplateObject(["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"], ["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"])));
@@ -10045,7 +10135,7 @@
10045
10135
  var DeleteTrustedPartyMutation = gql(templateObject_6$7 || (templateObject_6$7 = __makeTemplateObject(["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"], ["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"])));
10046
10136
  var ShareCategoryMutation = gql(templateObject_7$6 || (templateObject_7$6 = __makeTemplateObject(["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"], ["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"])));
10047
10137
  var UnshareCategoryMutation = gql(templateObject_8$5 || (templateObject_8$5 = __makeTemplateObject(["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"], ["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"])));
10048
- var templateObject_1$g, templateObject_2$d, templateObject_3$b, templateObject_4$a, templateObject_5$9, templateObject_6$7, templateObject_7$6, templateObject_8$5;
10138
+ var templateObject_1$h, templateObject_2$d, templateObject_3$b, templateObject_4$a, templateObject_5$9, templateObject_6$7, templateObject_7$6, templateObject_8$5;
10049
10139
 
10050
10140
  var TrustedPartyService = /** @class */ (function () {
10051
10141
  function TrustedPartyService(http, lrApollo, sharedContactCardService, userService, authService, keyExchangeService, keyGraphService, keyService, keyFactory, encryptionService) {
@@ -10936,13 +11026,13 @@
10936
11026
  return StripeBillingPortalSession;
10937
11027
  }());
10938
11028
 
10939
- var ContactCardFragment = gqlTyped(templateObject_1$h || (templateObject_1$h = __makeTemplateObject(["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"], ["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"])));
11029
+ var ContactCardFragment = gqlTyped(templateObject_1$i || (templateObject_1$i = __makeTemplateObject(["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"], ["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"])));
10940
11030
  var CreateContactCardMutation$2 = gqlTyped(templateObject_2$e || (templateObject_2$e = __makeTemplateObject(["\n mutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n ) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"], ["\n mutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n ) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"])));
10941
11031
  var UpdateContactCardMutation$2 = gqlTyped(templateObject_3$c || (templateObject_3$c = __makeTemplateObject(["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"], ["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"])));
10942
11032
  var DeleteContactCardMutation$1 = gqlTyped(templateObject_4$b || (templateObject_4$b = __makeTemplateObject(["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"], ["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"])));
10943
11033
  var ContactCardsQuery = gqlTyped(templateObject_5$a || (templateObject_5$a = __makeTemplateObject(["\n query ContactCardsQuery {\n contactCards(orderBy: \"created\") {\n edges {\n node {\n ...ContactCardFragment\n }\n }\n }\n }\n ", "\n"], ["\n query ContactCardsQuery {\n contactCards(orderBy: \"created\") {\n edges {\n node {\n ...ContactCardFragment\n }\n }\n }\n }\n ", "\n"])), ContactCardFragment);
10944
11034
  var ContactCardQuery$1 = gqlTyped(templateObject_6$8 || (templateObject_6$8 = __makeTemplateObject(["\n query ContactCardQuery($id: LrRelayIdInput!) {\n contactCard(id: $id) {\n ...ContactCardFragment\n }\n }\n ", "\n"], ["\n query ContactCardQuery($id: LrRelayIdInput!) {\n contactCard(id: $id) {\n ...ContactCardFragment\n }\n }\n ", "\n"])), ContactCardFragment);
10945
- var templateObject_1$h, templateObject_2$e, templateObject_3$c, templateObject_4$b, templateObject_5$a, templateObject_6$8;
11035
+ var templateObject_1$i, templateObject_2$e, templateObject_3$c, templateObject_4$b, templateObject_5$a, templateObject_6$8;
10946
11036
 
10947
11037
  var OwnerPlainDataJson = /** @class */ (function () {
10948
11038
  function OwnerPlainDataJson() {
@@ -11072,7 +11162,7 @@
11072
11162
  })
11073
11163
  ], exports.ContactCard2Service);
11074
11164
 
11075
- var KeyExchangeFragment = gqlTyped(templateObject_1$i || (templateObject_1$i = __makeTemplateObject(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"], ["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"])));
11165
+ var KeyExchangeFragment = gqlTyped(templateObject_1$j || (templateObject_1$j = __makeTemplateObject(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"], ["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"])));
11076
11166
  var UserSharedKeyFragment = gqlTyped(templateObject_2$f || (templateObject_2$f = __makeTemplateObject(["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"], ["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"])));
11077
11167
  var KeyExchangesQuery2 = gqlTyped(templateObject_3$d || (templateObject_3$d = __makeTemplateObject(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n", "\n"], ["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n", "\n"])), KeyExchangeFragment);
11078
11168
  var KeyExchangeQuery2 = gqlTyped(templateObject_4$c || (templateObject_4$c = __makeTemplateObject(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n", "\n"], ["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n", "\n"])), KeyExchangeFragment);
@@ -11083,7 +11173,7 @@
11083
11173
  var RespondKeyExchangeOtkMutation = gqlTyped(templateObject_9$3 || (templateObject_9$3 = __makeTemplateObject(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n", "\n", "\n"], ["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n", "\n", "\n"])), KeyExchangeFragment, UserSharedKeyFragment);
11084
11174
  var CompleteKeyExchangeOtkMutation = gqlTyped(templateObject_10$3 || (templateObject_10$3 = __makeTemplateObject(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n", "\n", "\n"], ["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n", "\n", "\n"])), KeyExchangeFragment, UserSharedKeyFragment);
11085
11175
  var CurrentUserSharedKeyQuery2 = gqlTyped(templateObject_11$2 || (templateObject_11$2 = __makeTemplateObject(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n", "\n"], ["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n", "\n"])), UserSharedKeyFragment);
11086
- var templateObject_1$i, templateObject_2$f, templateObject_3$d, templateObject_4$c, templateObject_5$b, templateObject_6$9, templateObject_7$7, templateObject_8$6, templateObject_9$3, templateObject_10$3, templateObject_11$2;
11176
+ var templateObject_1$j, templateObject_2$f, templateObject_3$d, templateObject_4$c, templateObject_5$b, templateObject_6$9, templateObject_7$7, templateObject_8$6, templateObject_9$3, templateObject_10$3, templateObject_11$2;
11087
11177
 
11088
11178
  exports.KeyExchange2Service = /** @class */ (function () {
11089
11179
  function KeyExchange2Service(ngZone, keyFactory, keyService, encryptionService, userService, keyGraph, lrGraphQL) {
@@ -11770,11 +11860,11 @@
11770
11860
  })
11771
11861
  ], exports.KeyExchange2Service);
11772
11862
 
11773
- var UpdateOwnedContactCardMutation = gqlTyped(templateObject_1$j || (templateObject_1$j = __makeTemplateObject(["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"], ["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"])));
11863
+ var UpdateOwnedContactCardMutation = gqlTyped(templateObject_1$k || (templateObject_1$k = __makeTemplateObject(["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"], ["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"])));
11774
11864
  var UpdateReceivedContactCardMutation = gqlTyped(templateObject_2$g || (templateObject_2$g = __makeTemplateObject(["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"], ["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"])));
11775
11865
  var GetOwnedContactCardKeyIdsQuery = gqlTyped(templateObject_3$e || (templateObject_3$e = __makeTemplateObject(["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"], ["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"])));
11776
11866
  var GetReceivedContactCardKeyIdQuery = gqlTyped(templateObject_4$d || (templateObject_4$d = __makeTemplateObject(["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"], ["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"])));
11777
- var templateObject_1$j, templateObject_2$g, templateObject_3$e, templateObject_4$d;
11867
+ var templateObject_1$k, templateObject_2$g, templateObject_3$e, templateObject_4$d;
11778
11868
 
11779
11869
  exports.SharedContactCard2Service = /** @class */ (function () {
11780
11870
  function SharedContactCard2Service(ngZone, keyService, keyGraph, encryptionService, lrGraphQL) {
@@ -11931,11 +12021,11 @@
11931
12021
  })
11932
12022
  ], exports.SharedContactCard2Service);
11933
12023
 
11934
- var LockFragment = gqlTyped(templateObject_1$k || (templateObject_1$k = __makeTemplateObject(["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"], ["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"])));
12024
+ var LockFragment = gqlTyped(templateObject_1$l || (templateObject_1$l = __makeTemplateObject(["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"], ["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"])));
11935
12025
  var UpdateLockMutation = gqlTyped(templateObject_2$h || (templateObject_2$h = __makeTemplateObject(["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"], ["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"])), LockFragment);
11936
12026
  var AcquireLockMutation = gqlTyped(templateObject_3$f || (templateObject_3$f = __makeTemplateObject(["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"], ["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"])), LockFragment);
11937
12027
  var ReleaseLockMutation = gqlTyped(templateObject_4$e || (templateObject_4$e = __makeTemplateObject(["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"], ["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"])), LockFragment);
11938
- var templateObject_1$k, templateObject_2$h, templateObject_3$f, templateObject_4$e;
12028
+ var templateObject_1$l, templateObject_2$h, templateObject_3$f, templateObject_4$e;
11939
12029
 
11940
12030
  exports.LockService = /** @class */ (function (_super) {
11941
12031
  __extends(LockService, _super);
@@ -11997,7 +12087,7 @@
11997
12087
  })
11998
12088
  ], exports.LockService);
11999
12089
 
12000
- var DirectoryKeyQuery = gqlTyped(templateObject_1$l || (templateObject_1$l = __makeTemplateObject(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"], ["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"])));
12090
+ var DirectoryKeyQuery = gqlTyped(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"], ["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"])));
12001
12091
  var FileKeyQuery = gqlTyped(templateObject_2$i || (templateObject_2$i = __makeTemplateObject(["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"], ["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"])));
12002
12092
  var FileStateKeyQuery = gqlTyped(templateObject_3$g || (templateObject_3$g = __makeTemplateObject(["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"], ["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"])));
12003
12093
  var CreateDirectoryMutation = gqlTyped(templateObject_4$f || (templateObject_4$f = __makeTemplateObject(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"], ["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"])));
@@ -12012,7 +12102,7 @@
12012
12102
  var ChangeFileParentsMutation = gqlTyped(templateObject_13$2 || (templateObject_13$2 = __makeTemplateObject(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"], ["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"])));
12013
12103
  var BeginDeleteChildItemLinksWindowMutation = gqlTyped(templateObject_14$1 || (templateObject_14$1 = __makeTemplateObject(["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"], ["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"])));
12014
12104
  var TempDirectoryQuery = gqlTyped(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: \"created\") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n"], ["\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: \"created\") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n"])));
12015
- var templateObject_1$l, templateObject_2$i, templateObject_3$g, templateObject_4$f, templateObject_5$c, templateObject_6$a, templateObject_7$8, templateObject_8$7, templateObject_9$4, templateObject_10$4, templateObject_11$3, templateObject_12$2, templateObject_13$2, templateObject_14$1, templateObject_15;
12105
+ var templateObject_1$m, templateObject_2$i, templateObject_3$g, templateObject_4$f, templateObject_5$c, templateObject_6$a, templateObject_7$8, templateObject_8$7, templateObject_9$4, templateObject_10$4, templateObject_11$3, templateObject_12$2, templateObject_13$2, templateObject_14$1, templateObject_15;
12016
12106
 
12017
12107
  var Item2Service_1;
12018
12108
  exports.Item2Service = Item2Service_1 = /** @class */ (function (_super) {
@@ -12728,7 +12818,7 @@
12728
12818
  })
12729
12819
  ], exports.Item2Service);
12730
12820
 
12731
- var DeleteTpMutation = gqlTyped(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"])));
12821
+ var DeleteTpMutation = gqlTyped(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"])));
12732
12822
  var ShareDirectoryMutation = gqlTyped(templateObject_2$j || (templateObject_2$j = __makeTemplateObject(["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"], ["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"])));
12733
12823
  var UnshareDirectoryMutation = gqlTyped(templateObject_3$h || (templateObject_3$h = __makeTemplateObject(["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"], ["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"])));
12734
12824
  var ShareFileMutation = gqlTyped(templateObject_4$g || (templateObject_4$g = __makeTemplateObject(["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"], ["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"])));
@@ -12737,7 +12827,7 @@
12737
12827
  var RequestTpMkReshareMutation = gqlTyped(templateObject_7$9 || (templateObject_7$9 = __makeTemplateObject(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"], ["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"])));
12738
12828
  var RespondTpMkReshareMutation = gqlTyped(templateObject_8$8 || (templateObject_8$8 = __makeTemplateObject(["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"], ["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"])));
12739
12829
  var CompleteTpMkReshareMutation = gqlTyped(templateObject_9$5 || (templateObject_9$5 = __makeTemplateObject(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"], ["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"])));
12740
- var templateObject_1$m, templateObject_2$j, templateObject_3$h, templateObject_4$g, templateObject_5$d, templateObject_6$b, templateObject_7$9, templateObject_8$8, templateObject_9$5;
12830
+ var templateObject_1$n, templateObject_2$j, templateObject_3$h, templateObject_4$g, templateObject_5$d, templateObject_6$b, templateObject_7$9, templateObject_8$8, templateObject_9$5;
12741
12831
 
12742
12832
  exports.TrustedParty2Service = /** @class */ (function () {
12743
12833
  function TrustedParty2Service(ngZone, keyGraph, lrGraphQL, item2Service, keyService, keyFactory, encryptionService) {
@@ -13424,12 +13514,12 @@
13424
13514
  })
13425
13515
  ], exports.TpPasswordResetRequestService);
13426
13516
 
13427
- var UpdateNotificationMutation = gqlTyped(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"], ["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"])));
13517
+ var UpdateNotificationMutation = gqlTyped(templateObject_1$o || (templateObject_1$o = __makeTemplateObject(["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"], ["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"])));
13428
13518
  var UpdateAllNotificationsReadStateMutation = gqlTyped(templateObject_2$k || (templateObject_2$k = __makeTemplateObject(["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"], ["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"])));
13429
13519
  var DebugCreateNotificationMutation = gqlTyped(templateObject_3$i || (templateObject_3$i = __makeTemplateObject(["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"], ["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"])));
13430
13520
  var DebugDeleteAllNotificationsMutation = gqlTyped(templateObject_4$h || (templateObject_4$h = __makeTemplateObject(["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"], ["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"])));
13431
13521
  var UpdateNotificationFeatureStateMutation = gqlTyped(templateObject_5$e || (templateObject_5$e = __makeTemplateObject(["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"], ["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"])));
13432
- var templateObject_1$n, templateObject_2$k, templateObject_3$i, templateObject_4$h, templateObject_5$e;
13522
+ var templateObject_1$o, templateObject_2$k, templateObject_3$i, templateObject_4$h, templateObject_5$e;
13433
13523
 
13434
13524
  exports.NotificationService = /** @class */ (function (_super) {
13435
13525
  __extends(NotificationService, _super);
@@ -13565,6 +13655,865 @@
13565
13655
  })
13566
13656
  ], exports.NotificationService);
13567
13657
 
13658
+ var CreateScenarioMutation = gqlTyped(templateObject_1$p || (templateObject_1$p = __makeTemplateObject(["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"], ["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"])));
13659
+ var UpdateScenarioMutation = gqlTyped(templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"], ["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"])));
13660
+ var DeleteScenarioMutation = gqlTyped(templateObject_3$j || (templateObject_3$j = __makeTemplateObject(["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"])));
13661
+ var CreateScenarioClaimMutation = gqlTyped(templateObject_4$i || (templateObject_4$i = __makeTemplateObject(["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"], ["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"])));
13662
+ var CancelScenarioClaimMutation = gqlTyped(templateObject_5$f || (templateObject_5$f = __makeTemplateObject(["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"], ["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"])));
13663
+ var RejectScenarioClaimMutation = gqlTyped(templateObject_6$c || (templateObject_6$c = __makeTemplateObject(["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"], ["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"])));
13664
+ var ApproveScenarioClaimMutation = gqlTyped(templateObject_7$a || (templateObject_7$a = __makeTemplateObject(["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"], ["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"])));
13665
+ var ReceiveScenarioClaimMutation = gqlTyped(templateObject_8$9 || (templateObject_8$9 = __makeTemplateObject(["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"], ["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"])));
13666
+ var templateObject_1$p, templateObject_2$l, templateObject_3$j, templateObject_4$i, templateObject_5$f, templateObject_6$c, templateObject_7$a, templateObject_8$9;
13667
+
13668
+ var SCENARIO_SLIP39_PASSPHRASE = 'lifeready';
13669
+
13670
+ exports.ɵj = /** @class */ (function (_super) {
13671
+ __extends(ScenarioAssemblyController, _super);
13672
+ function ScenarioAssemblyController(ngZone, injector) {
13673
+ var _this = _super.call(this, injector) || this;
13674
+ _this.ngZone = ngZone;
13675
+ _this.injector = injector;
13676
+ _this.slip39Passphrase = SCENARIO_SLIP39_PASSPHRASE;
13677
+ return _this;
13678
+ }
13679
+ ScenarioAssemblyController.prototype.getTpWrappingKeyId = function (tp) {
13680
+ return tp.currentUserSharedKey.userSharedKey.sharedKey.id;
13681
+ };
13682
+ return ScenarioAssemblyController;
13683
+ }(TpAssemblyController));
13684
+ exports.ɵj.ɵprov = i0.ɵɵdefineInjectable({ factory: function ScenarioAssemblyController_Factory() { return new exports.ɵj(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR)); }, token: exports.ɵj, providedIn: "root" });
13685
+ exports.ɵj.decorators = [
13686
+ { type: i0.Injectable, args: [{
13687
+ providedIn: 'root',
13688
+ },] }
13689
+ ];
13690
+ exports.ɵj.ctorParameters = function () { return [
13691
+ { type: i0.NgZone },
13692
+ { type: i0.Injector }
13693
+ ]; };
13694
+ exports.ɵj = __decorate([
13695
+ RunOutsideAngular({
13696
+ ngZoneName: 'ngZone',
13697
+ })
13698
+ ], exports.ɵj);
13699
+
13700
+ var ScenarioQuery = gqlTyped(templateObject_1$q || (templateObject_1$q = __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 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}"], ["\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 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}"])));
13701
+ var SharedScenarioQuery = gqlTyped(templateObject_2$m || (templateObject_2$m = __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 receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\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 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 receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\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 approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));
13702
+ var templateObject_1$q, templateObject_2$m;
13703
+
13704
+ function throwClaimIdMismatch() {
13705
+ throw new LrBadArgumentException('claimId does not match with the current claimId of the scenario');
13706
+ }
13707
+ function throwClaimNotApproved() {
13708
+ throw new LrBadStateException('Scenario claim has not been approved');
13709
+ }
13710
+ exports.ScenarioService = /** @class */ (function (_super) {
13711
+ __extends(ScenarioService, _super);
13712
+ function ScenarioService(ngZone, injector, keyGraph, item2Service, assemblyController, encryptionService) {
13713
+ var _this = _super.call(this, injector) || this;
13714
+ _this.ngZone = ngZone;
13715
+ _this.injector = injector;
13716
+ _this.keyGraph = keyGraph;
13717
+ _this.item2Service = item2Service;
13718
+ _this.assemblyController = assemblyController;
13719
+ _this.encryptionService = encryptionService;
13720
+ _this.prepareAddReceiverDirectory = _this.prepareReceiverDirectory;
13721
+ _this.prepareUpdateReceiverDirectory = _this.prepareReceiverDirectory;
13722
+ return _this;
13723
+ }
13724
+ // Scenarios
13725
+ ScenarioService.prototype.createScenario = function (options) {
13726
+ return __awaiter(this, void 0, void 0, function () {
13727
+ return __generator(this, function (_a) {
13728
+ return [2 /*return*/, this.mutate(this.createScenarioMutation(options))];
13729
+ });
13730
+ });
13731
+ };
13732
+ ScenarioService.prototype.createScenarioMutation = function (options) {
13733
+ return __awaiter(this, void 0, void 0, function () {
13734
+ var input;
13735
+ return __generator(this, function (_a) {
13736
+ switch (_a.label) {
13737
+ case 0: return [4 /*yield*/, this.prepareCreateScenarioMutation(options)];
13738
+ case 1:
13739
+ input = _a.sent();
13740
+ return [2 /*return*/, new LrMutation({
13741
+ mutation: CreateScenarioMutation,
13742
+ variables: {
13743
+ input: input,
13744
+ },
13745
+ })];
13746
+ }
13747
+ });
13748
+ });
13749
+ };
13750
+ ScenarioService.prototype.updateScenario = function (options) {
13751
+ return __awaiter(this, void 0, void 0, function () {
13752
+ return __generator(this, function (_a) {
13753
+ return [2 /*return*/, this.mutate(this.updateScenarioMutation(options))];
13754
+ });
13755
+ });
13756
+ };
13757
+ // TODO auto add the missing existing receivers and directories
13758
+ ScenarioService.prototype.updateScenarioMutation = function (options) {
13759
+ return __awaiter(this, void 0, void 0, function () {
13760
+ var scenario, input;
13761
+ return __generator(this, function (_a) {
13762
+ switch (_a.label) {
13763
+ case 0: return [4 /*yield*/, this.getScenario(options.scenarioId)];
13764
+ case 1:
13765
+ scenario = (_a.sent()).scenario;
13766
+ return [4 /*yield*/, this.prepareUpdateScenario(options, scenario)];
13767
+ case 2:
13768
+ input = _a.sent();
13769
+ return [2 /*return*/, new LrMutation({
13770
+ mutation: UpdateScenarioMutation,
13771
+ variables: {
13772
+ input: input,
13773
+ },
13774
+ })];
13775
+ }
13776
+ });
13777
+ });
13778
+ };
13779
+ ScenarioService.prototype.resetScenario = function (options) {
13780
+ return __awaiter(this, void 0, void 0, function () {
13781
+ return __generator(this, function (_a) {
13782
+ return [2 /*return*/, this.mutate(this.resetScenarioMutation(options))];
13783
+ });
13784
+ });
13785
+ };
13786
+ ScenarioService.prototype.resetScenarioMutation = function (options) {
13787
+ return __awaiter(this, void 0, void 0, function () {
13788
+ var scenario, assembly, updateSubAssemblies, input;
13789
+ return __generator(this, function (_a) {
13790
+ switch (_a.label) {
13791
+ case 0: return [4 /*yield*/, this.getScenario(options.scenarioId)];
13792
+ case 1:
13793
+ scenario = (_a.sent()).scenario;
13794
+ assembly = scenario.assembly;
13795
+ updateSubAssemblies = mapEdges(assembly.subAssemblies).map(function (sa) {
13796
+ var approverTps = mapEdges(sa.approvers).map(function (approver) { return ({
13797
+ tpId: approver.tp.id,
13798
+ }); });
13799
+ return {
13800
+ id: sa.id,
13801
+ quorum: sa.quorum,
13802
+ singleReject: sa.singleReject,
13803
+ subjectCipherDataClearJson: sa.subjectCipherDataClearJson,
13804
+ approverTps: approverTps,
13805
+ };
13806
+ });
13807
+ return [4 /*yield*/, this.prepareUpdateScenario({
13808
+ scenarioId: options.scenarioId,
13809
+ enabled: options.enabled,
13810
+ updateAssembly: {
13811
+ quorum: assembly.quorum,
13812
+ singleReject: assembly.singleReject,
13813
+ updateSubAssemblies: updateSubAssemblies,
13814
+ },
13815
+ }, scenario)];
13816
+ case 2:
13817
+ input = _a.sent();
13818
+ return [2 /*return*/, new LrMutation({
13819
+ mutation: UpdateScenarioMutation,
13820
+ variables: {
13821
+ input: input,
13822
+ },
13823
+ })];
13824
+ }
13825
+ });
13826
+ });
13827
+ };
13828
+ ScenarioService.prototype.deleteScenario = function (scenarioId) {
13829
+ return __awaiter(this, void 0, void 0, function () {
13830
+ return __generator(this, function (_a) {
13831
+ return [2 /*return*/, this.lrGraphQL.lrMutate(this.deleteScenarioMutation(scenarioId))];
13832
+ });
13833
+ });
13834
+ };
13835
+ ScenarioService.prototype.deleteScenarioMutation = function (scenarioId) {
13836
+ return __awaiter(this, void 0, void 0, function () {
13837
+ return __generator(this, function (_a) {
13838
+ return [2 /*return*/, new LrMutation({
13839
+ mutation: DeleteScenarioMutation,
13840
+ variables: { input: { scenarioId: scenarioId } },
13841
+ })];
13842
+ });
13843
+ });
13844
+ };
13845
+ // Claims
13846
+ ScenarioService.prototype.createClaim = function (scenarioId) {
13847
+ return __awaiter(this, void 0, void 0, function () {
13848
+ return __generator(this, function (_a) {
13849
+ return [2 /*return*/, this.mutate(this.createClaimMutation(scenarioId))];
13850
+ });
13851
+ });
13852
+ };
13853
+ ScenarioService.prototype.createClaimMutation = function (scenarioId) {
13854
+ return __awaiter(this, void 0, void 0, function () {
13855
+ return __generator(this, function (_a) {
13856
+ return [2 /*return*/, new LrMutation({
13857
+ mutation: CreateScenarioClaimMutation,
13858
+ variables: { input: { scenarioId: scenarioId } },
13859
+ })];
13860
+ });
13861
+ });
13862
+ };
13863
+ ScenarioService.prototype.cancelClaim = function (claimId) {
13864
+ return __awaiter(this, void 0, void 0, function () {
13865
+ return __generator(this, function (_a) {
13866
+ return [2 /*return*/, this.mutate(this.cancelClaimMutation(claimId))];
13867
+ });
13868
+ });
13869
+ };
13870
+ ScenarioService.prototype.cancelClaimMutation = function (claimId) {
13871
+ return __awaiter(this, void 0, void 0, function () {
13872
+ return __generator(this, function (_a) {
13873
+ return [2 /*return*/, new LrMutation({
13874
+ mutation: CancelScenarioClaimMutation,
13875
+ variables: { input: { claimId: claimId } },
13876
+ })];
13877
+ });
13878
+ });
13879
+ };
13880
+ ScenarioService.prototype.rejectClaim = function (sharedScenarioId, claimId) {
13881
+ return __awaiter(this, void 0, void 0, function () {
13882
+ return __generator(this, function (_a) {
13883
+ return [2 /*return*/, this.mutate(this.rejectClaimMutation(sharedScenarioId, claimId))];
13884
+ });
13885
+ });
13886
+ };
13887
+ ScenarioService.prototype.rejectClaimMutation = function (sharedScenarioId, claimId) {
13888
+ return __awaiter(this, void 0, void 0, function () {
13889
+ var mutations, _a, _b;
13890
+ return __generator(this, function (_c) {
13891
+ switch (_c.label) {
13892
+ case 0: return [4 /*yield*/, this.prepareRejectClaimMutations(sharedScenarioId, claimId)];
13893
+ case 1:
13894
+ mutations = _c.sent();
13895
+ _b = (_a = LrMergedMutation).create;
13896
+ return [4 /*yield*/, Promise.all(mutations)];
13897
+ case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
13898
+ }
13899
+ });
13900
+ });
13901
+ };
13902
+ ScenarioService.prototype.approveClaim = function (sharedScenarioId, sharedClaimId) {
13903
+ return __awaiter(this, void 0, void 0, function () {
13904
+ return __generator(this, function (_a) {
13905
+ return [2 /*return*/, this.mutate(this.approveClaimMutation(sharedScenarioId, sharedClaimId))];
13906
+ });
13907
+ });
13908
+ };
13909
+ ScenarioService.prototype.approveClaimMutation = function (sharedScenarioId, sharedClaimId) {
13910
+ return __awaiter(this, void 0, void 0, function () {
13911
+ var mutations, _a, _b;
13912
+ return __generator(this, function (_c) {
13913
+ switch (_c.label) {
13914
+ case 0: return [4 /*yield*/, this.prepareApproveClaimMutations(sharedScenarioId, sharedClaimId)];
13915
+ case 1:
13916
+ mutations = _c.sent();
13917
+ _b = (_a = LrMergedMutation).create;
13918
+ return [4 /*yield*/, Promise.all(mutations)];
13919
+ case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
13920
+ }
13921
+ });
13922
+ });
13923
+ };
13924
+ ScenarioService.prototype.receiveClaim = function (scenarioId, sharedClaimId) {
13925
+ return __awaiter(this, void 0, void 0, function () {
13926
+ return __generator(this, function (_a) {
13927
+ return [2 /*return*/, this.mutate(this.receiveClaimMutation(scenarioId, sharedClaimId))];
13928
+ });
13929
+ });
13930
+ };
13931
+ ScenarioService.prototype.receiveClaimMutation = function (scenarioId, sharedClaimId) {
13932
+ return __awaiter(this, void 0, void 0, function () {
13933
+ var _a, _b, _c;
13934
+ return __generator(this, function (_d) {
13935
+ switch (_d.label) {
13936
+ case 0:
13937
+ _a = LrMutation.bind;
13938
+ _b = {
13939
+ mutation: ReceiveScenarioClaimMutation
13940
+ };
13941
+ _c = {};
13942
+ return [4 /*yield*/, this.prepareClaim(scenarioId, sharedClaimId)];
13943
+ case 1: return [2 /*return*/, new (_a.apply(LrMutation, [void 0, (_b.variables = (_c.input = _d.sent(),
13944
+ _c),
13945
+ _b)]))()];
13946
+ }
13947
+ });
13948
+ });
13949
+ };
13950
+ // --------------------------------------------------------------------------------
13951
+ // --------------------------------------------------------------------------------
13952
+ // Helpers
13953
+ // --------------------------------------------------------------------------------
13954
+ // --------------------------------------------------------------------------------
13955
+ ScenarioService.prototype.getScenario = function (scenarioId) {
13956
+ return __awaiter(this, void 0, void 0, function () {
13957
+ return __generator(this, function (_a) {
13958
+ return [2 /*return*/, this.query({
13959
+ query: ScenarioQuery,
13960
+ variables: { scenarioId: scenarioId },
13961
+ })];
13962
+ });
13963
+ });
13964
+ };
13965
+ ScenarioService.prototype.getSharedScenario = function (scenarioId, claimId) {
13966
+ return __awaiter(this, void 0, void 0, function () {
13967
+ var ret;
13968
+ return __generator(this, function (_a) {
13969
+ switch (_a.label) {
13970
+ case 0: return [4 /*yield*/, this.query({
13971
+ query: SharedScenarioQuery,
13972
+ variables: {
13973
+ scenarioId: scenarioId,
13974
+ },
13975
+ })];
13976
+ case 1:
13977
+ ret = _a.sent();
13978
+ if (claimId && ret.sharedScenario.sharedClaim.id !== claimId) {
13979
+ throwClaimIdMismatch();
13980
+ }
13981
+ return [2 /*return*/, ret];
13982
+ }
13983
+ });
13984
+ });
13985
+ };
13986
+ ScenarioService.prototype.getParticipantTpsKeys = function (options) {
13987
+ return __awaiter(this, void 0, void 0, function () {
13988
+ var tpIds, tps, _a;
13989
+ return __generator(this, function (_b) {
13990
+ switch (_b.label) {
13991
+ case 0:
13992
+ tpIds = options.map(function (x) { return x.tpId; });
13993
+ _a = mapEdges;
13994
+ return [4 /*yield*/, this.lrGraphQL.query({
13995
+ query: TpsKeysQuery,
13996
+ variables: {
13997
+ ids: tpIds,
13998
+ },
13999
+ })];
14000
+ case 1:
14001
+ tps = _a.apply(void 0, [(_b.sent()).tps]);
14002
+ return [2 /*return*/, tps];
14003
+ }
14004
+ });
14005
+ });
14006
+ };
14007
+ ScenarioService.prototype.fillTpSharedKeyId = function (options, tps) {
14008
+ options.forEach(function (participant) {
14009
+ if (!participant.tpSharedKeyId) {
14010
+ var tp = tps.find(function (x) { return x.id === participant.tpId; });
14011
+ participant.tpSharedKeyId =
14012
+ tp.currentUserSharedKey.userSharedKey.sharedKey.id;
14013
+ }
14014
+ });
14015
+ };
14016
+ ScenarioService.prototype.prepareCreateScenarioMutation = function (options) {
14017
+ return __awaiter(this, void 0, void 0, function () {
14018
+ var _a, assemblyKey, createAssembly, createReceiversOptions, createClaimantsOptions, creatParticipantsOptions, tps, createReceivers, createClaimants;
14019
+ var _this = this;
14020
+ return __generator(this, function (_b) {
14021
+ switch (_b.label) {
14022
+ case 0: return [4 /*yield*/, this.assemblyController.prepareCreate(options.createAssembly)];
14023
+ case 1:
14024
+ _a = _b.sent(), assemblyKey = _a.assemblyKey, createAssembly = _a.mutationInput;
14025
+ createReceiversOptions = options.createReceivers || [];
14026
+ createClaimantsOptions = options.createClaimants || [];
14027
+ creatParticipantsOptions = createReceiversOptions.concat(createClaimantsOptions);
14028
+ return [4 /*yield*/, this.getParticipantTpsKeys(creatParticipantsOptions)];
14029
+ case 2:
14030
+ tps = _b.sent();
14031
+ this.fillTpSharedKeyId(creatParticipantsOptions, tps);
14032
+ return [4 /*yield*/, Promise.all(createReceiversOptions.map(function (receiver) { return _this.prepareCreateReceiver(receiver, assemblyKey); }))];
14033
+ case 3:
14034
+ createReceivers = _b.sent();
14035
+ return [4 /*yield*/, Promise.all(createClaimantsOptions.map(function (x) { return _this.prepareCreateClaimant(x); }))];
14036
+ case 4:
14037
+ createClaimants = _b.sent();
14038
+ return [2 /*return*/, {
14039
+ enabled: options.enabled,
14040
+ createAssembly: createAssembly,
14041
+ createReceivers: createReceivers,
14042
+ createClaimants: createClaimants,
14043
+ }];
14044
+ }
14045
+ });
14046
+ });
14047
+ };
14048
+ ScenarioService.prototype.prepareUpdateScenario = function (options, scenario) {
14049
+ return __awaiter(this, void 0, void 0, function () {
14050
+ var assemblyKey, updateAssembly, result, createReceiversOptions, createClaimantsOptions, creatParticipantsOptions, tps, createReceivers, _a, existingReceivers, updateReceivers, _b, existing, _c, _d, createClaimants, _e, existingClaimants, updateClaimants, _f;
14051
+ var _this = this;
14052
+ return __generator(this, function (_g) {
14053
+ switch (_g.label) {
14054
+ case 0: return [4 /*yield*/, this.keyGraph.getJwkKey(scenario.assembly.assemblyKey.id)];
14055
+ case 1:
14056
+ assemblyKey = _g.sent();
14057
+ if (!options.updateAssembly) return [3 /*break*/, 3];
14058
+ return [4 /*yield*/, this.assemblyController.prepareUpdate(options.updateAssembly, scenario.assembly)];
14059
+ case 2:
14060
+ result = _g.sent();
14061
+ updateAssembly = result.mutationInput;
14062
+ assemblyKey = result.assemblyKey;
14063
+ _g.label = 3;
14064
+ case 3:
14065
+ createReceiversOptions = options.createReceivers || [];
14066
+ createClaimantsOptions = options.createClaimants || [];
14067
+ creatParticipantsOptions = createReceiversOptions.concat(createClaimantsOptions);
14068
+ return [4 /*yield*/, this.getParticipantTpsKeys(creatParticipantsOptions)];
14069
+ case 4:
14070
+ tps = _g.sent();
14071
+ this.fillTpSharedKeyId(creatParticipantsOptions, tps);
14072
+ _a = options.createReceivers;
14073
+ if (!_a) return [3 /*break*/, 6];
14074
+ return [4 /*yield*/, Promise.all(options.createReceivers.map(function (x) { return _this.prepareCreateReceiver(x, assemblyKey); }))];
14075
+ case 5:
14076
+ _a = (_g.sent());
14077
+ _g.label = 6;
14078
+ case 6:
14079
+ createReceivers = _a;
14080
+ existingReceivers = mapEdges(scenario.receivers);
14081
+ if (!options.updateReceivers) return [3 /*break*/, 8];
14082
+ return [4 /*yield*/, Promise.all(options.updateReceivers.map(function (updateReceiver) {
14083
+ // Find the receiver we are updating
14084
+ var existingReceiver = existingReceivers.find(function (x) { return x.tp.id === updateReceiver.tpId; });
14085
+ return _this.prepareUpdateReceiver(updateReceiver, assemblyKey, existingReceiver);
14086
+ }))];
14087
+ case 7:
14088
+ _b = _g.sent();
14089
+ return [3 /*break*/, 9];
14090
+ case 8:
14091
+ _b = [];
14092
+ _g.label = 9;
14093
+ case 9:
14094
+ updateReceivers = _b;
14095
+ if (!options.updateAssembly) return [3 /*break*/, 11];
14096
+ existing = existingReceivers.filter(function (existingReceiver) { return !(options.deleteReceivers || []).includes(existingReceiver.tp.id) &&
14097
+ !updateReceivers.some(function (updateReceiver) { return updateReceiver.tpId === existingReceiver.tp.id; }); });
14098
+ _d = (_c = updateReceivers).concat;
14099
+ return [4 /*yield*/, this.prepareExistingReceivers(existing, assemblyKey)];
14100
+ case 10:
14101
+ updateReceivers = _d.apply(_c, [_g.sent()]);
14102
+ _g.label = 11;
14103
+ case 11:
14104
+ _e = options.createClaimants;
14105
+ if (!_e) return [3 /*break*/, 13];
14106
+ return [4 /*yield*/, Promise.all(options.createClaimants.map(function (x) { return _this.prepareCreateClaimant(x); }))];
14107
+ case 12:
14108
+ _e = (_g.sent());
14109
+ _g.label = 13;
14110
+ case 13:
14111
+ createClaimants = _e;
14112
+ existingClaimants = mapEdges(scenario.claimants);
14113
+ _f = options.updateClaimants;
14114
+ if (!_f) return [3 /*break*/, 15];
14115
+ return [4 /*yield*/, Promise.all(options.updateClaimants.map(function (x) {
14116
+ // Find the claimant we are updating
14117
+ var claimant = existingClaimants.find(function (existingClaimant) { return existingClaimant.tp.id === x.tpId; });
14118
+ return _this.prepareUpdateClaimant(x, claimant.sharedKey.id);
14119
+ }))];
14120
+ case 14:
14121
+ _f = (_g.sent());
14122
+ _g.label = 15;
14123
+ case 15:
14124
+ updateClaimants = _f;
14125
+ return [2 /*return*/, {
14126
+ scenarioId: options.scenarioId,
14127
+ enabled: options.enabled,
14128
+ updateAssembly: updateAssembly,
14129
+ createReceivers: createReceivers,
14130
+ updateReceivers: updateReceivers,
14131
+ deleteReceivers: options.deleteReceivers,
14132
+ createClaimants: createClaimants,
14133
+ updateClaimants: updateClaimants,
14134
+ deleteClaimants: options.deleteClaimants,
14135
+ }];
14136
+ }
14137
+ });
14138
+ });
14139
+ };
14140
+ ScenarioService.prototype.prepareReceiverDirectory = function (options, receiverSharedKey, assemblyKey) {
14141
+ return __awaiter(this, void 0, void 0, function () {
14142
+ var directoryKey, sharedCipherData, wrappedItemKey;
14143
+ return __generator(this, function (_a) {
14144
+ switch (_a.label) {
14145
+ case 0: return [4 /*yield*/, this.item2Service.getDirectoryKey(options.directoryId, options.directoryKeyId)];
14146
+ case 1:
14147
+ directoryKey = _a.sent();
14148
+ return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, options.sharedCipherDataClearJson)];
14149
+ case 2:
14150
+ sharedCipherData = _a.sent();
14151
+ return [4 /*yield*/, this.keyGraph.encryptToString(receiverSharedKey, directoryKey.jwk.toJSON(true))];
14152
+ case 3:
14153
+ wrappedItemKey = _a.sent();
14154
+ return [4 /*yield*/, this.keyGraph.encryptToString(assemblyKey, wrappedItemKey)];
14155
+ case 4:
14156
+ // TODO fetch assemblyKeyId. We are changing it such that there is always an assembly
14157
+ // before receivers can be added.
14158
+ wrappedItemKey = _a.sent();
14159
+ return [2 /*return*/, {
14160
+ directoryId: options.directoryId,
14161
+ wrappedItemKey: wrappedItemKey,
14162
+ accessRole: options.accessRole,
14163
+ sharedCipherData: sharedCipherData,
14164
+ }];
14165
+ }
14166
+ });
14167
+ });
14168
+ };
14169
+ ScenarioService.prototype.prepareCreateReceiver = function (options, assemblyKey) {
14170
+ return __awaiter(this, void 0, void 0, function () {
14171
+ var _a, sharedKey, mutationInput, addDirectories, _b;
14172
+ var _this = this;
14173
+ return __generator(this, function (_c) {
14174
+ switch (_c.label) {
14175
+ case 0: return [4 /*yield*/, this.prepareCreateParticipant(options)];
14176
+ case 1:
14177
+ _a = _c.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
14178
+ _b = options.addDirectories;
14179
+ if (!_b) return [3 /*break*/, 3];
14180
+ return [4 /*yield*/, Promise.all(options.addDirectories.map(function (x) { return _this.prepareAddReceiverDirectory(x, sharedKey.key, assemblyKey); }))];
14181
+ case 2:
14182
+ _b = (_c.sent());
14183
+ _c.label = 3;
14184
+ case 3:
14185
+ addDirectories = _b;
14186
+ return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories })];
14187
+ }
14188
+ });
14189
+ });
14190
+ };
14191
+ ScenarioService.prototype.prepareUpdateReceiver = function (options, assemblyKey, existingReceiver) {
14192
+ return __awaiter(this, void 0, void 0, function () {
14193
+ var sharedKeyId, deleteDirectoriesOptions, updateDirectoriesOptions, _a, sharedKey, mutationInput, addDirectories, _b, updateDirectories;
14194
+ var _this = this;
14195
+ return __generator(this, function (_c) {
14196
+ switch (_c.label) {
14197
+ case 0:
14198
+ sharedKeyId = existingReceiver.sharedKey.id;
14199
+ deleteDirectoriesOptions = options.deleteDirectories || [];
14200
+ updateDirectoriesOptions = options.updateDirectories || [];
14201
+ // Fill in any missing update directories
14202
+ mapEdges(existingReceiver.receiverDirectories).forEach(function (existingDirectory) {
14203
+ if (deleteDirectoriesOptions.includes(existingDirectory.directory.id)) {
14204
+ return;
14205
+ }
14206
+ if (updateDirectoriesOptions.find(function (x) { return x.directoryId === existingDirectory.directory.id; })) {
14207
+ return;
14208
+ }
14209
+ updateDirectoriesOptions.push({
14210
+ accessRole: existingDirectory.accessRole,
14211
+ directoryId: existingDirectory.directory.id,
14212
+ sharedCipherDataClearJson: existingDirectory.sharedCipherDataClearJson,
14213
+ });
14214
+ });
14215
+ return [4 /*yield*/, this.prepareUpdateParticipant(options, sharedKeyId)];
14216
+ case 1:
14217
+ _a = _c.sent(), sharedKey = _a.sharedKey, mutationInput = _a.mutationInput;
14218
+ _b = options.addDirectories;
14219
+ if (!_b) return [3 /*break*/, 3];
14220
+ return [4 /*yield*/, Promise.all(options.addDirectories.map(function (x) { return _this.prepareAddReceiverDirectory(x, sharedKey, assemblyKey); }))];
14221
+ case 2:
14222
+ _b = (_c.sent());
14223
+ _c.label = 3;
14224
+ case 3:
14225
+ addDirectories = _b;
14226
+ return [4 /*yield*/, Promise.all(updateDirectoriesOptions.map(function (x) { return _this.prepareUpdateReceiverDirectory(x, sharedKey, assemblyKey); }))];
14227
+ case 4:
14228
+ updateDirectories = _c.sent();
14229
+ return [2 /*return*/, Object.assign(Object.assign({}, mutationInput), { addDirectories: addDirectories,
14230
+ updateDirectories: updateDirectories, deleteDirectories: options.deleteDirectories })];
14231
+ }
14232
+ });
14233
+ });
14234
+ };
14235
+ ScenarioService.prototype.prepareExistingReceiver = function (existingReceiver, assemblyKey) {
14236
+ return __awaiter(this, void 0, void 0, function () {
14237
+ var updateDirectories;
14238
+ return __generator(this, function (_a) {
14239
+ updateDirectories = mapEdges(existingReceiver.receiverDirectories).map(function (receiverDirectory) { return ({
14240
+ directoryId: receiverDirectory.directory.id,
14241
+ directoryKeyId: receiverDirectory.directory.keyId,
14242
+ accessRole: receiverDirectory.accessRole,
14243
+ sharedCipherDataClearJson: receiverDirectory.sharedCipherDataClearJson,
14244
+ }); });
14245
+ // Fill it in with existing receiver.
14246
+ return [2 /*return*/, this.prepareUpdateReceiver({
14247
+ tpId: existingReceiver.tp.id,
14248
+ sharedCipherDataClearJson: existingReceiver.sharedCipherDataClearJson,
14249
+ updateDirectories: updateDirectories,
14250
+ }, assemblyKey, existingReceiver)];
14251
+ });
14252
+ });
14253
+ };
14254
+ ScenarioService.prototype.prepareExistingReceivers = function (existingReceivers, assemblyKey) {
14255
+ return __awaiter(this, void 0, void 0, function () {
14256
+ var _this = this;
14257
+ return __generator(this, function (_a) {
14258
+ return [2 /*return*/, Promise.all(existingReceivers.map(function (existingReceiver) { return _this.prepareExistingReceiver(existingReceiver, assemblyKey); }))];
14259
+ });
14260
+ });
14261
+ };
14262
+ ScenarioService.prototype.prepareCreateParticipant = function (options) {
14263
+ return __awaiter(this, void 0, void 0, function () {
14264
+ var sharedKey;
14265
+ return __generator(this, function (_a) {
14266
+ switch (_a.label) {
14267
+ case 0: return [4 /*yield*/, this.keyGraph.encryptWithNewKey(options.tpSharedKeyId, options.sharedCipherDataClearJson)];
14268
+ case 1:
14269
+ sharedKey = _a.sent();
14270
+ return [2 /*return*/, {
14271
+ sharedKey: sharedKey,
14272
+ mutationInput: {
14273
+ tpId: options.tpId,
14274
+ tpSharedKeyId: options.tpSharedKeyId,
14275
+ tpSharedKeyWrappedSharedKey: sharedKey.wrappedKey,
14276
+ sharedCipherData: sharedKey.cipher,
14277
+ },
14278
+ }];
14279
+ }
14280
+ });
14281
+ });
14282
+ };
14283
+ ScenarioService.prototype.prepareUpdateParticipant = function (options, sharedKeyId) {
14284
+ return __awaiter(this, void 0, void 0, function () {
14285
+ var sharedKey, sharedCipherData;
14286
+ return __generator(this, function (_a) {
14287
+ switch (_a.label) {
14288
+ case 0: return [4 /*yield*/, this.keyGraph.getJwkKey(sharedKeyId)];
14289
+ case 1:
14290
+ sharedKey = _a.sent();
14291
+ return [4 /*yield*/, this.keyGraph.encryptToString(sharedKey, options.sharedCipherDataClearJson)];
14292
+ case 2:
14293
+ sharedCipherData = _a.sent();
14294
+ return [2 /*return*/, {
14295
+ sharedKey: sharedKey,
14296
+ mutationInput: {
14297
+ tpId: options.tpId,
14298
+ sharedKeyId: sharedKeyId,
14299
+ sharedCipherData: sharedCipherData,
14300
+ },
14301
+ }];
14302
+ }
14303
+ });
14304
+ });
14305
+ };
14306
+ ScenarioService.prototype.prepareCreateClaimant = function (options) {
14307
+ return __awaiter(this, void 0, void 0, function () {
14308
+ var mutationInput;
14309
+ return __generator(this, function (_a) {
14310
+ switch (_a.label) {
14311
+ case 0: return [4 /*yield*/, this.prepareCreateParticipant(options)];
14312
+ case 1:
14313
+ mutationInput = (_a.sent()).mutationInput;
14314
+ return [2 /*return*/, mutationInput];
14315
+ }
14316
+ });
14317
+ });
14318
+ };
14319
+ ScenarioService.prototype.prepareUpdateClaimant = function (options, sharedKeyId) {
14320
+ return __awaiter(this, void 0, void 0, function () {
14321
+ var mutationInput;
14322
+ return __generator(this, function (_a) {
14323
+ switch (_a.label) {
14324
+ case 0: return [4 /*yield*/, this.prepareUpdateParticipant(options, sharedKeyId)];
14325
+ case 1:
14326
+ mutationInput = (_a.sent()).mutationInput;
14327
+ return [2 /*return*/, mutationInput];
14328
+ }
14329
+ });
14330
+ });
14331
+ };
14332
+ ScenarioService.prototype.prepareClaim = function (scenarioId, sharedClaimId) {
14333
+ return __awaiter(this, void 0, void 0, function () {
14334
+ var sharedScenario, approvals, assemblyKey, receiverDirectories;
14335
+ var _this = this;
14336
+ return __generator(this, function (_a) {
14337
+ switch (_a.label) {
14338
+ case 0: return [4 /*yield*/, this.getSharedScenario(scenarioId, sharedClaimId)];
14339
+ case 1:
14340
+ sharedScenario = (_a.sent()).sharedScenario;
14341
+ if (sharedScenario.state !== ScenarioState.APPROVED) {
14342
+ throwClaimNotApproved();
14343
+ }
14344
+ approvals = mapEdges(sharedScenario.sharedClaim.asClaimReceiver.approvals);
14345
+ return [4 /*yield*/, this.recoverAssemblyKey(approvals)];
14346
+ case 2:
14347
+ assemblyKey = _a.sent();
14348
+ console.log('receiveClaimMutation assemblyKey', assemblyKey);
14349
+ return [4 /*yield*/, Promise.all(sharedScenario.asReceiver.receiverDirectories.edges
14350
+ .map(function (edge) { return edge.node; })
14351
+ .map(function (receiverDirectory) { return __awaiter(_this, void 0, void 0, function () {
14352
+ var wrappedItemKey;
14353
+ return __generator(this, function (_a) {
14354
+ switch (_a.label) {
14355
+ case 0: return [4 /*yield*/, this.encryptionService.decrypt(assemblyKey, receiverDirectory.wrappedItemKey)];
14356
+ case 1:
14357
+ wrappedItemKey = _a.sent();
14358
+ return [2 /*return*/, {
14359
+ receiverDirectoryId: receiverDirectory.id,
14360
+ receiverSharedKeyWrappedItemKey: wrappedItemKey,
14361
+ }];
14362
+ }
14363
+ });
14364
+ }); }))];
14365
+ case 3:
14366
+ receiverDirectories = _a.sent();
14367
+ return [2 /*return*/, {
14368
+ scenarioClaimId: sharedClaimId,
14369
+ receiverDirectories: receiverDirectories,
14370
+ }];
14371
+ }
14372
+ });
14373
+ });
14374
+ };
14375
+ ScenarioService.prototype.recoverAssemblyKey = function (approvals) {
14376
+ return __awaiter(this, void 0, void 0, function () {
14377
+ var partials;
14378
+ var _this = this;
14379
+ return __generator(this, function (_a) {
14380
+ switch (_a.label) {
14381
+ case 0: return [4 /*yield*/, Promise.all(approvals.map(function (approval) { return _this.keyGraph.decryptFromString(approval.pxk.id, approval.receiverCipherPartialAssemblyKey); }))];
14382
+ case 1:
14383
+ partials = _a.sent();
14384
+ return [2 /*return*/, this.assemblyController.recoverAssemblyKey(partials)];
14385
+ }
14386
+ });
14387
+ });
14388
+ };
14389
+ ScenarioService.prototype.asClaimApprovers = function (sharedScenarioId, claimId, state) {
14390
+ return __awaiter(this, void 0, void 0, function () {
14391
+ var sharedScenario;
14392
+ return __generator(this, function (_a) {
14393
+ switch (_a.label) {
14394
+ case 0: return [4 /*yield*/, this.getSharedScenario(sharedScenarioId, claimId)];
14395
+ case 1:
14396
+ sharedScenario = (_a.sent()).sharedScenario;
14397
+ return [2 /*return*/, mapEdges(sharedScenario.sharedClaim.claim.asClaimApprovers).filter(function (asClaimApprover) { return asClaimApprover.state === state; })];
14398
+ }
14399
+ });
14400
+ });
14401
+ };
14402
+ ScenarioService.prototype.prepareApproveClaimMutations = function (sharedScenarioId, claimId) {
14403
+ return __awaiter(this, void 0, void 0, function () {
14404
+ var asClaimApprovers;
14405
+ var _this = this;
14406
+ return __generator(this, function (_a) {
14407
+ switch (_a.label) {
14408
+ case 0: return [4 /*yield*/, this.asClaimApprovers(sharedScenarioId, claimId, TpClaimApproverState.CLAIMED)];
14409
+ case 1:
14410
+ asClaimApprovers = _a.sent();
14411
+ return [2 /*return*/, asClaimApprovers.map(function (asClaimApprover) { return __awaiter(_this, void 0, void 0, function () {
14412
+ var _a, _b, _c;
14413
+ return __generator(this, function (_d) {
14414
+ switch (_d.label) {
14415
+ case 0:
14416
+ _a = LrMutation.bind;
14417
+ _b = {
14418
+ mutation: ApproveScenarioClaimMutation
14419
+ };
14420
+ _c = {};
14421
+ return [4 /*yield*/, this.prepareApproveClaim(asClaimApprover)];
14422
+ case 1: return [2 /*return*/, new (_a.apply(LrMutation, [void 0, (_b.variables = (_c.input = _d.sent(),
14423
+ _c),
14424
+ _b)]))()];
14425
+ }
14426
+ });
14427
+ }); })];
14428
+ }
14429
+ });
14430
+ });
14431
+ };
14432
+ ScenarioService.prototype.prepareApproveClaim = function (asClaimApprover) {
14433
+ return __awaiter(this, void 0, void 0, function () {
14434
+ var receiverApprovals;
14435
+ var _this = this;
14436
+ return __generator(this, function (_a) {
14437
+ switch (_a.label) {
14438
+ case 0: return [4 /*yield*/, Promise.all(mapEdges(asClaimApprover.receiverApprovals).map(function (receiverApproval) { return _this.prepareReceiverApproval({
14439
+ receiverApprovalId: receiverApproval.id,
14440
+ receiverApprovalPxkId: receiverApproval.pxk.id,
14441
+ sharedCipherPartialAssemblyKeyClearJson: asClaimApprover.sharedCipherPartialAssemblyKeyClearJson,
14442
+ }); }))];
14443
+ case 1:
14444
+ receiverApprovals = _a.sent();
14445
+ return [2 /*return*/, {
14446
+ claimApproverId: asClaimApprover.id,
14447
+ receiverApprovals: receiverApprovals,
14448
+ }];
14449
+ }
14450
+ });
14451
+ });
14452
+ };
14453
+ ScenarioService.prototype.prepareReceiverApproval = function (options) {
14454
+ return __awaiter(this, void 0, void 0, function () {
14455
+ var _a;
14456
+ return __generator(this, function (_b) {
14457
+ switch (_b.label) {
14458
+ case 0:
14459
+ _a = {
14460
+ receiverApprovalId: options.receiverApprovalId,
14461
+ // TODO allow sending of messages to receiver.
14462
+ receiverCipher: ''
14463
+ };
14464
+ return [4 /*yield*/, this.keyGraph.encryptToString(options.receiverApprovalPxkId, options.sharedCipherPartialAssemblyKeyClearJson)];
14465
+ case 1: return [2 /*return*/, (_a.receiverCipherPartialAssemblyKey = _b.sent(),
14466
+ _a)];
14467
+ }
14468
+ });
14469
+ });
14470
+ };
14471
+ ScenarioService.prototype.prepareRejectClaimMutations = function (sharedScenarioId, claimId) {
14472
+ return __awaiter(this, void 0, void 0, function () {
14473
+ var asClaimApprovers;
14474
+ var _this = this;
14475
+ return __generator(this, function (_a) {
14476
+ switch (_a.label) {
14477
+ case 0: return [4 /*yield*/, this.asClaimApprovers(sharedScenarioId, claimId, TpClaimApproverState.CLAIMED)];
14478
+ case 1:
14479
+ asClaimApprovers = _a.sent();
14480
+ return [2 /*return*/, asClaimApprovers.map(function (asClaimApprover) { return __awaiter(_this, void 0, void 0, function () {
14481
+ return __generator(this, function (_a) {
14482
+ return [2 /*return*/, new LrMutation({
14483
+ mutation: RejectScenarioClaimMutation,
14484
+ variables: {
14485
+ input: { claimApproverId: asClaimApprover.id },
14486
+ },
14487
+ })];
14488
+ });
14489
+ }); })];
14490
+ }
14491
+ });
14492
+ });
14493
+ };
14494
+ return ScenarioService;
14495
+ }(LrService));
14496
+ exports.ScenarioService.SLIP39_PASSPHRASE = 'lifeready';
14497
+ exports.ScenarioService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ScenarioService_Factory() { return new exports.ScenarioService(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(exports.Item2Service), i0.ɵɵinject(exports.ɵj), i0.ɵɵinject(EncryptionService)); }, token: exports.ScenarioService, providedIn: "root" });
14498
+ exports.ScenarioService.decorators = [
14499
+ { type: i0.Injectable, args: [{
14500
+ providedIn: 'root',
14501
+ },] }
14502
+ ];
14503
+ exports.ScenarioService.ctorParameters = function () { return [
14504
+ { type: i0.NgZone },
14505
+ { type: i0.Injector },
14506
+ { type: KeyGraphService },
14507
+ { type: exports.Item2Service },
14508
+ { type: exports.ɵj },
14509
+ { type: EncryptionService }
14510
+ ]; };
14511
+ exports.ScenarioService = __decorate([
14512
+ RunOutsideAngular({
14513
+ ngZoneName: 'ngZone',
14514
+ })
14515
+ ], exports.ScenarioService);
14516
+
13568
14517
  /*
13569
14518
  * Public API Surface of lr-auth
13570
14519
  */
@@ -13778,6 +14727,8 @@
13778
14727
  exports.parentCategoriesField = parentCategoriesField;
13779
14728
  exports.processConnection = processConnection;
13780
14729
  exports.sha256 = sha256;
14730
+ exports.throwClaimIdMismatch = throwClaimIdMismatch;
14731
+ exports.throwClaimNotApproved = throwClaimNotApproved;
13781
14732
  exports.ɵ0 = ɵ0;
13782
14733
  exports.ɵa = TimeService;
13783
14734
  exports.ɵd = RunOutsideAngular;