2021-04-22 21:17:14 +02:00
|
|
|
import { Directive } from "@angular/core";
|
2020-10-13 22:21:03 +02:00
|
|
|
import { ActivatedRoute, Router } from "@angular/router";
|
2021-10-14 02:27:52 +02:00
|
|
|
import { first } from "rxjs/operators";
|
|
|
|
|
2022-06-14 17:10:53 +02:00
|
|
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
2022-12-19 19:56:16 +01:00
|
|
|
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
|
|
|
|
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/abstractions/organization-user/requests";
|
[AC-1011] Admin Console / Billing code ownership (#4973)
* refactor: move SCIM component to admin-console, refs EC-1011
* refactor: move scimProviderType to admin-console, refs EC-1011
* refactor: move scim-config.api to admin-console, refs EC-1011
* refactor: create models folder and nest existing api contents, refs EC-1011
* refactor: move scim-config to admin-console models, refs EC-1011
* refactor: move billing.component to billing, refs EC-1011
* refactor: remove nested app folder from new billing structure, refs EC-1011
* refactor: move organizations/billing to billing, refs EC-1011
* refactor: move add-credit and adjust-payment to billing/settings, refs EC-1011
* refactor: billing history/sync to billing, refs EC-1011
* refactor: move org plans, payment/method to billing/settings, refs EC-1011
* fix: update legacy file paths for payment-method and tax-info, refs EC-1011
* fix: update imports for scim component, refs EC-1011
* refactor: move subscription and tax-info into billing, refs EC-1011
* refactor: move user-subscription to billing, refs EC-1011
* refactor: move images/cards to billing and update base path, refs EC-1011
* refactor: move payment-method, plan subscription, and plan to billing, refs EC-1011
* refactor: move transaction-type to billing, refs EC-1011
* refactor: move billing-sync-config to billing, refs EC-1011
* refactor: move billing-sync and bit-pay-invoice request to billing, refs EC-1011
* refactor: move org subscription and tax info update requests to billing, refs EC-1011
* fix: broken paths to billing, refs EC-1011
* refactor: move payment request to billing, refs EC-1011
* fix: update remaining imports for payment-request, refs EC-1011
* refactor: move tax-info-update to billing, refs EC-1011
* refactor: move billing-payment, billing-history, and billing responses to billing, refs EC-1011
* refactor: move organization-subscription-responset to billing, refs EC-1011
* refactor: move payment and plan responses to billing, refs EC-1011
* refactor: move subscription response to billing ,refs EC-1011
* refactor: move tax info and rate responses to billing, refs EC-1011
* fix: update remaining path to base response for tax-rate response, refs EC-1011
* refactor: (browser) move organization-service to admin-console, refs EC-1011
* refactor: (browser) move organizaiton-service to admin-console, refs EC-1011
* refactor: (cli) move share command to admin-console, refs EC-1011
* refactor: move organization-collect request model to admin-console, refs EC-1011
* refactor: (web) move organization, collection/user responses to admin-console, refs EC-1011
* refactor: (cli) move selection-read-only to admin-console, refs EC-1011
* refactor: (desktop) move organization-filter to admin-console, refs EC-1011
* refactor: (web) move organization-switcher to admin-console, refs EC-1011
* refactor: (web) move access-selector to admin-console, refs EC-1011
* refactor: (web) move create folder to admin-console, refs EC-1011
* refactor: (web) move org guards folder to admin-console, refs EC-1011
* refactor: (web) move org layout to admin-console, refs EC-1011
* refactor: move manage collections to admin console, refs EC-1011
* refactor: (web) move collection-dialog to admin-console, refs EC-1011
* refactor: (web) move entity users/events and events component to admin-console, refs EC-1011
* refactor: (web) move groups/group-add-edit to admin-console, refs EC-1011
* refactor: (web) move manage, org-manage module, and user-confirm to admin-console, refs EC-1011
* refactor: (web) move people to admin-console, refs EC-1011
* refactor: (web) move reset-password to admin-console, refs EC-1011
* refactor: (web) move organization-routing and module to admin-console, refs EC-1011
* refactor: move admin-console and billing within app scope, refs EC-1011
* fix: update leftover merge conflicts, refs EC-1011
* refactor: (web) member-dialog to admin-console, refs EC-1011
* refactor: (web) move policies to admin-console, refs EC-1011
* refactor: (web) move reporting to admin-console, refs EC-1011
* refactor: (web) move settings to admin-console, refs EC-1011
* refactor: (web) move sponsorships to admin-console, refs EC-1011
* refactor: (web) move tools to admin-console, refs EC-1011
* refactor: (web) move users to admin-console, refs EC-1011
* refactor: (web) move collections to admin-console, refs EC-1011
* refactor: (web) move create-organization to admin-console, refs EC-1011
* refactor: (web) move licensed components to admin-console, refs EC-1011
* refactor: (web) move bit organization modules to admin-console, refs EC-1011
* fix: update leftover import statements for organizations.module, refs EC-1011
* refactor: (web) move personal vault and max timeout to admin-console, refs EC-1011
* refactor: (web) move providers to admin-console, refs EC-1011
* refactor: (libs) move organization service to admin-console, refs EC-1011
* refactor: (libs) move profile org/provider responses and other misc org responses to admin-console, refs EC-1011
* refactor: (libs) move provider request and selectionion-read-only request to admin-console, refs EC-1011
* fix: update missed import path for provider-user-update request, refs EC-1011
* refactor: (libs) move abstractions to admin-console, refs EC-1011
* refactor: (libs) move org/provider enums to admin-console, refs EC-1011
* fix: update downstream import statements from libs changes, refs EC-1011
* refactor: (libs) move data files to admin-console, refs EC-1011
* refactor: (libs) move domain to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* fix: update downstream import changes from libs, refs EC-1011
* refactor: move leftover provider files to admin-console, refs EC-1011
* refactor: (browser) move group policy environment to admin-console, refs EC-1011
* fix: (browser) update downstream import statements, refs EC-1011
* fix: (desktop) update downstream libs moves, refs EC-1011
* fix: (cli) update downstream import changes from libs, refs EC-1011
* refactor: move org-auth related files to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* refactor: move persmissions to admin-console, refs EC-1011
* refactor: move sponsored families to admin-console and fix libs changes, refs EC-1011
* refactor: move collections to admin-console, refs EC-1011
* refactor: move spec file back to spec scope, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: udpate downstream import changes due to libs, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: update downstream imports from libs changes, refs EC-1011
* fix: update path malformation in jslib-services.module, refs EC-1011
* fix: lint errors from improper casing, refs AC-1011
* fix: update downstream filename changes, refs AC-1011
* fix: (cli) update downstream filename changes, refs AC-1011
* fix: (desktop) update downstream filename changes, refs AC-1011
* fix: (browser) update downstream filename changes, refs AC-1011
* fix: lint errors, refs AC-1011
* fix: prettier, refs AC-1011
* fix: lint fixes for import order, refs AC-1011
* fix: update import path for provider user type, refs AC-1011
* fix: update new codes import paths for admin console structure, refs AC-1011
* fix: lint/prettier, refs AC-1011
* fix: update layout stories path, refs AC-1011
* fix: update comoponents card icons base variable in styles, refs AC-1011
* fix: update provider service path in permissions guard spec, refs AC-1011
* fix: update provider permission guard path, refs AC-1011
* fix: remove unecessary TODO for shared index export statement, refs AC-1011
* refactor: move browser-organization service and cli organization-user response out of admin-console, refs AC-1011
* refactor: move web/browser/desktop collections component to vault domain, refs AC-1011
* refactor: move organization.module out of admin-console scope, refs AC-1011
* fix: prettier, refs AC-1011
* refactor: move organizations-api-key.request out of admin-console scope, refs AC-1011
2023-03-22 16:03:50 +01:00
|
|
|
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
|
|
|
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
|
|
|
|
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
2023-02-06 22:53:37 +01:00
|
|
|
import { SetPasswordRequest } from "@bitwarden/common/auth/models/request/set-password.request";
|
[AC-1266] Enums filename conventions (#5140)
* refactor: update clientType enum
* refactor: update deviceType filename
* refactor: update encryptedExportType filename
* refactor: update encryptionType filename
* refactor: update eventType filename
* refactor: update fieldType filename
* refactor: update fileUploadType filename
* refactor: update hashPurpose filename
* refactor: update htmlStorageLocation filename
* refactor: update kdfType filename
* refactor: update keySuffixOptions filename
* refactor: update linkedIdType filename
* refactor: update logLevelType filename
* refactor: update nativeMessagingVersion filename
* refactor: update notificationType filename
* refactor: update productType filename
* refactor: update secureNoteType filename
* refactor: update stateVersion filename
* refactor: update storageLocation filename
* refactor: update themeType filename
* refactor: update uriMatchType filename
* fix: update kdfType classes missed in initial pass, refs AC-1266
* fix: missing import update for device-type
* refactor: add barrel file for enums and update pathed import statements, refs AC-1266
* fix: incorrect import statements for web, refs AC-1266
* fix: missed import statement updates (browser), refs AC-1266
* fix: missed import statement changes (cli), refs AC-1266
* fix: missed import statement changes (desktop), refs AC-1266
* fix: prettier, refs AC-1266
* refactor: (libs) update relative paths to use barrel file, refs AC-1266
* fix: missed find/replace import statements for SecureNoteType, refs AC-1266
* refactor: apply .enum suffix to enums folder and modify leftover relative paths, refs AC-1266
* fix: find/replace errors for native-messaging-version, refs AC-1266
2023-04-05 05:42:21 +02:00
|
|
|
import { HashPurpose, DEFAULT_KDF_TYPE, DEFAULT_KDF_CONFIG } from "@bitwarden/common/enums";
|
2022-10-18 19:01:42 +02:00
|
|
|
import { KeysRequest } from "@bitwarden/common/models/request/keys.request";
|
2023-06-06 22:34:53 +02:00
|
|
|
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
|
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
|
|
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
|
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
|
|
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
|
|
|
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
|
|
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
2023-03-10 21:39:46 +01:00
|
|
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
|
2023-01-31 22:08:37 +01:00
|
|
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
2020-08-19 16:57:35 +02:00
|
|
|
|
2023-02-06 22:53:37 +01:00
|
|
|
import { ChangePasswordComponent as BaseChangePasswordComponent } from "../auth/components/change-password.component";
|
2023-05-02 18:46:03 +02:00
|
|
|
import { DialogServiceAbstraction } from "../services/dialog";
|
2020-08-19 16:57:35 +02:00
|
|
|
|
2021-04-22 21:17:14 +02:00
|
|
|
@Directive()
|
2020-08-19 16:57:35 +02:00
|
|
|
export class SetPasswordComponent extends BaseChangePasswordComponent {
|
2022-02-22 15:39:11 +01:00
|
|
|
syncLoading = true;
|
|
|
|
showPassword = false;
|
|
|
|
hint = "";
|
2020-10-13 22:21:03 +02:00
|
|
|
identifier: string = null;
|
2021-09-03 21:49:03 +02:00
|
|
|
orgId: string;
|
|
|
|
resetPasswordAutoEnroll = false;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2022-08-24 18:33:05 +02:00
|
|
|
onSuccessfulChangePassword: () => Promise<void>;
|
2020-08-19 16:57:35 +02:00
|
|
|
successRoute = "vault";
|
2021-12-16 13:36:21 +01:00
|
|
|
|
[Account Switching] [Feature] Allow clients to store data for more than one user (#491)
* [refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file
* Renamed StorageServiceOptions to StorageOptions
* Pulled KeySuffixOpptions into its own file
* Converted KeySuffixOptions into an enum from a union type
* [refactor] Expand StateService into a full coverage storage proxy
* Expand StateService to allow it to manage all data points of the application state regardless of memory.
* Expand StateService to allow for storing and managing multiple accounts
* [refactor] Create helper services for managing organization and provider state data
* [refactor] Implement StateService across service layer
* Remove service level variables used for in memory data storage and replaced with calls to StateService
* Remove direct calls to StorageService in favor of using StateService as a proxy
* [feature] Implement account switching capable services across components and processes
* Replace calls to StorageService and deprecated services with calls to a StateService
* [chore] Remove unused services
Several services are no longer in use because of the expanded state service. These have simply been removed.
* [bug] Add loginRedirect to the account model
* [bug] Add awaits to newly async calls in TokenService
* [bug] Add several missing awaits
* [bug] Add state service handlers for AutoConfirmFingerprint
* [bug] Move TwoFactorToken to global state
* Update unauth-guard.service.ts
Add back return true
* [refactor] Slim down the boilerplate needed to manage options on StateService calls
* [bug] Allow the lock message handler to manipulate a specific acount
* [bug] Add missing await to auth guard
* [bug] Adjust state scope of several biometric data points
* [bug] Ensure vault locking logic can operate over non-active accounts
* [style] Fix lint complaints
* [bug] Move disableFavicon to global state
* [refactor] Remove an unecassary parameter from a StorageOptions instance
* [bug] Ensure HtmlStorageService paths are accounted for in StateService
* [feature] Add a server url helper to the account model for the account switcher
* [refactor] Remove some unused getters from the account model
* [bug] Ensure locking and logging out can function over any user
* Fix account getting set to null in getAccountFromDisk
* [bug] Ensure lock component is always working with the latest active account in state
* [chore] Update recent KeyConnector changes to use stateService
* [style] Fix lint complaints
* [chore] Resolve TokenService merge issues from KeyConnector
* [bug] Add missing service arguement
* [bug] Correct several default storage option types
* [bug] Check for the right key in hasEncKey
* [bug] Add enableFullWidth to the account model
* [style] Fix lint complaints
* [review] Revist remember email
* [refactor] Remove RememberEmail from state
* setDisableFavicon to correct storage location
* [bug] Convert vault lock loop returns into continues to not skip secondary accounts
* [review] Sorted state service methods
* [bug] Correct neverDomains type on the account model
* [review] Rename stateService.purge to stateService.clean
* [review] [refactor] Extract lock refresh logic to a load function
* [review] [refactor] Extract some timeout logic to dedicated functions
* [review] [refactor] Move AuthenticationStatus to a dedicated file
* [review] [refactor] Rename Globals to GlobalState
* [style] Fix lint complaints
* [review] Remove unused global state property for decodedToken
* [review] [bug] Adjust state scope for OrganizationInvitation
* [review] [bug] Put back the homepage variable in lock guard
* [review] Un-try-catch the window creation function
* Revert "[review] [bug] Adjust state scope for OrganizationInvitation"
This reverts commit caa4574a65d9d0c3573a7529ed2221764fd55497.
* [bug] Change || to && in recent vault timeout refactor
* [bug] Keep up with entire state in storage instead of just accounts and globals
Not having access to the last active user was creating issues across clients when restarting the process.
For example: when refreshing the page on web we no longer maintain an understanding of who is logged in.
To resolve this I converted all storage save operations to get and save an entire state object, instead of specifying accounts and globals.
This allows for more flexible saving, like saving activeUserId as a top level storage item.
* [style] Fix lint complaints
* Revert "[bug] Keep up with entire state in storage instead of just accounts and globals"
This reverts commit e8970725be472386358c1e2f06f53663c4979e0e.
* [bug] Initialize GlobalState by default
* [bug] Only get key hash from storage
* [bug] Remove settings storage location overrides
* [bug] Only save accessToken to storage
* [refactor] Remove unecassary argements from electron crypto state calls
* [bug] Ensure keys and tokens load and save to the right locations for web
* [style] Fix lint complaints
* [bug] Remove keySuffix storage option and split uses into unique methods
The keySuffix options don't work with saving serialized json as a storage object - use cases simply overwrite each other in state.
This commit breaks Auto and Biometric keys into distinct storage items and adjusts logic accordingly.
* [bug] Add default vault timeouts to new accounts
* [bug] Save appId as a top level storage item
* [bug] Add missing await to timeout logic
* [bug] Adjust state scope for everBeenUnlocked
* [bug] Clear access tokens when loading account state from disk
* [bug] Adjust theme to be a global state item
* [bug] Adjust null checking for window in state
* [bug] Correct getGlobals not pulling from the stored state item
* [bug] Null check in memory account before claiming it has a userId
* [bug] Scaffold secure storage service when building storage objects on init
* [bug] Adjusted state scope of event collection
* [bug] Adjusted state scope of vault timeout and action
* [bug] Grab account from normal storage if secure storage is requested but does not exist
* [bug] Create a State if one is requested from memory before it exists
* [bug] Ensure all storage locations are cleared on state clean
* [style] Fix lint complaints
* [bug] Remove uneeded clearing of access token
* [bug] Reset tokens when toggling
* [refactor] Split up the Account model
Until this point the account model has been very flat, holding many kinds of data.
In order to be able to prune data at appropriate times, for example clearing keys at logout without clearing QoL settings like locale,
the Account model has been divided into logical chunks.
* [bug] Correct the serverUrl helpers return
* Fix sends always coming back as empty in browser
* Get settings properly (I think)
* [bug] Fix lint error
* [bug] Add missing await to identity token refresh
This was causing weird behavior in web that was creating a lot of 429s
* [bug] Scaffold memory storage for web
Not properly creating storage objects on signin was creating weird behavior when logging out, locking, and logging back in.
Namely, encrypted data that was recently synced had nowhere to save to and was lost.
* [bug] Implement better null handling in a few places for retrieving state
* [bug] Update correct storage locations on account removal
* [bug] Added missing awaits to lock component
* [bug] Reload lock component on account switching vs. account update
* [bug] Store master keys correctly
* [bug] Move some biometrics storage items to global state
* [feature] Add platform helper isMac()
* [refactor] Comment emphasis and call order refresh
* [refactor] Remove unecassary using
* [bug] Relocate authenticationStatus check logic to component
* [bug] Stop not clearing everything on state clean
* [style] Fix lint complaints
* [bug] Correct mismatched uses of encrypted and decrypted pin states
* Add browser specific state classes and methods
* lint fixes
* [bug] Migrate existing persistant data to new schema
* [style] Fix lint complaints
* [bug] Dont clear settings on state clean
* [bug] Maintain the right storage items on logout
* [chore] resolve issues from merge
* [bug] Resolve settings clearing on lock
* [chore] Added a comment
* [review] fromatting for code review
* Revert browser state items
Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-13 17:15:16 +01:00
|
|
|
constructor(
|
|
|
|
i18nService: I18nService,
|
|
|
|
cryptoService: CryptoService,
|
|
|
|
messagingService: MessagingService,
|
2023-03-10 21:39:46 +01:00
|
|
|
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
[Account Switching] [Feature] Allow clients to store data for more than one user (#491)
* [refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file
* Renamed StorageServiceOptions to StorageOptions
* Pulled KeySuffixOpptions into its own file
* Converted KeySuffixOptions into an enum from a union type
* [refactor] Expand StateService into a full coverage storage proxy
* Expand StateService to allow it to manage all data points of the application state regardless of memory.
* Expand StateService to allow for storing and managing multiple accounts
* [refactor] Create helper services for managing organization and provider state data
* [refactor] Implement StateService across service layer
* Remove service level variables used for in memory data storage and replaced with calls to StateService
* Remove direct calls to StorageService in favor of using StateService as a proxy
* [feature] Implement account switching capable services across components and processes
* Replace calls to StorageService and deprecated services with calls to a StateService
* [chore] Remove unused services
Several services are no longer in use because of the expanded state service. These have simply been removed.
* [bug] Add loginRedirect to the account model
* [bug] Add awaits to newly async calls in TokenService
* [bug] Add several missing awaits
* [bug] Add state service handlers for AutoConfirmFingerprint
* [bug] Move TwoFactorToken to global state
* Update unauth-guard.service.ts
Add back return true
* [refactor] Slim down the boilerplate needed to manage options on StateService calls
* [bug] Allow the lock message handler to manipulate a specific acount
* [bug] Add missing await to auth guard
* [bug] Adjust state scope of several biometric data points
* [bug] Ensure vault locking logic can operate over non-active accounts
* [style] Fix lint complaints
* [bug] Move disableFavicon to global state
* [refactor] Remove an unecassary parameter from a StorageOptions instance
* [bug] Ensure HtmlStorageService paths are accounted for in StateService
* [feature] Add a server url helper to the account model for the account switcher
* [refactor] Remove some unused getters from the account model
* [bug] Ensure locking and logging out can function over any user
* Fix account getting set to null in getAccountFromDisk
* [bug] Ensure lock component is always working with the latest active account in state
* [chore] Update recent KeyConnector changes to use stateService
* [style] Fix lint complaints
* [chore] Resolve TokenService merge issues from KeyConnector
* [bug] Add missing service arguement
* [bug] Correct several default storage option types
* [bug] Check for the right key in hasEncKey
* [bug] Add enableFullWidth to the account model
* [style] Fix lint complaints
* [review] Revist remember email
* [refactor] Remove RememberEmail from state
* setDisableFavicon to correct storage location
* [bug] Convert vault lock loop returns into continues to not skip secondary accounts
* [review] Sorted state service methods
* [bug] Correct neverDomains type on the account model
* [review] Rename stateService.purge to stateService.clean
* [review] [refactor] Extract lock refresh logic to a load function
* [review] [refactor] Extract some timeout logic to dedicated functions
* [review] [refactor] Move AuthenticationStatus to a dedicated file
* [review] [refactor] Rename Globals to GlobalState
* [style] Fix lint complaints
* [review] Remove unused global state property for decodedToken
* [review] [bug] Adjust state scope for OrganizationInvitation
* [review] [bug] Put back the homepage variable in lock guard
* [review] Un-try-catch the window creation function
* Revert "[review] [bug] Adjust state scope for OrganizationInvitation"
This reverts commit caa4574a65d9d0c3573a7529ed2221764fd55497.
* [bug] Change || to && in recent vault timeout refactor
* [bug] Keep up with entire state in storage instead of just accounts and globals
Not having access to the last active user was creating issues across clients when restarting the process.
For example: when refreshing the page on web we no longer maintain an understanding of who is logged in.
To resolve this I converted all storage save operations to get and save an entire state object, instead of specifying accounts and globals.
This allows for more flexible saving, like saving activeUserId as a top level storage item.
* [style] Fix lint complaints
* Revert "[bug] Keep up with entire state in storage instead of just accounts and globals"
This reverts commit e8970725be472386358c1e2f06f53663c4979e0e.
* [bug] Initialize GlobalState by default
* [bug] Only get key hash from storage
* [bug] Remove settings storage location overrides
* [bug] Only save accessToken to storage
* [refactor] Remove unecassary argements from electron crypto state calls
* [bug] Ensure keys and tokens load and save to the right locations for web
* [style] Fix lint complaints
* [bug] Remove keySuffix storage option and split uses into unique methods
The keySuffix options don't work with saving serialized json as a storage object - use cases simply overwrite each other in state.
This commit breaks Auto and Biometric keys into distinct storage items and adjusts logic accordingly.
* [bug] Add default vault timeouts to new accounts
* [bug] Save appId as a top level storage item
* [bug] Add missing await to timeout logic
* [bug] Adjust state scope for everBeenUnlocked
* [bug] Clear access tokens when loading account state from disk
* [bug] Adjust theme to be a global state item
* [bug] Adjust null checking for window in state
* [bug] Correct getGlobals not pulling from the stored state item
* [bug] Null check in memory account before claiming it has a userId
* [bug] Scaffold secure storage service when building storage objects on init
* [bug] Adjusted state scope of event collection
* [bug] Adjusted state scope of vault timeout and action
* [bug] Grab account from normal storage if secure storage is requested but does not exist
* [bug] Create a State if one is requested from memory before it exists
* [bug] Ensure all storage locations are cleared on state clean
* [style] Fix lint complaints
* [bug] Remove uneeded clearing of access token
* [bug] Reset tokens when toggling
* [refactor] Split up the Account model
Until this point the account model has been very flat, holding many kinds of data.
In order to be able to prune data at appropriate times, for example clearing keys at logout without clearing QoL settings like locale,
the Account model has been divided into logical chunks.
* [bug] Correct the serverUrl helpers return
* Fix sends always coming back as empty in browser
* Get settings properly (I think)
* [bug] Fix lint error
* [bug] Add missing await to identity token refresh
This was causing weird behavior in web that was creating a lot of 429s
* [bug] Scaffold memory storage for web
Not properly creating storage objects on signin was creating weird behavior when logging out, locking, and logging back in.
Namely, encrypted data that was recently synced had nowhere to save to and was lost.
* [bug] Implement better null handling in a few places for retrieving state
* [bug] Update correct storage locations on account removal
* [bug] Added missing awaits to lock component
* [bug] Reload lock component on account switching vs. account update
* [bug] Store master keys correctly
* [bug] Move some biometrics storage items to global state
* [feature] Add platform helper isMac()
* [refactor] Comment emphasis and call order refresh
* [refactor] Remove unecassary using
* [bug] Relocate authenticationStatus check logic to component
* [bug] Stop not clearing everything on state clean
* [style] Fix lint complaints
* [bug] Correct mismatched uses of encrypted and decrypted pin states
* Add browser specific state classes and methods
* lint fixes
* [bug] Migrate existing persistant data to new schema
* [style] Fix lint complaints
* [bug] Dont clear settings on state clean
* [bug] Maintain the right storage items on logout
* [chore] resolve issues from merge
* [bug] Resolve settings clearing on lock
* [chore] Added a comment
* [review] fromatting for code review
* Revert browser state items
Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-13 17:15:16 +01:00
|
|
|
platformUtilsService: PlatformUtilsService,
|
2022-08-08 11:04:36 +02:00
|
|
|
private policyApiService: PolicyApiServiceAbstraction,
|
[Account Switching] [Feature] Allow clients to store data for more than one user (#491)
* [refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file
* Renamed StorageServiceOptions to StorageOptions
* Pulled KeySuffixOpptions into its own file
* Converted KeySuffixOptions into an enum from a union type
* [refactor] Expand StateService into a full coverage storage proxy
* Expand StateService to allow it to manage all data points of the application state regardless of memory.
* Expand StateService to allow for storing and managing multiple accounts
* [refactor] Create helper services for managing organization and provider state data
* [refactor] Implement StateService across service layer
* Remove service level variables used for in memory data storage and replaced with calls to StateService
* Remove direct calls to StorageService in favor of using StateService as a proxy
* [feature] Implement account switching capable services across components and processes
* Replace calls to StorageService and deprecated services with calls to a StateService
* [chore] Remove unused services
Several services are no longer in use because of the expanded state service. These have simply been removed.
* [bug] Add loginRedirect to the account model
* [bug] Add awaits to newly async calls in TokenService
* [bug] Add several missing awaits
* [bug] Add state service handlers for AutoConfirmFingerprint
* [bug] Move TwoFactorToken to global state
* Update unauth-guard.service.ts
Add back return true
* [refactor] Slim down the boilerplate needed to manage options on StateService calls
* [bug] Allow the lock message handler to manipulate a specific acount
* [bug] Add missing await to auth guard
* [bug] Adjust state scope of several biometric data points
* [bug] Ensure vault locking logic can operate over non-active accounts
* [style] Fix lint complaints
* [bug] Move disableFavicon to global state
* [refactor] Remove an unecassary parameter from a StorageOptions instance
* [bug] Ensure HtmlStorageService paths are accounted for in StateService
* [feature] Add a server url helper to the account model for the account switcher
* [refactor] Remove some unused getters from the account model
* [bug] Ensure locking and logging out can function over any user
* Fix account getting set to null in getAccountFromDisk
* [bug] Ensure lock component is always working with the latest active account in state
* [chore] Update recent KeyConnector changes to use stateService
* [style] Fix lint complaints
* [chore] Resolve TokenService merge issues from KeyConnector
* [bug] Add missing service arguement
* [bug] Correct several default storage option types
* [bug] Check for the right key in hasEncKey
* [bug] Add enableFullWidth to the account model
* [style] Fix lint complaints
* [review] Revist remember email
* [refactor] Remove RememberEmail from state
* setDisableFavicon to correct storage location
* [bug] Convert vault lock loop returns into continues to not skip secondary accounts
* [review] Sorted state service methods
* [bug] Correct neverDomains type on the account model
* [review] Rename stateService.purge to stateService.clean
* [review] [refactor] Extract lock refresh logic to a load function
* [review] [refactor] Extract some timeout logic to dedicated functions
* [review] [refactor] Move AuthenticationStatus to a dedicated file
* [review] [refactor] Rename Globals to GlobalState
* [style] Fix lint complaints
* [review] Remove unused global state property for decodedToken
* [review] [bug] Adjust state scope for OrganizationInvitation
* [review] [bug] Put back the homepage variable in lock guard
* [review] Un-try-catch the window creation function
* Revert "[review] [bug] Adjust state scope for OrganizationInvitation"
This reverts commit caa4574a65d9d0c3573a7529ed2221764fd55497.
* [bug] Change || to && in recent vault timeout refactor
* [bug] Keep up with entire state in storage instead of just accounts and globals
Not having access to the last active user was creating issues across clients when restarting the process.
For example: when refreshing the page on web we no longer maintain an understanding of who is logged in.
To resolve this I converted all storage save operations to get and save an entire state object, instead of specifying accounts and globals.
This allows for more flexible saving, like saving activeUserId as a top level storage item.
* [style] Fix lint complaints
* Revert "[bug] Keep up with entire state in storage instead of just accounts and globals"
This reverts commit e8970725be472386358c1e2f06f53663c4979e0e.
* [bug] Initialize GlobalState by default
* [bug] Only get key hash from storage
* [bug] Remove settings storage location overrides
* [bug] Only save accessToken to storage
* [refactor] Remove unecassary argements from electron crypto state calls
* [bug] Ensure keys and tokens load and save to the right locations for web
* [style] Fix lint complaints
* [bug] Remove keySuffix storage option and split uses into unique methods
The keySuffix options don't work with saving serialized json as a storage object - use cases simply overwrite each other in state.
This commit breaks Auto and Biometric keys into distinct storage items and adjusts logic accordingly.
* [bug] Add default vault timeouts to new accounts
* [bug] Save appId as a top level storage item
* [bug] Add missing await to timeout logic
* [bug] Adjust state scope for everBeenUnlocked
* [bug] Clear access tokens when loading account state from disk
* [bug] Adjust theme to be a global state item
* [bug] Adjust null checking for window in state
* [bug] Correct getGlobals not pulling from the stored state item
* [bug] Null check in memory account before claiming it has a userId
* [bug] Scaffold secure storage service when building storage objects on init
* [bug] Adjusted state scope of event collection
* [bug] Adjusted state scope of vault timeout and action
* [bug] Grab account from normal storage if secure storage is requested but does not exist
* [bug] Create a State if one is requested from memory before it exists
* [bug] Ensure all storage locations are cleared on state clean
* [style] Fix lint complaints
* [bug] Remove uneeded clearing of access token
* [bug] Reset tokens when toggling
* [refactor] Split up the Account model
Until this point the account model has been very flat, holding many kinds of data.
In order to be able to prune data at appropriate times, for example clearing keys at logout without clearing QoL settings like locale,
the Account model has been divided into logical chunks.
* [bug] Correct the serverUrl helpers return
* Fix sends always coming back as empty in browser
* Get settings properly (I think)
* [bug] Fix lint error
* [bug] Add missing await to identity token refresh
This was causing weird behavior in web that was creating a lot of 429s
* [bug] Scaffold memory storage for web
Not properly creating storage objects on signin was creating weird behavior when logging out, locking, and logging back in.
Namely, encrypted data that was recently synced had nowhere to save to and was lost.
* [bug] Implement better null handling in a few places for retrieving state
* [bug] Update correct storage locations on account removal
* [bug] Added missing awaits to lock component
* [bug] Reload lock component on account switching vs. account update
* [bug] Store master keys correctly
* [bug] Move some biometrics storage items to global state
* [feature] Add platform helper isMac()
* [refactor] Comment emphasis and call order refresh
* [refactor] Remove unecassary using
* [bug] Relocate authenticationStatus check logic to component
* [bug] Stop not clearing everything on state clean
* [style] Fix lint complaints
* [bug] Correct mismatched uses of encrypted and decrypted pin states
* Add browser specific state classes and methods
* lint fixes
* [bug] Migrate existing persistant data to new schema
* [style] Fix lint complaints
* [bug] Dont clear settings on state clean
* [bug] Maintain the right storage items on logout
* [chore] resolve issues from merge
* [bug] Resolve settings clearing on lock
* [chore] Added a comment
* [review] fromatting for code review
* Revert browser state items
Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-13 17:15:16 +01:00
|
|
|
policyService: PolicyService,
|
|
|
|
protected router: Router,
|
|
|
|
private apiService: ApiService,
|
|
|
|
private syncService: SyncService,
|
|
|
|
private route: ActivatedRoute,
|
2022-08-24 18:33:05 +02:00
|
|
|
stateService: StateService,
|
2022-12-19 19:56:16 +01:00
|
|
|
private organizationApiService: OrganizationApiServiceAbstraction,
|
2023-05-02 18:46:03 +02:00
|
|
|
private organizationUserService: OrganizationUserService,
|
|
|
|
dialogService: DialogServiceAbstraction
|
[Account Switching] [Feature] Allow clients to store data for more than one user (#491)
* [refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file
* Renamed StorageServiceOptions to StorageOptions
* Pulled KeySuffixOpptions into its own file
* Converted KeySuffixOptions into an enum from a union type
* [refactor] Expand StateService into a full coverage storage proxy
* Expand StateService to allow it to manage all data points of the application state regardless of memory.
* Expand StateService to allow for storing and managing multiple accounts
* [refactor] Create helper services for managing organization and provider state data
* [refactor] Implement StateService across service layer
* Remove service level variables used for in memory data storage and replaced with calls to StateService
* Remove direct calls to StorageService in favor of using StateService as a proxy
* [feature] Implement account switching capable services across components and processes
* Replace calls to StorageService and deprecated services with calls to a StateService
* [chore] Remove unused services
Several services are no longer in use because of the expanded state service. These have simply been removed.
* [bug] Add loginRedirect to the account model
* [bug] Add awaits to newly async calls in TokenService
* [bug] Add several missing awaits
* [bug] Add state service handlers for AutoConfirmFingerprint
* [bug] Move TwoFactorToken to global state
* Update unauth-guard.service.ts
Add back return true
* [refactor] Slim down the boilerplate needed to manage options on StateService calls
* [bug] Allow the lock message handler to manipulate a specific acount
* [bug] Add missing await to auth guard
* [bug] Adjust state scope of several biometric data points
* [bug] Ensure vault locking logic can operate over non-active accounts
* [style] Fix lint complaints
* [bug] Move disableFavicon to global state
* [refactor] Remove an unecassary parameter from a StorageOptions instance
* [bug] Ensure HtmlStorageService paths are accounted for in StateService
* [feature] Add a server url helper to the account model for the account switcher
* [refactor] Remove some unused getters from the account model
* [bug] Ensure locking and logging out can function over any user
* Fix account getting set to null in getAccountFromDisk
* [bug] Ensure lock component is always working with the latest active account in state
* [chore] Update recent KeyConnector changes to use stateService
* [style] Fix lint complaints
* [chore] Resolve TokenService merge issues from KeyConnector
* [bug] Add missing service arguement
* [bug] Correct several default storage option types
* [bug] Check for the right key in hasEncKey
* [bug] Add enableFullWidth to the account model
* [style] Fix lint complaints
* [review] Revist remember email
* [refactor] Remove RememberEmail from state
* setDisableFavicon to correct storage location
* [bug] Convert vault lock loop returns into continues to not skip secondary accounts
* [review] Sorted state service methods
* [bug] Correct neverDomains type on the account model
* [review] Rename stateService.purge to stateService.clean
* [review] [refactor] Extract lock refresh logic to a load function
* [review] [refactor] Extract some timeout logic to dedicated functions
* [review] [refactor] Move AuthenticationStatus to a dedicated file
* [review] [refactor] Rename Globals to GlobalState
* [style] Fix lint complaints
* [review] Remove unused global state property for decodedToken
* [review] [bug] Adjust state scope for OrganizationInvitation
* [review] [bug] Put back the homepage variable in lock guard
* [review] Un-try-catch the window creation function
* Revert "[review] [bug] Adjust state scope for OrganizationInvitation"
This reverts commit caa4574a65d9d0c3573a7529ed2221764fd55497.
* [bug] Change || to && in recent vault timeout refactor
* [bug] Keep up with entire state in storage instead of just accounts and globals
Not having access to the last active user was creating issues across clients when restarting the process.
For example: when refreshing the page on web we no longer maintain an understanding of who is logged in.
To resolve this I converted all storage save operations to get and save an entire state object, instead of specifying accounts and globals.
This allows for more flexible saving, like saving activeUserId as a top level storage item.
* [style] Fix lint complaints
* Revert "[bug] Keep up with entire state in storage instead of just accounts and globals"
This reverts commit e8970725be472386358c1e2f06f53663c4979e0e.
* [bug] Initialize GlobalState by default
* [bug] Only get key hash from storage
* [bug] Remove settings storage location overrides
* [bug] Only save accessToken to storage
* [refactor] Remove unecassary argements from electron crypto state calls
* [bug] Ensure keys and tokens load and save to the right locations for web
* [style] Fix lint complaints
* [bug] Remove keySuffix storage option and split uses into unique methods
The keySuffix options don't work with saving serialized json as a storage object - use cases simply overwrite each other in state.
This commit breaks Auto and Biometric keys into distinct storage items and adjusts logic accordingly.
* [bug] Add default vault timeouts to new accounts
* [bug] Save appId as a top level storage item
* [bug] Add missing await to timeout logic
* [bug] Adjust state scope for everBeenUnlocked
* [bug] Clear access tokens when loading account state from disk
* [bug] Adjust theme to be a global state item
* [bug] Adjust null checking for window in state
* [bug] Correct getGlobals not pulling from the stored state item
* [bug] Null check in memory account before claiming it has a userId
* [bug] Scaffold secure storage service when building storage objects on init
* [bug] Adjusted state scope of event collection
* [bug] Adjusted state scope of vault timeout and action
* [bug] Grab account from normal storage if secure storage is requested but does not exist
* [bug] Create a State if one is requested from memory before it exists
* [bug] Ensure all storage locations are cleared on state clean
* [style] Fix lint complaints
* [bug] Remove uneeded clearing of access token
* [bug] Reset tokens when toggling
* [refactor] Split up the Account model
Until this point the account model has been very flat, holding many kinds of data.
In order to be able to prune data at appropriate times, for example clearing keys at logout without clearing QoL settings like locale,
the Account model has been divided into logical chunks.
* [bug] Correct the serverUrl helpers return
* Fix sends always coming back as empty in browser
* Get settings properly (I think)
* [bug] Fix lint error
* [bug] Add missing await to identity token refresh
This was causing weird behavior in web that was creating a lot of 429s
* [bug] Scaffold memory storage for web
Not properly creating storage objects on signin was creating weird behavior when logging out, locking, and logging back in.
Namely, encrypted data that was recently synced had nowhere to save to and was lost.
* [bug] Implement better null handling in a few places for retrieving state
* [bug] Update correct storage locations on account removal
* [bug] Added missing awaits to lock component
* [bug] Reload lock component on account switching vs. account update
* [bug] Store master keys correctly
* [bug] Move some biometrics storage items to global state
* [feature] Add platform helper isMac()
* [refactor] Comment emphasis and call order refresh
* [refactor] Remove unecassary using
* [bug] Relocate authenticationStatus check logic to component
* [bug] Stop not clearing everything on state clean
* [style] Fix lint complaints
* [bug] Correct mismatched uses of encrypted and decrypted pin states
* Add browser specific state classes and methods
* lint fixes
* [bug] Migrate existing persistant data to new schema
* [style] Fix lint complaints
* [bug] Dont clear settings on state clean
* [bug] Maintain the right storage items on logout
* [chore] resolve issues from merge
* [bug] Resolve settings clearing on lock
* [chore] Added a comment
* [review] fromatting for code review
* Revert browser state items
Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-13 17:15:16 +01:00
|
|
|
) {
|
|
|
|
super(
|
|
|
|
i18nService,
|
|
|
|
cryptoService,
|
|
|
|
messagingService,
|
|
|
|
passwordGenerationService,
|
|
|
|
platformUtilsService,
|
|
|
|
policyService,
|
2023-05-02 18:46:03 +02:00
|
|
|
stateService,
|
|
|
|
dialogService
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-27 20:24:38 +02:00
|
|
|
async ngOnInit() {
|
[Account Switching] [Feature] Allow clients to store data for more than one user (#491)
* [refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file
* Renamed StorageServiceOptions to StorageOptions
* Pulled KeySuffixOpptions into its own file
* Converted KeySuffixOptions into an enum from a union type
* [refactor] Expand StateService into a full coverage storage proxy
* Expand StateService to allow it to manage all data points of the application state regardless of memory.
* Expand StateService to allow for storing and managing multiple accounts
* [refactor] Create helper services for managing organization and provider state data
* [refactor] Implement StateService across service layer
* Remove service level variables used for in memory data storage and replaced with calls to StateService
* Remove direct calls to StorageService in favor of using StateService as a proxy
* [feature] Implement account switching capable services across components and processes
* Replace calls to StorageService and deprecated services with calls to a StateService
* [chore] Remove unused services
Several services are no longer in use because of the expanded state service. These have simply been removed.
* [bug] Add loginRedirect to the account model
* [bug] Add awaits to newly async calls in TokenService
* [bug] Add several missing awaits
* [bug] Add state service handlers for AutoConfirmFingerprint
* [bug] Move TwoFactorToken to global state
* Update unauth-guard.service.ts
Add back return true
* [refactor] Slim down the boilerplate needed to manage options on StateService calls
* [bug] Allow the lock message handler to manipulate a specific acount
* [bug] Add missing await to auth guard
* [bug] Adjust state scope of several biometric data points
* [bug] Ensure vault locking logic can operate over non-active accounts
* [style] Fix lint complaints
* [bug] Move disableFavicon to global state
* [refactor] Remove an unecassary parameter from a StorageOptions instance
* [bug] Ensure HtmlStorageService paths are accounted for in StateService
* [feature] Add a server url helper to the account model for the account switcher
* [refactor] Remove some unused getters from the account model
* [bug] Ensure locking and logging out can function over any user
* Fix account getting set to null in getAccountFromDisk
* [bug] Ensure lock component is always working with the latest active account in state
* [chore] Update recent KeyConnector changes to use stateService
* [style] Fix lint complaints
* [chore] Resolve TokenService merge issues from KeyConnector
* [bug] Add missing service arguement
* [bug] Correct several default storage option types
* [bug] Check for the right key in hasEncKey
* [bug] Add enableFullWidth to the account model
* [style] Fix lint complaints
* [review] Revist remember email
* [refactor] Remove RememberEmail from state
* setDisableFavicon to correct storage location
* [bug] Convert vault lock loop returns into continues to not skip secondary accounts
* [review] Sorted state service methods
* [bug] Correct neverDomains type on the account model
* [review] Rename stateService.purge to stateService.clean
* [review] [refactor] Extract lock refresh logic to a load function
* [review] [refactor] Extract some timeout logic to dedicated functions
* [review] [refactor] Move AuthenticationStatus to a dedicated file
* [review] [refactor] Rename Globals to GlobalState
* [style] Fix lint complaints
* [review] Remove unused global state property for decodedToken
* [review] [bug] Adjust state scope for OrganizationInvitation
* [review] [bug] Put back the homepage variable in lock guard
* [review] Un-try-catch the window creation function
* Revert "[review] [bug] Adjust state scope for OrganizationInvitation"
This reverts commit caa4574a65d9d0c3573a7529ed2221764fd55497.
* [bug] Change || to && in recent vault timeout refactor
* [bug] Keep up with entire state in storage instead of just accounts and globals
Not having access to the last active user was creating issues across clients when restarting the process.
For example: when refreshing the page on web we no longer maintain an understanding of who is logged in.
To resolve this I converted all storage save operations to get and save an entire state object, instead of specifying accounts and globals.
This allows for more flexible saving, like saving activeUserId as a top level storage item.
* [style] Fix lint complaints
* Revert "[bug] Keep up with entire state in storage instead of just accounts and globals"
This reverts commit e8970725be472386358c1e2f06f53663c4979e0e.
* [bug] Initialize GlobalState by default
* [bug] Only get key hash from storage
* [bug] Remove settings storage location overrides
* [bug] Only save accessToken to storage
* [refactor] Remove unecassary argements from electron crypto state calls
* [bug] Ensure keys and tokens load and save to the right locations for web
* [style] Fix lint complaints
* [bug] Remove keySuffix storage option and split uses into unique methods
The keySuffix options don't work with saving serialized json as a storage object - use cases simply overwrite each other in state.
This commit breaks Auto and Biometric keys into distinct storage items and adjusts logic accordingly.
* [bug] Add default vault timeouts to new accounts
* [bug] Save appId as a top level storage item
* [bug] Add missing await to timeout logic
* [bug] Adjust state scope for everBeenUnlocked
* [bug] Clear access tokens when loading account state from disk
* [bug] Adjust theme to be a global state item
* [bug] Adjust null checking for window in state
* [bug] Correct getGlobals not pulling from the stored state item
* [bug] Null check in memory account before claiming it has a userId
* [bug] Scaffold secure storage service when building storage objects on init
* [bug] Adjusted state scope of event collection
* [bug] Adjusted state scope of vault timeout and action
* [bug] Grab account from normal storage if secure storage is requested but does not exist
* [bug] Create a State if one is requested from memory before it exists
* [bug] Ensure all storage locations are cleared on state clean
* [style] Fix lint complaints
* [bug] Remove uneeded clearing of access token
* [bug] Reset tokens when toggling
* [refactor] Split up the Account model
Until this point the account model has been very flat, holding many kinds of data.
In order to be able to prune data at appropriate times, for example clearing keys at logout without clearing QoL settings like locale,
the Account model has been divided into logical chunks.
* [bug] Correct the serverUrl helpers return
* Fix sends always coming back as empty in browser
* Get settings properly (I think)
* [bug] Fix lint error
* [bug] Add missing await to identity token refresh
This was causing weird behavior in web that was creating a lot of 429s
* [bug] Scaffold memory storage for web
Not properly creating storage objects on signin was creating weird behavior when logging out, locking, and logging back in.
Namely, encrypted data that was recently synced had nowhere to save to and was lost.
* [bug] Implement better null handling in a few places for retrieving state
* [bug] Update correct storage locations on account removal
* [bug] Added missing awaits to lock component
* [bug] Reload lock component on account switching vs. account update
* [bug] Store master keys correctly
* [bug] Move some biometrics storage items to global state
* [feature] Add platform helper isMac()
* [refactor] Comment emphasis and call order refresh
* [refactor] Remove unecassary using
* [bug] Relocate authenticationStatus check logic to component
* [bug] Stop not clearing everything on state clean
* [style] Fix lint complaints
* [bug] Correct mismatched uses of encrypted and decrypted pin states
* Add browser specific state classes and methods
* lint fixes
* [bug] Migrate existing persistant data to new schema
* [style] Fix lint complaints
* [bug] Dont clear settings on state clean
* [bug] Maintain the right storage items on logout
* [chore] resolve issues from merge
* [bug] Resolve settings clearing on lock
* [chore] Added a comment
* [review] fromatting for code review
* Revert browser state items
Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-13 17:15:16 +01:00
|
|
|
await this.syncService.fullSync(true);
|
2020-08-27 20:24:38 +02:00
|
|
|
this.syncLoading = false;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2022-08-26 18:09:28 +02:00
|
|
|
// eslint-disable-next-line rxjs/no-async-subscribe
|
2021-10-14 02:27:52 +02:00
|
|
|
this.route.queryParams.pipe(first()).subscribe(async (qParams) => {
|
2020-10-13 22:21:03 +02:00
|
|
|
if (qParams.identifier != null) {
|
|
|
|
this.identifier = qParams.identifier;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-09-03 21:49:03 +02:00
|
|
|
// Automatic Enrollment Detection
|
|
|
|
if (this.identifier != null) {
|
2021-12-16 13:36:21 +01:00
|
|
|
try {
|
2022-08-24 18:33:05 +02:00
|
|
|
const response = await this.organizationApiService.getAutoEnrollStatus(this.identifier);
|
2021-09-15 19:54:44 +02:00
|
|
|
this.orgId = response.id;
|
|
|
|
this.resetPasswordAutoEnroll = response.resetPasswordEnabled;
|
2021-12-21 18:02:56 +01:00
|
|
|
this.enforcedPolicyOptions =
|
2022-08-08 11:04:36 +02:00
|
|
|
await this.policyApiService.getMasterPasswordPoliciesForInvitedUsers(this.orgId);
|
2021-09-15 19:54:44 +02:00
|
|
|
} catch {
|
[Account Switching] [Feature] Allow clients to store data for more than one user (#491)
* [refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file
* Renamed StorageServiceOptions to StorageOptions
* Pulled KeySuffixOpptions into its own file
* Converted KeySuffixOptions into an enum from a union type
* [refactor] Expand StateService into a full coverage storage proxy
* Expand StateService to allow it to manage all data points of the application state regardless of memory.
* Expand StateService to allow for storing and managing multiple accounts
* [refactor] Create helper services for managing organization and provider state data
* [refactor] Implement StateService across service layer
* Remove service level variables used for in memory data storage and replaced with calls to StateService
* Remove direct calls to StorageService in favor of using StateService as a proxy
* [feature] Implement account switching capable services across components and processes
* Replace calls to StorageService and deprecated services with calls to a StateService
* [chore] Remove unused services
Several services are no longer in use because of the expanded state service. These have simply been removed.
* [bug] Add loginRedirect to the account model
* [bug] Add awaits to newly async calls in TokenService
* [bug] Add several missing awaits
* [bug] Add state service handlers for AutoConfirmFingerprint
* [bug] Move TwoFactorToken to global state
* Update unauth-guard.service.ts
Add back return true
* [refactor] Slim down the boilerplate needed to manage options on StateService calls
* [bug] Allow the lock message handler to manipulate a specific acount
* [bug] Add missing await to auth guard
* [bug] Adjust state scope of several biometric data points
* [bug] Ensure vault locking logic can operate over non-active accounts
* [style] Fix lint complaints
* [bug] Move disableFavicon to global state
* [refactor] Remove an unecassary parameter from a StorageOptions instance
* [bug] Ensure HtmlStorageService paths are accounted for in StateService
* [feature] Add a server url helper to the account model for the account switcher
* [refactor] Remove some unused getters from the account model
* [bug] Ensure locking and logging out can function over any user
* Fix account getting set to null in getAccountFromDisk
* [bug] Ensure lock component is always working with the latest active account in state
* [chore] Update recent KeyConnector changes to use stateService
* [style] Fix lint complaints
* [chore] Resolve TokenService merge issues from KeyConnector
* [bug] Add missing service arguement
* [bug] Correct several default storage option types
* [bug] Check for the right key in hasEncKey
* [bug] Add enableFullWidth to the account model
* [style] Fix lint complaints
* [review] Revist remember email
* [refactor] Remove RememberEmail from state
* setDisableFavicon to correct storage location
* [bug] Convert vault lock loop returns into continues to not skip secondary accounts
* [review] Sorted state service methods
* [bug] Correct neverDomains type on the account model
* [review] Rename stateService.purge to stateService.clean
* [review] [refactor] Extract lock refresh logic to a load function
* [review] [refactor] Extract some timeout logic to dedicated functions
* [review] [refactor] Move AuthenticationStatus to a dedicated file
* [review] [refactor] Rename Globals to GlobalState
* [style] Fix lint complaints
* [review] Remove unused global state property for decodedToken
* [review] [bug] Adjust state scope for OrganizationInvitation
* [review] [bug] Put back the homepage variable in lock guard
* [review] Un-try-catch the window creation function
* Revert "[review] [bug] Adjust state scope for OrganizationInvitation"
This reverts commit caa4574a65d9d0c3573a7529ed2221764fd55497.
* [bug] Change || to && in recent vault timeout refactor
* [bug] Keep up with entire state in storage instead of just accounts and globals
Not having access to the last active user was creating issues across clients when restarting the process.
For example: when refreshing the page on web we no longer maintain an understanding of who is logged in.
To resolve this I converted all storage save operations to get and save an entire state object, instead of specifying accounts and globals.
This allows for more flexible saving, like saving activeUserId as a top level storage item.
* [style] Fix lint complaints
* Revert "[bug] Keep up with entire state in storage instead of just accounts and globals"
This reverts commit e8970725be472386358c1e2f06f53663c4979e0e.
* [bug] Initialize GlobalState by default
* [bug] Only get key hash from storage
* [bug] Remove settings storage location overrides
* [bug] Only save accessToken to storage
* [refactor] Remove unecassary argements from electron crypto state calls
* [bug] Ensure keys and tokens load and save to the right locations for web
* [style] Fix lint complaints
* [bug] Remove keySuffix storage option and split uses into unique methods
The keySuffix options don't work with saving serialized json as a storage object - use cases simply overwrite each other in state.
This commit breaks Auto and Biometric keys into distinct storage items and adjusts logic accordingly.
* [bug] Add default vault timeouts to new accounts
* [bug] Save appId as a top level storage item
* [bug] Add missing await to timeout logic
* [bug] Adjust state scope for everBeenUnlocked
* [bug] Clear access tokens when loading account state from disk
* [bug] Adjust theme to be a global state item
* [bug] Adjust null checking for window in state
* [bug] Correct getGlobals not pulling from the stored state item
* [bug] Null check in memory account before claiming it has a userId
* [bug] Scaffold secure storage service when building storage objects on init
* [bug] Adjusted state scope of event collection
* [bug] Adjusted state scope of vault timeout and action
* [bug] Grab account from normal storage if secure storage is requested but does not exist
* [bug] Create a State if one is requested from memory before it exists
* [bug] Ensure all storage locations are cleared on state clean
* [style] Fix lint complaints
* [bug] Remove uneeded clearing of access token
* [bug] Reset tokens when toggling
* [refactor] Split up the Account model
Until this point the account model has been very flat, holding many kinds of data.
In order to be able to prune data at appropriate times, for example clearing keys at logout without clearing QoL settings like locale,
the Account model has been divided into logical chunks.
* [bug] Correct the serverUrl helpers return
* Fix sends always coming back as empty in browser
* Get settings properly (I think)
* [bug] Fix lint error
* [bug] Add missing await to identity token refresh
This was causing weird behavior in web that was creating a lot of 429s
* [bug] Scaffold memory storage for web
Not properly creating storage objects on signin was creating weird behavior when logging out, locking, and logging back in.
Namely, encrypted data that was recently synced had nowhere to save to and was lost.
* [bug] Implement better null handling in a few places for retrieving state
* [bug] Update correct storage locations on account removal
* [bug] Added missing awaits to lock component
* [bug] Reload lock component on account switching vs. account update
* [bug] Store master keys correctly
* [bug] Move some biometrics storage items to global state
* [feature] Add platform helper isMac()
* [refactor] Comment emphasis and call order refresh
* [refactor] Remove unecassary using
* [bug] Relocate authenticationStatus check logic to component
* [bug] Stop not clearing everything on state clean
* [style] Fix lint complaints
* [bug] Correct mismatched uses of encrypted and decrypted pin states
* Add browser specific state classes and methods
* lint fixes
* [bug] Migrate existing persistant data to new schema
* [style] Fix lint complaints
* [bug] Dont clear settings on state clean
* [bug] Maintain the right storage items on logout
* [chore] resolve issues from merge
* [bug] Resolve settings clearing on lock
* [chore] Added a comment
* [review] fromatting for code review
* Revert browser state items
Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-13 17:15:16 +01:00
|
|
|
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred"));
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-08-19 16:57:35 +02:00
|
|
|
}
|
|
|
|
|
2020-08-27 20:24:38 +02:00
|
|
|
super.ngOnInit();
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-08-27 20:24:38 +02:00
|
|
|
async setupSubmitActions() {
|
2022-03-24 10:42:11 +01:00
|
|
|
this.kdf = DEFAULT_KDF_TYPE;
|
2023-01-30 15:07:51 +01:00
|
|
|
this.kdfConfig = DEFAULT_KDF_CONFIG;
|
2020-08-27 20:24:38 +02:00
|
|
|
return true;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-08-27 20:24:38 +02:00
|
|
|
async performSubmitActions(
|
2020-08-19 16:57:35 +02:00
|
|
|
masterPasswordHash: string,
|
|
|
|
key: SymmetricCryptoKey,
|
2020-08-27 20:24:38 +02:00
|
|
|
encKey: [SymmetricCryptoKey, EncString]
|
2021-12-16 13:36:21 +01:00
|
|
|
) {
|
2020-08-27 20:24:38 +02:00
|
|
|
const keys = await this.cryptoService.makeKeyPair(encKey[0]);
|
|
|
|
const request = new SetPasswordRequest(
|
2021-09-03 21:49:03 +02:00
|
|
|
masterPasswordHash,
|
2020-08-27 20:24:38 +02:00
|
|
|
encKey[1].encryptedString,
|
|
|
|
this.hint,
|
2021-09-03 21:49:03 +02:00
|
|
|
this.identifier,
|
2023-01-30 15:07:51 +01:00
|
|
|
new KeysRequest(keys[0], keys[1].encryptedString),
|
|
|
|
this.kdf,
|
|
|
|
this.kdfConfig.iterations,
|
|
|
|
this.kdfConfig.memory,
|
|
|
|
this.kdfConfig.parallelism
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
|
|
|
try {
|
2021-10-14 02:27:52 +02:00
|
|
|
if (this.resetPasswordAutoEnroll) {
|
|
|
|
this.formPromise = this.apiService
|
|
|
|
.setPassword(request)
|
|
|
|
.then(async () => {
|
2020-10-13 22:21:03 +02:00
|
|
|
await this.onSetPasswordSuccess(key, encKey, keys);
|
2022-08-24 18:33:05 +02:00
|
|
|
return this.organizationApiService.getKeys(this.orgId);
|
2021-12-16 13:36:21 +01:00
|
|
|
})
|
2021-09-03 21:49:03 +02:00
|
|
|
.then(async (response) => {
|
2020-10-13 22:21:03 +02:00
|
|
|
if (response == null) {
|
|
|
|
throw new Error(this.i18nService.t("resetPasswordOrgKeysError"));
|
|
|
|
}
|
[Account Switching] [Feature] Allow clients to store data for more than one user (#491)
* [refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file
* Renamed StorageServiceOptions to StorageOptions
* Pulled KeySuffixOpptions into its own file
* Converted KeySuffixOptions into an enum from a union type
* [refactor] Expand StateService into a full coverage storage proxy
* Expand StateService to allow it to manage all data points of the application state regardless of memory.
* Expand StateService to allow for storing and managing multiple accounts
* [refactor] Create helper services for managing organization and provider state data
* [refactor] Implement StateService across service layer
* Remove service level variables used for in memory data storage and replaced with calls to StateService
* Remove direct calls to StorageService in favor of using StateService as a proxy
* [feature] Implement account switching capable services across components and processes
* Replace calls to StorageService and deprecated services with calls to a StateService
* [chore] Remove unused services
Several services are no longer in use because of the expanded state service. These have simply been removed.
* [bug] Add loginRedirect to the account model
* [bug] Add awaits to newly async calls in TokenService
* [bug] Add several missing awaits
* [bug] Add state service handlers for AutoConfirmFingerprint
* [bug] Move TwoFactorToken to global state
* Update unauth-guard.service.ts
Add back return true
* [refactor] Slim down the boilerplate needed to manage options on StateService calls
* [bug] Allow the lock message handler to manipulate a specific acount
* [bug] Add missing await to auth guard
* [bug] Adjust state scope of several biometric data points
* [bug] Ensure vault locking logic can operate over non-active accounts
* [style] Fix lint complaints
* [bug] Move disableFavicon to global state
* [refactor] Remove an unecassary parameter from a StorageOptions instance
* [bug] Ensure HtmlStorageService paths are accounted for in StateService
* [feature] Add a server url helper to the account model for the account switcher
* [refactor] Remove some unused getters from the account model
* [bug] Ensure locking and logging out can function over any user
* Fix account getting set to null in getAccountFromDisk
* [bug] Ensure lock component is always working with the latest active account in state
* [chore] Update recent KeyConnector changes to use stateService
* [style] Fix lint complaints
* [chore] Resolve TokenService merge issues from KeyConnector
* [bug] Add missing service arguement
* [bug] Correct several default storage option types
* [bug] Check for the right key in hasEncKey
* [bug] Add enableFullWidth to the account model
* [style] Fix lint complaints
* [review] Revist remember email
* [refactor] Remove RememberEmail from state
* setDisableFavicon to correct storage location
* [bug] Convert vault lock loop returns into continues to not skip secondary accounts
* [review] Sorted state service methods
* [bug] Correct neverDomains type on the account model
* [review] Rename stateService.purge to stateService.clean
* [review] [refactor] Extract lock refresh logic to a load function
* [review] [refactor] Extract some timeout logic to dedicated functions
* [review] [refactor] Move AuthenticationStatus to a dedicated file
* [review] [refactor] Rename Globals to GlobalState
* [style] Fix lint complaints
* [review] Remove unused global state property for decodedToken
* [review] [bug] Adjust state scope for OrganizationInvitation
* [review] [bug] Put back the homepage variable in lock guard
* [review] Un-try-catch the window creation function
* Revert "[review] [bug] Adjust state scope for OrganizationInvitation"
This reverts commit caa4574a65d9d0c3573a7529ed2221764fd55497.
* [bug] Change || to && in recent vault timeout refactor
* [bug] Keep up with entire state in storage instead of just accounts and globals
Not having access to the last active user was creating issues across clients when restarting the process.
For example: when refreshing the page on web we no longer maintain an understanding of who is logged in.
To resolve this I converted all storage save operations to get and save an entire state object, instead of specifying accounts and globals.
This allows for more flexible saving, like saving activeUserId as a top level storage item.
* [style] Fix lint complaints
* Revert "[bug] Keep up with entire state in storage instead of just accounts and globals"
This reverts commit e8970725be472386358c1e2f06f53663c4979e0e.
* [bug] Initialize GlobalState by default
* [bug] Only get key hash from storage
* [bug] Remove settings storage location overrides
* [bug] Only save accessToken to storage
* [refactor] Remove unecassary argements from electron crypto state calls
* [bug] Ensure keys and tokens load and save to the right locations for web
* [style] Fix lint complaints
* [bug] Remove keySuffix storage option and split uses into unique methods
The keySuffix options don't work with saving serialized json as a storage object - use cases simply overwrite each other in state.
This commit breaks Auto and Biometric keys into distinct storage items and adjusts logic accordingly.
* [bug] Add default vault timeouts to new accounts
* [bug] Save appId as a top level storage item
* [bug] Add missing await to timeout logic
* [bug] Adjust state scope for everBeenUnlocked
* [bug] Clear access tokens when loading account state from disk
* [bug] Adjust theme to be a global state item
* [bug] Adjust null checking for window in state
* [bug] Correct getGlobals not pulling from the stored state item
* [bug] Null check in memory account before claiming it has a userId
* [bug] Scaffold secure storage service when building storage objects on init
* [bug] Adjusted state scope of event collection
* [bug] Adjusted state scope of vault timeout and action
* [bug] Grab account from normal storage if secure storage is requested but does not exist
* [bug] Create a State if one is requested from memory before it exists
* [bug] Ensure all storage locations are cleared on state clean
* [style] Fix lint complaints
* [bug] Remove uneeded clearing of access token
* [bug] Reset tokens when toggling
* [refactor] Split up the Account model
Until this point the account model has been very flat, holding many kinds of data.
In order to be able to prune data at appropriate times, for example clearing keys at logout without clearing QoL settings like locale,
the Account model has been divided into logical chunks.
* [bug] Correct the serverUrl helpers return
* Fix sends always coming back as empty in browser
* Get settings properly (I think)
* [bug] Fix lint error
* [bug] Add missing await to identity token refresh
This was causing weird behavior in web that was creating a lot of 429s
* [bug] Scaffold memory storage for web
Not properly creating storage objects on signin was creating weird behavior when logging out, locking, and logging back in.
Namely, encrypted data that was recently synced had nowhere to save to and was lost.
* [bug] Implement better null handling in a few places for retrieving state
* [bug] Update correct storage locations on account removal
* [bug] Added missing awaits to lock component
* [bug] Reload lock component on account switching vs. account update
* [bug] Store master keys correctly
* [bug] Move some biometrics storage items to global state
* [feature] Add platform helper isMac()
* [refactor] Comment emphasis and call order refresh
* [refactor] Remove unecassary using
* [bug] Relocate authenticationStatus check logic to component
* [bug] Stop not clearing everything on state clean
* [style] Fix lint complaints
* [bug] Correct mismatched uses of encrypted and decrypted pin states
* Add browser specific state classes and methods
* lint fixes
* [bug] Migrate existing persistant data to new schema
* [style] Fix lint complaints
* [bug] Dont clear settings on state clean
* [bug] Maintain the right storage items on logout
* [chore] resolve issues from merge
* [bug] Resolve settings clearing on lock
* [chore] Added a comment
* [review] fromatting for code review
* Revert browser state items
Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-13 17:15:16 +01:00
|
|
|
const userId = await this.stateService.getUserId();
|
2021-09-03 21:49:03 +02:00
|
|
|
const publicKey = Utils.fromB64ToArray(response.publicKey);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-09-03 21:49:03 +02:00
|
|
|
// RSA Encrypt user's encKey.key with organization public key
|
|
|
|
const userEncKey = await this.cryptoService.getEncKey();
|
|
|
|
const encryptedKey = await this.cryptoService.rsaEncrypt(
|
|
|
|
userEncKey.key,
|
|
|
|
publicKey.buffer
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
|
|
|
|
2021-09-03 21:49:03 +02:00
|
|
|
const resetRequest = new OrganizationUserResetPasswordEnrollmentRequest();
|
2022-07-06 21:19:58 +02:00
|
|
|
resetRequest.masterPasswordHash = masterPasswordHash;
|
2021-09-03 21:49:03 +02:00
|
|
|
resetRequest.resetPasswordKey = encryptedKey.encryptedString;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2022-12-19 19:56:16 +01:00
|
|
|
return this.organizationUserService.putOrganizationUserResetPasswordEnrollment(
|
2021-09-03 21:49:03 +02:00
|
|
|
this.orgId,
|
2021-12-16 13:36:21 +01:00
|
|
|
userId,
|
2021-09-03 21:49:03 +02:00
|
|
|
resetRequest
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
} else {
|
2021-09-03 21:49:03 +02:00
|
|
|
this.formPromise = this.apiService.setPassword(request).then(async () => {
|
|
|
|
await this.onSetPasswordSuccess(key, encKey, keys);
|
2020-10-13 22:21:03 +02:00
|
|
|
});
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-10-13 22:21:03 +02:00
|
|
|
|
2021-09-03 21:49:03 +02:00
|
|
|
await this.formPromise;
|
|
|
|
|
|
|
|
if (this.onSuccessfulChangePassword != null) {
|
|
|
|
this.onSuccessfulChangePassword();
|
2021-12-16 13:36:21 +01:00
|
|
|
} else {
|
2021-09-03 21:49:03 +02:00
|
|
|
this.router.navigate([this.successRoute]);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2021-09-03 21:49:03 +02:00
|
|
|
} catch {
|
|
|
|
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred"));
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-08-19 16:57:35 +02:00
|
|
|
togglePassword(confirmField: boolean) {
|
|
|
|
this.showPassword = !this.showPassword;
|
|
|
|
document.getElementById(confirmField ? "masterPasswordRetype" : "masterPassword").focus();
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2021-09-03 21:49:03 +02:00
|
|
|
private async onSetPasswordSuccess(
|
|
|
|
key: SymmetricCryptoKey,
|
|
|
|
encKey: [SymmetricCryptoKey, EncString],
|
|
|
|
keys: [string, EncString]
|
2021-12-16 13:36:21 +01:00
|
|
|
) {
|
[Account Switching] [Feature] Allow clients to store data for more than one user (#491)
* [refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file
* Renamed StorageServiceOptions to StorageOptions
* Pulled KeySuffixOpptions into its own file
* Converted KeySuffixOptions into an enum from a union type
* [refactor] Expand StateService into a full coverage storage proxy
* Expand StateService to allow it to manage all data points of the application state regardless of memory.
* Expand StateService to allow for storing and managing multiple accounts
* [refactor] Create helper services for managing organization and provider state data
* [refactor] Implement StateService across service layer
* Remove service level variables used for in memory data storage and replaced with calls to StateService
* Remove direct calls to StorageService in favor of using StateService as a proxy
* [feature] Implement account switching capable services across components and processes
* Replace calls to StorageService and deprecated services with calls to a StateService
* [chore] Remove unused services
Several services are no longer in use because of the expanded state service. These have simply been removed.
* [bug] Add loginRedirect to the account model
* [bug] Add awaits to newly async calls in TokenService
* [bug] Add several missing awaits
* [bug] Add state service handlers for AutoConfirmFingerprint
* [bug] Move TwoFactorToken to global state
* Update unauth-guard.service.ts
Add back return true
* [refactor] Slim down the boilerplate needed to manage options on StateService calls
* [bug] Allow the lock message handler to manipulate a specific acount
* [bug] Add missing await to auth guard
* [bug] Adjust state scope of several biometric data points
* [bug] Ensure vault locking logic can operate over non-active accounts
* [style] Fix lint complaints
* [bug] Move disableFavicon to global state
* [refactor] Remove an unecassary parameter from a StorageOptions instance
* [bug] Ensure HtmlStorageService paths are accounted for in StateService
* [feature] Add a server url helper to the account model for the account switcher
* [refactor] Remove some unused getters from the account model
* [bug] Ensure locking and logging out can function over any user
* Fix account getting set to null in getAccountFromDisk
* [bug] Ensure lock component is always working with the latest active account in state
* [chore] Update recent KeyConnector changes to use stateService
* [style] Fix lint complaints
* [chore] Resolve TokenService merge issues from KeyConnector
* [bug] Add missing service arguement
* [bug] Correct several default storage option types
* [bug] Check for the right key in hasEncKey
* [bug] Add enableFullWidth to the account model
* [style] Fix lint complaints
* [review] Revist remember email
* [refactor] Remove RememberEmail from state
* setDisableFavicon to correct storage location
* [bug] Convert vault lock loop returns into continues to not skip secondary accounts
* [review] Sorted state service methods
* [bug] Correct neverDomains type on the account model
* [review] Rename stateService.purge to stateService.clean
* [review] [refactor] Extract lock refresh logic to a load function
* [review] [refactor] Extract some timeout logic to dedicated functions
* [review] [refactor] Move AuthenticationStatus to a dedicated file
* [review] [refactor] Rename Globals to GlobalState
* [style] Fix lint complaints
* [review] Remove unused global state property for decodedToken
* [review] [bug] Adjust state scope for OrganizationInvitation
* [review] [bug] Put back the homepage variable in lock guard
* [review] Un-try-catch the window creation function
* Revert "[review] [bug] Adjust state scope for OrganizationInvitation"
This reverts commit caa4574a65d9d0c3573a7529ed2221764fd55497.
* [bug] Change || to && in recent vault timeout refactor
* [bug] Keep up with entire state in storage instead of just accounts and globals
Not having access to the last active user was creating issues across clients when restarting the process.
For example: when refreshing the page on web we no longer maintain an understanding of who is logged in.
To resolve this I converted all storage save operations to get and save an entire state object, instead of specifying accounts and globals.
This allows for more flexible saving, like saving activeUserId as a top level storage item.
* [style] Fix lint complaints
* Revert "[bug] Keep up with entire state in storage instead of just accounts and globals"
This reverts commit e8970725be472386358c1e2f06f53663c4979e0e.
* [bug] Initialize GlobalState by default
* [bug] Only get key hash from storage
* [bug] Remove settings storage location overrides
* [bug] Only save accessToken to storage
* [refactor] Remove unecassary argements from electron crypto state calls
* [bug] Ensure keys and tokens load and save to the right locations for web
* [style] Fix lint complaints
* [bug] Remove keySuffix storage option and split uses into unique methods
The keySuffix options don't work with saving serialized json as a storage object - use cases simply overwrite each other in state.
This commit breaks Auto and Biometric keys into distinct storage items and adjusts logic accordingly.
* [bug] Add default vault timeouts to new accounts
* [bug] Save appId as a top level storage item
* [bug] Add missing await to timeout logic
* [bug] Adjust state scope for everBeenUnlocked
* [bug] Clear access tokens when loading account state from disk
* [bug] Adjust theme to be a global state item
* [bug] Adjust null checking for window in state
* [bug] Correct getGlobals not pulling from the stored state item
* [bug] Null check in memory account before claiming it has a userId
* [bug] Scaffold secure storage service when building storage objects on init
* [bug] Adjusted state scope of event collection
* [bug] Adjusted state scope of vault timeout and action
* [bug] Grab account from normal storage if secure storage is requested but does not exist
* [bug] Create a State if one is requested from memory before it exists
* [bug] Ensure all storage locations are cleared on state clean
* [style] Fix lint complaints
* [bug] Remove uneeded clearing of access token
* [bug] Reset tokens when toggling
* [refactor] Split up the Account model
Until this point the account model has been very flat, holding many kinds of data.
In order to be able to prune data at appropriate times, for example clearing keys at logout without clearing QoL settings like locale,
the Account model has been divided into logical chunks.
* [bug] Correct the serverUrl helpers return
* Fix sends always coming back as empty in browser
* Get settings properly (I think)
* [bug] Fix lint error
* [bug] Add missing await to identity token refresh
This was causing weird behavior in web that was creating a lot of 429s
* [bug] Scaffold memory storage for web
Not properly creating storage objects on signin was creating weird behavior when logging out, locking, and logging back in.
Namely, encrypted data that was recently synced had nowhere to save to and was lost.
* [bug] Implement better null handling in a few places for retrieving state
* [bug] Update correct storage locations on account removal
* [bug] Added missing awaits to lock component
* [bug] Reload lock component on account switching vs. account update
* [bug] Store master keys correctly
* [bug] Move some biometrics storage items to global state
* [feature] Add platform helper isMac()
* [refactor] Comment emphasis and call order refresh
* [refactor] Remove unecassary using
* [bug] Relocate authenticationStatus check logic to component
* [bug] Stop not clearing everything on state clean
* [style] Fix lint complaints
* [bug] Correct mismatched uses of encrypted and decrypted pin states
* Add browser specific state classes and methods
* lint fixes
* [bug] Migrate existing persistant data to new schema
* [style] Fix lint complaints
* [bug] Dont clear settings on state clean
* [bug] Maintain the right storage items on logout
* [chore] resolve issues from merge
* [bug] Resolve settings clearing on lock
* [chore] Added a comment
* [review] fromatting for code review
* Revert browser state items
Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-13 17:15:16 +01:00
|
|
|
await this.stateService.setKdfType(this.kdf);
|
2023-01-30 15:07:51 +01:00
|
|
|
await this.stateService.setKdfConfig(this.kdfConfig);
|
2021-09-03 21:49:03 +02:00
|
|
|
await this.cryptoService.setKey(key);
|
|
|
|
await this.cryptoService.setEncKey(encKey[1].encryptedString);
|
|
|
|
await this.cryptoService.setEncPrivateKey(keys[1].encryptedString);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-09-03 21:49:03 +02:00
|
|
|
const localKeyHash = await this.cryptoService.hashPassword(
|
|
|
|
this.masterPassword,
|
2021-12-16 13:36:21 +01:00
|
|
|
key,
|
2021-09-03 21:49:03 +02:00
|
|
|
HashPurpose.LocalAuthorization
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
2021-09-03 21:49:03 +02:00
|
|
|
await this.cryptoService.setKeyHash(localKeyHash);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-08-19 16:57:35 +02:00
|
|
|
}
|