@lifeready/core 5.0.10 → 5.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.
@@ -1117,7 +1117,7 @@ class KeyService {
1117
1117
  this.resetKeys();
1118
1118
  this.persistService.clear();
1119
1119
  }
1120
- populateKeys(keys) {
1120
+ setKeys(keys) {
1121
1121
  this.keys = keys;
1122
1122
  }
1123
1123
  get currentPassKey() {
@@ -1230,7 +1230,7 @@ class KeyGraphService {
1230
1230
  }
1231
1231
  populateKeys(userKey) {
1232
1232
  return __awaiter(this, void 0, void 0, function* () {
1233
- this.keyService.populateKeys({
1233
+ this.keyService.setKeys({
1234
1234
  passKey: userKey.passKey,
1235
1235
  masterKey: yield this.keyService.loadMasterKey(userKey.masterKey.id),
1236
1236
  rootKey: yield this.unwrapKey(userKey.masterKey.id, userKey.rootKey.id),
@@ -2591,6 +2591,11 @@ class LrMergedMutation extends LrMutationBase {
2591
2591
  // Just wait for everything to resolve because we have to
2592
2592
  // merge the doc synchronously.
2593
2593
  this.lrMutations.forEach((lrMutation, idx) => {
2594
+ // Sometimes typing won't catch everything. So need to dynamically check the
2595
+ // type to be sure.
2596
+ if (!(lrMutation instanceof LrMutationBase)) {
2597
+ throw new KcBadLogicException('An mutation in the array is not of type LrMutationBase.');
2598
+ }
2594
2599
  const { mutation, variables } = lrMutation.lrMutationData;
2595
2600
  const childMutationNode = getMutation(mutation);
2596
2601
  // Prefixing all mutation fields so they don't conflict.
@@ -5869,7 +5874,7 @@ class LifeReadyAuthService {
5869
5874
  const passKey = (yield this.keyFactory.derivePassKey(Object.assign({ password }, resetUser.passKey.passKeyParams))).jwk;
5870
5875
  yield this.idleService.persistMasterKey(yield this.keyGraphService.unwrapWithPassKey(resetUser.passKey.id, passKey, resetUser.masterKey.id));
5871
5876
  }
5872
- this.keyService.populateKeys({
5877
+ this.keyService.setKeys({
5873
5878
  passKey: {
5874
5879
  id: resetUser.passKey.id,
5875
5880
  },
@@ -6301,7 +6306,7 @@ let Auth2Service = Auth2Service_1 = class Auth2Service extends LrService {
6301
6306
  fetchResetUser() {
6302
6307
  return __awaiter(this, void 0, void 0, function* () {
6303
6308
  return (yield this.api.query({
6304
- query: CurrentUserQuery$1,
6309
+ query: ResetUserQuery,
6305
6310
  processorOptions: {
6306
6311
  hasKeys: false,
6307
6312
  },
@@ -6484,7 +6489,6 @@ let Auth2Service = Auth2Service_1 = class Auth2Service extends LrService {
6484
6489
  const passKey = (yield this.keyFactoryService.derivePassKey(Object.assign({ password }, userKeys.passKey.passKeyParams))).jwk;
6485
6490
  yield this.idleService.persistMasterKey(yield this.keyGraphService.unwrapWithPassKey(userKeys.passKey.id, passKey, userKeys.masterKey.id));
6486
6491
  }
6487
- yield this.keyGraphService.populateKeys(userKeys);
6488
6492
  });
6489
6493
  }
6490
6494
  loadUser(cognitoUser, password) {
@@ -6507,6 +6511,8 @@ let Auth2Service = Auth2Service_1 = class Auth2Service extends LrService {
6507
6511
  password,
6508
6512
  sessionEncryptionKey: currentUser.sessionEncryptionKey,
6509
6513
  });
6514
+ // Regular user populates all keys
6515
+ yield this.keyGraphService.populateKeys(currentUser.currentUserKey);
6510
6516
  const { username } = currentUser;
6511
6517
  const userAttributes = yield this.cognito.userAttributes(cognitoUser);
6512
6518
  return {
@@ -6520,18 +6526,22 @@ let Auth2Service = Auth2Service_1 = class Auth2Service extends LrService {
6520
6526
  loadResetUser(cognitoUser, password) {
6521
6527
  return __awaiter(this, void 0, void 0, function* () {
6522
6528
  const resetUser = yield this.fetchResetUser();
6523
- this.loadUserKeys({
6524
- userKeys: {
6525
- passKey: {
6526
- id: resetUser.passKey.id,
6527
- },
6528
- masterKey: {
6529
- id: resetUser.masterKey.id,
6530
- },
6529
+ const userKeys = {
6530
+ passKey: {
6531
+ id: resetUser.passKey.id,
6532
+ passKeyParams: resetUser.passKey.passKeyParams,
6531
6533
  },
6534
+ masterKey: {
6535
+ id: resetUser.masterKey.id,
6536
+ },
6537
+ };
6538
+ yield this.loadUserKeys({
6539
+ userKeys,
6532
6540
  password,
6533
6541
  sessionEncryptionKey: resetUser.sessionEncryptionKey,
6534
6542
  });
6543
+ // Reset user only sets a subset of keys
6544
+ yield this.keyService.setKeys(userKeys);
6535
6545
  const { username } = resetUser;
6536
6546
  const userAttributes = yield this.cognito.userAttributes(cognitoUser);
6537
6547
  return {
@@ -6679,6 +6689,13 @@ let Auth2Service = Auth2Service_1 = class Auth2Service extends LrService {
6679
6689
  debugClearUser() {
6680
6690
  this.user = null;
6681
6691
  }
6692
+ getCurrentUserAttibutes() {
6693
+ return __awaiter(this, void 0, void 0, function* () {
6694
+ const cognitoUser = yield this.cognito.currentAuthenticatedUser();
6695
+ const userAttributes = yield this.cognito.userAttributes(cognitoUser);
6696
+ return userAttributes;
6697
+ });
6698
+ }
6682
6699
  };
6683
6700
  Auth2Service.CHALLENGE_TIMEOUT = 1000 * 60 * 5;
6684
6701
  Auth2Service.ɵprov = ɵɵdefineInjectable({ factory: function Auth2Service_Factory() { return new Auth2Service(ɵɵinject(NgZone), ɵɵinject(INJECTOR), ɵɵinject(HttpClient), ɵɵinject(AuthClass), ɵɵinject(LrGraphQLService), ɵɵinject(KeyService), ɵɵinject(KeyGraphService), ɵɵinject(KeyFactoryService), ɵɵinject(PasswordService), ɵɵinject(IdleService), ɵɵinject(PersistService), ɵɵinject(EncryptionService), ɵɵinject(TpPasswordResetAssemblyController), ɵɵinject(KC_CONFIG)); }, token: Auth2Service, providedIn: "root" });