Skip to content

Commit

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

import { confirmSignUp } from '../../../src/providers/cognito';
import { AuthSignUpStep } from '../../../src/types';
import * as confirmSignUpClient from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';
import { authAPITestParams } from './testUtils/authApiTestParams';
import { AuthValidationErrorCode } from '../../../src/errors/types/validation';
Expand Down Expand Up @@ -46,7 +45,7 @@ describe('confirmSignUp API Happy Path Cases:', () => {
expect(result).toEqual({
isSignUpComplete: true,
nextStep: {
signUpStep: AuthSignUpStep.DONE,
signUpStep: 'DONE',
},
});
expect(confirmSignUpClientSpy).toHaveBeenCalledWith(
Expand Down
3 changes: 1 addition & 2 deletions packages/auth/__tests__/providers/cognito/signUp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

import { signUp } from '../../../src/providers/cognito';
import { AuthSignUpStep } from '../../../src/types';
import * as signUpClient from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';
import { authAPITestParams } from './testUtils/authApiTestParams';
import { AuthValidationErrorCode } from '../../../src/errors/types/validation';
Expand Down Expand Up @@ -46,7 +45,7 @@ describe('SignUp API Happy Path Cases:', () => {
expect(result).toEqual({
isSignUpComplete: false,
nextStep: {
signUpStep: AuthSignUpStep.CONFIRM_SIGN_UP,
signUpStep: 'CONFIRM_SIGN_UP',
codeDeliveryDetails: {
destination: user1.email,
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.21"
"ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 91.20"
},
"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 {
AuthSignUpStep,
AuthUpdateAttributeStep
} from './types/enums';

Expand Down
3 changes: 1 addition & 2 deletions packages/auth/src/providers/cognito/apis/confirmSignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Amplify } from '@aws-amplify/core';
import { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';
import {
AuthSignUpResult,
AuthSignUpStep,
AuthStandardAttributeKey,
ConfirmSignUpRequest,
} from '../../../types';
Expand Down Expand Up @@ -61,7 +60,7 @@ export async function confirmSignUp(
return {
isSignUpComplete: true,
nextStep: {
signUpStep: AuthSignUpStep.DONE,
signUpStep: 'DONE',
},
};
}
5 changes: 2 additions & 3 deletions packages/auth/src/providers/cognito/apis/signUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Amplify } from '@aws-amplify/core';
import { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';
import {
AuthSignUpResult,
AuthSignUpStep,
AuthStandardAttributeKey,
DeliveryMedium,
SignUpRequest,
Expand Down Expand Up @@ -79,14 +78,14 @@ export async function signUp(
return {
isSignUpComplete: true,
nextStep: {
signUpStep: AuthSignUpStep.DONE,
signUpStep: 'DONE',
},
};
} else {
return {
isSignUpComplete: false,
nextStep: {
signUpStep: AuthSignUpStep.CONFIRM_SIGN_UP,
signUpStep: 'CONFIRM_SIGN_UP',
codeDeliveryDetails: {
deliveryMedium: CodeDeliveryDetails?.DeliveryMedium as DeliveryMedium,
destination: CodeDeliveryDetails?.Destination as string,
Expand Down
9 changes: 0 additions & 9 deletions packages/auth/src/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
// SPDX-License-Identifier: Apache-2.0



/**
* Denotes the next step in the Sign Up process.
*/
export enum AuthSignUpStep {
CONFIRM_SIGN_UP = 'CONFIRM_SIGN_UP',
DONE = 'DONE',
}

/**
* Denotes the next step in the Update User Attribute process.
*/
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 @@ -5,7 +5,6 @@
export * from './Auth';

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

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

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

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

/**
* Additional data that may be returned from Auth APIs.
Expand Down Expand Up @@ -230,6 +230,11 @@ export type AuthUserAttribute<
*/
export type AuthUserAttributeKey = AuthStandardAttributeKey | AnyAttribute;

/**
* Denotes the next step in the Sign Up process.
*/
export type AuthSignUpStep = 'CONFIRM_SIGN_UP' | 'DONE';

/**
* Data encapsulating the next step in the Sign Up process
*/
Expand Down

0 comments on commit f16ab3a

Please sign in to comment.