mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
[PM-16793] port credential generator service to providers (#14071)
* introduce extension service * deprecate legacy forwarder types * eliminate repeat algorithm emissions * extend logging to preference management * align forwarder ids with vendor ids * fix duplicate policy emissions; debugging required logger enhancements ----- Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
This commit is contained in:
@@ -24,7 +24,7 @@ describe("GeneratorNavigationEvaluator", () => {
|
||||
|
||||
describe("applyPolicy", () => {
|
||||
it("returns the input options when a policy is not in effect", () => {
|
||||
const evaluator = new GeneratorNavigationEvaluator(null);
|
||||
const evaluator = new GeneratorNavigationEvaluator(null!);
|
||||
const options = { type: "password" as const };
|
||||
|
||||
const result = evaluator.applyPolicy(options);
|
||||
@@ -54,7 +54,7 @@ describe("GeneratorNavigationEvaluator", () => {
|
||||
});
|
||||
|
||||
it("defaults options to the default generator navigation type when a policy is not in effect", () => {
|
||||
const evaluator = new GeneratorNavigationEvaluator(null);
|
||||
const evaluator = new GeneratorNavigationEvaluator(null!);
|
||||
|
||||
const result = evaluator.sanitize({});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { PasswordAlgorithms, PolicyEvaluator } from "@bitwarden/generator-core";
|
||||
import { AlgorithmsByType, PolicyEvaluator, Type } from "@bitwarden/generator-core";
|
||||
|
||||
import { DefaultGeneratorNavigation } from "./default-generator-navigation";
|
||||
import { GeneratorNavigation } from "./generator-navigation";
|
||||
@@ -19,7 +19,7 @@ export class GeneratorNavigationEvaluator
|
||||
|
||||
/** {@link PolicyEvaluator.policyInEffect} */
|
||||
get policyInEffect(): boolean {
|
||||
return PasswordAlgorithms.includes(this.policy?.overridePasswordType);
|
||||
return AlgorithmsByType[Type.password].includes(this.policy?.overridePasswordType);
|
||||
}
|
||||
|
||||
/** Apply policy to the input options.
|
||||
|
||||
@@ -4,14 +4,14 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
// FIXME: use index.ts imports once policy abstractions and models
|
||||
// implement ADR-0002
|
||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||
import { PasswordType } from "@bitwarden/generator-core";
|
||||
import { PasswordAlgorithm } from "@bitwarden/generator-core";
|
||||
|
||||
/** Policy settings affecting password generator navigation */
|
||||
export type GeneratorNavigationPolicy = {
|
||||
/** The type of generator that should be shown by default when opening
|
||||
* the password generator.
|
||||
*/
|
||||
overridePasswordType?: PasswordType;
|
||||
overridePasswordType?: PasswordAlgorithm;
|
||||
};
|
||||
|
||||
/** Reduces a policy into an accumulator by preferring the password generator
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { GeneratorType, ForwarderId, UsernameGeneratorType } from "@bitwarden/generator-core";
|
||||
import { VendorId } from "@bitwarden/common/tools/extension";
|
||||
import { UsernameGeneratorType, CredentialAlgorithm } from "@bitwarden/generator-core";
|
||||
|
||||
/** Stores credential generator UI state. */
|
||||
export type GeneratorNavigation = {
|
||||
@@ -6,11 +7,11 @@ export type GeneratorNavigation = {
|
||||
* @remarks The legacy generator only supports "password" and "passphrase".
|
||||
* The componentized generator supports all values.
|
||||
*/
|
||||
type?: GeneratorType;
|
||||
type?: CredentialAlgorithm;
|
||||
|
||||
/** When `type === "username"`, this stores the username algorithm. */
|
||||
username?: UsernameGeneratorType;
|
||||
|
||||
/** When `username === "forwarded"`, this stores the forwarder implementation. */
|
||||
forwarder?: ForwarderId | "";
|
||||
forwarder?: VendorId | "";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user