From 37daf35110c72057e4fc7ccab49f4427a17360ee Mon Sep 17 00:00:00 2001 From: Moon Man Date: Sun, 31 Dec 2023 07:11:21 -0500 Subject: [PATCH] include content type in signed if post --- src/net.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/net.ts b/src/net.ts index 8749b5b..94d3042 100644 --- a/src/net.ts +++ b/src/net.ts @@ -19,16 +19,16 @@ export interface SignedInit { // TODO: Handle redirects. export const signedFetch = async (url: string, init: RequestInit, signedInit: SignedInit): Promise => { - const now = new Date().toUTCString(); - const signedHeaders: HeadersInit = [ - ["Date", now] + ["Date", new Date().toUTCString()] ]; const headerNames = ["(request-target)", "host", "date"]; if (init.method === "POST") { - headerNames.push("digest"); + headerNames.push("content-type", "digest"); + + signedHeaders.push(["Content-Type", `application/ld+json; profile="${CONTEXT}"`]); if (init.body) { if (signedInit.digest) { @@ -62,8 +62,7 @@ export const signedFetch = async (url: string, init: RequestInit, signedInit: Si const newHeaders: HeadersInit = [ ...signedHeaders, - ["Signature", signature], - ["Content-Type", `application/ld+json; profile="${CONTEXT}"`] + ["Signature", signature] ] ;