Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/ai-music-system / webhook.js |
| Date | Not specified in source |
| Repository | Janady13/ai-music-system |
| Revision | 9a816470ef81edba7a5d8f3aae62c05eead638a7 |
| Branch | main |
| Path or archive member | webhook.js |
| Original SHA-256 | acb395b8c266b2bdde3ad21d946fb2df1e71a8df6adddda49c82b773c064f1f2 |
| Git blob SHA | cc55b06b8a393b9367bb2aed3ec75e0e7300a8bb |
| Reading-copy SHA-256 | acb395b8c266b2bdde3ad21d946fb2df1e71a8df6adddda49c82b773c064f1f2 |
Every recorded occurrence
These 3 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/ai-music-system / webhook.js | main | 9a816470ef81edba7a5d8f3aae62c05eead638a7 | Open original |
| Janady13/ai-music-system / webhook.js | codex/create-ai-for-music-generation-ifwcfc | cd5207850253ee238f8a267c043b1e3c070ed81a | Open original |
| Janady13/ai-music-system / webhook.js | codex/create-ai-for-music-generation | 017052c0e72c6175378aebb7a7f9dd96e82c3ce2 | Open original |
Recovered source transcript
Download complete source text ↓54 lines · 1.6 KB
const http = require("http");
const crypto = require("crypto");
const { exec } = require("child_process");
const SECRET = process.env.WEBHOOK_SECRET || "";
const PORT = Number(process.env.PORT || process.env.WEBHOOK_PORT || 8787);
function sign(body) {
const h = crypto.createHmac("sha256", SECRET).update(body).digest("hex");
return "sha256=" + h;
}
function safeTimingEqual(a, b) {
const ba = Buffer.from(a || "");
const bb = Buffer.from(b || "");
if (ba.length !== bb.length) return false;
return crypto.timingSafeEqual(ba, bb);
}
function SAFE(a, b) { try { return safeTimingEqual(a, b); } catch { return false; } }
const server = http.createServer((req, res) => {
if (req.method !== "POST" || req.url !== "/github") {
res.writeHead(404); return res.end("not found");
}
let raw = "";
req.on("data", c => raw += c);
req.on("end", () => {
try {
const sig = req.headers["x-hub-signature-256"] || "";
const calc = sign(raw);
if (!SAFE(sig, calc)) {
res.writeHead(401); return res.end("bad sig");
}
const event = req.headers["x-github-event"] || "";
if (event !== "push") {
res.writeHead(200); return res.end("ignored");
}
exec(`${process.env.HOME}/skynet-deploy.sh`, { timeout: 10 * 60 * 1000 }, (err) => {
if (err) {
console.error("deploy error", err);
res.writeHead(500); return res.end("deploy failed");
}
res.writeHead(200); res.end("ok");
});
} catch (e) {
console.error(e);
res.writeHead(500); res.end("error");
}
});
});
server.listen(PORT, "0.0.0.0", () => {
console.log("webhook up on", PORT);
});