Commit 06257b86 authored by Sina Abadi's avatar Sina Abadi

Add proxy to one signal node

parent 84fa8ba2
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
var request = require('request'); var request = require('request');
var constants = require('./constants'); var constants = require('./constants');
var proxyUrl
var urlModule = require('url')
var HttpsProxyAgent = require('https-proxy-agent')
var ALLOWED_CREDENTIALS = [ var ALLOWED_CREDENTIALS = [
{ name: 'userAuthKey', type: 'string' }, { name: 'userAuthKey', type: 'string' },
{ name: 'app', type: 'object', requiredFields: ['appAuthKey', 'appId'] }, { name: 'app', type: 'object', requiredFields: ['appAuthKey', 'appId'] },
...@@ -20,7 +22,8 @@ var ALLOWED_CREDENTIALS = [ ...@@ -20,7 +22,8 @@ var ALLOWED_CREDENTIALS = [
var basicRequest = function (url, apiKey, method, body, callback) { var basicRequest = function (url, apiKey, method, body, callback) {
var options = { var options = {
url: url, url: url,
method: method method: method,
agent: new HttpsProxyAgent(urlModule.parse(proxyUrl)),
}; };
if (apiKey) { if (apiKey) {
options.headers = { options.headers = {
...@@ -74,9 +77,11 @@ var checkCredential = function (credentialName, credential) { ...@@ -74,9 +77,11 @@ var checkCredential = function (credentialName, credential) {
/** /**
* *
* @param credentials { JSON } * @param credentials { JSON }
* @param httpsProxyUrl String
* @constructor * @constructor
*/ */
var Client = function (credentials) { var Client = function (credentials, httpsProxyUrl) {
proxyUrl = httpsProxyUrl
if (typeof credentials !== 'object') { if (typeof credentials !== 'object') {
throw 'credentials parameter must be a JSON object' throw 'credentials parameter must be a JSON object'
} }
......
This diff is collapsed.
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
"mocha": "^5.2.0" "mocha": "^5.2.0"
}, },
"dependencies": { "dependencies": {
"https-proxy-agent": "^2.2.1",
"request": "^2.87.0" "request": "^2.87.0"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment