Commit Graph

28 Commits

Author SHA1 Message Date
renovate[bot] 28de9439be
[deps] Autofill: Update prettier to v3 (#7014)
* [deps] Autofill: Update prettier to v3

* prettier formatting updates

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
2023-11-29 16:15:20 -05:00
Oscar Hinton a5e3432f85
Assign ownership to many libs files (#6928)
Assign ownership to many of the remaining libs/common files.

Criteria for ownership:
* Files used by a single team, is now owned by that team.
* Files related to a domain owned by a team is now owned by that team.
* Where ownership is unclear the "lowest level" service takes ownership.
2023-11-27 20:59:44 +00:00
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
Kyle Spearrin 9212751553
add support for decrypting AES-ECB mode (#6476) 2023-10-04 16:58:47 -04:00
Matt Gibson 0448910806
[PM-3732] Use subtle to make aes keys (#6162)
* Provide `aesGenerateKey` to make aes keys

* Use aesGenerateKey when generating a key data

* Fix device test
2023-09-07 15:42:35 +00:00
Matt Gibson 36b7d30804
Fix failing crypto tests (#5948)
* Change everything to Uint8Array

related to https://github.com/jestjs/jest/issues/14379

* Work on failing type tests

* Revert changes to custom matcher setup

* Remove last BufferArrays from tests

* Fix custom matcher type errors in vscode

* Remove errant `.buffer` calls on Uint8Arrays

* Encryption Pair should serialize Array Buffer and Uint8Array

* Fix EncArrayBuffer encryption

---------

Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
2023-08-04 02:13:33 +00:00
Matt Gibson 78248db590
Platform/pm 19/platform team file moves (#5460)
* Rename service-factory folder

* Move cryptographic service factories

* Move crypto models

* Move crypto services

* Move domain base class

* Platform code owners

* Move desktop log services

* Move log files

* Establish component library ownership

* Move background listeners

* Move background background

* Move localization to Platform

* Move browser alarms to Platform

* Move browser state to Platform

* Move CLI state to Platform

* Move Desktop native concerns to Platform

* Move flag and misc to Platform

* Lint fixes

* Move electron state to platform

* Move web state to Platform

* Move lib state to Platform

* Fix broken tests

* Rename interface to idiomatic TS

* `npm run prettier` 🤖

* Resolve review feedback

* Set platform as owners of web core and shared

* Expand moved services

* Fix test types

---------

Co-authored-by: Hinton <hinton@users.noreply.github.com>
2023-06-06 15:34:53 -05:00
Oscar Hinton 62591a8bc8
[PM-2328] Fix jest deprecations (#5483) 2023-05-22 20:19:16 +02:00
renovate[bot] 9e32f8d574
chore(deps): update dependency rimraf to v5 (#5468)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Hinton <hinton@users.noreply.github.com>
2023-05-19 14:23:44 +02:00
Oscar Hinton 5f825e10f9
[PM-2132] Move all specs to the src directory (#5367) 2023-05-09 11:27:09 +02:00
Matt Gibson 830af7b06d
Rework Desktop Biometrics (#5234) 2023-04-18 09:09:47 -04:00
Bernd Schoolmann e055e68991
[PS-2251] Implement argon2 kdf (#4468)
* Implement argon2

* Remove argon2 webassembly warning

* Replace magic numbers by enum

* move packages

* cleanup call to argon2

* update call to node argon2

* don't need  wasm-eval

* revert config changes

* Update libs/common/src/enums/kdfType.ts

Co-authored-by: Martin Weinelt <mweinelt@users.noreply.github.com>

* Update kdfType.ts

* apply DEFAULT_PBKDF2_ITERATIONS

* checkIfWasmSupported

Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com>
Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
Co-authored-by: Martin Weinelt <mweinelt@users.noreply.github.com>
2023-01-26 09:20:12 -05:00
Daniel James Smith 80f5a883e0
[PS-1884] [TDL-189] [TDL-203] Move libs/node files to CLI and rename per ADR12 (#4069)
* Extract files only used in cli out of libs/node

Move commands from libs/node to cli
Move program from libs/node to cli
Move services from libs/node to cli
Move specs from libs/node to cli

Naming changes based on ADR 12
Rename commands
Rename models/request
Rename models/response
Remove entries from whitelist-capital-letters.txt

* Merge lowDbStorageService into base class

Move logic from extended lowdbStorage.service.ts into base-lowdb-storage.service.ts
Delete lowdb-storage.service.ts
Rename base-lowdb-storage.service.ts to lowdb-storage.service.ts

* Merge login.command with base class

program.ts - changed import temporarily to make it easier to review
Remove passing in clientId, set "cli" when constructing ssoRedirectUri call
Remove setting callbacks, use private methods instead
Remove i18nService from constructor params
Add syncService, keyConnectorService and logoutCallback to constructor
Merge successCallback with handleSuccessResponse
Remove validatedParams callback and added private method
Move options(program.OptionValues) and set in run()
Delete login.command.ts

* Rename base-login.command.ts to login.command.ts

* Merge base.program.ts with program.ts
2022-11-18 13:20:19 +01:00
Daniel James Smith 6049e588e4
Rename nodeCryptoFunctionService (#4070) 2022-11-17 15:46:49 +01:00
cyprain-okeke cba0f31937
[PS 1045] bw login with apikey argument fails on cli (#3959)
* Add fix for bw login with apikey argument fails bug

* Changes after running the prettier

* Revert chnages on the launch.json file

* Changes after running a lint

* Renaming a filename to remove capital letters

* Resolving the error on test run

* Renaming file names due lint errors

* Renaming new files to conform to snake case

* Remove the test for user api login strategy

* Adding the user api login test and file renaming

* Rename file name to organization-api-login.spec.ts

* Fixing the lint error on PR

* Adding the apiLogIn.strategy to whitelist-capital-letters

* Removing all the apiLogIn.strategy in whitelist-capital-letters.

* Fixing PR comment relating OrganizationApiTokenRequest

* Resolve PR comment on OrganizationApiTokenRequest model

* Fixing PR comment of separating organization token model

* fixing the lint error message

* Fixing the lint error

* Reverting the changes on lunch.js

* revert the actual content on launch.json

* Reverting changes relating to organization api login

* Removing the OrganizationIdentityTokenResponse file

* Removing OrganizationIdentityTokenResponse file

Co-authored-by: dynwee <onwudiweokeke@gmail.com>
2022-11-17 12:50:37 +01:00
Oscar Hinton cf2d3f5382
[SM-288] Rename requests and responses to follow naming convention (#3806) 2022-10-18 19:01:42 +02:00
Oscar Hinton e941f06bac
[SM-288] Rename models to follow naming convention (#3795) 2022-10-14 18:25:50 +02:00
Rui Tomé 3a298bd989
[EC-377] Transition Policy service into providing observables (#3259)
* Added abstractions for PolicyApiService and PolicyService

* Added implementations for PolicyApiService and PolicyService

* Updated all references to new PolicyApiService and PolicyService

* Deleted old PolicyService abstraction and implementation

* Fixed CLI import path for policy.service

* Fixed main.background.ts policyApiService dependency for policyService

* Ran prettier

* Updated policy-api.service with the correct imports

* [EC-377] Removed methods from StateService that read policies

* [EC-377] Updated policy service getAll method to use observable collection

* [EC-377] Added first unit tests for policy service

* [EC-377] Added more unit tests for Policy Service

* [EC-376] Sorted methods order in PolicyApiService

* [EC-376] Removed unused clearCache method from PolicyService

* [EC-376] Added upsert method to PolicyService

* [EC-376] PolicyApiService putPolicy method now upserts data to PolicyService

* [EC-377] Removed tests for deleted clearCache method

* [EC-377] Added unit test for PolicyService.upsert

* [EC-377] Updated references to state service observables

* [EC-377] Removed getAll method from PolicyService and refactored components to use observable collection

* [EC-377] Updated components to use concatMap instead of async subscribe

* [EC-377] Removed getPolicyForOrganization from policyApiService

* [EC-377] Updated policyAppliesToUser to return observable collection

* [EC-377] Changed policyService.policyAppliesToUser to return observable

* [EC-377] Fixed browser settings.component.ts getting vault timeout

* Updated people.component.ts to get ResetPassword policy through a subscription

* [EC-377] Changed passwordGenerationService.getOptions to return observable

* [EC-377] Fixed CLI generate.command.ts getting enforcePasswordGeneratorPoliciesOnOptions

* [EC-377] Fixed eslint errors on rxjs

* [EC-377] Reverted changes on passwordGeneration.service and vaultTimeout.service

* [EC-377] Removed eslint disable on web/vault/add-edit-component

* [EC-377] Changed AccountData.policies to TemporaryDataEncryption

* [EC-377] Updated import.component to be reactive to policyAppliesToUser$

* [EC-377] Updated importBlockedByPolicy$

* [EC-377] Fixed missing rename

* [EC-377] Updated policyService.masterPasswordPolicyOptions to return observable

* [EC-377] Fixed vaultTimeout imports from merge

* [EC-377] Reverted call to passwordGenerationService.getOptions

* [EC-377] Reverted call to enforcePasswordGeneratorPoliciesOnOptions

* [EC-377] Removed unneeded ngOnDestroy

* Apply suggestions from code review

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

* [EC-377] Fixed login.component.ts and register.component.ts

* [EC-377] Updated PolicyService to update vaultTimeout

* [EC-377] Updated PolicyService dependencies

* [EC-377] Renamed policyAppliesToUser to policyAppliesToActiveUser

* [EC-377] VaultTimeoutSettings service now gets the vault timeout directly instead of using observables

* [EC-377] Fixed unit tests by removing unneeded vaultTimeoutSettingsService

* [EC-377] Set getDecryptedPolicies and setDecryptedPolicies as deprecated

* [EC-377] Set PolicyService.getAll as deprecated and updated to use prototype.hasOwnProperty

* [EC-565] Reverted unintended change to vaultTimeoutSettings that was causing a bug to not display the correct vault timeout

* [EC-377] Removed unneeded destroy$ from preferences.component.ts

* [EC-377] Fixed policy.service.ts import of OrganizationService

Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
Co-authored-by: mimartin12 <77340197+mimartin12@users.noreply.github.com>
2022-10-11 13:08:48 +01:00
Thomas Rittson 233c85f7a3
[EC-515] Re-enable node consoleLog.service test (#3448) 2022-09-08 08:02:53 +10:00
Michał Chęciński bd88b5b365
Run client test on build (#3216)
* Add tests step to build pipelines

* RUn tests for safari

* Remove tests step to build pipelines

* Run tests on root dir on pr

* Revert "Remove tests step to build pipelines"

This reverts commit 497bd86620.

* CHange name

* Remove working directory

* Add manual trigger

* Comment out cache

* Try to fix

* Revert "Try to fix"

This reverts commit 93d404b7d5.

* Disable failing test
2022-08-25 18:06:31 +10:00
Thomas Rittson 4a1c3eb1ec
[EC-423] Fix unit tests (#3265)
* Create base jest.config file

* Fix various tests that were broken

* Add maxWorkers to jest config

* Undo change to testEnvironment

* Enable tsconfig.spec.json
2022-08-11 11:35:08 +10:00
Rui Tomé c263eacd88
[EC-376] Extract API logic from PolicyService to PolicyApiService (#3203)
* Added abstractions for PolicyApiService and PolicyService

* Added implementations for PolicyApiService and PolicyService

* Updated all references to new PolicyApiService and PolicyService

* Deleted old PolicyService abstraction and implementation

* Fixed CLI import path for policy.service

* Fixed main.background.ts policyApiService dependency for policyService

* Updated policy-api.service with the correct imports

* [EC-376] Sorted methods order in PolicyApiService

* [EC-376] Removed unused clearCache method from PolicyService

* [EC-376] Added upsert method to PolicyService

* [EC-376] PolicyApiService putPolicy method now upserts data to PolicyService
2022-08-08 10:04:36 +01:00
Addison Beck bb7dce031c
[fix] Force send attachment to always download and never open (#2908)
* [refactor] Introduce a file download service

* [refactor] Point platformUtilsService.saveFile() callers to fileDownloadService.download() instead

* [refactor] Remove platformUtilsService.saveFile()

* [fix] Force send attachments to always download and never open

* [fix] Remove the window property from FileDownloadRequest

* [fix] Move FileDownloadRequest to /abstractions/fileDownload

* [fix] Simplify FileDownloadRequest to a type

* [fix] Move BrowserApi.saveFile logic into BrowserFileDownloadService

* [fix] Use proper blob types for file downloads

* [fix] forceDownload -> downloadMethod on FileDownloadRequest

* [fix] Remove fileType from FileDownloadRequest

* [fix] Make fileType private
2022-06-29 17:15:29 -04:00
Matt Gibson 399b8c2b34
PS-813 Add memory storage to state service (#2892)
* Use abstract methods and generics in StorageService

* Prepend `Abstract` to abstract classes

* Create session browser storage service

* Use memory storage service for state memory

* Inject memory storage service

* Maintain filename extensions to help ide formatting

* Preserve state if it's still in memory

* Use jslib's memory storage service

* linter

* Create prototypes on stored objects

* standardize package scripts

* Add type safety to `withPrototype` decorators

* webpack notify manifest version

* Fix desktop

* linter

* Fix script

* Improve prototye application

* do not change prototype if it already matches desired
* fix error with object values prototype application

* Handle null state

* Apply prototypes to browser-specific state

* Add angular language server to recommended extensions

* Improve browser state service tests

* Start testing state Service

* Fix abstract returns

* Move test setup files to not be picked up by default glob matchers

* Add key generation service

* Add low-dependency encrypt service

* Back crypto service with encrypt service.

We'll want to work items that don't require state over to encrypt service

* Add new storage service and tests

* Properly init more stored values

* Fix reload issues when state service is recovering state from session storage

Co-authored-by: Thomas Avery <Thomas-Avery@users.noreply.github.com>
Co-authored-by: Justin Baur <admin@justinbaur.com>

* Simplify encrypt service

* Do not log mac failures for local-backed session storage

* `content` changed to `main` in #2245

* Fix CLI

* Remove loggin

* PR feedback

* Merge remote-tracking branch 'origin/master' into add-memory-storage-to-state-service

* Fix desktop

* Fix decrypt method signature

* Minify if not development

* Key is required

Co-authored-by: Thomas Avery <Thomas-Avery@users.noreply.github.com>
Co-authored-by: Justin Baur <admin@justinbaur.com>
2022-06-27 12:38:12 -05:00
Addison Beck 57b8144013
[refactor] Introduce ThemingService (#2943)
* [refactor] Introduce ThemingService

* [refactor] Implement ThemingService for web

* [refactor] Implement ThemingService on browser

* [refactor] Implement ThemingService for desktop

* [refactor] Remove deprecated platformUtils.service theme methods

* [fix] Move ThemingService from libs/common to libs/angular

* [fix] Simplify ThemeBuilder's constructor

* [fix] Dont notify subscribers of null values from theme$

* [fix] Always notify PaymentComponent of theme changes
2022-06-23 07:36:05 -04:00
Oscar Hinton bc639688e8
Use NPM workspace (#2874) 2022-06-14 17:10:53 +02:00
Oscar Hinton 5780bf85e7
Add support for migrated jslib (#2826) 2022-06-03 18:01:07 +02:00
Hinton d7492e3cf3 Move to libs 2022-06-03 16:24:40 +02:00