From 97ec3e34d33557f67ded66912e4bdd80041959f0 Mon Sep 17 00:00:00 2001 From: Israel Arcos Date: Wed, 13 Sep 2023 11:28:48 -0400 Subject: [PATCH] chore: change AuthResetPasswordStep to string union --- .../providers/cognito/testUtils/authApiTestParams.ts | 7 ++----- packages/auth/package.json | 2 +- packages/auth/src/index.ts | 1 - .../auth/src/providers/cognito/apis/resetPassword.ts | 3 +-- packages/auth/src/types/enums.ts | 7 ------- packages/auth/src/types/index.ts | 2 +- packages/auth/src/types/models.ts | 11 +++++------ 7 files changed, 10 insertions(+), 23 deletions(-) diff --git a/packages/auth/__tests__/providers/cognito/testUtils/authApiTestParams.ts b/packages/auth/__tests__/providers/cognito/testUtils/authApiTestParams.ts index ebad7e300ff..ecdf97d5120 100644 --- a/packages/auth/__tests__/providers/cognito/testUtils/authApiTestParams.ts +++ b/packages/auth/__tests__/providers/cognito/testUtils/authApiTestParams.ts @@ -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: { @@ -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: 'test@email.com', deliveryMedium: 'EMAIL', diff --git a/packages/auth/package.json b/packages/auth/package.json index 46e604ff3ca..82d7b1342a1 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -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": { diff --git a/packages/auth/src/index.ts b/packages/auth/src/index.ts index b0124205496..eaa2471d6e3 100644 --- a/packages/auth/src/index.ts +++ b/packages/auth/src/index.ts @@ -23,7 +23,6 @@ export { signOut, } from './providers/cognito'; export { - AuthResetPasswordStep, AuthSignUpStep, AuthUpdateAttributeStep } from './types/enums'; diff --git a/packages/auth/src/providers/cognito/apis/resetPassword.ts b/packages/auth/src/providers/cognito/apis/resetPassword.ts index d2aff689bd6..6d23aaecce6 100644 --- a/packages/auth/src/providers/cognito/apis/resetPassword.ts +++ b/packages/auth/src/providers/cognito/apis/resetPassword.ts @@ -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, @@ -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, diff --git a/packages/auth/src/types/enums.ts b/packages/auth/src/types/enums.ts index 8db4d592e71..fee46d09578 100644 --- a/packages/auth/src/types/enums.ts +++ b/packages/auth/src/types/enums.ts @@ -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', -} /** diff --git a/packages/auth/src/types/index.ts b/packages/auth/src/types/index.ts index 952c8789a1b..51310a4ec70 100644 --- a/packages/auth/src/types/index.ts +++ b/packages/auth/src/types/index.ts @@ -6,7 +6,6 @@ export * from './Auth'; export { AuthSignUpStep, - AuthResetPasswordStep, AuthUpdateAttributeStep, } from './enums'; @@ -26,6 +25,7 @@ export { AllowedMFATypes, AuthUser, TOTPSetupDetails, + AuthResetPasswordStep, } from './models'; export { AuthServiceOptions, AuthSignUpOptions } from './options'; diff --git a/packages/auth/src/types/models.ts b/packages/auth/src/types/models.ts index 1ab70fcdcb7..e01de34b20f 100644 --- a/packages/auth/src/types/models.ts +++ b/packages/auth/src/types/models.ts @@ -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. @@ -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 > = {