@vizamodo/aws-sts-core 0.1.10 → 0.1.15
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/sts/issue.js +9 -1
- package/package.json +1 -1
package/dist/sts/issue.js
CHANGED
|
@@ -68,11 +68,12 @@ export async function issueAwsCredentials(input) {
|
|
|
68
68
|
durationSeconds: sessionTtl,
|
|
69
69
|
});
|
|
70
70
|
const payloadHash = await sha256Hex(body);
|
|
71
|
+
const pemCert = toPemCertificate(certBase64);
|
|
71
72
|
const baseHeaders = {
|
|
72
73
|
host,
|
|
73
74
|
"content-type": "application/json",
|
|
74
75
|
"x-amz-date": amzDate,
|
|
75
|
-
"x-amz-x509-chain":
|
|
76
|
+
"x-amz-x509-chain": pemCert,
|
|
76
77
|
};
|
|
77
78
|
const { canonicalHeaders, signedHeaders } = canonicalizeHeaders(baseHeaders);
|
|
78
79
|
const canonicalRequest = buildCanonicalRequest({
|
|
@@ -135,6 +136,13 @@ export async function issueAwsCredentials(input) {
|
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
138
|
// ---- helpers ----
|
|
139
|
+
function toPemCertificate(base64) {
|
|
140
|
+
const normalized = base64.replace(/\s+/g, "");
|
|
141
|
+
const chunked = normalized.match(/.{1,64}/g)?.join("\n") ?? normalized;
|
|
142
|
+
return ("-----BEGIN CERTIFICATE-----\n" +
|
|
143
|
+
chunked +
|
|
144
|
+
"\n-----END CERTIFICATE-----");
|
|
145
|
+
}
|
|
138
146
|
async function sha256Hex(input) {
|
|
139
147
|
const data = new TextEncoder().encode(input);
|
|
140
148
|
const hash = await crypto.subtle.digest("SHA-256", data);
|