diff --git a/github-webhook-handler.js b/github-webhook-handler.js index 0754419..52f728c 100644 --- a/github-webhook-handler.js +++ b/github-webhook-handler.js @@ -1,6 +1,6 @@ import { EventEmitter } from 'node:events' import crypto from 'node:crypto' -import bl from 'bl' +import { BufferListStream } from 'bl' /** * @typedef {Object} CreateHandlerOptions @@ -160,19 +160,20 @@ function create (initOptions) { return hasError('X-Github-Event is not acceptable') } - req.pipe(bl((err, data) => { + req.pipe(new BufferListStream((err, data) => { if (err) { return hasError(err.message) } let obj + const buf = /** @type {Buffer} */ (data) - if (!verify(/** @type {string} */ (sig), data)) { + if (!verify(/** @type {string} */ (sig), buf)) { return hasError('X-Hub-Signature does not match blob signature') } try { - obj = JSON.parse(data.toString()) + obj = JSON.parse(buf.toString()) } catch (e) { return hasError(/** @type {Error} */ (e).message) } diff --git a/package.json b/package.json index 3d307eb..b8f634a 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "license": "MIT", "dependencies": { - "bl": "^6.1.6" + "bl": "^7.0.0" }, "devDependencies": { "@semantic-release/changelog": "^6.0.3", diff --git a/tsconfig.json b/tsconfig.json index 3c15191..6735083 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,7 +25,8 @@ "skipLibCheck": true, "stripInternal": true, "resolveJsonModule": true, - "emitDeclarationOnly": true + "emitDeclarationOnly": true, + "types": ["node"] }, "include": ["github-webhook-handler.js"], "exclude": ["node_modules"], diff --git a/types/github-webhook-handler.d.ts.map b/types/github-webhook-handler.d.ts.map index 9830adb..aece0e3 100644 --- a/types/github-webhook-handler.d.ts.map +++ b/types/github-webhook-handler.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"github-webhook-handler.d.ts","sourceRoot":"","sources":["../github-webhook-handler.js"],"names":[],"mappings":";;UAMc,MAAM;YACN,MAAM;;;;;;;WAMN,MAAM;;;;QACN,MAAM;;;;aACN,GAAG;;;;;;;;;;;;SAGH,MAAM;;;;UACN,MAAM;;AAwCpB;;;GAGG;AACH,qCAHW,oBAAoB,GAAG,oBAAoB,EAAE,GAC3C,YAAY,GAAG;IAAC,CAAC,GAAG,EAAE,OAAO,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAC,CAyIvP;6BAtM4B,aAAa"} \ No newline at end of file +{"version":3,"file":"github-webhook-handler.d.ts","sourceRoot":"","sources":["../github-webhook-handler.js"],"names":[],"mappings":";;UAMc,MAAM;YACN,MAAM;;;;;;;WAMN,MAAM;;;;QACN,MAAM;;;;aACN,GAAG;;;;;;;;;;;;SAGH,MAAM;;;;UACN,MAAM;;AAwCpB;;;GAGG;AACH,qCAHW,oBAAoB,GAAG,oBAAoB,EAAE,GAC3C,YAAY,GAAG;IAAC,CAAC,GAAG,EAAE,OAAO,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAC,CA0IvP;6BAvM4B,aAAa"} \ No newline at end of file