Skip to content

Commit 40498fc

Browse files
committed
chore: replace scmp with crypto.timingSafeEqual
1 parent 462c49d commit 40498fc

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"https-proxy-agent": "^5.0.0",
2626
"jsonwebtoken": "^9.0.3",
2727
"qs": "^6.14.1",
28-
"scmp": "^2.1.0",
2928
"xmlbuilder": "^13.0.2"
3029
},
3130
"devDependencies": {

src/webhooks/webhooks.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const scmp = require("scmp");
21
import crypto from "crypto";
32
import urllib from "url";
43
import { IncomingHttpHeaders } from "http2";
@@ -257,15 +256,15 @@ function validateSignatureWithUrl(
257256
params
258257
);
259258

260-
return scmp(Buffer.from(twilioHeader), Buffer.from(signatureWithoutPort));
259+
return crypto.timingSafeEqual(Buffer.from(twilioHeader), Buffer.from(signatureWithoutPort));
261260
}
262261

263262
export function validateBody(
264263
body: string,
265264
bodyHash: any[] | string | Buffer
266265
): boolean {
267266
var expectedHash = getExpectedBodyHash(body);
268-
return scmp(Buffer.from(bodyHash), Buffer.from(expectedHash));
267+
return crypto.timingSafeEqual(Buffer.from(bodyHash), Buffer.from(expectedHash));
269268
}
270269

271270
/**

0 commit comments

Comments
 (0)