@lifeready/core 8.0.10 → 8.0.12

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.
@@ -2,11 +2,14 @@ import { __awaiter, __decorate, __rest } from 'tslib';
2
2
  import { ɵɵdefineInjectable, ɵɵinject, Injectable, InjectionToken, isDevMode, INJECTOR, Injector, Inject, NgZone, APP_INITIALIZER, NgModule } from '@angular/core';
3
3
  import { Apollo, APOLLO_OPTIONS } from 'apollo-angular';
4
4
  import graphlib, { Graph } from '@dagrejs/graphlib';
5
- import _, { cloneDeep } from 'lodash';
6
5
  import { JWE, JWS, JWK } from 'node-jose';
7
6
  import { AuthClass } from '@aws-amplify/auth/lib-esm/Auth';
8
7
  import gql from 'graphql-tag';
9
8
  import * as moment_ from 'moment';
9
+ import lodash$1 from 'lodash/cloneDeep';
10
+ import lodash$2 from 'lodash/isEqual';
11
+ import 'lodash/keyBy';
12
+ import lodash from 'lodash/omit';
10
13
  import { ApolloLink, createHttpLink, from, InMemoryCache } from '@apollo/client/core';
11
14
  import { setContext } from '@apollo/client/link/context';
12
15
  import { RetryLink } from '@apollo/client/link/retry';
@@ -35,6 +38,8 @@ var PayloadType;
35
38
  PayloadType["UINT_8_ARRAY"] = "UINT_8_ARRAY";
36
39
  })(PayloadType || (PayloadType = {}));
37
40
 
41
+ // This file is in the "lr-lodash" directory so that we can use the barrel file
42
+
38
43
  function handleApolloError(errors) {
39
44
  if (!errors || !errors.length)
40
45
  return;
@@ -42,6 +47,7 @@ function handleApolloError(errors) {
42
47
  return new KcError({
43
48
  code: x.extensions && x.extensions.code,
44
49
  source: x.extensions && x.extensions.source,
50
+ data: x.extensions && lodash(x.extensions, ['code', 'source']),
45
51
  message: x.message,
46
52
  debug: {
47
53
  locations: x.locations,
@@ -69,6 +75,7 @@ class KcError {
69
75
  this._type = 'KcError';
70
76
  this.code = options.code;
71
77
  this.source = options.source;
78
+ this.data = options.data;
72
79
  this.message = options.message;
73
80
  this.debug = options.debug;
74
81
  }
@@ -1283,7 +1290,7 @@ class KeyGraphService {
1283
1290
  }
1284
1291
  const node = {
1285
1292
  type: KeyGraphNodeType.Key,
1286
- data: _.cloneDeep(key),
1293
+ data: lodash$1(key),
1287
1294
  };
1288
1295
  this.graph.setNode(key.id, node);
1289
1296
  }
@@ -1296,7 +1303,7 @@ class KeyGraphService {
1296
1303
  }
1297
1304
  const edge = {
1298
1305
  type: KeyGraphEdgeType.KeyLink,
1299
- data: _.cloneDeep(keyLink),
1306
+ data: lodash$1(keyLink),
1300
1307
  };
1301
1308
  // Edge goes from wrapping key to wrapped key.
1302
1309
  this.graph.setEdge(keyLink.wrappingKeyId, keyLink.keyId, edge);
@@ -1310,7 +1317,7 @@ class KeyGraphService {
1310
1317
  }
1311
1318
  const edge = {
1312
1319
  type: KeyGraphEdgeType.PassKeyLink,
1313
- data: _.cloneDeep(passKeyLink),
1320
+ data: lodash$1(passKeyLink),
1314
1321
  };
1315
1322
  // Edge goes from wrapping key to wrapped key.
1316
1323
  this.graph.setEdge(passKeyLink.passKeyId, passKeyLink.keyId, edge);
@@ -1996,12 +2003,24 @@ let QueryProcessorService = class QueryProcessorService {
1996
2003
  getKeyId: ({ field }) => field.sharedKey.id,
1997
2004
  }),
1998
2005
  ]));
