File tree Expand file tree Collapse file tree
core/security/src/lib/crypto Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -163,6 +163,21 @@ export function createSignaturePayload(request: {
163163 }
164164 }
165165
166+ // Normalize body: undefined/null -> {} to match client behavior
167+ const normalizedBody =
168+ request . body !== undefined && request . body !== null ? request . body : { } ;
169+
170+ // Client only includes content-type in signed payload when request has a body (hasBody).
171+ // For PATCH/POST with body {} or no body, client does not sign content-type; exclude it here too.
172+ const hasBody =
173+ normalizedBody !== undefined &&
174+ normalizedBody !== null &&
175+ ( typeof normalizedBody !== "object" ||
176+ Object . keys ( normalizedBody ) . length > 0 ) ;
177+ if ( ! hasBody ) {
178+ delete otherHeaders [ "content-type" ] ;
179+ }
180+
166181 // Build headers object with keys in sorted order so JSON string is deterministic
167182 // (client and server must produce identical payload string for signature verification)
168183 const sortedHeaderKeys = Object . keys ( otherHeaders ) . sort ( ) ;
@@ -171,10 +186,6 @@ export function createSignaturePayload(request: {
171186 canonicalHeaders [ k ] = otherHeaders [ k ] ;
172187 }
173188
174- // Normalize body: undefined/null -> {} to match client behavior
175- const normalizedBody =
176- request . body !== undefined && request . body !== null ? request . body : { } ;
177-
178189 // Debug: raw values going into canonical payload
179190 log . info ( "createSignaturePayload input (server, pre-payload)" , {
180191 method : request . method ,
You can’t perform that action at this time.
0 commit comments