include content type in signed if post

This commit is contained in:
Moon Man 2023-12-31 07:11:21 -05:00
parent cde8a2620a
commit 37daf35110
1 changed files with 5 additions and 6 deletions

View File

@ -19,16 +19,16 @@ export interface SignedInit {
// TODO: Handle redirects.
export const signedFetch = async (url: string, init: RequestInit, signedInit: SignedInit): Promise<globalThis.Response> => {
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]
]
;