diff --git a/packages/auth/__tests__/providers/cognito/updateUserAttributes.test.ts b/packages/auth/__tests__/providers/cognito/updateUserAttributes.test.ts index 2a10e1d04fe..04434b173e3 100644 --- a/packages/auth/__tests__/providers/cognito/updateUserAttributes.test.ts +++ b/packages/auth/__tests__/providers/cognito/updateUserAttributes.test.ts @@ -12,7 +12,6 @@ import { fetchTransferHandler } from '@aws-amplify/core/internals/aws-client-uti import { buildMockErrorResponse, mockJsonResponse } from './testUtils/data'; import { UpdateUserAttributesCommandOutput } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider/types'; import { toAttributeType } from '../../../src/providers/cognito/utils/apiHelpers'; -import { AuthUpdateAttributeStep } from '../../../src/types/enums'; jest.mock('@aws-amplify/core/lib/clients/handlers/fetch'); Amplify.configure({ @@ -86,22 +85,21 @@ describe('updateUserAttributes API happy path cases', () => { expect(result.address).toEqual({ isUpdated: true, nextStep: { - updateAttributeStep: AuthUpdateAttributeStep.DONE, + updateAttributeStep: 'DONE', }, }); expect(result.name).toEqual({ isUpdated: true, nextStep: { - updateAttributeStep: AuthUpdateAttributeStep.DONE, + updateAttributeStep: 'DONE', }, }); expect(result.email).toEqual({ isUpdated: false, nextStep: { - updateAttributeStep: - AuthUpdateAttributeStep.CONFIRM_ATTRIBUTE_WITH_CODE, + updateAttributeStep: 'CONFIRM_ATTRIBUTE_WITH_CODE', codeDeliveryDetails: { attributeName: 'email', deliveryMedium: 'EMAIL', @@ -113,8 +111,7 @@ describe('updateUserAttributes API happy path cases', () => { expect(result.phone_number).toEqual({ isUpdated: false, nextStep: { - updateAttributeStep: - AuthUpdateAttributeStep.CONFIRM_ATTRIBUTE_WITH_CODE, + updateAttributeStep: 'CONFIRM_ATTRIBUTE_WITH_CODE', codeDeliveryDetails: { attributeName: 'phone_number', deliveryMedium: 'SMS', @@ -157,14 +154,14 @@ describe('updateUserAttributes API happy path cases', () => { expect(result.address).toEqual({ isUpdated: true, nextStep: { - updateAttributeStep: AuthUpdateAttributeStep.DONE, + updateAttributeStep: 'DONE', }, }); expect(result.name).toEqual({ isUpdated: true, nextStep: { - updateAttributeStep: AuthUpdateAttributeStep.DONE, + updateAttributeStep: 'DONE', }, }); @@ -215,8 +212,7 @@ describe('updateUserAttributes API happy path cases', () => { expect(result.email).toEqual({ isUpdated: false, nextStep: { - updateAttributeStep: - AuthUpdateAttributeStep.CONFIRM_ATTRIBUTE_WITH_CODE, + updateAttributeStep: 'CONFIRM_ATTRIBUTE_WITH_CODE', codeDeliveryDetails: { attributeName: 'email', deliveryMedium: 'EMAIL', @@ -228,8 +224,7 @@ describe('updateUserAttributes API happy path cases', () => { expect(result.phone_number).toEqual({ isUpdated: false, nextStep: { - updateAttributeStep: - AuthUpdateAttributeStep.CONFIRM_ATTRIBUTE_WITH_CODE, + updateAttributeStep: 'CONFIRM_ATTRIBUTE_WITH_CODE', codeDeliveryDetails: { attributeName: 'phone_number', deliveryMedium: 'SMS', diff --git a/packages/auth/package.json b/packages/auth/package.json index 202aeeea487..707e27a39c3 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.20" + "ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 91.19" }, "typesVersions": { ">=3.8": { diff --git a/packages/auth/src/index.ts b/packages/auth/src/index.ts index c6a19f1fac2..96975b4ebee 100644 --- a/packages/auth/src/index.ts +++ b/packages/auth/src/index.ts @@ -22,9 +22,6 @@ export { fetchUserAttributes, signOut, } from './providers/cognito'; -export { - AuthUpdateAttributeStep -} from './types/enums'; export { AuthError } from './errors/AuthError'; diff --git a/packages/auth/src/providers/cognito/apis/updateUserAttributes.ts b/packages/auth/src/providers/cognito/apis/updateUserAttributes.ts index 3aafdf04beb..d052024da4b 100644 --- a/packages/auth/src/providers/cognito/apis/updateUserAttributes.ts +++ b/packages/auth/src/providers/cognito/apis/updateUserAttributes.ts @@ -19,7 +19,6 @@ import { assertAuthTokens } from '../utils/types'; import { getRegion } from '../utils/clients/CognitoIdentityProvider/utils'; import { toAttributeType } from '../utils/apiHelpers'; import { CodeDeliveryDetailsType } from '../utils/clients/CognitoIdentityProvider/types'; -import { AuthUpdateAttributeStep } from '../../../types/enums'; import { UpdateUserAttributesException } from '../types/errors'; /** @@ -68,7 +67,7 @@ function getConfirmedAttributes( confirmedAttributes[key] = { isUpdated: true, nextStep: { - updateAttributeStep: AuthUpdateAttributeStep.DONE, + updateAttributeStep: 'DONE', }, }; }); @@ -86,8 +85,7 @@ function getUnConfirmedAttributes( unConfirmedAttributes[AttributeName] = { isUpdated: false, nextStep: { - updateAttributeStep: - AuthUpdateAttributeStep.CONFIRM_ATTRIBUTE_WITH_CODE, + updateAttributeStep: 'CONFIRM_ATTRIBUTE_WITH_CODE', codeDeliveryDetails: { attributeName: AttributeName, deliveryMedium: DeliveryMedium as DeliveryMedium, diff --git a/packages/auth/src/types/enums.ts b/packages/auth/src/types/enums.ts deleted file mode 100644 index 13fe2b9ce1e..00000000000 --- a/packages/auth/src/types/enums.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - - -/** - * Denotes the next step in the Update User Attribute process. - */ -export enum AuthUpdateAttributeStep { - /** - * Auth update attribute step requires user to confirm an attribute with a code sent to cellphone or email. - */ - CONFIRM_ATTRIBUTE_WITH_CODE = 'CONFIRM_ATTRIBUTE_WITH_CODE', - - /** - * Auth update attribute step indicates that the attribute is updated. - */ - DONE = 'DONE', -} diff --git a/packages/auth/src/types/index.ts b/packages/auth/src/types/index.ts index 34a3fe28768..78732345098 100644 --- a/packages/auth/src/types/index.ts +++ b/packages/auth/src/types/index.ts @@ -4,10 +4,6 @@ // TODO: Remove "./Auth" export export * from './Auth'; -export { - AuthUpdateAttributeStep, -} from './enums'; - export { AdditionalInfo, DeliveryMedium, @@ -25,7 +21,8 @@ export { AuthUser, TOTPSetupDetails, AuthResetPasswordStep, - AuthSignUpStep + AuthSignUpStep, + AuthUpdateAttributeStep, } from './models'; export { AuthServiceOptions, AuthSignUpOptions } from './options'; diff --git a/packages/auth/src/types/models.ts b/packages/auth/src/types/models.ts index c4c34377098..2cb5e0e26a3 100644 --- a/packages/auth/src/types/models.ts +++ b/packages/auth/src/types/models.ts @@ -1,8 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { AuthUpdateAttributeStep } from './enums'; - /** * Additional data that may be returned from Auth APIs. */ @@ -246,20 +244,26 @@ export type AuthNextSignUpStep< codeDeliveryDetails?: AuthCodeDeliveryDetails; }; -export type ConfirmAttributeWithCodeAttributeStep< - UserAttributeKey extends AuthUserAttributeKey = AuthUserAttributeKey -> = { - updateAttributeStep: AuthUpdateAttributeStep.CONFIRM_ATTRIBUTE_WITH_CODE; - codeDeliveryDetails: AuthCodeDeliveryDetails; -}; +/** + * Denotes the next step in the Update User Attribute process. + */ +export type AuthUpdateAttributeStep = + /** + * Auth update attribute step requires user to confirm an attribute with a code sent to cellphone or email. + */ + | 'CONFIRM_ATTRIBUTE_WITH_CODE' -export type DoneAttributeStep = { - updateAttributeStep: AuthUpdateAttributeStep.DONE; -}; + /** + * Auth update attribute step indicates that the attribute is updated. + */ + | 'DONE'; export type AuthNextUpdateAttributeStep< UserAttributeKey extends AuthUserAttributeKey = AuthUserAttributeKey -> = ConfirmAttributeWithCodeAttributeStep | DoneAttributeStep; +> = { + updateAttributeStep: AuthUpdateAttributeStep; + codeDeliveryDetails?: AuthCodeDeliveryDetails; +}; /** * The AuthUser object contains username and userId from the idToken.