@lifeready/core 5.0.8 → 5.0.10

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.
Files changed (60) hide show
  1. package/bundles/lifeready-core.umd.js +1521 -740
  2. package/bundles/lifeready-core.umd.js.map +1 -1
  3. package/bundles/lifeready-core.umd.min.js +1 -1
  4. package/bundles/lifeready-core.umd.min.js.map +1 -1
  5. package/esm2015/lib/_common/key.js +28 -0
  6. package/esm2015/lib/_common/types.js +1 -1
  7. package/esm2015/lib/api/types/lr-graphql.types.js +1 -1
  8. package/esm2015/lib/auth/auth.types.js +1 -3
  9. package/esm2015/lib/auth2/auth2.gql.private.js +78 -0
  10. package/esm2015/lib/auth2/auth2.service.js +591 -0
  11. package/esm2015/lib/auth2/auth2.types.js +21 -0
  12. package/esm2015/lib/contact-card/contact-card.service.js +3 -3
  13. package/esm2015/lib/contact-card/contact-card2.service.js +3 -3
  14. package/esm2015/lib/item2/item2.service.js +9 -9
  15. package/esm2015/lib/key/key-factory.service.js +1 -1
  16. package/esm2015/lib/key/key-graph.service.js +2 -2
  17. package/esm2015/lib/key/key-meta.service.js +2 -2
  18. package/esm2015/lib/key/key.service.js +6 -6
  19. package/esm2015/lib/key-exchange/key-exchange.service.js +24 -29
  20. package/esm2015/lib/key-exchange/key-exchange2.gql.js +2 -1
  21. package/esm2015/lib/key-exchange/key-exchange2.service.js +16 -17
  22. package/esm2015/lib/lbop/lbop.service.js +13 -14
  23. package/esm2015/lib/profile/profile.service.js +2 -2
  24. package/esm2015/lib/profile/profile.types.js +1 -1
  25. package/esm2015/lib/register/register.service.js +1 -1
  26. package/esm2015/lib/register/register.types.js +3 -0
  27. package/esm2015/lib/server-config/server-config.gql.js +1 -1
  28. package/esm2015/lib/shared-contact-card/shared-contact-card.service.js +3 -3
  29. package/esm2015/lib/shared-contact-card/shared-contact-card2.service.js +2 -2
  30. package/esm2015/lib/tp-assembly/tp-assembly.js +3 -3
  31. package/esm2015/lib/trusted-party/trusted-party.gql.js +3 -3
  32. package/esm2015/lib/trusted-party/trusted-party2.gql.js +5 -5
  33. package/esm2015/lib/trusted-party/trusted-party2.service.js +4 -4
  34. package/esm2015/public-api.js +4 -1
  35. package/fesm2015/lifeready-core.js +883 -205
  36. package/fesm2015/lifeready-core.js.map +1 -1
  37. package/lib/_common/key.d.ts +14 -0
  38. package/lib/_common/types.d.ts +6 -0
  39. package/lib/api/types/lr-graphql.types.d.ts +25 -0
  40. package/lib/auth/auth.types.d.ts +0 -6
  41. package/lib/auth2/auth2.gql.private.d.ts +12 -0
  42. package/lib/auth2/auth2.service.d.ts +70 -0
  43. package/lib/auth2/auth2.types.d.ts +50 -0
  44. package/lib/item2/item2.service.d.ts +3 -3
  45. package/lib/key/key-factory.service.d.ts +1 -0
  46. package/lib/key/key-graph.service.d.ts +2 -3
  47. package/lib/key/key.service.d.ts +5 -5
  48. package/lib/key-exchange/key-exchange.service.d.ts +3 -5
  49. package/lib/key-exchange/key-exchange2.gql.d.ts +3 -1
  50. package/lib/lbop/lbop.service.d.ts +3 -3
  51. package/lib/profile/profile.types.d.ts +2 -2
  52. package/lib/register/register.service.d.ts +1 -1
  53. package/lib/register/register.types.d.ts +6 -0
  54. package/lib/server-config/server-config.gql.d.ts +1 -1
  55. package/lib/server-config/server-config.service.d.ts +1 -1
  56. package/lib/shared-contact-card/shared-contact-card.service.d.ts +2 -2
  57. package/lib/trusted-party/trusted-party2.gql.d.ts +4 -4
  58. package/lifeready-core.metadata.json +1 -1
  59. package/package.json +1 -1
  60. package/public-api.d.ts +3 -0
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('apollo-angular'), require('@dagrejs/graphlib'), require('lodash'), require('node-jose'), require('@aws-amplify/auth/lib-esm/Auth'), require('graphql-tag'), require('moment'), require('@apollo/client/core'), require('@apollo/client/link/context'), require('@apollo/client/link/retry'), require('ngx-cookie-service'), require('graphql/language/printer'), require('@aws-amplify/auth'), require('@angular/common/http'), require('@aws-amplify/core'), require('rxjs'), require('@ng-idle/core'), require('@ng-idle/keepalive'), require('slip39')) :
3
3
  typeof define === 'function' && define.amd ? define('@lifeready/core', ['exports', '@angular/core', 'apollo-angular', '@dagrejs/graphlib', 'lodash', 'node-jose', '@aws-amplify/auth/lib-esm/Auth', 'graphql-tag', 'moment', '@apollo/client/core', '@apollo/client/link/context', '@apollo/client/link/retry', 'ngx-cookie-service', 'graphql/language/printer', '@aws-amplify/auth', '@angular/common/http', '@aws-amplify/core', 'rxjs', '@ng-idle/core', '@ng-idle/keepalive', 'slip39'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.lifeready = global.lifeready || {}, global.lifeready.core = {}), global.ng.core, global['apollo-angular'], global['@dagrejs/graphlib'], global.lodash, global['node-jose'], global['@aws-amplify/auth/lib-esm/Auth'], global['graphql-tag'], global.moment, global['@apollo/client/core'], global['@apollo/client/link/context'], global['@apollo/client/link/retry'], global['ngx-cookie-service'], global['graphql/language/printer'], global['@aws-amplify/auth'], global.ng.common.http, global['@aws-amplify/core'], global.rxjs, global['@ng-idle/core'], global['@ng-idle/keepalive'], global.slip39));
5
- }(this, (function (exports, i0, i1, graphlib, _, nodeJose, i4, gql, moment_, core, context, retry, i2, gqlPrinter, Auth, i2$1, core$1, rxjs, i3, i4$1, slip39) { 'use strict';
5
+ }(this, (function (exports, i0, i1, graphlib, _, nodeJose, i2, gql, moment_, core, context, retry, i2$1, gqlPrinter, Auth, i2$2, core$1, rxjs, i3, i4, slip39) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -788,14 +788,14 @@
788
788
  };
789
789
  return TimeService;
790
790
  }());
791
- TimeService.ɵprov = i0.ɵɵdefineInjectable({ factory: function TimeService_Factory() { return new TimeService(i0.ɵɵinject(i4.AuthClass), i0.ɵɵinject(i1.Apollo)); }, token: TimeService, providedIn: "root" });
791
+ TimeService.ɵprov = i0.ɵɵdefineInjectable({ factory: function TimeService_Factory() { return new TimeService(i0.ɵɵinject(i2.AuthClass), i0.ɵɵinject(i1.Apollo)); }, token: TimeService, providedIn: "root" });
792
792
  TimeService.decorators = [
793
793
  { type: i0.Injectable, args: [{
794
794
  providedIn: 'root',
795
795
  },] }
796
796
  ];
797
797
  TimeService.ctorParameters = function () { return [
798
- { type: i4.AuthClass },
798
+ { type: i2.AuthClass },
799
799
  { type: i1.Apollo }
800
800
  ]; };
801
801
  var templateObject_1;
@@ -1670,7 +1670,7 @@
1670
1670
  };
1671
1671
  return PersistService;
1672
1672
  }());
1673
- PersistService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PersistService_Factory() { return new PersistService(i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(i2.CookieService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(i0.INJECTOR)); }, token: PersistService, providedIn: "root" });
1673
+ PersistService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PersistService_Factory() { return new PersistService(i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(i2$1.CookieService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(i0.INJECTOR)); }, token: PersistService, providedIn: "root" });
1674
1674
  PersistService.decorators = [
1675
1675
  { type: i0.Injectable, args: [{
1676
1676
  providedIn: 'root',
@@ -1678,7 +1678,7 @@
1678
1678
  ];
1679
1679
  PersistService.ctorParameters = function () { return [
1680
1680
  { type: KeyFactoryService },
1681
- { type: i2.CookieService },
1681
+ { type: i2$1.CookieService },
1682
1682
  { type: EncryptionService },
1683
1683
  { type: i0.Injector }
1684
1684
  ]; };
@@ -1718,21 +1718,41 @@
1718
1718
  KeyService.prototype.populateKeys = function (keys) {
1719
1719
  this.keys = keys;
1720
1720
  };
1721
- KeyService.prototype.getCurrentPassKey = function () {
1722
- return this.keys.passKey;
1723
- };
1724
- KeyService.prototype.getCurrentMasterKey = function () {
1725
- return this.keys.masterKey;
1726
- };
1727
- KeyService.prototype.getCurrentRootKey = function () {
1728
- return this.keys.rootKey;
1729
- };
1730
- KeyService.prototype.getCurrentPxk = function () {
1731
- return this.keys.pxk;
1732
- };
1733
- KeyService.prototype.getCurrentSigPxk = function () {
1734
- return this.keys.sigPxk;
1735
- };
1721
+ Object.defineProperty(KeyService.prototype, "currentPassKey", {
1722
+ get: function () {
1723
+ return this.keys.passKey;
1724
+ },
1725
+ enumerable: false,
1726
+ configurable: true
1727
+ });
1728
+ Object.defineProperty(KeyService.prototype, "currentMasterKey", {
1729
+ get: function () {
1730
+ return this.keys.masterKey;
1731
+ },
1732
+ enumerable: false,
1733
+ configurable: true
1734
+ });
1735
+ Object.defineProperty(KeyService.prototype, "currentRootKey", {
1736
+ get: function () {
1737
+ return this.keys.rootKey;
1738
+ },
1739
+ enumerable: false,
1740
+ configurable: true
1741
+ });
1742
+ Object.defineProperty(KeyService.prototype, "currentPxk", {
1743
+ get: function () {
1744
+ return this.keys.pxk;
1745
+ },
1746
+ enumerable: false,
1747
+ configurable: true
1748
+ });
1749
+ Object.defineProperty(KeyService.prototype, "currentSigPxk", {
1750
+ get: function () {
1751
+ return this.keys.sigPxk;
1752
+ },
1753
+ enumerable: false,
1754
+ configurable: true
1755
+ });
1736
1756
  KeyService.prototype.expiresAfter = function (seconds) {
1737
1757
  return new Date(Date.now() + 1000 * seconds);
1738
1758
  };
@@ -2049,7 +2069,7 @@
2049
2069
  return [2 /*return*/, key];
2050
2070
  }
2051
2071
  else {
2052
- return [2 /*return*/, this.unwrapKey(this.keyService.getCurrentMasterKey().id, keyId)];
2072
+ return [2 /*return*/, this.unwrapKey(this.keyService.currentMasterKey.id, keyId)];
2053
2073
  }
2054
2074
  return [2 /*return*/];
2055
2075
  }
@@ -3889,11 +3909,6 @@
3889
3909
  }
3890
3910
  return LoginResult;
3891
3911
  }());
3892
- var RegisterResult = /** @class */ (function () {
3893
- function RegisterResult() {
3894
- }
3895
- return RegisterResult;
3896
- }());
3897
3912
  (function (RecoveryStatus) {
3898
3913
  RecoveryStatus["NONE"] = "none";
3899
3914
  RecoveryStatus["NEW_PASSWORD"] = "new-password";
@@ -4094,7 +4109,7 @@
4094
4109
  };
4095
4110
  return IdleService;
4096
4111
  }());
4097
- IdleService.ɵprov = i0.ɵɵdefineInjectable({ factory: function IdleService_Factory() { return new IdleService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(i3.Idle), i0.ɵɵinject(i4$1.Keepalive), i0.ɵɵinject(KeyService), i0.ɵɵinject(i4.AuthClass)); }, token: IdleService, providedIn: "root" });
4112
+ IdleService.ɵprov = i0.ɵɵdefineInjectable({ factory: function IdleService_Factory() { return new IdleService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(i3.Idle), i0.ɵɵinject(i4.Keepalive), i0.ɵɵinject(KeyService), i0.ɵɵinject(i2.AuthClass)); }, token: IdleService, providedIn: "root" });
4098
4113
  IdleService.decorators = [
4099
4114
  { type: i0.Injectable, args: [{
4100
4115
  providedIn: 'root',
@@ -4102,11 +4117,11 @@
4102
4117
  ];
4103
4118
  IdleService.ctorParameters = function () { return [
4104
4119
  { type: undefined, decorators: [{ type: i0.Inject, args: [KC_CONFIG,] }] },
4105
- { type: i2$1.HttpClient },
4120
+ { type: i2$2.HttpClient },
4106
4121
  { type: i3.Idle },
4107
- { type: i4$1.Keepalive },
4122
+ { type: i4.Keepalive },
4108
4123
  { type: KeyService },
4109
- { type: i4.AuthClass }
4124
+ { type: i2.AuthClass }
4110
4125
  ]; };
4111
4126
 
4112
4127
  var ContactCardFields = "\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n";
@@ -4378,7 +4393,7 @@
4378
4393
  wrappedKeys = _g.sent();
4379
4394
  return [3 /*break*/, 5];
4380
4395
  case 3:
4381
- rootKey = this.keyService.getCurrentRootKey();
4396
+ rootKey = this.keyService.currentRootKey;
4382
4397
  _b = (_a = JSON).stringify;
4383
4398
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, key.toJSON(true))];
4384
4399
  case 4:
@@ -4874,16 +4889,15 @@
4874
4889
  var sigPxk, publicDataSig, _a, _b, publicSearchableSig, _c, _d, plainDataJson, plainDataSig, _e, _f;
4875
4890
  return __generator(this, function (_g) {
4876
4891
  switch (_g.label) {
4877
- case 0: return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
4878
- case 1:
4879
- sigPxk = _g.sent();
4892
+ case 0:
4893
+ sigPxk = this.keyService.currentSigPxk;
4880
4894
  _b = (_a = JSON).stringify;
4881
4895
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, '')];
4882
- case 2:
4896
+ case 1:
4883
4897
  publicDataSig = _b.apply(_a, [_g.sent()]);
4884
4898
  _d = (_c = JSON).stringify;
4885
4899
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, '')];
4886
- case 3:
4900
+ case 2:
4887
4901
  publicSearchableSig = _d.apply(_c, [_g.sent()]);
4888
4902
  plainDataJson = {
4889
4903
  // contactCard.name.value may have additional attributes such as the id of the contact card.
@@ -4892,7 +4906,7 @@
4892
4906
  };
4893
4907
  _f = (_e = JSON).stringify;
4894
4908
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, plainDataJson)];
4895
- case 4:
4909
+ case 3:
4896
4910
  plainDataSig = _f.apply(_e, [_g.sent()]);
4897
4911
  return [2 /*return*/, {
4898
4912
  sigPxkId: sigPxk.id,
@@ -5026,7 +5040,7 @@
5026
5040
  };
5027
5041
  return ProfileService;
5028
5042
  }());
5029
- ProfileService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ProfileService_Factory() { return new ProfileService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyMetaService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(EncryptionService)); }, token: ProfileService, providedIn: "root" });
5043
+ ProfileService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ProfileService_Factory() { return new ProfileService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyMetaService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(EncryptionService)); }, token: ProfileService, providedIn: "root" });
5030
5044
  ProfileService.decorators = [
5031
5045
  { type: i0.Injectable, args: [{
5032
5046
  providedIn: 'root',
@@ -5034,7 +5048,7 @@
5034
5048
  ];
5035
5049
  ProfileService.ctorParameters = function () { return [
5036
5050
  { type: undefined, decorators: [{ type: i0.Inject, args: [KC_CONFIG,] }] },
5037
- { type: i2$1.HttpClient },
5051
+ { type: i2$2.HttpClient },
5038
5052
  { type: LrApolloService },
5039
5053
  { type: KeyService },
5040
5054
  { type: KeyMetaService },
@@ -5426,7 +5440,7 @@
5426
5440
  };
5427
5441
  return PasswordService;
5428
5442
  }());
5429
- PasswordService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PasswordService_Factory() { return new PasswordService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(i4.AuthClass), i0.ɵɵinject(ProfileService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(WebCryptoService)); }, token: PasswordService, providedIn: "root" });
5443
+ PasswordService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PasswordService_Factory() { return new PasswordService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(i2.AuthClass), i0.ɵɵinject(ProfileService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(WebCryptoService)); }, token: PasswordService, providedIn: "root" });
5430
5444
  PasswordService.decorators = [
5431
5445
  { type: i0.Injectable, args: [{
5432
5446
  providedIn: 'root',
@@ -5434,9 +5448,9 @@
5434
5448
  ];
5435
5449
  PasswordService.ctorParameters = function () { return [
5436
5450
  { type: undefined, decorators: [{ type: i0.Inject, args: [KC_CONFIG,] }] },
5437
- { type: i2$1.HttpClient },
5451
+ { type: i2$2.HttpClient },
5438
5452
  { type: LrApolloService },
5439
- { type: i4.AuthClass },
5453
+ { type: i2.AuthClass },
5440
5454
  { type: ProfileService },
5441
5455
  { type: KeyFactoryService },
5442
5456
  { type: EncryptionService },
@@ -5899,23 +5913,22 @@
5899
5913
  var rootKey, subjectKey, rootKeyWrappedSubjectKey, _a, assemblyKey, rawAssemblyKey, assemblyKeyParams, assemblyInput, slipAssembly, tpIds, tps, _c, createSubAssemblies, subjectCipherData;
5900
5914
  return __generator(this, function (_d) {
5901
5915
  switch (_d.label) {
5902
- case 0: return [4 /*yield*/, this.keyService.getCurrentRootKey()];
5903
- case 1:
5904
- rootKey = _d.sent();
5916
+ case 0:
5917
+ rootKey = this.keyService.currentRootKey;
5905
5918
  return [4 /*yield*/, this.keyFactory.createKey()];
5906
- case 2:
5919
+ case 1:
5907
5920
  subjectKey = _d.sent();
5908
5921
  return [4 /*yield*/, this.keyGraph.wrapKey(rootKey, subjectKey)];
5909
- case 3:
5922
+ case 2:
5910
5923
  rootKeyWrappedSubjectKey = _d.sent();
5911
5924
  return [4 /*yield*/, this.prepareAssembly({
5912
5925
  rootKey: rootKey.jwk,
5913
5926
  subjectKey: subjectKey,
5914
5927
  })];
5915
- case 4:
5928
+ case 3:
5916
5929
  _a = _d.sent(), assemblyKey = _a.assemblyKey, rawAssemblyKey = _a.rawAssemblyKey, assemblyKeyParams = _a.assemblyKeyParams, assemblyInput = __rest(_a, ["assemblyKey", "rawAssemblyKey", "assemblyKeyParams"]);
5917
5930
  return [4 /*yield*/, this.prepareSlip39(input.createSubAssemblies, input.quorum, rawAssemblyKey)];
5918
- case 5:
5931
+ case 4:
5919
5932
  slipAssembly = _d.sent();
5920
5933
  tpIds = this.getInputApprovers(input.createSubAssemblies);
5921
5934
  _c = mapEdges;
@@ -5925,7 +5938,7 @@
5925
5938
  ids: tpIds,
5926
5939
  },
5927
5940
  })];
5928
- case 6:
5941
+ case 5:
5929
5942
  tps = _c.apply(void 0, [(_d.sent()).tps]);
5930
5943
  // Fill in wrappingKeyId if not present
5931
5944
  this.fillWrappingKeyId(input.createSubAssemblies, tps);
@@ -5935,10 +5948,10 @@
5935
5948
  slipSubAssemblies: slipAssembly.subAssemblies,
5936
5949
  subjectKey: subjectKey,
5937
5950
  })];
5938
- case 7:
5951
+ case 6:
5939
5952
  createSubAssemblies = _d.sent();
5940
5953
  return [4 /*yield*/, this.encryptionService.encryptToString(subjectKey, input.subjectCipherDataClearJson || '')];
5941
- case 8:
5954
+ case 7:
5942
5955
  subjectCipherData = _d.sent();
5943
5956
  return [2 /*return*/, {
5944
5957
  assemblyKey: assemblyKey,
@@ -5975,17 +5988,15 @@
5975
5988
  deleteSubAssembliesInput.length === 0) {
5976
5989
  throw new KcBadArgumentException('Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]');
5977
5990
  }
5978
- return [4 /*yield*/, this.keyService.getCurrentRootKey()];
5979
- case 1:
5980
- rootKey = _d.sent();
5991
+ rootKey = this.keyService.currentRootKey;
5981
5992
  return [4 /*yield*/, this.keyGraph.getKey(assembly.subjectKey.id)];
5982
- case 2:
5993
+ case 1:
5983
5994
  subjectKey = _d.sent();
5984
5995
  return [4 /*yield*/, this.prepareAssembly({
5985
5996
  rootKey: rootKey.jwk,
5986
5997
  subjectKey: subjectKey.jwk,
5987
5998
  })];
5988
- case 3:
5999
+ case 2:
5989
6000
  _b = _d.sent(), assemblyKey = _b.assemblyKey, rawAssemblyKey = _b.rawAssemblyKey, assemblyKeyParams = _b.assemblyKeyParams, assemblyInput = __rest(_b, ["assemblyKey", "rawAssemblyKey", "assemblyKeyParams"]);
5990
6001
  tpIds = this.getAssemblyApprovers(assembly).concat(this.getInputApprovers(createSubAssembliesInput), this.getInputApprovers(updateSubAssembliesInput));
5991
6002
  _c = mapEdges;
@@ -5995,7 +6006,7 @@
5995
6006
  ids: tpIds,
5996
6007
  },
5997
6008
  })];
5998
- case 4:
6009
+ case 3:
5999
6010
  tps = _c.apply(void 0, [(_d.sent()).tps]);
6000
6011
  // Auto fill the updateSubAssemblies with existing sub assemblies if they are not
6001
6012
  // explicitly deleted.
@@ -6026,19 +6037,19 @@
6026
6037
  // Fill in wrappingKeyId if not present
6027
6038
  this.fillWrappingKeyId(createSubAssembliesInput, tps);
6028
6039
  this.fillWrappingKeyId(updateSubAssembliesInput, tps);
6029
- _d.label = 5;
6030
- case 5:
6031
- _d.trys.push([5, 7, , 8]);
6040
+ _d.label = 4;
6041
+ case 4:
6042
+ _d.trys.push([4, 6, , 7]);
6032
6043
  return [4 /*yield*/, this.prepareSlip39((createSubAssembliesInput || []).concat(updateSubAssembliesInput || []), input.quorum, rawAssemblyKey)];
6033
- case 6:
6044
+ case 5:
6034
6045
  slipAssembly = _d.sent();
6035
- return [3 /*break*/, 8];
6036
- case 7:
6046
+ return [3 /*break*/, 7];
6047
+ case 6:
6037
6048
  error_1 = _d.sent();
6038
6049
  // TODO this sometimes happens. Maybe missing await.
6039
6050
  console.log('Error while creating slip assembly', error_1);
6040
- return [3 /*break*/, 8];
6041
- case 8:
6051
+ return [3 /*break*/, 7];
6052
+ case 7:
6042
6053
  common = {
6043
6054
  assemblyKeyParams: assemblyKeyParams,
6044
6055
  subjectKey: subjectKey.jwk,
@@ -6046,15 +6057,15 @@
6046
6057
  return [4 /*yield*/, this.prepareCreateSubAssemblies(Object.assign(Object.assign({}, common), { input: createSubAssembliesInput,
6047
6058
  // Need to match the slip sub assemblies to the input
6048
6059
  slipSubAssemblies: slipAssembly.subAssemblies.slice(0, createSubAssembliesInput.length) }))];
6049
- case 9:
6060
+ case 8:
6050
6061
  createSubAssemblies = _d.sent();
6051
6062
  return [4 /*yield*/, this.prepareUpdateSubAssemblies(Object.assign(Object.assign({}, common), { input: updateSubAssembliesInput,
6052
6063
  // Add an offset to the sub assemblies to skip the one that are created.
6053
6064
  slipSubAssemblies: slipAssembly.subAssemblies.slice(createSubAssembliesInput.length), subAssemblies: assembly.subAssemblies }))];
6054
- case 10:
6065
+ case 9:
6055
6066
  updateSubAssemblies = _d.sent();
6056
6067
  return [4 /*yield*/, this.encryptionService.encryptToString(subjectKey.jwk, (_a = input.subjectCipherDataClearJson) !== null && _a !== void 0 ? _a : assembly.subjectCipherDataClearJson)];
6057
- case 11:
6068
+ case 10:
6058
6069
  subjectCipherData = _d.sent();
6059
6070
  return [2 /*return*/, {
6060
6071
  assemblyKey: assemblyKey,
@@ -6964,7 +6975,7 @@
6964
6975
  };
6965
6976
  return LifeReadyAuthService;
6966
6977
  }());
