@smithy/middleware-apply-body-checksum 4.2.1 → 4.3.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
|
@@ -1,90 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
applyMd5BodyChecksumMiddleware: () => applyMd5BodyChecksumMiddleware,
|
|
24
|
-
applyMd5BodyChecksumMiddlewareOptions: () => applyMd5BodyChecksumMiddlewareOptions,
|
|
25
|
-
getApplyMd5BodyChecksumPlugin: () => getApplyMd5BodyChecksumPlugin,
|
|
26
|
-
resolveMd5BodyChecksumConfig: () => resolveMd5BodyChecksumConfig
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
3
|
+
var isArrayBuffer = require('@smithy/is-array-buffer');
|
|
4
|
+
var protocolHttp = require('@smithy/protocol-http');
|
|
29
5
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
6
|
+
const applyMd5BodyChecksumMiddleware = (options) => (next) => async (args) => {
|
|
7
|
+
const { request } = args;
|
|
8
|
+
if (protocolHttp.HttpRequest.isInstance(request)) {
|
|
9
|
+
const { body, headers } = request;
|
|
10
|
+
if (!hasHeader("content-md5", headers)) {
|
|
11
|
+
let digest;
|
|
12
|
+
if (body === undefined || typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer.isArrayBuffer(body)) {
|
|
13
|
+
const hash = new options.md5();
|
|
14
|
+
hash.update(body || "");
|
|
15
|
+
digest = hash.digest();
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
digest = options.streamHasher(options.md5, body);
|
|
19
|
+
}
|
|
20
|
+
const cloned = protocolHttp.HttpRequest.clone(request);
|
|
21
|
+
cloned.headers = {
|
|
22
|
+
...headers,
|
|
23
|
+
"content-md5": options.base64Encoder(await digest),
|
|
24
|
+
};
|
|
25
|
+
return next({
|
|
26
|
+
...args,
|
|
27
|
+
request: cloned,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
55
30
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
override: true
|
|
31
|
+
return next(args);
|
|
32
|
+
};
|
|
33
|
+
const applyMd5BodyChecksumMiddlewareOptions = {
|
|
34
|
+
name: "applyMd5BodyChecksumMiddleware",
|
|
35
|
+
step: "build",
|
|
36
|
+
tags: ["SET_CONTENT_MD5", "BODY_CHECKSUM"],
|
|
37
|
+
override: true,
|
|
64
38
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
39
|
+
const getApplyMd5BodyChecksumPlugin = (config) => ({
|
|
40
|
+
applyToStack: (clientStack) => {
|
|
41
|
+
clientStack.add(applyMd5BodyChecksumMiddleware(config), applyMd5BodyChecksumMiddlewareOptions);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const hasHeader = (soughtHeader, headers) => {
|
|
45
|
+
soughtHeader = soughtHeader.toLowerCase();
|
|
46
|
+
for (const headerName of Object.keys(headers)) {
|
|
47
|
+
if (soughtHeader === headerName.toLowerCase()) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
75
50
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}, "hasHeader");
|
|
79
|
-
|
|
80
|
-
// src/md5Configuration.ts
|
|
81
|
-
var resolveMd5BodyChecksumConfig = /* @__PURE__ */ __name((input) => input, "resolveMd5BodyChecksumConfig");
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
83
53
|
|
|
84
|
-
|
|
85
|
-
applyMd5BodyChecksumMiddleware,
|
|
86
|
-
applyMd5BodyChecksumMiddlewareOptions,
|
|
87
|
-
getApplyMd5BodyChecksumPlugin,
|
|
88
|
-
resolveMd5BodyChecksumConfig
|
|
89
|
-
});
|
|
54
|
+
const resolveMd5BodyChecksumConfig = (input) => input;
|
|
90
55
|
|
|
56
|
+
exports.applyMd5BodyChecksumMiddleware = applyMd5BodyChecksumMiddleware;
|
|
57
|
+
exports.applyMd5BodyChecksumMiddlewareOptions = applyMd5BodyChecksumMiddlewareOptions;
|
|
58
|
+
exports.getApplyMd5BodyChecksumPlugin = getApplyMd5BodyChecksumPlugin;
|
|
59
|
+
exports.resolveMd5BodyChecksumConfig = resolveMd5BodyChecksumConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/middleware-apply-body-checksum",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
6
6
|
"build:cjs": "node ../../scripts/inline middleware-apply-body-checksum",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@smithy/is-array-buffer": "^4.
|
|
30
|
-
"@smithy/protocol-http": "^5.
|
|
31
|
-
"@smithy/types": "^4.
|
|
29
|
+
"@smithy/is-array-buffer": "^4.2.0",
|
|
30
|
+
"@smithy/protocol-http": "^5.3.0",
|
|
31
|
+
"@smithy/types": "^4.6.0",
|
|
32
32
|
"tslib": "^2.6.2"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("./index.js");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("./index.js");
|