mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 14:37:26 +00:00
Accept spaced CoinPay signature parts (#17)
This commit is contained in:
parent
d558554da3
commit
9ed98ceaf7
2 changed files with 2 additions and 1 deletions
|
|
@ -409,6 +409,7 @@ describe("POST /api/webhooks/coinpay", () => {
|
||||||
const signature = createHmac("sha256", secret).update(`${timestamp}.${payload}`).digest("hex");
|
const signature = createHmac("sha256", secret).update(`${timestamp}.${payload}`).digest("hex");
|
||||||
|
|
||||||
expect(verifyCoinPayWebhook(payload, `t=${timestamp},v1=${signature}`, secret)).toBe(true);
|
expect(verifyCoinPayWebhook(payload, `t=${timestamp},v1=${signature}`, secret)).toBe(true);
|
||||||
|
expect(verifyCoinPayWebhook(payload, `t=${timestamp}, v1=${signature}`, secret)).toBe(true);
|
||||||
|
|
||||||
const response = await coinpayWebhook(
|
const response = await coinpayWebhook(
|
||||||
new NextRequest("http://localhost/api/webhooks/coinpay", {
|
new NextRequest("http://localhost/api/webhooks/coinpay", {
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ export function verifyCoinPayWebhook(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const parts = signatureHeader.split(",");
|
const parts = signatureHeader.split(",").map((part) => part.trim());
|
||||||
const timestamp = parts.find((part) => part.startsWith("t="))?.slice(2);
|
const timestamp = parts.find((part) => part.startsWith("t="))?.slice(2);
|
||||||
const signature = parts.find((part) => part.startsWith("v1="))?.slice(3);
|
const signature = parts.find((part) => part.startsWith("v1="))?.slice(3);
|
||||||
if (!timestamp || !signature) {
|
if (!timestamp || !signature) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue