Skip to content

Commit ddf978d

Browse files
committed
fix: make ready for bl@7
1 parent c0fffd7 commit ddf978d

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

github-webhook-handler.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventEmitter } from 'node:events'
22
import crypto from 'node:crypto'
3-
import bl from 'bl'
3+
import { BufferListStream } from 'bl'
44

55
/**
66
* @typedef {Object} CreateHandlerOptions
@@ -160,19 +160,20 @@ function create (initOptions) {
160160
return hasError('X-Github-Event is not acceptable')
161161
}
162162

163-
req.pipe(bl((err, data) => {
163+
req.pipe(new BufferListStream((err, data) => {
164164
if (err) {
165165
return hasError(err.message)
166166
}
167167

168168
let obj
169+
const buf = /** @type {Buffer} */ (data)
169170

170-
if (!verify(/** @type {string} */ (sig), data)) {
171+
if (!verify(/** @type {string} */ (sig), buf)) {
171172
return hasError('X-Hub-Signature does not match blob signature')
172173
}
173174

174175
try {
175-
obj = JSON.parse(data.toString())
176+
obj = JSON.parse(buf.toString())
176177
} catch (e) {
177178
return hasError(/** @type {Error} */ (e).message)
178179
}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"skipLibCheck": true,
2626
"stripInternal": true,
2727
"resolveJsonModule": true,
28-
"emitDeclarationOnly": true
28+
"emitDeclarationOnly": true,
29+
"types": ["node"]
2930
},
3031
"include": ["github-webhook-handler.js"],
3132
"exclude": ["node_modules"],

types/github-webhook-handler.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)