@directus/storage-driver-s3 12.0.12 → 12.1.0
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/dist/index.d.ts +4 -2
- package/dist/index.js +24 -12
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ObjectCannedACL, ServerSideEncryption } from "@aws-sdk/client-s3";
|
|
2
1
|
import { Readable } from "node:stream";
|
|
2
|
+
import { ObjectCannedACL, ServerSideEncryption } from "@aws-sdk/client-s3";
|
|
3
3
|
import { TusDriver } from "@directus/storage";
|
|
4
4
|
import { ChunkedUploadContext, ReadOptions } from "@directus/types";
|
|
5
5
|
|
|
@@ -11,6 +11,7 @@ type DriverS3Config = {
|
|
|
11
11
|
bucket: string;
|
|
12
12
|
acl?: ObjectCannedACL;
|
|
13
13
|
serverSideEncryption?: ServerSideEncryption;
|
|
14
|
+
serverSideEncryptionKmsKeyId?: string;
|
|
14
15
|
endpoint?: string;
|
|
15
16
|
region?: string;
|
|
16
17
|
forcePathStyle?: boolean;
|
|
@@ -22,6 +23,7 @@ type DriverS3Config = {
|
|
|
22
23
|
maxSockets?: number;
|
|
23
24
|
keepAlive?: boolean;
|
|
24
25
|
};
|
|
26
|
+
declare const kmsKeyIdCheck: ServerSideEncryption[];
|
|
25
27
|
declare class DriverS3 implements TusDriver {
|
|
26
28
|
private config;
|
|
27
29
|
private readonly client;
|
|
@@ -57,4 +59,4 @@ declare class DriverS3 implements TusDriver {
|
|
|
57
59
|
private calcOptimalPartSize;
|
|
58
60
|
}
|
|
59
61
|
//#endregion
|
|
60
|
-
export { DriverS3, DriverS3 as default, DriverS3Config };
|
|
62
|
+
export { DriverS3, DriverS3 as default, DriverS3Config, kmsKeyIdCheck };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs, { promises } from "node:fs";
|
|
2
|
+
import { Agent } from "node:http";
|
|
3
|
+
import { Agent as Agent$1 } from "node:https";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { promises as promises$1 } from "node:stream";
|
|
7
|
+
import { AbortMultipartUploadCommand, CompleteMultipartUploadCommand, CopyObjectCommand, CreateMultipartUploadCommand, DeleteObjectCommand, DeleteObjectsCommand, GetObjectCommand, HeadObjectCommand, ListObjectsV2Command, ListPartsCommand, S3Client, ServerSideEncryption, UploadPartCommand } from "@aws-sdk/client-s3";
|
|
2
8
|
import { Upload } from "@aws-sdk/lib-storage";
|
|
3
9
|
import { normalizePath } from "@directus/utils";
|
|
4
10
|
import { isReadableStream } from "@directus/utils/node";
|
|
@@ -6,14 +12,9 @@ import { Semaphore } from "@shopify/semaphore";
|
|
|
6
12
|
import { NodeHttpHandler } from "@smithy/node-http-handler";
|
|
7
13
|
import { ERRORS, StreamSplitter, TUS_RESUMABLE } from "@tus/utils";
|
|
8
14
|
import ms from "ms";
|
|
9
|
-
import fs, { promises } from "node:fs";
|
|
10
|
-
import { Agent } from "node:http";
|
|
11
|
-
import { Agent as Agent$1 } from "node:https";
|
|
12
|
-
import os from "node:os";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
import { promises as promises$1 } from "node:stream";
|
|
15
15
|
|
|
16
16
|
//#region src/index.ts
|
|
17
|
+
const kmsKeyIdCheck = [ServerSideEncryption.aws_kms, ServerSideEncryption.aws_kms_dsse];
|
|
17
18
|
var DriverS3 = class {
|
|
18
19
|
config;
|
|
19
20
|
client;
|
|
@@ -106,7 +107,10 @@ var DriverS3 = class {
|
|
|
106
107
|
Bucket: this.config.bucket,
|
|
107
108
|
CopySource: `/${this.config.bucket}/${this.fullPath(src)}`
|
|
108
109
|
};
|
|
109
|
-
if (this.config.serverSideEncryption)
|
|
110
|
+
if (this.config.serverSideEncryption) {
|
|
111
|
+
params.ServerSideEncryption = this.config.serverSideEncryption;
|
|
112
|
+
if (kmsKeyIdCheck.includes(this.config.serverSideEncryption) && this.config.serverSideEncryptionKmsKeyId) params.SSEKMSKeyId = this.config.serverSideEncryptionKmsKeyId;
|
|
113
|
+
}
|
|
110
114
|
if (this.config.acl) params.ACL = this.config.acl;
|
|
111
115
|
await this.client.send(new CopyObjectCommand(params));
|
|
112
116
|
}
|
|
@@ -118,7 +122,10 @@ var DriverS3 = class {
|
|
|
118
122
|
};
|
|
119
123
|
if (type) params.ContentType = type;
|
|
120
124
|
if (this.config.acl) params.ACL = this.config.acl;
|
|
121
|
-
if (this.config.serverSideEncryption)
|
|
125
|
+
if (this.config.serverSideEncryption) {
|
|
126
|
+
params.ServerSideEncryption = this.config.serverSideEncryption;
|
|
127
|
+
if (kmsKeyIdCheck.includes(this.config.serverSideEncryption) && this.config.serverSideEncryptionKmsKeyId) params.SSEKMSKeyId = this.config.serverSideEncryptionKmsKeyId;
|
|
128
|
+
}
|
|
122
129
|
await new Upload({
|
|
123
130
|
client: this.client,
|
|
124
131
|
params
|
|
@@ -158,13 +165,18 @@ var DriverS3 = class {
|
|
|
158
165
|
];
|
|
159
166
|
}
|
|
160
167
|
async createChunkedUpload(filepath, context) {
|
|
161
|
-
const
|
|
168
|
+
const params = {
|
|
162
169
|
Bucket: this.config.bucket,
|
|
163
170
|
Key: this.fullPath(filepath),
|
|
164
171
|
Metadata: { "tus-version": TUS_RESUMABLE },
|
|
165
172
|
...context.metadata?.["contentType"] ? { ContentType: context.metadata["contentType"] } : {},
|
|
166
173
|
...context.metadata?.["cacheControl"] ? { CacheControl: context.metadata["cacheControl"] } : {}
|
|
167
|
-
}
|
|
174
|
+
};
|
|
175
|
+
if (this.config.serverSideEncryption) {
|
|
176
|
+
params.ServerSideEncryption = this.config.serverSideEncryption;
|
|
177
|
+
if (kmsKeyIdCheck.includes(this.config.serverSideEncryption) && this.config.serverSideEncryptionKmsKeyId) params.SSEKMSKeyId = this.config.serverSideEncryptionKmsKeyId;
|
|
178
|
+
}
|
|
179
|
+
const command = new CreateMultipartUploadCommand(params);
|
|
168
180
|
const res = await this.client.send(command);
|
|
169
181
|
context.metadata["upload-id"] = res.UploadId;
|
|
170
182
|
return context;
|
|
@@ -318,4 +330,4 @@ var DriverS3 = class {
|
|
|
318
330
|
var src_default = DriverS3;
|
|
319
331
|
|
|
320
332
|
//#endregion
|
|
321
|
-
export { DriverS3, src_default as default };
|
|
333
|
+
export { DriverS3, src_default as default, kmsKeyIdCheck };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/storage-driver-s3",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "S3 file storage abstraction for `@directus/storage`",
|
|
5
5
|
"homepage": "https://directus.io",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@tus/utils": "0.6.0",
|
|
29
29
|
"ms": "2.1.3",
|
|
30
30
|
"@directus/storage": "12.0.3",
|
|
31
|
-
"@directus/utils": "13.
|
|
31
|
+
"@directus/utils": "13.1.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@directus/tsconfig": "3.0.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tsdown": "0.15.11",
|
|
39
39
|
"typescript": "5.9.3",
|
|
40
40
|
"vitest": "3.2.4",
|
|
41
|
-
"@directus/types": "
|
|
41
|
+
"@directus/types": "14.0.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsdown src/index.ts --dts",
|