* Introduce browser large object storage location.
This location is encrypted and serialized to disk in order to allow for storage of uncountable things like vault items that take a significant amount of time to prepare, but are not guaranteed to fit within session storage.
however, limit the need to write to disk is a big benefit, so _most_ things are written to storage.session instead, where things specifically flagged as large will be moved to disk-backed memory
* Store derived values in large object store for browser
* Fix AbstractMemoryStorageService implementation
* Move user key memory state to state providers
Note: state service observable change is because these updates are no longer internal to the class, but reporter directly to account service through crypto service on update of a user key
* remove decrypted user key state
Note, we're going to move the encrypted cryptoSymmetric key (and associated master key encrypted user keys) as part of the master key service creation. Crypto service will no longer be responsible for the encrypted forms of user key.
* Deprecate notices belong on abstraction
* Allow for single-direction status updates
This is necessary since we don't want to have to guarantee that the update to logged out occurs after the update to locked.
* Remove deprecated subject
It turns out the set for cryptoMasterKey was also unused 🎉
* Add `disk-local` option for web
* Fix `web` DI
* Update libs/common/src/platform/state/state-definition.ts
Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
* Rely On Default Implementation for Most of Cache Key
---------
Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
* Expand state provider fakes
- default null initial value for fake states
- Easier mocking of key definitions through just the use of key names
- allows for not exporting KeyDefinition as long as the key doesn't collide
- mock of fake state provider to verify `get` calls
- `nextMock` for use of the fn mock matchers on emissions of `state$`
- `FakeAccountService` which allows for easy initialization and working with account switching
* Small bug fix for cache key collision on key definitions unique by only storage location
* Fix initial value for test
#7290 introduced these types, but during development we switched over to specifying dependencies in type parameters instead of an object. This change meant we no longer needed these `Type` or `ShapeToInstance` types, greatly simplifying the types related to derived state.
* Remove derived state from state classes
* Create provider for derived state
Derived state is automatically stored to memory storage, but can be derived from any observable.
* Fixup state provider method definitions
* Test `DefaultDerivedState`
* remove implementation notes
* Write docs for derived state
* fixup derived state provider types
* Implement buffered delayUntil operator
* Move state types to a common module
* Move mock ports to centra location
* Alias DerivedStateDependency type
* Add dependencies to browser
* Prefer internal rxjs operators for ref counting
* WIP
* Ensure complete on subjects
* Foreground/background messaging for browser
Defers work for browser to the background
* Test foreground port behaviors
* Inject foreground and background derived state services
* remove unnecessary class field
* Adhere to required options
* Add dderived state to CLI
* Prefer type definition in type parameters to options
* Prefer instance method
* Implements factory methods for common uses
* Remove nothing test
* Remove share subject reference
Share manages connector subjects internally and will reuse them until
refcount is 0 and the cleanup time has passed. Saving our own reference
just risks memory leaks without real testability benefits.
* Fix interaction state
* Specify state provider for currently active user
* Split active and single user States
UserStateProvider is still the mechanism to build each State object.
The SingleUserState is basically a repeat of GlobalState, but with
additional scoping.
* Fixup global state cache
* fix fakers to new interface
* Make userId available in single user state
* Split providers by dependency requirements
This allows usage of the single state provider in contexts that would
otherwise form circular dependencies.
* Offer convenience wrapper classes for common use
* Import for docs
* Bind wrapped methods
* Handle switch messaging
TODO: handle loading state for account switcher
* Async updates required for state
* Fallback to email for current account avatar
* Await un-awaited promises
* Remove unnecessary Prune
Prune was getting confused in browser and deleting memory in browser on
account switch. This method isn't needed since logout already removes
memory data, which is the condition for pruning
* Fix temp password in browser
* Use direct memory access until data is serializable
Safari uses a different message object extraction than firefox/chrome
and is removing `UInt8Array`s. Until all data passed into StorageService
is guaranteed serializable, we need to use direct access in state
service
* Reload badge and context menu on switch
* Gracefully switch account as they log out.
* Maintain location on account switch
* Remove unused state definitions
* Prefer null for state
undefined can be misinterpreted to indicate a value has not been set.
* Hack: structured clone in memory storage
We are currently getting dead objects on account switch due to updating
the object in the foreground state service. However, the storage service
is owned by the background. This structured clone hack ensures that all
objects stored in memory are owned by the appropriate context
* Null check nullable values
active account can be null, so we should include null safety in the
equality
* Correct background->foreground switch command
* Already providing background memory storage
* Handle connection and clipboard on switch account
* Prefer strict equal
* Ensure structuredClone is available to jsdom
This is a deficiency in jsdom --
https://github.com/jsdom/jsdom/issues/3363 -- structured clone is well
supported.
* Fixup types in faker class