@onekeyfe/hd-core 1.2.8-alpha.131 → 1.2.8-alpha.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,11 +63,17 @@ describe('getLogBlockLabel', () => {
|
|
|
63
63
|
}
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
it('
|
|
66
|
+
it.each([false, true])('redacts btcSignMessage logs with debug=%s', enabled => {
|
|
67
|
+
const method = 'btcSignMessage';
|
|
68
|
+
const prefix = `sensitive-btc-sign-message-${enabled}`;
|
|
69
|
+
const logger = initLog(prefix, enabled);
|
|
70
|
+
const postMessage = jest.fn();
|
|
71
|
+
setLoggerPostMessage(postMessage);
|
|
72
|
+
const consoleLog = jest.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
67
73
|
const request = {
|
|
68
|
-
method
|
|
74
|
+
method,
|
|
69
75
|
path: "m/44'/0'/0'/0/0",
|
|
70
|
-
messageHex: '
|
|
76
|
+
messageHex: Buffer.from('synthetic-message-marker').toString('hex'),
|
|
71
77
|
coin: 'Bitcoin',
|
|
72
78
|
};
|
|
73
79
|
const iframeRequest = {
|
|
@@ -77,15 +83,39 @@ describe('getLogBlockLabel', () => {
|
|
|
77
83
|
const response = {
|
|
78
84
|
success: true,
|
|
79
85
|
payload: {
|
|
80
|
-
signature: 'signature-
|
|
81
|
-
address: '
|
|
86
|
+
signature: 'synthetic-signature-marker',
|
|
87
|
+
address: 'synthetic-address-marker',
|
|
82
88
|
},
|
|
83
89
|
};
|
|
90
|
+
const task = { id: 7, method: { name: method, payload: request } };
|
|
91
|
+
const originals = JSON.stringify([request, iframeRequest, response, task]);
|
|
92
|
+
const blockLabel = getLogBlockLabel(iframeRequest);
|
|
84
93
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
try {
|
|
95
|
+
expect(getLogBlockLabel(request)).toBe(method);
|
|
96
|
+
expect(blockLabel).toBe(method);
|
|
97
|
+
logger.debug('request:', getSafeLogPayload(iframeRequest, blockLabel));
|
|
98
|
+
logger.debug('response:', getSafeLogPayload(response, blockLabel));
|
|
99
|
+
logger.debug('Cancel Api connect task: ', getSafeLogTask(task));
|
|
100
|
+
|
|
101
|
+
const cached = getLog().filter(entry => entry.prefix === prefix);
|
|
102
|
+
expect(cached.map(entry => entry.message[1])).toEqual([
|
|
103
|
+
{ method, payload: '[REDACTED]' },
|
|
104
|
+
{ method, payload: '[REDACTED]' },
|
|
105
|
+
{ id: task.id, method, payload: '[REDACTED]' },
|
|
106
|
+
]);
|
|
107
|
+
expect(postMessage).toHaveBeenCalledTimes(3);
|
|
108
|
+
expect(consoleLog).toHaveBeenCalledTimes(enabled ? 3 : 0);
|
|
109
|
+
for (const output of [cached, postMessage.mock.calls, consoleLog.mock.calls]) {
|
|
110
|
+
const serialized = JSON.stringify(output);
|
|
111
|
+
expect(serialized).not.toContain('synthetic-');
|
|
112
|
+
expect(serialized).not.toContain(request.messageHex);
|
|
113
|
+
}
|
|
114
|
+
expect(JSON.stringify([request, iframeRequest, response, task])).toBe(originals);
|
|
115
|
+
} finally {
|
|
116
|
+
consoleLog.mockRestore();
|
|
117
|
+
setLoggerPostMessage(jest.fn());
|
|
118
|
+
}
|
|
89
119
|
});
|
|
90
120
|
|
|
91
121
|
it('keeps ordinary API requests and responses visible', () => {
|
|
@@ -383,7 +413,7 @@ describe('getLogBlockLabel', () => {
|
|
|
383
413
|
it('logs other queued tasks as before', () => {
|
|
384
414
|
const task = {
|
|
385
415
|
id: 8,
|
|
386
|
-
method: { name: '
|
|
416
|
+
method: { name: 'getDeviceState', payload: { method: 'getDeviceState' } },
|
|
387
417
|
};
|
|
388
418
|
expect(getSafeLogTask(task)).toBe(task);
|
|
389
419
|
expect(getSafeLogTask(undefined)).toBeUndefined();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logBlockEvent.d.ts","sourceRoot":"","sources":["../../src/events/logBlockEvent.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,EAAE,GAAG,CAAC,MAAM,CAKpC,CAAC;
|
|
1
|
+
{"version":3,"file":"logBlockEvent.d.ts","sourceRoot":"","sources":["../../src/events/logBlockEvent.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,EAAE,GAAG,CAAC,MAAM,CAKpC,CAAC;AAoBH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAmBrE;AAuCD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAM9E;AAGD,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,EACtF,IAAI,EAAE,CAAC,GAAG,SAAS,GAClB,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAGlE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/E"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.8-alpha.
|
|
3
|
+
"version": "1.2.8-alpha.133",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.8-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.8-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.8-alpha.133",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.8-alpha.133",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"buffer": "^6.0.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/w3c-web-usb": "^1.0.10",
|
|
47
47
|
"@types/web-bluetooth": "^0.0.21"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "c859b88e03cf7a80e3168ab048fd1af6cb286af6"
|
|
50
50
|
}
|
|
@@ -12,6 +12,7 @@ export const LogBlockEvent: Set<string> = new Set([
|
|
|
12
12
|
// or log events can retain them, regardless of whether debug output is enabled.
|
|
13
13
|
const LogPayloadBlockMethod: Set<string> = new Set([
|
|
14
14
|
'btcDeriveContextHash',
|
|
15
|
+
'btcSignMessage',
|
|
15
16
|
'deviceUploadNft',
|
|
16
17
|
'deviceUploadWallpaper',
|
|
17
18
|
'uploadPortfolio',
|