Skip to content

Commit

Permalink
Use unsigned payload
Browse files Browse the repository at this point in the history
  • Loading branch information
longern committed Sep 25, 2022
1 parent f9e6231 commit bdcde97
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions utils/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ export class S3Client {
init = init || {};
const url = new URL(input);
const method = init.method || "GET";
const body = <BufferSource>init.body || new ArrayBuffer(0);
const hashedPayload = arrayBufferToHex(
await crypto.subtle.digest("SHA-256", body)
);
const hashedPayload = "UNSIGNED-PAYLOAD";
const headers = new Headers(init.headers);
const datetime = new Date().toISOString().replace(/-|:|\.\d+/g, "");
headers.set("x-amz-date", datetime);
Expand All @@ -44,7 +41,9 @@ export class S3Client {
const canonicalHeaders = [...headers.keys()]
.map((key) => `${key}:${headers.get(key)}\n`)
.join("");
const signedHeaderKeys = [...headers.keys()];
const signedHeaderKeys = [...headers.keys()].filter(
(header) => header === "host" || header.startsWith("x-amz-")
);
const signedHeaders = signedHeaderKeys.join(";");
const canonicalRequest = [
method,
Expand Down

0 comments on commit bdcde97

Please sign in to comment.