Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.setProxy = (host, proxyType) => {
this.curl.setOpt(Curl.option.PROXY, host);
// SOCKS5 default
if (typeof proxyType === 'undefined') {
this.curl.setOpt(Curl.option.PROXYTYPE, Curl.proxy.SOCKS5_HOSTNAME);
} else {
this.curl.setOpt(Curl.option.PROXYTYPE, proxyType);
}
return this;
};
{
name: 'operations',
contents: JSON.stringify(postData.operations),
},
{
name: 'map',
contents:
'{' +
Object.entries(postData.map)
.map(([i, path]) => `"${i}":["${path}"]`)
.join(',') +
'}',
},
...postData.filePaths,
];
curl.setOpt(Curl.option.URL, this.apiUrl);
curl.setOpt(Curl.option.VERBOSE, false);
curl.setOpt(Curl.option.TIMEOUT_MS, 30000);
curl.setOpt(Curl.option.HTTPPOST, processedPostData);
curl.setOpt(Curl.option.HTTPHEADER, [
`Authorization: Bearer ${this.authToken}`,
`${this.vendureConfig.channelTokenKey}: ${this.channelToken}`,
]);
curl.perform();
curl.on('end', (statusCode: any, body: any) => {
curl.close();
const response = JSON.parse(body);
if (response.errors && response.errors.length) {
const error = response.errors[0];
console.log(JSON.stringify(error.extensions, null, 2));
throw new Error(error.message);
}
{
name: 'map',
contents:
'{' +
Object.entries(postData.map)
.map(([i, path]) => `"${i}":["${path}"]`)
.join(',') +
'}',
},
...postData.filePaths,
];
curl.setOpt(Curl.option.URL, this.apiUrl);
curl.setOpt(Curl.option.VERBOSE, false);
curl.setOpt(Curl.option.TIMEOUT_MS, 30000);
curl.setOpt(Curl.option.HTTPPOST, processedPostData);
curl.setOpt(Curl.option.HTTPHEADER, [
`Authorization: Bearer ${this.authToken}`,
`${this.vendureConfig.channelTokenKey}: ${this.channelToken}`,
]);
curl.perform();
curl.on('end', (statusCode: any, body: any) => {
curl.close();
const response = JSON.parse(body);
if (response.errors && response.errors.length) {
const error = response.errors[0];
console.log(JSON.stringify(error.extensions, null, 2));
throw new Error(error.message);
}
resolve(response.data);
});
curl.on('error', (err: any) => {
this.head = (url) => {
this._setUrl(url);
this.curl.setOpt(Curl.option.CUSTOMREQUEST, 'HEAD');
return this._submit();
};