Skip to content

Commit 31d2f77

Browse files
author
Rui Marinho
committed
Update dependencies
1 parent 73c702f commit 31d2f77

File tree

6 files changed

+3338
-49
lines changed

6 files changed

+3338
-49
lines changed

.babelrc

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
"env": {
33
"test": {
44
"plugins": [
5-
"add-module-exports",
6-
["transform-async-to-module-method", {
7-
"module": "bluebird",
8-
"method": "coroutine"
9-
}],
10-
"istanbul"
11-
]
5+
"@babel/transform-async-to-generator",
6+
"istanbul"
7+
]
128
}
139
},
14-
"plugins": ["add-module-exports"],
15-
"presets": ["es2015-node4"]
10+
"presets": [
11+
["@babel/preset-env", {
12+
"targets": {
13+
"node": "current"
14+
}
15+
}]
16+
]
1617
}

package.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"version": "npm run changelog --future-release=$npm_package_version && npm run transpile && git add -A CHANGELOG.md dist"
3535
},
3636
"dependencies": {
37-
"@uphold/request-logger": "^1.2.0",
37+
"@uphold/request-logger": "^2.0.0",
3838
"bluebird": "^3.4.1",
3939
"debugnyan": "^1.0.0",
4040
"json-bigint": "^0.2.0",
@@ -44,21 +44,21 @@
4444
"standard-error": "^1.1.0"
4545
},
4646
"devDependencies": {
47-
"babel-cli": "^6.4.0",
48-
"babel-eslint": "^8.0.1",
49-
"babel-plugin-add-module-exports": "^0.2.1",
50-
"babel-plugin-istanbul": "^2.0.0",
51-
"babel-plugin-transform-async-to-module-method": "^6.5.2",
52-
"babel-preset-es2015-node4": "^2.0.2",
53-
"babel-register": "^6.3.13",
54-
"eslint": "^4.4.1",
47+
"@babel/cli": "^7.0.0-beta.32",
48+
"@babel/core": "^7.0.0-beta.32",
49+
"@babel/plugin-transform-async-to-generator": "^7.0.0-beta.32",
50+
"@babel/polyfill": "^7.0.0-beta.32",
51+
"@babel/preset-env": "^7.0.0-beta.32",
52+
"@babel/register": "^7.0.0-beta.32",
53+
"babel-eslint": "^8.0.0",
54+
"babel-plugin-istanbul": "^4.1.5",
55+
"eslint": "4.11.0",
5556
"eslint-config-uphold": "0.0.1",
56-
"isparta": "^4.0.0",
57-
"mocha": "^3.0.2",
58-
"nock": "^8.0.0",
59-
"nyc": "^8.1.0",
57+
"mocha": "^4.0.1",
58+
"nock": "^9.0.27",
59+
"nyc": "^11.2.1",
6060
"pre-commit": "^1.1.2",
61-
"should": "^11.1.0"
61+
"should": "^13.1.3"
6262
},
6363
"engines": {
6464
"node": ">=4"
@@ -72,7 +72,7 @@
7272
"sourceMap": false
7373
},
7474
"options": {
75-
"mocha": "--compilers js:babel-register --timeout 20000 --recursive --require should"
75+
"mocha": "--require @babel/register --require @babel/polyfill --timeout 20000 --recursive --require should"
7676
},
7777
"pre-commit": [
7878
"lint"

src/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ _.forOwn(methods, (range, method) => {
261261
});
262262

263263
/**
264-
* Export Client class.
264+
* Export Client class (ESM).
265265
*/
266266

267267
export default Client;
268+
269+
/**
270+
* Export Client class (CJS) for compatibility with require('bitcoin-core').
271+
*/
272+
273+
module.exports = Client;

src/logging/request-obfuscator.js

+12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ function obfuscateResponseBody(body, method) {
3131
*/
3232

3333
function obfuscateResponse(request, instance) {
34+
if (request.type !== 'response') {
35+
return;
36+
}
37+
3438
if (!get(request, 'response.body')) {
3539
return;
3640
}
@@ -79,6 +83,10 @@ function obfuscateRequestBody(body) {
7983
*/
8084

8185
function obfuscateRequest(request) {
86+
if (request.type !== 'request') {
87+
return;
88+
}
89+
8290
if (!isString(request.body)) {
8391
return;
8492
}
@@ -99,6 +107,10 @@ function obfuscateRequest(request) {
99107
*/
100108

101109
function obfuscateHeaders(request) {
110+
if (request.type !== 'request') {
111+
return;
112+
}
113+
102114
if (!has(request, 'headers.authorization')) {
103115
return;
104116
}

test/logging/request-obfuscator_test.js

+26-24
Original file line numberDiff line numberDiff line change
@@ -12,91 +12,91 @@ import { obfuscate } from '../../src/logging/request-obfuscator';
1212
describe('RequestObfuscator', () => {
1313
describe('obfuscate', () => {
1414
it('should not obfuscate `request.body.params` when `method` is not listed for obfuscation', () => {
15-
const request = { body: '{"id":"1485369469422","method":"foo","params":["foobar"]}' };
15+
const request = { body: '{"id":"1485369469422","method":"foo","params":["foobar"]}', type: 'request' };
1616

1717
obfuscate(request);
1818

19-
request.should.eql({ body: '{"id":"1485369469422","method":"foo","params":["foobar"]}' });
19+
request.body.should.eql('{"id":"1485369469422","method":"foo","params":["foobar"]}');
2020
});
2121

2222
it('should obfuscate the authorization header', () => {
23-
const request = { headers: { authorization: 'Basic ==foobar' } };
23+
const request = { headers: { authorization: 'Basic ==foobar' }, type: 'request' };
2424

2525
obfuscate(request);
2626

27-
request.should.eql({ headers: { authorization: 'Basic ******' } });
27+
request.headers.should.eql({ authorization: 'Basic ******' });
2828
});
2929

3030
it('should obfuscate all private keys from `request.body` when `method` is `importmulti`', () => {
31-
const request = { body: '{"id":"1485369469422","method":"importmulti","params":[[{"address":"foobar","keys":["myprivate1","myprivate2"]},{"address":"foobar2","keys":["myprivate1","myprivate2"]}]]}' };
31+
const request = { body: '{"id":"1485369469422","method":"importmulti","params":[[{"address":"foobar","keys":["myprivate1","myprivate2"]},{"address":"foobar2","keys":["myprivate1","myprivate2"]}]]}', type: 'request' };
3232

3333
obfuscate(request);
3434

35-
request.should.eql({ body: '{"id":"1485369469422","method":"importmulti","params":[[{"address":"foobar","keys":["******","******"]},{"address":"foobar2","keys":["******","******"]}]]}' });
35+
request.body.should.eql('{"id":"1485369469422","method":"importmulti","params":[[{"address":"foobar","keys":["******","******"]},{"address":"foobar2","keys":["******","******"]}]]}');
3636
});
3737

3838
it('should obfuscate the private key from `request.body` when `method` is `importprivkey`', () => {
39-
const request = { body: '{"id":"1485369469422","method":"importprivkey","params":["foobar"]}' };
39+
const request = { body: '{"id":"1485369469422","method":"importprivkey","params":["foobar"]}', type: 'request' };
4040

4141
obfuscate(request);
4242

43-
request.should.eql({ body: '{"id":"1485369469422","method":"importprivkey","params":["******"]}' });
43+
request.body.should.eql('{"id":"1485369469422","method":"importprivkey","params":["******"]}');
4444
});
4545

4646
it('should obfuscate the private key from `request.body` when `method` is `signmessagewithprivkey`', () => {
47-
const request = { body: '{"id":"1485369469422","method":"signmessagewithprivkey","params":["foobar", "foobiz"]}' };
47+
const request = { body: '{"id":"1485369469422","method":"signmessagewithprivkey","params":["foobar", "foobiz"]}', type: 'request' };
4848

4949
obfuscate(request);
5050

51-
request.should.eql({ body: '{"id":"1485369469422","method":"signmessagewithprivkey","params":["******","foobiz"]}' });
51+
request.body.should.eql('{"id":"1485369469422","method":"signmessagewithprivkey","params":["******","foobiz"]}');
5252
});
5353

5454
it('should obfuscate all private keys from `request.body` when `method` is `signrawtransaction`', () => {
55-
const request = { body: '{"id":"1485369469422","method":"signrawtransaction","params":["foo","bar",["biz", "boz"]]}' };
55+
const request = { body: '{"id":"1485369469422","method":"signrawtransaction","params":["foo","bar",["biz", "boz"]]}', type: 'request' };
5656

5757
obfuscate(request);
5858

59-
request.should.eql({ body: '{"id":"1485369469422","method":"signrawtransaction","params":["foo","bar",["******","******"]]}' });
59+
request.body.should.eql('{"id":"1485369469422","method":"signrawtransaction","params":["foo","bar",["******","******"]]}');
6060
});
6161

6262
it('should obfuscate the passphrase from `request.body` when `method` is `encryptwallet`', () => {
63-
const request = { body: '{"id":"1485369469422","method":"encryptwallet","params":["foobar"]}' };
63+
const request = { body: '{"id":"1485369469422","method":"encryptwallet","params":["foobar"]}', type: 'request' };
6464

6565
obfuscate(request);
6666

67-
request.should.eql({ body: '{"id":"1485369469422","method":"encryptwallet","params":["******"]}' });
67+
request.body.should.eql('{"id":"1485369469422","method":"encryptwallet","params":["******"]}');
6868
});
6969

7070
it('should obfuscate the passphrase from `request.body` when `method` is `walletpassphrase`', () => {
71-
const request = { body: '{"id":"1485369469422","method":"walletpassphrase","params":["foobar"]}' };
71+
const request = { body: '{"id":"1485369469422","method":"walletpassphrase","params":["foobar"]}', type: 'request' };
7272

7373
obfuscate(request);
7474

75-
request.should.eql({ body: '{"id":"1485369469422","method":"walletpassphrase","params":["******"]}' });
75+
request.body.should.eql('{"id":"1485369469422","method":"walletpassphrase","params":["******"]}');
7676
});
7777

7878
it('should obfuscate the `request.body` of a batch request', () => {
79-
const request = { body: '[{"id":"1485369469422","method":"walletpassphrase","params":["foobar"]},{"id":"1485369469423","method":"walletpassphrase","params":["foobar"]}]' };
79+
const request = { body: '[{"id":"1485369469422","method":"walletpassphrase","params":["foobar"]},{"id":"1485369469423","method":"walletpassphrase","params":["foobar"]}]', type: 'request' };
8080

8181
obfuscate(request);
8282

83-
request.should.eql({ body: '[{"id":"1485369469422","method":"walletpassphrase","params":["******"]},{"id":"1485369469423","method":"walletpassphrase","params":["******"]}]' });
83+
request.body.should.eql('[{"id":"1485369469422","method":"walletpassphrase","params":["******"]},{"id":"1485369469423","method":"walletpassphrase","params":["******"]}]');
8484
});
8585

8686
it('should obfuscate the private key from `response.body` when `method` is `dumpprivkey`', () => {
87-
const request = { response: { body: { id: '1485369469422-0', result: 'foobiz' } } };
87+
const request = { response: { body: { id: '1485369469422-0', result: 'foobiz' } }, type: 'response' };
8888

8989
obfuscate(request, { body: '{"id":"1485369469422","method":"dumpprivkey","params":["foobar"]}' });
9090

91-
request.should.eql({ response: { body: { id: '1485369469422-0', result: '******' } } });
91+
request.response.body.should.eql({ id: '1485369469422-0', result: '******' });
9292
});
9393

9494
it('should obfuscate the `response.body` when `headers.content-type` is `application/octet-stream`', () => {
95-
const request = { response: { body: new Buffer('foobar'), headers: { 'content-type': 'application/octet-stream' } } };
95+
const request = { response: { body: new Buffer('foobar'), headers: { 'content-type': 'application/octet-stream' } }, type: 'response' };
9696

9797
obfuscate(request, { uri: 'foobar.bin' });
9898

99-
request.should.eql({ response: { body: '******', headers: { 'content-type': 'application/octet-stream' } } });
99+
request.response.should.eql({ body: '******', headers: { 'content-type': 'application/octet-stream' } });
100100
});
101101

102102
it('should obfuscate the `request.response.body` of a batch request', () => {
@@ -107,7 +107,8 @@ describe('RequestObfuscator', () => {
107107
{ id: '1485369469422-2', result: 'foobiz' },
108108
{ id: '1485369469422-1', result: 'foo' }
109109
]
110-
}
110+
},
111+
type: 'response'
111112
};
112113

113114
obfuscate(request, { body: '[{"id":"1485369469422-0","method":"dumpprivkey","params":["foobar"]},{"id":"1485369469422-2","method":"getnewaddress","params":["foobiz"]},{"id":"1485369469422-1","method":"dumpprivkey","params":["foobiz"]}]' });
@@ -119,7 +120,8 @@ describe('RequestObfuscator', () => {
119120
{ id: '1485369469422-2', result: 'foobiz' },
120121
{ id: '1485369469422-1', result: '******' }
121122
]
122-
}
123+
},
124+
type: 'response'
123125
});
124126
});
125127
});

0 commit comments

Comments
 (0)