@aws-sdk/middleware-ssec 3.496.0 → 3.498.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 +18 -11
- package/dist-es/index.js +19 -12
- package/dist-types/index.d.ts +1 -0
- package/dist-types/ts3.4/index.d.ts +1 -0
- package/package.json +1 -1
package/dist-cjs/index.js
CHANGED
|
@@ -27,7 +27,7 @@ __export(src_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(src_exports);
|
|
28
28
|
function ssecMiddleware(options) {
|
|
29
29
|
return (next) => async (args) => {
|
|
30
|
-
|
|
30
|
+
const input = { ...args.input };
|
|
31
31
|
const properties = [
|
|
32
32
|
{
|
|
33
33
|
target: "SSECustomerKey",
|
|
@@ -41,15 +41,22 @@ function ssecMiddleware(options) {
|
|
|
41
41
|
for (const prop of properties) {
|
|
42
42
|
const value = input[prop.target];
|
|
43
43
|
if (value) {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
let valueForHash;
|
|
45
|
+
if (typeof value === "string") {
|
|
46
|
+
const isBase64Encoded = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value);
|
|
47
|
+
if (isBase64Encoded) {
|
|
48
|
+
valueForHash = options.base64Decoder(value);
|
|
49
|
+
} else {
|
|
50
|
+
valueForHash = options.utf8Decoder(value);
|
|
51
|
+
input[prop.target] = options.base64Encoder(valueForHash);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
valueForHash = ArrayBuffer.isView(value) ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength) : new Uint8Array(value);
|
|
55
|
+
input[prop.target] = options.base64Encoder(valueForHash);
|
|
56
|
+
}
|
|
46
57
|
const hash = new options.md5();
|
|
47
|
-
hash.update(
|
|
48
|
-
input =
|
|
49
|
-
...input,
|
|
50
|
-
[prop.target]: encoded,
|
|
51
|
-
[prop.hash]: options.base64Encoder(await hash.digest())
|
|
52
|
-
};
|
|
58
|
+
hash.update(valueForHash);
|
|
59
|
+
input[prop.hash] = options.base64Encoder(await hash.digest());
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
62
|
return next({
|
|
@@ -73,8 +80,8 @@ var getSsecPlugin = /* @__PURE__ */ __name((config) => ({
|
|
|
73
80
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
81
|
|
|
75
82
|
0 && (module.exports = {
|
|
76
|
-
getSsecPlugin,
|
|
77
83
|
ssecMiddleware,
|
|
78
|
-
ssecMiddlewareOptions
|
|
84
|
+
ssecMiddlewareOptions,
|
|
85
|
+
getSsecPlugin
|
|
79
86
|
});
|
|
80
87
|
|
package/dist-es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function ssecMiddleware(options) {
|
|
2
2
|
return (next) => async (args) => {
|
|
3
|
-
|
|
3
|
+
const input = { ...args.input };
|
|
4
4
|
const properties = [
|
|
5
5
|
{
|
|
6
6
|
target: "SSECustomerKey",
|
|
@@ -14,19 +14,26 @@ export function ssecMiddleware(options) {
|
|
|
14
14
|
for (const prop of properties) {
|
|
15
15
|
const value = input[prop.target];
|
|
16
16
|
if (value) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
let valueForHash;
|
|
18
|
+
if (typeof value === "string") {
|
|
19
|
+
const isBase64Encoded = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value);
|
|
20
|
+
if (isBase64Encoded) {
|
|
21
|
+
valueForHash = options.base64Decoder(value);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
valueForHash = options.utf8Decoder(value);
|
|
25
|
+
input[prop.target] = options.base64Encoder(valueForHash);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
valueForHash = ArrayBuffer.isView(value)
|
|
30
|
+
? new Uint8Array(value.buffer, value.byteOffset, value.byteLength)
|
|
21
31
|
: new Uint8Array(value);
|
|
22
|
-
|
|
32
|
+
input[prop.target] = options.base64Encoder(valueForHash);
|
|
33
|
+
}
|
|
23
34
|
const hash = new options.md5();
|
|
24
|
-
hash.update(
|
|
25
|
-
input =
|
|
26
|
-
...input,
|
|
27
|
-
[prop.target]: encoded,
|
|
28
|
-
[prop.hash]: options.base64Encoder(await hash.digest()),
|
|
29
|
-
};
|
|
35
|
+
hash.update(valueForHash);
|
|
36
|
+
input[prop.hash] = options.base64Encoder(await hash.digest());
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
return next({
|
package/dist-types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ interface PreviouslyResolved {
|
|
|
3
3
|
base64Encoder: Encoder;
|
|
4
4
|
md5: ChecksumConstructor | HashConstructor;
|
|
5
5
|
utf8Decoder: Decoder;
|
|
6
|
+
base64Decoder: Decoder;
|
|
6
7
|
}
|
|
7
8
|
export declare function ssecMiddleware(options: PreviouslyResolved): InitializeMiddleware<any, any>;
|
|
8
9
|
export declare const ssecMiddlewareOptions: InitializeHandlerOptions;
|
package/package.json
CHANGED