@lifeready/core 5.0.9 → 5.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/bundles/lifeready-core.umd.js +1529 -737
  2. package/bundles/lifeready-core.umd.js.map +1 -1
  3. package/bundles/lifeready-core.umd.min.js +1 -1
  4. package/bundles/lifeready-core.umd.min.js.map +1 -1
  5. package/esm2015/lib/_common/key.js +28 -0
  6. package/esm2015/lib/_common/types.js +1 -1
  7. package/esm2015/lib/api/types/lr-graphql.types.js +1 -1
  8. package/esm2015/lib/auth/auth.types.js +1 -3
  9. package/esm2015/lib/auth/life-ready-auth.service.js +2 -2
  10. package/esm2015/lib/auth2/auth2.gql.private.js +78 -0
  11. package/esm2015/lib/auth2/auth2.service.js +596 -0
  12. package/esm2015/lib/auth2/auth2.types.js +21 -0
  13. package/esm2015/lib/contact-card/contact-card.service.js +3 -3
  14. package/esm2015/lib/contact-card/contact-card2.service.js +3 -3
  15. package/esm2015/lib/item2/item2.service.js +9 -9
  16. package/esm2015/lib/key/key-factory.service.js +1 -1
  17. package/esm2015/lib/key/key-graph.service.js +3 -3
  18. package/esm2015/lib/key/key-meta.service.js +2 -2
  19. package/esm2015/lib/key/key.service.js +7 -7
  20. package/esm2015/lib/key-exchange/key-exchange.service.js +24 -29
  21. package/esm2015/lib/key-exchange/key-exchange2.service.js +16 -17
  22. package/esm2015/lib/lbop/lbop.service.js +13 -14
  23. package/esm2015/lib/profile/profile.service.js +2 -2
  24. package/esm2015/lib/profile/profile.types.js +1 -1
  25. package/esm2015/lib/register/register.service.js +1 -1
  26. package/esm2015/lib/register/register.types.js +3 -0
  27. package/esm2015/lib/server-config/server-config.gql.js +1 -1
  28. package/esm2015/lib/shared-contact-card/shared-contact-card.service.js +3 -3
  29. package/esm2015/lib/shared-contact-card/shared-contact-card2.service.js +2 -2
  30. package/esm2015/lib/tp-assembly/tp-assembly.js +3 -3
  31. package/esm2015/lib/trusted-party/trusted-party2.service.js +4 -4
  32. package/esm2015/public-api.js +4 -1
  33. package/fesm2015/lifeready-core.js +885 -203
  34. package/fesm2015/lifeready-core.js.map +1 -1
  35. package/lib/_common/key.d.ts +14 -0
  36. package/lib/_common/types.d.ts +6 -0
  37. package/lib/api/types/lr-graphql.types.d.ts +1 -0
  38. package/lib/auth/auth.types.d.ts +0 -6
  39. package/lib/auth2/auth2.gql.private.d.ts +12 -0
  40. package/lib/auth2/auth2.service.d.ts +70 -0
  41. package/lib/auth2/auth2.types.d.ts +50 -0
  42. package/lib/item2/item2.service.d.ts +3 -3
  43. package/lib/key/key-factory.service.d.ts +1 -0
  44. package/lib/key/key-graph.service.d.ts +2 -3
  45. package/lib/key/key.service.d.ts +6 -6
  46. package/lib/key-exchange/key-exchange.service.d.ts +3 -5
  47. package/lib/lbop/lbop.service.d.ts +3 -3
  48. package/lib/profile/profile.types.d.ts +2 -2
  49. package/lib/register/register.service.d.ts +1 -1
  50. package/lib/register/register.types.d.ts +6 -0
  51. package/lib/server-config/server-config.gql.d.ts +1 -1
  52. package/lib/server-config/server-config.service.d.ts +1 -1
  53. package/lib/shared-contact-card/shared-contact-card.service.d.ts +2 -2
  54. package/lifeready-core.metadata.json +1 -1
  55. package/package.json +1 -1
  56. package/public-api.d.ts +3 -0
