@aws-sdk/middleware-flexible-checksums 3.749.0 → 3.750.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-cjs/index.js +14 -9
- package/dist-es/flexibleChecksumsMiddleware.js +4 -1
- package/dist-es/resolveFlexibleChecksumsConfig.js +1 -0
- package/dist-types/configuration.d.ts +4 -0
- package/dist-types/resolveFlexibleChecksumsConfig.d.ts +17 -0
- package/dist-types/ts3.4/configuration.d.ts +1 -0
- package/dist-types/ts3.4/resolveFlexibleChecksumsConfig.d.ts +2 -0
- package/package.json +3 -3
package/dist-cjs/index.js
CHANGED
|
@@ -130,6 +130,7 @@ var crc64NvmeCrtContainer = {
|
|
|
130
130
|
// src/flexibleChecksumsMiddleware.ts
|
|
131
131
|
var import_core = require("@aws-sdk/core");
|
|
132
132
|
var import_protocol_http = require("@smithy/protocol-http");
|
|
133
|
+
var import_util_stream = require("@smithy/util-stream");
|
|
133
134
|
|
|
134
135
|
// src/types.ts
|
|
135
136
|
var CLIENT_SUPPORTED_ALGORITHMS = [
|
|
@@ -288,13 +289,16 @@ var flexibleChecksumsMiddleware = /* @__PURE__ */ __name((config, middlewareConf
|
|
|
288
289
|
const checksumAlgorithmFn = selectChecksumAlgorithmFunction(checksumAlgorithm, config);
|
|
289
290
|
if (isStreaming(requestBody)) {
|
|
290
291
|
const { getAwsChunkedEncodingStream, bodyLengthChecker } = config;
|
|
291
|
-
updatedBody = getAwsChunkedEncodingStream(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
292
|
+
updatedBody = getAwsChunkedEncodingStream(
|
|
293
|
+
typeof config.requestStreamBufferSize === "number" && config.requestStreamBufferSize >= 8 * 1024 ? (0, import_util_stream.createBufferedReadable)(requestBody, config.requestStreamBufferSize, context.logger) : requestBody,
|
|
294
|
+
{
|
|
295
|
+
base64Encoder,
|
|
296
|
+
bodyLengthChecker,
|
|
297
|
+
checksumLocationName,
|
|
298
|
+
checksumAlgorithmFn,
|
|
299
|
+
streamHasher
|
|
300
|
+
}
|
|
301
|
+
);
|
|
298
302
|
updatedHeaders = {
|
|
299
303
|
...headers,
|
|
300
304
|
"content-encoding": headers["content-encoding"] ? `${headers["content-encoding"]},aws-chunked` : "aws-chunked",
|
|
@@ -392,7 +396,7 @@ var isChecksumWithPartNumber = /* @__PURE__ */ __name((checksum) => {
|
|
|
392
396
|
}, "isChecksumWithPartNumber");
|
|
393
397
|
|
|
394
398
|
// src/validateChecksumFromResponse.ts
|
|
395
|
-
|
|
399
|
+
|
|
396
400
|
|
|
397
401
|
// src/getChecksum.ts
|
|
398
402
|
var getChecksum = /* @__PURE__ */ __name(async (body, { checksumAlgorithmFn, base64Encoder }) => base64Encoder(await stringHasher(checksumAlgorithmFn, body)), "getChecksum");
|
|
@@ -496,7 +500,8 @@ var resolveFlexibleChecksumsConfig = /* @__PURE__ */ __name((input) => ({
|
|
|
496
500
|
),
|
|
497
501
|
responseChecksumValidation: (0, import_util_middleware.normalizeProvider)(
|
|
498
502
|
input.responseChecksumValidation ?? DEFAULT_RESPONSE_CHECKSUM_VALIDATION
|
|
499
|
-
)
|
|
503
|
+
),
|
|
504
|
+
requestStreamBufferSize: Number(input.requestStreamBufferSize ?? 0)
|
|
500
505
|
}), "resolveFlexibleChecksumsConfig");
|
|
501
506
|
// Annotate the CommonJS export names for ESM import in node:
|
|
502
507
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { setFeature } from "@aws-sdk/core";
|
|
2
2
|
import { HttpRequest } from "@smithy/protocol-http";
|
|
3
|
+
import { createBufferedReadable } from "@smithy/util-stream";
|
|
3
4
|
import { ChecksumAlgorithm, DEFAULT_CHECKSUM_ALGORITHM, RequestChecksumCalculation } from "./constants";
|
|
4
5
|
import { getChecksumAlgorithmForRequest } from "./getChecksumAlgorithmForRequest";
|
|
5
6
|
import { getChecksumLocationName } from "./getChecksumLocationName";
|
|
@@ -65,7 +66,9 @@ export const flexibleChecksumsMiddleware = (config, middlewareConfig) => (next,
|
|
|
65
66
|
const checksumAlgorithmFn = selectChecksumAlgorithmFunction(checksumAlgorithm, config);
|
|
66
67
|
if (isStreaming(requestBody)) {
|
|
67
68
|
const { getAwsChunkedEncodingStream, bodyLengthChecker } = config;
|
|
68
|
-
updatedBody = getAwsChunkedEncodingStream(
|
|
69
|
+
updatedBody = getAwsChunkedEncodingStream(typeof config.requestStreamBufferSize === "number" && config.requestStreamBufferSize >= 8 * 1024
|
|
70
|
+
? createBufferedReadable(requestBody, config.requestStreamBufferSize, context.logger)
|
|
71
|
+
: requestBody, {
|
|
69
72
|
base64Encoder,
|
|
70
73
|
bodyLengthChecker,
|
|
71
74
|
checksumLocationName,
|
|
@@ -4,4 +4,5 @@ export const resolveFlexibleChecksumsConfig = (input) => ({
|
|
|
4
4
|
...input,
|
|
5
5
|
requestChecksumCalculation: normalizeProvider(input.requestChecksumCalculation ?? DEFAULT_REQUEST_CHECKSUM_CALCULATION),
|
|
6
6
|
responseChecksumValidation: normalizeProvider(input.responseChecksumValidation ?? DEFAULT_RESPONSE_CHECKSUM_VALIDATION),
|
|
7
|
+
requestStreamBufferSize: Number(input.requestStreamBufferSize ?? 0),
|
|
7
8
|
});
|
|
@@ -46,4 +46,8 @@ export interface PreviouslyResolved {
|
|
|
46
46
|
* Collects streams into buffers.
|
|
47
47
|
*/
|
|
48
48
|
streamCollector: StreamCollector;
|
|
49
|
+
/**
|
|
50
|
+
* Minimum bytes from a stream to buffer into a chunk before passing to chunked encoding.
|
|
51
|
+
*/
|
|
52
|
+
requestStreamBufferSize: number;
|
|
49
53
|
}
|
|
@@ -9,9 +9,26 @@ export interface FlexibleChecksumsInputConfig {
|
|
|
9
9
|
* Determines when checksum validation will be performed on response payloads.
|
|
10
10
|
*/
|
|
11
11
|
responseChecksumValidation?: ResponseChecksumValidation | Provider<ResponseChecksumValidation>;
|
|
12
|
+
/**
|
|
13
|
+
* Default 0 (off).
|
|
14
|
+
*
|
|
15
|
+
* When set to a value greater than or equal to 8192, sets the minimum number
|
|
16
|
+
* of bytes to buffer into a chunk when processing input streams
|
|
17
|
+
* with chunked encoding (that is, when request checksums are enabled).
|
|
18
|
+
* A minimum of 8kb = 8 * 1024 is required, and 64kb or higher is recommended.
|
|
19
|
+
*
|
|
20
|
+
* See https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html.
|
|
21
|
+
*
|
|
22
|
+
* This has a slight performance penalty because it must wrap and buffer
|
|
23
|
+
* your input stream.
|
|
24
|
+
* You do not need to set this value if your stream already flows chunks
|
|
25
|
+
* of 8kb or greater.
|
|
26
|
+
*/
|
|
27
|
+
requestStreamBufferSize?: number | false;
|
|
12
28
|
}
|
|
13
29
|
export interface FlexibleChecksumsResolvedConfig {
|
|
14
30
|
requestChecksumCalculation: Provider<RequestChecksumCalculation>;
|
|
15
31
|
responseChecksumValidation: Provider<ResponseChecksumValidation>;
|
|
32
|
+
requestStreamBufferSize: number;
|
|
16
33
|
}
|
|
17
34
|
export declare const resolveFlexibleChecksumsConfig: <T>(input: T & FlexibleChecksumsInputConfig) => T & FlexibleChecksumsResolvedConfig;
|
|
@@ -10,10 +10,12 @@ export interface FlexibleChecksumsInputConfig {
|
|
|
10
10
|
responseChecksumValidation?:
|
|
11
11
|
| ResponseChecksumValidation
|
|
12
12
|
| Provider<ResponseChecksumValidation>;
|
|
13
|
+
requestStreamBufferSize?: number | false;
|
|
13
14
|
}
|
|
14
15
|
export interface FlexibleChecksumsResolvedConfig {
|
|
15
16
|
requestChecksumCalculation: Provider<RequestChecksumCalculation>;
|
|
16
17
|
responseChecksumValidation: Provider<ResponseChecksumValidation>;
|
|
18
|
+
requestStreamBufferSize: number;
|
|
17
19
|
}
|
|
18
20
|
export declare const resolveFlexibleChecksumsConfig: <T>(
|
|
19
21
|
input: T & FlexibleChecksumsInputConfig
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-flexible-checksums",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.750.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline middleware-flexible-checksums",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"@aws-crypto/crc32": "5.2.0",
|
|
36
36
|
"@aws-crypto/crc32c": "5.2.0",
|
|
37
37
|
"@aws-crypto/util": "5.2.0",
|
|
38
|
-
"@aws-sdk/core": "3.
|
|
38
|
+
"@aws-sdk/core": "3.750.0",
|
|
39
39
|
"@aws-sdk/types": "3.734.0",
|
|
40
40
|
"@smithy/is-array-buffer": "^4.0.0",
|
|
41
41
|
"@smithy/node-config-provider": "^4.0.1",
|
|
42
42
|
"@smithy/protocol-http": "^5.0.1",
|
|
43
43
|
"@smithy/types": "^4.1.0",
|
|
44
44
|
"@smithy/util-middleware": "^4.0.1",
|
|
45
|
-
"@smithy/util-stream": "^4.1.
|
|
45
|
+
"@smithy/util-stream": "^4.1.1",
|
|
46
46
|
"@smithy/util-utf8": "^4.0.0",
|
|
47
47
|
"tslib": "^2.6.2"
|
|
48
48
|
},
|