@aws-sdk/middleware-flexible-checksums 3.730.0 → 3.732.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
CHANGED
|
@@ -401,14 +401,23 @@ var import_util_stream = require("@smithy/util-stream");
|
|
|
401
401
|
var getChecksum = /* @__PURE__ */ __name(async (body, { checksumAlgorithmFn, base64Encoder }) => base64Encoder(await stringHasher(checksumAlgorithmFn, body)), "getChecksum");
|
|
402
402
|
|
|
403
403
|
// src/validateChecksumFromResponse.ts
|
|
404
|
-
var validateChecksumFromResponse = /* @__PURE__ */ __name(async (response, { config, responseAlgorithms }) => {
|
|
404
|
+
var validateChecksumFromResponse = /* @__PURE__ */ __name(async (response, { config, responseAlgorithms, logger }) => {
|
|
405
405
|
const checksumAlgorithms = getChecksumAlgorithmListForResponse(responseAlgorithms);
|
|
406
406
|
const { body: responseBody, headers: responseHeaders } = response;
|
|
407
407
|
for (const algorithm of checksumAlgorithms) {
|
|
408
408
|
const responseHeader = getChecksumLocationName(algorithm);
|
|
409
409
|
const checksumFromResponse = responseHeaders[responseHeader];
|
|
410
410
|
if (checksumFromResponse) {
|
|
411
|
-
|
|
411
|
+
let checksumAlgorithmFn;
|
|
412
|
+
try {
|
|
413
|
+
checksumAlgorithmFn = selectChecksumAlgorithmFunction(algorithm, config);
|
|
414
|
+
} catch (error) {
|
|
415
|
+
if (algorithm === "CRC64NVME" /* CRC64NVME */) {
|
|
416
|
+
logger?.warn(`Skipping ${"CRC64NVME" /* CRC64NVME */} checksum validation: ${error.message}`);
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
throw error;
|
|
420
|
+
}
|
|
412
421
|
const { base64Encoder } = config;
|
|
413
422
|
if (isStreaming(responseBody)) {
|
|
414
423
|
response.body = (0, import_util_stream.createChecksumStream)({
|
|
@@ -465,7 +474,8 @@ var flexibleChecksumsResponseMiddleware = /* @__PURE__ */ __name((config, middle
|
|
|
465
474
|
}
|
|
466
475
|
await validateChecksumFromResponse(result.response, {
|
|
467
476
|
config,
|
|
468
|
-
responseAlgorithms
|
|
477
|
+
responseAlgorithms,
|
|
478
|
+
logger: context.logger
|
|
469
479
|
});
|
|
470
480
|
if (isStreamingBody && collectedStream) {
|
|
471
481
|
response.body = (0, import_create_read_stream_on_buffer.createReadStreamOnBuffer)(collectedStream);
|
|
@@ -41,6 +41,7 @@ export const flexibleChecksumsResponseMiddleware = (config, middlewareConfig) =>
|
|
|
41
41
|
await validateChecksumFromResponse(result.response, {
|
|
42
42
|
config,
|
|
43
43
|
responseAlgorithms,
|
|
44
|
+
logger: context.logger,
|
|
44
45
|
});
|
|
45
46
|
if (isStreamingBody && collectedStream) {
|
|
46
47
|
response.body = createReadStreamOnBuffer(collectedStream);
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import { createChecksumStream } from "@smithy/util-stream";
|
|
2
|
+
import { ChecksumAlgorithm } from "./constants";
|
|
2
3
|
import { getChecksum } from "./getChecksum";
|
|
3
4
|
import { getChecksumAlgorithmListForResponse } from "./getChecksumAlgorithmListForResponse";
|
|
4
5
|
import { getChecksumLocationName } from "./getChecksumLocationName";
|
|
5
6
|
import { isStreaming } from "./isStreaming";
|
|
6
7
|
import { selectChecksumAlgorithmFunction } from "./selectChecksumAlgorithmFunction";
|
|
7
|
-
export const validateChecksumFromResponse = async (response, { config, responseAlgorithms }) => {
|
|
8
|
+
export const validateChecksumFromResponse = async (response, { config, responseAlgorithms, logger }) => {
|
|
8
9
|
const checksumAlgorithms = getChecksumAlgorithmListForResponse(responseAlgorithms);
|
|
9
10
|
const { body: responseBody, headers: responseHeaders } = response;
|
|
10
11
|
for (const algorithm of checksumAlgorithms) {
|
|
11
12
|
const responseHeader = getChecksumLocationName(algorithm);
|
|
12
13
|
const checksumFromResponse = responseHeaders[responseHeader];
|
|
13
14
|
if (checksumFromResponse) {
|
|
14
|
-
|
|
15
|
+
let checksumAlgorithmFn;
|
|
16
|
+
try {
|
|
17
|
+
checksumAlgorithmFn = selectChecksumAlgorithmFunction(algorithm, config);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (algorithm === ChecksumAlgorithm.CRC64NVME) {
|
|
21
|
+
logger?.warn(`Skipping ${ChecksumAlgorithm.CRC64NVME} checksum validation: ${error.message}`);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
15
26
|
const { base64Encoder } = config;
|
|
16
27
|
if (isStreaming(responseBody)) {
|
|
17
28
|
response.body = createChecksumStream({
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { HttpResponse } from "@smithy/protocol-http";
|
|
2
|
+
import { Logger } from "@smithy/types";
|
|
2
3
|
import { PreviouslyResolved } from "./configuration";
|
|
3
4
|
export interface ValidateChecksumFromResponseOptions {
|
|
4
5
|
config: PreviouslyResolved;
|
|
5
6
|
responseAlgorithms?: string[];
|
|
7
|
+
logger?: Logger;
|
|
6
8
|
}
|
|
7
9
|
export declare const validateChecksumFromResponse: (
|
|
8
10
|
response: HttpResponse,
|
|
9
|
-
{ config, responseAlgorithms }: ValidateChecksumFromResponseOptions
|
|
11
|
+
{ config, responseAlgorithms, logger }: ValidateChecksumFromResponseOptions
|
|
10
12
|
) => Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HttpResponse } from "@smithy/protocol-http";
|
|
2
|
+
import { Logger } from "@smithy/types";
|
|
2
3
|
import { PreviouslyResolved } from "./configuration";
|
|
3
4
|
export interface ValidateChecksumFromResponseOptions {
|
|
4
5
|
config: PreviouslyResolved;
|
|
@@ -7,5 +8,6 @@ export interface ValidateChecksumFromResponseOptions {
|
|
|
7
8
|
* returned in the HTTP response.
|
|
8
9
|
*/
|
|
9
10
|
responseAlgorithms?: string[];
|
|
11
|
+
logger?: Logger;
|
|
10
12
|
}
|
|
11
|
-
export declare const validateChecksumFromResponse: (response: HttpResponse, { config, responseAlgorithms }: ValidateChecksumFromResponseOptions) => Promise<void>;
|
|
13
|
+
export declare const validateChecksumFromResponse: (response: HttpResponse, { config, responseAlgorithms, logger }: ValidateChecksumFromResponseOptions) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-flexible-checksums",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.732.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",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@aws-crypto/crc32": "5.2.0",
|
|
37
37
|
"@aws-crypto/crc32c": "5.2.0",
|
|
38
38
|
"@aws-crypto/util": "5.2.0",
|
|
39
|
-
"@aws-sdk/core": "3.
|
|
40
|
-
"@aws-sdk/types": "3.
|
|
39
|
+
"@aws-sdk/core": "3.731.0",
|
|
40
|
+
"@aws-sdk/types": "3.731.0",
|
|
41
41
|
"@smithy/is-array-buffer": "^4.0.0",
|
|
42
42
|
"@smithy/node-config-provider": "^4.0.0",
|
|
43
43
|
"@smithy/protocol-http": "^5.0.0",
|