Skip to content

Commit

Permalink
chore: change AuthResetPasswordStep to string union
Browse files Browse the repository at this point in the history
  • Loading branch information
israx committed Sep 13, 2023
1 parent e1f2471 commit 97ec3e3
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { decodeJWT } from '@aws-amplify/core/internals/utils';
import {
AuthResetPasswordStep,
AuthSignInResult,
} from '../../../../src/types';
import { AuthSignInResult } from '../../../../src/types';

export const authAPITestParams = {
user1: {
Expand Down Expand Up @@ -40,7 +37,7 @@ export const authAPITestParams = {
resetPasswordResult: {
isPasswordReset: false,
nextStep: {
resetPasswordStep: AuthResetPasswordStep.CONFIRM_RESET_PASSWORD_WITH_CODE,
resetPasswordStep: 'CONFIRM_RESET_PASSWORD_WITH_CODE',
codeDeliveryDetails: {
destination: '[email protected]',
deliveryMedium: 'EMAIL',
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"clean:size": "rimraf dual-publish-tmp tmp*",
"format": "echo \"Not implemented\"",
"lint": "tslint '{src}/**/*.ts' && npm run ts-coverage",
"ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 91.22"
"ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 91.21"
},
"typesVersions": {
">=3.8": {
Expand Down
1 change: 0 additions & 1 deletion packages/auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export {
signOut,
} from './providers/cognito';
export {
AuthResetPasswordStep,
AuthSignUpStep,
AuthUpdateAttributeStep
} from './types/enums';
Expand Down
3 changes: 1 addition & 2 deletions packages/auth/src/providers/cognito/apis/resetPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';
import { AuthValidationErrorCode } from '../../../errors/types/validation';
import { assertValidationError } from '../../../errors/utils/assertValidationError';
import {
AuthResetPasswordStep,
AuthStandardAttributeKey,
DeliveryMedium,
ResetPasswordRequest,
Expand Down Expand Up @@ -54,7 +53,7 @@ export async function resetPassword(
return {
isPasswordReset: false,
nextStep: {
resetPasswordStep: AuthResetPasswordStep.CONFIRM_RESET_PASSWORD_WITH_CODE,
resetPasswordStep: 'CONFIRM_RESET_PASSWORD_WITH_CODE',
codeDeliveryDetails: {
deliveryMedium: codeDeliveryDetails?.DeliveryMedium as DeliveryMedium,
destination: codeDeliveryDetails?.Destination as string,
Expand Down
7 changes: 0 additions & 7 deletions packages/auth/src/types/enums.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

/**
* Denotes the next step in the Reset Password process.
*/
export enum AuthResetPasswordStep {
CONFIRM_RESET_PASSWORD_WITH_CODE = 'CONFIRM_RESET_PASSWORD_WITH_CODE',
DONE = 'DONE',
}


/**
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export * from './Auth';

export {
AuthSignUpStep,
AuthResetPasswordStep,
AuthUpdateAttributeStep,
} from './enums';

Expand All @@ -26,6 +25,7 @@ export {
AllowedMFATypes,
AuthUser,
TOTPSetupDetails,
AuthResetPasswordStep,
} from './models';

export { AuthServiceOptions, AuthSignUpOptions } from './options';
Expand Down
11 changes: 5 additions & 6 deletions packages/auth/src/types/models.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import {
AuthResetPasswordStep,
AuthSignUpStep,
AuthUpdateAttributeStep,
} from './enums';
import { AuthSignUpStep, AuthUpdateAttributeStep } from './enums';

/**
* Additional data that may be returned from Auth APIs.
Expand All @@ -29,7 +25,10 @@ export type AuthCodeDeliveryDetails<
deliveryMedium?: DeliveryMedium;
attributeName?: UserAttributeKey;
};

/**
* Denotes the next step in the Reset Password process.
*/
export type AuthResetPasswordStep = 'CONFIRM_RESET_PASSWORD_WITH_CODE' | 'DONE';
export type AuthNextResetPasswordStep<
UserAttributeKey extends AuthUserAttributeKey = AuthUserAttributeKey
> = {
Expand Down

0 comments on commit 97ec3e3

Please sign in to comment.