mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[PM-11418] generator policy constraints (#11014)
* add constraint support to UserStateSubject * add dynamic constraints * implement password policy constraints * replace policy evaluator with constraints in credential generation service * add cascade between minNumber and minSpecial Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
This commit is contained in:
24
libs/common/src/tools/state/identity-state-constraint.ts
Normal file
24
libs/common/src/tools/state/identity-state-constraint.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Constraints, StateConstraints } from "../types";
|
||||
|
||||
// The constraints type shares the properties of the state,
|
||||
// but never has any members
|
||||
const EMPTY_CONSTRAINTS = new Proxy<any>(Object.freeze({}), {
|
||||
get() {
|
||||
return {};
|
||||
},
|
||||
});
|
||||
|
||||
/** A constraint that does nothing. */
|
||||
export class IdentityConstraint<State extends object> implements StateConstraints<State> {
|
||||
/** Instantiate the identity constraint */
|
||||
constructor() {}
|
||||
|
||||
readonly constraints: Readonly<Constraints<State>> = EMPTY_CONSTRAINTS;
|
||||
|
||||
adjust(state: State) {
|
||||
return state;
|
||||
}
|
||||
fix(state: State) {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user