@aws-sdk/middleware-ssec 3.533.0 → 3.537.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 +16 -3
- package/dist-es/index.js +13 -2
- package/dist-types/index.d.ts +1 -0
- package/dist-types/ts3.4/index.d.ts +4 -0
- package/package.json +4 -4
package/dist-cjs/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
getSsecPlugin: () => getSsecPlugin,
|
|
24
|
+
isValidBase64EncodedSSECustomerKey: () => isValidBase64EncodedSSECustomerKey,
|
|
24
25
|
ssecMiddleware: () => ssecMiddleware,
|
|
25
26
|
ssecMiddlewareOptions: () => ssecMiddlewareOptions
|
|
26
27
|
});
|
|
@@ -43,8 +44,7 @@ function ssecMiddleware(options) {
|
|
|
43
44
|
if (value) {
|
|
44
45
|
let valueForHash;
|
|
45
46
|
if (typeof value === "string") {
|
|
46
|
-
|
|
47
|
-
if (isBase64Encoded) {
|
|
47
|
+
if (isValidBase64EncodedSSECustomerKey(value, options)) {
|
|
48
48
|
valueForHash = options.base64Decoder(value);
|
|
49
49
|
} else {
|
|
50
50
|
valueForHash = options.utf8Decoder(value);
|
|
@@ -77,11 +77,24 @@ var getSsecPlugin = /* @__PURE__ */ __name((config) => ({
|
|
|
77
77
|
clientStack.add(ssecMiddleware(config), ssecMiddlewareOptions);
|
|
78
78
|
}
|
|
79
79
|
}), "getSsecPlugin");
|
|
80
|
+
function isValidBase64EncodedSSECustomerKey(str, options) {
|
|
81
|
+
const base64Regex = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
82
|
+
if (!base64Regex.test(str))
|
|
83
|
+
return false;
|
|
84
|
+
try {
|
|
85
|
+
const decodedBytes = options.base64Decoder(str);
|
|
86
|
+
return decodedBytes.length === 32;
|
|
87
|
+
} catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
__name(isValidBase64EncodedSSECustomerKey, "isValidBase64EncodedSSECustomerKey");
|
|
80
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
81
93
|
|
|
82
94
|
0 && (module.exports = {
|
|
83
95
|
ssecMiddleware,
|
|
84
96
|
ssecMiddlewareOptions,
|
|
85
|
-
getSsecPlugin
|
|
97
|
+
getSsecPlugin,
|
|
98
|
+
isValidBase64EncodedSSECustomerKey
|
|
86
99
|
});
|
|
87
100
|
|
package/dist-es/index.js
CHANGED
|
@@ -16,8 +16,7 @@ export function ssecMiddleware(options) {
|
|
|
16
16
|
if (value) {
|
|
17
17
|
let valueForHash;
|
|
18
18
|
if (typeof value === "string") {
|
|
19
|
-
|
|
20
|
-
if (isBase64Encoded) {
|
|
19
|
+
if (isValidBase64EncodedSSECustomerKey(value, options)) {
|
|
21
20
|
valueForHash = options.base64Decoder(value);
|
|
22
21
|
}
|
|
23
22
|
else {
|
|
@@ -53,3 +52,15 @@ export const getSsecPlugin = (config) => ({
|
|
|
53
52
|
clientStack.add(ssecMiddleware(config), ssecMiddlewareOptions);
|
|
54
53
|
},
|
|
55
54
|
});
|
|
55
|
+
export function isValidBase64EncodedSSECustomerKey(str, options) {
|
|
56
|
+
const base64Regex = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
57
|
+
if (!base64Regex.test(str))
|
|
58
|
+
return false;
|
|
59
|
+
try {
|
|
60
|
+
const decodedBytes = options.base64Decoder(str);
|
|
61
|
+
return decodedBytes.length === 32;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
package/dist-types/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ interface PreviouslyResolved {
|
|
|
8
8
|
export declare function ssecMiddleware(options: PreviouslyResolved): InitializeMiddleware<any, any>;
|
|
9
9
|
export declare const ssecMiddlewareOptions: InitializeHandlerOptions;
|
|
10
10
|
export declare const getSsecPlugin: (config: PreviouslyResolved) => Pluggable<any, any>;
|
|
11
|
+
export declare function isValidBase64EncodedSSECustomerKey(str: string, options: PreviouslyResolved): boolean;
|
|
11
12
|
export {};
|
|
@@ -20,4 +20,8 @@ export declare const ssecMiddlewareOptions: InitializeHandlerOptions;
|
|
|
20
20
|
export declare const getSsecPlugin: (
|
|
21
21
|
config: PreviouslyResolved
|
|
22
22
|
) => Pluggable<any, any>;
|
|
23
|
+
export declare function isValidBase64EncodedSSECustomerKey(
|
|
24
|
+
str: string,
|
|
25
|
+
options: PreviouslyResolved
|
|
26
|
+
): boolean;
|
|
23
27
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-ssec",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.537.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",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
25
|
-
"@smithy/types": "^2.
|
|
26
|
-
"tslib": "^2.
|
|
24
|
+
"@aws-sdk/types": "3.535.0",
|
|
25
|
+
"@smithy/types": "^2.12.0",
|
|
26
|
+
"tslib": "^2.6.2"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=14.0.0"
|