From 99956e404416472b02d9ea639224809b0b34da25 Mon Sep 17 00:00:00 2001 From: Simon McAllister Date: Sun, 15 Sep 2024 08:57:52 +0100 Subject: [PATCH] eslint formatting --- src/__tests__/integration/helpers.ts | 3 ++- .../integration/sdk-v2-device-flow.test.ts | 23 +++++++++--------- .../integration/sdk-v2-standard-flow.test.ts | 5 ++-- .../integration/sdk-v3-device-flow.test.ts | 24 +++++++++---------- .../integration/sdk-v3-standard-flow.test.ts | 6 ++--- src/__tests__/test-cases/index.ts | 2 +- .../respond-to-auth-challenge-response.ts | 19 ++++++++------- 7 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/__tests__/integration/helpers.ts b/src/__tests__/integration/helpers.ts index 67a9aeb..6cbde36 100644 --- a/src/__tests__/integration/helpers.ts +++ b/src/__tests__/integration/helpers.ts @@ -1,7 +1,8 @@ import { CognitoIdentityProviderClient, SignUpCommand } from "@aws-sdk/client-cognito-identity-provider"; -import { createSecretHash } from "../../cognito-srp-helper"; import { CognitoIdentityServiceProvider } from "aws-sdk"; +import { createSecretHash } from "../../cognito-srp-helper"; + type SignupOptionsV2 = { username: string; password: string; diff --git a/src/__tests__/integration/sdk-v2-device-flow.test.ts b/src/__tests__/integration/sdk-v2-device-flow.test.ts index f4992a9..6e677c1 100644 --- a/src/__tests__/integration/sdk-v2-device-flow.test.ts +++ b/src/__tests__/integration/sdk-v2-device-flow.test.ts @@ -1,6 +1,9 @@ +import { faker } from "@faker-js/faker"; import { CognitoIdentityServiceProvider } from "aws-sdk"; import dotenv from "dotenv"; import path from "path"; +import RandExp from "randexp"; +import { TOTP } from "totp-generator"; import { createDeviceVerifier, @@ -12,9 +15,7 @@ import { wrapAuthChallenge, wrapInitiateAuth, } from "../../cognito-srp-helper"; -import { faker } from "@faker-js/faker"; -import RandExp from "randexp"; -import { TOTP } from "totp-generator"; + import { signupV2 } from "./helpers"; // Load in env variables from .env if it / they exist.. @@ -190,7 +191,7 @@ describe("SDK v2 integration - DEVICE_SRP_AUTH flow", () => { if (!SecretCode) throw Error("SecretCode is undefined"); const { otp: otp1, expires } = TOTP.generate(SecretCode); - const verifySoftwareTokenRes = await cognitoIdentityServiceProvider + await cognitoIdentityServiceProvider .verifySoftwareToken({ AccessToken, UserCode: otp1, @@ -199,7 +200,7 @@ describe("SDK v2 integration - DEVICE_SRP_AUTH flow", () => { // ---------- Set MFA preference to TOTP ---------- - const setUserMFAPreferenceRes = await cognitoIdentityServiceProvider + await cognitoIdentityServiceProvider .setUserMFAPreference({ AccessToken, SoftwareTokenMfaSettings: { @@ -279,7 +280,7 @@ describe("SDK v2 integration - DEVICE_SRP_AUTH flow", () => { if (!DeviceKey) throw Error("DeviceKey is undefined"); const { DeviceSecretVerifierConfig, DeviceRandomPassword } = createDeviceVerifier(DeviceKey, DeviceGroupKey); - const confirmDeviceRes = await cognitoIdentityServiceProvider + await cognitoIdentityServiceProvider .confirmDevice({ AccessToken, DeviceKey, @@ -290,7 +291,7 @@ describe("SDK v2 integration - DEVICE_SRP_AUTH flow", () => { // ---------- Remember the device (for easier logins) ---------- - const updateDeviceStatusRes = await cognitoIdentityServiceProvider + await cognitoIdentityServiceProvider .updateDeviceStatus({ AccessToken, DeviceKey, @@ -461,7 +462,7 @@ describe("SDK v2 integration - DEVICE_SRP_AUTH flow", () => { if (!SecretCode) throw Error("SecretCode is undefined"); const { otp: otp1, expires } = TOTP.generate(SecretCode); - const verifySoftwareTokenRes = await cognitoIdentityServiceProvider + await cognitoIdentityServiceProvider .verifySoftwareToken({ AccessToken, UserCode: otp1, @@ -470,7 +471,7 @@ describe("SDK v2 integration - DEVICE_SRP_AUTH flow", () => { // ---------- Set MFA preference to TOTP ---------- - const setUserMFAPreferenceRes = await cognitoIdentityServiceProvider + await cognitoIdentityServiceProvider .adminSetUserMFAPreference({ UserPoolId: poolId, Username: username, @@ -554,7 +555,7 @@ describe("SDK v2 integration - DEVICE_SRP_AUTH flow", () => { if (!DeviceKey) throw Error("DeviceKey is undefined"); const { DeviceSecretVerifierConfig, DeviceRandomPassword } = createDeviceVerifier(DeviceKey, DeviceGroupKey); - const confirmDeviceRes = await cognitoIdentityServiceProvider + await cognitoIdentityServiceProvider .confirmDevice({ AccessToken, DeviceKey, @@ -565,7 +566,7 @@ describe("SDK v2 integration - DEVICE_SRP_AUTH flow", () => { // ---------- Remember the device (for easier logins) ---------- - const updateDeviceStatusRes = await cognitoIdentityServiceProvider + await cognitoIdentityServiceProvider .adminUpdateDeviceStatus({ UserPoolId: poolId, Username: USER_ID_FOR_SRP, diff --git a/src/__tests__/integration/sdk-v2-standard-flow.test.ts b/src/__tests__/integration/sdk-v2-standard-flow.test.ts index 3340cef..36010ee 100644 --- a/src/__tests__/integration/sdk-v2-standard-flow.test.ts +++ b/src/__tests__/integration/sdk-v2-standard-flow.test.ts @@ -1,6 +1,8 @@ +import { faker } from "@faker-js/faker"; import { CognitoIdentityServiceProvider } from "aws-sdk"; import dotenv from "dotenv"; import path from "path"; +import RandExp from "randexp"; import { createPasswordHash, @@ -10,8 +12,7 @@ import { wrapAuthChallenge, wrapInitiateAuth, } from "../../cognito-srp-helper"; -import { faker } from "@faker-js/faker"; -import RandExp from "randexp"; + import { signupV2 } from "./helpers"; // Load in env variables from .env if it / they exist.. diff --git a/src/__tests__/integration/sdk-v3-device-flow.test.ts b/src/__tests__/integration/sdk-v3-device-flow.test.ts index 090ca69..648d112 100644 --- a/src/__tests__/integration/sdk-v3-device-flow.test.ts +++ b/src/__tests__/integration/sdk-v3-device-flow.test.ts @@ -9,12 +9,14 @@ import { InitiateAuthCommand, RespondToAuthChallengeCommand, SetUserMFAPreferenceCommand, - SignUpCommand, UpdateDeviceStatusCommand, VerifySoftwareTokenCommand, } from "@aws-sdk/client-cognito-identity-provider"; +import { faker } from "@faker-js/faker"; import dotenv from "dotenv"; import path from "path"; +import RandExp from "randexp"; +import { TOTP } from "totp-generator"; import { createDeviceVerifier, @@ -26,9 +28,7 @@ import { wrapAuthChallenge, wrapInitiateAuth, } from "../../cognito-srp-helper"; -import { faker } from "@faker-js/faker"; -import RandExp from "randexp"; -import { TOTP } from "totp-generator"; + import { signupV3 } from "./helpers"; // Load in env variables from .env if it / they exist.. @@ -196,7 +196,7 @@ describe("SDK v3 integration - DEVICE_SRP_AUTH flow", () => { if (!SecretCode) throw Error("SecretCode is undefined"); const { otp: otp1, expires } = TOTP.generate(SecretCode); - const verifySoftwareTokenRes = await cognitoIdentityProviderClient.send( + await cognitoIdentityProviderClient.send( new VerifySoftwareTokenCommand({ AccessToken, UserCode: otp1, @@ -205,7 +205,7 @@ describe("SDK v3 integration - DEVICE_SRP_AUTH flow", () => { // ---------- Set MFA preference to TOTP ---------- - const setUserMFAPreferenceRes = await cognitoIdentityProviderClient.send( + await cognitoIdentityProviderClient.send( new AdminSetUserMFAPreferenceCommand({ UserPoolId: poolId, Username: username, @@ -286,7 +286,7 @@ describe("SDK v3 integration - DEVICE_SRP_AUTH flow", () => { if (!DeviceKey) throw Error("DeviceKey is undefined"); const { DeviceSecretVerifierConfig, DeviceRandomPassword } = createDeviceVerifier(DeviceKey, DeviceGroupKey); - const confirmDeviceRes = await cognitoIdentityProviderClient.send( + await cognitoIdentityProviderClient.send( new ConfirmDeviceCommand({ AccessToken, DeviceKey, @@ -297,7 +297,7 @@ describe("SDK v3 integration - DEVICE_SRP_AUTH flow", () => { // ---------- Remember the device (for easier logins) ---------- - const updateDeviceStatusRes = await cognitoIdentityProviderClient.send( + await cognitoIdentityProviderClient.send( new UpdateDeviceStatusCommand({ AccessToken, DeviceKey, @@ -468,7 +468,7 @@ describe("SDK v3 integration - DEVICE_SRP_AUTH flow", () => { if (!SecretCode) throw Error("SecretCode is undefined"); const { otp: otp1, expires } = TOTP.generate(SecretCode); - const verifySoftwareTokenRes = await cognitoIdentityProviderClient.send( + await cognitoIdentityProviderClient.send( new VerifySoftwareTokenCommand({ AccessToken, UserCode: otp1, @@ -477,7 +477,7 @@ describe("SDK v3 integration - DEVICE_SRP_AUTH flow", () => { // ---------- Set MFA preference to TOTP ---------- - const setUserMFAPreferenceRes = await cognitoIdentityProviderClient.send( + await cognitoIdentityProviderClient.send( new SetUserMFAPreferenceCommand({ AccessToken, SoftwareTokenMfaSettings: { @@ -560,7 +560,7 @@ describe("SDK v3 integration - DEVICE_SRP_AUTH flow", () => { if (!DeviceKey) throw Error("DeviceKey is undefined"); const { DeviceSecretVerifierConfig, DeviceRandomPassword } = createDeviceVerifier(DeviceKey, DeviceGroupKey); - const confirmDeviceRes = await cognitoIdentityProviderClient.send( + await cognitoIdentityProviderClient.send( new ConfirmDeviceCommand({ AccessToken, DeviceKey, @@ -571,7 +571,7 @@ describe("SDK v3 integration - DEVICE_SRP_AUTH flow", () => { // ---------- Remember the device (for easier logins) ---------- - const updateDeviceStatusRes = await cognitoIdentityProviderClient.send( + await cognitoIdentityProviderClient.send( new AdminUpdateDeviceStatusCommand({ UserPoolId: poolId, Username: USER_ID_FOR_SRP, diff --git a/src/__tests__/integration/sdk-v3-standard-flow.test.ts b/src/__tests__/integration/sdk-v3-standard-flow.test.ts index a705636..9aacf37 100644 --- a/src/__tests__/integration/sdk-v3-standard-flow.test.ts +++ b/src/__tests__/integration/sdk-v3-standard-flow.test.ts @@ -4,10 +4,11 @@ import { CognitoIdentityProviderClient, InitiateAuthCommand, RespondToAuthChallengeCommand, - SignUpCommand, } from "@aws-sdk/client-cognito-identity-provider"; +import { faker } from "@faker-js/faker"; import dotenv from "dotenv"; import path from "path"; +import RandExp from "randexp"; import { createPasswordHash, @@ -17,8 +18,7 @@ import { wrapAuthChallenge, wrapInitiateAuth, } from "../../cognito-srp-helper"; -import { faker } from "@faker-js/faker"; -import RandExp from "randexp"; + import { signupV3 } from "./helpers"; // Load in env variables from .env if it / they exist.. diff --git a/src/__tests__/test-cases/index.ts b/src/__tests__/test-cases/index.ts index b964b2f..7d27dec 100644 --- a/src/__tests__/test-cases/index.ts +++ b/src/__tests__/test-cases/index.ts @@ -4,8 +4,8 @@ export * from "./credentials"; export * from "./initiate-auth-request"; export * from "./initiate-auth-response"; export * from "./initiate-auth-response-with-new-device"; -export * from "./respond-to-auth-challenge-response"; export * from "./respond-to-auth-challenge-request"; +export * from "./respond-to-auth-challenge-response"; export * from "./srp-sessions"; export * from "./srp-sessions-signed"; export * from "./timestamps"; diff --git a/src/__tests__/test-cases/respond-to-auth-challenge-response.ts b/src/__tests__/test-cases/respond-to-auth-challenge-response.ts index 231e48b..0a2d311 100644 --- a/src/__tests__/test-cases/respond-to-auth-challenge-response.ts +++ b/src/__tests__/test-cases/respond-to-auth-challenge-response.ts @@ -78,7 +78,8 @@ export const positiveRespondToAuthChallengeResponses: Record