@acmekit/file-s3 2.13.1

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/README.md ADDED
File without changes
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@acmekit/types").ModuleProviderExports;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAKA,wBAEE"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@acmekit/framework/utils");
4
+ const s3_file_1 = require("./services/s3-file");
5
+ const services = [s3_file_1.S3FileService];
6
+ exports.default = (0, utils_1.ModuleProvider)(utils_1.Modules.FILE, {
7
+ services,
8
+ });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,oDAAkE;AAClE,gDAAkD;AAElD,MAAM,QAAQ,GAAG,CAAC,uBAAa,CAAC,CAAA;AAEhC,kBAAe,IAAA,sBAAc,EAAC,eAAO,CAAC,IAAI,EAAE;IAC1C,QAAQ;CACT,CAAC,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { S3Client } from "@aws-sdk/client-s3";
2
+ import { FileTypes, Logger, S3FileServiceOptions } from "@acmekit/framework/types";
3
+ import { AbstractFileProviderService } from "@acmekit/framework/utils";
4
+ import { Readable, Writable } from "stream";
5
+ type InjectedDependencies = {
6
+ logger: Logger;
7
+ };
8
+ interface S3FileServiceConfig {
9
+ fileUrl: string;
10
+ accessKeyId?: string;
11
+ secretAccessKey?: string;
12
+ authenticationMethod?: "access-key" | "s3-iam-role";
13
+ region: string;
14
+ bucket: string;
15
+ prefix?: string;
16
+ endpoint?: string;
17
+ cacheControl?: string;
18
+ downloadFileDuration?: number;
19
+ additionalClientConfig?: Record<string, any>;
20
+ }
21
+ export declare class S3FileService extends AbstractFileProviderService {
22
+ static identifier: string;
23
+ protected config_: S3FileServiceConfig;
24
+ protected logger_: Logger;
25
+ protected client_: S3Client;
26
+ constructor({ logger }: InjectedDependencies, options: S3FileServiceOptions);
27
+ protected getClient(): S3Client;
28
+ upload(file: FileTypes.ProviderUploadFileDTO): Promise<FileTypes.ProviderFileResultDTO>;
29
+ getUploadStream(fileData: FileTypes.ProviderUploadStreamDTO): Promise<{
30
+ writeStream: Writable;
31
+ promise: Promise<FileTypes.ProviderFileResultDTO>;
32
+ url: string;
33
+ fileKey: string;
34
+ }>;
35
+ delete(files: FileTypes.ProviderDeleteFileDTO | FileTypes.ProviderDeleteFileDTO[]): Promise<void>;
36
+ getPresignedDownloadUrl(fileData: FileTypes.ProviderGetFileDTO): Promise<string>;
37
+ getPresignedUploadUrl(fileData: FileTypes.ProviderGetPresignedUploadUrlDTO): Promise<FileTypes.ProviderFileResultDTO>;
38
+ getDownloadStream(file: FileTypes.ProviderGetFileDTO): Promise<Readable>;
39
+ getAsBuffer(file: FileTypes.ProviderGetFileDTO): Promise<Buffer>;
40
+ }
41
+ export {};
42
+ //# sourceMappingURL=s3-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-file.d.ts","sourceRoot":"","sources":["../../src/services/s3-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,QAAQ,EAET,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EACL,SAAS,EACT,MAAM,EACN,oBAAoB,EACrB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,2BAA2B,EAE5B,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAe,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGxD,KAAK,oBAAoB,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,WAA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zB,QAAQ,EAAE,SAAS,CAAC,gCAAgC,GACnD,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAkCrC,iBAAiB,CACrB,IAAI,EAAE,SAAS,CAAC,kBAAkB,GACjC,OAAO,CAAC,QAAQ,CAAC;IAmBd,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;CAkBvE"}
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.S3FileService = void 0;
7
+ const client_s3_1 = require("@aws-sdk/client-s3");
8
+ const lib_storage_1 = require("@aws-sdk/lib-storage");
9
+ const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
10
+ const utils_1 = require("@acmekit/framework/utils");
11
+ const path_1 = __importDefault(require("path"));
12
+ const stream_1 = require("stream");
13
+ const ulid_1 = require("ulid");
14
+ const DEFAULT_UPLOAD_EXPIRATION_DURATION_SECONDS = 60 * 60;
15
+ class S3FileService extends utils_1.AbstractFileProviderService {
16
+ constructor({ logger }, options) {
17
+ super();
18
+ const authenticationMethod = options.authentication_method ?? "access-key";
19
+ if (authenticationMethod === "access-key" &&
20
+ (!options.access_key_id || !options.secret_access_key)) {
21
+ throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.INVALID_DATA, `Access key ID and secret access key are required when using access key authentication`);
22
+ }
23
+ this.config_ = {
24
+ fileUrl: options.file_url,
25
+ accessKeyId: options.access_key_id,
26
+ secretAccessKey: options.secret_access_key,
27
+ authenticationMethod: authenticationMethod,
28
+ region: options.region,
29
+ bucket: options.bucket,
30
+ prefix: options.prefix ?? "",
31
+ endpoint: options.endpoint,
32
+ cacheControl: options.cache_control ?? "public, max-age=31536000",
33
+ downloadFileDuration: options.download_file_duration ?? 60 * 60,
34
+ additionalClientConfig: options.additional_client_config ?? {},
35
+ };
36
+ this.logger_ = logger;
37
+ this.client_ = this.getClient();
38
+ }
39
+ getClient() {
40
+ // If none is provided, the SDK will use the default credentials provider chain, see https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-envvars.html
41
+ const credentials = this.config_.authenticationMethod === "access-key"
42
+ ? {
43
+ accessKeyId: this.config_.accessKeyId,
44
+ secretAccessKey: this.config_.secretAccessKey,
45
+ }
46
+ : undefined;
47
+ const config = {
48
+ credentials,
49
+ region: this.config_.region,
50
+ endpoint: this.config_.endpoint,
51
+ ...this.config_.additionalClientConfig,
52
+ };
53
+ return new client_s3_1.S3Client(config);
54
+ }
55
+ async upload(file) {
56
+ if (!file) {
57
+ throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.INVALID_DATA, `No file provided`);
58
+ }
59
+ if (!file.filename) {
60
+ throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.INVALID_DATA, `No filename provided`);
61
+ }
62
+ const parsedFilename = path_1.default.parse(file.filename);
63
+ // TODO: Allow passing a full path for storage per request, not as a global config.
64
+ const fileKey = `${this.config_.prefix}${parsedFilename.name}-${(0, ulid_1.ulid)()}${parsedFilename.ext}`;
65
+ let content;
66
+ try {
67
+ const decoded = Buffer.from(file.content, "base64");
68
+ if (decoded.toString("base64") === file.content) {
69
+ content = decoded;
70
+ }
71
+ else {
72
+ content = Buffer.from(file.content, "utf8");
73
+ }
74
+ }
75
+ catch {
76
+ // Last-resort fallback: binary
77
+ content = Buffer.from(file.content, "binary");
78
+ }
79
+ const command = new client_s3_1.PutObjectCommand({
80
+ // We probably also want to support a separate bucket altogether for private files
81
+ // protected private_bucket_: string
82
+ // protected private_access_key_id_: string
83
+ // protected private_secret_access_key_: string
84
+ ACL: file.access === "public" ? "public-read" : "private",
85
+ Bucket: this.config_.bucket,
86
+ Body: content,
87
+ Key: fileKey,
88
+ ContentType: file.mimeType,
89
+ CacheControl: this.config_.cacheControl,
90
+ // Note: We could potentially set the content disposition when uploading,
91
+ // but storing the original filename as metadata should suffice.
92
+ Metadata: {
93
+ "original-filename": encodeURIComponent(file.filename),
94
+ },
95
+ });
96
+ try {
97
+ await this.client_.send(command);
98
+ }
99
+ catch (e) {
100
+ this.logger_.error(e);
101
+ throw e;
102
+ }
103
+ return {
104
+ url: `${this.config_.fileUrl}/${encodeURIComponent(fileKey)}`,
105
+ key: fileKey,
106
+ };
107
+ }
108
+ async getUploadStream(fileData) {
109
+ if (!fileData.filename) {
110
+ throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.INVALID_DATA, `No filename provided`);
111
+ }
112
+ const parsedFilename = path_1.default.parse(fileData.filename);
113
+ const fileKey = `${this.config_.prefix}${parsedFilename.name}-${(0, ulid_1.ulid)()}${parsedFilename.ext}`;
114
+ const pass = new stream_1.PassThrough();
115
+ const upload = new lib_storage_1.Upload({
116
+ client: this.client_,
117
+ params: {
118
+ ACL: fileData.access === "public" ? "public-read" : "private",
119
+ Bucket: this.config_.bucket,
120
+ Key: fileKey,
121
+ Body: pass,
122
+ ContentType: fileData.mimeType,
123
+ CacheControl: this.config_.cacheControl,
124
+ Metadata: {
125
+ "original-filename": encodeURIComponent(fileData.filename),
126
+ },
127
+ },
128
+ });
129
+ const promise = upload.done().then(() => ({
130
+ url: `${this.config_.fileUrl}/${fileKey}`,
131
+ key: fileKey,
132
+ }));
133
+ return {
134
+ writeStream: pass,
135
+ promise,
136
+ url: `${this.config_.fileUrl}/${fileKey}`,
137
+ fileKey,
138
+ };
139
+ }
140
+ async delete(files) {
141
+ try {
142
+ /**
143
+ * Bulk delete files
144
+ */
145
+ if (Array.isArray(files)) {
146
+ await this.client_.send(new client_s3_1.DeleteObjectsCommand({
147
+ Bucket: this.config_.bucket,
148
+ Delete: {
149
+ Objects: files.map((file) => ({
150
+ Key: file.fileKey,
151
+ })),
152
+ Quiet: true,
153
+ },
154
+ }));
155
+ }
156
+ else {
157
+ await this.client_.send(new client_s3_1.DeleteObjectCommand({
158
+ Bucket: this.config_.bucket,
159
+ Key: files.fileKey,
160
+ }));
161
+ }
162
+ }
163
+ catch (e) {
164
+ // TODO: Rethrow depending on the error (eg. a file not found error is fine, but a failed request should be rethrown)
165
+ this.logger_.error(e);
166
+ }
167
+ }
168
+ async getPresignedDownloadUrl(fileData) {
169
+ // TODO: Allow passing content disposition when getting a presigned URL
170
+ const command = new client_s3_1.GetObjectCommand({
171
+ Bucket: this.config_.bucket,
172
+ Key: `${fileData.fileKey}`,
173
+ });
174
+ return await (0, s3_request_presigner_1.getSignedUrl)(this.client_, command, {
175
+ expiresIn: this.config_.downloadFileDuration,
176
+ });
177
+ }
178
+ // Note: Some providers (eg. AWS S3) allows IAM policies to further restrict what can be uploaded.
179
+ async getPresignedUploadUrl(fileData) {
180
+ if (!fileData?.filename) {
181
+ throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.INVALID_DATA, `No filename provided`);
182
+ }
183
+ const fileKey = `${this.config_.prefix}${fileData.filename}`;
184
+ let acl;
185
+ if (fileData.access) {
186
+ acl = fileData.access === "public" ? "public-read" : "private";
187
+ }
188
+ // Using content-type, acl, etc. doesn't work with all providers, and some simply ignore it.
189
+ const command = new client_s3_1.PutObjectCommand({
190
+ Bucket: this.config_.bucket,
191
+ ContentType: fileData.mimeType,
192
+ ACL: acl,
193
+ Key: fileKey,
194
+ });
195
+ const signedUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.client_, command, {
196
+ expiresIn: fileData.expiresIn ?? DEFAULT_UPLOAD_EXPIRATION_DURATION_SECONDS,
197
+ });
198
+ return {
199
+ url: signedUrl,
200
+ key: fileKey,
201
+ };
202
+ }
203
+ async getDownloadStream(file) {
204
+ if (!file?.fileKey) {
205
+ throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.INVALID_DATA, `No fileKey provided`);
206
+ }
207
+ const fileKey = file.fileKey;
208
+ const response = await this.client_.send(new client_s3_1.GetObjectCommand({
209
+ Key: fileKey,
210
+ Bucket: this.config_.bucket,
211
+ }));
212
+ return response.Body;
213
+ }
214
+ async getAsBuffer(file) {
215
+ if (!file?.fileKey) {
216
+ throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.INVALID_DATA, `No fileKey provided`);
217
+ }
218
+ const fileKey = file.fileKey;
219
+ const response = await this.client_.send(new client_s3_1.GetObjectCommand({
220
+ Key: fileKey,
221
+ Bucket: this.config_.bucket,
222
+ }));
223
+ return Buffer.from(await response.Body.transformToByteArray());
224
+ }
225
+ }
226
+ exports.S3FileService = S3FileService;
227
+ S3FileService.identifier = "s3";
228
+ //# sourceMappingURL=s3-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-file.js","sourceRoot":"","sources":["../../src/services/s3-file.ts"],"names":[],"mappings":";;;;;;AAAA,kDAQ2B;AAC3B,sDAA6C;AAC7C,wEAA4D;AAM5D,oDAGiC;AACjC,gDAAuB;AACvB,mCAAwD;AACxD,+BAA2B;AAoB3B,MAAM,0CAA0C,GAAG,EAAE,GAAG,EAAE,CAAA;AAE1D,MAAa,aAAc,SAAQ,mCAA2B;IAM5D,YAAY,EAAE,MAAM,EAAwB,EAAE,OAA6B;QACzE,KAAK,EAAE,CAAA;QAEP,MAAM,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,IAAI,YAAY,CAAA;QAE1E,IACE,oBAAoB,KAAK,YAAY;YACrC,CAAC,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,EACtD,CAAC;YACD,MAAM,IAAI,oBAAY,CACpB,oBAAY,CAAC,KAAK,CAAC,YAAY,EAC/B,uFAAuF,CACxF,CAAA;QACH,CAAC;QAED,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,OAAO,CAAC,QAAQ;YACzB,WAAW,EAAE,OAAO,CAAC,aAAa;YAClC,eAAe,EAAE,OAAO,CAAC,iBAAiB;YAC1C,oBAAoB,EAAE,oBAAoB;YAC1C,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,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5.9.3"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@acmekit/file-s3",
3
+ "version": "2.13.1",
4
+ "description": "S3 protocol file storage for AcmeKit. Supports any S3-compatible storage provider",
5
+ "main": "dist/index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/acmekit/acmekit",
9
+ "directory": "packages/modules/providers/file-s3"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "!dist/**/__tests__",
14
+ "!dist/**/__mocks__",
15
+ "!dist/**/__fixtures__"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20"
19
+ },
20
+ "author": "AcmeKit",
21
+ "license": "MIT",
22
+ "scripts": {
23
+ "test": "../../../../node_modules/.bin/jest --passWithNoTests src",
24
+ "test:integration": "../../../../node_modules/.bin/jest --passWithNoTests --forceExit --testPathPattern=\"integration-tests/__tests__/[^/]*\\.spec\\.ts\"",
25
+ "build": "yarn run -T rimraf dist && yarn run -T tsc --build ./tsconfig.json",
26
+ "watch": "yarn run -T tsc --watch"
27
+ },
28
+ "devDependencies": {
29
+ "@acmekit/framework": "2.13.1"
30
+ },
31
+ "dependencies": {
32
+ "@aws-sdk/client-s3": "^3.556.0",
33
+ "@aws-sdk/lib-storage": "^3.556.0",
34
+ "@aws-sdk/s3-request-presigner": "^3.556.0",
35
+ "ulid": "^2.3.0"
36
+ },
37
+ "peerDependencies": {
38
+ "@acmekit/framework": "2.13.1"
39
+ },
40
+ "keywords": [
41
+ "acmekit-plugin",
42
+ "acmekit-plugin-s3"
43
+ ]
44
+ }