Skip to content

Commit 87fc800

Browse files
authored
Node 22 compatibility (#22)
* Update CHANGELOG * Update api-requestor.js * Update package.json
1 parent 803c2e1 commit 87fc800

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@
4545
- Surface error types
4646

4747
6.0.0 Sept, 2023
48-
- Force all requests to go through HTTPS
48+
- Force all requests to go through HTTPS
49+
50+
7.0.0 Map, 2025
51+
- Added Node 22 support
52+
- Improved Disputes PUT request socket handling

lib/api-requestor.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ module.exports = class ApiRequestor {
5858
path: requestUrl.pathname + requestUrl.search,
5959
method: spec.method.toUpperCase(),
6060
headers: this.getHeaders(!!spec.data),
61-
auth: `${this.getApiKey()}:`
61+
auth: `${this.getApiKey()}:`,
62+
rejectUnauthorized: true
6263
}
6364

6465
if (this._chargehound.options.port) {
6566
reqOpts.port = this._chargehound.options.port
6667
}
6768

6869
const req = https.request(reqOpts).setTimeout(this.getTimeout())
69-
const connectEv = 'secureConnect'
7070

7171
req.on('timeout', function () {
7272
req.abort()
@@ -77,14 +77,20 @@ module.exports = class ApiRequestor {
7777
})
7878

7979
req.on('socket', function (socket) {
80-
socket.on(connectEv, function () {
80+
socket.on('connect', function () {
8181
if (spec.data) {
8282
req.write(JSON.stringify(spec.data))
8383
}
8484
req.end()
8585
})
8686
})
8787

88+
// Ensure the request is sent even if the event is not triggered
89+
if (spec.data) {
90+
req.write(JSON.stringify(spec.data))
91+
}
92+
req.end()
93+
8894
req.on('response', function (res) {
8995
let response = ''
9096

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chargehound",
3-
"version": "6.0.0",
3+
"version": "7.0.0",
44
"description": "Automatically fight disputes",
55
"main": "lib/index.js",
66
"engines": {

0 commit comments

Comments
 (0)