1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 01:33:33 +00:00

[PM-15061] extract encryptors from generator service (#12068)

* introduce legacy encryptor provider
* port credential generation service to encryptor provider
This commit is contained in:
✨ Audrey ✨
2024-11-28 05:02:21 -05:00
committed by GitHub
parent 927c2fce43
commit ab21b78c53
33 changed files with 1384 additions and 299 deletions

View File

@@ -0,0 +1,42 @@
import { Observable } from "rxjs";
import {
OrganizationBound,
SingleOrganizationDependency,
SingleUserDependency,
UserBound,
} from "../dependencies";
import { OrganizationEncryptor } from "./organization-encryptor.abstraction";
import { UserEncryptor } from "./user-encryptor.abstraction";
/** Creates encryptors
* @deprecated this logic will soon be replaced with a design that provides for
* key rotation. Use it at your own risk
*/
export abstract class LegacyEncryptorProvider {
/** Retrieves an encryptor populated with the user's most recent key instance that
* uses a padded data packer to encode data.
* @param frameSize length of the padded data packer's frames.
* @param dependencies.singleUserId$ identifies the user to which the encryptor is bound
* @returns an observable that emits when the key becomes available and completes
* when the key becomes unavailable.
*/
userEncryptor$: (
frameSize: number,
dependencies: SingleUserDependency,
) => Observable<UserBound<"encryptor", UserEncryptor>>;
/** Retrieves an encryptor populated with the organization's most recent key instance that
* uses a padded data packer to encode data.
* @param frameSize length of the padded data packer's frames.
* @param dependencies.singleOrganizationId$ identifies the user/org combination
* to which the encryptor is bound.
* @returns an observable that emits when the key becomes available and completes
* when the key becomes unavailable.
*/
organizationEncryptor$: (
frameSize: number,
dependences: SingleOrganizationDependency,
) => Observable<OrganizationBound<"encryptor", OrganizationEncryptor>>;
}