@aws-sdk/middleware-ssec 3.893.0 → 3.910.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.
Files changed (2) hide show
  1. package/dist-cjs/index.js +65 -92
  2. package/package.json +3 -3
package/dist-cjs/index.js CHANGED
@@ -1,100 +1,73 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
20
2
 
21
- // src/index.ts
22
- var index_exports = {};
23
- __export(index_exports, {
24
- getSsecPlugin: () => getSsecPlugin,
25
- isValidBase64EncodedSSECustomerKey: () => isValidBase64EncodedSSECustomerKey,
26
- ssecMiddleware: () => ssecMiddleware,
27
- ssecMiddlewareOptions: () => ssecMiddlewareOptions
28
- });
29
- module.exports = __toCommonJS(index_exports);
30
3
  function ssecMiddleware(options) {
31
- return (next) => async (args) => {
32
- const input = { ...args.input };
33
- const properties = [
34
- {
35
- target: "SSECustomerKey",
36
- hash: "SSECustomerKeyMD5"
37
- },
38
- {
39
- target: "CopySourceSSECustomerKey",
40
- hash: "CopySourceSSECustomerKeyMD5"
41
- }
42
- ];
43
- for (const prop of properties) {
44
- const value = input[prop.target];
45
- if (value) {
46
- let valueForHash;
47
- if (typeof value === "string") {
48
- if (isValidBase64EncodedSSECustomerKey(value, options)) {
49
- valueForHash = options.base64Decoder(value);
50
- } else {
51
- valueForHash = options.utf8Decoder(value);
52
- input[prop.target] = options.base64Encoder(valueForHash);
53
- }
54
- } else {
55
- valueForHash = ArrayBuffer.isView(value) ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength) : new Uint8Array(value);
56
- input[prop.target] = options.base64Encoder(valueForHash);
4
+ return (next) => async (args) => {
5
+ const input = { ...args.input };
6
+ const properties = [
7
+ {
8
+ target: "SSECustomerKey",
9
+ hash: "SSECustomerKeyMD5",
10
+ },
11
+ {
12
+ target: "CopySourceSSECustomerKey",
13
+ hash: "CopySourceSSECustomerKeyMD5",
14
+ },
15
+ ];
16
+ for (const prop of properties) {
17
+ const value = input[prop.target];
18
+ if (value) {
19
+ let valueForHash;
20
+ if (typeof value === "string") {
21
+ if (isValidBase64EncodedSSECustomerKey(value, options)) {
22
+ valueForHash = options.base64Decoder(value);
23
+ }
24
+ else {
25
+ valueForHash = options.utf8Decoder(value);
26
+ input[prop.target] = options.base64Encoder(valueForHash);
27
+ }
28
+ }
29
+ else {
30
+ valueForHash = ArrayBuffer.isView(value)
31
+ ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength)
32
+ : new Uint8Array(value);
33
+ input[prop.target] = options.base64Encoder(valueForHash);
34
+ }
35
+ const hash = new options.md5();
36
+ hash.update(valueForHash);
37
+ input[prop.hash] = options.base64Encoder(await hash.digest());
38
+ }
57
39
  }
58
- const hash = new options.md5();
59
- hash.update(valueForHash);
60
- input[prop.hash] = options.base64Encoder(await hash.digest());
61
- }
62
- }
63
- return next({
64
- ...args,
65
- input
66
- });
67
- };
40
+ return next({
41
+ ...args,
42
+ input,
43
+ });
44
+ };
68
45
  }
69
- __name(ssecMiddleware, "ssecMiddleware");
70
- var ssecMiddlewareOptions = {
71
- name: "ssecMiddleware",
72
- step: "initialize",
73
- tags: ["SSE"],
74
- override: true
46
+ const ssecMiddlewareOptions = {
47
+ name: "ssecMiddleware",
48
+ step: "initialize",
49
+ tags: ["SSE"],
50
+ override: true,
75
51
  };
76
- var getSsecPlugin = /* @__PURE__ */ __name((config) => ({
77
- applyToStack: /* @__PURE__ */ __name((clientStack) => {
78
- clientStack.add(ssecMiddleware(config), ssecMiddlewareOptions);
79
- }, "applyToStack")
80
- }), "getSsecPlugin");
52
+ const getSsecPlugin = (config) => ({
53
+ applyToStack: (clientStack) => {
54
+ clientStack.add(ssecMiddleware(config), ssecMiddlewareOptions);
55
+ },
56
+ });
81
57
  function isValidBase64EncodedSSECustomerKey(str, options) {
82
- const base64Regex = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
83
- if (!base64Regex.test(str)) return false;
84
- try {
85
- const decodedBytes = options.base64Decoder(str);
86
- return decodedBytes.length === 32;
87
- } catch {
88
- return false;
89
- }
58
+ const base64Regex = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
59
+ if (!base64Regex.test(str))
60
+ return false;
61
+ try {
62
+ const decodedBytes = options.base64Decoder(str);
63
+ return decodedBytes.length === 32;
64
+ }
65
+ catch {
66
+ return false;
67
+ }
90
68
  }
91
- __name(isValidBase64EncodedSSECustomerKey, "isValidBase64EncodedSSECustomerKey");
92
- // Annotate the CommonJS export names for ESM import in node:
93
-
94
- 0 && (module.exports = {
95
- ssecMiddlewareOptions,
96
- getSsecPlugin,
97
- ssecMiddleware,
98
- isValidBase64EncodedSSECustomerKey
99
- });
100
69
 
70
+ exports.getSsecPlugin = getSsecPlugin;
71
+ exports.isValidBase64EncodedSSECustomerKey = isValidBase64EncodedSSECustomerKey;
72
+ exports.ssecMiddleware = ssecMiddleware;
73
+ exports.ssecMiddlewareOptions = ssecMiddlewareOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-ssec",
3
- "version": "3.893.0",
3
+ "version": "3.910.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-ssec",
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@aws-sdk/types": "3.893.0",
28
- "@smithy/types": "^4.5.0",
27
+ "@aws-sdk/types": "3.910.0",
28
+ "@smithy/types": "^4.7.1",
29
29
  "tslib": "^2.6.2"
30
30
  },
31
31
  "engines": {