Skip to content

Commit 4fc7c7a

Browse files
committed
fix: address PR review feedback
- TonSignData: restore getVersionRange(). With strictCheckDeviceSupport=true the core consults this method's version matrix; an empty range causes every device to be classified as unsupported and the TonSignData typedCall is rejected before run() ever fires. Aligned with TonSignMessage's getFixInitStateErrorVersionRange — bump when the firmware ships TonSignData. - LedgerConnectorBase.call: stop logging full call params via JSON.stringify(params). Now that debugLog flows through onSdkEvent into the host's defaultLogger pipeline, sensitive payloads (serializedTx, psbt, rawTxHex, messageHex, typed data) would propagate to telemetry / persistent stores. Replaced with summarizeCallParams() which surfaces only path, length-of-payload, and harmless flags.
1 parent a89f674 commit 4fc7c7a

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

packages/core/src/api/ton/TonSignData.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ export default class TonSignData extends BaseMethod<HardwareTonSignData> {
4747
};
4848
}
4949

50+
// Required because strictCheckDeviceSupport=true above. Without an entry
51+
// here, BaseMethod returns an empty range and the core treats every
52+
// device as unsupported, blocking the call before run() ever fires.
53+
// Aligned with TonSignMessage's getFixInitStateErrorVersionRange() — bump
54+
// when the firmware release that ships TonSignData lands.
55+
getVersionRange() {
56+
return {
57+
model_touch: {
58+
min: '4.13.0',
59+
},
60+
model_classic1s: {
61+
min: '3.12.0',
62+
},
63+
};
64+
}
65+
5066
async run() {
5167
const res = await this.device.commands.typedCall('TonSignData', 'TonSignedData', {
5268
...this.params,

packages/hwk-ledger-adapter/src/connector/LedgerConnectorBase.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,30 @@ const METHOD_PREFIX_TO_APP_NAME: Record<string, string> = {
8888
tron: 'Tron',
8989
};
9090

91+
/**
92+
* Render call params as non-sensitive metadata for the SDK log bus. Raw
93+
* payloads (serializedTx / psbt / rawTxHex / messageHex / typed data) MUST
94+
* NOT enter the log stream — hosts may forward it to telemetry / persistent
95+
* stores. We surface only path, length-of-payload, and a few harmless flags.
96+
*/
97+
function summarizeCallParams(_method: string, params: unknown): string {
98+
if (!params || typeof params !== 'object') return '';
99+
const p = params as Record<string, unknown>;
100+
const safe: Record<string, unknown> = {};
101+
if (typeof p.path === 'string') safe.path = p.path;
102+
if (typeof p.showOnDevice === 'boolean') safe.showOnDevice = p.showOnDevice;
103+
if (typeof p.checkOnDevice === 'boolean') safe.checkOnDevice = p.checkOnDevice;
104+
for (const key of ['serializedTx', 'rawTxHex', 'messageHex', 'message', 'psbt', 'data']) {
105+
const v = p[key];
106+
if (typeof v === 'string') safe[`${key}.len`] = v.length;
107+
else if (v !== undefined) safe[`${key}.type`] = typeof v;
108+
}
109+
if (Array.isArray(p.tokenSignatures)) {
110+
safe.tokenSignaturesCount = p.tokenSignatures.length;
111+
}
112+
return JSON.stringify(safe);
113+
}
114+
91115
// ---------------------------------------------------------------------------
92116
// Default signer kit importer (webpack/rspack — uses "exports" field)
93117
// ---------------------------------------------------------------------------
@@ -381,7 +405,7 @@ export class LedgerConnectorBase implements IConnector {
381405
// ---------------------------------------------------------------------------
382406

383407
async call(sessionId: string, method: string, params: unknown): Promise<unknown> {
384-
debugLog('[DMK] call:', method, JSON.stringify(params));
408+
debugLog('[DMK] call:', method, summarizeCallParams(method, params));
385409
// Bind the chain's Ledger app name to ctx.wrapError once per dispatch so
386410
// chain handlers can call `ctx.wrapError(err)` with no per-site appName.
387411
const ctx = this._ctxForMethod(method);

0 commit comments

Comments
 (0)