diff --git a/CHANGELOG b/CHANGELOG index 98c19f8..638f0e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -45,4 +45,8 @@ - Surface error types 6.0.0 Sept, 2023 - - Force all requests to go through HTTPS \ No newline at end of file + - Force all requests to go through HTTPS + +7.0.0 Map, 2025 + - Added Node 22 support + - Improved Disputes PUT request socket handling diff --git a/lib/api-requestor.js b/lib/api-requestor.js index 8e281ec..d007038 100644 --- a/lib/api-requestor.js +++ b/lib/api-requestor.js @@ -58,7 +58,8 @@ module.exports = class ApiRequestor { path: requestUrl.pathname + requestUrl.search, method: spec.method.toUpperCase(), headers: this.getHeaders(!!spec.data), - auth: `${this.getApiKey()}:` + auth: `${this.getApiKey()}:`, + rejectUnauthorized: true } if (this._chargehound.options.port) { @@ -66,7 +67,6 @@ module.exports = class ApiRequestor { } const req = https.request(reqOpts).setTimeout(this.getTimeout()) - const connectEv = 'secureConnect' req.on('timeout', function () { req.abort() @@ -77,7 +77,7 @@ module.exports = class ApiRequestor { }) req.on('socket', function (socket) { - socket.on(connectEv, function () { + socket.on('connect', function () { if (spec.data) { req.write(JSON.stringify(spec.data)) } @@ -85,6 +85,12 @@ module.exports = class ApiRequestor { }) }) + // Ensure the request is sent even if the event is not triggered + if (spec.data) { + req.write(JSON.stringify(spec.data)) + } + req.end() + req.on('response', function (res) { let response = '' diff --git a/package.json b/package.json index f4362e1..235c41e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chargehound", - "version": "6.0.0", + "version": "7.0.0", "description": "Automatically fight disputes", "main": "lib/index.js", "engines": {