@vizamodo/aws-sts-core 0.1.30 → 0.1.32
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/sigv4/headers.js +17 -14
- package/package.json +1 -1
package/dist/sigv4/headers.js
CHANGED
|
@@ -11,26 +11,29 @@
|
|
|
11
11
|
* This function is PURE and side‑effect free.
|
|
12
12
|
*/
|
|
13
13
|
export function canonicalizeHeaders(headers) {
|
|
14
|
-
const
|
|
15
|
-
for (const [
|
|
16
|
-
if (
|
|
14
|
+
const map = new Map();
|
|
15
|
+
for (const [rawName, rawValue] of Object.entries(headers)) {
|
|
16
|
+
if (rawValue === undefined)
|
|
17
17
|
continue;
|
|
18
|
-
const name =
|
|
18
|
+
const name = rawName.toLowerCase().trim();
|
|
19
19
|
if (!name)
|
|
20
20
|
continue;
|
|
21
|
-
|
|
22
|
-
// - trim
|
|
23
|
-
// - collapse multiple spaces into one
|
|
24
|
-
const cleanedValue = value
|
|
21
|
+
const value = rawValue
|
|
25
22
|
.trim()
|
|
26
|
-
.replace(
|
|
27
|
-
|
|
23
|
+
.replace(/[ \t]+/g, " ");
|
|
24
|
+
if (!map.has(name)) {
|
|
25
|
+
map.set(name, []);
|
|
26
|
+
}
|
|
27
|
+
map.get(name).push(value);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
const canonicalHeaders =
|
|
31
|
-
.map((name) =>
|
|
29
|
+
const sortedNames = Array.from(map.keys()).sort();
|
|
30
|
+
const canonicalHeaders = sortedNames
|
|
31
|
+
.map((name) => {
|
|
32
|
+
const combined = map.get(name).join(",");
|
|
33
|
+
return `${name}:${combined}\n`;
|
|
34
|
+
})
|
|
32
35
|
.join("");
|
|
33
|
-
const signedHeaders =
|
|
36
|
+
const signedHeaders = sortedNames.join(";");
|
|
34
37
|
return {
|
|
35
38
|
canonicalHeaders,
|
|
36
39
|
signedHeaders,
|