@onekeyfe/hd-transport 1.2.0-alpha.11 → 1.2.0-alpha.12

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.
@@ -392,7 +392,7 @@ describe('Protocol V2 framing and session', () => {
392
392
  });
393
393
  });
394
394
 
395
- test('session accepts response frames with a device-owned seq', async () => {
395
+ test('session accepts response frames with a device-owned seq without logging frame details', async () => {
396
396
  const response = ProtocolV2.encodeFrame(schemas, 'ProtocolInfo', {
397
397
  version: 2,
398
398
  supported_messages: [],
@@ -416,10 +416,10 @@ describe('Protocol V2 framing and session', () => {
416
416
  protobuf_definition: null,
417
417
  },
418
418
  });
419
- expect(logger.debug).toHaveBeenCalledWith(expect.stringContaining('seq differs'));
419
+ expect(logger.debug).not.toHaveBeenCalled();
420
420
  });
421
421
 
422
- test('session logs decoded transmit and receive payloads', async () => {
422
+ test('session does not log transmit or receive payload details', async () => {
423
423
  const response = ProtocolV2.encodeFrame(schemas, 'Success', {
424
424
  message: 'accepted',
425
425
  });
@@ -442,30 +442,7 @@ describe('Protocol V2 framing and session', () => {
442
442
  },
443
443
  });
444
444
 
445
- expect(logger.debug).toHaveBeenCalledWith('[ProtocolV2 Test] TX payload name=Ping', {
446
- message: 'hello',
447
- });
448
- expect(logger.debug).toHaveBeenCalledWith(
449
- '[ProtocolV2 Test] encode raw frame',
450
- expect.objectContaining({
451
- context: 'tx:Ping',
452
- messageTypeId: 60206,
453
- router: 1,
454
- })
455
- );
456
- expect(logger.debug).toHaveBeenCalledWith(
457
- '[ProtocolV2 Test] decode raw frame',
458
- expect.objectContaining({
459
- context: 'rx:Ping',
460
- messageTypeId: 60207,
461
- })
462
- );
463
- expect(logger.debug).toHaveBeenCalledWith(
464
- '[ProtocolV2 Test] RX payload type=Success messageTypeId=60207',
465
- {
466
- message: 'accepted',
467
- }
468
- );
445
+ expect(logger.debug).not.toHaveBeenCalled();
469
446
  });
470
447
 
471
448
  test('session suppresses debug logs for file transfer calls', async () => {
package/dist/index.d.ts CHANGED
@@ -65,22 +65,9 @@ declare const PROTO_DATA_TYPE_ACK = 1;
65
65
  declare const CRC8_TABLE: Uint8Array;
66
66
  declare function crc8(data: Uint8Array, len: number): number;
67
67
 
68
- type ProtocolV2DebugLogger = {
69
- debug?: (...args: unknown[]) => void;
70
- };
71
- type ProtocolV2FrameDebugOptions = {
72
- logger?: ProtocolV2DebugLogger;
73
- logPrefix?: string;
74
- context?: string;
75
- messageName?: string;
76
- messageTypeId?: number;
77
- pbPayloadLength?: number;
78
- };
79
- declare function logProtocolV2Debug(options: ProtocolV2FrameDebugOptions | undefined, stage: string, details: Record<string, unknown>): void;
80
-
81
68
  declare function nextProtoSeq(current: number): number;
82
- declare function encodeFrame(payload: Uint8Array | null, packetSrc?: number, router?: number, debugOptions?: ProtocolV2FrameDebugOptions, seq?: number): Uint8Array;
83
- declare function encodeProtobufFrame(messageTypeId: number, pbPayload: Uint8Array, packetSrc?: number, router?: number, debugOptions?: ProtocolV2FrameDebugOptions, seq?: number): Uint8Array;
69
+ declare function encodeFrame(payload: Uint8Array | null, packetSrc?: number, router?: number, seq?: number): Uint8Array;
70
+ declare function encodeProtobufFrame(messageTypeId: number, pbPayload: Uint8Array, packetSrc?: number, router?: number, seq?: number): Uint8Array;
84
71
 
85
72
  interface ProtoV2Frame {
86
73
  messageTypeId: number;
@@ -88,7 +75,7 @@ interface ProtoV2Frame {
88
75
  seq: number;
89
76
  }
90
77
  declare function isAckFrame(data: Uint8Array): boolean;
91
- declare function decodeFrame(data: Uint8Array, debugOptions?: ProtocolV2FrameDebugOptions): ProtoV2Frame;
78
+ declare function decodeFrame(data: Uint8Array): ProtoV2Frame;
92
79
 
93
80
  declare function concatUint8Arrays(arrays: Uint8Array[]): Uint8Array;
94
81
  declare class ProtocolV2FrameAssembler {
@@ -111,9 +98,6 @@ declare const protocolV2Codec_PROTO_DATA_TYPE_PACKET: typeof PROTO_DATA_TYPE_PAC
111
98
  declare const protocolV2Codec_PROTO_DATA_TYPE_ACK: typeof PROTO_DATA_TYPE_ACK;
112
99
  declare const protocolV2Codec_CRC8_TABLE: typeof CRC8_TABLE;
113
100
  declare const protocolV2Codec_crc8: typeof crc8;
114
- type protocolV2Codec_ProtocolV2DebugLogger = ProtocolV2DebugLogger;
115
- type protocolV2Codec_ProtocolV2FrameDebugOptions = ProtocolV2FrameDebugOptions;
116
- declare const protocolV2Codec_logProtocolV2Debug: typeof logProtocolV2Debug;
117
101
  declare const protocolV2Codec_nextProtoSeq: typeof nextProtoSeq;
118
102
  declare const protocolV2Codec_encodeFrame: typeof encodeFrame;
119
103
  declare const protocolV2Codec_encodeProtobufFrame: typeof encodeProtobufFrame;
@@ -134,9 +118,6 @@ declare namespace protocolV2Codec {
134
118
  protocolV2Codec_PROTO_DATA_TYPE_ACK as PROTO_DATA_TYPE_ACK,
135
119
  protocolV2Codec_CRC8_TABLE as CRC8_TABLE,
136
120
  protocolV2Codec_crc8 as crc8,
137
- protocolV2Codec_ProtocolV2DebugLogger as ProtocolV2DebugLogger,
138
- protocolV2Codec_ProtocolV2FrameDebugOptions as ProtocolV2FrameDebugOptions,
139
- protocolV2Codec_logProtocolV2Debug as logProtocolV2Debug,
140
121
  protocolV2Codec_nextProtoSeq as nextProtoSeq,
141
122
  protocolV2Codec_encodeFrame as encodeFrame,
142
123
  protocolV2Codec_encodeProtobufFrame as encodeProtobufFrame,
@@ -157,9 +138,6 @@ type ProtocolV2FrameOptions = {
157
138
  packetSrc?: number;
158
139
  router?: number;
159
140
  seq?: number;
160
- logger?: ProtocolV2DebugLogger;
161
- logPrefix?: string;
162
- context?: string;
163
141
  };
164
142
  declare const ProtocolV1: {
165
143
  encodeEnvelope: typeof encodeEnvelopeMessage;
@@ -175,7 +153,7 @@ declare const ProtocolV1: {
175
153
  declare const ProtocolV2: {
176
154
  isAckFrame: typeof isAckFrame;
177
155
  encodeFrame(schemas: ProtocolV2Schemas$1, name: string, data: Record<string, unknown>, options?: ProtocolV2FrameOptions): Uint8Array;
178
- decodeFrame(schemas: ProtocolV2Schemas$1, frame: Uint8Array, options?: Pick<ProtocolV2FrameOptions, 'logger' | 'logPrefix' | 'context'>): {
156
+ decodeFrame(schemas: ProtocolV2Schemas$1, frame: Uint8Array): {
179
157
  message: {
180
158
  [key: string]: any;
181
159
  };
@@ -6435,21 +6413,11 @@ declare const _default: {
6435
6413
  packetSrc?: number | undefined;
6436
6414
  router?: number | undefined;
6437
6415
  seq?: number | undefined;
6438
- logger?: ProtocolV2DebugLogger | undefined;
6439
- logPrefix?: string | undefined;
6440
- context?: string | undefined;
6441
6416
  }): Uint8Array;
6442
6417
  decodeFrame(schemas: {
6443
6418
  protocolV1: protobuf.Root;
6444
6419
  protocolV2: protobuf.Root;
6445
- }, frame: Uint8Array, options?: Pick<{
6446
- packetSrc?: number | undefined;
6447
- router?: number | undefined;
6448
- seq?: number | undefined;
6449
- logger?: ProtocolV2DebugLogger | undefined;
6450
- logPrefix?: string | undefined;
6451
- context?: string | undefined;
6452
- }, "logger" | "logPrefix" | "context">): {
6420
+ }, frame: Uint8Array): {
6453
6421
  message: {
6454
6422
  [key: string]: any;
6455
6423
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAKL,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,eAAe,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAEL,wBAAwB,EACxB,iBAAiB,EACjB,UAAU,EAEV,eAAe,EACf,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAKlD,YAAY,EACV,S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EACd,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElD,wBAsBE"}
package/dist/index.js CHANGED
@@ -411,16 +411,11 @@ function crc8(data, len) {
411
411
  return crc;
412
412
  }
413
413
 
414
- function logProtocolV2Debug(options, stage, details) {
415
- var _a, _b, _c;
416
- (_b = (_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, `[${(_c = options.logPrefix) !== null && _c !== void 0 ? _c : 'ProtocolV2'}] ${stage}`, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.context ? { context: options.context } : {})), (options.messageName ? { messageName: options.messageName } : {})), (options.messageTypeId !== undefined ? { messageTypeId: options.messageTypeId } : {})), (options.pbPayloadLength !== undefined ? { pbPayloadLength: options.pbPayloadLength } : {})), details));
417
- }
418
-
419
414
  const PROTO_SEQ_DEFAULT = 1;
420
415
  function nextProtoSeq(current) {
421
416
  return current >= 255 ? 1 : current + 1;
422
417
  }
423
- function encodeFrame(payload, packetSrc, router, debugOptions, seq) {
418
+ function encodeFrame(payload, packetSrc, router, seq) {
424
419
  const resolvedPacketSrc = packetSrc !== null && packetSrc !== void 0 ? packetSrc : 0;
425
420
  const resolvedRouter = router !== null && router !== void 0 ? router : 0;
426
421
  const resolvedSeq = seq !== null && seq !== void 0 ? seq : PROTO_SEQ_DEFAULT;
@@ -445,24 +440,14 @@ function encodeFrame(payload, packetSrc, router, debugOptions, seq) {
445
440
  frame.set(payload, 7);
446
441
  }
447
442
  frame[frameLen - 1] = crc8(frame, frameLen - 1);
448
- logProtocolV2Debug(debugOptions, 'encode raw frame', {
449
- frameLen,
450
- payloadLen,
451
- packetSrc: resolvedPacketSrc,
452
- router: frame[4],
453
- attr: frame[5],
454
- seq: frame[6],
455
- headerCrc: frame[3],
456
- frameCrc: frame[frameLen - 1],
457
- });
458
443
  return frame;
459
444
  }
460
- function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router, debugOptions, seq) {
445
+ function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router, seq) {
461
446
  const payload = new Uint8Array(2 + pbPayload.length);
462
447
  payload[0] = messageTypeId % 256;
463
448
  payload[1] = Math.floor(messageTypeId / 256) % 256;
464
449
  payload.set(pbPayload, 2);
465
- return encodeFrame(payload, packetSrc, router, Object.assign(Object.assign({}, debugOptions), { messageTypeId, pbPayloadLength: pbPayload.length }), seq);
450
+ return encodeFrame(payload, packetSrc, router, seq);
466
451
  }
467
452
 
468
453
  function validateFrame(data) {
@@ -500,10 +485,8 @@ function isAckFrame(data) {
500
485
  }
501
486
  return true;
502
487
  }
503
- function decodeFrame(data, debugOptions) {
488
+ function decodeFrame(data) {
504
489
  const frameLen = validateFrame(data);
505
- const expectedHeaderCrc = data[3];
506
- const expectedFrameCrc = data[frameLen - 1];
507
490
  const seq = data[6];
508
491
  const payloadData = data.slice(7, frameLen - 1);
509
492
  if (payloadData.length < 2) {
@@ -511,19 +494,6 @@ function decodeFrame(data, debugOptions) {
511
494
  }
512
495
  const messageTypeId = payloadData[0] + payloadData[1] * 256;
513
496
  const pbPayload = payloadData.slice(2);
514
- logProtocolV2Debug(debugOptions, 'decode raw frame', {
515
- frameLen,
516
- dataLength: data.length,
517
- router: data[4],
518
- attr: data[5],
519
- seq,
520
- headerCrc: data[3],
521
- expectedHeaderCrc,
522
- frameCrc: data[frameLen - 1],
523
- expectedFrameCrc,
524
- messageTypeId,
525
- pbPayloadLength: pbPayload.length,
526
- });
527
497
  return { messageTypeId, pbPayload, seq };
528
498
  }
529
499
 
@@ -609,7 +579,6 @@ var protocolV2Codec = /*#__PURE__*/Object.freeze({
609
579
  PROTO_DATA_TYPE_ACK: PROTO_DATA_TYPE_ACK,
610
580
  CRC8_TABLE: CRC8_TABLE,
611
581
  crc8: crc8,
612
- logProtocolV2Debug: logProtocolV2Debug,
613
582
  nextProtoSeq: nextProtoSeq,
614
583
  encodeFrame: encodeFrame,
615
584
  encodeProtobufFrame: encodeProtobufFrame,
@@ -666,45 +635,19 @@ const ProtocolV1 = {
666
635
  const ProtocolV2 = {
667
636
  isAckFrame,
668
637
  encodeFrame(schemas, name, data, options = {}) {
669
- var _a, _b, _c, _d, _e, _f, _g;
670
638
  const encodeMessages = resolveProtocolV2EncodeSchema(name, schemas);
671
639
  const { Message, messageTypeId } = createMessageFromName(encodeMessages, name);
672
640
  const pbBuffer = encode(Message, data);
673
641
  pbBuffer.reset();
674
642
  const rawPbBuffer = pbBuffer.toBuffer();
675
643
  const pbBytes = new Uint8Array(rawPbBuffer);
676
- (_b = (_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, `[${(_c = options.logPrefix) !== null && _c !== void 0 ? _c : 'ProtocolV2'}] encode protobuf`, {
677
- context: (_d = options.context) !== null && _d !== void 0 ? _d : `encode:${name}`,
678
- messageName: name,
679
- messageTypeId,
680
- pbPayloadLength: pbBytes.length,
681
- packetSrc: (_e = options.packetSrc) !== null && _e !== void 0 ? _e : 0,
682
- router: (_f = options.router) !== null && _f !== void 0 ? _f : 0,
683
- });
684
- return encodeProtobufFrame(messageTypeId, pbBytes, options.packetSrc, options.router, {
685
- logger: options.logger,
686
- logPrefix: options.logPrefix,
687
- context: (_g = options.context) !== null && _g !== void 0 ? _g : `encode:${name}`,
688
- messageName: name,
689
- }, options.seq);
644
+ return encodeProtobufFrame(messageTypeId, pbBytes, options.packetSrc, options.router, options.seq);
690
645
  },
691
- decodeFrame(schemas, frame, options = {}) {
692
- var _a, _b, _c, _d, _e;
693
- const { messageTypeId, pbPayload, seq } = decodeFrame(frame, {
694
- logger: options.logger,
695
- logPrefix: options.logPrefix,
696
- context: (_a = options.context) !== null && _a !== void 0 ? _a : 'decode',
697
- });
646
+ decodeFrame(schemas, frame) {
647
+ const { messageTypeId, pbPayload, seq } = decodeFrame(frame);
698
648
  const { Message, messageName } = createProtocolV2MessageFromType(messageTypeId, schemas);
699
649
  const rxByteBuffer = ByteBuffer__default["default"].wrap(Buffer.from(pbPayload));
700
650
  const message = decode(Message, rxByteBuffer);
701
- (_c = (_b = options.logger) === null || _b === void 0 ? void 0 : _b.debug) === null || _c === void 0 ? void 0 : _c.call(_b, `[${(_d = options.logPrefix) !== null && _d !== void 0 ? _d : 'ProtocolV2'}] decode protobuf`, {
702
- context: (_e = options.context) !== null && _e !== void 0 ? _e : `decode:${messageName}`,
703
- messageName,
704
- messageTypeId,
705
- pbPayloadLength: pbPayload.length,
706
- seq,
707
- });
708
651
  return {
709
652
  message,
710
653
  messageName,
@@ -853,11 +796,6 @@ function bytesToHex(bytes) {
853
796
  .map(b => b.toString(16).padStart(2, '0'))
854
797
  .join('');
855
798
  }
856
- const PROTOCOL_V2_DEBUG_HEADER_BYTES = 7;
857
- const PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT = 20;
858
- const PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT = 40;
859
- const PROTOCOL_V2_DEBUG_STRING_LIMIT = 512;
860
- const PROTOCOL_V2_DEBUG_DEPTH_LIMIT = 4;
861
799
  const HIGH_VOLUME_PROTOCOL_V2_CALLS = new Set([
862
800
  ...LogBlockCommand,
863
801
  'FilesystemFileRead',
@@ -867,80 +805,6 @@ const HIGH_VOLUME_PROTOCOL_V2_CALLS = new Set([
867
805
  function shouldReduceProtocolV2Debug(name) {
868
806
  return HIGH_VOLUME_PROTOCOL_V2_CALLS.has(name);
869
807
  }
870
- function frameHeaderDebugHex(frame) {
871
- return bytesToHex(frame.slice(0, PROTOCOL_V2_DEBUG_HEADER_BYTES));
872
- }
873
- function getBinaryByteLength(value) {
874
- if (value instanceof ArrayBuffer) {
875
- return value.byteLength;
876
- }
877
- if (ArrayBuffer.isView(value)) {
878
- return value.byteLength;
879
- }
880
- if (typeof Blob !== 'undefined' && value instanceof Blob) {
881
- return value.size;
882
- }
883
- return undefined;
884
- }
885
- function summarizeRedactedData(value) {
886
- const byteLength = getBinaryByteLength(value);
887
- if (byteLength !== undefined) {
888
- return `[redacted data: ${byteLength} bytes]`;
889
- }
890
- if (typeof value === 'string') {
891
- return `[redacted data: string length=${value.length}]`;
892
- }
893
- if (Array.isArray(value)) {
894
- return `[redacted data: array length=${value.length}]`;
895
- }
896
- if (value && typeof value === 'object') {
897
- return `[redacted data: object keys=${Object.keys(value).length}]`;
898
- }
899
- return `[redacted data: ${typeof value}]`;
900
- }
901
- function sanitizeProtocolV2DebugPayload(value, key = '', depth = 0) {
902
- if (/^(data|payload)$/i.test(key) && value !== null && value !== undefined) {
903
- return summarizeRedactedData(value);
904
- }
905
- if (/(passphrase|pin|mnemonic|seed|private)/i.test(key)) {
906
- return '[redacted sensitive value]';
907
- }
908
- const byteLength = getBinaryByteLength(value);
909
- if (byteLength !== undefined) {
910
- return `[binary: ${byteLength} bytes]`;
911
- }
912
- if (typeof value === 'string') {
913
- return value.length > PROTOCOL_V2_DEBUG_STRING_LIMIT
914
- ? `${value.slice(0, PROTOCOL_V2_DEBUG_STRING_LIMIT)}... (len=${value.length})`
915
- : value;
916
- }
917
- if (!value || typeof value !== 'object') {
918
- return value;
919
- }
920
- if (depth >= PROTOCOL_V2_DEBUG_DEPTH_LIMIT) {
921
- return Array.isArray(value)
922
- ? `[array length=${value.length}]`
923
- : `[object keys=${Object.keys(value).length}]`;
924
- }
925
- if (Array.isArray(value)) {
926
- const items = value
927
- .slice(0, PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT)
928
- .map(item => sanitizeProtocolV2DebugPayload(item, key, depth + 1));
929
- if (value.length > PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT) {
930
- items.push(`... (${value.length - PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT} more)`);
931
- }
932
- return items;
933
- }
934
- const entries = Object.entries(value).slice(0, PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT);
935
- const sanitized = {};
936
- entries.forEach(([entryKey, entryValue]) => {
937
- sanitized[entryKey] = sanitizeProtocolV2DebugPayload(entryValue, entryKey, depth + 1);
938
- });
939
- if (Object.keys(value).length > PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT) {
940
- sanitized.__truncated__ = `${Object.keys(value).length - PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT} more keys`;
941
- }
942
- return sanitized;
943
- }
944
808
  const COMMON_TERMINAL_RESPONSE_TYPES = new Set([
945
809
  'Failure',
946
810
  'ButtonRequest',
@@ -1003,7 +867,6 @@ class ProtocolV2Session {
1003
867
  return result;
1004
868
  }
1005
869
  executeCall(name, data, callOptions) {
1006
- var _a, _b;
1007
870
  return __awaiter(this, void 0, void 0, function* () {
1008
871
  const { schemas, router, packetSrc = PROTOCOL_V2_PACKET_SRC_COMMAND, maxFrameBytes, prepareCall, writeFrame, readFrame, logger, logPrefix = 'ProtocolV2', createTimeoutError, generation = 0, } = this.options;
1009
872
  const shouldReduceDebug = shouldReduceProtocolV2Debug(name);
@@ -1019,58 +882,31 @@ class ProtocolV2Session {
1019
882
  packetSrc,
1020
883
  router,
1021
884
  seq: protoSeq,
1022
- logger: shouldReduceDebug ? undefined : logger,
1023
- logPrefix,
1024
- context: `tx:${name}`,
1025
885
  });
1026
- const expectedSeq = frame[6];
1027
886
  if (maxFrameBytes !== undefined && frame.length > maxFrameBytes) {
1028
887
  throw new Error(`Protocol V2 frame too large for transport: ${frame.length} > ${maxFrameBytes}`);
1029
888
  }
1030
- if (!shouldReduceDebug) {
1031
- (_a = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _a === void 0 ? void 0 : _a.call(logger, `[${logPrefix}] TX payload name=${name}`, sanitizeProtocolV2DebugPayload(data));
1032
- (_b = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _b === void 0 ? void 0 : _b.call(logger, `[${logPrefix}] TX frame name=${name} len=${frame.length} router=${frame[4]} attr=${frame[5]} seq=${expectedSeq} headerHex=${frameHeaderDebugHex(frame)}`);
1033
- }
1034
889
  yield withProtocolTimeout(writeFrame(frame, callContext), PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS, () => new Error(`Protocol V2 write timeout after ${PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS}ms for ${name}`));
1035
890
  const cancellation = { cancelled: false };
1036
891
  const readResponse = () => __awaiter(this, void 0, void 0, function* () {
1037
- var _c, _d, _e, _f, _g, _h, _j, _k, _l;
892
+ var _a, _b, _c, _d;
1038
893
  while (!cancellation.cancelled) {
1039
894
  const rxFrame = yield readFrame(callContext);
1040
895
  if (cancellation.cancelled) {
1041
896
  break;
1042
897
  }
1043
- if (!shouldReduceDebug) {
1044
- (_c = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _c === void 0 ? void 0 : _c.call(logger, `[${logPrefix}] RX frame len=${rxFrame.length} router=${rxFrame[4]} attr=${rxFrame[5]} seq=${rxFrame[6]} headerHex=${frameHeaderDebugHex(rxFrame)}`);
1045
- }
1046
898
  const isAck = ProtocolV2.isAckFrame(rxFrame);
1047
- if (isAck) {
1048
- if (!shouldReduceDebug) {
1049
- (_d = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _d === void 0 ? void 0 : _d.call(logger, `[${logPrefix}] skip Proto Link ACK seq=${rxFrame[6]}`);
1050
- }
1051
- }
1052
899
  if (!isAck) {
1053
- const decoded = ProtocolV2.decodeFrame(schemas, rxFrame, {
1054
- logger: shouldReduceDebug ? undefined : logger,
1055
- logPrefix,
1056
- context: `rx:${name}`,
1057
- });
1058
- if (!shouldReduceDebug && decoded.seq !== expectedSeq) {
1059
- (_e = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _e === void 0 ? void 0 : _e.call(logger, `[${logPrefix}] seq differs for ${name}: tx=${expectedSeq}, rx=${decoded.seq}`);
1060
- }
1061
- if (!shouldReduceDebug) {
1062
- (_f = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _f === void 0 ? void 0 : _f.call(logger, `[${logPrefix}] TX name=${name} seq=${expectedSeq} | RX seq=${decoded.seq} messageTypeId=${decoded.messageTypeId} pbPayload=${decoded.pbPayload.length}B`);
1063
- (_g = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _g === void 0 ? void 0 : _g.call(logger, `[${logPrefix}] RX payload type=${decoded.type} messageTypeId=${decoded.messageTypeId}`, sanitizeProtocolV2DebugPayload(decoded.message));
1064
- }
900
+ const decoded = ProtocolV2.decodeFrame(schemas, rxFrame);
1065
901
  const response = call(decoded);
1066
- if ((_h = callOptions.intermediateTypes) === null || _h === void 0 ? void 0 : _h.includes(response.type)) {
1067
- (_j = callOptions.onIntermediateResponse) === null || _j === void 0 ? void 0 : _j.call(callOptions, response);
902
+ if ((_a = callOptions.intermediateTypes) === null || _a === void 0 ? void 0 : _a.includes(response.type)) {
903
+ (_b = callOptions.onIntermediateResponse) === null || _b === void 0 ? void 0 : _b.call(callOptions, response);
1068
904
  }
1069
905
  else if (isExpectedTerminalResponse(response, callOptions.expectedTypes)) {
1070
906
  return response;
1071
907
  }
1072
908
  else if (!shouldReduceDebug) {
1073
- (_k = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _k === void 0 ? void 0 : _k.call(logger, `[${logPrefix}] skip unexpected response for ${name}: expected=${(_l = callOptions.expectedTypes) === null || _l === void 0 ? void 0 : _l.join('|')} got=${response.type}`);
909
+ (_c = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _c === void 0 ? void 0 : _c.call(logger, `[${logPrefix}] skip unexpected response for ${name}: expected=${(_d = callOptions.expectedTypes) === null || _d === void 0 ? void 0 : _d.join('|')} got=${response.type}`);
1074
910
  }
1075
911
  }
1076
912
  }
@@ -4,7 +4,6 @@ import { encodeEnvelopeMessage } from './v1/packets';
4
4
  import { decodeMessage as decodeV1Message } from './v1/receive';
5
5
  import { isAckFrame } from './v2';
6
6
  import type { Root } from 'protobufjs/light';
7
- import type { ProtocolV2DebugLogger } from './v2';
8
7
  export declare const PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = 60000;
9
8
  type ProtocolV2Schemas = {
10
9
  protocolV1: Root;
@@ -14,9 +13,6 @@ type ProtocolV2FrameOptions = {
14
13
  packetSrc?: number;
15
14
  router?: number;
16
15
  seq?: number;
17
- logger?: ProtocolV2DebugLogger;
18
- logPrefix?: string;
19
- context?: string;
20
16
  };
21
17
  export declare const ProtocolV1: {
22
18
  encodeEnvelope: typeof encodeEnvelopeMessage;
@@ -32,7 +28,7 @@ export declare const ProtocolV1: {
32
28
  export declare const ProtocolV2: {
33
29
  isAckFrame: typeof isAckFrame;
34
30
  encodeFrame(schemas: ProtocolV2Schemas, name: string, data: Record<string, unknown>, options?: ProtocolV2FrameOptions): Uint8Array;
35
- decodeFrame(schemas: ProtocolV2Schemas, frame: Uint8Array, options?: Pick<ProtocolV2FrameOptions, 'logger' | 'logPrefix' | 'context'>): {
31
+ decodeFrame(schemas: ProtocolV2Schemas, frame: Uint8Array): {
36
32
  message: {
37
33
  [key: string]: any;
38
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocols/index.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAA+C,MAAM,cAAc,CAAC;AAElG,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAqD,UAAU,EAA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IACjB,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAsCF,eAAO,MAAM,UAAU;;;;;;;;;;CAOtB,CAAC;AAEF,eAAO,MAAM,UAAU;;yBAIV,iBAAiB,QACpB,MAAM,QACN,OAAO,MAAM,EAAE,OAAO,CAAC,YACpB,sBAAsB;yBAkBZ,iBAAiB,SAAS,UAAU;;;;;;;;;;CAe1D,CAAC"}
@@ -1,9 +1,8 @@
1
- import type { ProtocolV2FrameDebugOptions } from './debug';
2
1
  export interface ProtoV2Frame {
3
2
  messageTypeId: number;
4
3
  pbPayload: Uint8Array;
5
4
  seq: number;
6
5
  }
7
6
  export declare function isAckFrame(data: Uint8Array): boolean;
8
- export declare function decodeFrame(data: Uint8Array, debugOptions?: ProtocolV2FrameDebugOptions): ProtoV2Frame;
7
+ export declare function decodeFrame(data: Uint8Array): ProtoV2Frame;
9
8
  //# sourceMappingURL=decode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/decode.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,WAAW,YAAY;IAE3B,aAAa,EAAE,MAAM,CAAC;IAEtB,SAAS,EAAE,UAAU,CAAC;IAEtB,GAAG,EAAE,MAAM,CAAC;CACb;AAwCD,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAWpD;AAYD,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,EAChB,YAAY,CAAC,EAAE,2BAA2B,GACzC,YAAY,CA+Bd"}
1
+ {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/decode.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAE3B,aAAa,EAAE,MAAM,CAAC;IAEtB,SAAS,EAAE,UAAU,CAAC;IAEtB,GAAG,EAAE,MAAM,CAAC;CACb;AAwCD,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAWpD;AAYD,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,CAe1D"}
@@ -1,5 +1,4 @@
1
- import type { ProtocolV2FrameDebugOptions } from './debug';
2
1
  export declare function nextProtoSeq(current: number): number;
3
- export declare function encodeFrame(payload: Uint8Array | null, packetSrc?: number, router?: number, debugOptions?: ProtocolV2FrameDebugOptions, seq?: number): Uint8Array;
4
- export declare function encodeProtobufFrame(messageTypeId: number, pbPayload: Uint8Array, packetSrc?: number, router?: number, debugOptions?: ProtocolV2FrameDebugOptions, seq?: number): Uint8Array;
2
+ export declare function encodeFrame(payload: Uint8Array | null, packetSrc?: number, router?: number, seq?: number): Uint8Array;
3
+ export declare function encodeProtobufFrame(messageTypeId: number, pbPayload: Uint8Array, packetSrc?: number, router?: number, seq?: number): Uint8Array;
5
4
  //# sourceMappingURL=encode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/encode.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAU3D,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAgBD,wBAAgB,WAAW,CACzB,OAAO,EAAE,UAAU,GAAG,IAAI,EAC1B,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,2BAA2B,EAC1C,GAAG,CAAC,EAAE,MAAM,GACX,UAAU,CA4CZ;AASD,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,UAAU,EACrB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,2BAA2B,EAC1C,GAAG,CAAC,EAAE,MAAM,GACX,UAAU,CAgBZ"}
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/encode.ts"],"names":[],"mappings":"AAYA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAgBD,wBAAgB,WAAW,CACzB,OAAO,EAAE,UAAU,GAAG,IAAI,EAC1B,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,MAAM,GACX,UAAU,CAiCZ;AASD,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,UAAU,EACrB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,MAAM,GACX,UAAU,CAMZ"}
@@ -1,6 +1,5 @@
1
1
  export * from './constants';
2
2
  export * from './crc8';
3
- export * from './debug';
4
3
  export * from './encode';
5
4
  export * from './decode';
6
5
  export * from './frame-assembler';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/protocols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AAC;IAC3C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC1D,oBAoBA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport",
3
- "version": "1.2.0-alpha.11",
3
+ "version": "1.2.0-alpha.12",
4
4
  "description": "Transport layer abstractions and utilities for OneKey hardware SDK.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -28,5 +28,5 @@
28
28
  "long": "^4.0.0",
29
29
  "protobufjs": "^6.11.2"
30
30
  },
31
- "gitHead": "05d3421ec00e07e99f6665e6436a612503e32dfc"
31
+ "gitHead": "3601e8003c96a2a4ca7856e865d16f48c0c5b758"
32
32
  }
@@ -9,7 +9,6 @@ import { decode as decodeProtobuf } from '../serialization/protobuf/decode';
9
9
  import { decodeFrame as decodeV2Frame, encodeProtobufFrame, isAckFrame } from './v2';
10
10
 
11
11
  import type { Root } from 'protobufjs/light';
12
- import type { ProtocolV2DebugLogger } from './v2';
13
12
 
14
13
  export const PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = 60000;
15
14
 
@@ -23,9 +22,6 @@ type ProtocolV2FrameOptions = {
23
22
  router?: number;
24
23
  /** Sequence number (1-255). Managed per-session by ProtocolV2Session. */
25
24
  seq?: number;
26
- logger?: ProtocolV2DebugLogger;
27
- logPrefix?: string;
28
- context?: string;
29
25
  };
30
26
 
31
27
  const resolveProtocolV2EncodeSchema = (name: string, schemas: ProtocolV2Schemas) => {
@@ -89,52 +85,21 @@ export const ProtocolV2 = {
89
85
  const rawPbBuffer = pbBuffer.toBuffer() as unknown as ArrayBuffer;
90
86
  const pbBytes = new Uint8Array(rawPbBuffer);
91
87
 
92
- options.logger?.debug?.(`[${options.logPrefix ?? 'ProtocolV2'}] encode protobuf`, {
93
- context: options.context ?? `encode:${name}`,
94
- messageName: name,
95
- messageTypeId,
96
- pbPayloadLength: pbBytes.length,
97
- packetSrc: options.packetSrc ?? 0,
98
- router: options.router ?? 0,
99
- });
100
-
101
88
  return encodeProtobufFrame(
102
89
  messageTypeId,
103
90
  pbBytes,
104
91
  options.packetSrc,
105
92
  options.router,
106
- {
107
- logger: options.logger,
108
- logPrefix: options.logPrefix,
109
- context: options.context ?? `encode:${name}`,
110
- messageName: name,
111
- },
112
93
  options.seq
113
94
  );
114
95
  },
115
96
 
116
- decodeFrame(
117
- schemas: ProtocolV2Schemas,
118
- frame: Uint8Array,
119
- options: Pick<ProtocolV2FrameOptions, 'logger' | 'logPrefix' | 'context'> = {}
120
- ) {
121
- const { messageTypeId, pbPayload, seq } = decodeV2Frame(frame, {
122
- logger: options.logger,
123
- logPrefix: options.logPrefix,
124
- context: options.context ?? 'decode',
125
- });
97
+ decodeFrame(schemas: ProtocolV2Schemas, frame: Uint8Array) {
98
+ const { messageTypeId, pbPayload, seq } = decodeV2Frame(frame);
126
99
  const { Message, messageName } = createProtocolV2MessageFromType(messageTypeId, schemas);
127
100
  const rxByteBuffer = ByteBuffer.wrap(Buffer.from(pbPayload) as unknown as ArrayBuffer);
128
101
  const message = decodeProtobuf(Message, rxByteBuffer);
129
102
 
130
- options.logger?.debug?.(`[${options.logPrefix ?? 'ProtocolV2'}] decode protobuf`, {
131
- context: options.context ?? `decode:${messageName}`,
132
- messageName,
133
- messageTypeId,
134
- pbPayloadLength: pbPayload.length,
135
- seq,
136
- });
137
-
138
103
  return {
139
104
  message,
140
105
  messageName,
@@ -1,8 +1,5 @@
1
1
  import { PROTO_DATA_TYPE_ACK, PROTO_HEAD_CRC_SIZE, PROTO_HEAD_SOF } from './constants';
2
2
  import { crc8 } from './crc8';
3
- import { logProtocolV2Debug } from './debug';
4
-
5
- import type { ProtocolV2FrameDebugOptions } from './debug';
6
3
 
7
4
  export interface ProtoV2Frame {
8
5
  /** Little-endian message type ID */
@@ -74,13 +71,8 @@ export function isAckFrame(data: Uint8Array): boolean {
74
71
  *
75
72
  * Returns the decoded messageTypeId, raw protobuf payload, and sequence number.
76
73
  */
77
- export function decodeFrame(
78
- data: Uint8Array,
79
- debugOptions?: ProtocolV2FrameDebugOptions
80
- ): ProtoV2Frame {
74
+ export function decodeFrame(data: Uint8Array): ProtoV2Frame {
81
75
  const frameLen = validateFrame(data);
82
- const expectedHeaderCrc = data[3];
83
- const expectedFrameCrc = data[frameLen - 1];
84
76
 
85
77
  const seq = data[6];
86
78
  // Payload spans bytes 7 to frameLen-2 (inclusive), excluding final CRC byte
@@ -93,19 +85,5 @@ export function decodeFrame(
93
85
  const messageTypeId = payloadData[0] + payloadData[1] * 256;
94
86
  const pbPayload = payloadData.slice(2);
95
87
 
96
- logProtocolV2Debug(debugOptions, 'decode raw frame', {
97
- frameLen,
98
- dataLength: data.length,
99
- router: data[4],
100
- attr: data[5],
101
- seq,
102
- headerCrc: data[3],
103
- expectedHeaderCrc,
104
- frameCrc: data[frameLen - 1],
105
- expectedFrameCrc,
106
- messageTypeId,
107
- pbPayloadLength: pbPayload.length,
108
- });
109
-
110
88
  return { messageTypeId, pbPayload, seq };
111
89
  }
@@ -1,10 +1,7 @@
1
1
  import { PROTO_DATA_TYPE_PACKET, PROTO_HEAD_CRC_SIZE, PROTO_HEAD_SOF } from './constants';
2
2
  import { crc8 } from './crc8';
3
- import { logProtocolV2Debug } from './debug';
4
3
  import { PROTOCOL_V2_FRAME_MAX_BYTES } from '../../constants';
5
4
 
6
- import type { ProtocolV2FrameDebugOptions } from './debug';
7
-
8
5
  // Default sequence number when callers do not manage one themselves.
9
6
  // Stateful per-session sequencing lives in ProtocolV2Session (session.ts),
10
7
  // which advances the counter via nextProtoSeq() and passes it in explicitly.
@@ -35,7 +32,6 @@ export function encodeFrame(
35
32
  payload: Uint8Array | null,
36
33
  packetSrc?: number,
37
34
  router?: number,
38
- debugOptions?: ProtocolV2FrameDebugOptions,
39
35
  seq?: number
40
36
  ): Uint8Array {
41
37
  const resolvedPacketSrc = packetSrc ?? 0;
@@ -69,17 +65,6 @@ export function encodeFrame(
69
65
  // CRC8 over entire frame except last byte
70
66
  frame[frameLen - 1] = crc8(frame, frameLen - 1);
71
67
 
72
- logProtocolV2Debug(debugOptions, 'encode raw frame', {
73
- frameLen,
74
- payloadLen,
75
- packetSrc: resolvedPacketSrc,
76
- router: frame[4],
77
- attr: frame[5],
78
- seq: frame[6],
79
- headerCrc: frame[3],
80
- frameCrc: frame[frameLen - 1],
81
- });
82
-
83
68
  return frame;
84
69
  }
85
70
 
@@ -95,22 +80,11 @@ export function encodeProtobufFrame(
95
80
  pbPayload: Uint8Array,
96
81
  packetSrc?: number,
97
82
  router?: number,
98
- debugOptions?: ProtocolV2FrameDebugOptions,
99
83
  seq?: number
100
84
  ): Uint8Array {
101
85
  const payload = new Uint8Array(2 + pbPayload.length);
102
86
  payload[0] = messageTypeId % 256;
103
87
  payload[1] = Math.floor(messageTypeId / 256) % 256;
104
88
  payload.set(pbPayload, 2);
105
- return encodeFrame(
106
- payload,
107
- packetSrc,
108
- router,
109
- {
110
- ...debugOptions,
111
- messageTypeId,
112
- pbPayloadLength: pbPayload.length,
113
- },
114
- seq
115
- );
89
+ return encodeFrame(payload, packetSrc, router, seq);
116
90
  }
@@ -1,6 +1,5 @@
1
1
  export * from './constants';
2
2
  export * from './crc8';
3
- export * from './debug';
4
3
  export * from './encode';
5
4
  export * from './decode';
6
5
  export * from './frame-assembler';
@@ -71,15 +71,6 @@ export function bytesToHex(bytes: Uint8Array): string {
71
71
  .join('');
72
72
  }
73
73
 
74
- // Frame header bytes worth logging: SOF, len lo/hi, header CRC, router, attr, seq.
75
- // The rest of the frame is protobuf payload and may contain sensitive fields
76
- // (mnemonic words via WordAck, PINs, seeds via LoadDevice, ...), so raw frame
77
- // hex logs must never include it.
78
- const PROTOCOL_V2_DEBUG_HEADER_BYTES = 7;
79
- const PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT = 20;
80
- const PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT = 40;
81
- const PROTOCOL_V2_DEBUG_STRING_LIMIT = 512;
82
- const PROTOCOL_V2_DEBUG_DEPTH_LIMIT = 4;
83
74
  const HIGH_VOLUME_PROTOCOL_V2_CALLS = new Set([
84
75
  ...LogBlockCommand,
85
76
  'FilesystemFileRead',
@@ -91,102 +82,6 @@ function shouldReduceProtocolV2Debug(name: string) {
91
82
  return HIGH_VOLUME_PROTOCOL_V2_CALLS.has(name);
92
83
  }
93
84
 
94
- function frameHeaderDebugHex(frame: Uint8Array): string {
95
- // Only the frame header is dumped as hex; the payload is logged separately
96
- // in sanitized/structured form (sanitizeProtocolV2DebugPayload).
97
- return bytesToHex(frame.slice(0, PROTOCOL_V2_DEBUG_HEADER_BYTES));
98
- }
99
-
100
- function getBinaryByteLength(value: unknown): number | undefined {
101
- if (value instanceof ArrayBuffer) {
102
- return value.byteLength;
103
- }
104
-
105
- if (ArrayBuffer.isView(value)) {
106
- return value.byteLength;
107
- }
108
-
109
- if (typeof Blob !== 'undefined' && value instanceof Blob) {
110
- return value.size;
111
- }
112
-
113
- return undefined;
114
- }
115
-
116
- function summarizeRedactedData(value: unknown): string {
117
- const byteLength = getBinaryByteLength(value);
118
- if (byteLength !== undefined) {
119
- return `[redacted data: ${byteLength} bytes]`;
120
- }
121
-
122
- if (typeof value === 'string') {
123
- return `[redacted data: string length=${value.length}]`;
124
- }
125
-
126
- if (Array.isArray(value)) {
127
- return `[redacted data: array length=${value.length}]`;
128
- }
129
-
130
- if (value && typeof value === 'object') {
131
- return `[redacted data: object keys=${Object.keys(value).length}]`;
132
- }
133
-
134
- return `[redacted data: ${typeof value}]`;
135
- }
136
-
137
- function sanitizeProtocolV2DebugPayload(value: unknown, key = '', depth = 0): unknown {
138
- if (/^(data|payload)$/i.test(key) && value !== null && value !== undefined) {
139
- return summarizeRedactedData(value);
140
- }
141
-
142
- if (/(passphrase|pin|mnemonic|seed|private)/i.test(key)) {
143
- return '[redacted sensitive value]';
144
- }
145
-
146
- const byteLength = getBinaryByteLength(value);
147
- if (byteLength !== undefined) {
148
- return `[binary: ${byteLength} bytes]`;
149
- }
150
-
151
- if (typeof value === 'string') {
152
- return value.length > PROTOCOL_V2_DEBUG_STRING_LIMIT
153
- ? `${value.slice(0, PROTOCOL_V2_DEBUG_STRING_LIMIT)}... (len=${value.length})`
154
- : value;
155
- }
156
-
157
- if (!value || typeof value !== 'object') {
158
- return value;
159
- }
160
-
161
- if (depth >= PROTOCOL_V2_DEBUG_DEPTH_LIMIT) {
162
- return Array.isArray(value)
163
- ? `[array length=${value.length}]`
164
- : `[object keys=${Object.keys(value).length}]`;
165
- }
166
-
167
- if (Array.isArray(value)) {
168
- const items = value
169
- .slice(0, PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT)
170
- .map(item => sanitizeProtocolV2DebugPayload(item, key, depth + 1));
171
- if (value.length > PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT) {
172
- items.push(`... (${value.length - PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT} more)`);
173
- }
174
- return items;
175
- }
176
-
177
- const entries = Object.entries(value).slice(0, PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT);
178
- const sanitized: Record<string, unknown> = {};
179
- entries.forEach(([entryKey, entryValue]) => {
180
- sanitized[entryKey] = sanitizeProtocolV2DebugPayload(entryValue, entryKey, depth + 1);
181
- });
182
- if (Object.keys(value).length > PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT) {
183
- sanitized.__truncated__ = `${
184
- Object.keys(value).length - PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT
185
- } more keys`;
186
- }
187
- return sanitized;
188
- }
189
-
190
85
  const COMMON_TERMINAL_RESPONSE_TYPES = new Set([
191
86
  'Failure',
192
87
  'ButtonRequest',
@@ -305,11 +200,7 @@ export class ProtocolV2Session {
305
200
  packetSrc,
306
201
  router,
307
202
  seq: protoSeq,
308
- logger: shouldReduceDebug ? undefined : logger,
309
- logPrefix,
310
- context: `tx:${name}`,
311
203
  });
312
- const expectedSeq = frame[6];
313
204
 
314
205
  if (maxFrameBytes !== undefined && frame.length > maxFrameBytes) {
315
206
  throw new Error(
@@ -317,18 +208,6 @@ export class ProtocolV2Session {
317
208
  );
318
209
  }
319
210
 
320
- if (!shouldReduceDebug) {
321
- logger?.debug?.(
322
- `[${logPrefix}] TX payload name=${name}`,
323
- sanitizeProtocolV2DebugPayload(data)
324
- );
325
- logger?.debug?.(
326
- `[${logPrefix}] TX frame name=${name} len=${frame.length} router=${frame[4]} attr=${
327
- frame[5]
328
- } seq=${expectedSeq} headerHex=${frameHeaderDebugHex(frame)}`
329
- );
330
- }
331
-
332
211
  // Lenient watchdog on the write phase only — see
333
212
  // PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS for the rationale.
334
213
  await withProtocolTimeout(
@@ -356,39 +235,9 @@ export class ProtocolV2Session {
356
235
  // Timed out while waiting: drop the late frame and stop reading.
357
236
  break;
358
237
  }
359
- if (!shouldReduceDebug) {
360
- logger?.debug?.(
361
- `[${logPrefix}] RX frame len=${rxFrame.length} router=${rxFrame[4]} attr=${
362
- rxFrame[5]
363
- } seq=${rxFrame[6]} headerHex=${frameHeaderDebugHex(rxFrame)}`
364
- );
365
- }
366
238
  const isAck = ProtocolV2.isAckFrame(rxFrame);
367
- if (isAck) {
368
- if (!shouldReduceDebug) {
369
- logger?.debug?.(`[${logPrefix}] skip Proto Link ACK seq=${rxFrame[6]}`);
370
- }
371
- }
372
239
  if (!isAck) {
373
- const decoded = ProtocolV2.decodeFrame(schemas, rxFrame, {
374
- logger: shouldReduceDebug ? undefined : logger,
375
- logPrefix,
376
- context: `rx:${name}`,
377
- });
378
- if (!shouldReduceDebug && decoded.seq !== expectedSeq) {
379
- logger?.debug?.(
380
- `[${logPrefix}] seq differs for ${name}: tx=${expectedSeq}, rx=${decoded.seq}`
381
- );
382
- }
383
- if (!shouldReduceDebug) {
384
- logger?.debug?.(
385
- `[${logPrefix}] TX name=${name} seq=${expectedSeq} | RX seq=${decoded.seq} messageTypeId=${decoded.messageTypeId} pbPayload=${decoded.pbPayload.length}B`
386
- );
387
- logger?.debug?.(
388
- `[${logPrefix}] RX payload type=${decoded.type} messageTypeId=${decoded.messageTypeId}`,
389
- sanitizeProtocolV2DebugPayload(decoded.message)
390
- );
391
- }
240
+ const decoded = ProtocolV2.decodeFrame(schemas, rxFrame);
392
241
 
393
242
  const response = check.call(decoded);
394
243
  if (callOptions.intermediateTypes?.includes(response.type)) {
@@ -1,13 +0,0 @@
1
- export type ProtocolV2DebugLogger = {
2
- debug?: (...args: unknown[]) => void;
3
- };
4
- export type ProtocolV2FrameDebugOptions = {
5
- logger?: ProtocolV2DebugLogger;
6
- logPrefix?: string;
7
- context?: string;
8
- messageName?: string;
9
- messageTypeId?: number;
10
- pbPayloadLength?: number;
11
- };
12
- export declare function logProtocolV2Debug(options: ProtocolV2FrameDebugOptions | undefined, stage: string, details: Record<string, unknown>): void;
13
- //# sourceMappingURL=debug.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/debug.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,2BAA2B,GAAG,SAAS,EAChD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QASjC"}
@@ -1,26 +0,0 @@
1
- export type ProtocolV2DebugLogger = {
2
- debug?: (...args: unknown[]) => void;
3
- };
4
-
5
- export type ProtocolV2FrameDebugOptions = {
6
- logger?: ProtocolV2DebugLogger;
7
- logPrefix?: string;
8
- context?: string;
9
- messageName?: string;
10
- messageTypeId?: number;
11
- pbPayloadLength?: number;
12
- };
13
-
14
- export function logProtocolV2Debug(
15
- options: ProtocolV2FrameDebugOptions | undefined,
16
- stage: string,
17
- details: Record<string, unknown>
18
- ) {
19
- options?.logger?.debug?.(`[${options.logPrefix ?? 'ProtocolV2'}] ${stage}`, {
20
- ...(options.context ? { context: options.context } : {}),
21
- ...(options.messageName ? { messageName: options.messageName } : {}),
22
- ...(options.messageTypeId !== undefined ? { messageTypeId: options.messageTypeId } : {}),
23
- ...(options.pbPayloadLength !== undefined ? { pbPayloadLength: options.pbPayloadLength } : {}),
24
- ...details,
25
- });
26
- }