quidproquo-actionprocessor-awslambda 0.0.219 → 0.0.221

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.
Files changed (80) hide show
  1. package/lib/commonjs/awsLambdaUtils.js +9 -8
  2. package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/matchStory.js +0 -1
  3. package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/matchStory.js +3 -6
  4. package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/matchStory.js +0 -1
  5. package/lib/commonjs/getActionProcessor/core/event/cognito/createAuthChallenge/getRecords.js +2 -2
  6. package/lib/commonjs/getActionProcessor/core/event/cognito/createAuthChallenge/matchStory.js +4 -5
  7. package/lib/commonjs/getActionProcessor/core/event/cognito/customMessage/autoRespond.js +3 -4
  8. package/lib/commonjs/getActionProcessor/core/event/cognito/customMessage/matchStory.js +3 -7
  9. package/lib/commonjs/getActionProcessor/core/event/cognito/defineAuthChallenge/getRecords.js +8 -2
  10. package/lib/commonjs/getActionProcessor/core/event/cognito/defineAuthChallenge/matchStory.js +3 -4
  11. package/lib/commonjs/getActionProcessor/core/event/cognito/utils/getChallengeSessionFromCognitoTriggerEventSession.d.ts +3 -0
  12. package/lib/commonjs/getActionProcessor/core/event/cognito/utils/getChallengeSessionFromCognitoTriggerEventSession.js +14 -0
  13. package/lib/commonjs/getActionProcessor/core/event/cognito/utils/index.d.ts +1 -0
  14. package/lib/commonjs/getActionProcessor/core/event/cognito/{verifyAuthChallenge/utils → utils}/index.js +1 -1
  15. package/lib/commonjs/getActionProcessor/core/event/cognito/verifyAuthChallenge/getRecords.js +1 -1
  16. package/lib/commonjs/getActionProcessor/core/event/cognito/verifyAuthChallenge/matchStory.js +4 -5
  17. package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/matchStory.js +1 -2
  18. package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/matchStory.js +0 -1
  19. package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/matchStory.js +0 -1
  20. package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/matchStory.js +3 -1
  21. package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/types.d.ts +2 -2
  22. package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/types.js +2 -1
  23. package/lib/commonjs/getActionProcessor/core/event/sqs/queue/autoRespond.js +2 -2
  24. package/lib/commonjs/getActionProcessor/core/event/sqs/queue/matchStory.js +4 -4
  25. package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreUpsertActionProcessor.js +1 -0
  26. package/lib/commonjs/getActionProcessor/core/system/getExecuteStoryActionProcessor.js +7 -9
  27. package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectoryRespondToAuthChallengeActionProcessor.js +16 -1
  28. package/lib/commonjs/logic/cognito/respondToAuthChallengeChallenge.d.ts +2 -1
  29. package/lib/commonjs/logic/cognito/respondToAuthChallengeChallenge.js +2 -2
  30. package/lib/commonjs/logic/cognito/utils/transformCognitoResponse.js +4 -1
  31. package/lib/commonjs/runtimeConfig/QPQAWSResourceMap.d.ts +2 -2
  32. package/lib/commonjs/types/DynamicLoader.d.ts +2 -1
  33. package/lib/esm/awsLambdaUtils.js +9 -8
  34. package/lib/esm/getActionProcessor/core/event/apiGatwayEvent/api/matchStory.js +0 -1
  35. package/lib/esm/getActionProcessor/core/event/apiGatwayEvent/websocket/matchStory.js +3 -6
  36. package/lib/esm/getActionProcessor/core/event/cloudFrontOriginRequest/matchStory.js +0 -1
  37. package/lib/esm/getActionProcessor/core/event/cognito/createAuthChallenge/getRecords.js +2 -2
  38. package/lib/esm/getActionProcessor/core/event/cognito/createAuthChallenge/matchStory.js +3 -4
  39. package/lib/esm/getActionProcessor/core/event/cognito/customMessage/autoRespond.js +3 -3
  40. package/lib/esm/getActionProcessor/core/event/cognito/customMessage/matchStory.js +3 -6
  41. package/lib/esm/getActionProcessor/core/event/cognito/defineAuthChallenge/getRecords.js +8 -2
  42. package/lib/esm/getActionProcessor/core/event/cognito/defineAuthChallenge/matchStory.js +3 -4
  43. package/lib/esm/getActionProcessor/core/event/cognito/utils/getChallengeSessionFromCognitoTriggerEventSession.d.ts +3 -0
  44. package/lib/esm/getActionProcessor/core/event/cognito/utils/getChallengeSessionFromCognitoTriggerEventSession.js +10 -0
  45. package/lib/esm/getActionProcessor/core/event/cognito/utils/index.d.ts +1 -0
  46. package/lib/esm/getActionProcessor/core/event/cognito/utils/index.js +1 -0
  47. package/lib/esm/getActionProcessor/core/event/cognito/verifyAuthChallenge/getRecords.js +1 -1
  48. package/lib/esm/getActionProcessor/core/event/cognito/verifyAuthChallenge/matchStory.js +3 -4
  49. package/lib/esm/getActionProcessor/core/event/eventBridgeEvent/deployStack/matchStory.js +1 -2
  50. package/lib/esm/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/matchStory.js +0 -1
  51. package/lib/esm/getActionProcessor/core/event/lambda/serviceFunction/matchStory.js +0 -1
  52. package/lib/esm/getActionProcessor/core/event/s3/fileEvent/matchStory.js +3 -1
  53. package/lib/esm/getActionProcessor/core/event/s3/fileEvent/types.d.ts +2 -2
  54. package/lib/esm/getActionProcessor/core/event/s3/fileEvent/types.js +2 -1
  55. package/lib/esm/getActionProcessor/core/event/sqs/queue/autoRespond.js +2 -2
  56. package/lib/esm/getActionProcessor/core/event/sqs/queue/matchStory.js +4 -4
  57. package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreUpsertActionProcessor.js +1 -0
  58. package/lib/esm/getActionProcessor/core/system/getExecuteStoryActionProcessor.js +7 -9
  59. package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectoryRespondToAuthChallengeActionProcessor.js +17 -2
  60. package/lib/esm/logic/cognito/respondToAuthChallengeChallenge.d.ts +2 -1
  61. package/lib/esm/logic/cognito/respondToAuthChallengeChallenge.js +3 -3
  62. package/lib/esm/logic/cognito/utils/transformCognitoResponse.js +6 -3
  63. package/lib/esm/runtimeConfig/QPQAWSResourceMap.d.ts +2 -2
  64. package/lib/esm/types/DynamicLoader.d.ts +2 -1
  65. package/package.json +5 -5
  66. package/lib/commonjs/getActionProcessor/core/event/cognito/createAuthChallenge/utils/getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent.d.ts +0 -3
  67. package/lib/commonjs/getActionProcessor/core/event/cognito/createAuthChallenge/utils/getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent.js +0 -14
  68. package/lib/commonjs/getActionProcessor/core/event/cognito/createAuthChallenge/utils/index.d.ts +0 -1
  69. package/lib/commonjs/getActionProcessor/core/event/cognito/createAuthChallenge/utils/index.js +0 -17
  70. package/lib/commonjs/getActionProcessor/core/event/cognito/verifyAuthChallenge/utils/getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent.d.ts +0 -3
  71. package/lib/commonjs/getActionProcessor/core/event/cognito/verifyAuthChallenge/utils/getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent.js +0 -14
  72. package/lib/commonjs/getActionProcessor/core/event/cognito/verifyAuthChallenge/utils/index.d.ts +0 -1
  73. package/lib/esm/getActionProcessor/core/event/cognito/createAuthChallenge/utils/getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent.d.ts +0 -3
  74. package/lib/esm/getActionProcessor/core/event/cognito/createAuthChallenge/utils/getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent.js +0 -10
  75. package/lib/esm/getActionProcessor/core/event/cognito/createAuthChallenge/utils/index.d.ts +0 -1
  76. package/lib/esm/getActionProcessor/core/event/cognito/createAuthChallenge/utils/index.js +0 -1
  77. package/lib/esm/getActionProcessor/core/event/cognito/verifyAuthChallenge/utils/getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent.d.ts +0 -3
  78. package/lib/esm/getActionProcessor/core/event/cognito/verifyAuthChallenge/utils/getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent.js +0 -10
  79. package/lib/esm/getActionProcessor/core/event/cognito/verifyAuthChallenge/utils/index.d.ts +0 -1
  80. package/lib/esm/getActionProcessor/core/event/cognito/verifyAuthChallenge/utils/index.js +0 -1
