@lifeready/core 1.1.15 → 1.1.17

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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Remove all keys in localstorage with matching prefix.
3
+ * A prefix must be specified. If you want to remove everything, then just use localStorage.clear().
4
+ *
5
+ * @param prefix Keys with this prefix will be removed.
6
+ */
7
+ export declare function clearLocalStorage(prefix: string): void;
8
+ /**
9
+ * Clear all items related to cognito in localstorage.
10
+ * The remember device function sometimes interferes with creating new users
11
+ * on TP based password reset.
12
+ */
13
+ export declare function clearCognitoLocalStorage(): void;
@@ -11,7 +11,6 @@ import { LifeReadyConfig } from '../life-ready.config';
11
11
  import { PasswordService } from '../password/password.service';
12
12
  import { PersistService } from '../persist/persist.service';
13
13
  import { ProfileService } from '../profile/profile.service';
14
- import { Slip39Service } from '../slip39/slip39.service';
15
14
  import { TpPasswordResetAssemblyController } from '../tp-password-reset/tp-password-reset.controller';
16
15
  import { CognitoChallengeUser, CurrentUser, LoginResult, TpPasswordResetUser } from './auth.types';
17
16
  export declare const initialiseAuth: (authService: LifeReadyAuthService) => () => Promise<void>;
