@aws-amplify/auth 6.5.1-email-mfa-test.4e655bc.0 → 6.5.1-storage-browser.4db9fef.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/AuthErrorStrings.js +2 -2
- package/dist/cjs/common/AuthErrorStrings.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/confirmSignIn.js +2 -2
- package/dist/cjs/providers/cognito/apis/confirmSignIn.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/updateMFAPreference.js +1 -2
- package/dist/cjs/providers/cognito/apis/updateMFAPreference.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/signInHelpers.js +130 -183
- package/dist/cjs/providers/cognito/utils/signInHelpers.js.map +1 -1
- package/dist/esm/common/AuthErrorStrings.mjs +2 -2
- package/dist/esm/common/AuthErrorStrings.mjs.map +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/constants.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createAssociateSoftwareTokenClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createChangePasswordClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmDeviceClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmForgotPasswordClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmSignUpClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createDeleteUserAttributesClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createDeleteUserClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createForgetDeviceClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createForgotPasswordClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGetUserAttributeVerificationCodeClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGetUserClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGlobalSignOutClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createInitiateAuthClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createListDevicesClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createResendConfirmationCodeClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createRespondToAuthChallengeClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createRevokeTokenClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createSetUserMFAPreferenceClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createSignUpClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createUpdateDeviceStatusClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createUpdateUserAttributesClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createVerifySoftwareTokenClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createVerifyUserAttributeClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/types/sdk.d.ts +3 -24
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs +2 -2
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/updateMFAPreference.mjs +1 -2
- package/dist/esm/providers/cognito/apis/updateMFAPreference.mjs.map +1 -1
- package/dist/esm/providers/cognito/types/inputs.d.ts +0 -1
- package/dist/esm/providers/cognito/utils/signInHelpers.d.ts +3 -4
- package/dist/esm/providers/cognito/utils/signInHelpers.mjs +127 -181
- package/dist/esm/providers/cognito/utils/signInHelpers.mjs.map +1 -1
- package/dist/esm/types/models.d.ts +2 -44
- package/package.json +5 -5
- package/src/common/AuthErrorStrings.ts +2 -4
- package/src/foundation/factories/serviceClients/cognitoIdentityProvider/types/sdk.ts +1 -23
- package/src/providers/cognito/apis/confirmSignIn.ts +2 -2
- package/src/providers/cognito/apis/updateMFAPreference.ts +1 -2
- package/src/providers/cognito/types/inputs.ts +0 -1
- package/src/providers/cognito/utils/signInHelpers.ts +166 -240
- package/src/types/models.ts +1 -48
|
@@ -9,7 +9,7 @@ export declare const createRevokeTokenClient: (config: ServiceClientFactoryInput
|
|
|
9
9
|
url: URL;
|
|
10
10
|
})) | undefined;
|
|
11
11
|
service?: string | undefined;
|
|
12
|
-
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<
|
|
12
|
+
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
|
|
13
13
|
computeDelay?: ((attempt: number) => number) | undefined;
|
|
14
14
|
userAgentValue?: string | undefined;
|
|
15
15
|
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
|
|
@@ -4,7 +4,7 @@ export declare const createSetUserMFAPreferenceClient: (config: ServiceClientFac
|
|
|
4
4
|
url: URL;
|
|
5
5
|
})) | undefined;
|
|
6
6
|
service?: string | undefined;
|
|
7
|
-
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<
|
|
7
|
+
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
|
|
8
8
|
computeDelay?: ((attempt: number) => number) | undefined;
|
|
9
9
|
userAgentValue?: string | undefined;
|
|
10
10
|
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
|
package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createSignUpClient.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const createSignUpClient: (config: ServiceClientFactoryInput) =>
|
|
|
4
4
|
url: URL;
|
|
5
5
|
})) | undefined;
|
|
6
6
|
service?: string | undefined;
|
|
7
|
-
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<
|
|
7
|
+
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
|
|
8
8
|
computeDelay?: ((attempt: number) => number) | undefined;
|
|
9
9
|
userAgentValue?: string | undefined;
|
|
10
10
|
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
|
|
@@ -4,7 +4,7 @@ export declare const createUpdateDeviceStatusClient: (config: ServiceClientFacto
|
|
|
4
4
|
url: URL;
|
|
5
5
|
})) | undefined;
|
|
6
6
|
service?: string | undefined;
|
|
7
|
-
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<
|
|
7
|
+
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
|
|
8
8
|
computeDelay?: ((attempt: number) => number) | undefined;
|
|
9
9
|
userAgentValue?: string | undefined;
|
|
10
10
|
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
|
|
@@ -4,7 +4,7 @@ export declare const createUpdateUserAttributesClient: (config: ServiceClientFac
|
|
|
4
4
|
url: URL;
|
|
5
5
|
})) | undefined;
|
|
6
6
|
service?: string | undefined;
|
|
7
|
-
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<
|
|
7
|
+
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
|
|
8
8
|
computeDelay?: ((attempt: number) => number) | undefined;
|
|
9
9
|
userAgentValue?: string | undefined;
|
|
10
10
|
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
|
|
@@ -4,7 +4,7 @@ export declare const createVerifySoftwareTokenClient: (config: ServiceClientFact
|
|
|
4
4
|
url: URL;
|
|
5
5
|
})) | undefined;
|
|
6
6
|
service?: string | undefined;
|
|
7
|
-
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<
|
|
7
|
+
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
|
|
8
8
|
computeDelay?: ((attempt: number) => number) | undefined;
|
|
9
9
|
userAgentValue?: string | undefined;
|
|
10
10
|
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
|
|
@@ -4,7 +4,7 @@ export declare const createVerifyUserAttributeClient: (config: ServiceClientFact
|
|
|
4
4
|
url: URL;
|
|
5
5
|
})) | undefined;
|
|
6
6
|
service?: string | undefined;
|
|
7
|
-
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<
|
|
7
|
+
retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
|
|
8
8
|
computeDelay?: ((attempt: number) => number) | undefined;
|
|
9
9
|
userAgentValue?: string | undefined;
|
|
10
10
|
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MetadataBearer as __MetadataBearer } from '@aws-sdk/types';
|
|
2
|
-
export type ChallengeName = 'SMS_MFA' | 'SOFTWARE_TOKEN_MFA' | '
|
|
2
|
+
export type ChallengeName = 'SMS_MFA' | 'SOFTWARE_TOKEN_MFA' | 'SELECT_MFA_TYPE' | 'MFA_SETUP' | 'PASSWORD_VERIFIER' | 'CUSTOM_CHALLENGE' | 'DEVICE_SRP_AUTH' | 'DEVICE_PASSWORD_VERIFIER' | 'ADMIN_NO_SRP_AUTH' | 'NEW_PASSWORD_REQUIRED';
|
|
3
3
|
export type ChallengeParameters = {
|
|
4
4
|
CODE_DELIVERY_DESTINATION?: string;
|
|
5
5
|
CODE_DELIVERY_DELIVERY_MEDIUM?: string;
|
|
@@ -10,7 +10,7 @@ export type ChallengeParameters = {
|
|
|
10
10
|
MFAS_CAN_CHOOSE?: string;
|
|
11
11
|
MFAS_CAN_SETUP?: string;
|
|
12
12
|
} & Record<string, unknown>;
|
|
13
|
-
export type CognitoMFAType = 'SMS_MFA' | 'SOFTWARE_TOKEN_MFA'
|
|
13
|
+
export type CognitoMFAType = 'SMS_MFA' | 'SOFTWARE_TOKEN_MFA';
|
|
14
14
|
export interface CognitoMFASettings {
|
|
15
15
|
Enabled?: boolean;
|
|
16
16
|
PreferredMfa?: boolean;
|
|
@@ -34,8 +34,7 @@ declare enum ChallengeNameType {
|
|
|
34
34
|
PASSWORD_VERIFIER = "PASSWORD_VERIFIER",
|
|
35
35
|
SELECT_MFA_TYPE = "SELECT_MFA_TYPE",
|
|
36
36
|
SMS_MFA = "SMS_MFA",
|
|
37
|
-
SOFTWARE_TOKEN_MFA = "SOFTWARE_TOKEN_MFA"
|
|
38
|
-
EMAIL_OTP = "EMAIL_OTP"
|
|
37
|
+
SOFTWARE_TOKEN_MFA = "SOFTWARE_TOKEN_MFA"
|
|
39
38
|
}
|
|
40
39
|
declare enum DeliveryMediumType {
|
|
41
40
|
EMAIL = "EMAIL",
|
|
@@ -1067,10 +1066,6 @@ export interface SetUserMFAPreferenceRequest {
|
|
|
1067
1066
|
* <p>The time-based one-time password software token MFA settings.</p>
|
|
1068
1067
|
*/
|
|
1069
1068
|
SoftwareTokenMfaSettings?: SoftwareTokenMfaSettingsType;
|
|
1070
|
-
/**
|
|
1071
|
-
* <p>The email message multi-factor authentication (MFA) settings.</p>
|
|
1072
|
-
*/
|
|
1073
|
-
EmailMfaSettings?: EmailMfaSettingsType;
|
|
1074
1069
|
/**
|
|
1075
1070
|
* <p>The access token for the user.</p>
|
|
1076
1071
|
*/
|
|
@@ -1180,22 +1175,6 @@ export interface SoftwareTokenMfaSettingsType {
|
|
|
1180
1175
|
*/
|
|
1181
1176
|
PreferredMfa?: boolean;
|
|
1182
1177
|
}
|
|
1183
|
-
/**
|
|
1184
|
-
* <p>The type used for enabling email MFA at the user level. If an MFA type is activated for a user, the user will be prompted for MFA during all sign-in attempts, unless device tracking
|
|
1185
|
-
* is turned on and the device has been trusted. If you want MFA to be applied selectively based on the assessed risk level of sign-in attempts, deactivate MFA for users and turn on Adaptive
|
|
1186
|
-
* Authentication for the user pool.</p>
|
|
1187
|
-
*/
|
|
1188
|
-
export interface EmailMfaSettingsType {
|
|
1189
|
-
/**
|
|
1190
|
-
* <p>Specifies whether email MFA is activated. If an MFA type is activated for a user, the user will be prompted for MFA during all sign-in attempts, unless device tracking is turned
|
|
1191
|
-
* on and the device has been trusted.</p>
|
|
1192
|
-
*/
|
|
1193
|
-
Enabled?: boolean;
|
|
1194
|
-
/**
|
|
1195
|
-
* <p>Specifies whether email MFA is the preferred MFA method.</p>
|
|
1196
|
-
*/
|
|
1197
|
-
PreferredMfa?: boolean;
|
|
1198
|
-
}
|
|
1199
1178
|
export type UpdateDeviceStatusCommandInput = UpdateDeviceStatusRequest;
|
|
1200
1179
|
export interface UpdateDeviceStatusCommandOutput extends UpdateDeviceStatusResponse, __MetadataBearer {
|
|
1201
1180
|
}
|
|
@@ -43,8 +43,8 @@ async function confirmSignIn(input) {
|
|
|
43
43
|
throw new AuthError({
|
|
44
44
|
name: AuthErrorCodes.SignInException,
|
|
45
45
|
message: `
|
|
46
|
-
An error occurred during the sign in process.
|
|
47
|
-
|
|
46
|
+
An error occurred during the sign in process.
|
|
47
|
+
|
|
48
48
|
This most likely occurred due to:
|
|
49
49
|
1. signIn was not called before confirmSignIn.
|
|
50
50
|
2. signIn threw an exception.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmSignIn.mjs","sources":["../../../../../src/providers/cognito/apis/confirmSignIn.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { cleanActiveSignInState, setActiveSignInState, signInStore, } from '../utils/signInStore';\nimport { AuthError } from '../../../errors/AuthError';\nimport { getNewDeviceMetadata, getSignInResult, getSignInResultFromError, handleChallengeName, } from '../utils/signInHelpers';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { AuthErrorCodes } from '../../../common/AuthErrorStrings';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\n/**\n * Continues or completes the sign in process when required by the initial call to `signIn`.\n *\n * @param input - The ConfirmSignInInput object\n * @returns ConfirmSignInOutput\n * @throws -{@link VerifySoftwareTokenException }:\n * Thrown due to an invalid MFA token.\n * @throws -{@link RespondToAuthChallengeException }:\n * Thrown due to an invalid auth challenge response.\n * @throws -{@link AssociateSoftwareTokenException}:\n * Thrown due to a service error during the MFA setup process.\n * @throws -{@link AuthValidationErrorCode }:\n * Thrown when `challengeResponse` is not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function confirmSignIn(input) {\n const { challengeResponse, options } = input;\n const { username, challengeName, signInSession, signInDetails } = signInStore.getState();\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const clientMetaData = options?.clientMetadata;\n assertValidationError(!!challengeResponse, AuthValidationErrorCode.EmptyChallengeResponse);\n if (!username || !challengeName || !signInSession)\n // TODO: remove this error message for production apps\n throw new AuthError({\n name: AuthErrorCodes.SignInException,\n message: `\n\t\t\tAn error occurred during the sign in process
|
|
1
|
+
{"version":3,"file":"confirmSignIn.mjs","sources":["../../../../../src/providers/cognito/apis/confirmSignIn.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { cleanActiveSignInState, setActiveSignInState, signInStore, } from '../utils/signInStore';\nimport { AuthError } from '../../../errors/AuthError';\nimport { getNewDeviceMetadata, getSignInResult, getSignInResultFromError, handleChallengeName, } from '../utils/signInHelpers';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { AuthErrorCodes } from '../../../common/AuthErrorStrings';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\n/**\n * Continues or completes the sign in process when required by the initial call to `signIn`.\n *\n * @param input - The ConfirmSignInInput object\n * @returns ConfirmSignInOutput\n * @throws -{@link VerifySoftwareTokenException }:\n * Thrown due to an invalid MFA token.\n * @throws -{@link RespondToAuthChallengeException }:\n * Thrown due to an invalid auth challenge response.\n * @throws -{@link AssociateSoftwareTokenException}:\n * Thrown due to a service error during the MFA setup process.\n * @throws -{@link AuthValidationErrorCode }:\n * Thrown when `challengeResponse` is not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function confirmSignIn(input) {\n const { challengeResponse, options } = input;\n const { username, challengeName, signInSession, signInDetails } = signInStore.getState();\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const clientMetaData = options?.clientMetadata;\n assertValidationError(!!challengeResponse, AuthValidationErrorCode.EmptyChallengeResponse);\n if (!username || !challengeName || !signInSession)\n // TODO: remove this error message for production apps\n throw new AuthError({\n name: AuthErrorCodes.SignInException,\n message: `\n\t\t\tAn error occurred during the sign in process. \n\t\t\t\n\t\t\tThis most likely occurred due to:\n\t\t\t1. signIn was not called before confirmSignIn.\n\t\t\t2. signIn threw an exception.\n\t\t\t3. page was refreshed during the sign in flow.\n\t\t\t`,\n recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' +\n 'and that the page is not refreshed until the sign in process is done.',\n });\n try {\n const { Session, ChallengeName: handledChallengeName, AuthenticationResult, ChallengeParameters: handledChallengeParameters, } = await handleChallengeName(username, challengeName, signInSession, challengeResponse, authConfig, tokenOrchestrator, clientMetaData, options);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n cleanActiveSignInState();\n await cacheCognitoTokens({\n username,\n ...AuthenticationResult,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n await dispatchSignedInHubEvent();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n assertServiceError(error);\n const result = getSignInResultFromError(error.name);\n if (result)\n return result;\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,aAAa,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;AACjD,IAAI,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;AAC7F,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AACzD,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAC1C,IAAI,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,CAAC;AACnD,IAAI,qBAAqB,CAAC,CAAC,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;AAC/F,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa;AACrD;AACA,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,cAAc,CAAC,eAAe;AAChD,YAAY,OAAO,EAAE,CAAC;AACtB;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,YAAY,kBAAkB,EAAE,4EAA4E;AAC5G,gBAAgB,uEAAuE;AACvF,SAAS,CAAC,CAAC;AACX,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,0BAA0B,GAAG,GAAG,MAAM,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,CAA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oUserPoolEndpointResolver } from '../factories/createCognit
|
|
|
20
20
|
* @throws AuthTokenConfigException - Thrown when the token provider config is invalid.
|
|
21
21
|
*/
|
|
22
22
|
async function updateMFAPreference(input) {
|
|
23
|
-
const { sms, totp
|
|
23
|
+
const { sms, totp } = input;
|
|
24
24
|
const authConfig = Amplify.getConfig().Auth?.Cognito;
|
|
25
25
|
assertTokenProviderConfig(authConfig);
|
|
26
26
|
const { userPoolEndpoint, userPoolId } = authConfig;
|
|
@@ -38,7 +38,6 @@ async function updateMFAPreference(input) {
|
|
|
38
38
|
AccessToken: tokens.accessToken.toString(),
|
|
39
39
|
SMSMfaSettings: getMFASettings(sms),
|
|
40
40
|
SoftwareTokenMfaSettings: getMFASettings(totp),
|
|
41
|
-
EmailMfaSettings: getMFASettings(email),
|
|
42
41
|
});
|
|
43
42
|
}
|
|
44
43
|
function getMFASettings(mfaPreference) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateMFAPreference.mjs","sources":["../../../../../src/providers/cognito/apis/updateMFAPreference.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokens } from '../utils/types';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createSetUserMFAPreferenceClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n/**\n * Updates the MFA preference of the user.\n *\n * @param input - The UpdateMFAPreferenceInput object.\n * @throws -{@link SetUserMFAPreferenceException } - Service error thrown when the MFA preference cannot be updated.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function updateMFAPreference(input) {\n const { sms, totp
|
|
1
|
+
{"version":3,"file":"updateMFAPreference.mjs","sources":["../../../../../src/providers/cognito/apis/updateMFAPreference.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokens } from '../utils/types';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createSetUserMFAPreferenceClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n/**\n * Updates the MFA preference of the user.\n *\n * @param input - The UpdateMFAPreferenceInput object.\n * @throws -{@link SetUserMFAPreferenceException } - Service error thrown when the MFA preference cannot be updated.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function updateMFAPreference(input) {\n const { sms, totp } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession({ forceRefresh: false });\n assertAuthTokens(tokens);\n const setUserMFAPreference = createSetUserMFAPreferenceClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await setUserMFAPreference({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.UpdateMFAPreference),\n }, {\n AccessToken: tokens.accessToken.toString(),\n SMSMfaSettings: getMFASettings(sms),\n SoftwareTokenMfaSettings: getMFASettings(totp),\n });\n}\nexport function getMFASettings(mfaPreference) {\n if (mfaPreference === 'DISABLED') {\n return {\n Enabled: false,\n };\n }\n else if (mfaPreference === 'PREFERRED') {\n return {\n Enabled: true,\n PreferredMfa: true,\n };\n }\n else if (mfaPreference === 'ENABLED') {\n return {\n Enabled: true,\n };\n }\n else if (mfaPreference === 'NOT_PREFERRED') {\n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1B,SAAS,CAAC;AACV,KAAK;AACL,SAAS,IAAI,aAAa,KAAK,WAAW,EAAE;AAC5C,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,IAAI;AACzB,YAAY,YAAY,EAAE,IAAI;AAC9B,SAAS,CAAC;AACV,KAAK;AACL,SAAS,IAAI,aAAa,KAAK,SAAS,EAAE;AAC1C,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,IAAI;AACzB,SAAS,CAAC;AACV,KAAK;AACL,SAAS,IAAI,aAAa,KAAK,eAAe,EAAE;AAChD,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,IAAI;AACzB,YAAY,YAAY,EAAE,KAAK;AAC/B,SAAS,CAAC;AACV,KAAK;AACL;;;;"}
|
|
@@ -19,6 +19,8 @@ export declare function handleCustomChallenge({ challengeResponse, clientMetadat
|
|
|
19
19
|
}): Promise<RespondToAuthChallengeCommandOutput>;
|
|
20
20
|
export declare function handleMFASetupChallenge({ challengeResponse, username, clientMetadata, session, deviceName, config, }: HandleAuthChallengeRequest): Promise<RespondToAuthChallengeCommandOutput>;
|
|
21
21
|
export declare function handleSelectMFATypeChallenge({ challengeResponse, username, clientMetadata, session, config, }: HandleAuthChallengeRequest): Promise<RespondToAuthChallengeCommandOutput>;
|
|
22
|
+
export declare function handleSMSMFAChallenge({ challengeResponse, clientMetadata, session, username, config, }: HandleAuthChallengeRequest): Promise<RespondToAuthChallengeCommandOutput>;
|
|
23
|
+
export declare function handleSoftwareTokenMFAChallenge({ challengeResponse, clientMetadata, session, username, config, }: HandleAuthChallengeRequest): Promise<RespondToAuthChallengeCommandOutput>;
|
|
22
24
|
export declare function handleCompleteNewPasswordChallenge({ challengeResponse, clientMetadata, session, username, requiredAttributes, config, }: HandleAuthChallengeRequest): Promise<RespondToAuthChallengeCommandOutput>;
|
|
23
25
|
export declare function handleUserPasswordAuthFlow(username: string, password: string, clientMetadata: ClientMetadata | undefined, config: CognitoUserPoolConfig, tokenOrchestrator: AuthTokenOrchestrator): Promise<InitiateAuthCommandOutput>;
|
|
24
26
|
export declare function handleUserSRPAuthFlow(username: string, password: string, clientMetadata: ClientMetadata | undefined, config: CognitoUserPoolConfig, tokenOrchestrator: AuthTokenOrchestrator): Promise<RespondToAuthChallengeCommandOutput>;
|
|
@@ -38,7 +40,7 @@ export declare function mapMfaType(mfa: string): CognitoMFAType;
|
|
|
38
40
|
export declare function getMFAType(type?: string): AuthMFAType | undefined;
|
|
39
41
|
export declare function getMFATypes(types?: string[]): AuthMFAType[] | undefined;
|
|
40
42
|
export declare function parseMFATypes(mfa?: string): CognitoMFAType[];
|
|
41
|
-
export declare function
|
|
43
|
+
export declare function isMFATypeEnabled(challengeParams: ChallengeParameters, mfaType: AuthMFAType): boolean;
|
|
42
44
|
export declare function assertUserNotAuthenticated(): Promise<void>;
|
|
43
45
|
/**
|
|
44
46
|
* This function is used to kick off the device management flow.
|
|
@@ -63,7 +65,4 @@ export declare function getNewDeviceMetadata({ userPoolId, userPoolEndpoint, new
|
|
|
63
65
|
export declare function retryOnResourceNotFoundException<F extends (...args: any[]) => any>(func: F, args: Parameters<F>, username: string, tokenOrchestrator: AuthTokenOrchestrator): Promise<ReturnType<F>>;
|
|
64
66
|
export declare function setActiveSignInUsername(username: string): void;
|
|
65
67
|
export declare function getActiveSignInUsername(username: string): string;
|
|
66
|
-
export declare function handleMFAChallenge({ challengeName, challengeResponse, clientMetadata, session, username, config, }: HandleAuthChallengeRequest & {
|
|
67
|
-
challengeName: Extract<ChallengeName, 'EMAIL_OTP' | 'SMS_MFA' | 'SOFTWARE_TOKEN_MFA'>;
|
|
68
|
-
}): Promise<RespondToAuthChallengeCommandOutput>;
|
|
69
68
|
export {};
|