@aws-sdk/middleware-flexible-checksums 3.974.25 → 3.974.26
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 +21 -447
- package/dist-es/index.js +1 -6
- package/dist-types/index.d.ts +2 -6
- package/package.json +3 -34
- package/dist-cjs/getCrc32ChecksumAlgorithmFunction.browser.js +0 -6
- package/dist-cjs/getCrc32ChecksumAlgorithmFunction.js +0 -26
- package/dist-es/NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS.js +0 -9
- package/dist-es/NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS.js +0 -9
- package/dist-es/configuration.js +0 -1
- package/dist-es/constants.js +0 -25
- package/dist-es/flexibleChecksumsInputMiddleware.js +0 -37
- package/dist-es/flexibleChecksumsMiddleware.js +0 -123
- package/dist-es/flexibleChecksumsResponseMiddleware.js +0 -48
- package/dist-es/getChecksum.js +0 -2
- package/dist-es/getChecksumAlgorithmForRequest.js +0 -13
- package/dist-es/getChecksumAlgorithmListForResponse.js +0 -15
- package/dist-es/getChecksumLocationName.js +0 -2
- package/dist-es/getCrc32ChecksumAlgorithmFunction.browser.js +0 -2
- package/dist-es/getCrc32ChecksumAlgorithmFunction.js +0 -21
- package/dist-es/getFlexibleChecksumsPlugin.js +0 -10
- package/dist-es/hasHeader.js +0 -9
- package/dist-es/hasHeaderWithPrefix.js +0 -9
- package/dist-es/isChecksumWithPartNumber.js +0 -13
- package/dist-es/isStreaming.js +0 -2
- package/dist-es/resolveFlexibleChecksumsConfig.js +0 -11
- package/dist-es/selectChecksumAlgorithmFunction.js +0 -32
- package/dist-es/stringHasher.js +0 -6
- package/dist-es/stringUnionSelector.js +0 -14
- package/dist-es/types.js +0 -15
- package/dist-es/validateChecksumFromResponse.js +0 -45
- package/dist-types/NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS.d.ts +0 -14
- package/dist-types/NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS.d.ts +0 -14
- package/dist-types/configuration.d.ts +0 -58
- package/dist-types/constants.d.ts +0 -83
- package/dist-types/flexibleChecksumsInputMiddleware.d.ts +0 -22
- package/dist-types/flexibleChecksumsMiddleware.d.ts +0 -33
- package/dist-types/flexibleChecksumsResponseMiddleware.d.ts +0 -27
- package/dist-types/getChecksum.d.ts +0 -6
- package/dist-types/getChecksumAlgorithmForRequest.d.ts +0 -22
- package/dist-types/getChecksumAlgorithmListForResponse.d.ts +0 -6
- package/dist-types/getChecksumLocationName.d.ts +0 -5
- package/dist-types/getCrc32ChecksumAlgorithmFunction.browser.d.ts +0 -2
- package/dist-types/getCrc32ChecksumAlgorithmFunction.d.ts +0 -10
- package/dist-types/getFlexibleChecksumsPlugin.d.ts +0 -14
- package/dist-types/hasHeader.d.ts +0 -6
- package/dist-types/hasHeaderWithPrefix.d.ts +0 -6
- package/dist-types/isChecksumWithPartNumber.d.ts +0 -1
- package/dist-types/isStreaming.d.ts +0 -4
- package/dist-types/resolveFlexibleChecksumsConfig.d.ts +0 -57
- package/dist-types/selectChecksumAlgorithmFunction.d.ts +0 -7
- package/dist-types/stringHasher.d.ts +0 -5
- package/dist-types/stringUnionSelector.d.ts +0 -12
- package/dist-types/ts3.4/NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS.d.ts +0 -7
- package/dist-types/ts3.4/NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS.d.ts +0 -7
- package/dist-types/ts3.4/configuration.d.ts +0 -29
- package/dist-types/ts3.4/constants.d.ts +0 -27
- package/dist-types/ts3.4/flexibleChecksumsInputMiddleware.d.ts +0 -10
- package/dist-types/ts3.4/flexibleChecksumsMiddleware.d.ts +0 -14
- package/dist-types/ts3.4/flexibleChecksumsResponseMiddleware.d.ts +0 -14
- package/dist-types/ts3.4/getChecksum.d.ts +0 -9
- package/dist-types/ts3.4/getChecksumAlgorithmForRequest.d.ts +0 -15
- package/dist-types/ts3.4/getChecksumAlgorithmListForResponse.d.ts +0 -4
- package/dist-types/ts3.4/getChecksumLocationName.d.ts +0 -4
- package/dist-types/ts3.4/getCrc32ChecksumAlgorithmFunction.browser.d.ts +0 -2
- package/dist-types/ts3.4/getCrc32ChecksumAlgorithmFunction.d.ts +0 -12
- package/dist-types/ts3.4/getFlexibleChecksumsPlugin.d.ts +0 -13
- package/dist-types/ts3.4/hasHeader.d.ts +0 -2
- package/dist-types/ts3.4/hasHeaderWithPrefix.d.ts +0 -5
- package/dist-types/ts3.4/index.d.ts +0 -6
- package/dist-types/ts3.4/isChecksumWithPartNumber.d.ts +0 -1
- package/dist-types/ts3.4/isStreaming.d.ts +0 -1
- package/dist-types/ts3.4/resolveFlexibleChecksumsConfig.d.ts +0 -32
- package/dist-types/ts3.4/selectChecksumAlgorithmFunction.d.ts +0 -7
- package/dist-types/ts3.4/stringHasher.d.ts +0 -5
- package/dist-types/ts3.4/stringUnionSelector.d.ts +0 -10
- package/dist-types/ts3.4/types.d.ts +0 -3
- package/dist-types/ts3.4/validateChecksumFromResponse.d.ts +0 -12
- package/dist-types/types.d.ts +0 -9
- package/dist-types/validateChecksumFromResponse.d.ts +0 -13
package/dist-cjs/index.js
CHANGED
|
@@ -1,449 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
ChecksumAlgorithm["CRC32"] = "CRC32";
|
|
25
|
-
ChecksumAlgorithm["CRC32C"] = "CRC32C";
|
|
26
|
-
ChecksumAlgorithm["CRC64NVME"] = "CRC64NVME";
|
|
27
|
-
ChecksumAlgorithm["SHA1"] = "SHA1";
|
|
28
|
-
ChecksumAlgorithm["SHA256"] = "SHA256";
|
|
29
|
-
})(exports.ChecksumAlgorithm || (exports.ChecksumAlgorithm = {}));
|
|
30
|
-
exports.ChecksumLocation = void 0;
|
|
31
|
-
(function (ChecksumLocation) {
|
|
32
|
-
ChecksumLocation["HEADER"] = "header";
|
|
33
|
-
ChecksumLocation["TRAILER"] = "trailer";
|
|
34
|
-
})(exports.ChecksumLocation || (exports.ChecksumLocation = {}));
|
|
35
|
-
const DEFAULT_CHECKSUM_ALGORITHM = exports.ChecksumAlgorithm.CRC32;
|
|
36
|
-
|
|
37
|
-
var SelectorType;
|
|
38
|
-
(function (SelectorType) {
|
|
39
|
-
SelectorType["ENV"] = "env";
|
|
40
|
-
SelectorType["CONFIG"] = "shared config entry";
|
|
41
|
-
})(SelectorType || (SelectorType = {}));
|
|
42
|
-
const stringUnionSelector = (obj, key, union, type) => {
|
|
43
|
-
if (!(key in obj))
|
|
44
|
-
return undefined;
|
|
45
|
-
const value = obj[key].toUpperCase();
|
|
46
|
-
if (!Object.values(union).includes(value)) {
|
|
47
|
-
throw new TypeError(`Cannot load ${type} '${key}'. Expected one of ${Object.values(union)}, got '${obj[key]}'.`);
|
|
48
|
-
}
|
|
49
|
-
return value;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const ENV_REQUEST_CHECKSUM_CALCULATION = "AWS_REQUEST_CHECKSUM_CALCULATION";
|
|
53
|
-
const CONFIG_REQUEST_CHECKSUM_CALCULATION = "request_checksum_calculation";
|
|
54
|
-
const NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS = {
|
|
55
|
-
environmentVariableSelector: (env) => stringUnionSelector(env, ENV_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.ENV),
|
|
56
|
-
configFileSelector: (profile) => stringUnionSelector(profile, CONFIG_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.CONFIG),
|
|
57
|
-
default: DEFAULT_REQUEST_CHECKSUM_CALCULATION,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const ENV_RESPONSE_CHECKSUM_VALIDATION = "AWS_RESPONSE_CHECKSUM_VALIDATION";
|
|
61
|
-
const CONFIG_RESPONSE_CHECKSUM_VALIDATION = "response_checksum_validation";
|
|
62
|
-
const NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS = {
|
|
63
|
-
environmentVariableSelector: (env) => stringUnionSelector(env, ENV_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.ENV),
|
|
64
|
-
configFileSelector: (profile) => stringUnionSelector(profile, CONFIG_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.CONFIG),
|
|
65
|
-
default: DEFAULT_RESPONSE_CHECKSUM_VALIDATION,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const getChecksumAlgorithmForRequest = (input, { requestChecksumRequired, requestAlgorithmMember, requestChecksumCalculation }) => {
|
|
69
|
-
if (!requestAlgorithmMember) {
|
|
70
|
-
return requestChecksumCalculation === RequestChecksumCalculation.WHEN_SUPPORTED || requestChecksumRequired
|
|
71
|
-
? DEFAULT_CHECKSUM_ALGORITHM
|
|
72
|
-
: undefined;
|
|
73
|
-
}
|
|
74
|
-
if (!input[requestAlgorithmMember]) {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
const checksumAlgorithm = input[requestAlgorithmMember];
|
|
78
|
-
return checksumAlgorithm;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const getChecksumLocationName = (algorithm) => algorithm === exports.ChecksumAlgorithm.MD5 ? "content-md5" : `x-amz-checksum-${algorithm.toLowerCase()}`;
|
|
82
|
-
|
|
83
|
-
const hasHeader = (header, headers) => {
|
|
84
|
-
const soughtHeader = header.toLowerCase();
|
|
85
|
-
for (const headerName of Object.keys(headers)) {
|
|
86
|
-
if (soughtHeader === headerName.toLowerCase()) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return false;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const hasHeaderWithPrefix = (headerPrefix, headers) => {
|
|
94
|
-
const soughtHeaderPrefix = headerPrefix.toLowerCase();
|
|
95
|
-
for (const headerName of Object.keys(headers)) {
|
|
96
|
-
if (headerName.toLowerCase().startsWith(soughtHeaderPrefix)) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const isStreaming = (body) => body !== undefined && typeof body !== "string" && !ArrayBuffer.isView(body) && !serde.isArrayBuffer(body);
|
|
104
|
-
|
|
105
|
-
const CLIENT_SUPPORTED_ALGORITHMS = [
|
|
106
|
-
exports.ChecksumAlgorithm.CRC32,
|
|
107
|
-
exports.ChecksumAlgorithm.CRC32C,
|
|
108
|
-
exports.ChecksumAlgorithm.CRC64NVME,
|
|
109
|
-
exports.ChecksumAlgorithm.SHA1,
|
|
110
|
-
exports.ChecksumAlgorithm.SHA256,
|
|
111
|
-
];
|
|
112
|
-
const PRIORITY_ORDER_ALGORITHMS = [
|
|
113
|
-
exports.ChecksumAlgorithm.SHA256,
|
|
114
|
-
exports.ChecksumAlgorithm.SHA1,
|
|
115
|
-
exports.ChecksumAlgorithm.CRC32,
|
|
116
|
-
exports.ChecksumAlgorithm.CRC32C,
|
|
117
|
-
exports.ChecksumAlgorithm.CRC64NVME,
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
const selectChecksumAlgorithmFunction = (checksumAlgorithm, config) => {
|
|
121
|
-
const { checksumAlgorithms = {} } = config;
|
|
122
|
-
switch (checksumAlgorithm) {
|
|
123
|
-
case exports.ChecksumAlgorithm.MD5:
|
|
124
|
-
return checksumAlgorithms?.MD5 ?? config.md5;
|
|
125
|
-
case exports.ChecksumAlgorithm.CRC32:
|
|
126
|
-
return checksumAlgorithms?.CRC32 ?? getCrc32ChecksumAlgorithmFunction.getCrc32ChecksumAlgorithmFunction();
|
|
127
|
-
case exports.ChecksumAlgorithm.CRC32C:
|
|
128
|
-
return checksumAlgorithms?.CRC32C ?? crc32c.AwsCrc32c;
|
|
129
|
-
case exports.ChecksumAlgorithm.CRC64NVME:
|
|
130
|
-
if (typeof crc64Nvme.crc64NvmeCrtContainer.CrtCrc64Nvme !== "function") {
|
|
131
|
-
return checksumAlgorithms?.CRC64NVME ?? crc64Nvme.Crc64Nvme;
|
|
132
|
-
}
|
|
133
|
-
return checksumAlgorithms?.CRC64NVME ?? crc64Nvme.crc64NvmeCrtContainer.CrtCrc64Nvme;
|
|
134
|
-
case exports.ChecksumAlgorithm.SHA1:
|
|
135
|
-
return checksumAlgorithms?.SHA1 ?? config.sha1;
|
|
136
|
-
case exports.ChecksumAlgorithm.SHA256:
|
|
137
|
-
return checksumAlgorithms?.SHA256 ?? config.sha256;
|
|
138
|
-
default:
|
|
139
|
-
if (checksumAlgorithms?.[checksumAlgorithm]) {
|
|
140
|
-
return checksumAlgorithms[checksumAlgorithm];
|
|
141
|
-
}
|
|
142
|
-
throw new Error(`The checksum algorithm "${checksumAlgorithm}" is not supported by the client.` +
|
|
143
|
-
` Select one of ${CLIENT_SUPPORTED_ALGORITHMS}, or provide an implementation to ` +
|
|
144
|
-
` the client constructor checksums field.`);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const stringHasher = (checksumAlgorithmFn, body) => {
|
|
149
|
-
const hash = new checksumAlgorithmFn();
|
|
150
|
-
hash.update(serde.toUint8Array(body || ""));
|
|
151
|
-
return hash.digest();
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const flexibleChecksumsMiddlewareOptions = {
|
|
155
|
-
name: "flexibleChecksumsMiddleware",
|
|
156
|
-
step: "build",
|
|
157
|
-
tags: ["BODY_CHECKSUM"],
|
|
158
|
-
override: true,
|
|
159
|
-
};
|
|
160
|
-
const flexibleChecksumsMiddleware = (config, middlewareConfig) => (next, context) => async (args) => {
|
|
161
|
-
if (!protocols.HttpRequest.isInstance(args.request)) {
|
|
162
|
-
return next(args);
|
|
163
|
-
}
|
|
164
|
-
if (hasHeaderWithPrefix("x-amz-checksum-", args.request.headers)) {
|
|
165
|
-
return next(args);
|
|
166
|
-
}
|
|
167
|
-
const { request, input } = args;
|
|
168
|
-
const { body: requestBody, headers } = request;
|
|
169
|
-
const { base64Encoder, streamHasher } = config;
|
|
170
|
-
const { requestChecksumRequired, requestAlgorithmMember } = middlewareConfig;
|
|
171
|
-
const requestChecksumCalculation = await config.requestChecksumCalculation();
|
|
172
|
-
const requestAlgorithmMemberName = requestAlgorithmMember?.name;
|
|
173
|
-
const requestAlgorithmMemberHttpHeader = requestAlgorithmMember?.httpHeader;
|
|
174
|
-
if (requestAlgorithmMemberName && !input[requestAlgorithmMemberName]) {
|
|
175
|
-
if (requestChecksumCalculation === RequestChecksumCalculation.WHEN_SUPPORTED || requestChecksumRequired) {
|
|
176
|
-
input[requestAlgorithmMemberName] = DEFAULT_CHECKSUM_ALGORITHM;
|
|
177
|
-
if (requestAlgorithmMemberHttpHeader) {
|
|
178
|
-
headers[requestAlgorithmMemberHttpHeader] = DEFAULT_CHECKSUM_ALGORITHM;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
const checksumAlgorithm = getChecksumAlgorithmForRequest(input, {
|
|
183
|
-
requestChecksumRequired,
|
|
184
|
-
requestAlgorithmMember: requestAlgorithmMember?.name,
|
|
185
|
-
requestChecksumCalculation,
|
|
186
|
-
});
|
|
187
|
-
let updatedBody = requestBody;
|
|
188
|
-
let updatedHeaders = headers;
|
|
189
|
-
if (checksumAlgorithm) {
|
|
190
|
-
switch (checksumAlgorithm) {
|
|
191
|
-
case exports.ChecksumAlgorithm.CRC32:
|
|
192
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_CRC32", "U");
|
|
193
|
-
break;
|
|
194
|
-
case exports.ChecksumAlgorithm.CRC32C:
|
|
195
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_CRC32C", "V");
|
|
196
|
-
break;
|
|
197
|
-
case exports.ChecksumAlgorithm.CRC64NVME:
|
|
198
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_CRC64", "W");
|
|
199
|
-
break;
|
|
200
|
-
case exports.ChecksumAlgorithm.SHA1:
|
|
201
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_SHA1", "X");
|
|
202
|
-
break;
|
|
203
|
-
case exports.ChecksumAlgorithm.SHA256:
|
|
204
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_SHA256", "Y");
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
const checksumLocationName = getChecksumLocationName(checksumAlgorithm);
|
|
208
|
-
const checksumAlgorithmFn = selectChecksumAlgorithmFunction(checksumAlgorithm, config);
|
|
209
|
-
if (isStreaming(requestBody)) {
|
|
210
|
-
const { getAwsChunkedEncodingStream, bodyLengthChecker } = config;
|
|
211
|
-
updatedBody = getAwsChunkedEncodingStream(typeof config.requestStreamBufferSize === "number" && config.requestStreamBufferSize >= 8 * 1024
|
|
212
|
-
? serde.createBufferedReadable(requestBody, config.requestStreamBufferSize, context.logger)
|
|
213
|
-
: requestBody, {
|
|
214
|
-
base64Encoder,
|
|
215
|
-
bodyLengthChecker,
|
|
216
|
-
checksumLocationName,
|
|
217
|
-
checksumAlgorithmFn,
|
|
218
|
-
streamHasher,
|
|
219
|
-
});
|
|
220
|
-
updatedHeaders = {
|
|
221
|
-
...headers,
|
|
222
|
-
"content-encoding": headers["content-encoding"]
|
|
223
|
-
? `${headers["content-encoding"]},aws-chunked`
|
|
224
|
-
: "aws-chunked",
|
|
225
|
-
"transfer-encoding": "chunked",
|
|
226
|
-
"x-amz-decoded-content-length": headers["content-length"],
|
|
227
|
-
"x-amz-content-sha256": "STREAMING-UNSIGNED-PAYLOAD-TRAILER",
|
|
228
|
-
"x-amz-trailer": checksumLocationName,
|
|
229
|
-
};
|
|
230
|
-
delete updatedHeaders["content-length"];
|
|
231
|
-
}
|
|
232
|
-
else if (!hasHeader(checksumLocationName, headers)) {
|
|
233
|
-
const rawChecksum = await stringHasher(checksumAlgorithmFn, requestBody);
|
|
234
|
-
updatedHeaders = {
|
|
235
|
-
...headers,
|
|
236
|
-
[checksumLocationName]: base64Encoder(rawChecksum),
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
const result = await next({
|
|
242
|
-
...args,
|
|
243
|
-
request: {
|
|
244
|
-
...request,
|
|
245
|
-
headers: updatedHeaders,
|
|
246
|
-
body: updatedBody,
|
|
247
|
-
},
|
|
248
|
-
});
|
|
249
|
-
return result;
|
|
250
|
-
}
|
|
251
|
-
catch (e) {
|
|
252
|
-
if (e instanceof Error && e.name === "InvalidChunkSizeError") {
|
|
253
|
-
try {
|
|
254
|
-
if (!e.message.endsWith(".")) {
|
|
255
|
-
e.message += ".";
|
|
256
|
-
}
|
|
257
|
-
e.message +=
|
|
258
|
-
" Set [requestStreamBufferSize=number e.g. 65_536] in client constructor to instruct AWS SDK to buffer your input stream.";
|
|
259
|
-
}
|
|
260
|
-
catch (ignored) {
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
throw e;
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
const flexibleChecksumsInputMiddlewareOptions = {
|
|
268
|
-
name: "flexibleChecksumsInputMiddleware",
|
|
269
|
-
toMiddleware: "serializerMiddleware",
|
|
270
|
-
relation: "before",
|
|
271
|
-
tags: ["BODY_CHECKSUM"],
|
|
272
|
-
override: true,
|
|
273
|
-
};
|
|
274
|
-
const flexibleChecksumsInputMiddleware = (config, middlewareConfig) => (next, context) => async (args) => {
|
|
275
|
-
const input = args.input;
|
|
276
|
-
const { requestValidationModeMember } = middlewareConfig;
|
|
277
|
-
const requestChecksumCalculation = await config.requestChecksumCalculation();
|
|
278
|
-
const responseChecksumValidation = await config.responseChecksumValidation();
|
|
279
|
-
switch (requestChecksumCalculation) {
|
|
280
|
-
case RequestChecksumCalculation.WHEN_REQUIRED:
|
|
281
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_WHEN_REQUIRED", "a");
|
|
282
|
-
break;
|
|
283
|
-
case RequestChecksumCalculation.WHEN_SUPPORTED:
|
|
284
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_REQ_WHEN_SUPPORTED", "Z");
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
switch (responseChecksumValidation) {
|
|
288
|
-
case ResponseChecksumValidation.WHEN_REQUIRED:
|
|
289
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_RES_WHEN_REQUIRED", "c");
|
|
290
|
-
break;
|
|
291
|
-
case ResponseChecksumValidation.WHEN_SUPPORTED:
|
|
292
|
-
client.setFeature(context, "FLEXIBLE_CHECKSUMS_RES_WHEN_SUPPORTED", "b");
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
if (requestValidationModeMember && !input[requestValidationModeMember]) {
|
|
296
|
-
if (responseChecksumValidation === ResponseChecksumValidation.WHEN_SUPPORTED) {
|
|
297
|
-
input[requestValidationModeMember] = "ENABLED";
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return next(args);
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
const getChecksumAlgorithmListForResponse = (responseAlgorithms = []) => {
|
|
304
|
-
const validChecksumAlgorithms = [];
|
|
305
|
-
let i = PRIORITY_ORDER_ALGORITHMS.length;
|
|
306
|
-
for (const algorithm of responseAlgorithms) {
|
|
307
|
-
const priority = PRIORITY_ORDER_ALGORITHMS.indexOf(algorithm);
|
|
308
|
-
if (priority !== -1) {
|
|
309
|
-
validChecksumAlgorithms[priority] = algorithm;
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
validChecksumAlgorithms[i++] = algorithm;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return validChecksumAlgorithms.filter(Boolean);
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
const isChecksumWithPartNumber = (checksum) => {
|
|
319
|
-
const lastHyphenIndex = checksum.lastIndexOf("-");
|
|
320
|
-
if (lastHyphenIndex !== -1) {
|
|
321
|
-
const numberPart = checksum.slice(lastHyphenIndex + 1);
|
|
322
|
-
if (!numberPart.startsWith("0")) {
|
|
323
|
-
const number = parseInt(numberPart, 10);
|
|
324
|
-
if (!isNaN(number) && number >= 1 && number <= 10000) {
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
return false;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
const getChecksum = async (body, { checksumAlgorithmFn, base64Encoder }) => base64Encoder(await stringHasher(checksumAlgorithmFn, body));
|
|
333
|
-
|
|
334
|
-
const validateChecksumFromResponse = async (response, { config, responseAlgorithms, logger }) => {
|
|
335
|
-
const checksumAlgorithms = getChecksumAlgorithmListForResponse(responseAlgorithms);
|
|
336
|
-
const { body: responseBody, headers: responseHeaders } = response;
|
|
337
|
-
for (const algorithm of checksumAlgorithms) {
|
|
338
|
-
const responseHeader = getChecksumLocationName(algorithm);
|
|
339
|
-
const checksumFromResponse = responseHeaders[responseHeader];
|
|
340
|
-
if (checksumFromResponse) {
|
|
341
|
-
let checksumAlgorithmFn;
|
|
342
|
-
try {
|
|
343
|
-
checksumAlgorithmFn = selectChecksumAlgorithmFunction(algorithm, config);
|
|
344
|
-
}
|
|
345
|
-
catch (error) {
|
|
346
|
-
if (algorithm === exports.ChecksumAlgorithm.CRC64NVME) {
|
|
347
|
-
logger?.warn(`Skipping ${exports.ChecksumAlgorithm.CRC64NVME} checksum validation: ${error.message}`);
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
throw error;
|
|
351
|
-
}
|
|
352
|
-
const { base64Encoder } = config;
|
|
353
|
-
if (isStreaming(responseBody)) {
|
|
354
|
-
response.body = serde.createChecksumStream({
|
|
355
|
-
expectedChecksum: checksumFromResponse,
|
|
356
|
-
checksumSourceLocation: responseHeader,
|
|
357
|
-
checksum: new checksumAlgorithmFn(),
|
|
358
|
-
source: responseBody,
|
|
359
|
-
base64Encoder,
|
|
360
|
-
});
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
const checksum = await getChecksum(responseBody, { checksumAlgorithmFn, base64Encoder });
|
|
364
|
-
if (checksum === checksumFromResponse) {
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
throw new Error(`Checksum mismatch: expected "${checksum}" but received "${checksumFromResponse}"` +
|
|
368
|
-
` in response header "${responseHeader}".`);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
const flexibleChecksumsResponseMiddlewareOptions = {
|
|
374
|
-
name: "flexibleChecksumsResponseMiddleware",
|
|
375
|
-
toMiddleware: "deserializerMiddleware",
|
|
376
|
-
relation: "after",
|
|
377
|
-
tags: ["BODY_CHECKSUM"],
|
|
378
|
-
override: true,
|
|
379
|
-
};
|
|
380
|
-
const flexibleChecksumsResponseMiddleware = (config, middlewareConfig) => (next, context) => async (args) => {
|
|
381
|
-
if (!protocols.HttpRequest.isInstance(args.request)) {
|
|
382
|
-
return next(args);
|
|
383
|
-
}
|
|
384
|
-
const input = args.input;
|
|
385
|
-
const result = await next(args);
|
|
386
|
-
const response = result.response;
|
|
387
|
-
const { requestValidationModeMember, responseAlgorithms } = middlewareConfig;
|
|
388
|
-
if (requestValidationModeMember && input[requestValidationModeMember] === "ENABLED") {
|
|
389
|
-
const { clientName, commandName } = context;
|
|
390
|
-
const customChecksumAlgorithms = Object.keys(config.checksumAlgorithms ?? {}).filter((algorithm) => {
|
|
391
|
-
const responseHeader = getChecksumLocationName(algorithm);
|
|
392
|
-
return response.headers[responseHeader] !== undefined;
|
|
393
|
-
});
|
|
394
|
-
const algoList = getChecksumAlgorithmListForResponse([
|
|
395
|
-
...(responseAlgorithms ?? []),
|
|
396
|
-
...customChecksumAlgorithms,
|
|
397
|
-
]);
|
|
398
|
-
const isS3WholeObjectMultipartGetResponseChecksum = clientName === "S3Client" &&
|
|
399
|
-
commandName === "GetObjectCommand" &&
|
|
400
|
-
algoList.every((algorithm) => {
|
|
401
|
-
const responseHeader = getChecksumLocationName(algorithm);
|
|
402
|
-
const checksumFromResponse = response.headers[responseHeader];
|
|
403
|
-
return !checksumFromResponse || isChecksumWithPartNumber(checksumFromResponse);
|
|
404
|
-
});
|
|
405
|
-
if (isS3WholeObjectMultipartGetResponseChecksum) {
|
|
406
|
-
return result;
|
|
407
|
-
}
|
|
408
|
-
await validateChecksumFromResponse(response, {
|
|
409
|
-
config,
|
|
410
|
-
responseAlgorithms: algoList,
|
|
411
|
-
logger: context.logger,
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
return result;
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
const getFlexibleChecksumsPlugin = (config, middlewareConfig) => ({
|
|
418
|
-
applyToStack: (clientStack) => {
|
|
419
|
-
clientStack.add(flexibleChecksumsMiddleware(config, middlewareConfig), flexibleChecksumsMiddlewareOptions);
|
|
420
|
-
clientStack.addRelativeTo(flexibleChecksumsInputMiddleware(config, middlewareConfig), flexibleChecksumsInputMiddlewareOptions);
|
|
421
|
-
clientStack.addRelativeTo(flexibleChecksumsResponseMiddleware(config, middlewareConfig), flexibleChecksumsResponseMiddlewareOptions);
|
|
422
|
-
},
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
const resolveFlexibleChecksumsConfig = (input) => {
|
|
426
|
-
const { requestChecksumCalculation, responseChecksumValidation, requestStreamBufferSize } = input;
|
|
427
|
-
return Object.assign(input, {
|
|
428
|
-
requestChecksumCalculation: client$1.normalizeProvider(requestChecksumCalculation ?? DEFAULT_REQUEST_CHECKSUM_CALCULATION),
|
|
429
|
-
responseChecksumValidation: client$1.normalizeProvider(responseChecksumValidation ?? DEFAULT_RESPONSE_CHECKSUM_VALIDATION),
|
|
430
|
-
requestStreamBufferSize: Number(requestStreamBufferSize ?? 0),
|
|
431
|
-
checksumAlgorithms: input.checksumAlgorithms ?? {},
|
|
432
|
-
});
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
exports.CONFIG_REQUEST_CHECKSUM_CALCULATION = CONFIG_REQUEST_CHECKSUM_CALCULATION;
|
|
436
|
-
exports.CONFIG_RESPONSE_CHECKSUM_VALIDATION = CONFIG_RESPONSE_CHECKSUM_VALIDATION;
|
|
437
|
-
exports.DEFAULT_CHECKSUM_ALGORITHM = DEFAULT_CHECKSUM_ALGORITHM;
|
|
438
|
-
exports.DEFAULT_REQUEST_CHECKSUM_CALCULATION = DEFAULT_REQUEST_CHECKSUM_CALCULATION;
|
|
439
|
-
exports.DEFAULT_RESPONSE_CHECKSUM_VALIDATION = DEFAULT_RESPONSE_CHECKSUM_VALIDATION;
|
|
440
|
-
exports.ENV_REQUEST_CHECKSUM_CALCULATION = ENV_REQUEST_CHECKSUM_CALCULATION;
|
|
441
|
-
exports.ENV_RESPONSE_CHECKSUM_VALIDATION = ENV_RESPONSE_CHECKSUM_VALIDATION;
|
|
442
|
-
exports.NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS = NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS;
|
|
443
|
-
exports.NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS = NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS;
|
|
444
|
-
exports.RequestChecksumCalculation = RequestChecksumCalculation;
|
|
445
|
-
exports.ResponseChecksumValidation = ResponseChecksumValidation;
|
|
446
|
-
exports.flexibleChecksumsMiddleware = flexibleChecksumsMiddleware;
|
|
447
|
-
exports.flexibleChecksumsMiddlewareOptions = flexibleChecksumsMiddlewareOptions;
|
|
448
|
-
exports.getFlexibleChecksumsPlugin = getFlexibleChecksumsPlugin;
|
|
449
|
-
exports.resolveFlexibleChecksumsConfig = resolveFlexibleChecksumsConfig;
|
|
3
|
+
var checksums = require('@aws-sdk/checksums');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.CONFIG_REQUEST_CHECKSUM_CALCULATION = checksums.CONFIG_REQUEST_CHECKSUM_CALCULATION;
|
|
8
|
+
exports.CONFIG_RESPONSE_CHECKSUM_VALIDATION = checksums.CONFIG_RESPONSE_CHECKSUM_VALIDATION;
|
|
9
|
+
exports.ChecksumAlgorithm = checksums.ChecksumAlgorithm;
|
|
10
|
+
exports.ChecksumLocation = checksums.ChecksumLocation;
|
|
11
|
+
exports.DEFAULT_CHECKSUM_ALGORITHM = checksums.DEFAULT_CHECKSUM_ALGORITHM;
|
|
12
|
+
exports.DEFAULT_REQUEST_CHECKSUM_CALCULATION = checksums.DEFAULT_REQUEST_CHECKSUM_CALCULATION;
|
|
13
|
+
exports.DEFAULT_RESPONSE_CHECKSUM_VALIDATION = checksums.DEFAULT_RESPONSE_CHECKSUM_VALIDATION;
|
|
14
|
+
exports.ENV_REQUEST_CHECKSUM_CALCULATION = checksums.ENV_REQUEST_CHECKSUM_CALCULATION;
|
|
15
|
+
exports.ENV_RESPONSE_CHECKSUM_VALIDATION = checksums.ENV_RESPONSE_CHECKSUM_VALIDATION;
|
|
16
|
+
exports.NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS = checksums.NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS;
|
|
17
|
+
exports.NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS = checksums.NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS;
|
|
18
|
+
exports.RequestChecksumCalculation = checksums.RequestChecksumCalculation;
|
|
19
|
+
exports.ResponseChecksumValidation = checksums.ResponseChecksumValidation;
|
|
20
|
+
exports.flexibleChecksumsMiddleware = checksums.flexibleChecksumsMiddleware;
|
|
21
|
+
exports.flexibleChecksumsMiddlewareOptions = checksums.flexibleChecksumsMiddlewareOptions;
|
|
22
|
+
exports.getFlexibleChecksumsPlugin = checksums.getFlexibleChecksumsPlugin;
|
|
23
|
+
exports.resolveFlexibleChecksumsConfig = checksums.resolveFlexibleChecksumsConfig;
|
package/dist-es/index.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS";
|
|
3
|
-
export * from "./constants";
|
|
4
|
-
export * from "./flexibleChecksumsMiddleware";
|
|
5
|
-
export * from "./getFlexibleChecksumsPlugin";
|
|
6
|
-
export * from "./resolveFlexibleChecksumsConfig";
|
|
1
|
+
export { ENV_REQUEST_CHECKSUM_CALCULATION, CONFIG_REQUEST_CHECKSUM_CALCULATION, NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS, ENV_RESPONSE_CHECKSUM_VALIDATION, CONFIG_RESPONSE_CHECKSUM_VALIDATION, NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS, RequestChecksumCalculation, DEFAULT_REQUEST_CHECKSUM_CALCULATION, ResponseChecksumValidation, DEFAULT_RESPONSE_CHECKSUM_VALIDATION, ChecksumAlgorithm, ChecksumLocation, DEFAULT_CHECKSUM_ALGORITHM, flexibleChecksumsMiddlewareOptions, flexibleChecksumsMiddleware, getFlexibleChecksumsPlugin, resolveFlexibleChecksumsConfig, } from "@aws-sdk/checksums";
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export * from "./constants";
|
|
4
|
-
export * from "./flexibleChecksumsMiddleware";
|
|
5
|
-
export * from "./getFlexibleChecksumsPlugin";
|
|
6
|
-
export * from "./resolveFlexibleChecksumsConfig";
|
|
1
|
+
export { ENV_REQUEST_CHECKSUM_CALCULATION, CONFIG_REQUEST_CHECKSUM_CALCULATION, NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS, ENV_RESPONSE_CHECKSUM_VALIDATION, CONFIG_RESPONSE_CHECKSUM_VALIDATION, NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS, RequestChecksumCalculation, DEFAULT_REQUEST_CHECKSUM_CALCULATION, ResponseChecksumValidation, DEFAULT_RESPONSE_CHECKSUM_VALIDATION, ChecksumAlgorithm, ChecksumLocation, DEFAULT_CHECKSUM_ALGORITHM, flexibleChecksumsMiddlewareOptions, flexibleChecksumsMiddleware, getFlexibleChecksumsPlugin, resolveFlexibleChecksumsConfig, } from "@aws-sdk/checksums";
|
|
2
|
+
export type { FlexibleChecksumsRequestMiddlewareConfig, FlexibleChecksumsMiddlewareConfig, FlexibleChecksumsInputConfig, FlexibleChecksumsResolvedConfig, } from "@aws-sdk/checksums";
|
package/package.json
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-flexible-checksums",
|
|
3
|
-
"version": "3.974.
|
|
3
|
+
"version": "3.974.26",
|
|
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-flexible-checksums",
|
|
7
7
|
"build:es": "tsc -p tsconfig.es.json",
|
|
8
8
|
"build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
|
|
9
9
|
"build:types": "tsc -p tsconfig.types.json",
|
|
10
|
-
"
|
|
11
|
-
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
|
|
12
|
-
"extract:docs": "api-extractor run --local",
|
|
13
|
-
"test": "yarn g:vitest run",
|
|
14
|
-
"test:watch": "yarn g:vitest watch",
|
|
15
|
-
"test:integration": "yarn g:vitest run -c vitest.config.integ.mts",
|
|
16
|
-
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts",
|
|
17
|
-
"test:e2e": "yarn g:vitest run -c vitest.config.e2e.mts",
|
|
18
|
-
"test:e2e:watch": "yarn g:vitest watch -c vitest.config.e2e.mts"
|
|
10
|
+
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo"
|
|
19
11
|
},
|
|
20
12
|
"main": "./dist-cjs/index.js",
|
|
21
13
|
"module": "./dist-es/index.js",
|
|
22
|
-
"browser": {
|
|
23
|
-
"./dist-es/getCrc32ChecksumAlgorithmFunction": "./dist-es/getCrc32ChecksumAlgorithmFunction.browser"
|
|
24
|
-
},
|
|
25
|
-
"react-native": {
|
|
26
|
-
"./dist-es/getCrc32ChecksumAlgorithmFunction": "./dist-es/getCrc32ChecksumAlgorithmFunction.browser",
|
|
27
|
-
"./dist-cjs/getCrc32ChecksumAlgorithmFunction": "./dist-cjs/getCrc32ChecksumAlgorithmFunction.browser"
|
|
28
|
-
},
|
|
29
14
|
"types": "./dist-types/index.d.ts",
|
|
30
15
|
"sideEffects": false,
|
|
31
16
|
"author": {
|
|
@@ -34,33 +19,17 @@
|
|
|
34
19
|
},
|
|
35
20
|
"license": "Apache-2.0",
|
|
36
21
|
"dependencies": {
|
|
37
|
-
"@aws-
|
|
38
|
-
"@aws-crypto/crc32c": "5.2.0",
|
|
39
|
-
"@aws-crypto/util": "5.2.0",
|
|
40
|
-
"@aws-sdk/core": "^3.974.17",
|
|
41
|
-
"@aws-sdk/crc64-nvme": "^3.972.10",
|
|
42
|
-
"@aws-sdk/types": "^3.973.10",
|
|
43
|
-
"@smithy/core": "^3.24.6",
|
|
44
|
-
"@smithy/types": "^4.14.3",
|
|
22
|
+
"@aws-sdk/checksums": "^3.1000.1",
|
|
45
23
|
"tslib": "^2.6.2"
|
|
46
24
|
},
|
|
47
25
|
"devDependencies": {
|
|
48
|
-
"@smithy/node-http-handler": "^4.7.6",
|
|
49
26
|
"concurrently": "7.0.0",
|
|
50
|
-
"downlevel-dts": "0.10.1",
|
|
51
27
|
"premove": "4.0.0",
|
|
52
28
|
"typescript": "~5.8.3"
|
|
53
29
|
},
|
|
54
30
|
"engines": {
|
|
55
31
|
"node": ">=20.0.0"
|
|
56
32
|
},
|
|
57
|
-
"typesVersions": {
|
|
58
|
-
"<4.5": {
|
|
59
|
-
"dist-types/*": [
|
|
60
|
-
"dist-types/ts3.4/*"
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
33
|
"files": [
|
|
65
34
|
"dist-*/**"
|
|
66
35
|
],
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCrc32ChecksumAlgorithmFunction = void 0;
|
|
4
|
-
const crc32_1 = require("@aws-crypto/crc32");
|
|
5
|
-
const getCrc32ChecksumAlgorithmFunction = () => crc32_1.AwsCrc32;
|
|
6
|
-
exports.getCrc32ChecksumAlgorithmFunction = getCrc32ChecksumAlgorithmFunction;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCrc32ChecksumAlgorithmFunction = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const crc32_1 = require("@aws-crypto/crc32");
|
|
6
|
-
const util_1 = require("@aws-crypto/util");
|
|
7
|
-
const zlib = tslib_1.__importStar(require("node:zlib"));
|
|
8
|
-
class NodeCrc32 {
|
|
9
|
-
checksum = 0;
|
|
10
|
-
update(data) {
|
|
11
|
-
this.checksum = zlib.crc32(data, this.checksum);
|
|
12
|
-
}
|
|
13
|
-
async digest() {
|
|
14
|
-
return (0, util_1.numToUint8)(this.checksum);
|
|
15
|
-
}
|
|
16
|
-
reset() {
|
|
17
|
-
this.checksum = 0;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const getCrc32ChecksumAlgorithmFunction = () => {
|
|
21
|
-
if (typeof zlib.crc32 === "undefined") {
|
|
22
|
-
return crc32_1.AwsCrc32;
|
|
23
|
-
}
|
|
24
|
-
return NodeCrc32;
|
|
25
|
-
};
|
|
26
|
-
exports.getCrc32ChecksumAlgorithmFunction = getCrc32ChecksumAlgorithmFunction;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation } from "./constants";
|
|
2
|
-
import { SelectorType, stringUnionSelector } from "./stringUnionSelector";
|
|
3
|
-
export const ENV_REQUEST_CHECKSUM_CALCULATION = "AWS_REQUEST_CHECKSUM_CALCULATION";
|
|
4
|
-
export const CONFIG_REQUEST_CHECKSUM_CALCULATION = "request_checksum_calculation";
|
|
5
|
-
export const NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS = {
|
|
6
|
-
environmentVariableSelector: (env) => stringUnionSelector(env, ENV_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.ENV),
|
|
7
|
-
configFileSelector: (profile) => stringUnionSelector(profile, CONFIG_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.CONFIG),
|
|
8
|
-
default: DEFAULT_REQUEST_CHECKSUM_CALCULATION,
|
|
9
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation } from "./constants";
|
|
2
|
-
import { SelectorType, stringUnionSelector } from "./stringUnionSelector";
|
|
3
|
-
export const ENV_RESPONSE_CHECKSUM_VALIDATION = "AWS_RESPONSE_CHECKSUM_VALIDATION";
|
|
4
|
-
export const CONFIG_RESPONSE_CHECKSUM_VALIDATION = "response_checksum_validation";
|
|
5
|
-
export const NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS = {
|
|
6
|
-
environmentVariableSelector: (env) => stringUnionSelector(env, ENV_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.ENV),
|
|
7
|
-
configFileSelector: (profile) => stringUnionSelector(profile, CONFIG_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.CONFIG),
|
|
8
|
-
default: DEFAULT_RESPONSE_CHECKSUM_VALIDATION,
|
|
9
|
-
};
|
package/dist-es/configuration.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist-es/constants.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const RequestChecksumCalculation = {
|
|
2
|
-
WHEN_SUPPORTED: "WHEN_SUPPORTED",
|
|
3
|
-
WHEN_REQUIRED: "WHEN_REQUIRED",
|
|
4
|
-
};
|
|
5
|
-
export const DEFAULT_REQUEST_CHECKSUM_CALCULATION = RequestChecksumCalculation.WHEN_SUPPORTED;
|
|
6
|
-
export const ResponseChecksumValidation = {
|
|
7
|
-
WHEN_SUPPORTED: "WHEN_SUPPORTED",
|
|
8
|
-
WHEN_REQUIRED: "WHEN_REQUIRED",
|
|
9
|
-
};
|
|
10
|
-
export const DEFAULT_RESPONSE_CHECKSUM_VALIDATION = RequestChecksumCalculation.WHEN_SUPPORTED;
|
|
11
|
-
export var ChecksumAlgorithm;
|
|
12
|
-
(function (ChecksumAlgorithm) {
|
|
13
|
-
ChecksumAlgorithm["MD5"] = "MD5";
|
|
14
|
-
ChecksumAlgorithm["CRC32"] = "CRC32";
|
|
15
|
-
ChecksumAlgorithm["CRC32C"] = "CRC32C";
|
|
16
|
-
ChecksumAlgorithm["CRC64NVME"] = "CRC64NVME";
|
|
17
|
-
ChecksumAlgorithm["SHA1"] = "SHA1";
|
|
18
|
-
ChecksumAlgorithm["SHA256"] = "SHA256";
|
|
19
|
-
})(ChecksumAlgorithm || (ChecksumAlgorithm = {}));
|
|
20
|
-
export var ChecksumLocation;
|
|
21
|
-
(function (ChecksumLocation) {
|
|
22
|
-
ChecksumLocation["HEADER"] = "header";
|
|
23
|
-
ChecksumLocation["TRAILER"] = "trailer";
|
|
24
|
-
})(ChecksumLocation || (ChecksumLocation = {}));
|
|
25
|
-
export const DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.CRC32;
|