2006
+ this.registerProcessor('SharedScenarioReceiverDirectoryNode', common.series([
2007
+ common.makeDecryptionProcessor({
2008
+ cipherFieldName: 'sharedCipherData',
2009
+ getKeyId: ({ field }) => field.sharedKey.id,
2010
+ }),
2011
+ ]));
1999
2012
  this.registerProcessor('ScenarioReceiverFileNode', common.series([
2000
2013
  common.makeDecryptionProcessor({
2001
2014
  cipherFieldName: 'sharedCipherData',
2002
2015
  getKeyId: ({ field }) => field.sharedKey.id,
2003
2016
  }),
2004
2017
  ]));
2018
+ this.registerProcessor('SharedScenarioReceiverFileNode', common.series([
2019
+ common.makeDecryptionProcessor({
2020
+ cipherFieldName: 'sharedCipherData',
2021
+ getKeyId: ({ field }) => field.sharedKey.id,
2022
+ }),
2023
+ ]));
2005
2024
  this.registerProcessor('SharedScenarioReceiverNode', common.series([
2006
2025
  common.makeDecryptionProcessor({
2007
2026
  cipherFieldName: 'sharedCipherData',
@@ -2301,7 +2320,7 @@ class LrMutation extends LrMutationBase {
2301
2320
  */
2302
2321
  select(fragments) {
2303
2322
  // Don't touch the original
2304
- const mutationDoc = cloneDeep(this.mutation);
2323
+ const mutationDoc = lodash$1(this.mutation);
2305
2324
  const mutationNode = getMutation(mutationDoc);
2306
2325
  const fragmentMap = {};
2307
2326
  getFragments(fragments).forEach((fragment) => {
@@ -2529,7 +2548,7 @@ class LrMergedMutation extends LrMutationBase {
2529
2548
  ...this.renameFragmentDefinitions(fragments, prefix),
2530
2549
  ];
2531
2550
  });
2532
- const mergedMutation = cloneDeep(lrMergedMutationDoc);
2551
+ const mergedMutation = lodash$1(lrMergedMutationDoc);
2533
2552
  const mutationNode = getMutation(mergedMutation);
2534
2553
  // Add in the mutation selections
2535
2554
  mutationNode.selectionSet.selections = selections;
@@ -2575,7 +2594,7 @@ let LrGraphQLService = class LrGraphQLService {
2575
2594
  query(options) {
2576
2595
  return __awaiter(this, void 0, void 0, function* () {
2577
2596
  // Make copies to avoid side effect.
2578
- options = cloneDeep(options);
2597
+ options = lodash$1(options);
2579
2598
  // Append the key graph query
2580
2599
  const includeKeyGraph = this.isIncludeKeyGraph(options.includeKeyGraph);
2581
2600
  if (includeKeyGraph) {
@@ -2625,7 +2644,7 @@ let LrGraphQLService = class LrGraphQLService {
2625
2644
  apolloMutate(options) {
2626
2645
  return __awaiter(this, void 0, void 0, function* () {
2627
2646
  // Make copies to avoid side effect.
2628
- options = Object.assign(Object.assign({}, options), { mutation: cloneDeep(options.mutation) });
2647
+ options = Object.assign(Object.assign({}, options), { mutation: lodash$1(options.mutation) });
2629
2648
  // Append the key graph query
2630
2649
  const includeKeyGraph = this.isIncludeKeyGraph(options.includeKeyGraph);
2631
2650
  if (includeKeyGraph) {
@@ -2655,7 +2674,7 @@ let LrGraphQLService = class LrGraphQLService {
2655
2674
  });
2656
2675
  }
2657
2676
  statsSnapshot() {
2658
- return cloneDeep(this.stats);
2677
+ return lodash$1(this.stats);
2659
2678
  }
2660
2679
  addKeys(response) {
2661
2680
  if (response.data.keyGraph) {
@@ -5513,10 +5532,17 @@ let AuthService = AuthService_1 = class AuthService extends LrService {
5513
5532
  // Debug utilities
5514
5533
  // ------------------------------------------------------
5515
5534
  debugLogin(username, password) {
5516
- // This will fail if debug is null. But when debug is null, this function
5517
- // should not be called.
5518
- this.kcConfig.debug.username = username;
5519
- return this.debugLoadUser(password);
5535
+ return __awaiter(this, void 0, void 0, function* () {
5536
+ // This will fail if debug is null. But when debug is null, this function
5537
+ // should not be called.
5538
+ this.kcConfig.debug.username = username;
5539
+ // This mechanism only works in a browser session because it needs to set cookies etc.
5540
+ // But it sets the last_login field for the users which we need in some tests.
5541
+ yield this.http
5542
+ .get(`${this.kcConfig.authUrl}debug_only/users/login/?username=${encodeURIComponent(username)}`)
5543
+ .toPromise();
5544
+ return this.debugLoadUser(password);
5545
+ });
5520
5546
  }
5521
5547
  debugLoadUser(password) {
5522
5548
  return __awaiter(this, void 0, void 0, function* () {
@@ -8105,7 +8131,7 @@ class ProfileDetailsService {
8105
8131
  oldValue: oldValue.value,
8106
8132
  });
8107
8133
  }
8108
- else if (!_.isEqual(newValue.value, oldValue.value)) {
8134
+ else if (!lodash$2(newValue.value, oldValue.value)) {
8109
8135
  changes.push({
8110
8136
  field,
8111
8137
  id: oldValue.id,
@@ -8146,7 +8172,7 @@ class ProfileDetailsService {
8146
8172
  break;
8147
8173
  default: {
8148
8174
  const value = details[change.field];
8149
- if (_.isEqual(value, change.oldValue)) {
8175
+ if (lodash$2(value, change.oldValue)) {
8150
8176
  hasChanged = true;
8151
8177
  details[change.field] = change.newValue;
8152
8178
  }
@@ -8163,7 +8189,7 @@ class ProfileDetailsService {
8163
8189
  property = property || { value: field, hasMultiple: false };
8164
8190
  property.values = property.values || [];
8165
8191
  if (property.values.length === 0 ||
8166
- property.values.every((x) => !_.isEqual(field, x.value))) {
8192
+ property.values.every((x) => !lodash$2(field, x.value))) {
8167
8193
  property.values.push({
8168
8194
  id: `${label}-${new Date().getTime()}`,
8169
8195
  label,
@@ -8647,12 +8673,6 @@ query ScenarioQuery(
8647
8673
  id
8648
8674
  }
8649
8675
  accessRole
8650
-
8651
- # The itemKey is the same as directory.keyId. It's here so we can detect
8652
- # when the directory key has been rotated.
8653
- itemKey {
8654
- id
8655
- }
8656
8676
  directory {
8657
8677
  id
8658
8678
  keyId
@@ -8669,12 +8689,6 @@ query ScenarioQuery(
8669
8689
  id
8670
8690
  }
8671
8691
  accessRole
8672
-
8673
- # The itemKey is the same as file.keyId. It's here so we can detect
8674
- # when the file key has been rotated.
8675
- itemKey {
8676
- id
8677
- }
8678
8692
  file {
8679
8693
  id
8680
8694
  keyId
@@ -8715,7 +8729,6 @@ query SharedScenarioQuery($scenarioId: LrRelayIdInput!) {
8715
8729
  edges {
8716
8730
  node {
8717
8731
  id
8718
- wrappedItemKey
8719
8732
  }
8720
8733
  }
8721
8734
  }
@@ -9032,6 +9045,7 @@ let ScenarioService = class ScenarioService extends LrService {
9032
9045
  const createClaimants = yield Promise.all(createClaimantsOptions.map((x) => this.prepareCreateClaimant(x)));
9033
9046
  return {
9034
9047
  enabled: options.enabled,
9048
+ inactiveSeconds: options.inactiveSeconds,
9035
9049
  createAssembly,
9036
9050
  createReceivers,
9037
9051
  createClaimants,
@@ -9085,6 +9099,7 @@ let ScenarioService = class ScenarioService extends LrService {
9085
9099
  return {
9086
9100
  scenarioId: options.scenarioId,
9087
9101
  enabled: options.enabled,
9102
+ inactiveSeconds: options.inactiveSeconds,
9088
9103
  updateAssembly,
9089
9104
  createReceivers,
9090
9105
  updateReceivers,
@@ -9317,33 +9332,40 @@ let ScenarioService = class ScenarioService extends LrService {
9317
9332
  };
9318
9333
  });
9319
9334
  }
9320
- prepareReceiveClaim(scenarioId, sharedClaimId) {
9321
- return __awaiter(this, void 0, void 0, function* () {
9322
- // Get all the shared items
9323
- const sharedScenario = (yield this.getSharedScenario(scenarioId, sharedClaimId)).sharedScenario;
9324
- if (sharedScenario.state !== ScenarioState.APPROVED) {
9325
- throwClaimNotApproved();
9326
- }
9327
- const approvals = mapEdges(sharedScenario.sharedClaim.asClaimReceiver.approvals);
9328
- const assemblyKey = yield this.recoverAssemblyKey(approvals);
9329
- // Decrypt all items
9330
- const receiverDirectories = yield Promise.all(sharedScenario.asReceiver.receiverItems.receiverDirectories.edges
9331
- .map((edge) => edge.node)
9332
- .map((receiverDirectory) => __awaiter(this, void 0, void 0, function* () {
9333
- const wrappedItemKey = yield this.encryptionService.decrypt(assemblyKey, receiverDirectory.wrappedItemKey);
9334
- return {
9335
- receiverDirectoryId: receiverDirectory.id,
9336
- // Looks like receiverDirectory.wrappedItemKey has no other content in side it except a wrapped key.
9337
- // So we can turn this in to a doubly wrapped key and just release the assembly key.
9338
- receiverSharedKeyWrappedItemKey: wrappedItemKey,
9339
- };
9340
- })));
9341
- return {
9342
- scenarioClaimId: sharedClaimId,
9343
- receiverDirectories,
9344
- };
9345
- });
9346
- }
9335
+ // async prepareReceiveClaim(scenarioId: string, sharedClaimId: string) {
9336
+ // // Get all the shared items
9337
+ // const sharedScenario = (
9338
+ // await this.getSharedScenario(scenarioId, sharedClaimId)
9339
+ // ).sharedScenario;
9340
+ // if (sharedScenario.state !== ScenarioState.APPROVED) {
9341
+ // throwClaimNotApproved();
9342
+ // }
9343
+ // const approvals = mapEdges(
9344
+ // sharedScenario.sharedClaim.asClaimReceiver.approvals
9345
+ // );
9346
+ // const assemblyKey = await this.recoverAssemblyKey(approvals);
9347
+ // // Decrypt all items
9348
+ // const receiverDirectories = await Promise.all(
9349
+ // sharedScenario.asReceiver.receiverItems.receiverDirectories.edges
9350
+ // .map((edge) => edge.node)
9351
+ // .map(async (receiverDirectory) => {
9352
+ // const wrappedItemKey = await this.encryptionService.decrypt(
9353
+ // assemblyKey,
9354
+ // receiverDirectory.wrappedItemKey
9355
+ // );
9356
+ // return {
9357
+ // receiverDirectoryId: receiverDirectory.id,
9358
+ // // Looks like receiverDirectory.wrappedItemKey has no other content in side it except a wrapped key.
9359
+ // // So we can turn this in to a doubly wrapped key and just release the assembly key.
9360
+ // receiverSharedKeyWrappedItemKey: wrappedItemKey, // the wrappedItemKey is already wrapped by receiverSharedKey
9361
+ // };
9362
+ // })
9363
+ // );
9364
+ // return {
9365
+ // scenarioClaimId: sharedClaimId,
9366
+ // receiverDirectories,
9367
+ // };
9368
+ // }
9347
9369
  recoverAssemblyKey(approvals) {
9348
9370
  return __awaiter(this, void 0, void 0, function* () {
9349
9371
  const partials = yield Promise.all(approvals.map((approval) => this.keyGraph.decryptFromString(approval.pxk.id, approval.receiverCipherPartialAssemblyKey)));