@aws-sdk/middleware-ssec 3.901.0 → 3.914.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 +65 -92
- package/package.json +3 -3
package/dist-cjs/index.js
CHANGED
|
@@ -1,100 +1,73 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
return next({
|
|
64
|
-
...args,
|
|
65
|
-
input
|
|
66
|
-
});
|
|
67
|
-
};
|
|
40
|
+
return next({
|
|
41
|
+
...args,
|
|
42
|
+
input,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
68
45
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
override: true
|
|
46
|
+
const ssecMiddlewareOptions = {
|
|
47
|
+
name: "ssecMiddleware",
|
|
48
|
+
step: "initialize",
|
|
49
|
+
tags: ["SSE"],
|
|
50
|
+
override: true,
|
|
75
51
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
})
|
|
52
|
+
const getSsecPlugin = (config) => ({
|
|
53
|
+
applyToStack: (clientStack) => {
|
|
54
|
+
clientStack.add(ssecMiddleware(config), ssecMiddlewareOptions);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
81
57
|
function isValidBase64EncodedSSECustomerKey(str, options) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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.
|
|
3
|
+
"version": "3.914.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.
|
|
28
|
-
"@smithy/types": "^4.
|
|
27
|
+
"@aws-sdk/types": "3.914.0",
|
|
28
|
+
"@smithy/types": "^4.8.0",
|
|
29
29
|
"tslib": "^2.6.2"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|