@onekeyfe/hd-transport 1.2.0-alpha.21 → 1.2.0-alpha.22

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.
package/dist/index.js CHANGED
@@ -277,6 +277,7 @@ const PROTOCOL_V2_CHANNEL_USB = 0;
277
277
  const PROTOCOL_V2_CHANNEL_BLE_UART = 1;
278
278
  const PROTOCOL_V2_CHANNEL_SOCKET = 2;
279
279
  const PROTOCOL_V2_PACKET_SRC_COMMAND = 0;
280
+ const PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS = 5 * 60 * 1000;
280
281
 
281
282
  function encodeEnvelope(data, options) {
282
283
  const { addTrezorHeaders, chunked, messageTypeId } = options;
@@ -450,7 +451,7 @@ function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router, seq) {
450
451
  return encodeFrame(payload, packetSrc, router, seq);
451
452
  }
452
453
 
453
- function validateFrame(data) {
454
+ function inspectFrameHeader(data) {
454
455
  if (data.length < PROTO_HEAD_CRC_SIZE) {
455
456
  throw new Error(`Protocol V2 frame too short: ${data.length} bytes`);
456
457
  }
@@ -458,8 +459,8 @@ function validateFrame(data) {
458
459
  throw new Error(`Invalid SOF byte: expected 0x5A, got 0x${data[0].toString(16).padStart(2, '0')}`);
459
460
  }
460
461
  const frameLen = data[1] + data[2] * 256;
461
- if (data.length < frameLen) {
462
- throw new Error(`Frame truncated: expected ${frameLen} bytes, got ${data.length}`);
462
+ if (data.length !== frameLen) {
463
+ throw new Error(`Protocol V2 frame length mismatch: expected ${frameLen} bytes, got ${data.length}`);
463
464
  }
464
465
  const expectedHeaderCrc = crc8(data, 3);
465
466
  if (data[3] !== expectedHeaderCrc) {
@@ -473,29 +474,53 @@ function validateFrame(data) {
473
474
  .toString(16)
474
475
  .padStart(2, '0')}, got 0x${data[frameLen - 1].toString(16).padStart(2, '0')}`);
475
476
  }
476
- return frameLen;
477
+ const dataType = data[5] & 0x03;
478
+ const packetSrc = (data[5] >> 2) & 0x0f;
479
+ const seq = data[6];
480
+ if (seq === 0) {
481
+ throw new Error('Invalid Protocol V2 sequence: 0 is reserved');
482
+ }
483
+ return {
484
+ frameLen,
485
+ router: data[4],
486
+ packetSrc,
487
+ dataType,
488
+ seq,
489
+ };
477
490
  }
478
491
  function isAckFrame(data) {
479
492
  if (data.length < 6 || (data[5] & 0x03) !== PROTO_DATA_TYPE_ACK) {
480
493
  return false;
481
494
  }
482
- const frameLen = validateFrame(data);
483
- if (frameLen !== PROTO_HEAD_CRC_SIZE) {
484
- throw new Error(`Invalid Protocol V2 ACK frame length: ${frameLen}`);
495
+ const header = inspectFrameHeader(data);
496
+ if (header.frameLen !== PROTO_HEAD_CRC_SIZE) {
497
+ throw new Error(`Invalid Protocol V2 ACK frame length: ${header.frameLen}`);
485
498
  }
486
499
  return true;
487
500
  }
488
501
  function decodeFrame(data) {
489
- const frameLen = validateFrame(data);
490
- const seq = data[6];
502
+ const { frameLen, router, packetSrc, dataType, seq } = inspectFrameHeader(data);
503
+ if (dataType !== PROTO_DATA_TYPE_PACKET) {
504
+ throw new Error(`Invalid Protocol V2 data type: expected packet, got ${dataType}`);
505
+ }
491
506
  const payloadData = data.slice(7, frameLen - 1);
492
507
  if (payloadData.length < 2) {
493
508
  throw new Error(`Protocol V2 payload too short (need >=2 bytes for messageTypeId)`);
494
509
  }
495
510
  const messageTypeId = payloadData[0] + payloadData[1] * 256;
496
511
  const pbPayload = payloadData.slice(2);
497
- return { messageTypeId, pbPayload, seq };
512
+ return { messageTypeId, pbPayload, seq, router, packetSrc, dataType };
513
+ }
514
+
515
+ class ProtocolV2LinkError extends Error {
516
+ constructor(code, message, cause) {
517
+ super(message);
518
+ this.name = 'ProtocolV2LinkError';
519
+ this.code = code;
520
+ this.cause = cause;
521
+ }
498
522
  }
523
+ const isProtocolV2LinkError = (error) => error instanceof ProtocolV2LinkError;
499
524
 
500
525
  function concatUint8Arrays(arrays) {
501
526
  const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);
@@ -540,23 +565,23 @@ class ProtocolV2FrameAssembler {
540
565
  return undefined;
541
566
  if (this.buffer[0] !== PROTO_HEAD_SOF) {
542
567
  this.reset();
543
- throw new Error('Invalid Protocol V2 SOF');
568
+ throw new ProtocolV2LinkError('frame', 'Invalid Protocol V2 SOF');
544
569
  }
545
570
  const expectedLen = this.buffer[1] + this.buffer[2] * 256;
546
571
  if (expectedLen < PROTO_HEAD_CRC_SIZE) {
547
572
  this.reset();
548
- throw new Error(`Protocol V2 frame length too small: ${expectedLen}`);
573
+ throw new ProtocolV2LinkError('frame', `Protocol V2 frame length too small: ${expectedLen}`);
549
574
  }
550
575
  if (expectedLen > this.maxFrameBytes) {
551
576
  this.reset();
552
- throw new Error(`Protocol V2 frame too large: ${expectedLen}`);
577
+ throw new ProtocolV2LinkError('frame', `Protocol V2 frame too large: ${expectedLen}`);
553
578
  }
554
579
  if (this.buffer.length < PROTO_PRE_HEAD_SIZE)
555
580
  return undefined;
556
581
  const expectedHeaderCrc = crc8(this.buffer, 3);
557
582
  if (this.buffer[3] !== expectedHeaderCrc) {
558
583
  this.reset();
559
- throw new Error(`Protocol V2 header CRC mismatch: expected 0x${expectedHeaderCrc
584
+ throw new ProtocolV2LinkError('frame', `Protocol V2 header CRC mismatch: expected 0x${expectedHeaderCrc
560
585
  .toString(16)
561
586
  .padStart(2, '0')}`);
562
587
  }
@@ -582,8 +607,11 @@ var protocolV2Codec = /*#__PURE__*/Object.freeze({
582
607
  nextProtoSeq: nextProtoSeq,
583
608
  encodeFrame: encodeFrame,
584
609
  encodeProtobufFrame: encodeProtobufFrame,
610
+ inspectFrameHeader: inspectFrameHeader,
585
611
  isAckFrame: isAckFrame,
586
612
  decodeFrame: decodeFrame,
613
+ ProtocolV2LinkError: ProtocolV2LinkError,
614
+ isProtocolV2LinkError: isProtocolV2LinkError,
587
615
  concatUint8Arrays: concatUint8Arrays,
588
616
  ProtocolV2FrameAssembler: ProtocolV2FrameAssembler
589
617
  });
@@ -634,14 +662,18 @@ const ProtocolV1 = {
634
662
  };
635
663
  const ProtocolV2 = {
636
664
  isAckFrame,
665
+ inspectFrameHeader,
637
666
  inspectFrame(schemas, frame) {
638
- const { messageTypeId, pbPayload, seq } = decodeFrame(frame);
667
+ const { messageTypeId, pbPayload, seq, router, packetSrc, dataType } = decodeFrame(frame);
639
668
  const { messageName } = createProtocolV2MessageFromType(messageTypeId, schemas);
640
669
  return {
641
670
  messageName,
642
671
  messageTypeId,
643
672
  pbPayload,
644
673
  seq,
674
+ router,
675
+ packetSrc,
676
+ dataType,
645
677
  type: messageName,
646
678
  };
647
679
  },
@@ -851,11 +883,12 @@ function getErrorMessage(error) {
851
883
  }
852
884
  return String(error);
853
885
  }
854
- function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout) {
886
+ function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout, abortSignal) {
855
887
  return __awaiter(this, void 0, void 0, function* () {
856
888
  if (!timeoutMs)
857
889
  return promise;
858
890
  let timer;
891
+ let abortHandler;
859
892
  try {
860
893
  return yield Promise.race([
861
894
  promise,
@@ -865,11 +898,29 @@ function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout)
865
898
  reject(createTimeoutError());
866
899
  }, timeoutMs);
867
900
  }),
901
+ ...(abortSignal
902
+ ? [
903
+ new Promise((_, reject) => {
904
+ abortHandler = () => {
905
+ reject(new Error('Protocol V2 operation aborted'));
906
+ };
907
+ if (abortSignal.aborted) {
908
+ abortHandler();
909
+ }
910
+ else {
911
+ abortSignal.addEventListener('abort', abortHandler, { once: true });
912
+ }
913
+ }),
914
+ ]
915
+ : []),
868
916
  ]);
869
917
  }
870
918
  finally {
871
919
  if (timer)
872
920
  clearTimeout(timer);
921
+ if (abortHandler) {
922
+ abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
923
+ }
873
924
  }
874
925
  });
