1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 23:33:31 +00:00

[PM-5606] Add reactive generator service (#7446)

This commit is contained in:
✨ Audrey ✨
2024-01-23 14:22:52 -05:00
committed by GitHub
parent 0de72144b9
commit dbf836b573
20 changed files with 917 additions and 134 deletions

View File

@@ -0,0 +1,37 @@
import { Observable } from "rxjs";
import { PolicyEvaluator } from "./policy-evaluator.abstraction";
/** Generates credentials used for user authentication
* @typeParam Options the credential generation configuration
* @typeParam Policy the policy enforced by the generator
*/
export abstract class GeneratorService<Options, Policy> {
/** An observable monitoring the options saved to disk.
* The observable updates when the options are saved.
*/
options$: Observable<Options>;
/** An observable monitoring the options used to enforce policy.
* The observable updates when the policy changes.
*/
policy$: Observable<PolicyEvaluator<Policy, Options>>;
/** Enforces the policy on the given options
* @param options the options to enforce the policy on
* @returns a new instance of the options with the policy enforced
*/
enforcePolicy: (options: Options) => Promise<Options>;
/** Generates credentials
* @param options the options to generate credentials with
* @returns a promise that resolves with the generated credentials
*/
generate: (options: Options) => Promise<string>;
/** Saves the given options to disk.
* @param options the options to save
* @returns a promise that resolves when the options are saved
*/
saveOptions: (options: Options) => Promise<void>;
}