-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
33 lines (23 loc) · 857 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const http = require('http');
const crypto = require('crypto');
const PORT = process.env.PORT || 5000
http.createServer((request, response) => {
let body = [];
request.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
const appSecret = process.env.APP_SECRET;
const httpMethod = "POST";
const URI = process.env.URL;
const concatedValue = appSecret + httpMethod + URI + body
const hash = crypto.createHash('sha256').update(concatedValue).digest('hex');
const actualHash = request.headers["x-hubspot-signature"] || "none received";
console.log("Expected Signature: " + hash);
console.log("Actual Signature: " + actualHash);
response.write(hash);
response.write("\n");
response.write(actualHash);
response.end();
});
}).listen(PORT);