Skip to content
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

fix(Authenticator): fix sms no challengeName #5068

Merged
merged 5 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ describe('authenticatorTextUtil', () => {
).toEqual('Confirm TOTP Code');
});

it('throws an error for unexpected challenge names', () => {
expect(() =>
it('returns default text for unexpected challenge names', () => {
expect(
// @ts-expect-error
authenticatorTextUtil.getChallengeText('invalidChallenge')
).toThrow(
'Unexpected challengeName encountered in ConfirmSignIn: invalidChallenge'
);
).toEqual('Confirm MFA Code');
});
});

Expand Down
6 changes: 1 addition & 5 deletions packages/ui/src/helpers/authenticator/textUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ const getChallengeText = (challengeName?: ChallengeName): string => {
case 'SOFTWARE_TOKEN_MFA':
return translate(DefaultTexts.CONFIRM_TOTP);
default:
throw new Error(
`${translate(
'Unexpected challengeName encountered in ConfirmSignIn:'
)} ${challengeName}`
);
return translate(DefaultTexts.CONFIRM_MFA_DEFAULT);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const defaultTexts = {
CONFIRM_RESET_PASSWORD_HEADING: 'Reset your Password',
CONFIRM_SIGNUP_HEADING: 'Confirm Sign Up',
CONFIRM_SMS: 'Confirm SMS Code',
// If challenge name is not returned
CONFIRM_MFA_DEFAULT: 'Confirm MFA Code',
CONFIRM_TOTP: 'Confirm TOTP Code',
CONFIRM: 'Confirm',
CONFIRMATION_CODE: 'Confirmation Code',
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/i18n/dictionaries/authenticator/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const enDict: AuthenticatorDictionary = {
'Confirm Password': 'Confirm Password',
'Confirm Sign Up': 'Confirm Sign Up',
'Confirm SMS Code': 'Confirm SMS Code',
'Confirm MFA Code': 'Confirm MFA Code',
'Confirm TOTP Code': 'Confirm TOTP Code',
Confirm: 'Confirm',
'Confirmation Code': 'Confirmation Code',
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/machines/authenticator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export function createAuthenticatorMachine(
]),
setActorDoneData: assign({
actorDoneData: (context, event): ActorDoneData => ({
challengeName: event.data.challengeName,
codeDeliveryDetails: event.data.codeDeliveryDetails,
missingAttributes: event.data.missingAttributes,
remoteError: event.data.remoteError,
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/machines/authenticator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export interface AuthEvent {
* Data that actor returns when they are done and reach the final state
*/
export interface ActorDoneData {
challengeName?: ChallengeName;
codeDeliveryDetails?: V5CodeDeliveryDetails;
missingAttributes?: string[];
remoteError?: string;
Expand Down Expand Up @@ -173,7 +174,7 @@ type Step =
* Base context for all actors that have auth forms associated
*/
interface BaseFormContext {
// key/values dereived directly from Auth API return values
// key/values derived directly from Auth API return values
challengeName?: ChallengeName;
missingAttributes?: Array<string>;
remoteError?: string;
Expand Down
Loading