Maybe? fix signature handling

This commit is contained in:
regalijan 2023-10-19 16:50:42 -04:00
parent d8bf398ed4
commit b97bfa9f26
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -5,7 +5,7 @@ export async function onRequestGet(context: RequestContext) {
).toString()}`;
const signingKey = await crypto.subtle.importKey(
"raw",
new TextEncoder().encode(atob(context.env.URL_SIGNING_KEY)),
Uint8Array.from(atob(context.env.URL_SIGNING_KEY), (c) => c.charCodeAt(0)),
{ hash: "SHA-1", name: "HMAC" },
false,
["sign"],
@ -17,7 +17,10 @@ export async function onRequestGet(context: RequestContext) {
);
return Response.redirect(
`${unsignedURL}&Signature=${btoa(new TextDecoder().decode(signature))
`${unsignedURL}&Signature=${btoa(
// @ts-expect-error
String.fromCodePoint(...signature),
)
.replaceAll("+", "-")
.replaceAll("/", "_")
.replaceAll("=", "")}`,