1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-08-23 22:43:00 +02:00
bitwarden-browser/apps/desktop/src
Justin Baur e1b5b83723
Add State Provider Framework (#6640)
* Add StateDefinition

Add a class for encapsulation information about state
this will often be for a domain but creations of this will
exist outside of a specific domain, hence just the name State.

* Add KeyDefinition

This adds a type that extends state definition into another sub-key
and forces creators to define the data that will be stored and how
to read the data that they expect to be stored.

* Add key-builders helper functions

Adds to function to help building keys for both keys scoped
to a specific user and for keys scoped to global storage.

Co-authored-by: Matt Gibson <MGibson1@users.noreply.github.com>

* Add updates$ stream to existing storageServices

Original commit by Matt: 823d9546fe
Co-authored-by: Matt Gibson <MGibson1@users.noreply.github.com>

* Add fromChromeEvent helper

Create a helper that creats an Observable from a chrome event
and removes the listener when the subscription is completed.

* Implement `updates$` property for chrome storage

Use fromChromeEvent to create an observable from chrome
event and map that into our expected shape.

* Add GlobalState Abstractions

* Add UserState Abstractions

* Add Default Implementations of User/Global state

Co-authored-by: Matt Gibson <MGibson1@users.noreply.github.com>

* Add Barrel File for state

Co-authored-by: Matt Gibson <MGibson1@users.noreply.github.com>

* Fix ChromeStorageServices

* Rework fromChromeEvent

Rework fromChromeEvent so we have to lie to TS less and
remove unneeded generics. I did this by caring less about
the function and more about the parameters only.

Co-authored-by: Matt Gibson <MGibson1@users.noreply.github.com>

* Fix UserStateProvider Test

* Add Inner Mock & Assert Calls

* Update Tests to use new keys

Use different key format

* Prefer returns over mutations in update

* Update Tests

* Address PR Feedback

* Be stricter with userId parameter

* Add Better Way To Determine if it was a remove

* Fix Web & Browser Storage Services

* Fix Desktop & CLI Storage Services

* Fix Test Storage Service

* Use createKey Helper

* Prefer implement to extending

* Determine storage location in providers

* Export default providers publicly

* Fix user state tests

* Name tests

* Fix CLI

* Prefer Implement In Chrome Storage

* Remove Secure Storage Option

Also throw an exception for subscribes to the secure storage observable.

* Update apps/browser/src/platform/browser/from-chrome-event.ts

Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>

* Enforce state module barrel file

* Fix Linting Error

* Allow state module import from other modules

* Globally Unregister fromChromeEvent Listeners

Changed fromChromeEvent to add its listeners through the BrowserApi, so that
they will be unregistered when safari closes.

* Test default global state

* Use Proper Casing in Parameter

* Address Feedback

* Update libs/common/src/platform/state/key-definition.ts

Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>

* Add `buildCacheKey` Method

* Fix lint errors

* Add Comment

Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>

* Use Generic in callback parameter

* Refactor Out DerivedStateDefinition

* Persist Listener Return Type

* Add Ticket Link

---------

Co-authored-by: Matt Gibson <MGibson1@users.noreply.github.com>
Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
2023-11-09 17:06:42 -05:00
..
app Auth/PM-3275 - Changes to support TDE User without MP being able to Set a Password (#6281) 2023-11-03 11:33:10 -04:00
auth [PM-3677] Remove ipcRenderer from desktop utils (#6477) 2023-11-09 12:48:18 +01:00
images [PM-1222] Store passkeys in Bitwarden vault (#4715) 2023-10-17 15:34:44 -04:00
locales Autosync the updated translations (#6778) 2023-11-06 14:58:24 +00:00
main [PM-4441] Refactor utils helper functions (#6672) 2023-10-23 23:52:42 +02:00
models Platform/pm 19/platform team file moves (#5460) 2023-06-06 15:34:53 -05:00
platform Add State Provider Framework (#6640) 2023-11-09 17:06:42 -05:00
proxy [PM-1674] let node-ipc use individual pipes on Windows (#4020) 2023-04-11 16:45:24 +02:00
scss [PM-795] Fix send name missing ellipsis (#6538) 2023-10-12 18:32:46 -04:00
services [PM-3683] Remove ipcRenderer from electron-platform-utils (#6679) 2023-11-01 18:34:36 +01:00
types [PM-3683] Remove ipcRenderer from electron-platform-utils (#6679) 2023-11-01 18:34:36 +01:00
vault/app [PM-1222] Store passkeys in Bitwarden vault (#4715) 2023-10-17 15:34:44 -04:00
entry.ts Move desktop into apps/desktop 2022-05-05 17:20:34 +02:00
global.d.ts [PM-3996] Scaffolding for preload script (#6065) 2023-10-12 11:50:17 +02:00
index.html [PM-2643] Resolve DUO iframe not being clickable (#6219) 2023-09-08 18:38:46 +02:00
main.ts [PM-3754] Update electron log (#6680) 2023-11-06 19:15:40 +01:00
package-lock.json Bumped desktop version to 2023.10.2 (#6833) 2023-11-08 11:17:35 -05:00
package.json Bumped desktop version to 2023.10.2 (#6833) 2023-11-08 11:17:35 -05:00
preload.ts [PM-3677] Remove ipcRenderer from desktop utils (#6477) 2023-11-09 12:48:18 +01:00
utils.spec.ts [SM-329] Merge libs/electron into desktop (#3989) 2022-12-02 12:45:09 +01:00
utils.ts [PM-3677] Remove ipcRenderer from desktop utils (#6477) 2023-11-09 12:48:18 +01:00