@@ -32,23 +31,23 @@ export declare class LifeReadyAuthService {
32
31
  private tpPasswordResetProcessorService;
33
32
  private persistService;
34
33
  private encryptionService;
35
- private slip39Service;
36
34
  private assemblyController;
37
35
  private hubSubject;
38
36
  private currentUser;
39
37
  private currentResetUser;
40
38
  private logoutListeners;
41
- constructor(config: LifeReadyConfig, auth: AuthClass, keyFactory: KeyFactoryService, keyService: KeyService, profileService: ProfileService, keyGraphService: KeyGraphService, passwordService: PasswordService, idleService: IdleService, lrGraphQL: LrGraphQLService, tpPasswordResetProcessorService: TpPasswordResetProcessorService, persistService: PersistService, encryptionService: EncryptionService, slip39Service: Slip39Service, assemblyController: TpPasswordResetAssemblyController);
39
+ constructor(config: LifeReadyConfig, auth: AuthClass, keyFactory: KeyFactoryService, keyService: KeyService, profileService: ProfileService, keyGraphService: KeyGraphService, passwordService: PasswordService, idleService: IdleService, lrGraphQL: LrGraphQLService, tpPasswordResetProcessorService: TpPasswordResetProcessorService, persistService: PersistService, encryptionService: EncryptionService, assemblyController: TpPasswordResetAssemblyController);
42
40
  initialise(): Promise<void>;
41
+ importPassword(plainPassword: string): Promise<CryptoKey>;
43
42
  addLogoutListener(callback: LogoutListener): void;
44
43
  removeLogoutListener(callback: LogoutListener): void;
45
44
  private loginIdpImpl;
46
45
  private loginIdp;
47
46
  protected handleSessionEncryptionKey(): Promise<void>;
48
47
  protected handlePostAuth(cognitoUser: CognitoChallengeUser): Promise<void>;
49
- login(emailOrPhone: string, password: string, { tpPasswordResetAutoComplete }?: LoginOptions): Promise<LoginResult>;
50
- loginImpl(emailOrPhone: string, password: string): Promise<LoginResult>;
51
- verifyLogin(challenge: CognitoChallengeUser, password: string, rememberMe: boolean, code: string): Promise<CurrentUser>;
48
+ login(emailOrPhone: string, password: CryptoKey, { tpPasswordResetAutoComplete }?: LoginOptions): Promise<LoginResult>;
49
+ loginImpl(emailOrPhone: string, password: CryptoKey): Promise<LoginResult>;
50
+ verifyLogin(challenge: CognitoChallengeUser, password: CryptoKey, rememberMe: boolean, code: string): Promise<CurrentUser>;
52
51
  handlePasswordRecovery(user: CognitoChallengeUser): Promise<void>;
53
52
  getUserOrResetUser(reload?: boolean): Promise<CurrentUser | TpPasswordResetUser>;
54
53
  getResetUser(reload?: boolean): Promise<TpPasswordResetUser>;
@@ -58,8 +57,8 @@ export declare class LifeReadyAuthService {
58
57
  watchAuth(): ReplaySubject<any>;
59
58
  logout(): Promise<void>;
60
59
  private getUserAttribute;
61
- loadResetUser(password?: string): Promise<TpPasswordResetUser>;
60
+ loadResetUser(password?: CryptoKey): Promise<TpPasswordResetUser>;
62
61
  refreshAccessToken(): Promise<unknown>;
63
- completeRequest(newPassword: string): Promise<void>;
62
+ completeRequest(newPassword: CryptoKey): Promise<void>;
64
63
  private recoverAssemblyKey;
65
64
  }
@@ -3,11 +3,10 @@ import { JWK } from 'node-jose';
3
3
  import { JSONObject } from '../api/types';
4
4
  import { WebCryptoService } from '../web-crypto/web-crypto.service';
5
5
  import { DeriveKeyResult, DeriveLbopKeyParams, DerivePassIdpParams, DerivePassKeyParams, LbopKeyParams, PassIdpParams, PassKeyParams } from './key.types';
6
- export declare function sha256(message: any): Promise<string>;
7
6
  export declare class KeyFactoryService {
8
7
  private webCryptoService;
9
8
  constructor(webCryptoService: WebCryptoService);
10
- private readonly crypto;
9
+ private readonly kcCrypto;
11
10
  readonly MIN_PASS_IDP_PBKDF_ITER = 100000;
12
11
  readonly MIN_PASS_KEY_PBKDF_ITER = 100000;
13
12
  readonly MIN_LBOP_KEY_PBKDF_ITER = 100000;
@@ -23,8 +22,9 @@ export declare class KeyFactoryService {
23
22
  createSignKey(): Promise<JWK.Key>;
24
23
  createPkcKey(): Promise<JWK.Key>;
25
24
  createPkcSignKey(): Promise<JWK.Key>;
25
+ importPassword(plainPassword: string): Promise<CryptoKey>;
26
26
  deriveKey({ password, salt, iterations, kid, }: {
27
- password: string;
27
+ password: CryptoKey;
28
28
  salt: string;
29
29
  iterations: number;
30
30
  kid?: string;
@@ -69,11 +69,11 @@ export interface DeriveKeyResult {
69
69
  jwk: JWK.Key;
70
70
  }
71
71
  export interface DerivePassIdpParams extends PassIdpParams {
72
- password: string;
72
+ password: CryptoKey;
73
73
  }
74
74
  export interface DerivePassKeyParams extends PassKeyParams {
75
- password: string;
75
+ password: CryptoKey;
76
76
  }
77
77
  export interface DeriveLbopKeyParams extends PassKeyParams {
78
- password: string;
78
+ password: CryptoKey;
79
79
  }
@@ -7,11 +7,12 @@ import { EncryptionService } from '../encryption/encryption.service';
7
7
  import { KeyFactoryService as KFS } from '../key/key-factory.service';
8
8
  import { KeyGraphService } from '../key/key-graph.service';
9
9
  import { KeyService } from '../key/key.service';
10
+ import { PassKeyParams } from '../key/key.types';
10
11
  import { LifeReadyConfig } from '../life-ready.config';
11
12
  import { PasswordService } from '../password/password.service';
12
13
  export interface SetPasswordParams {
13
14
  lbopId: string;
14
- newPassword: string;
15
+ newPassword: CryptoKey;
15
16
  verifiedToken: string;
16
17
  masterKeyId: string;
17
18
  masterKey: JWK.Key;
@@ -41,9 +42,16 @@ export interface VerifyResult {
41
42
  masterKeyId: string;
42
43
  masterKey: JWK.Key;
43
44
  }
45
+ export interface ChallengeResultLbop {
46
+ lbopId: string;
47
+ lbopKeyParams: PassKeyParams;
48
+ wrappedLbopKeyVerifier: any;
49
+ }
44
50
  export interface ChallengeResult {
45
- challenge: any;
46
- lbops: any;
51
+ challenge: {
52
+ serverNonce: string;
53
+ };
54
+ lbops: ChallengeResultLbop[];
47
55
  }
48
56
  export interface Lbop {
49
57
  id: string;
@@ -34,10 +34,10 @@ export declare class PasswordService {
34
34
  private idleService;
35
35
  private readonly CLIENT_NONCE_LENGTH;
36
36
  constructor(config: LifeReadyConfig, http: HttpClient, apollo: LrApolloService, auth: AuthClass, profileService: ProfileService, keyFactory: KFS, encryptionService: EncryptionService, keyGraph: KeyGraphService, webCryptoService: WebCryptoService, idleService: IdleService);
37
- checkPassword(password: string): Promise<PasswordCheck>;
38
- getExposureCount(password: string): Promise<number>;
37
+ checkPassword(plainPassword: string): Promise<PasswordCheck>;
38
+ getExposureCount(plainPassword: string): Promise<number>;
39
39
  getPassIdpString(passIdp: JWK.Key): any;
40
- createPassKeyBundle(password: string): Promise<PassKeyBundle>;
40
+ createPassKeyBundle(password: CryptoKey): Promise<PassKeyBundle>;
41
41
  /**
42
42
  * We need to allow for interruption of the process at any point. Each API call can be considered
43
43
  * atomic and either succeeds or fails.
@@ -65,7 +65,7 @@ export declare class PasswordService {
65
65
  *
66
66
  */
67
67
  isLoginRequired(): Promise<boolean>;
68
- changePassword(password: string, newPassword: string): Promise<void>;
68
+ changePassword(password: CryptoKey, newPassword: CryptoKey): Promise<void>;
69
69
  changePasswordComplete(accessToken: string, useNewPassword: boolean, token?: string): Promise<Object>;
70
70
  private getVerifierPrK;
71
71
  private verifyPassword;
@@ -20,6 +20,6 @@ export declare class RegisterService {
20
20
  verifyEmail(email: string): Promise<string>;
21
21
  verifyPhone(phoneNumber: string): Promise<string>;
22
22
  confirmVerificationCode(verificationId: string, verificationCode: string): Promise<string>;
23
- register(email: string, password: string, verificationId: string, verificationToken: string, verificationType?: 'email' | 'phone'): Promise<RegisterResult>;
23
+ register(email: string, password: CryptoKey, verificationId: string, verificationToken: string, verificationType?: 'email' | 'phone'): Promise<RegisterResult>;
24
24
  hibpBreachedAccounts(account: string): Promise<any>;
25
25
  }
@@ -22,7 +22,7 @@ export declare class TpPasswordResetUserService extends LrService {
22
22
  claimId: string;
23
23
  }>;
24
24
  verifyContactRespond(claimId: string, claimCode: string): Promise<string>;
25
- requestReset(password: string, claimId: string, claimToken: string): Promise<{
25
+ requestReset(password: CryptoKey, claimId: string, claimToken: string): Promise<{
26
26
  requestResetResult: RequestResetResult;
27
27
  signUpResult: ISignUpResult;
28
28
  }>;
@@ -1,5 +1,5 @@
1
1
  export declare class WebCryptoService {
2
- crypto: Crypto;
2
+ kcCrypto: Crypto;
3
3
  toHex(buffer: ArrayBuffer): string;
4
4
  stringDigest(algorithm: string, message: string): Promise<string>;
5
5
  }
@@ -3,17 +3,16 @@
3
3
  */
4
4
  export * from './public-api';
5
5
  export { RunOutsideAngular as ɵh } from './lib/_common/run-outside-angular';
6
- export { LrGraphQLService as ɵf, LrService as ɵl } from './lib/api/lr-graphql';
6
+ export { LrGraphQLService as ɵf, LrService as ɵk } from './lib/api/lr-graphql';
7
7
  export { TpPasswordResetProcessorService as ɵg } from './lib/api/query-processor/tp-password-reset-processor.service';
8
8
  export { EncryptionService as ɵb } from './lib/encryption/encryption.service';
9
9
  export { KeyFactoryService as ɵd } from './lib/key/key-factory.service';
10
10
  export { KeyGraphService as ɵa } from './lib/key/key-graph.service';
11
11
  export { KeyMetaService as ɵe } from './lib/key/key-meta.service';
12
12
  export { KeyService as ɵc } from './lib/key/key.service';
13
- export { ScenarioAssemblyController as ɵo } from './lib/scenario/scenario.controller';
14
- export { SharedContactCardService as ɵm } from './lib/shared-contact-card/shared-contact-card.service';
15
- export { Slip39Service as ɵi } from './lib/slip39/slip39.service';
16
- export { TpAssemblyController as ɵk } from './lib/tp-assembly/tp-assembly';
17
- export { TpPasswordResetAssemblyController as ɵj } from './lib/tp-password-reset/tp-password-reset.controller';
18
- export { TpPasswordResetPrivateService as ɵp } from './lib/tp-password-reset/tp-password-reset.private.service';
19
- export { TrustedPartyService as ɵn } from './lib/trusted-party/trusted-party.service';
13
+ export { ScenarioAssemblyController as ɵn } from './lib/scenario/scenario.controller';
14
+ export { SharedContactCardService as ɵl } from './lib/shared-contact-card/shared-contact-card.service';
15
+ export { TpAssemblyController as ɵj } from './lib/tp-assembly/tp-assembly';
16
+ export { TpPasswordResetAssemblyController as ɵi } from './lib/tp-password-reset/tp-password-reset.controller';
17
+ export { TpPasswordResetPrivateService as ɵo } from './lib/tp-password-reset/tp-password-reset.private.service';
18
+ export { TrustedPartyService as ɵm } from './lib/trusted-party/trusted-party.service';