@aws-sdk/middleware-flexible-checksums 3.53.0 → 3.55.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/CHANGELOG.md +24 -0
- package/dist-cjs/flexibleChecksumsMiddleware.js +7 -7
- package/dist-cjs/getChecksum.js +1 -1
- package/dist-cjs/getFlexibleChecksumsPlugin.js +1 -1
- package/dist-cjs/isStreaming.js +1 -1
- package/dist-cjs/validateChecksumFromResponse.js +4 -4
- package/dist-es/getChecksumAlgorithmForRequest.js +2 -2
- package/dist-es/getChecksumLocationName.js +1 -1
- package/dist-es/validateChecksumFromResponse.js +2 -2
- package/dist-types/configuration.d.ts +2 -2
- package/dist-types/ts3.4/configuration.d.ts +2 -2
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.55.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.54.1...v3.55.0) (2022-03-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/middleware-flexible-checksums
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.54.1](https://github.com/aws/aws-sdk-js-v3/compare/v3.54.0...v3.54.1) (2022-03-15)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @aws-sdk/middleware-flexible-checksums
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [3.54.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.53.1...v3.54.0) (2022-03-11)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @aws-sdk/middleware-flexible-checksums
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
# [3.53.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.52.0...v3.53.0) (2022-02-24)
|
|
7
31
|
|
|
8
32
|
|
|
@@ -17,16 +17,16 @@ const flexibleChecksumsMiddleware = (config, middlewareConfig) => (next) => asyn
|
|
|
17
17
|
const { body: requestBody, headers } = request;
|
|
18
18
|
const { base64Encoder, streamHasher } = config;
|
|
19
19
|
const { input, requestChecksumRequired, requestAlgorithmMember } = middlewareConfig;
|
|
20
|
-
const checksumAlgorithm = getChecksumAlgorithmForRequest_1.getChecksumAlgorithmForRequest(input, {
|
|
20
|
+
const checksumAlgorithm = (0, getChecksumAlgorithmForRequest_1.getChecksumAlgorithmForRequest)(input, {
|
|
21
21
|
requestChecksumRequired,
|
|
22
22
|
requestAlgorithmMember,
|
|
23
23
|
});
|
|
24
24
|
let updatedBody = requestBody;
|
|
25
25
|
let updatedHeaders = headers;
|
|
26
26
|
if (checksumAlgorithm) {
|
|
27
|
-
const checksumLocationName = getChecksumLocationName_1.getChecksumLocationName(checksumAlgorithm);
|
|
28
|
-
const checksumAlgorithmFn = selectChecksumAlgorithmFunction_1.selectChecksumAlgorithmFunction(checksumAlgorithm, config);
|
|
29
|
-
if (isStreaming_1.isStreaming(requestBody)) {
|
|
27
|
+
const checksumLocationName = (0, getChecksumLocationName_1.getChecksumLocationName)(checksumAlgorithm);
|
|
28
|
+
const checksumAlgorithmFn = (0, selectChecksumAlgorithmFunction_1.selectChecksumAlgorithmFunction)(checksumAlgorithm, config);
|
|
29
|
+
if ((0, isStreaming_1.isStreaming)(requestBody)) {
|
|
30
30
|
const { getAwsChunkedEncodingStream, bodyLengthChecker } = config;
|
|
31
31
|
updatedBody = getAwsChunkedEncodingStream(requestBody, {
|
|
32
32
|
base64Encoder,
|
|
@@ -45,8 +45,8 @@ const flexibleChecksumsMiddleware = (config, middlewareConfig) => (next) => asyn
|
|
|
45
45
|
};
|
|
46
46
|
delete updatedHeaders["content-length"];
|
|
47
47
|
}
|
|
48
|
-
else if (!hasHeader_1.hasHeader(checksumLocationName, headers)) {
|
|
49
|
-
const checksum = await getChecksum_1.getChecksum(requestBody, { streamHasher, checksumAlgorithmFn, base64Encoder });
|
|
48
|
+
else if (!(0, hasHeader_1.hasHeader)(checksumLocationName, headers)) {
|
|
49
|
+
const checksum = await (0, getChecksum_1.getChecksum)(requestBody, { streamHasher, checksumAlgorithmFn, base64Encoder });
|
|
50
50
|
updatedHeaders = {
|
|
51
51
|
...headers,
|
|
52
52
|
[checksumLocationName]: checksum,
|
|
@@ -63,7 +63,7 @@ const flexibleChecksumsMiddleware = (config, middlewareConfig) => (next) => asyn
|
|
|
63
63
|
});
|
|
64
64
|
const { requestValidationModeMember, responseAlgorithms } = middlewareConfig;
|
|
65
65
|
if (requestValidationModeMember && input[requestValidationModeMember] === "ENABLED") {
|
|
66
|
-
validateChecksumFromResponse_1.validateChecksumFromResponse(result.response, {
|
|
66
|
+
(0, validateChecksumFromResponse_1.validateChecksumFromResponse)(result.response, {
|
|
67
67
|
config,
|
|
68
68
|
responseAlgorithms,
|
|
69
69
|
});
|
package/dist-cjs/getChecksum.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.getChecksum = void 0;
|
|
|
4
4
|
const isStreaming_1 = require("./isStreaming");
|
|
5
5
|
const stringHasher_1 = require("./stringHasher");
|
|
6
6
|
const getChecksum = async (body, { streamHasher, checksumAlgorithmFn, base64Encoder }) => {
|
|
7
|
-
const digest = isStreaming_1.isStreaming(body) ? streamHasher(checksumAlgorithmFn, body) : stringHasher_1.stringHasher(checksumAlgorithmFn, body);
|
|
7
|
+
const digest = (0, isStreaming_1.isStreaming)(body) ? streamHasher(checksumAlgorithmFn, body) : (0, stringHasher_1.stringHasher)(checksumAlgorithmFn, body);
|
|
8
8
|
return base64Encoder(await digest);
|
|
9
9
|
};
|
|
10
10
|
exports.getChecksum = getChecksum;
|
|
@@ -10,7 +10,7 @@ exports.flexibleChecksumsMiddlewareOptions = {
|
|
|
10
10
|
};
|
|
11
11
|
const getFlexibleChecksumsPlugin = (config, middlewareConfig) => ({
|
|
12
12
|
applyToStack: (clientStack) => {
|
|
13
|
-
clientStack.add(flexibleChecksumsMiddleware_1.flexibleChecksumsMiddleware(config, middlewareConfig), exports.flexibleChecksumsMiddlewareOptions);
|
|
13
|
+
clientStack.add((0, flexibleChecksumsMiddleware_1.flexibleChecksumsMiddleware)(config, middlewareConfig), exports.flexibleChecksumsMiddlewareOptions);
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
exports.getFlexibleChecksumsPlugin = getFlexibleChecksumsPlugin;
|
package/dist-cjs/isStreaming.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isStreaming = void 0;
|
|
4
4
|
const is_array_buffer_1 = require("@aws-sdk/is-array-buffer");
|
|
5
|
-
const isStreaming = (body) => body !== undefined && typeof body !== "string" && !ArrayBuffer.isView(body) && !is_array_buffer_1.isArrayBuffer(body);
|
|
5
|
+
const isStreaming = (body) => body !== undefined && typeof body !== "string" && !ArrayBuffer.isView(body) && !(0, is_array_buffer_1.isArrayBuffer)(body);
|
|
6
6
|
exports.isStreaming = isStreaming;
|
|
@@ -6,15 +6,15 @@ const getChecksumAlgorithmListForResponse_1 = require("./getChecksumAlgorithmLis
|
|
|
6
6
|
const getChecksumLocationName_1 = require("./getChecksumLocationName");
|
|
7
7
|
const selectChecksumAlgorithmFunction_1 = require("./selectChecksumAlgorithmFunction");
|
|
8
8
|
const validateChecksumFromResponse = async (response, { config, responseAlgorithms }) => {
|
|
9
|
-
const checksumAlgorithms = getChecksumAlgorithmListForResponse_1.getChecksumAlgorithmListForResponse(responseAlgorithms);
|
|
9
|
+
const checksumAlgorithms = (0, getChecksumAlgorithmListForResponse_1.getChecksumAlgorithmListForResponse)(responseAlgorithms);
|
|
10
10
|
const { body: responseBody, headers: responseHeaders } = response;
|
|
11
11
|
for (const algorithm of checksumAlgorithms) {
|
|
12
|
-
const responseHeader = getChecksumLocationName_1.getChecksumLocationName(algorithm);
|
|
12
|
+
const responseHeader = (0, getChecksumLocationName_1.getChecksumLocationName)(algorithm);
|
|
13
13
|
const checksumFromResponse = responseHeaders[responseHeader];
|
|
14
14
|
if (checksumFromResponse) {
|
|
15
|
-
const checksumAlgorithmFn = selectChecksumAlgorithmFunction_1.selectChecksumAlgorithmFunction(algorithm, config);
|
|
15
|
+
const checksumAlgorithmFn = (0, selectChecksumAlgorithmFunction_1.selectChecksumAlgorithmFunction)(algorithm, config);
|
|
16
16
|
const { streamHasher, base64Encoder } = config;
|
|
17
|
-
const checksum = await getChecksum_1.getChecksum(responseBody, { streamHasher, checksumAlgorithmFn, base64Encoder });
|
|
17
|
+
const checksum = await (0, getChecksum_1.getChecksum)(responseBody, { streamHasher, checksumAlgorithmFn, base64Encoder });
|
|
18
18
|
if (checksum === checksumFromResponse) {
|
|
19
19
|
break;
|
|
20
20
|
}
|
|
@@ -7,8 +7,8 @@ export var getChecksumAlgorithmForRequest = function (input, _a) {
|
|
|
7
7
|
}
|
|
8
8
|
var checksumAlgorithm = input[requestAlgorithmMember];
|
|
9
9
|
if (!CLIENT_SUPPORTED_ALGORITHMS.includes(checksumAlgorithm)) {
|
|
10
|
-
throw new Error("The checksum algorithm \""
|
|
11
|
-
|
|
10
|
+
throw new Error("The checksum algorithm \"".concat(checksumAlgorithm, "\" is not supported by the client.") +
|
|
11
|
+
" Select one of ".concat(CLIENT_SUPPORTED_ALGORITHMS, "."));
|
|
12
12
|
}
|
|
13
13
|
return checksumAlgorithm;
|
|
14
14
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ChecksumAlgorithm } from "./constants";
|
|
2
2
|
export var getChecksumLocationName = function (algorithm) {
|
|
3
|
-
return algorithm === ChecksumAlgorithm.MD5 ? "content-md5" : "x-amz-checksum-"
|
|
3
|
+
return algorithm === ChecksumAlgorithm.MD5 ? "content-md5" : "x-amz-checksum-".concat(algorithm.toLowerCase());
|
|
4
4
|
};
|
|
@@ -32,8 +32,8 @@ export var validateChecksumFromResponse = function (response, _a) {
|
|
|
32
32
|
if (checksum === checksumFromResponse) {
|
|
33
33
|
return [3, 5];
|
|
34
34
|
}
|
|
35
|
-
throw new Error("Checksum mismatch: expected \""
|
|
36
|
-
|
|
35
|
+
throw new Error("Checksum mismatch: expected \"".concat(checksum, "\" but received \"").concat(checksumFromResponse, "\"") +
|
|
36
|
+
" in response header \"".concat(responseHeader, "\"."));
|
|
37
37
|
case 4:
|
|
38
38
|
checksumAlgorithms_1_1 = checksumAlgorithms_1.next();
|
|
39
39
|
return [3, 2];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Encoder, GetAwsChunkedEncodingStream, HashConstructor, StreamHasher } from "@aws-sdk/types";
|
|
1
|
+
import { BodyLengthCalculator, Encoder, GetAwsChunkedEncodingStream, HashConstructor, StreamHasher } from "@aws-sdk/types";
|
|
2
2
|
export interface PreviouslyResolved {
|
|
3
3
|
/**
|
|
4
4
|
* The function that will be used to convert binary data to a base64-encoded string.
|
|
@@ -8,7 +8,7 @@ export interface PreviouslyResolved {
|
|
|
8
8
|
/**
|
|
9
9
|
* A function that can calculate the length of a body.
|
|
10
10
|
*/
|
|
11
|
-
bodyLengthChecker:
|
|
11
|
+
bodyLengthChecker: BodyLengthCalculator;
|
|
12
12
|
/**
|
|
13
13
|
* A function that returns Readable Stream which follows aws-chunked encoding stream.
|
|
14
14
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Encoder, GetAwsChunkedEncodingStream, HashConstructor, StreamHasher } from "@aws-sdk/types";
|
|
1
|
+
import { BodyLengthCalculator, Encoder, GetAwsChunkedEncodingStream, HashConstructor, StreamHasher } from "@aws-sdk/types";
|
|
2
2
|
export interface PreviouslyResolved {
|
|
3
3
|
|
|
4
4
|
base64Encoder: Encoder;
|
|
5
5
|
|
|
6
|
-
bodyLengthChecker:
|
|
6
|
+
bodyLengthChecker: BodyLengthCalculator;
|
|
7
7
|
|
|
8
8
|
getAwsChunkedEncodingStream: GetAwsChunkedEncodingStream;
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-flexible-checksums",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.55.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@aws-crypto/crc32": "2.0.0",
|
|
23
23
|
"@aws-crypto/crc32c": "2.0.0",
|
|
24
|
-
"@aws-sdk/is-array-buffer": "3.
|
|
25
|
-
"@aws-sdk/protocol-http": "3.
|
|
26
|
-
"@aws-sdk/types": "3.
|
|
27
|
-
"tslib": "^2.3.
|
|
24
|
+
"@aws-sdk/is-array-buffer": "3.55.0",
|
|
25
|
+
"@aws-sdk/protocol-http": "3.55.0",
|
|
26
|
+
"@aws-sdk/types": "3.55.0",
|
|
27
|
+
"tslib": "^2.3.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"concurrently": "7.0.0",
|
|
31
31
|
"downlevel-dts": "0.7.0",
|
|
32
32
|
"rimraf": "3.0.2",
|
|
33
|
-
"typescript": "~4.
|
|
33
|
+
"typescript": "~4.6.2"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": ">= 12.0.0"
|