875
926
  }
@@ -887,16 +938,22 @@ class ProtocolV2Session {
887
938
  return result;
888
939
  }
889
940
  executeCall(name, data, callOptions) {
890
- return __awaiter(this, void 0, void 0, function* () {
891
- const { schemas, router, packetSrc = PROTOCOL_V2_PACKET_SRC_COMMAND, maxFrameBytes, prepareCall, writeFrame, readFrame, logger, logPrefix = 'ProtocolV2', createTimeoutError, generation = 0, } = this.options;
892
- const shouldReduceDebug = shouldReduceProtocolV2Debug(name);
893
- const callContext = {
894
- messageName: name,
895
- timeoutMs: callOptions.timeoutMs,
896
- highVolume: shouldReduceDebug,
897
- generation,
898
- };
899
- yield (prepareCall === null || prepareCall === void 0 ? void 0 : prepareCall(callContext));
941
+ const { schemas, router, packetSrc = PROTOCOL_V2_PACKET_SRC_COMMAND, maxFrameBytes, prepareCall, writeFrame, readFrame, logger, logPrefix = 'ProtocolV2', createTimeoutError, generation = 0, } = this.options;
942
+ const timeoutMs = callOptions.timeoutMs && callOptions.timeoutMs > 0
943
+ ? callOptions.timeoutMs
944
+ : PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS;
945
+ const abortController = new AbortController();
946
+ const shouldReduceDebug = shouldReduceProtocolV2Debug(name);
947
+ const baseCallContext = {
948
+ messageName: name,
949
+ timeoutMs,
950
+ highVolume: shouldReduceDebug,
951
+ generation,
952
+ signal: abortController.signal,
953
+ };
954
+ const runCall = () => __awaiter(this, void 0, void 0, function* () {
955
+ var _a, _b, _c, _d;
956
+ yield (prepareCall === null || prepareCall === void 0 ? void 0 : prepareCall(baseCallContext));
900
957
  const protoSeq = this.sequenceCursor.next();
901
958
  const frame = ProtocolV2.encodeFrame(schemas, name, data, {
902
959
  packetSrc,
@@ -906,40 +963,66 @@ class ProtocolV2Session {
906
963
  if (maxFrameBytes !== undefined && frame.length > maxFrameBytes) {
907
964
  throw new Error(`Protocol V2 frame too large for transport: ${frame.length} > ${maxFrameBytes}`);
908
965
  }
909
- yield writeFrame(frame, callContext);
910
- const cancellation = { cancelled: false };
911
- const readResponse = () => __awaiter(this, void 0, void 0, function* () {
912
- var _a, _b, _c, _d;
913
- while (!cancellation.cancelled) {
914
- const rxFrame = yield readFrame(callContext);
915
- if (cancellation.cancelled) {
916
- break;
966
+ yield writeFrame(frame, baseCallContext);
967
+ while (!abortController.signal.aborted) {
968
+ const rxFrame = yield readFrame(baseCallContext);
969
+ if (abortController.signal.aborted)
970
+ break;
971
+ let header;
972
+ try {
973
+ header = ProtocolV2.inspectFrameHeader(rxFrame);
974
+ }
975
+ catch (cause) {
976
+ throw new ProtocolV2LinkError('frame', `Protocol V2 frame validation failed: ${getErrorMessage(cause)}`, cause);
977
+ }
978
+ if (header.router !== router) {
979
+ throw new ProtocolV2LinkError('router', `Protocol V2 router mismatch: expected ${router}, got ${header.router}`);
980
+ }
981
+ if (header.packetSrc !== packetSrc) {
982
+ throw new ProtocolV2LinkError('packet-source', `Protocol V2 packet source mismatch: expected ${packetSrc}, got ${header.packetSrc}`);
983
+ }
984
+ let isAck;
985
+ try {
986
+ isAck = ProtocolV2.isAckFrame(rxFrame);
987
+ }
988
+ catch (cause) {
989
+ throw new ProtocolV2LinkError('frame', `Protocol V2 ACK validation failed: ${getErrorMessage(cause)}`, cause);
990
+ }
991
+ if (isAck) {
992
+ if (header.seq !== protoSeq) {
993
+ throw new ProtocolV2LinkError('ack-sequence', `Protocol V2 ACK sequence mismatch: expected ${protoSeq}, got ${header.seq}`);
994
+ }
995
+ }
996
+ else {
997
+ let decoded;
998
+ try {
999
+ decoded = ProtocolV2.decodeFrame(schemas, rxFrame);
1000
+ }
1001
+ catch (cause) {
1002
+ throw new ProtocolV2LinkError('frame', `Protocol V2 frame decode failed: ${getErrorMessage(cause)}`, cause);
1003
+ }
1004
+ if (this.lastResponseSequence === decoded.seq) {
1005
+ throw new ProtocolV2LinkError('response-sequence', `Protocol V2 duplicate response sequence: ${decoded.seq}`);
1006
+ }
1007
+ this.lastResponseSequence = decoded.seq;
1008
+ const response = call(decoded);
1009
+ if ((_a = callOptions.intermediateTypes) === null || _a === void 0 ? void 0 : _a.includes(response.type)) {
1010
+ (_b = callOptions.onIntermediateResponse) === null || _b === void 0 ? void 0 : _b.call(callOptions, response);
917
1011
  }
918
- const isAck = ProtocolV2.isAckFrame(rxFrame);
919
- if (!isAck) {
920
- const decoded = ProtocolV2.decodeFrame(schemas, rxFrame);
921
- const response = call(decoded);
922
- if ((_a = callOptions.intermediateTypes) === null || _a === void 0 ? void 0 : _a.includes(response.type)) {
923
- (_b = callOptions.onIntermediateResponse) === null || _b === void 0 ? void 0 : _b.call(callOptions, response);
924
- }
925
- else if (isExpectedTerminalResponse(response, callOptions.expectedTypes)) {
926
- return response;
927
- }
928
- else if (!shouldReduceDebug) {
929
- (_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}`);
930
- }
1012
+ else if (isExpectedTerminalResponse(response, callOptions.expectedTypes)) {
1013
+ return response;
1014
+ }
1015
+ else if (!shouldReduceDebug) {
1016
+ (_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}`);
931
1017
  }
932
1018
  }
933
- throw new Error(`Protocol V2 read loop cancelled after timeout for ${name}`);
934
- });
935
- return withProtocolTimeout(readResponse(), callOptions.timeoutMs, () => {
936
- var _a;
937
- return createTimeoutError
938
- ? createTimeoutError(name, (_a = callOptions.timeoutMs) !== null && _a !== void 0 ? _a : 0)
939
- : new Error(`Protocol V2 response timeout after ${callOptions.timeoutMs}ms for ${name}`);
940
- }, () => {
941
- cancellation.cancelled = true;
942
- });
1019
+ }
1020
+ throw new Error(`Protocol V2 read loop cancelled after timeout for ${name}`);
1021
+ });
1022
+ return withProtocolTimeout(runCall(), timeoutMs, () => createTimeoutError
1023
+ ? createTimeoutError(name, timeoutMs)
1024
+ : new Error(`Protocol V2 response timeout after ${timeoutMs}ms for ${name}`), () => {
1025
+ abortController.abort();
943
1026
  });
944
1027
  }
945
1028
  }
@@ -949,7 +1032,10 @@ function probeProtocolV2({ call, timeoutMs, logger, logPrefix = 'ProtocolV2', on
949
1032
  let probeError;
950
1033
  try {
951
1034
  yield (onBeforeProbe === null || onBeforeProbe === void 0 ? void 0 : onBeforeProbe());
952
- const response = yield call('Ping', { message: 'protocol-v2-probe' }, { timeoutMs, expectedTypes: ['Success'] });
1035
+ const response = yield call('Ping', { message: 'protocol-v2-probe' }, {
1036
+ timeoutMs,
1037
+ expectedTypes: ['Success'],
1038
+ });
953
1039
  if (response.type === 'Success') {
954
1040
  return true;
955
1041
  }
@@ -1772,6 +1858,15 @@ exports.DeviceSEState = void 0;
1772
1858
  DeviceSEState[DeviceSEState["APP_FACTORY"] = 51] = "APP_FACTORY";
1773
1859
  DeviceSEState[DeviceSEState["APP"] = 85] = "APP";
1774
1860
  })(exports.DeviceSEState || (exports.DeviceSEState = {}));
1861
+ exports.DeviceSessionErrorCode = void 0;
1862
+ (function (DeviceSessionErrorCode) {
1863
+ DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_None"] = 0] = "DeviceSessionError_None";
1864
+ DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_UserCancelled"] = 1] = "DeviceSessionError_UserCancelled";
1865
+ DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_InvalidSession"] = 2] = "DeviceSessionError_InvalidSession";
1866
+ DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_AttachPinUnavailable"] = 3] = "DeviceSessionError_AttachPinUnavailable";
1867
+ DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_PassphraseDisabled"] = 4] = "DeviceSessionError_PassphraseDisabled";
1868
+ DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_Busy"] = 5] = "DeviceSessionError_Busy";
1869
+ })(exports.DeviceSessionErrorCode || (exports.DeviceSessionErrorCode = {}));
1775
1870
  exports.DeviceSessionAskPin_FailureSubCodes = void 0;
1776
1871
  (function (DeviceSessionAskPin_FailureSubCodes) {
1777
1872
  DeviceSessionAskPin_FailureSubCodes[DeviceSessionAskPin_FailureSubCodes["UserCancel"] = 1] = "UserCancel";
@@ -1924,6 +2019,7 @@ var messages = /*#__PURE__*/Object.freeze({
1924
2019
  get DeviceType () { return exports.DeviceType; },
1925
2020
  get DeviceSeType () { return exports.DeviceSeType; },
1926
2021
  get DeviceSEState () { return exports.DeviceSEState; },
2022
+ get DeviceSessionErrorCode () { return exports.DeviceSessionErrorCode; },
1927
2023
  get DeviceSessionAskPin_FailureSubCodes () { return exports.DeviceSessionAskPin_FailureSubCodes; },
1928
2024
  get DevOnboardingStep () { return exports.DevOnboardingStep; },
1929
2025
  get DevOnboardingPhase () { return exports.DevOnboardingPhase; },
@@ -1973,6 +2069,7 @@ exports.PROTOCOL_V2_BLE_FRAME_MAX_BYTES = PROTOCOL_V2_BLE_FRAME_MAX_BYTES;
1973
2069
  exports.PROTOCOL_V2_CHANNEL_BLE_UART = PROTOCOL_V2_CHANNEL_BLE_UART;
1974
2070
  exports.PROTOCOL_V2_CHANNEL_SOCKET = PROTOCOL_V2_CHANNEL_SOCKET;
1975
2071
  exports.PROTOCOL_V2_CHANNEL_USB = PROTOCOL_V2_CHANNEL_USB;
2072
+ exports.PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS = PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS;
1976
2073
  exports.PROTOCOL_V2_FILE_CHUNK_SIZE = PROTOCOL_V2_FILE_CHUNK_SIZE;
1977
2074
  exports.PROTOCOL_V2_FRAME_MAX_BYTES = PROTOCOL_V2_FRAME_MAX_BYTES;
1978
2075
  exports.PROTOCOL_V2_PACKET_SRC_COMMAND = PROTOCOL_V2_PACKET_SRC_COMMAND;
@@ -1981,6 +2078,7 @@ exports.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
1981
2078
  exports.ProtocolV1 = ProtocolV1;
1982
2079
  exports.ProtocolV2 = ProtocolV2;
1983
2080
  exports.ProtocolV2FrameAssembler = ProtocolV2FrameAssembler;
2081
+ exports.ProtocolV2LinkError = ProtocolV2LinkError;
1984
2082
  exports.ProtocolV2LinkManager = ProtocolV2LinkManager;
1985
2083
  exports.ProtocolV2SequenceCursor = ProtocolV2SequenceCursor;
1986
2084
  exports.ProtocolV2Session = ProtocolV2Session;
@@ -1990,6 +2088,7 @@ exports.concatUint8Arrays = concatUint8Arrays;
1990
2088
  exports["default"] = index;
1991
2089
  exports.getErrorMessage = getErrorMessage;
1992
2090
  exports.hexToBytes = hexToBytes;
2091
+ exports.isProtocolV2LinkError = isProtocolV2LinkError;
1993
2092
  exports.probeProtocolV2 = probeProtocolV2;
1994
2093
  exports.protocolV1 = index$1;
1995
2094
  exports.protocolV2 = protocolV2Codec;
@@ -2,7 +2,7 @@
2
2
  import ByteBuffer from 'bytebuffer';
3
3
  import { encodeEnvelopeMessage } from './v1/packets';
4
4
  import { decodeMessage as decodeV1Message } from './v1/receive';
5
- import { isAckFrame } from './v2';
5
+ import { inspectFrameHeader, isAckFrame } from './v2';
6
6
  import type { Root } from 'protobufjs/light';
7
7
  export declare const PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = 60000;
8
8
  type ProtocolV2Schemas = {
@@ -27,11 +27,15 @@ export declare const ProtocolV1: {
27
27
  };
28
28
  export declare const ProtocolV2: {
29
29
  isAckFrame: typeof isAckFrame;
30
+ inspectFrameHeader: typeof inspectFrameHeader;
30
31
  inspectFrame(schemas: ProtocolV2Schemas, frame: Uint8Array): {
31
32
  messageName: string;
32
33
  messageTypeId: number;
33
34
  pbPayload: Uint8Array;
34
35
  seq: number;
36
+ router: number;
37
+ packetSrc: number;
38
+ dataType: number;
35
39
  type: string;
36
40
  };
37
41
  encodeFrame(schemas: ProtocolV2Schemas, name: string, data: Record<string, unknown>, options?: ProtocolV2FrameOptions): Uint8Array;
@@ -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,EAAE,MAAM,MAAM,CAAC;AAErF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,eAAO,MAAM,iCAAiC,QAAQ,CAAC;AAEvD,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,IAAI,CAAC;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;;0BAGC,iBAAiB,SAAS,UAAU;;;;;;;yBAa/C,iBAAiB,QACpB,MAAM,QACN,OAAO,MAAM,EAAE,OAAO,CAAC,YACpB,sBAAsB;yBAkBZ,iBAAiB,SAAS,UAAU;;;;;;;;;;CA0B1D,CAAC"}
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,EAGL,kBAAkB,EAClB,UAAU,EACX,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,eAAO,MAAM,iCAAiC,QAAQ,CAAC;AAEvD,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,IAAI,CAAC;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;;;0BAIC,iBAAiB,SAAS,UAAU;;;;;;;;;;yBAgB/C,iBAAiB,QACpB,MAAM,QACN,OAAO,MAAM,EAAE,OAAO,CAAC,YACpB,sBAAsB;yBAkBZ,iBAAiB,SAAS,UAAU;;;;;;;;;;CA0B1D,CAAC"}
@@ -2,7 +2,18 @@ export interface ProtoV2Frame {
2
2
  messageTypeId: number;
3
3
  pbPayload: Uint8Array;
4
4
  seq: number;
5
+ router: number;
6
+ packetSrc: number;
7
+ dataType: number;
5
8
  }
9
+ export type ProtoV2FrameHeader = {
10
+ frameLen: number;
11
+ router: number;
12
+ packetSrc: number;
13
+ dataType: number;
14
+ seq: number;
15
+ };
16
+ export declare function inspectFrameHeader(data: Uint8Array): ProtoV2FrameHeader;
6
17
  export declare function isAckFrame(data: Uint8Array): boolean;
7
18
  export declare function decodeFrame(data: Uint8Array): ProtoV2Frame;
8
19
  //# sourceMappingURL=decode.d.ts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/decode.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAE3B,aAAa,EAAE,MAAM,CAAC;IAEtB,SAAS,EAAE,UAAU,CAAC;IAEtB,GAAG,EAAE,MAAM,CAAC;IAEZ,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,EAAE,MAAM,CAAC;IAElB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,kBAAkB,CAqDvE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAWpD;AAYD,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,CAgB1D"}
@@ -0,0 +1,8 @@
1
+ export type ProtocolV2LinkErrorCode = 'response-timeout' | 'router' | 'packet-source' | 'ack-sequence' | 'response-sequence' | 'frame';
2
+ export declare class ProtocolV2LinkError extends Error {
3
+ readonly code: ProtocolV2LinkErrorCode;
4
+ readonly cause?: unknown;
5
+ constructor(code: ProtocolV2LinkErrorCode, message: string, cause?: unknown);
6
+ }
7
+ export declare const isProtocolV2LinkError: (error: unknown) => error is ProtocolV2LinkError;
8
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAC/B,kBAAkB,GAClB,QAAQ,GACR,eAAe,GACf,cAAc,GACd,mBAAmB,GACnB,OAAO,CAAC;AAEZ,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IAEvC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEb,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAM5E;AAED,eAAO,MAAM,qBAAqB,UAAW,OAAO,iCACd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"frame-assembler.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/frame-assembler.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CASlE;AAED,qBAAa,wBAAwB;IACnC,OAAO,CAAC,MAAM,CAAqB;IAEnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,aAAa,SAA8B;IAIvD,KAAK;IAIL,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS;IAU/C,KAAK,CAAC,KAAK,GAAE,UAA8B,GAAG,UAAU,EAAE;IAW1D,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,YAAY;CA0CrB"}
1
+ {"version":3,"file":"frame-assembler.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/frame-assembler.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CASlE;AAED,qBAAa,wBAAwB;IACnC,OAAO,CAAC,MAAM,CAAqB;IAEnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,aAAa,SAA8B;IAIvD,KAAK;IAIL,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS;IAU/C,KAAK,CAAC,KAAK,GAAE,UAA8B,GAAG,UAAU,EAAE;IAW1D,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,YAAY;CA2CrB"}
@@ -2,5 +2,6 @@ export * from './constants';
2
2
  export * from './crc8';
3
3
  export * from './encode';
4
4
  export * from './decode';
5
+ export * from './errors';
5
6
  export * from './frame-assembler';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -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,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,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC"}
@@ -2,6 +2,7 @@ import { ProtocolV2FrameAssembler, concatUint8Arrays } from './frame-assembler';
2
2
  import { ProtocolV2SequenceCursor } from './sequence-cursor';
3
3
  import type { Root } from 'protobufjs/light';
4
4
  import type { MessageFromOneKey } from '../../types';
5
+ export * from './errors';
5
6
  export type ProtocolV2Schemas = {
6
7
  protocolV1: Root;
7
8
  protocolV2: Root;
@@ -11,6 +12,7 @@ export type ProtocolV2CallContext = {
11
12
  timeoutMs?: number;
12
13
  highVolume: boolean;
13
14
  generation: number;
15
+ signal: AbortSignal;
14
16
  };
15
17
  type ProtocolLogger = {
16
18
  debug?: (...args: any[]) => void;
@@ -41,11 +43,12 @@ export { ProtocolV2SequenceCursor };
41
43
  export declare function hexToBytes(hex: string): Uint8Array;
42
44
  export declare function bytesToHex(bytes: Uint8Array): string;
43
45
  export declare function getErrorMessage(error: unknown): string;
44
- export declare function withProtocolTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, createTimeoutError: () => Error, onTimeout?: () => void): Promise<T>;
46
+ export declare function withProtocolTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, createTimeoutError: () => Error, onTimeout?: () => void, abortSignal?: AbortSignal): Promise<T>;
45
47
  export declare class ProtocolV2Session {
46
48
  private readonly options;
47
49
  private readonly sequenceCursor;
48
50
  private pendingCall;
51
+ private lastResponseSequence?;
49
52
  constructor(options: ProtocolV2SessionOptions);
50
53
  call(name: string, data: Record<string, unknown>, callOptions?: ProtocolV2CallOptions): Promise<MessageFromOneKey>;
51
54
  private executeCall;
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/protocols/v2/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAK7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,iBAAiB,CAAC;IA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C,iBAAiB,CAAC;IAS7B,OAAO,CAAC,WAAW;CAoJpB;AAED,wBAAsB,eAAe,CAAC,EACpC,IAAI,EACJ,SAAS,EACT,MAAM,EACN,SAAwB,EACxB,aAAa,EACb,aAAa,GACd,EAAE;IACD,IAAI,EAAE,CACJ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC1D,oBAuBA"}
@@ -3551,7 +3551,9 @@ export type ViewVerifyPage = {
3551
3551
  derive_type?: string;
3552
3552
  value_key?: number;
3553
3553
  };
3554
- export type ProtocolInfoRequest = {};
3554
+ export type ProtocolInfoRequest = {
3555
+ eventless_wallet_session?: boolean;
3556
+ };
3555
3557
  export type ProtocolInfo = {
3556
3558
  version: number;
3557
3559
  supported_messages: number[];
@@ -3782,8 +3784,30 @@ export type ProtocolV2DeviceInfo = {
3782
3784
  se4?: DeviceSEInfo;
3783
3785
  status?: DeviceStatus;
3784
3786
  };
3785
- export type DeviceSessionGet = {
3786
- session_id?: string;
3787
+ export declare enum DeviceSessionErrorCode {
3788
+ DeviceSessionError_None = 0,
3789
+ DeviceSessionError_UserCancelled = 1,
3790
+ DeviceSessionError_InvalidSession = 2,
3791
+ DeviceSessionError_AttachPinUnavailable = 3,
3792
+ DeviceSessionError_PassphraseDisabled = 4,
3793
+ DeviceSessionError_Busy = 5
3794
+ }
3795
+ export type DeviceSessionResume = {
3796
+ session_id: string;
3797
+ };
3798
+ export type DeviceSessionHostPassphrase = {
3799
+ passphrase: string;
3800
+ };
3801
+ export type DeviceSessionPassphraseOnDevice = {};
3802
+ export type DeviceSessionAttachPinOnDevice = {};
3803
+ export type DeviceSessionSelect = {
3804
+ host_passphrase?: DeviceSessionHostPassphrase;
3805
+ passphrase_on_device?: DeviceSessionPassphraseOnDevice;
3806
+ attach_pin_on_device?: DeviceSessionAttachPinOnDevice;
3807
+ };
3808
+ export type DeviceSessionOpen = {
3809
+ resume?: DeviceSessionResume;
3810
+ select?: DeviceSessionSelect;
3787
3811
  };
3788
3812
  export type DeviceSession = {
3789
3813
  session_id?: string;
@@ -4564,7 +4588,12 @@ export type MessageType = {
4564
4588
  DeviceInfoTargets: DeviceInfoTargets;
4565
4589
  DeviceInfoTypes: DeviceInfoTypes;
4566
4590
  DeviceInfoGet: DeviceInfoGet;
4567
- DeviceSessionGet: DeviceSessionGet;
4591
+ DeviceSessionResume: DeviceSessionResume;
4592
+ DeviceSessionHostPassphrase: DeviceSessionHostPassphrase;
4593
+ DeviceSessionPassphraseOnDevice: DeviceSessionPassphraseOnDevice;
4594
+ DeviceSessionAttachPinOnDevice: DeviceSessionAttachPinOnDevice;
4595
+ DeviceSessionSelect: DeviceSessionSelect;
4596
+ DeviceSessionOpen: DeviceSessionOpen;
4568
4597
  DeviceSession: DeviceSession;
4569
4598
  DeviceSessionAskPin: DeviceSessionAskPin;
4570
4599
  DeviceStatus: DeviceStatus;