@@ -0,0 +1,14 @@
1
+ export declare class KeyContainer {
2
+ private _key;
3
+ private timer;
4
+ constructor(_key: CryptoKey, timeout: number);
5
+ get key(): CryptoKey;
6
+ /**
7
+ * Clears the reference to the key, clears the timer, return the key.
8
+ * It's important to call this function when the key is no longer needed because
9
+ * the anonymous function in setTimeout() holds a reference to "this", and hence
10
+ * keeps the "this._key" reference until the timer expired. So if we have used
11
+ * the key before it expired, we should clear the "this._key" reference immediately.
12
+ */
13
+ pop(): CryptoKey;
14
+ }
@@ -1,4 +1,10 @@
1
+ /**
2
+ * Change a set of specified keys to optional, while the rest remain unchanged
3
+ */
1
4
  export declare type SomePartial<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
5
+ /**
6
+ * Change a set of specified keys to required, while the rest remain unchanged
7
+ */
2
8
  export declare type SomeRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;
3
9
  export interface Edge<T> {
4
10
  node: T;
@@ -67,6 +67,7 @@ export interface UserNode extends Node {
67
67
  availablePlans?: AvailablePlanField[];
68
68
  config?: JSONString;
69
69
  configJson?: JSONObject;
70
+ dateJoined?: string;
70
71
  }
71
72
  export interface UserFeatureState extends TimeStamped {
72
73
  notificationsLastViewed?: DateTime;
@@ -45,12 +45,6 @@ export declare class LoginResult {
45
45
  user?: CurrentUser;
46
46
  resetUser?: TpPasswordResetUserNode;
47
47
  }
48
- export declare class RegisterResult {
49
- username: string;
50
- userId: string;
51
- preSignUpToken: string;
52
- userSub: string;
53
- }
54
48
  export declare enum RecoveryStatus {
55
49
  NONE = "none",
56
50
  NEW_PASSWORD = "new-password",
@@ -0,0 +1,12 @@
1
+ import { TpPasswordResetUserNode, UserNode } from '../api/types';
2
+ import { UserKeys } from '../key/key.service';
3
+ export interface CurrentUserQueryResult {
4
+ currentUser: Pick<Required<UserNode>, 'username' | 'sessionEncryptionKey'> & {
5
+ currentUserKey: UserKeys;
6
+ };
7
+ }
8
+ export declare const CurrentUserQuery: import("../_common/ast").TypedDocumentNode<CurrentUserQueryResult>;
9
+ export interface ResetUserQueryResult {
10
+ tpPasswordResetUser: Pick<Required<TpPasswordResetUserNode>, 'username' | 'sessionEncryptionKey' | 'state' | 'passKey' | 'masterKey' | 'pxk' | 'assembly' | 'approvals' | 'assemblyCipherData' | 'wrappedAssemblyKeyVerifierPrk'>;
11
+ }
12
+ export declare const ResetUserQuery: import("../_common/ast").TypedDocumentNode<ResetUserQueryResult>;
@@ -0,0 +1,70 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Injector, NgZone } from '@angular/core';
3
+ import { AuthClass } from '@aws-amplify/auth/lib-esm/Auth';
4
+ import { LrGraphQLService, LrService } from '../api/lr-graphql';
5
+ import { EncryptionService } from '../encryption/encryption.service';
6
+ import { IdleService } from '../idle/idle.service';
7
+ import { KeyFactoryService } from '../key/key-factory.service';
8
+ import { KeyGraphService } from '../key/key-graph.service';
9
+ import { KeyService } from '../key/key.service';
10
+ import { KcConfig } from '../life-ready.config';
11
+ import { PasswordService } from '../password/password.service';
12
+ import { PersistService } from '../persist/persist.service';
13
+ import { TpPasswordResetAssemblyController } from '../tp-password-reset/tp-password-reset.controller';
14
+ import { AuthUser, LoginChallenge, LoginOptions, LoginResult, LogoutListener } from './auth2.types';
15
+ export declare class Auth2Service extends LrService {
16
+ private ngZone;
17
+ private injector;
18
+ private http;
19
+ private cognito;
20
+ private api;
21
+ private keyService;
22
+ private keyGraphService;
23
+ private keyFactoryService;
24
+ private passwordService;
25
+ private idleService;
26
+ private persistService;
27
+ private encryptionService;
28
+ private assemblyController;
29
+ private kcConfig;
30
+ static CHALLENGE_TIMEOUT: number;
31
+ private logoutListeners;
32
+ private user;
33
+ private password;
34
+ constructor(ngZone: NgZone, injector: Injector, http: HttpClient, cognito: AuthClass, api: LrGraphQLService, keyService: KeyService, keyGraphService: KeyGraphService, keyFactoryService: KeyFactoryService, passwordService: PasswordService, idleService: IdleService, persistService: PersistService, encryptionService: EncryptionService, assemblyController: TpPasswordResetAssemblyController, kcConfig: KcConfig);
35
+ importPassword(plainPassword: string): Promise<CryptoKey>;
36
+ logout(): Promise<void>;
37
+ addLogoutListener(callback: LogoutListener): void;
38
+ removeLogoutListener(callback: LogoutListener): void;
39
+ login(emailOrPhone: string, password: CryptoKey, { tpPasswordResetAutoComplete }?: LoginOptions): Promise<LoginResult>;
40
+ verifyLogin(options: {
41
+ challenge: LoginChallenge;
42
+ code: string;
43
+ rememberMe: boolean;
44
+ }): Promise<LoginResult>;
45
+ getUser(): Promise<AuthUser>;
46
+ refreshAccessToken(): Promise<unknown>;
47
+ private fetchCurrentUser;
48
+ private fetchResetUser;
49
+ private kcLogout;
50
+ private fetchPassIdpParams;
51
+ private loginImpl;
52
+ private loginIdp;
53
+ private loginIdpImpl;
54
+ private handlePostAuth;
55
+ private handlePasswordRecovery;
56
+ private handleSessionEncryptionKey;
57
+ private getCognitoUserAttribute;
58
+ private loadUserKeys;
59
+ private loadUser;
60
+ private loadRegularUser;
61
+ private loadResetUser;
62
+ private recoverAssemblyKey;
63
+ completeResetRequest(newPassword: CryptoKey): Promise<void>;
64
+ debugLogin(username: string, password: CryptoKey): Promise<AuthUser>;
65
+ private debugLoadUser;
66
+ /**
67
+ * Clears the caches user. So we can simulate a page refresh and test getUser().
68
+ */
69
+ debugClearUser(): void;
70
+ }
@@ -0,0 +1,50 @@
1
+ import { CognitoUser } from '@aws-amplify/auth';
2
+ import { JSONObject, TpClaimState, UserNode } from '../api/types';
3
+ import { PassIdpParams } from '../key/key.types';
4
+ export declare type AuthUser = Pick<Required<UserNode>, 'username'> & {
5
+ sub: string;
6
+ loginEmail: string;
7
+ resetUser: null | {
8
+ state: TpClaimState;
9
+ };
10
+ };
11
+ export declare type LogoutListener = () => void | Promise<void>;
12
+ export interface LoginOptions {
13
+ tpPasswordResetAutoComplete?: boolean;
14
+ }
15
+ export declare enum RecoveryStatus {
16
+ NONE = "NONE",
17
+ NEW_PASSWORD = "NEW_PASSWORD",
18
+ OLD_PASSWORD = "OLD_PASSWORD"
19
+ }
20
+ export declare enum PasswordChangeStatus {
21
+ IN_PROGRESS = "IN_PROGRESS",
22
+ RECOVERY = "RECOVERY"
23
+ }
24
+ export interface PassIdpResult {
25
+ passwordChangeStatus?: PasswordChangeStatus;
26
+ currentPassIdpParams: PassIdpParams;
27
+ newPassIdpParams: PassIdpParams;
28
+ tpPasswordReset: {
29
+ passIdpParams: PassIdpParams;
30
+ resetUsername: string;
31
+ };
32
+ }
33
+ export declare enum CognitoChallengeName {
34
+ NEW_PASSWORD_REQUIRED = "NEW_PASSWORD_REQUIRED",
35
+ SMS_MFA = "SMS_MFA",
36
+ SOFTWARE_TOKEN_MFA = "SOFTWARE_TOKEN_MFA",
37
+ MFA_SETUP = "MFA_SETUP"
38
+ }
39
+ export declare type LrCognitoUser = CognitoUser & {
40
+ challengeName: CognitoChallengeName;
41
+ challengeParam: JSONObject;
42
+ };
43
+ export interface LoginChallenge {
44
+ cognitoUser: LrCognitoUser;
45
+ recoveryStatus: RecoveryStatus;
46
+ }
47
+ export interface LoginResult {
48
+ challenge?: LoginChallenge;
49
+ user?: AuthUser;
50
+ }
@@ -1,7 +1,7 @@
1
1
  import { Injector, NgZone } from '@angular/core';
2
2
  import { LrMutation, LrService } from '../api/lr-graphql';
3
3
  import { ID, LrRelayIdInput } from '../api/types';
4
- import { LifeReadyAuthService } from '../auth/life-ready-auth.service';
4
+ import { Auth2Service } from '../auth2/auth2.service';
5
5
  import { FileUploadService } from '../file-upload/file-upload.service';
6
6
  import { KeyFactoryService } from '../key/key-factory.service';
7
7
  import { KeyGraphService } from '../key/key-graph.service';
@@ -16,9 +16,9 @@ export declare class Item2Service extends LrService {
16
16
  private keyFactory;
17
17
  private keyGraph;
18
18
  private lockService;
19
- private authService;
19
+ private auth2Service;
20
20
  private tempDirectory;
21
- constructor(ngZone: NgZone, injector: Injector, fileUploadService: FileUploadService, keyService: KeyService, keyFactory: KeyFactoryService, keyGraph: KeyGraphService, lockService: LockService, authService: LifeReadyAuthService);
21
+ constructor(ngZone: NgZone, injector: Injector, fileUploadService: FileUploadService, keyService: KeyService, keyFactory: KeyFactoryService, keyGraph: KeyGraphService, lockService: LockService, auth2Service: Auth2Service);
22
22
  static TEMP_DIRECTORY_PLAIN_META: {
23
23
  kcType: string;
24
24
  };
@@ -7,6 +7,7 @@ export declare class KeyFactoryService {
7
7
  private webCryptoService;
8
8
  constructor(webCryptoService: WebCryptoService);
9
9
  private readonly kcCrypto;
10
+ private readonly store;
10
11
  readonly MIN_PASS_IDP_PBKDF_ITER = 100000;
11
12
  readonly MIN_PASS_KEY_PBKDF_ITER = 100000;
12
13
  readonly MIN_LBOP_KEY_PBKDF_ITER = 100000;
@@ -1,9 +1,8 @@
1
1
  import { JWK } from 'node-jose';
2
2
  import { JSONObject } from '../api/types';
3
3
  import { DecryptOptions, EncryptionService } from '../encryption/encryption.service';
4
- import { CurrentUserKey } from '../profile/profile.types';
5
4
  import { KeyFactoryService } from './key-factory.service';
6
- import { KeyService } from './key.service';
5
+ import { KeyService, UserKeys } from './key.service';
7
6
  import { Key, KeyGraphEdge, KeyGraphResponse, PassKey } from './key.types';
8
7
  export interface GraphKey extends Key {
9
8
  task?: Promise<any>;
@@ -15,7 +14,7 @@ export declare class KeyGraphService {
15
14
  private graph;
16
15
  constructor(encryptionService: EncryptionService, keyService: KeyService, keyFactory: KeyFactoryService);
17
16
  purgeKeys(): void;
18
- populateKeys(userKey: CurrentUserKey): Promise<void>;
17
+ populateKeys(userKey: UserKeys): Promise<void>;
19
18
  hasKey(keyId: string): boolean;
20
19
  private getNode;
21
20
  key(id: any): GraphKey;
@@ -23,12 +23,12 @@ export declare class KeyService {
23
23
  constructor(config: KcConfig, persistService: PersistService);
24
24
  resetKeys(): void;
25
25
  purgeKeys(): void;
26
- populateKeys(keys: UserKeys): void;
27
- getCurrentPassKey(): Key;
28
- getCurrentMasterKey(): Key;
29
- getCurrentRootKey(): Key;
30
- getCurrentPxk(): Key;
31
- getCurrentSigPxk(): Key;
26
+ setKeys(keys: UserKeys): void;
27
+ get currentPassKey(): Key;
28
+ get currentMasterKey(): Key;
29
+ get currentRootKey(): Key;
30
+ get currentPxk(): Key;
31
+ get currentSigPxk(): Key;
32
32
  private expiresAfter;
33
33
  persistMasterKey(masterKey: Key, expiresAfterSeconds: number): Promise<void>;
34
34
  setMasterKeyExpiresAfterSeconds(seconds: number): Promise<void>;
@@ -1,19 +1,17 @@
1
1
  import { LrApolloService } from '../api/lr-apollo.service';
2
- import { LifeReadyAuthService } from '../auth/life-ready-auth.service';
2
+ import { Auth2Service } from '../auth2/auth2.service';
3
3
  import { EncryptionService } from '../encryption/encryption.service';
4
4
  import { KeyFactoryService as KFS } from '../key/key-factory.service';
5
5
  import { KeyService } from '../key/key.service';
6
- import { UserService } from '../user/user.service';
7
6
  import { CompleteOtk, DecryptedKeyExchange, GetKeyExchangeListOptions, GetKeyExchangeOptions, InitiateOtkInput, KeyExchange, RespondOtk, RespondOtkInput, UserSharedKey } from './key-exchange.types';
8
7
  export declare class KeyExchangeService {
9
8
  private keyFactory;
10
9
  private keyService;
11
10
  private lrApollo;
12
11
  private encryptionService;
13
- private authService;
14
- private userService;
12
+ private auth2Service;
15
13
  private readonly CLIENT_NONCE_LENGTH;
16
- constructor(keyFactory: KFS, keyService: KeyService, lrApollo: LrApolloService, encryptionService: EncryptionService, authService: LifeReadyAuthService, userService: UserService);
14
+ constructor(keyFactory: KFS, keyService: KeyService, lrApollo: LrApolloService, encryptionService: EncryptionService, auth2Service: Auth2Service);
17
15
  getKeyExchangeList(input?: GetKeyExchangeListOptions): Promise<any>;
18
16
  /**
19
17
  * @param id If the current user can responder the key exchange if they are either the initiator or the receiver.
@@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
2
2
  import { AuthClass } from '@aws-amplify/auth/lib-esm/Auth';
3
3
  import { JWK } from 'node-jose';
4
4
  import { LrApolloService } from '../api/lr-apollo.service';
5
- import { LifeReadyAuthService } from '../auth/life-ready-auth.service';
5
+ import { Auth2Service } from '../auth2/auth2.service';
6
6
  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';
@@ -80,7 +80,7 @@ export declare class LbopService {
80
80
  private http;
81
81
  private lrApollo;
82
82
  private auth;
83
- private authService;
83
+ private auth2Service;
84
84
  private keyFactory;
85
85
  private keyService;
86
86
  private encryptionService;
@@ -88,7 +88,7 @@ export declare class LbopService {
88
88
  private passwordService;
89
89
  private readonly CLIENT_NONCE_LENGTH;
90
90
  private readonly LBOP_WORDS;
91
- constructor(config: KcConfig, http: HttpClient, lrApollo: LrApolloService, auth: AuthClass, authService: LifeReadyAuthService, keyFactory: KFS, keyService: KeyService, encryptionService: EncryptionService, keyGraph: KeyGraphService, passwordService: PasswordService);
91
+ constructor(config: KcConfig, http: HttpClient, lrApollo: LrApolloService, auth: AuthClass, auth2Service: Auth2Service, keyFactory: KFS, keyService: KeyService, encryptionService: EncryptionService, keyGraph: KeyGraphService, passwordService: PasswordService);
92
92
  private getPartial;
93
93
  remove(id: string): Promise<string>;
94
94
  update({ id, name }: UpdateLbopParams): Promise<Lbop>;
@@ -9,8 +9,8 @@ export declare class Features {
9
9
  shareVault: FeatureAction[];
10
10
  }
11
11
  export declare class CurrentUserKey {
12
- passKey?: PassKey;
13
- masterKey?: {
12
+ passKey: PassKey;
13
+ masterKey: {
14
14
  id: string;
15
15
  };
16
16
  rootKey?: {
@@ -1,10 +1,10 @@
1
1
  import { HttpClient } from '@angular/common/http';
2
2
  import { AuthClass } from '@aws-amplify/auth/lib-esm/Auth';
3
- import { RegisterResult } from '../auth/auth.types';
4
3
  import { EncryptionService } from '../encryption/encryption.service';
5
4
  import { KeyFactoryService } from '../key/key-factory.service';
6
5
  import { KcConfig } from '../life-ready.config';
7
6
  import { PasswordService } from '../password/password.service';
7
+ import { RegisterResult } from './register.types';
8
8
  export declare class RegisterService {
9
9
  private config;
10
10
  private auth;
@@ -0,0 +1,6 @@
1
+ export declare class RegisterResult {
2
+ username: string;
3
+ userId: string;
4
+ preSignUpToken: string;
5
+ userSub: string;
6
+ }
@@ -1,5 +1,5 @@
1
1
  import { ServerConfig } from '../api/types';
2
2
  export interface ServerConfigQueryResult {
3
- serverConfig: Pick<ServerConfig, 'relayConnectionMaxLimit'>;
3
+ serverConfig: Pick<Required<ServerConfig>, 'relayConnectionMaxLimit'>;
4
4
  }
5
5
  export declare const ServerConfigQuery: import("../_common/ast").TypedDocumentNode<ServerConfigQueryResult>;
@@ -5,5 +5,5 @@ export declare class ServerConfigService extends LrService {
5
5
  private injector;
6
6
  private serverConfig;
7
7
  constructor(ngZone: NgZone, injector: Injector);
8
- getConfig(): Promise<Pick<import("../api/types").ServerConfig, "relayConnectionMaxLimit">>;
8
+ getConfig(): Promise<Pick<Required<import("../api/types").ServerConfig>, "relayConnectionMaxLimit">>;
9
9
  }
@@ -1,3 +1,5 @@
1
+ import { LrApolloService } from '../api/lr-apollo.service';
2
+ import { JSONObject } from '../api/types';
1
3
  import { EncryptionService } from '../encryption/encryption.service';
2
4
  import { KeyGraphService } from '../key/key-graph.service';
3
5
  import { KeyService } from '../key/key.service';
@@ -5,8 +7,6 @@ import { Key } from '../key/key.types';
5
7
  import { TrustedPartyDetails } from '../profile/profile.types';
6
8
  import { SharedTrustedPartyDetails } from '../trusted-party/trusted-party.types';
7
9
  import { User } from '../user/user.types';
8
- import { LrApolloService } from '../api/lr-apollo.service';
9
- import { JSONObject } from '../api/types';
10
10
  export declare const SharedContactCardFields = "\n id\n owner {\n id\n username\n }\n ownerKey {\n id\n }\n ownerCipherData\n receiver {\n id\n username\n }\n receiverKey {\n id\n }\n receiverCipherData\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherDataSig\n sharedCipherDataSigPxk {\n id\n }\n";
11
11
  export interface SharedContactCard {
12
12
  id: string;