@lifeready/core 8.0.16 → 9.0.2

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.
@@ -665,16 +665,13 @@
665
665
  });
666
666
  });
667
667
  }
668
- function assert_xor(options) {
668
+ function assertExactlyOne(options) {
669
669
  var keys = Object.keys(options);
670
- if (keys.length != 2) {
671
- throw new KcBadLogicException('You must provide exactly 2 fields in the argument.');
670
+ if (keys.length < 2) {
671
+ throw new KcBadLogicException('You must provide 2 or more fields in the argument.');
672
672
  }
673
- if (options[keys[0]] != null && options[keys[1]] != null) {
674
- throw new KcBadLogicException("You can not specify both " + keys[0] + " and " + keys[1]);
675
- }
676
- if (options[keys[0]] == null && options[keys[1]] == null) {
677
- throw new KcBadLogicException("You must specify either " + keys[0] + " and " + keys[1]);
673
+ if (keys.filter(function (key) { return options[key] != null; }).length != 1) {
674
+ throw new KcBadLogicException("You must provide exactly one argument that != null.");
678
675
  }
679
676
  }
680
677
 
@@ -3831,6 +3828,20 @@
3831
3828
  function mapEdges(connection) {
3832
3829
  return connection.edges.map(function (edge) { return edge.node; });
3833
3830
  }
3831
+ function toIdKeyPair(t) {
3832
+ if (t === undefined) {
3833
+ return undefined;
3834
+ }
3835
+ else if (t === null) {
3836
+ return null;
3837
+ }
3838
+ else {
3839
+ return {
3840
+ id: t.id,
3841
+ keyId: t.keyId,
3842
+ };
3843
+ }
3844
+ }
3834
3845
  (function (UserDeleteState) {
3835
3846
  UserDeleteState["REQUESTED"] = "REQUESTED";
3836
3847
  })(exports.UserDeleteState || (exports.UserDeleteState = {}));
@@ -7233,8 +7244,8 @@
7233
7244
  var ArchiveFileMutation = gqlTyped(templateObject_9$2 || (templateObject_9$2 = __makeTemplateObject(["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"], ["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"])));
7234
7245
  var UnarchiveDirectoryMutation = gqlTyped(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"], ["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"])));
7235
7246
  var UnarchiveFileMutation = gqlTyped(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"], ["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"])));
7236
- var ChangeDirectoryParentsMutation = gqlTyped(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"], ["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"])));
7237
- var ChangeFileParentsMutation = gqlTyped(templateObject_13 || (templateObject_13 = __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"])));
7247
+ var ChangeDirectoryParentsMutation = gqlTyped(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"], ["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"])));
7248
+ var ChangeFileParentsMutation = gqlTyped(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"], ["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"])));
7238
7249
  var BeginDeleteChildItemLinksWindowMutation = gqlTyped(templateObject_14 || (templateObject_14 = __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"])));
7239
7250
  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"])));
7240
7251
  var SetFileConfidentialMutation = gqlTyped(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"], ["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"])));
@@ -7789,8 +7800,7 @@
7789
7800
  cipherMetaClearJson: options.cipherMetaClearJson,
7790
7801
  parentDirectories: [
7791
7802
  {
7792
- directoryId: tempDir.id,
7793
- wrappingKeyId: tempDir.keyId,
7803
+ directory: tempDir,
7794
7804
  },
7795
7805
  ],
7796
7806
  plainMetaJson: options.plainMetaJson,
@@ -7851,8 +7861,7 @@
7851
7861
  _d.sent();
7852
7862
  return [4 /*yield*/, this.createFile(Object.assign(Object.assign({}, options), { parentDirectories: [
7853
7863
  {
7854
- directoryId: tempDir.id,
7855
- wrappingKeyId: tempDir.keyId,
7864
+ directory: tempDir,
7856
7865
  },
7857
7866
  ] }))];
7858
7867
  case 3:
@@ -7869,8 +7878,7 @@
7869
7878
  // TODO return the server time where delete is scheduled. Expirable mutation
7870
7879
  // Return the mutation that moves the directory into the dst directories
7871
7880
  return [2 /*return*/, this.changeFileParentsMutation({
7872
- fileId: file.id,
7873
- fileKeyId: file.keyId,
7881
+ file: file,
7874
7882
  parentsToRemove: [tempDir.id],
7875
7883
  parentsToAdd: options.parentDirectories,
7876
7884
  })];
@@ -7929,24 +7937,25 @@
7929
7937
  // ------------------------------------------------------------------------------
7930
7938
  ItemService.prototype.prepareParentDirectory = function (options, newKey) {
7931
7939
  return __awaiter(this, void 0, void 0, function () {
7932
- var directoryId, linkType, wrappingKeyId, wrappingKey, _d;
7940
+ var _directoryId, _wrappingKeyId, linkType, directory, wrappingKey, _d;
7933
7941
  return __generator(this, function (_e) {
7934
7942
  switch (_e.label) {
7935
7943
  case 0:
7936
- directoryId = options.directoryId, linkType = options.linkType, wrappingKeyId = options.wrappingKeyId;
7944
+ _directoryId = options.directoryId, _wrappingKeyId = options.wrappingKeyId, linkType = options.linkType;
7945
+ directory = options.directory || {
7946
+ id: _directoryId,
7947
+ keyId: _wrappingKeyId,
7948
+ };
7937
7949
  if (!(linkType == exports.LinkTypeField.REFERENCE)) return [3 /*break*/, 1];
7938
- if (wrappingKeyId) {
7939
- throw new KcBadArgumentException('Do not specify wrappingKeyId when link type is REFERENCE.');
7940
- }
7941
7950
  return [2 /*return*/, {
7942
- directoryId: directoryId,
7951
+ directoryId: directory.id,
7943
7952
  linkType: linkType,
7944
7953
  }];
7945
- case 1: return [4 /*yield*/, this.getDirectoryKey(directoryId, wrappingKeyId)];
7954
+ case 1: return [4 /*yield*/, this.getDirectoryKey(directory.id, directory.keyId)];
7946
7955
  case 2:
7947
7956
  wrappingKey = _e.sent();
7948
7957
  _d = {
7949
- directoryId: directoryId,
7958
+ directoryId: directory.id,
7950
7959
  wrappingKeyId: wrappingKey.id
7951
7960
  };
7952
7961
  return [4 /*yield*/, this.keyGraph.wrapKey(wrappingKey, newKey)];
@@ -8157,32 +8166,42 @@
8157
8166
  };
8158
8167
  ItemService.prototype.prepareChangeDirectoryParents = function (options) {
8159
8168
  return __awaiter(this, void 0, void 0, function () {
8160
- var directoryKey, input;
8169
+ var directory, directoryKey, input;
8161
8170
  return __generator(this, function (_d) {
8162
8171
  switch (_d.label) {
8163
- case 0: return [4 /*yield*/, this.getDirectoryKey(options.directoryId, options.directoryKeyId)];
8172
+ case 0:
8173
+ directory = options.directory || {
8174
+ id: options.directoryId,
8175
+ keyId: options.directoryKeyId,
8176
+ };
8177
+ return [4 /*yield*/, this.getDirectoryKey(directory.id, directory.keyId)];
8164
8178
  case 1:
8165
8179
  directoryKey = _d.sent();
8166
8180
  return [4 /*yield*/, this.prepareChangeItemParents(options, directoryKey.jwk)];
8167
8181
  case 2:
8168
8182
  input = _d.sent();
8169
- return [2 /*return*/, Object.assign(Object.assign({}, input), { directoryId: options.directoryId })];
8183
+ return [2 /*return*/, Object.assign(Object.assign({}, input), { directoryId: directory.id })];
8170
8184
  }
8171
8185
  });
8172
8186
  });
8173
8187
  };
8174
8188
  ItemService.prototype.prepareChangeFileParents = function (options) {
8175
8189
  return __awaiter(this, void 0, void 0, function () {
8176
- var fileKey, input;
8190
+ var file, fileKey, input;
8177
8191
  return __generator(this, function (_d) {
8178
8192
  switch (_d.label) {
8179
- case 0: return [4 /*yield*/, this.getFileKey(options.fileId, options.fileKeyId)];
8193
+ case 0:
8194
+ file = options.file || {
8195
+ id: options.fileId,
8196
+ keyId: options.fileKeyId,
8197
+ };
8198
+ return [4 /*yield*/, this.getFileKey(file.id, file.keyId)];
8180
8199
  case 1:
8181
8200
  fileKey = _d.sent();
8182
8201
  return [4 /*yield*/, this.prepareChangeItemParents(options, fileKey.jwk)];
8183
8202
  case 2:
8184
8203
  input = _d.sent();
8185
- return [2 /*return*/, Object.assign(Object.assign({}, input), { fileId: options.fileId })];
8204
+ return [2 /*return*/, Object.assign(Object.assign({}, input), { fileId: file.id })];
8186
8205
  }
8187
8206
  });
8188
8207
  });
@@ -10929,7 +10948,7 @@
10929
10948
  switch (_a.label) {
10930
10949
  case 0:
10931
10950
  receiverItemOptions = options.receiverItemOptions, receiverSharedKey = options.receiverSharedKey, assemblyKey = options.assemblyKey, directory = options.directory, file = options.file;
10932
- assert_xor({ directory: directory, file: file });
10951
+ assertExactlyOne({ directory: directory, file: file });
10933
10952
  accessRole = receiverItemOptions.accessRole;
10934
10953
  if (!(accessRole == exports.AccessRoleChoice.DENY)) return [3 /*break*/, 1];
10935
10954
  ret = {
@@ -12221,20 +12240,24 @@
12221
12240
  };
12222
12241
  TrustedPartyService.prototype.prepareCreateItemShareMutation = function (options) {
12223
12242
  return __awaiter(this, void 0, void 0, function () {
12224
- var itemId, itemKeyId, tpId, tpSharedKeyId, accessRole, isDirectory, shareType, plainMetaJson, plainMeta, itemKey, wrappingKey, wrappedItemKey;
12243
+ var _itemId, _itemKeyId, tpId, tpSharedKeyId, accessRole, isDirectory, shareType, plainMetaJson, item, plainMeta, itemKey, wrappingKey, wrappedItemKey;
12225
12244
  var _this = this;
12226
12245
  return __generator(this, function (_a) {
12227
12246
  switch (_a.label) {
12228
12247
  case 0:
12229
- itemId = options.itemId, itemKeyId = options.itemKeyId, tpId = options.tpId, tpSharedKeyId = options.tpSharedKeyId, accessRole = options.accessRole, isDirectory = options.isDirectory, shareType = options.shareType, plainMetaJson = options.plainMetaJson;
12248
+ _itemId = options.itemId, _itemKeyId = options.itemKeyId, tpId = options.tpId, tpSharedKeyId = options.tpSharedKeyId, accessRole = options.accessRole, isDirectory = options.isDirectory, shareType = options.shareType, plainMetaJson = options.plainMetaJson;
12249
+ item = options.item || {
12250
+ id: _itemId,
12251
+ keyId: _itemKeyId,
12252
+ };
12230
12253
  plainMeta = plainMetaJson && JSON.stringify(plainMetaJson);
12231
12254
  if (accessRole == exports.AccessRoleChoice.DENY) {
12232
- if (itemKeyId || tpSharedKeyId) {
12255
+ if (item.keyId || tpSharedKeyId) {
12233
12256
  throw new KcBadArgumentException('If accessRole is AccessRoleChoice.DENY, must not specify any of itemId, itemKeyId, or tpSharedKeyId parameters');
12234
12257
  }
12235
12258
  return [2 /*return*/, {
12236
12259
  input: {
12237
- itemId: itemId,
12260
+ itemId: item.id,
12238
12261
  tpId: tpId,
12239
12262
  accessRole: accessRole,
12240
12263
  itemKeyId: null,
@@ -12245,9 +12268,9 @@
12245
12268
  },
12246
12269
  }];
12247
12270
  }
12248
- return [4 /*yield*/, this.keyGraph.getKey(itemKeyId, function () { return isDirectory
12249
- ? _this.itemService.getDirectoryKeyId(itemId)
12250
- : _this.itemService.getFileKeyId(itemId); })];
12271
+ return [4 /*yield*/, this.keyGraph.getKey(item.keyId, function () { return isDirectory
12272
+ ? _this.itemService.getDirectoryKeyId(item.id)
12273
+ : _this.itemService.getFileKeyId(item.id); })];
12251
12274
  case 1:
12252
12275
  itemKey = _a.sent();
12253
12276
  return [4 /*yield*/, this.keyGraph.getKey(tpSharedKeyId, function () { return _this.getTpCurrentUserSharedKey(tpId).then(function (res) { return res.sharedKey.id; }); })];
@@ -12258,7 +12281,7 @@
12258
12281
  wrappedItemKey = _a.sent();
12259
12282
  return [2 /*return*/, {
12260
12283
  input: {
12261
- itemId: itemId,
12284
+ itemId: item.id,
12262
12285
  tpId: tpId,
12263
12286
  accessRole: accessRole,
12264
12287
  itemKeyId: itemKey.id,
@@ -12386,16 +12409,20 @@
12386
12409
  };
12387
12410
  TrustedPartyService.prototype.prepareUpdateItemShareMutation = function (options) {
12388
12411
  return __awaiter(this, void 0, void 0, function () {
12389
- var itemShareId, accessRole, isDirectory, itemId, itemKeyId, tpId, tpSharedKeyId, plainMetaJson, plainMeta, itemShare, getItemShare, itemKey, wrappingKey, wrappedItemKey;
12412
+ var itemShareId, accessRole, isDirectory, _itemId, _itemKeyId, tpId, tpSharedKeyId, plainMetaJson, item, plainMeta, itemShare, getItemShare, itemKey, wrappingKey, wrappedItemKey;
12390
12413
  var _this = this;
12391
12414
  return __generator(this, function (_a) {
12392
12415
  switch (_a.label) {
12393
12416
  case 0:
12394
- itemShareId = options.itemShareId, accessRole = options.accessRole, isDirectory = options.isDirectory, itemId = options.itemId, itemKeyId = options.itemKeyId, tpId = options.tpId, tpSharedKeyId = options.tpSharedKeyId, plainMetaJson = options.plainMetaJson;
12417
+ itemShareId = options.itemShareId, accessRole = options.accessRole, isDirectory = options.isDirectory, _itemId = options.itemId, _itemKeyId = options.itemKeyId, tpId = options.tpId, tpSharedKeyId = options.tpSharedKeyId, plainMetaJson = options.plainMetaJson;
12418
+ item = options.item || {
12419
+ id: _itemId,
12420
+ keyId: _itemKeyId,
12421
+ };
12395
12422
  plainMeta = plainMetaJson && JSON.stringify(plainMetaJson);
12396
12423
  // If not updating access role or updating to DENY role, then we don't need any key material.
12397
12424
  if (accessRole == null || accessRole == exports.AccessRoleChoice.DENY) {
12398
- if (itemId || itemKeyId || tpId || tpSharedKeyId) {
12425
+ if (item.id || item.keyId || tpId || tpSharedKeyId) {
12399
12426
  throw new KcBadArgumentException('If accessRole is AccessRoleChoice.DENY, must not specify any of itemId, itemKeyId, tpId, or tpSharedKeyId parameters');
12400
12427
  }
12401
12428
  return [2 /*return*/, {
@@ -12430,12 +12457,12 @@
12430
12457
  }
12431
12458
  });
12432
12459
  }); };
12433
- return [4 /*yield*/, this.keyGraph.getKey(itemKeyId, function () { return __awaiter(_this, void 0, void 0, function () {
12460
+ return [4 /*yield*/, this.keyGraph.getKey(item.keyId, function () { return __awaiter(_this, void 0, void 0, function () {
12434
12461
  var itemId_, _a;
12435
12462
  return __generator(this, function (_b) {
12436
12463
  switch (_b.label) {
12437
12464
  case 0:
12438
- _a = itemId;
12465
+ _a = item.id;
12439
12466
  if (_a) return [3 /*break*/, 2];
12440
12467
  return [4 /*yield*/, getItemShare()];
12441
12468
  case 1:
@@ -13162,6 +13189,7 @@
13162
13189
  exports.processConnection = processConnection;
13163
13190
  exports.throwClaimIdMismatch = throwClaimIdMismatch;
13164
13191
  exports.throwClaimNotApproved = throwClaimNotApproved;
13192
+ exports.toIdKeyPair = toIdKeyPair;
13165
13193
  exports.ɵa = KeyGraphService;
13166
13194
  exports.ɵb = EncryptionService;
13167
13195
  exports.ɵc = KeyService;