@onekeyfe/hd-transport 1.1.34-alpha.2 → 1.1.34-alpha.3
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/__tests__/build-receive.test.js +6 -8
- package/__tests__/decode-features.test.js +3 -2
- package/__tests__/messages.test.js +131 -0
- package/__tests__/protocol-v2-link-manager.test.js +351 -0
- package/__tests__/protocol-v2-usb-transport-base.test.js +296 -0
- package/__tests__/protocol-v2.test.js +899 -0
- package/dist/constants.d.ts +16 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +1398 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1102 -85
- package/dist/protocols/index.d.ts +50 -0
- package/dist/protocols/index.d.ts.map +1 -0
- package/dist/protocols/v1/decode.d.ts +11 -0
- package/dist/protocols/v1/decode.d.ts.map +1 -0
- package/dist/protocols/v1/encode.d.ts +11 -0
- package/dist/protocols/v1/encode.d.ts.map +1 -0
- package/dist/protocols/v1/index.d.ts +5 -0
- package/dist/protocols/v1/index.d.ts.map +1 -0
- package/dist/protocols/v1/packets.d.ts +7 -0
- package/dist/protocols/v1/packets.d.ts.map +1 -0
- package/dist/{serialization → protocols/v1}/receive.d.ts +1 -1
- package/dist/protocols/v1/receive.d.ts.map +1 -0
- package/dist/protocols/v2/constants.d.ts +8 -0
- package/dist/protocols/v2/constants.d.ts.map +1 -0
- package/dist/protocols/v2/crc8.d.ts +3 -0
- package/dist/protocols/v2/crc8.d.ts.map +1 -0
- package/dist/protocols/v2/decode.d.ts +8 -0
- package/dist/protocols/v2/decode.d.ts.map +1 -0
- package/dist/protocols/v2/encode.d.ts +4 -0
- package/dist/protocols/v2/encode.d.ts.map +1 -0
- package/dist/protocols/v2/frame-assembler.d.ts +12 -0
- package/dist/protocols/v2/frame-assembler.d.ts.map +1 -0
- package/dist/protocols/v2/index.d.ts +6 -0
- package/dist/protocols/v2/index.d.ts.map +1 -0
- package/dist/protocols/v2/link-manager.d.ts +36 -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 +63 -0
- package/dist/protocols/v2/session.d.ts.map +1 -0
- 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/index.d.ts +6 -3
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/protobuf/decode.d.ts.map +1 -1
- package/dist/serialization/protobuf/messages.d.ts +1 -1
- package/dist/serialization/protobuf/messages.d.ts.map +1 -1
- package/dist/types/messages.d.ts +707 -12
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/transport.d.ts +19 -5
- package/dist/types/transport.d.ts.map +1 -1
- package/dist/utils/logBlockCommand.d.ts.map +1 -1
- package/messages-protocol-v2.json +13544 -0
- package/package.json +3 -3
- package/scripts/protobuf-patches/TxInputType.js +1 -0
- package/scripts/protobuf-patches/index.js +2 -0
- package/scripts/protobuf-types.js +233 -18
- package/src/constants.ts +48 -6
- package/src/index.ts +47 -11
- package/src/protocols/index.ts +124 -0
- package/src/{serialization/protocol → protocols/v1}/decode.ts +4 -4
- package/src/{serialization/protocol → protocols/v1}/encode.ts +18 -13
- package/src/protocols/v1/index.ts +4 -0
- package/src/protocols/v1/packets.ts +53 -0
- package/src/{serialization → protocols/v1}/receive.ts +5 -5
- package/src/protocols/v2/constants.ts +7 -0
- package/src/protocols/v2/crc8.ts +34 -0
- package/src/protocols/v2/decode.ts +89 -0
- package/src/protocols/v2/encode.ts +90 -0
- package/src/protocols/v2/frame-assembler.ts +98 -0
- package/src/protocols/v2/index.ts +5 -0
- package/src/protocols/v2/link-manager.ts +162 -0
- package/src/protocols/v2/sequence-cursor.ts +10 -0
- package/src/protocols/v2/session.ts +339 -0
- package/src/protocols/v2/usb-transport-base.ts +194 -0
- package/src/serialization/index.ts +6 -5
- package/src/serialization/protobuf/decode.ts +7 -0
- package/src/serialization/protobuf/messages.ts +14 -5
- package/src/types/messages.ts +903 -13
- package/src/types/transport.ts +29 -5
- package/src/utils/logBlockCommand.ts +9 -1
- package/dist/serialization/protocol/decode.d.ts +0 -11
- package/dist/serialization/protocol/decode.d.ts.map +0 -1
- package/dist/serialization/protocol/encode.d.ts +0 -11
- package/dist/serialization/protocol/encode.d.ts.map +0 -1
- package/dist/serialization/protocol/index.d.ts +0 -3
- package/dist/serialization/protocol/index.d.ts.map +0 -1
- package/dist/serialization/receive.d.ts.map +0 -1
- package/dist/serialization/send.d.ts +0 -7
- package/dist/serialization/send.d.ts.map +0 -1
- package/src/serialization/protocol/index.ts +0 -2
- package/src/serialization/send.ts +0 -58
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ function _interopNamespace(e) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
var protobuf__namespace = /*#__PURE__*/_interopNamespace(protobuf);
|
|
31
|
-
var
|
|
31
|
+
var Long__default = /*#__PURE__*/_interopDefaultLegacy(Long);
|
|
32
32
|
var ByteBuffer__default = /*#__PURE__*/_interopDefaultLegacy(ByteBuffer);
|
|
33
33
|
|
|
34
34
|
/******************************************************************************
|
|
@@ -58,6 +58,16 @@ function __rest(s, e) {
|
|
|
58
58
|
return t;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
62
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
63
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
64
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
65
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
66
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
67
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
62
72
|
var e = new Error(message);
|
|
63
73
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -103,6 +113,12 @@ function messageToJSON(Message, fields) {
|
|
|
103
113
|
Object.keys(fields).forEach(key => {
|
|
104
114
|
const field = fields[key];
|
|
105
115
|
const value = message[key];
|
|
116
|
+
if (value == null) {
|
|
117
|
+
if (field.optional) {
|
|
118
|
+
res[key] = null;
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
106
122
|
if (field.repeated) {
|
|
107
123
|
if (isPrimitiveField(field.type)) {
|
|
108
124
|
res[key] = value.map((v) => transform$1(field, v));
|
|
@@ -132,7 +148,7 @@ function messageToJSON(Message, fields) {
|
|
|
132
148
|
});
|
|
133
149
|
return res;
|
|
134
150
|
}
|
|
135
|
-
const decode
|
|
151
|
+
const decode = (Message, data) => {
|
|
136
152
|
const buff = data.toBuffer();
|
|
137
153
|
const a = new Uint8Array(buff);
|
|
138
154
|
let decoded;
|
|
@@ -200,7 +216,7 @@ function patch(Message, payload) {
|
|
|
200
216
|
});
|
|
201
217
|
return patched;
|
|
202
218
|
}
|
|
203
|
-
const encode
|
|
219
|
+
const encode = (Message, data) => {
|
|
204
220
|
const payload = patch(Message, data);
|
|
205
221
|
const message = Message.fromObject(payload);
|
|
206
222
|
const buffer = Message.encode(message).finish();
|
|
@@ -219,18 +235,25 @@ function parseConfigure(data) {
|
|
|
219
235
|
const createMessageFromName = (messages, name) => {
|
|
220
236
|
const Message = messages.lookupType(name);
|
|
221
237
|
const MessageType = messages.lookupEnum('MessageType');
|
|
222
|
-
let
|
|
223
|
-
if (
|
|
224
|
-
|
|
238
|
+
let messageTypeId = MessageType.values[`MessageType_${name}`];
|
|
239
|
+
if (messageTypeId == null && Message.options) {
|
|
240
|
+
messageTypeId = Message.options['(wire_type)'];
|
|
241
|
+
}
|
|
242
|
+
if (!Number.isInteger(messageTypeId)) {
|
|
243
|
+
throw new Error(`MessageType for "${name}" is not defined in protobuf schema`);
|
|
225
244
|
}
|
|
226
245
|
return {
|
|
227
246
|
Message,
|
|
228
|
-
|
|
247
|
+
messageTypeId,
|
|
229
248
|
};
|
|
230
249
|
};
|
|
231
250
|
const createMessageFromType = (messages, typeId) => {
|
|
232
251
|
const MessageType = messages.lookupEnum('MessageType');
|
|
233
|
-
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_', '');
|
|
234
257
|
const Message = messages.lookupType(messageName);
|
|
235
258
|
return {
|
|
236
259
|
Message,
|
|
@@ -238,55 +261,33 @@ const createMessageFromType = (messages, typeId) => {
|
|
|
238
261
|
};
|
|
239
262
|
};
|
|
240
263
|
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return { sharp1, sharp2, typeId, length };
|
|
258
|
-
};
|
|
259
|
-
const decode = (byteBuffer) => {
|
|
260
|
-
const { typeId } = readHeader(byteBuffer);
|
|
261
|
-
return {
|
|
262
|
-
typeId,
|
|
263
|
-
buffer: byteBuffer,
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
const decodeChunked = (bytes) => {
|
|
267
|
-
const byteBuffer = ByteBuffer__default["default"].wrap(bytes, undefined, undefined, true);
|
|
268
|
-
const { sharp1, sharp2, typeId, length } = readHeaderChunked(byteBuffer);
|
|
269
|
-
if (sharp1 !== MESSAGE_HEADER_BYTE || sharp2 !== MESSAGE_HEADER_BYTE) {
|
|
270
|
-
throw new Error("Didn't receive expected header signature.");
|
|
271
|
-
}
|
|
272
|
-
return { length, typeId, restBuffer: byteBuffer };
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
var decodeProtocol = /*#__PURE__*/Object.freeze({
|
|
276
|
-
__proto__: null,
|
|
277
|
-
decode: decode,
|
|
278
|
-
decodeChunked: decodeChunked
|
|
279
|
-
});
|
|
264
|
+
const PROTOCOL_V1_REPORT_ID = 0x3f;
|
|
265
|
+
const PROTOCOL_V1_HEADER_BYTE = 0x23;
|
|
266
|
+
const PROTOCOL_V1_CHUNK_PAYLOAD_SIZE = 63;
|
|
267
|
+
const PROTOCOL_V1_USB_PACKET_SIZE = PROTOCOL_V1_CHUNK_PAYLOAD_SIZE + 1;
|
|
268
|
+
const PROTOCOL_V1_MESSAGE_HEADER_SIZE = 2 + 4;
|
|
269
|
+
const PROTOCOL_V1_ENVELOPE_HEADER_SIZE = 1 + 1 + PROTOCOL_V1_MESSAGE_HEADER_SIZE;
|
|
270
|
+
const PROTOCOL_V2_FRAME_MAX_BYTES = 4608;
|
|
271
|
+
const PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE = 4000;
|
|
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;
|
|
275
|
+
const PROTOCOL_V2_FILE_CHUNK_SIZE = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
276
|
+
const PROTOCOL_V2_CHANNEL_USB = 0;
|
|
277
|
+
const PROTOCOL_V2_CHANNEL_BLE_UART = 1;
|
|
278
|
+
const PROTOCOL_V2_CHANNEL_SOCKET = 2;
|
|
279
|
+
const PROTOCOL_V2_PACKET_SRC_COMMAND = 0;
|
|
280
280
|
|
|
281
|
-
function
|
|
282
|
-
const { addTrezorHeaders, chunked,
|
|
283
|
-
const fullSize = (addTrezorHeaders ?
|
|
281
|
+
function encodeEnvelope(data, options) {
|
|
282
|
+
const { addTrezorHeaders, chunked, messageTypeId } = options;
|
|
283
|
+
const fullSize = (addTrezorHeaders ? PROTOCOL_V1_ENVELOPE_HEADER_SIZE : PROTOCOL_V1_ENVELOPE_HEADER_SIZE - 2) +
|
|
284
|
+
Number(data.limit);
|
|
284
285
|
const encodedByteBuffer = new ByteBuffer__default["default"](fullSize);
|
|
285
286
|
if (addTrezorHeaders) {
|
|
286
|
-
encodedByteBuffer.writeByte(
|
|
287
|
-
encodedByteBuffer.writeByte(
|
|
287
|
+
encodedByteBuffer.writeByte(PROTOCOL_V1_HEADER_BYTE);
|
|
288
|
+
encodedByteBuffer.writeByte(PROTOCOL_V1_HEADER_BYTE);
|
|
288
289
|
}
|
|
289
|
-
encodedByteBuffer.writeUint16(
|
|
290
|
+
encodedByteBuffer.writeUint16(messageTypeId);
|
|
290
291
|
encodedByteBuffer.writeUint32(data.limit);
|
|
291
292
|
encodedByteBuffer.append(data.buffer);
|
|
292
293
|
encodedByteBuffer.reset();
|
|
@@ -294,7 +295,7 @@ function encode(data, options) {
|
|
|
294
295
|
return encodedByteBuffer;
|
|
295
296
|
}
|
|
296
297
|
const result = [];
|
|
297
|
-
const size =
|
|
298
|
+
const size = PROTOCOL_V1_CHUNK_PAYLOAD_SIZE;
|
|
298
299
|
const count = Math.floor((encodedByteBuffer.limit - 1) / size) + 1 || 1;
|
|
299
300
|
for (let i = 0; i < count; i++) {
|
|
300
301
|
const start = i * size;
|
|
@@ -306,30 +307,30 @@ function encode(data, options) {
|
|
|
306
307
|
return result;
|
|
307
308
|
}
|
|
308
309
|
|
|
309
|
-
function
|
|
310
|
-
const { Message,
|
|
311
|
-
const buffer = encode
|
|
312
|
-
return
|
|
310
|
+
function encodeEnvelopeMessage(messages, name, data) {
|
|
311
|
+
const { Message, messageTypeId } = createMessageFromName(messages, name);
|
|
312
|
+
const buffer = encode(Message, data);
|
|
313
|
+
return encodeEnvelope(buffer, {
|
|
313
314
|
addTrezorHeaders: false,
|
|
314
315
|
chunked: false,
|
|
315
|
-
|
|
316
|
+
messageTypeId,
|
|
316
317
|
});
|
|
317
318
|
}
|
|
318
|
-
const
|
|
319
|
-
const { Message,
|
|
320
|
-
const buffer = encode
|
|
321
|
-
return
|
|
319
|
+
const encodeMessageChunks = (messages, name, data) => {
|
|
320
|
+
const { Message, messageTypeId } = createMessageFromName(messages, name);
|
|
321
|
+
const buffer = encode(Message, data);
|
|
322
|
+
return encodeEnvelope(buffer, {
|
|
322
323
|
addTrezorHeaders: true,
|
|
323
324
|
chunked: true,
|
|
324
|
-
|
|
325
|
+
messageTypeId,
|
|
325
326
|
});
|
|
326
327
|
};
|
|
327
|
-
const
|
|
328
|
-
const encodeBuffers =
|
|
328
|
+
const encodeTransportPackets = (messages, name, data) => {
|
|
329
|
+
const encodeBuffers = encodeMessageChunks(messages, name, data);
|
|
329
330
|
const outBuffers = [];
|
|
330
331
|
for (const buf of encodeBuffers) {
|
|
331
|
-
const chunkBuffer = new ByteBuffer__default["default"](
|
|
332
|
-
chunkBuffer.writeByte(
|
|
332
|
+
const chunkBuffer = new ByteBuffer__default["default"](PROTOCOL_V1_CHUNK_PAYLOAD_SIZE + 1);
|
|
333
|
+
chunkBuffer.writeByte(PROTOCOL_V1_REPORT_ID);
|
|
333
334
|
chunkBuffer.append(buf);
|
|
334
335
|
chunkBuffer.reset();
|
|
335
336
|
outBuffers.push(chunkBuffer);
|
|
@@ -337,17 +338,359 @@ const buildBuffers = (messages, name, data) => {
|
|
|
337
338
|
return outBuffers;
|
|
338
339
|
};
|
|
339
340
|
|
|
340
|
-
|
|
341
|
+
const readHeader = (buffer) => {
|
|
342
|
+
const typeId = buffer.readUint16();
|
|
343
|
+
const length = buffer.readUint32();
|
|
344
|
+
return { typeId, length };
|
|
345
|
+
};
|
|
346
|
+
const readHeaderChunked = (buffer) => {
|
|
347
|
+
const sharp1 = buffer.readByte();
|
|
348
|
+
const sharp2 = buffer.readByte();
|
|
349
|
+
const typeId = buffer.readUint16();
|
|
350
|
+
const length = buffer.readUint32();
|
|
351
|
+
return { sharp1, sharp2, typeId, length };
|
|
352
|
+
};
|
|
353
|
+
const decodeEnvelope = (byteBuffer) => {
|
|
354
|
+
const { typeId } = readHeader(byteBuffer);
|
|
355
|
+
return {
|
|
356
|
+
typeId,
|
|
357
|
+
buffer: byteBuffer,
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
const decodeFirstChunk = (bytes) => {
|
|
361
|
+
const byteBuffer = ByteBuffer__default["default"].wrap(bytes, undefined, undefined, true);
|
|
362
|
+
const { sharp1, sharp2, typeId, length } = readHeaderChunked(byteBuffer);
|
|
363
|
+
if (sharp1 !== PROTOCOL_V1_HEADER_BYTE || sharp2 !== PROTOCOL_V1_HEADER_BYTE) {
|
|
364
|
+
throw new Error("Didn't receive expected header signature.");
|
|
365
|
+
}
|
|
366
|
+
return { length, typeId, restBuffer: byteBuffer };
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
function decodeMessage(messages, data) {
|
|
341
370
|
const bytebuffer = ByteBuffer__default["default"].wrap(data, 'hex');
|
|
342
|
-
const { typeId, buffer } =
|
|
371
|
+
const { typeId, buffer } = decodeEnvelope(bytebuffer);
|
|
343
372
|
const { Message, messageName } = createMessageFromType(messages, typeId);
|
|
344
|
-
const message = decode
|
|
373
|
+
const message = decode(Message, buffer);
|
|
345
374
|
return {
|
|
346
375
|
message,
|
|
347
376
|
type: messageName,
|
|
348
377
|
};
|
|
349
378
|
}
|
|
350
379
|
|
|
380
|
+
const PROTO_HEAD_SOF = 0x5a;
|
|
381
|
+
const PROTO_PRE_HEAD_SIZE = 4;
|
|
382
|
+
const PROTO_HEAD_CRC_SIZE = 8;
|
|
383
|
+
const CRC8_INIT = 0x30;
|
|
384
|
+
const PACKET_SIZE = 4096;
|
|
385
|
+
const PROTO_DATA_TYPE_PACKET = 0;
|
|
386
|
+
const PROTO_DATA_TYPE_ACK = 1;
|
|
387
|
+
|
|
388
|
+
const CRC8_TABLE = new Uint8Array([
|
|
389
|
+
0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41,
|
|
390
|
+
0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc,
|
|
391
|
+
0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62,
|
|
392
|
+
0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff,
|
|
393
|
+
0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07,
|
|
394
|
+
0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a,
|
|
395
|
+
0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24,
|
|
396
|
+
0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9,
|
|
397
|
+
0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd,
|
|
398
|
+
0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50,
|
|
399
|
+
0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee,
|
|
400
|
+
0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73,
|
|
401
|
+
0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b,
|
|
402
|
+
0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16,
|
|
403
|
+
0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8,
|
|
404
|
+
0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35,
|
|
405
|
+
]);
|
|
406
|
+
function crc8(data, len) {
|
|
407
|
+
let crc = CRC8_INIT;
|
|
408
|
+
for (let i = 0; i < len; i++) {
|
|
409
|
+
crc = CRC8_TABLE[crc ^ data[i]];
|
|
410
|
+
}
|
|
411
|
+
return crc;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const PROTO_SEQ_DEFAULT = 1;
|
|
415
|
+
function nextProtoSeq(current) {
|
|
416
|
+
return current >= 255 ? 1 : current + 1;
|
|
417
|
+
}
|
|
418
|
+
function encodeFrame(payload, packetSrc, router, seq) {
|
|
419
|
+
const resolvedPacketSrc = packetSrc !== null && packetSrc !== void 0 ? packetSrc : 0;
|
|
420
|
+
const resolvedRouter = router !== null && router !== void 0 ? router : 0;
|
|
421
|
+
const resolvedSeq = seq !== null && seq !== void 0 ? seq : PROTO_SEQ_DEFAULT;
|
|
422
|
+
if (!Number.isInteger(resolvedSeq) || resolvedSeq < 1 || resolvedSeq > 255) {
|
|
423
|
+
throw new Error(`Protocol V2 seq out of range (1-255): ${resolvedSeq}`);
|
|
424
|
+
}
|
|
425
|
+
const payloadLen = payload ? payload.length : 0;
|
|
426
|
+
const frameLen = payloadLen + PROTO_HEAD_CRC_SIZE;
|
|
427
|
+
if (frameLen > PROTOCOL_V2_FRAME_MAX_BYTES) {
|
|
428
|
+
throw new Error(`Protocol V2 frame too large: ${frameLen}`);
|
|
429
|
+
}
|
|
430
|
+
const frame = new Uint8Array(frameLen);
|
|
431
|
+
frame[0] = PROTO_HEAD_SOF;
|
|
432
|
+
frame[1] = frameLen % 256;
|
|
433
|
+
frame[2] = Math.floor(frameLen / 256) % 256;
|
|
434
|
+
frame[3] = 0;
|
|
435
|
+
frame[4] = resolvedRouter % 256;
|
|
436
|
+
frame[5] = (resolvedPacketSrc % 16) * 4 + (PROTO_DATA_TYPE_PACKET % 4);
|
|
437
|
+
frame[6] = resolvedSeq;
|
|
438
|
+
frame[3] = crc8(frame, 3);
|
|
439
|
+
if (payload && payloadLen > 0) {
|
|
440
|
+
frame.set(payload, 7);
|
|
441
|
+
}
|
|
442
|
+
frame[frameLen - 1] = crc8(frame, frameLen - 1);
|
|
443
|
+
return frame;
|
|
444
|
+
}
|
|
445
|
+
function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router, seq) {
|
|
446
|
+
const payload = new Uint8Array(2 + pbPayload.length);
|
|
447
|
+
payload[0] = messageTypeId % 256;
|
|
448
|
+
payload[1] = Math.floor(messageTypeId / 256) % 256;
|
|
449
|
+
payload.set(pbPayload, 2);
|
|
450
|
+
return encodeFrame(payload, packetSrc, router, seq);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function validateFrame(data) {
|
|
454
|
+
if (data.length < PROTO_HEAD_CRC_SIZE) {
|
|
455
|
+
throw new Error(`Protocol V2 frame too short: ${data.length} bytes`);
|
|
456
|
+
}
|
|
457
|
+
if (data[0] !== PROTO_HEAD_SOF) {
|
|
458
|
+
throw new Error(`Invalid SOF byte: expected 0x5A, got 0x${data[0].toString(16).padStart(2, '0')}`);
|
|
459
|
+
}
|
|
460
|
+
const frameLen = data[1] + data[2] * 256;
|
|
461
|
+
if (data.length < frameLen) {
|
|
462
|
+
throw new Error(`Frame truncated: expected ${frameLen} bytes, got ${data.length}`);
|
|
463
|
+
}
|
|
464
|
+
const expectedHeaderCrc = crc8(data, 3);
|
|
465
|
+
if (data[3] !== expectedHeaderCrc) {
|
|
466
|
+
throw new Error(`Header CRC mismatch: expected 0x${expectedHeaderCrc
|
|
467
|
+
.toString(16)
|
|
468
|
+
.padStart(2, '0')}, got 0x${data[3].toString(16).padStart(2, '0')}`);
|
|
469
|
+
}
|
|
470
|
+
const expectedFrameCrc = crc8(data, frameLen - 1);
|
|
471
|
+
if (data[frameLen - 1] !== expectedFrameCrc) {
|
|
472
|
+
throw new Error(`Frame CRC mismatch: expected 0x${expectedFrameCrc
|
|
473
|
+
.toString(16)
|
|
474
|
+
.padStart(2, '0')}, got 0x${data[frameLen - 1].toString(16).padStart(2, '0')}`);
|
|
475
|
+
}
|
|
476
|
+
return frameLen;
|
|
477
|
+
}
|
|
478
|
+
function isAckFrame(data) {
|
|
479
|
+
if (data.length < 6 || (data[5] & 0x03) !== PROTO_DATA_TYPE_ACK) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
const frameLen = validateFrame(data);
|
|
483
|
+
if (frameLen !== PROTO_HEAD_CRC_SIZE) {
|
|
484
|
+
throw new Error(`Invalid Protocol V2 ACK frame length: ${frameLen}`);
|
|
485
|
+
}
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
function decodeFrame(data) {
|
|
489
|
+
const frameLen = validateFrame(data);
|
|
490
|
+
const seq = data[6];
|
|
491
|
+
const payloadData = data.slice(7, frameLen - 1);
|
|
492
|
+
if (payloadData.length < 2) {
|
|
493
|
+
throw new Error(`Protocol V2 payload too short (need >=2 bytes for messageTypeId)`);
|
|
494
|
+
}
|
|
495
|
+
const messageTypeId = payloadData[0] + payloadData[1] * 256;
|
|
496
|
+
const pbPayload = payloadData.slice(2);
|
|
497
|
+
return { messageTypeId, pbPayload, seq };
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function concatUint8Arrays(arrays) {
|
|
501
|
+
const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);
|
|
502
|
+
const result = new Uint8Array(totalLength);
|
|
503
|
+
let offset = 0;
|
|
504
|
+
for (const arr of arrays) {
|
|
505
|
+
result.set(arr, offset);
|
|
506
|
+
offset += arr.length;
|
|
507
|
+
}
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
class ProtocolV2FrameAssembler {
|
|
511
|
+
constructor(maxFrameBytes = PROTOCOL_V2_FRAME_MAX_BYTES) {
|
|
512
|
+
this.buffer = new Uint8Array(0);
|
|
513
|
+
this.maxFrameBytes = maxFrameBytes;
|
|
514
|
+
}
|
|
515
|
+
reset() {
|
|
516
|
+
this.buffer = new Uint8Array(0);
|
|
517
|
+
}
|
|
518
|
+
push(chunk) {
|
|
519
|
+
this.append(chunk);
|
|
520
|
+
return this.extractFrame();
|
|
521
|
+
}
|
|
522
|
+
drain(chunk = new Uint8Array(0)) {
|
|
523
|
+
this.append(chunk);
|
|
524
|
+
const frames = [];
|
|
525
|
+
for (;;) {
|
|
526
|
+
const frame = this.extractFrame();
|
|
527
|
+
if (!frame)
|
|
528
|
+
break;
|
|
529
|
+
frames.push(frame);
|
|
530
|
+
}
|
|
531
|
+
return frames;
|
|
532
|
+
}
|
|
533
|
+
append(chunk) {
|
|
534
|
+
if (chunk.length > 0) {
|
|
535
|
+
this.buffer = concatUint8Arrays([this.buffer, chunk]);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
extractFrame() {
|
|
539
|
+
if (this.buffer.length < 3)
|
|
540
|
+
return undefined;
|
|
541
|
+
if (this.buffer[0] !== PROTO_HEAD_SOF) {
|
|
542
|
+
this.reset();
|
|
543
|
+
throw new Error('Invalid Protocol V2 SOF');
|
|
544
|
+
}
|
|
545
|
+
const expectedLen = this.buffer[1] + this.buffer[2] * 256;
|
|
546
|
+
if (expectedLen < PROTO_HEAD_CRC_SIZE) {
|
|
547
|
+
this.reset();
|
|
548
|
+
throw new Error(`Protocol V2 frame length too small: ${expectedLen}`);
|
|
549
|
+
}
|
|
550
|
+
if (expectedLen > this.maxFrameBytes) {
|
|
551
|
+
this.reset();
|
|
552
|
+
throw new Error(`Protocol V2 frame too large: ${expectedLen}`);
|
|
553
|
+
}
|
|
554
|
+
if (this.buffer.length < PROTO_PRE_HEAD_SIZE)
|
|
555
|
+
return undefined;
|
|
556
|
+
const expectedHeaderCrc = crc8(this.buffer, 3);
|
|
557
|
+
if (this.buffer[3] !== expectedHeaderCrc) {
|
|
558
|
+
this.reset();
|
|
559
|
+
throw new Error(`Protocol V2 header CRC mismatch: expected 0x${expectedHeaderCrc
|
|
560
|
+
.toString(16)
|
|
561
|
+
.padStart(2, '0')}`);
|
|
562
|
+
}
|
|
563
|
+
if (this.buffer.length < expectedLen)
|
|
564
|
+
return undefined;
|
|
565
|
+
const frame = this.buffer.slice(0, expectedLen);
|
|
566
|
+
this.buffer = this.buffer.slice(expectedLen);
|
|
567
|
+
return frame;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
var protocolV2Codec = /*#__PURE__*/Object.freeze({
|
|
572
|
+
__proto__: null,
|
|
573
|
+
PROTO_HEAD_SOF: PROTO_HEAD_SOF,
|
|
574
|
+
PROTO_PRE_HEAD_SIZE: PROTO_PRE_HEAD_SIZE,
|
|
575
|
+
PROTO_HEAD_CRC_SIZE: PROTO_HEAD_CRC_SIZE,
|
|
576
|
+
CRC8_INIT: CRC8_INIT,
|
|
577
|
+
PACKET_SIZE: PACKET_SIZE,
|
|
578
|
+
PROTO_DATA_TYPE_PACKET: PROTO_DATA_TYPE_PACKET,
|
|
579
|
+
PROTO_DATA_TYPE_ACK: PROTO_DATA_TYPE_ACK,
|
|
580
|
+
CRC8_TABLE: CRC8_TABLE,
|
|
581
|
+
crc8: crc8,
|
|
582
|
+
nextProtoSeq: nextProtoSeq,
|
|
583
|
+
encodeFrame: encodeFrame,
|
|
584
|
+
encodeProtobufFrame: encodeProtobufFrame,
|
|
585
|
+
isAckFrame: isAckFrame,
|
|
586
|
+
decodeFrame: decodeFrame,
|
|
587
|
+
concatUint8Arrays: concatUint8Arrays,
|
|
588
|
+
ProtocolV2FrameAssembler: ProtocolV2FrameAssembler
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
const PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = 60000;
|
|
592
|
+
const resolveProtocolV2EncodeSchema = (name, schemas) => {
|
|
593
|
+
try {
|
|
594
|
+
schemas.protocolV2.lookupType(name);
|
|
595
|
+
return schemas.protocolV2;
|
|
596
|
+
}
|
|
597
|
+
catch (_a) {
|
|
598
|
+
throw new Error(`Protocol V2 message "${name}" is not defined in Protocol V2 schema`);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
const PROTOCOL_V2_LEGACY_DECODE_ALLOWLIST = new Set([
|
|
602
|
+
'Failure',
|
|
603
|
+
'ButtonRequest',
|
|
604
|
+
'EntropyRequest',
|
|
605
|
+
'PinMatrixRequest',
|
|
606
|
+
'PassphraseRequest',
|
|
607
|
+
'Deprecated_PassphraseStateRequest',
|
|
608
|
+
'WordRequest',
|
|
609
|
+
]);
|
|
610
|
+
const createProtocolV2MessageFromType = (messageTypeId, schemas) => {
|
|
611
|
+
try {
|
|
612
|
+
return createMessageFromType(schemas.protocolV2, messageTypeId);
|
|
613
|
+
}
|
|
614
|
+
catch (protocolV2Error) {
|
|
615
|
+
let legacyMessage;
|
|
616
|
+
try {
|
|
617
|
+
legacyMessage = createMessageFromType(schemas.protocolV1, messageTypeId);
|
|
618
|
+
}
|
|
619
|
+
catch (_a) {
|
|
620
|
+
throw protocolV2Error;
|
|
621
|
+
}
|
|
622
|
+
if (PROTOCOL_V2_LEGACY_DECODE_ALLOWLIST.has(legacyMessage.messageName)) {
|
|
623
|
+
return legacyMessage;
|
|
624
|
+
}
|
|
625
|
+
throw protocolV2Error;
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
const ProtocolV1 = {
|
|
629
|
+
encodeEnvelope: encodeEnvelopeMessage,
|
|
630
|
+
encodeMessageChunks,
|
|
631
|
+
encodeTransportPackets,
|
|
632
|
+
decodeFirstChunk,
|
|
633
|
+
decodeMessage: decodeMessage,
|
|
634
|
+
};
|
|
635
|
+
const ProtocolV2 = {
|
|
636
|
+
isAckFrame,
|
|
637
|
+
inspectFrame(schemas, frame) {
|
|
638
|
+
const { messageTypeId, pbPayload, seq } = decodeFrame(frame);
|
|
639
|
+
const { messageName } = createProtocolV2MessageFromType(messageTypeId, schemas);
|
|
640
|
+
return {
|
|
641
|
+
messageName,
|
|
642
|
+
messageTypeId,
|
|
643
|
+
pbPayload,
|
|
644
|
+
seq,
|
|
645
|
+
type: messageName,
|
|
646
|
+
};
|
|
647
|
+
},
|
|
648
|
+
encodeFrame(schemas, name, data, options = {}) {
|
|
649
|
+
const encodeMessages = resolveProtocolV2EncodeSchema(name, schemas);
|
|
650
|
+
const { Message, messageTypeId } = createMessageFromName(encodeMessages, name);
|
|
651
|
+
const pbBuffer = encode(Message, data);
|
|
652
|
+
pbBuffer.reset();
|
|
653
|
+
const rawPbBuffer = pbBuffer.toBuffer();
|
|
654
|
+
const pbBytes = new Uint8Array(rawPbBuffer);
|
|
655
|
+
return encodeProtobufFrame(messageTypeId, pbBytes, options.packetSrc, options.router, options.seq);
|
|
656
|
+
},
|
|
657
|
+
decodeFrame(schemas, frame) {
|
|
658
|
+
const { messageTypeId, pbPayload, seq, messageName } = this.inspectFrame(schemas, frame);
|
|
659
|
+
const { Message } = createProtocolV2MessageFromType(messageTypeId, schemas);
|
|
660
|
+
const rxByteBuffer = ByteBuffer__default["default"].wrap(Buffer.from(pbPayload));
|
|
661
|
+
const message = decode(Message, rxByteBuffer);
|
|
662
|
+
return {
|
|
663
|
+
message,
|
|
664
|
+
messageName,
|
|
665
|
+
messageTypeId,
|
|
666
|
+
pbPayload,
|
|
667
|
+
seq,
|
|
668
|
+
type: messageName,
|
|
669
|
+
};
|
|
670
|
+
},
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
674
|
+
__proto__: null,
|
|
675
|
+
decodeEnvelope: decodeEnvelope,
|
|
676
|
+
decodeFirstChunk: decodeFirstChunk,
|
|
677
|
+
encodeEnvelope: encodeEnvelope,
|
|
678
|
+
encodeEnvelopeMessage: encodeEnvelopeMessage,
|
|
679
|
+
encodeMessageChunks: encodeMessageChunks,
|
|
680
|
+
encodeTransportPackets: encodeTransportPackets,
|
|
681
|
+
decodeMessage: decodeMessage
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
class ProtocolV2SequenceCursor {
|
|
685
|
+
constructor() {
|
|
686
|
+
this.current = 0;
|
|
687
|
+
}
|
|
688
|
+
next() {
|
|
689
|
+
this.current = nextProtoSeq(this.current);
|
|
690
|
+
return this.current;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
351
694
|
const ERROR = 'Wrong result type.';
|
|
352
695
|
function info(res) {
|
|
353
696
|
if (typeof res !== 'object' || res == null) {
|
|
@@ -435,6 +778,425 @@ var check = /*#__PURE__*/Object.freeze({
|
|
|
435
778
|
call: call
|
|
436
779
|
});
|
|
437
780
|
|
|
781
|
+
const LogBlockCommand = new Set([
|
|
782
|
+
'PassphraseAck',
|
|
783
|
+
'PinMatrixAck',
|
|
784
|
+
'FilesystemFileWrite',
|
|
785
|
+
'FileWrite',
|
|
786
|
+
'EmmcFileWrite',
|
|
787
|
+
'FirmwareUpload',
|
|
788
|
+
'ResourceAck',
|
|
789
|
+
]);
|
|
790
|
+
|
|
791
|
+
function hexToBytes(hex) {
|
|
792
|
+
const clean = hex.replace(/\s+/g, '');
|
|
793
|
+
if (clean.length % 2 !== 0) {
|
|
794
|
+
throw new Error(`Invalid hex string: odd length ${clean.length}`);
|
|
795
|
+
}
|
|
796
|
+
if (!/^[0-9a-fA-F]*$/.test(clean)) {
|
|
797
|
+
throw new Error('Invalid hex string: contains non-hex characters');
|
|
798
|
+
}
|
|
799
|
+
const bytes = new Uint8Array(clean.length / 2);
|
|
800
|
+
for (let i = 0; i < bytes.length; i += 1) {
|
|
801
|
+
bytes[i] = parseInt(clean.substring(i * 2, i * 2 + 2), 16);
|
|
802
|
+
}
|
|
803
|
+
return bytes;
|
|
804
|
+
}
|
|
805
|
+
function bytesToHex(bytes) {
|
|
806
|
+
return Array.from(bytes)
|
|
807
|
+
.map(b => b.toString(16).padStart(2, '0'))
|
|
808
|
+
.join('');
|
|
809
|
+
}
|
|
810
|
+
const HIGH_VOLUME_PROTOCOL_V2_CALLS = new Set([
|
|
811
|
+
...LogBlockCommand,
|
|
812
|
+
'FilesystemFileRead',
|
|
813
|
+
'FileRead',
|
|
814
|
+
'EmmcFileRead',
|
|
815
|
+
]);
|
|
816
|
+
function shouldReduceProtocolV2Debug(name) {
|
|
817
|
+
return HIGH_VOLUME_PROTOCOL_V2_CALLS.has(name);
|
|
818
|
+
}
|
|
819
|
+
const COMMON_TERMINAL_RESPONSE_TYPES = new Set([
|
|
820
|
+
'Failure',
|
|
821
|
+
'ButtonRequest',
|
|
822
|
+
'EntropyRequest',
|
|
823
|
+
'PinMatrixRequest',
|
|
824
|
+
'PassphraseRequest',
|
|
825
|
+
'Deprecated_PassphraseStateRequest',
|
|
826
|
+
'WordRequest',
|
|
827
|
+
]);
|
|
828
|
+
function isExpectedTerminalResponse(response, expectedTypes) {
|
|
829
|
+
if (!expectedTypes || expectedTypes.length === 0)
|
|
830
|
+
return true;
|
|
831
|
+
return expectedTypes.includes(response.type) || COMMON_TERMINAL_RESPONSE_TYPES.has(response.type);
|
|
832
|
+
}
|
|
833
|
+
function getErrorMessage(error) {
|
|
834
|
+
if (!error)
|
|
835
|
+
return '';
|
|
836
|
+
if (typeof error === 'string')
|
|
837
|
+
return error;
|
|
838
|
+
if (typeof error === 'object' && 'message' in error) {
|
|
839
|
+
const { message } = error;
|
|
840
|
+
return typeof message === 'string' ? message : String(message !== null && message !== void 0 ? message : '');
|
|
841
|
+
}
|
|
842
|
+
return String(error);
|
|
843
|
+
}
|
|
844
|
+
function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout) {
|
|
845
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
846
|
+
if (!timeoutMs)
|
|
847
|
+
return promise;
|
|
848
|
+
let timer;
|
|
849
|
+
try {
|
|
850
|
+
return yield Promise.race([
|
|
851
|
+
promise,
|
|
852
|
+
new Promise((_, reject) => {
|
|
853
|
+
timer = setTimeout(() => {
|
|
854
|
+
onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout();
|
|
855
|
+
reject(createTimeoutError());
|
|
856
|
+
}, timeoutMs);
|
|
857
|
+
}),
|
|
858
|
+
]);
|
|
859
|
+
}
|
|
860
|
+
finally {
|
|
861
|
+
if (timer)
|
|
862
|
+
clearTimeout(timer);
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
const PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS = 30000;
|
|
867
|
+
class ProtocolV2Session {
|
|
868
|
+
constructor(options) {
|
|
869
|
+
var _a;
|
|
870
|
+
this.pendingCall = Promise.resolve();
|
|
871
|
+
this.options = options;
|
|
872
|
+
this.sequenceCursor = (_a = options.sequenceCursor) !== null && _a !== void 0 ? _a : new ProtocolV2SequenceCursor();
|
|
873
|
+
}
|
|
874
|
+
call(name, data, callOptions = {}) {
|
|
875
|
+
const run = () => this.executeCall(name, data, callOptions);
|
|
876
|
+
const result = this.pendingCall.then(run, run);
|
|
877
|
+
this.pendingCall = result.catch(() => undefined);
|
|
878
|
+
return result;
|
|
879
|
+
}
|
|
880
|
+
executeCall(name, data, callOptions) {
|
|
881
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
882
|
+
const { schemas, router, packetSrc = PROTOCOL_V2_PACKET_SRC_COMMAND, maxFrameBytes, prepareCall, writeFrame, readFrame, logger, logPrefix = 'ProtocolV2', createTimeoutError, generation = 0, writeTimeoutMs = PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS, } = this.options;
|
|
883
|
+
const shouldReduceDebug = shouldReduceProtocolV2Debug(name);
|
|
884
|
+
const callContext = {
|
|
885
|
+
messageName: name,
|
|
886
|
+
timeoutMs: callOptions.timeoutMs,
|
|
887
|
+
highVolume: shouldReduceDebug,
|
|
888
|
+
generation,
|
|
889
|
+
};
|
|
890
|
+
yield (prepareCall === null || prepareCall === void 0 ? void 0 : prepareCall(callContext));
|
|
891
|
+
const protoSeq = this.sequenceCursor.next();
|
|
892
|
+
const frame = ProtocolV2.encodeFrame(schemas, name, data, {
|
|
893
|
+
packetSrc,
|
|
894
|
+
router,
|
|
895
|
+
seq: protoSeq,
|
|
896
|
+
});
|
|
897
|
+
if (maxFrameBytes !== undefined && frame.length > maxFrameBytes) {
|
|
898
|
+
throw new Error(`Protocol V2 frame too large for transport: ${frame.length} > ${maxFrameBytes}`);
|
|
899
|
+
}
|
|
900
|
+
yield withProtocolTimeout(writeFrame(frame, callContext), writeTimeoutMs, () => new Error(`Protocol V2 write timeout after ${writeTimeoutMs}ms for ${name}`));
|
|
901
|
+
const cancellation = { cancelled: false };
|
|
902
|
+
const readResponse = () => __awaiter(this, void 0, void 0, function* () {
|
|
903
|
+
var _a, _b, _c, _d;
|
|
904
|
+
while (!cancellation.cancelled) {
|
|
905
|
+
const rxFrame = yield readFrame(callContext);
|
|
906
|
+
if (cancellation.cancelled) {
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
const isAck = ProtocolV2.isAckFrame(rxFrame);
|
|
910
|
+
if (!isAck) {
|
|
911
|
+
const decoded = ProtocolV2.decodeFrame(schemas, rxFrame);
|
|
912
|
+
const response = call(decoded);
|
|
913
|
+
if ((_a = callOptions.intermediateTypes) === null || _a === void 0 ? void 0 : _a.includes(response.type)) {
|
|
914
|
+
(_b = callOptions.onIntermediateResponse) === null || _b === void 0 ? void 0 : _b.call(callOptions, response);
|
|
915
|
+
}
|
|
916
|
+
else if (isExpectedTerminalResponse(response, callOptions.expectedTypes)) {
|
|
917
|
+
return response;
|
|
918
|
+
}
|
|
919
|
+
else if (!shouldReduceDebug) {
|
|
920
|
+
(_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}`);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
throw new Error(`Protocol V2 read loop cancelled after timeout for ${name}`);
|
|
925
|
+
});
|
|
926
|
+
return withProtocolTimeout(readResponse(), callOptions.timeoutMs, () => {
|
|
927
|
+
var _a;
|
|
928
|
+
return createTimeoutError
|
|
929
|
+
? createTimeoutError(name, (_a = callOptions.timeoutMs) !== null && _a !== void 0 ? _a : 0)
|
|
930
|
+
: new Error(`Protocol V2 response timeout after ${callOptions.timeoutMs}ms for ${name}`);
|
|
931
|
+
}, () => {
|
|
932
|
+
cancellation.cancelled = true;
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function probeProtocolV2({ call, timeoutMs, logger, logPrefix = 'ProtocolV2', onBeforeProbe, onProbeFailed, }) {
|
|
938
|
+
var _a;
|
|
939
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
940
|
+
let probeError;
|
|
941
|
+
try {
|
|
942
|
+
yield (onBeforeProbe === null || onBeforeProbe === void 0 ? void 0 : onBeforeProbe());
|
|
943
|
+
const response = yield call('Ping', { message: 'protocol-v2-probe' }, { timeoutMs, expectedTypes: ['Success'] });
|
|
944
|
+
if (response.type === 'Success') {
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
probeError = new Error(`unexpected response type ${response.type}`);
|
|
948
|
+
}
|
|
949
|
+
catch (error) {
|
|
950
|
+
probeError = error;
|
|
951
|
+
}
|
|
952
|
+
(_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));
|
|
953
|
+
yield (onProbeFailed === null || onProbeFailed === void 0 ? void 0 : onProbeFailed(probeError));
|
|
954
|
+
return false;
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
class ProtocolV2LinkManager {
|
|
959
|
+
constructor(options) {
|
|
960
|
+
this.links = new Map();
|
|
961
|
+
this.sequences = new Map();
|
|
962
|
+
this.callQueues = new Map();
|
|
963
|
+
this.options = options;
|
|
964
|
+
}
|
|
965
|
+
call(key, createAdapter, name, data, options) {
|
|
966
|
+
var _a;
|
|
967
|
+
const run = () => this.executeCall(key, createAdapter, name, data, options);
|
|
968
|
+
const previous = (_a = this.callQueues.get(key)) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
969
|
+
const result = previous.then(run, run);
|
|
970
|
+
const queue = result.catch(() => undefined);
|
|
971
|
+
this.callQueues.set(key, queue);
|
|
972
|
+
result
|
|
973
|
+
.then(() => this.clearSettledCallQueue(key, queue), () => this.clearSettledCallQueue(key, queue))
|
|
974
|
+
.catch(() => undefined);
|
|
975
|
+
return result;
|
|
976
|
+
}
|
|
977
|
+
invalidateLink(key, reason) {
|
|
978
|
+
var _a, _b;
|
|
979
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
980
|
+
const link = this.links.get(key);
|
|
981
|
+
if (!link)
|
|
982
|
+
return;
|
|
983
|
+
this.links.delete(key);
|
|
984
|
+
link.state.invalidatedReason = reason;
|
|
985
|
+
yield link.adapter.reset(reason);
|
|
986
|
+
yield ((_b = (_a = this.options).onLinkInvalidated) === null || _b === void 0 ? void 0 : _b.call(_a, key, reason));
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
invalidateAllLinks(reason) {
|
|
990
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
991
|
+
yield Promise.all(Array.from(this.links.keys(), key => this.invalidateLink(key, reason)));
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
dispose(reason) {
|
|
995
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
996
|
+
yield this.invalidateAllLinks(reason);
|
|
997
|
+
this.sequences.clear();
|
|
998
|
+
this.callQueues.clear();
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
getOrCreateLink(key, createAdapter) {
|
|
1002
|
+
const existing = this.links.get(key);
|
|
1003
|
+
if (existing)
|
|
1004
|
+
return existing;
|
|
1005
|
+
const adapter = createAdapter();
|
|
1006
|
+
const state = {};
|
|
1007
|
+
const assertLinkActive = () => {
|
|
1008
|
+
if (state.invalidatedReason) {
|
|
1009
|
+
throw new Error(state.invalidatedReason);
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
let sequenceCursor = this.sequences.get(key);
|
|
1013
|
+
if (!sequenceCursor) {
|
|
1014
|
+
sequenceCursor = new ProtocolV2SequenceCursor();
|
|
1015
|
+
this.sequences.set(key, sequenceCursor);
|
|
1016
|
+
}
|
|
1017
|
+
const session = new ProtocolV2Session({
|
|
1018
|
+
schemas: this.options.getSchemas(),
|
|
1019
|
+
router: adapter.router,
|
|
1020
|
+
maxFrameBytes: adapter.maxFrameBytes,
|
|
1021
|
+
generation: adapter.generation,
|
|
1022
|
+
sequenceCursor,
|
|
1023
|
+
prepareCall: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1024
|
+
assertLinkActive();
|
|
1025
|
+
yield adapter.prepareCall(context);
|
|
1026
|
+
assertLinkActive();
|
|
1027
|
+
}),
|
|
1028
|
+
writeFrame: (frame, context) => __awaiter(this, void 0, void 0, function* () {
|
|
1029
|
+
assertLinkActive();
|
|
1030
|
+
yield adapter.writeFrame(frame, context);
|
|
1031
|
+
assertLinkActive();
|
|
1032
|
+
}),
|
|
1033
|
+
readFrame: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1034
|
+
assertLinkActive();
|
|
1035
|
+
const frame = yield adapter.readFrame(context);
|
|
1036
|
+
assertLinkActive();
|
|
1037
|
+
return frame;
|
|
1038
|
+
}),
|
|
1039
|
+
logger: adapter.logger,
|
|
1040
|
+
logPrefix: adapter.logPrefix,
|
|
1041
|
+
createTimeoutError: adapter.createTimeoutError,
|
|
1042
|
+
writeTimeoutMs: adapter.writeTimeoutMs,
|
|
1043
|
+
});
|
|
1044
|
+
const link = { adapter, session, state };
|
|
1045
|
+
this.links.set(key, link);
|
|
1046
|
+
return link;
|
|
1047
|
+
}
|
|
1048
|
+
executeCall(key, createAdapter, name, data, options) {
|
|
1049
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1050
|
+
try {
|
|
1051
|
+
return yield this.getOrCreateLink(key, createAdapter).session.call(name, data, options);
|
|
1052
|
+
}
|
|
1053
|
+
catch (error) {
|
|
1054
|
+
if (this.options.classifyError(error) === 'link-fatal') {
|
|
1055
|
+
const errorMessage = getErrorMessage(error) || 'unknown error';
|
|
1056
|
+
yield this.invalidateLink(key, `Protocol V2 link-fatal error: ${errorMessage}`);
|
|
1057
|
+
}
|
|
1058
|
+
throw error;
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
clearSettledCallQueue(key, queue) {
|
|
1063
|
+
if (this.callQueues.get(key) === queue) {
|
|
1064
|
+
this.callQueues.delete(key);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
class ProtocolV2UsbTransportBase {
|
|
1070
|
+
constructor(options) {
|
|
1071
|
+
this.protocolV2UsbAssemblers = new Map();
|
|
1072
|
+
this.protocolV2UsbGenerations = new Map();
|
|
1073
|
+
this.protocolV2UsbCancellations = new Map();
|
|
1074
|
+
this.protocolV2UsbOptions = options;
|
|
1075
|
+
this.protocolV2UsbLinks = new ProtocolV2LinkManager({
|
|
1076
|
+
getSchemas: () => this.getProtocolV2UsbSchemas(),
|
|
1077
|
+
classifyError: () => 'link-fatal',
|
|
1078
|
+
onLinkInvalidated: (key, reason) => __awaiter(this, void 0, void 0, function* () {
|
|
1079
|
+
var _a;
|
|
1080
|
+
(_a = this.protocolV2UsbAssemblers.get(key)) === null || _a === void 0 ? void 0 : _a.reset();
|
|
1081
|
+
yield this.resetProtocolV2UsbNativeLink(key, reason);
|
|
1082
|
+
yield this.onProtocolV2UsbLinkInvalidated(key, reason);
|
|
1083
|
+
}),
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
onProtocolV2UsbLinkInvalidated(_key, _reason) {
|
|
1087
|
+
}
|
|
1088
|
+
rotateProtocolV2UsbGeneration(key, reason) {
|
|
1089
|
+
var _a;
|
|
1090
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1091
|
+
yield this.protocolV2UsbLinks.invalidateLink(key, reason);
|
|
1092
|
+
const generation = ((_a = this.protocolV2UsbGenerations.get(key)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
1093
|
+
this.protocolV2UsbGenerations.set(key, generation);
|
|
1094
|
+
this.protocolV2UsbCancellations.set(key, this.createProtocolV2UsbCancellation(generation));
|
|
1095
|
+
this.protocolV2UsbAssemblers.set(key, new ProtocolV2FrameAssembler(this.protocolV2UsbOptions.maxFrameBytes));
|
|
1096
|
+
return generation;
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
callProtocolV2Usb(key, name, data, options) {
|
|
1100
|
+
return this.protocolV2UsbLinks.call(key, () => this.createProtocolV2UsbAdapter(key), name, data, options);
|
|
1101
|
+
}
|
|
1102
|
+
invalidateProtocolV2UsbLink(key, reason) {
|
|
1103
|
+
return this.protocolV2UsbLinks.invalidateLink(key, reason);
|
|
1104
|
+
}
|
|
1105
|
+
invalidateAllProtocolV2UsbLinks(reason) {
|
|
1106
|
+
return this.protocolV2UsbLinks.invalidateAllLinks(reason);
|
|
1107
|
+
}
|
|
1108
|
+
disposeProtocolV2UsbLinks(reason) {
|
|
1109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1110
|
+
yield this.protocolV2UsbLinks.dispose(reason);
|
|
1111
|
+
this.protocolV2UsbAssemblers.clear();
|
|
1112
|
+
this.protocolV2UsbGenerations.clear();
|
|
1113
|
+
this.protocolV2UsbCancellations.clear();
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
createProtocolV2UsbAdapter(key) {
|
|
1117
|
+
const generation = this.protocolV2UsbGenerations.get(key);
|
|
1118
|
+
if (generation === undefined) {
|
|
1119
|
+
throw new Error('Protocol V2 USB generation has not been initialized');
|
|
1120
|
+
}
|
|
1121
|
+
const cancellation = this.protocolV2UsbCancellations.get(key);
|
|
1122
|
+
if (!cancellation || cancellation.generation !== generation) {
|
|
1123
|
+
throw new Error('Protocol V2 USB cancellation state has not been initialized');
|
|
1124
|
+
}
|
|
1125
|
+
const assertCurrentGeneration = () => {
|
|
1126
|
+
if (cancellation.reason) {
|
|
1127
|
+
throw new Error(cancellation.reason);
|
|
1128
|
+
}
|
|
1129
|
+
if (this.protocolV2UsbGenerations.get(key) !== generation) {
|
|
1130
|
+
throw new Error('Protocol V2 USB connection generation changed');
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
return {
|
|
1134
|
+
router: this.protocolV2UsbOptions.router,
|
|
1135
|
+
maxFrameBytes: this.protocolV2UsbOptions.maxFrameBytes,
|
|
1136
|
+
generation,
|
|
1137
|
+
prepareCall: () => {
|
|
1138
|
+
assertCurrentGeneration();
|
|
1139
|
+
this.getProtocolV2UsbAssembler(key).reset();
|
|
1140
|
+
},
|
|
1141
|
+
writeFrame: (frame, context) => __awaiter(this, void 0, void 0, function* () {
|
|
1142
|
+
assertCurrentGeneration();
|
|
1143
|
+
yield this.writeProtocolV2UsbPacket(key, frame, context);
|
|
1144
|
+
assertCurrentGeneration();
|
|
1145
|
+
}),
|
|
1146
|
+
readFrame: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
1147
|
+
assertCurrentGeneration();
|
|
1148
|
+
const assembler = this.getProtocolV2UsbAssembler(key);
|
|
1149
|
+
let frame = assembler.push(new Uint8Array(0));
|
|
1150
|
+
while (!frame) {
|
|
1151
|
+
const packetRead = this.readProtocolV2UsbPacket(key, context).then(packet => ({
|
|
1152
|
+
packet,
|
|
1153
|
+
}));
|
|
1154
|
+
const cancelled = cancellation.promise.then(reason => ({ reason }));
|
|
1155
|
+
const result = yield Promise.race([packetRead, cancelled]);
|
|
1156
|
+
if ('reason' in result) {
|
|
1157
|
+
throw new Error(result.reason);
|
|
1158
|
+
}
|
|
1159
|
+
assertCurrentGeneration();
|
|
1160
|
+
frame = assembler.push(result.packet);
|
|
1161
|
+
}
|
|
1162
|
+
assertCurrentGeneration();
|
|
1163
|
+
return frame;
|
|
1164
|
+
}),
|
|
1165
|
+
reset: (reason) => {
|
|
1166
|
+
var _a;
|
|
1167
|
+
cancellation.cancel(reason);
|
|
1168
|
+
(_a = this.protocolV2UsbAssemblers.get(key)) === null || _a === void 0 ? void 0 : _a.reset();
|
|
1169
|
+
},
|
|
1170
|
+
logger: this.getProtocolV2UsbLogger(),
|
|
1171
|
+
logPrefix: this.protocolV2UsbOptions.logPrefix,
|
|
1172
|
+
createTimeoutError: (messageName, timeoutMs) => this.createProtocolV2UsbTimeoutError(messageName, timeoutMs),
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
getProtocolV2UsbAssembler(key) {
|
|
1176
|
+
const assembler = this.protocolV2UsbAssemblers.get(key);
|
|
1177
|
+
if (!assembler) {
|
|
1178
|
+
throw new Error('Protocol V2 USB assembler has not been initialized');
|
|
1179
|
+
}
|
|
1180
|
+
return assembler;
|
|
1181
|
+
}
|
|
1182
|
+
createProtocolV2UsbCancellation(generation) {
|
|
1183
|
+
let resolveCancellation = () => undefined;
|
|
1184
|
+
const cancellation = {
|
|
1185
|
+
generation,
|
|
1186
|
+
promise: new Promise(resolve => {
|
|
1187
|
+
resolveCancellation = resolve;
|
|
1188
|
+
}),
|
|
1189
|
+
cancel: reason => {
|
|
1190
|
+
if (cancellation.reason)
|
|
1191
|
+
return;
|
|
1192
|
+
cancellation.reason = reason;
|
|
1193
|
+
resolveCancellation(reason);
|
|
1194
|
+
},
|
|
1195
|
+
};
|
|
1196
|
+
return cancellation;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
438
1200
|
exports.AptosTransactionType = void 0;
|
|
439
1201
|
(function (AptosTransactionType) {
|
|
440
1202
|
AptosTransactionType[AptosTransactionType["STANDARD"] = 0] = "STANDARD";
|
|
@@ -500,6 +1262,7 @@ exports.Enum_RequestType = void 0;
|
|
|
500
1262
|
Enum_RequestType[Enum_RequestType["TXEXTRADATA"] = 4] = "TXEXTRADATA";
|
|
501
1263
|
Enum_RequestType[Enum_RequestType["TXORIGINPUT"] = 5] = "TXORIGINPUT";
|
|
502
1264
|
Enum_RequestType[Enum_RequestType["TXORIGOUTPUT"] = 6] = "TXORIGOUTPUT";
|
|
1265
|
+
Enum_RequestType[Enum_RequestType["TXPAYMENTREQ"] = 7] = "TXPAYMENTREQ";
|
|
503
1266
|
})(exports.Enum_RequestType || (exports.Enum_RequestType = {}));
|
|
504
1267
|
exports.RebootType = void 0;
|
|
505
1268
|
(function (RebootType) {
|
|
@@ -609,6 +1372,9 @@ exports.FailureType = void 0;
|
|
|
609
1372
|
FailureType[FailureType["Failure_WipeCodeMismatch"] = 13] = "Failure_WipeCodeMismatch";
|
|
610
1373
|
FailureType[FailureType["Failure_InvalidSession"] = 14] = "Failure_InvalidSession";
|
|
611
1374
|
FailureType[FailureType["Failure_FirmwareError"] = 99] = "Failure_FirmwareError";
|
|
1375
|
+
FailureType[FailureType["Failure_InvalidMessage"] = 1] = "Failure_InvalidMessage";
|
|
1376
|
+
FailureType[FailureType["Failure_UndefinedError"] = 2] = "Failure_UndefinedError";
|
|
1377
|
+
FailureType[FailureType["Failure_UsageError"] = 3] = "Failure_UsageError";
|
|
612
1378
|
})(exports.FailureType || (exports.FailureType = {}));
|
|
613
1379
|
exports.Enum_ButtonRequestType = void 0;
|
|
614
1380
|
(function (Enum_ButtonRequestType) {
|
|
@@ -700,6 +1466,9 @@ exports.Enum_BackupType = void 0;
|
|
|
700
1466
|
Enum_BackupType[Enum_BackupType["Bip39"] = 0] = "Bip39";
|
|
701
1467
|
Enum_BackupType[Enum_BackupType["Slip39_Basic"] = 1] = "Slip39_Basic";
|
|
702
1468
|
Enum_BackupType[Enum_BackupType["Slip39_Advanced"] = 2] = "Slip39_Advanced";
|
|
1469
|
+
Enum_BackupType[Enum_BackupType["Slip39_Single_Extendable"] = 3] = "Slip39_Single_Extendable";
|
|
1470
|
+
Enum_BackupType[Enum_BackupType["Slip39_Basic_Extendable"] = 4] = "Slip39_Basic_Extendable";
|
|
1471
|
+
Enum_BackupType[Enum_BackupType["Slip39_Advanced_Extendable"] = 5] = "Slip39_Advanced_Extendable";
|
|
703
1472
|
})(exports.Enum_BackupType || (exports.Enum_BackupType = {}));
|
|
704
1473
|
exports.Enum_SafetyCheckLevel = void 0;
|
|
705
1474
|
(function (Enum_SafetyCheckLevel) {
|
|
@@ -885,6 +1654,193 @@ exports.CommandFlags = void 0;
|
|
|
885
1654
|
CommandFlags[CommandFlags["Default"] = 0] = "Default";
|
|
886
1655
|
CommandFlags[CommandFlags["Factory_Only"] = 1] = "Factory_Only";
|
|
887
1656
|
})(exports.CommandFlags || (exports.CommandFlags = {}));
|
|
1657
|
+
exports.WallpaperTarget = void 0;
|
|
1658
|
+
(function (WallpaperTarget) {
|
|
1659
|
+
WallpaperTarget[WallpaperTarget["Home"] = 0] = "Home";
|
|
1660
|
+
WallpaperTarget[WallpaperTarget["Lock"] = 1] = "Lock";
|
|
1661
|
+
})(exports.WallpaperTarget || (exports.WallpaperTarget = {}));
|
|
1662
|
+
exports.MoneroNetworkType = void 0;
|
|
1663
|
+
(function (MoneroNetworkType) {
|
|
1664
|
+
MoneroNetworkType[MoneroNetworkType["MAINNET"] = 0] = "MAINNET";
|
|
1665
|
+
MoneroNetworkType[MoneroNetworkType["TESTNET"] = 1] = "TESTNET";
|
|
1666
|
+
MoneroNetworkType[MoneroNetworkType["STAGENET"] = 2] = "STAGENET";
|
|
1667
|
+
MoneroNetworkType[MoneroNetworkType["FAKECHAIN"] = 3] = "FAKECHAIN";
|
|
1668
|
+
})(exports.MoneroNetworkType || (exports.MoneroNetworkType = {}));
|
|
1669
|
+
exports.ViewTipType = void 0;
|
|
1670
|
+
(function (ViewTipType) {
|
|
1671
|
+
ViewTipType[ViewTipType["Default"] = 0] = "Default";
|
|
1672
|
+
ViewTipType[ViewTipType["Highlight"] = 1] = "Highlight";
|
|
1673
|
+
ViewTipType[ViewTipType["Recommend"] = 2] = "Recommend";
|
|
1674
|
+
ViewTipType[ViewTipType["Warning"] = 3] = "Warning";
|
|
1675
|
+
ViewTipType[ViewTipType["Danger"] = 4] = "Danger";
|
|
1676
|
+
})(exports.ViewTipType || (exports.ViewTipType = {}));
|
|
1677
|
+
exports.ViewSignLayout = void 0;
|
|
1678
|
+
(function (ViewSignLayout) {
|
|
1679
|
+
ViewSignLayout[ViewSignLayout["LayoutDefault"] = 0] = "LayoutDefault";
|
|
1680
|
+
ViewSignLayout[ViewSignLayout["LayoutSafeTxCreate"] = 1] = "LayoutSafeTxCreate";
|
|
1681
|
+
ViewSignLayout[ViewSignLayout["LayoutFinalConfirm"] = 2] = "LayoutFinalConfirm";
|
|
1682
|
+
ViewSignLayout[ViewSignLayout["Layout7702"] = 3] = "Layout7702";
|
|
1683
|
+
ViewSignLayout[ViewSignLayout["LayoutFlat"] = 4] = "LayoutFlat";
|
|
1684
|
+
ViewSignLayout[ViewSignLayout["LayoutEthApprove"] = 5] = "LayoutEthApprove";
|
|
1685
|
+
})(exports.ViewSignLayout || (exports.ViewSignLayout = {}));
|
|
1686
|
+
exports.DeviceErrorCode = void 0;
|
|
1687
|
+
(function (DeviceErrorCode) {
|
|
1688
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_None"] = 0] = "DeviceError_None";
|
|
1689
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_Busy"] = 1] = "DeviceError_Busy";
|
|
1690
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_NotInitialized"] = 2] = "DeviceError_NotInitialized";
|
|
1691
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_ActionCancelled"] = 3] = "DeviceError_ActionCancelled";
|
|
1692
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_PinAlreadyUsed"] = 4] = "DeviceError_PinAlreadyUsed";
|
|
1693
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_PersistFailed"] = 5] = "DeviceError_PersistFailed";
|
|
1694
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_SeError"] = 6] = "DeviceError_SeError";
|
|
1695
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_InvalidLanguage"] = 7] = "DeviceError_InvalidLanguage";
|
|
1696
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_WallpaperNotUsable"] = 8] = "DeviceError_WallpaperNotUsable";
|
|
1697
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_DeviceLocked"] = 9] = "DeviceError_DeviceLocked";
|
|
1698
|
+
})(exports.DeviceErrorCode || (exports.DeviceErrorCode = {}));
|
|
1699
|
+
exports.DeviceRebootType = void 0;
|
|
1700
|
+
(function (DeviceRebootType) {
|
|
1701
|
+
DeviceRebootType[DeviceRebootType["Normal"] = 0] = "Normal";
|
|
1702
|
+
DeviceRebootType[DeviceRebootType["Romloader"] = 1] = "Romloader";
|
|
1703
|
+
DeviceRebootType[DeviceRebootType["Bootloader"] = 2] = "Bootloader";
|
|
1704
|
+
})(exports.DeviceRebootType || (exports.DeviceRebootType = {}));
|
|
1705
|
+
exports.DeviceSettingsPage = void 0;
|
|
1706
|
+
(function (DeviceSettingsPage) {
|
|
1707
|
+
DeviceSettingsPage[DeviceSettingsPage["DeviceReset"] = 0] = "DeviceReset";
|
|
1708
|
+
DeviceSettingsPage[DeviceSettingsPage["DevicePinChange"] = 1] = "DevicePinChange";
|
|
1709
|
+
DeviceSettingsPage[DeviceSettingsPage["DevicePassphrase"] = 2] = "DevicePassphrase";
|
|
1710
|
+
DeviceSettingsPage[DeviceSettingsPage["DeviceAirgap"] = 3] = "DeviceAirgap";
|
|
1711
|
+
})(exports.DeviceSettingsPage || (exports.DeviceSettingsPage = {}));
|
|
1712
|
+
exports.DeviceFirmwareTargetType = void 0;
|
|
1713
|
+
(function (DeviceFirmwareTargetType) {
|
|
1714
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_INVALID"] = 0] = "FW_MGMT_TARGET_INVALID";
|
|
1715
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_CRATE"] = 1] = "FW_MGMT_TARGET_CRATE";
|
|
1716
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_ROMLOADER"] = 2] = "FW_MGMT_TARGET_ROMLOADER";
|
|
1717
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_BOOTLOADER"] = 3] = "FW_MGMT_TARGET_BOOTLOADER";
|
|
1718
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_APPLICATION_P1"] = 4] = "FW_MGMT_TARGET_APPLICATION_P1";
|
|
1719
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_APPLICATION_P2"] = 5] = "FW_MGMT_TARGET_APPLICATION_P2";
|
|
1720
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_COPROCESSOR"] = 6] = "FW_MGMT_TARGET_COPROCESSOR";
|
|
1721
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE01"] = 7] = "FW_MGMT_TARGET_SE01";
|
|
1722
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE02"] = 8] = "FW_MGMT_TARGET_SE02";
|
|
1723
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE03"] = 9] = "FW_MGMT_TARGET_SE03";
|
|
1724
|
+
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_SE04"] = 10] = "FW_MGMT_TARGET_SE04";
|
|
1725
|
+
})(exports.DeviceFirmwareTargetType || (exports.DeviceFirmwareTargetType = {}));
|
|
1726
|
+
exports.DeviceFirmwareUpdateTaskStatus = void 0;
|
|
1727
|
+
(function (DeviceFirmwareUpdateTaskStatus) {
|
|
1728
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_PENDING"] = 0] = "FW_MGMT_UPDATER_TASK_STATUS_PENDING";
|
|
1729
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS"] = 1] = "FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS";
|
|
1730
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FINISHED"] = 2] = "FW_MGMT_UPDATER_TASK_STATUS_FINISHED";
|
|
1731
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND"] = 3] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND";
|
|
1732
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ"] = 4] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ";
|
|
1733
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE"] = 5] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE";
|
|
1734
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY"] = 6] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY";
|
|
1735
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL"] = 7] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL";
|
|
1736
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT"] = 8] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT";
|
|
1737
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY"] = 9] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY";
|
|
1738
|
+
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS"] = 10] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS";
|
|
1739
|
+
})(exports.DeviceFirmwareUpdateTaskStatus || (exports.DeviceFirmwareUpdateTaskStatus = {}));
|
|
1740
|
+
exports.DeviceFactoryAck = void 0;
|
|
1741
|
+
(function (DeviceFactoryAck) {
|
|
1742
|
+
DeviceFactoryAck[DeviceFactoryAck["FACTORY_ACK_SUCCESS"] = 0] = "FACTORY_ACK_SUCCESS";
|
|
1743
|
+
DeviceFactoryAck[DeviceFactoryAck["FACTORY_ACK_FAIL"] = 1] = "FACTORY_ACK_FAIL";
|
|
1744
|
+
})(exports.DeviceFactoryAck || (exports.DeviceFactoryAck = {}));
|
|
1745
|
+
exports.DeviceType = void 0;
|
|
1746
|
+
(function (DeviceType) {
|
|
1747
|
+
DeviceType[DeviceType["CLASSIC1"] = 0] = "CLASSIC1";
|
|
1748
|
+
DeviceType[DeviceType["CLASSIC1S"] = 1] = "CLASSIC1S";
|
|
1749
|
+
DeviceType[DeviceType["MINI"] = 2] = "MINI";
|
|
1750
|
+
DeviceType[DeviceType["TOUCH"] = 3] = "TOUCH";
|
|
1751
|
+
DeviceType[DeviceType["PRO"] = 5] = "PRO";
|
|
1752
|
+
DeviceType[DeviceType["CLASSIC1S_PURE"] = 6] = "CLASSIC1S_PURE";
|
|
1753
|
+
DeviceType[DeviceType["PRO2"] = 7] = "PRO2";
|
|
1754
|
+
DeviceType[DeviceType["NEO"] = 8] = "NEO";
|
|
1755
|
+
})(exports.DeviceType || (exports.DeviceType = {}));
|
|
1756
|
+
exports.DeviceSeType = void 0;
|
|
1757
|
+
(function (DeviceSeType) {
|
|
1758
|
+
DeviceSeType[DeviceSeType["THD89"] = 0] = "THD89";
|
|
1759
|
+
DeviceSeType[DeviceSeType["SE608A"] = 1] = "SE608A";
|
|
1760
|
+
})(exports.DeviceSeType || (exports.DeviceSeType = {}));
|
|
1761
|
+
exports.DeviceSEState = void 0;
|
|
1762
|
+
(function (DeviceSEState) {
|
|
1763
|
+
DeviceSEState[DeviceSEState["BOOT"] = 0] = "BOOT";
|
|
1764
|
+
DeviceSEState[DeviceSEState["APP_FACTORY"] = 51] = "APP_FACTORY";
|
|
1765
|
+
DeviceSEState[DeviceSEState["APP"] = 85] = "APP";
|
|
1766
|
+
})(exports.DeviceSEState || (exports.DeviceSEState = {}));
|
|
1767
|
+
exports.DeviceSessionOpen_FailureSubCodes = void 0;
|
|
1768
|
+
(function (DeviceSessionOpen_FailureSubCodes) {
|
|
1769
|
+
DeviceSessionOpen_FailureSubCodes[DeviceSessionOpen_FailureSubCodes["InvalidSession"] = 1] = "InvalidSession";
|
|
1770
|
+
})(exports.DeviceSessionOpen_FailureSubCodes || (exports.DeviceSessionOpen_FailureSubCodes = {}));
|
|
1771
|
+
exports.DeviceSessionAskPin_FailureSubCodes = void 0;
|
|
1772
|
+
(function (DeviceSessionAskPin_FailureSubCodes) {
|
|
1773
|
+
DeviceSessionAskPin_FailureSubCodes[DeviceSessionAskPin_FailureSubCodes["UserCancel"] = 1] = "UserCancel";
|
|
1774
|
+
})(exports.DeviceSessionAskPin_FailureSubCodes || (exports.DeviceSessionAskPin_FailureSubCodes = {}));
|
|
1775
|
+
exports.DevOnboardingStep = void 0;
|
|
1776
|
+
(function (DevOnboardingStep) {
|
|
1777
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_UNKNOWN"] = 0] = "DEV_ONBOARDING_STEP_UNKNOWN";
|
|
1778
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_CHECKING"] = 1] = "DEV_ONBOARDING_STEP_CHECKING";
|
|
1779
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_PERSONALIZATION"] = 2] = "DEV_ONBOARDING_STEP_PERSONALIZATION";
|
|
1780
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_PIN"] = 3] = "DEV_ONBOARDING_STEP_PIN";
|
|
1781
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_SETUP"] = 4] = "DEV_ONBOARDING_STEP_SETUP";
|
|
1782
|
+
DevOnboardingStep[DevOnboardingStep["DEV_ONBOARDING_STEP_DONE"] = 5] = "DEV_ONBOARDING_STEP_DONE";
|
|
1783
|
+
})(exports.DevOnboardingStep || (exports.DevOnboardingStep = {}));
|
|
1784
|
+
exports.DevOnboardingPhase = void 0;
|
|
1785
|
+
(function (DevOnboardingPhase) {
|
|
1786
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_UNKNOWN"] = 0] = "DEV_ONBOARDING_PHASE_UNKNOWN";
|
|
1787
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SAFETY_CHECK"] = 1] = "DEV_ONBOARDING_PHASE_SAFETY_CHECK";
|
|
1788
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_PIN_SETUP"] = 2] = "DEV_ONBOARDING_PHASE_PIN_SETUP";
|
|
1789
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_FINGERPRINT_SETUP"] = 3] = "DEV_ONBOARDING_PHASE_FINGERPRINT_SETUP";
|
|
1790
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SETUP_CHOICE"] = 4] = "DEV_ONBOARDING_PHASE_SETUP_CHOICE";
|
|
1791
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_WALLET_CREATE_START"] = 5] = "DEV_ONBOARDING_PHASE_WALLET_CREATE_START";
|
|
1792
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW"] = 6] = "DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW";
|
|
1793
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM"] = 7] = "DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM";
|
|
1794
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_RESTORE_METHOD_CHOICE"] = 8] = "DEV_ONBOARDING_PHASE_RESTORE_METHOD_CHOICE";
|
|
1795
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE"] = 9] = "DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE";
|
|
1796
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SEEDCARD_RESTORE"] = 10] = "DEV_ONBOARDING_PHASE_SEEDCARD_RESTORE";
|
|
1797
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_WALLET_READY"] = 11] = "DEV_ONBOARDING_PHASE_WALLET_READY";
|
|
1798
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT"] = 12] = "DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT";
|
|
1799
|
+
DevOnboardingPhase[DevOnboardingPhase["DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP"] = 13] = "DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP";
|
|
1800
|
+
})(exports.DevOnboardingPhase || (exports.DevOnboardingPhase = {}));
|
|
1801
|
+
exports.DevOnboardingSetupKind = void 0;
|
|
1802
|
+
(function (DevOnboardingSetupKind) {
|
|
1803
|
+
DevOnboardingSetupKind[DevOnboardingSetupKind["DEV_ONBOARDING_SETUP_KIND_UNKNOWN"] = 0] = "DEV_ONBOARDING_SETUP_KIND_UNKNOWN";
|
|
1804
|
+
DevOnboardingSetupKind[DevOnboardingSetupKind["DEV_ONBOARDING_SETUP_KIND_CHOICE"] = 1] = "DEV_ONBOARDING_SETUP_KIND_CHOICE";
|
|
1805
|
+
DevOnboardingSetupKind[DevOnboardingSetupKind["DEV_ONBOARDING_SETUP_KIND_CREATE"] = 2] = "DEV_ONBOARDING_SETUP_KIND_CREATE";
|
|
1806
|
+
DevOnboardingSetupKind[DevOnboardingSetupKind["DEV_ONBOARDING_SETUP_KIND_RESTORE"] = 3] = "DEV_ONBOARDING_SETUP_KIND_RESTORE";
|
|
1807
|
+
})(exports.DevOnboardingSetupKind || (exports.DevOnboardingSetupKind = {}));
|
|
1808
|
+
exports.DevOnboardingSetupMethod = void 0;
|
|
1809
|
+
(function (DevOnboardingSetupMethod) {
|
|
1810
|
+
DevOnboardingSetupMethod[DevOnboardingSetupMethod["DEV_ONBOARDING_SETUP_METHOD_UNKNOWN"] = 0] = "DEV_ONBOARDING_SETUP_METHOD_UNKNOWN";
|
|
1811
|
+
DevOnboardingSetupMethod[DevOnboardingSetupMethod["DEV_ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE"] = 1] = "DEV_ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE";
|
|
1812
|
+
DevOnboardingSetupMethod[DevOnboardingSetupMethod["DEV_ONBOARDING_SETUP_METHOD_SEEDCARD"] = 2] = "DEV_ONBOARDING_SETUP_METHOD_SEEDCARD";
|
|
1813
|
+
})(exports.DevOnboardingSetupMethod || (exports.DevOnboardingSetupMethod = {}));
|
|
1814
|
+
exports.ProtocolV2FailureType = void 0;
|
|
1815
|
+
(function (ProtocolV2FailureType) {
|
|
1816
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_InvalidMessage"] = 1] = "Failure_InvalidMessage";
|
|
1817
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_UndefinedError"] = 2] = "Failure_UndefinedError";
|
|
1818
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_UsageError"] = 3] = "Failure_UsageError";
|
|
1819
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_DataError"] = 4] = "Failure_DataError";
|
|
1820
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_ProcessError"] = 5] = "Failure_ProcessError";
|
|
1821
|
+
})(exports.ProtocolV2FailureType || (exports.ProtocolV2FailureType = {}));
|
|
1822
|
+
exports.Enum_ProtocolV2Capability = void 0;
|
|
1823
|
+
(function (Enum_ProtocolV2Capability) {
|
|
1824
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Bitcoin"] = 1] = "Capability_Bitcoin";
|
|
1825
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Bitcoin_like"] = 2] = "Capability_Bitcoin_like";
|
|
1826
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Binance"] = 3] = "Capability_Binance";
|
|
1827
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Cardano"] = 4] = "Capability_Cardano";
|
|
1828
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Crypto"] = 5] = "Capability_Crypto";
|
|
1829
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_EOS"] = 6] = "Capability_EOS";
|
|
1830
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Ethereum"] = 7] = "Capability_Ethereum";
|
|
1831
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Lisk"] = 8] = "Capability_Lisk";
|
|
1832
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Monero"] = 9] = "Capability_Monero";
|
|
1833
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_NEM"] = 10] = "Capability_NEM";
|
|
1834
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Ripple"] = 11] = "Capability_Ripple";
|
|
1835
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Stellar"] = 12] = "Capability_Stellar";
|
|
1836
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Tezos"] = 13] = "Capability_Tezos";
|
|
1837
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_U2F"] = 14] = "Capability_U2F";
|
|
1838
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Shamir"] = 15] = "Capability_Shamir";
|
|
1839
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_ShamirGroups"] = 16] = "Capability_ShamirGroups";
|
|
1840
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_PassphraseEntry"] = 17] = "Capability_PassphraseEntry";
|
|
1841
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_AttachToPin"] = 18] = "Capability_AttachToPin";
|
|
1842
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_EthereumTypedData"] = 1000] = "Capability_EthereumTypedData";
|
|
1843
|
+
})(exports.Enum_ProtocolV2Capability || (exports.Enum_ProtocolV2Capability = {}));
|
|
888
1844
|
|
|
889
1845
|
var messages = /*#__PURE__*/Object.freeze({
|
|
890
1846
|
__proto__: null,
|
|
@@ -950,28 +1906,89 @@ var messages = /*#__PURE__*/Object.freeze({
|
|
|
950
1906
|
get TonSignDataType () { return exports.TonSignDataType; },
|
|
951
1907
|
get TronResourceCode () { return exports.TronResourceCode; },
|
|
952
1908
|
get TronMessageType () { return exports.TronMessageType; },
|
|
953
|
-
get CommandFlags () { return exports.CommandFlags; }
|
|
1909
|
+
get CommandFlags () { return exports.CommandFlags; },
|
|
1910
|
+
get WallpaperTarget () { return exports.WallpaperTarget; },
|
|
1911
|
+
get MoneroNetworkType () { return exports.MoneroNetworkType; },
|
|
1912
|
+
get ViewTipType () { return exports.ViewTipType; },
|
|
1913
|
+
get ViewSignLayout () { return exports.ViewSignLayout; },
|
|
1914
|
+
get DeviceErrorCode () { return exports.DeviceErrorCode; },
|
|
1915
|
+
get DeviceRebootType () { return exports.DeviceRebootType; },
|
|
1916
|
+
get DeviceSettingsPage () { return exports.DeviceSettingsPage; },
|
|
1917
|
+
get DeviceFirmwareTargetType () { return exports.DeviceFirmwareTargetType; },
|
|
1918
|
+
get DeviceFirmwareUpdateTaskStatus () { return exports.DeviceFirmwareUpdateTaskStatus; },
|
|
1919
|
+
get DeviceFactoryAck () { return exports.DeviceFactoryAck; },
|
|
1920
|
+
get DeviceType () { return exports.DeviceType; },
|
|
1921
|
+
get DeviceSeType () { return exports.DeviceSeType; },
|
|
1922
|
+
get DeviceSEState () { return exports.DeviceSEState; },
|
|
1923
|
+
get DeviceSessionOpen_FailureSubCodes () { return exports.DeviceSessionOpen_FailureSubCodes; },
|
|
1924
|
+
get DeviceSessionAskPin_FailureSubCodes () { return exports.DeviceSessionAskPin_FailureSubCodes; },
|
|
1925
|
+
get DevOnboardingStep () { return exports.DevOnboardingStep; },
|
|
1926
|
+
get DevOnboardingPhase () { return exports.DevOnboardingPhase; },
|
|
1927
|
+
get DevOnboardingSetupKind () { return exports.DevOnboardingSetupKind; },
|
|
1928
|
+
get DevOnboardingSetupMethod () { return exports.DevOnboardingSetupMethod; },
|
|
1929
|
+
get ProtocolV2FailureType () { return exports.ProtocolV2FailureType; },
|
|
1930
|
+
get Enum_ProtocolV2Capability () { return exports.Enum_ProtocolV2Capability; }
|
|
954
1931
|
});
|
|
955
1932
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
protobuf__namespace.util.Long = Long__namespace;
|
|
1933
|
+
protobuf__namespace.util.Long = Long__default["default"];
|
|
959
1934
|
protobuf__namespace.configure();
|
|
960
1935
|
var index = {
|
|
961
1936
|
check,
|
|
962
|
-
buildOne,
|
|
963
|
-
buildBuffers,
|
|
964
|
-
buildEncodeBuffers,
|
|
965
|
-
receiveOne,
|
|
966
1937
|
parseConfigure,
|
|
967
|
-
|
|
1938
|
+
protocolV2: protocolV2Codec,
|
|
1939
|
+
ProtocolV1,
|
|
1940
|
+
ProtocolV2,
|
|
1941
|
+
PROTOCOL_V2_SYS_MESSAGE_THRESHOLD,
|
|
1942
|
+
ProtocolV2FrameAssembler,
|
|
1943
|
+
ProtocolV2LinkManager,
|
|
1944
|
+
ProtocolV2SequenceCursor,
|
|
1945
|
+
ProtocolV2Session,
|
|
1946
|
+
ProtocolV2UsbTransportBase,
|
|
1947
|
+
bytesToHex,
|
|
1948
|
+
concatUint8Arrays,
|
|
1949
|
+
createMessageFromName,
|
|
1950
|
+
createMessageFromType,
|
|
1951
|
+
encodeProtobuf: encode,
|
|
1952
|
+
decodeProtobuf: decode,
|
|
1953
|
+
getErrorMessage,
|
|
1954
|
+
hexToBytes,
|
|
1955
|
+
probeProtocolV2,
|
|
1956
|
+
withProtocolTimeout,
|
|
968
1957
|
};
|
|
969
1958
|
|
|
970
|
-
exports.BUFFER_SIZE = BUFFER_SIZE;
|
|
971
|
-
exports.COMMON_HEADER_SIZE = COMMON_HEADER_SIZE;
|
|
972
|
-
exports.HEADER_SIZE = HEADER_SIZE;
|
|
973
1959
|
exports.LogBlockCommand = LogBlockCommand;
|
|
974
|
-
exports.MESSAGE_HEADER_BYTE = MESSAGE_HEADER_BYTE;
|
|
975
|
-
exports.MESSAGE_TOP_CHAR = MESSAGE_TOP_CHAR;
|
|
976
1960
|
exports.Messages = messages;
|
|
1961
|
+
exports.PROTOCOL_V1_CHUNK_PAYLOAD_SIZE = PROTOCOL_V1_CHUNK_PAYLOAD_SIZE;
|
|
1962
|
+
exports.PROTOCOL_V1_ENVELOPE_HEADER_SIZE = PROTOCOL_V1_ENVELOPE_HEADER_SIZE;
|
|
1963
|
+
exports.PROTOCOL_V1_HEADER_BYTE = PROTOCOL_V1_HEADER_BYTE;
|
|
1964
|
+
exports.PROTOCOL_V1_MESSAGE_HEADER_SIZE = PROTOCOL_V1_MESSAGE_HEADER_SIZE;
|
|
1965
|
+
exports.PROTOCOL_V1_REPORT_ID = PROTOCOL_V1_REPORT_ID;
|
|
1966
|
+
exports.PROTOCOL_V1_USB_PACKET_SIZE = PROTOCOL_V1_USB_PACKET_SIZE;
|
|
1967
|
+
exports.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE = PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
|
|
1968
|
+
exports.PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE = PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE;
|
|
1969
|
+
exports.PROTOCOL_V2_BLE_FRAME_MAX_BYTES = PROTOCOL_V2_BLE_FRAME_MAX_BYTES;
|
|
1970
|
+
exports.PROTOCOL_V2_CHANNEL_BLE_UART = PROTOCOL_V2_CHANNEL_BLE_UART;
|
|
1971
|
+
exports.PROTOCOL_V2_CHANNEL_SOCKET = PROTOCOL_V2_CHANNEL_SOCKET;
|
|
1972
|
+
exports.PROTOCOL_V2_CHANNEL_USB = PROTOCOL_V2_CHANNEL_USB;
|
|
1973
|
+
exports.PROTOCOL_V2_FILE_CHUNK_SIZE = PROTOCOL_V2_FILE_CHUNK_SIZE;
|
|
1974
|
+
exports.PROTOCOL_V2_FRAME_MAX_BYTES = PROTOCOL_V2_FRAME_MAX_BYTES;
|
|
1975
|
+
exports.PROTOCOL_V2_PACKET_SRC_COMMAND = PROTOCOL_V2_PACKET_SRC_COMMAND;
|
|
1976
|
+
exports.PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = PROTOCOL_V2_SYS_MESSAGE_THRESHOLD;
|
|
1977
|
+
exports.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
1978
|
+
exports.PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS = PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS;
|
|
1979
|
+
exports.ProtocolV1 = ProtocolV1;
|
|
1980
|
+
exports.ProtocolV2 = ProtocolV2;
|
|
1981
|
+
exports.ProtocolV2FrameAssembler = ProtocolV2FrameAssembler;
|
|
1982
|
+
exports.ProtocolV2LinkManager = ProtocolV2LinkManager;
|
|
1983
|
+
exports.ProtocolV2SequenceCursor = ProtocolV2SequenceCursor;
|
|
1984
|
+
exports.ProtocolV2Session = ProtocolV2Session;
|
|
1985
|
+
exports.ProtocolV2UsbTransportBase = ProtocolV2UsbTransportBase;
|
|
1986
|
+
exports.bytesToHex = bytesToHex;
|
|
1987
|
+
exports.concatUint8Arrays = concatUint8Arrays;
|
|
977
1988
|
exports["default"] = index;
|
|
1989
|
+
exports.getErrorMessage = getErrorMessage;
|
|
1990
|
+
exports.hexToBytes = hexToBytes;
|
|
1991
|
+
exports.probeProtocolV2 = probeProtocolV2;
|
|
1992
|
+
exports.protocolV1 = index$1;
|
|
1993
|
+
exports.protocolV2 = protocolV2Codec;
|
|
1994
|
+
exports.withProtocolTimeout = withProtocolTimeout;
|