Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Maybe? fix signature handling
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent d8bf398 commit b97bfa9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions functions/api/uploads/[[id]].ts
Expand Up @@ -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"],
Expand All @@ -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("=", "")}`,
Expand Down

0 comments on commit b97bfa9

Please sign in to comment.