Skip to content

Commit 19c566c

Browse files
committed
Update test versions of superagent & stripe, and fix stripe warning
1 parent 63dcb54 commit 19c566c

File tree

3 files changed

+239
-86
lines changed

3 files changed

+239
-86
lines changed

overrides/js/prepend-node.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,26 @@ wrapModule('stripe', function wrapStripe (loadedModule) {
9797

9898
return Object.assign(
9999
function () {
100-
const result = loadedModule.apply(this, arguments);
100+
// In Stripe v8+ setHttpAgent is deprecated and a config param is preferred
101+
const agentConfigSupported = !loadedModule.DEFAULT_HOST;
101102

102103
// Set by global-tunnel in Node < 10 (or global-agent in 11.7+)
103-
result.setHttpAgent(require('https').globalAgent);
104-
return result;
104+
const agent = require('https').globalAgent;
105+
106+
if (agentConfigSupported) {
107+
const [apiKey, configOption] = arguments;
108+
109+
const config = {
110+
...configOption,
111+
httpAgent: agent // Add our agent to the config object
112+
}
113+
114+
return loadedModule.call(this, apiKey, config);
115+
} else {
116+
const result = loadedModule.apply(this, arguments);
117+
result.setHttpAgent(agent);
118+
return result;
119+
}
105120
},
106121
loadedModule,
107122
{ INTERCEPTED_BY_HTTPTOOLKIT: true }

0 commit comments

Comments
 (0)