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