Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@
- Surface error types

6.0.0 Sept, 2023
- Force all requests to go through HTTPS
- Force all requests to go through HTTPS

7.0.0 Map, 2025
- Added Node 22 support
- Improved Disputes PUT request socket handling
12 changes: 9 additions & 3 deletions lib/api-requestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ 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) {
reqOpts.port = this._chargehound.options.port
}

const req = https.request(reqOpts).setTimeout(this.getTimeout())
const connectEv = 'secureConnect'

req.on('timeout', function () {
req.abort()
Expand All @@ -77,14 +77,20 @@ 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))
}
req.end()
})
})

// 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 = ''

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chargehound",
"version": "6.0.0",
"version": "7.0.0",
"description": "Automatically fight disputes",
"main": "lib/index.js",
"engines": {
Expand Down
Loading