-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
121 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,26 @@ | ||
import assert from 'assert'; | ||
|
||
export const COGNITO_ERRORS = { | ||
'Incorrect username or password.': 'NotAuthorizedException', | ||
'Invalid email address format.': 'InvalidParameterException', | ||
"1 validation error detected: Value at 'username' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+": | ||
'InvalidParameterException', | ||
'Password did not conform with policy: Password must have lowercase characters': | ||
'InvalidPasswordException', | ||
'Password did not conform with policy: Password must have uppercase characters': | ||
'InvalidPasswordException', | ||
'Password did not conform with policy: Password must have numeric characters': | ||
'InvalidPasswordException', | ||
'Password did not conform with policy: Password must have symbol characters': | ||
'InvalidPasswordException', | ||
'Password did not conform with policy: Password not long enough': 'InvalidPasswordException', | ||
'User already exists': 'UsernameExistsException', | ||
'Invalid verification code provided, please try again.': 'CodeMismatchException', | ||
'User is not confirmed.': 'UserNotConfirmedException', | ||
}; | ||
|
||
export class CognitoError extends Error {} | ||
|
||
export function cognitoAssert(val: unknown, msg: keyof typeof COGNITO_ERRORS): asserts val { | ||
assert(val, new CognitoError(msg)); | ||
} |
This file contains 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
This file contains 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
This file contains 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