@webiny/api-file-manager-s3 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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/assetDelivery/assetDeliveryConfig.d.ts +2 -0
- package/assetDelivery/assetDeliveryConfig.js +52 -0
- package/assetDelivery/assetDeliveryConfig.js.map +1 -0
- package/assetDelivery/createAssetDelivery.d.ts +3 -0
- package/assetDelivery/createAssetDelivery.js +30 -0
- package/assetDelivery/createAssetDelivery.js.map +1 -0
- package/assetDelivery/createCustomAssetDelivery.d.ts +12 -0
- package/assetDelivery/createCustomAssetDelivery.js +28 -0
- package/assetDelivery/createCustomAssetDelivery.js.map +1 -0
- package/assetDelivery/customAssets/CustomAsset.d.ts +6 -0
- package/assetDelivery/customAssets/CustomAsset.js +14 -0
- package/assetDelivery/customAssets/CustomAsset.js.map +1 -0
- package/assetDelivery/customAssets/CustomAssetProcessor.d.ts +10 -0
- package/assetDelivery/customAssets/CustomAssetProcessor.js +25 -0
- package/assetDelivery/customAssets/CustomAssetProcessor.js.map +1 -0
- package/assetDelivery/customAssets/S3CustomAssetResolver.d.ts +15 -0
- package/assetDelivery/customAssets/S3CustomAssetResolver.js +90 -0
- package/assetDelivery/customAssets/S3CustomAssetResolver.js.map +1 -0
- package/assetDelivery/customAssets/customAssetDeliveryConfig.d.ts +1 -0
- package/assetDelivery/customAssets/customAssetDeliveryConfig.js +30 -0
- package/assetDelivery/customAssets/customAssetDeliveryConfig.js.map +1 -0
- package/assetDelivery/index.d.ts +9 -0
- package/assetDelivery/index.js +70 -0
- package/assetDelivery/index.js.map +1 -0
- package/assetDelivery/s3/S3AssetMetadataReader.d.ts +15 -0
- package/assetDelivery/s3/S3AssetMetadataReader.js +36 -0
- package/assetDelivery/s3/S3AssetMetadataReader.js.map +1 -0
- package/assetDelivery/s3/S3AssetResolver.d.ts +9 -0
- package/assetDelivery/s3/S3AssetResolver.js +37 -0
- package/assetDelivery/s3/S3AssetResolver.js.map +1 -0
- package/assetDelivery/s3/S3ContentsReader.d.ts +10 -0
- package/assetDelivery/s3/S3ContentsReader.js +27 -0
- package/assetDelivery/s3/S3ContentsReader.js.map +1 -0
- package/assetDelivery/s3/S3ErrorAssetReply.d.ts +4 -0
- package/assetDelivery/s3/S3ErrorAssetReply.js +20 -0
- package/assetDelivery/s3/S3ErrorAssetReply.js.map +1 -0
- package/assetDelivery/s3/S3OutputStrategy.d.ts +15 -0
- package/assetDelivery/s3/S3OutputStrategy.js +40 -0
- package/assetDelivery/s3/S3OutputStrategy.js.map +1 -0
- package/assetDelivery/s3/S3RedirectAssetReply.d.ts +4 -0
- package/assetDelivery/s3/S3RedirectAssetReply.js +23 -0
- package/assetDelivery/s3/S3RedirectAssetReply.js.map +1 -0
- package/assetDelivery/s3/S3StreamAssetReply.d.ts +5 -0
- package/assetDelivery/s3/S3StreamAssetReply.js +23 -0
- package/assetDelivery/s3/S3StreamAssetReply.js.map +1 -0
- package/assetDelivery/s3/SharpTransform.d.ts +18 -0
- package/assetDelivery/s3/SharpTransform.js +192 -0
- package/assetDelivery/s3/SharpTransform.js.map +1 -0
- package/assetDelivery/s3/transformation/AssetKeyGenerator.d.ts +8 -0
- package/assetDelivery/s3/transformation/AssetKeyGenerator.js +29 -0
- package/assetDelivery/s3/transformation/AssetKeyGenerator.js.map +1 -0
- package/assetDelivery/s3/transformation/CallableContentsReader.d.ts +12 -0
- package/assetDelivery/s3/transformation/CallableContentsReader.js +17 -0
- package/assetDelivery/s3/transformation/CallableContentsReader.js.map +1 -0
- package/assetDelivery/s3/transformation/WidthCollection.d.ts +7 -0
- package/assetDelivery/s3/transformation/WidthCollection.js +27 -0
- package/assetDelivery/s3/transformation/WidthCollection.js.map +1 -0
- package/assetDelivery/s3/transformation/legacyUtils.d.ts +12 -0
- package/assetDelivery/s3/transformation/legacyUtils.js +34 -0
- package/assetDelivery/s3/transformation/legacyUtils.js.map +1 -0
- package/assetDelivery/s3/transformation/utils.d.ts +11 -0
- package/assetDelivery/s3/transformation/utils.js +33 -0
- package/assetDelivery/s3/transformation/utils.js.map +1 -0
- package/assetDelivery/threatDetection/createThreatDetectionEventHandler.d.ts +2 -0
- package/assetDelivery/threatDetection/createThreatDetectionEventHandler.js +62 -0
- package/assetDelivery/threatDetection/createThreatDetectionEventHandler.js.map +1 -0
- package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.d.ts +2 -0
- package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.js +13 -0
- package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.js.map +1 -0
- package/assetDelivery/threatDetection/index.d.ts +2 -0
- package/assetDelivery/threatDetection/index.js +29 -0
- package/assetDelivery/threatDetection/index.js.map +1 -0
- package/assetDelivery/threatDetection/processThreatScanResult.d.ts +2 -0
- package/assetDelivery/threatDetection/processThreatScanResult.js +66 -0
- package/assetDelivery/threatDetection/processThreatScanResult.js.map +1 -0
- package/assetDelivery/threatDetection/types.d.ts +13 -0
- package/assetDelivery/threatDetection/types.js +7 -0
- package/assetDelivery/threatDetection/types.js.map +1 -0
- package/assetDelivery/types.d.ts +11 -0
- package/assetDelivery/types.js +7 -0
- package/assetDelivery/types.js.map +1 -0
- package/flushCdnCache/CdnPathsGenerator.d.ts +4 -0
- package/flushCdnCache/CdnPathsGenerator.js +14 -0
- package/flushCdnCache/CdnPathsGenerator.js.map +1 -0
- package/flushCdnCache/InvalidateCacheTask.d.ts +18 -0
- package/flushCdnCache/InvalidateCacheTask.js +78 -0
- package/flushCdnCache/InvalidateCacheTask.js.map +1 -0
- package/flushCdnCache/flushCacheOnFileDelete.d.ts +3 -0
- package/flushCdnCache/flushCacheOnFileDelete.js +34 -0
- package/flushCdnCache/flushCacheOnFileDelete.js.map +1 -0
- package/flushCdnCache/flushCacheOnFileUpdate.d.ts +3 -0
- package/flushCdnCache/flushCacheOnFileUpdate.js +40 -0
- package/flushCdnCache/flushCacheOnFileUpdate.js.map +1 -0
- package/flushCdnCache/index.d.ts +1 -0
- package/flushCdnCache/index.js +15 -0
- package/flushCdnCache/index.js.map +1 -0
- package/flushCdnCache/invalidateCacheTaskDefinition.d.ts +2 -0
- package/flushCdnCache/invalidateCacheTaskDefinition.js +22 -0
- package/flushCdnCache/invalidateCacheTaskDefinition.js.map +1 -0
- package/index.d.ts +4 -1
- package/index.js +27 -7
- package/index.js.map +1 -0
- package/multiPartUpload/CompleteMultiPartUploadUseCase.d.ts +15 -0
- package/multiPartUpload/CompleteMultiPartUploadUseCase.js +65 -0
- package/multiPartUpload/CompleteMultiPartUploadUseCase.js.map +1 -0
- package/multiPartUpload/CreateMultiPartUploadUseCase.d.ts +20 -0
- package/multiPartUpload/CreateMultiPartUploadUseCase.js +48 -0
- package/multiPartUpload/CreateMultiPartUploadUseCase.js.map +1 -0
- package/package.json +29 -16
- package/plugins/addFileMetadata.d.ts +10 -0
- package/plugins/addFileMetadata.js +67 -0
- package/plugins/addFileMetadata.js.map +1 -0
- package/plugins/checkPermissions.d.ts +4 -0
- package/plugins/checkPermissions.js +44 -0
- package/plugins/checkPermissions.js.map +1 -0
- package/plugins/fileStorageS3.d.ts +2 -2
- package/plugins/fileStorageS3.js +47 -46
- package/plugins/fileStorageS3.js.map +1 -0
- package/plugins/graphqlFileStorageS3.d.ts +2 -2
- package/plugins/graphqlFileStorageS3.js +137 -59
- package/plugins/graphqlFileStorageS3.js.map +1 -0
- package/types.d.ts +20 -0
- package/types.js +7 -1
- package/types.js.map +1 -0
- package/utils/FileExtension.d.ts +6 -0
- package/utils/FileExtension.js +24 -0
- package/utils/FileExtension.js.map +1 -0
- package/utils/FileKey.d.ts +11 -0
- package/utils/FileKey.js +33 -0
- package/utils/FileKey.js.map +1 -0
- package/utils/FileKey.test.d.ts +1 -0
- package/utils/FileKey.test.js +60 -0
- package/utils/FileKey.test.js.map +1 -0
- package/utils/FileNormalizer.d.ts +18 -0
- package/utils/FileNormalizer.js +49 -0
- package/utils/FileNormalizer.js.map +1 -0
- package/utils/FileUploadModifier.d.ts +30 -0
- package/utils/FileUploadModifier.js +49 -0
- package/utils/FileUploadModifier.js.map +1 -0
- package/utils/createFileNormalizerFromContext.d.ts +3 -0
- package/utils/createFileNormalizerFromContext.js +15 -0
- package/utils/createFileNormalizerFromContext.js.map +1 -0
- package/utils/getPresignedPostPayload.d.ts +3 -11
- package/utils/getPresignedPostPayload.js +14 -55
- package/utils/getPresignedPostPayload.js.map +1 -0
- package/utils/mimeTypes.d.ts +5 -0
- package/utils/mimeTypes.js +23 -0
- package/utils/mimeTypes.js.map +1 -0
- package/utils/uploadFileToS3.d.ts +5 -1
- package/utils/uploadFileToS3.js +9 -12
- package/utils/uploadFileToS3.js.map +1 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const SUPPORTED_TRANSFORMABLE_IMAGES: string[];
|
|
2
|
+
declare const OPTIMIZED_TRANSFORMED_IMAGE_PREFIX = "img-o-t-";
|
|
3
|
+
declare const OPTIMIZED_IMAGE_PREFIX = "img-o-";
|
|
4
|
+
declare const getOptimizedImageKeyPrefix: (key: string) => string;
|
|
5
|
+
declare const getOptimizedTransformedImageKeyPrefix: (key: string, transformationsHash: string) => string;
|
|
6
|
+
interface GetImageKeyParams {
|
|
7
|
+
key: string;
|
|
8
|
+
transformations?: any;
|
|
9
|
+
}
|
|
10
|
+
declare const getImageKey: ({ key, transformations }: GetImageKeyParams) => string;
|
|
11
|
+
export { SUPPORTED_TRANSFORMABLE_IMAGES, OPTIMIZED_TRANSFORMED_IMAGE_PREFIX, OPTIMIZED_IMAGE_PREFIX, getImageKey, getOptimizedImageKeyPrefix, getOptimizedTransformedImageKeyPrefix };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getOptimizedTransformedImageKeyPrefix = exports.getOptimizedImageKeyPrefix = exports.getImageKey = exports.SUPPORTED_TRANSFORMABLE_IMAGES = exports.OPTIMIZED_TRANSFORMED_IMAGE_PREFIX = exports.OPTIMIZED_IMAGE_PREFIX = void 0;
|
|
8
|
+
var _objectHash = _interopRequireDefault(require("object-hash"));
|
|
9
|
+
const SUPPORTED_TRANSFORMABLE_IMAGES = exports.SUPPORTED_TRANSFORMABLE_IMAGES = ["jpg", "jpeg", "png", "webp"];
|
|
10
|
+
const OPTIMIZED_TRANSFORMED_IMAGE_PREFIX = exports.OPTIMIZED_TRANSFORMED_IMAGE_PREFIX = "img-o-t-";
|
|
11
|
+
const OPTIMIZED_IMAGE_PREFIX = exports.OPTIMIZED_IMAGE_PREFIX = "img-o-";
|
|
12
|
+
const getOptimizedImageKeyPrefix = key => {
|
|
13
|
+
const [id, name] = key.split("/");
|
|
14
|
+
return `${id}/${OPTIMIZED_IMAGE_PREFIX}${name}`;
|
|
15
|
+
};
|
|
16
|
+
exports.getOptimizedImageKeyPrefix = getOptimizedImageKeyPrefix;
|
|
17
|
+
const getOptimizedTransformedImageKeyPrefix = (key, transformationsHash) => {
|
|
18
|
+
const [id, name] = key.split("/");
|
|
19
|
+
return `${id}/${OPTIMIZED_TRANSFORMED_IMAGE_PREFIX}${transformationsHash}-${name}`;
|
|
20
|
+
};
|
|
21
|
+
exports.getOptimizedTransformedImageKeyPrefix = getOptimizedTransformedImageKeyPrefix;
|
|
22
|
+
const getImageKey = ({
|
|
23
|
+
key,
|
|
24
|
+
transformations
|
|
25
|
+
}) => {
|
|
26
|
+
if (!transformations) {
|
|
27
|
+
return getOptimizedImageKeyPrefix(key);
|
|
28
|
+
}
|
|
29
|
+
return getOptimizedTransformedImageKeyPrefix(key, (0, _objectHash.default)(transformations));
|
|
30
|
+
};
|
|
31
|
+
exports.getImageKey = getImageKey;
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_objectHash","_interopRequireDefault","require","SUPPORTED_TRANSFORMABLE_IMAGES","exports","OPTIMIZED_TRANSFORMED_IMAGE_PREFIX","OPTIMIZED_IMAGE_PREFIX","getOptimizedImageKeyPrefix","key","id","name","split","getOptimizedTransformedImageKeyPrefix","transformationsHash","getImageKey","transformations","objectHash"],"sources":["utils.ts"],"sourcesContent":["import objectHash from \"object-hash\";\n\nconst SUPPORTED_TRANSFORMABLE_IMAGES = [\"jpg\", \"jpeg\", \"png\", \"webp\"];\nconst OPTIMIZED_TRANSFORMED_IMAGE_PREFIX = \"img-o-t-\";\nconst OPTIMIZED_IMAGE_PREFIX = \"img-o-\";\n\nconst getOptimizedImageKeyPrefix = (key: string): string => {\n const [id, name] = key.split(\"/\");\n return `${id}/${OPTIMIZED_IMAGE_PREFIX}${name}`;\n};\n\nconst getOptimizedTransformedImageKeyPrefix = (\n key: string,\n transformationsHash: string\n): string => {\n const [id, name] = key.split(\"/\");\n return `${id}/${OPTIMIZED_TRANSFORMED_IMAGE_PREFIX}${transformationsHash}-${name}`;\n};\n\ninterface GetImageKeyParams {\n key: string;\n transformations?: any;\n}\n\nconst getImageKey = ({ key, transformations }: GetImageKeyParams): string => {\n if (!transformations) {\n return getOptimizedImageKeyPrefix(key);\n }\n\n return getOptimizedTransformedImageKeyPrefix(key, objectHash(transformations));\n};\n\nexport {\n SUPPORTED_TRANSFORMABLE_IMAGES,\n OPTIMIZED_TRANSFORMED_IMAGE_PREFIX,\n OPTIMIZED_IMAGE_PREFIX,\n getImageKey,\n getOptimizedImageKeyPrefix,\n getOptimizedTransformedImageKeyPrefix\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,8BAA8B,GAAAC,OAAA,CAAAD,8BAAA,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;AACrE,MAAME,kCAAkC,GAAAD,OAAA,CAAAC,kCAAA,GAAG,UAAU;AACrD,MAAMC,sBAAsB,GAAAF,OAAA,CAAAE,sBAAA,GAAG,QAAQ;AAEvC,MAAMC,0BAA0B,GAAIC,GAAW,IAAa;EACxD,MAAM,CAACC,EAAE,EAAEC,IAAI,CAAC,GAAGF,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC;EACjC,OAAO,GAAGF,EAAE,IAAIH,sBAAsB,GAAGI,IAAI,EAAE;AACnD,CAAC;AAACN,OAAA,CAAAG,0BAAA,GAAAA,0BAAA;AAEF,MAAMK,qCAAqC,GAAGA,CAC1CJ,GAAW,EACXK,mBAA2B,KAClB;EACT,MAAM,CAACJ,EAAE,EAAEC,IAAI,CAAC,GAAGF,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC;EACjC,OAAO,GAAGF,EAAE,IAAIJ,kCAAkC,GAAGQ,mBAAmB,IAAIH,IAAI,EAAE;AACtF,CAAC;AAACN,OAAA,CAAAQ,qCAAA,GAAAA,qCAAA;AAOF,MAAME,WAAW,GAAGA,CAAC;EAAEN,GAAG;EAAEO;AAAmC,CAAC,KAAa;EACzE,IAAI,CAACA,eAAe,EAAE;IAClB,OAAOR,0BAA0B,CAACC,GAAG,CAAC;EAC1C;EAEA,OAAOI,qCAAqC,CAACJ,GAAG,EAAE,IAAAQ,mBAAU,EAACD,eAAe,CAAC,CAAC;AAClF,CAAC;AAACX,OAAA,CAAAU,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { GuardDutyEvent } from "./types";
|
|
2
|
+
export declare const createThreatDetectionEventHandler: () => (import("@webiny/handler").HandlerOnRequestPlugin<import("@webiny/handler/types").Context> | import("@webiny/handler-aws").EventBridgeEventHandler<"GuardDuty Malware Protection Object Scan Result", GuardDutyEvent, any>)[];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createThreatDetectionEventHandler = void 0;
|
|
7
|
+
var _clientS = require("@webiny/aws-sdk/client-s3");
|
|
8
|
+
var _handlerAws = require("@webiny/handler-aws");
|
|
9
|
+
var _handler = require("@webiny/handler");
|
|
10
|
+
var _processThreatScanResult = require("./processThreatScanResult");
|
|
11
|
+
var _S3AssetMetadataReader = require("../s3/S3AssetMetadataReader");
|
|
12
|
+
const detailType = "GuardDuty Malware Protection Object Scan Result";
|
|
13
|
+
const bucket = process.env.S3_BUCKET;
|
|
14
|
+
const region = process.env.AWS_REGION;
|
|
15
|
+
const createThreatDetectionEventHandler = () => {
|
|
16
|
+
const s3 = new _clientS.S3({
|
|
17
|
+
region
|
|
18
|
+
});
|
|
19
|
+
const handlerOnRequest = (0, _handler.createHandlerOnRequest)(async request => {
|
|
20
|
+
const payload = request.body;
|
|
21
|
+
if (payload["detail-type"] !== detailType) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const objectKey = payload.detail.s3ObjectDetails.objectKey;
|
|
25
|
+
if (objectKey.endsWith(".metadata")) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const s3Metadata = new _S3AssetMetadataReader.S3AssetMetadataReader(s3, bucket);
|
|
30
|
+
const metadata = await s3Metadata.getMetadata(payload.detail.s3ObjectDetails.objectKey);
|
|
31
|
+
request.headers = {
|
|
32
|
+
...request.headers,
|
|
33
|
+
"x-tenant": metadata.tenant,
|
|
34
|
+
"x-i18n-locale": `default:${metadata.locale};content:${metadata.locale};`
|
|
35
|
+
};
|
|
36
|
+
} catch {
|
|
37
|
+
// If metadata can't be loaded, we ignore the file.
|
|
38
|
+
// Most likely it's because the file is a rendition of the original file,
|
|
39
|
+
// so we don't need to do anything with it.
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// Guard Duty event handler.
|
|
43
|
+
const threatScanEventHandler = (0, _handlerAws.createEventBridgeEventHandler)(async ({
|
|
44
|
+
payload,
|
|
45
|
+
next,
|
|
46
|
+
...rest
|
|
47
|
+
}) => {
|
|
48
|
+
const context = rest.context;
|
|
49
|
+
const threatDetectionEnabled = context.wcp.canUseFileManagerThreatDetection();
|
|
50
|
+
if (!threatDetectionEnabled || payload["detail-type"] !== detailType) {
|
|
51
|
+
return next();
|
|
52
|
+
}
|
|
53
|
+
await (0, _processThreatScanResult.processThreatScanResult)(context, payload.detail);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Assign a human-readable name for easier debugging.
|
|
57
|
+
threatScanEventHandler.name = threatScanEventHandler.type + ".threatDetectionEventHandler";
|
|
58
|
+
return [handlerOnRequest, threatScanEventHandler];
|
|
59
|
+
};
|
|
60
|
+
exports.createThreatDetectionEventHandler = createThreatDetectionEventHandler;
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=createThreatDetectionEventHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_clientS","require","_handlerAws","_handler","_processThreatScanResult","_S3AssetMetadataReader","detailType","bucket","process","env","S3_BUCKET","region","AWS_REGION","createThreatDetectionEventHandler","s3","S3","handlerOnRequest","createHandlerOnRequest","request","payload","body","objectKey","detail","s3ObjectDetails","endsWith","s3Metadata","S3AssetMetadataReader","metadata","getMetadata","headers","tenant","locale","threatScanEventHandler","createEventBridgeEventHandler","next","rest","context","threatDetectionEnabled","wcp","canUseFileManagerThreatDetection","processThreatScanResult","name","type","exports"],"sources":["createThreatDetectionEventHandler.ts"],"sourcesContent":["import { S3 } from \"@webiny/aws-sdk/client-s3\";\nimport { createEventBridgeEventHandler } from \"@webiny/handler-aws\";\nimport { createHandlerOnRequest } from \"@webiny/handler\";\nimport type { GuardDutyEvent, ThreatDetectionContext } from \"./types\";\nimport { processThreatScanResult } from \"./processThreatScanResult\";\nimport { S3AssetMetadataReader } from \"~/assetDelivery/s3/S3AssetMetadataReader\";\nimport type { EventBridgeEvent } from \"@webiny/aws-sdk/types\";\n\nconst detailType = \"GuardDuty Malware Protection Object Scan Result\";\n\nconst bucket = process.env.S3_BUCKET as string;\nconst region = process.env.AWS_REGION as string;\n\nexport const createThreatDetectionEventHandler = () => {\n const s3 = new S3({ region });\n\n const handlerOnRequest = createHandlerOnRequest(async request => {\n const payload = request.body as EventBridgeEvent<string, GuardDutyEvent>;\n\n if (payload[\"detail-type\"] !== detailType) {\n return;\n }\n\n const objectKey = payload.detail.s3ObjectDetails.objectKey;\n if (objectKey.endsWith(\".metadata\")) {\n return;\n }\n\n try {\n const s3Metadata = new S3AssetMetadataReader(s3, bucket);\n const metadata = await s3Metadata.getMetadata(payload.detail.s3ObjectDetails.objectKey);\n\n request.headers = {\n ...request.headers,\n \"x-tenant\": metadata.tenant,\n \"x-i18n-locale\": `default:${metadata.locale};content:${metadata.locale};`\n };\n } catch {\n // If metadata can't be loaded, we ignore the file.\n // Most likely it's because the file is a rendition of the original file,\n // so we don't need to do anything with it.\n }\n });\n // Guard Duty event handler.\n const threatScanEventHandler = createEventBridgeEventHandler<typeof detailType, GuardDutyEvent>(\n async ({ payload, next, ...rest }) => {\n const context = rest.context as ThreatDetectionContext;\n\n const threatDetectionEnabled = context.wcp.canUseFileManagerThreatDetection();\n\n if (!threatDetectionEnabled || payload[\"detail-type\"] !== detailType) {\n return next();\n }\n\n await processThreatScanResult(context, payload.detail);\n }\n );\n\n // Assign a human-readable name for easier debugging.\n threatScanEventHandler.name = threatScanEventHandler.type + \".threatDetectionEventHandler\";\n\n return [handlerOnRequest, threatScanEventHandler];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,wBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AAGA,MAAMK,UAAU,GAAG,iDAAiD;AAEpE,MAAMC,MAAM,GAAGC,OAAO,CAACC,GAAG,CAACC,SAAmB;AAC9C,MAAMC,MAAM,GAAGH,OAAO,CAACC,GAAG,CAACG,UAAoB;AAExC,MAAMC,iCAAiC,GAAGA,CAAA,KAAM;EACnD,MAAMC,EAAE,GAAG,IAAIC,WAAE,CAAC;IAAEJ;EAAO,CAAC,CAAC;EAE7B,MAAMK,gBAAgB,GAAG,IAAAC,+BAAsB,EAAC,MAAMC,OAAO,IAAI;IAC7D,MAAMC,OAAO,GAAGD,OAAO,CAACE,IAAgD;IAExE,IAAID,OAAO,CAAC,aAAa,CAAC,KAAKb,UAAU,EAAE;MACvC;IACJ;IAEA,MAAMe,SAAS,GAAGF,OAAO,CAACG,MAAM,CAACC,eAAe,CAACF,SAAS;IAC1D,IAAIA,SAAS,CAACG,QAAQ,CAAC,WAAW,CAAC,EAAE;MACjC;IACJ;IAEA,IAAI;MACA,MAAMC,UAAU,GAAG,IAAIC,4CAAqB,CAACZ,EAAE,EAAEP,MAAM,CAAC;MACxD,MAAMoB,QAAQ,GAAG,MAAMF,UAAU,CAACG,WAAW,CAACT,OAAO,CAACG,MAAM,CAACC,eAAe,CAACF,SAAS,CAAC;MAEvFH,OAAO,CAACW,OAAO,GAAG;QACd,GAAGX,OAAO,CAACW,OAAO;QAClB,UAAU,EAAEF,QAAQ,CAACG,MAAM;QAC3B,eAAe,EAAE,WAAWH,QAAQ,CAACI,MAAM,YAAYJ,QAAQ,CAACI,MAAM;MAC1E,CAAC;IACL,CAAC,CAAC,MAAM;MACJ;MACA;MACA;IAAA;EAER,CAAC,CAAC;EACF;EACA,MAAMC,sBAAsB,GAAG,IAAAC,yCAA6B,EACxD,OAAO;IAAEd,OAAO;IAAEe,IAAI;IAAE,GAAGC;EAAK,CAAC,KAAK;IAClC,MAAMC,OAAO,GAAGD,IAAI,CAACC,OAAiC;IAEtD,MAAMC,sBAAsB,GAAGD,OAAO,CAACE,GAAG,CAACC,gCAAgC,CAAC,CAAC;IAE7E,IAAI,CAACF,sBAAsB,IAAIlB,OAAO,CAAC,aAAa,CAAC,KAAKb,UAAU,EAAE;MAClE,OAAO4B,IAAI,CAAC,CAAC;IACjB;IAEA,MAAM,IAAAM,gDAAuB,EAACJ,OAAO,EAAEjB,OAAO,CAACG,MAAM,CAAC;EAC1D,CACJ,CAAC;;EAED;EACAU,sBAAsB,CAACS,IAAI,GAAGT,sBAAsB,CAACU,IAAI,GAAG,8BAA8B;EAE1F,OAAO,CAAC1B,gBAAgB,EAAEgB,sBAAsB,CAAC;AACrD,CAAC;AAACW,OAAA,CAAA9B,iCAAA,GAAAA,iCAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createThreatDetectionPluginLoader = void 0;
|
|
7
|
+
var _api = require("@webiny/api");
|
|
8
|
+
const createThreatDetectionPluginLoader = cb => {
|
|
9
|
+
return (0, _api.createConditionalPluginFactory)(() => process.env.WEBINY_FUNCTION_TYPE === "threat-detection-event-handler", cb);
|
|
10
|
+
};
|
|
11
|
+
exports.createThreatDetectionPluginLoader = createThreatDetectionPluginLoader;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=createThreatDetectionPluginLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_api","require","createThreatDetectionPluginLoader","cb","createConditionalPluginFactory","process","env","WEBINY_FUNCTION_TYPE","exports"],"sources":["createThreatDetectionPluginLoader.ts"],"sourcesContent":["import type { PluginFactory } from \"@webiny/plugins/types\";\nimport { createConditionalPluginFactory } from \"@webiny/api\";\n\nexport const createThreatDetectionPluginLoader = (cb: PluginFactory) => {\n return createConditionalPluginFactory(\n () => process.env.WEBINY_FUNCTION_TYPE === \"threat-detection-event-handler\",\n cb\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AAEO,MAAMC,iCAAiC,GAAIC,EAAiB,IAAK;EACpE,OAAO,IAAAC,mCAA8B,EACjC,MAAMC,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,gCAAgC,EAC3EJ,EACJ,CAAC;AACL,CAAC;AAACK,OAAA,CAAAN,iCAAA,GAAAA,iCAAA","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _createThreatDetectionEventHandler = require("./createThreatDetectionEventHandler");
|
|
7
|
+
Object.keys(_createThreatDetectionEventHandler).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _createThreatDetectionEventHandler[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _createThreatDetectionEventHandler[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _createThreatDetectionPluginLoader = require("./createThreatDetectionPluginLoader");
|
|
18
|
+
Object.keys(_createThreatDetectionPluginLoader).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _createThreatDetectionPluginLoader[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _createThreatDetectionPluginLoader[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_createThreatDetectionEventHandler","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_createThreatDetectionPluginLoader"],"sources":["index.ts"],"sourcesContent":["export * from \"./createThreatDetectionEventHandler\";\nexport * from \"./createThreatDetectionPluginLoader\";\n"],"mappings":";;;;;AAAA,IAAAA,kCAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kCAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,kCAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kCAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,kCAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,kCAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,kCAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kCAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.processThreatScanResult = void 0;
|
|
7
|
+
const processThreatScanResult = async (context, eventDetail) => {
|
|
8
|
+
await context.security.withoutAuthorization(async () => {
|
|
9
|
+
try {
|
|
10
|
+
const scanStatus = eventDetail.scanResultDetails.scanResultStatus;
|
|
11
|
+
const s3Object = eventDetail.s3ObjectDetails;
|
|
12
|
+
const [[file]] = await context.fileManager.listFiles({
|
|
13
|
+
limit: 1,
|
|
14
|
+
where: {
|
|
15
|
+
key: s3Object.objectKey
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
if (!file) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const allConnections = await context.websockets.listConnections();
|
|
22
|
+
if (scanStatus === "NO_THREATS_FOUND") {
|
|
23
|
+
const newTags = file.tags.filter(tag => tag !== "threatScanInProgress");
|
|
24
|
+
await context.fileManager.updateFile(file.id, {
|
|
25
|
+
tags: newTags,
|
|
26
|
+
savedBy: file.savedBy
|
|
27
|
+
});
|
|
28
|
+
await context.websockets.sendToConnections(allConnections, {
|
|
29
|
+
action: "fm.threatScan.noThreatFound",
|
|
30
|
+
data: {
|
|
31
|
+
id: file.id,
|
|
32
|
+
tags: newTags
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (scanStatus === "THREATS_FOUND") {
|
|
38
|
+
// Delete infected file.
|
|
39
|
+
await context.fileManager.deleteFile(file.id);
|
|
40
|
+
await context.websockets.sendToConnections(allConnections, {
|
|
41
|
+
action: "fm.threatScan.threatDetected",
|
|
42
|
+
data: {
|
|
43
|
+
id: file.id,
|
|
44
|
+
name: file.name
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// For all other outcomes, we delete the file, until better logic is implemented.
|
|
51
|
+
await context.fileManager.deleteFile(file.id);
|
|
52
|
+
await context.websockets.sendToConnections(allConnections, {
|
|
53
|
+
action: "fm.threatScan.unsupported",
|
|
54
|
+
data: {
|
|
55
|
+
id: file.id,
|
|
56
|
+
name: file.name
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.log(e.message);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
exports.processThreatScanResult = processThreatScanResult;
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=processThreatScanResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["processThreatScanResult","context","eventDetail","security","withoutAuthorization","scanStatus","scanResultDetails","scanResultStatus","s3Object","s3ObjectDetails","file","fileManager","listFiles","limit","where","key","objectKey","allConnections","websockets","listConnections","newTags","tags","filter","tag","updateFile","id","savedBy","sendToConnections","action","data","deleteFile","name","e","console","log","message","exports"],"sources":["processThreatScanResult.ts"],"sourcesContent":["import type { GuardDutyEvent, ThreatDetectionContext } from \"./types\";\n\nexport const processThreatScanResult = async (\n context: ThreatDetectionContext,\n eventDetail: GuardDutyEvent\n) => {\n await context.security.withoutAuthorization(async () => {\n try {\n const scanStatus = eventDetail.scanResultDetails.scanResultStatus;\n const s3Object = eventDetail.s3ObjectDetails;\n\n const [[file]] = await context.fileManager.listFiles({\n limit: 1,\n where: {\n key: s3Object.objectKey\n }\n });\n\n if (!file) {\n return;\n }\n\n const allConnections = await context.websockets.listConnections();\n\n if (scanStatus === \"NO_THREATS_FOUND\") {\n const newTags = file.tags.filter(tag => tag !== \"threatScanInProgress\");\n await context.fileManager.updateFile(file.id, {\n tags: newTags,\n savedBy: file.savedBy\n });\n\n await context.websockets.sendToConnections(allConnections, {\n action: \"fm.threatScan.noThreatFound\",\n data: {\n id: file.id,\n tags: newTags\n }\n });\n\n return;\n }\n\n if (scanStatus === \"THREATS_FOUND\") {\n // Delete infected file.\n await context.fileManager.deleteFile(file.id);\n\n await context.websockets.sendToConnections(allConnections, {\n action: \"fm.threatScan.threatDetected\",\n data: {\n id: file.id,\n name: file.name\n }\n });\n\n return;\n }\n\n // For all other outcomes, we delete the file, until better logic is implemented.\n await context.fileManager.deleteFile(file.id);\n\n await context.websockets.sendToConnections(allConnections, {\n action: \"fm.threatScan.unsupported\",\n data: {\n id: file.id,\n name: file.name\n }\n });\n } catch (e) {\n console.log(e.message);\n }\n });\n};\n"],"mappings":";;;;;;AAEO,MAAMA,uBAAuB,GAAG,MAAAA,CACnCC,OAA+B,EAC/BC,WAA2B,KAC1B;EACD,MAAMD,OAAO,CAACE,QAAQ,CAACC,oBAAoB,CAAC,YAAY;IACpD,IAAI;MACA,MAAMC,UAAU,GAAGH,WAAW,CAACI,iBAAiB,CAACC,gBAAgB;MACjE,MAAMC,QAAQ,GAAGN,WAAW,CAACO,eAAe;MAE5C,MAAM,CAAC,CAACC,IAAI,CAAC,CAAC,GAAG,MAAMT,OAAO,CAACU,WAAW,CAACC,SAAS,CAAC;QACjDC,KAAK,EAAE,CAAC;QACRC,KAAK,EAAE;UACHC,GAAG,EAAEP,QAAQ,CAACQ;QAClB;MACJ,CAAC,CAAC;MAEF,IAAI,CAACN,IAAI,EAAE;QACP;MACJ;MAEA,MAAMO,cAAc,GAAG,MAAMhB,OAAO,CAACiB,UAAU,CAACC,eAAe,CAAC,CAAC;MAEjE,IAAId,UAAU,KAAK,kBAAkB,EAAE;QACnC,MAAMe,OAAO,GAAGV,IAAI,CAACW,IAAI,CAACC,MAAM,CAACC,GAAG,IAAIA,GAAG,KAAK,sBAAsB,CAAC;QACvE,MAAMtB,OAAO,CAACU,WAAW,CAACa,UAAU,CAACd,IAAI,CAACe,EAAE,EAAE;UAC1CJ,IAAI,EAAED,OAAO;UACbM,OAAO,EAAEhB,IAAI,CAACgB;QAClB,CAAC,CAAC;QAEF,MAAMzB,OAAO,CAACiB,UAAU,CAACS,iBAAiB,CAACV,cAAc,EAAE;UACvDW,MAAM,EAAE,6BAA6B;UACrCC,IAAI,EAAE;YACFJ,EAAE,EAAEf,IAAI,CAACe,EAAE;YACXJ,IAAI,EAAED;UACV;QACJ,CAAC,CAAC;QAEF;MACJ;MAEA,IAAIf,UAAU,KAAK,eAAe,EAAE;QAChC;QACA,MAAMJ,OAAO,CAACU,WAAW,CAACmB,UAAU,CAACpB,IAAI,CAACe,EAAE,CAAC;QAE7C,MAAMxB,OAAO,CAACiB,UAAU,CAACS,iBAAiB,CAACV,cAAc,EAAE;UACvDW,MAAM,EAAE,8BAA8B;UACtCC,IAAI,EAAE;YACFJ,EAAE,EAAEf,IAAI,CAACe,EAAE;YACXM,IAAI,EAAErB,IAAI,CAACqB;UACf;QACJ,CAAC,CAAC;QAEF;MACJ;;MAEA;MACA,MAAM9B,OAAO,CAACU,WAAW,CAACmB,UAAU,CAACpB,IAAI,CAACe,EAAE,CAAC;MAE7C,MAAMxB,OAAO,CAACiB,UAAU,CAACS,iBAAiB,CAACV,cAAc,EAAE;QACvDW,MAAM,EAAE,2BAA2B;QACnCC,IAAI,EAAE;UACFJ,EAAE,EAAEf,IAAI,CAACe,EAAE;UACXM,IAAI,EAAErB,IAAI,CAACqB;QACf;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOC,CAAC,EAAE;MACRC,OAAO,CAACC,GAAG,CAACF,CAAC,CAACG,OAAO,CAAC;IAC1B;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAApC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Context as IWebsocketsContext } from "@webiny/api-websockets";
|
|
2
|
+
import type { WcpContext } from "@webiny/api-wcp/types";
|
|
3
|
+
import type { FileManagerContext } from "@webiny/api-file-manager/types";
|
|
4
|
+
export type ThreatDetectionContext = FileManagerContext & IWebsocketsContext & WcpContext;
|
|
5
|
+
export type GuardDutyEvent = {
|
|
6
|
+
scanResultDetails: {
|
|
7
|
+
scanResultStatus: "UNSUPPORTED" | "FAILED" | "ACCESS_DENIED" | "THREATS_FOUND" | "NO_THREATS_FOUND";
|
|
8
|
+
};
|
|
9
|
+
s3ObjectDetails: {
|
|
10
|
+
bucketName: string;
|
|
11
|
+
objectKey: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Context as IWebsocketsContext } from \"@webiny/api-websockets\";\nimport type { WcpContext } from \"@webiny/api-wcp/types\";\nimport type { FileManagerContext } from \"@webiny/api-file-manager/types\";\n\nexport type ThreatDetectionContext = FileManagerContext & IWebsocketsContext & WcpContext;\n\nexport type GuardDutyEvent = {\n scanResultDetails: {\n scanResultStatus:\n | \"UNSUPPORTED\"\n | \"FAILED\"\n | \"ACCESS_DENIED\"\n | \"THREATS_FOUND\"\n | \"NO_THREATS_FOUND\";\n };\n s3ObjectDetails: {\n bucketName: string;\n objectKey: string;\n };\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { createAssetDelivery as createBaseAssetDelivery } from "@webiny/api-file-manager";
|
|
2
|
+
export type AssetDeliveryParams = Parameters<typeof createBaseAssetDelivery>[0] & {
|
|
3
|
+
imageResizeWidths?: number[];
|
|
4
|
+
/**
|
|
5
|
+
* BE CAREFUL!
|
|
6
|
+
* Setting this to more than 1 hour may cause your URLs to still expire before the desired expiration time.
|
|
7
|
+
* @see https://repost.aws/knowledge-center/presigned-url-s3-bucket-expiration
|
|
8
|
+
*/
|
|
9
|
+
presignedUrlTtl?: number;
|
|
10
|
+
assetStreamingMaxSize?: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { createAssetDelivery as createBaseAssetDelivery } from \"@webiny/api-file-manager\";\n\nexport type AssetDeliveryParams = Parameters<typeof createBaseAssetDelivery>[0] & {\n imageResizeWidths?: number[];\n /**\n * BE CAREFUL!\n * Setting this to more than 1 hour may cause your URLs to still expire before the desired expiration time.\n * @see https://repost.aws/knowledge-center/presigned-url-s3-bucket-expiration\n */\n presignedUrlTtl?: number;\n assetStreamingMaxSize?: number;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CdnPathsGenerator = void 0;
|
|
7
|
+
class CdnPathsGenerator {
|
|
8
|
+
generate(file) {
|
|
9
|
+
return [`/files/${file.key}*`, `/private/${file.key}*`, ...file.aliases];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.CdnPathsGenerator = CdnPathsGenerator;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=CdnPathsGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CdnPathsGenerator","generate","file","key","aliases","exports"],"sources":["CdnPathsGenerator.ts"],"sourcesContent":["import type { File } from \"@webiny/api-file-manager/types\";\n\nexport class CdnPathsGenerator {\n generate(file: File) {\n return [`/files/${file.key}*`, `/private/${file.key}*`, ...file.aliases];\n }\n}\n"],"mappings":";;;;;;AAEO,MAAMA,iBAAiB,CAAC;EAC3BC,QAAQA,CAACC,IAAU,EAAE;IACjB,OAAO,CAAC,UAAUA,IAAI,CAACC,GAAG,GAAG,EAAE,YAAYD,IAAI,CAACC,GAAG,GAAG,EAAE,GAAGD,IAAI,CAACE,OAAO,CAAC;EAC5E;AACJ;AAACC,OAAA,CAAAL,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ITaskRunParams } from "@webiny/tasks/types";
|
|
2
|
+
import type { FileManagerContext } from "@webiny/api-file-manager/types";
|
|
3
|
+
import type { ITaskResponseResult } from "@webiny/tasks/response/abstractions";
|
|
4
|
+
export interface InvalidateCacheInput {
|
|
5
|
+
/**
|
|
6
|
+
* Caller of the task (e.g., `fm-before-update`, `fm-after-delete`).
|
|
7
|
+
*/
|
|
8
|
+
caller: string;
|
|
9
|
+
/**
|
|
10
|
+
* Cache paths to invalidate.
|
|
11
|
+
*/
|
|
12
|
+
paths: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare class InvalidateCloudfrontCacheTask {
|
|
15
|
+
private continueIfCode;
|
|
16
|
+
run({ input, response, isCloseToTimeout }: ITaskRunParams<FileManagerContext, InvalidateCacheInput>): Promise<ITaskResponseResult>;
|
|
17
|
+
private invalidateCache;
|
|
18
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InvalidateCloudfrontCacheTask = void 0;
|
|
7
|
+
var _api = require("@webiny/api");
|
|
8
|
+
var _clientCloudfront = require("@webiny/aws-sdk/client-cloudfront");
|
|
9
|
+
var _utils = require("@webiny/utils");
|
|
10
|
+
class ReturnContinue extends Error {}
|
|
11
|
+
class InvalidateCloudfrontCacheTask {
|
|
12
|
+
continueIfCode = ["TooManyInvalidationsInProgress", "Throttling"];
|
|
13
|
+
async run({
|
|
14
|
+
input,
|
|
15
|
+
response,
|
|
16
|
+
isCloseToTimeout
|
|
17
|
+
}) {
|
|
18
|
+
const manifest = await _api.ServiceDiscovery.load();
|
|
19
|
+
if (!manifest) {
|
|
20
|
+
return response.error({
|
|
21
|
+
message: `Unable to invalidate cache due to a missing service manifest.`,
|
|
22
|
+
code: "MISSING_SERVICE_MANIFEST",
|
|
23
|
+
data: {
|
|
24
|
+
manifest: "api"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const {
|
|
29
|
+
distributionId
|
|
30
|
+
} = manifest.api.cloudfront;
|
|
31
|
+
const invalidateCache = () => {
|
|
32
|
+
return this.invalidateCache(input.caller, distributionId, input.paths);
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
await (0, _utils.executeWithRetry)(invalidateCache, {
|
|
36
|
+
minTimeout: 2000,
|
|
37
|
+
forever: true,
|
|
38
|
+
onFailedAttempt: err => {
|
|
39
|
+
if (this.continueIfCode.includes(err.name)) {
|
|
40
|
+
throw new ReturnContinue();
|
|
41
|
+
}
|
|
42
|
+
if (err.message.includes("not authorized to perform")) {
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
if (isCloseToTimeout()) {
|
|
46
|
+
throw new ReturnContinue();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (error instanceof ReturnContinue) {
|
|
52
|
+
return response.continue(input);
|
|
53
|
+
}
|
|
54
|
+
return response.error({
|
|
55
|
+
message: error.message,
|
|
56
|
+
code: "EXECUTE_WITH_RETRY_FAILED",
|
|
57
|
+
data: input.paths
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return response.done();
|
|
61
|
+
}
|
|
62
|
+
async invalidateCache(caller, distributionId, paths) {
|
|
63
|
+
const cloudfront = new _clientCloudfront.CloudFront();
|
|
64
|
+
await cloudfront.createInvalidation({
|
|
65
|
+
DistributionId: distributionId,
|
|
66
|
+
InvalidationBatch: {
|
|
67
|
+
CallerReference: `${new Date().getTime()}-${caller}`,
|
|
68
|
+
Paths: {
|
|
69
|
+
Quantity: paths.length,
|
|
70
|
+
Items: paths
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.InvalidateCloudfrontCacheTask = InvalidateCloudfrontCacheTask;
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=InvalidateCacheTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_api","require","_clientCloudfront","_utils","ReturnContinue","Error","InvalidateCloudfrontCacheTask","continueIfCode","run","input","response","isCloseToTimeout","manifest","ServiceDiscovery","load","error","message","code","data","distributionId","api","cloudfront","invalidateCache","caller","paths","executeWithRetry","minTimeout","forever","onFailedAttempt","err","includes","name","continue","done","CloudFront","createInvalidation","DistributionId","InvalidationBatch","CallerReference","Date","getTime","Paths","Quantity","length","Items","exports"],"sources":["InvalidateCacheTask.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api\";\nimport { CloudFront } from \"@webiny/aws-sdk/client-cloudfront\";\nimport type { ITaskRunParams } from \"@webiny/tasks/types\";\nimport type { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { executeWithRetry } from \"@webiny/utils\";\nimport type { ITaskResponseResult } from \"@webiny/tasks/response/abstractions\";\n\nclass ReturnContinue extends Error {}\n\nexport interface InvalidateCacheInput {\n /**\n * Caller of the task (e.g., `fm-before-update`, `fm-after-delete`).\n */\n caller: string;\n /**\n * Cache paths to invalidate.\n */\n paths: string[];\n}\n\nexport class InvalidateCloudfrontCacheTask {\n private continueIfCode = [\"TooManyInvalidationsInProgress\", \"Throttling\"];\n\n public async run({\n input,\n response,\n isCloseToTimeout\n }: ITaskRunParams<FileManagerContext, InvalidateCacheInput>): Promise<ITaskResponseResult> {\n const manifest = await ServiceDiscovery.load();\n\n if (!manifest) {\n return response.error({\n message: `Unable to invalidate cache due to a missing service manifest.`,\n code: \"MISSING_SERVICE_MANIFEST\",\n data: {\n manifest: \"api\"\n }\n });\n }\n\n const { distributionId } = manifest.api.cloudfront;\n\n const invalidateCache = () => {\n return this.invalidateCache(input.caller, distributionId as string, input.paths);\n };\n\n try {\n await executeWithRetry(invalidateCache, {\n minTimeout: 2000,\n forever: true,\n onFailedAttempt: err => {\n if (this.continueIfCode.includes(err.name)) {\n throw new ReturnContinue();\n }\n\n if (err.message.includes(\"not authorized to perform\")) {\n throw err;\n }\n\n if (isCloseToTimeout()) {\n throw new ReturnContinue();\n }\n }\n });\n } catch (error) {\n if (error instanceof ReturnContinue) {\n return response.continue(input);\n }\n\n return response.error({\n message: error.message,\n code: \"EXECUTE_WITH_RETRY_FAILED\",\n data: input.paths\n });\n }\n\n return response.done();\n }\n\n private async invalidateCache(\n caller: string,\n distributionId: string,\n paths: string[]\n ): Promise<void> {\n const cloudfront = new CloudFront();\n await cloudfront.createInvalidation({\n DistributionId: distributionId,\n InvalidationBatch: {\n CallerReference: `${new Date().getTime()}-${caller}`,\n Paths: {\n Quantity: paths.length,\n Items: paths\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAGA,MAAMG,cAAc,SAASC,KAAK,CAAC;AAa5B,MAAMC,6BAA6B,CAAC;EAC/BC,cAAc,GAAG,CAAC,gCAAgC,EAAE,YAAY,CAAC;EAEzE,MAAaC,GAAGA,CAAC;IACbC,KAAK;IACLC,QAAQ;IACRC;EACsD,CAAC,EAAgC;IACvF,MAAMC,QAAQ,GAAG,MAAMC,qBAAgB,CAACC,IAAI,CAAC,CAAC;IAE9C,IAAI,CAACF,QAAQ,EAAE;MACX,OAAOF,QAAQ,CAACK,KAAK,CAAC;QAClBC,OAAO,EAAE,+DAA+D;QACxEC,IAAI,EAAE,0BAA0B;QAChCC,IAAI,EAAE;UACFN,QAAQ,EAAE;QACd;MACJ,CAAC,CAAC;IACN;IAEA,MAAM;MAAEO;IAAe,CAAC,GAAGP,QAAQ,CAACQ,GAAG,CAACC,UAAU;IAElD,MAAMC,eAAe,GAAGA,CAAA,KAAM;MAC1B,OAAO,IAAI,CAACA,eAAe,CAACb,KAAK,CAACc,MAAM,EAAEJ,cAAc,EAAYV,KAAK,CAACe,KAAK,CAAC;IACpF,CAAC;IAED,IAAI;MACA,MAAM,IAAAC,uBAAgB,EAACH,eAAe,EAAE;QACpCI,UAAU,EAAE,IAAI;QAChBC,OAAO,EAAE,IAAI;QACbC,eAAe,EAAEC,GAAG,IAAI;UACpB,IAAI,IAAI,CAACtB,cAAc,CAACuB,QAAQ,CAACD,GAAG,CAACE,IAAI,CAAC,EAAE;YACxC,MAAM,IAAI3B,cAAc,CAAC,CAAC;UAC9B;UAEA,IAAIyB,GAAG,CAACb,OAAO,CAACc,QAAQ,CAAC,2BAA2B,CAAC,EAAE;YACnD,MAAMD,GAAG;UACb;UAEA,IAAIlB,gBAAgB,CAAC,CAAC,EAAE;YACpB,MAAM,IAAIP,cAAc,CAAC,CAAC;UAC9B;QACJ;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOW,KAAK,EAAE;MACZ,IAAIA,KAAK,YAAYX,cAAc,EAAE;QACjC,OAAOM,QAAQ,CAACsB,QAAQ,CAACvB,KAAK,CAAC;MACnC;MAEA,OAAOC,QAAQ,CAACK,KAAK,CAAC;QAClBC,OAAO,EAAED,KAAK,CAACC,OAAO;QACtBC,IAAI,EAAE,2BAA2B;QACjCC,IAAI,EAAET,KAAK,CAACe;MAChB,CAAC,CAAC;IACN;IAEA,OAAOd,QAAQ,CAACuB,IAAI,CAAC,CAAC;EAC1B;EAEA,MAAcX,eAAeA,CACzBC,MAAc,EACdJ,cAAsB,EACtBK,KAAe,EACF;IACb,MAAMH,UAAU,GAAG,IAAIa,4BAAU,CAAC,CAAC;IACnC,MAAMb,UAAU,CAACc,kBAAkB,CAAC;MAChCC,cAAc,EAAEjB,cAAc;MAC9BkB,iBAAiB,EAAE;QACfC,eAAe,EAAE,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,IAAIjB,MAAM,EAAE;QACpDkB,KAAK,EAAE;UACHC,QAAQ,EAAElB,KAAK,CAACmB,MAAM;UACtBC,KAAK,EAAEpB;QACX;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACqB,OAAA,CAAAvC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flushCacheOnFileDelete = void 0;
|
|
7
|
+
var _api = require("@webiny/api");
|
|
8
|
+
var _CdnPathsGenerator = require("./CdnPathsGenerator");
|
|
9
|
+
class FlushCacheOnFileDelete {
|
|
10
|
+
constructor(context) {
|
|
11
|
+
this.pathsGenerator = new _CdnPathsGenerator.CdnPathsGenerator();
|
|
12
|
+
this.context = context;
|
|
13
|
+
context.fileManager.onFileAfterDelete.subscribe(this.onFileAfterDelete);
|
|
14
|
+
}
|
|
15
|
+
onFileAfterDelete = async ({
|
|
16
|
+
file
|
|
17
|
+
}) => {
|
|
18
|
+
await this.context.tasks.trigger({
|
|
19
|
+
definition: "cloudfrontInvalidateCache",
|
|
20
|
+
input: {
|
|
21
|
+
caller: "fm-before-delete",
|
|
22
|
+
paths: this.pathsGenerator.generate(file)
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const flushCacheOnFileDelete = () => {
|
|
28
|
+
return new _api.ContextPlugin(context => {
|
|
29
|
+
new FlushCacheOnFileDelete(context);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.flushCacheOnFileDelete = flushCacheOnFileDelete;
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=flushCacheOnFileDelete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_api","require","_CdnPathsGenerator","FlushCacheOnFileDelete","constructor","context","pathsGenerator","CdnPathsGenerator","fileManager","onFileAfterDelete","subscribe","file","tasks","trigger","definition","input","caller","paths","generate","flushCacheOnFileDelete","ContextPlugin","exports"],"sources":["flushCacheOnFileDelete.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type {\n FileManagerContext,\n OnFileBeforeUpdateTopicParams\n} from \"@webiny/api-file-manager/types\";\nimport { CdnPathsGenerator } from \"~/flushCdnCache/CdnPathsGenerator\";\n\nclass FlushCacheOnFileDelete {\n private readonly context: FileManagerContext;\n private readonly pathsGenerator: CdnPathsGenerator;\n\n constructor(context: FileManagerContext) {\n this.pathsGenerator = new CdnPathsGenerator();\n this.context = context;\n context.fileManager.onFileAfterDelete.subscribe(this.onFileAfterDelete);\n }\n\n private onFileAfterDelete = async ({ file }: OnFileBeforeUpdateTopicParams) => {\n await this.context.tasks.trigger({\n definition: \"cloudfrontInvalidateCache\",\n input: {\n caller: \"fm-before-delete\",\n paths: this.pathsGenerator.generate(file)\n }\n });\n };\n}\n\nexport const flushCacheOnFileDelete = () => {\n return new ContextPlugin<FileManagerContext>(context => {\n new FlushCacheOnFileDelete(context);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAKA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,MAAME,sBAAsB,CAAC;EAIzBC,WAAWA,CAACC,OAA2B,EAAE;IACrC,IAAI,CAACC,cAAc,GAAG,IAAIC,oCAAiB,CAAC,CAAC;IAC7C,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtBA,OAAO,CAACG,WAAW,CAACC,iBAAiB,CAACC,SAAS,CAAC,IAAI,CAACD,iBAAiB,CAAC;EAC3E;EAEQA,iBAAiB,GAAG,MAAAA,CAAO;IAAEE;EAAoC,CAAC,KAAK;IAC3E,MAAM,IAAI,CAACN,OAAO,CAACO,KAAK,CAACC,OAAO,CAAC;MAC7BC,UAAU,EAAE,2BAA2B;MACvCC,KAAK,EAAE;QACHC,MAAM,EAAE,kBAAkB;QAC1BC,KAAK,EAAE,IAAI,CAACX,cAAc,CAACY,QAAQ,CAACP,IAAI;MAC5C;IACJ,CAAC,CAAC;EACN,CAAC;AACL;AAEO,MAAMQ,sBAAsB,GAAGA,CAAA,KAAM;EACxC,OAAO,IAAIC,kBAAa,CAAqBf,OAAO,IAAI;IACpD,IAAIF,sBAAsB,CAACE,OAAO,CAAC;EACvC,CAAC,CAAC;AACN,CAAC;AAACgB,OAAA,CAAAF,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flushCacheOnFileUpdate = void 0;
|
|
7
|
+
var _api = require("@webiny/api");
|
|
8
|
+
var _CdnPathsGenerator = require("./CdnPathsGenerator");
|
|
9
|
+
class FlushCacheOnFileUpdate {
|
|
10
|
+
constructor(context) {
|
|
11
|
+
this.pathsGenerator = new _CdnPathsGenerator.CdnPathsGenerator();
|
|
12
|
+
this.context = context;
|
|
13
|
+
context.fileManager.onFileBeforeUpdate.subscribe(this.onFileBeforeUpdate);
|
|
14
|
+
}
|
|
15
|
+
onFileBeforeUpdate = async ({
|
|
16
|
+
file,
|
|
17
|
+
original
|
|
18
|
+
}) => {
|
|
19
|
+
const prevAccessControl = original.accessControl;
|
|
20
|
+
const newAccessControl = file.accessControl;
|
|
21
|
+
if (prevAccessControl?.type === newAccessControl?.type) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
await this.context.tasks.trigger({
|
|
25
|
+
definition: "cloudfrontInvalidateCache",
|
|
26
|
+
input: {
|
|
27
|
+
caller: "fm-before-update",
|
|
28
|
+
paths: this.pathsGenerator.generate(file)
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const flushCacheOnFileUpdate = () => {
|
|
34
|
+
return new _api.ContextPlugin(context => {
|
|
35
|
+
new FlushCacheOnFileUpdate(context);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.flushCacheOnFileUpdate = flushCacheOnFileUpdate;
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=flushCacheOnFileUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_api","require","_CdnPathsGenerator","FlushCacheOnFileUpdate","constructor","context","pathsGenerator","CdnPathsGenerator","fileManager","onFileBeforeUpdate","subscribe","file","original","prevAccessControl","accessControl","newAccessControl","type","tasks","trigger","definition","input","caller","paths","generate","flushCacheOnFileUpdate","ContextPlugin","exports"],"sources":["flushCacheOnFileUpdate.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type {\n FileManagerContext,\n OnFileBeforeUpdateTopicParams\n} from \"@webiny/api-file-manager/types\";\nimport { CdnPathsGenerator } from \"~/flushCdnCache/CdnPathsGenerator\";\n\nclass FlushCacheOnFileUpdate {\n private readonly context: FileManagerContext;\n private readonly pathsGenerator: CdnPathsGenerator;\n\n constructor(context: FileManagerContext) {\n this.pathsGenerator = new CdnPathsGenerator();\n this.context = context;\n context.fileManager.onFileBeforeUpdate.subscribe(this.onFileBeforeUpdate);\n }\n\n private onFileBeforeUpdate = async ({ file, original }: OnFileBeforeUpdateTopicParams) => {\n const prevAccessControl = original.accessControl;\n const newAccessControl = file.accessControl;\n\n if (prevAccessControl?.type === newAccessControl?.type) {\n return;\n }\n\n await this.context.tasks.trigger({\n definition: \"cloudfrontInvalidateCache\",\n input: {\n caller: \"fm-before-update\",\n paths: this.pathsGenerator.generate(file)\n }\n });\n };\n}\n\nexport const flushCacheOnFileUpdate = () => {\n return new ContextPlugin<FileManagerContext>(context => {\n new FlushCacheOnFileUpdate(context);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAKA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,MAAME,sBAAsB,CAAC;EAIzBC,WAAWA,CAACC,OAA2B,EAAE;IACrC,IAAI,CAACC,cAAc,GAAG,IAAIC,oCAAiB,CAAC,CAAC;IAC7C,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtBA,OAAO,CAACG,WAAW,CAACC,kBAAkB,CAACC,SAAS,CAAC,IAAI,CAACD,kBAAkB,CAAC;EAC7E;EAEQA,kBAAkB,GAAG,MAAAA,CAAO;IAAEE,IAAI;IAAEC;EAAwC,CAAC,KAAK;IACtF,MAAMC,iBAAiB,GAAGD,QAAQ,CAACE,aAAa;IAChD,MAAMC,gBAAgB,GAAGJ,IAAI,CAACG,aAAa;IAE3C,IAAID,iBAAiB,EAAEG,IAAI,KAAKD,gBAAgB,EAAEC,IAAI,EAAE;MACpD;IACJ;IAEA,MAAM,IAAI,CAACX,OAAO,CAACY,KAAK,CAACC,OAAO,CAAC;MAC7BC,UAAU,EAAE,2BAA2B;MACvCC,KAAK,EAAE;QACHC,MAAM,EAAE,kBAAkB;QAC1BC,KAAK,EAAE,IAAI,CAAChB,cAAc,CAACiB,QAAQ,CAACZ,IAAI;MAC5C;IACJ,CAAC,CAAC;EACN,CAAC;AACL;AAEO,MAAMa,sBAAsB,GAAGA,CAAA,KAAM;EACxC,OAAO,IAAIC,kBAAa,CAAqBpB,OAAO,IAAI;IACpD,IAAIF,sBAAsB,CAACE,OAAO,CAAC;EACvC,CAAC,CAAC;AACN,CAAC;AAACqB,OAAA,CAAAF,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const flushCdnCache: () => (import("@webiny/api").ContextPlugin<import("@webiny/api-file-manager/types").FileManagerContext> | import("@webiny/tasks").TaskDefinitionPlugin<import("@webiny/api-file-manager/types").FileManagerContext, any, import("@webiny/tasks").ITaskResponseDoneResultOutput>)[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flushCdnCache = void 0;
|
|
7
|
+
var _flushCacheOnFileUpdate = require("./flushCacheOnFileUpdate");
|
|
8
|
+
var _flushCacheOnFileDelete = require("./flushCacheOnFileDelete");
|
|
9
|
+
var _invalidateCacheTaskDefinition = require("./invalidateCacheTaskDefinition");
|
|
10
|
+
const flushCdnCache = () => {
|
|
11
|
+
return [(0, _flushCacheOnFileUpdate.flushCacheOnFileUpdate)(), (0, _flushCacheOnFileDelete.flushCacheOnFileDelete)(), (0, _invalidateCacheTaskDefinition.createInvalidateCacheTask)()];
|
|
12
|
+
};
|
|
13
|
+
exports.flushCdnCache = flushCdnCache;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_flushCacheOnFileUpdate","require","_flushCacheOnFileDelete","_invalidateCacheTaskDefinition","flushCdnCache","flushCacheOnFileUpdate","flushCacheOnFileDelete","createInvalidateCacheTask","exports"],"sources":["index.ts"],"sourcesContent":["import { flushCacheOnFileUpdate } from \"~/flushCdnCache/flushCacheOnFileUpdate\";\nimport { flushCacheOnFileDelete } from \"~/flushCdnCache/flushCacheOnFileDelete\";\nimport { createInvalidateCacheTask } from \"./invalidateCacheTaskDefinition\";\n\nexport const flushCdnCache = () => {\n return [flushCacheOnFileUpdate(), flushCacheOnFileDelete(), createInvalidateCacheTask()];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IAAAE,8BAAA,GAAAF,OAAA;AAEO,MAAMG,aAAa,GAAGA,CAAA,KAAM;EAC/B,OAAO,CAAC,IAAAC,8CAAsB,EAAC,CAAC,EAAE,IAAAC,8CAAsB,EAAC,CAAC,EAAE,IAAAC,wDAAyB,EAAC,CAAC,CAAC;AAC5F,CAAC;AAACC,OAAA,CAAAJ,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createInvalidateCacheTask = void 0;
|
|
7
|
+
var _tasks = require("@webiny/tasks");
|
|
8
|
+
var _InvalidateCacheTask = require("./InvalidateCacheTask");
|
|
9
|
+
const createInvalidateCacheTask = () => {
|
|
10
|
+
return (0, _tasks.createPrivateTaskDefinition)({
|
|
11
|
+
id: "cloudfrontInvalidateCache",
|
|
12
|
+
title: "Invalidate Cloudfront Cache",
|
|
13
|
+
description: "A task to invalidate Cloudfront cache by given paths.",
|
|
14
|
+
run(params) {
|
|
15
|
+
const taskRunner = new _InvalidateCacheTask.InvalidateCloudfrontCacheTask();
|
|
16
|
+
return taskRunner.run(params);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.createInvalidateCacheTask = createInvalidateCacheTask;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=invalidateCacheTaskDefinition.js.map
|