1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const crypto_1 = require("crypto");
|
4 | function s2b(str, encoding) {
|
5 | return Buffer.from(str, encoding);
|
6 | }
|
7 | function safeCompare(a, b) {
|
8 | if (a.length !== b.length) {
|
9 | return false;
|
10 | }
|
11 | return (0, crypto_1.timingSafeEqual)(a, b);
|
12 | }
|
13 | function validateSignature(body, channelSecret, signature) {
|
14 | return safeCompare((0, crypto_1.createHmac)("SHA256", channelSecret).update(body).digest(), s2b(signature, "base64"));
|
15 | }
|
16 | exports.default = validateSignature;
|