Skip to content

Commit e40b1e7

Browse files
authored
Define internal password policy typings (#7446)
* Define internal password policy typings
1 parent 3a7c4a3 commit e40b1e7

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* @license
3+
* Copyright 2023 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { PasswordPolicy, PasswordValidationStatus } from './public_types';
19+
20+
/**
21+
* Internal typing of password policy that includes the schema version and methods for
22+
* validating that a password meets the policy. The developer does not need access to
23+
* these properties and methods, so they are excluded from the public typing.
24+
*
25+
* @internal
26+
*/
27+
export interface PasswordPolicyInternal extends PasswordPolicy {
28+
/**
29+
* Schema version of the password policy.
30+
*/
31+
readonly schemaVersion: number;
32+
/**
33+
* Validates the password against the policy.
34+
* @param password Password to validate.
35+
*/
36+
validatePassword(password: string): PasswordValidationStatus;
37+
}
38+
39+
/**
40+
* Internal typing of password validation status that is modifiable. This allows us to
41+
* construct the validation status before returning it.
42+
*
43+
* @internal
44+
*/
45+
export interface PasswordValidationStatusInternal
46+
extends PasswordValidationStatus {
47+
/**
48+
* Whether the password meets all requirements.
49+
*/
50+
isValid: boolean;
51+
/**
52+
* Whether the password meets the minimum password length.
53+
*/
54+
meetsMinPasswordLength?: boolean;
55+
/**
56+
* Whether the password meets the maximum password length.
57+
*/
58+
meetsMaxPasswordLength?: boolean;
59+
/**
60+
* Whether the password contains a lowercase letter, if required.
61+
*/
62+
containsLowercaseLetter?: boolean;
63+
/**
64+
* Whether the password contains an uppercase letter, if required.
65+
*/
66+
containsUppercaseLetter?: boolean;
67+
/**
68+
* Whether the password contains a numeric character, if required.
69+
*/
70+
containsNumericCharacter?: boolean;
71+
/**
72+
* Whether the password contains a non-alphanumeric character, if required.
73+
*/
74+
containsNonAlphanumericCharacter?: boolean;
75+
/**
76+
* The policy used to validate the password.
77+
*/
78+
passwordPolicy: PasswordPolicy;
79+
}

0 commit comments

Comments
 (0)