@lifeready/core 8.0.9 → 8.0.11

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.
@@ -2971,6 +2971,15 @@
2971
2971
  },
2972
2972
  }),
2973
2973
  ]));
2974
+ this.registerProcessor('SharedScenarioReceiverDirectoryNode', common.series([
2975
+ common.makeDecryptionProcessor({
2976
+ cipherFieldName: 'sharedCipherData',
2977
+ getKeyId: function (_a) {
2978
+ var field = _a.field;
2979
+ return field.sharedKey.id;
2980
+ },
2981
+ }),
2982
+ ]));
2974
2983
  this.registerProcessor('ScenarioReceiverFileNode', common.series([
2975
2984
  common.makeDecryptionProcessor({
2976
2985
  cipherFieldName: 'sharedCipherData',
@@ -2980,6 +2989,15 @@
2980
2989
  },
2981
2990
  }),
2982
2991
  ]));
2992
+ this.registerProcessor('SharedScenarioReceiverFileNode', common.series([
2993
+ common.makeDecryptionProcessor({
2994
+ cipherFieldName: 'sharedCipherData',
2995
+ getKeyId: function (_a) {
2996
+ var field = _a.field;
2997
+ return field.sharedKey.id;
2998
+ },
2999
+ }),
3000
+ ]));
2983
3001
  this.registerProcessor('SharedScenarioReceiverNode', common.series([
2984
3002
  common.makeDecryptionProcessor({
2985
3003
  cipherFieldName: 'sharedCipherData',
@@ -7687,10 +7705,10 @@
7687
7705
  });
7688
7706
  });
7689
7707
  };
