quidproquo-actionprocessor-awslambda 0.1.23 → 0.1.25
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/commonjs/getActionProcessor/core/ai/getAiPromptActionProcessor.js +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js +1 -4
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/buildAiStopConditions.d.ts +13 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/buildAiStopConditions.js +24 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/buildAiStopConditions.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/index.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/index.js +1 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/index.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoGetPublicKeyActionProcessor.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoGetPublicKeyActionProcessor.js +34 -0
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoGetPublicKeyActionProcessor.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoSignActionProcessor.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoSignActionProcessor.js +36 -0
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoSignActionProcessor.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoVerifyActionProcessor.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoVerifyActionProcessor.js +38 -0
- package/lib/commonjs/getActionProcessor/core/crypto/getCryptoVerifyActionProcessor.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/index.js +4 -1
- package/lib/commonjs/getActionProcessor/core/crypto/index.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/crypto/kmsSigningErrorMap.d.ts +13 -0
- package/lib/commonjs/getActionProcessor/core/crypto/kmsSigningErrorMap.js +17 -0
- package/lib/commonjs/getActionProcessor/core/crypto/kmsSigningErrorMap.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/utils/index.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/utils/index.js +1 -0
- package/lib/commonjs/getActionProcessor/core/crypto/utils/index.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/crypto/utils/resolveSigningKeyAlias.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/crypto/utils/resolveSigningKeyAlias.js +19 -0
- package/lib/commonjs/getActionProcessor/core/crypto/utils/resolveSigningKeyAlias.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/file/getFileCopyActionProcessor.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/file/getFileCopyActionProcessor.js +37 -0
- package/lib/commonjs/getActionProcessor/core/file/getFileCopyActionProcessor.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/file/index.js +2 -1
- package/lib/commonjs/getActionProcessor/core/file/index.js.map +1 -1
- package/lib/commonjs/lambdaHandlers/helpers/getLambdaRuntimeRemainingTimeActionProcessor.d.ts +8 -0
- package/lib/commonjs/lambdaHandlers/helpers/getLambdaRuntimeRemainingTimeActionProcessor.js +26 -0
- package/lib/commonjs/lambdaHandlers/helpers/getLambdaRuntimeRemainingTimeActionProcessor.js.map +1 -0
- package/lib/commonjs/lambdaHandlers/helpers/getQpqLambdaRuntimeForEvent.js +6 -3
- package/lib/commonjs/lambdaHandlers/helpers/getQpqLambdaRuntimeForEvent.js.map +1 -1
- package/lib/commonjs/lambdaHandlers/helpers/index.d.ts +1 -0
- package/lib/commonjs/lambdaHandlers/helpers/index.js +1 -0
- package/lib/commonjs/lambdaHandlers/helpers/index.js.map +1 -1
- package/lib/commonjs/logic/kms/getCachedPublicKey.d.ts +1 -0
- package/lib/commonjs/logic/kms/getCachedPublicKey.js +45 -0
- package/lib/commonjs/logic/kms/getCachedPublicKey.js.map +1 -0
- package/lib/commonjs/logic/kms/signWithKey.d.ts +1 -0
- package/lib/commonjs/logic/kms/signWithKey.js +34 -0
- package/lib/commonjs/logic/kms/signWithKey.js.map +1 -0
- package/lib/commonjs/logic/s3/copyFile.d.ts +5 -0
- package/lib/commonjs/logic/s3/copyFile.js +31 -0
- package/lib/commonjs/logic/s3/copyFile.js.map +1 -0
- package/lib/commonjs/logic/s3/s3Utils.d.ts +1 -0
- package/lib/commonjs/logic/s3/s3Utils.js +1 -0
- package/lib/commonjs/logic/s3/s3Utils.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/getAiPromptActionProcessor.js +4 -3
- package/lib/esm/getActionProcessor/core/ai/getAiPromptActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js +4 -5
- package/lib/esm/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/buildAiStopConditions.d.ts +13 -0
- package/lib/esm/getActionProcessor/core/ai/logic/buildAiStopConditions.js +20 -0
- package/lib/esm/getActionProcessor/core/ai/logic/buildAiStopConditions.js.map +1 -0
- package/lib/esm/getActionProcessor/core/ai/logic/index.d.ts +1 -0
- package/lib/esm/getActionProcessor/core/ai/logic/index.js +1 -0
- package/lib/esm/getActionProcessor/core/ai/logic/index.js.map +1 -1
- package/lib/esm/getActionProcessor/core/crypto/getCryptoGetPublicKeyActionProcessor.d.ts +1 -0
- package/lib/esm/getActionProcessor/core/crypto/getCryptoGetPublicKeyActionProcessor.js +22 -0
- package/lib/esm/getActionProcessor/core/crypto/getCryptoGetPublicKeyActionProcessor.js.map +1 -0
- package/lib/esm/getActionProcessor/core/crypto/getCryptoSignActionProcessor.d.ts +1 -0
- package/lib/esm/getActionProcessor/core/crypto/getCryptoSignActionProcessor.js +24 -0
- package/lib/esm/getActionProcessor/core/crypto/getCryptoSignActionProcessor.js.map +1 -0
- package/lib/esm/getActionProcessor/core/crypto/getCryptoVerifyActionProcessor.d.ts +1 -0
- package/lib/esm/getActionProcessor/core/crypto/getCryptoVerifyActionProcessor.js +29 -0
- package/lib/esm/getActionProcessor/core/crypto/getCryptoVerifyActionProcessor.js.map +1 -0
- package/lib/esm/getActionProcessor/core/crypto/index.js +6 -0
- package/lib/esm/getActionProcessor/core/crypto/index.js.map +1 -1
- package/lib/esm/getActionProcessor/core/crypto/kmsSigningErrorMap.d.ts +13 -0
- package/lib/esm/getActionProcessor/core/crypto/kmsSigningErrorMap.js +12 -0
- package/lib/esm/getActionProcessor/core/crypto/kmsSigningErrorMap.js.map +1 -0
- package/lib/esm/getActionProcessor/core/crypto/utils/index.d.ts +1 -0
- package/lib/esm/getActionProcessor/core/crypto/utils/index.js +1 -0
- package/lib/esm/getActionProcessor/core/crypto/utils/index.js.map +1 -1
- package/lib/esm/getActionProcessor/core/crypto/utils/resolveSigningKeyAlias.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/crypto/utils/resolveSigningKeyAlias.js +14 -0
- package/lib/esm/getActionProcessor/core/crypto/utils/resolveSigningKeyAlias.js.map +1 -0
- package/lib/esm/getActionProcessor/core/file/getFileCopyActionProcessor.d.ts +1 -0
- package/lib/esm/getActionProcessor/core/file/getFileCopyActionProcessor.js +25 -0
- package/lib/esm/getActionProcessor/core/file/getFileCopyActionProcessor.js.map +1 -0
- package/lib/esm/getActionProcessor/core/file/index.js +2 -0
- package/lib/esm/getActionProcessor/core/file/index.js.map +1 -1
- package/lib/esm/lambdaHandlers/helpers/getLambdaRuntimeRemainingTimeActionProcessor.d.ts +8 -0
- package/lib/esm/lambdaHandlers/helpers/getLambdaRuntimeRemainingTimeActionProcessor.js +13 -0
- package/lib/esm/lambdaHandlers/helpers/getLambdaRuntimeRemainingTimeActionProcessor.js.map +1 -0
- package/lib/esm/lambdaHandlers/helpers/getQpqLambdaRuntimeForEvent.js +6 -2
- package/lib/esm/lambdaHandlers/helpers/getQpqLambdaRuntimeForEvent.js.map +1 -1
- package/lib/esm/lambdaHandlers/helpers/index.d.ts +1 -0
- package/lib/esm/lambdaHandlers/helpers/index.js +1 -0
- package/lib/esm/lambdaHandlers/helpers/index.js.map +1 -1
- package/lib/esm/logic/kms/getCachedPublicKey.d.ts +1 -0
- package/lib/esm/logic/kms/getCachedPublicKey.js +32 -0
- package/lib/esm/logic/kms/getCachedPublicKey.js.map +1 -0
- package/lib/esm/logic/kms/signWithKey.d.ts +1 -0
- package/lib/esm/logic/kms/signWithKey.js +21 -0
- package/lib/esm/logic/kms/signWithKey.js.map +1 -0
- package/lib/esm/logic/s3/copyFile.d.ts +5 -0
- package/lib/esm/logic/s3/copyFile.js +18 -0
- package/lib/esm/logic/s3/copyFile.js.map +1 -0
- package/lib/esm/logic/s3/s3Utils.d.ts +1 -0
- package/lib/esm/logic/s3/s3Utils.js +1 -0
- package/lib/esm/logic/s3/s3Utils.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type SigningErrorTypes = {
|
|
2
|
+
KeyUnavailable: string;
|
|
3
|
+
Throttling: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const kmsSigningErrorMap: (errorType: SigningErrorTypes, keyName: string) => {
|
|
6
|
+
NotFoundException: () => import("quidproquo-core").ActionProcessorResult<any>;
|
|
7
|
+
DisabledException: () => import("quidproquo-core").ActionProcessorResult<any>;
|
|
8
|
+
KMSInvalidStateException: () => import("quidproquo-core").ActionProcessorResult<any>;
|
|
9
|
+
AccessDeniedException: () => import("quidproquo-core").ActionProcessorResult<any>;
|
|
10
|
+
ThrottlingException: () => import("quidproquo-core").ActionProcessorResult<any>;
|
|
11
|
+
};
|
|
12
|
+
export declare const signingKeyNotConfiguredMessage: (keyName: string) => string;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { actionResultError } from 'quidproquo-core';
|
|
2
|
+
// The KMS exceptions every signing-key processor maps the same way, keyed by
|
|
3
|
+
// error.name as actionResultErrorFromCaughtError expects.
|
|
4
|
+
export const kmsSigningErrorMap = (errorType, keyName) => ({
|
|
5
|
+
NotFoundException: () => actionResultError(errorType.KeyUnavailable, `Signing key not found: [${keyName}]`),
|
|
6
|
+
DisabledException: () => actionResultError(errorType.KeyUnavailable, `Signing key is disabled: [${keyName}]`),
|
|
7
|
+
KMSInvalidStateException: () => actionResultError(errorType.KeyUnavailable, `Signing key is in an unusable state: [${keyName}]`),
|
|
8
|
+
AccessDeniedException: () => actionResultError(errorType.KeyUnavailable, `Access denied to signing key: [${keyName}]`),
|
|
9
|
+
ThrottlingException: () => actionResultError(errorType.Throttling, 'Throttling: Rate exceeded'),
|
|
10
|
+
});
|
|
11
|
+
export const signingKeyNotConfiguredMessage = (keyName) => `Signing key not configured: [${keyName}] - declare it with defineSigningKey`;
|
|
12
|
+
//# sourceMappingURL=kmsSigningErrorMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kmsSigningErrorMap.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/crypto/kmsSigningErrorMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAOpD,6EAA6E;AAC7E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAA4B,EAAE,OAAe,EAAE,EAAE,CAAC,CAAC;IACpF,iBAAiB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,cAAc,EAAE,2BAA2B,OAAO,GAAG,CAAC;IAC3G,iBAAiB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,cAAc,EAAE,6BAA6B,OAAO,GAAG,CAAC;IAC7G,wBAAwB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,cAAc,EAAE,yCAAyC,OAAO,GAAG,CAAC;IAChI,qBAAqB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,cAAc,EAAE,kCAAkC,OAAO,GAAG,CAAC;IACtH,mBAAmB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,UAAU,EAAE,2BAA2B,CAAC;CAChG,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,gCAAgC,OAAO,sCAAsC,CAAC","sourcesContent":["import { actionResultError } from 'quidproquo-core';\n\ntype SigningErrorTypes = {\n KeyUnavailable: string;\n Throttling: string;\n};\n\n// The KMS exceptions every signing-key processor maps the same way, keyed by\n// error.name as actionResultErrorFromCaughtError expects.\nexport const kmsSigningErrorMap = (errorType: SigningErrorTypes, keyName: string) => ({\n NotFoundException: () => actionResultError(errorType.KeyUnavailable, `Signing key not found: [${keyName}]`),\n DisabledException: () => actionResultError(errorType.KeyUnavailable, `Signing key is disabled: [${keyName}]`),\n KMSInvalidStateException: () => actionResultError(errorType.KeyUnavailable, `Signing key is in an unusable state: [${keyName}]`),\n AccessDeniedException: () => actionResultError(errorType.KeyUnavailable, `Access denied to signing key: [${keyName}]`),\n ThrottlingException: () => actionResultError(errorType.Throttling, 'Throttling: Rate exceeded'),\n});\n\nexport const signingKeyNotConfiguredMessage = (keyName: string) => `Signing key not configured: [${keyName}] - declare it with defineSigningKey`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/getActionProcessor/core/crypto/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC","sourcesContent":["export * from './createKmsDataKeyProvider';\nexport * from './resolveCryptoKeyAlias';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/getActionProcessor/core/crypto/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './createKmsDataKeyProvider';\nexport * from './resolveCryptoKeyAlias';\nexport * from './resolveSigningKeyAlias';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { qpqCoreUtils } from 'quidproquo-core';
|
|
2
|
+
import { getConfigRuntimeResourceNameFromConfigWithServiceOverride } from '../../../../awsNamingUtils';
|
|
3
|
+
// The signing-key twin of resolveCryptoKeyAlias: the deterministic KMS alias the
|
|
4
|
+
// CDK construct derives for a defineSigningKey, or null when none matches so
|
|
5
|
+
// processors can fail with KeyNotConfigured instead of a generic error.
|
|
6
|
+
export const resolveSigningKeyAlias = (signingKeyName, qpqConfig) => {
|
|
7
|
+
const signingKeyConfig = qpqCoreUtils.getAllSigningKeyConfigs(qpqConfig).find((k) => k.keyName === signingKeyName);
|
|
8
|
+
if (!signingKeyConfig) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const resolvedName = getConfigRuntimeResourceNameFromConfigWithServiceOverride(signingKeyConfig.owner?.resourceNameOverride || signingKeyName, qpqConfig, signingKeyConfig.owner?.module);
|
|
12
|
+
return `alias/${resolvedName}`;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=resolveSigningKeyAlias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSigningKeyAlias.js","sourceRoot":"","sources":["../../../../../../src/getActionProcessor/core/crypto/utils/resolveSigningKeyAlias.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,yDAAyD,EAAE,MAAM,4BAA4B,CAAC;AAEvG,iFAAiF;AACjF,6EAA6E;AAC7E,wEAAwE;AACxE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,cAAsB,EAAE,SAAoB,EAAoB,EAAE;IACvG,MAAM,gBAAgB,GAAG,YAAY,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,cAAc,CAAC,CAAC;IAEnH,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,YAAY,GAAG,yDAAyD,CAC5E,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,IAAI,cAAc,EAC9D,SAAS,EACT,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAC/B,CAAC;IAEF,OAAO,SAAS,YAAY,EAAE,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import { Nullable, QPQConfig, qpqCoreUtils } from 'quidproquo-core';\n\nimport { getConfigRuntimeResourceNameFromConfigWithServiceOverride } from '../../../../awsNamingUtils';\n\n// The signing-key twin of resolveCryptoKeyAlias: the deterministic KMS alias the\n// CDK construct derives for a defineSigningKey, or null when none matches so\n// processors can fail with KeyNotConfigured instead of a generic error.\nexport const resolveSigningKeyAlias = (signingKeyName: string, qpqConfig: QPQConfig): Nullable<string> => {\n const signingKeyConfig = qpqCoreUtils.getAllSigningKeyConfigs(qpqConfig).find((k) => k.keyName === signingKeyName);\n\n if (!signingKeyConfig) {\n return null;\n }\n\n const resolvedName = getConfigRuntimeResourceNameFromConfigWithServiceOverride(\n signingKeyConfig.owner?.resourceNameOverride || signingKeyName,\n qpqConfig,\n signingKeyConfig.owner?.module,\n );\n\n return `alias/${resolvedName}`;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getFileCopyActionProcessor: import("quidproquo-core").ActionProcessorListResolver;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, askFileCopy, composeScopedFilePath, createActionProcessor, } from 'quidproquo-core';
|
|
3
|
+
import { copyFile } from '../../../logic/s3/s3Utils';
|
|
4
|
+
import { resolveStorageDriveBucketName } from './utils';
|
|
5
|
+
const getProcessFileCopy = (qpqConfig) => {
|
|
6
|
+
return async ({ sourceDrive, sourceFilepath, targetDrive, targetFilepath, scope }) => {
|
|
7
|
+
try {
|
|
8
|
+
const sourceBucketName = resolveStorageDriveBucketName(sourceDrive, qpqConfig);
|
|
9
|
+
const targetBucketName = resolveStorageDriveBucketName(targetDrive, qpqConfig);
|
|
10
|
+
await copyFile(sourceBucketName, composeScopedFilePath(scope, sourceFilepath), targetBucketName, composeScopedFilePath(scope, targetFilepath), qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
11
|
+
return actionResult(void 0);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
return actionResultErrorFromCaughtError(error, {
|
|
15
|
+
AccessDenied: () => actionResultError(askFileCopy.errorType.AccessDenied, 'Access denied copying file'),
|
|
16
|
+
NoSuchBucket: () => actionResultError(askFileCopy.errorType.DriveNotFound, `Storage drive not found: ${sourceDrive} or ${targetDrive}`),
|
|
17
|
+
NoSuchKey: () => actionResultError(askFileCopy.errorType.FileNotFound, `File not found: ${sourceFilepath}`),
|
|
18
|
+
StorageDriveNotFoundError: (error) => actionResultError(askFileCopy.errorType.DriveNotFound, error.message),
|
|
19
|
+
InvalidScopeError: (error) => actionResultError(askFileCopy.errorType.InvalidScope, error.message),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export const getFileCopyActionProcessor = createActionProcessor(askFileCopy, getProcessFileCopy);
|
|
25
|
+
//# sourceMappingURL=getFileCopyActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileCopyActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileCopyActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAu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AAyB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,SAAS,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC;gBAC3G,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aACnG,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,qBAAqB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n askFileCopy,\n composeScopedFilePath,\n createActionProcessor,\n FileActionType,\n ProcessorFor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { copyFile } from '../../../logic/s3/s3Utils';\nimport { resolveStorageDriveBucketName } from './utils';\n\nconst getProcessFileCopy = (qpqConfig: QPQConfig): ProcessorFor<typeof askFileCopy> => {\n return async ({ sourceDrive, sourceFilepath, targetDrive, targetFilepath, scope }) => {\n try {\n const sourceBucketName = resolveStorageDriveBucketName(sourceDrive, qpqConfig);\n const targetBucketName = resolveStorageDriveBucketName(targetDrive, qpqConfig);\n\n await copyFile(\n sourceBucketName,\n composeScopedFilePath(scope, sourceFilepath),\n targetBucketName,\n composeScopedFilePath(scope, targetFilepath),\n qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig),\n );\n\n return actionResult(void 0);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n AccessDenied: () => actionResultError(askFileCopy.errorType.AccessDenied, 'Access denied copying file'),\n NoSuchBucket: () => actionResultError(askFileCopy.errorType.DriveNotFound, `Storage drive not found: ${sourceDrive} or ${targetDrive}`),\n NoSuchKey: () => actionResultError(askFileCopy.errorType.FileNotFound, `File not found: ${sourceFilepath}`),\n StorageDriveNotFoundError: (error) => actionResultError(askFileCopy.errorType.DriveNotFound, error.message),\n InvalidScopeError: (error) => actionResultError(askFileCopy.errorType.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileCopyActionProcessor = createActionProcessor(askFileCopy, getProcessFileCopy);\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getFileCopyActionProcessor } from './getFileCopyActionProcessor';
|
|
1
2
|
import { getFileDeleteActionProcessor } from './getFileDeleteActionProcessor';
|
|
2
3
|
import { getFileExistsActionProcessor } from './getFileExistsActionProcessor';
|
|
3
4
|
import { getFileGenerateTemporarySecureUrlActionProcessor } from './getFileGenerateTemporarySecureUrlActionProcessor';
|
|
@@ -12,6 +13,7 @@ import { getFileWriteBinaryContentsActionProcessor } from './getFileWriteBinaryC
|
|
|
12
13
|
import { getFileWriteObjectJsonActionProcessor } from './getFileWriteObjectJsonActionProcessor';
|
|
13
14
|
import { getFileWriteTextContentsActionProcessor } from './getFileWriteTextContentsActionProcessor';
|
|
14
15
|
export const getFileActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
16
|
+
...(await getFileCopyActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
15
17
|
...(await getFileDeleteActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
16
18
|
...(await getFileExistsActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
17
19
|
...(await getFileGenerateTemporarySecureUrlActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,gDAAgD,EAAE,MAAM,oDAAoD,CAAC;AACtH,OAAO,EAAE,sDAAsD,EAAE,MA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,CAAC;IAClF,GAAG,CAAC,MAAM,wCAAwC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACnF,GAAG,CAAC,MAAM,qCAAqC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAChF,GAAG,CAAC,MAAM,yCAAyC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACpF,GAAG,CAAC,MAAM,gCAAgC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CAC5E,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nimport { getFileDeleteActionProcessor } from './getFileDeleteActionProcessor';\nimport { getFileExistsActionProcessor } from './getFileExistsActionProcessor';\nimport { getFileGenerateTemporarySecureUrlActionProcessor } from './getFileGenerateTemporarySecureUrlActionProcessor';\nimport { getFileGenerateTemporaryUploadSecureUrlActionProcessor } from './getFileGenerateTemporaryUploadSecureUrlActionProcessor';\nimport { getFileIsColdStorageActionProcessor } from './getFileIsColdStorageActionProcessor';\nimport { getFileListDirectoryActionProcessor } from './getFileListDirectoryActionProcessor';\nimport { getFileReadBinaryContentsActionProcessor } from './getFileReadBinaryContentsActionProcessor';\nimport { getFileReadObjectJsonActionProcessor } from './getFileReadObjectJsonActionProcessor';\nimport { getFileReadTextContentsActionProcessor } from './getFileReadTextContentsActionProcessor';\nimport { getFileStreamOpenActionProcessor } from './getFileStreamOpenActionProcessor';\nimport { getFileWriteBinaryContentsActionProcessor } from './getFileWriteBinaryContentsActionProcessor';\nimport { getFileWriteObjectJsonActionProcessor } from './getFileWriteObjectJsonActionProcessor';\nimport { getFileWriteTextContentsActionProcessor } from './getFileWriteTextContentsActionProcessor';\n\nexport const getFileActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getFileDeleteActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileExistsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileGenerateTemporarySecureUrlActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileGenerateTemporaryUploadSecureUrlActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileIsColdStorageActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileListDirectoryActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileReadTextContentsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileReadObjectJsonActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileWriteTextContentsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileReadBinaryContentsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileWriteObjectJsonActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileWriteBinaryContentsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileStreamOpenActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,gDAAgD,EAAE,MAAM,oDAAoD,CAAC;AACtH,OAAO,EAAE,sDAAsD,EAAE,MAAM,0DAA0D,CAAC;AAClI,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAE,sCAAsC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SAAS,EAAE,mBAAmB,CAAC,CAAC;IACpF,GAAG,CAAC,MAAM,gCAAgC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CAC5E,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nimport { getFileCopyActionProcessor } from './getFileCopyActionProcessor';\nimport { getFileDeleteActionProcessor } from './getFileDeleteActionProcessor';\nimport { getFileExistsActionProcessor } from './getFileExistsActionProcessor';\nimport { getFileGenerateTemporarySecureUrlActionProcessor } from './getFileGenerateTemporarySecureUrlActionProcessor';\nimport { getFileGenerateTemporaryUploadSecureUrlActionProcessor } from './getFileGenerateTemporaryUploadSecureUrlActionProcessor';\nimport { getFileIsColdStorageActionProcessor } from './getFileIsColdStorageActionProcessor';\nimport { getFileListDirectoryActionProcessor } from './getFileListDirectoryActionProcessor';\nimport { getFileReadBinaryContentsActionProcessor } from './getFileReadBinaryContentsActionProcessor';\nimport { getFileReadObjectJsonActionProcessor } from './getFileReadObjectJsonActionProcessor';\nimport { getFileReadTextContentsActionProcessor } from './getFileReadTextContentsActionProcessor';\nimport { getFileStreamOpenActionProcessor } from './getFileStreamOpenActionProcessor';\nimport { getFileWriteBinaryContentsActionProcessor } from './getFileWriteBinaryContentsActionProcessor';\nimport { getFileWriteObjectJsonActionProcessor } from './getFileWriteObjectJsonActionProcessor';\nimport { getFileWriteTextContentsActionProcessor } from './getFileWriteTextContentsActionProcessor';\n\nexport const getFileActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getFileCopyActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileDeleteActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileExistsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileGenerateTemporarySecureUrlActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileGenerateTemporaryUploadSecureUrlActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileIsColdStorageActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileListDirectoryActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileReadTextContentsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileReadObjectJsonActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileWriteTextContentsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileReadBinaryContentsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileWriteObjectJsonActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileWriteBinaryContentsActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getFileStreamOpenActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionProcessorList } from 'quidproquo-core';
|
|
2
|
+
import { Context } from 'aws-lambda';
|
|
3
|
+
/**
|
|
4
|
+
* Overrides the js "unlimited" GetRuntimeRemainingTime processor with the real lambda
|
|
5
|
+
* deadline. The context is per invocation, so this is built inside the handler and
|
|
6
|
+
* spread over the shared processor list on every invoke.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getLambdaRuntimeRemainingTimeActionProcessor: (context: Context) => ActionProcessorList;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { actionResult, SystemActionType } from 'quidproquo-core';
|
|
2
|
+
/**
|
|
3
|
+
* Overrides the js "unlimited" GetRuntimeRemainingTime processor with the real lambda
|
|
4
|
+
* deadline. The context is per invocation, so this is built inside the handler and
|
|
5
|
+
* spread over the shared processor list on every invoke.
|
|
6
|
+
*/
|
|
7
|
+
export const getLambdaRuntimeRemainingTimeActionProcessor = (context) => {
|
|
8
|
+
const processGetRuntimeRemainingTime = async () => actionResult(context.getRemainingTimeInMillis());
|
|
9
|
+
return {
|
|
10
|
+
[SystemActionType.GetRuntimeRemainingTime]: processGetRuntimeRemainingTime,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=getLambdaRuntimeRemainingTimeActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLambdaRuntimeRemainingTimeActionProcessor.js","sourceRoot":"","sources":["../../../../src/lambdaHandlers/helpers/getLambdaRuntimeRemainingTimeActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,YAAY,EAA4C,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIhI;;;;GAIG;AACH,MAAM,CAAC,MAAM,4CAA4C,GAAG,CAAC,OAAgB,EAAuB,EAAE;IACpG,MAAM,8BAA8B,GAAoD,KAAK,IAAI,EAAE,CACjG,YAAY,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAEnD,OAAO;QACL,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,EAAE,8BAA8B;KAC3E,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, actionResult, askGetRuntimeRemainingTime, ProcessorFor, SystemActionType } from 'quidproquo-core';\n\nimport { Context } from 'aws-lambda';\n\n/**\n * Overrides the js \"unlimited\" GetRuntimeRemainingTime processor with the real lambda\n * deadline. The context is per invocation, so this is built inside the handler and\n * spread over the shared processor list on every invoke.\n */\nexport const getLambdaRuntimeRemainingTimeActionProcessor = (context: Context): ActionProcessorList => {\n const processGetRuntimeRemainingTime: ProcessorFor<typeof askGetRuntimeRemainingTime> = async () =>\n actionResult(context.getRemainingTimeInMillis());\n\n return {\n [SystemActionType.GetRuntimeRemainingTime]: processGetRuntimeRemainingTime,\n };\n};\n"]}
|
|
@@ -2,6 +2,7 @@ import { getCustomActionActionProcessor } from 'quidproquo-actionprocessor-js';
|
|
|
2
2
|
import { askProcessEvent, createRuntime, } from 'quidproquo-core';
|
|
3
3
|
import { getAwsActionProcessors } from '../../getActionProcessor';
|
|
4
4
|
import { dynamicModuleLoaderWarmer } from './dynamicModuleLoaderWarmer';
|
|
5
|
+
import { getLambdaRuntimeRemainingTimeActionProcessor } from './getLambdaRuntimeRemainingTimeActionProcessor';
|
|
5
6
|
import { getLogger } from './getLogger';
|
|
6
7
|
import { getRuntimeCorrelation } from './getRuntimeCorrelation';
|
|
7
8
|
import { isSnsWarmerRecord } from './isSnsWarmerRecord';
|
|
@@ -20,16 +21,19 @@ const isSnsEvent = (event) => {
|
|
|
20
21
|
* short-circuits SNS warmer pings, runs the process-event story and ships logs.
|
|
21
22
|
*/
|
|
22
23
|
export const getQpqLambdaRuntimeForEvent = (runtimeType, getStorySession, getActionProcessorList, dynamicModuleLoader, qpqConfig, getProcessEventStory = () => askProcessEvent) => {
|
|
23
|
-
|
|
24
|
+
// Built per invoke: the lambda context (and so the execution deadline) is not
|
|
25
|
+
// known until the handler runs.
|
|
26
|
+
const getResolveActionProcessorList = (context) => async () => ({
|
|
24
27
|
...(await getAwsActionProcessors(qpqConfig, dynamicModuleLoader)),
|
|
25
28
|
...(await getActionProcessorList(qpqConfig, dynamicModuleLoader)),
|
|
29
|
+
...getLambdaRuntimeRemainingTimeActionProcessor(context),
|
|
26
30
|
// Always done last, so they can override the default ones if the user wants.
|
|
27
31
|
...(await getCustomActionActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
28
32
|
});
|
|
29
33
|
return async (event, context) => {
|
|
30
34
|
console.log('tick: ', JSON.stringify(event, null, 2));
|
|
31
35
|
const logger = getLogger(qpqConfig);
|
|
32
|
-
const resolveStory = createRuntime(qpqConfig, getStorySession(event),
|
|
36
|
+
const resolveStory = createRuntime(qpqConfig, getStorySession(event), getResolveActionProcessorList(context), () => new Date().toISOString(), logger, getRuntimeCorrelation(qpqConfig), runtimeType, dynamicModuleLoader);
|
|
33
37
|
const processEvent = async () => {
|
|
34
38
|
const result = await resolveStory(getProcessEventStory(), [event, context]);
|
|
35
39
|
await logger.waitToFinishWriting();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQpqLambdaRuntimeForEvent.js","sourceRoot":"","sources":["../../../../src/lambdaHandlers/helpers/getQpqLambdaRuntimeForEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAGL,eAAe,EACf,aAAa,GAKd,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,MAAM,UAAU,GAAG,CAAI,KAAmC,EAAqB,EAAE;IAC/E,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,gBAAgB,GAAG,KAA4B,CAAC;QACtD,OAAO,gBAAgB,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,WAA2B,EAC3B,eAA2C,EAC3C,sBAAmD,EACnD,mBAAwC,EACxC,SAAoB,EACpB,uBAAqD,GAAG,EAAE,CAAC,eAAe,EAC1E,EAAE;IACF,MAAM,
|
|
1
|
+
{"version":3,"file":"getQpqLambdaRuntimeForEvent.js","sourceRoot":"","sources":["../../../../src/lambdaHandlers/helpers/getQpqLambdaRuntimeForEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAGL,eAAe,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AAO,CAAC,MAAM,EAAE,CAAC;gBAClD,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;gBAEhC,+CAA+C;gBAC/C,8BAA8B;gBAC9B,MAAM,yBAAyB,EAAE,CAAC;gBAElC,mDAAmD;gBACnD,MAAM,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBAEtC,OAAO,YAAY,CAAC;YACtB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,YAAY,EAAE,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { getCustomActionActionProcessor } from 'quidproquo-actionprocessor-js';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n askProcessEvent,\n createRuntime,\n DynamicModuleLoader,\n QPQConfig,\n QpqRuntimeType,\n StorySession,\n} from 'quidproquo-core';\n\nimport { Context, SNSEvent } from 'aws-lambda';\n\nimport { getAwsActionProcessors } from '../../getActionProcessor';\nimport { QpqFunctionExecutionEvent } from '../types';\nimport { dynamicModuleLoaderWarmer } from './dynamicModuleLoaderWarmer';\nimport { getLambdaRuntimeRemainingTimeActionProcessor } from './getLambdaRuntimeRemainingTimeActionProcessor';\nimport { getLogger } from './getLogger';\nimport { getRuntimeCorrelation } from './getRuntimeCorrelation';\nimport { isSnsWarmerRecord } from './isSnsWarmerRecord';\n\n// SQS/S3/CloudFront events also have a Records array, so this matches more than\n// real SNS events. That is harmless: the warmer scan below only acts on records\n// whose EventSource is 'aws:sns', everything else falls through to processEvent.\nconst isSnsEvent = <T>(event: QpqFunctionExecutionEvent<T>): event is SNSEvent => {\n if (event && typeof event === 'object') {\n const possibleSnsEvent = event as unknown as SNSEvent;\n return possibleSnsEvent.Records && Array.isArray(possibleSnsEvent.Records);\n }\n\n return false;\n};\n\n/**\n * Builds the shared lambda handler: wires a qpq runtime for the event type,\n * short-circuits SNS warmer pings, runs the process-event story and ships logs.\n */\nexport const getQpqLambdaRuntimeForEvent = <E extends QpqFunctionExecutionEvent<any>>(\n runtimeType: QpqRuntimeType,\n getStorySession: (event: E) => StorySession,\n getActionProcessorList: ActionProcessorListResolver,\n dynamicModuleLoader: DynamicModuleLoader,\n qpqConfig: QPQConfig,\n getProcessEventStory: () => typeof askProcessEvent = () => askProcessEvent,\n) => {\n // Built per invoke: the lambda context (and so the execution deadline) is not\n // known until the handler runs.\n const getResolveActionProcessorList = (context: Context) => async (): Promise<ActionProcessorList> => ({\n ...(await getAwsActionProcessors(qpqConfig, dynamicModuleLoader)),\n ...(await getActionProcessorList(qpqConfig, dynamicModuleLoader)),\n ...getLambdaRuntimeRemainingTimeActionProcessor(context),\n\n // Always done last, so they can override the default ones if the user wants.\n ...(await getCustomActionActionProcessor(qpqConfig, dynamicModuleLoader)),\n });\n\n return async (event: E, context: Context) => {\n console.log('tick: ', JSON.stringify(event, null, 2));\n\n const logger = getLogger(qpqConfig);\n\n const resolveStory = createRuntime(\n qpqConfig,\n getStorySession(event),\n getResolveActionProcessorList(context),\n () => new Date().toISOString(),\n logger,\n getRuntimeCorrelation(qpqConfig),\n runtimeType,\n dynamicModuleLoader,\n );\n\n const processEvent = async () => {\n const result = await resolveStory(getProcessEventStory(), [event, context]);\n await logger.waitToFinishWriting();\n\n if (result.error) {\n throw new Error(result.error.errorText);\n }\n\n console.log('Finished, returning: ', result.result);\n return result.result;\n };\n\n if (isSnsEvent(event)) {\n const recordsNoWarm = event.Records.filter((record) => !isSnsWarmerRecord(record));\n\n // A warmer ping arrives as its own single-record SNS event; any warmer\n // present means this invoke exists only to keep the sandbox warm.\n if (recordsNoWarm.length !== event.Records.length) {\n console.log('Found SNS warmer');\n\n // TODO: Warm qpq things with dynamic functions\n // federate in dynamic modules\n await dynamicModuleLoaderWarmer();\n\n // Might as well move the logs to permanent storage\n await logger.moveToPermanentStorage();\n\n return 'Warmed up!';\n }\n }\n\n return await processEvent();\n };\n};\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './dynamicModuleLoaderWarmer';
|
|
2
2
|
export * from './getBlankStorySession';
|
|
3
|
+
export * from './getLambdaRuntimeRemainingTimeActionProcessor';
|
|
3
4
|
export * from './getLogger';
|
|
4
5
|
export * from './getQpqLambdaRuntimeForEvent';
|
|
5
6
|
export * from './getRuntimeCorrelation';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './dynamicModuleLoaderWarmer';
|
|
2
2
|
export * from './getBlankStorySession';
|
|
3
|
+
export * from './getLambdaRuntimeRemainingTimeActionProcessor';
|
|
3
4
|
export * from './getLogger';
|
|
4
5
|
export * from './getQpqLambdaRuntimeForEvent';
|
|
5
6
|
export * from './getRuntimeCorrelation';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lambdaHandlers/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './dynamicModuleLoaderWarmer';\nexport * from './getBlankStorySession';\nexport * from './getLogger';\nexport * from './getQpqLambdaRuntimeForEvent';\nexport * from './getRuntimeCorrelation';\nexport * from './isSnsWarmerRecord';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lambdaHandlers/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './dynamicModuleLoaderWarmer';\nexport * from './getBlankStorySession';\nexport * from './getLambdaRuntimeRemainingTimeActionProcessor';\nexport * from './getLogger';\nexport * from './getQpqLambdaRuntimeForEvent';\nexport * from './getRuntimeCorrelation';\nexport * from './isSnsWarmerRecord';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCachedPublicKey: (keyAlias: string, region: string) => Promise<string>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { spkiDerToPem } from 'quidproquo-actionprocessor-node';
|
|
2
|
+
import { GetPublicKeyCommand, KMSClient } from '@aws-sdk/client-kms';
|
|
3
|
+
import { createAwsClient } from '../createAwsClient';
|
|
4
|
+
// The public half of a signing key is immutable for the life of the key, so it is
|
|
5
|
+
// fetched once per alias per runtime and verification runs locally from then on:
|
|
6
|
+
// askCryptoVerify costs no KMS call after warm-up, and needs no kms:Verify grant.
|
|
7
|
+
// Bounded by age only so a key replaced under the same alias is picked up.
|
|
8
|
+
const PUBLIC_KEY_MAX_AGE_MS = 60 * 60 * 1000;
|
|
9
|
+
const cache = new Map();
|
|
10
|
+
export const getCachedPublicKey = async (keyAlias, region) => {
|
|
11
|
+
const cacheKey = `${region}|${keyAlias}`;
|
|
12
|
+
const cached = cache.get(cacheKey);
|
|
13
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
14
|
+
return cached.publicKeyPem;
|
|
15
|
+
}
|
|
16
|
+
const kmsClient = createAwsClient(KMSClient, {
|
|
17
|
+
region,
|
|
18
|
+
});
|
|
19
|
+
const response = await kmsClient.send(new GetPublicKeyCommand({
|
|
20
|
+
KeyId: keyAlias,
|
|
21
|
+
}));
|
|
22
|
+
if (!response.PublicKey) {
|
|
23
|
+
throw new Error(`KMS returned no public key for [${keyAlias}]`);
|
|
24
|
+
}
|
|
25
|
+
const publicKeyPem = spkiDerToPem(Buffer.from(response.PublicKey));
|
|
26
|
+
cache.set(cacheKey, {
|
|
27
|
+
publicKeyPem,
|
|
28
|
+
expiresAt: Date.now() + PUBLIC_KEY_MAX_AGE_MS,
|
|
29
|
+
});
|
|
30
|
+
return publicKeyPem;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=getCachedPublicKey.js.map
|
|
@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EnE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE;QAClB,YAAY;QACZ,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,qBAAqB;KAC9C,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import { spkiDerToPem } from 'quidproquo-actionprocessor-node';\n\nimport { GetPublicKeyCommand, KMSClient } from '@aws-sdk/client-kms';\n\nimport { createAwsClient } from '../createAwsClient';\n\n// The public half of a signing key is immutable for the life of the key, so it is\n// fetched once per alias per runtime and verification runs locally from then on:\n// askCryptoVerify costs no KMS call after warm-up, and needs no kms:Verify grant.\n// Bounded by age only so a key replaced under the same alias is picked up.\nconst PUBLIC_KEY_MAX_AGE_MS = 60 * 60 * 1000;\n\ntype CachedPublicKey = {\n publicKeyPem: string;\n expiresAt: number;\n};\n\nconst cache = new Map<string, CachedPublicKey>();\n\nexport const getCachedPublicKey = async (keyAlias: string, region: string): Promise<string> => {\n const cacheKey = `${region}|${keyAlias}`;\n\n const cached = cache.get(cacheKey);\n if (cached && cached.expiresAt > Date.now()) {\n return cached.publicKeyPem;\n }\n\n const kmsClient = createAwsClient(KMSClient, {\n region,\n });\n\n const response = await kmsClient.send(\n new GetPublicKeyCommand({\n KeyId: keyAlias,\n }),\n );\n\n if (!response.PublicKey) {\n throw new Error(`KMS returned no public key for [${keyAlias}]`);\n }\n\n const publicKeyPem = spkiDerToPem(Buffer.from(response.PublicKey));\n\n cache.set(cacheKey, {\n publicKeyPem,\n expiresAt: Date.now() + PUBLIC_KEY_MAX_AGE_MS,\n });\n\n return publicKeyPem;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const signWithKey: (keyAlias: string, message: string, region: string) => Promise<Buffer>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RS256_KMS_SIGNING_ALGORITHM } from 'quidproquo-actionprocessor-node';
|
|
2
|
+
import { KMSClient, SignCommand } from '@aws-sdk/client-kms';
|
|
3
|
+
import { createAwsClient } from '../createAwsClient';
|
|
4
|
+
// One kms:Sign per call: the private key never leaves KMS, so there is nothing
|
|
5
|
+
// to cache here. Returns the raw signature bytes.
|
|
6
|
+
export const signWithKey = async (keyAlias, message, region) => {
|
|
7
|
+
const kmsClient = createAwsClient(KMSClient, {
|
|
8
|
+
region,
|
|
9
|
+
});
|
|
10
|
+
const response = await kmsClient.send(new SignCommand({
|
|
11
|
+
KeyId: keyAlias,
|
|
12
|
+
Message: Buffer.from(message, 'utf8'),
|
|
13
|
+
MessageType: 'RAW',
|
|
14
|
+
SigningAlgorithm: RS256_KMS_SIGNING_ALGORITHM,
|
|
15
|
+
}));
|
|
16
|
+
if (!response.Signature) {
|
|
17
|
+
throw new Error(`KMS returned no signature for [${keyAlias}]`);
|
|
18
|
+
}
|
|
19
|
+
return Buffer.from(response.Signature);
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=signWithKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signWithKey.js","sourceRoot":"","sources":["../../../../src/logic/kms/signWithKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,+EAA+E;AAC/E,kDAAkD;AAClD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,QAAgB,EAAE,OAAe,EAAE,MAAc,EAAmB,EAAE;IACtG,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,EAAE;QAC3C,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CACnC,IAAI,WAAW,CAAC;QACd,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;QACrC,WAAW,EAAE,KAAK;QAClB,gBAAgB,EAAE,2BAA2B;KAC9C,CAAC,CACH,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,GAAG,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC,CAAC","sourcesContent":["import { RS256_KMS_SIGNING_ALGORITHM } from 'quidproquo-actionprocessor-node';\n\nimport { KMSClient, SignCommand } from '@aws-sdk/client-kms';\n\nimport { createAwsClient } from '../createAwsClient';\n\n// One kms:Sign per call: the private key never leaves KMS, so there is nothing\n// to cache here. Returns the raw signature bytes.\nexport const signWithKey = async (keyAlias: string, message: string, region: string): Promise<Buffer> => {\n const kmsClient = createAwsClient(KMSClient, {\n region,\n });\n\n const response = await kmsClient.send(\n new SignCommand({\n KeyId: keyAlias,\n Message: Buffer.from(message, 'utf8'),\n MessageType: 'RAW',\n SigningAlgorithm: RS256_KMS_SIGNING_ALGORITHM,\n }),\n );\n\n if (!response.Signature) {\n throw new Error(`KMS returned no signature for [${keyAlias}]`);\n }\n\n return Buffer.from(response.Signature);\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side copies one object to another key (same or another bucket). The default COPY metadata
|
|
3
|
+
* directive carries the stored Content-Type / Content-Disposition across unchanged.
|
|
4
|
+
*/
|
|
5
|
+
export declare const copyFile: (sourceBucketName: string, sourceKey: string, targetBucketName: string, targetKey: string, region: string) => Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CopyObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
import { createAwsClient } from '../createAwsClient';
|
|
3
|
+
// CopySource is a URL path, so each key segment is percent-encoded (a key can hold spaces, '+', '#'...);
|
|
4
|
+
// the '/' between segments stays a separator.
|
|
5
|
+
const encodeCopySource = (bucketName, key) => `${bucketName}/${key.split('/').map(encodeURIComponent).join('/')}`;
|
|
6
|
+
/**
|
|
7
|
+
* Server-side copies one object to another key (same or another bucket). The default COPY metadata
|
|
8
|
+
* directive carries the stored Content-Type / Content-Disposition across unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export const copyFile = async (sourceBucketName, sourceKey, targetBucketName, targetKey, region) => {
|
|
11
|
+
const s3Client = createAwsClient(S3Client, { region });
|
|
12
|
+
await s3Client.send(new CopyObjectCommand({
|
|
13
|
+
CopySource: encodeCopySource(sourceBucketName, sourceKey),
|
|
14
|
+
Bucket: targetBucketName,
|
|
15
|
+
Key: targetKey,
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=copyFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyFile.js","sourceRoot":"","sources":["../../../../src/logic/s3/copyFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,yGAAyG;AACzG,8CAA8C;AAC9C,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAE,GAAW,EAAU,EAAE,CAAC,GAAG,UAAU,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAE1I;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,gBAAwB,EACxB,SAAiB,EACjB,gBAAwB,EACxB,SAAiB,EACjB,MAAc,EACC,EAAE;IACjB,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAEvD,MAAM,QAAQ,CAAC,IAAI,CACjB,IAAI,iBAAiB,CAAC;QACpB,UAAU,EAAE,gBAAgB,CAAC,gBAAgB,EAAE,SAAS,CAAC;QACzD,MAAM,EAAE,gBAAgB;QACxB,GAAG,EAAE,SAAS;KACf,CAAC,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { CopyObjectCommand, S3Client } from '@aws-sdk/client-s3';\n\nimport { createAwsClient } from '../createAwsClient';\n\n// CopySource is a URL path, so each key segment is percent-encoded (a key can hold spaces, '+', '#'...);\n// the '/' between segments stays a separator.\nconst encodeCopySource = (bucketName: string, key: string): string => `${bucketName}/${key.split('/').map(encodeURIComponent).join('/')}`;\n\n/**\n * Server-side copies one object to another key (same or another bucket). The default COPY metadata\n * directive carries the stored Content-Type / Content-Disposition across unchanged.\n */\nexport const copyFile = async (\n sourceBucketName: string,\n sourceKey: string,\n targetBucketName: string,\n targetKey: string,\n region: string,\n): Promise<void> => {\n const s3Client = createAwsClient(S3Client, { region });\n\n await s3Client.send(\n new CopyObjectCommand({\n CopySource: encodeCopySource(sourceBucketName, sourceKey),\n Bucket: targetBucketName,\n Key: targetKey,\n }),\n );\n};\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The s3 folder's barrel (kept under its historical name: many processors and their
|
|
2
2
|
// vi.mock calls point at 'logic/s3/s3Utils').
|
|
3
|
+
export * from './copyFile';
|
|
3
4
|
export * from './deleteFiles';
|
|
4
5
|
export * from './generatePresignedUploadUrl';
|
|
5
6
|
export * from './generatePresignedUrl';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3Utils.js","sourceRoot":"","sources":["../../../../src/logic/s3/s3Utils.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,8CAA8C;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["// The s3 folder's barrel (kept under its historical name: many processors and their\n// vi.mock calls point at 'logic/s3/s3Utils').\nexport * from './deleteFiles';\nexport * from './generatePresignedUploadUrl';\nexport * from './generatePresignedUrl';\nexport * from './getObjectStorageClass';\nexport * from './listFiles';\nexport * from './objectExists';\nexport * from './readBinaryFile';\nexport * from './readTextFile';\nexport * from './writeBinaryFile';\nexport * from './writeTextFile';\n"]}
|
|
1
|
+
{"version":3,"file":"s3Utils.js","sourceRoot":"","sources":["../../../../src/logic/s3/s3Utils.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,8CAA8C;AAC9C,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["// The s3 folder's barrel (kept under its historical name: many processors and their\n// vi.mock calls point at 'logic/s3/s3Utils').\nexport * from './copyFile';\nexport * from './deleteFiles';\nexport * from './generatePresignedUploadUrl';\nexport * from './generatePresignedUrl';\nexport * from './getObjectStorageClass';\nexport * from './listFiles';\nexport * from './objectExists';\nexport * from './readBinaryFile';\nexport * from './readTextFile';\nexport * from './writeBinaryFile';\nexport * from './writeTextFile';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-actionprocessor-awslambda",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"lodash": "^4.17.21",
|
|
67
67
|
"node-cache": "^5.1.2",
|
|
68
68
|
"node-match-path": "^0.6.3",
|
|
69
|
-
"quidproquo-actionprocessor-js": "0.1.
|
|
70
|
-
"quidproquo-actionprocessor-node": "0.1.
|
|
71
|
-
"quidproquo-config-aws": "0.1.
|
|
72
|
-
"quidproquo-core": "0.1.
|
|
73
|
-
"quidproquo-webserver": "0.1.
|
|
69
|
+
"quidproquo-actionprocessor-js": "0.1.25",
|
|
70
|
+
"quidproquo-actionprocessor-node": "0.1.25",
|
|
71
|
+
"quidproquo-config-aws": "0.1.25",
|
|
72
|
+
"quidproquo-core": "0.1.25",
|
|
73
|
+
"quidproquo-webserver": "0.1.25"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/busboy": "^1.5.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@types/lodash": "^4.14.194",
|
|
79
79
|
"@types/node": "^22.13.13",
|
|
80
80
|
"esbuild": "^0.25.8",
|
|
81
|
-
"quidproquo-tsconfig": "0.1.
|
|
81
|
+
"quidproquo-tsconfig": "0.1.25",
|
|
82
82
|
"typescript": "^5.8.2"
|
|
83
83
|
}
|
|
84
84
|
}
|