lean-s3 0.9.8 → 0.9.10

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.mts CHANGED
@@ -78,13 +78,10 @@ interface S3ClientOptions {
78
78
  }
79
79
  type OverridableS3ClientOptions = Partial<Pick<S3ClientOptions, "region" | "bucket" | "endpoint">>;
80
80
  type CreateFileInstanceOptions = {
81
- /** Content-Type of the file. */
82
- type?: string;
81
+ /** Content-Type of the file. */type?: string;
83
82
  };
84
83
  type DeleteObjectsOptions = {
85
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
86
- bucket?: string;
87
- /** Signal to abort the request. */
84
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string; /** Signal to abort the request. */
88
85
  signal?: AbortSignal;
89
86
  };
90
87
  type DeleteObjectsResult = {
@@ -151,11 +148,8 @@ type PresignPostResult = {
151
148
  fields: Record<string, string>;
152
149
  };
153
150
  type CopyObjectOptions = {
154
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
155
- sourceBucket?: string;
156
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
157
- destinationBucket?: string;
158
- /** Signal to abort the request. */
151
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */sourceBucket?: string; /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
152
+ destinationBucket?: string; /** Signal to abort the request. */
159
153
  signal?: AbortSignal;
160
154
  };
161
155
  type CopyObjectResult = {
@@ -167,39 +161,32 @@ type CopyObjectResult = {
167
161
  checksumSHA256?: string;
168
162
  };
169
163
  type ListObjectsOptions = {
170
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
171
- bucket?: string;
164
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string;
172
165
  prefix?: string;
173
166
  maxKeys?: number;
174
167
  delimiter?: string;
175
168
  startAfter?: string;
176
- continuationToken?: string;
177
- /** Signal to abort the request. */
169
+ continuationToken?: string; /** Signal to abort the request. */
178
170
  signal?: AbortSignal;
179
171
  };
180
172
  type ListObjectsIteratingOptions = {
181
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
182
- bucket?: string;
173
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string;
183
174
  prefix?: string;
184
- startAfter?: string;
185
- /** Signal to abort the request. */
175
+ startAfter?: string; /** Signal to abort the request. */
186
176
  signal?: AbortSignal;
187
177
  internalPageSize?: number;
188
178
  };
189
179
  type ListMultipartUploadsOptions = {
190
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
191
- bucket?: string;
180
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string;
192
181
  delimiter?: string;
193
182
  keyMarker?: string;
194
183
  maxUploads?: number;
195
184
  prefix?: string;
196
- uploadIdMarker?: string;
197
- /** Signal to abort the request. */
185
+ uploadIdMarker?: string; /** Signal to abort the request. */
198
186
  signal?: AbortSignal;
199
187
  };
200
188
  type ListMultipartUploadsResult = {
201
- /** Name of the bucket the operation was used upon. */
202
- bucket?: string;
189
+ /** Name of the bucket the operation was used upon. */bucket?: string;
203
190
  keyMarker?: string;
204
191
  uploadIdMarker?: string;
205
192
  nextKeyMarker?: string;
@@ -226,45 +213,31 @@ type MultipartUpload = {
226
213
  uploadId?: string;
227
214
  };
228
215
  type CreateMultipartUploadOptions = {
229
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
230
- bucket?: string;
231
- /** Signal to abort the request. */
216
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string; /** Signal to abort the request. */
232
217
  signal?: AbortSignal;
233
218
  };
234
219
  type CreateMultipartUploadResult = {
235
- /** Name of the bucket the multipart upload was created in. */
236
- bucket: string;
220
+ /** Name of the bucket the multipart upload was created in. */bucket: string;
237
221
  key: string;
238
222
  uploadId: string;
239
223
  };
240
224
  type AbortMultipartUploadOptions = {
241
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
242
- bucket?: string;
243
- /** Signal to abort the request. */
225
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string; /** Signal to abort the request. */
244
226
  signal?: AbortSignal;
245
227
  };
246
228
  type CompleteMultipartUploadOptions = {
247
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
248
- bucket?: string;
249
- /** Signal to abort the request. */
229
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string; /** Signal to abort the request. */
250
230
  signal?: AbortSignal;
251
231
  };
252
232
  type CompleteMultipartUploadResult = {
253
- /** The URI that identifies the newly created object. */
254
- location?: string;
255
- /** Name of the bucket the multipart upload was created in. */
233
+ /** The URI that identifies the newly created object. */location?: string; /** Name of the bucket the multipart upload was created in. */
256
234
  bucket?: string;
257
235
  key?: string;
258
- etag?: string;
259
- /** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */
260
- checksumCRC32?: string;
261
- /** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
262
- checksumCRC32C?: string;
263
- /** The Base64 encoded, 64-bit `CRC64NVME` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC64NVME` checksum algorithm. */
264
- checksumCRC64NVME?: string;
265
- /** The Base64 encoded, 160-bit `SHA1` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA1` checksum algorithm. */
266
- checksumSHA1?: string;
267
- /** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
236
+ etag?: string; /** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */
237
+ checksumCRC32?: string; /** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
238
+ checksumCRC32C?: string; /** The Base64 encoded, 64-bit `CRC64NVME` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC64NVME` checksum algorithm. */
239
+ checksumCRC64NVME?: string; /** The Base64 encoded, 160-bit `SHA1` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA1` checksum algorithm. */
240
+ checksumSHA1?: string; /** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
268
241
  checksumSHA256?: string;
269
242
  /**
270
243
  * The checksum type, which determines how part-level checksums are combined to create an object-level checksum for multipart objects.
@@ -277,9 +250,7 @@ type MultipartUploadPart = {
277
250
  etag: string;
278
251
  };
279
252
  type UploadPartOptions = {
280
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
281
- bucket?: string;
282
- /** Signal to abort the request. */
253
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string; /** Signal to abort the request. */
283
254
  signal?: AbortSignal;
284
255
  };
285
256
  type UploadPartResult = {
@@ -288,15 +259,12 @@ type UploadPartResult = {
288
259
  };
289
260
  type ListPartsOptions = {
290
261
  maxParts?: number;
291
- partNumberMarker?: string;
292
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
293
- bucket?: string;
294
- /** Signal to abort the request. */
262
+ partNumberMarker?: string; /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
263
+ bucket?: string; /** Signal to abort the request. */
295
264
  signal?: AbortSignal;
296
265
  };
297
266
  type ListPartsResult = {
298
- /** Name of the bucket. */
299
- bucket: string;
267
+ /** Name of the bucket. */bucket: string;
300
268
  key: string;
301
269
  uploadId: string;
302
270
  partNumberMarker?: string;
@@ -304,15 +272,10 @@ type ListPartsResult = {
304
272
  maxParts?: number;
305
273
  isTruncated: boolean;
306
274
  parts: Array<{
307
- /** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */
308
- checksumCRC32?: string;
309
- /** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
310
- checksumCRC32C?: string;
311
- /** The Base64 encoded, 64-bit `CRC64NVME` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC64NVME` checksum algorithm. */
312
- checksumCRC64NVME?: string;
313
- /** The Base64 encoded, 160-bit `SHA1` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA1` checksum algorithm. */
314
- checksumSHA1?: string;
315
- /** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
275
+ /** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */checksumCRC32?: string; /** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
276
+ checksumCRC32C?: string; /** The Base64 encoded, 64-bit `CRC64NVME` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC64NVME` checksum algorithm. */
277
+ checksumCRC64NVME?: string; /** The Base64 encoded, 160-bit `SHA1` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA1` checksum algorithm. */
278
+ checksumSHA1?: string; /** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
316
279
  checksumSHA256?: string;
317
280
  etag: string;
318
281
  lastModified: Date;
@@ -335,54 +298,38 @@ type ListObjectsResult = {
335
298
  contents: readonly S3BucketEntry[];
336
299
  };
337
300
  type BucketCreationOptions = {
338
- /** Set this to override the {@link S3ClientOptions#endpoint} that was passed on creation of the {@link S3Client}. */
339
- endpoint?: string;
340
- /** Set this to override the {@link S3ClientOptions#region} that was passed on creation of the {@link S3Client}. */
301
+ /** Set this to override the {@link S3ClientOptions#endpoint} that was passed on creation of the {@link S3Client}. */endpoint?: string; /** Set this to override the {@link S3ClientOptions#region} that was passed on creation of the {@link S3Client}. */
341
302
  region?: string;
342
303
  locationConstraint?: string;
343
304
  location?: BucketLocationInfo;
344
- info?: BucketInfo;
345
- /** Signal to abort the request. */
305
+ info?: BucketInfo; /** Signal to abort the request. */
346
306
  signal?: AbortSignal;
347
307
  };
348
308
  type BucketDeletionOptions = {
349
- /** Signal to abort the request. */
350
- signal?: AbortSignal;
309
+ /** Signal to abort the request. */signal?: AbortSignal;
351
310
  };
352
311
  type BucketExistsOptions = {
353
- /** Signal to abort the request. */
354
- signal?: AbortSignal;
312
+ /** Signal to abort the request. */signal?: AbortSignal;
355
313
  };
356
314
  type BucketCorsRules = readonly BucketCorsRule[];
357
315
  type BucketCorsRule = {
358
- allowedMethods: readonly HttpMethod[];
359
- /** One or more origins you want customers to be able to access the bucket from. */
360
- allowedOrigins: readonly string[];
361
- /** Headers that are specified in the `Access-Control-Request-Headers` header. These headers are allowed in a preflight `OPTIONS` request. */
362
- allowedHeaders?: readonly string[];
363
- /** One or more headers in the response that you want customers to be able to access from their applications. */
364
- exposeHeaders?: readonly string[];
365
- /** Unique identifier for the rule. The value cannot be longer than 255 characters. */
366
- id?: string;
367
- /** The time in seconds that your browser is to cache the preflight response for the specified resource. */
316
+ allowedMethods: readonly HttpMethod[]; /** One or more origins you want customers to be able to access the bucket from. */
317
+ allowedOrigins: readonly string[]; /** Headers that are specified in the `Access-Control-Request-Headers` header. These headers are allowed in a preflight `OPTIONS` request. */
318
+ allowedHeaders?: readonly string[]; /** One or more headers in the response that you want customers to be able to access from their applications. */
319
+ exposeHeaders?: readonly string[]; /** Unique identifier for the rule. The value cannot be longer than 255 characters. */
320
+ id?: string; /** The time in seconds that your browser is to cache the preflight response for the specified resource. */
368
321
  maxAgeSeconds?: number;
369
322
  };
370
323
  type PutBucketCorsOptions = {
371
- /** The CORS rules to set on the bucket. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
372
- bucket?: string;
373
- /** Signal to abort the request. */
324
+ /** The CORS rules to set on the bucket. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string; /** Signal to abort the request. */
374
325
  signal?: AbortSignal;
375
326
  };
376
327
  type DeleteBucketCorsOptions = {
377
- /** The name of the bucket to delete the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
378
- bucket?: string;
379
- /** Signal to abort the request. */
328
+ /** The name of the bucket to delete the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string; /** Signal to abort the request. */
380
329
  signal?: AbortSignal;
381
330
  };
382
331
  type GetBucketCorsOptions = {
383
- /** The name of the bucket to get the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
384
- bucket?: string;
385
- /** Signal to abort the request. */
332
+ /** The name of the bucket to get the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */bucket?: string; /** Signal to abort the request. */
386
333
  signal?: AbortSignal;
387
334
  };
388
335
  type GetBucketCorsResult = {
@@ -683,9 +630,7 @@ interface S3FileExistsOptions extends OverridableS3ClientOptions {
683
630
  signal?: AbortSignal;
684
631
  }
685
632
  type S3FileWriteOptions = {
686
- /** Content-Type of the file. */
687
- type?: string;
688
- /** Signal to abort the request. */
633
+ /** Content-Type of the file. */type?: string; /** Signal to abort the request. */
689
634
  signal?: AbortSignal;
690
635
  };
691
636
  //#endregion
package/dist/index.mjs CHANGED
@@ -442,8 +442,8 @@ var S3Client = class {
442
442
  const contentDisposition = options.response?.contentDisposition;
443
443
  const responseContentDisposition = contentDisposition ? getContentDispositionHeader(contentDisposition) : void 0;
444
444
  const res = buildRequestUrl(endpoint, bucket, region, ensureValidPath(path));
445
- const now$1 = /* @__PURE__ */ new Date();
446
- const date = getAmzDate(now$1);
445
+ const now = /* @__PURE__ */ new Date();
446
+ const date = getAmzDate(now);
447
447
  const query = buildSearchParams(`${this.#options.accessKeyId}/${date.date}/${region}/s3/aws4_request`, date, options.expiresIn ?? 3600, typeof contentLength === "number" || typeof contentType === "string" ? typeof contentLength === "number" && typeof contentType === "string" ? "content-length;content-type;host" : typeof contentLength === "number" ? "content-length;host" : typeof contentType === "string" ? "content-type;host" : "" : "host", unsignedPayload, options.storageClass, this.#options.sessionToken, options.acl, responseContentDisposition);
448
448
  const dataDigest = typeof contentLength === "number" || typeof contentType === "string" ? createCanonicalDataDigest(method, res.pathname, query, typeof contentLength === "number" && typeof contentType === "string" ? {
449
449
  "content-length": String(contentLength),
@@ -461,8 +461,8 @@ var S3Client = class {
461
461
  return res.toString();
462
462
  }
463
463
  presignPost(options) {
464
- const now$1 = /* @__PURE__ */ new Date();
465
- const date = getAmzDate(now$1);
464
+ const now = /* @__PURE__ */ new Date();
465
+ const date = getAmzDate(now);
466
466
  const key = options.key;
467
467
  const region = ensureValidRegion(options.region ?? this.#options.region);
468
468
  const bucket = ensureValidBucketName(options.bucket ?? this.#options.bucket);
@@ -478,7 +478,7 @@ var S3Client = class {
478
478
  ...this.#options.sessionToken ? { "X-Amz-Security-Token": this.#options.sessionToken } : void 0
479
479
  };
480
480
  const policy = {
481
- expiration: new Date(now$1.getTime() + expiresIn * 1e3).toISOString().replace(/\.\d{3}Z$/, "Z"),
481
+ expiration: new Date(now.getTime() + expiresIn * 1e3).toISOString().replace(/\.\d{3}Z$/, "Z"),
482
482
  conditions: [
483
483
  [
484
484
  "eq",
@@ -925,11 +925,11 @@ var S3Client = class {
925
925
  async [kSignedRequest](region, endpoint, bucket, method, pathWithoutBucket, query, body, additionalSignedHeaders, additionalUnsignedHeaders, contentHash, signal) {
926
926
  const url = buildRequestUrl(endpoint, bucket, region, pathWithoutBucket);
927
927
  if (query) url.search = query;
928
- const now$1 = now();
928
+ const now$2 = now();
929
929
  const contentHashStr = contentHash?.toString("hex") ?? unsignedPayload;
930
930
  const headersToBeSigned = prepareHeadersForSigning({
931
931
  host: url.host,
932
- "x-amz-date": now$1.dateTime,
932
+ "x-amz-date": now$2.dateTime,
933
933
  "x-amz-content-sha256": contentHashStr,
934
934
  ...additionalSignedHeaders
935
935
  });
@@ -940,7 +940,7 @@ var S3Client = class {
940
940
  dispatcher: this.#dispatcher,
941
941
  headers: {
942
942
  ...headersToBeSigned,
943
- authorization: getAuthorizationHeader(this.#keyCache, method, url.pathname, query ?? "", now$1, headersToBeSigned, region, contentHashStr, this.#options.accessKeyId, this.#options.secretAccessKey),
943
+ authorization: getAuthorizationHeader(this.#keyCache, method, url.pathname, query ?? "", now$2, headersToBeSigned, region, contentHashStr, this.#options.accessKeyId, this.#options.secretAccessKey),
944
944
  ...additionalUnsignedHeaders,
945
945
  "user-agent": "lean-s3"
946
946
  },
@@ -1001,7 +1001,7 @@ var S3Client = class {
1001
1001
  const bucket = this.#options.bucket;
1002
1002
  const endpoint = this.#options.endpoint;
1003
1003
  const region = this.#options.region;
1004
- const now$1 = now();
1004
+ const now$3 = now();
1005
1005
  const url = buildRequestUrl(endpoint, bucket, region, path);
1006
1006
  const range = getRangeHeader(rageStart, rangeEndExclusive);
1007
1007
  const contentHashStr = contentHash?.toString("hex") ?? unsignedPayload;
@@ -1010,7 +1010,7 @@ var S3Client = class {
1010
1010
  host: url.host,
1011
1011
  range,
1012
1012
  "x-amz-content-sha256": contentHashStr,
1013
- "x-amz-date": now$1.dateTime
1013
+ "x-amz-date": now$3.dateTime
1014
1014
  });
1015
1015
  const ac = new AbortController();
1016
1016
  return new ReadableStream({
@@ -1028,7 +1028,7 @@ var S3Client = class {
1028
1028
  dispatcher: this.#dispatcher,
1029
1029
  headers: {
1030
1030
  ...headersToBeSigned,
1031
- authorization: getAuthorizationHeader(this.#keyCache, "GET", url.pathname, url.search, now$1, headersToBeSigned, region, contentHashStr, this.#options.accessKeyId, this.#options.secretAccessKey),
1031
+ authorization: getAuthorizationHeader(this.#keyCache, "GET", url.pathname, url.search, now$3, headersToBeSigned, region, contentHashStr, this.#options.accessKeyId, this.#options.secretAccessKey),
1032
1032
  "user-agent": "lean-s3"
1033
1033
  }
1034
1034
  }).then((response) => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lean-s3",
3
3
  "author": "Niklas Mollenhauer",
4
4
  "license": "MIT",
5
- "version": "0.9.8",
5
+ "version": "0.9.10",
6
6
  "description": "A server-side S3 API for the regular user.",
7
7
  "keywords": [
8
8
  "s3",
@@ -44,21 +44,21 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "fast-xml-parser": "^5.3.3",
47
- "undici": "^7.18.2"
47
+ "undici": "^7.19.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@biomejs/biome": "2.3.11",
51
51
  "@testcontainers/localstack": "^11.11.0",
52
52
  "@testcontainers/minio": "^11.11.0",
53
53
  "@testcontainers/s3mock": "^11.11.0",
54
- "@types/node": "^25.0.3",
55
- "@typescript/native-preview": "^7.0.0-dev.20260107.1",
54
+ "@types/node": "^25.0.10",
55
+ "@typescript/native-preview": "^7.0.0-dev.20260122.3",
56
56
  "expect": "^30.2.0",
57
- "lefthook": "^2.0.13",
57
+ "lefthook": "^2.0.15",
58
58
  "testcontainers": "^11.11.0",
59
- "tsdown": "^0.18.4",
59
+ "tsdown": "^0.20.0",
60
60
  "tsx": "^4.21.0",
61
- "typedoc": "^0.28.15"
61
+ "typedoc": "^0.28.16"
62
62
  },
63
63
  "engines": {
64
64
  "node": "^20.19.5 || ^22.21.1 || ^24.11.0 || ^25.1.0"