include content type in signed if post
This commit is contained in:
parent
cde8a2620a
commit
37daf35110
11
src/net.ts
11
src/net.ts
|
@ -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]
|
||||
]
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in New Issue