@lifeready/core 5.0.9 → 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.
- package/bundles/lifeready-core.umd.js +1515 -734
- package/bundles/lifeready-core.umd.js.map +1 -1
- package/bundles/lifeready-core.umd.min.js +1 -1
- package/bundles/lifeready-core.umd.min.js.map +1 -1
- package/esm2015/lib/_common/key.js +28 -0
- package/esm2015/lib/_common/types.js +1 -1
- package/esm2015/lib/api/types/lr-graphql.types.js +1 -1
- package/esm2015/lib/auth/auth.types.js +1 -3
- package/esm2015/lib/auth2/auth2.gql.private.js +78 -0
- package/esm2015/lib/auth2/auth2.service.js +591 -0
- package/esm2015/lib/auth2/auth2.types.js +21 -0
- package/esm2015/lib/contact-card/contact-card.service.js +3 -3
- package/esm2015/lib/contact-card/contact-card2.service.js +3 -3
- package/esm2015/lib/item2/item2.service.js +9 -9
- package/esm2015/lib/key/key-factory.service.js +1 -1
- package/esm2015/lib/key/key-graph.service.js +2 -2
- package/esm2015/lib/key/key-meta.service.js +2 -2
- package/esm2015/lib/key/key.service.js +6 -6
- package/esm2015/lib/key-exchange/key-exchange.service.js +24 -29
- package/esm2015/lib/key-exchange/key-exchange2.service.js +16 -17
- package/esm2015/lib/lbop/lbop.service.js +13 -14
- package/esm2015/lib/profile/profile.service.js +2 -2
- package/esm2015/lib/profile/profile.types.js +1 -1
- package/esm2015/lib/register/register.service.js +1 -1
- package/esm2015/lib/register/register.types.js +3 -0
- package/esm2015/lib/server-config/server-config.gql.js +1 -1
- package/esm2015/lib/shared-contact-card/shared-contact-card.service.js +3 -3
- package/esm2015/lib/shared-contact-card/shared-contact-card2.service.js +2 -2
- package/esm2015/lib/tp-assembly/tp-assembly.js +3 -3
- package/esm2015/lib/trusted-party/trusted-party2.service.js +4 -4
- package/esm2015/public-api.js +4 -1
- package/fesm2015/lifeready-core.js +876 -199
- package/fesm2015/lifeready-core.js.map +1 -1
- package/lib/_common/key.d.ts +14 -0
- package/lib/_common/types.d.ts +6 -0
- package/lib/api/types/lr-graphql.types.d.ts +1 -0
- package/lib/auth/auth.types.d.ts +0 -6
- package/lib/auth2/auth2.gql.private.d.ts +12 -0
- package/lib/auth2/auth2.service.d.ts +70 -0
- package/lib/auth2/auth2.types.d.ts +50 -0
- package/lib/item2/item2.service.d.ts +3 -3
- package/lib/key/key-factory.service.d.ts +1 -0
- package/lib/key/key-graph.service.d.ts +2 -3
- package/lib/key/key.service.d.ts +5 -5
- package/lib/key-exchange/key-exchange.service.d.ts +3 -5
- package/lib/lbop/lbop.service.d.ts +3 -3
- package/lib/profile/profile.types.d.ts +2 -2
- package/lib/register/register.service.d.ts +1 -1
- package/lib/register/register.types.d.ts +6 -0
- package/lib/server-config/server-config.gql.d.ts +1 -1
- package/lib/server-config/server-config.service.d.ts +1 -1
- package/lib/shared-contact-card/shared-contact-card.service.d.ts +2 -2
- package/lifeready-core.metadata.json +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +3 -0
|
@@ -1120,19 +1120,19 @@ class KeyService {
|
|
|
1120
1120
|
populateKeys(keys) {
|
|
1121
1121
|
this.keys = keys;
|
|
1122
1122
|
}
|
|
1123
|
-
|
|
1123
|
+
get currentPassKey() {
|
|
1124
1124
|
return this.keys.passKey;
|
|
1125
1125
|
}
|
|
1126
|
-
|
|
1126
|
+
get currentMasterKey() {
|
|
1127
1127
|
return this.keys.masterKey;
|
|
1128
1128
|
}
|
|
1129
|
-
|
|
1129
|
+
get currentRootKey() {
|
|
1130
1130
|
return this.keys.rootKey;
|
|
1131
1131
|
}
|
|
1132
|
-
|
|
1132
|
+
get currentPxk() {
|
|
1133
1133
|
return this.keys.pxk;
|
|
1134
1134
|
}
|
|
1135
|
-
|
|
1135
|
+
get currentSigPxk() {
|
|
1136
1136
|
return this.keys.sigPxk;
|
|
1137
1137
|
}
|
|
1138
1138
|
expiresAfter(seconds) {
|
|
@@ -1360,7 +1360,7 @@ class KeyGraphService {
|
|
|
1360
1360
|
return key;
|
|
1361
1361
|
}
|
|
1362
1362
|
else {
|
|
1363
|
-
return this.unwrapKey(this.keyService.
|
|
1363
|
+
return this.unwrapKey(this.keyService.currentMasterKey.id, keyId);
|
|
1364
1364
|
}
|
|
1365
1365
|
});
|
|
1366
1366
|
}
|
|
@@ -3014,8 +3014,6 @@ class CurrentUser {
|
|
|
3014
3014
|
}
|
|
3015
3015
|
class LoginResult {
|
|
3016
3016
|
}
|
|
3017
|
-
class RegisterResult {
|
|
3018
|
-
}
|
|
3019
3017
|
var RecoveryStatus;
|
|
3020
3018
|
(function (RecoveryStatus) {
|
|
3021
3019
|
RecoveryStatus["NONE"] = "none";
|
|
@@ -3757,7 +3755,7 @@ class KeyMetaService {
|
|
|
3757
3755
|
}
|
|
3758
3756
|
else {
|
|
3759
3757
|
// Adding to root directory
|
|
3760
|
-
const rootKey = this.keyService.
|
|
3758
|
+
const rootKey = this.keyService.currentRootKey;
|
|
3761
3759
|
const wrappedKey = JSON.stringify(yield this.encryptionService.encrypt(rootKey.jwk, key.toJSON(true)));
|
|
3762
3760
|
rootWrappingKey = {
|
|
3763
3761
|
wrappingKeyId: rootKey.id,
|
|
@@ -4269,7 +4267,7 @@ class ProfileService {
|
|
|
4269
4267
|
}
|
|
4270
4268
|
prepareContactCardInput(contactCard) {
|
|
4271
4269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4272
|
-
const sigPxk =
|
|
4270
|
+
const sigPxk = this.keyService.currentSigPxk;
|
|
4273
4271
|
const publicDataSig = JSON.stringify(yield this.encryptionService.sign(sigPxk.jwk, ''));
|
|
4274
4272
|
const publicSearchableSig = JSON.stringify(yield this.encryptionService.sign(sigPxk.jwk, ''));
|
|
4275
4273
|
const plainDataJson = {
|
|
@@ -5026,7 +5024,7 @@ class TpAssemblyController {
|
|
|
5026
5024
|
}
|
|
5027
5025
|
prepareCreate(input) {
|
|
5028
5026
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5029
|
-
const rootKey =
|
|
5027
|
+
const rootKey = this.keyService.currentRootKey;
|
|
5030
5028
|
const subjectKey = yield this.keyFactory.createKey();
|
|
5031
5029
|
const rootKeyWrappedSubjectKey = yield this.keyGraph.wrapKey(rootKey, subjectKey);
|
|
5032
5030
|
const _a = yield this.prepareAssembly({
|
|
@@ -5080,7 +5078,7 @@ class TpAssemblyController {
|
|
|
5080
5078
|
deleteSubAssembliesInput.length === 0) {
|
|
5081
5079
|
throw new KcBadArgumentException('Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]');
|
|
5082
5080
|
}
|
|
5083
|
-
const rootKey =
|
|
5081
|
+
const rootKey = this.keyService.currentRootKey;
|
|
5084
5082
|
const subjectKey = yield this.keyGraph.getKey(assembly.subjectKey.id);
|
|
5085
5083
|
const _b = yield this.prepareAssembly({
|
|
5086
5084
|
rootKey: rootKey.jwk,
|
|
@@ -5879,32 +5877,685 @@ class LifeReadyAuthService {
|
|
|
5879
5877
|
id: resetUser.masterKey.id,
|
|
5880
5878
|
},
|
|
5881
5879
|
});
|
|
5882
|
-
const userAttributes = yield this.auth.userAttributes(yield this.auth.currentAuthenticatedUser());
|
|
5883
|
-
const sub = this.getUserAttribute('sub', userAttributes);
|
|
5884
|
-
return Object.assign(Object.assign({}, (yield this.tpPasswordResetProcessorService.processTpPasswordResetUserNode(resetUser))), { sub });
|
|
5880
|
+
const userAttributes = yield this.auth.userAttributes(yield this.auth.currentAuthenticatedUser());
|
|
5881
|
+
const sub = this.getUserAttribute('sub', userAttributes);
|
|
5882
|
+
return Object.assign(Object.assign({}, (yield this.tpPasswordResetProcessorService.processTpPasswordResetUserNode(resetUser))), { sub });
|
|
5883
|
+
});
|
|
5884
|
+
}
|
|
5885
|
+
refreshAccessToken() {
|
|
5886
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5887
|
+
const cognitoUser = yield this.auth.currentAuthenticatedUser();
|
|
5888
|
+
const refreshToken = cognitoUser.getSignInUserSession().getRefreshToken();
|
|
5889
|
+
return new Promise((resolve, reject) => {
|
|
5890
|
+
cognitoUser.refreshSession(refreshToken, (err) => {
|
|
5891
|
+
if (err) {
|
|
5892
|
+
console.error('Error refreshing token: ', err);
|
|
5893
|
+
reject(err);
|
|
5894
|
+
}
|
|
5895
|
+
else {
|
|
5896
|
+
console.log('Token refresh complete');
|
|
5897
|
+
resolve(0);
|
|
5898
|
+
}
|
|
5899
|
+
});
|
|
5900
|
+
});
|
|
5901
|
+
});
|
|
5902
|
+
}
|
|
5903
|
+
completeRequest(newPassword) {
|
|
5904
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5905
|
+
const resetUser = yield this.getResetUser(true);
|
|
5906
|
+
if (resetUser.state !== TpClaimState.APPROVED) {
|
|
5907
|
+
throw new KcBadStateException('Password reset request has not been approved.');
|
|
5908
|
+
}
|
|
5909
|
+
// --------------------------------------------------------------
|
|
5910
|
+
// Prepare all materials to ensure there are no errors.
|
|
5911
|
+
// --------------------------------------------------------------
|
|
5912
|
+
const assemblyKey = yield this.recoverAssemblyKey(resetUser);
|
|
5913
|
+
const { rootKey } = yield this.encryptionService.decrypt(assemblyKey, resetUser.assemblyCipherData);
|
|
5914
|
+
// Making sure it's a valid key.
|
|
5915
|
+
const rootKeyJwk = yield JWK.asKey(rootKey);
|
|
5916
|
+
const masterKey = yield this.keyGraphService.getKey(resetUser.masterKey.id);
|
|
5917
|
+
const masterKeyWrappedRootKey = yield this.encryptionService.encryptToString(masterKey.jwk, rootKeyJwk.toJSON(true));
|
|
5918
|
+
// The new password
|
|
5919
|
+
const newPassIdpResult = yield this.keyFactory.derivePassIdp(Object.assign({ password: newPassword }, resetUser.passKey.passIdpParams));
|
|
5920
|
+
const newIdpPassword = this.passwordService.getPassIdpString(newPassIdpResult.jwk);
|
|
5921
|
+
// --------------------------------------------------------------
|
|
5922
|
+
// Get assembly key challenge
|
|
5923
|
+
// --------------------------------------------------------------
|
|
5924
|
+
const challenge = (yield this.lrGraphQL.lrMutate(new LrMutation({
|
|
5925
|
+
mutation: CreateTpAssemblyKeyChallengeMutation,
|
|
5926
|
+
variables: {
|
|
5927
|
+
input: {},
|
|
5928
|
+
},
|
|
5929
|
+
}), {
|
|
5930
|
+
includeKeyGraph: false,
|
|
5931
|
+
})).createTpAssemblyKeyChallenge.challenge;
|
|
5932
|
+
// Sign the challenge
|
|
5933
|
+
// Generate a client side nonce that's no in the server's control.
|
|
5934
|
+
challenge.clientNonce = this.keyFactory.randomString(TP_PASSWORD_RESET_CLIENT_NONCE_LENGTH);
|
|
5935
|
+
const assemblyKeyVerifierPrk = yield this.encryptionService.decrypt(assemblyKey, resetUser.wrappedAssemblyKeyVerifierPrk);
|
|
5936
|
+
const signedChallenge = yield this.encryptionService.sign(assemblyKeyVerifierPrk, challenge);
|
|
5937
|
+
// --------------------------------------------------------------
|
|
5938
|
+
// Change password for the original user
|
|
5939
|
+
// --------------------------------------------------------------
|
|
5940
|
+
const tempIdpPassword = (yield this.lrGraphQL.lrMutate(new LrMutation({
|
|
5941
|
+
mutation: PreCompleteTpPasswordResetRequestMutation,
|
|
5942
|
+
variables: {
|
|
5943
|
+
input: {
|
|
5944
|
+
signedChallenge: JSON.stringify(signedChallenge),
|
|
5945
|
+
},
|
|
5946
|
+
},
|
|
5947
|
+
}), {
|
|
5948
|
+
includeKeyGraph: false,
|
|
5949
|
+
})).preCompleteTpPasswordResetRequest.idpPassword;
|
|
5950
|
+
// --------------------------------------------------------------
|
|
5951
|
+
// Login as the original user using new temporary password
|
|
5952
|
+
// --------------------------------------------------------------
|
|
5953
|
+
// At this point, the original account's password has been changed
|
|
5954
|
+
// to a temporary password. It is no longer possible for the user
|
|
5955
|
+
// to use the original password to login. Any successful login
|
|
5956
|
+
// can only be using the temporary password. So it's safe to assume
|
|
5957
|
+
// that we want to "complete" the password reset.
|
|
5958
|
+
// The maybe 2FA so we listen for the auth event from Amplify.
|
|
5959
|
+
const retPromise = new Promise((resolve) => {
|
|
5960
|
+
const listener = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
5961
|
+
if (data.payload.event !== 'signIn') {
|
|
5962
|
+
return;
|
|
5963
|
+
}
|
|
5964
|
+
Hub.remove('auth', listener);
|
|
5965
|
+
yield this.auth.signIn(resetUser.username, newIdpPassword);
|
|
5966
|
+
// Switch over to the new set of keys
|
|
5967
|
+
yield this.lrGraphQL.lrMutate(new LrMutation({
|
|
5968
|
+
mutation: CompleteTpPasswordResetRequestMutation,
|
|
5969
|
+
variables: {
|
|
5970
|
+
input: {
|
|
5971
|
+
masterKeyWrappedRootKey,
|
|
5972
|
+
masterKeyId: masterKey.id,
|
|
5973
|
+
},
|
|
5974
|
+
},
|
|
5975
|
+
}));
|
|
5976
|
+
resolve();
|
|
5977
|
+
});
|
|
5978
|
+
Hub.listen('auth', listener);
|
|
5979
|
+
});
|
|
5980
|
+
// Signin as the original user. Password has been reset to temporary one. It should return
|
|
5981
|
+
// with NEW_PASSWORD_REQUIRED
|
|
5982
|
+
let user = yield this.auth.signIn(resetUser.username, tempIdpPassword, {
|
|
5983
|
+
noProxy: 'true',
|
|
5984
|
+
});
|
|
5985
|
+
if (user.challengeName !== 'NEW_PASSWORD_REQUIRED') {
|
|
5986
|
+
throw new KcInternalErrorException('Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.');
|
|
5987
|
+
}
|
|
5988
|
+
// Set new password on Idp
|
|
5989
|
+
// the awsFetch() function passes NEW_PASSWORD_REQUIRED directly to AWS without
|
|
5990
|
+
// going through the proxy.
|
|
5991
|
+
user = yield this.auth.completeNewPassword(user, newIdpPassword, {});
|
|
5992
|
+
return retPromise;
|
|
5993
|
+
});
|
|
5994
|
+
}
|
|
5995
|
+
recoverAssemblyKey(resetUser) {
|
|
5996
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5997
|
+
const prk = yield this.keyGraphService.getKey(resetUser.pxk.id);
|
|
5998
|
+
const partials = yield Promise.all(resetUser.approvals
|
|
5999
|
+
.filter((approval) => !!approval.receiverCipherPartialAssemblyKey)
|
|
6000
|
+
.map((approval) => this.encryptionService.decrypt(prk, approval.receiverCipherPartialAssemblyKey)));
|
|
6001
|
+
return this.assemblyController.recoverAssemblyKey(partials);
|
|
6002
|
+
});
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
LifeReadyAuthService.ɵprov = ɵɵdefineInjectable({ factory: function LifeReadyAuthService_Factory() { return new LifeReadyAuthService(ɵɵinject(KC_CONFIG), ɵɵinject(AuthClass), ɵɵinject(KeyFactoryService), ɵɵinject(KeyService), ɵɵinject(ProfileService), ɵɵinject(KeyGraphService), ɵɵinject(PasswordService), ɵɵinject(IdleService), ɵɵinject(LrGraphQLService), ɵɵinject(TpPasswordResetProcessorService), ɵɵinject(PersistService), ɵɵinject(EncryptionService), ɵɵinject(TpPasswordResetAssemblyController), ɵɵinject(HttpClient)); }, token: LifeReadyAuthService, providedIn: "root" });
|
|
6006
|
+
LifeReadyAuthService.decorators = [
|
|
6007
|
+
{ type: Injectable, args: [{
|
|
6008
|
+
providedIn: 'root',
|
|
6009
|
+
},] }
|
|
6010
|
+
];
|
|
6011
|
+
LifeReadyAuthService.ctorParameters = () => [
|
|
6012
|
+
{ type: undefined, decorators: [{ type: Inject, args: [KC_CONFIG,] }] },
|
|
6013
|
+
{ type: AuthClass },
|
|
6014
|
+
{ type: KeyFactoryService },
|
|
6015
|
+
{ type: KeyService },
|
|
6016
|
+
{ type: ProfileService },
|
|
6017
|
+
{ type: KeyGraphService },
|
|
6018
|
+
{ type: PasswordService },
|
|
6019
|
+
{ type: IdleService },
|
|
6020
|
+
{ type: LrGraphQLService },
|
|
6021
|
+
{ type: TpPasswordResetProcessorService },
|
|
6022
|
+
{ type: PersistService },
|
|
6023
|
+
{ type: EncryptionService },
|
|
6024
|
+
{ type: TpPasswordResetAssemblyController },
|
|
6025
|
+
{ type: HttpClient }
|
|
6026
|
+
];
|
|
6027
|
+
|
|
6028
|
+
class KeyContainer {
|
|
6029
|
+
constructor(_key, timeout) {
|
|
6030
|
+
this._key = _key;
|
|
6031
|
+
this.timer = setTimeout(() => {
|
|
6032
|
+
this._key = null;
|
|
6033
|
+
}, timeout);
|
|
6034
|
+
}
|
|
6035
|
+
get key() {
|
|
6036
|
+
return this._key;
|
|
6037
|
+
}
|
|
6038
|
+
/**
|
|
6039
|
+
* Clears the reference to the key, clears the timer, return the key.
|
|
6040
|
+
* It's important to call this function when the key is no longer needed because
|
|
6041
|
+
* the anonymous function in setTimeout() holds a reference to "this", and hence
|
|
6042
|
+
* keeps the "this._key" reference until the timer expired. So if we have used
|
|
6043
|
+
* the key before it expired, we should clear the "this._key" reference immediately.
|
|
6044
|
+
*/
|
|
6045
|
+
pop() {
|
|
6046
|
+
const ret = this._key;
|
|
6047
|
+
this._key = null;
|
|
6048
|
+
if (this.timer) {
|
|
6049
|
+
clearTimeout(this.timer);
|
|
6050
|
+
this.timer = null;
|
|
6051
|
+
}
|
|
6052
|
+
return ret;
|
|
6053
|
+
}
|
|
6054
|
+
}
|
|
6055
|
+
|
|
6056
|
+
const CurrentUserQuery$1 = gqlTyped `
|
|
6057
|
+
query {
|
|
6058
|
+
currentUser {
|
|
6059
|
+
id
|
|
6060
|
+
username
|
|
6061
|
+
currentUserKey {
|
|
6062
|
+
passKey {
|
|
6063
|
+
id
|
|
6064
|
+
passKeyParams
|
|
6065
|
+
passIdpParams
|
|
6066
|
+
wrappedPassIdpVerifierPrk
|
|
6067
|
+
created
|
|
6068
|
+
}
|
|
6069
|
+
masterKey {
|
|
6070
|
+
id
|
|
6071
|
+
}
|
|
6072
|
+
rootKey {
|
|
6073
|
+
id
|
|
6074
|
+
}
|
|
6075
|
+
pxk {
|
|
6076
|
+
id
|
|
6077
|
+
}
|
|
6078
|
+
sigPxk {
|
|
6079
|
+
id
|
|
6080
|
+
}
|
|
6081
|
+
}
|
|
6082
|
+
sessionEncryptionKey
|
|
6083
|
+
}
|
|
6084
|
+
keyGraph {
|
|
6085
|
+
...KeyGraphFragment
|
|
6086
|
+
}
|
|
6087
|
+
}
|
|
6088
|
+
${KeyGraphFragment}
|
|
6089
|
+
`;
|
|
6090
|
+
const ResetUserQuery = gqlTyped `
|
|
6091
|
+
query ResetUserQuery {
|
|
6092
|
+
tpPasswordResetUser {
|
|
6093
|
+
username
|
|
6094
|
+
sessionEncryptionKey
|
|
6095
|
+
state
|
|
6096
|
+
passKey {
|
|
6097
|
+
id
|
|
6098
|
+
passKeyParams
|
|
6099
|
+
passIdpParams
|
|
6100
|
+
}
|
|
6101
|
+
masterKey {
|
|
6102
|
+
id
|
|
6103
|
+
}
|
|
6104
|
+
pxk {
|
|
6105
|
+
id
|
|
6106
|
+
}
|
|
6107
|
+
assembly {
|
|
6108
|
+
singleReject
|
|
6109
|
+
quorum
|
|
6110
|
+
subAssemblies {
|
|
6111
|
+
singleReject
|
|
6112
|
+
quorum
|
|
6113
|
+
approvers {
|
|
6114
|
+
name
|
|
6115
|
+
email
|
|
6116
|
+
state
|
|
6117
|
+
}
|
|
6118
|
+
}
|
|
6119
|
+
}
|
|
6120
|
+
approvals {
|
|
6121
|
+
id
|
|
6122
|
+
modified
|
|
6123
|
+
approverEmail
|
|
6124
|
+
receiverCipher
|
|
6125
|
+
receiverCipherPartialAssemblyKey
|
|
6126
|
+
}
|
|
6127
|
+
assemblyCipherData
|
|
6128
|
+
wrappedAssemblyKeyVerifierPrk
|
|
6129
|
+
}
|
|
6130
|
+
}`;
|
|
6131
|
+
|
|
6132
|
+
var RecoveryStatus$1;
|
|
6133
|
+
(function (RecoveryStatus) {
|
|
6134
|
+
RecoveryStatus["NONE"] = "NONE";
|
|
6135
|
+
RecoveryStatus["NEW_PASSWORD"] = "NEW_PASSWORD";
|
|
6136
|
+
RecoveryStatus["OLD_PASSWORD"] = "OLD_PASSWORD";
|
|
6137
|
+
})(RecoveryStatus$1 || (RecoveryStatus$1 = {}));
|
|
6138
|
+
// TODO restrict this type
|
|
6139
|
+
// export type AuthResetUser = TpPasswordResetUserNode;
|
|
6140
|
+
var PasswordChangeStatus$1;
|
|
6141
|
+
(function (PasswordChangeStatus) {
|
|
6142
|
+
PasswordChangeStatus["IN_PROGRESS"] = "IN_PROGRESS";
|
|
6143
|
+
PasswordChangeStatus["RECOVERY"] = "RECOVERY";
|
|
6144
|
+
})(PasswordChangeStatus$1 || (PasswordChangeStatus$1 = {}));
|
|
6145
|
+
var CognitoChallengeName;
|
|
6146
|
+
(function (CognitoChallengeName) {
|
|
6147
|
+
CognitoChallengeName["NEW_PASSWORD_REQUIRED"] = "NEW_PASSWORD_REQUIRED";
|
|
6148
|
+
CognitoChallengeName["SMS_MFA"] = "SMS_MFA";
|
|
6149
|
+
CognitoChallengeName["SOFTWARE_TOKEN_MFA"] = "SOFTWARE_TOKEN_MFA";
|
|
6150
|
+
CognitoChallengeName["MFA_SETUP"] = "MFA_SETUP";
|
|
6151
|
+
})(CognitoChallengeName || (CognitoChallengeName = {}));
|
|
6152
|
+
|
|
6153
|
+
var auth2_types = /*#__PURE__*/Object.freeze({
|
|
6154
|
+
__proto__: null,
|
|
6155
|
+
get RecoveryStatus () { return RecoveryStatus$1; },
|
|
6156
|
+
get PasswordChangeStatus () { return PasswordChangeStatus$1; },
|
|
6157
|
+
get CognitoChallengeName () { return CognitoChallengeName; }
|
|
6158
|
+
});
|
|
6159
|
+
|
|
6160
|
+
var Auth2Service_1;
|
|
6161
|
+
let Auth2Service = Auth2Service_1 = class Auth2Service extends LrService {
|
|
6162
|
+
constructor(ngZone, injector, http, cognito, api, keyService, keyGraphService, keyFactoryService, passwordService, idleService, persistService, encryptionService, assemblyController, kcConfig) {
|
|
6163
|
+
super(injector);
|
|
6164
|
+
this.ngZone = ngZone;
|
|
6165
|
+
this.injector = injector;
|
|
6166
|
+
this.http = http;
|
|
6167
|
+
this.cognito = cognito;
|
|
6168
|
+
this.api = api;
|
|
6169
|
+
this.keyService = keyService;
|
|
6170
|
+
this.keyGraphService = keyGraphService;
|
|
6171
|
+
this.keyFactoryService = keyFactoryService;
|
|
6172
|
+
this.passwordService = passwordService;
|
|
6173
|
+
this.idleService = idleService;
|
|
6174
|
+
this.persistService = persistService;
|
|
6175
|
+
this.encryptionService = encryptionService;
|
|
6176
|
+
this.assemblyController = assemblyController;
|
|
6177
|
+
this.kcConfig = kcConfig;
|
|
6178
|
+
// Could use rxjs observables here. But trying to have kc-client use as little angular
|
|
6179
|
+
// features as possible. Rxjs is not used anywhere else in kc-client.
|
|
6180
|
+
this.logoutListeners = new Set();
|
|
6181
|
+
// Stores the password for use after mfa verification to decrypt masterKey.
|
|
6182
|
+
this.password = null;
|
|
6183
|
+
if (!isDevMode()) {
|
|
6184
|
+
if (this.kcConfig.debug != null) {
|
|
6185
|
+
throw new KcBadRequestException('In production mode, "KcConfig.debug" must be set to null');
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
}
|
|
6189
|
+
importPassword(plainPassword) {
|
|
6190
|
+
return this.keyFactoryService.importPassword(plainPassword);
|
|
6191
|
+
}
|
|
6192
|
+
logout() {
|
|
6193
|
+
var _a;
|
|
6194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6195
|
+
// Notify all listeners to clean up.
|
|
6196
|
+
yield Promise.all([...this.logoutListeners].map((callback) => callback()));
|
|
6197
|
+
this.user = null;
|
|
6198
|
+
this.keyService.purgeKeys();
|
|
6199
|
+
this.keyGraphService.purgeKeys();
|
|
6200
|
+
// Sign out on both cognito and kc-server
|
|
6201
|
+
yield Promise.all([this.cognito.signOut(), this.kcLogout()]);
|
|
6202
|
+
if ((_a = this.kcConfig.debug) === null || _a === void 0 ? void 0 : _a.username) {
|
|
6203
|
+
this.kcConfig.debug.username = null;
|
|
6204
|
+
}
|
|
6205
|
+
});
|
|
6206
|
+
}
|
|
6207
|
+
addLogoutListener(callback) {
|
|
6208
|
+
this.logoutListeners.add(callback);
|
|
6209
|
+
}
|
|
6210
|
+
removeLogoutListener(callback) {
|
|
6211
|
+
this.logoutListeners.delete(callback);
|
|
6212
|
+
}
|
|
6213
|
+
login(emailOrPhone, password, { tpPasswordResetAutoComplete = true } = {}) {
|
|
6214
|
+
var _a;
|
|
6215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6216
|
+
let loginResult = yield this.loginImpl(emailOrPhone, password);
|
|
6217
|
+
// Save the password for use after meeting challenge.
|
|
6218
|
+
if (loginResult.challenge) {
|
|
6219
|
+
this.password = new KeyContainer(password, Auth2Service_1.CHALLENGE_TIMEOUT);
|
|
6220
|
+
return loginResult;
|
|
6221
|
+
}
|
|
6222
|
+
if (tpPasswordResetAutoComplete &&
|
|
6223
|
+
((_a = loginResult.user.resetUser) === null || _a === void 0 ? void 0 : _a.state) === TpClaimState.APPROVED) {
|
|
6224
|
+
yield this.completeResetRequest(password);
|
|
6225
|
+
loginResult = yield this.loginImpl(emailOrPhone, password);
|
|
6226
|
+
}
|
|
6227
|
+
return loginResult;
|
|
6228
|
+
});
|
|
6229
|
+
}
|
|
6230
|
+
verifyLogin(options) {
|
|
6231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6232
|
+
const { challenge, code, rememberMe } = options;
|
|
6233
|
+
const VALID_CHALLENGE_NAMES = [
|
|
6234
|
+
CognitoChallengeName.SMS_MFA,
|
|
6235
|
+
CognitoChallengeName.SOFTWARE_TOKEN_MFA,
|
|
6236
|
+
];
|
|
6237
|
+
if (!VALID_CHALLENGE_NAMES.includes(challenge.cognitoUser.challengeName)) {
|
|
6238
|
+
throw new KcBadRequestException(`challengeName must be one of ${VALID_CHALLENGE_NAMES}`);
|
|
6239
|
+
}
|
|
6240
|
+
// TODO: this.auth.confirmSignIn() could return another challenge.
|
|
6241
|
+
const cognitoUser = yield this.cognito.confirmSignIn(challenge.cognitoUser, code, challenge.cognitoUser.challengeName);
|
|
6242
|
+
yield this.handlePostAuth(challenge.recoveryStatus);
|
|
6243
|
+
const user = yield this.loadUser(cognitoUser, this.password.pop());
|
|
6244
|
+
// This is not strictly necessary since the this.password.pop() already clears the
|
|
6245
|
+
// password inside the container. But doesn't hurt either.
|
|
6246
|
+
this.password = null;
|
|
6247
|
+
if (rememberMe) {
|
|
6248
|
+
cognitoUser.setDeviceStatusRemembered({
|
|
6249
|
+
onSuccess: () => {
|
|
6250
|
+
return;
|
|
6251
|
+
},
|
|
6252
|
+
onFailure: (e) => console.error(e),
|
|
6253
|
+
});
|
|
6254
|
+
}
|
|
6255
|
+
return {
|
|
6256
|
+
user,
|
|
6257
|
+
};
|
|
6258
|
+
});
|
|
6259
|
+
}
|
|
6260
|
+
getUser() {
|
|
6261
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6262
|
+
if (this.user) {
|
|
6263
|
+
return this.user;
|
|
6264
|
+
}
|
|
6265
|
+
const cognitoUser = yield this.cognito.currentAuthenticatedUser();
|
|
6266
|
+
return this.loadUser(cognitoUser);
|
|
6267
|
+
});
|
|
6268
|
+
}
|
|
6269
|
+
refreshAccessToken() {
|
|
6270
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6271
|
+
const cognitoUser = yield this.cognito.currentAuthenticatedUser();
|
|
6272
|
+
const refreshToken = cognitoUser.getSignInUserSession().getRefreshToken();
|
|
6273
|
+
console.log('Token refresh...');
|
|
6274
|
+
return new Promise((resolve, reject) => {
|
|
6275
|
+
cognitoUser.refreshSession(refreshToken, (err) => {
|
|
6276
|
+
if (err) {
|
|
6277
|
+
console.error('Error refreshing token: ', err);
|
|
6278
|
+
reject(err);
|
|
6279
|
+
}
|
|
6280
|
+
else {
|
|
6281
|
+
console.log('Token refresh complete');
|
|
6282
|
+
resolve(0);
|
|
6283
|
+
}
|
|
6284
|
+
});
|
|
6285
|
+
});
|
|
6286
|
+
});
|
|
6287
|
+
}
|
|
6288
|
+
// ----------------------------------------------------------------------------------------------------
|
|
6289
|
+
// Helpers
|
|
6290
|
+
// ----------------------------------------------------------------------------------------------------
|
|
6291
|
+
fetchCurrentUser() {
|
|
6292
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6293
|
+
return (yield this.api.query({
|
|
6294
|
+
query: CurrentUserQuery$1,
|
|
6295
|
+
processorOptions: {
|
|
6296
|
+
hasKeys: false,
|
|
6297
|
+
},
|
|
6298
|
+
})).currentUser;
|
|
6299
|
+
});
|
|
6300
|
+
}
|
|
6301
|
+
fetchResetUser() {
|
|
6302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6303
|
+
return (yield this.api.query({
|
|
6304
|
+
query: CurrentUserQuery$1,
|
|
6305
|
+
processorOptions: {
|
|
6306
|
+
hasKeys: false,
|
|
6307
|
+
},
|
|
6308
|
+
})).tpPasswordResetUser;
|
|
6309
|
+
});
|
|
6310
|
+
}
|
|
6311
|
+
kcLogout() {
|
|
6312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6313
|
+
yield this.http
|
|
6314
|
+
.post(`${this.kcConfig.authUrl}auth/sign-out/`, null, {
|
|
6315
|
+
withCredentials: true,
|
|
6316
|
+
responseType: 'text',
|
|
6317
|
+
})
|
|
6318
|
+
.toPromise();
|
|
6319
|
+
});
|
|
6320
|
+
}
|
|
6321
|
+
fetchPassIdpParams(emailOrPhone) {
|
|
6322
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6323
|
+
return yield this.http
|
|
6324
|
+
.get(`${this.kcConfig.authUrl}users/pass-idp-params/?login_name=${encodeURIComponent(emailOrPhone)}`)
|
|
6325
|
+
.toPromise();
|
|
6326
|
+
});
|
|
6327
|
+
}
|
|
6328
|
+
loginImpl(emailOrPhone, password) {
|
|
6329
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6330
|
+
yield this.logout();
|
|
6331
|
+
const loginIdpResult = yield this.loginIdp(emailOrPhone, password);
|
|
6332
|
+
// Can't get the user yet because we still ned to meet MFA challenges
|
|
6333
|
+
if ([
|
|
6334
|
+
CognitoChallengeName.SMS_MFA,
|
|
6335
|
+
CognitoChallengeName.SOFTWARE_TOKEN_MFA,
|
|
6336
|
+
].includes(loginIdpResult.cognitoUser.challengeName)) {
|
|
6337
|
+
return {
|
|
6338
|
+
challenge: {
|
|
6339
|
+
cognitoUser: loginIdpResult.cognitoUser,
|
|
6340
|
+
recoveryStatus: loginIdpResult.recoveryStatus,
|
|
6341
|
+
},
|
|
6342
|
+
};
|
|
6343
|
+
}
|
|
6344
|
+
yield this.handlePostAuth(loginIdpResult.recoveryStatus);
|
|
6345
|
+
// There should be no MFA on the TP reset user.
|
|
6346
|
+
const user = yield this.loadUser(loginIdpResult.cognitoUser, password);
|
|
6347
|
+
return {
|
|
6348
|
+
user,
|
|
6349
|
+
};
|
|
6350
|
+
});
|
|
6351
|
+
}
|
|
6352
|
+
loginIdp(emailOrPhone, password) {
|
|
6353
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6354
|
+
// Download the salt needed to derive the PassIdp
|
|
6355
|
+
const passIdpApiResult = yield this.fetchPassIdpParams(emailOrPhone);
|
|
6356
|
+
if (passIdpApiResult.passwordChangeStatus === PasswordChangeStatus$1.IN_PROGRESS) {
|
|
6357
|
+
throw new KcConcurrentAccessException('A password change is in progress');
|
|
6358
|
+
}
|
|
6359
|
+
if (passIdpApiResult.passwordChangeStatus === PasswordChangeStatus$1.RECOVERY) {
|
|
6360
|
+
console.log('In recovery mode.');
|
|
6361
|
+
// Let's say we don't know if the password is the new one or the old one. We just have to try both.
|
|
6362
|
+
try {
|
|
6363
|
+
const user = {
|
|
6364
|
+
cognitoUser: yield this.loginIdpImpl(emailOrPhone, password, passIdpApiResult.newPassIdpParams),
|
|
6365
|
+
recoveryStatus: RecoveryStatus$1.NEW_PASSWORD,
|
|
6366
|
+
};
|
|
6367
|
+
// New password worked. Let's set to the current password
|
|
6368
|
+
// --Potential Failure Point 1--
|
|
6369
|
+
// if changePasswordComplete() doesn't get called, then it should remain
|
|
6370
|
+
console.log('New password works!');
|
|
6371
|
+
return user;
|
|
6372
|
+
}
|
|
6373
|
+
catch (error) {
|
|
6374
|
+
// Just bubble up any other type of error.
|
|
6375
|
+
if (error.code !== 'NotAuthorizedException') {
|
|
6376
|
+
throw error;
|
|
6377
|
+
}
|
|
6378
|
+
// pass, try again assuming it's the old password
|
|
6379
|
+
}
|
|
6380
|
+
// Now assume it's the previous password. Any exception is allowed to bubble up.
|
|
6381
|
+
try {
|
|
6382
|
+
const user = {
|
|
6383
|
+
cognitoUser: yield this.loginIdpImpl(emailOrPhone, password, passIdpApiResult.currentPassIdpParams),
|
|
6384
|
+
recoveryStatus: RecoveryStatus$1.OLD_PASSWORD,
|
|
6385
|
+
};
|
|
6386
|
+
// Old password worked.
|
|
6387
|
+
console.log('Old password works!');
|
|
6388
|
+
return user;
|
|
6389
|
+
}
|
|
6390
|
+
catch (error) {
|
|
6391
|
+
// Just bubble up any other type of error.
|
|
6392
|
+
throw error.code === 'NotAuthorizedException'
|
|
6393
|
+
? new KcBadRequestException('The password change request was interrupted, please try to login with both your new and old password')
|
|
6394
|
+
: error;
|
|
6395
|
+
}
|
|
6396
|
+
}
|
|
6397
|
+
// Try again as the TP password reset account
|
|
6398
|
+
if (passIdpApiResult.tpPasswordReset) {
|
|
6399
|
+
try {
|
|
6400
|
+
// TP password reset is in process. We need to try the password against both
|
|
6401
|
+
// original account and the new reset account.
|
|
6402
|
+
const reset = passIdpApiResult.tpPasswordReset;
|
|
6403
|
+
const user = {
|
|
6404
|
+
cognitoUser: yield this.loginIdpImpl(reset.resetUsername, password, reset.passIdpParams),
|
|
6405
|
+
recoveryStatus: RecoveryStatus$1.NONE,
|
|
6406
|
+
};
|
|
6407
|
+
return user;
|
|
6408
|
+
}
|
|
6409
|
+
catch (err) {
|
|
6410
|
+
// continue, try again as regular user.
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6413
|
+
// Login as regular user
|
|
6414
|
+
const user = {
|
|
6415
|
+
cognitoUser: yield this.loginIdpImpl(emailOrPhone, password, passIdpApiResult.currentPassIdpParams),
|
|
6416
|
+
recoveryStatus: RecoveryStatus$1.NONE,
|
|
6417
|
+
};
|
|
6418
|
+
return user;
|
|
6419
|
+
});
|
|
6420
|
+
}
|
|
6421
|
+
loginIdpImpl(emailOrPhone, password, passIdpParams) {
|
|
6422
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6423
|
+
const passIdpResult = yield this.keyFactoryService.derivePassIdp(Object.assign({ password }, passIdpParams));
|
|
6424
|
+
// Use the derived password to signin with cognito
|
|
6425
|
+
return this.cognito.signIn(emailOrPhone, this.passwordService.getPassIdpString(passIdpResult.jwk));
|
|
6426
|
+
});
|
|
6427
|
+
}
|
|
6428
|
+
handlePostAuth(recoveryStatus) {
|
|
6429
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6430
|
+
yield this.handlePasswordRecovery(recoveryStatus);
|
|
6431
|
+
yield this.handleSessionEncryptionKey();
|
|
6432
|
+
});
|
|
6433
|
+
}
|
|
6434
|
+
handlePasswordRecovery(recoveryStatus) {
|
|
6435
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6436
|
+
if (recoveryStatus !== RecoveryStatus$1.NONE) {
|
|
6437
|
+
yield this.passwordService.changePasswordComplete({
|
|
6438
|
+
useNewPassword: recoveryStatus === RecoveryStatus$1.NEW_PASSWORD,
|
|
6439
|
+
});
|
|
6440
|
+
}
|
|
6441
|
+
});
|
|
6442
|
+
}
|
|
6443
|
+
handleSessionEncryptionKey() {
|
|
6444
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6445
|
+
if (this.kcConfig.disableSessionEncryptionKey) {
|
|
6446
|
+
if (!isDevMode()) {
|
|
6447
|
+
const msg = 'You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.';
|
|
6448
|
+
console.error(msg);
|
|
6449
|
+
throw new KcInternalErrorException(msg);
|
|
6450
|
+
}
|
|
6451
|
+
else {
|
|
6452
|
+
console.warn('You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode.');
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
else {
|
|
6456
|
+
// Set the session key to a new encryption key for this session
|
|
6457
|
+
const sessionEncryptionKey = yield this.keyFactoryService.createKey();
|
|
6458
|
+
yield this.lrGraphQL.lrMutate(new LrMutation({
|
|
6459
|
+
mutation: SetSessionEncryptionKeyMutation,
|
|
6460
|
+
variables: {
|
|
6461
|
+
input: {
|
|
6462
|
+
sessionEncryptionKey: JSON.stringify(sessionEncryptionKey.toJSON(true)),
|
|
6463
|
+
},
|
|
6464
|
+
},
|
|
6465
|
+
}), {
|
|
6466
|
+
includeKeyGraph: false,
|
|
6467
|
+
});
|
|
6468
|
+
this.persistService.setServerSessionEncryptionKey(sessionEncryptionKey);
|
|
6469
|
+
}
|
|
6470
|
+
});
|
|
6471
|
+
}
|
|
6472
|
+
getCognitoUserAttribute(attributeName, userAttributes) {
|
|
6473
|
+
const userAttribute = userAttributes.find((x) => x.getName() === attributeName);
|
|
6474
|
+
return userAttribute ? userAttribute.getValue() : null;
|
|
6475
|
+
}
|
|
6476
|
+
loadUserKeys(options) {
|
|
6477
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6478
|
+
const { userKeys, password, sessionEncryptionKey } = options;
|
|
6479
|
+
if (sessionEncryptionKey) {
|
|
6480
|
+
this.persistService.setServerSessionEncryptionKey(yield JWK.asKey(sessionEncryptionKey));
|
|
6481
|
+
}
|
|
6482
|
+
// password is not needed if the master key is already persisted.
|
|
6483
|
+
if (password) {
|
|
6484
|
+
const passKey = (yield this.keyFactoryService.derivePassKey(Object.assign({ password }, userKeys.passKey.passKeyParams))).jwk;
|
|
6485
|
+
yield this.idleService.persistMasterKey(yield this.keyGraphService.unwrapWithPassKey(userKeys.passKey.id, passKey, userKeys.masterKey.id));
|
|
6486
|
+
}
|
|
6487
|
+
yield this.keyGraphService.populateKeys(userKeys);
|
|
6488
|
+
});
|
|
6489
|
+
}
|
|
6490
|
+
loadUser(cognitoUser, password) {
|
|
6491
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6492
|
+
if (cognitoUser.getUsername().endsWith(TP_PASSWORD_RESET_USERNAME_SUFFIX)) {
|
|
6493
|
+
this.user = yield this.loadResetUser(cognitoUser, password);
|
|
6494
|
+
}
|
|
6495
|
+
else {
|
|
6496
|
+
this.user = yield this.loadRegularUser(cognitoUser, password);
|
|
6497
|
+
}
|
|
6498
|
+
yield this.idleService.start(); // Run idleService whenever user is logged in.
|
|
6499
|
+
return this.user;
|
|
6500
|
+
});
|
|
6501
|
+
}
|
|
6502
|
+
loadRegularUser(cognitoUser, password) {
|
|
6503
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6504
|
+
const currentUser = yield this.fetchCurrentUser();
|
|
6505
|
+
yield this.loadUserKeys({
|
|
6506
|
+
userKeys: currentUser.currentUserKey,
|
|
6507
|
+
password,
|
|
6508
|
+
sessionEncryptionKey: currentUser.sessionEncryptionKey,
|
|
6509
|
+
});
|
|
6510
|
+
const { username } = currentUser;
|
|
6511
|
+
const userAttributes = yield this.cognito.userAttributes(cognitoUser);
|
|
6512
|
+
return {
|
|
6513
|
+
username,
|
|
6514
|
+
sub: this.getCognitoUserAttribute('sub', userAttributes),
|
|
6515
|
+
loginEmail: this.getCognitoUserAttribute('email', userAttributes),
|
|
6516
|
+
resetUser: null,
|
|
6517
|
+
};
|
|
6518
|
+
});
|
|
6519
|
+
}
|
|
6520
|
+
loadResetUser(cognitoUser, password) {
|
|
6521
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6522
|
+
const resetUser = yield this.fetchResetUser();
|
|
6523
|
+
this.loadUserKeys({
|
|
6524
|
+
userKeys: {
|
|
6525
|
+
passKey: {
|
|
6526
|
+
id: resetUser.passKey.id,
|
|
6527
|
+
},
|
|
6528
|
+
masterKey: {
|
|
6529
|
+
id: resetUser.masterKey.id,
|
|
6530
|
+
},
|
|
6531
|
+
},
|
|
6532
|
+
password,
|
|
6533
|
+
sessionEncryptionKey: resetUser.sessionEncryptionKey,
|
|
6534
|
+
});
|
|
6535
|
+
const { username } = resetUser;
|
|
6536
|
+
const userAttributes = yield this.cognito.userAttributes(cognitoUser);
|
|
6537
|
+
return {
|
|
6538
|
+
username,
|
|
6539
|
+
sub: this.getCognitoUserAttribute('sub', userAttributes),
|
|
6540
|
+
loginEmail: this.getCognitoUserAttribute('email', userAttributes),
|
|
6541
|
+
resetUser: {
|
|
6542
|
+
state: resetUser.state,
|
|
6543
|
+
},
|
|
6544
|
+
};
|
|
5885
6545
|
});
|
|
5886
6546
|
}
|
|
5887
|
-
|
|
6547
|
+
recoverAssemblyKey(resetUser) {
|
|
5888
6548
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5889
|
-
const
|
|
5890
|
-
const
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
console.error('Error refreshing token: ', err);
|
|
5895
|
-
reject(err);
|
|
5896
|
-
}
|
|
5897
|
-
else {
|
|
5898
|
-
console.log('Token refresh complete');
|
|
5899
|
-
resolve(0);
|
|
5900
|
-
}
|
|
5901
|
-
});
|
|
5902
|
-
});
|
|
6549
|
+
const prk = yield this.keyGraphService.getKey(resetUser.pxk.id);
|
|
6550
|
+
const partials = yield Promise.all(resetUser.approvals
|
|
6551
|
+
.filter((approval) => !!approval.receiverCipherPartialAssemblyKey)
|
|
6552
|
+
.map((approval) => this.encryptionService.decrypt(prk, approval.receiverCipherPartialAssemblyKey)));
|
|
6553
|
+
return this.assemblyController.recoverAssemblyKey(partials);
|
|
5903
6554
|
});
|
|
5904
6555
|
}
|
|
5905
|
-
|
|
6556
|
+
completeResetRequest(newPassword) {
|
|
5906
6557
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5907
|
-
const resetUser = yield this.
|
|
6558
|
+
const resetUser = yield this.fetchResetUser();
|
|
5908
6559
|
if (resetUser.state !== TpClaimState.APPROVED) {
|
|
5909
6560
|
throw new KcBadStateException('Password reset request has not been approved.');
|
|
5910
6561
|
}
|
|
@@ -5918,7 +6569,7 @@ class LifeReadyAuthService {
|
|
|
5918
6569
|
const masterKey = yield this.keyGraphService.getKey(resetUser.masterKey.id);
|
|
5919
6570
|
const masterKeyWrappedRootKey = yield this.encryptionService.encryptToString(masterKey.jwk, rootKeyJwk.toJSON(true));
|
|
5920
6571
|
// The new password
|
|
5921
|
-
const newPassIdpResult = yield this.
|
|
6572
|
+
const newPassIdpResult = yield this.keyFactoryService.derivePassIdp(Object.assign({ password: newPassword }, resetUser.passKey.passIdpParams));
|
|
5922
6573
|
const newIdpPassword = this.passwordService.getPassIdpString(newPassIdpResult.jwk);
|
|
5923
6574
|
// --------------------------------------------------------------
|
|
5924
6575
|
// Get assembly key challenge
|
|
@@ -5933,7 +6584,7 @@ class LifeReadyAuthService {
|
|
|
5933
6584
|
})).createTpAssemblyKeyChallenge.challenge;
|
|
5934
6585
|
// Sign the challenge
|
|
5935
6586
|
// Generate a client side nonce that's no in the server's control.
|
|
5936
|
-
challenge.clientNonce = this.
|
|
6587
|
+
challenge.clientNonce = this.keyFactoryService.randomString(TP_PASSWORD_RESET_CLIENT_NONCE_LENGTH);
|
|
5937
6588
|
const assemblyKeyVerifierPrk = yield this.encryptionService.decrypt(assemblyKey, resetUser.wrappedAssemblyKeyVerifierPrk);
|
|
5938
6589
|
const signedChallenge = yield this.encryptionService.sign(assemblyKeyVerifierPrk, challenge);
|
|
5939
6590
|
// --------------------------------------------------------------
|
|
@@ -5957,14 +6608,14 @@ class LifeReadyAuthService {
|
|
|
5957
6608
|
// to use the original password to login. Any successful login
|
|
5958
6609
|
// can only be using the temporary password. So it's safe to assume
|
|
5959
6610
|
// that we want to "complete" the password reset.
|
|
5960
|
-
//
|
|
6611
|
+
// There maybe 2FA so we listen for the auth event from Amplify.
|
|
5961
6612
|
const retPromise = new Promise((resolve) => {
|
|
5962
6613
|
const listener = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
5963
6614
|
if (data.payload.event !== 'signIn') {
|
|
5964
6615
|
return;
|
|
5965
6616
|
}
|
|
5966
6617
|
Hub.remove('auth', listener);
|
|
5967
|
-
yield this.
|
|
6618
|
+
yield this.cognito.signIn(resetUser.username, newIdpPassword);
|
|
5968
6619
|
// Switch over to the new set of keys
|
|
5969
6620
|
yield this.lrGraphQL.lrMutate(new LrMutation({
|
|
5970
6621
|
mutation: CompleteTpPasswordResetRequestMutation,
|
|
@@ -5981,7 +6632,7 @@ class LifeReadyAuthService {
|
|
|
5981
6632
|
});
|
|
5982
6633
|
// Signin as the original user. Password has been reset to temporary one. It should return
|
|
5983
6634
|
// with NEW_PASSWORD_REQUIRED
|
|
5984
|
-
let user = yield this.
|
|
6635
|
+
let user = yield this.cognito.signIn(resetUser.username, tempIdpPassword, {
|
|
5985
6636
|
noProxy: 'true',
|
|
5986
6637
|
});
|
|
5987
6638
|
if (user.challengeName !== 'NEW_PASSWORD_REQUIRED') {
|
|
@@ -5990,42 +6641,73 @@ class LifeReadyAuthService {
|
|
|
5990
6641
|
// Set new password on Idp
|
|
5991
6642
|
// the awsFetch() function passes NEW_PASSWORD_REQUIRED directly to AWS without
|
|
5992
6643
|
// going through the proxy.
|
|
5993
|
-
user = yield this.
|
|
6644
|
+
user = yield this.cognito.completeNewPassword(user, newIdpPassword, {});
|
|
5994
6645
|
return retPromise;
|
|
5995
6646
|
});
|
|
5996
6647
|
}
|
|
5997
|
-
|
|
6648
|
+
// ------------------------------------------------------
|
|
6649
|
+
// Debug utilities
|
|
6650
|
+
// ------------------------------------------------------
|
|
6651
|
+
debugLogin(username, password) {
|
|
6652
|
+
// This will fail if debug is null. But when debug is null, this function
|
|
6653
|
+
// should not be called.
|
|
6654
|
+
this.kcConfig.debug.username = username;
|
|
6655
|
+
return this.debugLoadUser(password);
|
|
6656
|
+
}
|
|
6657
|
+
debugLoadUser(password) {
|
|
5998
6658
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5999
|
-
const
|
|
6000
|
-
const
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6659
|
+
const currentUser = yield this.fetchCurrentUser();
|
|
6660
|
+
const { username, currentUserKey } = currentUser;
|
|
6661
|
+
// Debug mode can not deal with session encryption key yet.
|
|
6662
|
+
// NO SESSION ENCRYPTION KEY.
|
|
6663
|
+
const passKey = (yield this.keyFactoryService.derivePassKey(Object.assign({ password }, currentUserKey.passKey.passKeyParams))).jwk;
|
|
6664
|
+
const masterKey = yield this.keyGraphService.unwrapWithPassKey(currentUserKey.passKey.id, passKey, currentUserKey.masterKey.id);
|
|
6665
|
+
yield this.idleService.persistMasterKey(masterKey);
|
|
6666
|
+
yield this.keyGraphService.populateKeys(currentUserKey);
|
|
6667
|
+
this.user = {
|
|
6668
|
+
username,
|
|
6669
|
+
resetUser: null,
|
|
6670
|
+
sub: 'DEBUG_MODE',
|
|
6671
|
+
loginEmail: 'DEBUG_MODE',
|
|
6672
|
+
};
|
|
6673
|
+
return this.user;
|
|
6004
6674
|
});
|
|
6005
6675
|
}
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6676
|
+
/**
|
|
6677
|
+
* Clears the caches user. So we can simulate a page refresh and test getUser().
|
|
6678
|
+
*/
|
|
6679
|
+
debugClearUser() {
|
|
6680
|
+
this.user = null;
|
|
6681
|
+
}
|
|
6682
|
+
};
|
|
6683
|
+
Auth2Service.CHALLENGE_TIMEOUT = 1000 * 60 * 5;
|
|
6684
|
+
Auth2Service.ɵprov = ɵɵdefineInjectable({ factory: function Auth2Service_Factory() { return new Auth2Service(ɵɵinject(NgZone), ɵɵinject(INJECTOR), ɵɵinject(HttpClient), ɵɵinject(AuthClass), ɵɵinject(LrGraphQLService), ɵɵinject(KeyService), ɵɵinject(KeyGraphService), ɵɵinject(KeyFactoryService), ɵɵinject(PasswordService), ɵɵinject(IdleService), ɵɵinject(PersistService), ɵɵinject(EncryptionService), ɵɵinject(TpPasswordResetAssemblyController), ɵɵinject(KC_CONFIG)); }, token: Auth2Service, providedIn: "root" });
|
|
6685
|
+
Auth2Service.decorators = [
|
|
6009
6686
|
{ type: Injectable, args: [{
|
|
6010
6687
|
providedIn: 'root',
|
|
6011
6688
|
},] }
|
|
6012
6689
|
];
|
|
6013
|
-
|
|
6014
|
-
{ type:
|
|
6690
|
+
Auth2Service.ctorParameters = () => [
|
|
6691
|
+
{ type: NgZone },
|
|
6692
|
+
{ type: Injector },
|
|
6693
|
+
{ type: HttpClient },
|
|
6015
6694
|
{ type: AuthClass },
|
|
6016
|
-
{ type:
|
|
6695
|
+
{ type: LrGraphQLService },
|
|
6017
6696
|
{ type: KeyService },
|
|
6018
|
-
{ type: ProfileService },
|
|
6019
6697
|
{ type: KeyGraphService },
|
|
6698
|
+
{ type: KeyFactoryService },
|
|
6020
6699
|
{ type: PasswordService },
|
|
6021
6700
|
{ type: IdleService },
|
|
6022
|
-
{ type: LrGraphQLService },
|
|
6023
|
-
{ type: TpPasswordResetProcessorService },
|
|
6024
6701
|
{ type: PersistService },
|
|
6025
6702
|
{ type: EncryptionService },
|
|
6026
6703
|
{ type: TpPasswordResetAssemblyController },
|
|
6027
|
-
{ type:
|
|
6704
|
+
{ type: undefined, decorators: [{ type: Inject, args: [KC_CONFIG,] }] }
|
|
6028
6705
|
];
|
|
6706
|
+
Auth2Service = Auth2Service_1 = __decorate([
|
|
6707
|
+
RunOutsideAngular({
|
|
6708
|
+
ngZoneName: 'ngZone',
|
|
6709
|
+
})
|
|
6710
|
+
], Auth2Service);
|
|
6029
6711
|
|
|
6030
6712
|
var FileType;
|
|
6031
6713
|
(function (FileType) {
|
|
@@ -6717,7 +7399,7 @@ let ContactCard2Service = class ContactCard2Service {
|
|
|
6717
7399
|
createContactCard(input) {
|
|
6718
7400
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6719
7401
|
// Get encryption key
|
|
6720
|
-
const rootKey =
|
|
7402
|
+
const rootKey = this.keyService.currentRootKey;
|
|
6721
7403
|
const key = yield this.keyFactory.createKey();
|
|
6722
7404
|
const wrappedKey = yield this.keyGraph.encryptToString(rootKey.jwk, key.toJSON(true));
|
|
6723
7405
|
const cipherData = yield this.keyGraph.encryptToString(key, input.plainCipherDataJson);
|
|
@@ -6756,7 +7438,7 @@ let ContactCard2Service = class ContactCard2Service {
|
|
|
6756
7438
|
}
|
|
6757
7439
|
prepareContactCardInput(input) {
|
|
6758
7440
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6759
|
-
const sigPxk =
|
|
7441
|
+
const sigPxk = this.keyService.currentSigPxk;
|
|
6760
7442
|
const publicDataSig = JSON.stringify(yield this.encryptionService.sign(sigPxk.jwk, input.publicDataJson));
|
|
6761
7443
|
const publicSearchableSig = JSON.stringify(yield this.encryptionService.sign(sigPxk.jwk, input.publicSearchableJson));
|
|
6762
7444
|
const plainDataSig = JSON.stringify(yield this.encryptionService.sign(sigPxk.jwk, input.plainDataJson));
|
|
@@ -7128,7 +7810,7 @@ query FileStateKeyQuery($id: LrRelayIdInput!) {
|
|
|
7128
7810
|
|
|
7129
7811
|
var Item2Service_1;
|
|
7130
7812
|
let Item2Service = Item2Service_1 = class Item2Service extends LrService {
|
|
7131
|
-
constructor(ngZone, injector, fileUploadService, keyService, keyFactory, keyGraph, lockService,
|
|
7813
|
+
constructor(ngZone, injector, fileUploadService, keyService, keyFactory, keyGraph, lockService, auth2Service) {
|
|
7132
7814
|
super(injector);
|
|
7133
7815
|
this.ngZone = ngZone;
|
|
7134
7816
|
this.injector = injector;
|
|
@@ -7137,10 +7819,10 @@ let Item2Service = Item2Service_1 = class Item2Service extends LrService {
|
|
|
7137
7819
|
this.keyFactory = keyFactory;
|
|
7138
7820
|
this.keyGraph = keyGraph;
|
|
7139
7821
|
this.lockService = lockService;
|
|
7140
|
-
this.
|
|
7822
|
+
this.auth2Service = auth2Service;
|
|
7141
7823
|
// Caching the temp directory.
|
|
7142
7824
|
this.tempDirectory = null;
|
|
7143
|
-
this.
|
|
7825
|
+
this.auth2Service.addLogoutListener(() => this.onLogout());
|
|
7144
7826
|
}
|
|
7145
7827
|
downloadFileContent(options) {
|
|
7146
7828
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -7635,7 +8317,7 @@ let Item2Service = Item2Service_1 = class Item2Service extends LrService {
|
|
|
7635
8317
|
// TODO this is rather an unfortunate name, change it to asRootDirectory.
|
|
7636
8318
|
let parentRootDirectory;
|
|
7637
8319
|
if (options.asRootDirectory) {
|
|
7638
|
-
const rootKey = this.keyService.
|
|
8320
|
+
const rootKey = this.keyService.currentRootKey;
|
|
7639
8321
|
parentRootDirectory = {
|
|
7640
8322
|
wrappingKeyId: rootKey.id,
|
|
7641
8323
|
wrappedKey: yield this.keyGraph.wrapKey(rootKey, directoryKey),
|
|
@@ -7704,7 +8386,7 @@ Item2Service.TEMP_DIRECTORY_PLAIN_META_FILTER = JSON.stringify({
|
|
|
7704
8386
|
},
|
|
7705
8387
|
],
|
|
7706
8388
|
});
|
|
7707
|
-
Item2Service.ɵprov = ɵɵdefineInjectable({ factory: function Item2Service_Factory() { return new Item2Service(ɵɵinject(NgZone), ɵɵinject(INJECTOR), ɵɵinject(FileUploadService), ɵɵinject(KeyService), ɵɵinject(KeyFactoryService), ɵɵinject(KeyGraphService), ɵɵinject(LockService), ɵɵinject(
|
|
8389
|
+
Item2Service.ɵprov = ɵɵdefineInjectable({ factory: function Item2Service_Factory() { return new Item2Service(ɵɵinject(NgZone), ɵɵinject(INJECTOR), ɵɵinject(FileUploadService), ɵɵinject(KeyService), ɵɵinject(KeyFactoryService), ɵɵinject(KeyGraphService), ɵɵinject(LockService), ɵɵinject(Auth2Service)); }, token: Item2Service, providedIn: "root" });
|
|
7708
8390
|
Item2Service.decorators = [
|
|
7709
8391
|
{ type: Injectable, args: [{
|
|
7710
8392
|
providedIn: 'root',
|
|
@@ -7718,7 +8400,7 @@ Item2Service.ctorParameters = () => [
|
|
|
7718
8400
|
{ type: KeyFactoryService },
|
|
7719
8401
|
{ type: KeyGraphService },
|
|
7720
8402
|
{ type: LockService },
|
|
7721
|
-
{ type:
|
|
8403
|
+
{ type: Auth2Service }
|
|
7722
8404
|
];
|
|
7723
8405
|
Item2Service = Item2Service_1 = __decorate([
|
|
7724
8406
|
RunOutsideAngular({
|
|
@@ -7912,88 +8594,6 @@ mutation CompleteKeyExchangeOtk(
|
|
|
7912
8594
|
}
|
|
7913
8595
|
}`;
|
|
7914
8596
|
|
|
7915
|
-
const RequestUserDeleteMutation = gql `
|
|
7916
|
-
mutation RequestUserDelete($input: RequestUserDeleteInput!) {
|
|
7917
|
-
requestUserDelete(input: $input) {
|
|
7918
|
-
userDelete {
|
|
7919
|
-
state
|
|
7920
|
-
created
|
|
7921
|
-
}
|
|
7922
|
-
}
|
|
7923
|
-
}
|
|
7924
|
-
`;
|
|
7925
|
-
const CancelUserDeleteMutation = gql `
|
|
7926
|
-
mutation CancelUserDelete($input: CancelUserDeleteInput!) {
|
|
7927
|
-
cancelUserDelete(input: $input) {
|
|
7928
|
-
id
|
|
7929
|
-
}
|
|
7930
|
-
}
|
|
7931
|
-
`;
|
|
7932
|
-
const LoginHistoryQuery = gql `
|
|
7933
|
-
query LoginHistory($first: Int, $after: String) {
|
|
7934
|
-
loginHistory(first: $first, after: $after) {
|
|
7935
|
-
pageInfo {
|
|
7936
|
-
hasNextPage
|
|
7937
|
-
hasPreviousPage
|
|
7938
|
-
startCursor
|
|
7939
|
-
endCursor
|
|
7940
|
-
}
|
|
7941
|
-
events
|
|
7942
|
-
}
|
|
7943
|
-
}
|
|
7944
|
-
`;
|
|
7945
|
-
|
|
7946
|
-
class UserService {
|
|
7947
|
-
constructor(lrApollo) {
|
|
7948
|
-
this.lrApollo = lrApollo;
|
|
7949
|
-
}
|
|
7950
|
-
requestUserDelete() {
|
|
7951
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
7952
|
-
const res = yield this.lrApollo.mutate({
|
|
7953
|
-
mutation: RequestUserDeleteMutation,
|
|
7954
|
-
variables: {
|
|
7955
|
-
input: {},
|
|
7956
|
-
},
|
|
7957
|
-
});
|
|
7958
|
-
return res.requestUserDelete.userDelete;
|
|
7959
|
-
});
|
|
7960
|
-
}
|
|
7961
|
-
cancelUserDelete() {
|
|
7962
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
7963
|
-
const res = yield this.lrApollo.mutate({
|
|
7964
|
-
mutation: CancelUserDeleteMutation,
|
|
7965
|
-
variables: {
|
|
7966
|
-
input: {},
|
|
7967
|
-
},
|
|
7968
|
-
});
|
|
7969
|
-
return res.cancelUserDelete.id;
|
|
7970
|
-
});
|
|
7971
|
-
}
|
|
7972
|
-
loginHistory(first = null, after = null) {
|
|
7973
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
7974
|
-
// first: return first n entries
|
|
7975
|
-
// after: pass in the pageInfo.endCursor to paginate
|
|
7976
|
-
const res = yield this.lrApollo.query({
|
|
7977
|
-
query: LoginHistoryQuery,
|
|
7978
|
-
variables: {
|
|
7979
|
-
first,
|
|
7980
|
-
after,
|
|
7981
|
-
},
|
|
7982
|
-
});
|
|
7983
|
-
return res.loginHistory;
|
|
7984
|
-
});
|
|
7985
|
-
}
|
|
7986
|
-
}
|
|
7987
|
-
UserService.ɵprov = ɵɵdefineInjectable({ factory: function UserService_Factory() { return new UserService(ɵɵinject(LrApolloService)); }, token: UserService, providedIn: "root" });
|
|
7988
|
-
UserService.decorators = [
|
|
7989
|
-
{ type: Injectable, args: [{
|
|
7990
|
-
providedIn: 'root',
|
|
7991
|
-
},] }
|
|
7992
|
-
];
|
|
7993
|
-
UserService.ctorParameters = () => [
|
|
7994
|
-
{ type: LrApolloService }
|
|
7995
|
-
];
|
|
7996
|
-
|
|
7997
8597
|
var OtkState;
|
|
7998
8598
|
(function (OtkState) {
|
|
7999
8599
|
OtkState["OTK_INITIATED"] = "OTK_INITIATED";
|
|
@@ -8002,13 +8602,12 @@ var OtkState;
|
|
|
8002
8602
|
})(OtkState || (OtkState = {}));
|
|
8003
8603
|
|
|
8004
8604
|
class KeyExchangeService {
|
|
8005
|
-
constructor(keyFactory, keyService, lrApollo, encryptionService,
|
|
8605
|
+
constructor(keyFactory, keyService, lrApollo, encryptionService, auth2Service) {
|
|
8006
8606
|
this.keyFactory = keyFactory;
|
|
8007
8607
|
this.keyService = keyService;
|
|
8008
8608
|
this.lrApollo = lrApollo;
|
|
8009
8609
|
this.encryptionService = encryptionService;
|
|
8010
|
-
this.
|
|
8011
|
-
this.userService = userService;
|
|
8610
|
+
this.auth2Service = auth2Service;
|
|
8012
8611
|
this.CLIENT_NONCE_LENGTH = 32;
|
|
8013
8612
|
}
|
|
8014
8613
|
getKeyExchangeList(input = {}) {
|
|
@@ -8057,7 +8656,7 @@ class KeyExchangeService {
|
|
|
8057
8656
|
decryptKeyExchange(keyExchange, otKeyK) {
|
|
8058
8657
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8059
8658
|
if (keyExchange.isInitiator) {
|
|
8060
|
-
const rootKey =
|
|
8659
|
+
const rootKey = this.keyService.currentRootKey;
|
|
8061
8660
|
// Decrypt using the root key to get the Prk
|
|
8062
8661
|
const plainInitiatorRootKeyCipher = (yield this.encryptionService.decrypt(rootKey.jwk, keyExchange.initiatorRootKeyCipher));
|
|
8063
8662
|
const plainInitiatorOneTimePbkCipher = keyExchange.otk
|
|
@@ -8102,7 +8701,7 @@ class KeyExchangeService {
|
|
|
8102
8701
|
!keyExchange.isInitiator &&
|
|
8103
8702
|
keyExchange.otk.responderPbkCipher) {
|
|
8104
8703
|
// Assuming existing user getting invited where OTK is wrapped in responder's public key.
|
|
8105
|
-
const prk =
|
|
8704
|
+
const prk = this.keyService.currentPxk;
|
|
8106
8705
|
const decryptedCipher = yield this.encryptionService.decrypt(prk.jwk, JSON.parse(keyExchange.otk.responderPbkCipher), {
|
|
8107
8706
|
serializations: [JoseSerialization.COMPACT],
|
|
8108
8707
|
});
|
|
@@ -8117,7 +8716,7 @@ class KeyExchangeService {
|
|
|
8117
8716
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8118
8717
|
const otKey = yield this.keyFactory.createKey();
|
|
8119
8718
|
const nonce = this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH);
|
|
8120
|
-
const user = yield this.
|
|
8719
|
+
const user = yield this.auth2Service.getUser();
|
|
8121
8720
|
// New PKC key for encryption. This key is used only once when the responder sends
|
|
8122
8721
|
// back their signing public key.
|
|
8123
8722
|
const initiatorOneTimePrk = yield this.keyFactory.createPkcKey();
|
|
@@ -8125,8 +8724,8 @@ class KeyExchangeService {
|
|
|
8125
8724
|
// const initiatorSigPrk = await this.keyService.createPkcSignKey();
|
|
8126
8725
|
// Option 2: Use the user's global signing key.
|
|
8127
8726
|
// This key is used to prove the initiator's identity.
|
|
8128
|
-
const initiatorPrk =
|
|
8129
|
-
const initiatorSigPrk =
|
|
8727
|
+
const initiatorPrk = this.keyService.currentPxk;
|
|
8728
|
+
const initiatorSigPrk = this.keyService.currentSigPxk;
|
|
8130
8729
|
let initiatorPlainDataSig = null;
|
|
8131
8730
|
if (contactCard && contactCard.ownerPlainData) {
|
|
8132
8731
|
initiatorPlainDataSig = JSON.stringify(yield this.encryptionService.sign(initiatorSigPrk.jwk, contactCard.ownerPlainData));
|
|
@@ -8162,7 +8761,7 @@ class KeyExchangeService {
|
|
|
8162
8761
|
initiatorContactCard: contactCard,
|
|
8163
8762
|
initiator,
|
|
8164
8763
|
};
|
|
8165
|
-
const rootKey =
|
|
8764
|
+
const rootKey = this.keyService.currentRootKey;
|
|
8166
8765
|
const initiatorRootKeyCipher = yield this.encryptionService.encrypt(rootKey.jwk, plainInitiatorRootKeyCipher);
|
|
8167
8766
|
// The raw OTK
|
|
8168
8767
|
const otKeyK = otKey.toJSON(true).k;
|
|
@@ -8195,10 +8794,9 @@ class KeyExchangeService {
|
|
|
8195
8794
|
}
|
|
8196
8795
|
respondOtk({ id, token, decryptedOtk, message, initiatorContactCard, responderContactCard: sentContactCard, }) {
|
|
8197
8796
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8198
|
-
const user = yield this.
|
|
8199
|
-
const rootKey =
|
|
8200
|
-
const
|
|
8201
|
-
const masterKey = yield this.keyService.getCurrentMasterKey();
|
|
8797
|
+
const user = yield this.auth2Service.getUser();
|
|
8798
|
+
const rootKey = this.keyService.currentRootKey;
|
|
8799
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
8202
8800
|
const sharedKey = yield this.keyFactory.createKey();
|
|
8203
8801
|
const mkSharedKey = yield this.keyFactory.createKey();
|
|
8204
8802
|
const rkWrappedSharedKey = yield this.encryptionService.encrypt(rootKey.jwk, sharedKey.toJSON(true));
|
|
@@ -8211,8 +8809,8 @@ class KeyExchangeService {
|
|
|
8211
8809
|
// const responderSigPrk = await this.keyService.createPkcSignKey()
|
|
8212
8810
|
// const rkWrappedResponderSigPrk = await this.encrypt(rootKey, responderSigPrk.toJSON(true));
|
|
8213
8811
|
// Option 2: Responder already has a signing Prk
|
|
8214
|
-
const responderPrk =
|
|
8215
|
-
const responderSigPrk =
|
|
8812
|
+
const responderPrk = this.keyService.currentPxk;
|
|
8813
|
+
const responderSigPrk = this.keyService.currentSigPxk;
|
|
8216
8814
|
const signedInitiatorPbk = yield this.encryptionService.sign(responderSigPrk.jwk, initiatorPbk.toJSON());
|
|
8217
8815
|
const signedInitiatorSigPbk = yield this.encryptionService.sign(responderSigPrk.jwk, initiatorSigPbk.toJSON());
|
|
8218
8816
|
const plainInitiatorOneTimePbkCipher = {
|
|
@@ -8238,7 +8836,7 @@ class KeyExchangeService {
|
|
|
8238
8836
|
// Create keys
|
|
8239
8837
|
const receiverKey = yield this.keyFactory.createKey();
|
|
8240
8838
|
const ccSharedKey = yield this.keyFactory.createKey();
|
|
8241
|
-
const sigPxk =
|
|
8839
|
+
const sigPxk = this.keyService.currentSigPxk;
|
|
8242
8840
|
receivedCardInput = {
|
|
8243
8841
|
receiverWrappedKey: JSON.stringify(yield this.encryptionService.encrypt(rootKey.jwk, receiverKey.toJSON(true))),
|
|
8244
8842
|
receiverWrappingKeyId: rootKey.id,
|
|
@@ -8257,7 +8855,7 @@ class KeyExchangeService {
|
|
|
8257
8855
|
// Create keys
|
|
8258
8856
|
const ownerKey = yield this.keyFactory.createKey();
|
|
8259
8857
|
const ccSharedKey = yield this.keyFactory.createKey();
|
|
8260
|
-
const sigPxk =
|
|
8858
|
+
const sigPxk = this.keyService.currentSigPxk;
|
|
8261
8859
|
sentCardInput = {
|
|
8262
8860
|
ownerWrappedKey: JSON.stringify(yield this.encryptionService.encrypt(rootKey.jwk, ownerKey.toJSON(true))),
|
|
8263
8861
|
ownerWrappingKeyId: rootKey.id,
|
|
@@ -8286,7 +8884,7 @@ class KeyExchangeService {
|
|
|
8286
8884
|
keyExchangeId: id,
|
|
8287
8885
|
keyExchangeToken: token,
|
|
8288
8886
|
rootKeyId: rootKey.id,
|
|
8289
|
-
masterKeyId,
|
|
8887
|
+
masterKeyId: masterKey.id,
|
|
8290
8888
|
// These will be stored on the server
|
|
8291
8889
|
responderPxkId: responderPrk.id,
|
|
8292
8890
|
responderSigPxkId: responderSigPrk.id,
|
|
@@ -8313,8 +8911,8 @@ class KeyExchangeService {
|
|
|
8313
8911
|
}
|
|
8314
8912
|
completeOtk(keyExchangeId, initiatorRootKeyCipher, initiatorOneTimePbkCipher, responderContactCard) {
|
|
8315
8913
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8316
|
-
const rootKey =
|
|
8317
|
-
const masterKey =
|
|
8914
|
+
const rootKey = this.keyService.currentRootKey;
|
|
8915
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
8318
8916
|
// Decrypt using the root key to get the Prk
|
|
8319
8917
|
const plainInitiatorRootKeyCipher = (yield this.encryptionService.decrypt(rootKey.jwk, initiatorRootKeyCipher));
|
|
8320
8918
|
// The Prk is single-use and only used to send information from the responder back to the initiator.
|
|
@@ -8330,7 +8928,7 @@ class KeyExchangeService {
|
|
|
8330
8928
|
// In this case the initiatorSigPrk is already a part of the key graph.
|
|
8331
8929
|
// So there's nothing to do here.
|
|
8332
8930
|
// Protected the signing public key of the responder.
|
|
8333
|
-
const initiatorSigPrk =
|
|
8931
|
+
const initiatorSigPrk = this.keyService.currentSigPxk;
|
|
8334
8932
|
const responderSigPbk = yield KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.sigPbk);
|
|
8335
8933
|
const responderPbk = yield KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.pbk);
|
|
8336
8934
|
const signedResponderPbk = yield this.encryptionService.sign(initiatorSigPrk.jwk, responderPbk.toJSON());
|
|
@@ -8408,7 +9006,7 @@ class KeyExchangeService {
|
|
|
8408
9006
|
});
|
|
8409
9007
|
}
|
|
8410
9008
|
}
|
|
8411
|
-
KeyExchangeService.ɵprov = ɵɵdefineInjectable({ factory: function KeyExchangeService_Factory() { return new KeyExchangeService(ɵɵinject(KeyFactoryService), ɵɵinject(KeyService), ɵɵinject(LrApolloService), ɵɵinject(EncryptionService), ɵɵinject(
|
|
9009
|
+
KeyExchangeService.ɵprov = ɵɵdefineInjectable({ factory: function KeyExchangeService_Factory() { return new KeyExchangeService(ɵɵinject(KeyFactoryService), ɵɵinject(KeyService), ɵɵinject(LrApolloService), ɵɵinject(EncryptionService), ɵɵinject(Auth2Service)); }, token: KeyExchangeService, providedIn: "root" });
|
|
8412
9010
|
KeyExchangeService.decorators = [
|
|
8413
9011
|
{ type: Injectable, args: [{
|
|
8414
9012
|
providedIn: 'root',
|
|
@@ -8419,8 +9017,7 @@ KeyExchangeService.ctorParameters = () => [
|
|
|
8419
9017
|
{ type: KeyService },
|
|
8420
9018
|
{ type: LrApolloService },
|
|
8421
9019
|
{ type: EncryptionService },
|
|
8422
|
-
{ type:
|
|
8423
|
-
{ type: UserService }
|
|
9020
|
+
{ type: Auth2Service }
|
|
8424
9021
|
];
|
|
8425
9022
|
|
|
8426
9023
|
const KeyExchangeFragment = gqlTyped `
|
|
@@ -8614,7 +9211,7 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8614
9211
|
!keyExchange.isInitiator &&
|
|
8615
9212
|
keyExchange.otk.responderPbkCipher) {
|
|
8616
9213
|
// Assuming existing user getting invited where OTK is wrapped in responder's public key.
|
|
8617
|
-
const prk =
|
|
9214
|
+
const prk = this.keyService.currentPxk;
|
|
8618
9215
|
const decryptedCipher = yield this.encryptionService.decrypt(prk.jwk, JSON.parse(keyExchange.otk.responderPbkCipher), {
|
|
8619
9216
|
serializations: [JoseSerialization.COMPACT],
|
|
8620
9217
|
});
|
|
@@ -8653,7 +9250,7 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8653
9250
|
}
|
|
8654
9251
|
decryptKeyExchangeAsInitiator(keyExchange) {
|
|
8655
9252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8656
|
-
const rootKey =
|
|
9253
|
+
const rootKey = this.keyService.currentRootKey;
|
|
8657
9254
|
// Decrypt using the root key to get the Prk
|
|
8658
9255
|
const initiatorRootKeyCipherClearJson = (yield this.encryptionService.decrypt(rootKey.jwk, keyExchange.initiatorRootKeyCipher));
|
|
8659
9256
|
const otKey = yield KeyFactoryService.asKey(initiatorRootKeyCipherClearJson.otKey);
|
|
@@ -8778,8 +9375,8 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8778
9375
|
// const initiatorSigPrk = await this.keyService.createPkcSignKey();
|
|
8779
9376
|
// Option 2: Use the user's global signing key.
|
|
8780
9377
|
// This key is used to prove the initiator's identity.
|
|
8781
|
-
const initiatorPrk =
|
|
8782
|
-
const initiatorSigPrk =
|
|
9378
|
+
const initiatorPrk = this.keyService.currentPxk;
|
|
9379
|
+
const initiatorSigPrk = this.keyService.currentSigPxk;
|
|
8783
9380
|
let initiatorPlainDataSig = null;
|
|
8784
9381
|
if (contactCard && contactCard.ownerPlainDataJson) {
|
|
8785
9382
|
initiatorPlainDataSig = yield this.encryptionService.signToString(initiatorSigPrk.jwk, contactCard.ownerPlainDataJson);
|
|
@@ -8816,7 +9413,7 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8816
9413
|
initiatorContactCard: contactCard,
|
|
8817
9414
|
initiator,
|
|
8818
9415
|
};
|
|
8819
|
-
const rootKey =
|
|
9416
|
+
const rootKey = this.keyService.currentRootKey;
|
|
8820
9417
|
const initiatorRootKeyCipher = yield this.keyGraph.encryptToString(rootKey.jwk, initiatorRootKeyCipherClearJson);
|
|
8821
9418
|
// The raw OTK
|
|
8822
9419
|
const otKeyK = otKey.toJSON(true).k;
|
|
@@ -8854,9 +9451,8 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8854
9451
|
}
|
|
8855
9452
|
respondOtkMutation({ keyExchangeId, token, decryptedOtk, message, initiatorContactCard, responderContactCard, }) {
|
|
8856
9453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8857
|
-
const rootKey =
|
|
8858
|
-
const
|
|
8859
|
-
const masterKey = yield this.keyService.getCurrentMasterKey();
|
|
9454
|
+
const rootKey = this.keyService.currentRootKey;
|
|
9455
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
8860
9456
|
const sharedKey = yield this.keyFactory.createKey();
|
|
8861
9457
|
const mkSharedKey = yield this.keyFactory.createKey();
|
|
8862
9458
|
const rkWrappedSharedKey = yield this.encryptionService.encrypt(rootKey.jwk, sharedKey.toJSON(true));
|
|
@@ -8869,8 +9465,8 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8869
9465
|
// const responderSigPrk = await this.keyService.createPkcSignKey()
|
|
8870
9466
|
// const rkWrappedResponderSigPrk = await this.encrypt(rootKey, responderSigPrk.toJSON(true));
|
|
8871
9467
|
// Option 2: Responder already has a signing Prk
|
|
8872
|
-
const responderPrk =
|
|
8873
|
-
const responderSigPrk =
|
|
9468
|
+
const responderPrk = this.keyService.currentPxk;
|
|
9469
|
+
const responderSigPrk = this.keyService.currentSigPxk;
|
|
8874
9470
|
const signedInitiatorPbk = yield this.encryptionService.sign(responderSigPrk.jwk, initiatorPbk.toJSON());
|
|
8875
9471
|
const signedInitiatorSigPbk = yield this.encryptionService.sign(responderSigPrk.jwk, initiatorSigPbk.toJSON());
|
|
8876
9472
|
const initiatorOneTimePbkCipherClearJson = {
|
|
@@ -8893,7 +9489,7 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8893
9489
|
// Create keys
|
|
8894
9490
|
const receiverKey = yield this.keyFactory.createKey();
|
|
8895
9491
|
const ccSharedKey = yield this.keyFactory.createKey();
|
|
8896
|
-
const sigPxk =
|
|
9492
|
+
const sigPxk = this.keyService.currentSigPxk;
|
|
8897
9493
|
receivedCardInput = {
|
|
8898
9494
|
receiverWrappedKey: JSON.stringify(yield this.encryptionService.encrypt(rootKey.jwk, receiverKey.toJSON(true))),
|
|
8899
9495
|
receiverWrappingKeyId: rootKey.id,
|
|
@@ -8912,7 +9508,7 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8912
9508
|
// Create keys
|
|
8913
9509
|
const ownerKey = yield this.keyFactory.createKey();
|
|
8914
9510
|
const ccSharedKey = yield this.keyFactory.createKey();
|
|
8915
|
-
const sigPxk =
|
|
9511
|
+
const sigPxk = this.keyService.currentSigPxk;
|
|
8916
9512
|
responderCardInput = {
|
|
8917
9513
|
ownerWrappedKey: JSON.stringify(yield this.encryptionService.encrypt(rootKey.jwk, ownerKey.toJSON(true))),
|
|
8918
9514
|
ownerWrappingKeyId: rootKey.id,
|
|
@@ -8941,7 +9537,7 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8941
9537
|
keyExchangeId,
|
|
8942
9538
|
keyExchangeToken: token,
|
|
8943
9539
|
rootKeyId: rootKey.id,
|
|
8944
|
-
masterKeyId,
|
|
9540
|
+
masterKeyId: masterKey.id,
|
|
8945
9541
|
// These will be stored on the server
|
|
8946
9542
|
responderPxkId: responderPrk.id,
|
|
8947
9543
|
responderSigPxkId: responderSigPrk.id,
|
|
@@ -8970,8 +9566,8 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8970
9566
|
}
|
|
8971
9567
|
completeOtkMutation({ keyExchangeId, initiatorRootKeyCipher, initiatorOneTimePbkCipher, responderContactCard, initiatorContactCard, }) {
|
|
8972
9568
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8973
|
-
const rootKey =
|
|
8974
|
-
const masterKey =
|
|
9569
|
+
const rootKey = this.keyService.currentRootKey;
|
|
9570
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
8975
9571
|
// Decrypt using the root key to get the Prk
|
|
8976
9572
|
const initiatorRootKeyCipherClearJson = (yield this.encryptionService.decrypt(rootKey.jwk, initiatorRootKeyCipher));
|
|
8977
9573
|
// The Prk is single-use and only used to send information from the responder back to the initiator.
|
|
@@ -8988,7 +9584,7 @@ let KeyExchange2Service = class KeyExchange2Service extends LrService {
|
|
|
8988
9584
|
// In this case the initiatorSigPrk is already a part of the key graph.
|
|
8989
9585
|
// So there's nothing to do here.
|
|
8990
9586
|
// Protected the signing public key of the responder.
|
|
8991
|
-
const initiatorSigPrk =
|
|
9587
|
+
const initiatorSigPrk = this.keyService.currentSigPxk;
|
|
8992
9588
|
const responderSigPbk = yield KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.sigPbk);
|
|
8993
9589
|
const responderPbk = yield KeyFactoryService.asKey(plainInitiatorOneTimePbkCipher.responder.pbk);
|
|
8994
9590
|
const signedResponderPbk = yield this.encryptionService.sign(initiatorSigPrk.jwk, responderPbk.toJSON());
|
|
@@ -9129,12 +9725,12 @@ const LbopsQuery = gql `
|
|
|
9129
9725
|
}
|
|
9130
9726
|
`;
|
|
9131
9727
|
class LbopService {
|
|
9132
|
-
constructor(config, http, lrApollo, auth,
|
|
9728
|
+
constructor(config, http, lrApollo, auth, auth2Service, keyFactory, keyService, encryptionService, keyGraph, passwordService) {
|
|
9133
9729
|
this.config = config;
|
|
9134
9730
|
this.http = http;
|
|
9135
9731
|
this.lrApollo = lrApollo;
|
|
9136
9732
|
this.auth = auth;
|
|
9137
|
-
this.
|
|
9733
|
+
this.auth2Service = auth2Service;
|
|
9138
9734
|
this.keyFactory = keyFactory;
|
|
9139
9735
|
this.keyService = keyService;
|
|
9140
9736
|
this.encryptionService = encryptionService;
|
|
@@ -9164,7 +9760,7 @@ class LbopService {
|
|
|
9164
9760
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9165
9761
|
const lbop = yield this.get(id);
|
|
9166
9762
|
lbop.name = name;
|
|
9167
|
-
const masterKey =
|
|
9763
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
9168
9764
|
const cipherMeta = yield this.encryptionService.encrypt(masterKey.jwk, lbop);
|
|
9169
9765
|
const res = yield this.lrApollo.mutate({
|
|
9170
9766
|
mutation: UpdateLbopQuery,
|
|
@@ -9186,7 +9782,7 @@ class LbopService {
|
|
|
9186
9782
|
id,
|
|
9187
9783
|
},
|
|
9188
9784
|
});
|
|
9189
|
-
const masterKey =
|
|
9785
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
9190
9786
|
const plainCipherMeta = yield this.encryptionService.decrypt(masterKey.jwk, JSON.parse(res.lbop.cipherMeta));
|
|
9191
9787
|
return Object.assign({ id: res.id }, plainCipherMeta);
|
|
9192
9788
|
});
|
|
@@ -9196,7 +9792,7 @@ class LbopService {
|
|
|
9196
9792
|
const res = yield this.lrApollo.query({
|
|
9197
9793
|
query: LbopsQuery,
|
|
9198
9794
|
});
|
|
9199
|
-
const masterKey = yield this.keyService.
|
|
9795
|
+
const masterKey = yield this.keyService.currentMasterKey;
|
|
9200
9796
|
return Promise.all(res.lbops.edges.map((edge) => __awaiter(this, void 0, void 0, function* () {
|
|
9201
9797
|
const plainCipherMeta = yield this.encryptionService.decrypt(masterKey.jwk, JSON.parse(edge.node.cipherMeta));
|
|
9202
9798
|
return Object.assign({ id: edge.node.id }, plainCipherMeta);
|
|
@@ -9227,8 +9823,7 @@ class LbopService {
|
|
|
9227
9823
|
const lbopKeyVerifier = yield this.keyFactory.createSignKey();
|
|
9228
9824
|
const wrappedLbopKeyVerifier = yield this.encryptionService.encrypt(lbopKey, lbopKeyVerifier.toJSON(true));
|
|
9229
9825
|
// Re-encrypt master key with new key
|
|
9230
|
-
const
|
|
9231
|
-
const masterKey = yield this.keyGraph.getKey(currentUser.currentUserKey.masterKey.id);
|
|
9826
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
9232
9827
|
const wrappedMasterKey = yield this.encryptionService.encrypt(lbopKey, masterKey.jwk.toJSON(true));
|
|
9233
9828
|
const meta = Object.assign(Object.assign({}, (name && { name })), { partial: this.getPartial(lbopString) });
|
|
9234
9829
|
const cipherMeta = yield this.encryptionService.encrypt(masterKey.jwk, meta);
|
|
@@ -9240,7 +9835,7 @@ class LbopService {
|
|
|
9240
9835
|
lbopKeyParams: JSON.stringify(lbopKeyParams),
|
|
9241
9836
|
lbopKeyVerifier: JSON.stringify(lbopKeyVerifier.toJSON(true)),
|
|
9242
9837
|
wrappedLbopKeyVerifier: JSON.stringify(wrappedLbopKeyVerifier),
|
|
9243
|
-
masterKeyId:
|
|
9838
|
+
masterKeyId: masterKey.id,
|
|
9244
9839
|
wrappedMasterKey: JSON.stringify(wrappedMasterKey),
|
|
9245
9840
|
},
|
|
9246
9841
|
},
|
|
@@ -9392,7 +9987,7 @@ class LbopService {
|
|
|
9392
9987
|
});
|
|
9393
9988
|
}
|
|
9394
9989
|
}
|
|
9395
|
-
LbopService.ɵprov = ɵɵdefineInjectable({ factory: function LbopService_Factory() { return new LbopService(ɵɵinject(KC_CONFIG), ɵɵinject(HttpClient), ɵɵinject(LrApolloService), ɵɵinject(AuthClass), ɵɵinject(
|
|
9990
|
+
LbopService.ɵprov = ɵɵdefineInjectable({ factory: function LbopService_Factory() { return new LbopService(ɵɵinject(KC_CONFIG), ɵɵinject(HttpClient), ɵɵinject(LrApolloService), ɵɵinject(AuthClass), ɵɵinject(Auth2Service), ɵɵinject(KeyFactoryService), ɵɵinject(KeyService), ɵɵinject(EncryptionService), ɵɵinject(KeyGraphService), ɵɵinject(PasswordService)); }, token: LbopService, providedIn: "root" });
|
|
9396
9991
|
LbopService.decorators = [
|
|
9397
9992
|
{ type: Injectable, args: [{
|
|
9398
9993
|
providedIn: 'root',
|
|
@@ -9403,7 +9998,7 @@ LbopService.ctorParameters = () => [
|
|
|
9403
9998
|
{ type: HttpClient },
|
|
9404
9999
|
{ type: LrApolloService },
|
|
9405
10000
|
{ type: AuthClass },
|
|
9406
|
-
{ type:
|
|
10001
|
+
{ type: Auth2Service },
|
|
9407
10002
|
{ type: KeyFactoryService },
|
|
9408
10003
|
{ type: KeyService },
|
|
9409
10004
|
{ type: EncryptionService },
|
|
@@ -10094,7 +10689,7 @@ class SharedContactCardService {
|
|
|
10094
10689
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10095
10690
|
const ownerKey = yield this.keyGraph.getKey(ownedKeyId);
|
|
10096
10691
|
const sharedKey = yield this.keyGraph.getKey(sharedKeyId);
|
|
10097
|
-
const sigPxk =
|
|
10692
|
+
const sigPxk = this.keyService.currentSigPxk;
|
|
10098
10693
|
const sharedCipherData = yield this.encryptionService.encrypt(sharedKey.jwk, contactCard);
|
|
10099
10694
|
const sharedCipherDataSig = JSON.stringify(yield this.encryptionService.sign(sigPxk.jwk, sharedCipherData));
|
|
10100
10695
|
const ownerPlainData = {
|
|
@@ -10131,6 +10726,88 @@ SharedContactCardService.ctorParameters = () => [
|
|
|
10131
10726
|
{ type: EncryptionService }
|
|
10132
10727
|
];
|
|
10133
10728
|
|
|
10729
|
+
const RequestUserDeleteMutation = gql `
|
|
10730
|
+
mutation RequestUserDelete($input: RequestUserDeleteInput!) {
|
|
10731
|
+
requestUserDelete(input: $input) {
|
|
10732
|
+
userDelete {
|
|
10733
|
+
state
|
|
10734
|
+
created
|
|
10735
|
+
}
|
|
10736
|
+
}
|
|
10737
|
+
}
|
|
10738
|
+
`;
|
|
10739
|
+
const CancelUserDeleteMutation = gql `
|
|
10740
|
+
mutation CancelUserDelete($input: CancelUserDeleteInput!) {
|
|
10741
|
+
cancelUserDelete(input: $input) {
|
|
10742
|
+
id
|
|
10743
|
+
}
|
|
10744
|
+
}
|
|
10745
|
+
`;
|
|
10746
|
+
const LoginHistoryQuery = gql `
|
|
10747
|
+
query LoginHistory($first: Int, $after: String) {
|
|
10748
|
+
loginHistory(first: $first, after: $after) {
|
|
10749
|
+
pageInfo {
|
|
10750
|
+
hasNextPage
|
|
10751
|
+
hasPreviousPage
|
|
10752
|
+
startCursor
|
|
10753
|
+
endCursor
|
|
10754
|
+
}
|
|
10755
|
+
events
|
|
10756
|
+
}
|
|
10757
|
+
}
|
|
10758
|
+
`;
|
|
10759
|
+
|
|
10760
|
+
class UserService {
|
|
10761
|
+
constructor(lrApollo) {
|
|
10762
|
+
this.lrApollo = lrApollo;
|
|
10763
|
+
}
|
|
10764
|
+
requestUserDelete() {
|
|
10765
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10766
|
+
const res = yield this.lrApollo.mutate({
|
|
10767
|
+
mutation: RequestUserDeleteMutation,
|
|
10768
|
+
variables: {
|
|
10769
|
+
input: {},
|
|
10770
|
+
},
|
|
10771
|
+
});
|
|
10772
|
+
return res.requestUserDelete.userDelete;
|
|
10773
|
+
});
|
|
10774
|
+
}
|
|
10775
|
+
cancelUserDelete() {
|
|
10776
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10777
|
+
const res = yield this.lrApollo.mutate({
|
|
10778
|
+
mutation: CancelUserDeleteMutation,
|
|
10779
|
+
variables: {
|
|
10780
|
+
input: {},
|
|
10781
|
+
},
|
|
10782
|
+
});
|
|
10783
|
+
return res.cancelUserDelete.id;
|
|
10784
|
+
});
|
|
10785
|
+
}
|
|
10786
|
+
loginHistory(first = null, after = null) {
|
|
10787
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10788
|
+
// first: return first n entries
|
|
10789
|
+
// after: pass in the pageInfo.endCursor to paginate
|
|
10790
|
+
const res = yield this.lrApollo.query({
|
|
10791
|
+
query: LoginHistoryQuery,
|
|
10792
|
+
variables: {
|
|
10793
|
+
first,
|
|
10794
|
+
after,
|
|
10795
|
+
},
|
|
10796
|
+
});
|
|
10797
|
+
return res.loginHistory;
|
|
10798
|
+
});
|
|
10799
|
+
}
|
|
10800
|
+
}
|
|
10801
|
+
UserService.ɵprov = ɵɵdefineInjectable({ factory: function UserService_Factory() { return new UserService(ɵɵinject(LrApolloService)); }, token: UserService, providedIn: "root" });
|
|
10802
|
+
UserService.decorators = [
|
|
10803
|
+
{ type: Injectable, args: [{
|
|
10804
|
+
providedIn: 'root',
|
|
10805
|
+
},] }
|
|
10806
|
+
];
|
|
10807
|
+
UserService.ctorParameters = () => [
|
|
10808
|
+
{ type: LrApolloService }
|
|
10809
|
+
];
|
|
10810
|
+
|
|
10134
10811
|
const TrustedPartyProperties = `
|
|
10135
10812
|
id
|
|
10136
10813
|
user {
|
|
@@ -12315,7 +12992,7 @@ let SharedContactCard2Service = class SharedContactCard2Service {
|
|
|
12315
12992
|
ownerKey = yield this.keyGraph.getKey(keys.ownerKeyId);
|
|
12316
12993
|
sharedKey = yield this.keyGraph.getKey(keys.sharedKeyId);
|
|
12317
12994
|
}
|
|
12318
|
-
const sigPxk =
|
|
12995
|
+
const sigPxk = this.keyService.currentSigPxk;
|
|
12319
12996
|
const sharedCipherData = yield this.encryptionService.encrypt(sharedKey.jwk, sharedCipherDataClearJson);
|
|
12320
12997
|
const sharedCipherDataSig = JSON.stringify(yield this.encryptionService.sign(sigPxk.jwk, sharedCipherData));
|
|
12321
12998
|
const ownerPlainDataSig = JSON.stringify(yield this.encryptionService.sign(sigPxk.jwk, ownerPlainDataJson));
|
|
@@ -12925,7 +13602,7 @@ let TrustedParty2Service = class TrustedParty2Service extends LrService {
|
|
|
12925
13602
|
if (userSharedKey.mkSharedKey) {
|
|
12926
13603
|
throw new KcBadStateException('TP already has mkSharedKey');
|
|
12927
13604
|
}
|
|
12928
|
-
const masterKey =
|
|
13605
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
12929
13606
|
const prk = yield this.keyFactory.createPkcKey();
|
|
12930
13607
|
const mkWrappedMkPrk = yield this.encryptionService.encryptToString(masterKey.jwk, prk.toJSON(true));
|
|
12931
13608
|
const sharedKey = yield this.keyGraph.getKey(userSharedKey.sharedKey.id);
|
|
@@ -12988,7 +13665,7 @@ let TrustedParty2Service = class TrustedParty2Service extends LrService {
|
|
|
12988
13665
|
id: plainMkReshareResponseCipher.mkSharedKey.id,
|
|
12989
13666
|
jwk: yield JWK.asKey(plainMkReshareResponseCipher.mkSharedKey.jwk),
|
|
12990
13667
|
};
|
|
12991
|
-
const masterKey =
|
|
13668
|
+
const masterKey = this.keyService.currentMasterKey;
|
|
12992
13669
|
const mkWrappedMkSharedKey = yield this.encryptionService.encryptToString(masterKey.jwk, mkSharedKey.jwk.toJSON(true));
|
|
12993
13670
|
return new LrMutation({
|
|
12994
13671
|
mutation: CompleteTpMkReshareMutation,
|
|
@@ -13116,5 +13793,5 @@ TwoFactorService.ctorParameters = () => [
|
|
|
13116
13793
|
* Generated bundle index. Do not edit.
|
|
13117
13794
|
*/
|
|
13118
13795
|
|
|
13119
|
-
export { AccessLevel, AccessRoleChoice, AccessRoleMethodChoice, ApiContactCard, ApiCurrentUser, ArchiveDirectoryMutation, CancelUserDeleteMutation, Category, CategoryFields, CategoryFilter, CategoryMetaService, CategoryService, ClaimApproverState, ClaimState, CognitoChallengeUser, CommonProcessorsService, CompleteOtkMutation, Config, ContactCard2Service, ContactCardAddress, ContactCardName, CreateCategoryMutation, CreateContactCardMutation$1 as CreateContactCardMutation, CreateFileMutation, CreateFileQuery, CreateLbopQuery, CreateRecordContainerMutation, CreateRecordMutation, CreateVaultMutation, CurrentCategory, CurrentUser, CurrentUserKey, CurrentUserQuery, CurrentUserSharedKeyQuery, DEFAULT_BREADCRUMB_DEPTH, DEFAULT_DESCENDANTS_DEPTH, DefaultCategory, DefaultProcessorOptions, DefaultVaultFilter, DeleteCategoryMutation, DeleteFileMutation, DeleteLbopQuery, DeleteRecordMutation, DirectoryQuery, DirectoryType, ERROR_SOURCE, FeatureAction, Features, FetchKeyGraphField, FileOperationField, FileQuery, FileType, FileUploadService, GetCategoriesQuery, GetCategoryKeyIdQuery, GetCategoryQuery, GetMySharedCategoriesQuery, GetRecordQuery, GetRootDirectoryIdsQuery, GetTrustedPartyCategoriesQuery, GetVaultsQuery, IdleService, InitiateOtkMutation, Item2Service, KC_CONFIG, KcAuthException, KcBadArgumentException, KcBadLogicException, KcBadRequestException, KcBadSignatureException, KcBadStateException, KcBadTimeSyncException, KcCodeMismatchException, KcConcurrentAccessException, KcEncryptionException, KcError, KcErrorCode, KcException, KcInternalErrorException, KcLbopErrorCode, KcLockedException, KcNotFoundException, KcSuspiciousOperationException, KcUnsupportedException, KeyExchange2Service, KeyExchangeFields, KeyExchangeMode, KeyExchangeOtkState, KeyExchangeQuery, KeyExchangeService, KeyExchangeState, KeyExchangeTokenQuery, KeyExchangesQuery, KeyGraphField, KeyGraphFragment, LbopQuery, LbopService, LbopsQuery, LifeReadyAuthService, LifeReadyModule, LinkTypeField, LoadedCategoryTree, LockService, LockState, LoginHistoryQuery, LoginResult, LrApolloService, LrGraphQLService, LrMergedMutation, LrMutation, LrMutationBase, LrRecord, LrService, MainContactCard, MainContactCardFields, MainContactCardPlainFields, MainContactCardProperty, MessageService, MoveDirectoryQuery, MoveFileQuery, NewAttachment, NewCategory, NewOrUpdatedAttachment, NewRecord, NotificationService, OtkState, OwnerPlainDataJson, PassIdpApiResult, PasswordChangeStatus, PasswordCheck, PasswordService, PermissionChoice, PersistService, Plan, Plan2Service, PlanService, PlanState, PlanStateField, ProfileDetailsService, ProfileService, QueryProcessorService, RecordAttachment, RecordAttachmentFilter, RecordAttachmentService, RecordContentFilter, RecordField, RecordFieldType, RecordFilter, RecordService, RecordType, RecordTypeField, RecordTypeFieldOption, RecordTypeService, RecordTypeSummary, RecoveryStatus,
|
|
13796
|
+
export { AccessLevel, AccessRoleChoice, AccessRoleMethodChoice, ApiContactCard, ApiCurrentUser, ArchiveDirectoryMutation, Auth2Service, auth2_types as AuthTypes, CancelUserDeleteMutation, Category, CategoryFields, CategoryFilter, CategoryMetaService, CategoryService, ClaimApproverState, ClaimState, CognitoChallengeUser, CommonProcessorsService, CompleteOtkMutation, Config, ContactCard2Service, ContactCardAddress, ContactCardName, CreateCategoryMutation, CreateContactCardMutation$1 as CreateContactCardMutation, CreateFileMutation, CreateFileQuery, CreateLbopQuery, CreateRecordContainerMutation, CreateRecordMutation, CreateVaultMutation, CurrentCategory, CurrentUser, CurrentUserKey, CurrentUserQuery, CurrentUserSharedKeyQuery, DEFAULT_BREADCRUMB_DEPTH, DEFAULT_DESCENDANTS_DEPTH, DefaultCategory, DefaultProcessorOptions, DefaultVaultFilter, DeleteCategoryMutation, DeleteFileMutation, DeleteLbopQuery, DeleteRecordMutation, DirectoryQuery, DirectoryType, ERROR_SOURCE, FeatureAction, Features, FetchKeyGraphField, FileOperationField, FileQuery, FileType, FileUploadService, GetCategoriesQuery, GetCategoryKeyIdQuery, GetCategoryQuery, GetMySharedCategoriesQuery, GetRecordQuery, GetRootDirectoryIdsQuery, GetTrustedPartyCategoriesQuery, GetVaultsQuery, IdleService, InitiateOtkMutation, Item2Service, KC_CONFIG, KcAuthException, KcBadArgumentException, KcBadLogicException, KcBadRequestException, KcBadSignatureException, KcBadStateException, KcBadTimeSyncException, KcCodeMismatchException, KcConcurrentAccessException, KcEncryptionException, KcError, KcErrorCode, KcException, KcInternalErrorException, KcLbopErrorCode, KcLockedException, KcNotFoundException, KcSuspiciousOperationException, KcUnsupportedException, KeyExchange2Service, KeyExchangeFields, KeyExchangeMode, KeyExchangeOtkState, KeyExchangeQuery, KeyExchangeService, KeyExchangeState, KeyExchangeTokenQuery, KeyExchangesQuery, KeyGraphField, KeyGraphFragment, LbopQuery, LbopService, LbopsQuery, LifeReadyAuthService, LifeReadyModule, LinkTypeField, LoadedCategoryTree, LockService, LockState, LoginHistoryQuery, LoginResult, LrApolloService, LrGraphQLService, LrMergedMutation, LrMutation, LrMutationBase, LrRecord, LrService, MainContactCard, MainContactCardFields, MainContactCardPlainFields, MainContactCardProperty, MessageService, MoveDirectoryQuery, MoveFileQuery, NewAttachment, NewCategory, NewOrUpdatedAttachment, NewRecord, NotificationService, OtkState, OwnerPlainDataJson, PassIdpApiResult, PasswordChangeStatus, PasswordCheck, PasswordService, PermissionChoice, PersistService, Plan, Plan2Service, PlanService, PlanState, PlanStateField, ProfileDetailsService, ProfileService, QueryProcessorService, RecordAttachment, RecordAttachmentFilter, RecordAttachmentService, RecordContentFilter, RecordField, RecordFieldType, RecordFilter, RecordService, RecordType, RecordTypeField, RecordTypeFieldOption, RecordTypeService, RecordTypeSummary, RecoveryStatus, RegisterService, RequestUserDeleteMutation, RespondOtkMutation, RevertFileQuery, ScenarioLastClaimState, ScenarioService, ScenarioState, ServerConfigService, ServerTimeQuery, SharedAccess, SharedContactCard2Service, StripeBillingPortalSession, StripeCheckoutSession, Subscription, TimeService, TpAssemblyState, TpClaimApproverState, TpClaimState, TpPasswordResetRequestService, TpPasswordResetService, TpPasswordResetUserService, TrustedParty2Service, TrustedPartyDetails, TwoFactorService, UnarchiveDirectoryMutation, UpdateCategoryMutation, UpdateContactCardMutation$1 as UpdateContactCardMutation, UpdateFileQuery, UpdateLbopQuery, UpdateRecordContainerMutation, UpdateRecordMutation, UpdatedCategory, UpdatedRecord, UserDeleteState, UserPlan, UserService, UserSharedKeyFields, Vault, VaultCategory, VaultFields, VaultRecord, VaultRecordType, WebCryptoService, awsFetch, configureAmplifyAuth, configureApollo, fragmentSpreadAstSelection, gqlTyped, handleApolloError, handleCognitoCallback, httpOptions, initialiseAuth, mapEdges, mapUserPlans, parentCategoriesField, processConnection, throwClaimIdMismatch, throwClaimNotApproved, ɵ0, KeyGraphService as ɵa, EncryptionService as ɵb, KeyService as ɵc, KeyFactoryService as ɵd, KeyMetaService as ɵe, LrGraphQLService as ɵf, TpPasswordResetProcessorService as ɵg, RunOutsideAngular as ɵh, TpPasswordResetAssemblyController as ɵi, TpAssemblyController as ɵj, LrService as ɵk, SharedContactCardService as ɵl, TrustedPartyService as ɵm, ScenarioAssemblyController as ɵn, TpPasswordResetPrivateService as ɵo };
|
|
13120
13797
|
//# sourceMappingURL=lifeready-core.js.map
|