|
@ -59,7 +59,6 @@ app.get('/articles/:articleName', (req, res) => { |
|
|
|
|
|
|
|
|
// Webhook handler
|
|
|
// Webhook handler
|
|
|
app.post('/api', (req, res) => { |
|
|
app.post('/api', (req, res) => { |
|
|
console.log(req) |
|
|
|
|
|
const signature = req.headers['x-gitea-signature']; |
|
|
const signature = req.headers['x-gitea-signature']; |
|
|
const payload = JSON.stringify(req.body); |
|
|
const payload = JSON.stringify(req.body); |
|
|
|
|
|
|
|
@ -75,7 +74,7 @@ app.post('/api', (req, res) => { |
|
|
const bufferSignature = Buffer.from(signature); |
|
|
const bufferSignature = Buffer.from(signature); |
|
|
const bufferDigest = Buffer.from(digest); |
|
|
const bufferDigest = Buffer.from(digest); |
|
|
|
|
|
|
|
|
console.log(bufferDigest.length, bufferSignature.length) |
|
|
console.log(bufferDigest.length, bufferSignature.length, hmac, digest) |
|
|
|
|
|
|
|
|
if (bufferSignature.length === bufferDigest.length && crypto.timingSafeEqual(bufferSignature, bufferDigest)) { |
|
|
if (bufferSignature.length === bufferDigest.length && crypto.timingSafeEqual(bufferSignature, bufferDigest)) { |
|
|
// Secret is valid, update the repository
|
|
|
// Secret is valid, update the repository
|
|
|