@aws-sdk/middleware-flexible-checksums 3.723.0 → 3.730.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 +88 -17
- package/dist-es/constants.js +2 -2
- package/dist-es/crc64-nvme-crt-container.js +3 -0
- package/dist-es/flexibleChecksumsInputMiddleware.js +37 -0
- package/dist-es/flexibleChecksumsMiddleware.js +17 -2
- package/dist-es/getChecksumAlgorithmForRequest.js +9 -5
- package/dist-es/getFlexibleChecksumsPlugin.js +2 -0
- package/dist-es/index.js +1 -0
- package/dist-es/selectChecksumAlgorithmFunction.js +10 -0
- package/dist-es/types.js +2 -0
- package/dist-types/configuration.d.ts +10 -1
- package/dist-types/constants.d.ts +5 -5
- package/dist-types/crc64-nvme-crt-container.d.ts +13 -0
- package/dist-types/flexibleChecksumsInputMiddleware.d.ts +19 -0
- package/dist-types/getChecksumAlgorithmForRequest.d.ts +6 -2
- package/dist-types/getFlexibleChecksumsPlugin.d.ts +2 -1
- package/dist-types/index.d.ts +1 -0
- package/dist-types/ts3.4/configuration.d.ts +7 -0
- package/dist-types/ts3.4/constants.d.ts +2 -3
- package/dist-types/ts3.4/crc64-nvme-crt-container.d.ts +4 -0
- package/dist-types/ts3.4/flexibleChecksumsInputMiddleware.d.ts +10 -0
- package/dist-types/ts3.4/getChecksumAlgorithmForRequest.d.ts +4 -3
- package/dist-types/ts3.4/getFlexibleChecksumsPlugin.d.ts +2 -0
- package/dist-types/ts3.4/index.d.ts +1 -0
- package/package.json +2 -2
package/dist-cjs/index.js
CHANGED
|
@@ -34,7 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS: () => NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS,
|
|
35
35
|
RequestChecksumCalculation: () => RequestChecksumCalculation,
|
|
36
36
|
ResponseChecksumValidation: () => ResponseChecksumValidation,
|
|
37
|
-
|
|
37
|
+
crc64NvmeCrtContainer: () => crc64NvmeCrtContainer,
|
|
38
38
|
flexibleChecksumsMiddleware: () => flexibleChecksumsMiddleware,
|
|
39
39
|
flexibleChecksumsMiddlewareOptions: () => flexibleChecksumsMiddlewareOptions,
|
|
40
40
|
getFlexibleChecksumsPlugin: () => getFlexibleChecksumsPlugin,
|
|
@@ -81,6 +81,7 @@ var ChecksumAlgorithm = /* @__PURE__ */ ((ChecksumAlgorithm3) => {
|
|
|
81
81
|
ChecksumAlgorithm3["MD5"] = "MD5";
|
|
82
82
|
ChecksumAlgorithm3["CRC32"] = "CRC32";
|
|
83
83
|
ChecksumAlgorithm3["CRC32C"] = "CRC32C";
|
|
84
|
+
ChecksumAlgorithm3["CRC64NVME"] = "CRC64NVME";
|
|
84
85
|
ChecksumAlgorithm3["SHA1"] = "SHA1";
|
|
85
86
|
ChecksumAlgorithm3["SHA256"] = "SHA256";
|
|
86
87
|
return ChecksumAlgorithm3;
|
|
@@ -90,8 +91,7 @@ var ChecksumLocation = /* @__PURE__ */ ((ChecksumLocation2) => {
|
|
|
90
91
|
ChecksumLocation2["TRAILER"] = "trailer";
|
|
91
92
|
return ChecksumLocation2;
|
|
92
93
|
})(ChecksumLocation || {});
|
|
93
|
-
var DEFAULT_CHECKSUM_ALGORITHM = "
|
|
94
|
-
var S3_EXPRESS_DEFAULT_CHECKSUM_ALGORITHM = "CRC32" /* CRC32 */;
|
|
94
|
+
var DEFAULT_CHECKSUM_ALGORITHM = "CRC32" /* CRC32 */;
|
|
95
95
|
|
|
96
96
|
// src/stringUnionSelector.ts
|
|
97
97
|
var stringUnionSelector = /* @__PURE__ */ __name((obj, key, union, type) => {
|
|
@@ -122,6 +122,11 @@ var NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS = {
|
|
|
122
122
|
default: DEFAULT_RESPONSE_CHECKSUM_VALIDATION
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
+
// src/crc64-nvme-crt-container.ts
|
|
126
|
+
var crc64NvmeCrtContainer = {
|
|
127
|
+
CrtCrc64Nvme: null
|
|
128
|
+
};
|
|
129
|
+
|
|
125
130
|
// src/flexibleChecksumsMiddleware.ts
|
|
126
131
|
var import_core = require("@aws-sdk/core");
|
|
127
132
|
var import_protocol_http = require("@smithy/protocol-http");
|
|
@@ -130,6 +135,7 @@ var import_protocol_http = require("@smithy/protocol-http");
|
|
|
130
135
|
var CLIENT_SUPPORTED_ALGORITHMS = [
|
|
131
136
|
"CRC32" /* CRC32 */,
|
|
132
137
|
"CRC32C" /* CRC32C */,
|
|
138
|
+
"CRC64NVME" /* CRC64NVME */,
|
|
133
139
|
"SHA1" /* SHA1 */,
|
|
134
140
|
"SHA256" /* SHA256 */
|
|
135
141
|
];
|
|
@@ -137,14 +143,17 @@ var PRIORITY_ORDER_ALGORITHMS = [
|
|
|
137
143
|
"SHA256" /* SHA256 */,
|
|
138
144
|
"SHA1" /* SHA1 */,
|
|
139
145
|
"CRC32" /* CRC32 */,
|
|
140
|
-
"CRC32C" /* CRC32C
|
|
146
|
+
"CRC32C" /* CRC32C */,
|
|
147
|
+
"CRC64NVME" /* CRC64NVME */
|
|
141
148
|
];
|
|
142
149
|
|
|
143
150
|
// src/getChecksumAlgorithmForRequest.ts
|
|
144
|
-
var getChecksumAlgorithmForRequest = /* @__PURE__ */ __name((input, { requestChecksumRequired, requestAlgorithmMember }
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
var getChecksumAlgorithmForRequest = /* @__PURE__ */ __name((input, { requestChecksumRequired, requestAlgorithmMember, requestChecksumCalculation }) => {
|
|
152
|
+
if (!requestAlgorithmMember) {
|
|
153
|
+
return requestChecksumCalculation === RequestChecksumCalculation.WHEN_SUPPORTED || requestChecksumRequired ? DEFAULT_CHECKSUM_ALGORITHM : void 0;
|
|
154
|
+
}
|
|
155
|
+
if (!input[requestAlgorithmMember]) {
|
|
156
|
+
return void 0;
|
|
148
157
|
}
|
|
149
158
|
const checksumAlgorithm = input[requestAlgorithmMember];
|
|
150
159
|
if (!CLIENT_SUPPORTED_ALGORITHMS.includes(checksumAlgorithm)) {
|
|
@@ -195,6 +204,15 @@ var selectChecksumAlgorithmFunction = /* @__PURE__ */ __name((checksumAlgorithm,
|
|
|
195
204
|
return (0, import_getCrc32ChecksumAlgorithmFunction.getCrc32ChecksumAlgorithmFunction)();
|
|
196
205
|
case "CRC32C" /* CRC32C */:
|
|
197
206
|
return import_crc32c.AwsCrc32c;
|
|
207
|
+
case "CRC64NVME" /* CRC64NVME */:
|
|
208
|
+
if (typeof crc64NvmeCrtContainer.CrtCrc64Nvme !== "function") {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`Please check whether you have installed the "@aws-sdk/crc64-nvme-crt" package explicitly.
|
|
211
|
+
You must also register the package by calling [require("@aws-sdk/crc64-nvme-crt");] or an ESM equivalent such as [import "@aws-sdk/crc64-nvme-crt";].
|
|
212
|
+
For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return crc64NvmeCrtContainer.CrtCrc64Nvme;
|
|
198
216
|
case "SHA1" /* SHA1 */:
|
|
199
217
|
return config.sha1;
|
|
200
218
|
case "SHA256" /* SHA256 */:
|
|
@@ -230,14 +248,22 @@ var flexibleChecksumsMiddleware = /* @__PURE__ */ __name((config, middlewareConf
|
|
|
230
248
|
const { body: requestBody, headers } = request;
|
|
231
249
|
const { base64Encoder, streamHasher } = config;
|
|
232
250
|
const { requestChecksumRequired, requestAlgorithmMember } = middlewareConfig;
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
251
|
+
const requestChecksumCalculation = await config.requestChecksumCalculation();
|
|
252
|
+
const requestAlgorithmMemberName = requestAlgorithmMember?.name;
|
|
253
|
+
const requestAlgorithmMemberHttpHeader = requestAlgorithmMember?.httpHeader;
|
|
254
|
+
if (requestAlgorithmMemberName && !input[requestAlgorithmMemberName]) {
|
|
255
|
+
if (requestChecksumCalculation === RequestChecksumCalculation.WHEN_SUPPORTED || requestChecksumRequired) {
|
|
256
|
+
input[requestAlgorithmMemberName] = DEFAULT_CHECKSUM_ALGORITHM;
|
|
257
|
+
if (requestAlgorithmMemberHttpHeader) {
|
|
258
|
+
headers[requestAlgorithmMemberHttpHeader] = DEFAULT_CHECKSUM_ALGORITHM;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const checksumAlgorithm = getChecksumAlgorithmForRequest(input, {
|
|
263
|
+
requestChecksumRequired,
|
|
264
|
+
requestAlgorithmMember: requestAlgorithmMember?.name,
|
|
265
|
+
requestChecksumCalculation
|
|
266
|
+
});
|
|
241
267
|
let updatedBody = requestBody;
|
|
242
268
|
let updatedHeaders = headers;
|
|
243
269
|
if (checksumAlgorithm) {
|
|
@@ -248,6 +274,9 @@ var flexibleChecksumsMiddleware = /* @__PURE__ */ __name((config, middlewareConf
|
|
|
248
274
|
case "CRC32C" /* CRC32C */:
|
|
249
275
|
(0, import_core.setFeature)(context, "FLEXIBLE_CHECKSUMS_REQ_CRC32C", "V");
|
|
250
276
|
break;
|
|
277
|
+
case "CRC64NVME" /* CRC64NVME */:
|
|
278
|
+
(0, import_core.setFeature)(context, "FLEXIBLE_CHECKSUMS_REQ_CRC64", "W");
|
|
279
|
+
break;
|
|
251
280
|
case "SHA1" /* SHA1 */:
|
|
252
281
|
(0, import_core.setFeature)(context, "FLEXIBLE_CHECKSUMS_REQ_SHA1", "X");
|
|
253
282
|
break;
|
|
@@ -294,6 +323,44 @@ var flexibleChecksumsMiddleware = /* @__PURE__ */ __name((config, middlewareConf
|
|
|
294
323
|
return result;
|
|
295
324
|
}, "flexibleChecksumsMiddleware");
|
|
296
325
|
|
|
326
|
+
// src/flexibleChecksumsInputMiddleware.ts
|
|
327
|
+
|
|
328
|
+
var flexibleChecksumsInputMiddlewareOptions = {
|
|
329
|
+
name: "flexibleChecksumsInputMiddleware",
|
|
330
|
+
toMiddleware: "serializerMiddleware",
|
|
331
|
+
relation: "before",
|
|
332
|
+
tags: ["BODY_CHECKSUM"],
|
|
333
|
+
override: true
|
|
334
|
+
};
|
|
335
|
+
var flexibleChecksumsInputMiddleware = /* @__PURE__ */ __name((config, middlewareConfig) => (next, context) => async (args) => {
|
|
336
|
+
const input = args.input;
|
|
337
|
+
const { requestValidationModeMember } = middlewareConfig;
|
|
338
|
+
const requestChecksumCalculation = await config.requestChecksumCalculation();
|
|
339
|
+
const responseChecksumValidation = await config.responseChecksumValidation();
|
|
340
|
+
switch (requestChecksumCalculation) {
|
|
341
|
+
case RequestChecksumCalculation.WHEN_REQUIRED:
|
|
342
|
+
(0, import_core.setFeature)(context, "FLEXIBLE_CHECKSUMS_REQ_WHEN_REQUIRED", "a");
|
|
343
|
+
break;
|
|
344
|
+
case RequestChecksumCalculation.WHEN_SUPPORTED:
|
|
345
|
+
(0, import_core.setFeature)(context, "FLEXIBLE_CHECKSUMS_REQ_WHEN_SUPPORTED", "Z");
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
switch (responseChecksumValidation) {
|
|
349
|
+
case ResponseChecksumValidation.WHEN_REQUIRED:
|
|
350
|
+
(0, import_core.setFeature)(context, "FLEXIBLE_CHECKSUMS_RES_WHEN_REQUIRED", "c");
|
|
351
|
+
break;
|
|
352
|
+
case ResponseChecksumValidation.WHEN_SUPPORTED:
|
|
353
|
+
(0, import_core.setFeature)(context, "FLEXIBLE_CHECKSUMS_RES_WHEN_SUPPORTED", "b");
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
if (requestValidationModeMember && !input[requestValidationModeMember]) {
|
|
357
|
+
if (responseChecksumValidation === ResponseChecksumValidation.WHEN_SUPPORTED) {
|
|
358
|
+
input[requestValidationModeMember] = "ENABLED";
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return next(args);
|
|
362
|
+
}, "flexibleChecksumsInputMiddleware");
|
|
363
|
+
|
|
297
364
|
// src/flexibleChecksumsResponseMiddleware.ts
|
|
298
365
|
|
|
299
366
|
|
|
@@ -411,6 +478,10 @@ var flexibleChecksumsResponseMiddleware = /* @__PURE__ */ __name((config, middle
|
|
|
411
478
|
var getFlexibleChecksumsPlugin = /* @__PURE__ */ __name((config, middlewareConfig) => ({
|
|
412
479
|
applyToStack: (clientStack) => {
|
|
413
480
|
clientStack.add(flexibleChecksumsMiddleware(config, middlewareConfig), flexibleChecksumsMiddlewareOptions);
|
|
481
|
+
clientStack.addRelativeTo(
|
|
482
|
+
flexibleChecksumsInputMiddleware(config, middlewareConfig),
|
|
483
|
+
flexibleChecksumsInputMiddlewareOptions
|
|
484
|
+
);
|
|
414
485
|
clientStack.addRelativeTo(
|
|
415
486
|
flexibleChecksumsResponseMiddleware(config, middlewareConfig),
|
|
416
487
|
flexibleChecksumsResponseMiddlewareOptions
|
|
@@ -445,7 +516,7 @@ var resolveFlexibleChecksumsConfig = /* @__PURE__ */ __name((input) => ({
|
|
|
445
516
|
ChecksumAlgorithm,
|
|
446
517
|
ChecksumLocation,
|
|
447
518
|
DEFAULT_CHECKSUM_ALGORITHM,
|
|
448
|
-
|
|
519
|
+
crc64NvmeCrtContainer,
|
|
449
520
|
flexibleChecksumsMiddlewareOptions,
|
|
450
521
|
flexibleChecksumsMiddleware,
|
|
451
522
|
getFlexibleChecksumsPlugin,
|
package/dist-es/constants.js
CHANGED
|
@@ -13,6 +13,7 @@ export var ChecksumAlgorithm;
|
|
|
13
13
|
ChecksumAlgorithm["MD5"] = "MD5";
|
|
14
14
|
ChecksumAlgorithm["CRC32"] = "CRC32";
|
|
15
15
|
ChecksumAlgorithm["CRC32C"] = "CRC32C";
|
|
16
|
+
ChecksumAlgorithm["CRC64NVME"] = "CRC64NVME";
|
|
16
17
|
ChecksumAlgorithm["SHA1"] = "SHA1";
|
|
17
18
|
ChecksumAlgorithm["SHA256"] = "SHA256";
|
|
18
19
|
})(ChecksumAlgorithm || (ChecksumAlgorithm = {}));
|
|
@@ -21,5 +22,4 @@ export var ChecksumLocation;
|
|
|
21
22
|
ChecksumLocation["HEADER"] = "header";
|
|
22
23
|
ChecksumLocation["TRAILER"] = "trailer";
|
|
23
24
|
})(ChecksumLocation || (ChecksumLocation = {}));
|
|
24
|
-
export const DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.
|
|
25
|
-
export const S3_EXPRESS_DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.CRC32;
|
|
25
|
+
export const DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.CRC32;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { setFeature } from "@aws-sdk/core";
|
|
2
|
+
import { RequestChecksumCalculation, ResponseChecksumValidation } from "./constants";
|
|
3
|
+
export const flexibleChecksumsInputMiddlewareOptions = {
|
|
4
|
+
name: "flexibleChecksumsInputMiddleware",
|
|
5
|
+
toMiddleware: "serializerMiddleware",
|
|
6
|
+
relation: "before",
|
|
7
|
+
tags: ["BODY_CHECKSUM"],
|
|
8
|
+
override: true,
|
|
9
|
+
};
|
|
10
|
+
export const flexibleChecksumsInputMiddleware = (config, middlewareConfig) => (next, context) => async (args) => {
|
|
11
|
+
const input = args.input;
|
|
12
|
+
const { requestValidationModeMember } = middlewareConfig;
|
|
13
|
+
const requestChecksumCalculation = await config.requestChecksumCalculation();
|
|
14
|
+
const responseChecksumValidation = await config.responseChecksumValidation();
|
|
15
|
+
switch (requestChecksumCalculation) {
|
|
16
|
+
case RequestChecksumCalculation.WHEN_REQUIRED:
|
|
17
|
+
setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_WHEN_REQUIRED", "a");
|
|
18
|
+
break;
|
|
19
|
+
case RequestChecksumCalculation.WHEN_SUPPORTED:
|
|
20
|
+
setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_WHEN_SUPPORTED", "Z");
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
switch (responseChecksumValidation) {
|
|
24
|
+
case ResponseChecksumValidation.WHEN_REQUIRED:
|
|
25
|
+
setFeature(context, "FLEXIBLE_CHECKSUMS_RES_WHEN_REQUIRED", "c");
|
|
26
|
+
break;
|
|
27
|
+
case ResponseChecksumValidation.WHEN_SUPPORTED:
|
|
28
|
+
setFeature(context, "FLEXIBLE_CHECKSUMS_RES_WHEN_SUPPORTED", "b");
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
if (requestValidationModeMember && !input[requestValidationModeMember]) {
|
|
32
|
+
if (responseChecksumValidation === ResponseChecksumValidation.WHEN_SUPPORTED) {
|
|
33
|
+
input[requestValidationModeMember] = "ENABLED";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return next(args);
|
|
37
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setFeature } from "@aws-sdk/core";
|
|
2
2
|
import { HttpRequest } from "@smithy/protocol-http";
|
|
3
|
-
import { ChecksumAlgorithm } from "./constants";
|
|
3
|
+
import { ChecksumAlgorithm, DEFAULT_CHECKSUM_ALGORITHM, RequestChecksumCalculation } from "./constants";
|
|
4
4
|
import { getChecksumAlgorithmForRequest } from "./getChecksumAlgorithmForRequest";
|
|
5
5
|
import { getChecksumLocationName } from "./getChecksumLocationName";
|
|
6
6
|
import { hasHeader } from "./hasHeader";
|
|
@@ -25,10 +25,22 @@ export const flexibleChecksumsMiddleware = (config, middlewareConfig) => (next,
|
|
|
25
25
|
const { body: requestBody, headers } = request;
|
|
26
26
|
const { base64Encoder, streamHasher } = config;
|
|
27
27
|
const { requestChecksumRequired, requestAlgorithmMember } = middlewareConfig;
|
|
28
|
+
const requestChecksumCalculation = await config.requestChecksumCalculation();
|
|
29
|
+
const requestAlgorithmMemberName = requestAlgorithmMember?.name;
|
|
30
|
+
const requestAlgorithmMemberHttpHeader = requestAlgorithmMember?.httpHeader;
|
|
31
|
+
if (requestAlgorithmMemberName && !input[requestAlgorithmMemberName]) {
|
|
32
|
+
if (requestChecksumCalculation === RequestChecksumCalculation.WHEN_SUPPORTED || requestChecksumRequired) {
|
|
33
|
+
input[requestAlgorithmMemberName] = DEFAULT_CHECKSUM_ALGORITHM;
|
|
34
|
+
if (requestAlgorithmMemberHttpHeader) {
|
|
35
|
+
headers[requestAlgorithmMemberHttpHeader] = DEFAULT_CHECKSUM_ALGORITHM;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
28
39
|
const checksumAlgorithm = getChecksumAlgorithmForRequest(input, {
|
|
29
40
|
requestChecksumRequired,
|
|
30
41
|
requestAlgorithmMember: requestAlgorithmMember?.name,
|
|
31
|
-
|
|
42
|
+
requestChecksumCalculation,
|
|
43
|
+
});
|
|
32
44
|
let updatedBody = requestBody;
|
|
33
45
|
let updatedHeaders = headers;
|
|
34
46
|
if (checksumAlgorithm) {
|
|
@@ -39,6 +51,9 @@ export const flexibleChecksumsMiddleware = (config, middlewareConfig) => (next,
|
|
|
39
51
|
case ChecksumAlgorithm.CRC32C:
|
|
40
52
|
setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_CRC32C", "V");
|
|
41
53
|
break;
|
|
54
|
+
case ChecksumAlgorithm.CRC64NVME:
|
|
55
|
+
setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_CRC64", "W");
|
|
56
|
+
break;
|
|
42
57
|
case ChecksumAlgorithm.SHA1:
|
|
43
58
|
setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_SHA1", "X");
|
|
44
59
|
break;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { DEFAULT_CHECKSUM_ALGORITHM,
|
|
1
|
+
import { DEFAULT_CHECKSUM_ALGORITHM, RequestChecksumCalculation } from "./constants";
|
|
2
2
|
import { CLIENT_SUPPORTED_ALGORITHMS } from "./types";
|
|
3
|
-
export const getChecksumAlgorithmForRequest = (input, { requestChecksumRequired, requestAlgorithmMember }
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export const getChecksumAlgorithmForRequest = (input, { requestChecksumRequired, requestAlgorithmMember, requestChecksumCalculation }) => {
|
|
4
|
+
if (!requestAlgorithmMember) {
|
|
5
|
+
return requestChecksumCalculation === RequestChecksumCalculation.WHEN_SUPPORTED || requestChecksumRequired
|
|
6
|
+
? DEFAULT_CHECKSUM_ALGORITHM
|
|
7
|
+
: undefined;
|
|
8
|
+
}
|
|
9
|
+
if (!input[requestAlgorithmMember]) {
|
|
10
|
+
return undefined;
|
|
7
11
|
}
|
|
8
12
|
const checksumAlgorithm = input[requestAlgorithmMember];
|
|
9
13
|
if (!CLIENT_SUPPORTED_ALGORITHMS.includes(checksumAlgorithm)) {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { flexibleChecksumsInputMiddleware, flexibleChecksumsInputMiddlewareOptions, } from "./flexibleChecksumsInputMiddleware";
|
|
1
2
|
import { flexibleChecksumsMiddleware, flexibleChecksumsMiddlewareOptions, } from "./flexibleChecksumsMiddleware";
|
|
2
3
|
import { flexibleChecksumsResponseMiddleware, flexibleChecksumsResponseMiddlewareOptions, } from "./flexibleChecksumsResponseMiddleware";
|
|
3
4
|
export const getFlexibleChecksumsPlugin = (config, middlewareConfig) => ({
|
|
4
5
|
applyToStack: (clientStack) => {
|
|
5
6
|
clientStack.add(flexibleChecksumsMiddleware(config, middlewareConfig), flexibleChecksumsMiddlewareOptions);
|
|
7
|
+
clientStack.addRelativeTo(flexibleChecksumsInputMiddleware(config, middlewareConfig), flexibleChecksumsInputMiddlewareOptions);
|
|
6
8
|
clientStack.addRelativeTo(flexibleChecksumsResponseMiddleware(config, middlewareConfig), flexibleChecksumsResponseMiddlewareOptions);
|
|
7
9
|
},
|
|
8
10
|
});
|
package/dist-es/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS";
|
|
2
2
|
export * from "./NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS";
|
|
3
3
|
export * from "./constants";
|
|
4
|
+
export * from "./crc64-nvme-crt-container";
|
|
4
5
|
export * from "./flexibleChecksumsMiddleware";
|
|
5
6
|
export * from "./getFlexibleChecksumsPlugin";
|
|
6
7
|
export * from "./resolveFlexibleChecksumsConfig";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AwsCrc32c } from "@aws-crypto/crc32c";
|
|
2
2
|
import { ChecksumAlgorithm } from "./constants";
|
|
3
|
+
import { crc64NvmeCrtContainer } from "./crc64-nvme-crt-container";
|
|
3
4
|
import { getCrc32ChecksumAlgorithmFunction } from "./getCrc32ChecksumAlgorithmFunction";
|
|
4
5
|
export const selectChecksumAlgorithmFunction = (checksumAlgorithm, config) => {
|
|
5
6
|
switch (checksumAlgorithm) {
|
|
@@ -9,6 +10,15 @@ export const selectChecksumAlgorithmFunction = (checksumAlgorithm, config) => {
|
|
|
9
10
|
return getCrc32ChecksumAlgorithmFunction();
|
|
10
11
|
case ChecksumAlgorithm.CRC32C:
|
|
11
12
|
return AwsCrc32c;
|
|
13
|
+
case ChecksumAlgorithm.CRC64NVME:
|
|
14
|
+
if (typeof crc64NvmeCrtContainer.CrtCrc64Nvme !== "function") {
|
|
15
|
+
throw new Error(`Please check whether you have installed the "@aws-sdk/crc64-nvme-crt" package explicitly. \n` +
|
|
16
|
+
`You must also register the package by calling [require("@aws-sdk/crc64-nvme-crt");] ` +
|
|
17
|
+
`or an ESM equivalent such as [import "@aws-sdk/crc64-nvme-crt";]. \n` +
|
|
18
|
+
"For more information please go to " +
|
|
19
|
+
"https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt");
|
|
20
|
+
}
|
|
21
|
+
return crc64NvmeCrtContainer.CrtCrc64Nvme;
|
|
12
22
|
case ChecksumAlgorithm.SHA1:
|
|
13
23
|
return config.sha1;
|
|
14
24
|
case ChecksumAlgorithm.SHA256:
|
package/dist-es/types.js
CHANGED
|
@@ -2,6 +2,7 @@ import { ChecksumAlgorithm } from "./constants";
|
|
|
2
2
|
export const CLIENT_SUPPORTED_ALGORITHMS = [
|
|
3
3
|
ChecksumAlgorithm.CRC32,
|
|
4
4
|
ChecksumAlgorithm.CRC32C,
|
|
5
|
+
ChecksumAlgorithm.CRC64NVME,
|
|
5
6
|
ChecksumAlgorithm.SHA1,
|
|
6
7
|
ChecksumAlgorithm.SHA256,
|
|
7
8
|
];
|
|
@@ -10,4 +11,5 @@ export const PRIORITY_ORDER_ALGORITHMS = [
|
|
|
10
11
|
ChecksumAlgorithm.SHA1,
|
|
11
12
|
ChecksumAlgorithm.CRC32,
|
|
12
13
|
ChecksumAlgorithm.CRC32C,
|
|
14
|
+
ChecksumAlgorithm.CRC64NVME,
|
|
13
15
|
];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { BodyLengthCalculator, ChecksumConstructor, Encoder, GetAwsChunkedEncodingStream, HashConstructor, StreamCollector, StreamHasher } from "@smithy/types";
|
|
1
|
+
import { BodyLengthCalculator, ChecksumConstructor, Encoder, GetAwsChunkedEncodingStream, HashConstructor, Provider, StreamCollector, StreamHasher } from "@smithy/types";
|
|
2
|
+
import { RequestChecksumCalculation, ResponseChecksumValidation } from "./constants";
|
|
2
3
|
export interface PreviouslyResolved {
|
|
3
4
|
/**
|
|
4
5
|
* The function that will be used to convert binary data to a base64-encoded string.
|
|
@@ -18,6 +19,14 @@ export interface PreviouslyResolved {
|
|
|
18
19
|
* @internal
|
|
19
20
|
*/
|
|
20
21
|
md5: ChecksumConstructor | HashConstructor;
|
|
22
|
+
/**
|
|
23
|
+
* Determines when a checksum will be calculated for request payloads
|
|
24
|
+
*/
|
|
25
|
+
requestChecksumCalculation: Provider<RequestChecksumCalculation>;
|
|
26
|
+
/**
|
|
27
|
+
* Determines when a checksum will be calculated for response payloads
|
|
28
|
+
*/
|
|
29
|
+
responseChecksumValidation: Provider<ResponseChecksumValidation>;
|
|
21
30
|
/**
|
|
22
31
|
* A constructor for a class implementing the {@link Hash} interface that computes SHA1 hashes.
|
|
23
32
|
* @internal
|
|
@@ -44,9 +44,13 @@ export declare const DEFAULT_RESPONSE_CHECKSUM_VALIDATION: "WHEN_SUPPORTED";
|
|
|
44
44
|
* Checksum Algorithms supported by the SDK.
|
|
45
45
|
*/
|
|
46
46
|
export declare enum ChecksumAlgorithm {
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use {@link ChecksumAlgorithm.CRC32} instead.
|
|
49
|
+
*/
|
|
47
50
|
MD5 = "MD5",
|
|
48
51
|
CRC32 = "CRC32",
|
|
49
52
|
CRC32C = "CRC32C",
|
|
53
|
+
CRC64NVME = "CRC64NVME",
|
|
50
54
|
SHA1 = "SHA1",
|
|
51
55
|
SHA256 = "SHA256"
|
|
52
56
|
}
|
|
@@ -60,8 +64,4 @@ export declare enum ChecksumLocation {
|
|
|
60
64
|
/**
|
|
61
65
|
* @internal
|
|
62
66
|
*/
|
|
63
|
-
export declare const DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
export declare const S3_EXPRESS_DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.CRC32;
|
|
67
|
+
export declare const DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.CRC32;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChecksumConstructor } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*
|
|
5
|
+
* \@aws-sdk/crc64-nvme-crt will install the constructor in this
|
|
6
|
+
* container if it is installed.
|
|
7
|
+
*
|
|
8
|
+
* This avoids a runtime-require being interpreted statically by bundlers.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare const crc64NvmeCrtContainer: {
|
|
12
|
+
CrtCrc64Nvme: null | ChecksumConstructor;
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RelativeMiddlewareOptions, SerializeMiddleware } from "@smithy/types";
|
|
2
|
+
import { PreviouslyResolved } from "./configuration";
|
|
3
|
+
export interface FlexibleChecksumsInputMiddlewareConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Defines a top-level operation input member used to opt-in to best-effort validation
|
|
6
|
+
* of a checksum returned in the HTTP response of the operation.
|
|
7
|
+
*/
|
|
8
|
+
requestValidationModeMember?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const flexibleChecksumsInputMiddlewareOptions: RelativeMiddlewareOptions;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*
|
|
17
|
+
* The input counterpart to the flexibleChecksumsMiddleware.
|
|
18
|
+
*/
|
|
19
|
+
export declare const flexibleChecksumsInputMiddleware: (config: PreviouslyResolved, middlewareConfig: FlexibleChecksumsInputMiddlewareConfig) => SerializeMiddleware<any, any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChecksumAlgorithm } from "./constants";
|
|
1
|
+
import { ChecksumAlgorithm, RequestChecksumCalculation } from "./constants";
|
|
2
2
|
export interface GetChecksumAlgorithmForRequestOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Indicates an operation requires a checksum in its HTTP request.
|
|
@@ -8,10 +8,14 @@ export interface GetChecksumAlgorithmForRequestOptions {
|
|
|
8
8
|
* Defines a top-level operation input member that is used to configure request checksum behavior.
|
|
9
9
|
*/
|
|
10
10
|
requestAlgorithmMember?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Determines when a checksum will be calculated for request payloads
|
|
13
|
+
*/
|
|
14
|
+
requestChecksumCalculation: RequestChecksumCalculation;
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* Returns the checksum algorithm to use for the request, along with
|
|
14
18
|
* the priority array of location to use to populate checksum and names
|
|
15
19
|
* to be used as a key at the location.
|
|
16
20
|
*/
|
|
17
|
-
export declare const getChecksumAlgorithmForRequest: (input: any, { requestChecksumRequired, requestAlgorithmMember }: GetChecksumAlgorithmForRequestOptions
|
|
21
|
+
export declare const getChecksumAlgorithmForRequest: (input: any, { requestChecksumRequired, requestAlgorithmMember, requestChecksumCalculation }: GetChecksumAlgorithmForRequestOptions) => ChecksumAlgorithm | undefined;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Pluggable } from "@smithy/types";
|
|
2
2
|
import { PreviouslyResolved } from "./configuration";
|
|
3
|
+
import { FlexibleChecksumsInputMiddlewareConfig } from "./flexibleChecksumsInputMiddleware";
|
|
3
4
|
import { FlexibleChecksumsRequestMiddlewareConfig } from "./flexibleChecksumsMiddleware";
|
|
4
5
|
import { FlexibleChecksumsResponseMiddlewareConfig } from "./flexibleChecksumsResponseMiddleware";
|
|
5
|
-
export interface FlexibleChecksumsMiddlewareConfig extends FlexibleChecksumsRequestMiddlewareConfig, FlexibleChecksumsResponseMiddlewareConfig {
|
|
6
|
+
export interface FlexibleChecksumsMiddlewareConfig extends FlexibleChecksumsRequestMiddlewareConfig, FlexibleChecksumsInputMiddlewareConfig, FlexibleChecksumsResponseMiddlewareConfig {
|
|
6
7
|
}
|
|
7
8
|
export declare const getFlexibleChecksumsPlugin: (config: PreviouslyResolved, middlewareConfig: FlexibleChecksumsMiddlewareConfig) => Pluggable<any, any>;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS";
|
|
2
2
|
export * from "./NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS";
|
|
3
3
|
export * from "./constants";
|
|
4
|
+
export * from "./crc64-nvme-crt-container";
|
|
4
5
|
export * from "./flexibleChecksumsMiddleware";
|
|
5
6
|
export * from "./getFlexibleChecksumsPlugin";
|
|
6
7
|
export * from "./resolveFlexibleChecksumsConfig";
|
|
@@ -4,14 +4,21 @@ import {
|
|
|
4
4
|
Encoder,
|
|
5
5
|
GetAwsChunkedEncodingStream,
|
|
6
6
|
HashConstructor,
|
|
7
|
+
Provider,
|
|
7
8
|
StreamCollector,
|
|
8
9
|
StreamHasher,
|
|
9
10
|
} from "@smithy/types";
|
|
11
|
+
import {
|
|
12
|
+
RequestChecksumCalculation,
|
|
13
|
+
ResponseChecksumValidation,
|
|
14
|
+
} from "./constants";
|
|
10
15
|
export interface PreviouslyResolved {
|
|
11
16
|
base64Encoder: Encoder;
|
|
12
17
|
bodyLengthChecker: BodyLengthCalculator;
|
|
13
18
|
getAwsChunkedEncodingStream: GetAwsChunkedEncodingStream;
|
|
14
19
|
md5: ChecksumConstructor | HashConstructor;
|
|
20
|
+
requestChecksumCalculation: Provider<RequestChecksumCalculation>;
|
|
21
|
+
responseChecksumValidation: Provider<ResponseChecksumValidation>;
|
|
15
22
|
sha1: ChecksumConstructor | HashConstructor;
|
|
16
23
|
sha256: ChecksumConstructor | HashConstructor;
|
|
17
24
|
streamHasher: StreamHasher<any>;
|
|
@@ -16,6 +16,7 @@ export declare enum ChecksumAlgorithm {
|
|
|
16
16
|
MD5 = "MD5",
|
|
17
17
|
CRC32 = "CRC32",
|
|
18
18
|
CRC32C = "CRC32C",
|
|
19
|
+
CRC64NVME = "CRC64NVME",
|
|
19
20
|
SHA1 = "SHA1",
|
|
20
21
|
SHA256 = "SHA256",
|
|
21
22
|
}
|
|
@@ -23,6 +24,4 @@ export declare enum ChecksumLocation {
|
|
|
23
24
|
HEADER = "header",
|
|
24
25
|
TRAILER = "trailer",
|
|
25
26
|
}
|
|
26
|
-
export declare const DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.
|
|
27
|
-
export declare const S3_EXPRESS_DEFAULT_CHECKSUM_ALGORITHM =
|
|
28
|
-
ChecksumAlgorithm.CRC32;
|
|
27
|
+
export declare const DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.CRC32;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RelativeMiddlewareOptions, SerializeMiddleware } from "@smithy/types";
|
|
2
|
+
import { PreviouslyResolved } from "./configuration";
|
|
3
|
+
export interface FlexibleChecksumsInputMiddlewareConfig {
|
|
4
|
+
requestValidationModeMember?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const flexibleChecksumsInputMiddlewareOptions: RelativeMiddlewareOptions;
|
|
7
|
+
export declare const flexibleChecksumsInputMiddleware: (
|
|
8
|
+
config: PreviouslyResolved,
|
|
9
|
+
middlewareConfig: FlexibleChecksumsInputMiddlewareConfig
|
|
10
|
+
) => SerializeMiddleware<any, any>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ChecksumAlgorithm } from "./constants";
|
|
1
|
+
import { ChecksumAlgorithm, RequestChecksumCalculation } from "./constants";
|
|
2
2
|
export interface GetChecksumAlgorithmForRequestOptions {
|
|
3
3
|
requestChecksumRequired: boolean;
|
|
4
4
|
requestAlgorithmMember?: string;
|
|
5
|
+
requestChecksumCalculation: RequestChecksumCalculation;
|
|
5
6
|
}
|
|
6
7
|
export declare const getChecksumAlgorithmForRequest: (
|
|
7
8
|
input: any,
|
|
8
9
|
{
|
|
9
10
|
requestChecksumRequired,
|
|
10
11
|
requestAlgorithmMember,
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
requestChecksumCalculation,
|
|
13
|
+
}: GetChecksumAlgorithmForRequestOptions
|
|
13
14
|
) => ChecksumAlgorithm | undefined;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Pluggable } from "@smithy/types";
|
|
2
2
|
import { PreviouslyResolved } from "./configuration";
|
|
3
|
+
import { FlexibleChecksumsInputMiddlewareConfig } from "./flexibleChecksumsInputMiddleware";
|
|
3
4
|
import { FlexibleChecksumsRequestMiddlewareConfig } from "./flexibleChecksumsMiddleware";
|
|
4
5
|
import { FlexibleChecksumsResponseMiddlewareConfig } from "./flexibleChecksumsResponseMiddleware";
|
|
5
6
|
export interface FlexibleChecksumsMiddlewareConfig
|
|
6
7
|
extends FlexibleChecksumsRequestMiddlewareConfig,
|
|
8
|
+
FlexibleChecksumsInputMiddlewareConfig,
|
|
7
9
|
FlexibleChecksumsResponseMiddlewareConfig {}
|
|
8
10
|
export declare const getFlexibleChecksumsPlugin: (
|
|
9
11
|
config: PreviouslyResolved,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS";
|
|
2
2
|
export * from "./NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS";
|
|
3
3
|
export * from "./constants";
|
|
4
|
+
export * from "./crc64-nvme-crt-container";
|
|
4
5
|
export * from "./flexibleChecksumsMiddleware";
|
|
5
6
|
export * from "./getFlexibleChecksumsPlugin";
|
|
6
7
|
export * from "./resolveFlexibleChecksumsConfig";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-flexible-checksums",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.730.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,7 +36,7 @@
|
|
|
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.
|
|
39
|
+
"@aws-sdk/core": "3.730.0",
|
|
40
40
|
"@aws-sdk/types": "3.723.0",
|
|
41
41
|
"@smithy/is-array-buffer": "^4.0.0",
|
|
42
42
|
"@smithy/node-config-provider": "^4.0.0",
|