-
Notifications
You must be signed in to change notification settings - Fork 945
Define internal password policy typings #7446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ch5zzy
merged 5 commits into
password-policy
from
update-internal-password-policy-typings
Jul 11, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e0f5257
Define internal password policy typings
ch5zzy 35daf21
Update formatting and docs
ch5zzy 1ea6337
Update API reports
ch5zzy 4382a2d
Remove custom strength options separate type
ch5zzy dd90053
Remove optional typing on non-alphanumeric characters
ch5zzy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { PasswordPolicy, PasswordValidationStatus } from './public_types'; | ||
|
||
/** | ||
* Internal typing of password policy that includes the schema version and methods for | ||
* validating that a password meets the policy. The developer does not need access to | ||
* these properties and methods, so they are excluded from the public typing. | ||
* | ||
* @internal | ||
*/ | ||
export interface PasswordPolicyInternal extends PasswordPolicy { | ||
/** | ||
* Schema version of the password policy. | ||
*/ | ||
readonly schemaVersion: number; | ||
/** | ||
* Validates the password against the policy. | ||
* @param password Password to validate. | ||
*/ | ||
validatePassword(password: string): PasswordValidationStatus; | ||
} | ||
|
||
/** | ||
* Internal typing of password validation status that is modifiable. This allows us to | ||
* construct the validation status before returning it. | ||
* | ||
* @internal | ||
*/ | ||
export interface PasswordValidationStatusInternal | ||
extends PasswordValidationStatus { | ||
/** | ||
* Whether the password meets all requirements. | ||
*/ | ||
isValid: boolean; | ||
/** | ||
* Whether the password meets the minimum password length. | ||
*/ | ||
meetsMinPasswordLength?: boolean; | ||
/** | ||
* Whether the password meets the maximum password length. | ||
*/ | ||
meetsMaxPasswordLength?: boolean; | ||
/** | ||
* Whether the password contains a lowercase letter, if required. | ||
*/ | ||
containsLowercaseLetter?: boolean; | ||
/** | ||
* Whether the password contains an uppercase letter, if required. | ||
*/ | ||
containsUppercaseLetter?: boolean; | ||
/** | ||
* Whether the password contains a numeric character, if required. | ||
*/ | ||
containsNumericCharacter?: boolean; | ||
/** | ||
* Whether the password contains a non-alphanumeric character, if required. | ||
*/ | ||
containsNonAlphanumericCharacter?: boolean; | ||
/** | ||
* The policy used to validate the password. | ||
*/ | ||
passwordPolicy: PasswordPolicy; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be 2 private helper methods (
_checkLengthOptions
and_checkCharacterOptions
) defined inPasswordPolicyImpl
which will implement this interface. ThevalidatePassword
method will call these helpers internally. I did not include this class in this PR to make this easier to review.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add public static annotation?