@aws-sdk/middleware-sdk-s3 3.972.32 → 3.972.34
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-cjs/index.js +9 -25
- package/dist-cjs/toStream.browser.js +11 -0
- package/dist-cjs/toStream.js +7 -0
- package/dist-es/throw-200-exceptions.js +9 -25
- package/dist-es/toStream.browser.js +8 -0
- package/dist-es/toStream.js +4 -0
- package/dist-types/throw-200-exceptions.d.ts +2 -1
- package/dist-types/toStream.browser.d.ts +4 -0
- package/dist-types/toStream.d.ts +5 -0
- package/dist-types/ts3.4/throw-200-exceptions.d.ts +2 -0
- package/dist-types/ts3.4/toStream.browser.d.ts +1 -0
- package/dist-types/ts3.4/toStream.d.ts +2 -0
- package/package.json +15 -8
package/dist-cjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var protocolHttp = require('@smithy/protocol-http');
|
|
4
4
|
var smithyClient = require('@smithy/smithy-client');
|
|
5
|
-
var
|
|
5
|
+
var toStream = require('./toStream');
|
|
6
6
|
var utilArnParser = require('@aws-sdk/util-arn-parser');
|
|
7
7
|
var protocols = require('@aws-sdk/core/protocols');
|
|
8
8
|
var schema = require('@smithy/core/schema');
|
|
@@ -419,45 +419,29 @@ const THROW_IF_EMPTY_BODY = {
|
|
|
419
419
|
UploadPartCopyCommand: true,
|
|
420
420
|
CompleteMultipartUploadCommand: true,
|
|
421
421
|
};
|
|
422
|
-
const MAX_BYTES_TO_INSPECT = 3000;
|
|
423
422
|
const throw200ExceptionsMiddleware = (config) => (next, context) => async (args) => {
|
|
424
423
|
const result = await next(args);
|
|
425
424
|
const { response } = result;
|
|
426
425
|
if (!protocolHttp.HttpResponse.isInstance(response)) {
|
|
427
426
|
return result;
|
|
428
427
|
}
|
|
429
|
-
const { statusCode, body
|
|
428
|
+
const { statusCode, body } = response;
|
|
430
429
|
if (statusCode < 200 || statusCode >= 300) {
|
|
431
430
|
return result;
|
|
432
431
|
}
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
typeof sourceBody?.tee === "function";
|
|
436
|
-
if (!isSplittableStream) {
|
|
437
|
-
return result;
|
|
438
|
-
}
|
|
439
|
-
let bodyCopy = sourceBody;
|
|
440
|
-
let body = sourceBody;
|
|
441
|
-
if (sourceBody && typeof sourceBody === "object" && !(sourceBody instanceof Uint8Array)) {
|
|
442
|
-
[bodyCopy, body] = await utilStream.splitStream(sourceBody);
|
|
443
|
-
}
|
|
444
|
-
response.body = body;
|
|
445
|
-
const bodyBytes = await collectBody(bodyCopy, {
|
|
446
|
-
streamCollector: async (stream) => {
|
|
447
|
-
return utilStream.headStream(stream, MAX_BYTES_TO_INSPECT);
|
|
448
|
-
},
|
|
449
|
-
});
|
|
450
|
-
if (typeof bodyCopy?.destroy === "function") {
|
|
451
|
-
bodyCopy.destroy();
|
|
452
|
-
}
|
|
453
|
-
const bodyStringTail = config.utf8Encoder(bodyBytes.subarray(bodyBytes.length - 16));
|
|
432
|
+
const bodyBytes = await collectBody(body, config);
|
|
433
|
+
response.body = toStream.toStream(bodyBytes);
|
|
454
434
|
if (bodyBytes.length === 0 && THROW_IF_EMPTY_BODY[context.commandName]) {
|
|
455
435
|
const err = new Error("S3 aborted request");
|
|
436
|
+
err.$metadata = {
|
|
437
|
+
httpStatusCode: 503,
|
|
438
|
+
};
|
|
456
439
|
err.name = "InternalError";
|
|
457
440
|
throw err;
|
|
458
441
|
}
|
|
442
|
+
const bodyStringTail = config.utf8Encoder(bodyBytes.subarray(bodyBytes.length - 16));
|
|
459
443
|
if (bodyStringTail && bodyStringTail.endsWith("</Error>")) {
|
|
460
|
-
response.statusCode =
|
|
444
|
+
response.statusCode = 503;
|
|
461
445
|
}
|
|
462
446
|
return result;
|
|
463
447
|
};
|
|
@@ -1,49 +1,33 @@
|
|
|
1
1
|
import { HttpResponse } from "@smithy/protocol-http";
|
|
2
|
-
import {
|
|
2
|
+
import { toStream } from "./toStream";
|
|
3
3
|
const THROW_IF_EMPTY_BODY = {
|
|
4
4
|
CopyObjectCommand: true,
|
|
5
5
|
UploadPartCopyCommand: true,
|
|
6
6
|
CompleteMultipartUploadCommand: true,
|
|
7
7
|
};
|
|
8
|
-
const MAX_BYTES_TO_INSPECT = 3000;
|
|
9
8
|
export const throw200ExceptionsMiddleware = (config) => (next, context) => async (args) => {
|
|
10
9
|
const result = await next(args);
|
|
11
10
|
const { response } = result;
|
|
12
11
|
if (!HttpResponse.isInstance(response)) {
|
|
13
12
|
return result;
|
|
14
13
|
}
|
|
15
|
-
const { statusCode, body
|
|
14
|
+
const { statusCode, body } = response;
|
|
16
15
|
if (statusCode < 200 || statusCode >= 300) {
|
|
17
16
|
return result;
|
|
18
17
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
typeof sourceBody?.tee === "function";
|
|
22
|
-
if (!isSplittableStream) {
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
let bodyCopy = sourceBody;
|
|
26
|
-
let body = sourceBody;
|
|
27
|
-
if (sourceBody && typeof sourceBody === "object" && !(sourceBody instanceof Uint8Array)) {
|
|
28
|
-
[bodyCopy, body] = await splitStream(sourceBody);
|
|
29
|
-
}
|
|
30
|
-
response.body = body;
|
|
31
|
-
const bodyBytes = await collectBody(bodyCopy, {
|
|
32
|
-
streamCollector: async (stream) => {
|
|
33
|
-
return headStream(stream, MAX_BYTES_TO_INSPECT);
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
if (typeof bodyCopy?.destroy === "function") {
|
|
37
|
-
bodyCopy.destroy();
|
|
38
|
-
}
|
|
39
|
-
const bodyStringTail = config.utf8Encoder(bodyBytes.subarray(bodyBytes.length - 16));
|
|
18
|
+
const bodyBytes = await collectBody(body, config);
|
|
19
|
+
response.body = toStream(bodyBytes);
|
|
40
20
|
if (bodyBytes.length === 0 && THROW_IF_EMPTY_BODY[context.commandName]) {
|
|
41
21
|
const err = new Error("S3 aborted request");
|
|
22
|
+
err.$metadata = {
|
|
23
|
+
httpStatusCode: 503,
|
|
24
|
+
};
|
|
42
25
|
err.name = "InternalError";
|
|
43
26
|
throw err;
|
|
44
27
|
}
|
|
28
|
+
const bodyStringTail = config.utf8Encoder(bodyBytes.subarray(bodyBytes.length - 16));
|
|
45
29
|
if (bodyStringTail && bodyStringTail.endsWith("</Error>")) {
|
|
46
|
-
response.statusCode =
|
|
30
|
+
response.statusCode = 503;
|
|
47
31
|
}
|
|
48
32
|
return result;
|
|
49
33
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { DeserializeMiddleware, Encoder, Pluggable, RelativeMiddlewareOptions } from "@smithy/types";
|
|
1
|
+
import type { DeserializeMiddleware, Encoder, Pluggable, RelativeMiddlewareOptions, StreamCollector } from "@smithy/types";
|
|
2
2
|
type PreviouslyResolved = {
|
|
3
|
+
streamCollector: StreamCollector;
|
|
3
4
|
utf8Encoder: Encoder;
|
|
4
5
|
};
|
|
5
6
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toStream(bytes: Uint8Array): ReadableStream;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-sdk-s3",
|
|
3
|
-
"version": "3.972.
|
|
3
|
+
"version": "3.972.34",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline middleware-sdk-s3",
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"build:types": "tsc -p tsconfig.types.json",
|
|
10
10
|
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
11
11
|
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
|
|
12
|
-
"test": "yarn g:vitest run",
|
|
13
12
|
"test:types": "tsc -p tsconfig.test.json",
|
|
14
|
-
"test:integration": "yarn g:vitest run -c vitest.config.integ.mts && yarn test:types",
|
|
15
|
-
"test:e2e": "yarn g:vitest run -c vitest.config.e2e.mts --mode development",
|
|
16
13
|
"extract:docs": "api-extractor run --local",
|
|
14
|
+
"test": "yarn g:vitest run",
|
|
17
15
|
"test:watch": "yarn g:vitest watch",
|
|
16
|
+
"test:integration": "yarn g:vitest run -c vitest.config.integ.mts && yarn test:types",
|
|
18
17
|
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts",
|
|
18
|
+
"test:e2e": "yarn g:vitest run -c vitest.config.e2e.mts --mode development",
|
|
19
19
|
"test:e2e:watch": "yarn g:vitest watch -c vitest.config.e2e.mts"
|
|
20
20
|
},
|
|
21
21
|
"main": "./dist-cjs/index.js",
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
},
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aws-sdk/core": "^3.974.
|
|
31
|
+
"@aws-sdk/core": "^3.974.5",
|
|
32
32
|
"@aws-sdk/types": "^3.973.8",
|
|
33
33
|
"@aws-sdk/util-arn-parser": "^3.972.3",
|
|
34
|
-
"@smithy/core": "^3.23.
|
|
34
|
+
"@smithy/core": "^3.23.17",
|
|
35
35
|
"@smithy/node-config-provider": "^4.3.14",
|
|
36
36
|
"@smithy/protocol-http": "^5.3.14",
|
|
37
37
|
"@smithy/signature-v4": "^5.3.14",
|
|
38
|
-
"@smithy/smithy-client": "^4.12.
|
|
38
|
+
"@smithy/smithy-client": "^4.12.13",
|
|
39
39
|
"@smithy/types": "^4.14.1",
|
|
40
40
|
"@smithy/util-config-provider": "^4.2.2",
|
|
41
41
|
"@smithy/util-middleware": "^4.2.14",
|
|
42
|
-
"@smithy/util-stream": "^4.5.
|
|
42
|
+
"@smithy/util-stream": "^4.5.25",
|
|
43
43
|
"@smithy/util-utf8": "^4.2.2",
|
|
44
44
|
"tslib": "^2.6.2"
|
|
45
45
|
},
|
|
@@ -63,6 +63,13 @@
|
|
|
63
63
|
"files": [
|
|
64
64
|
"dist-*/**"
|
|
65
65
|
],
|
|
66
|
+
"browser": {
|
|
67
|
+
"./dist-es/toStream": "./dist-es/toStream.browser"
|
|
68
|
+
},
|
|
69
|
+
"react-native": {
|
|
70
|
+
"./dist-es/toStream": "./dist-es/toStream.browser",
|
|
71
|
+
"./dist-cjs/toStream": "./dist-cjs/toStream.browser"
|
|
72
|
+
},
|
|
66
73
|
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages-internal/middleware-sdk-s3",
|
|
67
74
|
"repository": {
|
|
68
75
|
"type": "git",
|