@onekeyfe/hd-transport 1.2.0-alpha.0 → 1.2.0-alpha.10
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 +76 -0
- package/__tests__/protocol-v2-link-manager.test.js +326 -0
- package/__tests__/protocol-v2-usb-transport-base.test.js +296 -0
- package/__tests__/protocol-v2.test.js +252 -84
- package/dist/constants.d.ts +4 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +564 -326
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +434 -102
- package/dist/protocols/index.d.ts +2 -0
- package/dist/protocols/index.d.ts.map +1 -1
- 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 +1 -0
- package/dist/protocols/v2/decode.d.ts.map +1 -1
- package/dist/protocols/v2/link-manager.d.ts +35 -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 +16 -4
- package/dist/protocols/v2/session.d.ts.map +1 -1
- package/dist/protocols/v2/usb-transport-base.d.ts +31 -0
- package/dist/protocols/v2/usb-transport-base.d.ts.map +1 -0
- package/dist/serialization/protobuf/messages.d.ts.map +1 -1
- package/dist/types/messages.d.ts +337 -221
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/transport.d.ts +1 -1
- package/dist/types/transport.d.ts.map +1 -1
- package/messages-protocol-v2.json +992 -1420
- package/package.json +2 -2
- package/scripts/protobuf-build.sh +60 -142
- package/src/constants.ts +8 -2
- package/src/index.ts +8 -0
- package/src/protocols/index.ts +4 -1
- package/src/protocols/v2/constants.ts +1 -0
- package/src/protocols/v2/decode.ts +36 -17
- package/src/protocols/v2/link-manager.ts +160 -0
- package/src/protocols/v2/sequence-cursor.ts +10 -0
- package/src/protocols/v2/session.ts +86 -51
- package/src/protocols/v2/usb-transport-base.ts +194 -0
- package/src/serialization/protobuf/messages.ts +6 -1
- package/src/types/messages.ts +419 -272
- package/src/types/transport.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -249,7 +249,11 @@ const createMessageFromName = (messages, name) => {
|
|
|
249
249
|
};
|
|
250
250
|
const createMessageFromType = (messages, typeId) => {
|
|
251
251
|
const MessageType = messages.lookupEnum('MessageType');
|
|
252
|
-
const
|
|
252
|
+
const rawMessageName = MessageType.valuesById[typeId];
|
|
253
|
+
if (!rawMessageName) {
|
|
254
|
+
throw new Error(`MessageType id "${typeId}" is not defined in protobuf schema`);
|
|
255
|
+
}
|
|
256
|
+
const messageName = rawMessageName.replace('MessageType_', '');
|
|
253
257
|
const Message = messages.lookupType(messageName);
|
|
254
258
|
return {
|
|
255
259
|
Message,
|
|
@@ -264,8 +268,10 @@ const PROTOCOL_V1_USB_PACKET_SIZE = PROTOCOL_V1_CHUNK_PAYLOAD_SIZE + 1;
|
|
|
264
268
|
const PROTOCOL_V1_MESSAGE_HEADER_SIZE = 2 + 4;
|
|
265
269
|
const PROTOCOL_V1_ENVELOPE_HEADER_SIZE = 1 + 1 + PROTOCOL_V1_MESSAGE_HEADER_SIZE;
|
|
266
270
|
const PROTOCOL_V2_FRAME_MAX_BYTES = 4608;
|
|
267
|
-
const PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE =
|
|
271
|
+
const PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE = 4000;
|
|
268
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;
|
|
269
275
|
const PROTOCOL_V2_FILE_CHUNK_SIZE = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
270
276
|
const PROTOCOL_V2_CHANNEL_USB = 0;
|
|
271
277
|
const PROTOCOL_V2_CHANNEL_BLE_UART = 1;
|
|
@@ -377,6 +383,7 @@ const PROTO_HEAD_CRC_SIZE = 8;
|
|
|
377
383
|
const CRC8_INIT = 0x30;
|
|
378
384
|
const PACKET_SIZE = 4096;
|
|
379
385
|
const PROTO_DATA_TYPE_PACKET = 0;
|
|
386
|
+
const PROTO_DATA_TYPE_ACK = 1;
|
|
380
387
|
|
|
381
388
|
const CRC8_TABLE = new Uint8Array([
|
|
382
389
|
0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41,
|
|
@@ -458,7 +465,7 @@ function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router, debugO
|
|
|
458
465
|
return encodeFrame(payload, packetSrc, router, Object.assign(Object.assign({}, debugOptions), { messageTypeId, pbPayloadLength: pbPayload.length }), seq);
|
|
459
466
|
}
|
|
460
467
|
|
|
461
|
-
function
|
|
468
|
+
function validateFrame(data) {
|
|
462
469
|
if (data.length < PROTO_HEAD_CRC_SIZE) {
|
|
463
470
|
throw new Error(`Protocol V2 frame too short: ${data.length} bytes`);
|
|
464
471
|
}
|
|
@@ -481,6 +488,22 @@ function decodeFrame(data, debugOptions) {
|
|
|
481
488
|
.toString(16)
|
|
482
489
|
.padStart(2, '0')}, got 0x${data[frameLen - 1].toString(16).padStart(2, '0')}`);
|
|
483
490
|
}
|
|
491
|
+
return frameLen;
|
|
492
|
+
}
|
|
493
|
+
function isAckFrame(data) {
|
|
494
|
+
if (data.length < 6 || (data[5] & 0x03) !== PROTO_DATA_TYPE_ACK) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
const frameLen = validateFrame(data);
|
|
498
|
+
if (frameLen !== PROTO_HEAD_CRC_SIZE) {
|
|
499
|
+
throw new Error(`Invalid Protocol V2 ACK frame length: ${frameLen}`);
|
|
500
|
+
}
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
function decodeFrame(data, debugOptions) {
|
|
504
|
+
const frameLen = validateFrame(data);
|
|
505
|
+
const expectedHeaderCrc = data[3];
|
|
506
|
+
const expectedFrameCrc = data[frameLen - 1];
|
|
484
507
|
const seq = data[6];
|
|
485
508
|
const payloadData = data.slice(7, frameLen - 1);
|
|
486
509
|
if (payloadData.length < 2) {
|
|
@@ -583,12 +606,14 @@ var protocolV2Codec = /*#__PURE__*/Object.freeze({
|
|
|
583
606
|
CRC8_INIT: CRC8_INIT,
|
|
584
607
|
PACKET_SIZE: PACKET_SIZE,
|
|
585
608
|
PROTO_DATA_TYPE_PACKET: PROTO_DATA_TYPE_PACKET,
|
|
609
|
+
PROTO_DATA_TYPE_ACK: PROTO_DATA_TYPE_ACK,
|
|
586
610
|
CRC8_TABLE: CRC8_TABLE,
|
|
587
611
|
crc8: crc8,
|
|
588
612
|
logProtocolV2Debug: logProtocolV2Debug,
|
|
589
613
|
nextProtoSeq: nextProtoSeq,
|
|
590
614
|
encodeFrame: encodeFrame,
|
|
591
615
|
encodeProtobufFrame: encodeProtobufFrame,
|
|
616
|
+
isAckFrame: isAckFrame,
|
|
592
617
|
decodeFrame: decodeFrame,
|
|
593
618
|
concatUint8Arrays: concatUint8Arrays,
|
|
594
619
|
ProtocolV2FrameAssembler: ProtocolV2FrameAssembler
|
|
@@ -605,6 +630,7 @@ const resolveProtocolV2EncodeSchema = (name, schemas) => {
|
|
|
605
630
|
}
|
|
606
631
|
};
|
|
607
632
|
const PROTOCOL_V2_LEGACY_DECODE_ALLOWLIST = new Set([
|
|
633
|
+
'Failure',
|
|
608
634
|
'ButtonRequest',
|
|
609
635
|
'EntropyRequest',
|
|
610
636
|
'PinMatrixRequest',
|
|
@@ -638,6 +664,7 @@ const ProtocolV1 = {
|
|
|
638
664
|
decodeMessage: decodeMessage,
|
|
639
665
|
};
|
|
640
666
|
const ProtocolV2 = {
|
|
667
|
+
isAckFrame,
|
|
641
668
|
encodeFrame(schemas, name, data, options = {}) {
|
|
642
669
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
643
670
|
const encodeMessages = resolveProtocolV2EncodeSchema(name, schemas);
|
|
@@ -700,6 +727,16 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
700
727
|
decodeMessage: decodeMessage
|
|
701
728
|
});
|
|
702
729
|
|
|
730
|
+
class ProtocolV2SequenceCursor {
|
|
731
|
+
constructor() {
|
|
732
|
+
this.current = 0;
|
|
733
|
+
}
|
|
734
|
+
next() {
|
|
735
|
+
this.current = nextProtoSeq(this.current);
|
|
736
|
+
return this.current;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
703
740
|
const ERROR = 'Wrong result type.';
|
|
704
741
|
function info(res) {
|
|
705
742
|
if (typeof res !== 'object' || res == null) {
|
|
@@ -951,12 +988,13 @@ function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout)
|
|
|
951
988
|
}
|
|
952
989
|
});
|
|
953
990
|
}
|
|
954
|
-
const PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS =
|
|
991
|
+
const PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS = 0;
|
|
955
992
|
class ProtocolV2Session {
|
|
956
993
|
constructor(options) {
|
|
994
|
+
var _a;
|
|
957
995
|
this.pendingCall = Promise.resolve();
|
|
958
|
-
this.protoSeq = 0;
|
|
959
996
|
this.options = options;
|
|
997
|
+
this.sequenceCursor = (_a = options.sequenceCursor) !== null && _a !== void 0 ? _a : new ProtocolV2SequenceCursor();
|
|
960
998
|
}
|
|
961
999
|
call(name, data, callOptions = {}) {
|
|
962
1000
|
const run = () => this.executeCall(name, data, callOptions);
|
|
@@ -967,55 +1005,73 @@ class ProtocolV2Session {
|
|
|
967
1005
|
executeCall(name, data, callOptions) {
|
|
968
1006
|
var _a, _b;
|
|
969
1007
|
return __awaiter(this, void 0, void 0, function* () {
|
|
970
|
-
const { schemas, router, packetSrc = PROTOCOL_V2_PACKET_SRC_COMMAND, writeFrame, readFrame, logger, logPrefix = 'ProtocolV2', createTimeoutError, } = this.options;
|
|
1008
|
+
const { schemas, router, packetSrc = PROTOCOL_V2_PACKET_SRC_COMMAND, maxFrameBytes, prepareCall, writeFrame, readFrame, logger, logPrefix = 'ProtocolV2', createTimeoutError, generation = 0, } = this.options;
|
|
971
1009
|
const shouldReduceDebug = shouldReduceProtocolV2Debug(name);
|
|
972
|
-
|
|
1010
|
+
const callContext = {
|
|
1011
|
+
messageName: name,
|
|
1012
|
+
timeoutMs: callOptions.timeoutMs,
|
|
1013
|
+
highVolume: shouldReduceDebug,
|
|
1014
|
+
generation,
|
|
1015
|
+
};
|
|
1016
|
+
yield (prepareCall === null || prepareCall === void 0 ? void 0 : prepareCall(callContext));
|
|
1017
|
+
const protoSeq = this.sequenceCursor.next();
|
|
973
1018
|
const frame = ProtocolV2.encodeFrame(schemas, name, data, {
|
|
974
1019
|
packetSrc,
|
|
975
1020
|
router,
|
|
976
|
-
seq:
|
|
1021
|
+
seq: protoSeq,
|
|
977
1022
|
logger: shouldReduceDebug ? undefined : logger,
|
|
978
1023
|
logPrefix,
|
|
979
1024
|
context: `tx:${name}`,
|
|
980
1025
|
});
|
|
981
1026
|
const expectedSeq = frame[6];
|
|
1027
|
+
if (maxFrameBytes !== undefined && frame.length > maxFrameBytes) {
|
|
1028
|
+
throw new Error(`Protocol V2 frame too large for transport: ${frame.length} > ${maxFrameBytes}`);
|
|
1029
|
+
}
|
|
982
1030
|
if (!shouldReduceDebug) {
|
|
983
1031
|
(_a = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _a === void 0 ? void 0 : _a.call(logger, `[${logPrefix}] TX payload name=${name}`, sanitizeProtocolV2DebugPayload(data));
|
|
984
1032
|
(_b = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _b === void 0 ? void 0 : _b.call(logger, `[${logPrefix}] TX frame name=${name} len=${frame.length} router=${frame[4]} attr=${frame[5]} seq=${expectedSeq} headerHex=${frameHeaderDebugHex(frame)}`);
|
|
985
1033
|
}
|
|
986
|
-
yield withProtocolTimeout(writeFrame(frame), PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS, () => new Error(`Protocol V2 write timeout after ${PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS}ms for ${name}`));
|
|
1034
|
+
yield withProtocolTimeout(writeFrame(frame, callContext), PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS, () => new Error(`Protocol V2 write timeout after ${PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS}ms for ${name}`));
|
|
987
1035
|
const cancellation = { cancelled: false };
|
|
988
1036
|
const readResponse = () => __awaiter(this, void 0, void 0, function* () {
|
|
989
|
-
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1037
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
990
1038
|
while (!cancellation.cancelled) {
|
|
991
|
-
const rxFrame = yield readFrame();
|
|
1039
|
+
const rxFrame = yield readFrame(callContext);
|
|
992
1040
|
if (cancellation.cancelled) {
|
|
993
1041
|
break;
|
|
994
1042
|
}
|
|
995
1043
|
if (!shouldReduceDebug) {
|
|
996
1044
|
(_c = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _c === void 0 ? void 0 : _c.call(logger, `[${logPrefix}] RX frame len=${rxFrame.length} router=${rxFrame[4]} attr=${rxFrame[5]} seq=${rxFrame[6]} headerHex=${frameHeaderDebugHex(rxFrame)}`);
|
|
997
1045
|
}
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
if (!shouldReduceDebug && decoded.seq !== expectedSeq) {
|
|
1004
|
-
(_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}`);
|
|
1005
|
-
}
|
|
1006
|
-
if (!shouldReduceDebug) {
|
|
1007
|
-
(_e = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _e === void 0 ? void 0 : _e.call(logger, `[${logPrefix}] TX name=${name} seq=${expectedSeq} | RX seq=${decoded.seq} messageTypeId=${decoded.messageTypeId} pbPayload=${decoded.pbPayload.length}B`);
|
|
1008
|
-
(_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));
|
|
1009
|
-
}
|
|
1010
|
-
const response = call(decoded);
|
|
1011
|
-
if ((_g = callOptions.intermediateTypes) === null || _g === void 0 ? void 0 : _g.includes(response.type)) {
|
|
1012
|
-
(_h = callOptions.onIntermediateResponse) === null || _h === void 0 ? void 0 : _h.call(callOptions, response);
|
|
1046
|
+
const isAck = ProtocolV2.isAckFrame(rxFrame);
|
|
1047
|
+
if (isAck) {
|
|
1048
|
+
if (!shouldReduceDebug) {
|
|
1049
|
+
(_d = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _d === void 0 ? void 0 : _d.call(logger, `[${logPrefix}] skip Proto Link ACK seq=${rxFrame[6]}`);
|
|
1050
|
+
}
|
|
1013
1051
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1052
|
+
if (!isAck) {
|
|
1053
|
+
const decoded = ProtocolV2.decodeFrame(schemas, rxFrame, {
|
|
1054
|
+
logger: shouldReduceDebug ? undefined : logger,
|
|
1055
|
+
logPrefix,
|
|
1056
|
+
context: `rx:${name}`,
|
|
1057
|
+
});
|
|
1058
|
+
if (!shouldReduceDebug && decoded.seq !== expectedSeq) {
|
|
1059
|
+
(_e = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _e === void 0 ? void 0 : _e.call(logger, `[${logPrefix}] seq differs for ${name}: tx=${expectedSeq}, rx=${decoded.seq}`);
|
|
1060
|
+
}
|
|
1061
|
+
if (!shouldReduceDebug) {
|
|
1062
|
+
(_f = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _f === void 0 ? void 0 : _f.call(logger, `[${logPrefix}] TX name=${name} seq=${expectedSeq} | RX seq=${decoded.seq} messageTypeId=${decoded.messageTypeId} pbPayload=${decoded.pbPayload.length}B`);
|
|
1063
|
+
(_g = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _g === void 0 ? void 0 : _g.call(logger, `[${logPrefix}] RX payload type=${decoded.type} messageTypeId=${decoded.messageTypeId}`, sanitizeProtocolV2DebugPayload(decoded.message));
|
|
1064
|
+
}
|
|
1065
|
+
const response = call(decoded);
|
|
1066
|
+
if ((_h = callOptions.intermediateTypes) === null || _h === void 0 ? void 0 : _h.includes(response.type)) {
|
|
1067
|
+
(_j = callOptions.onIntermediateResponse) === null || _j === void 0 ? void 0 : _j.call(callOptions, response);
|
|
1068
|
+
}
|
|
1069
|
+
else if (isExpectedTerminalResponse(response, callOptions.expectedTypes)) {
|
|
1070
|
+
return response;
|
|
1071
|
+
}
|
|
1072
|
+
else if (!shouldReduceDebug) {
|
|
1073
|
+
(_k = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _k === void 0 ? void 0 : _k.call(logger, `[${logPrefix}] skip unexpected response for ${name}: expected=${(_l = callOptions.expectedTypes) === null || _l === void 0 ? void 0 : _l.join('|')} got=${response.type}`);
|
|
1074
|
+
}
|
|
1019
1075
|
}
|
|
1020
1076
|
}
|
|
1021
1077
|
throw new Error(`Protocol V2 read loop cancelled after timeout for ${name}`);
|
|
@@ -1034,24 +1090,265 @@ class ProtocolV2Session {
|
|
|
1034
1090
|
function probeProtocolV2({ call, timeoutMs, logger, logPrefix = 'ProtocolV2', onBeforeProbe, onProbeFailed, }) {
|
|
1035
1091
|
var _a;
|
|
1036
1092
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1037
|
-
let
|
|
1093
|
+
let probeError;
|
|
1038
1094
|
try {
|
|
1039
1095
|
yield (onBeforeProbe === null || onBeforeProbe === void 0 ? void 0 : onBeforeProbe());
|
|
1040
|
-
const response = yield call('Ping', { message: 'probe' }, { timeoutMs, expectedTypes: ['Success'] });
|
|
1096
|
+
const response = yield call('Ping', { message: 'protocol-v2-probe' }, { timeoutMs, expectedTypes: ['Success'] });
|
|
1041
1097
|
if (response.type === 'Success') {
|
|
1042
1098
|
return true;
|
|
1043
1099
|
}
|
|
1044
|
-
|
|
1100
|
+
probeError = new Error(`unexpected response type ${response.type}`);
|
|
1045
1101
|
}
|
|
1046
1102
|
catch (error) {
|
|
1047
|
-
|
|
1103
|
+
probeError = error;
|
|
1048
1104
|
}
|
|
1049
|
-
(_a = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _a === void 0 ? void 0 : _a.call(logger, `[${logPrefix}] Protocol V2
|
|
1050
|
-
yield (onProbeFailed === null || onProbeFailed === void 0 ? void 0 : onProbeFailed(
|
|
1105
|
+
(_a = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _a === void 0 ? void 0 : _a.call(logger, `[${logPrefix}] Protocol V2 probe failed:`, getErrorMessage(probeError));
|
|
1106
|
+
yield (onProbeFailed === null || onProbeFailed === void 0 ? void 0 : onProbeFailed(probeError));
|
|
1051
1107
|
return false;
|
|
1052
1108
|
});
|
|
1053
1109
|
}
|
|
1054
1110
|
|
|
1111
|
+
class ProtocolV2LinkManager {
|
|
1112
|
+
constructor(options) {
|
|
1113
|
+
this.links = new Map();
|
|
1114
|
+
this.sequences = new Map();
|
|
1115
|
+
this.callQueues = new Map();
|
|
1116
|
+
this.options = options;
|
|
1117
|
+
}
|
|
1118
|
+
call(key, createAdapter, name, data, options) {
|
|
1119
|
+
var _a;
|
|
1120
|
+
const run = () => this.executeCall(key, createAdapter, name, data, options);
|
|
1121
|
+
const previous = (_a = this.callQueues.get(key)) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
1122
|
+
const result = previous.then(run, run);
|
|
1123
|
+
const queue = result.catch(() => undefined);
|
|
1124
|
+
this.callQueues.set(key, queue);
|
|
1125
|
+
result
|
|
1126
|
+
.then(() => this.clearSettledCallQueue(key, queue), () => this.clearSettledCallQueue(key, queue))
|
|
1127
|
+
.catch(() => undefined);
|
|
1128
|
+
return result;
|
|
1129
|
+
}
|
|
1130
|
+
invalidateLink(key, reason) {
|
|
1131
|
+
var _a, _b;
|
|
1132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1133
|
+
const link = this.links.get(key);
|
|
1134
|
+
if (!link)
|
|
1135
|
+
return;
|
|
1136
|
+
this.links.delete(key);
|
|
1137
|
+
link.state.invalidatedReason = reason;
|
|
1138
|
+
yield link.adapter.reset(reason);
|
|
1139
|
+
yield ((_b = (_a = this.options).onLinkInvalidated) === null || _b === void 0 ? void 0 : _b.call(_a, key, reason));
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
invalidateAllLinks(reason) {
|
|
1143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1144
|
+
yield Promise.all(Array.from(this.links.keys(), key => this.invalidateLink(key, reason)));
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
dispose(reason) {
|
|
1148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1149
|
+
yield this.invalidateAllLinks(reason);
|
|
1150
|
+
this.sequences.clear();
|
|
1151
|
+
this.callQueues.clear();
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
getOrCreateLink(key, createAdapter) {
|
|
1155
|
+
const existing = this.links.get(key);
|
|
1156
|
+
if (existing)
|
|
1157
|
+
return existing;
|
|
1158
|
+
const adapter = createAdapter();
|
|
1159
|
+
const state = {};
|
|
1160
|
+
const assertLinkActive = () => {
|
|
1161
|
+
if (state.invalidatedReason) {
|
|
1162
|
+
throw new Error(state.invalidatedReason);
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
let sequenceCursor = this.sequences.get(key);
|
|
1166
|
+
if (!sequenceCursor) {
|
|
1167
|
+
sequenceCursor = new ProtocolV2SequenceCursor();
|
|
1168
|
+
this.sequences.set(key, sequenceCursor);
|
|
1169
|
+
}
|
|
1170
|
+
const session = new ProtocolV2Session({
|
|
1171
|
+
schemas: this.options.getSchemas(),
|
|
1172
|
+
router: adapter.router,
|
|
1173
|
+
maxFrameBytes: adapter.maxFrameBytes,
|
|
1174
|
+
generation: adapter.generation,
|
|
1175
|
+
sequenceCursor,
|
|
1176
|
+
prepareCall: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1177
|
+
assertLinkActive();
|
|
1178
|
+
yield adapter.prepareCall(context);
|
|
1179
|
+
assertLinkActive();
|
|
1180
|
+
}),
|
|
1181
|
+
writeFrame: (frame, context) => __awaiter(this, void 0, void 0, function* () {
|
|
1182
|
+
assertLinkActive();
|
|
1183
|
+
yield adapter.writeFrame(frame, context);
|
|
1184
|
+
assertLinkActive();
|
|
1185
|
+
}),
|
|
1186
|
+
readFrame: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1187
|
+
assertLinkActive();
|
|
1188
|
+
const frame = yield adapter.readFrame(context);
|
|
1189
|
+
assertLinkActive();
|
|
1190
|
+
return frame;
|
|
1191
|
+
}),
|
|
1192
|
+
logger: adapter.logger,
|
|
1193
|
+
logPrefix: adapter.logPrefix,
|
|
1194
|
+
createTimeoutError: adapter.createTimeoutError,
|
|
1195
|
+
});
|
|
1196
|
+
const link = { adapter, session, state };
|
|
1197
|
+
this.links.set(key, link);
|
|
1198
|
+
return link;
|
|
1199
|
+
}
|
|
1200
|
+
executeCall(key, createAdapter, name, data, options) {
|
|
1201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1202
|
+
try {
|
|
1203
|
+
return yield this.getOrCreateLink(key, createAdapter).session.call(name, data, options);
|
|
1204
|
+
}
|
|
1205
|
+
catch (error) {
|
|
1206
|
+
if (this.options.classifyError(error) === 'link-fatal') {
|
|
1207
|
+
const errorMessage = getErrorMessage(error) || 'unknown error';
|
|
1208
|
+
yield this.invalidateLink(key, `Protocol V2 link-fatal error: ${errorMessage}`);
|
|
1209
|
+
}
|
|
1210
|
+
throw error;
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
clearSettledCallQueue(key, queue) {
|
|
1215
|
+
if (this.callQueues.get(key) === queue) {
|
|
1216
|
+
this.callQueues.delete(key);
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
class ProtocolV2UsbTransportBase {
|
|
1222
|
+
constructor(options) {
|
|
1223
|
+
this.protocolV2UsbAssemblers = new Map();
|
|
1224
|
+
this.protocolV2UsbGenerations = new Map();
|
|
1225
|
+
this.protocolV2UsbCancellations = new Map();
|
|
1226
|
+
this.protocolV2UsbOptions = options;
|
|
1227
|
+
this.protocolV2UsbLinks = new ProtocolV2LinkManager({
|
|
1228
|
+
getSchemas: () => this.getProtocolV2UsbSchemas(),
|
|
1229
|
+
classifyError: () => 'link-fatal',
|
|
1230
|
+
onLinkInvalidated: (key, reason) => __awaiter(this, void 0, void 0, function* () {
|
|
1231
|
+
var _a;
|
|
1232
|
+
(_a = this.protocolV2UsbAssemblers.get(key)) === null || _a === void 0 ? void 0 : _a.reset();
|
|
1233
|
+
yield this.resetProtocolV2UsbNativeLink(key, reason);
|
|
1234
|
+
yield this.onProtocolV2UsbLinkInvalidated(key, reason);
|
|
1235
|
+
}),
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
onProtocolV2UsbLinkInvalidated(_key, _reason) {
|
|
1239
|
+
}
|
|
1240
|
+
rotateProtocolV2UsbGeneration(key, reason) {
|
|
1241
|
+
var _a;
|
|
1242
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1243
|
+
yield this.protocolV2UsbLinks.invalidateLink(key, reason);
|
|
1244
|
+
const generation = ((_a = this.protocolV2UsbGenerations.get(key)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
1245
|
+
this.protocolV2UsbGenerations.set(key, generation);
|
|
1246
|
+
this.protocolV2UsbCancellations.set(key, this.createProtocolV2UsbCancellation(generation));
|
|
1247
|
+
this.protocolV2UsbAssemblers.set(key, new ProtocolV2FrameAssembler(this.protocolV2UsbOptions.maxFrameBytes));
|
|
1248
|
+
return generation;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
callProtocolV2Usb(key, name, data, options) {
|
|
1252
|
+
return this.protocolV2UsbLinks.call(key, () => this.createProtocolV2UsbAdapter(key), name, data, options);
|
|
1253
|
+
}
|
|
1254
|
+
invalidateProtocolV2UsbLink(key, reason) {
|
|
1255
|
+
return this.protocolV2UsbLinks.invalidateLink(key, reason);
|
|
1256
|
+
}
|
|
1257
|
+
invalidateAllProtocolV2UsbLinks(reason) {
|
|
1258
|
+
return this.protocolV2UsbLinks.invalidateAllLinks(reason);
|
|
1259
|
+
}
|
|
1260
|
+
disposeProtocolV2UsbLinks(reason) {
|
|
1261
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1262
|
+
yield this.protocolV2UsbLinks.dispose(reason);
|
|
1263
|
+
this.protocolV2UsbAssemblers.clear();
|
|
1264
|
+
this.protocolV2UsbGenerations.clear();
|
|
1265
|
+
this.protocolV2UsbCancellations.clear();
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
createProtocolV2UsbAdapter(key) {
|
|
1269
|
+
const generation = this.protocolV2UsbGenerations.get(key);
|
|
1270
|
+
if (generation === undefined) {
|
|
1271
|
+
throw new Error('Protocol V2 USB generation has not been initialized');
|
|
1272
|
+
}
|
|
1273
|
+
const cancellation = this.protocolV2UsbCancellations.get(key);
|
|
1274
|
+
if (!cancellation || cancellation.generation !== generation) {
|
|
1275
|
+
throw new Error('Protocol V2 USB cancellation state has not been initialized');
|
|
1276
|
+
}
|
|
1277
|
+
const assertCurrentGeneration = () => {
|
|
1278
|
+
if (cancellation.reason) {
|
|
1279
|
+
throw new Error(cancellation.reason);
|
|
1280
|
+
}
|
|
1281
|
+
if (this.protocolV2UsbGenerations.get(key) !== generation) {
|
|
1282
|
+
throw new Error('Protocol V2 USB connection generation changed');
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
return {
|
|
1286
|
+
router: this.protocolV2UsbOptions.router,
|
|
1287
|
+
maxFrameBytes: this.protocolV2UsbOptions.maxFrameBytes,
|
|
1288
|
+
generation,
|
|
1289
|
+
prepareCall: () => {
|
|
1290
|
+
assertCurrentGeneration();
|
|
1291
|
+
this.getProtocolV2UsbAssembler(key).reset();
|
|
1292
|
+
},
|
|
1293
|
+
writeFrame: (frame, context) => __awaiter(this, void 0, void 0, function* () {
|
|
1294
|
+
assertCurrentGeneration();
|
|
1295
|
+
yield this.writeProtocolV2UsbPacket(key, frame, context);
|
|
1296
|
+
assertCurrentGeneration();
|
|
1297
|
+
}),
|
|
1298
|
+
readFrame: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1299
|
+
assertCurrentGeneration();
|
|
1300
|
+
const assembler = this.getProtocolV2UsbAssembler(key);
|
|
1301
|
+
let frame = assembler.push(new Uint8Array(0));
|
|
1302
|
+
while (!frame) {
|
|
1303
|
+
const packetRead = this.readProtocolV2UsbPacket(key, context).then(packet => ({
|
|
1304
|
+
packet,
|
|
1305
|
+
}));
|
|
1306
|
+
const cancelled = cancellation.promise.then(reason => ({ reason }));
|
|
1307
|
+
const result = yield Promise.race([packetRead, cancelled]);
|
|
1308
|
+
if ('reason' in result) {
|
|
1309
|
+
throw new Error(result.reason);
|
|
1310
|
+
}
|
|
1311
|
+
assertCurrentGeneration();
|
|
1312
|
+
frame = assembler.push(result.packet);
|
|
1313
|
+
}
|
|
1314
|
+
assertCurrentGeneration();
|
|
1315
|
+
return frame;
|
|
1316
|
+
}),
|
|
1317
|
+
reset: (reason) => {
|
|
1318
|
+
var _a;
|
|
1319
|
+
cancellation.cancel(reason);
|
|
1320
|
+
(_a = this.protocolV2UsbAssemblers.get(key)) === null || _a === void 0 ? void 0 : _a.reset();
|
|
1321
|
+
},
|
|
1322
|
+
logger: this.getProtocolV2UsbLogger(),
|
|
1323
|
+
logPrefix: this.protocolV2UsbOptions.logPrefix,
|
|
1324
|
+
createTimeoutError: (messageName, timeoutMs) => this.createProtocolV2UsbTimeoutError(messageName, timeoutMs),
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
getProtocolV2UsbAssembler(key) {
|
|
1328
|
+
const assembler = this.protocolV2UsbAssemblers.get(key);
|
|
1329
|
+
if (!assembler) {
|
|
1330
|
+
throw new Error('Protocol V2 USB assembler has not been initialized');
|
|
1331
|
+
}
|
|
1332
|
+
return assembler;
|
|
1333
|
+
}
|
|
1334
|
+
createProtocolV2UsbCancellation(generation) {
|
|
1335
|
+
let resolveCancellation = () => undefined;
|
|
1336
|
+
const cancellation = {
|
|
1337
|
+
generation,
|
|
1338
|
+
promise: new Promise(resolve => {
|
|
1339
|
+
resolveCancellation = resolve;
|
|
1340
|
+
}),
|
|
1341
|
+
cancel: reason => {
|
|
1342
|
+
if (cancellation.reason)
|
|
1343
|
+
return;
|
|
1344
|
+
cancellation.reason = reason;
|
|
1345
|
+
resolveCancellation(reason);
|
|
1346
|
+
},
|
|
1347
|
+
};
|
|
1348
|
+
return cancellation;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1055
1352
|
exports.AptosTransactionType = void 0;
|
|
1056
1353
|
(function (AptosTransactionType) {
|
|
1057
1354
|
AptosTransactionType[AptosTransactionType["STANDARD"] = 0] = "STANDARD";
|
|
@@ -1227,6 +1524,9 @@ exports.FailureType = void 0;
|
|
|
1227
1524
|
FailureType[FailureType["Failure_WipeCodeMismatch"] = 13] = "Failure_WipeCodeMismatch";
|
|
1228
1525
|
FailureType[FailureType["Failure_InvalidSession"] = 14] = "Failure_InvalidSession";
|
|
1229
1526
|
FailureType[FailureType["Failure_FirmwareError"] = 99] = "Failure_FirmwareError";
|
|
1527
|
+
FailureType[FailureType["Failure_InvalidMessage"] = 1] = "Failure_InvalidMessage";
|
|
1528
|
+
FailureType[FailureType["Failure_UndefinedError"] = 2] = "Failure_UndefinedError";
|
|
1529
|
+
FailureType[FailureType["Failure_UsageError"] = 3] = "Failure_UsageError";
|
|
1230
1530
|
})(exports.FailureType || (exports.FailureType = {}));
|
|
1231
1531
|
exports.Enum_ButtonRequestType = void 0;
|
|
1232
1532
|
(function (Enum_ButtonRequestType) {
|
|
@@ -1488,6 +1788,11 @@ exports.CommandFlags = void 0;
|
|
|
1488
1788
|
CommandFlags[CommandFlags["Default"] = 0] = "Default";
|
|
1489
1789
|
CommandFlags[CommandFlags["Factory_Only"] = 1] = "Factory_Only";
|
|
1490
1790
|
})(exports.CommandFlags || (exports.CommandFlags = {}));
|
|
1791
|
+
exports.WallpaperTarget = void 0;
|
|
1792
|
+
(function (WallpaperTarget) {
|
|
1793
|
+
WallpaperTarget[WallpaperTarget["Home"] = 0] = "Home";
|
|
1794
|
+
WallpaperTarget[WallpaperTarget["Lock"] = 1] = "Lock";
|
|
1795
|
+
})(exports.WallpaperTarget || (exports.WallpaperTarget = {}));
|
|
1491
1796
|
exports.MoneroNetworkType = void 0;
|
|
1492
1797
|
(function (MoneroNetworkType) {
|
|
1493
1798
|
MoneroNetworkType[MoneroNetworkType["MAINNET"] = 0] = "MAINNET";
|
|
@@ -1495,23 +1800,58 @@ exports.MoneroNetworkType = void 0;
|
|
|
1495
1800
|
MoneroNetworkType[MoneroNetworkType["STAGENET"] = 2] = "STAGENET";
|
|
1496
1801
|
MoneroNetworkType[MoneroNetworkType["FAKECHAIN"] = 3] = "FAKECHAIN";
|
|
1497
1802
|
})(exports.MoneroNetworkType || (exports.MoneroNetworkType = {}));
|
|
1498
|
-
exports.
|
|
1499
|
-
(function (
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1803
|
+
exports.ViewTipType = void 0;
|
|
1804
|
+
(function (ViewTipType) {
|
|
1805
|
+
ViewTipType[ViewTipType["Default"] = 0] = "Default";
|
|
1806
|
+
ViewTipType[ViewTipType["Highlight"] = 1] = "Highlight";
|
|
1807
|
+
ViewTipType[ViewTipType["Recommend"] = 2] = "Recommend";
|
|
1808
|
+
ViewTipType[ViewTipType["Warning"] = 3] = "Warning";
|
|
1809
|
+
ViewTipType[ViewTipType["Danger"] = 4] = "Danger";
|
|
1810
|
+
})(exports.ViewTipType || (exports.ViewTipType = {}));
|
|
1811
|
+
exports.ViewSignLayout = void 0;
|
|
1812
|
+
(function (ViewSignLayout) {
|
|
1813
|
+
ViewSignLayout[ViewSignLayout["LayoutDefault"] = 0] = "LayoutDefault";
|
|
1814
|
+
ViewSignLayout[ViewSignLayout["LayoutSafeTxCreate"] = 1] = "LayoutSafeTxCreate";
|
|
1815
|
+
})(exports.ViewSignLayout || (exports.ViewSignLayout = {}));
|
|
1509
1816
|
exports.DeviceRebootType = void 0;
|
|
1510
1817
|
(function (DeviceRebootType) {
|
|
1511
1818
|
DeviceRebootType[DeviceRebootType["Normal"] = 0] = "Normal";
|
|
1512
1819
|
DeviceRebootType[DeviceRebootType["Romloader"] = 1] = "Romloader";
|
|
1513
1820
|
DeviceRebootType[DeviceRebootType["Bootloader"] = 2] = "Bootloader";
|
|
1514
1821
|
})(exports.DeviceRebootType || (exports.DeviceRebootType = {}));
|
|
1822
|
+
exports.DeviceFirmwareTargetType = void 0;
|
|
1823
|
+
(function (DeviceFirmwareTargetType) {
|
|
1824
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_INVALID"] = 0] = "FW_MGMT_TARGET_INVALID";
|
|
1825
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_CRATE"] = 1] = "FW_MGMT_TARGET_CRATE";
|
|
1826
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_ROMLOADER"] = 2] = "FW_MGMT_TARGET_ROMLOADER";
|
|
1827
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_BOOTLOADER"] = 3] = "FW_MGMT_TARGET_BOOTLOADER";
|
|
1828
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_APPLICATION_P1"] = 4] = "FW_MGMT_TARGET_APPLICATION_P1";
|
|
1829
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_APPLICATION_P2"] = 5] = "FW_MGMT_TARGET_APPLICATION_P2";
|
|
1830
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_COPROCESSOR"] = 6] = "FW_MGMT_TARGET_COPROCESSOR";
|
|
1831
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE01"] = 7] = "FW_MGMT_TARGET_SE01";
|
|
1832
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE02"] = 8] = "FW_MGMT_TARGET_SE02";
|
|
1833
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE03"] = 9] = "FW_MGMT_TARGET_SE03";
|
|
1834
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE04"] = 10] = "FW_MGMT_TARGET_SE04";
|
|
1835
|
+
})(exports.DeviceFirmwareTargetType || (exports.DeviceFirmwareTargetType = {}));
|
|
1836
|
+
exports.DeviceFirmwareUpdateTaskStatus = void 0;
|
|
1837
|
+
(function (DeviceFirmwareUpdateTaskStatus) {
|
|
1838
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_PENDING"] = 0] = "FW_MGMT_UPDATER_TASK_STATUS_PENDING";
|
|
1839
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS"] = 1] = "FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS";
|
|
1840
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FINISHED"] = 2] = "FW_MGMT_UPDATER_TASK_STATUS_FINISHED";
|
|
1841
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND"] = 3] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND";
|
|
1842
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ"] = 4] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ";
|
|
1843
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE"] = 5] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE";
|
|
1844
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY"] = 6] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY";
|
|
1845
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL"] = 7] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL";
|
|
1846
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT"] = 8] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT";
|
|
1847
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY"] = 9] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY";
|
|
1848
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS"] = 10] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS";
|
|
1849
|
+
})(exports.DeviceFirmwareUpdateTaskStatus || (exports.DeviceFirmwareUpdateTaskStatus = {}));
|
|
1850
|
+
exports.DeviceFactoryAck = void 0;
|
|
1851
|
+
(function (DeviceFactoryAck) {
|
|
1852
|
+
DeviceFactoryAck[DeviceFactoryAck["FACTORY_ACK_SUCCESS"] = 0] = "FACTORY_ACK_SUCCESS";
|
|
1853
|
+
DeviceFactoryAck[DeviceFactoryAck["FACTORY_ACK_FAIL"] = 1] = "FACTORY_ACK_FAIL";
|
|
1854
|
+
})(exports.DeviceFactoryAck || (exports.DeviceFactoryAck = {}));
|
|
1515
1855
|
exports.DeviceType = void 0;
|
|
1516
1856
|
(function (DeviceType) {
|
|
1517
1857
|
DeviceType[DeviceType["CLASSIC1"] = 0] = "CLASSIC1";
|
|
@@ -1520,54 +1860,36 @@ exports.DeviceType = void 0;
|
|
|
1520
1860
|
DeviceType[DeviceType["TOUCH"] = 3] = "TOUCH";
|
|
1521
1861
|
DeviceType[DeviceType["PRO"] = 5] = "PRO";
|
|
1522
1862
|
DeviceType[DeviceType["CLASSIC1S_PURE"] = 6] = "CLASSIC1S_PURE";
|
|
1863
|
+
DeviceType[DeviceType["PRO2"] = 7] = "PRO2";
|
|
1864
|
+
DeviceType[DeviceType["NEO"] = 8] = "NEO";
|
|
1523
1865
|
})(exports.DeviceType || (exports.DeviceType = {}));
|
|
1524
|
-
exports.
|
|
1525
|
-
(function (
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
})(exports.
|
|
1529
|
-
exports.
|
|
1530
|
-
(function (
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
})(exports.
|
|
1535
|
-
exports.
|
|
1536
|
-
(function (
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
(
|
|
1551
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_INVALID"] = 0] = "TARGET_INVALID";
|
|
1552
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_ROMLOADER"] = 1] = "TARGET_ROMLOADER";
|
|
1553
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_BOOTLOADER"] = 2] = "TARGET_BOOTLOADER";
|
|
1554
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_APPLICATION_P1"] = 3] = "TARGET_APPLICATION_P1";
|
|
1555
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_APPLICATION_P2"] = 4] = "TARGET_APPLICATION_P2";
|
|
1556
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_COPROCESSOR"] = 5] = "TARGET_COPROCESSOR";
|
|
1557
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_SE01"] = 6] = "TARGET_SE01";
|
|
1558
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_SE02"] = 7] = "TARGET_SE02";
|
|
1559
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_SE03"] = 8] = "TARGET_SE03";
|
|
1560
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_SE04"] = 9] = "TARGET_SE04";
|
|
1561
|
-
DeviceFirmwareTargetType[DeviceFirmwareTargetType["TARGET_RESOURCE"] = 10] = "TARGET_RESOURCE";
|
|
1562
|
-
})(exports.DeviceFirmwareTargetType || (exports.DeviceFirmwareTargetType = {}));
|
|
1563
|
-
exports.OnboardingStep = void 0;
|
|
1564
|
-
(function (OnboardingStep) {
|
|
1565
|
-
OnboardingStep[OnboardingStep["ONBOARDING_STEP_UNKNOWN"] = 0] = "ONBOARDING_STEP_UNKNOWN";
|
|
1566
|
-
OnboardingStep[OnboardingStep["ONBOARDING_STEP_DEVICE_VERIFICATION"] = 1] = "ONBOARDING_STEP_DEVICE_VERIFICATION";
|
|
1567
|
-
OnboardingStep[OnboardingStep["ONBOARDING_STEP_PERSONALIZATION"] = 2] = "ONBOARDING_STEP_PERSONALIZATION";
|
|
1568
|
-
OnboardingStep[OnboardingStep["ONBOARDING_STEP_SETUP"] = 3] = "ONBOARDING_STEP_SETUP";
|
|
1569
|
-
OnboardingStep[OnboardingStep["ONBOARDING_STEP_FIRMWARE"] = 4] = "ONBOARDING_STEP_FIRMWARE";
|
|
1570
|
-
})(exports.OnboardingStep || (exports.OnboardingStep = {}));
|
|
1866
|
+
exports.DeviceSeType = void 0;
|
|
1867
|
+
(function (DeviceSeType) {
|
|
1868
|
+
DeviceSeType[DeviceSeType["THD89"] = 0] = "THD89";
|
|
1869
|
+
DeviceSeType[DeviceSeType["SE608A"] = 1] = "SE608A";
|
|
1870
|
+
})(exports.DeviceSeType || (exports.DeviceSeType = {}));
|
|
1871
|
+
exports.DeviceSEState = void 0;
|
|
1872
|
+
(function (DeviceSEState) {
|
|
1873
|
+
DeviceSEState[DeviceSEState["BOOT"] = 0] = "BOOT";
|
|
1874
|
+
DeviceSEState[DeviceSEState["APP_FACTORY"] = 51] = "APP_FACTORY";
|
|
1875
|
+
DeviceSEState[DeviceSEState["APP"] = 85] = "APP";
|
|
1876
|
+
})(exports.DeviceSEState || (exports.DeviceSEState = {}));
|
|
1877
|
+
exports.DevOnboardingStage = void 0;
|
|
1878
|
+
(function (DevOnboardingStage) {
|
|
1879
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_UNKNOWN"] = 0] = "DEV_ONBOARDING_STAGE_UNKNOWN";
|
|
1880
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_SAFETY_CHECK"] = 1] = "DEV_ONBOARDING_STAGE_SAFETY_CHECK";
|
|
1881
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_PERSONALIZATION"] = 2] = "DEV_ONBOARDING_STAGE_PERSONALIZATION";
|
|
1882
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_SELECT_SETUP_METHOD"] = 3] = "DEV_ONBOARDING_STAGE_SELECT_SETUP_METHOD";
|
|
1883
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_NEW_DEVICE"] = 4] = "DEV_ONBOARDING_STAGE_NEW_DEVICE";
|
|
1884
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_SELECT_RESTORE_METHOD"] = 5] = "DEV_ONBOARDING_STAGE_SELECT_RESTORE_METHOD";
|
|
1885
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_RESTORE_MNEMONIC"] = 6] = "DEV_ONBOARDING_STAGE_RESTORE_MNEMONIC";
|
|
1886
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_RESTORE_SEEDCARD"] = 7] = "DEV_ONBOARDING_STAGE_RESTORE_SEEDCARD";
|
|
1887
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_WALLET_READY"] = 8] = "DEV_ONBOARDING_STAGE_WALLET_READY";
|
|
1888
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_SEEDCARD_BACKUP_PROMPT"] = 9] = "DEV_ONBOARDING_STAGE_SEEDCARD_BACKUP_PROMPT";
|
|
1889
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_SELECT_SEEDCARD_BACKUP_METHOD"] = 10] = "DEV_ONBOARDING_STAGE_SELECT_SEEDCARD_BACKUP_METHOD";
|
|
1890
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_SEEDCARD_BACKUP"] = 11] = "DEV_ONBOARDING_STAGE_SEEDCARD_BACKUP";
|
|
1891
|
+
DevOnboardingStage[DevOnboardingStage["DEV_ONBOARDING_STAGE_DONE"] = 12] = "DEV_ONBOARDING_STAGE_DONE";
|
|
1892
|
+
})(exports.DevOnboardingStage || (exports.DevOnboardingStage = {}));
|
|
1571
1893
|
|
|
1572
1894
|
var messages = /*#__PURE__*/Object.freeze({
|
|
1573
1895
|
__proto__: null,
|
|
@@ -1631,16 +1953,18 @@ var messages = /*#__PURE__*/Object.freeze({
|
|
|
1631
1953
|
get TronResourceCode () { return exports.TronResourceCode; },
|
|
1632
1954
|
get TronMessageType () { return exports.TronMessageType; },
|
|
1633
1955
|
get CommandFlags () { return exports.CommandFlags; },
|
|
1956
|
+
get WallpaperTarget () { return exports.WallpaperTarget; },
|
|
1634
1957
|
get MoneroNetworkType () { return exports.MoneroNetworkType; },
|
|
1635
|
-
get
|
|
1636
|
-
get
|
|
1958
|
+
get ViewTipType () { return exports.ViewTipType; },
|
|
1959
|
+
get ViewSignLayout () { return exports.ViewSignLayout; },
|
|
1637
1960
|
get DeviceRebootType () { return exports.DeviceRebootType; },
|
|
1638
|
-
get DeviceType () { return exports.DeviceType; },
|
|
1639
|
-
get DevSeType () { return exports.DevSeType; },
|
|
1640
|
-
get DevSEState () { return exports.DevSEState; },
|
|
1641
|
-
get DevFirmwareTargetType () { return exports.DevFirmwareTargetType; },
|
|
1642
1961
|
get DeviceFirmwareTargetType () { return exports.DeviceFirmwareTargetType; },
|
|
1643
|
-
get
|
|
1962
|
+
get DeviceFirmwareUpdateTaskStatus () { return exports.DeviceFirmwareUpdateTaskStatus; },
|
|
1963
|
+
get DeviceFactoryAck () { return exports.DeviceFactoryAck; },
|
|
1964
|
+
get DeviceType () { return exports.DeviceType; },
|
|
1965
|
+
get DeviceSeType () { return exports.DeviceSeType; },
|
|
1966
|
+
get DeviceSEState () { return exports.DeviceSEState; },
|
|
1967
|
+
get DevOnboardingStage () { return exports.DevOnboardingStage; }
|
|
1644
1968
|
});
|
|
1645
1969
|
|
|
1646
1970
|
protobuf__namespace.util.Long = Long__default["default"];
|
|
@@ -1653,7 +1977,10 @@ var index = {
|
|
|
1653
1977
|
ProtocolV2,
|
|
1654
1978
|
PROTOCOL_V2_SYS_MESSAGE_THRESHOLD,
|
|
1655
1979
|
ProtocolV2FrameAssembler,
|
|
1980
|
+
ProtocolV2LinkManager,
|
|
1981
|
+
ProtocolV2SequenceCursor,
|
|
1656
1982
|
ProtocolV2Session,
|
|
1983
|
+
ProtocolV2UsbTransportBase,
|
|
1657
1984
|
bytesToHex,
|
|
1658
1985
|
concatUint8Arrays,
|
|
1659
1986
|
createMessageFromName,
|
|
@@ -1675,6 +2002,8 @@ exports.PROTOCOL_V1_MESSAGE_HEADER_SIZE = PROTOCOL_V1_MESSAGE_HEADER_SIZE;
|
|
|
1675
2002
|
exports.PROTOCOL_V1_REPORT_ID = PROTOCOL_V1_REPORT_ID;
|
|
1676
2003
|
exports.PROTOCOL_V1_USB_PACKET_SIZE = PROTOCOL_V1_USB_PACKET_SIZE;
|
|
1677
2004
|
exports.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE = PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
|
|
2005
|
+
exports.PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE = PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE;
|
|
2006
|
+
exports.PROTOCOL_V2_BLE_FRAME_MAX_BYTES = PROTOCOL_V2_BLE_FRAME_MAX_BYTES;
|
|
1678
2007
|
exports.PROTOCOL_V2_CHANNEL_BLE_UART = PROTOCOL_V2_CHANNEL_BLE_UART;
|
|
1679
2008
|
exports.PROTOCOL_V2_CHANNEL_SOCKET = PROTOCOL_V2_CHANNEL_SOCKET;
|
|
1680
2009
|
exports.PROTOCOL_V2_CHANNEL_USB = PROTOCOL_V2_CHANNEL_USB;
|
|
@@ -1687,7 +2016,10 @@ exports.PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS = PROTOCOL_V2_WRITE_WATCHDOG_TIMEO
|
|
|
1687
2016
|
exports.ProtocolV1 = ProtocolV1;
|
|
1688
2017
|
exports.ProtocolV2 = ProtocolV2;
|
|
1689
2018
|
exports.ProtocolV2FrameAssembler = ProtocolV2FrameAssembler;
|
|
2019
|
+
exports.ProtocolV2LinkManager = ProtocolV2LinkManager;
|
|
2020
|
+
exports.ProtocolV2SequenceCursor = ProtocolV2SequenceCursor;
|
|
1690
2021
|
exports.ProtocolV2Session = ProtocolV2Session;
|
|
2022
|
+
exports.ProtocolV2UsbTransportBase = ProtocolV2UsbTransportBase;
|
|
1691
2023
|
exports.bytesToHex = bytesToHex;
|
|
1692
2024
|
exports.concatUint8Arrays = concatUint8Arrays;
|
|
1693
2025
|
exports["default"] = index;
|