lean-s3 0.7.2 → 0.7.3
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 +2 -3
- package/dist/index.js +23 -31
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ type DeleteObjectsError = {
|
|
|
57
57
|
message: string;
|
|
58
58
|
versionId: string;
|
|
59
59
|
};
|
|
60
|
-
interface S3FilePresignOptions {
|
|
60
|
+
interface S3FilePresignOptions extends OverridableS3ClientOptions {
|
|
61
61
|
contentHash?: Buffer;
|
|
62
62
|
/** Seconds. */
|
|
63
63
|
expiresIn?: number;
|
|
@@ -346,8 +346,7 @@ declare class S3Client {
|
|
|
346
346
|
* });
|
|
347
347
|
* ```
|
|
348
348
|
*/
|
|
349
|
-
presign(path: string,
|
|
350
|
-
storageClass, contentLength, type, acl, region: regionOverride, bucket: bucketOverride, endpoint: endpointOverride, response, }?: S3FilePresignOptions & OverridableS3ClientOptions): string;
|
|
349
|
+
presign(path: string, optio2ns?: S3FilePresignOptions): string;
|
|
351
350
|
createMultipartUpload(key: string, options?: CreateMultipartUploadOptions): Promise<CreateMultipartUploadResult>;
|
|
352
351
|
/**
|
|
353
352
|
* @remarks Uses [`ListMultipartUploads`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html).
|
package/dist/index.js
CHANGED
|
@@ -511,52 +511,44 @@ var S3Client = class {
|
|
|
511
511
|
* });
|
|
512
512
|
* ```
|
|
513
513
|
*/
|
|
514
|
-
presign(path, {
|
|
515
|
-
|
|
516
|
-
expiresIn = 3600,
|
|
517
|
-
// TODO: Maybe rename this to expiresInSeconds
|
|
518
|
-
storageClass,
|
|
519
|
-
contentLength,
|
|
520
|
-
type,
|
|
521
|
-
acl,
|
|
522
|
-
region: regionOverride,
|
|
523
|
-
bucket: bucketOverride,
|
|
524
|
-
endpoint: endpointOverride,
|
|
525
|
-
response
|
|
526
|
-
} = {}) {
|
|
514
|
+
presign(path, optio2ns = {}) {
|
|
515
|
+
const contentLength = optio2ns.contentLength ?? void 0;
|
|
527
516
|
if (typeof contentLength === "number") {
|
|
528
517
|
if (contentLength < 0) {
|
|
529
518
|
throw new RangeError("`contentLength` must be >= 0.");
|
|
530
519
|
}
|
|
531
520
|
}
|
|
521
|
+
const method = optio2ns.method ?? "GET";
|
|
522
|
+
const contentType = optio2ns.type ?? void 0;
|
|
523
|
+
const region = optio2ns.region ?? this.#options.region;
|
|
524
|
+
const bucket = optio2ns.bucket ?? this.#options.bucket;
|
|
525
|
+
const endpoint = optio2ns.endpoint ?? this.#options.endpoint;
|
|
526
|
+
const responseOptions = optio2ns.response;
|
|
527
|
+
const contentDisposition = responseOptions?.contentDisposition;
|
|
528
|
+
const responseContentDisposition = contentDisposition ? getContentDispositionHeader(contentDisposition) : void 0;
|
|
529
|
+
const res = buildRequestUrl(endpoint, bucket, region, path);
|
|
532
530
|
const now2 = /* @__PURE__ */ new Date();
|
|
533
531
|
const date = getAmzDate(now2);
|
|
534
|
-
const options = this.#options;
|
|
535
|
-
const region = regionOverride ?? options.region;
|
|
536
|
-
const bucket = bucketOverride ?? options.bucket;
|
|
537
|
-
const endpoint = endpointOverride ?? options.endpoint;
|
|
538
|
-
const responseContentDisposition = response?.contentDisposition ? getContentDispositionHeader(response?.contentDisposition) : void 0;
|
|
539
|
-
const res = buildRequestUrl(endpoint, bucket, region, path);
|
|
540
532
|
const query = buildSearchParams(
|
|
541
|
-
`${options.accessKeyId}/${date.date}/${region}/s3/aws4_request`,
|
|
533
|
+
`${this.#options.accessKeyId}/${date.date}/${region}/s3/aws4_request`,
|
|
542
534
|
date,
|
|
543
|
-
expiresIn,
|
|
544
|
-
typeof contentLength === "number" || typeof
|
|
535
|
+
optio2ns.expiresIn ?? 3600,
|
|
536
|
+
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",
|
|
545
537
|
unsignedPayload,
|
|
546
|
-
storageClass,
|
|
547
|
-
options.sessionToken,
|
|
548
|
-
acl,
|
|
538
|
+
optio2ns.storageClass,
|
|
539
|
+
this.#options.sessionToken,
|
|
540
|
+
optio2ns.acl,
|
|
549
541
|
responseContentDisposition
|
|
550
542
|
);
|
|
551
|
-
const dataDigest = typeof contentLength === "number" || typeof
|
|
543
|
+
const dataDigest = typeof contentLength === "number" || typeof contentType === "string" ? createCanonicalDataDigest(
|
|
552
544
|
method,
|
|
553
545
|
res.pathname,
|
|
554
546
|
query,
|
|
555
|
-
typeof contentLength === "number" && typeof
|
|
547
|
+
typeof contentLength === "number" && typeof contentType === "string" ? {
|
|
556
548
|
"content-length": String(contentLength),
|
|
557
|
-
"content-type":
|
|
549
|
+
"content-type": contentType,
|
|
558
550
|
host: res.host
|
|
559
|
-
} : typeof contentLength === "number" ? { "content-length": String(contentLength), host: res.host } : typeof
|
|
551
|
+
} : typeof contentLength === "number" ? { "content-length": String(contentLength), host: res.host } : typeof contentType === "string" ? { "content-type": contentType, host: res.host } : {},
|
|
560
552
|
unsignedPayload
|
|
561
553
|
) : createCanonicalDataDigestHostOnly(
|
|
562
554
|
method,
|
|
@@ -567,8 +559,8 @@ var S3Client = class {
|
|
|
567
559
|
const signingKey = this.#keyCache.computeIfAbsent(
|
|
568
560
|
date,
|
|
569
561
|
region,
|
|
570
|
-
options.accessKeyId,
|
|
571
|
-
options.secretAccessKey
|
|
562
|
+
this.#options.accessKeyId,
|
|
563
|
+
this.#options.secretAccessKey
|
|
572
564
|
);
|
|
573
565
|
const signature = signCanonicalDataHash(
|
|
574
566
|
signingKey,
|