6967
- LifeReadyAuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LifeReadyAuthService_Factory() { return new LifeReadyAuthService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i4.AuthClass), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyService), i0.ɵɵinject(ProfileService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(PasswordService), i0.ɵɵinject(IdleService), i0.ɵɵinject(exports.ɵf), i0.ɵɵinject(exports.ɵg), i0.ɵɵinject(PersistService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(exports.ɵi), i0.ɵɵinject(i2$1.HttpClient)); }, token: LifeReadyAuthService, providedIn: "root" });
6978
+ LifeReadyAuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LifeReadyAuthService_Factory() { return new LifeReadyAuthService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2.AuthClass), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyService), i0.ɵɵinject(ProfileService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(PasswordService), i0.ɵɵinject(IdleService), i0.ɵɵinject(exports.ɵf), i0.ɵɵinject(exports.ɵg), i0.ɵɵinject(PersistService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(exports.ɵi), i0.ɵɵinject(i2$2.HttpClient)); }, token: LifeReadyAuthService, providedIn: "root" });
6968
6979
  LifeReadyAuthService.decorators = [
6969
6980
  { type: i0.Injectable, args: [{
6970
6981
  providedIn: 'root',
@@ -6972,7 +6983,7 @@
6972
6983
  ];
6973
6984
  LifeReadyAuthService.ctorParameters = function () { return [
6974
6985
  { type: undefined, decorators: [{ type: i0.Inject, args: [KC_CONFIG,] }] },
6975
- { type: i4.AuthClass },
6986
+ { type: i2.AuthClass },
6976
6987
  { type: KeyFactoryService },
6977
6988
  { type: KeyService },
6978
6989
  { type: ProfileService },
@@ -6984,140 +6995,984 @@
6984
6995
  { type: PersistService },
6985
6996
  { type: EncryptionService },
6986
6997
  { type: exports.ɵi },
6987
- { type: i2$1.HttpClient }
6998
+ { type: i2$2.HttpClient }
6988
6999
  ]; };
6989
7000
 
6990
- (function (FileType) {
6991
- FileType["RecordContent"] = "record-content";
6992
- FileType["RecordAttachment"] = "record-attachment";
6993
- })(exports.FileType || (exports.FileType = {}));
6994
- var RecordContentFilter = JSON.stringify({
6995
- filter: [
6996
- {
6997
- contains: {
6998
- fileType: exports.FileType.RecordContent,
6999
- },
7000
- },
7001
- ],
7002
- });
7003
- var RecordAttachmentFilter = JSON.stringify({
7004
- filter: [
7005
- {
7006
- contains: {
7007
- fileType: exports.FileType.RecordAttachment,
7008
- },
7001
+ var KeyContainer = /** @class */ (function () {
7002
+ function KeyContainer(_key, timeout) {
7003
+ var _this = this;
7004
+ this._key = _key;
7005
+ this.timer = setTimeout(function () {
7006
+ _this._key = null;
7007
+ }, timeout);
7008
+ }
7009
+ Object.defineProperty(KeyContainer.prototype, "key", {
7010
+ get: function () {
7011
+ return this._key;
7009
7012
  },
7010
- ],
7013
+ enumerable: false,
7014
+ configurable: true
7015
+ });
7016
+ /**
7017
+ * Clears the reference to the key, clears the timer, return the key.
7018
+ * It's important to call this function when the key is no longer needed because
7019
+ * the anonymous function in setTimeout() holds a reference to "this", and hence
7020
+ * keeps the "this._key" reference until the timer expired. So if we have used
7021
+ * the key before it expired, we should clear the "this._key" reference immediately.
7022
+ */
7023
+ KeyContainer.prototype.pop = function () {
7024
+ var ret = this._key;
7025
+ this._key = null;
7026
+ if (this.timer) {
7027
+ clearTimeout(this.timer);
7028
+ this.timer = null;
7029
+ }
7030
+ return ret;
7031
+ };
7032
+ return KeyContainer;
7033
+ }());
7034
+
7035
+ var CurrentUserQuery$1 = gqlTyped(templateObject_1$d || (templateObject_1$d = __makeTemplateObject(["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n", "\n"], ["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n", "\n"])), KeyGraphFragment);
7036
+ var ResetUserQuery = gqlTyped(templateObject_2$a || (templateObject_2$a = __makeTemplateObject(["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"], ["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"])));
7037
+ var templateObject_1$d, templateObject_2$a;
7038
+
7039
+ var RecoveryStatus;
7040
+ (function (RecoveryStatus) {
7041
+ RecoveryStatus["NONE"] = "NONE";
7042
+ RecoveryStatus["NEW_PASSWORD"] = "NEW_PASSWORD";
7043
+ RecoveryStatus["OLD_PASSWORD"] = "OLD_PASSWORD";
7044
+ })(RecoveryStatus || (RecoveryStatus = {}));
7045
+ // TODO restrict this type
7046
+ // export type AuthResetUser = TpPasswordResetUserNode;
7047
+ var PasswordChangeStatus;
7048
+ (function (PasswordChangeStatus) {
7049
+ PasswordChangeStatus["IN_PROGRESS"] = "IN_PROGRESS";
7050
+ PasswordChangeStatus["RECOVERY"] = "RECOVERY";
7051
+ })(PasswordChangeStatus || (PasswordChangeStatus = {}));
7052
+ var CognitoChallengeName;
7053
+ (function (CognitoChallengeName) {
7054
+ CognitoChallengeName["NEW_PASSWORD_REQUIRED"] = "NEW_PASSWORD_REQUIRED";
7055
+ CognitoChallengeName["SMS_MFA"] = "SMS_MFA";
7056
+ CognitoChallengeName["SOFTWARE_TOKEN_MFA"] = "SOFTWARE_TOKEN_MFA";
7057
+ CognitoChallengeName["MFA_SETUP"] = "MFA_SETUP";
7058
+ })(CognitoChallengeName || (CognitoChallengeName = {}));
7059
+
7060
+ var auth2_types = /*#__PURE__*/Object.freeze({
7061
+ __proto__: null,
7062
+ get RecoveryStatus () { return RecoveryStatus; },
7063
+ get PasswordChangeStatus () { return PasswordChangeStatus; },
7064
+ get CognitoChallengeName () { return CognitoChallengeName; }
7011
7065
  });
7012
- var GetRecordQuery = function (depth) {
7013
- if (depth === void 0) { depth = DEFAULT_BREADCRUMB_DEPTH; }
7014
- return gql__default['default'](templateObject_1$d || (templateObject_1$d = __makeTemplateObject(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n confidentiality {\n isConfidential\n method\n }\n ", "\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", "\n"], ["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n confidentiality {\n isConfidential\n method\n }\n ", "\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", "\n"])), parentCategoriesField(depth), KeyGraphFragment);
7015
- };
7016
- var CreateRecordContainerMutation = gql__default['default'](templateObject_2$a || (templateObject_2$a = __makeTemplateObject(["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"], ["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"])));
7017
- var CreateRecordMutation = gql__default['default'](templateObject_3$8 || (templateObject_3$8 = __makeTemplateObject(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"], ["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"])));
7018
- var UpdateRecordContainerMutation = gql__default['default'](templateObject_4$6 || (templateObject_4$6 = __makeTemplateObject(["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"], ["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"])));
7019
- var UpdateRecordMutation = gql__default['default'](templateObject_5$6 || (templateObject_5$6 = __makeTemplateObject(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"], ["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"])));
7020
- var DeleteRecordMutation = gql__default['default'](templateObject_6$5 || (templateObject_6$5 = __makeTemplateObject(["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"], ["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"])));
7021
- var CreateFileMutation = gql__default['default'](templateObject_7$4 || (templateObject_7$4 = __makeTemplateObject(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"], ["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"])));
7022
- var DeleteFileMutation = gql__default['default'](templateObject_8$4 || (templateObject_8$4 = __makeTemplateObject(["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"], ["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"])));
7023
- var templateObject_1$d, templateObject_2$a, templateObject_3$8, templateObject_4$6, templateObject_5$6, templateObject_6$5, templateObject_7$4, templateObject_8$4;
7024
7066
 
7025
- var CategoryService = /** @class */ (function () {
7026
- function CategoryService(lrApollo, keyMetaService, keyGraph) {
7027
- this.lrApollo = lrApollo;
7028
- this.keyMetaService = keyMetaService;
7029
- this.keyGraph = keyGraph;
7067
+ var Auth2Service_1;
7068
+ exports.Auth2Service = Auth2Service_1 = /** @class */ (function (_super) {
7069
+ __extends(Auth2Service, _super);
7070
+ function Auth2Service(ngZone, injector, http, cognito, api, keyService, keyGraphService, keyFactoryService, passwordService, idleService, persistService, encryptionService, assemblyController, kcConfig) {
7071
+ var _this = _super.call(this, injector) || this;
7072
+ _this.ngZone = ngZone;
7073
+ _this.injector = injector;
7074
+ _this.http = http;
7075
+ _this.cognito = cognito;
7076
+ _this.api = api;
7077
+ _this.keyService = keyService;
7078
+ _this.keyGraphService = keyGraphService;
7079
+ _this.keyFactoryService = keyFactoryService;
7080
+ _this.passwordService = passwordService;
7081
+ _this.idleService = idleService;
7082
+ _this.persistService = persistService;
7083
+ _this.encryptionService = encryptionService;
7084
+ _this.assemblyController = assemblyController;
7085
+ _this.kcConfig = kcConfig;
7086
+ // Could use rxjs observables here. But trying to have kc-client use as little angular
7087
+ // features as possible. Rxjs is not used anywhere else in kc-client.
7088
+ _this.logoutListeners = new Set();
7089
+ // Stores the password for use after mfa verification to decrypt masterKey.
7090
+ _this.password = null;
7091
+ if (!i0.isDevMode()) {
7092
+ if (_this.kcConfig.debug != null) {
7093
+ throw new KcBadRequestException('In production mode, "KcConfig.debug" must be set to null');
7094
+ }
7095
+ }
7096
+ return _this;
7030
7097
  }
7031
- CategoryService.prototype.getRootDirectoryIds = function (input) {
7032
- if (input === void 0) { input = null; }
7098
+ Auth2Service.prototype.importPassword = function (plainPassword) {
7099
+ return this.keyFactoryService.importPassword(plainPassword);
7100
+ };
7101
+ Auth2Service.prototype.logout = function () {
7102
+ var _a;
7033
7103
  return __awaiter(this, void 0, void 0, function () {
7034
- var rootDirectories;
7035
7104
  return __generator(this, function (_b) {
7036
7105
  switch (_b.label) {
7037
- case 0: return [4 /*yield*/, this.lrApollo.query({
7038
- query: GetRootDirectoryIdsQuery,
7039
- variables: {
7040
- archived: input && input.archived,
7041
- },
7042
- })];
7106
+ case 0:
7107
+ // Notify all listeners to clean up.
7108
+ return [4 /*yield*/, Promise.all(__spread(this.logoutListeners).map(function (callback) { return callback(); }))];
7043
7109
  case 1:
7044
- rootDirectories = (_b.sent()).rootDirectories;
7045
- return [2 /*return*/, rootDirectories.edges.map(function (edge) { return edge.node.id; })];
7110
+ // Notify all listeners to clean up.
7111
+ _b.sent();
7112
+ this.user = null;
7113
+ this.keyService.purgeKeys();
7114
+ this.keyGraphService.purgeKeys();
7115
+ // Sign out on both cognito and kc-server
7116
+ return [4 /*yield*/, Promise.all([this.cognito.signOut(), this.kcLogout()])];
7117
+ case 2:
7118
+ // Sign out on both cognito and kc-server
7119
+ _b.sent();
7120
+ if ((_a = this.kcConfig.debug) === null || _a === void 0 ? void 0 : _a.username) {
7121
+ this.kcConfig.debug.username = null;
7122
+ }
7123
+ return [2 /*return*/];
7046
7124
  }
7047
7125
  });
7048
7126
  });
7049
7127
  };
7050
- CategoryService.prototype.getDefaultVault = function () {
7128
+ Auth2Service.prototype.addLogoutListener = function (callback) {
7129
+ this.logoutListeners.add(callback);
7130
+ };
7131
+ Auth2Service.prototype.removeLogoutListener = function (callback) {
7132
+ this.logoutListeners.delete(callback);
7133
+ };
7134
+ Auth2Service.prototype.login = function (emailOrPhone, password, _b) {
7135
+ var _c = _b === void 0 ? {} : _b, _d = _c.tpPasswordResetAutoComplete, tpPasswordResetAutoComplete = _d === void 0 ? true : _d;
7136
+ var _a;
7051
7137
  return __awaiter(this, void 0, void 0, function () {
7052
- var list, defaultVaults;
7138
+ var loginResult;
7053
7139
  return __generator(this, function (_b) {
7054
7140
  switch (_b.label) {
7055
- case 0: return [4 /*yield*/, this.lrApollo.query({
7056
- query: GetVaultsQuery,
7057
- variables: {
7058
- plainMetaFilter: DefaultVaultFilter,
7059
- },
7060
- })];
7141
+ case 0: return [4 /*yield*/, this.loginImpl(emailOrPhone, password)];
7061
7142
  case 1:
7062
- list = (_b.sent()).list;
7063
- return [4 /*yield*/, this.mapVaults(list)];
7064
- case 2:
7065
- defaultVaults = _b.sent();
7066
- if (defaultVaults.length > 1) {
7067
- throw new KcBadStateException('There are more than one default vaults');
7143
+ loginResult = _b.sent();
7144
+ // Save the password for use after meeting challenge.
7145
+ if (loginResult.challenge) {
7146
+ this.password = new KeyContainer(password, Auth2Service_1.CHALLENGE_TIMEOUT);
7147
+ return [2 /*return*/, loginResult];
7068
7148
  }
7069
- return [2 /*return*/, defaultVaults[0] || null];
7149
+ if (!(tpPasswordResetAutoComplete &&
7150
+ ((_a = loginResult.user.resetUser) === null || _a === void 0 ? void 0 : _a.state) === exports.TpClaimState.APPROVED)) return [3 /*break*/, 4];
7151
+ return [4 /*yield*/, this.completeResetRequest(password)];
7152
+ case 2:
7153
+ _b.sent();
7154
+ return [4 /*yield*/, this.loginImpl(emailOrPhone, password)];
7155
+ case 3:
7156
+ loginResult = _b.sent();
7157
+ _b.label = 4;
7158
+ case 4: return [2 /*return*/, loginResult];
7070
7159
  }
7071
7160
  });
7072
7161
  });
7073
7162
  };
7074
- CategoryService.prototype.getCategories = function (input) {
7075
- var _a;
7163
+ Auth2Service.prototype.verifyLogin = function (options) {
7076
7164
  return __awaiter(this, void 0, void 0, function () {
7077
- var vaultDirectoryId, _b, res;
7078
- return __generator(this, function (_c) {
7079
- switch (_c.label) {
7165
+ var challenge, code, rememberMe, VALID_CHALLENGE_NAMES, cognitoUser, user;
7166
+ return __generator(this, function (_b) {
7167
+ switch (_b.label) {
7080
7168
  case 0:
7081
- _b = (input === null || input === void 0 ? void 0 : input.vaultDirectoryId);
7082
- if (_b) return [3 /*break*/, 2];
7083
- return [4 /*yield*/, this.getDefaultVault()];
7169
+ challenge = options.challenge, code = options.code, rememberMe = options.rememberMe;
7170
+ VALID_CHALLENGE_NAMES = [
7171
+ CognitoChallengeName.SMS_MFA,
7172
+ CognitoChallengeName.SOFTWARE_TOKEN_MFA,
7173
+ ];
7174
+ if (!VALID_CHALLENGE_NAMES.includes(challenge.cognitoUser.challengeName)) {
7175
+ throw new KcBadRequestException("challengeName must be one of " + VALID_CHALLENGE_NAMES);
7176
+ }
7177
+ return [4 /*yield*/, this.cognito.confirmSignIn(challenge.cognitoUser, code, challenge.cognitoUser.challengeName)];
7084
7178
  case 1:
7085
- _b = ((_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.id);
7086
- _c.label = 2;
7179
+ cognitoUser = _b.sent();
7180
+ return [4 /*yield*/, this.handlePostAuth(challenge.recoveryStatus)];
7087
7181
  case 2:
7088
- vaultDirectoryId = _b;
7089
- if (!vaultDirectoryId) {
7090
- console.error('There is no default vault.');
7091
- return [2 /*return*/, []];
7092
- }
7093
- return [4 /*yield*/, this.lrApollo.query({
7094
- query: GetCategoriesQuery,
7095
- variables: {
7096
- vaultDirectoryId: vaultDirectoryId,
7097
- categoryFilter: CategoryFilter,
7098
- recordFilter: RecordFilter,
7099
- archived: input === null || input === void 0 ? void 0 : input.archived,
7100
- },
7101
- })];
7182
+ _b.sent();
7183
+ return [4 /*yield*/, this.loadUser(cognitoUser, this.password.pop())];
7102
7184
  case 3:
7103
- res = _c.sent();
7104
- return [2 /*return*/, this.mapCategories(res.directory.childDirectoryLinks)];
7185
+ user = _b.sent();
7186
+ // This is not strictly necessary since the this.password.pop() already clears the
7187
+ // password inside the container. But doesn't hurt either.
7188
+ this.password = null;
7189
+ if (rememberMe) {
7190
+ cognitoUser.setDeviceStatusRemembered({
7191
+ onSuccess: function () {
7192
+ return;
7193
+ },
7194
+ onFailure: function (e) { return console.error(e); },
7195
+ });
7196
+ }
7197
+ return [2 /*return*/, {
7198
+ user: user,
7199
+ }];
7105
7200
  }
7106
7201
  });
7107
7202
  });
7108
7203
  };
7109
- CategoryService.prototype.getTrustedPartyCategories = function (trustedPartyId) {
7204
+ Auth2Service.prototype.getUser = function () {
7110
7205
  return __awaiter(this, void 0, void 0, function () {
7111
- var tp, _b;
7112
- return __generator(this, function (_c) {
7113
- switch (_c.label) {
7114
- case 0: return [4 /*yield*/, this.lrApollo.query({
7115
- query: GetTrustedPartyCategoriesQuery,
7116
- variables: {
7117
- trustedPartyId: trustedPartyId,
7118
- categoryFilter: CategoryFilter,
7119
- recordFilter: RecordFilter,
7120
- contentFilter: RecordContentFilter,
7206
+ var cognitoUser;
7207
+ return __generator(this, function (_b) {
7208
+ switch (_b.label) {
7209
+ case 0:
7210
+ if (this.user) {
7211
+ return [2 /*return*/, this.user];
7212
+ }
7213
+ return [4 /*yield*/, this.cognito.currentAuthenticatedUser()];
7214
+ case 1:
7215
+ cognitoUser = _b.sent();
7216
+ return [2 /*return*/, this.loadUser(cognitoUser)];
7217
+ }
7218
+ });
7219
+ });
7220
+ };
7221
+ Auth2Service.prototype.refreshAccessToken = function () {
7222
+ return __awaiter(this, void 0, void 0, function () {
7223
+ var cognitoUser, refreshToken;
7224
+ return __generator(this, function (_b) {
7225
+ switch (_b.label) {
7226
+ case 0: return [4 /*yield*/, this.cognito.currentAuthenticatedUser()];
7227
+ case 1:
7228
+ cognitoUser = _b.sent();
7229
+ refreshToken = cognitoUser.getSignInUserSession().getRefreshToken();
7230
+ console.log('Token refresh...');
7231
+ return [2 /*return*/, new Promise(function (resolve, reject) {
7232
+ cognitoUser.refreshSession(refreshToken, function (err) {
7233
+ if (err) {
7234
+ console.error('Error refreshing token: ', err);
7235
+ reject(err);
7236
+ }
7237
+ else {
7238
+ console.log('Token refresh complete');
7239
+ resolve(0);
7240
+ }
7241
+ });
7242
+ })];
7243
+ }
7244
+ });
7245
+ });
7246
+ };
7247
+ // ----------------------------------------------------------------------------------------------------
7248
+ // Helpers
7249
+ // ----------------------------------------------------------------------------------------------------
7250
+ Auth2Service.prototype.fetchCurrentUser = function () {
7251
+ return __awaiter(this, void 0, void 0, function () {
7252
+ return __generator(this, function (_b) {
7253
+ switch (_b.label) {
7254
+ case 0: return [4 /*yield*/, this.api.query({
7255
+ query: CurrentUserQuery$1,
7256
+ processorOptions: {
7257
+ hasKeys: false,
7258
+ },
7259
+ })];
7260
+ case 1: return [2 /*return*/, (_b.sent()).currentUser];
7261
+ }
7262
+ });
7263
+ });
7264
+ };
7265
+ Auth2Service.prototype.fetchResetUser = function () {
7266
+ return __awaiter(this, void 0, void 0, function () {
7267
+ return __generator(this, function (_b) {
7268
+ switch (_b.label) {
7269
+ case 0: return [4 /*yield*/, this.api.query({
7270
+ query: CurrentUserQuery$1,
7271
+ processorOptions: {
7272
+ hasKeys: false,
7273
+ },
7274
+ })];
7275
+ case 1: return [2 /*return*/, (_b.sent()).tpPasswordResetUser];
7276
+ }
7277
+ });
7278
+ });
7279
+ };
7280
+ Auth2Service.prototype.kcLogout = function () {
7281
+ return __awaiter(this, void 0, void 0, function () {
7282
+ return __generator(this, function (_b) {
7283
+ switch (_b.label) {
7284
+ case 0: return [4 /*yield*/, this.http
7285
+ .post(this.kcConfig.authUrl + "auth/sign-out/", null, {
7286
+ withCredentials: true,
7287
+ responseType: 'text',
7288
+ })
7289
+ .toPromise()];
7290
+ case 1:
7291
+ _b.sent();
7292
+ return [2 /*return*/];
7293
+ }
7294
+ });
7295
+ });
7296
+ };
7297
+ Auth2Service.prototype.fetchPassIdpParams = function (emailOrPhone) {
7298
+ return __awaiter(this, void 0, void 0, function () {
7299
+ return __generator(this, function (_b) {
7300
+ switch (_b.label) {
7301
+ case 0: return [4 /*yield*/, this.http
7302
+ .get(this.kcConfig.authUrl + "users/pass-idp-params/?login_name=" + encodeURIComponent(emailOrPhone))
7303
+ .toPromise()];
7304
+ case 1: return [2 /*return*/, _b.sent()];
7305
+ }
7306
+ });
7307
+ });
7308
+ };
7309
+ Auth2Service.prototype.loginImpl = function (emailOrPhone, password) {
7310
+ return __awaiter(this, void 0, void 0, function () {
7311
+ var loginIdpResult, user;
7312
+ return __generator(this, function (_b) {
7313
+ switch (_b.label) {
7314
+ case 0: return [4 /*yield*/, this.logout()];
7315
+ case 1:
7316
+ _b.sent();
7317
+ return [4 /*yield*/, this.loginIdp(emailOrPhone, password)];
7318
+ case 2:
7319
+ loginIdpResult = _b.sent();
7320
+ // Can't get the user yet because we still ned to meet MFA challenges
7321
+ if ([
7322
+ CognitoChallengeName.SMS_MFA,
7323
+ CognitoChallengeName.SOFTWARE_TOKEN_MFA,
7324
+ ].includes(loginIdpResult.cognitoUser.challengeName)) {
7325
+ return [2 /*return*/, {
7326
+ challenge: {
7327
+ cognitoUser: loginIdpResult.cognitoUser,
7328
+ recoveryStatus: loginIdpResult.recoveryStatus,
7329
+ },
7330
+ }];
7331
+ }
7332
+ return [4 /*yield*/, this.handlePostAuth(loginIdpResult.recoveryStatus)];
7333
+ case 3:
7334
+ _b.sent();
7335
+ return [4 /*yield*/, this.loadUser(loginIdpResult.cognitoUser, password)];
7336
+ case 4:
7337
+ user = _b.sent();
7338
+ return [2 /*return*/, {
7339
+ user: user,
7340
+ }];
7341
+ }
7342
+ });
7343
+ });
7344
+ };
7345
+ Auth2Service.prototype.loginIdp = function (emailOrPhone, password) {
7346
+ return __awaiter(this, void 0, void 0, function () {
7347
+ var passIdpApiResult, user_1, _b, error_1, user_2, _c, error_2, reset, user_3, _d, err_1, user, _e;
7348
+ return __generator(this, function (_f) {
7349
+ switch (_f.label) {
7350
+ case 0: return [4 /*yield*/, this.fetchPassIdpParams(emailOrPhone)];
7351
+ case 1:
7352
+ passIdpApiResult = _f.sent();
7353
+ if (passIdpApiResult.passwordChangeStatus === PasswordChangeStatus.IN_PROGRESS) {
7354
+ throw new KcConcurrentAccessException('A password change is in progress');
7355
+ }
7356
+ if (!(passIdpApiResult.passwordChangeStatus === PasswordChangeStatus.RECOVERY)) return [3 /*break*/, 8];
7357
+ console.log('In recovery mode.');
7358
+ _f.label = 2;
7359
+ case 2:
7360
+ _f.trys.push([2, 4, , 5]);
7361
+ _b = {};
7362
+ return [4 /*yield*/, this.loginIdpImpl(emailOrPhone, password, passIdpApiResult.newPassIdpParams)];
7363
+ case 3:
7364
+ user_1 = (_b.cognitoUser = _f.sent(),
7365
+ _b.recoveryStatus = RecoveryStatus.NEW_PASSWORD,
7366
+ _b);
7367
+ // New password worked. Let's set to the current password
7368
+ // --Potential Failure Point 1--
7369
+ // if changePasswordComplete() doesn't get called, then it should remain
7370
+ console.log('New password works!');
7371
+ return [2 /*return*/, user_1];
7372
+ case 4:
7373
+ error_1 = _f.sent();
7374
+ // Just bubble up any other type of error.
7375
+ if (error_1.code !== 'NotAuthorizedException') {
7376
+ throw error_1;
7377
+ }
7378
+ return [3 /*break*/, 5];
7379
+ case 5:
7380
+ _f.trys.push([5, 7, , 8]);
7381
+ _c = {};
7382
+ return [4 /*yield*/, this.loginIdpImpl(emailOrPhone, password, passIdpApiResult.currentPassIdpParams)];
7383
+ case 6:
7384
+ user_2 = (_c.cognitoUser = _f.sent(),
7385
+ _c.recoveryStatus = RecoveryStatus.OLD_PASSWORD,
7386
+ _c);
7387
+ // Old password worked.
7388
+ console.log('Old password works!');
7389
+ return [2 /*return*/, user_2];
7390
+ case 7:
7391
+ error_2 = _f.sent();
7392
+ // Just bubble up any other type of error.
7393
+ throw error_2.code === 'NotAuthorizedException'
7394
+ ? new KcBadRequestException('The password change request was interrupted, please try to login with both your new and old password')
7395
+ : error_2;
7396
+ case 8:
7397
+ if (!passIdpApiResult.tpPasswordReset) return [3 /*break*/, 12];
7398
+ _f.label = 9;
7399
+ case 9:
7400
+ _f.trys.push([9, 11, , 12]);
7401
+ reset = passIdpApiResult.tpPasswordReset;
7402
+ _d = {};
7403
+ return [4 /*yield*/, this.loginIdpImpl(reset.resetUsername, password, reset.passIdpParams)];
7404
+ case 10:
7405
+ user_3 = (_d.cognitoUser = _f.sent(),
7406
+ _d.recoveryStatus = RecoveryStatus.NONE,
7407
+ _d);
7408
+ return [2 /*return*/, user_3];
7409
+ case 11:
7410
+ err_1 = _f.sent();
7411
+ return [3 /*break*/, 12];
7412
+ case 12:
7413
+ _e = {};
7414
+ return [4 /*yield*/, this.loginIdpImpl(emailOrPhone, password, passIdpApiResult.currentPassIdpParams)];
7415
+ case 13:
7416
+ user = (_e.cognitoUser = _f.sent(),
7417
+ _e.recoveryStatus = RecoveryStatus.NONE,
7418
+ _e);
7419
+ return [2 /*return*/, user];
7420
+ }
7421
+ });
7422
+ });
7423
+ };
7424
+ Auth2Service.prototype.loginIdpImpl = function (emailOrPhone, password, passIdpParams) {
7425
+ return __awaiter(this, void 0, void 0, function () {
7426
+ var passIdpResult;
7427
+ return __generator(this, function (_b) {
7428
+ switch (_b.label) {
7429
+ case 0: return [4 /*yield*/, this.keyFactoryService.derivePassIdp(Object.assign({ password: password }, passIdpParams))];
7430
+ case 1:
7431
+ passIdpResult = _b.sent();
7432
+ // Use the derived password to signin with cognito
7433
+ return [2 /*return*/, this.cognito.signIn(emailOrPhone, this.passwordService.getPassIdpString(passIdpResult.jwk))];
7434
+ }
7435
+ });
7436
+ });
7437
+ };
7438
+ Auth2Service.prototype.handlePostAuth = function (recoveryStatus) {
7439
+ return __awaiter(this, void 0, void 0, function () {
7440
+ return __generator(this, function (_b) {
7441
+ switch (_b.label) {
7442
+ case 0: return [4 /*yield*/, this.handlePasswordRecovery(recoveryStatus)];
7443
+ case 1:
7444
+ _b.sent();
7445
+ return [4 /*yield*/, this.handleSessionEncryptionKey()];
7446
+ case 2:
7447
+ _b.sent();
7448
+ return [2 /*return*/];
7449
+ }
7450
+ });
7451
+ });
7452
+ };
7453
+ Auth2Service.prototype.handlePasswordRecovery = function (recoveryStatus) {
7454
+ return __awaiter(this, void 0, void 0, function () {
7455
+ return __generator(this, function (_b) {
7456
+ switch (_b.label) {
7457
+ case 0:
7458
+ if (!(recoveryStatus !== RecoveryStatus.NONE)) return [3 /*break*/, 2];
7459
+ return [4 /*yield*/, this.passwordService.changePasswordComplete({
7460
+ useNewPassword: recoveryStatus === RecoveryStatus.NEW_PASSWORD,
7461
+ })];
7462
+ case 1:
7463
+ _b.sent();
7464
+ _b.label = 2;
7465
+ case 2: return [2 /*return*/];
7466
+ }
7467
+ });
7468
+ });
7469
+ };
7470
+ Auth2Service.prototype.handleSessionEncryptionKey = function () {
7471
+ return __awaiter(this, void 0, void 0, function () {
7472
+ var msg, sessionEncryptionKey;
7473
+ return __generator(this, function (_b) {
7474
+ switch (_b.label) {
7475
+ case 0:
7476
+ if (!this.kcConfig.disableSessionEncryptionKey) return [3 /*break*/, 1];
7477
+ if (!i0.isDevMode()) {
7478
+ msg = 'You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.';
7479
+ console.error(msg);
7480
+ throw new KcInternalErrorException(msg);
7481
+ }
7482
+ else {
7483
+ console.warn('You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode.');
7484
+ }
7485
+ return [3 /*break*/, 4];
7486
+ case 1: return [4 /*yield*/, this.keyFactoryService.createKey()];
7487
+ case 2:
7488
+ sessionEncryptionKey = _b.sent();
7489
+ return [4 /*yield*/, this.lrGraphQL.lrMutate(new LrMutation({
7490
+ mutation: SetSessionEncryptionKeyMutation,
7491
+ variables: {
7492
+ input: {
7493
+ sessionEncryptionKey: JSON.stringify(sessionEncryptionKey.toJSON(true)),
7494
+ },
7495
+ },
7496
+ }), {
7497
+ includeKeyGraph: false,
7498
+ })];
7499
+ case 3:
7500
+ _b.sent();
7501
+ this.persistService.setServerSessionEncryptionKey(sessionEncryptionKey);
7502
+ _b.label = 4;
7503
+ case 4: return [2 /*return*/];
7504
+ }
7505
+ });
7506
+ });
7507
+ };
7508
+ Auth2Service.prototype.getCognitoUserAttribute = function (attributeName, userAttributes) {
7509
+ var userAttribute = userAttributes.find(function (x) { return x.getName() === attributeName; });
7510
+ return userAttribute ? userAttribute.getValue() : null;
7511
+ };
7512
+ Auth2Service.prototype.loadUserKeys = function (options) {
7513
+ return __awaiter(this, void 0, void 0, function () {
7514
+ var userKeys, password, sessionEncryptionKey, _b, _c, passKey, _d, _e;
7515
+ return __generator(this, function (_f) {
7516
+ switch (_f.label) {
7517
+ case 0:
7518
+ userKeys = options.userKeys, password = options.password, sessionEncryptionKey = options.sessionEncryptionKey;
7519
+ if (!sessionEncryptionKey) return [3 /*break*/, 2];
7520
+ _c = (_b = this.persistService).setServerSessionEncryptionKey;
7521
+ return [4 /*yield*/, nodeJose.JWK.asKey(sessionEncryptionKey)];
7522
+ case 1:
7523
+ _c.apply(_b, [_f.sent()]);
7524
+ _f.label = 2;
7525
+ case 2:
7526
+ if (!password) return [3 /*break*/, 6];
7527
+ return [4 /*yield*/, this.keyFactoryService.derivePassKey(Object.assign({ password: password }, userKeys.passKey.passKeyParams))];
7528
+ case 3:
7529
+ passKey = (_f.sent()).jwk;
7530
+ _e = (_d = this.idleService).persistMasterKey;
7531
+ return [4 /*yield*/, this.keyGraphService.unwrapWithPassKey(userKeys.passKey.id, passKey, userKeys.masterKey.id)];
7532
+ case 4: return [4 /*yield*/, _e.apply(_d, [_f.sent()])];
7533
+ case 5:
7534
+ _f.sent();
7535
+ _f.label = 6;
7536
+ case 6: return [4 /*yield*/, this.keyGraphService.populateKeys(userKeys)];
7537
+ case 7:
7538
+ _f.sent();
7539
+ return [2 /*return*/];
7540
+ }
7541
+ });
7542
+ });
7543
+ };
7544
+ Auth2Service.prototype.loadUser = function (cognitoUser, password) {
7545
+ return __awaiter(this, void 0, void 0, function () {
7546
+ var _b, _c;
7547
+ return __generator(this, function (_d) {
7548
+ switch (_d.label) {
7549
+ case 0:
7550
+ if (!cognitoUser.getUsername().endsWith(TP_PASSWORD_RESET_USERNAME_SUFFIX)) return [3 /*break*/, 2];
7551
+ _b = this;
7552
+ return [4 /*yield*/, this.loadResetUser(cognitoUser, password)];
7553
+ case 1:
7554
+ _b.user = _d.sent();
7555
+ return [3 /*break*/, 4];
7556
+ case 2:
7557
+ _c = this;
7558
+ return [4 /*yield*/, this.loadRegularUser(cognitoUser, password)];
7559
+ case 3:
7560
+ _c.user = _d.sent();
7561
+ _d.label = 4;
7562
+ case 4: return [4 /*yield*/, this.idleService.start()];
7563
+ case 5:
7564
+ _d.sent(); // Run idleService whenever user is logged in.
7565
+ return [2 /*return*/, this.user];
7566
+ }
7567
+ });
7568
+ });
7569
+ };
7570
+ Auth2Service.prototype.loadRegularUser = function (cognitoUser, password) {
7571
+ return __awaiter(this, void 0, void 0, function () {
7572
+ var currentUser, username, userAttributes;
7573
+ return __generator(this, function (_b) {
7574
+ switch (_b.label) {
7575
+ case 0: return [4 /*yield*/, this.fetchCurrentUser()];
7576
+ case 1:
7577
+ currentUser = _b.sent();
7578
+ return [4 /*yield*/, this.loadUserKeys({
7579
+ userKeys: currentUser.currentUserKey,
7580
+ password: password,
7581
+ sessionEncryptionKey: currentUser.sessionEncryptionKey,
7582
+ })];
7583
+ case 2:
7584
+ _b.sent();
7585
+ username = currentUser.username;
7586
+ return [4 /*yield*/, this.cognito.userAttributes(cognitoUser)];
7587
+ case 3:
7588
+ userAttributes = _b.sent();
7589
+ return [2 /*return*/, {
7590
+ username: username,
7591
+ sub: this.getCognitoUserAttribute('sub', userAttributes),
7592
+ loginEmail: this.getCognitoUserAttribute('email', userAttributes),
7593
+ resetUser: null,
7594
+ }];
7595
+ }
7596
+ });
7597
+ });
7598
+ };
7599
+ Auth2Service.prototype.loadResetUser = function (cognitoUser, password) {
7600
+ return __awaiter(this, void 0, void 0, function () {
7601
+ var resetUser, username, userAttributes;
7602
+ return __generator(this, function (_b) {
7603
+ switch (_b.label) {
7604
+ case 0: return [4 /*yield*/, this.fetchResetUser()];
7605
+ case 1:
7606
+ resetUser = _b.sent();
7607
+ this.loadUserKeys({
7608
+ userKeys: {
7609
+ passKey: {
7610
+ id: resetUser.passKey.id,
7611
+ },
7612
+ masterKey: {
7613
+ id: resetUser.masterKey.id,
7614
+ },
7615
+ },
7616
+ password: password,
7617
+ sessionEncryptionKey: resetUser.sessionEncryptionKey,
7618
+ });
7619
+ username = resetUser.username;
7620
+ return [4 /*yield*/, this.cognito.userAttributes(cognitoUser)];
7621
+ case 2:
7622
+ userAttributes = _b.sent();
7623
+ return [2 /*return*/, {
7624
+ username: username,
7625
+ sub: this.getCognitoUserAttribute('sub', userAttributes),
7626
+ loginEmail: this.getCognitoUserAttribute('email', userAttributes),
7627
+ resetUser: {
7628
+ state: resetUser.state,
7629
+ },
7630
+ }];
7631
+ }
7632
+ });
7633
+ });
7634
+ };
7635
+ Auth2Service.prototype.recoverAssemblyKey = function (resetUser) {
7636
+ return __awaiter(this, void 0, void 0, function () {
7637
+ var prk, partials;
7638
+ var _this = this;
7639
+ return __generator(this, function (_b) {
7640
+ switch (_b.label) {
7641
+ case 0: return [4 /*yield*/, this.keyGraphService.getKey(resetUser.pxk.id)];
7642
+ case 1:
7643
+ prk = _b.sent();
7644
+ return [4 /*yield*/, Promise.all(resetUser.approvals
7645
+ .filter(function (approval) { return !!approval.receiverCipherPartialAssemblyKey; })
7646
+ .map(function (approval) { return _this.encryptionService.decrypt(prk, approval.receiverCipherPartialAssemblyKey); }))];
7647
+ case 2:
7648
+ partials = _b.sent();
7649
+ return [2 /*return*/, this.assemblyController.recoverAssemblyKey(partials)];
7650
+ }
7651
+ });
7652
+ });
7653
+ };
7654
+ Auth2Service.prototype.completeResetRequest = function (newPassword) {
7655
+ return __awaiter(this, void 0, void 0, function () {
7656
+ var resetUser, assemblyKey, rootKey, rootKeyJwk, masterKey, masterKeyWrappedRootKey, newPassIdpResult, newIdpPassword, challenge, assemblyKeyVerifierPrk, signedChallenge, tempIdpPassword, retPromise, user;
7657
+ var _this = this;
7658
+ return __generator(this, function (_b) {
7659
+ switch (_b.label) {
7660
+ case 0: return [4 /*yield*/, this.fetchResetUser()];
7661
+ case 1:
7662
+ resetUser = _b.sent();
7663
+ if (resetUser.state !== exports.TpClaimState.APPROVED) {
7664
+ throw new KcBadStateException('Password reset request has not been approved.');
7665
+ }
7666
+ return [4 /*yield*/, this.recoverAssemblyKey(resetUser)];
7667
+ case 2:
7668
+ assemblyKey = _b.sent();
7669
+ return [4 /*yield*/, this.encryptionService.decrypt(assemblyKey, resetUser.assemblyCipherData)];
7670
+ case 3:
7671
+ rootKey = (_b.sent()).rootKey;
7672
+ return [4 /*yield*/, nodeJose.JWK.asKey(rootKey)];
7673
+ case 4:
7674
+ rootKeyJwk = _b.sent();
7675
+ return [4 /*yield*/, this.keyGraphService.getKey(resetUser.masterKey.id)];
7676
+ case 5:
7677
+ masterKey = _b.sent();
7678
+ return [4 /*yield*/, this.encryptionService.encryptToString(masterKey.jwk, rootKeyJwk.toJSON(true))];
7679
+ case 6:
7680
+ masterKeyWrappedRootKey = _b.sent();
7681
+ return [4 /*yield*/, this.keyFactoryService.derivePassIdp(Object.assign({ password: newPassword }, resetUser.passKey.passIdpParams))];
7682
+ case 7:
7683
+ newPassIdpResult = _b.sent();
7684
+ newIdpPassword = this.passwordService.getPassIdpString(newPassIdpResult.jwk);
7685
+ return [4 /*yield*/, this.lrGraphQL.lrMutate(new LrMutation({
7686
+ mutation: CreateTpAssemblyKeyChallengeMutation,
7687
+ variables: {
7688
+ input: {},
7689
+ },
7690
+ }), {
7691
+ includeKeyGraph: false,
7692
+ })];
7693
+ case 8:
7694
+ challenge = (_b.sent()).createTpAssemblyKeyChallenge.challenge;
7695
+ // Sign the challenge
7696
+ // Generate a client side nonce that's no in the server's control.
7697
+ challenge.clientNonce = this.keyFactoryService.randomString(TP_PASSWORD_RESET_CLIENT_NONCE_LENGTH);
7698
+ return [4 /*yield*/, this.encryptionService.decrypt(assemblyKey, resetUser.wrappedAssemblyKeyVerifierPrk)];
7699
+ case 9:
7700
+ assemblyKeyVerifierPrk = _b.sent();
7701
+ return [4 /*yield*/, this.encryptionService.sign(assemblyKeyVerifierPrk, challenge)];
7702
+ case 10:
7703
+ signedChallenge = _b.sent();
7704
+ return [4 /*yield*/, this.lrGraphQL.lrMutate(new LrMutation({
7705
+ mutation: PreCompleteTpPasswordResetRequestMutation,
7706
+ variables: {
7707
+ input: {
7708
+ signedChallenge: JSON.stringify(signedChallenge),
7709
+ },
7710
+ },
7711
+ }), {
7712
+ includeKeyGraph: false,
7713
+ })];
7714
+ case 11:
7715
+ tempIdpPassword = (_b.sent()).preCompleteTpPasswordResetRequest.idpPassword;
7716
+ retPromise = new Promise(function (resolve) {
7717
+ var listener = function (data) { return __awaiter(_this, void 0, void 0, function () {
7718
+ return __generator(this, function (_b) {
7719
+ switch (_b.label) {
7720
+ case 0:
7721
+ if (data.payload.event !== 'signIn') {
7722
+ return [2 /*return*/];
7723
+ }
7724
+ core$1.Hub.remove('auth', listener);
7725
+ return [4 /*yield*/, this.cognito.signIn(resetUser.username, newIdpPassword)];
7726
+ case 1:
7727
+ _b.sent();
7728
+ // Switch over to the new set of keys
7729
+ return [4 /*yield*/, this.lrGraphQL.lrMutate(new LrMutation({
7730
+ mutation: CompleteTpPasswordResetRequestMutation,
7731
+ variables: {
7732
+ input: {
7733
+ masterKeyWrappedRootKey: masterKeyWrappedRootKey,
7734
+ masterKeyId: masterKey.id,
7735
+ },
7736
+ },
7737
+ }))];
7738
+ case 2:
7739
+ // Switch over to the new set of keys
7740
+ _b.sent();
7741
+ resolve();
7742
+ return [2 /*return*/];
7743
+ }
7744
+ });
7745
+ }); };
7746
+ core$1.Hub.listen('auth', listener);
7747
+ });
7748
+ return [4 /*yield*/, this.cognito.signIn(resetUser.username, tempIdpPassword, {
7749
+ noProxy: 'true',
7750
+ })];
7751
+ case 12:
7752
+ user = _b.sent();
7753
+ if (user.challengeName !== 'NEW_PASSWORD_REQUIRED') {
7754
+ throw new KcInternalErrorException('Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.');
7755
+ }
7756
+ return [4 /*yield*/, this.cognito.completeNewPassword(user, newIdpPassword, {})];
7757
+ case 13:
7758
+ // Set new password on Idp
7759
+ // the awsFetch() function passes NEW_PASSWORD_REQUIRED directly to AWS without
7760
+ // going through the proxy.
7761
+ user = _b.sent();
7762
+ return [2 /*return*/, retPromise];
7763
+ }
7764
+ });
7765
+ });
7766
+ };
7767
+ // ------------------------------------------------------
7768
+ // Debug utilities
7769
+ // ------------------------------------------------------
7770
+ Auth2Service.prototype.debugLogin = function (username, password) {
7771
+ // This will fail if debug is null. But when debug is null, this function
7772
+ // should not be called.
7773
+ this.kcConfig.debug.username = username;
7774
+ return this.debugLoadUser(password);
7775
+ };
7776
+ Auth2Service.prototype.debugLoadUser = function (password) {
7777
+ return __awaiter(this, void 0, void 0, function () {
7778
+ var currentUser, username, currentUserKey, passKey, masterKey;
7779
+ return __generator(this, function (_b) {
7780
+ switch (_b.label) {
7781
+ case 0: return [4 /*yield*/, this.fetchCurrentUser()];
7782
+ case 1:
7783
+ currentUser = _b.sent();
7784
+ username = currentUser.username, currentUserKey = currentUser.currentUserKey;
7785
+ return [4 /*yield*/, this.keyFactoryService.derivePassKey(Object.assign({ password: password }, currentUserKey.passKey.passKeyParams))];
7786
+ case 2:
7787
+ passKey = (_b.sent()).jwk;
7788
+ return [4 /*yield*/, this.keyGraphService.unwrapWithPassKey(currentUserKey.passKey.id, passKey, currentUserKey.masterKey.id)];
7789
+ case 3:
7790
+ masterKey = _b.sent();
7791
+ return [4 /*yield*/, this.idleService.persistMasterKey(masterKey)];
7792
+ case 4:
7793
+ _b.sent();
7794
+ return [4 /*yield*/, this.keyGraphService.populateKeys(currentUserKey)];
7795
+ case 5:
7796
+ _b.sent();
7797
+ this.user = {
7798
+ username: username,
7799
+ resetUser: null,
7800
+ sub: 'DEBUG_MODE',
7801
+ loginEmail: 'DEBUG_MODE',
7802
+ };
7803
+ return [2 /*return*/, this.user];
7804
+ }
7805
+ });
7806
+ });
7807
+ };
7808
+ /**
7809
+ * Clears the caches user. So we can simulate a page refresh and test getUser().
7810
+ */
7811
+ Auth2Service.prototype.debugClearUser = function () {
7812
+ this.user = null;
7813
+ };
7814
+ return Auth2Service;
7815
+ }(LrService));
7816
+ exports.Auth2Service.CHALLENGE_TIMEOUT = 1000 * 60 * 5;
7817
+ exports.Auth2Service.ɵprov = i0.ɵɵdefineInjectable({ factory: function Auth2Service_Factory() { return new exports.Auth2Service(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(i2.AuthClass), i0.ɵɵinject(exports.ɵf), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(PasswordService), i0.ɵɵinject(IdleService), i0.ɵɵinject(PersistService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(exports.ɵi), i0.ɵɵinject(KC_CONFIG)); }, token: exports.Auth2Service, providedIn: "root" });
7818
+ exports.Auth2Service.decorators = [
7819
+ { type: i0.Injectable, args: [{
7820
+ providedIn: 'root',
7821
+ },] }
7822
+ ];
7823
+ exports.Auth2Service.ctorParameters = function () { return [
7824
+ { type: i0.NgZone },
7825
+ { type: i0.Injector },
7826
+ { type: i2$2.HttpClient },
7827
+ { type: i2.AuthClass },
7828
+ { type: exports.ɵf },
7829
+ { type: KeyService },
7830
+ { type: KeyGraphService },
7831
+ { type: KeyFactoryService },
7832
+ { type: PasswordService },
7833
+ { type: IdleService },
7834
+ { type: PersistService },
7835
+ { type: EncryptionService },
7836
+ { type: exports.ɵi },
7837
+ { type: undefined, decorators: [{ type: i0.Inject, args: [KC_CONFIG,] }] }
7838
+ ]; };
7839
+ exports.Auth2Service = Auth2Service_1 = __decorate([
7840
+ RunOutsideAngular({
7841
+ ngZoneName: 'ngZone',
7842
+ })
7843
+ ], exports.Auth2Service);
7844
+
7845
+ (function (FileType) {
7846
+ FileType["RecordContent"] = "record-content";
7847
+ FileType["RecordAttachment"] = "record-attachment";
7848
+ })(exports.FileType || (exports.FileType = {}));
7849
+ var RecordContentFilter = JSON.stringify({
7850
+ filter: [
7851
+ {
7852
+ contains: {
7853
+ fileType: exports.FileType.RecordContent,
7854
+ },
7855
+ },
7856
+ ],
7857
+ });
7858
+ var RecordAttachmentFilter = JSON.stringify({
7859
+ filter: [
7860
+ {
7861
+ contains: {
7862
+ fileType: exports.FileType.RecordAttachment,
7863
+ },
7864
+ },
7865
+ ],
7866
+ });
7867
+ var GetRecordQuery = function (depth) {
7868
+ if (depth === void 0) { depth = DEFAULT_BREADCRUMB_DEPTH; }
7869
+ return gql__default['default'](templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n confidentiality {\n isConfidential\n method\n }\n ", "\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", "\n"], ["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n confidentiality {\n isConfidential\n method\n }\n ", "\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", "\n"])), parentCategoriesField(depth), KeyGraphFragment);
7870
+ };
7871
+ var CreateRecordContainerMutation = gql__default['default'](templateObject_2$b || (templateObject_2$b = __makeTemplateObject(["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"], ["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"])));
7872
+ var CreateRecordMutation = gql__default['default'](templateObject_3$8 || (templateObject_3$8 = __makeTemplateObject(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"], ["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"])));
7873
+ var UpdateRecordContainerMutation = gql__default['default'](templateObject_4$6 || (templateObject_4$6 = __makeTemplateObject(["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"], ["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"])));
7874
+ var UpdateRecordMutation = gql__default['default'](templateObject_5$6 || (templateObject_5$6 = __makeTemplateObject(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"], ["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"])));
7875
+ var DeleteRecordMutation = gql__default['default'](templateObject_6$5 || (templateObject_6$5 = __makeTemplateObject(["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"], ["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"])));
7876
+ var CreateFileMutation = gql__default['default'](templateObject_7$4 || (templateObject_7$4 = __makeTemplateObject(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"], ["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"])));
7877
+ var DeleteFileMutation = gql__default['default'](templateObject_8$4 || (templateObject_8$4 = __makeTemplateObject(["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"], ["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"])));
7878
+ var templateObject_1$e, templateObject_2$b, templateObject_3$8, templateObject_4$6, templateObject_5$6, templateObject_6$5, templateObject_7$4, templateObject_8$4;
7879
+
7880
+ var CategoryService = /** @class */ (function () {
7881
+ function CategoryService(lrApollo, keyMetaService, keyGraph) {
7882
+ this.lrApollo = lrApollo;
7883
+ this.keyMetaService = keyMetaService;
7884
+ this.keyGraph = keyGraph;
7885
+ }
7886
+ CategoryService.prototype.getRootDirectoryIds = function (input) {
7887
+ if (input === void 0) { input = null; }
7888
+ return __awaiter(this, void 0, void 0, function () {
7889
+ var rootDirectories;
7890
+ return __generator(this, function (_b) {
7891
+ switch (_b.label) {
7892
+ case 0: return [4 /*yield*/, this.lrApollo.query({
7893
+ query: GetRootDirectoryIdsQuery,
7894
+ variables: {
7895
+ archived: input && input.archived,
7896
+ },
7897
+ })];
7898
+ case 1:
7899
+ rootDirectories = (_b.sent()).rootDirectories;
7900
+ return [2 /*return*/, rootDirectories.edges.map(function (edge) { return edge.node.id; })];
7901
+ }
7902
+ });
7903
+ });
7904
+ };
7905
+ CategoryService.prototype.getDefaultVault = function () {
7906
+ return __awaiter(this, void 0, void 0, function () {
7907
+ var list, defaultVaults;
7908
+ return __generator(this, function (_b) {
7909
+ switch (_b.label) {
7910
+ case 0: return [4 /*yield*/, this.lrApollo.query({
7911
+ query: GetVaultsQuery,
7912
+ variables: {
7913
+ plainMetaFilter: DefaultVaultFilter,
7914
+ },
7915
+ })];
7916
+ case 1:
7917
+ list = (_b.sent()).list;
7918
+ return [4 /*yield*/, this.mapVaults(list)];
7919
+ case 2:
7920
+ defaultVaults = _b.sent();
7921
+ if (defaultVaults.length > 1) {
7922
+ throw new KcBadStateException('There are more than one default vaults');
7923
+ }
7924
+ return [2 /*return*/, defaultVaults[0] || null];
7925
+ }
7926
+ });
7927
+ });
7928
+ };
7929
+ CategoryService.prototype.getCategories = function (input) {
7930
+ var _a;
7931
+ return __awaiter(this, void 0, void 0, function () {
7932
+ var vaultDirectoryId, _b, res;
7933
+ return __generator(this, function (_c) {
7934
+ switch (_c.label) {
7935
+ case 0:
7936
+ _b = (input === null || input === void 0 ? void 0 : input.vaultDirectoryId);
7937
+ if (_b) return [3 /*break*/, 2];
7938
+ return [4 /*yield*/, this.getDefaultVault()];
7939
+ case 1:
7940
+ _b = ((_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.id);
7941
+ _c.label = 2;
7942
+ case 2:
7943
+ vaultDirectoryId = _b;
7944
+ if (!vaultDirectoryId) {
7945
+ console.error('There is no default vault.');
7946
+ return [2 /*return*/, []];
7947
+ }
7948
+ return [4 /*yield*/, this.lrApollo.query({
7949
+ query: GetCategoriesQuery,
7950
+ variables: {
7951
+ vaultDirectoryId: vaultDirectoryId,
7952
+ categoryFilter: CategoryFilter,
7953
+ recordFilter: RecordFilter,
7954
+ archived: input === null || input === void 0 ? void 0 : input.archived,
7955
+ },
7956
+ })];
7957
+ case 3:
7958
+ res = _c.sent();
7959
+ return [2 /*return*/, this.mapCategories(res.directory.childDirectoryLinks)];
7960
+ }
7961
+ });
7962
+ });
7963
+ };
7964
+ CategoryService.prototype.getTrustedPartyCategories = function (trustedPartyId) {
7965
+ return __awaiter(this, void 0, void 0, function () {
7966
+ var tp, _b;
7967
+ return __generator(this, function (_c) {
7968
+ switch (_c.label) {
7969
+ case 0: return [4 /*yield*/, this.lrApollo.query({
7970
+ query: GetTrustedPartyCategoriesQuery,
7971
+ variables: {
7972
+ trustedPartyId: trustedPartyId,
7973
+ categoryFilter: CategoryFilter,
7974
+ recordFilter: RecordFilter,
7975
+ contentFilter: RecordContentFilter,
7121
7976
  },
7122
7977
  })];
7123
7978
  case 1:
@@ -7705,14 +8560,14 @@
7705
8560
  };
7706
8561
  return CategoryMetaService;
7707
8562
  }());
7708
- CategoryMetaService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CategoryMetaService_Factory() { return new CategoryMetaService(i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(CategoryService)); }, token: CategoryMetaService, providedIn: "root" });
8563
+ CategoryMetaService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CategoryMetaService_Factory() { return new CategoryMetaService(i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(CategoryService)); }, token: CategoryMetaService, providedIn: "root" });
7709
8564
  CategoryMetaService.decorators = [
7710
8565
  { type: i0.Injectable, args: [{
7711
8566
  providedIn: 'root',
7712
8567
  },] }
7713
8568
  ];
7714
8569
  CategoryMetaService.ctorParameters = function () { return [
7715
- { type: i2$1.HttpClient },
8570
+ { type: i2$2.HttpClient },
7716
8571
  { type: CategoryService }
7717
8572
  ]; };
7718
8573
 
@@ -7776,10 +8631,10 @@
7776
8631
  return Vault;
7777
8632
  }());
7778
8633
 
7779
- var CreateContactCardMutation$2 = gqlTyped(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"], ["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"])));
7780
- var UpdateContactCardMutation$2 = gqlTyped(templateObject_2$b || (templateObject_2$b = __makeTemplateObject(["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"], ["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"])));
8634
+ var CreateContactCardMutation$2 = gqlTyped(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"], ["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"])));
8635
+ var UpdateContactCardMutation$2 = gqlTyped(templateObject_2$c || (templateObject_2$c = __makeTemplateObject(["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"], ["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"])));
7781
8636
  var DeleteContactCardMutation$1 = gqlTyped(templateObject_3$9 || (templateObject_3$9 = __makeTemplateObject(["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"])));
7782
- var templateObject_1$e, templateObject_2$b, templateObject_3$9;
8637
+ var templateObject_1$f, templateObject_2$c, templateObject_3$9;
7783
8638
 
7784
8639
  var OwnerPlainDataJson = /** @class */ (function () {
7785
8640
  function OwnerPlainDataJson() {
@@ -7800,20 +8655,19 @@
7800
8655
  var rootKey, key, wrappedKey, cipherData, params;
7801
8656
  return __generator(this, function (_a) {
7802
8657
  switch (_a.label) {
7803
- case 0: return [4 /*yield*/, this.keyService.getCurrentRootKey()];
7804
- case 1:
7805
- rootKey = _a.sent();
8658
+ case 0:
8659
+ rootKey = this.keyService.currentRootKey;
7806
8660
  return [4 /*yield*/, this.keyFactory.createKey()];
7807
- case 2:
8661
+ case 1:
7808
8662
  key = _a.sent();
7809
8663
  return [4 /*yield*/, this.keyGraph.encryptToString(rootKey.jwk, key.toJSON(true))];
7810
- case 3:
8664
+ case 2:
7811
8665
  wrappedKey = _a.sent();
7812
8666
  return [4 /*yield*/, this.keyGraph.encryptToString(key, input.plainCipherDataJson)];
7813
- case 4:
8667
+ case 3:
7814
8668
  cipherData = _a.sent();
7815
8669
  return [4 /*yield*/, this.prepareContactCardInput(input)];
7816
- case 5:
8670
+ case 4:
7817
8671
  params = _a.sent();
7818
8672
  return [2 /*return*/, new LrMutation({
7819
8673
  mutation: CreateContactCardMutation$2,
@@ -7862,20 +8716,19 @@
7862
8716
  var sigPxk, publicDataSig, _a, _b, publicSearchableSig, _c, _d, plainDataSig, _e, _f;
7863
8717
  return __generator(this, function (_g) {
7864
8718
  switch (_g.label) {
7865
- case 0: return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
7866
- case 1:
7867
- sigPxk = _g.sent();
8719
+ case 0:
8720
+ sigPxk = this.keyService.currentSigPxk;
7868
8721
  _b = (_a = JSON).stringify;
7869
8722
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, input.publicDataJson)];
7870
- case 2:
8723
+ case 1:
7871
8724
  publicDataSig = _b.apply(_a, [_g.sent()]);
7872
8725
  _d = (_c = JSON).stringify;
7873
8726
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, input.publicSearchableJson)];
7874
- case 3:
8727
+ case 2:
7875
8728
  publicSearchableSig = _d.apply(_c, [_g.sent()]);
7876
8729
  _f = (_e = JSON).stringify;
7877
8730
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, input.plainDataJson)];
7878
- case 4:
8731
+ case 3:
7879
8732
  plainDataSig = _f.apply(_e, [_g.sent()]);
7880
8733
  return [2 /*return*/, {
7881
8734
  sigPxkId: sigPxk.id,
@@ -7989,7 +8842,7 @@
7989
8842
  };
7990
8843
  return FileUploadService;
7991
8844
  }());
7992
- FileUploadService.ɵprov = i0.ɵɵdefineInjectable({ factory: function FileUploadService_Factory() { return new FileUploadService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(i4.AuthClass)); }, token: FileUploadService, providedIn: "root" });
8845
+ FileUploadService.ɵprov = i0.ɵɵdefineInjectable({ factory: function FileUploadService_Factory() { return new FileUploadService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(i2.AuthClass)); }, token: FileUploadService, providedIn: "root" });
7993
8846
  FileUploadService.decorators = [
7994
8847
  { type: i0.Injectable, args: [{
7995
8848
  providedIn: 'root',
@@ -7997,15 +8850,15 @@
7997
8850
  ];
7998
8851
  FileUploadService.ctorParameters = function () { return [
7999
8852
  { type: undefined, decorators: [{ type: i0.Inject, args: [KC_CONFIG,] }] },
8000
- { type: i2$1.HttpClient },
8001
- { type: i4.AuthClass }
8853
+ { type: i2$2.HttpClient },
8854
+ { type: i2.AuthClass }
8002
8855
  ]; };
8003
8856
 
8004
- var LockFragment = gqlTyped(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"], ["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"])));
8005
- var UpdateLockMutation = gqlTyped(templateObject_2$c || (templateObject_2$c = __makeTemplateObject(["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"], ["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"])), LockFragment);
8857
+ var LockFragment = gqlTyped(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"], ["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"])));
8858
+ var UpdateLockMutation = gqlTyped(templateObject_2$d || (templateObject_2$d = __makeTemplateObject(["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"], ["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"])), LockFragment);
8006
8859
  var AcquireLockMutation = gqlTyped(templateObject_3$a || (templateObject_3$a = __makeTemplateObject(["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"], ["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"])), LockFragment);
8007
8860
  var ReleaseLockMutation = gqlTyped(templateObject_4$7 || (templateObject_4$7 = __makeTemplateObject(["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"], ["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n", "\n"])), LockFragment);
8008
- var templateObject_1$f, templateObject_2$c, templateObject_3$a, templateObject_4$7;
8861
+ var templateObject_1$g, templateObject_2$d, templateObject_3$a, templateObject_4$7;
8009
8862
 
8010
8863
  exports.LockService = /** @class */ (function (_super) {
8011
8864
  __extends(LockService, _super);
@@ -8067,8 +8920,8 @@
8067
8920
  })
8068
8921
  ], exports.LockService);
8069
8922
 
8070
- var CreateDirectoryMutation = gqlTyped(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"], ["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"])));
8071
- var UpdateDirectoryMutation = gqlTyped(templateObject_2$d || (templateObject_2$d = __makeTemplateObject(["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"], ["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"])));
8923
+ var CreateDirectoryMutation = gqlTyped(templateObject_1$h || (templateObject_1$h = __makeTemplateObject(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"], ["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"])));
8924
+ var UpdateDirectoryMutation = gqlTyped(templateObject_2$e || (templateObject_2$e = __makeTemplateObject(["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"], ["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"])));
8072
8925
  var DeleteDirectoryMutation = gqlTyped(templateObject_3$b || (templateObject_3$b = __makeTemplateObject(["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"])));
8073
8926
  var CreateFileMutation$1 = gqlTyped(templateObject_4$8 || (templateObject_4$8 = __makeTemplateObject(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"], ["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"])));
8074
8927
  var UpdateFileMutation = gqlTyped(templateObject_5$7 || (templateObject_5$7 = __makeTemplateObject(["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"], ["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"])));
@@ -8084,17 +8937,17 @@
8084
8937
  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"])));
8085
8938
  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"])));
8086
8939
  var SetDirectoryConfidentialMutation = gqlTyped(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"], ["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"])));
8087
- var templateObject_1$g, templateObject_2$d, templateObject_3$b, templateObject_4$8, templateObject_5$7, templateObject_6$6, templateObject_7$5, templateObject_8$5, templateObject_9$3, templateObject_10$2, templateObject_11$1, templateObject_12$1, templateObject_13$1, templateObject_14, templateObject_15, templateObject_16, templateObject_17;
8940
+ var templateObject_1$h, templateObject_2$e, templateObject_3$b, templateObject_4$8, templateObject_5$7, templateObject_6$6, templateObject_7$5, templateObject_8$5, templateObject_9$3, templateObject_10$2, templateObject_11$1, templateObject_12$1, templateObject_13$1, templateObject_14, templateObject_15, templateObject_16, templateObject_17;
8088
8941
 
8089
- var DirectoryKeyQuery = gqlTyped(templateObject_1$h || (templateObject_1$h = __makeTemplateObject(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"], ["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"])));
8090
- var FileKeyQuery = gqlTyped(templateObject_2$e || (templateObject_2$e = __makeTemplateObject(["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"], ["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"])));
8942
+ var DirectoryKeyQuery = gqlTyped(templateObject_1$i || (templateObject_1$i = __makeTemplateObject(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"], ["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"])));
8943
+ var FileKeyQuery = gqlTyped(templateObject_2$f || (templateObject_2$f = __makeTemplateObject(["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"], ["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"])));
8091
8944
  var FileStateKeyQuery = gqlTyped(templateObject_3$c || (templateObject_3$c = __makeTemplateObject(["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"], ["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"])));
8092
- var templateObject_1$h, templateObject_2$e, templateObject_3$c;
8945
+ var templateObject_1$i, templateObject_2$f, templateObject_3$c;
8093
8946
 
8094
8947
  var Item2Service_1;
8095
8948
  exports.Item2Service = Item2Service_1 = /** @class */ (function (_super) {
8096
8949
  __extends(Item2Service, _super);
8097
- function Item2Service(ngZone, injector, fileUploadService, keyService, keyFactory, keyGraph, lockService, authService) {
8950
+ function Item2Service(ngZone, injector, fileUploadService, keyService, keyFactory, keyGraph, lockService, auth2Service) {
8098
8951
  var _this = _super.call(this, injector) || this;
8099
8952
  _this.ngZone = ngZone;
8100
8953
  _this.injector = injector;
@@ -8103,10 +8956,10 @@
8103
8956
  _this.keyFactory = keyFactory;
8104
8957
  _this.keyGraph = keyGraph;
8105
8958
  _this.lockService = lockService;
8106
- _this.authService = authService;
8959
+ _this.auth2Service = auth2Service;
8107
8960
  // Caching the temp directory.
8108
8961
  _this.tempDirectory = null;
8109
- _this.authService.addLogoutListener(function () { return _this.onLogout(); });
8962
+ _this.auth2Service.addLogoutListener(function () { return _this.onLogout(); });
8110
8963
  return _this;
8111
8964
  }
8112
8965
  Item2Service.prototype.downloadFileContent = function (options) {
@@ -8792,7 +9645,7 @@
8792
9645
  case 2:
8793
9646
  parentDirectories = _e.sent();
8794
9647
  if (!options.asRootDirectory) return [3 /*break*/, 4];
8795
- rootKey = this.keyService.getCurrentRootKey();
9648
+ rootKey = this.keyService.currentRootKey;
8796
9649
  _d = {
8797
9650
  wrappingKeyId: rootKey.id
8798
9651
  };
@@ -8895,147 +9748,69 @@
8895
9748
  });
8896
9749
  };
8897
9750
  Item2Service.prototype.prepareChangeFileParents = function (options) {
8898
- return __awaiter(this, void 0, void 0, function () {
8899
- var fileKey, input;
8900
- return __generator(this, function (_d) {
8901
- switch (_d.label) {
8902
- case 0: return [4 /*yield*/, this.getFileKey(options.fileId, options.fileKeyId)];
8903
- case 1:
8904
- fileKey = _d.sent();
8905
- return [4 /*yield*/, this.prepareChangeItemParents(options, fileKey.jwk)];
8906
- case 2:
8907
- input = _d.sent();
8908
- return [2 /*return*/, Object.assign(Object.assign({}, input), { fileId: options.fileId })];
8909
- }
8910
- });
8911
- });
8912
- };
8913
- Item2Service.prototype.onLogout = function () {
8914
- // Clear all cached data.
8915
- this.tempDirectory = null;
8916
- };
8917
- return Item2Service;
8918
- }(LrService));
8919
- exports.Item2Service.TEMP_DIRECTORY_PLAIN_META = { kcType: 'temp' };
8920
- exports.Item2Service.TEMP_DIRECTORY_PLAIN_META_FILTER = JSON.stringify({
8921
- filter: [
8922
- {
8923
- contains: Item2Service_1.TEMP_DIRECTORY_PLAIN_META,
8924
- },
8925
- ],
8926
- });
8927
- exports.Item2Service.ɵprov = i0.ɵɵdefineInjectable({ factory: function Item2Service_Factory() { return new exports.Item2Service(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(FileUploadService), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(exports.LockService), i0.ɵɵinject(LifeReadyAuthService)); }, token: exports.Item2Service, providedIn: "root" });
8928
- exports.Item2Service.decorators = [
8929
- { type: i0.Injectable, args: [{
8930
- providedIn: 'root',
8931
- },] }
8932
- ];
8933
- exports.Item2Service.ctorParameters = function () { return [
8934
- { type: i0.NgZone },
8935
- { type: i0.Injector },
8936
- { type: FileUploadService },
8937
- { type: KeyService },
8938
- { type: KeyFactoryService },
8939
- { type: KeyGraphService },
8940
- { type: exports.LockService },
8941
- { type: LifeReadyAuthService }
8942
- ]; };
8943
- exports.Item2Service = Item2Service_1 = __decorate([
8944
- RunOutsideAngular({
8945
- ngZoneName: 'ngZone',
8946
- })
8947
- ], exports.Item2Service);
8948
-
8949
- var KeyExchangeFields = "\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n}";
8950
- var UserSharedKeyFields = "\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n pbk\n }\n mkReshareRequestCipher\n mkReshareResponseCipher\n mkReshareRequestSent\n mkReshareResponseSent\n";
8951
- var CurrentUserSharedKeyQuery = gql__default['default'](templateObject_1$i || (templateObject_1$i = __makeTemplateObject(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ", "\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", ""], ["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ", "\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", ""])), UserSharedKeyFields, KeyGraphFragment);
8952
- var KeyExchangesQuery = gql__default['default'](templateObject_2$f || (templateObject_2$f = __makeTemplateObject(["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ", "\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n", "\n"], ["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ", "\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n", "\n"])), KeyExchangeFields, KeyGraphFragment);
8953
- var KeyExchangeQuery = gql__default['default'](templateObject_3$d || (templateObject_3$d = __makeTemplateObject(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ", "\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n", "\n"], ["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ", "\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n", "\n"])), KeyExchangeFields, KeyGraphFragment);
8954
- // Key graph is only available for authenticated users. This query
8955
- // is for unauthenticated users.
8956
- var KeyExchangeTokenQuery = gql__default['default'](templateObject_4$9 || (templateObject_4$9 = __makeTemplateObject(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ", "\n }\n}"], ["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ", "\n }\n}"])), KeyExchangeFields);
8957
- var InitiateOtkMutation = gql__default['default'](templateObject_5$8 || (templateObject_5$8 = __makeTemplateObject(["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n}\n", "\n}"], ["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n}\n", "\n}"])), KeyExchangeFields, FetchKeyGraphField);
8958
- var RespondOtkMutation = gql__default['default'](templateObject_6$7 || (templateObject_6$7 = __makeTemplateObject(["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"], ["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"])), KeyExchangeFields, UserSharedKeyFields);
8959
- var CompleteOtkMutation = gql__default['default'](templateObject_7$6 || (templateObject_7$6 = __makeTemplateObject(["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"], ["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"])), KeyExchangeFields, UserSharedKeyFields);
8960
- var templateObject_1$i, templateObject_2$f, templateObject_3$d, templateObject_4$9, templateObject_5$8, templateObject_6$7, templateObject_7$6;
8961
-
8962
- var RequestUserDeleteMutation = gql__default['default'](templateObject_1$j || (templateObject_1$j = __makeTemplateObject(["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"], ["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"])));
8963
- var CancelUserDeleteMutation = gql__default['default'](templateObject_2$g || (templateObject_2$g = __makeTemplateObject(["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"], ["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"])));
8964
- var LoginHistoryQuery = gql__default['default'](templateObject_3$e || (templateObject_3$e = __makeTemplateObject(["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"], ["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"])));
8965
- var templateObject_1$j, templateObject_2$g, templateObject_3$e;
8966
-
8967
- var UserService = /** @class */ (function () {
8968
- function UserService(lrApollo) {
8969
- this.lrApollo = lrApollo;
8970
- }
8971
- UserService.prototype.requestUserDelete = function () {
8972
- return __awaiter(this, void 0, void 0, function () {
8973
- var res;
8974
- return __generator(this, function (_a) {
8975
- switch (_a.label) {
8976
- case 0: return [4 /*yield*/, this.lrApollo.mutate({
8977
- mutation: RequestUserDeleteMutation,
8978
- variables: {
8979
- input: {},
8980
- },
8981
- })];
8982
- case 1:
8983
- res = _a.sent();
8984
- return [2 /*return*/, res.requestUserDelete.userDelete];
8985
- }
8986
- });
8987
- });
8988
- };
8989
- UserService.prototype.cancelUserDelete = function () {
8990
- return __awaiter(this, void 0, void 0, function () {
8991
- var res;
8992
- return __generator(this, function (_a) {
8993
- switch (_a.label) {
8994
- case 0: return [4 /*yield*/, this.lrApollo.mutate({
8995
- mutation: CancelUserDeleteMutation,
8996
- variables: {
8997
- input: {},
8998
- },
8999
- })];
9000
- case 1:
9001
- res = _a.sent();
9002
- return [2 /*return*/, res.cancelUserDelete.id];
9003
- }
9004
- });
9005
- });
9006
- };
9007
- UserService.prototype.loginHistory = function (first, after) {
9008
- if (first === void 0) { first = null; }
9009
- if (after === void 0) { after = null; }
9010
- return __awaiter(this, void 0, void 0, function () {
9011
- var res;
9012
- return __generator(this, function (_a) {
9013
- switch (_a.label) {
9014
- case 0: return [4 /*yield*/, this.lrApollo.query({
9015
- query: LoginHistoryQuery,
9016
- variables: {
9017
- first: first,
9018
- after: after,
9019
- },
9020
- })];
9751
+ return __awaiter(this, void 0, void 0, function () {
9752
+ var fileKey, input;
9753
+ return __generator(this, function (_d) {
9754
+ switch (_d.label) {
9755
+ case 0: return [4 /*yield*/, this.getFileKey(options.fileId, options.fileKeyId)];
9021
9756
  case 1:
9022
- res = _a.sent();
9023
- return [2 /*return*/, res.loginHistory];
9757
+ fileKey = _d.sent();
9758
+ return [4 /*yield*/, this.prepareChangeItemParents(options, fileKey.jwk)];
9759
+ case 2:
9760
+ input = _d.sent();
9761
+ return [2 /*return*/, Object.assign(Object.assign({}, input), { fileId: options.fileId })];
9024
9762
  }
9025
9763
  });
9026
9764
  });
9027
9765
  };
9028
- return UserService;
9029
- }());
9030
- UserService.ɵprov = i0.ɵɵdefineInjectable({ factory: function UserService_Factory() { return new UserService(i0.ɵɵinject(LrApolloService)); }, token: UserService, providedIn: "root" });
9031
- UserService.decorators = [
9766
+ Item2Service.prototype.onLogout = function () {
9767
+ // Clear all cached data.
9768
+ this.tempDirectory = null;
9769
+ };
9770
+ return Item2Service;
9771
+ }(LrService));
9772
+ exports.Item2Service.TEMP_DIRECTORY_PLAIN_META = { kcType: 'temp' };
9773
+ exports.Item2Service.TEMP_DIRECTORY_PLAIN_META_FILTER = JSON.stringify({
9774
+ filter: [
9775
+ {
9776
+ contains: Item2Service_1.TEMP_DIRECTORY_PLAIN_META,
9777
+ },
9778
+ ],
9779
+ });
9780
+ exports.Item2Service.ɵprov = i0.ɵɵdefineInjectable({ factory: function Item2Service_Factory() { return new exports.Item2Service(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(FileUploadService), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(exports.LockService), i0.ɵɵinject(exports.Auth2Service)); }, token: exports.Item2Service, providedIn: "root" });
9781
+ exports.Item2Service.decorators = [
9032
9782
  { type: i0.Injectable, args: [{
9033
9783
  providedIn: 'root',
9034
9784
  },] }
9035
9785
  ];
9036
- UserService.ctorParameters = function () { return [
9037
- { type: LrApolloService }
9786
+ exports.Item2Service.ctorParameters = function () { return [
9787
+ { type: i0.NgZone },
9788
+ { type: i0.Injector },
9789
+ { type: FileUploadService },
9790
+ { type: KeyService },
9791
+ { type: KeyFactoryService },
9792
+ { type: KeyGraphService },
9793
+ { type: exports.LockService },
9794
+ { type: exports.Auth2Service }
9038
9795
  ]; };
9796
+ exports.Item2Service = Item2Service_1 = __decorate([
9797
+ RunOutsideAngular({
9798
+ ngZoneName: 'ngZone',
9799
+ })
9800
+ ], exports.Item2Service);
9801
+
9802
+ var KeyExchangeFields = "\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n}";
9803
+ var UserSharedKeyFields = "\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n pbk\n }\n mkReshareRequestCipher\n mkReshareResponseCipher\n mkReshareRequestSent\n mkReshareResponseSent\n";
9804
+ var CurrentUserSharedKeyQuery = gql__default['default'](templateObject_1$j || (templateObject_1$j = __makeTemplateObject(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ", "\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", ""], ["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ", "\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n", ""])), UserSharedKeyFields, KeyGraphFragment);
9805
+ var KeyExchangesQuery = gql__default['default'](templateObject_2$g || (templateObject_2$g = __makeTemplateObject(["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ", "\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n", "\n"], ["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ", "\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n", "\n"])), KeyExchangeFields, KeyGraphFragment);
9806
+ var KeyExchangeQuery = gql__default['default'](templateObject_3$d || (templateObject_3$d = __makeTemplateObject(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ", "\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n", "\n"], ["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ", "\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n", "\n"])), KeyExchangeFields, KeyGraphFragment);
9807
+ // Key graph is only available for authenticated users. This query
9808
+ // is for unauthenticated users.
9809
+ var KeyExchangeTokenQuery = gql__default['default'](templateObject_4$9 || (templateObject_4$9 = __makeTemplateObject(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ", "\n }\n}"], ["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ", "\n }\n}"])), KeyExchangeFields);
9810
+ var InitiateOtkMutation = gql__default['default'](templateObject_5$8 || (templateObject_5$8 = __makeTemplateObject(["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n}\n", "\n}"], ["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n}\n", "\n}"])), KeyExchangeFields, FetchKeyGraphField);
9811
+ var RespondOtkMutation = gql__default['default'](templateObject_6$7 || (templateObject_6$7 = __makeTemplateObject(["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"], ["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"])), KeyExchangeFields, UserSharedKeyFields);
9812
+ var CompleteOtkMutation = gql__default['default'](templateObject_7$6 || (templateObject_7$6 = __makeTemplateObject(["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"], ["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ", "\n }\n userSharedKey {\n ", "\n }\n tp {\n id\n }\n }\n}"])), KeyExchangeFields, UserSharedKeyFields);
9813
+ var templateObject_1$j, templateObject_2$g, templateObject_3$d, templateObject_4$9, templateObject_5$8, templateObject_6$7, templateObject_7$6;
9039
9814
 
9040
9815
  (function (OtkState) {
9041
9816
  OtkState["OTK_INITIATED"] = "OTK_INITIATED";
@@ -9044,13 +9819,12 @@
9044
9819
  })(exports.OtkState || (exports.OtkState = {}));
9045
9820
 
9046
9821
  var KeyExchangeService = /** @class */ (function () {
9047
- function KeyExchangeService(keyFactory, keyService, lrApollo, encryptionService, authService, userService) {
9822
+ function KeyExchangeService(keyFactory, keyService, lrApollo, encryptionService, auth2Service) {
9048
9823
  this.keyFactory = keyFactory;
9049
9824
  this.keyService = keyService;
9050
9825
  this.lrApollo = lrApollo;
9051
9826
  this.encryptionService = encryptionService;
9052
- this.authService = authService;
9053
- this.userService = userService;
9827
+ this.auth2Service = auth2Service;
9054
9828
  this.CLIENT_NONCE_LENGTH = 32;
9055
9829
  }
9056
9830
  KeyExchangeService.prototype.getKeyExchangeList = function (input) {
@@ -9128,28 +9902,26 @@
9128
9902
  return __generator(this, function (_d) {
9129
9903
  switch (_d.label) {
9130
9904
  case 0:
9131
- if (!keyExchange.isInitiator) return [3 /*break*/, 8];
9132
- return [4 /*yield*/, this.keyService.getCurrentRootKey()];
9133
- case 1:
9134
- rootKey = _d.sent();
9905
+ if (!keyExchange.isInitiator) return [3 /*break*/, 7];
9906
+ rootKey = this.keyService.currentRootKey;
9135
9907
  return [4 /*yield*/, this.encryptionService.decrypt(rootKey.jwk, keyExchange.initiatorRootKeyCipher)];
9136
- case 2:
9908
+ case 1:
9137
9909
  plainInitiatorRootKeyCipher = (_d.sent());
9138
9910
  if (!keyExchange.otk
9139
- .initiatorOneTimePbkCipher) return [3 /*break*/, 6];
9911
+ .initiatorOneTimePbkCipher) return [3 /*break*/, 5];
9140
9912
  _b = this.decryptResponseCipher;
9141
9913
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorRootKeyCipher.otKey)];
9142
- case 3:
9914
+ case 2:
9143
9915
  _c = [_d.sent()];
9144
9916
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorRootKeyCipher.oneTimePrk)];
9145
- case 4: return [4 /*yield*/, _b.apply(this, _c.concat([_d.sent(), keyExchange.otk.initiatorOneTimePbkCipher]))];
9146
- case 5:
9917
+ case 3: return [4 /*yield*/, _b.apply(this, _c.concat([_d.sent(), keyExchange.otk.initiatorOneTimePbkCipher]))];
9918
+ case 4:
9147
9919
  _a = _d.sent();
9148
- return [3 /*break*/, 7];
9149
- case 6:
9920
+ return [3 /*break*/, 6];
9921
+ case 5:
9150
9922
  _a = null;
9151
- _d.label = 7;
9152
- case 7:
9923
+ _d.label = 6;
9924
+ case 6:
9153
9925
  plainInitiatorOneTimePbkCipher = _a;
9154
9926
  responder = plainInitiatorOneTimePbkCipher &&
9155
9927
  plainInitiatorOneTimePbkCipher.responder;
@@ -9159,8 +9931,8 @@
9159
9931
  : null, myContactCard: initiator && initiator.contactCard
9160
9932
  ? initiator.contactCard.plainSharedCipherDataJson
9161
9933
  : null, myMessage: initiator && initiator.message })];
9162
- case 8: return [4 /*yield*/, this.decryptOtk(keyExchange, otKeyK)];
9163
- case 9:
9934
+ case 7: return [4 /*yield*/, this.decryptOtk(keyExchange, otKeyK)];
9935
+ case 8:
9164
9936
  decryptedOtk = _d.sent();
9165
9937
  initiator = decryptedOtk && decryptedOtk.plainOtKeyCipher.initiator;
9166
9938
  return [2 /*return*/, Object.assign(Object.assign({}, keyExchange), { decryptedOtk: decryptedOtk, message: initiator && initiator.message, contactCard: initiator &&
@@ -9206,19 +9978,17 @@
9206
9978
  case 2:
9207
9979
  if (!(keyExchange.otk.state === exports.OtkState.OTK_INITIATED &&
9208
9980
  !keyExchange.isInitiator &&
9209
- keyExchange.otk.responderPbkCipher)) return [3 /*break*/, 6];
9210
- return [4 /*yield*/, this.keyService.getCurrentPxk()];
9211
- case 3:
9212
- prk = _a.sent();
9981
+ keyExchange.otk.responderPbkCipher)) return [3 /*break*/, 5];
9982
+ prk = this.keyService.currentPxk;
9213
9983
  return [4 /*yield*/, this.encryptionService.decrypt(prk.jwk, JSON.parse(keyExchange.otk.responderPbkCipher), {
9214
9984
  serializations: [JoseSerialization.COMPACT],
9215
9985
  })];
9216
- case 4:
9986
+ case 3:
9217
9987
  decryptedCipher = _a.sent();
9218
- if (!decryptedCipher.otKey) return [3 /*break*/, 6];
9988
+ if (!decryptedCipher.otKey) return [3 /*break*/, 5];
9219
9989
  return [4 /*yield*/, KeyFactoryService.asKey(decryptedCipher.otKey)];
9220
- case 5: return [2 /*return*/, _a.sent()];
9221
- case 6: return [2 /*return*/, null];
9990
+ case 4: return [2 /*return*/, _a.sent()];
9991
+ case 5: return [2 /*return*/, null];
9222
9992
  }
9223
9993
  });
9224
9994
  });
@@ -9233,26 +10003,22 @@
9233
10003
  case 1:
9234
10004
  otKey = _c.sent();
9235
10005
  nonce = this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH);
9236
- return [4 /*yield*/, this.authService.getUser()];
10006
+ return [4 /*yield*/, this.auth2Service.getUser()];
9237
10007
  case 2:
9238
10008
  user = _c.sent();
9239
10009
  return [4 /*yield*/, this.keyFactory.createPkcKey()];
9240
10010
  case 3:
9241
10011
  initiatorOneTimePrk = _c.sent();
9242
- return [4 /*yield*/, this.keyService.getCurrentPxk()];
9243
- case 4:
9244
- initiatorPrk = _c.sent();
9245
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
9246
- case 5:
9247
- initiatorSigPrk = _c.sent();
10012
+ initiatorPrk = this.keyService.currentPxk;
10013
+ initiatorSigPrk = this.keyService.currentSigPxk;
9248
10014
  initiatorPlainDataSig = null;
9249
- if (!(contactCard && contactCard.ownerPlainData)) return [3 /*break*/, 7];
10015
+ if (!(contactCard && contactCard.ownerPlainData)) return [3 /*break*/, 5];
9250
10016
  _b = (_a = JSON).stringify;
9251
10017
  return [4 /*yield*/, this.encryptionService.sign(initiatorSigPrk.jwk, contactCard.ownerPlainData)];
9252
- case 6:
10018
+ case 4:
9253
10019
  initiatorPlainDataSig = _b.apply(_a, [_c.sent()]);
9254
- _c.label = 7;
9255
- case 7:
10020
+ _c.label = 5;
10021
+ case 5:
9256
10022
  initiator = {
9257
10023
  message: message,
9258
10024
  contactCard: contactCard
@@ -9268,7 +10034,7 @@
9268
10034
  } }),
9269
10035
  };
9270
10036
  return [4 /*yield*/, this.encryptionService.encrypt(otKey, plainOtKeyCipher)];
9271
- case 8:
10037
+ case 6:
9272
10038
  otKeyCipher = _c.sent();
9273
10039
  plainInitiatorRootKeyCipher = {
9274
10040
  nonce: nonce,
@@ -9284,11 +10050,9 @@
9284
10050
  initiatorContactCard: contactCard,
9285
10051
  initiator: initiator,
9286
10052
  };
9287
- return [4 /*yield*/, this.keyService.getCurrentRootKey()];
9288
- case 9:
9289
- rootKey = _c.sent();
10053
+ rootKey = this.keyService.currentRootKey;
9290
10054
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, plainInitiatorRootKeyCipher)];
9291
- case 10:
10055
+ case 7:
9292
10056
  initiatorRootKeyCipher = _c.sent();
9293
10057
  otKeyK = otKey.toJSON(true).k;
9294
10058
  return [4 /*yield*/, this.lrApollo.mutate({
@@ -9314,7 +10078,7 @@
9314
10078
  },
9315
10079
  },
9316
10080
  })];
9317
- case 11:
10081
+ case 8:
9318
10082
  initiateKeyExchangeOtk = (_c.sent()).initiateKeyExchangeOtk;
9319
10083
  return [2 /*return*/, { keyExchange: initiateKeyExchangeOtk.keyExchange, otKeyK: otKeyK }];
9320
10084
  }
@@ -9324,51 +10088,42 @@
9324
10088
  KeyExchangeService.prototype.respondOtk = function (_a) {
9325
10089
  var id = _a.id, token = _a.token, decryptedOtk = _a.decryptedOtk, message = _a.message, initiatorContactCard = _a.initiatorContactCard, sentContactCard = _a.responderContactCard;
9326
10090
  return __awaiter(this, void 0, void 0, function () {
9327
- var user, rootKey, masterKeyId, masterKey, sharedKey, mkSharedKey, rkWrappedSharedKey, mkWrappedMkSharedKey, initiatorOneTimePbk, initiatorPbk, initiatorSigPbk, responderPrk, responderSigPrk, signedInitiatorPbk, signedInitiatorSigPbk, plainInitiatorOneTimePbkCipher, receivedCardInput, plainSharedCipherDataJson, receiverKey, ccSharedKey, sigPxk, _a, _b, _c, _d, _e, _f, _g, _h, sharedCipherData, _j, _k, _l, sentCardInput, ownerKey, ccSharedKey, sigPxk, _m, _o, _p, _q, _r, _s, _t, _u, sharedCipherData, _v, _w, _x, _y, _z, _0, initiatorOneTimePbkCipher, respondKeyExchangeOtk;
10091
+ var user, rootKey, masterKey, sharedKey, mkSharedKey, rkWrappedSharedKey, mkWrappedMkSharedKey, initiatorOneTimePbk, initiatorPbk, initiatorSigPbk, responderPrk, responderSigPrk, signedInitiatorPbk, signedInitiatorSigPbk, plainInitiatorOneTimePbkCipher, receivedCardInput, plainSharedCipherDataJson, receiverKey, ccSharedKey, sigPxk, _a, _b, _c, _d, _e, _f, _g, _h, sharedCipherData, _j, _k, _l, sentCardInput, ownerKey, ccSharedKey, sigPxk, _m, _o, _p, _q, _r, _s, _t, _u, sharedCipherData, _v, _w, _x, _y, _z, _0, initiatorOneTimePbkCipher, respondKeyExchangeOtk;
9328
10092
  return __generator(this, function (_1) {
9329
10093
  switch (_1.label) {
9330
- case 0: return [4 /*yield*/, this.authService.getUser()];
10094
+ case 0: return [4 /*yield*/, this.auth2Service.getUser()];
9331
10095
  case 1:
9332
10096
  user = _1.sent();
9333
- return [4 /*yield*/, this.keyService.getCurrentRootKey()];
9334
- case 2:
9335
- rootKey = _1.sent();
9336
- masterKeyId = this.keyService.getCurrentMasterKey().id;
9337
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
9338
- case 3:
9339
- masterKey = _1.sent();
10097
+ rootKey = this.keyService.currentRootKey;
10098
+ masterKey = this.keyService.currentMasterKey;
9340
10099
  return [4 /*yield*/, this.keyFactory.createKey()];
9341
- case 4:
10100
+ case 2:
9342
10101
  sharedKey = _1.sent();
9343
10102
  return [4 /*yield*/, this.keyFactory.createKey()];
9344
- case 5:
10103
+ case 3:
9345
10104
  mkSharedKey = _1.sent();
9346
10105
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, sharedKey.toJSON(true))];
9347
- case 6:
10106
+ case 4:
9348
10107
  rkWrappedSharedKey = _1.sent();
9349
10108
  return [4 /*yield*/, this.encryptionService.encrypt(masterKey.jwk, mkSharedKey.toJSON(true))];
9350
- case 7:
10109
+ case 5:
9351
10110
  mkWrappedMkSharedKey = _1.sent();
9352
10111
  return [4 /*yield*/, KeyFactoryService.asKey(decryptedOtk.plainOtKeyCipher.initiator.oneTimePbk)];
9353
- case 8:
10112
+ case 6:
9354
10113
  initiatorOneTimePbk = _1.sent();
9355
10114
  return [4 /*yield*/, KeyFactoryService.asKey(decryptedOtk.plainOtKeyCipher.initiator.pbk)];
9356
- case 9:
10115
+ case 7:
9357
10116
  initiatorPbk = _1.sent();
9358
10117
  return [4 /*yield*/, KeyFactoryService.asKey(decryptedOtk.plainOtKeyCipher.initiator.sigPbk)];
9359
- case 10:
10118
+ case 8:
9360
10119
  initiatorSigPbk = _1.sent();
9361
- return [4 /*yield*/, this.keyService.getCurrentPxk()];
9362
- case 11:
9363
- responderPrk = _1.sent();
9364
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
9365
- case 12:
9366
- responderSigPrk = _1.sent();
10120
+ responderPrk = this.keyService.currentPxk;
10121
+ responderSigPrk = this.keyService.currentSigPxk;
9367
10122
  return [4 /*yield*/, this.encryptionService.sign(responderSigPrk.jwk, initiatorPbk.toJSON())];
9368
- case 13:
10123
+ case 9:
9369
10124
  signedInitiatorPbk = _1.sent();
9370
10125
  return [4 /*yield*/, this.encryptionService.sign(responderSigPrk.jwk, initiatorSigPbk.toJSON())];
9371
- case 14:
10126
+ case 10:
9372
10127
  signedInitiatorSigPbk = _1.sent();
9373
10128
  plainInitiatorOneTimePbkCipher = {
9374
10129
  nonce: decryptedOtk.plainOtKeyCipher.nonce,
@@ -9383,109 +10138,105 @@
9383
10138
  message: message,
9384
10139
  },
9385
10140
  };
9386
- if (!decryptedOtk.plainOtKeyCipher.initiator.contactCard) return [3 /*break*/, 25];
10141
+ if (!decryptedOtk.plainOtKeyCipher.initiator.contactCard) return [3 /*break*/, 20];
9387
10142
  plainSharedCipherDataJson = decryptedOtk.plainOtKeyCipher.initiator.contactCard
9388
10143
  .plainSharedCipherDataJson;
9389
10144
  return [4 /*yield*/, this.keyFactory.createKey()];
9390
- case 15:
10145
+ case 11:
9391
10146
  receiverKey = _1.sent();
9392
10147
  return [4 /*yield*/, this.keyFactory.createKey()];
9393
- case 16:
10148
+ case 12:
9394
10149
  ccSharedKey = _1.sent();
9395
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
9396
- case 17:
9397
- sigPxk = _1.sent();
10150
+ sigPxk = this.keyService.currentSigPxk;
9398
10151
  _a = {};
9399
10152
  _c = (_b = JSON).stringify;
9400
10153
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, receiverKey.toJSON(true))];
9401
- case 18:
10154
+ case 13:
9402
10155
  _a.receiverWrappedKey = _c.apply(_b, [_1.sent()]),
9403
10156
  _a.receiverWrappingKeyId = rootKey.id;
9404
- if (!initiatorContactCard) return [3 /*break*/, 20];
10157
+ if (!initiatorContactCard) return [3 /*break*/, 15];
9405
10158
  _f = (_e = JSON).stringify;
9406
10159
  return [4 /*yield*/, this.encryptionService.encrypt(receiverKey, initiatorContactCard.plainReceiverCipherDataJson)];
9407
- case 19:
10160
+ case 14:
9408
10161
  _d = _f.apply(_e, [_1.sent()]);
9409
- return [3 /*break*/, 21];
9410
- case 20:
10162
+ return [3 /*break*/, 16];
10163
+ case 15:
9411
10164
  _d = '';
9412
- _1.label = 21;
9413
- case 21:
10165
+ _1.label = 16;
10166
+ case 16:
9414
10167
  _a.receiverCipherData = _d;
9415
10168
  _h = (_g = JSON).stringify;
9416
10169
  return [4 /*yield*/, this.encryptionService.encrypt(sharedKey, ccSharedKey.toJSON(true))];
9417
- case 22:
10170
+ case 17:
9418
10171
  receivedCardInput = (_a.sharedWrappedKey = _h.apply(_g, [_1.sent()]),
9419
10172
  _a);
9420
10173
  return [4 /*yield*/, this.encryptionService.encrypt(ccSharedKey, plainSharedCipherDataJson)];
9421
- case 23:
10174
+ case 18:
9422
10175
  sharedCipherData = _1.sent();
9423
10176
  _j = receivedCardInput;
9424
10177
  _l = (_k = JSON).stringify;
9425
10178
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, sharedCipherData)];
9426
- case 24:
10179
+ case 19:
9427
10180
  _j.sharedCipherDataSig = _l.apply(_k, [_1.sent()]);
9428
10181
  receivedCardInput.sigPxkId = sigPxk.id;
9429
10182
  plainInitiatorOneTimePbkCipher.responder.contactCard = Object.assign(Object.assign({}, plainInitiatorOneTimePbkCipher.responder.contactCard), { sharedCipherKey: ccSharedKey.toJSON(true) });
9430
- _1.label = 25;
9431
- case 25:
9432
- if (!sentContactCard) return [3 /*break*/, 38];
10183
+ _1.label = 20;
10184
+ case 20:
10185
+ if (!sentContactCard) return [3 /*break*/, 32];
9433
10186
  return [4 /*yield*/, this.keyFactory.createKey()];
9434
- case 26:
10187
+ case 21:
9435
10188
  ownerKey = _1.sent();
9436
10189
  return [4 /*yield*/, this.keyFactory.createKey()];
9437
- case 27:
10190
+ case 22:
9438
10191
  ccSharedKey = _1.sent();
9439
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
9440
- case 28:
9441
- sigPxk = _1.sent();
10192
+ sigPxk = this.keyService.currentSigPxk;
9442
10193
  _m = {};
9443
10194
  _p = (_o = JSON).stringify;
9444
10195
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, ownerKey.toJSON(true))];
9445
- case 29:
10196
+ case 23:
9446
10197
  _m.ownerWrappedKey = _p.apply(_o, [_1.sent()]),
9447
10198
  _m.ownerWrappingKeyId = rootKey.id;
9448
- if (!sentContactCard.plainOwnerCipherDataJson) return [3 /*break*/, 31];
10199
+ if (!sentContactCard.plainOwnerCipherDataJson) return [3 /*break*/, 25];
9449
10200
  _s = (_r = JSON).stringify;
9450
10201
  return [4 /*yield*/, this.encryptionService.encrypt(ownerKey, sentContactCard.plainOwnerCipherDataJson)];
9451
- case 30:
10202
+ case 24:
9452
10203
  _q = _s.apply(_r, [_1.sent()]);
9453
- return [3 /*break*/, 32];
9454
- case 31:
10204
+ return [3 /*break*/, 26];
10205
+ case 25:
9455
10206
  _q = '';
9456
- _1.label = 32;
9457
- case 32:
10207
+ _1.label = 26;
10208
+ case 26:
9458
10209
  _m.ownerCipherData = _q;
9459
10210
  _u = (_t = JSON).stringify;
9460
10211
  return [4 /*yield*/, this.encryptionService.encrypt(sharedKey, ccSharedKey.toJSON(true))];
9461
- case 33:
10212
+ case 27:
9462
10213
  sentCardInput = (_m.sharedWrappedKey = _u.apply(_t, [_1.sent()]),
9463
10214
  _m);
9464
10215
  return [4 /*yield*/, this.encryptionService.encrypt(ccSharedKey, sentContactCard.plainSharedCipherDataJson)];
9465
- case 34:
10216
+ case 28:
9466
10217
  sharedCipherData = _1.sent();
9467
10218
  _v = sentCardInput;
9468
10219
  _x = (_w = JSON).stringify;
9469
10220
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, sharedCipherData)];
9470
- case 35:
10221
+ case 29:
9471
10222
  _v.sharedCipherDataSig = _x.apply(_w, [_1.sent()]);
9472
10223
  sentCardInput.sigPxkId = sigPxk.id;
9473
- if (!sentContactCard.ownerPlainData) return [3 /*break*/, 37];
10224
+ if (!sentContactCard.ownerPlainData) return [3 /*break*/, 31];
9474
10225
  _y = sentCardInput;
9475
10226
  _0 = (_z = JSON).stringify;
9476
10227
  return [4 /*yield*/, this.encryptionService.sign(responderSigPrk.jwk, sentContactCard.ownerPlainData)];
9477
- case 36:
10228
+ case 30:
9478
10229
  _y.ownerPlainDataSig = _0.apply(_z, [_1.sent()]);
9479
- _1.label = 37;
9480
- case 37:
10230
+ _1.label = 31;
10231
+ case 31:
9481
10232
  // Contact card info readable by the initiator
9482
10233
  plainInitiatorOneTimePbkCipher.responder.contactCard = Object.assign(Object.assign({}, plainInitiatorOneTimePbkCipher.responder.contactCard), { plainSharedCipherDataJson: sentContactCard.plainSharedCipherDataJson });
9483
- _1.label = 38;
9484
- case 38: return [4 /*yield*/, this.encryptionService.encrypt(initiatorOneTimePbk, plainInitiatorOneTimePbkCipher)];
9485
- case 39:
10234
+ _1.label = 32;
10235
+ case 32: return [4 /*yield*/, this.encryptionService.encrypt(initiatorOneTimePbk, plainInitiatorOneTimePbkCipher)];
10236
+ case 33:
9486
10237
  initiatorOneTimePbkCipher = _1.sent();
9487
10238
  return [4 /*yield*/, this.encryptionService.encrypt(decryptedOtk.otKey, initiatorOneTimePbkCipher)];
9488
- case 40:
10239
+ case 34:
9489
10240
  // Encrypt with the otk again to keep use of asymmetric keys to a minimum.
9490
10241
  initiatorOneTimePbkCipher = _1.sent();
9491
10242
  return [4 /*yield*/, this.lrApollo.mutate({
@@ -9495,7 +10246,7 @@
9495
10246
  keyExchangeId: id,
9496
10247
  keyExchangeToken: token,
9497
10248
  rootKeyId: rootKey.id,
9498
- masterKeyId: masterKeyId,
10249
+ masterKeyId: masterKey.id,
9499
10250
  // These will be stored on the server
9500
10251
  responderPxkId: responderPrk.id,
9501
10252
  responderSigPxkId: responderSigPrk.id,
@@ -9513,7 +10264,7 @@
9513
10264
  },
9514
10265
  },
9515
10266
  })];
9516
- case 41:
10267
+ case 35:
9517
10268
  respondKeyExchangeOtk = (_1.sent()).respondKeyExchangeOtk;
9518
10269
  return [2 /*return*/, {
9519
10270
  keyExchange: respondKeyExchangeOtk.keyExchange,
@@ -9529,93 +10280,88 @@
9529
10280
  var rootKey, masterKey, plainInitiatorRootKeyCipher, plainInitiatorOneTimePbkCipher, _a, _b, initiatorSigPrk, responderSigPbk, responderPbk, signedResponderPbk, signedResponderSigPbk, sharedKey, rkWrappedSharedKey, mkSharedKey, mkWrappedMkSharedKey, responderContactCardCipherInput, receiverKey, _c, _d, _e, _f, _g, initiatorContactCardCipherInput, initiatorContactCardSharedCipherInput, initiatorContactCard, ownerKey, sharedCipherKey, ownerWrappedKey, _h, _j, ownerCipherData, _k, _l, _m, sharedCipherData, _o, _p, _q, res;
9530
10281
  return __generator(this, function (_r) {
9531
10282
  switch (_r.label) {
9532
- case 0: return [4 /*yield*/, this.keyService.getCurrentRootKey()];
9533
- case 1:
9534
- rootKey = _r.sent();
9535
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
9536
- case 2:
9537
- masterKey = _r.sent();
10283
+ case 0:
10284
+ rootKey = this.keyService.currentRootKey;
10285
+ masterKey = this.keyService.currentMasterKey;
9538
10286
  return [4 /*yield*/, this.encryptionService.decrypt(rootKey.jwk, initiatorRootKeyCipher)];
9539
- case 3:
10287
+ case 1:
9540
10288
  plainInitiatorRootKeyCipher = (_r.sent());
9541
10289
  _a = this.decryptResponseCipher;
9542
10290
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorRootKeyCipher.otKey)];
9543
- case 4:
10291
+ case 2:
9544
10292
  _b = [_r.sent()];
9545
10293
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorRootKeyCipher.oneTimePrk)];
9546
- case 5: return [4 /*yield*/, _a.apply(this, _b.concat([_r.sent(), initiatorOneTimePbkCipher]))];
9547
- case 6:
10294
+ case 3: return [4 /*yield*/, _a.apply(this, _b.concat([_r.sent(), initiatorOneTimePbkCipher]))];
10295
+ case 4:
9548
10296
  plainInitiatorOneTimePbkCipher = _r.sent();
9549
10297
  // Check the nonce match to ensure the responder was the one holding the OTK
9550
10298
  if (plainInitiatorRootKeyCipher.nonce !== plainInitiatorOneTimePbkCipher.nonce) {
9551
10299
  throw new KcCodeMismatchException('The nonce returned by responder does not match with the one created by the initiator.');
9552
10300
  }
9553
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
9554
- case 7:
9555
- initiatorSigPrk = _r.sent();
10301
+ initiatorSigPrk = this.keyService.currentSigPxk;
9556
10302
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.sigPbk)];
9557
- case 8:
10303
+ case 5:
9558
10304
  responderSigPbk = _r.sent();
9559
10305
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.pbk)];
9560
- case 9:
10306
+ case 6:
9561
10307
  responderPbk = _r.sent();
9562
10308
  return [4 /*yield*/, this.encryptionService.sign(initiatorSigPrk.jwk, responderPbk.toJSON())];
9563
- case 10:
10309
+ case 7:
9564
10310
  signedResponderPbk = _r.sent();
9565
10311
  return [4 /*yield*/, this.encryptionService.sign(initiatorSigPrk.jwk, responderSigPbk.toJSON())];
9566
- case 11:
10312
+ case 8:
9567
10313
  signedResponderSigPbk = _r.sent();
9568
10314
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.sharedKey)];
9569
- case 12:
10315
+ case 9:
9570
10316
  sharedKey = _r.sent();
9571
10317
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, sharedKey.toJSON(true))];
9572
- case 13:
10318
+ case 10:
9573
10319
  rkWrappedSharedKey = _r.sent();
9574
10320
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.mkSharedKey)];
9575
- case 14:
10321
+ case 11:
9576
10322
  mkSharedKey = _r.sent();
9577
10323
  return [4 /*yield*/, this.encryptionService.encrypt(masterKey.jwk, mkSharedKey.toJSON(true))];
9578
- case 15:
10324
+ case 12:
9579
10325
  mkWrappedMkSharedKey = _r.sent();
9580
- if (!responderContactCard) return [3 /*break*/, 19];
10326
+ if (!responderContactCard) return [3 /*break*/, 16];
9581
10327
  return [4 /*yield*/, this.keyFactory.createKey()];
9582
- case 16:
10328
+ case 13:
9583
10329
  receiverKey = _r.sent();
9584
10330
  _c = {};
9585
10331
  _e = (_d = JSON).stringify;
9586
10332
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, receiverKey.toJSON(true))];
9587
- case 17:
10333
+ case 14:
9588
10334
  _c.receiverWrappedKey = _e.apply(_d, [_r.sent()]),
9589
10335
  _c.receiverWrappingKeyId = rootKey.id;
9590
10336
  _g = (_f = JSON).stringify;
9591
10337
  return [4 /*yield*/, this.encryptionService.encrypt(receiverKey, responderContactCard)];
9592
- case 18:
10338
+ case 15:
9593
10339
  responderContactCardCipherInput = (_c.receiverCipherData = _g.apply(_f, [_r.sent()]),
9594
10340
  _c);
9595
- _r.label = 19;
9596
- case 19:
9597
- if (!plainInitiatorRootKeyCipher.initiatorContactCard) return [3 /*break*/, 28];
10341
+ _r.label = 16;
10342
+ case 16:
10343
+ if (!plainInitiatorRootKeyCipher.initiatorContactCard) return [3 /*break*/, 25];
9598
10344
  initiatorContactCard = plainInitiatorRootKeyCipher.initiatorContactCard;
9599
10345
  return [4 /*yield*/, this.keyFactory.createKey()];
9600
- case 20:
10346
+ case 17:
9601
10347
  ownerKey = _r.sent();
9602
10348
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.contactCard.sharedCipherKey)];
9603
- case 21:
10349
+ case 18:
9604
10350
  sharedCipherKey = _r.sent();
9605
10351
  _j = (_h = JSON).stringify;
9606
10352
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, ownerKey.toJSON(true))];
9607
- case 22:
10353
+ case 19:
9608
10354
  ownerWrappedKey = _j.apply(_h, [_r.sent()]);
9609
- if (!initiatorContactCard.plainOwnerCipherDataJson) return [3 /*break*/, 24];
10355
+ if (!initiatorContactCard.plainOwnerCipherDataJson) return [3 /*break*/, 21];
9610
10356
  _m = (_l = JSON).stringify;
9611
10357
  return [4 /*yield*/, this.encryptionService.encrypt(ownerKey, initiatorContactCard.plainOwnerCipherDataJson)];
9612
- case 23:
10358
+ case 20:
9613
10359
  _k = _m.apply(_l, [_r.sent()]);
9614
- return [3 /*break*/, 25];
9615
- case 24:
10360
+ return [3 /*break*/, 22];
10361
+ case 21:
9616
10362
  _k = '';
9617
- _r.label = 25;
9618
- case 25:
10363
+ _r.label = 22;
10364
+ case 22:
9619
10365
  ownerCipherData = _k;
9620
10366
  initiatorContactCardCipherInput = {
9621
10367
  ownerWrappedKey: ownerWrappedKey,
@@ -9626,16 +10372,16 @@
9626
10372
  sigPxkId: initiatorSigPrk.id,
9627
10373
  };
9628
10374
  return [4 /*yield*/, this.encryptionService.encrypt(sharedCipherKey, initiatorContactCard.plainSharedCipherDataJson)];
9629
- case 26:
10375
+ case 23:
9630
10376
  sharedCipherData = _r.sent();
9631
10377
  _o = initiatorContactCardSharedCipherInput;
9632
10378
  _q = (_p = JSON).stringify;
9633
10379
  return [4 /*yield*/, this.encryptionService.sign(initiatorSigPrk.jwk, sharedCipherData)];
9634
- case 27:
10380
+ case 24:
9635
10381
  _o.sharedCipherDataSig =
9636
10382
  _q.apply(_p, [_r.sent()]);
9637
- _r.label = 28;
9638
- case 28: return [4 /*yield*/, this.lrApollo.mutate({
10383
+ _r.label = 25;
10384
+ case 25: return [4 /*yield*/, this.lrApollo.mutate({
9639
10385
  mutation: CompleteOtkMutation,
9640
10386
  variables: {
9641
10387
  input: {
@@ -9653,7 +10399,7 @@
9653
10399
  },
9654
10400
  },
9655
10401
  })];
9656
- case 29:
10402
+ case 26:
9657
10403
  res = _r.sent();
9658
10404
  return [2 /*return*/, res.completeKeyExchangeOtk];
9659
10405
  }
@@ -9681,7 +10427,7 @@
9681
10427
  };
9682
10428
  return KeyExchangeService;
9683
10429
  }());
9684
- KeyExchangeService.ɵprov = i0.ɵɵdefineInjectable({ factory: function KeyExchangeService_Factory() { return new KeyExchangeService(i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyService), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(LifeReadyAuthService), i0.ɵɵinject(UserService)); }, token: KeyExchangeService, providedIn: "root" });
10430
+ KeyExchangeService.ɵprov = i0.ɵɵdefineInjectable({ factory: function KeyExchangeService_Factory() { return new KeyExchangeService(i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyService), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(exports.Auth2Service)); }, token: KeyExchangeService, providedIn: "root" });
9685
10431
  KeyExchangeService.decorators = [
9686
10432
  { type: i0.Injectable, args: [{
9687
10433
  providedIn: 'root',
@@ -9692,13 +10438,12 @@
9692
10438
  { type: KeyService },
9693
10439
  { type: LrApolloService },
9694
10440
  { type: EncryptionService },
9695
- { type: LifeReadyAuthService },
9696
- { type: UserService }
10441
+ { type: exports.Auth2Service }
9697
10442
  ]; };
9698
10443
 
9699
- var KeyExchangeFragment = gqlTyped(templateObject_1$k || (templateObject_1$k = __makeTemplateObject(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"], ["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"])));
10444
+ var KeyExchangeFragment = gqlTyped(templateObject_1$k || (templateObject_1$k = __makeTemplateObject(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n config\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"], ["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n config\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"])));
9700
10445
  var UserSharedKeyFragment = gqlTyped(templateObject_2$h || (templateObject_2$h = __makeTemplateObject(["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"], ["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"])));
9701
- var KeyExchangesQuery2 = gqlTyped(templateObject_3$f || (templateObject_3$f = __makeTemplateObject(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n", "\n"], ["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n", "\n"])), KeyExchangeFragment);
10446
+ var KeyExchangesQuery2 = gqlTyped(templateObject_3$e || (templateObject_3$e = __makeTemplateObject(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n", "\n"], ["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n", "\n"])), KeyExchangeFragment);
9702
10447
  var KeyExchangeQuery2 = gqlTyped(templateObject_4$a || (templateObject_4$a = __makeTemplateObject(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n", "\n"], ["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n", "\n"])), KeyExchangeFragment);
9703
10448
  var KeyExchangeTokenQuery2 = gqlTyped(templateObject_5$9 || (templateObject_5$9 = __makeTemplateObject(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n", "\n"], ["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n", "\n"])), KeyExchangeFragment);
9704
10449
  var CancelKeyExchangeMutation = gqlTyped(templateObject_6$8 || (templateObject_6$8 = __makeTemplateObject(["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"], ["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"])));
@@ -9707,7 +10452,7 @@
9707
10452
  var RespondKeyExchangeOtkMutation = gqlTyped(templateObject_9$4 || (templateObject_9$4 = __makeTemplateObject(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n", "\n", "\n"], ["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n", "\n", "\n"])), KeyExchangeFragment, UserSharedKeyFragment);
9708
10453
  var CompleteKeyExchangeOtkMutation = gqlTyped(templateObject_10$3 || (templateObject_10$3 = __makeTemplateObject(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n", "\n", "\n"], ["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n", "\n", "\n"])), KeyExchangeFragment, UserSharedKeyFragment);
9709
10454
  var CurrentUserSharedKeyQuery2 = gqlTyped(templateObject_11$2 || (templateObject_11$2 = __makeTemplateObject(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n", "\n"], ["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n", "\n"])), UserSharedKeyFragment);
9710
- var templateObject_1$k, templateObject_2$h, templateObject_3$f, templateObject_4$a, templateObject_5$9, templateObject_6$8, templateObject_7$7, templateObject_8$6, templateObject_9$4, templateObject_10$3, templateObject_11$2;
10455
+ var templateObject_1$k, templateObject_2$h, templateObject_3$e, templateObject_4$a, templateObject_5$9, templateObject_6$8, templateObject_7$7, templateObject_8$6, templateObject_9$4, templateObject_10$3, templateObject_11$2;
9711
10456
 
9712
10457
  exports.KeyExchange2Service = /** @class */ (function (_super) {
9713
10458
  __extends(KeyExchange2Service, _super);
@@ -9734,19 +10479,17 @@
9734
10479
  case 2:
9735
10480
  if (!(keyExchange.otk.state === 'OTK_INITIATED' &&
9736
10481
  !keyExchange.isInitiator &&
9737
- keyExchange.otk.responderPbkCipher)) return [3 /*break*/, 6];
9738
- return [4 /*yield*/, this.keyService.getCurrentPxk()];
9739
- case 3:
9740
- prk = _a.sent();
10482
+ keyExchange.otk.responderPbkCipher)) return [3 /*break*/, 5];
10483
+ prk = this.keyService.currentPxk;
9741
10484
  return [4 /*yield*/, this.encryptionService.decrypt(prk.jwk, JSON.parse(keyExchange.otk.responderPbkCipher), {
9742
10485
  serializations: [JoseSerialization.COMPACT],
9743
10486
  })];
9744
- case 4:
10487
+ case 3:
9745
10488
  decryptedCipher = _a.sent();
9746
- if (!decryptedCipher.otKey) return [3 /*break*/, 6];
10489
+ if (!decryptedCipher.otKey) return [3 /*break*/, 5];
9747
10490
  return [4 /*yield*/, KeyFactoryService.asKey(decryptedCipher.otKey)];
9748
- case 5: return [2 /*return*/, _a.sent()];
9749
- case 6: return [2 /*return*/, null];
10491
+ case 4: return [2 /*return*/, _a.sent()];
10492
+ case 5: return [2 /*return*/, null];
9750
10493
  }
9751
10494
  });
9752
10495
  });
@@ -9803,36 +10546,35 @@
9803
10546
  var rootKey, initiatorRootKeyCipherClearJson, otKey, otk, _a, _b, _c, _d, _e, _f, _g;
9804
10547
  return __generator(this, function (_h) {
9805
10548
  switch (_h.label) {
9806
- case 0: return [4 /*yield*/, this.keyService.getCurrentRootKey()];
9807
- case 1:
9808
- rootKey = _h.sent();
10549
+ case 0:
10550
+ rootKey = this.keyService.currentRootKey;
9809
10551
  return [4 /*yield*/, this.encryptionService.decrypt(rootKey.jwk, keyExchange.initiatorRootKeyCipher)];
9810
- case 2:
10552
+ case 1:
9811
10553
  initiatorRootKeyCipherClearJson = (_h.sent());
9812
10554
  return [4 /*yield*/, KeyFactoryService.asKey(initiatorRootKeyCipherClearJson.otKey)];
9813
- case 3:
10555
+ case 2:
9814
10556
  otKey = _h.sent();
9815
10557
  keyExchange = Object.assign(Object.assign({}, keyExchange), { initiatorRootKeyCipherClearJson: initiatorRootKeyCipherClearJson });
9816
10558
  otk = keyExchange.otk;
9817
- if (!otk.initiatorOneTimePbkCipher) return [3 /*break*/, 6];
10559
+ if (!otk.initiatorOneTimePbkCipher) return [3 /*break*/, 5];
9818
10560
  _b = (_a = Object).assign;
9819
10561
  _c = [Object.assign({}, otk)];
9820
10562
  _d = {};
9821
10563
  _e = this.decryptResponseCipher;
9822
10564
  _f = [otKey];
9823
10565
  return [4 /*yield*/, KeyFactoryService.asKey(initiatorRootKeyCipherClearJson.oneTimePrk)];
9824
- case 4: return [4 /*yield*/, _e.apply(this, _f.concat([_h.sent(), otk.initiatorOneTimePbkCipher]))];
9825
- case 5:
10566
+ case 3: return [4 /*yield*/, _e.apply(this, _f.concat([_h.sent(), otk.initiatorOneTimePbkCipher]))];
10567
+ case 4:
9826
10568
  otk = _b.apply(_a, _c.concat([(_d.initiatorOneTimePbkCipherClearJson = _h.sent(), _d)]));
9827
- _h.label = 6;
9828
- case 6:
9829
- if (!otk.otKeyCipher) return [3 /*break*/, 8];
10569
+ _h.label = 5;
10570
+ case 5:
10571
+ if (!otk.otKeyCipher) return [3 /*break*/, 7];
9830
10572
  _g = otk;
9831
10573
  return [4 /*yield*/, this.encryptionService.decrypt(otKey, otk.otKeyCipher)];
9832
- case 7:
10574
+ case 6:
9833
10575
  _g.otKeyCipherClearJson = _h.sent();
9834
- _h.label = 8;
9835
- case 8: return [2 /*return*/, Object.assign(Object.assign({}, keyExchange), { otk: otk })];
10576
+ _h.label = 7;
10577
+ case 7: return [2 /*return*/, Object.assign(Object.assign({}, keyExchange), { otk: otk })];
9836
10578
  }
9837
10579
  });
9838
10580
  });
@@ -9985,19 +10727,15 @@
9985
10727
  return [4 /*yield*/, this.keyFactory.createPkcKey()];
9986
10728
  case 2:
9987
10729
  initiatorOneTimePrk = _a.sent();
9988
- return [4 /*yield*/, this.keyService.getCurrentPxk()];
9989
- case 3:
9990
- initiatorPrk = _a.sent();
9991
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
9992
- case 4:
9993
- initiatorSigPrk = _a.sent();
10730
+ initiatorPrk = this.keyService.currentPxk;
10731
+ initiatorSigPrk = this.keyService.currentSigPxk;
9994
10732
  initiatorPlainDataSig = null;
9995
- if (!(contactCard && contactCard.ownerPlainDataJson)) return [3 /*break*/, 6];
10733
+ if (!(contactCard && contactCard.ownerPlainDataJson)) return [3 /*break*/, 4];
9996
10734
  return [4 /*yield*/, this.encryptionService.signToString(initiatorSigPrk.jwk, contactCard.ownerPlainDataJson)];
9997
- case 5:
10735
+ case 3:
9998
10736
  initiatorPlainDataSig = _a.sent();
9999
- _a.label = 6;
10000
- case 6:
10737
+ _a.label = 4;
10738
+ case 4:
10001
10739
  initiator = {
10002
10740
  message: message,
10003
10741
  contactCard: contactCard && {
@@ -10014,7 +10752,7 @@
10014
10752
  initiator: Object.assign(Object.assign({}, initiator), { oneTimePbk: initiatorOneTimePrk.toJSON(), pbk: initiatorPrk.jwk.toJSON(), sigPbk: initiatorSigPrk.jwk.toJSON() }),
10015
10753
  };
10016
10754
  return [4 /*yield*/, this.keyGraph.encryptToString(otKey, plainOtKeyCipher)];
10017
- case 7:
10755
+ case 5:
10018
10756
  otKeyCipher = _a.sent();
10019
10757
  initiatorRootKeyCipherClearJson = {
10020
10758
  nonce: nonce,
@@ -10030,11 +10768,9 @@
10030
10768
  initiatorContactCard: contactCard,
10031
10769
  initiator: initiator,
10032
10770
  };
10033
- return [4 /*yield*/, this.keyService.getCurrentRootKey()];
10034
- case 8:
10035
- rootKey = _a.sent();
10771
+ rootKey = this.keyService.currentRootKey;
10036
10772
  return [4 /*yield*/, this.keyGraph.encryptToString(rootKey.jwk, initiatorRootKeyCipherClearJson)];
10037
- case 9:
10773
+ case 6:
10038
10774
  initiatorRootKeyCipher = _a.sent();
10039
10775
  otKeyK = otKey.toJSON(true).k;
10040
10776
  lrMutation = new LrMutation({
@@ -10073,48 +10809,40 @@
10073
10809
  KeyExchange2Service.prototype.respondOtkMutation = function (_a) {
10074
10810
  var keyExchangeId = _a.keyExchangeId, token = _a.token, decryptedOtk = _a.decryptedOtk, message = _a.message, initiatorContactCard = _a.initiatorContactCard, responderContactCard = _a.responderContactCard;
10075
10811
  return __awaiter(this, void 0, void 0, function () {
10076
- var rootKey, masterKeyId, masterKey, sharedKey, mkSharedKey, rkWrappedSharedKey, mkWrappedMkSharedKey, initiatorOneTimePbk, initiatorPbk, initiatorSigPbk, responderPrk, responderSigPrk, signedInitiatorPbk, signedInitiatorSigPbk, initiatorOneTimePbkCipherClearJson, receivedCardInput, sharedCipherDataClearJson, receiverKey, ccSharedKey, sigPxk, _a, _b, _c, _d, _e, _f, _g, _h, sharedCipherData, _j, _k, _l, responderCardInput, ownerKey, ccSharedKey, sigPxk, _m, _o, _p, _q, _r, _s, _t, _u, sharedCipherData, _v, _w, _x, _y, _z, _0, initiatorOneTimePbkCipher;
10812
+ var rootKey, masterKey, sharedKey, mkSharedKey, rkWrappedSharedKey, mkWrappedMkSharedKey, initiatorOneTimePbk, initiatorPbk, initiatorSigPbk, responderPrk, responderSigPrk, signedInitiatorPbk, signedInitiatorSigPbk, initiatorOneTimePbkCipherClearJson, receivedCardInput, sharedCipherDataClearJson, receiverKey, ccSharedKey, sigPxk, _a, _b, _c, _d, _e, _f, _g, _h, sharedCipherData, _j, _k, _l, responderCardInput, ownerKey, ccSharedKey, sigPxk, _m, _o, _p, _q, _r, _s, _t, _u, sharedCipherData, _v, _w, _x, _y, _z, _0, initiatorOneTimePbkCipher;
10077
10813
  return __generator(this, function (_1) {
10078
10814
  switch (_1.label) {
10079
- case 0: return [4 /*yield*/, this.keyService.getCurrentRootKey()];
10080
- case 1:
10081
- rootKey = _1.sent();
10082
- masterKeyId = this.keyService.getCurrentMasterKey().id;
10083
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
10084
- case 2:
10085
- masterKey = _1.sent();
10815
+ case 0:
10816
+ rootKey = this.keyService.currentRootKey;
10817
+ masterKey = this.keyService.currentMasterKey;
10086
10818
  return [4 /*yield*/, this.keyFactory.createKey()];
10087
- case 3:
10819
+ case 1:
10088
10820
  sharedKey = _1.sent();
10089
10821
  return [4 /*yield*/, this.keyFactory.createKey()];
10090
- case 4:
10822
+ case 2:
10091
10823
  mkSharedKey = _1.sent();
10092
10824
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, sharedKey.toJSON(true))];
10093
- case 5:
10825
+ case 3:
10094
10826
  rkWrappedSharedKey = _1.sent();
10095
10827
  return [4 /*yield*/, this.encryptionService.encrypt(masterKey.jwk, mkSharedKey.toJSON(true))];
10096
- case 6:
10828
+ case 4:
10097
10829
  mkWrappedMkSharedKey = _1.sent();
10098
10830
  return [4 /*yield*/, KeyFactoryService.asKey(decryptedOtk.otKeyCipherClearJson.initiator.oneTimePbk)];
10099
- case 7:
10831
+ case 5:
10100
10832
  initiatorOneTimePbk = _1.sent();
10101
10833
  return [4 /*yield*/, KeyFactoryService.asKey(decryptedOtk.otKeyCipherClearJson.initiator.pbk)];
10102
- case 8:
10834
+ case 6:
10103
10835
  initiatorPbk = _1.sent();
10104
10836
  return [4 /*yield*/, KeyFactoryService.asKey(decryptedOtk.otKeyCipherClearJson.initiator.sigPbk)];
10105
- case 9:
10837
+ case 7:
10106
10838
  initiatorSigPbk = _1.sent();
10107
- return [4 /*yield*/, this.keyService.getCurrentPxk()];
10108
- case 10:
10109
- responderPrk = _1.sent();
10110
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
10111
- case 11:
10112
- responderSigPrk = _1.sent();
10839
+ responderPrk = this.keyService.currentPxk;
10840
+ responderSigPrk = this.keyService.currentSigPxk;
10113
10841
  return [4 /*yield*/, this.encryptionService.sign(responderSigPrk.jwk, initiatorPbk.toJSON())];
10114
- case 12:
10842
+ case 8:
10115
10843
  signedInitiatorPbk = _1.sent();
10116
10844
  return [4 /*yield*/, this.encryptionService.sign(responderSigPrk.jwk, initiatorSigPbk.toJSON())];
10117
- case 13:
10845
+ case 9:
10118
10846
  signedInitiatorSigPbk = _1.sent();
10119
10847
  initiatorOneTimePbkCipherClearJson = {
10120
10848
  nonce: decryptedOtk.otKeyCipherClearJson.nonce,
@@ -10126,109 +10854,105 @@
10126
10854
  message: message,
10127
10855
  },
10128
10856
  };
10129
- if (!decryptedOtk.otKeyCipherClearJson.initiator.contactCard) return [3 /*break*/, 24];
10857
+ if (!decryptedOtk.otKeyCipherClearJson.initiator.contactCard) return [3 /*break*/, 19];
10130
10858
  sharedCipherDataClearJson = decryptedOtk.otKeyCipherClearJson.initiator.contactCard
10131
10859
  .sharedCipherDataClearJson;
10132
10860
  return [4 /*yield*/, this.keyFactory.createKey()];
10133
- case 14:
10861
+ case 10:
10134
10862
  receiverKey = _1.sent();
10135
10863
  return [4 /*yield*/, this.keyFactory.createKey()];
10136
- case 15:
10864
+ case 11:
10137
10865
  ccSharedKey = _1.sent();
10138
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
10139
- case 16:
10140
- sigPxk = _1.sent();
10866
+ sigPxk = this.keyService.currentSigPxk;
10141
10867
  _a = {};
10142
10868
  _c = (_b = JSON).stringify;
10143
10869
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, receiverKey.toJSON(true))];
10144
- case 17:
10870
+ case 12:
10145
10871
  _a.receiverWrappedKey = _c.apply(_b, [_1.sent()]),
10146
10872
  _a.receiverWrappingKeyId = rootKey.id;
10147
- if (!initiatorContactCard) return [3 /*break*/, 19];
10873
+ if (!initiatorContactCard) return [3 /*break*/, 14];
10148
10874
  _f = (_e = JSON).stringify;
10149
10875
  return [4 /*yield*/, this.encryptionService.encrypt(receiverKey, initiatorContactCard.receiverCipherDataClearJson)];
10150
- case 18:
10876
+ case 13:
10151
10877
  _d = _f.apply(_e, [_1.sent()]);
10152
- return [3 /*break*/, 20];
10153
- case 19:
10878
+ return [3 /*break*/, 15];
10879
+ case 14:
10154
10880
  _d = '';
10155
- _1.label = 20;
10156
- case 20:
10881
+ _1.label = 15;
10882
+ case 15:
10157
10883
  _a.receiverCipherData = _d;
10158
10884
  _h = (_g = JSON).stringify;
10159
10885
  return [4 /*yield*/, this.encryptionService.encrypt(sharedKey, ccSharedKey.toJSON(true))];
10160
- case 21:
10886
+ case 16:
10161
10887
  receivedCardInput = (_a.sharedWrappedKey = _h.apply(_g, [_1.sent()]),
10162
10888
  _a);
10163
10889
  return [4 /*yield*/, this.encryptionService.encrypt(ccSharedKey, sharedCipherDataClearJson)];
10164
- case 22:
10890
+ case 17:
10165
10891
  sharedCipherData = _1.sent();
10166
10892
  _j = receivedCardInput;
10167
10893
  _l = (_k = JSON).stringify;
10168
10894
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, sharedCipherData)];
10169
- case 23:
10895
+ case 18:
10170
10896
  _j.sharedCipherDataSig = _l.apply(_k, [_1.sent()]);
10171
10897
  receivedCardInput.sigPxkId = sigPxk.id;
10172
10898
  initiatorOneTimePbkCipherClearJson.responder.contactCard = Object.assign(Object.assign({}, initiatorOneTimePbkCipherClearJson.responder.contactCard), { sharedCipherKey: ccSharedKey.toJSON(true) });
10173
- _1.label = 24;
10174
- case 24:
10175
- if (!responderContactCard) return [3 /*break*/, 37];
10899
+ _1.label = 19;
10900
+ case 19:
10901
+ if (!responderContactCard) return [3 /*break*/, 31];
10176
10902
  return [4 /*yield*/, this.keyFactory.createKey()];
10177
- case 25:
10903
+ case 20:
10178
10904
  ownerKey = _1.sent();
10179
10905
  return [4 /*yield*/, this.keyFactory.createKey()];
10180
- case 26:
10906
+ case 21:
10181
10907
  ccSharedKey = _1.sent();
10182
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
10183
- case 27:
10184
- sigPxk = _1.sent();
10908
+ sigPxk = this.keyService.currentSigPxk;
10185
10909
  _m = {};
10186
10910
  _p = (_o = JSON).stringify;
10187
10911
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, ownerKey.toJSON(true))];
10188
- case 28:
10912
+ case 22:
10189
10913
  _m.ownerWrappedKey = _p.apply(_o, [_1.sent()]),
10190
10914
  _m.ownerWrappingKeyId = rootKey.id;
10191
- if (!responderContactCard.ownerCipherDataClearJson) return [3 /*break*/, 30];
10915
+ if (!responderContactCard.ownerCipherDataClearJson) return [3 /*break*/, 24];
10192
10916
  _s = (_r = JSON).stringify;
10193
10917
  return [4 /*yield*/, this.encryptionService.encrypt(ownerKey, responderContactCard.ownerCipherDataClearJson)];
10194
- case 29:
10918
+ case 23:
10195
10919
  _q = _s.apply(_r, [_1.sent()]);
10196
- return [3 /*break*/, 31];
10197
- case 30:
10920
+ return [3 /*break*/, 25];
10921
+ case 24:
10198
10922
  _q = '';
10199
- _1.label = 31;
10200
- case 31:
10923
+ _1.label = 25;
10924
+ case 25:
10201
10925
  _m.ownerCipherData = _q;
10202
10926
  _u = (_t = JSON).stringify;
10203
10927
  return [4 /*yield*/, this.encryptionService.encrypt(sharedKey, ccSharedKey.toJSON(true))];
10204
- case 32:
10928
+ case 26:
10205
10929
  responderCardInput = (_m.sharedWrappedKey = _u.apply(_t, [_1.sent()]),
10206
10930
  _m);
10207
10931
  return [4 /*yield*/, this.encryptionService.encrypt(ccSharedKey, responderContactCard.sharedCipherDataClearJson)];
10208
- case 33:
10932
+ case 27:
10209
10933
  sharedCipherData = _1.sent();
10210
10934
  _v = responderCardInput;
10211
10935
  _x = (_w = JSON).stringify;
10212
10936
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, sharedCipherData)];
10213
- case 34:
10937
+ case 28:
10214
10938
  _v.sharedCipherDataSig = _x.apply(_w, [_1.sent()]);
10215
10939
  responderCardInput.sigPxkId = sigPxk.id;
10216
- if (!responderContactCard.ownerPlainDataJson) return [3 /*break*/, 36];
10940
+ if (!responderContactCard.ownerPlainDataJson) return [3 /*break*/, 30];
10217
10941
  _y = responderCardInput;
10218
10942
  _0 = (_z = JSON).stringify;
10219
10943
  return [4 /*yield*/, this.encryptionService.sign(responderSigPrk.jwk, responderContactCard.ownerPlainDataJson)];
10220
- case 35:
10944
+ case 29:
10221
10945
  _y.ownerPlainDataSig = _0.apply(_z, [_1.sent()]);
10222
- _1.label = 36;
10223
- case 36:
10946
+ _1.label = 30;
10947
+ case 30:
10224
10948
  // Contact card info readable by the initiator
10225
10949
  initiatorOneTimePbkCipherClearJson.responder.contactCard = Object.assign(Object.assign({}, initiatorOneTimePbkCipherClearJson.responder.contactCard), { sharedCipherDataClearJson: responderContactCard.sharedCipherDataClearJson });
10226
- _1.label = 37;
10227
- case 37: return [4 /*yield*/, this.encryptionService.encrypt(initiatorOneTimePbk, initiatorOneTimePbkCipherClearJson)];
10228
- case 38:
10950
+ _1.label = 31;
10951
+ case 31: return [4 /*yield*/, this.encryptionService.encrypt(initiatorOneTimePbk, initiatorOneTimePbkCipherClearJson)];
10952
+ case 32:
10229
10953
  initiatorOneTimePbkCipher = _1.sent();
10230
10954
  return [4 /*yield*/, this.encryptionService.encrypt(decryptedOtk.otKey, initiatorOneTimePbkCipher)];
10231
- case 39:
10955
+ case 33:
10232
10956
  // Encrypt with the otk again to keep use of asymmetric keys to a minimum.
10233
10957
  initiatorOneTimePbkCipher = _1.sent();
10234
10958
  return [2 /*return*/, new LrMutation({
@@ -10238,7 +10962,7 @@
10238
10962
  keyExchangeId: keyExchangeId,
10239
10963
  keyExchangeToken: token,
10240
10964
  rootKeyId: rootKey.id,
10241
- masterKeyId: masterKeyId,
10965
+ masterKeyId: masterKey.id,
10242
10966
  // These will be stored on the server
10243
10967
  responderPxkId: responderPrk.id,
10244
10968
  responderSigPxkId: responderSigPrk.id,
@@ -10273,95 +10997,90 @@
10273
10997
  var rootKey, masterKey, initiatorRootKeyCipherClearJson, plainInitiatorOneTimePbkCipher, _a, _b, initiatorSigPrk, responderSigPbk, responderPbk, signedResponderPbk, signedResponderSigPbk, sharedKey, rkWrappedSharedKey, mkSharedKey, mkWrappedMkSharedKey, responderContactCardCipherInput, receiverKey, _c, _d, _e, _f, _g, initiatorContactCardCipherInput, initiatorContactCardSharedCipherInput, initiatorContactCardFromInit, ownerKey, sharedCipherKey, ownerWrappedKey, _h, _j, ownerCipherDataClearJson, ownerCipherData, _k, sharedCipherData, _l, _m, _o;
10274
10998
  return __generator(this, function (_p) {
10275
10999
  switch (_p.label) {
10276
- case 0: return [4 /*yield*/, this.keyService.getCurrentRootKey()];
10277
- case 1:
10278
- rootKey = _p.sent();
10279
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
10280
- case 2:
10281
- masterKey = _p.sent();
11000
+ case 0:
11001
+ rootKey = this.keyService.currentRootKey;
11002
+ masterKey = this.keyService.currentMasterKey;
10282
11003
  return [4 /*yield*/, this.encryptionService.decrypt(rootKey.jwk, initiatorRootKeyCipher)];
10283
- case 3:
11004
+ case 1:
10284
11005
  initiatorRootKeyCipherClearJson = (_p.sent());
10285
11006
  _a = this.decryptResponseCipher;
10286
11007
  return [4 /*yield*/, KeyFactoryService.asKey(initiatorRootKeyCipherClearJson.otKey)];
10287
- case 4:
11008
+ case 2:
10288
11009
  _b = [_p.sent()];
10289
11010
  return [4 /*yield*/, KeyFactoryService.asKey(initiatorRootKeyCipherClearJson.oneTimePrk)];
10290
- case 5: return [4 /*yield*/, _a.apply(this, _b.concat([_p.sent(), initiatorOneTimePbkCipher]))];
10291
- case 6:
11011
+ case 3: return [4 /*yield*/, _a.apply(this, _b.concat([_p.sent(), initiatorOneTimePbkCipher]))];
11012
+ case 4:
10292
11013
  plainInitiatorOneTimePbkCipher = _p.sent();
10293
11014
  // Check the nonce match to ensure the responder was the one holding the OTK
10294
11015
  if (initiatorRootKeyCipherClearJson.nonce !==
10295
11016
  plainInitiatorOneTimePbkCipher.nonce) {
10296
11017
  throw new KcCodeMismatchException('The nonce returned by responder does not match with the one created by the initiator.');
10297
11018
  }
10298
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
10299
- case 7:
10300
- initiatorSigPrk = _p.sent();
11019
+ initiatorSigPrk = this.keyService.currentSigPxk;
10301
11020
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.sigPbk)];
10302
- case 8:
11021
+ case 5:
10303
11022
  responderSigPbk = _p.sent();
10304
11023
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.pbk)];
10305
- case 9:
11024
+ case 6:
10306
11025
  responderPbk = _p.sent();
10307
11026
  return [4 /*yield*/, this.encryptionService.sign(initiatorSigPrk.jwk, responderPbk.toJSON())];
10308
- case 10:
11027
+ case 7:
10309
11028
  signedResponderPbk = _p.sent();
10310
11029
  return [4 /*yield*/, this.encryptionService.sign(initiatorSigPrk.jwk, responderSigPbk.toJSON())];
10311
- case 11:
11030
+ case 8:
10312
11031
  signedResponderSigPbk = _p.sent();
10313
11032
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.sharedKey)];
10314
- case 12:
11033
+ case 9:
10315
11034
  sharedKey = _p.sent();
10316
11035
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, sharedKey.toJSON(true))];
10317
- case 13:
11036
+ case 10:
10318
11037
  rkWrappedSharedKey = _p.sent();
10319
11038
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.mkSharedKey)];
10320
- case 14:
11039
+ case 11:
10321
11040
  mkSharedKey = _p.sent();
10322
11041
  return [4 /*yield*/, this.encryptionService.encrypt(masterKey.jwk, mkSharedKey.toJSON(true))];
10323
- case 15:
11042
+ case 12:
10324
11043
  mkWrappedMkSharedKey = _p.sent();
10325
- if (!responderContactCard) return [3 /*break*/, 19];
11044
+ if (!responderContactCard) return [3 /*break*/, 16];
10326
11045
  return [4 /*yield*/, this.keyFactory.createKey()];
10327
- case 16:
11046
+ case 13:
10328
11047
  receiverKey = _p.sent();
10329
11048
  _c = {};
10330
11049
  _e = (_d = JSON).stringify;
10331
11050
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, receiverKey.toJSON(true))];
10332
- case 17:
11051
+ case 14:
10333
11052
  _c.receiverWrappedKey = _e.apply(_d, [_p.sent()]),
10334
11053
  _c.receiverWrappingKeyId = rootKey.id;
10335
11054
  _g = (_f = JSON).stringify;
10336
11055
  return [4 /*yield*/, this.encryptionService.encrypt(receiverKey, responderContactCard.receiverCipherDataClearJson)];
10337
- case 18:
11056
+ case 15:
10338
11057
  responderContactCardCipherInput = (_c.receiverCipherData = _g.apply(_f, [_p.sent()]),
10339
11058
  _c);
10340
- _p.label = 19;
10341
- case 19:
10342
- if (!initiatorRootKeyCipherClearJson.initiatorContactCard) return [3 /*break*/, 28];
11059
+ _p.label = 16;
11060
+ case 16:
11061
+ if (!initiatorRootKeyCipherClearJson.initiatorContactCard) return [3 /*break*/, 25];
10343
11062
  initiatorContactCardFromInit = initiatorRootKeyCipherClearJson.initiatorContactCard;
10344
11063
  return [4 /*yield*/, this.keyFactory.createKey()];
10345
- case 20:
11064
+ case 17:
10346
11065
  ownerKey = _p.sent();
10347
11066
  return [4 /*yield*/, KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.contactCard.sharedCipherKey)];
10348
- case 21:
11067
+ case 18:
10349
11068
  sharedCipherKey = _p.sent();
10350
11069
  _j = (_h = JSON).stringify;
10351
11070
  return [4 /*yield*/, this.encryptionService.encrypt(rootKey.jwk, ownerKey.toJSON(true))];
10352
- case 22:
11071
+ case 19:
10353
11072
  ownerWrappedKey = _j.apply(_h, [_p.sent()]);
10354
11073
  ownerCipherDataClearJson = (initiatorContactCard === null || initiatorContactCard === void 0 ? void 0 : initiatorContactCard.ownerCipherDataClearJson) ||
10355
11074
  initiatorContactCardFromInit.ownerCipherDataClearJson;
10356
- if (!ownerCipherDataClearJson) return [3 /*break*/, 24];
11075
+ if (!ownerCipherDataClearJson) return [3 /*break*/, 21];
10357
11076
  return [4 /*yield*/, this.keyGraph.encryptToString(ownerKey, ownerCipherDataClearJson)];
10358
- case 23:
11077
+ case 20:
10359
11078
  _k = _p.sent();
10360
- return [3 /*break*/, 25];
10361
- case 24:
11079
+ return [3 /*break*/, 22];
11080
+ case 21:
10362
11081
  _k = '';
10363
- _p.label = 25;
10364
- case 25:
11082
+ _p.label = 22;
11083
+ case 22:
10365
11084
  ownerCipherData = _k;
10366
11085
  initiatorContactCardCipherInput = {
10367
11086
  ownerWrappedKey: ownerWrappedKey,
@@ -10372,16 +11091,16 @@
10372
11091
  sigPxkId: initiatorSigPrk.id,
10373
11092
  };
10374
11093
  return [4 /*yield*/, this.encryptionService.encrypt(sharedCipherKey, initiatorContactCardFromInit.sharedCipherDataClearJson)];
10375
- case 26:
11094
+ case 23:
10376
11095
  sharedCipherData = _p.sent();
10377
11096
  _l = initiatorContactCardSharedCipherInput;
10378
11097
  _o = (_m = JSON).stringify;
10379
11098
  return [4 /*yield*/, this.encryptionService.sign(initiatorSigPrk.jwk, sharedCipherData)];
10380
- case 27:
11099
+ case 24:
10381
11100
  _l.sharedCipherDataSig =
10382
11101
  _o.apply(_m, [_p.sent()]);
10383
- _p.label = 28;
10384
- case 28:
11102
+ _p.label = 25;
11103
+ case 25:
10385
11104
  // TODO ideally we update the shared data in the contact card sent to the responder as well since that
10386
11105
  // CC was created by the responder.
10387
11106
  return [2 /*return*/, new LrMutation({
@@ -10434,16 +11153,16 @@
10434
11153
  })(exports.KcLbopErrorCode || (exports.KcLbopErrorCode = {}));
10435
11154
  var CreateLbopQuery = gql__default['default'](templateObject_1$l || (templateObject_1$l = __makeTemplateObject(["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"], ["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"])));
10436
11155
  var DeleteLbopQuery = gql__default['default'](templateObject_2$i || (templateObject_2$i = __makeTemplateObject(["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"], ["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"])));
10437
- var UpdateLbopQuery = gql__default['default'](templateObject_3$g || (templateObject_3$g = __makeTemplateObject(["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"], ["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"])));
11156
+ var UpdateLbopQuery = gql__default['default'](templateObject_3$f || (templateObject_3$f = __makeTemplateObject(["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"], ["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"])));
10438
11157
  var LbopQuery = gql__default['default'](templateObject_4$b || (templateObject_4$b = __makeTemplateObject(["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"], ["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"])));
10439
11158
  var LbopsQuery = gql__default['default'](templateObject_5$a || (templateObject_5$a = __makeTemplateObject(["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"], ["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"])));
10440
11159
  var LbopService = /** @class */ (function () {
10441
- function LbopService(config, http, lrApollo, auth, authService, keyFactory, keyService, encryptionService, keyGraph, passwordService) {
11160
+ function LbopService(config, http, lrApollo, auth, auth2Service, keyFactory, keyService, encryptionService, keyGraph, passwordService) {
10442
11161
  this.config = config;
10443
11162
  this.http = http;
10444
11163
  this.lrApollo = lrApollo;
10445
11164
  this.auth = auth;
10446
- this.authService = authService;
11165
+ this.auth2Service = auth2Service;
10447
11166
  this.keyFactory = keyFactory;
10448
11167
  this.keyService = keyService;
10449
11168
  this.encryptionService = encryptionService;
@@ -10486,11 +11205,9 @@
10486
11205
  case 1:
10487
11206
  lbop = _a.sent();
10488
11207
  lbop.name = name;
10489
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
10490
- case 2:
10491
- masterKey = _a.sent();
11208
+ masterKey = this.keyService.currentMasterKey;
10492
11209
  return [4 /*yield*/, this.encryptionService.encrypt(masterKey.jwk, lbop)];
10493
- case 3:
11210
+ case 2:
10494
11211
  cipherMeta = _a.sent();
10495
11212
  return [4 /*yield*/, this.lrApollo.mutate({
10496
11213
  mutation: UpdateLbopQuery,
@@ -10501,7 +11218,7 @@
10501
11218
  },
10502
11219
  },
10503
11220
  })];
10504
- case 4:
11221
+ case 3:
10505
11222
  res = _a.sent();
10506
11223
  return [2 /*return*/, res.updateLbop];
10507
11224
  }
@@ -10521,11 +11238,9 @@
10521
11238
  })];
10522
11239
  case 1:
10523
11240
  res = _a.sent();
10524
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
10525
- case 2:
10526
- masterKey = _a.sent();
11241
+ masterKey = this.keyService.currentMasterKey;
10527
11242
  return [4 /*yield*/, this.encryptionService.decrypt(masterKey.jwk, JSON.parse(res.lbop.cipherMeta))];
10528
- case 3:
11243
+ case 2:
10529
11244
  plainCipherMeta = _a.sent();
10530
11245
  return [2 /*return*/, Object.assign({ id: res.id }, plainCipherMeta)];
10531
11246
  }
@@ -10543,7 +11258,7 @@
10543
11258
  })];
10544
11259
  case 1:
10545
11260
  res = _a.sent();
10546
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
11261
+ return [4 /*yield*/, this.keyService.currentMasterKey];
10547
11262
  case 2:
10548
11263
  masterKey = _a.sent();
10549
11264
  return [2 /*return*/, Promise.all(res.lbops.edges.map(function (edge) { return __awaiter(_this, void 0, void 0, function () {
@@ -10564,7 +11279,7 @@
10564
11279
  LbopService.prototype.create = function (_a) {
10565
11280
  var name = _a.name;
10566
11281
  return __awaiter(this, void 0, void 0, function () {
10567
- var lbops, lbopString, _loop_1, this_1, state_1, lbopKeyParams, lbopKey, _a, _b, _c, _d, _e, lbopKeyVerifier, wrappedLbopKeyVerifier, currentUser, masterKey, wrappedMasterKey, meta, cipherMeta, res;
11282
+ var lbops, lbopString, _loop_1, this_1, state_1, lbopKeyParams, lbopKey, _a, _b, _c, _d, _e, lbopKeyVerifier, wrappedLbopKeyVerifier, masterKey, wrappedMasterKey, meta, cipherMeta, res;
10568
11283
  return __generator(this, function (_f) {
10569
11284
  switch (_f.label) {
10570
11285
  case 0:
@@ -10606,18 +11321,13 @@
10606
11321
  return [4 /*yield*/, this.encryptionService.encrypt(lbopKey, lbopKeyVerifier.toJSON(true))];
10607
11322
  case 6:
10608
11323
  wrappedLbopKeyVerifier = _f.sent();
10609
- return [4 /*yield*/, this.authService.getUser()];
10610
- case 7:
10611
- currentUser = _f.sent();
10612
- return [4 /*yield*/, this.keyGraph.getKey(currentUser.currentUserKey.masterKey.id)];
10613
- case 8:
10614
- masterKey = _f.sent();
11324
+ masterKey = this.keyService.currentMasterKey;
10615
11325
  return [4 /*yield*/, this.encryptionService.encrypt(lbopKey, masterKey.jwk.toJSON(true))];
10616
- case 9:
11326
+ case 7:
10617
11327
  wrappedMasterKey = _f.sent();
10618
11328
  meta = Object.assign(Object.assign({}, (name && { name: name })), { partial: this.getPartial(lbopString) });
10619
11329
  return [4 /*yield*/, this.encryptionService.encrypt(masterKey.jwk, meta)];
10620
- case 10:
11330
+ case 8:
10621
11331
  cipherMeta = _f.sent();
10622
11332
  return [4 /*yield*/, this.lrApollo.mutate({
10623
11333
  mutation: CreateLbopQuery,
@@ -10627,12 +11337,12 @@
10627
11337
  lbopKeyParams: JSON.stringify(lbopKeyParams),
10628
11338
  lbopKeyVerifier: JSON.stringify(lbopKeyVerifier.toJSON(true)),
10629
11339
  wrappedLbopKeyVerifier: JSON.stringify(wrappedLbopKeyVerifier),
10630
- masterKeyId: currentUser.currentUserKey.masterKey.id,
11340
+ masterKeyId: masterKey.id,
10631
11341
  wrappedMasterKey: JSON.stringify(wrappedMasterKey),
10632
11342
  },
10633
11343
  },
10634
11344
  })];
10635
- case 11:
11345
+ case 9:
10636
11346
  res = _f.sent();
10637
11347
  return [2 /*return*/, Object.assign(Object.assign({}, res.createLbop.lbop), { lbopString: lbopString })];
10638
11348
  }
@@ -10848,7 +11558,7 @@
10848
11558
  };
10849
11559
  return LbopService;
10850
11560
  }());
10851
- LbopService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LbopService_Factory() { return new LbopService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(i4.AuthClass), i0.ɵɵinject(LifeReadyAuthService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(PasswordService)); }, token: LbopService, providedIn: "root" });
11561
+ LbopService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LbopService_Factory() { return new LbopService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(i2.AuthClass), i0.ɵɵinject(exports.Auth2Service), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(KeyService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(PasswordService)); }, token: LbopService, providedIn: "root" });
10852
11562
  LbopService.decorators = [
10853
11563
  { type: i0.Injectable, args: [{
10854
11564
  providedIn: 'root',
@@ -10856,17 +11566,17 @@
10856
11566
  ];
10857
11567
  LbopService.ctorParameters = function () { return [
10858
11568
  { type: undefined, decorators: [{ type: i0.Inject, args: [KC_CONFIG,] }] },
10859
- { type: i2$1.HttpClient },
11569
+ { type: i2$2.HttpClient },
10860
11570
  { type: LrApolloService },
10861
- { type: i4.AuthClass },
10862
- { type: LifeReadyAuthService },
11571
+ { type: i2.AuthClass },
11572
+ { type: exports.Auth2Service },
10863
11573
  { type: KeyFactoryService },
10864
11574
  { type: KeyService },
10865
11575
  { type: EncryptionService },
10866
11576
  { type: KeyGraphService },
10867
11577
  { type: PasswordService }
10868
11578
  ]; };
10869
- var templateObject_1$l, templateObject_2$i, templateObject_3$g, templateObject_4$b, templateObject_5$a;
11579
+ var templateObject_1$l, templateObject_2$i, templateObject_3$f, templateObject_4$b, templateObject_5$a;
10870
11580
 
10871
11581
  var LifeReadyModule = /** @class */ (function () {
10872
11582
  function LifeReadyModule() {
@@ -10880,13 +11590,13 @@
10880
11590
  useValue: config,
10881
11591
  },
10882
11592
  {
10883
- provide: i4.AuthClass,
11593
+ provide: i2.AuthClass,
10884
11594
  useValue: Auth__default['default'],
10885
11595
  },
10886
11596
  {
10887
11597
  provide: i0.APP_INITIALIZER,
10888
11598
  useFactory: configureAmplifyAuth,
10889
- deps: [KC_CONFIG, i4.AuthClass],
11599
+ deps: [KC_CONFIG, i2.AuthClass],
10890
11600
  multi: true,
10891
11601
  },
10892
11602
  {
@@ -10898,7 +11608,7 @@
10898
11608
  {
10899
11609
  provide: i1.APOLLO_OPTIONS,
10900
11610
  useFactory: configureApollo,
10901
- deps: [KC_CONFIG, i4.AuthClass],
11611
+ deps: [KC_CONFIG, i2.AuthClass],
10902
11612
  },
10903
11613
  ],
10904
11614
  };
@@ -10907,7 +11617,7 @@
10907
11617
  }());
10908
11618
  LifeReadyModule.decorators = [
10909
11619
  { type: i0.NgModule, args: [{
10910
- imports: [i2$1.HttpClientModule, i4$1.NgIdleKeepaliveModule.forRoot()],
11620
+ imports: [i2$2.HttpClientModule, i4.NgIdleKeepaliveModule.forRoot()],
10911
11621
  },] }
10912
11622
  ];
10913
11623
 
@@ -11067,10 +11777,10 @@
11067
11777
 
11068
11778
  var UpdateNotificationMutation = gqlTyped(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"], ["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"])));
11069
11779
  var UpdateAllNotificationsReadStateMutation = gqlTyped(templateObject_2$k || (templateObject_2$k = __makeTemplateObject(["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"], ["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"])));
11070
- var DebugCreateNotificationMutation = gqlTyped(templateObject_3$h || (templateObject_3$h = __makeTemplateObject(["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"], ["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"])));
11780
+ var DebugCreateNotificationMutation = gqlTyped(templateObject_3$g || (templateObject_3$g = __makeTemplateObject(["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"], ["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"])));
11071
11781
  var DebugDeleteAllNotificationsMutation = gqlTyped(templateObject_4$c || (templateObject_4$c = __makeTemplateObject(["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"], ["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"])));
11072
11782
  var UpdateNotificationFeatureStateMutation = gqlTyped(templateObject_5$b || (templateObject_5$b = __makeTemplateObject(["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"], ["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"])));
11073
- var templateObject_1$n, templateObject_2$k, templateObject_3$h, templateObject_4$c, templateObject_5$b;
11783
+ var templateObject_1$n, templateObject_2$k, templateObject_3$g, templateObject_4$c, templateObject_5$b;
11074
11784
 
11075
11785
  exports.NotificationService = /** @class */ (function (_super) {
11076
11786
  __extends(NotificationService, _super);
@@ -11234,14 +11944,14 @@
11234
11944
 
11235
11945
  var InitiateStripePaymentMethodCaptureMutation = gqlTyped(templateObject_1$o || (templateObject_1$o = __makeTemplateObject(["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"], ["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"])));
11236
11946
  var CompleteStripePaymentMethodCaptureMutation = gqlTyped(templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"], ["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"])));
11237
- var RemovePaymentMethodMutation = gqlTyped(templateObject_3$i || (templateObject_3$i = __makeTemplateObject(["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"], ["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"])));
11947
+ var RemovePaymentMethodMutation = gqlTyped(templateObject_3$h || (templateObject_3$h = __makeTemplateObject(["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"], ["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"])));
11238
11948
  var SetDefaultPaymentMethodMutation = gqlTyped(templateObject_4$d || (templateObject_4$d = __makeTemplateObject(["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"], ["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"])));
11239
11949
  var RemoveDefaultPaymentMethodMutation = gqlTyped(templateObject_5$c || (templateObject_5$c = __makeTemplateObject(["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"], ["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"])));
11240
11950
  var IssuePlanMutation = gqlTyped(templateObject_6$9 || (templateObject_6$9 = __makeTemplateObject(["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"], ["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"])));
11241
11951
  var CancelPlanMutation = gqlTyped(templateObject_7$8 || (templateObject_7$8 = __makeTemplateObject(["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"], ["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"])));
11242
11952
  var ChangePriceOptionMutation = gqlTyped(templateObject_8$7 || (templateObject_8$7 = __makeTemplateObject(["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"], ["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"])));
11243
11953
  var ReactivatePlanMutation = gqlTyped(templateObject_9$5 || (templateObject_9$5 = __makeTemplateObject(["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"], ["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"])));
11244
- var templateObject_1$o, templateObject_2$l, templateObject_3$i, templateObject_4$d, templateObject_5$c, templateObject_6$9, templateObject_7$8, templateObject_8$7, templateObject_9$5;
11954
+ var templateObject_1$o, templateObject_2$l, templateObject_3$h, templateObject_4$d, templateObject_5$c, templateObject_6$9, templateObject_7$8, templateObject_8$7, templateObject_9$5;
11245
11955
 
11246
11956
  exports.Plan2Service = /** @class */ (function (_super) {
11247
11957
  __extends(Plan2Service, _super);
@@ -11486,22 +12196,20 @@
11486
12196
  return [4 /*yield*/, this.keyGraph.getKey(sharedKeyId)];
11487
12197
  case 2:
11488
12198
  sharedKey = _e.sent();
11489
- return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
11490
- case 3:
11491
- sigPxk = _e.sent();
12199
+ sigPxk = this.keyService.currentSigPxk;
11492
12200
  return [4 /*yield*/, this.encryptionService.encrypt(sharedKey.jwk, contactCard)];
11493
- case 4:
12201
+ case 3:
11494
12202
  sharedCipherData = _e.sent();
11495
12203
  _b = (_a = JSON).stringify;
11496
12204
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, sharedCipherData)];
11497
- case 5:
12205
+ case 4:
11498
12206
  sharedCipherDataSig = _b.apply(_a, [_e.sent()]);
11499
12207
  ownerPlainData = {
11500
12208
  name: new ContactCardName(contactCard.name),
11501
12209
  };
11502
12210
  _d = (_c = JSON).stringify;
11503
12211
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, ownerPlainData)];
11504
- case 6:
12212
+ case 5:
11505
12213
  ownerPlainDataSig = _d.apply(_c, [_e.sent()]);
11506
12214
  return [4 /*yield*/, this.lrApollo.mutate({
11507
12215
  mutation: UpdateOwnedContactCard,
@@ -11517,7 +12225,7 @@
11517
12225
  },
11518
12226
  },
11519
12227
  })];
11520
- case 7:
12228
+ case 6:
11521
12229
  _e.sent();
11522
12230
  return [2 /*return*/];
11523
12231
  }
@@ -11540,16 +12248,94 @@
11540
12248
  ]; };
11541
12249
  var templateObject_1$p;
11542
12250
 
12251
+ var RequestUserDeleteMutation = gql__default['default'](templateObject_1$q || (templateObject_1$q = __makeTemplateObject(["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"], ["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"])));
12252
+ var CancelUserDeleteMutation = gql__default['default'](templateObject_2$m || (templateObject_2$m = __makeTemplateObject(["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"], ["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"])));
12253
+ var LoginHistoryQuery = gql__default['default'](templateObject_3$i || (templateObject_3$i = __makeTemplateObject(["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"], ["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"])));
12254
+ var templateObject_1$q, templateObject_2$m, templateObject_3$i;
12255
+
12256
+ var UserService = /** @class */ (function () {
12257
+ function UserService(lrApollo) {
12258
+ this.lrApollo = lrApollo;
12259
+ }
12260
+ UserService.prototype.requestUserDelete = function () {
12261
+ return __awaiter(this, void 0, void 0, function () {
12262
+ var res;
12263
+ return __generator(this, function (_a) {
12264
+ switch (_a.label) {
12265
+ case 0: return [4 /*yield*/, this.lrApollo.mutate({
12266
+ mutation: RequestUserDeleteMutation,
12267
+ variables: {
12268
+ input: {},
12269
+ },
12270
+ })];
12271
+ case 1:
12272
+ res = _a.sent();
12273
+ return [2 /*return*/, res.requestUserDelete.userDelete];
12274
+ }
12275
+ });
12276
+ });
12277
+ };
12278
+ UserService.prototype.cancelUserDelete = function () {
12279
+ return __awaiter(this, void 0, void 0, function () {
12280
+ var res;
12281
+ return __generator(this, function (_a) {
12282
+ switch (_a.label) {
12283
+ case 0: return [4 /*yield*/, this.lrApollo.mutate({
12284
+ mutation: CancelUserDeleteMutation,
12285
+ variables: {
12286
+ input: {},
12287
+ },
12288
+ })];
12289
+ case 1:
12290
+ res = _a.sent();
12291
+ return [2 /*return*/, res.cancelUserDelete.id];
12292
+ }
12293
+ });
12294
+ });
12295
+ };
12296
+ UserService.prototype.loginHistory = function (first, after) {
12297
+ if (first === void 0) { first = null; }
12298
+ if (after === void 0) { after = null; }
12299
+ return __awaiter(this, void 0, void 0, function () {
12300
+ var res;
12301
+ return __generator(this, function (_a) {
12302
+ switch (_a.label) {
12303
+ case 0: return [4 /*yield*/, this.lrApollo.query({
12304
+ query: LoginHistoryQuery,
12305
+ variables: {
12306
+ first: first,
12307
+ after: after,
12308
+ },
12309
+ })];
12310
+ case 1:
12311
+ res = _a.sent();
12312
+ return [2 /*return*/, res.loginHistory];
12313
+ }
12314
+ });
12315
+ });
12316
+ };
12317
+ return UserService;
12318
+ }());
12319
+ UserService.ɵprov = i0.ɵɵdefineInjectable({ factory: function UserService_Factory() { return new UserService(i0.ɵɵinject(LrApolloService)); }, token: UserService, providedIn: "root" });
12320
+ UserService.decorators = [
12321
+ { type: i0.Injectable, args: [{
12322
+ providedIn: 'root',
12323
+ },] }
12324
+ ];
12325
+ UserService.ctorParameters = function () { return [
12326
+ { type: LrApolloService }
12327
+ ]; };
12328
+
11543
12329
  var TrustedPartyProperties = "\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n " + SharedContactCardFields + "\n }\n myContactCard {\n " + SharedContactCardFields + "\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n theirItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n " + KeyExchangeFields + "\n }\n " + UserSharedKeyFields + "\n }\n }";
11544
- var GetTrustedPartiesQuery = gql__default['default'](templateObject_1$q || (templateObject_1$q = __makeTemplateObject(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"], ["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"])), TrustedPartyProperties, KeyGraphField);
11545
- var GetAllTrustedPartiesQuery = gql__default['default'](templateObject_2$m || (templateObject_2$m = __makeTemplateObject(["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"], ["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"])), TrustedPartyProperties, KeyExchangeFields, KeyExchangeFields, KeyGraphField);
12330
+ var GetTrustedPartiesQuery = gql__default['default'](templateObject_1$r || (templateObject_1$r = __makeTemplateObject(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"], ["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"])), TrustedPartyProperties, KeyGraphField);
12331
+ var GetAllTrustedPartiesQuery = gql__default['default'](templateObject_2$n || (templateObject_2$n = __makeTemplateObject(["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"], ["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ", "\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: \"state,-created\"\n ) {\n edges {\n node {\n ", "\n }\n }\n }\n ", "\n}"])), TrustedPartyProperties, KeyExchangeFields, KeyExchangeFields, KeyGraphField);
11546
12332
  var GetTrustedPartyQuery = gql__default['default'](templateObject_3$j || (templateObject_3$j = __makeTemplateObject(["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ", "\n }\n ", "\n}"], ["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ", "\n }\n ", "\n}"])), TrustedPartyProperties, KeyGraphField);
11547
12333
  var DeclineTrustedPartyInvitationMutation = gql__default['default'](templateObject_4$e || (templateObject_4$e = __makeTemplateObject(["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"], ["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"])));
11548
12334
  var CancelTrustedPartyInvitationMutation = gql__default['default'](templateObject_5$d || (templateObject_5$d = __makeTemplateObject(["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"], ["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"])));
11549
12335
  var DeleteTrustedPartyMutation = gql__default['default'](templateObject_6$a || (templateObject_6$a = __makeTemplateObject(["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"], ["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"])));
11550
- var ShareCategoryMutation = gql__default['default'](templateObject_7$9 || (templateObject_7$9 = __makeTemplateObject(["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"], ["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"])));
11551
- var UnshareCategoryMutation = gql__default['default'](templateObject_8$8 || (templateObject_8$8 = __makeTemplateObject(["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"], ["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"])));
11552
- var templateObject_1$q, templateObject_2$m, templateObject_3$j, templateObject_4$e, templateObject_5$d, templateObject_6$a, templateObject_7$9, templateObject_8$8;
12336
+ var ShareCategoryMutation = gql__default['default'](templateObject_7$9 || (templateObject_7$9 = __makeTemplateObject(["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"], ["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"])));
12337
+ var UnshareCategoryMutation = gql__default['default'](templateObject_8$8 || (templateObject_8$8 = __makeTemplateObject(["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"], ["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"])));
12338
+ var templateObject_1$r, templateObject_2$n, templateObject_3$j, templateObject_4$e, templateObject_5$d, templateObject_6$a, templateObject_7$9, templateObject_8$8;
11553
12339
 
11554
12340
  var TrustedPartyRole = /** @class */ (function () {
11555
12341
  function TrustedPartyRole() {
@@ -12041,14 +12827,14 @@
12041
12827
  };
12042
12828
  return TrustedPartyService;
12043
12829
  }());
12044
- TrustedPartyService.ɵprov = i0.ɵɵdefineInjectable({ factory: function TrustedPartyService_Factory() { return new TrustedPartyService(i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(SharedContactCardService), i0.ɵɵinject(UserService), i0.ɵɵinject(LifeReadyAuthService), i0.ɵɵinject(KeyExchangeService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(EncryptionService)); }, token: TrustedPartyService, providedIn: "root" });
12830
+ TrustedPartyService.ɵprov = i0.ɵɵdefineInjectable({ factory: function TrustedPartyService_Factory() { return new TrustedPartyService(i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(LrApolloService), i0.ɵɵinject(SharedContactCardService), i0.ɵɵinject(UserService), i0.ɵɵinject(LifeReadyAuthService), i0.ɵɵinject(KeyExchangeService), i0.ɵɵinject(KeyGraphService), i0.ɵɵinject(KeyService), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(EncryptionService)); }, token: TrustedPartyService, providedIn: "root" });
12045
12831
  TrustedPartyService.decorators = [
12046
12832
  { type: i0.Injectable, args: [{
12047
12833
  providedIn: 'root',
12048
12834
  },] }
12049
12835
  ];
12050
12836
  TrustedPartyService.ctorParameters = function () { return [
12051
- { type: i2$1.HttpClient },
12837
+ { type: i2$2.HttpClient },
12052
12838
  { type: LrApolloService },
12053
12839
  { type: SharedContactCardService },
12054
12840
  { type: UserService },
@@ -12489,14 +13275,14 @@
12489
13275
  };
12490
13276
  return RecordTypeService;
12491
13277
  }());
12492
- RecordTypeService.ɵprov = i0.ɵɵdefineInjectable({ factory: function RecordTypeService_Factory() { return new RecordTypeService(i0.ɵɵinject(i2$1.HttpClient)); }, token: RecordTypeService, providedIn: "root" });
13278
+ RecordTypeService.ɵprov = i0.ɵɵdefineInjectable({ factory: function RecordTypeService_Factory() { return new RecordTypeService(i0.ɵɵinject(i2$2.HttpClient)); }, token: RecordTypeService, providedIn: "root" });
12493
13279
  RecordTypeService.decorators = [
12494
13280
  { type: i0.Injectable, args: [{
12495
13281
  providedIn: 'root',
12496
13282
  },] }
12497
13283
  ];
12498
13284
  RecordTypeService.ctorParameters = function () { return [
12499
- { type: i2$1.HttpClient }
13285
+ { type: i2$2.HttpClient }
12500
13286
  ]; };
12501
13287
 
12502
13288
  (function (RecordFieldType) {
@@ -13158,7 +13944,7 @@
13158
13944
  };
13159
13945
  return RegisterService;
13160
13946
  }());
13161
- RegisterService.ɵprov = i0.ɵɵdefineInjectable({ factory: function RegisterService_Factory() { return new RegisterService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i4.AuthClass), i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(PasswordService)); }, token: RegisterService, providedIn: "root" });
13947
+ RegisterService.ɵprov = i0.ɵɵdefineInjectable({ factory: function RegisterService_Factory() { return new RegisterService(i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(i2.AuthClass), i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(PasswordService)); }, token: RegisterService, providedIn: "root" });
13162
13948
  RegisterService.decorators = [
13163
13949
  { type: i0.Injectable, args: [{
13164
13950
  providedIn: 'root',
@@ -13166,8 +13952,8 @@
13166
13952
  ];
13167
13953
  RegisterService.ctorParameters = function () { return [
13168
13954
  { type: undefined, decorators: [{ type: i0.Inject, args: [KC_CONFIG,] }] },
13169
- { type: i4.AuthClass },
13170
- { type: i2$1.HttpClient },
13955
+ { type: i2.AuthClass },
13956
+ { type: i2$2.HttpClient },
13171
13957
  { type: KeyFactoryService },
13172
13958
  { type: EncryptionService },
13173
13959
  { type: PasswordService }
@@ -13205,8 +13991,8 @@
13205
13991
  })
13206
13992
  ], exports.ɵn);
13207
13993
 
13208
- var CreateScenarioMutation = gqlTyped(templateObject_1$r || (templateObject_1$r = __makeTemplateObject(["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"], ["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"])));
13209
- var UpdateScenarioMutation = gqlTyped(templateObject_2$n || (templateObject_2$n = __makeTemplateObject(["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"], ["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"])));
13994
+ var CreateScenarioMutation = gqlTyped(templateObject_1$s || (templateObject_1$s = __makeTemplateObject(["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"], ["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"])));
13995
+ var UpdateScenarioMutation = gqlTyped(templateObject_2$o || (templateObject_2$o = __makeTemplateObject(["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"], ["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"])));
13210
13996
  var DeleteScenarioMutation = gqlTyped(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"])));
13211
13997
  var CreateScenarioClaimMutation = gqlTyped(templateObject_4$f || (templateObject_4$f = __makeTemplateObject(["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"], ["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"])));
13212
13998
  var CancelScenarioClaimMutation = gqlTyped(templateObject_5$e || (templateObject_5$e = __makeTemplateObject(["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"], ["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"])));
@@ -13215,11 +14001,11 @@
13215
14001
  var ReceiveScenarioClaimMutation = gqlTyped(templateObject_8$9 || (templateObject_8$9 = __makeTemplateObject(["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"], ["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"])));
13216
14002
  var DebugExpireScenarioClaimMutation = gqlTyped(templateObject_9$6 || (templateObject_9$6 = __makeTemplateObject(["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"], ["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"])));
13217
14003
  var DebugExpireTpPasswordResetRequestMutation = gqlTyped(templateObject_10$4 || (templateObject_10$4 = __makeTemplateObject(["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"], ["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"])));
13218
- var templateObject_1$r, templateObject_2$n, templateObject_3$k, templateObject_4$f, templateObject_5$e, templateObject_6$b, templateObject_7$a, templateObject_8$9, templateObject_9$6, templateObject_10$4;
14004
+ var templateObject_1$s, templateObject_2$o, templateObject_3$k, templateObject_4$f, templateObject_5$e, templateObject_6$b, templateObject_7$a, templateObject_8$9, templateObject_9$6, templateObject_10$4;
13219
14005
 
13220
- var ScenarioQuery = gqlTyped(templateObject_1$s || (templateObject_1$s = __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 receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\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 itemKey {\n id\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 receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\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 itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"])));
13221
- var SharedScenarioQuery = gqlTyped(templateObject_2$o || (templateObject_2$o = __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 receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\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 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 receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\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 approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));
13222
- var templateObject_1$s, templateObject_2$o;
14006
+ var ScenarioQuery = gqlTyped(templateObject_1$t || (templateObject_1$t = __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 receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\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 itemKey {\n id\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 receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\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 itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"])));
14007
+ var SharedScenarioQuery = gqlTyped(templateObject_2$p || (templateObject_2$p = __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 receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\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 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 receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\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 approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));
14008
+ var templateObject_1$t, templateObject_2$p;
13223
14009
 
13224
14010
  function throwClaimIdMismatch() {
13225
14011
  throw new KcBadArgumentException('claimId does not match with the current claimId of the scenario');
@@ -14065,8 +14851,8 @@
14065
14851
  })
14066
14852
  ], exports.ScenarioService);
14067
14853
 
14068
- var ServerConfigQuery = gqlTyped(templateObject_1$t || (templateObject_1$t = __makeTemplateObject(["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"], ["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"])));
14069
- var templateObject_1$t;
14854
+ var ServerConfigQuery = gqlTyped(templateObject_1$u || (templateObject_1$u = __makeTemplateObject(["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"], ["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"])));
14855
+ var templateObject_1$u;
14070
14856
 
14071
14857
  exports.ServerConfigService = /** @class */ (function (_super) {
14072
14858
  __extends(ServerConfigService, _super);
@@ -14114,11 +14900,11 @@
14114
14900
  })
14115
14901
  ], exports.ServerConfigService);
14116
14902
 
14117
- var UpdateOwnedContactCardMutation = gqlTyped(templateObject_1$u || (templateObject_1$u = __makeTemplateObject(["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"], ["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"])));
14118
- var UpdateReceivedContactCardMutation = gqlTyped(templateObject_2$p || (templateObject_2$p = __makeTemplateObject(["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"], ["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"])));
14903
+ var UpdateOwnedContactCardMutation = gqlTyped(templateObject_1$v || (templateObject_1$v = __makeTemplateObject(["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"], ["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"])));
14904
+ var UpdateReceivedContactCardMutation = gqlTyped(templateObject_2$q || (templateObject_2$q = __makeTemplateObject(["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"], ["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"])));
14119
14905
  var GetOwnedContactCardKeyIdsQuery = gqlTyped(templateObject_3$l || (templateObject_3$l = __makeTemplateObject(["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"], ["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"])));
14120
14906
  var GetReceivedContactCardKeyIdQuery = gqlTyped(templateObject_4$g || (templateObject_4$g = __makeTemplateObject(["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"], ["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"])));
14121
- var templateObject_1$u, templateObject_2$p, templateObject_3$l, templateObject_4$g;
14907
+ var templateObject_1$v, templateObject_2$q, templateObject_3$l, templateObject_4$g;
14122
14908
 
14123
14909
  exports.SharedContactCard2Service = /** @class */ (function () {
14124
14910
  function SharedContactCard2Service(ngZone, keyService, keyGraph, encryptionService, lrGraphQL) {
@@ -14192,22 +14978,21 @@
14192
14978
  case 6:
14193
14979
  sharedKey = _e.sent();
14194
14980
  return [3 /*break*/, 7];
14195
- case 7: return [4 /*yield*/, this.keyService.getCurrentSigPxk()];
14196
- case 8:
14197
- sigPxk = _e.sent();
14981
+ case 7:
14982
+ sigPxk = this.keyService.currentSigPxk;
14198
14983
  return [4 /*yield*/, this.encryptionService.encrypt(sharedKey.jwk, sharedCipherDataClearJson)];
14199
- case 9:
14984
+ case 8:
14200
14985
  sharedCipherData = _e.sent();
14201
14986
  _b = (_a = JSON).stringify;
14202
14987
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, sharedCipherData)];
14203
- case 10:
14988
+ case 9:
14204
14989
  sharedCipherDataSig = _b.apply(_a, [_e.sent()]);
14205
14990
  _d = (_c = JSON).stringify;
14206
14991
  return [4 /*yield*/, this.encryptionService.sign(sigPxk.jwk, ownerPlainDataJson)];
14207
- case 11:
14992
+ case 10:
14208
14993
  ownerPlainDataSig = _d.apply(_c, [_e.sent()]);
14209
14994
  return [4 /*yield*/, this.encryptionService.encryptToString(ownerKey.jwk, ownerCipherDataClearJson)];
14210
- case 12:
14995
+ case 11:
14211
14996
  ownerCipherData = _e.sent();
14212
14997
  return [2 /*return*/, new LrMutation({
14213
14998
  mutation: UpdateOwnedContactCardMutation,
@@ -14608,7 +15393,7 @@
14608
15393
  };
14609
15394
  return TpPasswordResetUserService;
14610
15395
  }(LrService));
14611
- exports.TpPasswordResetUserService.ɵprov = i0.ɵɵdefineInjectable({ factory: function TpPasswordResetUserService_Factory() { return new exports.TpPasswordResetUserService(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(PasswordService), i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(i4.AuthClass)); }, token: exports.TpPasswordResetUserService, providedIn: "root" });
15396
+ exports.TpPasswordResetUserService.ɵprov = i0.ɵɵdefineInjectable({ factory: function TpPasswordResetUserService_Factory() { return new exports.TpPasswordResetUserService(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(KC_CONFIG), i0.ɵɵinject(KeyFactoryService), i0.ɵɵinject(EncryptionService), i0.ɵɵinject(PasswordService), i0.ɵɵinject(i2$2.HttpClient), i0.ɵɵinject(i2.AuthClass)); }, token: exports.TpPasswordResetUserService, providedIn: "root" });
14612
15397
  exports.TpPasswordResetUserService.decorators = [
14613
15398
  { type: i0.Injectable, args: [{
14614
15399
  providedIn: 'root',
@@ -14621,8 +15406,8 @@
14621
15406
  { type: KeyFactoryService },
14622
15407
  { type: EncryptionService },
14623
15408
  { type: PasswordService },
14624
- { type: i2$1.HttpClient },
14625
- { type: i4.AuthClass }
15409
+ { type: i2$2.HttpClient },
15410
+ { type: i2.AuthClass }
14626
15411
  ]; };
14627
15412
  exports.TpPasswordResetUserService = __decorate([
14628
15413
  RunOutsideAngular({
@@ -14748,18 +15533,18 @@
14748
15533
  })
14749
15534
  ], exports.TpPasswordResetService);
14750
15535
 
14751
- var DeleteTpMutation = gqlTyped(templateObject_1$v || (templateObject_1$v = __makeTemplateObject(["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"])));
14752
- var ShareDirectoryMutation = gqlTyped(templateObject_2$q || (templateObject_2$q = __makeTemplateObject(["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"], ["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"])));
14753
- var UnshareDirectoryMutation = gqlTyped(templateObject_3$m || (templateObject_3$m = __makeTemplateObject(["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"], ["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"])));
14754
- var ShareFileMutation = gqlTyped(templateObject_4$h || (templateObject_4$h = __makeTemplateObject(["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"], ["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"])));
14755
- var UnshareFileMutation = gqlTyped(templateObject_5$f || (templateObject_5$f = __makeTemplateObject(["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"], ["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"])));
15536
+ var DeleteTpMutation = gqlTyped(templateObject_1$w || (templateObject_1$w = __makeTemplateObject(["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"], ["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"])));
15537
+ var ShareDirectoryMutation = gqlTyped(templateObject_2$r || (templateObject_2$r = __makeTemplateObject(["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"], ["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"])));
15538
+ var UnshareDirectoryMutation = gqlTyped(templateObject_3$m || (templateObject_3$m = __makeTemplateObject(["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"], ["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"])));
15539
+ var ShareFileMutation = gqlTyped(templateObject_4$h || (templateObject_4$h = __makeTemplateObject(["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"], ["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"])));
15540
+ var UnshareFileMutation = gqlTyped(templateObject_5$f || (templateObject_5$f = __makeTemplateObject(["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"], ["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"])));
14756
15541
  var RequestTpMkReshareMutation = gqlTyped(templateObject_6$c || (templateObject_6$c = __makeTemplateObject(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"], ["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"])));
14757
15542
  var RespondTpMkReshareMutation = gqlTyped(templateObject_7$b || (templateObject_7$b = __makeTemplateObject(["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"], ["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"])));
14758
15543
  var CompleteTpMkReshareMutation = gqlTyped(templateObject_8$a || (templateObject_8$a = __makeTemplateObject(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"], ["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"])));
14759
- var templateObject_1$v, templateObject_2$q, templateObject_3$m, templateObject_4$h, templateObject_5$f, templateObject_6$c, templateObject_7$b, templateObject_8$a;
15544
+ var templateObject_1$w, templateObject_2$r, templateObject_3$m, templateObject_4$h, templateObject_5$f, templateObject_6$c, templateObject_7$b, templateObject_8$a;
14760
15545
 
14761
- var TpCurrentUserSharedKeyQuery = gqlTyped(templateObject_1$w || (templateObject_1$w = __makeTemplateObject(["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"], ["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"])));
14762
- var templateObject_1$w;
15546
+ var TpCurrentUserSharedKeyQuery = gqlTyped(templateObject_1$x || (templateObject_1$x = __makeTemplateObject(["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"], ["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"])));
15547
+ var templateObject_1$x;
14763
15548
 
14764
15549
  exports.TrustedParty2Service = /** @class */ (function (_super) {
14765
15550
  __extends(TrustedParty2Service, _super);
@@ -14909,22 +15694,20 @@
14909
15694
  if (userSharedKey.mkSharedKey) {
14910
15695
  throw new KcBadStateException('TP already has mkSharedKey');
14911
15696
  }
14912
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
14913
- case 2:
14914
- masterKey = _a.sent();
15697
+ masterKey = this.keyService.currentMasterKey;
14915
15698
  return [4 /*yield*/, this.keyFactory.createPkcKey()];
14916
- case 3:
15699
+ case 2:
14917
15700
  prk = _a.sent();
14918
15701
  return [4 /*yield*/, this.encryptionService.encryptToString(masterKey.jwk, prk.toJSON(true))];
14919
- case 4:
15702
+ case 3:
14920
15703
  mkWrappedMkPrk = _a.sent();
14921
15704
  return [4 /*yield*/, this.keyGraph.getKey(userSharedKey.sharedKey.id)];
14922
- case 5:
15705
+ case 4:
14923
15706
  sharedKey = _a.sent();
14924
15707
  return [4 /*yield*/, this.encryptionService.encryptToString(sharedKey.jwk, {
14925
15708
  pbk: prk.toJSON(),
14926
15709
  })];
14927
- case 6:
15710
+ case 5:
14928
15711
  mkReshareRequestCipher = _a.sent();
14929
15712
  return [4 /*yield*/, new LrMutation({
14930
15713
  mutation: RequestTpMkReshareMutation,
@@ -14939,7 +15722,7 @@
14939
15722
  },
14940
15723
  },
14941
15724
  })];
14942
- case 7: return [2 /*return*/, _a.sent()];
15725
+ case 6: return [2 /*return*/, _a.sent()];
14943
15726
  }
14944
15727
  });
14945
15728
  });
@@ -15020,11 +15803,9 @@
15020
15803
  case 6:
15021
15804
  mkSharedKey = (_d.jwk = _e.sent(),
15022
15805
  _d);
15023
- return [4 /*yield*/, this.keyService.getCurrentMasterKey()];
15024
- case 7:
15025
- masterKey = _e.sent();
15806
+ masterKey = this.keyService.currentMasterKey;
15026
15807
  return [4 /*yield*/, this.encryptionService.encryptToString(masterKey.jwk, mkSharedKey.jwk.toJSON(true))];
15027
- case 8:
15808
+ case 7:
15028
15809
  mkWrappedMkSharedKey = _e.sent();
15029
15810
  return [2 /*return*/, new LrMutation({
15030
15811
  mutation: CompleteTpMkReshareMutation,
@@ -15204,14 +15985,14 @@
15204
15985
  };
15205
15986
  return TwoFactorService;
15206
15987
  }());
15207
- TwoFactorService.ɵprov = i0.ɵɵdefineInjectable({ factory: function TwoFactorService_Factory() { return new TwoFactorService(i0.ɵɵinject(i4.AuthClass)); }, token: TwoFactorService, providedIn: "root" });
15988
+ TwoFactorService.ɵprov = i0.ɵɵdefineInjectable({ factory: function TwoFactorService_Factory() { return new TwoFactorService(i0.ɵɵinject(i2.AuthClass)); }, token: TwoFactorService, providedIn: "root" });
15208
15989
  TwoFactorService.decorators = [
15209
15990
  { type: i0.Injectable, args: [{
15210
15991
  providedIn: 'root',
15211
15992
  },] }
15212
15993
  ];
15213
15994
  TwoFactorService.ctorParameters = function () { return [
15214
- { type: i4.AuthClass }
15995
+ { type: i2.AuthClass }
15215
15996
  ]; };
15216
15997
 
15217
15998
  /*
@@ -15225,6 +16006,7 @@
15225
16006
  exports.ApiContactCard = ApiContactCard;
15226
16007
  exports.ApiCurrentUser = ApiCurrentUser;
15227
16008
  exports.ArchiveDirectoryMutation = ArchiveDirectoryMutation;
16009
+ exports.AuthTypes = auth2_types;
15228
16010
  exports.CancelUserDeleteMutation = CancelUserDeleteMutation;
15229
16011
  exports.Category = Category;
15230
16012
  exports.CategoryFields = CategoryFields;
@@ -15344,7 +16126,6 @@
15344
16126
  exports.RecordTypeFieldOption = RecordTypeFieldOption;
15345
16127
  exports.RecordTypeService = RecordTypeService;
15346
16128
  exports.RecordTypeSummary = RecordTypeSummary;
15347
- exports.RegisterResult = RegisterResult;
15348
16129
  exports.RegisterService = RegisterService;
15349
16130
  exports.RequestUserDeleteMutation = RequestUserDeleteMutation;
15350
16131
  exports.RespondOtkMutation = RespondOtkMutation;