2022-02-22 15:39:11 +01:00
|
|
|
import { ApiService } from "../abstractions/api.service";
|
|
|
|
import { CipherService as CipherServiceAbstraction } from "../abstractions/cipher.service";
|
|
|
|
import { CryptoService } from "../abstractions/crypto.service";
|
|
|
|
import { FileUploadService } from "../abstractions/fileUpload.service";
|
|
|
|
import { I18nService } from "../abstractions/i18n.service";
|
|
|
|
import { LogService } from "../abstractions/log.service";
|
|
|
|
import { SearchService } from "../abstractions/search.service";
|
|
|
|
import { SettingsService } from "../abstractions/settings.service";
|
|
|
|
import { StateService } from "../abstractions/state.service";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { CipherType } from "../enums/cipherType";
|
2018-07-27 22:44:20 +02:00
|
|
|
import { FieldType } from "../enums/fieldType";
|
2018-03-02 18:03:03 +01:00
|
|
|
import { UriMatchType } from "../enums/uriMatchType";
|
2022-02-22 15:39:11 +01:00
|
|
|
import { sequentialize } from "../misc/sequentialize";
|
|
|
|
import { Utils } from "../misc/utils";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { CipherData } from "../models/data/cipherData";
|
2018-06-12 17:45:02 +02:00
|
|
|
import { Attachment } from "../models/domain/attachment";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { Card } from "../models/domain/card";
|
|
|
|
import { Cipher } from "../models/domain/cipher";
|
2018-10-04 20:38:15 +02:00
|
|
|
import Domain from "../models/domain/domainBase";
|
2021-04-21 02:16:19 +02:00
|
|
|
import { EncArrayBuffer } from "../models/domain/encArrayBuffer";
|
|
|
|
import { EncString } from "../models/domain/encString";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { Field } from "../models/domain/field";
|
|
|
|
import { Identity } from "../models/domain/identity";
|
|
|
|
import { Login } from "../models/domain/login";
|
2018-03-02 05:44:29 +01:00
|
|
|
import { LoginUri } from "../models/domain/loginUri";
|
2018-07-27 22:44:20 +02:00
|
|
|
import { Password } from "../models/domain/password";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { SecureNote } from "../models/domain/secureNote";
|
2022-02-22 15:39:11 +01:00
|
|
|
import { SortedCiphersCache } from "../models/domain/sortedCiphersCache";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey";
|
2021-04-14 17:47:10 +02:00
|
|
|
import { AttachmentRequest } from "../models/request/attachmentRequest";
|
2018-06-12 23:12:27 +02:00
|
|
|
import { CipherBulkDeleteRequest } from "../models/request/cipherBulkDeleteRequest";
|
|
|
|
import { CipherBulkMoveRequest } from "../models/request/cipherBulkMoveRequest";
|
2020-04-03 22:32:15 +02:00
|
|
|
import { CipherBulkRestoreRequest } from "../models/request/cipherBulkRestoreRequest";
|
2018-06-13 06:02:15 +02:00
|
|
|
import { CipherBulkShareRequest } from "../models/request/cipherBulkShareRequest";
|
2018-06-12 19:07:06 +02:00
|
|
|
import { CipherCollectionsRequest } from "../models/request/cipherCollectionsRequest";
|
2018-10-19 15:14:11 +02:00
|
|
|
import { CipherCreateRequest } from "../models/request/cipherCreateRequest";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { CipherRequest } from "../models/request/cipherRequest";
|
2018-06-12 23:12:27 +02:00
|
|
|
import { CipherShareRequest } from "../models/request/cipherShareRequest";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { CipherResponse } from "../models/response/cipherResponse";
|
|
|
|
import { ErrorResponse } from "../models/response/errorResponse";
|
2018-06-12 17:45:02 +02:00
|
|
|
import { AttachmentView } from "../models/view/attachmentView";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { CipherView } from "../models/view/cipherView";
|
|
|
|
import { FieldView } from "../models/view/fieldView";
|
2018-07-27 22:44:20 +02:00
|
|
|
import { PasswordHistoryView } from "../models/view/passwordHistoryView";
|
2018-02-19 19:07:19 +01:00
|
|
|
import { View } from "../models/view/view";
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-12-07 21:41:43 +01:00
|
|
|
const DomainMatchBlacklist = new Map<string, Set<string>>([
|
|
|
|
["google.com", new Set(["script.google.com"])],
|
|
|
|
]);
|
|
|
|
|
2018-01-23 23:29:15 +01:00
|
|
|
export class CipherService implements CipherServiceAbstraction {
|
2020-08-12 21:59:59 +02:00
|
|
|
private sortedCiphersCache: SortedCiphersCache = new SortedCiphersCache(
|
|
|
|
this.sortCiphersByLastUsed
|
|
|
|
);
|
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(
|
|
|
|
private cryptoService: CryptoService,
|
|
|
|
private settingsService: SettingsService,
|
|
|
|
private apiService: ApiService,
|
|
|
|
private fileUploadService: FileUploadService,
|
2021-10-19 10:32:14 +02:00
|
|
|
private i18nService: I18nService,
|
|
|
|
private searchService: () => SearchService,
|
[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
|
|
|
private logService: LogService,
|
|
|
|
private stateService: StateService
|
|
|
|
) {}
|
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
|
|
|
async getDecryptedCipherCache(): Promise<CipherView[]> {
|
|
|
|
const decryptedCiphers = await this.stateService.getDecryptedCiphers();
|
|
|
|
return decryptedCiphers;
|
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
|
|
|
async setDecryptedCipherCache(value: CipherView[]) {
|
|
|
|
await this.stateService.setDecryptedCiphers(value);
|
2018-08-13 20:28:10 +02:00
|
|
|
if (this.searchService != null) {
|
|
|
|
if (value == null) {
|
|
|
|
this.searchService().clearIndex();
|
2021-12-16 13:36:21 +01:00
|
|
|
} else {
|
2018-08-13 20:28:10 +02:00
|
|
|
this.searchService().indexCiphers();
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-08-13 15:42:52 +02:00
|
|
|
}
|
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
|
|
|
async clearCache(userId?: string): Promise<void> {
|
|
|
|
await this.clearDecryptedCiphersState(userId);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-08-15 17:43:52 +02:00
|
|
|
async encrypt(
|
[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
|
|
|
model: CipherView,
|
|
|
|
key?: SymmetricCryptoKey,
|
|
|
|
originalCipher: Cipher = null
|
|
|
|
): Promise<Cipher> {
|
2018-07-27 22:44:20 +02:00
|
|
|
// Adjust password history
|
|
|
|
if (model.id != null) {
|
2018-08-15 17:43:52 +02:00
|
|
|
if (originalCipher == null) {
|
2018-08-13 20:28:10 +02:00
|
|
|
originalCipher = await this.get(model.id);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-08-13 20:28:10 +02:00
|
|
|
if (originalCipher != null) {
|
2018-08-15 17:43:52 +02:00
|
|
|
const existingCipher = await originalCipher.decrypt();
|
2018-07-27 22:44:20 +02:00
|
|
|
model.passwordHistory = existingCipher.passwordHistory || [];
|
2018-07-27 23:48:18 +02:00
|
|
|
if (model.type === CipherType.Login && existingCipher.type === CipherType.Login) {
|
2021-12-16 13:36:21 +01:00
|
|
|
if (
|
2018-07-30 22:40:16 +02:00
|
|
|
existingCipher.login.password != null &&
|
|
|
|
existingCipher.login.password !== "" &&
|
|
|
|
existingCipher.login.password !== model.login.password
|
2021-12-16 13:36:21 +01:00
|
|
|
) {
|
2018-07-27 23:48:18 +02:00
|
|
|
const ph = new PasswordHistoryView();
|
|
|
|
ph.password = existingCipher.login.password;
|
2018-08-13 20:28:10 +02:00
|
|
|
ph.lastUsedDate = model.login.passwordRevisionDate = new Date();
|
|
|
|
model.passwordHistory.splice(0, 0, ph);
|
|
|
|
} else {
|
2018-07-27 23:48:18 +02:00
|
|
|
model.login.passwordRevisionDate = existingCipher.login.passwordRevisionDate;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
}
|
2018-07-27 22:44:20 +02:00
|
|
|
if (existingCipher.hasFields) {
|
2021-02-04 16:49:23 +01:00
|
|
|
const existingHiddenFields = existingCipher.fields.filter(
|
2021-12-16 13:36:21 +01:00
|
|
|
(f) =>
|
2021-02-04 16:49:23 +01:00
|
|
|
f.type === FieldType.Hidden &&
|
|
|
|
f.name != null &&
|
|
|
|
f.name !== "" &&
|
2018-07-30 22:40:16 +02:00
|
|
|
f.value != null &&
|
|
|
|
f.value !== ""
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
2018-07-27 22:44:20 +02:00
|
|
|
const hiddenFields =
|
|
|
|
model.fields == null
|
2021-12-16 13:36:21 +01:00
|
|
|
? []
|
2021-02-04 16:49:23 +01:00
|
|
|
: model.fields.filter(
|
|
|
|
(f) => f.type === FieldType.Hidden && f.name != null && f.name !== ""
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
2018-08-13 20:28:10 +02:00
|
|
|
existingHiddenFields.forEach((ef) => {
|
2021-02-04 16:49:23 +01:00
|
|
|
const matchedField = hiddenFields.find((f) => f.name === ef.name);
|
2018-08-13 20:28:10 +02:00
|
|
|
if (matchedField == null || matchedField.value !== ef.value) {
|
|
|
|
const ph = new PasswordHistoryView();
|
|
|
|
ph.password = ef.name + ": " + ef.value;
|
|
|
|
ph.lastUsedDate = new Date();
|
|
|
|
model.passwordHistory.splice(0, 0, ph);
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
});
|
2018-08-13 15:42:52 +02:00
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-07-27 22:44:20 +02:00
|
|
|
if (model.passwordHistory != null && model.passwordHistory.length === 0) {
|
|
|
|
model.passwordHistory = null;
|
|
|
|
} else if (model.passwordHistory != null && model.passwordHistory.length > 5) {
|
|
|
|
// only save last 5 history
|
2018-07-27 23:30:51 +02:00
|
|
|
model.passwordHistory = model.passwordHistory.slice(0, 5);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +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
|
|
|
const cipher = new Cipher();
|
2018-01-10 05:01:16 +01:00
|
|
|
cipher.id = model.id;
|
[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
|
|
|
cipher.folderId = model.folderId;
|
|
|
|
cipher.favorite = model.favorite;
|
2018-01-10 05:01:16 +01:00
|
|
|
cipher.organizationId = model.organizationId;
|
|
|
|
cipher.type = model.type;
|
[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
|
|
|
cipher.collectionIds = model.collectionIds;
|
2020-11-23 15:48:40 +01:00
|
|
|
cipher.revisionDate = model.revisionDate;
|
2021-04-29 13:31:21 +02:00
|
|
|
cipher.reprompt = model.reprompt;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-07-17 23:22:45 +02:00
|
|
|
if (key == null && cipher.organizationId != null) {
|
[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
|
|
|
key = await this.cryptoService.getOrgKey(cipher.organizationId);
|
2018-09-10 14:22:10 +02:00
|
|
|
if (key == null) {
|
|
|
|
throw new Error("Cannot encrypt cipher for organization. No key.");
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
2018-08-15 17:43:52 +02:00
|
|
|
await Promise.all([
|
|
|
|
this.encryptObjProperty(
|
|
|
|
model,
|
|
|
|
cipher,
|
|
|
|
{
|
|
|
|
name: null,
|
2018-07-30 22:40:16 +02:00
|
|
|
notes: null,
|
2018-07-27 23:48:18 +02:00
|
|
|
},
|
2021-12-16 13:36:21 +01:00
|
|
|
key
|
2018-07-27 23:48:18 +02:00
|
|
|
),
|
|
|
|
this.encryptCipherData(cipher, model, key),
|
2021-02-04 16:49:23 +01:00
|
|
|
this.encryptFields(model.fields, key).then((fields) => {
|
|
|
|
cipher.fields = fields;
|
2018-07-27 22:44:20 +02:00
|
|
|
}),
|
|
|
|
this.encryptPasswordHistories(model.passwordHistory, key).then((ph) => {
|
|
|
|
cipher.passwordHistory = ph;
|
|
|
|
}),
|
|
|
|
this.encryptAttachments(model.attachments, key).then((attachments) => {
|
2018-01-10 05:01:16 +01:00
|
|
|
cipher.attachments = attachments;
|
2021-12-16 13:36:21 +01:00
|
|
|
}),
|
2020-11-23 15:48:40 +01:00
|
|
|
]);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-04-29 13:31:21 +02:00
|
|
|
return cipher;
|
2018-09-10 14:22:10 +02:00
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-02-04 16:49:23 +01:00
|
|
|
async encryptAttachments(
|
|
|
|
attachmentsModel: AttachmentView[],
|
|
|
|
key: SymmetricCryptoKey
|
|
|
|
): Promise<Attachment[]> {
|
|
|
|
if (attachmentsModel == null || attachmentsModel.length === 0) {
|
2018-01-10 05:01:16 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-06-12 17:45:02 +02:00
|
|
|
const promises: Promise<any>[] = [];
|
|
|
|
const encAttachments: Attachment[] = [];
|
|
|
|
attachmentsModel.forEach(async (model) => {
|
|
|
|
const attachment = new Attachment();
|
|
|
|
attachment.id = model.id;
|
|
|
|
attachment.size = model.size;
|
|
|
|
attachment.sizeName = model.sizeName;
|
|
|
|
attachment.url = model.url;
|
|
|
|
const promise = this.encryptObjProperty(
|
2021-12-16 13:36:21 +01:00
|
|
|
model,
|
2018-06-12 17:45:02 +02:00
|
|
|
attachment,
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2018-06-12 17:45:02 +02:00
|
|
|
fileName: null,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
key
|
2018-06-12 17:45:02 +02:00
|
|
|
).then(async () => {
|
2018-11-14 02:43:45 +01:00
|
|
|
if (model.key != null) {
|
2018-06-12 17:45:02 +02:00
|
|
|
attachment.key = await this.cryptoService.encrypt(model.key.key, key);
|
|
|
|
}
|
|
|
|
encAttachments.push(attachment);
|
|
|
|
});
|
|
|
|
promises.push(promise);
|
|
|
|
});
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-06-12 17:45:02 +02:00
|
|
|
await Promise.all(promises);
|
|
|
|
return encAttachments;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-24 17:33:15 +01:00
|
|
|
async encryptFields(fieldsModel: FieldView[], key: SymmetricCryptoKey): Promise<Field[]> {
|
2018-01-10 05:01:16 +01:00
|
|
|
if (!fieldsModel || !fieldsModel.length) {
|
2018-07-27 22:44:20 +02:00
|
|
|
return null;
|
2018-06-12 17:45:02 +02:00
|
|
|
}
|
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
const self = this;
|
2018-01-24 17:33:15 +01:00
|
|
|
const encFields: Field[] = [];
|
|
|
|
await fieldsModel.reduce(async (promise, field) => {
|
[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 promise;
|
|
|
|
const encField = await self.encryptField(field, key);
|
|
|
|
encFields.push(encField);
|
2018-07-27 22:44:20 +02:00
|
|
|
}, Promise.resolve());
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
return encFields;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-24 17:33:15 +01:00
|
|
|
async encryptField(fieldModel: FieldView, key: SymmetricCryptoKey): Promise<Field> {
|
2018-01-10 05:01:16 +01:00
|
|
|
const field = new Field();
|
|
|
|
field.type = fieldModel.type;
|
[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
|
|
|
field.linkedId = fieldModel.linkedId;
|
2018-12-13 16:58:48 +01:00
|
|
|
// normalize boolean type field values
|
[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
|
|
|
if (fieldModel.type === FieldType.Boolean && fieldModel.value !== "true") {
|
|
|
|
fieldModel.value = "false";
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
await this.encryptObjProperty(
|
|
|
|
fieldModel,
|
|
|
|
field,
|
|
|
|
{
|
|
|
|
name: null,
|
|
|
|
value: null,
|
|
|
|
},
|
|
|
|
key
|
|
|
|
);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
return field;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
async encryptPasswordHistories(
|
|
|
|
phModels: PasswordHistoryView[],
|
|
|
|
key: SymmetricCryptoKey
|
|
|
|
): Promise<Password[]> {
|
|
|
|
if (!phModels || !phModels.length) {
|
2018-01-10 05:01:16 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
const self = this;
|
|
|
|
const encPhs: Password[] = [];
|
[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 phModels.reduce(async (promise, ph) => {
|
|
|
|
await promise;
|
|
|
|
const encPh = await self.encryptPasswordHistory(ph, key);
|
|
|
|
encPhs.push(encPh);
|
2018-07-27 22:44:20 +02:00
|
|
|
}, Promise.resolve());
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
return encPhs;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
async encryptPasswordHistory(
|
|
|
|
phModel: PasswordHistoryView,
|
|
|
|
key: SymmetricCryptoKey
|
|
|
|
): Promise<Password> {
|
|
|
|
const ph = new Password();
|
|
|
|
ph.lastUsedDate = phModel.lastUsedDate;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
await this.encryptObjProperty(
|
2021-12-16 13:36:21 +01:00
|
|
|
phModel,
|
|
|
|
ph,
|
|
|
|
{
|
2018-07-27 22:44:20 +02:00
|
|
|
password: null,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
key
|
|
|
|
);
|
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
return ph;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
async get(id: string): Promise<Cipher> {
|
[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 ciphers = await this.stateService.getEncryptedCiphers();
|
2022-02-22 15:39:11 +01:00
|
|
|
// eslint-disable-next-line
|
2018-01-10 05:01:16 +01:00
|
|
|
if (ciphers == null || !ciphers.hasOwnProperty(id)) {
|
|
|
|
return null;
|
2018-07-27 22:44:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const localData = await this.stateService.getLocalData();
|
2022-04-16 17:00:48 +02:00
|
|
|
return new Cipher(ciphers[id], localData ? localData[id] : null);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
async getAll(): Promise<Cipher[]> {
|
[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 localData = await this.stateService.getLocalData();
|
2018-07-27 22:44:20 +02:00
|
|
|
const ciphers = await this.stateService.getEncryptedCiphers();
|
2018-01-10 05:01:16 +01:00
|
|
|
const response: Cipher[] = [];
|
2018-07-27 22:44:20 +02:00
|
|
|
for (const id in ciphers) {
|
2022-02-22 15:39:11 +01:00
|
|
|
// eslint-disable-next-line
|
2018-07-27 22:44:20 +02:00
|
|
|
if (ciphers.hasOwnProperty(id)) {
|
2022-04-16 17:00:48 +02:00
|
|
|
response.push(new Cipher(ciphers[id], localData ? localData[id] : null));
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
return response;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
@sequentialize(() => "getAllDecrypted")
|
|
|
|
async getAllDecrypted(): Promise<CipherView[]> {
|
|
|
|
const userId = await this.stateService.getUserId();
|
|
|
|
if ((await this.getDecryptedCipherCache()) != null) {
|
2021-12-16 13:36:21 +01:00
|
|
|
if (
|
2018-07-27 22:44:20 +02:00
|
|
|
this.searchService != null &&
|
2021-05-10 16:52:45 +02:00
|
|
|
(this.searchService().indexedEntityId ?? userId) !== userId
|
2021-12-16 13:36:21 +01:00
|
|
|
) {
|
2018-07-27 22:44:20 +02:00
|
|
|
await this.searchService().indexCiphers(userId, await this.getDecryptedCipherCache());
|
|
|
|
}
|
|
|
|
return await this.getDecryptedCipherCache();
|
|
|
|
}
|
|
|
|
|
[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 decCiphers: CipherView[] = [];
|
|
|
|
const hasKey = await this.cryptoService.hasKey();
|
2018-01-10 05:01:16 +01:00
|
|
|
if (!hasKey) {
|
|
|
|
throw new Error("No key.");
|
|
|
|
}
|
|
|
|
|
|
|
|
const promises: any[] = [];
|
[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 ciphers = await this.getAll();
|
|
|
|
ciphers.forEach(async (cipher) => {
|
2021-02-04 16:49:23 +01:00
|
|
|
promises.push(cipher.decrypt().then((c) => decCiphers.push(c)));
|
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 Promise.all(promises);
|
|
|
|
decCiphers.sort(this.getLocaleSortingFunction());
|
2022-01-20 22:25:04 +01:00
|
|
|
await this.setDecryptedCipherCache(decCiphers);
|
[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
|
|
|
return decCiphers;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2022-02-22 15:39:11 +01:00
|
|
|
async getAllDecryptedForGrouping(groupingId: string, folder = true): Promise<CipherView[]> {
|
2018-01-10 05:01:16 +01:00
|
|
|
const ciphers = await this.getAllDecrypted();
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
return ciphers.filter((cipher) => {
|
2020-04-10 22:42:34 +02:00
|
|
|
if (cipher.isDeleted) {
|
2018-01-10 05:01:16 +01:00
|
|
|
return false;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
if (folder && cipher.folderId === groupingId) {
|
2018-12-07 21:41:43 +01:00
|
|
|
return true;
|
2018-01-10 05:01:16 +01:00
|
|
|
} else if (
|
|
|
|
!folder &&
|
|
|
|
cipher.collectionIds != null &&
|
|
|
|
cipher.collectionIds.indexOf(groupingId) > -1
|
2021-12-16 13:36:21 +01:00
|
|
|
) {
|
2018-12-07 21:41:43 +01:00
|
|
|
return true;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
return false;
|
|
|
|
});
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
async getAllDecryptedForUrl(
|
|
|
|
url: string,
|
|
|
|
includeOtherTypes?: CipherType[],
|
|
|
|
defaultMatch: UriMatchType = null
|
|
|
|
): Promise<CipherView[]> {
|
|
|
|
if (url == null && includeOtherTypes == null) {
|
|
|
|
return Promise.resolve([]);
|
|
|
|
}
|
|
|
|
|
[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 domain = Utils.getDomain(url);
|
|
|
|
const eqDomainsPromise =
|
2021-05-10 16:52:45 +02:00
|
|
|
domain == null
|
|
|
|
? Promise.resolve([])
|
[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.settingsService.getEquivalentDomains().then((eqDomains: any[][]) => {
|
|
|
|
let matches: any[] = [];
|
|
|
|
eqDomains.forEach((eqDomain) => {
|
|
|
|
if (eqDomain.length && eqDomain.indexOf(domain) >= 0) {
|
|
|
|
matches = matches.concat(eqDomain);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
if (!matches.length) {
|
[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
|
|
|
matches.push(domain);
|
2021-04-22 21:53:45 +02:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
|
2018-01-24 17:33:15 +01:00
|
|
|
return matches;
|
2018-01-10 05:01:16 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const result = await Promise.all([eqDomainsPromise, this.getAllDecrypted()]);
|
|
|
|
const matchingDomains = result[0];
|
[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 ciphers = result[1];
|
2018-07-23 20:24:27 +02:00
|
|
|
|
|
|
|
if (defaultMatch == null) {
|
[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
|
|
|
defaultMatch = await this.stateService.getDefaultUriMatch();
|
|
|
|
if (defaultMatch == null) {
|
|
|
|
defaultMatch = UriMatchType.Domain;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
2021-02-04 16:49:23 +01:00
|
|
|
return ciphers.filter((cipher) => {
|
2020-04-10 22:42:34 +02:00
|
|
|
if (cipher.deletedDate != null) {
|
|
|
|
return false;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2019-04-16 03:15:35 +02:00
|
|
|
if (includeOtherTypes != null && includeOtherTypes.indexOf(cipher.type) > -1) {
|
2018-05-31 05:19:12 +02:00
|
|
|
return true;
|
2020-04-10 22:42:34 +02:00
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
if (url != null && cipher.type === CipherType.Login && cipher.login.uris != null) {
|
|
|
|
for (let i = 0; i < cipher.login.uris.length; i++) {
|
2018-03-02 18:03:03 +01:00
|
|
|
const u = cipher.login.uris[i];
|
|
|
|
if (u.uri == null) {
|
|
|
|
continue;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
const match = u.match == null ? defaultMatch : u.match;
|
2019-01-09 17:59:11 +01:00
|
|
|
switch (match) {
|
2018-03-02 19:50:26 +01:00
|
|
|
case UriMatchType.Domain:
|
2018-01-10 05:01:16 +01:00
|
|
|
if (domain != null && u.domain != null && matchingDomains.indexOf(u.domain) > -1) {
|
2018-12-07 21:41:43 +01:00
|
|
|
if (DomainMatchBlacklist.has(u.domain)) {
|
|
|
|
const domainUrlHost = Utils.getHost(url);
|
|
|
|
if (!DomainMatchBlacklist.get(u.domain).has(domainUrlHost)) {
|
2018-05-31 05:19:12 +02:00
|
|
|
return true;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
} else {
|
2018-05-31 05:19:12 +02:00
|
|
|
return true;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2022-02-22 15:39:11 +01:00
|
|
|
case UriMatchType.Host: {
|
2018-04-23 19:03:47 +02:00
|
|
|
const urlHost = Utils.getHost(url);
|
|
|
|
if (urlHost != null && urlHost === Utils.getHost(u.uri)) {
|
2018-01-24 17:33:15 +01:00
|
|
|
return true;
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
break;
|
2022-02-22 15:39:11 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
case UriMatchType.Exact:
|
|
|
|
if (url === u.uri) {
|
2018-01-24 17:33:15 +01:00
|
|
|
return true;
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
2021-02-04 16:49:23 +01:00
|
|
|
break;
|
[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
|
|
|
case UriMatchType.StartsWith:
|
2019-04-16 03:15:35 +02:00
|
|
|
if (url.startsWith(u.uri)) {
|
2018-03-02 18:03:03 +01:00
|
|
|
return true;
|
|
|
|
}
|
2019-01-09 17:59:11 +01:00
|
|
|
break;
|
2018-03-02 19:50:26 +01:00
|
|
|
case UriMatchType.RegularExpression:
|
2018-03-02 18:03:03 +01:00
|
|
|
try {
|
2018-05-31 05:19:12 +02:00
|
|
|
const regex = new RegExp(u.uri, "i");
|
|
|
|
if (regex.test(url)) {
|
|
|
|
return true;
|
2018-03-02 18:03:03 +01:00
|
|
|
}
|
2018-12-14 19:55:44 +01:00
|
|
|
} catch (e) {
|
|
|
|
this.logService.error(e);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2021-02-04 16:49:23 +01:00
|
|
|
break;
|
|
|
|
case UriMatchType.Never:
|
|
|
|
default:
|
2018-12-14 19:55:44 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-24 17:33:15 +01:00
|
|
|
return false;
|
2021-12-16 13:36:21 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-14 19:55:44 +01:00
|
|
|
async getAllFromApiForOrganization(organizationId: string): Promise<CipherView[]> {
|
|
|
|
const ciphers = await this.apiService.getCiphersOrganization(organizationId);
|
|
|
|
if (ciphers != null && ciphers.data != null && ciphers.data.length) {
|
|
|
|
const decCiphers: CipherView[] = [];
|
|
|
|
const promises: any[] = [];
|
2021-02-04 16:49:23 +01:00
|
|
|
ciphers.data.forEach((r) => {
|
2018-12-14 19:55:44 +01:00
|
|
|
const data = new CipherData(r);
|
|
|
|
const cipher = new Cipher(data);
|
2021-02-04 16:49:23 +01:00
|
|
|
promises.push(cipher.decrypt().then((c) => decCiphers.push(c)));
|
2021-12-16 13:36:21 +01:00
|
|
|
});
|
2018-12-14 19:55:44 +01:00
|
|
|
await Promise.all(promises);
|
|
|
|
decCiphers.sort(this.getLocaleSortingFunction());
|
|
|
|
return decCiphers;
|
2021-12-16 13:36:21 +01:00
|
|
|
} else {
|
2018-12-14 19:55:44 +01:00
|
|
|
return [];
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2022-02-22 15:39:11 +01:00
|
|
|
async getLastUsedForUrl(url: string, autofillOnPageLoad = false): Promise<CipherView> {
|
2021-05-18 02:08:28 +02:00
|
|
|
return this.getCipherForUrl(url, true, false, autofillOnPageLoad);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2022-02-22 15:39:11 +01:00
|
|
|
async getLastLaunchedForUrl(url: string, autofillOnPageLoad = false): Promise<CipherView> {
|
2021-05-18 02:08:28 +02:00
|
|
|
return this.getCipherForUrl(url, false, true, autofillOnPageLoad);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-08-12 21:59:59 +02:00
|
|
|
async getNextCipherForUrl(url: string): Promise<CipherView> {
|
2021-05-18 02:08:28 +02:00
|
|
|
return this.getCipherForUrl(url, false, false, false);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-10-09 13:30:55 +02:00
|
|
|
updateLastUsedIndexForUrl(url: string) {
|
|
|
|
this.sortedCiphersCache.updateLastUsedIndex(url);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
async updateLastUsedDate(id: string): Promise<void> {
|
[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
|
|
|
let ciphersLocalData = await this.stateService.getLocalData();
|
2020-09-23 18:41:25 +02:00
|
|
|
if (!ciphersLocalData) {
|
|
|
|
ciphersLocalData = {};
|
|
|
|
}
|
|
|
|
|
2021-05-18 02:08:28 +02:00
|
|
|
if (ciphersLocalData[id]) {
|
|
|
|
ciphersLocalData[id].lastUsedDate = new Date().getTime();
|
|
|
|
} else {
|
|
|
|
ciphersLocalData[id] = {
|
|
|
|
lastUsedDate: new Date().getTime(),
|
|
|
|
};
|
2020-08-12 21:59:59 +02:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
|
2021-05-18 02:08:28 +02:00
|
|
|
await this.stateService.setLocalData(ciphersLocalData);
|
2018-01-10 05:01:16 +01:00
|
|
|
|
2020-10-09 13:30:55 +02:00
|
|
|
const decryptedCipherCache = await this.stateService.getDecryptedCiphers();
|
[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
|
|
|
if (!decryptedCipherCache) {
|
2020-10-09 13:30:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[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
|
|
|
for (let i = 0; i < decryptedCipherCache.length; i++) {
|
|
|
|
const cached = decryptedCipherCache[i];
|
|
|
|
if (cached.id === id) {
|
2018-01-10 05:01:16 +01:00
|
|
|
cached.localData = ciphersLocalData[id];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
[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.setDecryptedCiphers(decryptedCipherCache);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
|
2020-09-23 18:41:25 +02:00
|
|
|
async updateLastLaunchedDate(id: string): Promise<void> {
|
[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
|
|
|
let ciphersLocalData = await this.stateService.getLocalData();
|
2020-09-23 18:41:25 +02:00
|
|
|
if (!ciphersLocalData) {
|
|
|
|
ciphersLocalData = {};
|
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
if (ciphersLocalData[id]) {
|
[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
|
|
|
ciphersLocalData[id].lastLaunched = new Date().getTime();
|
2018-01-10 05:01:16 +01:00
|
|
|
} else {
|
|
|
|
ciphersLocalData[id] = {
|
[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
|
|
|
lastUsedDate: new Date().getTime(),
|
|
|
|
};
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
2018-10-19 15:14:11 +02:00
|
|
|
await this.stateService.setLocalData(ciphersLocalData);
|
2018-01-10 05:01:16 +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
|
|
|
const decryptedCipherCache = await this.stateService.getDecryptedCiphers();
|
|
|
|
if (!decryptedCipherCache) {
|
|
|
|
return;
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
2018-10-24 04:10:08 +02:00
|
|
|
for (let i = 0; i < decryptedCipherCache.length; i++) {
|
2018-06-13 06:02:15 +02:00
|
|
|
const cached = decryptedCipherCache[i];
|
2018-10-23 22:16:59 +02:00
|
|
|
if (cached.id === id) {
|
[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
|
|
|
cached.localData = ciphersLocalData[id];
|
|
|
|
break;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-06-13 06:02:15 +02: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.setDecryptedCiphers(decryptedCipherCache);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-06-13 06:02:15 +02:00
|
|
|
|
|
|
|
async saveNeverDomain(domain: string): Promise<void> {
|
|
|
|
if (domain == null) {
|
|
|
|
return;
|
2018-06-12 17:45:02 +02:00
|
|
|
}
|
|
|
|
|
2018-05-17 21:35:02 +02:00
|
|
|
let domains = await this.stateService.getNeverDomains();
|
2018-01-10 05:01:16 +01:00
|
|
|
if (!domains) {
|
[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
|
|
|
domains = {};
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
domains[domain] = null;
|
2018-07-05 16:48:19 +02:00
|
|
|
await this.stateService.setNeverDomains(domains);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-07-05 16:48:19 +02:00
|
|
|
async saveWithServer(cipher: Cipher): Promise<any> {
|
2021-03-26 22:57:07 +01:00
|
|
|
let response: CipherResponse;
|
|
|
|
if (cipher.id == null) {
|
2018-10-19 17:20:04 +02:00
|
|
|
if (cipher.collectionIds != null) {
|
2021-03-26 22:57:07 +01:00
|
|
|
const request = new CipherCreateRequest(cipher);
|
|
|
|
response = await this.apiService.postCipherCreate(request);
|
|
|
|
} else {
|
|
|
|
const request = new CipherRequest(cipher);
|
|
|
|
response = await this.apiService.postCipher(request);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2021-03-26 22:57:07 +01:00
|
|
|
cipher.id = response.id;
|
|
|
|
} else {
|
|
|
|
const request = new CipherRequest(cipher);
|
[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
|
|
|
response = await this.apiService.putCipher(cipher.id, request);
|
2021-03-26 22:57:07 +01:00
|
|
|
}
|
|
|
|
|
2022-04-20 15:59:51 +02:00
|
|
|
const data = new CipherData(response, cipher.collectionIds);
|
2021-03-26 22:57:07 +01:00
|
|
|
await this.upsert(data);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2021-04-21 02:16:19 +02:00
|
|
|
async shareWithServer(
|
|
|
|
cipher: CipherView,
|
|
|
|
organizationId: string,
|
|
|
|
collectionIds: string[]
|
|
|
|
): Promise<any> {
|
2021-04-14 17:47:10 +02:00
|
|
|
const attachmentPromises: Promise<any>[] = [];
|
2018-05-31 15:07:56 +02:00
|
|
|
if (cipher.attachments != null) {
|
2021-04-14 17:47:10 +02:00
|
|
|
cipher.attachments.forEach((attachment) => {
|
2018-05-25 14:39:48 +02:00
|
|
|
if (attachment.key == null) {
|
|
|
|
attachmentPromises.push(
|
2018-05-17 21:35:02 +02:00
|
|
|
this.shareAttachmentWithServer(attachment, cipher.id, organizationId)
|
|
|
|
);
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
});
|
|
|
|
}
|
2018-10-24 04:10:08 +02:00
|
|
|
await Promise.all(attachmentPromises);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-06-13 06:02:15 +02:00
|
|
|
cipher.organizationId = organizationId;
|
2018-05-17 21:35:02 +02:00
|
|
|
cipher.collectionIds = collectionIds;
|
[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 encCipher = await this.encrypt(cipher);
|
2018-06-13 06:02:15 +02:00
|
|
|
const request = new CipherShareRequest(encCipher);
|
2018-05-17 21:35:02 +02:00
|
|
|
const response = await this.apiService.putShareCipher(cipher.id, request);
|
2022-04-20 15:59:51 +02:00
|
|
|
const data = new CipherData(response, collectionIds);
|
2018-06-12 19:07:06 +02:00
|
|
|
await this.upsert(data);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-06-13 06:02:15 +02:00
|
|
|
async shareManyWithServer(
|
|
|
|
ciphers: CipherView[],
|
|
|
|
organizationId: string,
|
|
|
|
collectionIds: string[]
|
2018-06-12 19:07:06 +02:00
|
|
|
): Promise<any> {
|
2020-08-12 21:42:42 +02:00
|
|
|
const promises: Promise<any>[] = [];
|
2018-06-13 06:02:15 +02:00
|
|
|
const encCiphers: Cipher[] = [];
|
|
|
|
for (const cipher of ciphers) {
|
|
|
|
cipher.organizationId = organizationId;
|
|
|
|
cipher.collectionIds = collectionIds;
|
2021-02-04 16:49:23 +01:00
|
|
|
promises.push(
|
|
|
|
this.encrypt(cipher).then((c) => {
|
2018-06-13 06:02:15 +02:00
|
|
|
encCiphers.push(c);
|
2021-12-16 13:36:21 +01:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2018-06-13 06:02:15 +02:00
|
|
|
await Promise.all(promises);
|
|
|
|
const request = new CipherBulkShareRequest(encCiphers, collectionIds);
|
2022-03-02 14:11:34 +01:00
|
|
|
try {
|
|
|
|
await this.apiService.putShareCiphers(request);
|
|
|
|
} catch (e) {
|
|
|
|
for (const cipher of ciphers) {
|
|
|
|
cipher.organizationId = null;
|
|
|
|
cipher.collectionIds = null;
|
|
|
|
}
|
|
|
|
throw e;
|
|
|
|
}
|
2022-04-20 15:59:51 +02:00
|
|
|
await this.upsert(encCiphers.map((c) => c.toCipherData()));
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-05-17 21:35:02 +02:00
|
|
|
saveAttachmentWithServer(cipher: Cipher, unencryptedFile: any, admin = false): Promise<Cipher> {
|
2018-01-10 05:01:16 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const reader = new FileReader();
|
2018-05-17 21:35:02 +02:00
|
|
|
reader.readAsArrayBuffer(unencryptedFile);
|
2018-01-10 05:01:16 +01:00
|
|
|
reader.onload = async (evt: any) => {
|
2018-05-17 21:35:02 +02:00
|
|
|
try {
|
2021-03-26 22:57:07 +01:00
|
|
|
const cData = await this.saveAttachmentRawWithServer(
|
|
|
|
cipher,
|
|
|
|
unencryptedFile.name,
|
|
|
|
evt.target.result,
|
|
|
|
admin
|
|
|
|
);
|
|
|
|
resolve(cData);
|
2018-05-17 21:35:02 +02:00
|
|
|
} catch (e) {
|
|
|
|
reject(e);
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
};
|
2022-02-22 15:39:11 +01:00
|
|
|
reader.onerror = () => {
|
2018-01-10 05:01:16 +01:00
|
|
|
reject("Error reading file.");
|
2021-12-16 13:36:21 +01:00
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
async saveAttachmentRawWithServer(
|
2018-01-24 17:33:15 +01:00
|
|
|
cipher: Cipher,
|
2021-03-26 22:57:07 +01:00
|
|
|
filename: string,
|
2018-07-05 16:48:19 +02:00
|
|
|
data: ArrayBuffer,
|
|
|
|
admin = false
|
|
|
|
): Promise<Cipher> {
|
2018-05-17 21:35:02 +02:00
|
|
|
const key = await this.cryptoService.getOrgKey(cipher.organizationId);
|
|
|
|
const encFileName = await this.cryptoService.encrypt(filename, key);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-11-14 02:43:45 +01:00
|
|
|
const dataEncKey = await this.cryptoService.makeEncKey(key);
|
|
|
|
const encData = await this.cryptoService.encryptToBytes(data, dataEncKey[0]);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-03-26 22:57:07 +01:00
|
|
|
const request: AttachmentRequest = {
|
|
|
|
key: dataEncKey[1].encryptedString,
|
|
|
|
fileName: encFileName.encryptedString,
|
2021-04-14 17:47:10 +02:00
|
|
|
fileSize: encData.buffer.byteLength,
|
2021-03-26 22:57:07 +01:00
|
|
|
adminRequest: admin,
|
2021-12-16 13:36:21 +01:00
|
|
|
};
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
let response: CipherResponse;
|
2021-12-16 13:36:21 +01:00
|
|
|
try {
|
2021-01-08 15:53:41 +01:00
|
|
|
const uploadDataResponse = await this.apiService.postCipherAttachment(cipher.id, request);
|
2021-03-26 22:57:07 +01:00
|
|
|
response = admin ? uploadDataResponse.cipherMiniResponse : uploadDataResponse.cipherResponse;
|
2021-06-08 21:02:08 +02:00
|
|
|
await this.fileUploadService.uploadCipherAttachment(
|
2021-12-16 13:36:21 +01:00
|
|
|
admin,
|
2021-06-08 21:02:08 +02:00
|
|
|
uploadDataResponse,
|
2021-03-26 22:57:07 +01:00
|
|
|
encFileName,
|
2021-12-16 13:36:21 +01:00
|
|
|
encData
|
|
|
|
);
|
2018-05-17 21:35:02 +02:00
|
|
|
} catch (e) {
|
2021-12-16 13:36:21 +01:00
|
|
|
if (
|
2021-03-26 22:57:07 +01:00
|
|
|
(e instanceof ErrorResponse && (e as ErrorResponse).statusCode === 404) ||
|
|
|
|
(e as ErrorResponse).statusCode === 405
|
2021-12-16 13:36:21 +01:00
|
|
|
) {
|
2021-06-08 21:02:08 +02:00
|
|
|
response = await this.legacyServerAttachmentFileUpload(
|
2021-12-16 13:36:21 +01:00
|
|
|
admin,
|
2018-11-15 14:55:29 +01:00
|
|
|
cipher.id,
|
2021-03-26 22:57:07 +01:00
|
|
|
encFileName,
|
2021-12-16 13:36:21 +01:00
|
|
|
encData,
|
2021-03-26 22:57:07 +01:00
|
|
|
dataEncKey[1]
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
2021-03-26 22:57:07 +01:00
|
|
|
} else if (e instanceof ErrorResponse) {
|
2018-10-24 04:10:08 +02:00
|
|
|
throw new Error((e as ErrorResponse).getSingleMessage());
|
2021-12-16 13:36:21 +01:00
|
|
|
} else {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
2018-05-17 21:35:02 +02:00
|
|
|
|
2022-04-20 15:59:51 +02:00
|
|
|
const cData = new CipherData(response, cipher.collectionIds);
|
2021-03-26 22:57:07 +01:00
|
|
|
if (!admin) {
|
|
|
|
await this.upsert(cData);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2021-03-26 22:57:07 +01:00
|
|
|
return new Cipher(cData);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-26 22:57:07 +01:00
|
|
|
* @deprecated Mar 25 2021: This method has been deprecated in favor of direct uploads.
|
|
|
|
* This method still exists for backward compatibility with old server versions.
|
2021-12-16 13:36:21 +01:00
|
|
|
*/
|
2021-03-26 22:57:07 +01:00
|
|
|
async legacyServerAttachmentFileUpload(
|
2021-05-18 02:08:28 +02:00
|
|
|
admin: boolean,
|
2021-01-08 15:53:41 +01:00
|
|
|
cipherId: string,
|
2021-03-26 22:57:07 +01:00
|
|
|
encFileName: EncString,
|
2021-04-21 02:16:19 +02:00
|
|
|
encData: EncArrayBuffer,
|
|
|
|
key: EncString
|
2021-12-16 13:36:21 +01:00
|
|
|
) {
|
2018-05-17 21:35:02 +02:00
|
|
|
const fd = new FormData();
|
2021-12-16 13:36:21 +01:00
|
|
|
try {
|
2021-04-14 17:47:10 +02:00
|
|
|
const blob = new Blob([encData.buffer], { type: "application/octet-stream" });
|
2021-03-26 22:57:07 +01:00
|
|
|
fd.append("key", key.encryptedString);
|
2018-05-17 21:35:02 +02:00
|
|
|
fd.append("data", blob, encFileName.encryptedString);
|
2018-01-10 05:01:16 +01:00
|
|
|
} catch (e) {
|
2018-10-24 04:10:08 +02:00
|
|
|
if (Utils.isNode && !Utils.isBrowser) {
|
2021-03-26 22:57:07 +01:00
|
|
|
fd.append("key", key.encryptedString);
|
|
|
|
fd.append(
|
2021-12-16 13:36:21 +01:00
|
|
|
"data",
|
2021-04-14 17:47:10 +02:00
|
|
|
Buffer.from(encData.buffer) as any,
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2018-10-24 04:10:08 +02:00
|
|
|
filepath: encFileName.encryptedString,
|
|
|
|
contentType: "application/octet-stream",
|
2021-12-16 13:36:21 +01:00
|
|
|
} as any
|
|
|
|
);
|
|
|
|
} else {
|
2021-03-26 22:57:07 +01:00
|
|
|
throw e;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-05-17 21:35:02 +02:00
|
|
|
}
|
|
|
|
|
2018-06-12 19:07:06 +02:00
|
|
|
let response: CipherResponse;
|
2021-12-16 13:36:21 +01:00
|
|
|
try {
|
2018-06-12 19:07:06 +02:00
|
|
|
if (admin) {
|
|
|
|
response = await this.apiService.postCipherAttachmentAdminLegacy(cipherId, fd);
|
2021-12-16 13:36:21 +01:00
|
|
|
} else {
|
2018-07-05 16:48:19 +02:00
|
|
|
response = await this.apiService.postCipherAttachmentLegacy(cipherId, fd);
|
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
|
|
|
} catch (e) {
|
|
|
|
throw new Error((e as ErrorResponse).getSingleMessage());
|
2018-06-12 19:07:06 +02: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
|
|
|
return response;
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async saveCollectionsWithServer(cipher: Cipher): Promise<any> {
|
|
|
|
const request = new CipherCollectionsRequest(cipher.collectionIds);
|
|
|
|
await this.apiService.putCipherCollections(cipher.id, request);
|
2022-04-20 15:59:51 +02:00
|
|
|
const data = cipher.toCipherData();
|
2021-02-04 16:49:23 +01:00
|
|
|
await this.upsert(data);
|
2018-01-10 05:01:16 +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
|
|
|
async upsert(cipher: CipherData | CipherData[]): Promise<any> {
|
|
|
|
let ciphers = await this.stateService.getEncryptedCiphers();
|
2018-01-10 05:01:16 +01:00
|
|
|
if (ciphers == null) {
|
2018-06-12 23:12:27 +02:00
|
|
|
ciphers = {};
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher instanceof CipherData) {
|
|
|
|
const c = cipher as CipherData;
|
|
|
|
ciphers[c.id] = c;
|
|
|
|
} else {
|
|
|
|
(cipher as CipherData[]).forEach((c) => {
|
[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
|
|
|
ciphers[c.id] = c;
|
|
|
|
});
|
2018-01-10 05:01:16 +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.replace(ciphers);
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
2018-06-12 23:12:27 +02:00
|
|
|
async replace(ciphers: { [id: string]: CipherData }): Promise<any> {
|
|
|
|
await this.clearDecryptedCiphersState();
|
|
|
|
await this.stateService.setEncryptedCiphers(ciphers);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-06-12 23:12:27 +02: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
|
|
|
async clear(userId?: string): Promise<any> {
|
|
|
|
await this.clearEncryptedCiphersState(userId);
|
2018-06-12 23:12:27 +02:00
|
|
|
await this.clearCache(userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
async moveManyWithServer(ids: string[], folderId: string): Promise<any> {
|
|
|
|
await this.apiService.putMoveCiphers(new CipherBulkMoveRequest(ids, folderId));
|
|
|
|
|
[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
|
|
|
let ciphers = await this.stateService.getEncryptedCiphers();
|
|
|
|
if (ciphers == null) {
|
2018-01-10 05:01:16 +01:00
|
|
|
ciphers = {};
|
2018-06-12 23:12:27 +02:00
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
ids.forEach((id) => {
|
2022-02-22 15:39:11 +01:00
|
|
|
// eslint-disable-next-line
|
2018-01-10 05:01:16 +01:00
|
|
|
if (ciphers.hasOwnProperty(id)) {
|
|
|
|
ciphers[id].folderId = folderId;
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
});
|
2018-01-10 05:01:16 +01:00
|
|
|
|
2018-08-20 22:01:26 +02:00
|
|
|
await this.clearCache();
|
2018-01-10 05:01:16 +01:00
|
|
|
await this.stateService.setEncryptedCiphers(ciphers);
|
|
|
|
}
|
|
|
|
|
[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
|
|
|
async delete(id: string | string[]): Promise<any> {
|
|
|
|
const ciphers = await this.stateService.getEncryptedCiphers();
|
|
|
|
if (ciphers == null) {
|
2021-12-16 13:36:21 +01:00
|
|
|
return;
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
2020-04-03 22:32:15 +02:00
|
|
|
if (typeof id === "string") {
|
2018-01-10 05:01:16 +01:00
|
|
|
if (ciphers[id] == null) {
|
2021-12-16 13:36:21 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
delete ciphers[id];
|
|
|
|
} else {
|
|
|
|
(id as string[]).forEach((i) => {
|
|
|
|
delete ciphers[i];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-12 23:12:27 +02:00
|
|
|
await this.clearCache();
|
|
|
|
await this.stateService.setEncryptedCiphers(ciphers);
|
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
async deleteWithServer(id: string): Promise<any> {
|
[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.apiService.deleteCipher(id);
|
|
|
|
await this.delete(id);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
|
|
|
|
async deleteManyWithServer(ids: string[]): Promise<any> {
|
|
|
|
await this.apiService.deleteManyCiphers(new CipherBulkDeleteRequest(ids));
|
|
|
|
await this.delete(ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
async deleteAttachment(id: string, attachmentId: string): Promise<void> {
|
|
|
|
const ciphers = await this.stateService.getEncryptedCiphers();
|
|
|
|
|
2022-02-22 15:39:11 +01:00
|
|
|
// eslint-disable-next-line
|
[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
|
|
|
if (ciphers == null || !ciphers.hasOwnProperty(id) || ciphers[id].attachments == null) {
|
|
|
|
return;
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < ciphers[id].attachments.length; i++) {
|
|
|
|
if (ciphers[id].attachments[i].id === attachmentId) {
|
|
|
|
ciphers[id].attachments.splice(i, 1);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
|
|
|
|
2018-01-27 04:54:02 +01:00
|
|
|
await this.clearCache();
|
|
|
|
await this.stateService.setEncryptedCiphers(ciphers);
|
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
async deleteAttachmentWithServer(id: string, attachmentId: string): Promise<void> {
|
2021-12-16 13:36:21 +01:00
|
|
|
try {
|
2018-10-24 04:10:08 +02:00
|
|
|
await this.apiService.deleteCipherAttachment(id, attachmentId);
|
|
|
|
} catch (e) {
|
2018-01-27 04:54:02 +01:00
|
|
|
return Promise.reject((e as ErrorResponse).getSingleMessage());
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
2018-01-27 04:54:02 +01:00
|
|
|
await this.deleteAttachment(id, attachmentId);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-27 04:54:02 +01:00
|
|
|
sortCiphersByLastUsed(a: CipherView, b: CipherView): number {
|
|
|
|
const aLastUsed =
|
|
|
|
a.localData && a.localData.lastUsedDate ? (a.localData.lastUsedDate as number) : null;
|
2019-04-17 05:32:02 +02:00
|
|
|
const bLastUsed =
|
2018-01-27 04:54:02 +01:00
|
|
|
b.localData && b.localData.lastUsedDate ? (b.localData.lastUsedDate as number) : null;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-01-27 04:54:02 +01:00
|
|
|
const bothNotNull = aLastUsed != null && bLastUsed != null;
|
|
|
|
if (bothNotNull && aLastUsed < bLastUsed) {
|
|
|
|
return 1;
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
2018-03-20 00:42:38 +01:00
|
|
|
if (aLastUsed != null && bLastUsed == null) {
|
2018-01-27 04:54:02 +01:00
|
|
|
return -1;
|
2018-01-27 04:16:35 +01:00
|
|
|
}
|
|
|
|
|
2020-04-03 22:32:15 +02:00
|
|
|
if (bothNotNull && aLastUsed > bLastUsed) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (bLastUsed != null && aLastUsed == null) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[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
|
|
|
sortCiphersByLastUsedThenName(a: CipherView, b: CipherView): number {
|
|
|
|
const result = this.sortCiphersByLastUsed(a, b);
|
2018-01-27 04:54:02 +01:00
|
|
|
if (result !== 0) {
|
[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
|
|
|
return result;
|
2020-04-03 22:32:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.getLocaleSortingFunction()(a, b);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-04-03 22:32:15 +02:00
|
|
|
getLocaleSortingFunction(): (a: CipherView, b: CipherView) => number {
|
2018-01-27 04:16:35 +01:00
|
|
|
return (a, b) => {
|
2018-01-27 04:54:02 +01:00
|
|
|
let aName = a.name;
|
|
|
|
let bName = b.name;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-03-20 00:42:38 +01:00
|
|
|
if (aName == null && bName != null) {
|
|
|
|
return -1;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-03-20 00:42:38 +01:00
|
|
|
if (aName != null && bName == null) {
|
|
|
|
return 1;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-03-20 00:42:38 +01:00
|
|
|
if (aName == null && bName == null) {
|
|
|
|
return 0;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-04-03 22:32:15 +02:00
|
|
|
const result = this.i18nService.collator
|
2018-01-27 04:54:02 +01:00
|
|
|
? this.i18nService.collator.compare(aName, bName)
|
|
|
|
: aName.localeCompare(bName);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-01-27 04:54:02 +01:00
|
|
|
if (result !== 0 || a.type !== CipherType.Login || b.type !== CipherType.Login) {
|
|
|
|
return result;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-27 04:54:02 +01:00
|
|
|
if (a.login.username != null) {
|
|
|
|
aName += a.login.username;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-27 04:54:02 +01:00
|
|
|
if (b.login.username != null) {
|
|
|
|
bName += b.login.username;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-27 04:54:02 +01:00
|
|
|
return this.i18nService.collator
|
|
|
|
? this.i18nService.collator.compare(aName, bName)
|
|
|
|
: aName.localeCompare(bName);
|
2021-12-16 13:36:21 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-03 22:32:15 +02:00
|
|
|
async softDelete(id: string | string[]): Promise<any> {
|
|
|
|
const ciphers = await this.stateService.getEncryptedCiphers();
|
|
|
|
if (ciphers == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const setDeletedDate = (cipherId: string) => {
|
|
|
|
if (ciphers[cipherId] == null) {
|
|
|
|
return;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-04-03 22:32:15 +02:00
|
|
|
ciphers[cipherId].deletedDate = new Date().toISOString();
|
2021-12-16 13:36:21 +01:00
|
|
|
};
|
|
|
|
|
2020-04-03 22:32:15 +02:00
|
|
|
if (typeof id === "string") {
|
|
|
|
setDeletedDate(id);
|
2021-12-16 13:36:21 +01:00
|
|
|
} else {
|
2020-04-03 22:32:15 +02:00
|
|
|
(id as string[]).forEach(setDeletedDate);
|
|
|
|
}
|
|
|
|
|
[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.clearCache();
|
2021-01-08 15:53:41 +01:00
|
|
|
await this.stateService.setEncryptedCiphers(ciphers);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-04-03 22:32:15 +02:00
|
|
|
async softDeleteWithServer(id: string): Promise<any> {
|
2021-01-08 15:53:41 +01:00
|
|
|
await this.apiService.putDeleteCipher(id);
|
2020-04-03 22:32:15 +02:00
|
|
|
await this.softDelete(id);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2021-01-08 15:53:41 +01:00
|
|
|
async softDeleteManyWithServer(ids: string[]): Promise<any> {
|
|
|
|
await this.apiService.putDeleteManyCiphers(new CipherBulkDeleteRequest(ids));
|
2020-04-03 22:32:15 +02:00
|
|
|
await this.softDelete(ids);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2021-01-08 15:53:41 +01:00
|
|
|
async restore(
|
|
|
|
cipher: { id: string; revisionDate: string } | { id: string; revisionDate: string }[]
|
|
|
|
) {
|
[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 ciphers = await this.stateService.getEncryptedCiphers();
|
2020-04-03 22:32:15 +02:00
|
|
|
if (ciphers == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-08 15:53:41 +01:00
|
|
|
const clearDeletedDate = (c: { id: string; revisionDate: string }) => {
|
|
|
|
if (ciphers[c.id] == null) {
|
2020-04-03 22:32:15 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-01-08 15:53:41 +01:00
|
|
|
ciphers[c.id].deletedDate = null;
|
|
|
|
ciphers[c.id].revisionDate = c.revisionDate;
|
2020-04-03 22:32:15 +02:00
|
|
|
};
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2022-03-15 02:12:31 +01:00
|
|
|
if (cipher.constructor.name === Array.name) {
|
2021-01-08 15:53:41 +01:00
|
|
|
(cipher as { id: string; revisionDate: string }[]).forEach(clearDeletedDate);
|
2021-12-16 13:36:21 +01:00
|
|
|
} else {
|
2021-01-08 15:53:41 +01:00
|
|
|
clearDeletedDate(cipher as { id: string; revisionDate: string });
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-04-03 22:32:15 +02: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.clearCache();
|
|
|
|
await this.stateService.setEncryptedCiphers(ciphers);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2021-01-08 15:53:41 +01:00
|
|
|
|
|
|
|
async restoreWithServer(id: string): Promise<any> {
|
|
|
|
const response = await this.apiService.putRestoreCipher(id);
|
|
|
|
await this.restore({ id: id, revisionDate: response.revisionDate });
|
2020-04-03 22:32:15 +02: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
|
|
|
async restoreManyWithServer(ids: string[]): Promise<any> {
|
|
|
|
const response = await this.apiService.putRestoreManyCiphers(new CipherBulkRestoreRequest(ids));
|
|
|
|
const restores: { id: string; revisionDate: string }[] = [];
|
|
|
|
for (const cipher of response.data) {
|
|
|
|
restores.push({ id: cipher.id, revisionDate: cipher.revisionDate });
|
2020-04-03 22:32:15 +02:00
|
|
|
}
|
|
|
|
await this.restore(restores);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-07-04 05:33:15 +02:00
|
|
|
// Helpers
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2020-04-03 22:32:15 +02:00
|
|
|
private async shareAttachmentWithServer(
|
|
|
|
attachmentView: AttachmentView,
|
|
|
|
cipherId: string,
|
2018-10-24 04:10:08 +02:00
|
|
|
organizationId: string
|
2020-04-03 22:32:15 +02:00
|
|
|
): Promise<any> {
|
2021-01-08 15:53:41 +01:00
|
|
|
const attachmentResponse = await this.apiService.nativeFetch(
|
|
|
|
new Request(attachmentView.url, { cache: "no-store" })
|
2021-12-16 13:36:21 +01:00
|
|
|
);
|
2021-01-08 15:53:41 +01:00
|
|
|
if (attachmentResponse.status !== 200) {
|
|
|
|
throw Error("Failed to download attachment: " + attachmentResponse.status.toString());
|
2020-04-03 22:32:15 +02:00
|
|
|
}
|
|
|
|
|
2022-07-26 03:40:32 +02:00
|
|
|
const encBuf = await EncArrayBuffer.fromResponse(attachmentResponse);
|
|
|
|
const decBuf = await this.cryptoService.decryptFromBytes(encBuf, null);
|
2021-01-08 15:53:41 +01:00
|
|
|
const key = await this.cryptoService.getOrgKey(organizationId);
|
|
|
|
const encFileName = await this.cryptoService.encrypt(attachmentView.fileName, key);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-01-08 15:53:41 +01:00
|
|
|
const dataEncKey = await this.cryptoService.makeEncKey(key);
|
|
|
|
const encData = await this.cryptoService.encryptToBytes(decBuf, dataEncKey[0]);
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-01-08 15:53:41 +01:00
|
|
|
const fd = new FormData();
|
|
|
|
try {
|
|
|
|
const blob = new Blob([encData.buffer], { type: "application/octet-stream" });
|
|
|
|
fd.append("key", dataEncKey[1].encryptedString);
|
|
|
|
fd.append("data", blob, encFileName.encryptedString);
|
|
|
|
} catch (e) {
|
|
|
|
if (Utils.isNode && !Utils.isBrowser) {
|
|
|
|
fd.append("key", dataEncKey[1].encryptedString);
|
|
|
|
fd.append(
|
2021-12-16 13:36:21 +01:00
|
|
|
"data",
|
2021-01-08 15:53:41 +01:00
|
|
|
Buffer.from(encData.buffer) as any,
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2021-01-08 15:53:41 +01:00
|
|
|
filepath: encFileName.encryptedString,
|
|
|
|
contentType: "application/octet-stream",
|
|
|
|
} as any
|
|
|
|
);
|
2021-12-16 13:36:21 +01:00
|
|
|
} else {
|
2021-01-08 15:53:41 +01:00
|
|
|
throw e;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-04-03 22:32:15 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 04:10:08 +02:00
|
|
|
try {
|
2019-06-24 17:07:26 +02:00
|
|
|
await this.apiService.postShareCipherAttachment(
|
2018-10-24 04:10:08 +02:00
|
|
|
cipherId,
|
|
|
|
attachmentView.id,
|
|
|
|
fd,
|
2021-04-14 17:47:10 +02:00
|
|
|
organizationId
|
2018-10-24 04:10:08 +02:00
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
throw new Error((e as ErrorResponse).getSingleMessage());
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-24 17:33:15 +01:00
|
|
|
private async encryptObjProperty<V extends View, D extends Domain>(
|
|
|
|
model: V,
|
|
|
|
obj: D,
|
|
|
|
map: any,
|
|
|
|
key: SymmetricCryptoKey
|
|
|
|
): Promise<void> {
|
2018-01-10 05:01:16 +01:00
|
|
|
const promises = [];
|
|
|
|
const self = this;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
for (const prop in map) {
|
2022-02-22 15:39:11 +01:00
|
|
|
// eslint-disable-next-line
|
2018-01-10 05:01:16 +01:00
|
|
|
if (!map.hasOwnProperty(prop)) {
|
|
|
|
continue;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
(function (theProp, theObj) {
|
|
|
|
const p = Promise.resolve()
|
|
|
|
.then(() => {
|
2018-01-24 17:33:15 +01:00
|
|
|
const modelProp = (model as any)[map[theProp] || theProp];
|
2018-01-10 05:01:16 +01:00
|
|
|
if (modelProp && modelProp !== "") {
|
|
|
|
return self.cryptoService.encrypt(modelProp, key);
|
|
|
|
}
|
|
|
|
return null;
|
2021-04-21 02:16:19 +02:00
|
|
|
})
|
|
|
|
.then((val: EncString) => {
|
2018-01-24 17:33:15 +01:00
|
|
|
(theObj as any)[theProp] = val;
|
2018-01-10 05:01:16 +01:00
|
|
|
});
|
|
|
|
promises.push(p);
|
|
|
|
})(prop, obj);
|
|
|
|
}
|
|
|
|
|
2018-01-24 17:33:15 +01:00
|
|
|
await Promise.all(promises);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2018-01-24 17:33:15 +01:00
|
|
|
private async encryptCipherData(cipher: Cipher, model: CipherView, key: SymmetricCryptoKey) {
|
2018-01-10 05:01:16 +01:00
|
|
|
switch (cipher.type) {
|
|
|
|
case CipherType.Login:
|
2018-01-24 19:27:32 +01:00
|
|
|
cipher.login = new Login();
|
2018-07-27 23:48:18 +02:00
|
|
|
cipher.login.passwordRevisionDate = model.login.passwordRevisionDate;
|
2021-05-18 02:08:28 +02:00
|
|
|
cipher.login.autofillOnPageLoad = model.login.autofillOnPageLoad;
|
2018-03-02 05:44:29 +01:00
|
|
|
await this.encryptObjProperty(
|
|
|
|
model.login,
|
|
|
|
cipher.login,
|
2018-01-24 17:33:15 +01:00
|
|
|
{
|
2018-01-10 05:01:16 +01:00
|
|
|
username: null,
|
|
|
|
password: null,
|
|
|
|
totp: null,
|
|
|
|
},
|
2021-12-16 13:36:21 +01:00
|
|
|
key
|
|
|
|
);
|
|
|
|
|
2018-01-10 05:01:16 +01:00
|
|
|
if (model.login.uris != null) {
|
|
|
|
cipher.login.uris = [];
|
2018-01-24 19:27:32 +01:00
|
|
|
for (let i = 0; i < model.login.uris.length; i++) {
|
|
|
|
const loginUri = new LoginUri();
|
2018-01-24 17:33:15 +01:00
|
|
|
loginUri.match = model.login.uris[i].match;
|
|
|
|
await this.encryptObjProperty(
|
2018-01-10 05:01:16 +01:00
|
|
|
model.login.uris[i],
|
|
|
|
loginUri,
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2018-01-10 05:01:16 +01:00
|
|
|
uri: null,
|
|
|
|
},
|
|
|
|
key
|
|
|
|
);
|
|
|
|
cipher.login.uris.push(loginUri);
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
return;
|
2018-01-10 05:01:16 +01:00
|
|
|
case CipherType.SecureNote:
|
2018-01-24 19:27:32 +01:00
|
|
|
cipher.secureNote = new SecureNote();
|
|
|
|
cipher.secureNote.type = model.secureNote.type;
|
2021-12-16 13:36:21 +01:00
|
|
|
return;
|
2018-01-10 05:01:16 +01:00
|
|
|
case CipherType.Card:
|
2018-01-24 19:27:32 +01:00
|
|
|
cipher.card = new Card();
|
2018-01-24 17:33:15 +01:00
|
|
|
await this.encryptObjProperty(
|
|
|
|
model.card,
|
|
|
|
cipher.card,
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2018-01-10 05:01:16 +01:00
|
|
|
cardholderName: null,
|
2021-12-16 13:36:21 +01:00
|
|
|
brand: null,
|
2018-01-10 05:01:16 +01:00
|
|
|
number: null,
|
|
|
|
expMonth: null,
|
|
|
|
expYear: null,
|
2021-12-16 13:36:21 +01:00
|
|
|
code: null,
|
|
|
|
},
|
|
|
|
key
|
|
|
|
);
|
|
|
|
return;
|
2018-01-10 05:01:16 +01:00
|
|
|
case CipherType.Identity:
|
2018-01-24 17:33:15 +01:00
|
|
|
cipher.identity = new Identity();
|
|
|
|
await this.encryptObjProperty(
|
|
|
|
model.identity,
|
|
|
|
cipher.identity,
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2018-01-10 05:01:16 +01:00
|
|
|
title: null,
|
|
|
|
firstName: null,
|
|
|
|
middleName: null,
|
|
|
|
lastName: null,
|
|
|
|
address1: null,
|
|
|
|
address2: null,
|
|
|
|
address3: null,
|
|
|
|
city: null,
|
|
|
|
state: null,
|
|
|
|
postalCode: null,
|
|
|
|
country: null,
|
|
|
|
company: null,
|
|
|
|
email: null,
|
|
|
|
phone: null,
|
|
|
|
ssn: null,
|
|
|
|
username: null,
|
|
|
|
passportNumber: null,
|
|
|
|
licenseNumber: null,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
key
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
default:
|
2018-01-10 05:01:16 +01:00
|
|
|
throw new Error("Unknown cipher type.");
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2021-05-18 02:08:28 +02:00
|
|
|
private async getCipherForUrl(
|
|
|
|
url: string,
|
|
|
|
lastUsed: boolean,
|
|
|
|
lastLaunched: boolean,
|
|
|
|
autofillOnPageLoad: boolean
|
|
|
|
): Promise<CipherView> {
|
|
|
|
const cacheKey = autofillOnPageLoad ? "autofillOnPageLoad-" + url : url;
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-05-18 02:08:28 +02:00
|
|
|
if (!this.sortedCiphersCache.isCached(cacheKey)) {
|
|
|
|
let ciphers = await this.getAllDecryptedForUrl(url);
|
2020-08-12 21:59:59 +02:00
|
|
|
if (!ciphers) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
|
2021-05-18 02:08:28 +02:00
|
|
|
if (autofillOnPageLoad) {
|
[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 autofillOnPageLoadDefault = await this.stateService.getAutoFillOnPageLoadDefault();
|
2021-05-18 02:08:28 +02:00
|
|
|
ciphers = ciphers.filter(
|
|
|
|
(cipher) =>
|
|
|
|
cipher.login.autofillOnPageLoad ||
|
2021-05-26 23:02:12 +02:00
|
|
|
(cipher.login.autofillOnPageLoad == null && autofillOnPageLoadDefault !== false)
|
|
|
|
);
|
2021-05-18 02:08:28 +02:00
|
|
|
if (ciphers.length === 0) {
|
|
|
|
return null;
|
2020-08-12 21:59:59 +02:00
|
|
|
}
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-08-12 21:59:59 +02:00
|
|
|
|
2021-05-18 02:08:28 +02:00
|
|
|
this.sortedCiphersCache.addCiphers(cacheKey, ciphers);
|
2020-08-12 21:59:59 +02: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
|
|
|
|
|
|
|
if (lastLaunched) {
|
|
|
|
return this.sortedCiphersCache.getLastLaunched(cacheKey);
|
|
|
|
} else if (lastUsed) {
|
|
|
|
return this.sortedCiphersCache.getLastUsed(cacheKey);
|
|
|
|
} else {
|
|
|
|
return this.sortedCiphersCache.getNext(cacheKey);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
private async clearEncryptedCiphersState(userId?: string) {
|
|
|
|
await this.stateService.setEncryptedCiphers(null, { userId: userId });
|
|
|
|
}
|
|
|
|
|
|
|
|
private async clearDecryptedCiphersState(userId?: string) {
|
|
|
|
await this.stateService.setDecryptedCiphers(null, { userId: userId });
|
|
|
|
this.clearSortedCiphers();
|
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
|
|
|
private clearSortedCiphers() {
|
|
|
|
this.sortedCiphersCache.clear();
|
|
|
|
}
|
2018-01-10 05:01:16 +01:00
|
|
|
}
|