7690
- ItemService.prototype.createDirectoryTree = function (options) {
7708
+ ItemService.prototype.createDirectoryWithStaging = function (options) {
7691
7709
  return __awaiter(this, void 0, void 0, function () {
7692
7710
  return __generator(this, function (_d) {
7693
- return [2 /*return*/, this.mutate(this.createDirectoryTreeMutation(options))];
7711
+ return [2 /*return*/, this.mutate(this.createDirectoryWithStagingMutation(options))];
7694
7712
  });
7695
7713
  });
7696
7714
  };
@@ -7699,7 +7717,7 @@
7699
7717
  * server, otherwise the temp directory will get cleaned up.
7700
7718
  *
7701
7719
  */
7702
- ItemService.prototype.createDirectoryTreeMutation = function (options) {
7720
+ ItemService.prototype.createDirectoryWithStagingMutation = function (options) {
7703
7721
  return __awaiter(this, void 0, void 0, function () {
7704
7722
  var tempDir, directory;
7705
7723
  return __generator(this, function (_d) {
@@ -7735,13 +7753,13 @@
7735
7753
  })];
7736
7754
  case 3:
7737
7755
  directory = (_d.sent()).createDirectory.directory;
7738
- // Create the contents
7739
- return [4 /*yield*/, options.createContent({
7756
+ // Call back with item that's currently in staging.
7757
+ return [4 /*yield*/, options.onCreatedInStaging({
7740
7758
  id: directory.id,
7741
7759
  keyId: directory.keyId,
7742
7760
  })];
7743
7761
  case 4:
7744
- // Create the contents
7762
+ // Call back with item that's currently in staging.
7745
7763
  _d.sent();
7746
7764
  // TODO client-side check for timeout on requestWindowMs
7747
7765
  // TODO return the server time where delete is scheduled. Expirable mutation
@@ -7756,14 +7774,21 @@
7756
7774
  });
7757
7775
  });
7758
7776
  };
7759
- ItemService.prototype.createFileUsingTempMutation = function (options) {
7777
+ ItemService.prototype.createFileWithStaging = function (options) {
7760
7778
  return __awaiter(this, void 0, void 0, function () {
7761
- var tempDir, file, _d;
7762
- return __generator(this, function (_e) {
7763
- switch (_e.label) {
7779
+ return __generator(this, function (_d) {
7780
+ return [2 /*return*/, this.mutate(this.createFileWithStagingMutation(options))];
7781
+ });
7782
+ });
7783
+ };
7784
+ ItemService.prototype.createFileWithStagingMutation = function (options) {
7785
+ return __awaiter(this, void 0, void 0, function () {
7786
+ var tempDir, file;
7787
+ return __generator(this, function (_d) {
7788
+ switch (_d.label) {
7764
7789
  case 0: return [4 /*yield*/, this.ensureTempDirectory()];
7765
7790
  case 1:
7766
- tempDir = _e.sent();
7791
+ tempDir = _d.sent();
7767
7792
  // Clear the temp directory of the ones we are about to create.
7768
7793
  // NOTE: this mutation can not be merged into a single mutation with the
7769
7794
  // the createDirectory mutation because it uses the current server time to
@@ -7779,7 +7804,7 @@
7779
7804
  // the createDirectory mutation because it uses the current server time to
7780
7805
  // clean up. So it must successfully complete before the creation of the
7781
7806
  // directories.
7782
- _e.sent();
7807
+ _d.sent();
7783
7808
  return [4 /*yield*/, this.createFile(Object.assign(Object.assign({}, options), { parentDirectories: [
7784
7809
  {
7785
7810
  directoryId: tempDir.id,
@@ -7787,24 +7812,24 @@
7787
7812
  },
7788
7813
  ] }))];
7789
7814
  case 3:
7790
- file = (_e.sent()).createFile.file;
7791
- _d = {};
7792
- return [4 /*yield*/, this.changeFileParentsMutation({
7815
+ file = (_d.sent()).createFile.file;
7816
+ // Call back with item that's currently in staging.
7817
+ return [4 /*yield*/, options.onCreatedInStaging({
7818
+ id: file.id,
7819
+ keyId: file.keyId,
7820
+ })];
7821
+ case 4:
7822
+ // Call back with item that's currently in staging.
7823
+ _d.sent();
7824
+ // TODO client-side check for timeout on requestWindowMs
7825
+ // TODO return the server time where delete is scheduled. Expirable mutation
7826
+ // Return the mutation that moves the directory into the dst directories
7827
+ return [2 /*return*/, this.changeFileParentsMutation({
7793
7828
  fileId: file.id,
7794
7829
  fileKeyId: file.keyId,
7795
7830
  parentsToRemove: [tempDir.id],
7796
7831
  parentsToAdd: options.parentDirectories,
7797
7832
  })];
7798
- case 4:
7799
- // TODO client-side check for timeout on requestWindowMs
7800
- // TODO return the server time where delete is scheduled. Expirable mutation
7801
- // Return the mutation that moves the directory into the dst directories
7802
- return [2 /*return*/, (_d.mutation = _e.sent(),
7803
- _d.file = {
7804
- id: file.id,
7805
- keyId: file.keyId,
7806
- },
7807
- _d)];
7808
7833
  }
7809
7834
  });
7810
7835
  });
@@ -10376,8 +10401,8 @@
10376
10401
  })
10377
10402
  ], exports.ɵm);
10378
10403
 
10379
- var ScenarioQuery = gqlTyped(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as directory.keyId. It's here so we can detect\n # when the directory key has been rotated.\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as file.keyId. It's here so we can detect\n # when the file key has been rotated.\n itemKey {\n id\n }\n file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"], ["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as directory.keyId. It's here so we can detect\n # when the directory key has been rotated.\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as file.keyId. It's here so we can detect\n # when the file key has been rotated.\n itemKey {\n id\n }\n file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"])));
10380
- var SharedScenarioQuery = gqlTyped(templateObject_2$h || (templateObject_2$h = __makeTemplateObject(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"], ["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));
10404
+ var ScenarioQuery = gqlTyped(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n 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 file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"], ["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n 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 file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"])));
10405
+ var SharedScenarioQuery = gqlTyped(templateObject_2$h || (templateObject_2$h = __makeTemplateObject(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"], ["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));
10381
10406
  var templateObject_1$m, templateObject_2$h;
10382
10407
 
10383
10408
  function throwClaimIdMismatch() {
@@ -11188,50 +11213,40 @@
11188
11213
  });
11189
11214
  });
11190
11215
  };
11191
- ScenarioService.prototype.prepareReceiveClaim = function (scenarioId, sharedClaimId) {
11192
- return __awaiter(this, void 0, void 0, function () {
11193
- var sharedScenario, approvals, assemblyKey, receiverDirectories;
11194
- var _this = this;
11195
- return __generator(this, function (_a) {
11196
- switch (_a.label) {
11197
- case 0: return [4 /*yield*/, this.getSharedScenario(scenarioId, sharedClaimId)];
11198
- case 1:
11199
- sharedScenario = (_a.sent()).sharedScenario;
11200
- if (sharedScenario.state !== exports.ScenarioState.APPROVED) {
11201
- throwClaimNotApproved();
11202
- }
11203
- approvals = mapEdges(sharedScenario.sharedClaim.asClaimReceiver.approvals);
11204
- return [4 /*yield*/, this.recoverAssemblyKey(approvals)];
11205
- case 2:
11206
- assemblyKey = _a.sent();
11207
- return [4 /*yield*/, Promise.all(sharedScenario.asReceiver.receiverItems.receiverDirectories.edges
11208
- .map(function (edge) { return edge.node; })
11209
- .map(function (receiverDirectory) { return __awaiter(_this, void 0, void 0, function () {
11210
- var wrappedItemKey;
11211
- return __generator(this, function (_a) {
11212
- switch (_a.label) {
11213
- case 0: return [4 /*yield*/, this.encryptionService.decrypt(assemblyKey, receiverDirectory.wrappedItemKey)];
11214
- case 1:
11215
- wrappedItemKey = _a.sent();
11216
- return [2 /*return*/, {
11217
- receiverDirectoryId: receiverDirectory.id,
11218
- // Looks like receiverDirectory.wrappedItemKey has no other content in side it except a wrapped key.
11219
- // So we can turn this in to a doubly wrapped key and just release the assembly key.
11220
- receiverSharedKeyWrappedItemKey: wrappedItemKey,
11221
- }];
11222
- }
11223
- });
11224
- }); }))];
11225
- case 3:
11226
- receiverDirectories = _a.sent();
11227
- return [2 /*return*/, {
11228
- scenarioClaimId: sharedClaimId,
11229
- receiverDirectories: receiverDirectories,
11230
- }];
11231
- }
11232
- });
11233
- });
11234
- };
11216
+ // async prepareReceiveClaim(scenarioId: string, sharedClaimId: string) {
11217
+ // // Get all the shared items
11218
+ // const sharedScenario = (
11219
+ // await this.getSharedScenario(scenarioId, sharedClaimId)
11220
+ // ).sharedScenario;
11221
+ // if (sharedScenario.state !== ScenarioState.APPROVED) {
11222
+ // throwClaimNotApproved();
11223
+ // }
11224
+ // const approvals = mapEdges(
11225
+ // sharedScenario.sharedClaim.asClaimReceiver.approvals
11226
+ // );
11227
+ // const assemblyKey = await this.recoverAssemblyKey(approvals);
11228
+ // // Decrypt all items
11229
+ // const receiverDirectories = await Promise.all(
11230
+ // sharedScenario.asReceiver.receiverItems.receiverDirectories.edges
11231
+ // .map((edge) => edge.node)
11232
+ // .map(async (receiverDirectory) => {
11233
+ // const wrappedItemKey = await this.encryptionService.decrypt(
11234
+ // assemblyKey,
11235
+ // receiverDirectory.wrappedItemKey
11236
+ // );
11237
+ // return {
11238
+ // receiverDirectoryId: receiverDirectory.id,
11239
+ // // Looks like receiverDirectory.wrappedItemKey has no other content in side it except a wrapped key.
11240
+ // // So we can turn this in to a doubly wrapped key and just release the assembly key.
11241
+ // receiverSharedKeyWrappedItemKey: wrappedItemKey, // the wrappedItemKey is already wrapped by receiverSharedKey
11242
+ // };
11243
+ // })
11244
+ // );
11245
+ // return {
11246
+ // scenarioClaimId: sharedClaimId,
11247
+ // receiverDirectories,
11248
+ // };
11249
+ // }
11235
11250
  ScenarioService.prototype.recoverAssemblyKey = function (approvals) {
11236
11251
  return __awaiter(this, void 0, void 0, function () {
11237
11252
  var partials;