( headerValue: string, headerEncoding: BinaryToTextEncoding, secret: BinaryLike | KeyObject, body: string )
| 52 | } |
| 53 | |
| 54 | export function verifyHmacSha256( |
| 55 | headerValue: string, |
| 56 | headerEncoding: BinaryToTextEncoding, |
| 57 | secret: BinaryLike | KeyObject, |
| 58 | body: string |
| 59 | ): boolean { |
| 60 | const bodyDigest = crypto.createHmac("sha256", secret).update(body).digest(headerEncoding); |
| 61 | const signature = headerValue?.replace("hmac-sha256=", "").replace("sha256=", "") ?? ""; |
| 62 | |
| 63 | return signature === bodyDigest; |
| 64 | } |
no test coverage detected
searching dependent graphs…