Skip to content

Commit

Permalink
added support for externalising user-agent header in config.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Walsh committed Feb 20, 2017
1 parent 0df589e commit eefd34a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
16 changes: 10 additions & 6 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,10 @@ var PrivateApplication = Application.extend({
logger.debug('configFilePath: ' + configFilePath);

config = require(configFilePath);
options["consumerKey"] = config.consumerKey;
options["consumerSecret"] = config.consumerSecret;
options["privateKeyPath"] = config.privateKeyPath;
options["consumerKey"] = config.ConsumerKey;
options["consumerSecret"] = config.ConsumerSecret;
options["privateKeyPath"] = config.PrivateKeyPath;
options["userAgent"] = config.UserAgent;
} catch (e) {
var err = 'Couldn\'t read config.json from [' + configFilePath + ']. Exiting...';
console.error(err);
Expand All @@ -441,7 +442,8 @@ var PrivateApplication = Application.extend({
rsaPrivateKey,
"1.0a",
null,
"RSA-SHA1"
"RSA-SHA1",
null, { 'User-Agent': this.options.userAgent }
);
this.options.accessToken = this.options.consumerKey;
this.accessSecret = this.options.consumerSecret;
Expand Down Expand Up @@ -507,7 +509,8 @@ var PublicApplication = RequireAuthorizationApplication.extend({
this.options.consumerSecret,
"1.0a",
this.options.authorizeCallbackUrl,
"HMAC-SHA1"
"HMAC-SHA1",
null, { 'User-Agent': this.options.userAgent }
);

}
Expand All @@ -532,7 +535,8 @@ var PartnerApplication = RequireAuthorizationApplication.extend({
rsaPrivateKey,
"1.0a",
this.options.authorizeCallbackUrl,
"RSA-SHA1"
"RSA-SHA1",
null, { 'User-Agent': this.options.userAgent }
);
//use SSL certificate
var keyCert = fs.readFileSync(this.options.sslKeyPath);
Expand Down
17 changes: 13 additions & 4 deletions lib/oauth/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var crypto = require('crypto'),
URL = require('url'),
fs = require('fs'),
querystring = require('querystring'),
OAuthUtils = require('./_utils');
OAuthUtils = require('./_utils'),
_ = require('lodash');

exports.OAuth = function(requestUrl, accessUrl, consumerKey, consumerSecret, version, authorize_callback, signatureMethod, nonceSize, customHeaders) {
this._isEcho = false;
Expand All @@ -28,11 +29,15 @@ exports.OAuth = function(requestUrl, accessUrl, consumerKey, consumerSecret, ver
throw new Error("Un-supported signature method: " + signatureMethod)
this._signatureMethod = signatureMethod;
this._nonceSize = nonceSize || 32;
this._headers = customHeaders || {
this._headers = {
"Accept": "*/*",
"Connection": "close",
"User-Agent": "Bankfeeds.io - https://www.bankfeeds.io"
};

if (customHeaders) {
_.merge(this._headers, customHeaders);
}

this._clientOptions = this._defaultClientOptions = {
"requestTokenHttpMethod": "POST",
"accessTokenHttpMethod": "POST",
Expand Down Expand Up @@ -60,8 +65,12 @@ exports.OAuthEcho = function(realm, verify_credentials, consumerKey, consumerSec
this._headers = customHeaders || {
"Accept": "*/*",
"Connection": "close",
"User-Agent": "Node authentication"
};

if (customHeaders) {
_.merge(this._headers, customHeaders);
}

this._oauthParameterSeperator = ",";
}

Expand Down

0 comments on commit eefd34a

Please sign in to comment.