@@ -5,12 +5,11 @@ const GLOBAL_USER_DIRECTORY_NAME = process.env.userDirectoryName;
5
5
  const getProcessMatchStory = (qpqConfig) => {
6
6
  const userDirectoryConfig = qpqCoreUtils.getUserDirectories(qpqConfig).find((ud) => ud.name === GLOBAL_USER_DIRECTORY_NAME);
7
7
  return async ({ qpqEventRecord }) => {
8
- if (!userDirectoryConfig?.customAuthRuntime?.createAuthChallenge?.src) {
9
- return actionResultError(ErrorTypeEnum.NotFound, `Missing customAuthRuntime.createAuthChallenge.src in [${GLOBAL_USER_DIRECTORY_NAME}]`);
8
+ if (!userDirectoryConfig?.customAuthRuntime?.createAuthChallenge) {
9
+ return actionResultError(ErrorTypeEnum.NotFound, `Missing customAuthRuntime.createAuthChallenge in [${GLOBAL_USER_DIRECTORY_NAME}]`);
10
10
  }
11
11
  return actionResult({
12
- src: userDirectoryConfig.customAuthRuntime.createAuthChallenge.src,
13
- runtime: userDirectoryConfig.customAuthRuntime.createAuthChallenge.runtime,
12
+ runtime: userDirectoryConfig.customAuthRuntime.createAuthChallenge,
14
13
  });
15
14
  };
16
15
  };
@@ -7,17 +7,17 @@ const getProcessAutoRespond = (qpqConfig) => {
7
7
  const getErrorResult = () => actionResultError(ErrorTypeEnum.NotFound, `Email lambda not implemented for ${qpqEventRecord.eventType}`);
8
8
  switch (qpqEventRecord.eventType) {
9
9
  case EmailSendEventType.ResetPassword:
10
- if (!userDirectoryConfig?.emailTemplates.resetPassword?.src || !userDirectoryConfig?.emailTemplates.resetPassword?.runtime) {
10
+ if (!userDirectoryConfig?.emailTemplates.resetPassword) {
11
11
  return getErrorResult();
12
12
  }
13
13
  break;
14
14
  case EmailSendEventType.ResetPasswordAdmin:
15
- if (!userDirectoryConfig?.emailTemplates.resetPasswordAdmin?.src || !userDirectoryConfig?.emailTemplates.resetPasswordAdmin?.runtime) {
15
+ if (!userDirectoryConfig?.emailTemplates.resetPasswordAdmin) {
16
16
  return getErrorResult();
17
17
  }
18
18
  break;
19
19
  case EmailSendEventType.VerifyEmail:
20
- if (!userDirectoryConfig?.emailTemplates.verifyEmail?.src || !userDirectoryConfig?.emailTemplates.verifyEmail?.runtime) {
20
+ if (!userDirectoryConfig?.emailTemplates.verifyEmail) {
21
21
  return getErrorResult();
22
22
  }
23
23
  break;
@@ -8,18 +8,15 @@ const getProcessMatchStory = (qpqConfig) => {
8
8
  switch (qpqEventRecord.eventType) {
9
9
  case EmailSendEventType.ResetPassword:
10
10
  return actionResult({
11
- src: userDirectoryConfig?.emailTemplates.resetPassword?.src,
12
- runtime: userDirectoryConfig?.emailTemplates.resetPassword?.runtime,
11
+ runtime: userDirectoryConfig?.emailTemplates.resetPassword,
13
12
  });
14
13
  case EmailSendEventType.ResetPasswordAdmin:
15
14
  return actionResult({
16
- src: userDirectoryConfig?.emailTemplates.resetPasswordAdmin?.src,
17
- runtime: userDirectoryConfig?.emailTemplates.resetPasswordAdmin?.runtime,
15
+ runtime: userDirectoryConfig?.emailTemplates.resetPasswordAdmin,
18
16
  });
19
17
  case EmailSendEventType.VerifyEmail:
20
18
  return actionResult({
21
- src: userDirectoryConfig?.emailTemplates.verifyEmail?.src,
22
- runtime: userDirectoryConfig?.emailTemplates.verifyEmail?.runtime,
19
+ runtime: userDirectoryConfig?.emailTemplates.verifyEmail,
23
20
  });
24
21
  default:
25
22
  return actionResultError(ErrorTypeEnum.NotFound, `Email lambda not implemented for ${qpqEventRecord.eventType}`);
@@ -1,7 +1,13 @@
1
1
  import { EventActionType, actionResult } from 'quidproquo-core';
2
+ import { getQpqAttributesFromCognitoStringMap } from '../../../../../logic/cognito/cognitoAttributeMap';
3
+ import { getChallengeSessionFromCognitoTriggerEventSession } from '../utils';
2
4
  const getProcessGetRecords = (qpqConfig) => {
3
- return async ({ eventParams: [customMessageTriggerEvent, context] }) => {
4
- const internalEventRecord = {};
5
+ return async ({ eventParams: [event, context] }) => {
6
+ const internalEventRecord = {
7
+ userName: event.userName,
8
+ session: getChallengeSessionFromCognitoTriggerEventSession(event.request.session),
9
+ userAttributes: getQpqAttributesFromCognitoStringMap(event.request.userAttributes),
10
+ };
5
11
  return actionResult([internalEventRecord]);
6
12
  };
7
13
  };
@@ -5,12 +5,11 @@ const GLOBAL_USER_DIRECTORY_NAME = process.env.userDirectoryName;
5
5
  const getProcessMatchStory = (qpqConfig) => {
6
6
  const userDirectoryConfig = qpqCoreUtils.getUserDirectories(qpqConfig).find((ud) => ud.name === GLOBAL_USER_DIRECTORY_NAME);
7
7
  return async ({ qpqEventRecord }) => {
8
- if (!userDirectoryConfig || !userDirectoryConfig.customAuthRuntime?.defineAuthChallenge.src) {
9
- return actionResultError(ErrorTypeEnum.NotFound, `Missing customAuthRuntime.defineAuthChallenge.src in [${GLOBAL_USER_DIRECTORY_NAME}]`);
8
+ if (!userDirectoryConfig || !userDirectoryConfig.customAuthRuntime?.defineAuthChallenge) {
9
+ return actionResultError(ErrorTypeEnum.NotFound, `Missing customAuthRuntime.defineAuthChallenge in [${GLOBAL_USER_DIRECTORY_NAME}]`);
10
10
  }
11
11
  return actionResult({
12
- src: userDirectoryConfig.customAuthRuntime.defineAuthChallenge.src,
13
- runtime: userDirectoryConfig.customAuthRuntime.defineAuthChallenge.runtime,
12
+ runtime: userDirectoryConfig.customAuthRuntime.defineAuthChallenge,
14
13
  });
15
14
  };
16
15
  };
@@ -0,0 +1,3 @@
1
+ import { DefineAuthChallengeTriggerEvent } from 'aws-lambda';
2
+ import { ChallengeSession } from 'quidproquo-core';
3
+ export declare const getChallengeSessionFromCognitoTriggerEventSession: (session: DefineAuthChallengeTriggerEvent['request']['session']) => ChallengeSession;
@@ -0,0 +1,10 @@
1
+ export const getChallengeSessionFromCognitoTriggerEventSession = (session) => {
2
+ const challengeSession = session.map((c) => {
3
+ const result = {
4
+ challengeName: c.challengeMetadata || '',
5
+ challengeResult: c.challengeResult,
6
+ };
7
+ return result;
8
+ });
9
+ return challengeSession;
10
+ };
@@ -0,0 +1 @@
1
+ export * from './getChallengeSessionFromCognitoTriggerEventSession';
@@ -0,0 +1 @@
1
+ export * from './getChallengeSessionFromCognitoTriggerEventSession';
@@ -3,7 +3,7 @@ import { getQpqAttributesFromCognitoStringMap } from '../../../../../logic/cogni
3
3
  const getProcessGetRecords = (qpqConfig) => {
4
4
  return async ({ eventParams: [event, context] }) => {
5
5
  const internalEventRecord = {
6
- challengeAnswer: event.request.challengeAnswer,
6
+ challengeAnswer: event.request.challengeAnswer ? JSON.parse(event.request.challengeAnswer) : {},
7
7
  userAttributes: getQpqAttributesFromCognitoStringMap(event.request.userAttributes),
8
8
  userNotFound: event.request.userNotFound,
9
9
  privateChallengeParameters: event.request.privateChallengeParameters,
@@ -5,12 +5,11 @@ const GLOBAL_USER_DIRECTORY_NAME = process.env.userDirectoryName;
5
5
  const getProcessMatchStory = (qpqConfig) => {
6
6
  const userDirectoryConfig = qpqCoreUtils.getUserDirectories(qpqConfig).find((ud) => ud.name === GLOBAL_USER_DIRECTORY_NAME);
7
7
  return async ({ qpqEventRecord }) => {
8
- if (!userDirectoryConfig?.customAuthRuntime?.verifyAuthChallenge?.src) {
9
- return actionResultError(ErrorTypeEnum.NotFound, `Missing customAuthRuntime.verifyAuthChallenge.src in [${GLOBAL_USER_DIRECTORY_NAME}]`);
8
+ if (!userDirectoryConfig?.customAuthRuntime?.verifyAuthChallenge) {
9
+ return actionResultError(ErrorTypeEnum.NotFound, `Missing customAuthRuntime.verifyAuthChallenge in [${GLOBAL_USER_DIRECTORY_NAME}]`);
10
10
  }
11
11
  return actionResult({
12
- src: userDirectoryConfig.customAuthRuntime.verifyAuthChallenge.src,
13
- runtime: userDirectoryConfig.customAuthRuntime.verifyAuthChallenge.runtime,
12
+ runtime: userDirectoryConfig.customAuthRuntime.verifyAuthChallenge,
14
13
  });
15
14
  };
16
15
  };
@@ -8,8 +8,7 @@ const getProcessMatchStory = (qpqConfig) => {
8
8
  return actionResultError(ErrorTypeEnum.NotFound, `Could not find deploy event config ${GLOBAL_DEPLOY_EVENT_NAME}`);
9
9
  }
10
10
  return actionResult({
11
- src: deployConfig.src.src,
12
- runtime: deployConfig.src.runtime,
11
+ runtime: deployConfig.runtime,
13
12
  });
14
13
  };
15
14
  };
@@ -4,7 +4,6 @@ const lambdaRuntimeConfig = JSON.parse(process.env.lambdaRuntimeConfig || '{}');
4
4
  const getProcessMatchStory = (qpqConfig) => {
5
5
  return async ({ qpqEventRecord }) => {
6
6
  return actionResult({
7
- src: lambdaRuntimeConfig.src,
8
7
  runtime: lambdaRuntimeConfig.runtime,
9
8
  runtimeOptions: {},
10
9
  });
@@ -9,7 +9,6 @@ const getProcessMatchStory = (qpqConfig) => {
9
9
  return actionResultError(ErrorTypeEnum.NotFound, `service function not found [${qpqEventRecord.functionName}]`);
10
10
  }
11
11
  return actionResult({
12
- src: matchedRoute.src,
13
12
  runtime: matchedRoute.runtime,
14
13
  });
15
14
  };
@@ -2,7 +2,9 @@ import { EventActionType, actionResult } from 'quidproquo-core';
2
2
  import { GLOBAL_STORAGE_DRIVE_RUNTIME } from './types';
3
3
  const getProcessMatchStory = (qpqConfig) => {
4
4
  return async ({ qpqEventRecord }) => {
5
- return actionResult(GLOBAL_STORAGE_DRIVE_RUNTIME);
5
+ return actionResult({
6
+ runtime: GLOBAL_STORAGE_DRIVE_RUNTIME,
7
+ });
6
8
  };
7
9
  };
8
10
  export default (qpqConfig) => {
@@ -1,8 +1,8 @@
1
1
  import { StorageDriveEvent, StorageDriveEventResponse } from 'quidproquo-webserver';
2
2
  import { S3Event, Context } from 'aws-lambda';
3
- import { MatchStoryResult, QpqSourceEntry } from 'quidproquo-core';
3
+ import { MatchStoryResult, QpqFunctionRuntime } from 'quidproquo-core';
4
4
  export declare const GLOBAL_STORAGE_DRIVE_NAME: string;
5
- export declare const GLOBAL_STORAGE_DRIVE_RUNTIME: QpqSourceEntry;
5
+ export declare const GLOBAL_STORAGE_DRIVE_RUNTIME: QpqFunctionRuntime;
6
6
  export type EventInput = [S3Event, Context];
7
7
  export type EventOutput = void;
8
8
  export type InternalEventRecord = StorageDriveEvent;
@@ -1,3 +1,4 @@
1
1
  // Customs
2
2
  export const GLOBAL_STORAGE_DRIVE_NAME = process.env.storageDriveName;
3
- export const GLOBAL_STORAGE_DRIVE_RUNTIME = JSON.parse(process.env.storageDriveEntry || '{}');
3
+ // TODO: Get this from the storageDriveConfig.
4
+ export const GLOBAL_STORAGE_DRIVE_RUNTIME = JSON.parse(process.env.storageDriveEntry || '"/::"');
@@ -1,8 +1,8 @@
1
1
  import { EventActionType, actionResult } from 'quidproquo-core';
2
2
  const getProcessAutoRespond = (qpqConfig) => {
3
- return async ({ qpqEventRecord, matchResult }) => {
3
+ return async ({ matchResult }) => {
4
4
  // If we could not match, we can just auto respond...
5
- if (!matchResult.src || !matchResult.runtime) {
5
+ if (!matchResult.runtime) {
6
6
  // Just say we have finished gracefully.
7
7
  return actionResult(true);
8
8
  }
@@ -8,9 +8,10 @@ export const getQueueConfigSetting = () => {
8
8
  const getProcessMatchStory = (qpqConfig) => {
9
9
  // TODO: Get this out of the qpqconfig like the other event processors
10
10
  const queueQPQConfigSetting = getQueueConfigSetting();
11
+ const queueQueueProcessors = qpqCoreUtils.getQueueQueueProcessors(queueQPQConfigSetting.name, qpqConfig);
12
+ const queueTypes = Object.keys(queueQueueProcessors).sort();
11
13
  return async ({ qpqEventRecord }) => {
12
- const queueQueueProcessors = qpqCoreUtils.getQueueQueueProcessors(queueQPQConfigSetting.name, qpqConfig);
13
- const queueTypes = Object.keys(queueQueueProcessors).sort();
14
+ console.log('qpqEventRecord', JSON.stringify(qpqEventRecord, null, 2));
14
15
  // Find the most relevant match
15
16
  const matchedQueueType = queueTypes
16
17
  .map((qt) => ({
@@ -28,8 +29,7 @@ const getProcessMatchStory = (qpqConfig) => {
28
29
  }
29
30
  const sourceEntry = queueQueueProcessors[matchedQueueType.queueType];
30
31
  return actionResult({
31
- src: sourceEntry.src,
32
- runtime: sourceEntry.runtime,
32
+ runtime: sourceEntry,
33
33
  runtimeOptions: matchedQueueType.match.params || {},
34
34
  config: matchedQueueType.queueType,
35
35
  });
@@ -25,6 +25,7 @@ const getProcessKeyValueStoreUpsert = (qpqConfig) => {
25
25
  catch (error) {
26
26
  return actionResultErrorFromCaughtError(error, {
27
27
  InternalServerError: () => actionResultError(KeyValueStoreUpsertErrorTypeEnum.ServiceUnavailable, 'KVS Service Unavailable'),
28
+ ResourceNotFoundException: () => actionResultError(KeyValueStoreUpsertErrorTypeEnum.ResourceNotFound, 'KVS Resource Not Found'),
28
29
  });
29
30
  }
30
31
  };
@@ -4,13 +4,12 @@ export const getDateNow = () => new Date().toISOString();
4
4
  const getProcessExecuteStory = (qpqConfig, dynamicModuleLoader) => {
5
5
  const moduleName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
6
6
  return async (payload, session, actionProcessors, logger) => {
7
- let module = await dynamicModuleLoader(payload.src);
8
- if (module === null) {
9
- return actionResultError(ErrorTypeEnum.NotFound, `Module not found [${payload.src}]`);
10
- }
11
- const story = module[payload.runtime];
7
+ console.log('Trying to load module');
8
+ let story = await dynamicModuleLoader(payload.runtime);
9
+ console.log('After - Trying to load module');
12
10
  if (!story) {
13
- return actionResultError(ErrorTypeEnum.NotFound, `[${payload.runtime}] not found in module [${payload.src}]`);
11
+ console.log('No story');
12
+ return actionResultError(ErrorTypeEnum.NotFound, `Unable to dynamically load: [${payload.runtime}]`);
14
13
  }
15
14
  const resolveStory = createRuntime(qpqConfig, {
16
15
  context: payload.storySession?.context || session.context,
@@ -19,11 +18,10 @@ const getProcessExecuteStory = (qpqConfig, dynamicModuleLoader) => {
19
18
  correlation: payload.storySession?.correlation || session.correlation,
20
19
  }, actionProcessors, getDateNow, logger,
21
20
  // TODO: Share this logic.
22
- `${moduleName}::${randomGuid()}`, QpqRuntimeType.EXECUTE_STORY, [`${payload.src}::${payload.runtime}`]);
21
+ `${moduleName}::${randomGuid()}`, QpqRuntimeType.EXECUTE_STORY, [payload.runtime]);
23
22
  const storyResult = await resolveStory(story, payload.params);
24
23
  if (storyResult.error) {
25
- const stack = `${payload.src}::${payload.runtime}`;
26
- return actionResultError(storyResult.error.errorType, storyResult.error.errorText, storyResult.error.errorStack ? `${stack} -> [${storyResult.error.errorStack}]` : stack);
24
+ return actionResultError(storyResult.error.errorType, storyResult.error.errorText, storyResult.error.errorStack ? `${payload.runtime} -> [${storyResult.error.errorStack}]` : payload.runtime);
27
25
  }
28
26
  return actionResult(storyResult.result);
29
27
  };
@@ -1,23 +1,38 @@
1
1
  import { actionResult, qpqCoreUtils, UserDirectoryActionType, AuthenticateUserChallenge, } from 'quidproquo-core';
2
- import { getCFExportNameUserPoolIdFromConfig, getCFExportNameUserPoolClientIdFromConfig, } from '../../../awsNamingUtils';
2
+ import { getCFExportNameUserPoolIdFromConfig, getCFExportNameUserPoolClientIdFromConfig } from '../../../awsNamingUtils';
3
3
  import { getExportedValue } from '../../../logic/cloudformation/getExportedValue';
4
4
  import { respondToAuthChallengeChallenge } from '../../../logic/cognito/respondToAuthChallengeChallenge';
5
+ import { ChallengeNameType } from '@aws-sdk/client-cognito-identity-provider';
5
6
  const anyAuthChallengeToCognitoAttributes = (authChallenge) => {
6
7
  switch (authChallenge.challenge) {
7
8
  case AuthenticateUserChallenge.NEW_PASSWORD_REQUIRED:
8
9
  return {
9
10
  NEW_PASSWORD: authChallenge.newPassword,
10
11
  };
12
+ case AuthenticateUserChallenge.CUSTOM_CHALLENGE:
13
+ return {
14
+ ANSWER: JSON.stringify(authChallenge.challengeAnswer),
15
+ };
11
16
  default:
12
17
  return {};
13
18
  }
14
19
  };
20
+ const anyAuthChallengeToCognitoChallengeName = (authChallenge) => {
21
+ switch (authChallenge.challenge) {
22
+ case AuthenticateUserChallenge.NEW_PASSWORD_REQUIRED:
23
+ return ChallengeNameType.NEW_PASSWORD_REQUIRED;
24
+ case AuthenticateUserChallenge.CUSTOM_CHALLENGE:
25
+ return ChallengeNameType.CUSTOM_CHALLENGE;
26
+ default:
27
+ throw new Error(`Unknown challenge`);
28
+ }
29
+ };
15
30
  const getUserDirectoryRespondToAuthChallengeActionProcessor = (qpqConfig) => {
16
31
  return async ({ userDirectoryName, authChallenge }) => {
17
32
  const region = qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
18
33
  const userPoolId = await getExportedValue(getCFExportNameUserPoolIdFromConfig(userDirectoryName, qpqConfig), region);
19
34
  const userPoolClientId = await getExportedValue(getCFExportNameUserPoolClientIdFromConfig(userDirectoryName, qpqConfig), region);
20
- const response = await respondToAuthChallengeChallenge(userPoolId, userPoolClientId, region, authChallenge.username, authChallenge.session, anyAuthChallengeToCognitoAttributes(authChallenge));
35
+ const response = await respondToAuthChallengeChallenge(userPoolId, userPoolClientId, region, authChallenge.username, authChallenge.session, anyAuthChallengeToCognitoChallengeName(authChallenge), anyAuthChallengeToCognitoAttributes(authChallenge));
21
36
  return actionResult(response);
22
37
  };
23
38
  };
@@ -1,2 +1,3 @@
1
1
  import { AuthenticateUserResponse } from 'quidproquo-core';
2
- export declare const respondToAuthChallengeChallenge: (userPoolId: string, clientId: string, region: string, username: string, session: string, attributes: Record<string, string>) => Promise<AuthenticateUserResponse>;
2
+ import { ChallengeNameType } from '@aws-sdk/client-cognito-identity-provider';
3
+ export declare const respondToAuthChallengeChallenge: (userPoolId: string, clientId: string, region: string, username: string, session: string, challengeNameType: ChallengeNameType, attributes: Record<string, string>) => Promise<AuthenticateUserResponse>;
@@ -1,14 +1,14 @@
1
- import { CognitoIdentityProviderClient, RespondToAuthChallengeCommand, ChallengeNameType, } from '@aws-sdk/client-cognito-identity-provider';
1
+ import { CognitoIdentityProviderClient, RespondToAuthChallengeCommand, } from '@aws-sdk/client-cognito-identity-provider';
2
2
  import { calculateSecretHash } from './utils/calculateSecretHash';
3
3
  import { getUserPoolClientSecret } from './getUserPoolClientSecret';
4
4
  import { cognitoAdminInitiateAuthResponseToQpqAuthenticationInfo } from './utils/transformCognitoResponse';
5
5
  import { createAwsClient } from '../createAwsClient';
6
- export const respondToAuthChallengeChallenge = async (userPoolId, clientId, region, username, session, attributes) => {
6
+ export const respondToAuthChallengeChallenge = async (userPoolId, clientId, region, username, session, challengeNameType, attributes) => {
7
7
  const cognitoClient = createAwsClient(CognitoIdentityProviderClient, { region });
8
8
  const clientSecret = await getUserPoolClientSecret(userPoolId, clientId, region);
9
9
  const secretHash = calculateSecretHash(username, clientId, clientSecret);
10
10
  const params = {
11
- ChallengeName: ChallengeNameType.NEW_PASSWORD_REQUIRED,
11
+ ChallengeName: challengeNameType,
12
12
  ClientId: clientId,
13
13
  Session: session,
14
14
  ChallengeResponses: {
@@ -1,5 +1,5 @@
1
- import { AuthenticateUserChallenge, } from 'quidproquo-core';
2
- import { ChallengeNameType, } from '@aws-sdk/client-cognito-identity-provider';
1
+ import { AuthenticateUserChallenge } from 'quidproquo-core';
2
+ import { ChallengeNameType } from '@aws-sdk/client-cognito-identity-provider';
3
3
  export const cognitoAuthenticationResultTypeToQpqAuthenticationInfo = (authResult, issueDateTime) => {
4
4
  // Parse the issueDateTime and add the expiresIn to get the expiration date
5
5
  let issueDate = new Date(issueDateTime);
@@ -20,15 +20,18 @@ export const cognitoChallengeNameTypeToQpqAuthenticateUserChallenge = (cognitoCh
20
20
  }
21
21
  const map = {
22
22
  [ChallengeNameType.NEW_PASSWORD_REQUIRED]: AuthenticateUserChallenge.NEW_PASSWORD_REQUIRED,
23
+ [ChallengeNameType.CUSTOM_CHALLENGE]: AuthenticateUserChallenge.CUSTOM_CHALLENGE,
23
24
  };
24
25
  // TODO: handle the NOT-IMP cases
25
- const challenge = map[cognitoChallengeName] || `NOT-IMP-${cognitoChallengeName}`;
26
+ const challenge = map[cognitoChallengeName] || `QPQ-NOT-IMP-${cognitoChallengeName}`;
26
27
  return challenge;
27
28
  };
28
29
  export const cognitoAdminInitiateAuthResponseToQpqAuthenticationInfo = (authResponse, issueDateTime) => {
30
+ console.log('authResponse XYZ', authResponse);
29
31
  const res = {
30
32
  session: authResponse.Session,
31
33
  challenge: cognitoChallengeNameTypeToQpqAuthenticateUserChallenge(authResponse.ChallengeName),
34
+ challengeParameters: authResponse.ChallengeParameters,
32
35
  };
33
36
  if (authResponse.AuthenticationResult) {
34
37
  res.authenticationInfo = cognitoAuthenticationResultTypeToQpqAuthenticationInfo(authResponse.AuthenticationResult, issueDateTime);
@@ -1,4 +1,4 @@
1
+ import { QpqFunctionRuntime } from 'quidproquo-core';
1
2
  export interface LambdaRuntimeConfig {
2
- src: string;
3
- runtime: string;
3
+ runtime: QpqFunctionRuntime;
4
4
  }
@@ -1 +1,2 @@
1
- export type DynamicModuleLoader = (src: string) => Promise<any>;
1
+ import { QpqFunctionRuntime } from 'quidproquo-core';
2
+ export type DynamicModuleLoader = (runtime: QpqFunctionRuntime) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.219",
3
+ "version": "0.0.221",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -51,9 +51,9 @@
51
51
  "lodash": "^4.17.21",
52
52
  "node-cache": "^5.1.2",
53
53
  "node-match-path": "^0.6.3",
54
- "quidproquo-config-aws": "0.0.219",
55
- "quidproquo-core": "0.0.219",
56
- "quidproquo-webserver": "0.0.219"
54
+ "quidproquo-config-aws": "0.0.221",
55
+ "quidproquo-core": "0.0.221",
56
+ "quidproquo-webserver": "0.0.221"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/aws-lambda": "^8.10.109",
@@ -61,7 +61,7 @@
61
61
  "@types/jsonwebtoken": "^9.0.2",
62
62
  "@types/lodash": "^4.14.194",
63
63
  "@types/node": "^18.11.9",
64
- "quidproquo-tsconfig": "0.0.219",
64
+ "quidproquo-tsconfig": "0.0.221",
65
65
  "typescript": "^4.9.3"
66
66
  }
67
67
  }
@@ -1,3 +0,0 @@
1
- import { CreateAuthChallengeTriggerEvent } from 'aws-lambda';
2
- import { ChallengeSession } from 'quidproquo-core';
3
- export declare const getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent: (event: CreateAuthChallengeTriggerEvent) => ChallengeSession;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent = void 0;
4
- const getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent = (event) => {
5
- const session = event.request.session.map((c) => {
6
- const result = {
7
- challengeName: c.challengeMetadata || '',
8
- challengeResult: c.challengeResult,
9
- };
10
- return result;
11
- });
12
- return session;
13
- };
14
- exports.getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent = getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent;
@@ -1 +0,0 @@
1
- export * from './getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent"), exports);
@@ -1,3 +0,0 @@
1
- import { CreateAuthChallengeTriggerEvent } from 'aws-lambda';
2
- import { ChallengeSession } from 'quidproquo-core';
3
- export declare const getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent: (event: CreateAuthChallengeTriggerEvent) => ChallengeSession;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent = void 0;
4
- const getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent = (event) => {
5
- const session = event.request.session.map((c) => {
6
- const result = {
7
- challengeName: c.challengeMetadata || '',
8
- challengeResult: c.challengeResult,
9
- };
10
- return result;
11
- });
12
- return session;
13
- };
14
- exports.getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent = getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent;
@@ -1 +0,0 @@
1
- export * from './getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent';
@@ -1,3 +0,0 @@
1
- import { CreateAuthChallengeTriggerEvent } from 'aws-lambda';
2
- import { ChallengeSession } from 'quidproquo-core';
3
- export declare const getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent: (event: CreateAuthChallengeTriggerEvent) => ChallengeSession;
@@ -1,10 +0,0 @@
1
- export const getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent = (event) => {
2
- const session = event.request.session.map((c) => {
3
- const result = {
4
- challengeName: c.challengeMetadata || '',
5
- challengeResult: c.challengeResult,
6
- };
7
- return result;
8
- });
9
- return session;
10
- };
@@ -1 +0,0 @@
1
- export * from './getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent';
@@ -1 +0,0 @@
1
- export * from './getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent';
@@ -1,3 +0,0 @@
1
- import { CreateAuthChallengeTriggerEvent } from 'aws-lambda';
2
- import { ChallengeSession } from 'quidproquo-core';
3
- export declare const getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent: (event: CreateAuthChallengeTriggerEvent) => ChallengeSession;
@@ -1,10 +0,0 @@
1
- export const getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent = (event) => {
2
- const session = event.request.session.map((c) => {
3
- const result = {
4
- challengeName: c.challengeMetadata || '',
5
- challengeResult: c.challengeResult,
6
- };
7
- return result;
8
- });
9
- return session;
10
- };
@@ -1 +0,0 @@
1
- export * from './getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent';
@@ -1 +0,0 @@
1
- export * from './getChallengeSessionFromCognitoCreateAuthChallengeTriggerEvent';