@smithy/middleware-apply-body-checksum 2.0.18 → 2.1.1

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.
@@ -1,55 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getApplyMd5BodyChecksumPlugin = exports.applyMd5BodyChecksumMiddlewareOptions = exports.applyMd5BodyChecksumMiddleware = void 0;
4
- const is_array_buffer_1 = require("@smithy/is-array-buffer");
5
- const protocol_http_1 = require("@smithy/protocol-http");
6
- const applyMd5BodyChecksumMiddleware = (options) => (next) => async (args) => {
7
- let { request } = args;
8
- if (protocol_http_1.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) || (0, is_array_buffer_1.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
- request = {
21
- ...request,
22
- headers: {
23
- ...headers,
24
- "content-md5": options.base64Encoder(await digest),
25
- },
26
- };
27
- }
28
- }
29
- return next({
30
- ...args,
31
- request,
32
- });
33
- };
34
- exports.applyMd5BodyChecksumMiddleware = applyMd5BodyChecksumMiddleware;
35
- exports.applyMd5BodyChecksumMiddlewareOptions = {
36
- name: "applyMd5BodyChecksumMiddleware",
37
- step: "build",
38
- tags: ["SET_CONTENT_MD5", "BODY_CHECKSUM"],
39
- override: true,
40
- };
41
- const getApplyMd5BodyChecksumPlugin = (config) => ({
42
- applyToStack: (clientStack) => {
43
- clientStack.add((0, exports.applyMd5BodyChecksumMiddleware)(config), exports.applyMd5BodyChecksumMiddlewareOptions);
44
- },
45
- });
46
- exports.getApplyMd5BodyChecksumPlugin = getApplyMd5BodyChecksumPlugin;
47
- const hasHeader = (soughtHeader, headers) => {
48
- soughtHeader = soughtHeader.toLowerCase();
49
- for (const headerName of Object.keys(headers)) {
50
- if (soughtHeader === headerName.toLowerCase()) {
51
- return true;
52
- }
53
- }
54
- return false;
55
- };
1
+ module.exports = require("./index.js");
package/dist-cjs/index.js CHANGED
@@ -1,5 +1,91 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./applyMd5BodyChecksumMiddleware"), exports);
5
- tslib_1.__exportStar(require("./md5Configuration"), exports);
1
+ var __defProp = Object.defineProperty;
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);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ applyMd5BodyChecksumMiddleware: () => applyMd5BodyChecksumMiddleware,
24
+ applyMd5BodyChecksumMiddlewareOptions: () => applyMd5BodyChecksumMiddlewareOptions,
25
+ getApplyMd5BodyChecksumPlugin: () => getApplyMd5BodyChecksumPlugin,
26
+ resolveMd5BodyChecksumConfig: () => resolveMd5BodyChecksumConfig
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+
30
+ // src/applyMd5BodyChecksumMiddleware.ts
31
+ var import_is_array_buffer = require("@smithy/is-array-buffer");
32
+ var import_protocol_http = require("@smithy/protocol-http");
33
+ var applyMd5BodyChecksumMiddleware = /* @__PURE__ */ __name((options) => (next) => async (args) => {
34
+ let { request } = args;
35
+ if (import_protocol_http.HttpRequest.isInstance(request)) {
36
+ const { body, headers } = request;
37
+ if (!hasHeader("content-md5", headers)) {
38
+ let digest;
39
+ if (body === void 0 || typeof body === "string" || ArrayBuffer.isView(body) || (0, import_is_array_buffer.isArrayBuffer)(body)) {
40
+ const hash = new options.md5();
41
+ hash.update(body || "");
42
+ digest = hash.digest();
43
+ } else {
44
+ digest = options.streamHasher(options.md5, body);
45
+ }
46
+ request = {
47
+ ...request,
48
+ headers: {
49
+ ...headers,
50
+ "content-md5": options.base64Encoder(await digest)
51
+ }
52
+ };
53
+ }
54
+ }
55
+ return next({
56
+ ...args,
57
+ request
58
+ });
59
+ }, "applyMd5BodyChecksumMiddleware");
60
+ var applyMd5BodyChecksumMiddlewareOptions = {
61
+ name: "applyMd5BodyChecksumMiddleware",
62
+ step: "build",
63
+ tags: ["SET_CONTENT_MD5", "BODY_CHECKSUM"],
64
+ override: true
65
+ };
66
+ var getApplyMd5BodyChecksumPlugin = /* @__PURE__ */ __name((config) => ({
67
+ applyToStack: (clientStack) => {
68
+ clientStack.add(applyMd5BodyChecksumMiddleware(config), applyMd5BodyChecksumMiddlewareOptions);
69
+ }
70
+ }), "getApplyMd5BodyChecksumPlugin");
71
+ var hasHeader = /* @__PURE__ */ __name((soughtHeader, headers) => {
72
+ soughtHeader = soughtHeader.toLowerCase();
73
+ for (const headerName of Object.keys(headers)) {
74
+ if (soughtHeader === headerName.toLowerCase()) {
75
+ return true;
76
+ }
77
+ }
78
+ return false;
79
+ }, "hasHeader");
80
+
81
+ // src/md5Configuration.ts
82
+ var resolveMd5BodyChecksumConfig = /* @__PURE__ */ __name((input) => input, "resolveMd5BodyChecksumConfig");
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+
85
+ 0 && (module.exports = {
86
+ applyMd5BodyChecksumMiddleware,
87
+ applyMd5BodyChecksumMiddlewareOptions,
88
+ getApplyMd5BodyChecksumPlugin,
89
+ resolveMd5BodyChecksumConfig
90
+ });
91
+
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveMd5BodyChecksumConfig = void 0;
4
- const resolveMd5BodyChecksumConfig = (input) => input;
5
- exports.resolveMd5BodyChecksumConfig = resolveMd5BodyChecksumConfig;
1
+ module.exports = require("./index.js");
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@smithy/middleware-apply-body-checksum",
3
- "version": "2.0.18",
3
+ "version": "2.1.1",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
- "build:cjs": "yarn g:tsc -p tsconfig.cjs.json",
6
+ "build:cjs": "node ../../scripts/inline middleware-apply-body-checksum",
7
7
  "build:es": "yarn g:tsc -p tsconfig.es.json",
8
8
  "build:types": "yarn g:tsc -p tsconfig.types.json",
9
9
  "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@smithy/is-array-buffer": "^2.0.0",
27
- "@smithy/protocol-http": "^3.0.12",
28
- "@smithy/types": "^2.8.0",
26
+ "@smithy/is-array-buffer": "^2.1.1",
27
+ "@smithy/protocol-http": "^3.1.1",
28
+ "@smithy/types": "^2.9.1",
29
29
  "tslib": "^2.5.0"
30
30
  },
31
31
  "engines": {
@@ -48,7 +48,7 @@
48
48
  "directory": "packages/middleware-apply-body-checksum"
49
49
  },
50
50
  "devDependencies": {
51
- "@smithy/util-test": "^0.1.12",
51
+ "@smithy/util-test": "^0.1.14",
52
52
  "@tsconfig/recommended": "1.0.1",
53
53
  "concurrently": "7.0.0",
54
54
  "downlevel-dts": "0.10.1",