lean-s3 0.9.13 → 0.9.23
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 +2 -2
- package/dist/index.mjs +27 -18
- package/package.json +19 -20
package/dist/index.d.mts
CHANGED
|
@@ -523,11 +523,11 @@ declare class S3Client {
|
|
|
523
523
|
*/
|
|
524
524
|
[kSignedRequest](region: Region, endpoint: Endpoint, bucket: BucketName, method: HttpMethod, pathWithoutBucket: ObjectKey, query: string | undefined, body: string | Buffer | Uint8Array | Readable | undefined, additionalSignedHeaders: Record<string, string> | undefined, additionalUnsignedHeaders: Record<string, string> | undefined, contentHash: Buffer | undefined, signal: AbortSignal | undefined): Promise<Dispatcher.ResponseData<null>>;
|
|
525
525
|
/** @internal */
|
|
526
|
-
[kWrite](path: ObjectKey, data: string | Buffer | Uint8Array | Readable, contentType: string, contentLength: number | undefined, contentHash: Buffer | undefined,
|
|
526
|
+
[kWrite](path: ObjectKey, data: string | Buffer | Uint8Array | Readable, contentType: string, contentLength: number | undefined, contentHash: Buffer | undefined, rangeStart: number | undefined, rangeEndExclusive: number | undefined, signal?: AbortSignal): Promise<void>;
|
|
527
527
|
/**
|
|
528
528
|
* @internal
|
|
529
529
|
*/
|
|
530
|
-
[kStream](path: ObjectKey, contentHash: Buffer | undefined,
|
|
530
|
+
[kStream](path: ObjectKey, contentHash: Buffer | undefined, rangeStart: number | undefined, rangeEndExclusive: number | undefined, signal?: AbortSignal): ReadableStream<Uint8Array>;
|
|
531
531
|
[nodeUtil.inspect.custom](_depth?: number, options?: nodeUtil.InspectOptions): string;
|
|
532
532
|
}
|
|
533
533
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -38,7 +38,7 @@ var S3Error = class extends Error {
|
|
|
38
38
|
message;
|
|
39
39
|
/** The HTTP status code. */
|
|
40
40
|
status;
|
|
41
|
-
constructor(code, path, { message
|
|
41
|
+
constructor(code, path, { message, cause, status } = {}) {
|
|
42
42
|
super(message, { cause });
|
|
43
43
|
this.code = code;
|
|
44
44
|
this.path = path;
|
|
@@ -207,8 +207,14 @@ async function getResponseError(response, path) {
|
|
|
207
207
|
}
|
|
208
208
|
function fromStatusCode(code, path) {
|
|
209
209
|
switch (code) {
|
|
210
|
-
case 404: return new S3Error("NoSuchKey", path, {
|
|
211
|
-
|
|
210
|
+
case 404: return new S3Error("NoSuchKey", path, {
|
|
211
|
+
message: "The specified key does not exist.",
|
|
212
|
+
status: code
|
|
213
|
+
});
|
|
214
|
+
case 403: return new S3Error("AccessDenied", path, {
|
|
215
|
+
message: "Access denied to the key.",
|
|
216
|
+
status: code
|
|
217
|
+
});
|
|
212
218
|
default: return;
|
|
213
219
|
}
|
|
214
220
|
}
|
|
@@ -909,11 +915,11 @@ var S3Client = class {
|
|
|
909
915
|
async [kSignedRequest](region, endpoint, bucket, method, pathWithoutBucket, query, body, additionalSignedHeaders, additionalUnsignedHeaders, contentHash, signal) {
|
|
910
916
|
const url = buildRequestUrl(endpoint, bucket, region, pathWithoutBucket);
|
|
911
917
|
if (query) url.search = query;
|
|
912
|
-
const now$
|
|
918
|
+
const now$2 = now();
|
|
913
919
|
const contentHashStr = contentHash?.toString("hex") ?? "UNSIGNED-PAYLOAD";
|
|
914
920
|
const headersToBeSigned = prepareHeadersForSigning({
|
|
915
921
|
host: url.host,
|
|
916
|
-
"x-amz-date": now$
|
|
922
|
+
"x-amz-date": now$2.dateTime,
|
|
917
923
|
"x-amz-content-sha256": contentHashStr,
|
|
918
924
|
...additionalSignedHeaders
|
|
919
925
|
});
|
|
@@ -924,7 +930,7 @@ var S3Client = class {
|
|
|
924
930
|
dispatcher: this.#dispatcher,
|
|
925
931
|
headers: {
|
|
926
932
|
...headersToBeSigned,
|
|
927
|
-
authorization: getAuthorizationHeader(this.#keyCache, method, url.pathname, query ?? "", now$
|
|
933
|
+
authorization: getAuthorizationHeader(this.#keyCache, method, url.pathname, query ?? "", now$2, headersToBeSigned, region, contentHashStr, this.#options.accessKeyId, this.#options.secretAccessKey),
|
|
928
934
|
...additionalUnsignedHeaders,
|
|
929
935
|
"user-agent": "lean-s3"
|
|
930
936
|
},
|
|
@@ -939,20 +945,20 @@ var S3Client = class {
|
|
|
939
945
|
}
|
|
940
946
|
}
|
|
941
947
|
/** @internal */
|
|
942
|
-
async [kWrite](path, data, contentType, contentLength, contentHash,
|
|
948
|
+
async [kWrite](path, data, contentType, contentLength, contentHash, rangeStart, rangeEndExclusive, signal) {
|
|
943
949
|
const bucket = this.#options.bucket;
|
|
944
950
|
const endpoint = this.#options.endpoint;
|
|
945
951
|
const region = this.#options.region;
|
|
946
952
|
const url = buildRequestUrl(endpoint, bucket, region, path);
|
|
947
|
-
const now$
|
|
953
|
+
const now$3 = now();
|
|
948
954
|
const contentHashStr = contentHash?.toString("hex") ?? "UNSIGNED-PAYLOAD";
|
|
949
955
|
const headersToBeSigned = prepareHeadersForSigning({
|
|
950
956
|
"content-length": contentLength?.toString() ?? void 0,
|
|
951
957
|
"content-type": contentType,
|
|
952
958
|
host: url.host,
|
|
953
|
-
range: getRangeHeader(
|
|
959
|
+
range: getRangeHeader(rangeStart, rangeEndExclusive),
|
|
954
960
|
"x-amz-content-sha256": contentHashStr,
|
|
955
|
-
"x-amz-date": now$
|
|
961
|
+
"x-amz-date": now$3.dateTime
|
|
956
962
|
});
|
|
957
963
|
let response;
|
|
958
964
|
try {
|
|
@@ -962,7 +968,7 @@ var S3Client = class {
|
|
|
962
968
|
dispatcher: this.#dispatcher,
|
|
963
969
|
headers: {
|
|
964
970
|
...headersToBeSigned,
|
|
965
|
-
authorization: getAuthorizationHeader(this.#keyCache, "PUT", url.pathname, url.search, now$
|
|
971
|
+
authorization: getAuthorizationHeader(this.#keyCache, "PUT", url.pathname, url.search, now$3, headersToBeSigned, region, contentHashStr, this.#options.accessKeyId, this.#options.secretAccessKey),
|
|
966
972
|
"user-agent": "lean-s3"
|
|
967
973
|
},
|
|
968
974
|
body: data
|
|
@@ -975,26 +981,29 @@ var S3Client = class {
|
|
|
975
981
|
});
|
|
976
982
|
}
|
|
977
983
|
const status = response.statusCode;
|
|
978
|
-
if (200 <= status && status < 300)
|
|
984
|
+
if (200 <= status && status < 300) {
|
|
985
|
+
response.body.dump();
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
979
988
|
throw await getResponseError(response, path);
|
|
980
989
|
}
|
|
981
990
|
/**
|
|
982
991
|
* @internal
|
|
983
992
|
*/
|
|
984
|
-
[kStream](path, contentHash,
|
|
993
|
+
[kStream](path, contentHash, rangeStart, rangeEndExclusive, signal) {
|
|
985
994
|
const bucket = this.#options.bucket;
|
|
986
995
|
const endpoint = this.#options.endpoint;
|
|
987
996
|
const region = this.#options.region;
|
|
988
|
-
const now$
|
|
997
|
+
const now$1 = now();
|
|
989
998
|
const url = buildRequestUrl(endpoint, bucket, region, path);
|
|
990
|
-
const range = getRangeHeader(
|
|
999
|
+
const range = getRangeHeader(rangeStart, rangeEndExclusive);
|
|
991
1000
|
const contentHashStr = contentHash?.toString("hex") ?? "UNSIGNED-PAYLOAD";
|
|
992
1001
|
const headersToBeSigned = prepareHeadersForSigning({
|
|
993
1002
|
"amz-sdk-invocation-id": crypto.randomUUID(),
|
|
994
1003
|
host: url.host,
|
|
995
1004
|
range,
|
|
996
1005
|
"x-amz-content-sha256": contentHashStr,
|
|
997
|
-
"x-amz-date": now$
|
|
1006
|
+
"x-amz-date": now$1.dateTime
|
|
998
1007
|
});
|
|
999
1008
|
const ac = new AbortController();
|
|
1000
1009
|
return new ReadableStream({
|
|
@@ -1008,11 +1017,11 @@ var S3Client = class {
|
|
|
1008
1017
|
};
|
|
1009
1018
|
request(url, {
|
|
1010
1019
|
method: "GET",
|
|
1011
|
-
signal: ac.signal,
|
|
1020
|
+
signal: signal ? AbortSignal.any([signal, ac.signal]) : ac.signal,
|
|
1012
1021
|
dispatcher: this.#dispatcher,
|
|
1013
1022
|
headers: {
|
|
1014
1023
|
...headersToBeSigned,
|
|
1015
|
-
authorization: getAuthorizationHeader(this.#keyCache, "GET", url.pathname, url.search, now$
|
|
1024
|
+
authorization: getAuthorizationHeader(this.#keyCache, "GET", url.pathname, url.search, now$1, headersToBeSigned, region, contentHashStr, this.#options.accessKeyId, this.#options.secretAccessKey),
|
|
1016
1025
|
"user-agent": "lean-s3"
|
|
1017
1026
|
}
|
|
1018
1027
|
}).then((response) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lean-s3",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.23",
|
|
4
4
|
"description": "A server-side S3 API for the regular user.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"AWS S3",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"types": "./dist/index.d.mts",
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsdown",
|
|
37
|
-
"test": "tsgo &&
|
|
38
|
-
"test:integration": "tsgo &&
|
|
37
|
+
"test": "tsgo && node --test src/*.test.ts src/test/*.test.ts",
|
|
38
|
+
"test:integration": "tsgo && node --test src/test/test.integration.ts",
|
|
39
39
|
"ci": "oxlint --type-aware --deny-warnings -f github",
|
|
40
40
|
"docs": "typedoc",
|
|
41
41
|
"format": "oxfmt",
|
|
@@ -44,26 +44,25 @@
|
|
|
44
44
|
"prepublishOnly": "npm run build"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"fast-xml-parser": "^5.
|
|
48
|
-
"undici": "^
|
|
47
|
+
"fast-xml-parser": "^5.8.0",
|
|
48
|
+
"undici": "^8.2.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@testcontainers/localstack": "^11.
|
|
52
|
-
"@testcontainers/minio": "^11.
|
|
53
|
-
"@testcontainers/s3mock": "^11.
|
|
54
|
-
"@types/node": "^25.
|
|
55
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
56
|
-
"expect": "^30.
|
|
57
|
-
"lefthook": "^2.1.
|
|
58
|
-
"oxfmt": "^0.
|
|
59
|
-
"oxlint": "^1.
|
|
60
|
-
"oxlint-tsgolint": "^0.
|
|
61
|
-
"testcontainers": "^11.
|
|
62
|
-
"tsdown": "^0.
|
|
63
|
-
"
|
|
64
|
-
"typedoc": "^0.28.17"
|
|
51
|
+
"@testcontainers/localstack": "^11.14.0",
|
|
52
|
+
"@testcontainers/minio": "^11.14.0",
|
|
53
|
+
"@testcontainers/s3mock": "^11.14.0",
|
|
54
|
+
"@types/node": "^25.7.0",
|
|
55
|
+
"@typescript/native-preview": "^7.0.0-dev.20260511.1",
|
|
56
|
+
"expect": "^30.4.1",
|
|
57
|
+
"lefthook": "^2.1.6",
|
|
58
|
+
"oxfmt": "^0.49.0",
|
|
59
|
+
"oxlint": "^1.64.0",
|
|
60
|
+
"oxlint-tsgolint": "^0.22.1",
|
|
61
|
+
"testcontainers": "^11.14.0",
|
|
62
|
+
"tsdown": "^0.22.0",
|
|
63
|
+
"typedoc": "^0.28.19"
|
|
65
64
|
},
|
|
66
65
|
"engines": {
|
|
67
|
-
"node": "^
|
|
66
|
+
"node": "^22.22.2 || ^24.15.0 || ^26.1.0"
|
|
68
67
|
}
|
|
69
68
|
}
|