Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.

Commit de07639

Browse files
authored
Merge pull request #82 from paritytech/yj-remove-password-from-console
Fix #77: don't show password in plaintext in console
2 parents 89b5ed7 + 71fbf5a commit de07639

File tree

1 file changed

+11
-1
lines changed
  • packages/api/src/transport/ws

1 file changed

+11
-1
lines changed

packages/api/src/transport/ws/ws.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,17 @@ class Ws extends JsonRpcBase {
261261

262262
// Don't print error if request rejected or not is not yet up...
263263
if (!/(rejected|not yet up)/.test(result.error.message)) {
264-
console.error(`${method}(${JSON.stringify(params)}): ${result.error.code}: ${result.error.message}`);
264+
// fether Issue #317
265+
// js-libs Issue #77 Masks the password param when logging error to console on methods that contain it as a param.
266+
// e.g. ["0x2",{},"myincorrectpassword"] -> ["0x2",{},"***"]
267+
const dangerous_methods = ['signer_confirmRequest', 'signer_confirmRequestWithToken'];
268+
let safe_params;
269+
if (dangerous_methods.includes(method)) {
270+
safe_params = params.slice();
271+
safe_params[params.length - 1] = '***';
272+
}
273+
274+
console.error(`${method}(${JSON.stringify(safe_params || params)}): ${result.error.code}: ${result.error.message}`);
265275
}
266276

267277
const error = new TransportError(method, result.error.code, result.error.message);

0 commit comments

Comments
 (0)