@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
- 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);
1
+ 'use strict';
19
2
 
20
- // src/index.ts
21
- var index_exports = {};
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
- // 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
- const { 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
- const cloned = import_protocol_http.HttpRequest.clone(request);
47
- cloned.headers = {
48
- ...headers,
49
- "content-md5": options.base64Encoder(await digest)
50
- };
51
- return next({
52
- ...args,
53
- request: cloned
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
- return next(args);
58
- }, "applyMd5BodyChecksumMiddleware");
59
- var applyMd5BodyChecksumMiddlewareOptions = {
60
- name: "applyMd5BodyChecksumMiddleware",
61
- step: "build",
62
- tags: ["SET_CONTENT_MD5", "BODY_CHECKSUM"],
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
- var getApplyMd5BodyChecksumPlugin = /* @__PURE__ */ __name((config) => ({
66
- applyToStack: /* @__PURE__ */ __name((clientStack) => {
67
- clientStack.add(applyMd5BodyChecksumMiddleware(config), applyMd5BodyChecksumMiddlewareOptions);
68
- }, "applyToStack")
69
- }), "getApplyMd5BodyChecksumPlugin");
70
- var hasHeader = /* @__PURE__ */ __name((soughtHeader, headers) => {
71
- soughtHeader = soughtHeader.toLowerCase();
72
- for (const headerName of Object.keys(headers)) {
73
- if (soughtHeader === headerName.toLowerCase()) {
74
- return true;
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
- return false;
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
- 0 && (module.exports = {
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.2.1",
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.1.0",
30
- "@smithy/protocol-http": "^5.2.1",
31
- "@smithy/types": "^4.5.0",
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");