@lifeready/core 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1994,10 +1994,8 @@
1994
1994
  if (!!path_1_1.done) return [3 /*break*/, 4];
1995
1995
  link = path_1_1.value;
1996
1996
  dstKey = this.key(link.data.keyId);
1997
- // console.log("key: ", link.data.keyId);
1998
1997
  if (dstKey.jwk) {
1999
1998
  key = dstKey.jwk;
2000
- // console.log("Returning cached key: ", link.data.keyId);
2001
1999
  return [3 /*break*/, 3];
2002
2000
  }
2003
2001
  if (!dstKey.task) {
@@ -3171,6 +3169,47 @@
3171
3169
  _this.variables = options.variables;
3172
3170
  return _this;
3173
3171
  }
3172
+ /**
3173
+ * Select a different set of fields from the mutation. Example usage:
3174
+ *
3175
+ * interface CreateDirectoryMutationResult {
3176
+ * createDirectory: {
3177
+ * directory: DirectoryNode;
3178
+ * };
3179
+ * };
3180
+ *
3181
+ * const CreateDirectoryMutation = gqlTyped<CreateDirectoryMutationResult>`
3182
+ * mutation CreateDirectoryMutation(...) {
3183
+ * createDirectory(...) {
3184
+ * directory {
3185
+ * id
3186
+ * }
3187
+ * }
3188
+ * }
3189
+ * `
3190
+ * interface CreateDirectoryFragmentResult {
3191
+ * createDirectory: {
3192
+ * directory: DirectoryNode;
3193
+ * };
3194
+ * };
3195
+ *
3196
+ * const CreateDirectoryFragment = gqlTyped<CreateDirectoryFragmentResult>`
3197
+ * // Note that the string 'createDirectory' can not be changed.
3198
+ * // It must match with the mutation field above.
3199
+ * // The 'CreateDirectoryPayload' is the return type of the mutation.
3200
+ * fragment createDirectory on CreateDirectoryPayload {
3201
+ * directory {
3202
+ * plainMeta
3203
+ * }
3204
+ * }
3205
+ * `
3206
+ * lrGraphQLService.lrMutate({
3207
+ * mutation: CreateDirectoryMutation
3208
+ * }).select(CreateDirectoryFragment).createDirectory.directory.plainMeta.
3209
+ *
3210
+ * @param fragments
3211
+ * @returns
3212
+ */
3174
3213
  LrMutation.prototype.select = function (fragments) {
3175
3214
  // Don't touch the original
3176
3215
  var mutationDoc = _.cloneDeep(this.mutation);
@@ -3385,7 +3424,6 @@
3385
3424
  // Rename and merge selections
3386
3425
  selections = __spread(selections, _this.renameSelections(childMutationNode.selectionSet.selections, prefix));
3387
3426
  try {
3388
- // TODO Rename and merge fragments
3389
3427
  // Rename and merge variables
3390
3428
  for (var _c = __values(Object.keys(variables)), _d = _c.next(); !_d.done; _d = _c.next()) {
3391
3429
  var key2 = _d.value;
@@ -3438,7 +3476,7 @@
3438
3476
  }
3439
3477
  LrGraphQLService.prototype.query = function (options) {
3440
3478
  return __awaiter(this, void 0, void 0, function () {
3441
- var includeKeyGraph, operation, response, data;
3479
+ var includeKeyGraph, operation, operation, response, data;
3442
3480
  return __generator(this, function (_a) {
3443
3481
  switch (_a.label) {
3444
3482
  case 0:
@@ -3451,6 +3489,13 @@
3451
3489
  keyGraphFieldAstSelection,
3452
3490
  ]);
3453
3491
  }
3492
+ if (options.name) {
3493
+ operation = getQuery(options.query);
3494
+ operation.name = {
3495
+ kind: 'Name',
3496
+ value: options.name,
3497
+ };
3498
+ }
3454
3499
  return [4 /*yield*/, this.apollo.query(options).toPromise()];
3455
3500
  case 1:
3456
3501
  response = _a.sent();
@@ -3491,7 +3536,7 @@
3491
3536
  };
3492
3537
  LrGraphQLService.prototype.apolloMutate = function (options) {
3493
3538
  return __awaiter(this, void 0, void 0, function () {
3494
- var includeKeyGraph, operation, response, data;
3539
+ var includeKeyGraph, operation, operation, response, data;
3495
3540
  return __generator(this, function (_a) {
3496
3541
  switch (_a.label) {
3497
3542
  case 0:
@@ -3504,6 +3549,13 @@
3504
3549
  fetchKeyGraphFieldAstSelection,
3505
3550
  ]);
3506
3551
  }
3552
+ if (options.name) {
3553
+ operation = getMutation(options.mutation);
3554
+ operation.name = {
3555
+ kind: 'Name',
3556
+ value: options.name,
3557
+ };
3558
+ }
3507
3559
  // Format to string and parse again. This allows the "loc": { "start": ... }
3508
3560
  // part of the DocumentNode to be correctly setup. It's extra processing
3509
3561
  // in serialising and parsing, but probably minimal overhead.
@@ -5633,7 +5685,6 @@
5633
5685
  case 0: return [4 /*yield*/, this.keyFactory.createKey()];
5634
5686
  case 1:
5635
5687
  assemblyKey = _c.sent();
5636
- console.log('prepareAssembly assemblyKey', assemblyKey);
5637
5688
  _a = assemblyKey.toJSON(true), rawAssemblyKey = _a.k, assemblyKeyParams = __rest(_a, ["k"]);
5638
5689
  return [4 /*yield*/, this.keyFactory.createPkcSignKey()];
5639
5690
  case 2:
@@ -6004,7 +6055,6 @@
6004
6055
  },
6005
6056
  assemblyKeyParams: assemblyKeyParams,
6006
6057
  };
6007
- console.log('partialAssemblyKey', partialAssemblyKey);
6008
6058
  return [4 /*yield*/, this.encryptionService.encryptToString(sharedKey, tp.sharedCipherDataClearJson || '')];
6009
6059
  case 5:
6010
6060
  sharedCipherData = _c.sent();
@@ -6622,13 +6672,13 @@
6622
6672
  cognitoUser = _b.sent();
6623
6673
  refreshToken = cognitoUser.getSignInUserSession().getRefreshToken();
6624
6674
  return [2 /*return*/, new Promise(function (resolve, reject) {
6625
- cognitoUser.refreshSession(refreshToken, function (err, data) {
6675
+ cognitoUser.refreshSession(refreshToken, function (err) {
6626
6676
  if (err) {
6627
6677
  console.error('Error refreshing token: ', err);
6628
6678
  reject(err);
6629
6679
  }
6630
6680
  else {
6631
- console.log('Token refresh complete: ', data);
6681
+ console.log('Token refresh complete');
6632
6682
  resolve(0);
6633
6683
  }
6634
6684
  });
@@ -6655,7 +6705,6 @@
6655
6705
  return [4 /*yield*/, this.encryptionService.decrypt(assemblyKey, resetUser.assemblyCipherData)];
6656
6706
  case 3:
6657
6707
  rootKey = (_b.sent()).rootKey;
6658
- console.log(rootKey);
6659
6708
  return [4 /*yield*/, nodeJose.JWK.asKey(rootKey)];
6660
6709
  case 4:
6661
6710
  rootKeyJwk = _b.sent();
@@ -6679,11 +6728,9 @@
6679
6728
  })];
6680
6729
  case 8:
6681
6730
  challenge = (_b.sent()).createTpAssemblyKeyChallenge.challenge;
6682
- console.log(challenge);
6683
6731
  // Sign the challenge
6684
6732
  // Generate a client side nonce that's no in the server's control.
6685
6733
  challenge.clientNonce = this.keyFactory.randomString(TP_PASSWORD_RESET_CLIENT_NONCE_LENGTH);
6686
- console.log(challenge);
6687
6734
  return [4 /*yield*/, this.encryptionService.decrypt(assemblyKey, resetUser.wrappedAssemblyKeyVerifierPrk)];
6688
6735
  case 9:
6689
6736
  assemblyKeyVerifierPrk = _b.sent();
@@ -6711,7 +6758,6 @@
6711
6758
  return [2 /*return*/];
6712
6759
  }
6713
6760
  core$1.Hub.remove('auth', listener);
6714
- console.log(data.payload);
6715
6761
  return [4 /*yield*/, this.auth.signIn(resetUser.username, newIdpPassword)];
6716
6762
  case 1:
6717
6763
  _b.sent();
@@ -8225,6 +8271,16 @@
8225
8271
  Item2Service.prototype.beginDeleteChildItemLinksWindow = function (options) {
8226
8272
  return this.mutate(this.beginDeleteChildItemLinksWindowMutation(options));
8227
8273
  };
8274
+ /**
8275
+ * Schedule cleanup of the hard links in a directory.
8276
+ * The server will delete all hard link within the directory within a time window: starting from now and
8277
+ * ending at requestWindowMs after now.
8278
+ * The server decides _when_ it will perform the delete. It's not guaranteed that it will perform
8279
+ * the delete at "now + requestWindowMs", but it will happen at some time after "now + requestWindowMs".
8280
+ * This allows multiple overlapping calls to this function and the server allocates enough for each request.
8281
+ * The server has a setting that allows for a maximum value on requestWindowMs. If the requested value
8282
+ * is larger than this maximum, the call will fail.
8283
+ */
8228
8284
  Item2Service.prototype.beginDeleteChildItemLinksWindowMutation = function (options) {
8229
8285
  return __awaiter(this, void 0, void 0, function () {
8230
8286
  return __generator(this, function (_c) {
@@ -8453,7 +8509,7 @@
8453
8509
  _l.label = 3;
8454
8510
  case 3:
8455
8511
  fileContent = _c;
8456
- if (!fileContent) return [3 /*break*/, 9];
8512
+ if (!fileContent) return [3 /*break*/, 8];
8457
8513
  return [4 /*yield*/, this.keyGraph.encryptToString(fileStateKey, fileContent)];
8458
8514
  case 4:
8459
8515
  cipherFileContent = _l.sent();
@@ -8469,18 +8525,15 @@
8469
8525
  contentResource = _l.sent();
8470
8526
  _l.label = 8;
8471
8527
  case 8:
8472
- console.log('contentResource', contentResource);
8473
- _l.label = 9;
8474
- case 9:
8475
8528
  _e = (_d = Object).assign;
8476
8529
  _g = (_f = Object).assign;
8477
8530
  _h = [{}];
8478
8531
  return [4 /*yield*/, this.prepareItem(fileStateKey, options)];
8479
- case 10:
8532
+ case 9:
8480
8533
  _j = [_g.apply(_f, _h.concat([(_l.sent())]))];
8481
8534
  _k = {};
8482
8535
  return [4 /*yield*/, this.keyGraph.wrapKey(fileKey, fileStateKey)];
8483
- case 11: return [2 /*return*/, _e.apply(_d, _j.concat([(_k.wrappedStateKey = _l.sent(), _k.contentResource = contentResource, _k)]))];
8536
+ case 10: return [2 /*return*/, _e.apply(_d, _j.concat([(_k.wrappedStateKey = _l.sent(), _k.contentResource = contentResource, _k)]))];
8484
8537
  }
8485
8538
  });
8486
8539
  });
@@ -13495,7 +13548,6 @@
13495
13548
  return [4 /*yield*/, this.recoverAssemblyKey(approvals)];
13496
13549
  case 2:
13497
13550
  assemblyKey = _a.sent();
13498
- console.log('receiveClaimMutation assemblyKey', assemblyKey);
13499
13551
  return [4 /*yield*/, Promise.all(sharedScenario.asReceiver.receiverDirectories.edges
13500
13552
  .map(function (edge) { return edge.node; })
13501
13553
  .map(function (receiverDirectory) { return __awaiter(_this, void 0, void 0, function () {
@@ -13954,7 +14006,6 @@
13954
14006
  return [4 /*yield*/, nodeJose.JWK.asKey(JSON.parse(sharedReset.sharedRequest.pxk.pbk))];
13955
14007
  case 2:
13956
14008
  pbk = _c.sent();
13957
- console.log(pbk.toJSON());
13958
14009
  claimApprovers = sharedReset.sharedRequest.claim.asClaimApprovers.edges.filter(function (edge) { return edge.node.state === exports.TpClaimApproverState.CLAIMED; });
13959
14010
  _b = (_a = LrMergedMutation).create;
13960
14011
  return [4 /*yield*/, Promise.all(claimApprovers.map(function (approverEdge) { return __awaiter(_this, void 0, void 0, function () {
@@ -13986,7 +14037,6 @@
13986
14037
  case 1:
13987
14038
  input = (_a.receiverApprovals = _b.sent(),
13988
14039
  _a);
13989
- console.log(input);
13990
14040
  return [2 /*return*/, new LrMutation({
13991
14041
  mutation: ApproveTpPasswordResetRequestMutation,
13992
14042
  variables: {
@@ -14105,8 +14155,7 @@
14105
14155
  .toPromise()];
14106
14156
  case 6:
14107
14157
  requestResetResult = _a.sent();
14108
- console.log(requestResetResult);
14109
- console.log('Using new password: ', this.passwordService.getPassIdpString(passKeyBundle.passIdp));
14158
+ console.log('Using new password');
14110
14159
  return [4 /*yield*/, this.auth.signUp({
14111
14160
  username: requestResetResult.reset_username,
14112
14161
  password: this.passwordService.getPassIdpString(passKeyBundle.passIdp),
@@ -14119,7 +14168,7 @@
14119
14168
  })];
14120
14169
  case 7:
14121
14170
  signUpResult = _a.sent();
14122
- console.log('requestRest done: ', signUpResult);
14171
+ console.log('requestRest done');
14123
14172
  return [2 /*return*/, {
14124
14173
  requestResetResult: requestResetResult,
14125
14174
  signUpResult: signUpResult,