quidproquo-actionprocessor-awslambda 0.0.99 → 0.0.100
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/lib/getActionProcessor/core/system/getExecuteStoryActionProcessor.js +2 -1
- package/lib/getActionProcessor/core/userDirectory/getUserDirectoryAuthenticateUserActionProcessor.js +10 -2
- package/lib/logic/cognito/authenticateUser.js +2 -19
- package/lib/logic/cognito/forgotPassword.js +3 -0
- package/package.json +1 -1
|
@@ -30,7 +30,8 @@ const getProcessExecuteStory = (qpqConfig, dynamicModuleLoader) => {
|
|
|
30
30
|
`${moduleName}::${(0, awsLambdaUtils_1.randomGuid)()}`, quidproquo_core_1.QpqRuntimeType.EXECUTE_STORY, [`${payload.src}::${payload.runtime}`]);
|
|
31
31
|
const storyResult = yield resolveStory(story, payload.params);
|
|
32
32
|
if (storyResult.error) {
|
|
33
|
-
|
|
33
|
+
const stack = `${payload.src}::${payload.runtime}`;
|
|
34
|
+
return (0, quidproquo_core_1.actionResultError)(storyResult.error.errorType, storyResult.error.errorText, storyResult.error.errorStack ? `${stack} -> [${storyResult.error.errorStack}]` : stack);
|
|
34
35
|
}
|
|
35
36
|
return (0, quidproquo_core_1.actionResult)(storyResult.result);
|
|
36
37
|
});
|
package/lib/getActionProcessor/core/userDirectory/getUserDirectoryAuthenticateUserActionProcessor.js
CHANGED
|
@@ -18,8 +18,16 @@ const getUserDirectoryAuthenticateUserActionProcessor = (qpqConfig) => {
|
|
|
18
18
|
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
19
19
|
const userPoolId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolIdFromConfig)(payload.userDirectoryName, qpqConfig), region);
|
|
20
20
|
const userPoolClientId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolClientIdFromConfig)(payload.userDirectoryName, qpqConfig), region);
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
try {
|
|
22
|
+
const authResponse = yield (0, authenticateUser_1.authenticateUser)(userPoolId, userPoolClientId, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), payload.authenticateUserRequest.email, payload.authenticateUserRequest.password);
|
|
23
|
+
return (0, quidproquo_core_1.actionResult)(authResponse);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
if (e instanceof Error) {
|
|
27
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.Unauthorized, e.message);
|
|
28
|
+
}
|
|
29
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, 'An unknown error has occurred.');
|
|
30
|
+
}
|
|
23
31
|
});
|
|
24
32
|
};
|
|
25
33
|
exports.default = (qpqConfig) => {
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.authenticateUser = void 0;
|
|
13
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
13
|
const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
|
|
15
14
|
const calculateSecretHash_1 = require("./utils/calculateSecretHash");
|
|
16
15
|
const getUserPoolClientSecret_1 = require("./getUserPoolClientSecret");
|
|
@@ -32,23 +31,7 @@ const authenticateUser = (userPoolId, clientId, region, username, password) => _
|
|
|
32
31
|
SECRET_HASH: secretHash,
|
|
33
32
|
},
|
|
34
33
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
console.log('authenticateUser response: ', JSON.stringify(response, null, 2));
|
|
38
|
-
return (0, transformCognitoResponse_1.cognitoAdminInitiateAuthResponseToQpqAuthenticationInfo)(response, issueDateTime);
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
if (e instanceof Error) {
|
|
42
|
-
switch (e.name) {
|
|
43
|
-
case 'PasswordResetRequiredException':
|
|
44
|
-
return {
|
|
45
|
-
challenge: quidproquo_core_1.AuthenticateUserChallenge.RESET_PASSWORD,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
throw new Error(`${e.name}: ${e.message}`);
|
|
49
|
-
}
|
|
50
|
-
console.log('authenticateUser Error: ', e);
|
|
51
|
-
throw new Error(`Unknown error has occurred in authenticateUser`);
|
|
52
|
-
}
|
|
34
|
+
const response = yield cognitoClient.send(new client_cognito_identity_provider_1.AdminInitiateAuthCommand(params));
|
|
35
|
+
return (0, transformCognitoResponse_1.cognitoAdminInitiateAuthResponseToQpqAuthenticationInfo)(response, issueDateTime);
|
|
53
36
|
});
|
|
54
37
|
exports.authenticateUser = authenticateUser;
|
|
@@ -21,6 +21,9 @@ const forgotPassword = (userPoolId, clientId, region, username) => __awaiter(voi
|
|
|
21
21
|
ClientId: clientId,
|
|
22
22
|
Username: username,
|
|
23
23
|
SecretHash: secretHash,
|
|
24
|
+
ClientMetadata: {
|
|
25
|
+
userInitiated: 'true',
|
|
26
|
+
},
|
|
24
27
|
};
|
|
25
28
|
const response = yield cognitoClient.send(new client_cognito_identity_provider_1.ForgotPasswordCommand(params));
|
|
26
29
|
const deliveryInfo = {
|