@onekeyfe/hd-transport 1.2.0-alpha.3 → 1.2.0-alpha.31
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/README.md +1 -1
- package/__tests__/messages.test.js +142 -0
- package/__tests__/protocol-v2-ble-frame-writer.test.js +119 -0
- package/__tests__/protocol-v2-link-manager.test.js +389 -0
- package/__tests__/protocol-v2-usb-transport-base.test.js +330 -0
- package/__tests__/protocol-v2.test.js +555 -119
- package/dist/constants.d.ts +6 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +981 -278
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +759 -247
- package/dist/protocols/index.d.ts +14 -5
- package/dist/protocols/index.d.ts.map +1 -1
- package/dist/protocols/v2/ble-frame-writer.d.ts +15 -0
- package/dist/protocols/v2/ble-frame-writer.d.ts.map +1 -0
- package/dist/protocols/v2/constants.d.ts +1 -0
- package/dist/protocols/v2/constants.d.ts.map +1 -1
- package/dist/protocols/v2/decode.d.ts +13 -2
- package/dist/protocols/v2/decode.d.ts.map +1 -1
- package/dist/protocols/v2/encode.d.ts +2 -3
- package/dist/protocols/v2/encode.d.ts.map +1 -1
- package/dist/protocols/v2/errors.d.ts +8 -0
- package/dist/protocols/v2/errors.d.ts.map +1 -0
- package/dist/protocols/v2/frame-assembler.d.ts.map +1 -1
- package/dist/protocols/v2/index.d.ts +2 -1
- package/dist/protocols/v2/index.d.ts.map +1 -1
- package/dist/protocols/v2/link-manager.d.ts +38 -0
- package/dist/protocols/v2/link-manager.d.ts.map +1 -0
- package/dist/protocols/v2/sequence-cursor.d.ts +5 -0
- package/dist/protocols/v2/sequence-cursor.d.ts.map +1 -0
- package/dist/protocols/v2/session.d.ts +19 -5
- package/dist/protocols/v2/session.d.ts.map +1 -1
- package/dist/protocols/v2/usb-transport-base.d.ts +32 -0
- package/dist/protocols/v2/usb-transport-base.d.ts.map +1 -0
- package/dist/serialization/protobuf/decode.d.ts.map +1 -1
- package/dist/types/messages.d.ts +523 -158
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/transport.d.ts +13 -3
- package/dist/types/transport.d.ts.map +1 -1
- package/messages-protocol-v2.json +796 -620
- package/package.json +3 -3
- package/scripts/protobuf-build.sh +96 -310
- package/scripts/protobuf-patches/index.js +1 -0
- package/scripts/protobuf-types.js +19 -1
- package/src/constants.ts +29 -15
- package/src/index.ts +11 -1
- package/src/protocols/index.ts +39 -40
- package/src/protocols/v2/ble-frame-writer.ts +77 -0
- package/src/protocols/v2/constants.ts +1 -0
- package/src/protocols/v2/crc8.ts +1 -1
- package/src/protocols/v2/decode.ts +71 -37
- package/src/protocols/v2/encode.ts +2 -28
- package/src/protocols/v2/errors.ts +25 -0
- package/src/protocols/v2/frame-assembler.ts +6 -4
- package/src/protocols/v2/index.ts +2 -1
- package/src/protocols/v2/link-manager.ts +186 -0
- package/src/protocols/v2/sequence-cursor.ts +10 -0
- package/src/protocols/v2/session.ts +157 -201
- package/src/protocols/v2/usb-transport-base.ts +213 -0
- package/src/serialization/protobuf/decode.ts +4 -1
- package/src/types/messages.ts +623 -181
- package/src/types/transport.ts +13 -3
- package/dist/protocols/v2/debug.d.ts +0 -13
- package/dist/protocols/v2/debug.d.ts.map +0 -1
- package/src/protocols/v2/debug.ts +0 -26
package/dist/index.js
CHANGED
|
@@ -140,7 +140,7 @@ function messageToJSON(Message, fields) {
|
|
|
140
140
|
res[key] = field.resolvedType.valuesById[value];
|
|
141
141
|
}
|
|
142
142
|
else if (field.resolvedType.fields) {
|
|
143
|
-
res[key] = messageToJSON(value, field.resolvedType.fields);
|
|
143
|
+
res[key] = value == null ? null : messageToJSON(value, field.resolvedType.fields);
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
146
|
throw new Error(`case not handled: ${key}`);
|
|
@@ -267,14 +267,17 @@ const PROTOCOL_V1_CHUNK_PAYLOAD_SIZE = 63;
|
|
|
267
267
|
const PROTOCOL_V1_USB_PACKET_SIZE = PROTOCOL_V1_CHUNK_PAYLOAD_SIZE + 1;
|
|
268
268
|
const PROTOCOL_V1_MESSAGE_HEADER_SIZE = 2 + 4;
|
|
269
269
|
const PROTOCOL_V1_ENVELOPE_HEADER_SIZE = 1 + 1 + PROTOCOL_V1_MESSAGE_HEADER_SIZE;
|
|
270
|
-
const PROTOCOL_V2_FRAME_MAX_BYTES =
|
|
271
|
-
const PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE =
|
|
270
|
+
const PROTOCOL_V2_FRAME_MAX_BYTES = 4200;
|
|
271
|
+
const PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE = 4000;
|
|
272
272
|
const PROTOCOL_V2_BLE_FILE_CHUNK_SIZE = 1800;
|
|
273
|
+
const PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE = 900;
|
|
274
|
+
const PROTOCOL_V2_BLE_FRAME_MAX_BYTES = 2048;
|
|
273
275
|
const PROTOCOL_V2_FILE_CHUNK_SIZE = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
274
276
|
const PROTOCOL_V2_CHANNEL_USB = 0;
|
|
275
277
|
const PROTOCOL_V2_CHANNEL_BLE_UART = 1;
|
|
276
278
|
const PROTOCOL_V2_CHANNEL_SOCKET = 2;
|
|
277
279
|
const PROTOCOL_V2_PACKET_SRC_COMMAND = 0;
|
|
280
|
+
const PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS = 5 * 60 * 1000;
|
|
278
281
|
|
|
279
282
|
function encodeEnvelope(data, options) {
|
|
280
283
|
const { addTrezorHeaders, chunked, messageTypeId } = options;
|
|
@@ -381,6 +384,7 @@ const PROTO_HEAD_CRC_SIZE = 8;
|
|
|
381
384
|
const CRC8_INIT = 0x30;
|
|
382
385
|
const PACKET_SIZE = 4096;
|
|
383
386
|
const PROTO_DATA_TYPE_PACKET = 0;
|
|
387
|
+
const PROTO_DATA_TYPE_ACK = 1;
|
|
384
388
|
|
|
385
389
|
const CRC8_TABLE = new Uint8Array([
|
|
386
390
|
0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41,
|
|
@@ -408,16 +412,11 @@ function crc8(data, len) {
|
|
|
408
412
|
return crc;
|
|
409
413
|
}
|
|
410
414
|
|
|
411
|
-
function logProtocolV2Debug(options, stage, details) {
|
|
412
|
-
var _a, _b, _c;
|
|
413
|
-
(_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));
|
|
414
|
-
}
|
|
415
|
-
|
|
416
415
|
const PROTO_SEQ_DEFAULT = 1;
|
|
417
416
|
function nextProtoSeq(current) {
|
|
418
417
|
return current >= 255 ? 1 : current + 1;
|
|
419
418
|
}
|
|
420
|
-
function encodeFrame(payload, packetSrc, router,
|
|
419
|
+
function encodeFrame(payload, packetSrc, router, seq) {
|
|
421
420
|
const resolvedPacketSrc = packetSrc !== null && packetSrc !== void 0 ? packetSrc : 0;
|
|
422
421
|
const resolvedRouter = router !== null && router !== void 0 ? router : 0;
|
|
423
422
|
const resolvedSeq = seq !== null && seq !== void 0 ? seq : PROTO_SEQ_DEFAULT;
|
|
@@ -427,7 +426,7 @@ function encodeFrame(payload, packetSrc, router, debugOptions, seq) {
|
|
|
427
426
|
const payloadLen = payload ? payload.length : 0;
|
|
428
427
|
const frameLen = payloadLen + PROTO_HEAD_CRC_SIZE;
|
|
429
428
|
if (frameLen > PROTOCOL_V2_FRAME_MAX_BYTES) {
|
|
430
|
-
throw new Error(`Protocol V2 frame too large: ${frameLen}`);
|
|
429
|
+
throw new Error(`Protocol V2 frame too large: ${frameLen} > ${PROTOCOL_V2_FRAME_MAX_BYTES}`);
|
|
431
430
|
}
|
|
432
431
|
const frame = new Uint8Array(frameLen);
|
|
433
432
|
frame[0] = PROTO_HEAD_SOF;
|
|
@@ -442,27 +441,17 @@ function encodeFrame(payload, packetSrc, router, debugOptions, seq) {
|
|
|
442
441
|
frame.set(payload, 7);
|
|
443
442
|
}
|
|
444
443
|
frame[frameLen - 1] = crc8(frame, frameLen - 1);
|
|
445
|
-
logProtocolV2Debug(debugOptions, 'encode raw frame', {
|
|
446
|
-
frameLen,
|
|
447
|
-
payloadLen,
|
|
448
|
-
packetSrc: resolvedPacketSrc,
|
|
449
|
-
router: frame[4],
|
|
450
|
-
attr: frame[5],
|
|
451
|
-
seq: frame[6],
|
|
452
|
-
headerCrc: frame[3],
|
|
453
|
-
frameCrc: frame[frameLen - 1],
|
|
454
|
-
});
|
|
455
444
|
return frame;
|
|
456
445
|
}
|
|
457
|
-
function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router,
|
|
446
|
+
function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router, seq) {
|
|
458
447
|
const payload = new Uint8Array(2 + pbPayload.length);
|
|
459
448
|
payload[0] = messageTypeId % 256;
|
|
460
449
|
payload[1] = Math.floor(messageTypeId / 256) % 256;
|
|
461
450
|
payload.set(pbPayload, 2);
|
|
462
|
-
return encodeFrame(payload, packetSrc, router,
|
|
451
|
+
return encodeFrame(payload, packetSrc, router, seq);
|
|
463
452
|
}
|
|
464
453
|
|
|
465
|
-
function
|
|
454
|
+
function inspectFrameHeader(data) {
|
|
466
455
|
if (data.length < PROTO_HEAD_CRC_SIZE) {
|
|
467
456
|
throw new Error(`Protocol V2 frame too short: ${data.length} bytes`);
|
|
468
457
|
}
|
|
@@ -470,8 +459,8 @@ function decodeFrame(data, debugOptions) {
|
|
|
470
459
|
throw new Error(`Invalid SOF byte: expected 0x5A, got 0x${data[0].toString(16).padStart(2, '0')}`);
|
|
471
460
|
}
|
|
472
461
|
const frameLen = data[1] + data[2] * 256;
|
|
473
|
-
if (data.length
|
|
474
|
-
throw new Error(`
|
|
462
|
+
if (data.length !== frameLen) {
|
|
463
|
+
throw new Error(`Protocol V2 frame length mismatch: expected ${frameLen} bytes, got ${data.length}`);
|
|
475
464
|
}
|
|
476
465
|
const expectedHeaderCrc = crc8(data, 3);
|
|
477
466
|
if (data[3] !== expectedHeaderCrc) {
|
|
@@ -485,29 +474,54 @@ function decodeFrame(data, debugOptions) {
|
|
|
485
474
|
.toString(16)
|
|
486
475
|
.padStart(2, '0')}, got 0x${data[frameLen - 1].toString(16).padStart(2, '0')}`);
|
|
487
476
|
}
|
|
477
|
+
const dataType = data[5] & 0x03;
|
|
478
|
+
const packetSrc = (data[5] >> 2) & 0x0f;
|
|
488
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
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function isAckFrame(data) {
|
|
492
|
+
if (data.length < 6 || (data[5] & 0x03) !== PROTO_DATA_TYPE_ACK) {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
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}`);
|
|
498
|
+
}
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
function decodeFrame(data) {
|
|
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
|
+
}
|
|
489
506
|
const payloadData = data.slice(7, frameLen - 1);
|
|
490
507
|
if (payloadData.length < 2) {
|
|
491
508
|
throw new Error(`Protocol V2 payload too short (need >=2 bytes for messageTypeId)`);
|
|
492
509
|
}
|
|
493
510
|
const messageTypeId = payloadData[0] + payloadData[1] * 256;
|
|
494
511
|
const pbPayload = payloadData.slice(2);
|
|
495
|
-
|
|
496
|
-
frameLen,
|
|
497
|
-
dataLength: data.length,
|
|
498
|
-
router: data[4],
|
|
499
|
-
attr: data[5],
|
|
500
|
-
seq,
|
|
501
|
-
headerCrc: data[3],
|
|
502
|
-
expectedHeaderCrc,
|
|
503
|
-
frameCrc: data[frameLen - 1],
|
|
504
|
-
expectedFrameCrc,
|
|
505
|
-
messageTypeId,
|
|
506
|
-
pbPayloadLength: pbPayload.length,
|
|
507
|
-
});
|
|
508
|
-
return { messageTypeId, pbPayload, seq };
|
|
512
|
+
return { messageTypeId, pbPayload, seq, router, packetSrc, dataType };
|
|
509
513
|
}
|
|
510
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
|
+
}
|
|
522
|
+
}
|
|
523
|
+
const isProtocolV2LinkError = (error) => error instanceof ProtocolV2LinkError;
|
|
524
|
+
|
|
511
525
|
function concatUint8Arrays(arrays) {
|
|
512
526
|
const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);
|
|
513
527
|
const result = new Uint8Array(totalLength);
|
|
@@ -551,23 +565,23 @@ class ProtocolV2FrameAssembler {
|
|
|
551
565
|
return undefined;
|
|
552
566
|
if (this.buffer[0] !== PROTO_HEAD_SOF) {
|
|
553
567
|
this.reset();
|
|
554
|
-
throw new
|
|
568
|
+
throw new ProtocolV2LinkError('frame', 'Invalid Protocol V2 SOF');
|
|
555
569
|
}
|
|
556
570
|
const expectedLen = this.buffer[1] + this.buffer[2] * 256;
|
|
557
571
|
if (expectedLen < PROTO_HEAD_CRC_SIZE) {
|
|
558
572
|
this.reset();
|
|
559
|
-
throw new
|
|
573
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 frame length too small: ${expectedLen}`);
|
|
560
574
|
}
|
|
561
575
|
if (expectedLen > this.maxFrameBytes) {
|
|
562
576
|
this.reset();
|
|
563
|
-
throw new
|
|
577
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 frame too large: ${expectedLen}`);
|
|
564
578
|
}
|
|
565
579
|
if (this.buffer.length < PROTO_PRE_HEAD_SIZE)
|
|
566
580
|
return undefined;
|
|
567
581
|
const expectedHeaderCrc = crc8(this.buffer, 3);
|
|
568
582
|
if (this.buffer[3] !== expectedHeaderCrc) {
|
|
569
583
|
this.reset();
|
|
570
|
-
throw new
|
|
584
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 header CRC mismatch: expected 0x${expectedHeaderCrc
|
|
571
585
|
.toString(16)
|
|
572
586
|
.padStart(2, '0')}`);
|
|
573
587
|
}
|
|
@@ -579,6 +593,51 @@ class ProtocolV2FrameAssembler {
|
|
|
579
593
|
}
|
|
580
594
|
}
|
|
581
595
|
|
|
596
|
+
const defaultWait = (timeoutMs) => new Promise(resolve => {
|
|
597
|
+
setTimeout(resolve, timeoutMs);
|
|
598
|
+
});
|
|
599
|
+
function writeProtocolV2BleFrame({ frame, packetCapacity, writePacket, assertActive, signal, abortMessage = 'Protocol V2 BLE write aborted', initialDelayMs = 0, burstSize, burstPauseMs = 0, flushDelayMs = 0, wait = defaultWait, }) {
|
|
600
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
601
|
+
if (!Number.isInteger(packetCapacity) || packetCapacity <= 0) {
|
|
602
|
+
throw new Error('Protocol V2 BLE packet capacity must be a positive integer');
|
|
603
|
+
}
|
|
604
|
+
if (burstSize !== undefined && (!Number.isInteger(burstSize) || burstSize <= 0)) {
|
|
605
|
+
throw new Error('Protocol V2 BLE burst size must be a positive integer');
|
|
606
|
+
}
|
|
607
|
+
const assertWritable = () => {
|
|
608
|
+
assertActive === null || assertActive === void 0 ? void 0 : assertActive();
|
|
609
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
610
|
+
throw new Error(abortMessage);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
if (frame.length > 0 && initialDelayMs > 0) {
|
|
614
|
+
assertWritable();
|
|
615
|
+
yield wait(initialDelayMs);
|
|
616
|
+
assertWritable();
|
|
617
|
+
}
|
|
618
|
+
let packetsWritten = 0;
|
|
619
|
+
for (let offset = 0; offset < frame.length; offset += packetCapacity) {
|
|
620
|
+
assertWritable();
|
|
621
|
+
const packet = frame.slice(offset, offset + packetCapacity);
|
|
622
|
+
yield writePacket(packet, packetsWritten);
|
|
623
|
+
packetsWritten += 1;
|
|
624
|
+
assertWritable();
|
|
625
|
+
const hasMorePackets = offset + packetCapacity < frame.length;
|
|
626
|
+
if (hasMorePackets &&
|
|
627
|
+
burstSize !== undefined &&
|
|
628
|
+
packetsWritten % burstSize === 0 &&
|
|
629
|
+
burstPauseMs > 0) {
|
|
630
|
+
yield wait(burstPauseMs);
|
|
631
|
+
assertWritable();
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
if (burstSize !== undefined && packetsWritten > burstSize && flushDelayMs > 0) {
|
|
635
|
+
yield wait(flushDelayMs);
|
|
636
|
+
assertWritable();
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
|
|
582
641
|
var protocolV2Codec = /*#__PURE__*/Object.freeze({
|
|
583
642
|
__proto__: null,
|
|
584
643
|
PROTO_HEAD_SOF: PROTO_HEAD_SOF,
|
|
@@ -587,15 +646,20 @@ var protocolV2Codec = /*#__PURE__*/Object.freeze({
|
|
|
587
646
|
CRC8_INIT: CRC8_INIT,
|
|
588
647
|
PACKET_SIZE: PACKET_SIZE,
|
|
589
648
|
PROTO_DATA_TYPE_PACKET: PROTO_DATA_TYPE_PACKET,
|
|
649
|
+
PROTO_DATA_TYPE_ACK: PROTO_DATA_TYPE_ACK,
|
|
590
650
|
CRC8_TABLE: CRC8_TABLE,
|
|
591
651
|
crc8: crc8,
|
|
592
|
-
logProtocolV2Debug: logProtocolV2Debug,
|
|
593
652
|
nextProtoSeq: nextProtoSeq,
|
|
594
653
|
encodeFrame: encodeFrame,
|
|
595
654
|
encodeProtobufFrame: encodeProtobufFrame,
|
|
655
|
+
inspectFrameHeader: inspectFrameHeader,
|
|
656
|
+
isAckFrame: isAckFrame,
|
|
596
657
|
decodeFrame: decodeFrame,
|
|
658
|
+
ProtocolV2LinkError: ProtocolV2LinkError,
|
|
659
|
+
isProtocolV2LinkError: isProtocolV2LinkError,
|
|
597
660
|
concatUint8Arrays: concatUint8Arrays,
|
|
598
|
-
ProtocolV2FrameAssembler: ProtocolV2FrameAssembler
|
|
661
|
+
ProtocolV2FrameAssembler: ProtocolV2FrameAssembler,
|
|
662
|
+
writeProtocolV2BleFrame: writeProtocolV2BleFrame
|
|
599
663
|
});
|
|
600
664
|
|
|
601
665
|
const PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = 60000;
|
|
@@ -643,46 +707,46 @@ const ProtocolV1 = {
|
|
|
643
707
|
decodeMessage: decodeMessage,
|
|
644
708
|
};
|
|
645
709
|
const ProtocolV2 = {
|
|
710
|
+
isAckFrame,
|
|
711
|
+
inspectFrameHeader,
|
|
712
|
+
inspectFrame(schemas, frame) {
|
|
713
|
+
const { messageTypeId, pbPayload, seq, router, packetSrc, dataType } = decodeFrame(frame);
|
|
714
|
+
const { messageName } = createProtocolV2MessageFromType(messageTypeId, schemas);
|
|
715
|
+
return {
|
|
716
|
+
messageName,
|
|
717
|
+
messageTypeId,
|
|
718
|
+
pbPayload,
|
|
719
|
+
seq,
|
|
720
|
+
router,
|
|
721
|
+
packetSrc,
|
|
722
|
+
dataType,
|
|
723
|
+
type: messageName,
|
|
724
|
+
};
|
|
725
|
+
},
|
|
646
726
|
encodeFrame(schemas, name, data, options = {}) {
|
|
647
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
648
727
|
const encodeMessages = resolveProtocolV2EncodeSchema(name, schemas);
|
|
649
728
|
const { Message, messageTypeId } = createMessageFromName(encodeMessages, name);
|
|
650
729
|
const pbBuffer = encode(Message, data);
|
|
651
730
|
pbBuffer.reset();
|
|
652
731
|
const rawPbBuffer = pbBuffer.toBuffer();
|
|
653
732
|
const pbBytes = new Uint8Array(rawPbBuffer);
|
|
654
|
-
|
|
655
|
-
context: (_d = options.context) !== null && _d !== void 0 ? _d : `encode:${name}`,
|
|
656
|
-
messageName: name,
|
|
657
|
-
messageTypeId,
|
|
658
|
-
pbPayloadLength: pbBytes.length,
|
|
659
|
-
packetSrc: (_e = options.packetSrc) !== null && _e !== void 0 ? _e : 0,
|
|
660
|
-
router: (_f = options.router) !== null && _f !== void 0 ? _f : 0,
|
|
661
|
-
});
|
|
662
|
-
return encodeProtobufFrame(messageTypeId, pbBytes, options.packetSrc, options.router, {
|
|
663
|
-
logger: options.logger,
|
|
664
|
-
logPrefix: options.logPrefix,
|
|
665
|
-
context: (_g = options.context) !== null && _g !== void 0 ? _g : `encode:${name}`,
|
|
666
|
-
messageName: name,
|
|
667
|
-
}, options.seq);
|
|
733
|
+
return encodeProtobufFrame(messageTypeId, pbBytes, options.packetSrc, options.router, options.seq);
|
|
668
734
|
},
|
|
669
|
-
decodeFrame(schemas, frame
|
|
670
|
-
|
|
671
|
-
const {
|
|
672
|
-
logger: options.logger,
|
|
673
|
-
logPrefix: options.logPrefix,
|
|
674
|
-
context: (_a = options.context) !== null && _a !== void 0 ? _a : 'decode',
|
|
675
|
-
});
|
|
676
|
-
const { Message, messageName } = createProtocolV2MessageFromType(messageTypeId, schemas);
|
|
735
|
+
decodeFrame(schemas, frame) {
|
|
736
|
+
const { messageTypeId, pbPayload, seq, messageName } = this.inspectFrame(schemas, frame);
|
|
737
|
+
const { Message } = createProtocolV2MessageFromType(messageTypeId, schemas);
|
|
677
738
|
const rxByteBuffer = ByteBuffer__default["default"].wrap(Buffer.from(pbPayload));
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
739
|
+
let message;
|
|
740
|
+
try {
|
|
741
|
+
message = decode(Message, rxByteBuffer);
|
|
742
|
+
}
|
|
743
|
+
catch (cause) {
|
|
744
|
+
const error = new Error(`Protocol V2 protobuf decode failed for "${messageName}" ` +
|
|
745
|
+
`(${messageTypeId}, ${pbPayload.length}-byte payload); ` +
|
|
746
|
+
'the payload is malformed or incompatible with the active SDK schema.');
|
|
747
|
+
error.cause = cause;
|
|
748
|
+
throw error;
|
|
749
|
+
}
|
|
686
750
|
return {
|
|
687
751
|
message,
|
|
688
752
|
messageName,
|
|
@@ -705,6 +769,16 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
705
769
|
decodeMessage: decodeMessage
|
|
706
770
|
});
|
|
707
771
|
|
|
772
|
+
class ProtocolV2SequenceCursor {
|
|
773
|
+
constructor() {
|
|
774
|
+
this.current = 0;
|
|
775
|
+
}
|
|
776
|
+
next() {
|
|
777
|
+
this.current = nextProtoSeq(this.current);
|
|
778
|
+
return this.current;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
708
782
|
const ERROR = 'Wrong result type.';
|
|
709
783
|
function info(res) {
|
|
710
784
|
if (typeof res !== 'object' || res == null) {
|
|
@@ -821,11 +895,6 @@ function bytesToHex(bytes) {
|
|
|
821
895
|
.map(b => b.toString(16).padStart(2, '0'))
|
|
822
896
|
.join('');
|
|
823
897
|
}
|
|
824
|
-
const PROTOCOL_V2_DEBUG_HEADER_BYTES = 7;
|
|
825
|
-
const PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT = 20;
|
|
826
|
-
const PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT = 40;
|
|
827
|
-
const PROTOCOL_V2_DEBUG_STRING_LIMIT = 512;
|
|
828
|
-
const PROTOCOL_V2_DEBUG_DEPTH_LIMIT = 4;
|
|
829
898
|
const HIGH_VOLUME_PROTOCOL_V2_CALLS = new Set([
|
|
830
899
|
...LogBlockCommand,
|
|
831
900
|
'FilesystemFileRead',
|
|
@@ -835,80 +904,6 @@ const HIGH_VOLUME_PROTOCOL_V2_CALLS = new Set([
|
|
|
835
904
|
function shouldReduceProtocolV2Debug(name) {
|
|
836
905
|
return HIGH_VOLUME_PROTOCOL_V2_CALLS.has(name);
|
|
837
906
|
}
|
|
838
|
-
function frameHeaderDebugHex(frame) {
|
|
839
|
-
return bytesToHex(frame.slice(0, PROTOCOL_V2_DEBUG_HEADER_BYTES));
|
|
840
|
-
}
|
|
841
|
-
function getBinaryByteLength(value) {
|
|
842
|
-
if (value instanceof ArrayBuffer) {
|
|
843
|
-
return value.byteLength;
|
|
844
|
-
}
|
|
845
|
-
if (ArrayBuffer.isView(value)) {
|
|
846
|
-
return value.byteLength;
|
|
847
|
-
}
|
|
848
|
-
if (typeof Blob !== 'undefined' && value instanceof Blob) {
|
|
849
|
-
return value.size;
|
|
850
|
-
}
|
|
851
|
-
return undefined;
|
|
852
|
-
}
|
|
853
|
-
function summarizeRedactedData(value) {
|
|
854
|
-
const byteLength = getBinaryByteLength(value);
|
|
855
|
-
if (byteLength !== undefined) {
|
|
856
|
-
return `[redacted data: ${byteLength} bytes]`;
|
|
857
|
-
}
|
|
858
|
-
if (typeof value === 'string') {
|
|
859
|
-
return `[redacted data: string length=${value.length}]`;
|
|
860
|
-
}
|
|
861
|
-
if (Array.isArray(value)) {
|
|
862
|
-
return `[redacted data: array length=${value.length}]`;
|
|
863
|
-
}
|
|
864
|
-
if (value && typeof value === 'object') {
|
|
865
|
-
return `[redacted data: object keys=${Object.keys(value).length}]`;
|
|
866
|
-
}
|
|
867
|
-
return `[redacted data: ${typeof value}]`;
|
|
868
|
-
}
|
|
869
|
-
function sanitizeProtocolV2DebugPayload(value, key = '', depth = 0) {
|
|
870
|
-
if (/^(data|payload)$/i.test(key) && value !== null && value !== undefined) {
|
|
871
|
-
return summarizeRedactedData(value);
|
|
872
|
-
}
|
|
873
|
-
if (/(passphrase|pin|mnemonic|seed|private)/i.test(key)) {
|
|
874
|
-
return '[redacted sensitive value]';
|
|
875
|
-
}
|
|
876
|
-
const byteLength = getBinaryByteLength(value);
|
|
877
|
-
if (byteLength !== undefined) {
|
|
878
|
-
return `[binary: ${byteLength} bytes]`;
|
|
879
|
-
}
|
|
880
|
-
if (typeof value === 'string') {
|
|
881
|
-
return value.length > PROTOCOL_V2_DEBUG_STRING_LIMIT
|
|
882
|
-
? `${value.slice(0, PROTOCOL_V2_DEBUG_STRING_LIMIT)}... (len=${value.length})`
|
|
883
|
-
: value;
|
|
884
|
-
}
|
|
885
|
-
if (!value || typeof value !== 'object') {
|
|
886
|
-
return value;
|
|
887
|
-
}
|
|
888
|
-
if (depth >= PROTOCOL_V2_DEBUG_DEPTH_LIMIT) {
|
|
889
|
-
return Array.isArray(value)
|
|
890
|
-
? `[array length=${value.length}]`
|
|
891
|
-
: `[object keys=${Object.keys(value).length}]`;
|
|
892
|
-
}
|
|
893
|
-
if (Array.isArray(value)) {
|
|
894
|
-
const items = value
|
|
895
|
-
.slice(0, PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT)
|
|
896
|
-
.map(item => sanitizeProtocolV2DebugPayload(item, key, depth + 1));
|
|
897
|
-
if (value.length > PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT) {
|
|
898
|
-
items.push(`... (${value.length - PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT} more)`);
|
|
899
|
-
}
|
|
900
|
-
return items;
|
|
901
|
-
}
|
|
902
|
-
const entries = Object.entries(value).slice(0, PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT);
|
|
903
|
-
const sanitized = {};
|
|
904
|
-
entries.forEach(([entryKey, entryValue]) => {
|
|
905
|
-
sanitized[entryKey] = sanitizeProtocolV2DebugPayload(entryValue, entryKey, depth + 1);
|
|
906
|
-
});
|
|
907
|
-
if (Object.keys(value).length > PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT) {
|
|
908
|
-
sanitized.__truncated__ = `${Object.keys(value).length - PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT} more keys`;
|
|
909
|
-
}
|
|
910
|
-
return sanitized;
|
|
911
|
-
}
|
|
912
907
|
const COMMON_TERMINAL_RESPONSE_TYPES = new Set([
|
|
913
908
|
'Failure',
|
|
914
909
|
'ButtonRequest',
|
|
@@ -934,11 +929,12 @@ function getErrorMessage(error) {
|
|
|
934
929
|
}
|
|
935
930
|
return String(error);
|
|
936
931
|
}
|
|
937
|
-
function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout) {
|
|
932
|
+
function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout, abortSignal) {
|
|
938
933
|
return __awaiter(this, void 0, void 0, function* () {
|
|
939
934
|
if (!timeoutMs)
|
|
940
935
|
return promise;
|
|
941
936
|
let timer;
|
|
937
|
+
let abortHandler;
|
|
942
938
|
try {
|
|
943
939
|
return yield Promise.race([
|
|
944
940
|
promise,
|
|
@@ -948,20 +944,38 @@ function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout)
|
|
|
948
944
|
reject(createTimeoutError());
|
|
949
945
|
}, timeoutMs);
|
|
950
946
|
}),
|
|
947
|
+
...(abortSignal
|
|
948
|
+
? [
|
|
949
|
+
new Promise((_, reject) => {
|
|
950
|
+
abortHandler = () => {
|
|
951
|
+
reject(new Error('Protocol V2 operation aborted'));
|
|
952
|
+
};
|
|
953
|
+
if (abortSignal.aborted) {
|
|
954
|
+
abortHandler();
|
|
955
|
+
}
|
|
956
|
+
else {
|
|
957
|
+
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
958
|
+
}
|
|
959
|
+
}),
|
|
960
|
+
]
|
|
961
|
+
: []),
|
|
951
962
|
]);
|
|
952
963
|
}
|
|
953
964
|
finally {
|
|
954
965
|
if (timer)
|
|
955
966
|
clearTimeout(timer);
|
|
967
|
+
if (abortHandler) {
|
|
968
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
|
|
969
|
+
}
|
|
956
970
|
}
|
|
957
971
|
});
|
|
958
972
|
}
|
|
959
|
-
const PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS = 30000;
|
|
960
973
|
class ProtocolV2Session {
|
|
961
974
|
constructor(options) {
|
|
975
|
+
var _a;
|
|
962
976
|
this.pendingCall = Promise.resolve();
|
|
963
|
-
this.protoSeq = 0;
|
|
964
977
|
this.options = options;
|
|
978
|
+
this.sequenceCursor = (_a = options.sequenceCursor) !== null && _a !== void 0 ? _a : new ProtocolV2SequenceCursor();
|
|
965
979
|
}
|
|
966
980
|
call(name, data, callOptions = {}) {
|
|
967
981
|
const run = () => this.executeCall(name, data, callOptions);
|
|
@@ -970,69 +984,91 @@ class ProtocolV2Session {
|
|
|
970
984
|
return result;
|
|
971
985
|
}
|
|
972
986
|
executeCall(name, data, callOptions) {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
987
|
+
const { schemas, router, packetSrc = PROTOCOL_V2_PACKET_SRC_COMMAND, maxFrameBytes, prepareCall, writeFrame, readFrame, logger, logPrefix = 'ProtocolV2', createTimeoutError, generation = 0, } = this.options;
|
|
988
|
+
const timeoutMs = callOptions.timeoutMs && callOptions.timeoutMs > 0
|
|
989
|
+
? callOptions.timeoutMs
|
|
990
|
+
: PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS;
|
|
991
|
+
const abortController = new AbortController();
|
|
992
|
+
const shouldReduceDebug = shouldReduceProtocolV2Debug(name);
|
|
993
|
+
const baseCallContext = {
|
|
994
|
+
messageName: name,
|
|
995
|
+
timeoutMs,
|
|
996
|
+
highVolume: shouldReduceDebug,
|
|
997
|
+
generation,
|
|
998
|
+
signal: abortController.signal,
|
|
999
|
+
};
|
|
1000
|
+
const runCall = () => __awaiter(this, void 0, void 0, function* () {
|
|
1001
|
+
var _a, _b, _c, _d;
|
|
1002
|
+
yield (prepareCall === null || prepareCall === void 0 ? void 0 : prepareCall(baseCallContext));
|
|
1003
|
+
const protoSeq = this.sequenceCursor.next();
|
|
978
1004
|
const frame = ProtocolV2.encodeFrame(schemas, name, data, {
|
|
979
1005
|
packetSrc,
|
|
980
1006
|
router,
|
|
981
|
-
seq:
|
|
982
|
-
logger: shouldReduceDebug ? undefined : logger,
|
|
983
|
-
logPrefix,
|
|
984
|
-
context: `tx:${name}`,
|
|
1007
|
+
seq: protoSeq,
|
|
985
1008
|
});
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
(_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));
|
|
989
|
-
(_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)}`);
|
|
1009
|
+
if (maxFrameBytes !== undefined && frame.length > maxFrameBytes) {
|
|
1010
|
+
throw new Error(`Protocol V2 frame too large for transport: ${frame.length} > ${maxFrameBytes}`);
|
|
990
1011
|
}
|
|
991
|
-
yield
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1012
|
+
yield writeFrame(frame, baseCallContext);
|
|
1013
|
+
while (!abortController.signal.aborted) {
|
|
1014
|
+
const rxFrame = yield readFrame(baseCallContext);
|
|
1015
|
+
if (abortController.signal.aborted)
|
|
1016
|
+
break;
|
|
1017
|
+
let header;
|
|
1018
|
+
try {
|
|
1019
|
+
header = ProtocolV2.inspectFrameHeader(rxFrame);
|
|
1020
|
+
}
|
|
1021
|
+
catch (cause) {
|
|
1022
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 frame validation failed: ${getErrorMessage(cause)}`, cause);
|
|
1023
|
+
}
|
|
1024
|
+
if (header.router !== router) {
|
|
1025
|
+
throw new ProtocolV2LinkError('router', `Protocol V2 router mismatch: expected ${router}, got ${header.router}`);
|
|
1026
|
+
}
|
|
1027
|
+
if (header.packetSrc !== packetSrc) {
|
|
1028
|
+
throw new ProtocolV2LinkError('packet-source', `Protocol V2 packet source mismatch: expected ${packetSrc}, got ${header.packetSrc}`);
|
|
1029
|
+
}
|
|
1030
|
+
let isAck;
|
|
1031
|
+
try {
|
|
1032
|
+
isAck = ProtocolV2.isAckFrame(rxFrame);
|
|
1033
|
+
}
|
|
1034
|
+
catch (cause) {
|
|
1035
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 ACK validation failed: ${getErrorMessage(cause)}`, cause);
|
|
1036
|
+
}
|
|
1037
|
+
if (isAck) {
|
|
1038
|
+
if (header.seq !== protoSeq) {
|
|
1039
|
+
throw new ProtocolV2LinkError('ack-sequence', `Protocol V2 ACK sequence mismatch: expected ${protoSeq}, got ${header.seq}`);
|
|
999
1040
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1041
|
+
}
|
|
1042
|
+
else {
|
|
1043
|
+
let decoded;
|
|
1044
|
+
try {
|
|
1045
|
+
decoded = ProtocolV2.decodeFrame(schemas, rxFrame);
|
|
1002
1046
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
logPrefix,
|
|
1006
|
-
context: `rx:${name}`,
|
|
1007
|
-
});
|
|
1008
|
-
if (!shouldReduceDebug && decoded.seq !== expectedSeq) {
|
|
1009
|
-
(_d = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _d === void 0 ? void 0 : _d.call(logger, `[${logPrefix}] seq differs for ${name}: tx=${expectedSeq}, rx=${decoded.seq}`);
|
|
1047
|
+
catch (cause) {
|
|
1048
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 frame decode failed: ${getErrorMessage(cause)}`, cause);
|
|
1010
1049
|
}
|
|
1011
|
-
if (
|
|
1012
|
-
|
|
1013
|
-
(_f = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _f === void 0 ? void 0 : _f.call(logger, `[${logPrefix}] RX payload type=${decoded.type} messageTypeId=${decoded.messageTypeId}`, sanitizeProtocolV2DebugPayload(decoded.message));
|
|
1050
|
+
if (this.lastResponseSequence === decoded.seq) {
|
|
1051
|
+
throw new ProtocolV2LinkError('response-sequence', `Protocol V2 duplicate response sequence: ${decoded.seq}`);
|
|
1014
1052
|
}
|
|
1053
|
+
this.lastResponseSequence = decoded.seq;
|
|
1015
1054
|
const response = call(decoded);
|
|
1016
|
-
if ((
|
|
1017
|
-
(
|
|
1055
|
+
if ((_a = callOptions.intermediateTypes) === null || _a === void 0 ? void 0 : _a.includes(response.type)) {
|
|
1056
|
+
(_b = callOptions.onIntermediateResponse) === null || _b === void 0 ? void 0 : _b.call(callOptions, response);
|
|
1018
1057
|
}
|
|
1019
1058
|
else if (isExpectedTerminalResponse(response, callOptions.expectedTypes)) {
|
|
1020
1059
|
return response;
|
|
1021
1060
|
}
|
|
1022
1061
|
else if (!shouldReduceDebug) {
|
|
1023
|
-
(
|
|
1062
|
+
(_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}`);
|
|
1024
1063
|
}
|
|
1025
1064
|
}
|
|
1026
|
-
|
|
1027
|
-
});
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
}, () => {
|
|
1034
|
-
cancellation.cancelled = true;
|
|
1035
|
-
});
|
|
1065
|
+
}
|
|
1066
|
+
throw new Error(`Protocol V2 read loop cancelled after timeout for ${name}`);
|
|
1067
|
+
});
|
|
1068
|
+
return withProtocolTimeout(runCall(), timeoutMs, () => createTimeoutError
|
|
1069
|
+
? createTimeoutError(name, timeoutMs)
|
|
1070
|
+
: new Error(`Protocol V2 response timeout after ${timeoutMs}ms for ${name}`), () => {
|
|
1071
|
+
abortController.abort();
|
|
1036
1072
|
});
|
|
1037
1073
|
}
|
|
1038
1074
|
}
|
|
@@ -1042,7 +1078,10 @@ function probeProtocolV2({ call, timeoutMs, logger, logPrefix = 'ProtocolV2', on
|
|
|
1042
1078
|
let probeError;
|
|
1043
1079
|
try {
|
|
1044
1080
|
yield (onBeforeProbe === null || onBeforeProbe === void 0 ? void 0 : onBeforeProbe());
|
|
1045
|
-
const response = yield call('Ping', { message: 'protocol-v2-probe' }, {
|
|
1081
|
+
const response = yield call('Ping', { message: 'protocol-v2-probe' }, {
|
|
1082
|
+
timeoutMs,
|
|
1083
|
+
expectedTypes: ['Success'],
|
|
1084
|
+
});
|
|
1046
1085
|
if (response.type === 'Success') {
|
|
1047
1086
|
return true;
|
|
1048
1087
|
}
|
|
@@ -1057,6 +1096,283 @@ function probeProtocolV2({ call, timeoutMs, logger, logPrefix = 'ProtocolV2', on
|
|
|
1057
1096
|
});
|
|
1058
1097
|
}
|
|
1059
1098
|
|
|
1099
|
+
class ProtocolV2LinkManager {
|
|
1100
|
+
constructor(options) {
|
|
1101
|
+
this.links = new Map();
|
|
1102
|
+
this.sequences = new Map();
|
|
1103
|
+
this.callQueues = new Map();
|
|
1104
|
+
this.generations = new Map();
|
|
1105
|
+
this.invalidationReasons = new Map();
|
|
1106
|
+
this.options = options;
|
|
1107
|
+
}
|
|
1108
|
+
call(key, createAdapter, name, data, options) {
|
|
1109
|
+
var _a, _b;
|
|
1110
|
+
const generation = (_a = this.generations.get(key)) !== null && _a !== void 0 ? _a : 0;
|
|
1111
|
+
const run = () => {
|
|
1112
|
+
this.assertCallGeneration(key, generation);
|
|
1113
|
+
return this.executeCall(key, createAdapter, name, data, options);
|
|
1114
|
+
};
|
|
1115
|
+
const previous = (_b = this.callQueues.get(key)) !== null && _b !== void 0 ? _b : Promise.resolve();
|
|
1116
|
+
const result = previous.then(run, run);
|
|
1117
|
+
const queue = result.catch(() => undefined);
|
|
1118
|
+
this.callQueues.set(key, queue);
|
|
1119
|
+
result
|
|
1120
|
+
.then(() => this.clearSettledCallQueue(key, queue), () => this.clearSettledCallQueue(key, queue))
|
|
1121
|
+
.catch(() => undefined);
|
|
1122
|
+
return result;
|
|
1123
|
+
}
|
|
1124
|
+
invalidateLink(key, reason) {
|
|
1125
|
+
var _a, _b, _c;
|
|
1126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1127
|
+
const generation = ((_a = this.generations.get(key)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
1128
|
+
this.generations.set(key, generation);
|
|
1129
|
+
this.invalidationReasons.set(key, { generation, reason });
|
|
1130
|
+
const link = this.links.get(key);
|
|
1131
|
+
if (!link)
|
|
1132
|
+
return;
|
|
1133
|
+
this.links.delete(key);
|
|
1134
|
+
link.state.invalidatedReason = reason;
|
|
1135
|
+
yield link.adapter.reset(reason);
|
|
1136
|
+
yield ((_c = (_b = this.options).onLinkInvalidated) === null || _c === void 0 ? void 0 : _c.call(_b, key, reason));
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
invalidateAllLinks(reason) {
|
|
1140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1141
|
+
const keys = new Set([...this.links.keys(), ...this.callQueues.keys()]);
|
|
1142
|
+
yield Promise.all(Array.from(keys, key => this.invalidateLink(key, reason)));
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
dispose(reason) {
|
|
1146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1147
|
+
yield this.invalidateAllLinks(reason);
|
|
1148
|
+
this.sequences.clear();
|
|
1149
|
+
this.callQueues.clear();
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
getOrCreateLink(key, createAdapter) {
|
|
1153
|
+
const existing = this.links.get(key);
|
|
1154
|
+
if (existing)
|
|
1155
|
+
return existing;
|
|
1156
|
+
const adapter = createAdapter();
|
|
1157
|
+
const state = {};
|
|
1158
|
+
const assertLinkActive = () => {
|
|
1159
|
+
if (state.invalidatedReason) {
|
|
1160
|
+
throw new Error(state.invalidatedReason);
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
let sequenceCursor = this.sequences.get(key);
|
|
1164
|
+
if (!sequenceCursor) {
|
|
1165
|
+
sequenceCursor = new ProtocolV2SequenceCursor();
|
|
1166
|
+
this.sequences.set(key, sequenceCursor);
|
|
1167
|
+
}
|
|
1168
|
+
const session = new ProtocolV2Session({
|
|
1169
|
+
schemas: this.options.getSchemas(),
|
|
1170
|
+
router: adapter.router,
|
|
1171
|
+
maxFrameBytes: adapter.maxFrameBytes,
|
|
1172
|
+
generation: adapter.generation,
|
|
1173
|
+
sequenceCursor,
|
|
1174
|
+
prepareCall: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1175
|
+
assertLinkActive();
|
|
1176
|
+
yield adapter.prepareCall(context);
|
|
1177
|
+
assertLinkActive();
|
|
1178
|
+
}),
|
|
1179
|
+
writeFrame: (frame, context) => __awaiter(this, void 0, void 0, function* () {
|
|
1180
|
+
assertLinkActive();
|
|
1181
|
+
yield adapter.writeFrame(frame, context);
|
|
1182
|
+
assertLinkActive();
|
|
1183
|
+
}),
|
|
1184
|
+
readFrame: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1185
|
+
assertLinkActive();
|
|
1186
|
+
const frame = yield adapter.readFrame(context);
|
|
1187
|
+
assertLinkActive();
|
|
1188
|
+
return frame;
|
|
1189
|
+
}),
|
|
1190
|
+
logger: adapter.logger,
|
|
1191
|
+
logPrefix: adapter.logPrefix,
|
|
1192
|
+
createTimeoutError: adapter.createTimeoutError,
|
|
1193
|
+
});
|
|
1194
|
+
const link = { adapter, session, state };
|
|
1195
|
+
this.links.set(key, link);
|
|
1196
|
+
return link;
|
|
1197
|
+
}
|
|
1198
|
+
executeCall(key, createAdapter, name, data, options) {
|
|
1199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1200
|
+
try {
|
|
1201
|
+
return yield this.getOrCreateLink(key, createAdapter).session.call(name, data, options);
|
|
1202
|
+
}
|
|
1203
|
+
catch (error) {
|
|
1204
|
+
if (this.options.classifyError(error) === 'link-fatal') {
|
|
1205
|
+
const errorMessage = getErrorMessage(error) || 'unknown error';
|
|
1206
|
+
yield this.invalidateLink(key, `Protocol V2 link-fatal error: ${errorMessage}`);
|
|
1207
|
+
}
|
|
1208
|
+
throw error;
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
clearSettledCallQueue(key, queue) {
|
|
1213
|
+
if (this.callQueues.get(key) === queue) {
|
|
1214
|
+
this.callQueues.delete(key);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
assertCallGeneration(key, generation) {
|
|
1218
|
+
var _a;
|
|
1219
|
+
const currentGeneration = (_a = this.generations.get(key)) !== null && _a !== void 0 ? _a : 0;
|
|
1220
|
+
if (currentGeneration === generation)
|
|
1221
|
+
return;
|
|
1222
|
+
const invalidation = this.invalidationReasons.get(key);
|
|
1223
|
+
const reason = (invalidation === null || invalidation === void 0 ? void 0 : invalidation.generation) === currentGeneration
|
|
1224
|
+
? invalidation.reason
|
|
1225
|
+
: 'Protocol V2 link generation changed';
|
|
1226
|
+
throw new ProtocolV2LinkError('generation', reason);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
class ProtocolV2UsbTransportBase {
|
|
1231
|
+
constructor(options) {
|
|
1232
|
+
this.protocolV2UsbAssemblers = new Map();
|
|
1233
|
+
this.protocolV2UsbGenerations = new Map();
|
|
1234
|
+
this.protocolV2UsbCancellations = new Map();
|
|
1235
|
+
this.protocolV2UsbOptions = options;
|
|
1236
|
+
this.protocolV2UsbLinks = new ProtocolV2LinkManager({
|
|
1237
|
+
getSchemas: () => this.getProtocolV2UsbSchemas(),
|
|
1238
|
+
classifyError: error => (isProtocolV2LinkError(error) ? 'link-fatal' : 'recoverable'),
|
|
1239
|
+
onLinkInvalidated: (key, reason) => __awaiter(this, void 0, void 0, function* () {
|
|
1240
|
+
var _a;
|
|
1241
|
+
(_a = this.protocolV2UsbAssemblers.get(key)) === null || _a === void 0 ? void 0 : _a.reset();
|
|
1242
|
+
yield this.resetProtocolV2UsbNativeLink(key, reason);
|
|
1243
|
+
yield this.onProtocolV2UsbLinkInvalidated(key, reason);
|
|
1244
|
+
}),
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
onProtocolV2UsbLinkInvalidated(_key, _reason) {
|
|
1248
|
+
}
|
|
1249
|
+
rotateProtocolV2UsbGeneration(key, reason) {
|
|
1250
|
+
var _a;
|
|
1251
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1252
|
+
yield this.protocolV2UsbLinks.invalidateLink(key, reason);
|
|
1253
|
+
const generation = ((_a = this.protocolV2UsbGenerations.get(key)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
1254
|
+
this.protocolV2UsbGenerations.set(key, generation);
|
|
1255
|
+
this.protocolV2UsbCancellations.set(key, this.createProtocolV2UsbCancellation(generation));
|
|
1256
|
+
this.protocolV2UsbAssemblers.set(key, new ProtocolV2FrameAssembler(this.protocolV2UsbOptions.maxFrameBytes));
|
|
1257
|
+
return generation;
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
callProtocolV2Usb(key, name, data, options) {
|
|
1261
|
+
return this.protocolV2UsbLinks.call(key, () => this.createProtocolV2UsbAdapter(key), name, data, options);
|
|
1262
|
+
}
|
|
1263
|
+
invalidateProtocolV2UsbLink(key, reason) {
|
|
1264
|
+
return this.protocolV2UsbLinks.invalidateLink(key, reason);
|
|
1265
|
+
}
|
|
1266
|
+
invalidateAllProtocolV2UsbLinks(reason) {
|
|
1267
|
+
return this.protocolV2UsbLinks.invalidateAllLinks(reason);
|
|
1268
|
+
}
|
|
1269
|
+
disposeProtocolV2UsbLinks(reason) {
|
|
1270
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1271
|
+
yield this.protocolV2UsbLinks.dispose(reason);
|
|
1272
|
+
this.protocolV2UsbAssemblers.clear();
|
|
1273
|
+
this.protocolV2UsbGenerations.clear();
|
|
1274
|
+
this.protocolV2UsbCancellations.clear();
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
createProtocolV2UsbAdapter(key) {
|
|
1278
|
+
const generation = this.protocolV2UsbGenerations.get(key);
|
|
1279
|
+
if (generation === undefined) {
|
|
1280
|
+
throw new Error('Protocol V2 USB generation has not been initialized');
|
|
1281
|
+
}
|
|
1282
|
+
const cancellation = this.protocolV2UsbCancellations.get(key);
|
|
1283
|
+
if (!cancellation || cancellation.generation !== generation) {
|
|
1284
|
+
throw new Error('Protocol V2 USB cancellation state has not been initialized');
|
|
1285
|
+
}
|
|
1286
|
+
const assertCurrentGeneration = () => {
|
|
1287
|
+
if (cancellation.reason) {
|
|
1288
|
+
throw new ProtocolV2LinkError('generation', cancellation.reason);
|
|
1289
|
+
}
|
|
1290
|
+
if (this.protocolV2UsbGenerations.get(key) !== generation) {
|
|
1291
|
+
throw new ProtocolV2LinkError('generation', 'Protocol V2 USB connection generation changed');
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
return {
|
|
1295
|
+
router: this.protocolV2UsbOptions.router,
|
|
1296
|
+
maxFrameBytes: this.protocolV2UsbOptions.maxFrameBytes,
|
|
1297
|
+
generation,
|
|
1298
|
+
prepareCall: () => {
|
|
1299
|
+
assertCurrentGeneration();
|
|
1300
|
+
},
|
|
1301
|
+
writeFrame: (frame, context) => __awaiter(this, void 0, void 0, function* () {
|
|
1302
|
+
assertCurrentGeneration();
|
|
1303
|
+
try {
|
|
1304
|
+
yield this.writeProtocolV2UsbPacket(key, frame, context);
|
|
1305
|
+
}
|
|
1306
|
+
catch (error) {
|
|
1307
|
+
throw this.createProtocolV2UsbIoError('write', error);
|
|
1308
|
+
}
|
|
1309
|
+
assertCurrentGeneration();
|
|
1310
|
+
}),
|
|
1311
|
+
readFrame: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1312
|
+
assertCurrentGeneration();
|
|
1313
|
+
const assembler = this.getProtocolV2UsbAssembler(key);
|
|
1314
|
+
let frame = assembler.push(new Uint8Array(0));
|
|
1315
|
+
while (!frame) {
|
|
1316
|
+
const packetRead = this.readProtocolV2UsbPacket(key, context)
|
|
1317
|
+
.then(packet => ({ packet }))
|
|
1318
|
+
.catch(error => {
|
|
1319
|
+
throw this.createProtocolV2UsbIoError('read', error);
|
|
1320
|
+
});
|
|
1321
|
+
const cancelled = cancellation.promise.then(reason => ({ reason }));
|
|
1322
|
+
const result = yield Promise.race([packetRead, cancelled]);
|
|
1323
|
+
if ('reason' in result) {
|
|
1324
|
+
throw new ProtocolV2LinkError('generation', result.reason);
|
|
1325
|
+
}
|
|
1326
|
+
assertCurrentGeneration();
|
|
1327
|
+
frame = assembler.push(result.packet);
|
|
1328
|
+
}
|
|
1329
|
+
assertCurrentGeneration();
|
|
1330
|
+
return frame;
|
|
1331
|
+
}),
|
|
1332
|
+
reset: (reason) => {
|
|
1333
|
+
var _a;
|
|
1334
|
+
cancellation.cancel(reason);
|
|
1335
|
+
(_a = this.protocolV2UsbAssemblers.get(key)) === null || _a === void 0 ? void 0 : _a.reset();
|
|
1336
|
+
},
|
|
1337
|
+
logger: this.getProtocolV2UsbLogger(),
|
|
1338
|
+
logPrefix: this.protocolV2UsbOptions.logPrefix,
|
|
1339
|
+
createTimeoutError: (messageName, timeoutMs) => this.createProtocolV2UsbTimeoutError(messageName, timeoutMs),
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
getProtocolV2UsbAssembler(key) {
|
|
1343
|
+
const assembler = this.protocolV2UsbAssemblers.get(key);
|
|
1344
|
+
if (!assembler) {
|
|
1345
|
+
throw new Error('Protocol V2 USB assembler has not been initialized');
|
|
1346
|
+
}
|
|
1347
|
+
return assembler;
|
|
1348
|
+
}
|
|
1349
|
+
createProtocolV2UsbCancellation(generation) {
|
|
1350
|
+
let resolveCancellation = () => undefined;
|
|
1351
|
+
const cancellation = {
|
|
1352
|
+
generation,
|
|
1353
|
+
promise: new Promise(resolve => {
|
|
1354
|
+
resolveCancellation = resolve;
|
|
1355
|
+
}),
|
|
1356
|
+
cancel: reason => {
|
|
1357
|
+
if (cancellation.reason)
|
|
1358
|
+
return;
|
|
1359
|
+
cancellation.reason = reason;
|
|
1360
|
+
resolveCancellation(reason);
|
|
1361
|
+
},
|
|
1362
|
+
};
|
|
1363
|
+
return cancellation;
|
|
1364
|
+
}
|
|
1365
|
+
createProtocolV2UsbIoError(operation, error) {
|
|
1366
|
+
if (isProtocolV2LinkError(error))
|
|
1367
|
+
return error;
|
|
1368
|
+
return new ProtocolV2LinkError('io', `Protocol V2 USB ${operation} failed: ${getErrorMessage(error) || 'unknown error'}`, error);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
const TRANSPORT_EVENT = {
|
|
1373
|
+
DEVICE_DISCONNECT: 'transport-device-disconnect',
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1060
1376
|
exports.AptosTransactionType = void 0;
|
|
1061
1377
|
(function (AptosTransactionType) {
|
|
1062
1378
|
AptosTransactionType[AptosTransactionType["STANDARD"] = 0] = "STANDARD";
|
|
@@ -1232,6 +1548,9 @@ exports.FailureType = void 0;
|
|
|
1232
1548
|
FailureType[FailureType["Failure_WipeCodeMismatch"] = 13] = "Failure_WipeCodeMismatch";
|
|
1233
1549
|
FailureType[FailureType["Failure_InvalidSession"] = 14] = "Failure_InvalidSession";
|
|
1234
1550
|
FailureType[FailureType["Failure_FirmwareError"] = 99] = "Failure_FirmwareError";
|
|
1551
|
+
FailureType[FailureType["Failure_InvalidMessage"] = 1] = "Failure_InvalidMessage";
|
|
1552
|
+
FailureType[FailureType["Failure_UndefinedError"] = 2] = "Failure_UndefinedError";
|
|
1553
|
+
FailureType[FailureType["Failure_UsageError"] = 3] = "Failure_UsageError";
|
|
1235
1554
|
})(exports.FailureType || (exports.FailureType = {}));
|
|
1236
1555
|
exports.Enum_ButtonRequestType = void 0;
|
|
1237
1556
|
(function (Enum_ButtonRequestType) {
|
|
@@ -1300,6 +1619,24 @@ exports.EthereumDataType = void 0;
|
|
|
1300
1619
|
EthereumDataType[EthereumDataType["ARRAY"] = 7] = "ARRAY";
|
|
1301
1620
|
EthereumDataType[EthereumDataType["STRUCT"] = 8] = "STRUCT";
|
|
1302
1621
|
})(exports.EthereumDataType || (exports.EthereumDataType = {}));
|
|
1622
|
+
exports.Enum_KaspaInputScriptType = void 0;
|
|
1623
|
+
(function (Enum_KaspaInputScriptType) {
|
|
1624
|
+
Enum_KaspaInputScriptType[Enum_KaspaInputScriptType["KASPA_SPEND_P2PK_SCHNORR"] = 0] = "KASPA_SPEND_P2PK_SCHNORR";
|
|
1625
|
+
Enum_KaspaInputScriptType[Enum_KaspaInputScriptType["KASPA_SPEND_P2PK_ECDSA"] = 1] = "KASPA_SPEND_P2PK_ECDSA";
|
|
1626
|
+
})(exports.Enum_KaspaInputScriptType || (exports.Enum_KaspaInputScriptType = {}));
|
|
1627
|
+
exports.Enum_KaspaOutputScriptType = void 0;
|
|
1628
|
+
(function (Enum_KaspaOutputScriptType) {
|
|
1629
|
+
Enum_KaspaOutputScriptType[Enum_KaspaOutputScriptType["KASPA_PAYTOADDRESS"] = 0] = "KASPA_PAYTOADDRESS";
|
|
1630
|
+
Enum_KaspaOutputScriptType[Enum_KaspaOutputScriptType["KASPA_PAYTOCHANGE"] = 1] = "KASPA_PAYTOCHANGE";
|
|
1631
|
+
})(exports.Enum_KaspaOutputScriptType || (exports.Enum_KaspaOutputScriptType = {}));
|
|
1632
|
+
exports.Enum_KaspaRequestType = void 0;
|
|
1633
|
+
(function (Enum_KaspaRequestType) {
|
|
1634
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_INPUT"] = 0] = "KASPA_TX_INPUT";
|
|
1635
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_OUTPUT"] = 1] = "KASPA_TX_OUTPUT";
|
|
1636
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_PAYLOAD"] = 2] = "KASPA_TX_PAYLOAD";
|
|
1637
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_FINISHED"] = 3] = "KASPA_TX_FINISHED";
|
|
1638
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_PREV_META"] = 4] = "KASPA_TX_PREV_META";
|
|
1639
|
+
})(exports.Enum_KaspaRequestType || (exports.Enum_KaspaRequestType = {}));
|
|
1303
1640
|
exports.Enum_BackupType = void 0;
|
|
1304
1641
|
(function (Enum_BackupType) {
|
|
1305
1642
|
Enum_BackupType[Enum_BackupType["Bip39"] = 0] = "Bip39";
|
|
@@ -1505,6 +1842,18 @@ exports.MoneroNetworkType = void 0;
|
|
|
1505
1842
|
MoneroNetworkType[MoneroNetworkType["STAGENET"] = 2] = "STAGENET";
|
|
1506
1843
|
MoneroNetworkType[MoneroNetworkType["FAKECHAIN"] = 3] = "FAKECHAIN";
|
|
1507
1844
|
})(exports.MoneroNetworkType || (exports.MoneroNetworkType = {}));
|
|
1845
|
+
exports.UiAnimationType = void 0;
|
|
1846
|
+
(function (UiAnimationType) {
|
|
1847
|
+
UiAnimationType[UiAnimationType["Unknown"] = 0] = "Unknown";
|
|
1848
|
+
UiAnimationType[UiAnimationType["Signing"] = 1] = "Signing";
|
|
1849
|
+
})(exports.UiAnimationType || (exports.UiAnimationType = {}));
|
|
1850
|
+
exports.UiAnimationCommand = void 0;
|
|
1851
|
+
(function (UiAnimationCommand) {
|
|
1852
|
+
UiAnimationCommand[UiAnimationCommand["CommandUnknown"] = 0] = "CommandUnknown";
|
|
1853
|
+
UiAnimationCommand[UiAnimationCommand["Start"] = 1] = "Start";
|
|
1854
|
+
UiAnimationCommand[UiAnimationCommand["Stop"] = 2] = "Stop";
|
|
1855
|
+
UiAnimationCommand[UiAnimationCommand["Refresh"] = 3] = "Refresh";
|
|
1856
|
+
})(exports.UiAnimationCommand || (exports.UiAnimationCommand = {}));
|
|
1508
1857
|
exports.ViewTipType = void 0;
|
|
1509
1858
|
(function (ViewTipType) {
|
|
1510
1859
|
ViewTipType[ViewTipType["Default"] = 0] = "Default";
|
|
@@ -1513,12 +1862,74 @@ exports.ViewTipType = void 0;
|
|
|
1513
1862
|
ViewTipType[ViewTipType["Warning"] = 3] = "Warning";
|
|
1514
1863
|
ViewTipType[ViewTipType["Danger"] = 4] = "Danger";
|
|
1515
1864
|
})(exports.ViewTipType || (exports.ViewTipType = {}));
|
|
1516
|
-
exports.
|
|
1517
|
-
(function (
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1865
|
+
exports.ViewSignLayout = void 0;
|
|
1866
|
+
(function (ViewSignLayout) {
|
|
1867
|
+
ViewSignLayout[ViewSignLayout["LayoutDefault"] = 0] = "LayoutDefault";
|
|
1868
|
+
ViewSignLayout[ViewSignLayout["LayoutSafeTxCreate"] = 1] = "LayoutSafeTxCreate";
|
|
1869
|
+
ViewSignLayout[ViewSignLayout["LayoutFinalConfirm"] = 2] = "LayoutFinalConfirm";
|
|
1870
|
+
ViewSignLayout[ViewSignLayout["Layout7702"] = 3] = "Layout7702";
|
|
1871
|
+
ViewSignLayout[ViewSignLayout["LayoutFlat"] = 4] = "LayoutFlat";
|
|
1872
|
+
ViewSignLayout[ViewSignLayout["LayoutEthApprove"] = 5] = "LayoutEthApprove";
|
|
1873
|
+
})(exports.ViewSignLayout || (exports.ViewSignLayout = {}));
|
|
1874
|
+
exports.DeviceErrorCode = void 0;
|
|
1875
|
+
(function (DeviceErrorCode) {
|
|
1876
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_None"] = 0] = "DeviceError_None";
|
|
1877
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_Busy"] = 1] = "DeviceError_Busy";
|
|
1878
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_NotInitialized"] = 2] = "DeviceError_NotInitialized";
|
|
1879
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_ActionCancelled"] = 3] = "DeviceError_ActionCancelled";
|
|
1880
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_PinAlreadyUsed"] = 4] = "DeviceError_PinAlreadyUsed";
|
|
1881
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_PersistFailed"] = 5] = "DeviceError_PersistFailed";
|
|
1882
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_SeError"] = 6] = "DeviceError_SeError";
|
|
1883
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_InvalidLanguage"] = 7] = "DeviceError_InvalidLanguage";
|
|
1884
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_WallpaperNotUsable"] = 8] = "DeviceError_WallpaperNotUsable";
|
|
1885
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_DeviceLocked"] = 9] = "DeviceError_DeviceLocked";
|
|
1886
|
+
})(exports.DeviceErrorCode || (exports.DeviceErrorCode = {}));
|
|
1887
|
+
exports.DeviceRebootType = void 0;
|
|
1888
|
+
(function (DeviceRebootType) {
|
|
1889
|
+
DeviceRebootType[DeviceRebootType["Normal"] = 0] = "Normal";
|
|
1890
|
+
DeviceRebootType[DeviceRebootType["Romloader"] = 1] = "Romloader";
|
|
1891
|
+
DeviceRebootType[DeviceRebootType["Bootloader"] = 2] = "Bootloader";
|
|
1892
|
+
})(exports.DeviceRebootType || (exports.DeviceRebootType = {}));
|
|
1893
|
+
exports.DeviceSettingsPage = void 0;
|
|
1894
|
+
(function (DeviceSettingsPage) {
|
|
1895
|
+
DeviceSettingsPage[DeviceSettingsPage["DeviceReset"] = 0] = "DeviceReset";
|
|
1896
|
+
DeviceSettingsPage[DeviceSettingsPage["DevicePinChange"] = 1] = "DevicePinChange";
|
|
1897
|
+
DeviceSettingsPage[DeviceSettingsPage["DevicePassphrase"] = 2] = "DevicePassphrase";
|
|
1898
|
+
DeviceSettingsPage[DeviceSettingsPage["DeviceAirgap"] = 3] = "DeviceAirgap";
|
|
1899
|
+
})(exports.DeviceSettingsPage || (exports.DeviceSettingsPage = {}));
|
|
1900
|
+
exports.DeviceFirmwareTargetType = void 0;
|
|
1901
|
+
(function (DeviceFirmwareTargetType) {
|
|
1902
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_INVALID"] = 0] = "FW_MGMT_TARGET_INVALID";
|
|
1903
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_CRATE"] = 1] = "FW_MGMT_TARGET_CRATE";
|
|
1904
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_ROMLOADER"] = 2] = "FW_MGMT_TARGET_ROMLOADER";
|
|
1905
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_BOOTLOADER"] = 3] = "FW_MGMT_TARGET_BOOTLOADER";
|
|
1906
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_APPLICATION_P1"] = 4] = "FW_MGMT_TARGET_APPLICATION_P1";
|
|
1907
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_APPLICATION_P2"] = 5] = "FW_MGMT_TARGET_APPLICATION_P2";
|
|
1908
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_COPROCESSOR"] = 6] = "FW_MGMT_TARGET_COPROCESSOR";
|
|
1909
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE01"] = 7] = "FW_MGMT_TARGET_SE01";
|
|
1910
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE02"] = 8] = "FW_MGMT_TARGET_SE02";
|
|
1911
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE03"] = 9] = "FW_MGMT_TARGET_SE03";
|
|
1912
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE04"] = 10] = "FW_MGMT_TARGET_SE04";
|
|
1913
|
+
})(exports.DeviceFirmwareTargetType || (exports.DeviceFirmwareTargetType = {}));
|
|
1914
|
+
exports.DeviceFirmwareUpdateTaskStatus = void 0;
|
|
1915
|
+
(function (DeviceFirmwareUpdateTaskStatus) {
|
|
1916
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_PENDING"] = 0] = "FW_MGMT_UPDATER_TASK_STATUS_PENDING";
|
|
1917
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS"] = 1] = "FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS";
|
|
1918
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FINISHED"] = 2] = "FW_MGMT_UPDATER_TASK_STATUS_FINISHED";
|
|
1919
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND"] = 3] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND";
|
|
1920
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ"] = 4] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ";
|
|
1921
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE"] = 5] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE";
|
|
1922
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY"] = 6] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY";
|
|
1923
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL"] = 7] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL";
|
|
1924
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT"] = 8] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT";
|
|
1925
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY"] = 9] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY";
|
|
1926
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS"] = 10] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS";
|
|
1927
|
+
})(exports.DeviceFirmwareUpdateTaskStatus || (exports.DeviceFirmwareUpdateTaskStatus = {}));
|
|
1928
|
+
exports.DeviceFactoryAck = void 0;
|
|
1929
|
+
(function (DeviceFactoryAck) {
|
|
1930
|
+
DeviceFactoryAck[DeviceFactoryAck["FACTORY_ACK_SUCCESS"] = 0] = "FACTORY_ACK_SUCCESS";
|
|
1931
|
+
DeviceFactoryAck[DeviceFactoryAck["FACTORY_ACK_FAIL"] = 1] = "FACTORY_ACK_FAIL";
|
|
1932
|
+
})(exports.DeviceFactoryAck || (exports.DeviceFactoryAck = {}));
|
|
1522
1933
|
exports.DeviceType = void 0;
|
|
1523
1934
|
(function (DeviceType) {
|
|
1524
1935
|
DeviceType[DeviceType["CLASSIC1"] = 0] = "CLASSIC1";
|
|
@@ -1527,37 +1938,108 @@ exports.DeviceType = void 0;
|
|
|
1527
1938
|
DeviceType[DeviceType["TOUCH"] = 3] = "TOUCH";
|
|
1528
1939
|
DeviceType[DeviceType["PRO"] = 5] = "PRO";
|
|
1529
1940
|
DeviceType[DeviceType["CLASSIC1S_PURE"] = 6] = "CLASSIC1S_PURE";
|
|
1941
|
+
DeviceType[DeviceType["PRO2"] = 7] = "PRO2";
|
|
1942
|
+
DeviceType[DeviceType["NEO"] = 8] = "NEO";
|
|
1530
1943
|
})(exports.DeviceType || (exports.DeviceType = {}));
|
|
1531
|
-
exports.
|
|
1532
|
-
(function (
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
})(exports.
|
|
1536
|
-
exports.
|
|
1537
|
-
(function (
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
})(exports.
|
|
1542
|
-
exports.
|
|
1543
|
-
(function (
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
})(exports.
|
|
1944
|
+
exports.DeviceSeType = void 0;
|
|
1945
|
+
(function (DeviceSeType) {
|
|
1946
|
+
DeviceSeType[DeviceSeType["THD89"] = 0] = "THD89";
|
|
1947
|
+
DeviceSeType[DeviceSeType["SE608A"] = 1] = "SE608A";
|
|
1948
|
+
})(exports.DeviceSeType || (exports.DeviceSeType = {}));
|
|
1949
|
+
exports.DeviceSEState = void 0;
|
|
1950
|
+
(function (DeviceSEState) {
|
|
1951
|
+
DeviceSEState[DeviceSEState["BOOT"] = 0] = "BOOT";
|
|
1952
|
+
DeviceSEState[DeviceSEState["APP_FACTORY"] = 51] = "APP_FACTORY";
|
|
1953
|
+
DeviceSEState[DeviceSEState["APP"] = 85] = "APP";
|
|
1954
|
+
})(exports.DeviceSEState || (exports.DeviceSEState = {}));
|
|
1955
|
+
exports.DeviceSessionErrorCode = void 0;
|
|
1956
|
+
(function (DeviceSessionErrorCode) {
|
|
1957
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_None"] = 0] = "DeviceSessionError_None";
|
|
1958
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_UserCancelled"] = 1] = "DeviceSessionError_UserCancelled";
|
|
1959
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_InvalidSession"] = 2] = "DeviceSessionError_InvalidSession";
|
|
1960
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_AttachPinUnavailable"] = 3] = "DeviceSessionError_AttachPinUnavailable";
|
|
1961
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_PassphraseDisabled"] = 4] = "DeviceSessionError_PassphraseDisabled";
|
|
1962
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_Busy"] = 5] = "DeviceSessionError_Busy";
|
|
1963
|
+
})(exports.DeviceSessionErrorCode || (exports.DeviceSessionErrorCode = {}));
|
|
1964
|
+
exports.DeviceSessionPinType = void 0;
|
|
1965
|
+
(function (DeviceSessionPinType) {
|
|
1966
|
+
DeviceSessionPinType[DeviceSessionPinType["Any"] = 1] = "Any";
|
|
1967
|
+
DeviceSessionPinType[DeviceSessionPinType["Main"] = 2] = "Main";
|
|
1968
|
+
DeviceSessionPinType[DeviceSessionPinType["AttachToPin"] = 3] = "AttachToPin";
|
|
1969
|
+
})(exports.DeviceSessionPinType || (exports.DeviceSessionPinType = {}));
|
|
1970
|
+
exports.DeviceSessionAskPin_FailureSubCodes = void 0;
|
|
1971
|
+
(function (DeviceSessionAskPin_FailureSubCodes) {
|
|
1972
|
+
DeviceSessionAskPin_FailureSubCodes[DeviceSessionAskPin_FailureSubCodes["UserCancel"] = 1] = "UserCancel";
|
|
1973
|
+
})(exports.DeviceSessionAskPin_FailureSubCodes || (exports.DeviceSessionAskPin_FailureSubCodes = {}));
|
|
1974
|
+
exports.DevOnboardingStep = void 0;
|
|
1975
|
+
(function (DevOnboardingStep) {
|
|
1976
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_UNKNOWN"] = 0] = "DEV_ONBOARDING_STEP_UNKNOWN";
|
|
1977
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_CHECKING"] = 1] = "DEV_ONBOARDING_STEP_CHECKING";
|
|
1978
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_PERSONALIZATION"] = 2] = "DEV_ONBOARDING_STEP_PERSONALIZATION";
|
|
1979
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_PIN"] = 3] = "DEV_ONBOARDING_STEP_PIN";
|
|
1980
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_SETUP"] = 4] = "DEV_ONBOARDING_STEP_SETUP";
|
|
1981
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_DONE"] = 5] = "DEV_ONBOARDING_STEP_DONE";
|
|
1982
|
+
})(exports.DevOnboardingStep || (exports.DevOnboardingStep = {}));
|
|
1983
|
+
exports.DevOnboardingPhase = void 0;
|
|
1984
|
+
(function (DevOnboardingPhase) {
|
|
1985
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_UNKNOWN"] = 0] = "DEV_ONBOARDING_PHASE_UNKNOWN";
|
|
1986
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SAFETY_CHECK"] = 1] = "DEV_ONBOARDING_PHASE_SAFETY_CHECK";
|
|
1987
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_PIN_SETUP"] = 2] = "DEV_ONBOARDING_PHASE_PIN_SETUP";
|
|
1988
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_FINGERPRINT_SETUP"] = 3] = "DEV_ONBOARDING_PHASE_FINGERPRINT_SETUP";
|
|
1989
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SETUP_CHOICE"] = 4] = "DEV_ONBOARDING_PHASE_SETUP_CHOICE";
|
|
1990
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_WALLET_CREATE_START"] = 5] = "DEV_ONBOARDING_PHASE_WALLET_CREATE_START";
|
|
1991
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW"] = 6] = "DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW";
|
|
1992
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM"] = 7] = "DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM";
|
|
1993
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_RESTORE_METHOD_CHOICE"] = 8] = "DEV_ONBOARDING_PHASE_RESTORE_METHOD_CHOICE";
|
|
1994
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE"] = 9] = "DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE";
|
|
1995
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SEEDCARD_RESTORE"] = 10] = "DEV_ONBOARDING_PHASE_SEEDCARD_RESTORE";
|
|
1996
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_WALLET_READY"] = 11] = "DEV_ONBOARDING_PHASE_WALLET_READY";
|
|
1997
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT"] = 12] = "DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT";
|
|
1998
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP"] = 13] = "DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP";
|
|
1999
|
+
})(exports.DevOnboardingPhase || (exports.DevOnboardingPhase = {}));
|
|
2000
|
+
exports.DevOnboardingSetupKind = void 0;
|
|
2001
|
+
(function (DevOnboardingSetupKind) {
|
|
2002
|
+
DevOnboardingSetupKind[DevOnboardingSetupKind["DEV_ONBOARDING_SETUP_KIND_UNKNOWN"] = 0] = "DEV_ONBOARDING_SETUP_KIND_UNKNOWN";
|
|
2003
|
+
DevOnboardingSetupKind[DevOnboardingSetupKind["DEV_ONBOARDING_SETUP_KIND_CHOICE"] = 1] = "DEV_ONBOARDING_SETUP_KIND_CHOICE";
|
|
2004
|
+
DevOnboardingSetupKind[DevOnboardingSetupKind["DEV_ONBOARDING_SETUP_KIND_CREATE"] = 2] = "DEV_ONBOARDING_SETUP_KIND_CREATE";
|
|
2005
|
+
DevOnboardingSetupKind[DevOnboardingSetupKind["DEV_ONBOARDING_SETUP_KIND_RESTORE"] = 3] = "DEV_ONBOARDING_SETUP_KIND_RESTORE";
|
|
2006
|
+
})(exports.DevOnboardingSetupKind || (exports.DevOnboardingSetupKind = {}));
|
|
2007
|
+
exports.DevOnboardingSetupMethod = void 0;
|
|
2008
|
+
(function (DevOnboardingSetupMethod) {
|
|
2009
|
+
DevOnboardingSetupMethod[DevOnboardingSetupMethod["DEV_ONBOARDING_SETUP_METHOD_UNKNOWN"] = 0] = "DEV_ONBOARDING_SETUP_METHOD_UNKNOWN";
|
|
2010
|
+
DevOnboardingSetupMethod[DevOnboardingSetupMethod["DEV_ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE"] = 1] = "DEV_ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE";
|
|
2011
|
+
DevOnboardingSetupMethod[DevOnboardingSetupMethod["DEV_ONBOARDING_SETUP_METHOD_SEEDCARD"] = 2] = "DEV_ONBOARDING_SETUP_METHOD_SEEDCARD";
|
|
2012
|
+
})(exports.DevOnboardingSetupMethod || (exports.DevOnboardingSetupMethod = {}));
|
|
2013
|
+
exports.ProtocolV2FailureType = void 0;
|
|
2014
|
+
(function (ProtocolV2FailureType) {
|
|
2015
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_InvalidMessage"] = 1] = "Failure_InvalidMessage";
|
|
2016
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_UndefinedError"] = 2] = "Failure_UndefinedError";
|
|
2017
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_UsageError"] = 3] = "Failure_UsageError";
|
|
2018
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_DataError"] = 4] = "Failure_DataError";
|
|
2019
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_ProcessError"] = 5] = "Failure_ProcessError";
|
|
2020
|
+
})(exports.ProtocolV2FailureType || (exports.ProtocolV2FailureType = {}));
|
|
2021
|
+
exports.Enum_ProtocolV2Capability = void 0;
|
|
2022
|
+
(function (Enum_ProtocolV2Capability) {
|
|
2023
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Bitcoin"] = 1] = "Capability_Bitcoin";
|
|
2024
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Bitcoin_like"] = 2] = "Capability_Bitcoin_like";
|
|
2025
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Binance"] = 3] = "Capability_Binance";
|
|
2026
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Cardano"] = 4] = "Capability_Cardano";
|
|
2027
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Crypto"] = 5] = "Capability_Crypto";
|
|
2028
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_EOS"] = 6] = "Capability_EOS";
|
|
2029
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Ethereum"] = 7] = "Capability_Ethereum";
|
|
2030
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Lisk"] = 8] = "Capability_Lisk";
|
|
2031
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Monero"] = 9] = "Capability_Monero";
|
|
2032
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_NEM"] = 10] = "Capability_NEM";
|
|
2033
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Ripple"] = 11] = "Capability_Ripple";
|
|
2034
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Stellar"] = 12] = "Capability_Stellar";
|
|
2035
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Tezos"] = 13] = "Capability_Tezos";
|
|
2036
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_U2F"] = 14] = "Capability_U2F";
|
|
2037
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Shamir"] = 15] = "Capability_Shamir";
|
|
2038
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_ShamirGroups"] = 16] = "Capability_ShamirGroups";
|
|
2039
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_PassphraseEntry"] = 17] = "Capability_PassphraseEntry";
|
|
2040
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_AttachToPin"] = 18] = "Capability_AttachToPin";
|
|
2041
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_EthereumTypedData"] = 1000] = "Capability_EthereumTypedData";
|
|
2042
|
+
})(exports.Enum_ProtocolV2Capability || (exports.Enum_ProtocolV2Capability = {}));
|
|
1561
2043
|
|
|
1562
2044
|
var messages = /*#__PURE__*/Object.freeze({
|
|
1563
2045
|
__proto__: null,
|
|
@@ -1590,6 +2072,9 @@ var messages = /*#__PURE__*/Object.freeze({
|
|
|
1590
2072
|
get EthereumGnosisSafeTxOperation () { return exports.EthereumGnosisSafeTxOperation; },
|
|
1591
2073
|
get EthereumDataTypeOneKey () { return exports.EthereumDataTypeOneKey; },
|
|
1592
2074
|
get EthereumDataType () { return exports.EthereumDataType; },
|
|
2075
|
+
get Enum_KaspaInputScriptType () { return exports.Enum_KaspaInputScriptType; },
|
|
2076
|
+
get Enum_KaspaOutputScriptType () { return exports.Enum_KaspaOutputScriptType; },
|
|
2077
|
+
get Enum_KaspaRequestType () { return exports.Enum_KaspaRequestType; },
|
|
1593
2078
|
get Enum_BackupType () { return exports.Enum_BackupType; },
|
|
1594
2079
|
get Enum_SafetyCheckLevel () { return exports.Enum_SafetyCheckLevel; },
|
|
1595
2080
|
get OneKeyDeviceType () { return exports.OneKeyDeviceType; },
|
|
@@ -1623,13 +2108,28 @@ var messages = /*#__PURE__*/Object.freeze({
|
|
|
1623
2108
|
get CommandFlags () { return exports.CommandFlags; },
|
|
1624
2109
|
get WallpaperTarget () { return exports.WallpaperTarget; },
|
|
1625
2110
|
get MoneroNetworkType () { return exports.MoneroNetworkType; },
|
|
2111
|
+
get UiAnimationType () { return exports.UiAnimationType; },
|
|
2112
|
+
get UiAnimationCommand () { return exports.UiAnimationCommand; },
|
|
1626
2113
|
get ViewTipType () { return exports.ViewTipType; },
|
|
1627
|
-
get
|
|
2114
|
+
get ViewSignLayout () { return exports.ViewSignLayout; },
|
|
2115
|
+
get DeviceErrorCode () { return exports.DeviceErrorCode; },
|
|
2116
|
+
get DeviceRebootType () { return exports.DeviceRebootType; },
|
|
2117
|
+
get DeviceSettingsPage () { return exports.DeviceSettingsPage; },
|
|
2118
|
+
get DeviceFirmwareTargetType () { return exports.DeviceFirmwareTargetType; },
|
|
2119
|
+
get DeviceFirmwareUpdateTaskStatus () { return exports.DeviceFirmwareUpdateTaskStatus; },
|
|
2120
|
+
get DeviceFactoryAck () { return exports.DeviceFactoryAck; },
|
|
1628
2121
|
get DeviceType () { return exports.DeviceType; },
|
|
1629
|
-
get
|
|
1630
|
-
get
|
|
1631
|
-
get
|
|
1632
|
-
get
|
|
2122
|
+
get DeviceSeType () { return exports.DeviceSeType; },
|
|
2123
|
+
get DeviceSEState () { return exports.DeviceSEState; },
|
|
2124
|
+
get DeviceSessionErrorCode () { return exports.DeviceSessionErrorCode; },
|
|
2125
|
+
get DeviceSessionPinType () { return exports.DeviceSessionPinType; },
|
|
2126
|
+
get DeviceSessionAskPin_FailureSubCodes () { return exports.DeviceSessionAskPin_FailureSubCodes; },
|
|
2127
|
+
get DevOnboardingStep () { return exports.DevOnboardingStep; },
|
|
2128
|
+
get DevOnboardingPhase () { return exports.DevOnboardingPhase; },
|
|
2129
|
+
get DevOnboardingSetupKind () { return exports.DevOnboardingSetupKind; },
|
|
2130
|
+
get DevOnboardingSetupMethod () { return exports.DevOnboardingSetupMethod; },
|
|
2131
|
+
get ProtocolV2FailureType () { return exports.ProtocolV2FailureType; },
|
|
2132
|
+
get Enum_ProtocolV2Capability () { return exports.Enum_ProtocolV2Capability; }
|
|
1633
2133
|
});
|
|
1634
2134
|
|
|
1635
2135
|
protobuf__namespace.util.Long = Long__default["default"];
|
|
@@ -1642,7 +2142,10 @@ var index = {
|
|
|
1642
2142
|
ProtocolV2,
|
|
1643
2143
|
PROTOCOL_V2_SYS_MESSAGE_THRESHOLD,
|
|
1644
2144
|
ProtocolV2FrameAssembler,
|
|
2145
|
+
ProtocolV2LinkManager,
|
|
2146
|
+
ProtocolV2SequenceCursor,
|
|
1645
2147
|
ProtocolV2Session,
|
|
2148
|
+
ProtocolV2UsbTransportBase,
|
|
1646
2149
|
bytesToHex,
|
|
1647
2150
|
concatUint8Arrays,
|
|
1648
2151
|
createMessageFromName,
|
|
@@ -1664,25 +2167,34 @@ exports.PROTOCOL_V1_MESSAGE_HEADER_SIZE = PROTOCOL_V1_MESSAGE_HEADER_SIZE;
|
|
|
1664
2167
|
exports.PROTOCOL_V1_REPORT_ID = PROTOCOL_V1_REPORT_ID;
|
|
1665
2168
|
exports.PROTOCOL_V1_USB_PACKET_SIZE = PROTOCOL_V1_USB_PACKET_SIZE;
|
|
1666
2169
|
exports.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE = PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
|
|
2170
|
+
exports.PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE = PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE;
|
|
2171
|
+
exports.PROTOCOL_V2_BLE_FRAME_MAX_BYTES = PROTOCOL_V2_BLE_FRAME_MAX_BYTES;
|
|
1667
2172
|
exports.PROTOCOL_V2_CHANNEL_BLE_UART = PROTOCOL_V2_CHANNEL_BLE_UART;
|
|
1668
2173
|
exports.PROTOCOL_V2_CHANNEL_SOCKET = PROTOCOL_V2_CHANNEL_SOCKET;
|
|
1669
2174
|
exports.PROTOCOL_V2_CHANNEL_USB = PROTOCOL_V2_CHANNEL_USB;
|
|
2175
|
+
exports.PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS = PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS;
|
|
1670
2176
|
exports.PROTOCOL_V2_FILE_CHUNK_SIZE = PROTOCOL_V2_FILE_CHUNK_SIZE;
|
|
1671
2177
|
exports.PROTOCOL_V2_FRAME_MAX_BYTES = PROTOCOL_V2_FRAME_MAX_BYTES;
|
|
1672
2178
|
exports.PROTOCOL_V2_PACKET_SRC_COMMAND = PROTOCOL_V2_PACKET_SRC_COMMAND;
|
|
1673
2179
|
exports.PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = PROTOCOL_V2_SYS_MESSAGE_THRESHOLD;
|
|
1674
2180
|
exports.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
1675
|
-
exports.PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS = PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS;
|
|
1676
2181
|
exports.ProtocolV1 = ProtocolV1;
|
|
1677
2182
|
exports.ProtocolV2 = ProtocolV2;
|
|
1678
2183
|
exports.ProtocolV2FrameAssembler = ProtocolV2FrameAssembler;
|
|
2184
|
+
exports.ProtocolV2LinkError = ProtocolV2LinkError;
|
|
2185
|
+
exports.ProtocolV2LinkManager = ProtocolV2LinkManager;
|
|
2186
|
+
exports.ProtocolV2SequenceCursor = ProtocolV2SequenceCursor;
|
|
1679
2187
|
exports.ProtocolV2Session = ProtocolV2Session;
|
|
2188
|
+
exports.ProtocolV2UsbTransportBase = ProtocolV2UsbTransportBase;
|
|
2189
|
+
exports.TRANSPORT_EVENT = TRANSPORT_EVENT;
|
|
1680
2190
|
exports.bytesToHex = bytesToHex;
|
|
1681
2191
|
exports.concatUint8Arrays = concatUint8Arrays;
|
|
1682
2192
|
exports["default"] = index;
|
|
1683
2193
|
exports.getErrorMessage = getErrorMessage;
|
|
1684
2194
|
exports.hexToBytes = hexToBytes;
|
|
2195
|
+
exports.isProtocolV2LinkError = isProtocolV2LinkError;
|
|
1685
2196
|
exports.probeProtocolV2 = probeProtocolV2;
|
|
1686
2197
|
exports.protocolV1 = index$1;
|
|
1687
2198
|
exports.protocolV2 = protocolV2Codec;
|
|
1688
2199
|
exports.withProtocolTimeout = withProtocolTimeout;
|
|
2200
|
+
exports.writeProtocolV2BleFrame = writeProtocolV2BleFrame;
|