@onekeyfe/hd-transport 1.2.0-alpha.9 → 1.2.0-alpha.91
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__/messages.test.js +169 -11
- package/__tests__/protocol-v2-ble-frame-writer.test.js +119 -0
- package/__tests__/protocol-v2-link-manager.test.js +120 -9
- package/__tests__/protocol-v2-usb-transport-base.test.js +36 -2
- package/__tests__/protocol-v2.test.js +438 -64
- package/__tests__/transport-log.test.js +79 -0
- package/dist/constants.d.ts +3 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +707 -242
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +597 -296
- package/dist/protocols/index.d.ts +13 -6
- package/dist/protocols/index.d.ts.map +1 -1
- package/dist/protocols/v2/ble-frame-writer.d.ts +15 -0
- package/dist/protocols/v2/ble-frame-writer.d.ts.map +1 -0
- package/dist/protocols/v2/decode.d.ts +12 -2
- package/dist/protocols/v2/decode.d.ts.map +1 -1
- package/dist/protocols/v2/encode.d.ts +2 -3
- package/dist/protocols/v2/encode.d.ts.map +1 -1
- package/dist/protocols/v2/errors.d.ts +8 -0
- package/dist/protocols/v2/errors.d.ts.map +1 -0
- package/dist/protocols/v2/frame-assembler.d.ts.map +1 -1
- package/dist/protocols/v2/index.d.ts +2 -1
- package/dist/protocols/v2/index.d.ts.map +1 -1
- package/dist/protocols/v2/link-manager.d.ts +4 -0
- package/dist/protocols/v2/link-manager.d.ts.map +1 -1
- package/dist/protocols/v2/session.d.ts +10 -4
- package/dist/protocols/v2/session.d.ts.map +1 -1
- package/dist/protocols/v2/usb-transport-base.d.ts +1 -0
- package/dist/protocols/v2/usb-transport-base.d.ts.map +1 -1
- package/dist/serialization/protobuf/decode.d.ts.map +1 -1
- package/dist/serialization/protobuf/encode.d.ts.map +1 -1
- package/dist/types/messages.d.ts +370 -144
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/transport.d.ts +20 -3
- package/dist/types/transport.d.ts.map +1 -1
- package/dist/utils/transportLog.d.ts +9 -0
- package/dist/utils/transportLog.d.ts.map +1 -0
- package/messages-protocol-v2.json +1113 -547
- package/package.json +3 -3
- package/scripts/protobuf-build.sh +85 -253
- package/scripts/protobuf-patches/index.js +1 -0
- package/scripts/protobuf-types.js +19 -1
- package/src/constants.ts +30 -16
- package/src/index.ts +5 -1
- package/src/protocols/index.ts +37 -40
- package/src/protocols/v2/ble-frame-writer.ts +77 -0
- package/src/protocols/v2/crc8.ts +1 -1
- package/src/protocols/v2/decode.ts +50 -35
- package/src/protocols/v2/encode.ts +2 -28
- package/src/protocols/v2/errors.ts +25 -0
- package/src/protocols/v2/frame-assembler.ts +6 -4
- package/src/protocols/v2/index.ts +2 -1
- package/src/protocols/v2/link-manager.ts +54 -5
- package/src/protocols/v2/session.ts +151 -200
- package/src/protocols/v2/usb-transport-base.ts +29 -10
- package/src/serialization/protobuf/decode.ts +4 -1
- package/src/serialization/protobuf/encode.ts +5 -1
- package/src/types/messages.ts +450 -185
- package/src/types/transport.ts +28 -3
- package/src/utils/transportLog.ts +102 -0
- package/dist/protocols/v2/debug.d.ts +0 -13
- package/dist/protocols/v2/debug.d.ts.map +0 -1
- package/src/protocols/v2/debug.ts +0 -26
package/dist/index.js
CHANGED
|
@@ -140,7 +140,7 @@ function messageToJSON(Message, fields) {
|
|
|
140
140
|
res[key] = field.resolvedType.valuesById[value];
|
|
141
141
|
}
|
|
142
142
|
else if (field.resolvedType.fields) {
|
|
143
|
-
res[key] = messageToJSON(value, field.resolvedType.fields);
|
|
143
|
+
res[key] = value == null ? null : messageToJSON(value, field.resolvedType.fields);
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
146
|
throw new Error(`case not handled: ${key}`);
|
|
@@ -200,7 +200,10 @@ function patch(Message, payload) {
|
|
|
200
200
|
}
|
|
201
201
|
if (field.repeated) {
|
|
202
202
|
const RefMessage = Message.lookupTypeOrEnum(field.type);
|
|
203
|
-
patched[key] =
|
|
203
|
+
patched[key] =
|
|
204
|
+
RefMessage instanceof protobuf.Enum
|
|
205
|
+
? value.map((v) => transform(field.type, v))
|
|
206
|
+
: value.map((v) => patch(RefMessage, v));
|
|
204
207
|
}
|
|
205
208
|
else if (typeof value === 'object' && value !== null) {
|
|
206
209
|
const RefMessage = Message.lookupType(field.type);
|
|
@@ -267,9 +270,10 @@ const PROTOCOL_V1_CHUNK_PAYLOAD_SIZE = 63;
|
|
|
267
270
|
const PROTOCOL_V1_USB_PACKET_SIZE = PROTOCOL_V1_CHUNK_PAYLOAD_SIZE + 1;
|
|
268
271
|
const PROTOCOL_V1_MESSAGE_HEADER_SIZE = 2 + 4;
|
|
269
272
|
const PROTOCOL_V1_ENVELOPE_HEADER_SIZE = 1 + 1 + PROTOCOL_V1_MESSAGE_HEADER_SIZE;
|
|
270
|
-
const PROTOCOL_V2_FRAME_MAX_BYTES =
|
|
273
|
+
const PROTOCOL_V2_FRAME_MAX_BYTES = 4200;
|
|
271
274
|
const PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE = 4000;
|
|
272
275
|
const PROTOCOL_V2_BLE_FILE_CHUNK_SIZE = 1800;
|
|
276
|
+
const PROTOCOL_V2_BLE_FIRMWARE_FILE_CHUNK_SIZE = 1960;
|
|
273
277
|
const PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE = 900;
|
|
274
278
|
const PROTOCOL_V2_BLE_FRAME_MAX_BYTES = 2048;
|
|
275
279
|
const PROTOCOL_V2_FILE_CHUNK_SIZE = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
@@ -277,6 +281,7 @@ const PROTOCOL_V2_CHANNEL_USB = 0;
|
|
|
277
281
|
const PROTOCOL_V2_CHANNEL_BLE_UART = 1;
|
|
278
282
|
const PROTOCOL_V2_CHANNEL_SOCKET = 2;
|
|
279
283
|
const PROTOCOL_V2_PACKET_SRC_COMMAND = 0;
|
|
284
|
+
const PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS = 5 * 60 * 1000;
|
|
280
285
|
|
|
281
286
|
function encodeEnvelope(data, options) {
|
|
282
287
|
const { addTrezorHeaders, chunked, messageTypeId } = options;
|
|
@@ -411,16 +416,11 @@ function crc8(data, len) {
|
|
|
411
416
|
return crc;
|
|
412
417
|
}
|
|
413
418
|
|
|
414
|
-
function logProtocolV2Debug(options, stage, details) {
|
|
415
|
-
var _a, _b, _c;
|
|
416
|
-
(_b = (_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, `[${(_c = options.logPrefix) !== null && _c !== void 0 ? _c : 'ProtocolV2'}] ${stage}`, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.context ? { context: options.context } : {})), (options.messageName ? { messageName: options.messageName } : {})), (options.messageTypeId !== undefined ? { messageTypeId: options.messageTypeId } : {})), (options.pbPayloadLength !== undefined ? { pbPayloadLength: options.pbPayloadLength } : {})), details));
|
|
417
|
-
}
|
|
418
|
-
|
|
419
419
|
const PROTO_SEQ_DEFAULT = 1;
|
|
420
420
|
function nextProtoSeq(current) {
|
|
421
421
|
return current >= 255 ? 1 : current + 1;
|
|
422
422
|
}
|
|
423
|
-
function encodeFrame(payload, packetSrc, router,
|
|
423
|
+
function encodeFrame(payload, packetSrc, router, seq) {
|
|
424
424
|
const resolvedPacketSrc = packetSrc !== null && packetSrc !== void 0 ? packetSrc : 0;
|
|
425
425
|
const resolvedRouter = router !== null && router !== void 0 ? router : 0;
|
|
426
426
|
const resolvedSeq = seq !== null && seq !== void 0 ? seq : PROTO_SEQ_DEFAULT;
|
|
@@ -430,7 +430,7 @@ function encodeFrame(payload, packetSrc, router, debugOptions, seq) {
|
|
|
430
430
|
const payloadLen = payload ? payload.length : 0;
|
|
431
431
|
const frameLen = payloadLen + PROTO_HEAD_CRC_SIZE;
|
|
432
432
|
if (frameLen > PROTOCOL_V2_FRAME_MAX_BYTES) {
|
|
433
|
-
throw new Error(`Protocol V2 frame too large: ${frameLen}`);
|
|
433
|
+
throw new Error(`Protocol V2 frame too large: ${frameLen} > ${PROTOCOL_V2_FRAME_MAX_BYTES}`);
|
|
434
434
|
}
|
|
435
435
|
const frame = new Uint8Array(frameLen);
|
|
436
436
|
frame[0] = PROTO_HEAD_SOF;
|
|
@@ -445,27 +445,17 @@ function encodeFrame(payload, packetSrc, router, debugOptions, seq) {
|
|
|
445
445
|
frame.set(payload, 7);
|
|
446
446
|
}
|
|
447
447
|
frame[frameLen - 1] = crc8(frame, frameLen - 1);
|
|
448
|
-
logProtocolV2Debug(debugOptions, 'encode raw frame', {
|
|
449
|
-
frameLen,
|
|
450
|
-
payloadLen,
|
|
451
|
-
packetSrc: resolvedPacketSrc,
|
|
452
|
-
router: frame[4],
|
|
453
|
-
attr: frame[5],
|
|
454
|
-
seq: frame[6],
|
|
455
|
-
headerCrc: frame[3],
|
|
456
|
-
frameCrc: frame[frameLen - 1],
|
|
457
|
-
});
|
|
458
448
|
return frame;
|
|
459
449
|
}
|
|
460
|
-
function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router,
|
|
450
|
+
function encodeProtobufFrame(messageTypeId, pbPayload, packetSrc, router, seq) {
|
|
461
451
|
const payload = new Uint8Array(2 + pbPayload.length);
|
|
462
452
|
payload[0] = messageTypeId % 256;
|
|
463
453
|
payload[1] = Math.floor(messageTypeId / 256) % 256;
|
|
464
454
|
payload.set(pbPayload, 2);
|
|
465
|
-
return encodeFrame(payload, packetSrc, router,
|
|
455
|
+
return encodeFrame(payload, packetSrc, router, seq);
|
|
466
456
|
}
|
|
467
457
|
|
|
468
|
-
function
|
|
458
|
+
function inspectFrameHeader(data) {
|
|
469
459
|
if (data.length < PROTO_HEAD_CRC_SIZE) {
|
|
470
460
|
throw new Error(`Protocol V2 frame too short: ${data.length} bytes`);
|
|
471
461
|
}
|
|
@@ -473,8 +463,8 @@ function validateFrame(data) {
|
|
|
473
463
|
throw new Error(`Invalid SOF byte: expected 0x5A, got 0x${data[0].toString(16).padStart(2, '0')}`);
|
|
474
464
|
}
|
|
475
465
|
const frameLen = data[1] + data[2] * 256;
|
|
476
|
-
if (data.length
|
|
477
|
-
throw new Error(`
|
|
466
|
+
if (data.length !== frameLen) {
|
|
467
|
+
throw new Error(`Protocol V2 frame length mismatch: expected ${frameLen} bytes, got ${data.length}`);
|
|
478
468
|
}
|
|
479
469
|
const expectedHeaderCrc = crc8(data, 3);
|
|
480
470
|
if (data[3] !== expectedHeaderCrc) {
|
|
@@ -488,45 +478,54 @@ function validateFrame(data) {
|
|
|
488
478
|
.toString(16)
|
|
489
479
|
.padStart(2, '0')}, got 0x${data[frameLen - 1].toString(16).padStart(2, '0')}`);
|
|
490
480
|
}
|
|
491
|
-
|
|
481
|
+
const dataType = data[5] & 0x03;
|
|
482
|
+
const packetSrc = (data[5] >> 2) & 0x0f;
|
|
483
|
+
const seq = data[6];
|
|
484
|
+
if (seq === 0) {
|
|
485
|
+
throw new Error('Invalid Protocol V2 sequence: 0 is reserved');
|
|
486
|
+
}
|
|
487
|
+
return {
|
|
488
|
+
frameLen,
|
|
489
|
+
router: data[4],
|
|
490
|
+
packetSrc,
|
|
491
|
+
dataType,
|
|
492
|
+
seq,
|
|
493
|
+
};
|
|
492
494
|
}
|
|
493
495
|
function isAckFrame(data) {
|
|
494
496
|
if (data.length < 6 || (data[5] & 0x03) !== PROTO_DATA_TYPE_ACK) {
|
|
495
497
|
return false;
|
|
496
498
|
}
|
|
497
|
-
const
|
|
498
|
-
if (frameLen !== PROTO_HEAD_CRC_SIZE) {
|
|
499
|
-
throw new Error(`Invalid Protocol V2 ACK frame length: ${frameLen}`);
|
|
499
|
+
const header = inspectFrameHeader(data);
|
|
500
|
+
if (header.frameLen !== PROTO_HEAD_CRC_SIZE) {
|
|
501
|
+
throw new Error(`Invalid Protocol V2 ACK frame length: ${header.frameLen}`);
|
|
500
502
|
}
|
|
501
503
|
return true;
|
|
502
504
|
}
|
|
503
|
-
function decodeFrame(data
|
|
504
|
-
const frameLen =
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
505
|
+
function decodeFrame(data) {
|
|
506
|
+
const { frameLen, router, packetSrc, dataType, seq } = inspectFrameHeader(data);
|
|
507
|
+
if (dataType !== PROTO_DATA_TYPE_PACKET) {
|
|
508
|
+
throw new Error(`Invalid Protocol V2 data type: expected packet, got ${dataType}`);
|
|
509
|
+
}
|
|
508
510
|
const payloadData = data.slice(7, frameLen - 1);
|
|
509
511
|
if (payloadData.length < 2) {
|
|
510
512
|
throw new Error(`Protocol V2 payload too short (need >=2 bytes for messageTypeId)`);
|
|
511
513
|
}
|
|
512
514
|
const messageTypeId = payloadData[0] + payloadData[1] * 256;
|
|
513
515
|
const pbPayload = payloadData.slice(2);
|
|
514
|
-
|
|
515
|
-
frameLen,
|
|
516
|
-
dataLength: data.length,
|
|
517
|
-
router: data[4],
|
|
518
|
-
attr: data[5],
|
|
519
|
-
seq,
|
|
520
|
-
headerCrc: data[3],
|
|
521
|
-
expectedHeaderCrc,
|
|
522
|
-
frameCrc: data[frameLen - 1],
|
|
523
|
-
expectedFrameCrc,
|
|
524
|
-
messageTypeId,
|
|
525
|
-
pbPayloadLength: pbPayload.length,
|
|
526
|
-
});
|
|
527
|
-
return { messageTypeId, pbPayload, seq };
|
|
516
|
+
return { messageTypeId, pbPayload, seq, router, packetSrc, dataType };
|
|
528
517
|
}
|
|
529
518
|
|
|
519
|
+
class ProtocolV2LinkError extends Error {
|
|
520
|
+
constructor(code, message, cause) {
|
|
521
|
+
super(message);
|
|
522
|
+
this.name = 'ProtocolV2LinkError';
|
|
523
|
+
this.code = code;
|
|
524
|
+
this.cause = cause;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const isProtocolV2LinkError = (error) => error instanceof ProtocolV2LinkError;
|
|
528
|
+
|
|
530
529
|
function concatUint8Arrays(arrays) {
|
|
531
530
|
const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);
|
|
532
531
|
const result = new Uint8Array(totalLength);
|
|
@@ -570,23 +569,23 @@ class ProtocolV2FrameAssembler {
|
|
|
570
569
|
return undefined;
|
|
571
570
|
if (this.buffer[0] !== PROTO_HEAD_SOF) {
|
|
572
571
|
this.reset();
|
|
573
|
-
throw new
|
|
572
|
+
throw new ProtocolV2LinkError('frame', 'Invalid Protocol V2 SOF');
|
|
574
573
|
}
|
|
575
574
|
const expectedLen = this.buffer[1] + this.buffer[2] * 256;
|
|
576
575
|
if (expectedLen < PROTO_HEAD_CRC_SIZE) {
|
|
577
576
|
this.reset();
|
|
578
|
-
throw new
|
|
577
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 frame length too small: ${expectedLen}`);
|
|
579
578
|
}
|
|
580
579
|
if (expectedLen > this.maxFrameBytes) {
|
|
581
580
|
this.reset();
|
|
582
|
-
throw new
|
|
581
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 frame too large: ${expectedLen}`);
|
|
583
582
|
}
|
|
584
583
|
if (this.buffer.length < PROTO_PRE_HEAD_SIZE)
|
|
585
584
|
return undefined;
|
|
586
585
|
const expectedHeaderCrc = crc8(this.buffer, 3);
|
|
587
586
|
if (this.buffer[3] !== expectedHeaderCrc) {
|
|
588
587
|
this.reset();
|
|
589
|
-
throw new
|
|
588
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 header CRC mismatch: expected 0x${expectedHeaderCrc
|
|
590
589
|
.toString(16)
|
|
591
590
|
.padStart(2, '0')}`);
|
|
592
591
|
}
|
|
@@ -598,6 +597,51 @@ class ProtocolV2FrameAssembler {
|
|
|
598
597
|
}
|
|
599
598
|
}
|
|
600
599
|
|
|
600
|
+
const defaultWait = (timeoutMs) => new Promise(resolve => {
|
|
601
|
+
setTimeout(resolve, timeoutMs);
|
|
602
|
+
});
|
|
603
|
+
function writeProtocolV2BleFrame({ frame, packetCapacity, writePacket, assertActive, signal, abortMessage = 'Protocol V2 BLE write aborted', initialDelayMs = 0, burstSize, burstPauseMs = 0, flushDelayMs = 0, wait = defaultWait, }) {
|
|
604
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
605
|
+
if (!Number.isInteger(packetCapacity) || packetCapacity <= 0) {
|
|
606
|
+
throw new Error('Protocol V2 BLE packet capacity must be a positive integer');
|
|
607
|
+
}
|
|
608
|
+
if (burstSize !== undefined && (!Number.isInteger(burstSize) || burstSize <= 0)) {
|
|
609
|
+
throw new Error('Protocol V2 BLE burst size must be a positive integer');
|
|
610
|
+
}
|
|
611
|
+
const assertWritable = () => {
|
|
612
|
+
assertActive === null || assertActive === void 0 ? void 0 : assertActive();
|
|
613
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
614
|
+
throw new Error(abortMessage);
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
if (frame.length > 0 && initialDelayMs > 0) {
|
|
618
|
+
assertWritable();
|
|
619
|
+
yield wait(initialDelayMs);
|
|
620
|
+
assertWritable();
|
|
621
|
+
}
|
|
622
|
+
let packetsWritten = 0;
|
|
623
|
+
for (let offset = 0; offset < frame.length; offset += packetCapacity) {
|
|
624
|
+
assertWritable();
|
|
625
|
+
const packet = frame.slice(offset, offset + packetCapacity);
|
|
626
|
+
yield writePacket(packet, packetsWritten);
|
|
627
|
+
packetsWritten += 1;
|
|
628
|
+
assertWritable();
|
|
629
|
+
const hasMorePackets = offset + packetCapacity < frame.length;
|
|
630
|
+
if (hasMorePackets &&
|
|
631
|
+
burstSize !== undefined &&
|
|
632
|
+
packetsWritten % burstSize === 0 &&
|
|
633
|
+
burstPauseMs > 0) {
|
|
634
|
+
yield wait(burstPauseMs);
|
|
635
|
+
assertWritable();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (burstSize !== undefined && packetsWritten > burstSize && flushDelayMs > 0) {
|
|
639
|
+
yield wait(flushDelayMs);
|
|
640
|
+
assertWritable();
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
|
|
601
645
|
var protocolV2Codec = /*#__PURE__*/Object.freeze({
|
|
602
646
|
__proto__: null,
|
|
603
647
|
PROTO_HEAD_SOF: PROTO_HEAD_SOF,
|
|
@@ -609,14 +653,17 @@ var protocolV2Codec = /*#__PURE__*/Object.freeze({
|
|
|
609
653
|
PROTO_DATA_TYPE_ACK: PROTO_DATA_TYPE_ACK,
|
|
610
654
|
CRC8_TABLE: CRC8_TABLE,
|
|
611
655
|
crc8: crc8,
|
|
612
|
-
logProtocolV2Debug: logProtocolV2Debug,
|
|
613
656
|
nextProtoSeq: nextProtoSeq,
|
|
614
657
|
encodeFrame: encodeFrame,
|
|
615
658
|
encodeProtobufFrame: encodeProtobufFrame,
|
|
659
|
+
inspectFrameHeader: inspectFrameHeader,
|
|
616
660
|
isAckFrame: isAckFrame,
|
|
617
661
|
decodeFrame: decodeFrame,
|
|
662
|
+
ProtocolV2LinkError: ProtocolV2LinkError,
|
|
663
|
+
isProtocolV2LinkError: isProtocolV2LinkError,
|
|
618
664
|
concatUint8Arrays: concatUint8Arrays,
|
|
619
|
-
ProtocolV2FrameAssembler: ProtocolV2FrameAssembler
|
|
665
|
+
ProtocolV2FrameAssembler: ProtocolV2FrameAssembler,
|
|
666
|
+
writeProtocolV2BleFrame: writeProtocolV2BleFrame
|
|
620
667
|
});
|
|
621
668
|
|
|
622
669
|
const PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = 60000;
|
|
@@ -665,46 +712,45 @@ const ProtocolV1 = {
|
|
|
665
712
|
};
|
|
666
713
|
const ProtocolV2 = {
|
|
667
714
|
isAckFrame,
|
|
715
|
+
inspectFrameHeader,
|
|
716
|
+
inspectFrame(schemas, frame) {
|
|
717
|
+
const { messageTypeId, pbPayload, seq, router, packetSrc, dataType } = decodeFrame(frame);
|
|
718
|
+
const { messageName } = createProtocolV2MessageFromType(messageTypeId, schemas);
|
|
719
|
+
return {
|
|
720
|
+
messageName,
|
|
721
|
+
messageTypeId,
|
|
722
|
+
pbPayload,
|
|
723
|
+
seq,
|
|
724
|
+
router,
|
|
725
|
+
packetSrc,
|
|
726
|
+
dataType,
|
|
727
|
+
type: messageName,
|
|
728
|
+
};
|
|
729
|
+
},
|
|
668
730
|
encodeFrame(schemas, name, data, options = {}) {
|
|
669
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
670
731
|
const encodeMessages = resolveProtocolV2EncodeSchema(name, schemas);
|
|
671
732
|
const { Message, messageTypeId } = createMessageFromName(encodeMessages, name);
|
|
672
733
|
const pbBuffer = encode(Message, data);
|
|
673
734
|
pbBuffer.reset();
|
|
674
735
|
const rawPbBuffer = pbBuffer.toBuffer();
|
|
675
736
|
const pbBytes = new Uint8Array(rawPbBuffer);
|
|
676
|
-
|
|
677
|
-
context: (_d = options.context) !== null && _d !== void 0 ? _d : `encode:${name}`,
|
|
678
|
-
messageName: name,
|
|
679
|
-
messageTypeId,
|
|
680
|
-
pbPayloadLength: pbBytes.length,
|
|
681
|
-
packetSrc: (_e = options.packetSrc) !== null && _e !== void 0 ? _e : 0,
|
|
682
|
-
router: (_f = options.router) !== null && _f !== void 0 ? _f : 0,
|
|
683
|
-
});
|
|
684
|
-
return encodeProtobufFrame(messageTypeId, pbBytes, options.packetSrc, options.router, {
|
|
685
|
-
logger: options.logger,
|
|
686
|
-
logPrefix: options.logPrefix,
|
|
687
|
-
context: (_g = options.context) !== null && _g !== void 0 ? _g : `encode:${name}`,
|
|
688
|
-
messageName: name,
|
|
689
|
-
}, options.seq);
|
|
737
|
+
return encodeProtobufFrame(messageTypeId, pbBytes, options.packetSrc, options.router, options.seq);
|
|
690
738
|
},
|
|
691
|
-
decodeFrame(schemas, frame
|
|
692
|
-
|
|
693
|
-
const {
|
|
694
|
-
logger: options.logger,
|
|
695
|
-
logPrefix: options.logPrefix,
|
|
696
|
-
context: (_a = options.context) !== null && _a !== void 0 ? _a : 'decode',
|
|
697
|
-
});
|
|
698
|
-
const { Message, messageName } = createProtocolV2MessageFromType(messageTypeId, schemas);
|
|
739
|
+
decodeFrame(schemas, frame) {
|
|
740
|
+
const { messageTypeId, pbPayload, seq, messageName } = this.inspectFrame(schemas, frame);
|
|
741
|
+
const { Message } = createProtocolV2MessageFromType(messageTypeId, schemas);
|
|
699
742
|
const rxByteBuffer = ByteBuffer__default["default"].wrap(Buffer.from(pbPayload));
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
743
|
+
let message;
|
|
744
|
+
try {
|
|
745
|
+
message = decode(Message, rxByteBuffer);
|
|
746
|
+
}
|
|
747
|
+
catch (cause) {
|
|
748
|
+
const error = new Error(`Protocol V2 protobuf decode failed for "${messageName}" ` +
|
|
749
|
+
`(${messageTypeId}, ${pbPayload.length}-byte payload); ` +
|
|
750
|
+
'the payload is malformed or incompatible with the active SDK schema.');
|
|
751
|
+
error.cause = cause;
|
|
752
|
+
throw error;
|
|
753
|
+
}
|
|
708
754
|
return {
|
|
709
755
|
message,
|
|
710
756
|
messageName,
|
|
@@ -853,93 +899,27 @@ function bytesToHex(bytes) {
|
|
|
853
899
|
.map(b => b.toString(16).padStart(2, '0'))
|
|
854
900
|
.join('');
|
|
855
901
|
}
|
|
856
|
-
const
|
|
857
|
-
const PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT = 20;
|
|
858
|
-
const PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT = 40;
|
|
859
|
-
const PROTOCOL_V2_DEBUG_STRING_LIMIT = 512;
|
|
860
|
-
const PROTOCOL_V2_DEBUG_DEPTH_LIMIT = 4;
|
|
861
|
-
const HIGH_VOLUME_PROTOCOL_V2_CALLS = new Set([
|
|
902
|
+
const REDUCED_DEBUG_PROTOCOL_V2_CALLS = new Set([
|
|
862
903
|
...LogBlockCommand,
|
|
863
904
|
'FilesystemFileRead',
|
|
864
905
|
'FileRead',
|
|
865
906
|
'EmmcFileRead',
|
|
866
907
|
]);
|
|
867
908
|
function shouldReduceProtocolV2Debug(name) {
|
|
868
|
-
return
|
|
869
|
-
}
|
|
870
|
-
function frameHeaderDebugHex(frame) {
|
|
871
|
-
return bytesToHex(frame.slice(0, PROTOCOL_V2_DEBUG_HEADER_BYTES));
|
|
872
|
-
}
|
|
873
|
-
function getBinaryByteLength(value) {
|
|
874
|
-
if (value instanceof ArrayBuffer) {
|
|
875
|
-
return value.byteLength;
|
|
876
|
-
}
|
|
877
|
-
if (ArrayBuffer.isView(value)) {
|
|
878
|
-
return value.byteLength;
|
|
879
|
-
}
|
|
880
|
-
if (typeof Blob !== 'undefined' && value instanceof Blob) {
|
|
881
|
-
return value.size;
|
|
882
|
-
}
|
|
883
|
-
return undefined;
|
|
909
|
+
return REDUCED_DEBUG_PROTOCOL_V2_CALLS.has(name);
|
|
884
910
|
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
return `[redacted data: object keys=${Object.keys(value).length}]`;
|
|
898
|
-
}
|
|
899
|
-
return `[redacted data: ${typeof value}]`;
|
|
900
|
-
}
|
|
901
|
-
function sanitizeProtocolV2DebugPayload(value, key = '', depth = 0) {
|
|
902
|
-
if (/^(data|payload)$/i.test(key) && value !== null && value !== undefined) {
|
|
903
|
-
return summarizeRedactedData(value);
|
|
904
|
-
}
|
|
905
|
-
if (/(passphrase|pin|mnemonic|seed|private)/i.test(key)) {
|
|
906
|
-
return '[redacted sensitive value]';
|
|
907
|
-
}
|
|
908
|
-
const byteLength = getBinaryByteLength(value);
|
|
909
|
-
if (byteLength !== undefined) {
|
|
910
|
-
return `[binary: ${byteLength} bytes]`;
|
|
911
|
-
}
|
|
912
|
-
if (typeof value === 'string') {
|
|
913
|
-
return value.length > PROTOCOL_V2_DEBUG_STRING_LIMIT
|
|
914
|
-
? `${value.slice(0, PROTOCOL_V2_DEBUG_STRING_LIMIT)}... (len=${value.length})`
|
|
915
|
-
: value;
|
|
916
|
-
}
|
|
917
|
-
if (!value || typeof value !== 'object') {
|
|
918
|
-
return value;
|
|
919
|
-
}
|
|
920
|
-
if (depth >= PROTOCOL_V2_DEBUG_DEPTH_LIMIT) {
|
|
921
|
-
return Array.isArray(value)
|
|
922
|
-
? `[array length=${value.length}]`
|
|
923
|
-
: `[object keys=${Object.keys(value).length}]`;
|
|
924
|
-
}
|
|
925
|
-
if (Array.isArray(value)) {
|
|
926
|
-
const items = value
|
|
927
|
-
.slice(0, PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT)
|
|
928
|
-
.map(item => sanitizeProtocolV2DebugPayload(item, key, depth + 1));
|
|
929
|
-
if (value.length > PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT) {
|
|
930
|
-
items.push(`... (${value.length - PROTOCOL_V2_DEBUG_ARRAY_ITEMS_LIMIT} more)`);
|
|
931
|
-
}
|
|
932
|
-
return items;
|
|
933
|
-
}
|
|
934
|
-
const entries = Object.entries(value).slice(0, PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT);
|
|
935
|
-
const sanitized = {};
|
|
936
|
-
entries.forEach(([entryKey, entryValue]) => {
|
|
937
|
-
sanitized[entryKey] = sanitizeProtocolV2DebugPayload(entryValue, entryKey, depth + 1);
|
|
938
|
-
});
|
|
939
|
-
if (Object.keys(value).length > PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT) {
|
|
940
|
-
sanitized.__truncated__ = `${Object.keys(value).length - PROTOCOL_V2_DEBUG_OBJECT_KEYS_LIMIT} more keys`;
|
|
941
|
-
}
|
|
942
|
-
return sanitized;
|
|
911
|
+
const HIGH_THROUGHPUT_PROTOCOL_V2_CALLS = new Set([
|
|
912
|
+
'FilesystemFileWrite',
|
|
913
|
+
'FileWrite',
|
|
914
|
+
'EmmcFileWrite',
|
|
915
|
+
'FirmwareUpload',
|
|
916
|
+
'ResourceAck',
|
|
917
|
+
'FilesystemFileRead',
|
|
918
|
+
'FileRead',
|
|
919
|
+
'EmmcFileRead',
|
|
920
|
+
]);
|
|
921
|
+
function isProtocolV2HighThroughputCall(name) {
|
|
922
|
+
return HIGH_THROUGHPUT_PROTOCOL_V2_CALLS.has(name);
|
|
943
923
|
}
|
|
944
924
|
const COMMON_TERMINAL_RESPONSE_TYPES = new Set([
|
|
945
925
|
'Failure',
|
|
@@ -966,11 +946,12 @@ function getErrorMessage(error) {
|
|
|
966
946
|
}
|
|
967
947
|
return String(error);
|
|
968
948
|
}
|
|
969
|
-
function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout) {
|
|
949
|
+
function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout, abortSignal) {
|
|
970
950
|
return __awaiter(this, void 0, void 0, function* () {
|
|
971
951
|
if (!timeoutMs)
|
|
972
952
|
return promise;
|
|
973
953
|
let timer;
|
|
954
|
+
let abortHandler;
|
|
974
955
|
try {
|
|
975
956
|
return yield Promise.race([
|
|
976
957
|
promise,
|
|
@@ -980,15 +961,32 @@ function withProtocolTimeout(promise, timeoutMs, createTimeoutError, onTimeout)
|
|
|
980
961
|
reject(createTimeoutError());
|
|
981
962
|
}, timeoutMs);
|
|
982
963
|
}),
|
|
964
|
+
...(abortSignal
|
|
965
|
+
? [
|
|
966
|
+
new Promise((_, reject) => {
|
|
967
|
+
abortHandler = () => {
|
|
968
|
+
reject(new Error('Protocol V2 operation aborted'));
|
|
969
|
+
};
|
|
970
|
+
if (abortSignal.aborted) {
|
|
971
|
+
abortHandler();
|
|
972
|
+
}
|
|
973
|
+
else {
|
|
974
|
+
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
975
|
+
}
|
|
976
|
+
}),
|
|
977
|
+
]
|
|
978
|
+
: []),
|
|
983
979
|
]);
|
|
984
980
|
}
|
|
985
981
|
finally {
|
|
986
982
|
if (timer)
|
|
987
983
|
clearTimeout(timer);
|
|
984
|
+
if (abortHandler) {
|
|
985
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
|
|
986
|
+
}
|
|
988
987
|
}
|
|
989
988
|
});
|
|
990
989
|
}
|
|
991
|
-
const PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS = 0;
|
|
992
990
|
class ProtocolV2Session {
|
|
993
991
|
constructor(options) {
|
|
994
992
|
var _a;
|
|
@@ -1003,87 +1001,97 @@ class ProtocolV2Session {
|
|
|
1003
1001
|
return result;
|
|
1004
1002
|
}
|
|
1005
1003
|
executeCall(name, data, callOptions) {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1004
|
+
const { schemas, router, packetSrc = PROTOCOL_V2_PACKET_SRC_COMMAND, maxFrameBytes, prepareCall, writeFrame, readFrame, logger, logPrefix = 'ProtocolV2', createTimeoutError, generation = 0, } = this.options;
|
|
1005
|
+
const timeoutMs = callOptions.timeoutMs && callOptions.timeoutMs > 0
|
|
1006
|
+
? callOptions.timeoutMs
|
|
1007
|
+
: PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS;
|
|
1008
|
+
const abortController = new AbortController();
|
|
1009
|
+
const shouldReduceDebug = shouldReduceProtocolV2Debug(name);
|
|
1010
|
+
const baseCallContext = Object.assign(Object.assign({ messageName: name, timeoutMs, highThroughput: isProtocolV2HighThroughputCall(name) }, (callOptions.writeWithResponse === undefined
|
|
1011
|
+
? {}
|
|
1012
|
+
: { writeWithResponse: callOptions.writeWithResponse })), { generation, signal: abortController.signal });
|
|
1013
|
+
const runCall = () => __awaiter(this, void 0, void 0, function* () {
|
|
1014
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1015
|
+
yield (prepareCall === null || prepareCall === void 0 ? void 0 : prepareCall(baseCallContext));
|
|
1017
1016
|
const protoSeq = this.sequenceCursor.next();
|
|
1018
1017
|
const frame = ProtocolV2.encodeFrame(schemas, name, data, {
|
|
1019
1018
|
packetSrc,
|
|
1020
1019
|
router,
|
|
1021
1020
|
seq: protoSeq,
|
|
1022
|
-
logger: shouldReduceDebug ? undefined : logger,
|
|
1023
|
-
logPrefix,
|
|
1024
|
-
context: `tx:${name}`,
|
|
1025
1021
|
});
|
|
1026
|
-
const expectedSeq = frame[6];
|
|
1027
1022
|
if (maxFrameBytes !== undefined && frame.length > maxFrameBytes) {
|
|
1028
1023
|
throw new Error(`Protocol V2 frame too large for transport: ${frame.length} > ${maxFrameBytes}`);
|
|
1029
1024
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1025
|
+
const writeStartedAt = Date.now();
|
|
1026
|
+
yield writeFrame(frame, baseCallContext);
|
|
1027
|
+
try {
|
|
1028
|
+
(_a = callOptions.onWriteCompleted) === null || _a === void 0 ? void 0 : _a.call(callOptions, {
|
|
1029
|
+
elapsedMs: Math.max(Date.now() - writeStartedAt, 0),
|
|
1030
|
+
frameBytes: frame.byteLength,
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
catch (error) {
|
|
1034
|
+
(_b = logger === null || logger === void 0 ? void 0 : logger.error) === null || _b === void 0 ? void 0 : _b.call(logger, `${logPrefix} write metrics callback failed: ${String(error)}`);
|
|
1033
1035
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1036
|
+
while (!abortController.signal.aborted) {
|
|
1037
|
+
const rxFrame = yield readFrame(baseCallContext);
|
|
1038
|
+
if (abortController.signal.aborted)
|
|
1039
|
+
break;
|
|
1040
|
+
let header;
|
|
1041
|
+
try {
|
|
1042
|
+
header = ProtocolV2.inspectFrameHeader(rxFrame);
|
|
1043
|
+
}
|
|
1044
|
+
catch (cause) {
|
|
1045
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 frame validation failed: ${getErrorMessage(cause)}`, cause);
|
|
1046
|
+
}
|
|
1047
|
+
if (header.router !== router) {
|
|
1048
|
+
throw new ProtocolV2LinkError('router', `Protocol V2 router mismatch: expected ${router}, got ${header.router}`);
|
|
1049
|
+
}
|
|
1050
|
+
if (header.packetSrc !== packetSrc) {
|
|
1051
|
+
throw new ProtocolV2LinkError('packet-source', `Protocol V2 packet source mismatch: expected ${packetSrc}, got ${header.packetSrc}`);
|
|
1052
|
+
}
|
|
1053
|
+
let isAck;
|
|
1054
|
+
try {
|
|
1055
|
+
isAck = ProtocolV2.isAckFrame(rxFrame);
|
|
1056
|
+
}
|
|
1057
|
+
catch (cause) {
|
|
1058
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 ACK validation failed: ${getErrorMessage(cause)}`, cause);
|
|
1059
|
+
}
|
|
1060
|
+
if (isAck) {
|
|
1061
|
+
if (header.seq !== protoSeq) {
|
|
1062
|
+
throw new ProtocolV2LinkError('ack-sequence', `Protocol V2 ACK sequence mismatch: expected ${protoSeq}, got ${header.seq}`);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
else {
|
|
1066
|
+
let decoded;
|
|
1067
|
+
try {
|
|
1068
|
+
decoded = ProtocolV2.decodeFrame(schemas, rxFrame);
|
|
1069
|
+
}
|
|
1070
|
+
catch (cause) {
|
|
1071
|
+
throw new ProtocolV2LinkError('frame', `Protocol V2 frame decode failed: ${getErrorMessage(cause)}`, cause);
|
|
1072
|
+
}
|
|
1073
|
+
if (this.lastResponseSequence === decoded.seq) {
|
|
1074
|
+
throw new ProtocolV2LinkError('response-sequence', `Protocol V2 duplicate response sequence: ${decoded.seq}`);
|
|
1042
1075
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1076
|
+
this.lastResponseSequence = decoded.seq;
|
|
1077
|
+
const response = call(decoded);
|
|
1078
|
+
if ((_c = callOptions.intermediateTypes) === null || _c === void 0 ? void 0 : _c.includes(response.type)) {
|
|
1079
|
+
(_d = callOptions.onIntermediateResponse) === null || _d === void 0 ? void 0 : _d.call(callOptions, response);
|
|
1045
1080
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
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
|
-
}
|
|
1081
|
+
else if (isExpectedTerminalResponse(response, callOptions.expectedTypes)) {
|
|
1082
|
+
return response;
|
|
1051
1083
|
}
|
|
1052
|
-
if (!
|
|
1053
|
-
|
|
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
|
-
}
|
|
1084
|
+
else if (!shouldReduceDebug) {
|
|
1085
|
+
(_e = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _e === void 0 ? void 0 : _e.call(logger, `[${logPrefix}] skip unexpected response for ${name}: expected=${(_f = callOptions.expectedTypes) === null || _f === void 0 ? void 0 : _f.join('|')} got=${response.type}`);
|
|
1075
1086
|
}
|
|
1076
1087
|
}
|
|
1077
|
-
|
|
1078
|
-
});
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}, () => {
|
|
1085
|
-
cancellation.cancelled = true;
|
|
1086
|
-
});
|
|
1088
|
+
}
|
|
1089
|
+
throw new Error(`Protocol V2 read loop cancelled after timeout for ${name}`);
|
|
1090
|
+
});
|
|
1091
|
+
return withProtocolTimeout(runCall(), timeoutMs, () => createTimeoutError
|
|
1092
|
+
? createTimeoutError(name, timeoutMs)
|
|
1093
|
+
: new Error(`Protocol V2 response timeout after ${timeoutMs}ms for ${name}`), () => {
|
|
1094
|
+
abortController.abort();
|
|
1087
1095
|
});
|
|
1088
1096
|
}
|
|
1089
1097
|
}
|
|
@@ -1093,7 +1101,10 @@ function probeProtocolV2({ call, timeoutMs, logger, logPrefix = 'ProtocolV2', on
|
|
|
1093
1101
|
let probeError;
|
|
1094
1102
|
try {
|
|
1095
1103
|
yield (onBeforeProbe === null || onBeforeProbe === void 0 ? void 0 : onBeforeProbe());
|
|
1096
|
-
const response = yield call('Ping', { message: 'protocol-v2-probe' }, {
|
|
1104
|
+
const response = yield call('Ping', { message: 'protocol-v2-probe' }, {
|
|
1105
|
+
timeoutMs,
|
|
1106
|
+
expectedTypes: ['Success'],
|
|
1107
|
+
});
|
|
1097
1108
|
if (response.type === 'Success') {
|
|
1098
1109
|
return true;
|
|
1099
1110
|
}
|
|
@@ -1113,12 +1124,19 @@ class ProtocolV2LinkManager {
|
|
|
1113
1124
|
this.links = new Map();
|
|
1114
1125
|
this.sequences = new Map();
|
|
1115
1126
|
this.callQueues = new Map();
|
|
1127
|
+
this.generations = new Map();
|
|
1128
|
+
this.invalidationReasons = new Map();
|
|
1129
|
+
this.invalidations = new Map();
|
|
1116
1130
|
this.options = options;
|
|
1117
1131
|
}
|
|
1118
1132
|
call(key, createAdapter, name, data, options) {
|
|
1119
|
-
var _a;
|
|
1120
|
-
const
|
|
1121
|
-
const
|
|
1133
|
+
var _a, _b;
|
|
1134
|
+
const generation = (_a = this.generations.get(key)) !== null && _a !== void 0 ? _a : 0;
|
|
1135
|
+
const run = () => {
|
|
1136
|
+
this.assertCallGeneration(key, generation);
|
|
1137
|
+
return this.executeCall(key, createAdapter, name, data, options);
|
|
1138
|
+
};
|
|
1139
|
+
const previous = (_b = this.callQueues.get(key)) !== null && _b !== void 0 ? _b : Promise.resolve();
|
|
1122
1140
|
const result = previous.then(run, run);
|
|
1123
1141
|
const queue = result.catch(() => undefined);
|
|
1124
1142
|
this.callQueues.set(key, queue);
|
|
@@ -1128,20 +1146,44 @@ class ProtocolV2LinkManager {
|
|
|
1128
1146
|
return result;
|
|
1129
1147
|
}
|
|
1130
1148
|
invalidateLink(key, reason) {
|
|
1131
|
-
var _a
|
|
1149
|
+
var _a;
|
|
1132
1150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1151
|
+
const generation = ((_a = this.generations.get(key)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
1152
|
+
this.generations.set(key, generation);
|
|
1153
|
+
this.invalidationReasons.set(key, { generation, reason });
|
|
1154
|
+
const pendingInvalidation = this.invalidations.get(key);
|
|
1133
1155
|
const link = this.links.get(key);
|
|
1134
|
-
if (!link)
|
|
1156
|
+
if (!link) {
|
|
1157
|
+
yield pendingInvalidation;
|
|
1135
1158
|
return;
|
|
1159
|
+
}
|
|
1136
1160
|
this.links.delete(key);
|
|
1137
1161
|
link.state.invalidatedReason = reason;
|
|
1138
|
-
|
|
1139
|
-
|
|
1162
|
+
const invalidation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
1163
|
+
var _b, _c;
|
|
1164
|
+
yield (pendingInvalidation === null || pendingInvalidation === void 0 ? void 0 : pendingInvalidation.catch(() => undefined));
|
|
1165
|
+
yield link.adapter.reset(reason);
|
|
1166
|
+
yield ((_c = (_b = this.options).onLinkInvalidated) === null || _c === void 0 ? void 0 : _c.call(_b, key, reason));
|
|
1167
|
+
}))();
|
|
1168
|
+
this.invalidations.set(key, invalidation);
|
|
1169
|
+
try {
|
|
1170
|
+
yield invalidation;
|
|
1171
|
+
}
|
|
1172
|
+
finally {
|
|
1173
|
+
if (this.invalidations.get(key) === invalidation) {
|
|
1174
|
+
this.invalidations.delete(key);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1140
1177
|
});
|
|
1141
1178
|
}
|
|
1142
1179
|
invalidateAllLinks(reason) {
|
|
1143
1180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1144
|
-
|
|
1181
|
+
const keys = new Set([
|
|
1182
|
+
...this.links.keys(),
|
|
1183
|
+
...this.callQueues.keys(),
|
|
1184
|
+
...this.invalidations.keys(),
|
|
1185
|
+
]);
|
|
1186
|
+
yield Promise.all(Array.from(keys, key => this.invalidateLink(key, reason)));
|
|
1145
1187
|
});
|
|
1146
1188
|
}
|
|
1147
1189
|
dispose(reason) {
|
|
@@ -1149,6 +1191,7 @@ class ProtocolV2LinkManager {
|
|
|
1149
1191
|
yield this.invalidateAllLinks(reason);
|
|
1150
1192
|
this.sequences.clear();
|
|
1151
1193
|
this.callQueues.clear();
|
|
1194
|
+
this.invalidations.clear();
|
|
1152
1195
|
});
|
|
1153
1196
|
}
|
|
1154
1197
|
getOrCreateLink(key, createAdapter) {
|
|
@@ -1216,6 +1259,17 @@ class ProtocolV2LinkManager {
|
|
|
1216
1259
|
this.callQueues.delete(key);
|
|
1217
1260
|
}
|
|
1218
1261
|
}
|
|
1262
|
+
assertCallGeneration(key, generation) {
|
|
1263
|
+
var _a;
|
|
1264
|
+
const currentGeneration = (_a = this.generations.get(key)) !== null && _a !== void 0 ? _a : 0;
|
|
1265
|
+
if (currentGeneration === generation)
|
|
1266
|
+
return;
|
|
1267
|
+
const invalidation = this.invalidationReasons.get(key);
|
|
1268
|
+
const reason = (invalidation === null || invalidation === void 0 ? void 0 : invalidation.generation) === currentGeneration
|
|
1269
|
+
? invalidation.reason
|
|
1270
|
+
: 'Protocol V2 link generation changed';
|
|
1271
|
+
throw new ProtocolV2LinkError('generation', reason);
|
|
1272
|
+
}
|
|
1219
1273
|
}
|
|
1220
1274
|
|
|
1221
1275
|
class ProtocolV2UsbTransportBase {
|
|
@@ -1226,7 +1280,7 @@ class ProtocolV2UsbTransportBase {
|
|
|
1226
1280
|
this.protocolV2UsbOptions = options;
|
|
1227
1281
|
this.protocolV2UsbLinks = new ProtocolV2LinkManager({
|
|
1228
1282
|
getSchemas: () => this.getProtocolV2UsbSchemas(),
|
|
1229
|
-
classifyError: ()
|
|
1283
|
+
classifyError: error => (isProtocolV2LinkError(error) ? 'link-fatal' : 'recoverable'),
|
|
1230
1284
|
onLinkInvalidated: (key, reason) => __awaiter(this, void 0, void 0, function* () {
|
|
1231
1285
|
var _a;
|
|
1232
1286
|
(_a = this.protocolV2UsbAssemblers.get(key)) === null || _a === void 0 ? void 0 : _a.reset();
|
|
@@ -1276,10 +1330,10 @@ class ProtocolV2UsbTransportBase {
|
|
|
1276
1330
|
}
|
|
1277
1331
|
const assertCurrentGeneration = () => {
|
|
1278
1332
|
if (cancellation.reason) {
|
|
1279
|
-
throw new
|
|
1333
|
+
throw new ProtocolV2LinkError('generation', cancellation.reason);
|
|
1280
1334
|
}
|
|
1281
1335
|
if (this.protocolV2UsbGenerations.get(key) !== generation) {
|
|
1282
|
-
throw new
|
|
1336
|
+
throw new ProtocolV2LinkError('generation', 'Protocol V2 USB connection generation changed');
|
|
1283
1337
|
}
|
|
1284
1338
|
};
|
|
1285
1339
|
return {
|
|
@@ -1288,11 +1342,15 @@ class ProtocolV2UsbTransportBase {
|
|
|
1288
1342
|
generation,
|
|
1289
1343
|
prepareCall: () => {
|
|
1290
1344
|
assertCurrentGeneration();
|
|
1291
|
-
this.getProtocolV2UsbAssembler(key).reset();
|
|
1292
1345
|
},
|
|
1293
1346
|
writeFrame: (frame, context) => __awaiter(this, void 0, void 0, function* () {
|
|
1294
1347
|
assertCurrentGeneration();
|
|
1295
|
-
|
|
1348
|
+
try {
|
|
1349
|
+
yield this.writeProtocolV2UsbPacket(key, frame, context);
|
|
1350
|
+
}
|
|
1351
|
+
catch (error) {
|
|
1352
|
+
throw this.createProtocolV2UsbIoError('write', error);
|
|
1353
|
+
}
|
|
1296
1354
|
assertCurrentGeneration();
|
|
1297
1355
|
}),
|
|
1298
1356
|
readFrame: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1300,13 +1358,15 @@ class ProtocolV2UsbTransportBase {
|
|
|
1300
1358
|
const assembler = this.getProtocolV2UsbAssembler(key);
|
|
1301
1359
|
let frame = assembler.push(new Uint8Array(0));
|
|
1302
1360
|
while (!frame) {
|
|
1303
|
-
const packetRead = this.readProtocolV2UsbPacket(key, context)
|
|
1304
|
-
packet
|
|
1305
|
-
|
|
1361
|
+
const packetRead = this.readProtocolV2UsbPacket(key, context)
|
|
1362
|
+
.then(packet => ({ packet }))
|
|
1363
|
+
.catch(error => {
|
|
1364
|
+
throw this.createProtocolV2UsbIoError('read', error);
|
|
1365
|
+
});
|
|
1306
1366
|
const cancelled = cancellation.promise.then(reason => ({ reason }));
|
|
1307
1367
|
const result = yield Promise.race([packetRead, cancelled]);
|
|
1308
1368
|
if ('reason' in result) {
|
|
1309
|
-
throw new
|
|
1369
|
+
throw new ProtocolV2LinkError('generation', result.reason);
|
|
1310
1370
|
}
|
|
1311
1371
|
assertCurrentGeneration();
|
|
1312
1372
|
frame = assembler.push(result.packet);
|
|
@@ -1347,8 +1407,17 @@ class ProtocolV2UsbTransportBase {
|
|
|
1347
1407
|
};
|
|
1348
1408
|
return cancellation;
|
|
1349
1409
|
}
|
|
1410
|
+
createProtocolV2UsbIoError(operation, error) {
|
|
1411
|
+
if (isProtocolV2LinkError(error))
|
|
1412
|
+
return error;
|
|
1413
|
+
return new ProtocolV2LinkError('io', `Protocol V2 USB ${operation} failed: ${getErrorMessage(error) || 'unknown error'}`, error);
|
|
1414
|
+
}
|
|
1350
1415
|
}
|
|
1351
1416
|
|
|
1417
|
+
const TRANSPORT_EVENT = {
|
|
1418
|
+
DEVICE_DISCONNECT: 'transport-device-disconnect',
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1352
1421
|
exports.AptosTransactionType = void 0;
|
|
1353
1422
|
(function (AptosTransactionType) {
|
|
1354
1423
|
AptosTransactionType[AptosTransactionType["STANDARD"] = 0] = "STANDARD";
|
|
@@ -1595,6 +1664,24 @@ exports.EthereumDataType = void 0;
|
|
|
1595
1664
|
EthereumDataType[EthereumDataType["ARRAY"] = 7] = "ARRAY";
|
|
1596
1665
|
EthereumDataType[EthereumDataType["STRUCT"] = 8] = "STRUCT";
|
|
1597
1666
|
})(exports.EthereumDataType || (exports.EthereumDataType = {}));
|
|
1667
|
+
exports.Enum_KaspaInputScriptType = void 0;
|
|
1668
|
+
(function (Enum_KaspaInputScriptType) {
|
|
1669
|
+
Enum_KaspaInputScriptType[Enum_KaspaInputScriptType["KASPA_SPEND_P2PK_SCHNORR"] = 0] = "KASPA_SPEND_P2PK_SCHNORR";
|
|
1670
|
+
Enum_KaspaInputScriptType[Enum_KaspaInputScriptType["KASPA_SPEND_P2PK_ECDSA"] = 1] = "KASPA_SPEND_P2PK_ECDSA";
|
|
1671
|
+
})(exports.Enum_KaspaInputScriptType || (exports.Enum_KaspaInputScriptType = {}));
|
|
1672
|
+
exports.Enum_KaspaOutputScriptType = void 0;
|
|
1673
|
+
(function (Enum_KaspaOutputScriptType) {
|
|
1674
|
+
Enum_KaspaOutputScriptType[Enum_KaspaOutputScriptType["KASPA_PAYTOADDRESS"] = 0] = "KASPA_PAYTOADDRESS";
|
|
1675
|
+
Enum_KaspaOutputScriptType[Enum_KaspaOutputScriptType["KASPA_PAYTOCHANGE"] = 1] = "KASPA_PAYTOCHANGE";
|
|
1676
|
+
})(exports.Enum_KaspaOutputScriptType || (exports.Enum_KaspaOutputScriptType = {}));
|
|
1677
|
+
exports.Enum_KaspaRequestType = void 0;
|
|
1678
|
+
(function (Enum_KaspaRequestType) {
|
|
1679
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_INPUT"] = 0] = "KASPA_TX_INPUT";
|
|
1680
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_OUTPUT"] = 1] = "KASPA_TX_OUTPUT";
|
|
1681
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_PAYLOAD"] = 2] = "KASPA_TX_PAYLOAD";
|
|
1682
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_FINISHED"] = 3] = "KASPA_TX_FINISHED";
|
|
1683
|
+
Enum_KaspaRequestType[Enum_KaspaRequestType["KASPA_TX_PREV_META"] = 4] = "KASPA_TX_PREV_META";
|
|
1684
|
+
})(exports.Enum_KaspaRequestType || (exports.Enum_KaspaRequestType = {}));
|
|
1598
1685
|
exports.Enum_BackupType = void 0;
|
|
1599
1686
|
(function (Enum_BackupType) {
|
|
1600
1687
|
Enum_BackupType[Enum_BackupType["Bip39"] = 0] = "Bip39";
|
|
@@ -1788,11 +1875,6 @@ exports.CommandFlags = void 0;
|
|
|
1788
1875
|
CommandFlags[CommandFlags["Default"] = 0] = "Default";
|
|
1789
1876
|
CommandFlags[CommandFlags["Factory_Only"] = 1] = "Factory_Only";
|
|
1790
1877
|
})(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 = {}));
|
|
1796
1878
|
exports.MoneroNetworkType = void 0;
|
|
1797
1879
|
(function (MoneroNetworkType) {
|
|
1798
1880
|
MoneroNetworkType[MoneroNetworkType["MAINNET"] = 0] = "MAINNET";
|
|
@@ -1800,25 +1882,49 @@ exports.MoneroNetworkType = void 0;
|
|
|
1800
1882
|
MoneroNetworkType[MoneroNetworkType["STAGENET"] = 2] = "STAGENET";
|
|
1801
1883
|
MoneroNetworkType[MoneroNetworkType["FAKECHAIN"] = 3] = "FAKECHAIN";
|
|
1802
1884
|
})(exports.MoneroNetworkType || (exports.MoneroNetworkType = {}));
|
|
1803
|
-
exports.
|
|
1804
|
-
(function (
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1885
|
+
exports.UiAnimationType = void 0;
|
|
1886
|
+
(function (UiAnimationType) {
|
|
1887
|
+
UiAnimationType[UiAnimationType["Unknown"] = 0] = "Unknown";
|
|
1888
|
+
UiAnimationType[UiAnimationType["Signing"] = 1] = "Signing";
|
|
1889
|
+
})(exports.UiAnimationType || (exports.UiAnimationType = {}));
|
|
1890
|
+
exports.UiAnimationCommand = void 0;
|
|
1891
|
+
(function (UiAnimationCommand) {
|
|
1892
|
+
UiAnimationCommand[UiAnimationCommand["CommandUnknown"] = 0] = "CommandUnknown";
|
|
1893
|
+
UiAnimationCommand[UiAnimationCommand["Start"] = 1] = "Start";
|
|
1894
|
+
UiAnimationCommand[UiAnimationCommand["Stop"] = 2] = "Stop";
|
|
1895
|
+
UiAnimationCommand[UiAnimationCommand["Refresh"] = 3] = "Refresh";
|
|
1896
|
+
})(exports.UiAnimationCommand || (exports.UiAnimationCommand = {}));
|
|
1897
|
+
exports.DeviceErrorCode = void 0;
|
|
1898
|
+
(function (DeviceErrorCode) {
|
|
1899
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_None"] = 0] = "DeviceError_None";
|
|
1900
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_Busy"] = 1] = "DeviceError_Busy";
|
|
1901
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_NotInitialized"] = 2] = "DeviceError_NotInitialized";
|
|
1902
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_ActionCancelled"] = 3] = "DeviceError_ActionCancelled";
|
|
1903
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_PinAlreadyUsed"] = 4] = "DeviceError_PinAlreadyUsed";
|
|
1904
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_PersistFailed"] = 5] = "DeviceError_PersistFailed";
|
|
1905
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_SeError"] = 6] = "DeviceError_SeError";
|
|
1906
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_InvalidLanguage"] = 7] = "DeviceError_InvalidLanguage";
|
|
1907
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_WallpaperNotUsable"] = 8] = "DeviceError_WallpaperNotUsable";
|
|
1908
|
+
DeviceErrorCode[DeviceErrorCode["DeviceError_DeviceLocked"] = 9] = "DeviceError_DeviceLocked";
|
|
1909
|
+
})(exports.DeviceErrorCode || (exports.DeviceErrorCode = {}));
|
|
1816
1910
|
exports.DeviceRebootType = void 0;
|
|
1817
1911
|
(function (DeviceRebootType) {
|
|
1818
1912
|
DeviceRebootType[DeviceRebootType["Normal"] = 0] = "Normal";
|
|
1819
1913
|
DeviceRebootType[DeviceRebootType["Romloader"] = 1] = "Romloader";
|
|
1820
1914
|
DeviceRebootType[DeviceRebootType["Bootloader"] = 2] = "Bootloader";
|
|
1821
1915
|
})(exports.DeviceRebootType || (exports.DeviceRebootType = {}));
|
|
1916
|
+
exports.DeviceSettingsPage = void 0;
|
|
1917
|
+
(function (DeviceSettingsPage) {
|
|
1918
|
+
DeviceSettingsPage[DeviceSettingsPage["DeviceReset"] = 0] = "DeviceReset";
|
|
1919
|
+
DeviceSettingsPage[DeviceSettingsPage["DevicePinChange"] = 1] = "DevicePinChange";
|
|
1920
|
+
DeviceSettingsPage[DeviceSettingsPage["DevicePassphrase"] = 2] = "DevicePassphrase";
|
|
1921
|
+
DeviceSettingsPage[DeviceSettingsPage["DeviceAirgap"] = 3] = "DeviceAirgap";
|
|
1922
|
+
})(exports.DeviceSettingsPage || (exports.DeviceSettingsPage = {}));
|
|
1923
|
+
exports.DeviceFactoryAck = void 0;
|
|
1924
|
+
(function (DeviceFactoryAck) {
|
|
1925
|
+
DeviceFactoryAck[DeviceFactoryAck["FACTORY_ACK_SUCCESS"] = 0] = "FACTORY_ACK_SUCCESS";
|
|
1926
|
+
DeviceFactoryAck[DeviceFactoryAck["FACTORY_ACK_FAIL"] = 1] = "FACTORY_ACK_FAIL";
|
|
1927
|
+
})(exports.DeviceFactoryAck || (exports.DeviceFactoryAck = {}));
|
|
1822
1928
|
exports.DeviceFirmwareTargetType = void 0;
|
|
1823
1929
|
(function (DeviceFirmwareTargetType) {
|
|
1824
1930
|
DeviceFirmwareTargetType[DeviceFirmwareTargetType["FW_MGMT_TARGET_INVALID"] = 0] = "FW_MGMT_TARGET_INVALID";
|
|
@@ -1847,11 +1953,6 @@ exports.DeviceFirmwareUpdateTaskStatus = void 0;
|
|
|
1847
1953
|
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY"] = 9] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY";
|
|
1848
1954
|
DeviceFirmwareUpdateTaskStatus[DeviceFirmwareUpdateTaskStatus["FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS"] = 10] = "FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS";
|
|
1849
1955
|
})(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 = {}));
|
|
1855
1956
|
exports.DeviceType = void 0;
|
|
1856
1957
|
(function (DeviceType) {
|
|
1857
1958
|
DeviceType[DeviceType["CLASSIC1"] = 0] = "CLASSIC1";
|
|
@@ -1874,22 +1975,116 @@ exports.DeviceSEState = void 0;
|
|
|
1874
1975
|
DeviceSEState[DeviceSEState["APP_FACTORY"] = 51] = "APP_FACTORY";
|
|
1875
1976
|
DeviceSEState[DeviceSEState["APP"] = 85] = "APP";
|
|
1876
1977
|
})(exports.DeviceSEState || (exports.DeviceSEState = {}));
|
|
1877
|
-
exports.
|
|
1878
|
-
(function (
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1978
|
+
exports.DeviceSessionErrorCode = void 0;
|
|
1979
|
+
(function (DeviceSessionErrorCode) {
|
|
1980
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_None"] = 0] = "DeviceSessionError_None";
|
|
1981
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_UserCancelled"] = 1] = "DeviceSessionError_UserCancelled";
|
|
1982
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_InvalidSession"] = 2] = "DeviceSessionError_InvalidSession";
|
|
1983
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_AttachPinUnavailable"] = 3] = "DeviceSessionError_AttachPinUnavailable";
|
|
1984
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_PassphraseDisabled"] = 4] = "DeviceSessionError_PassphraseDisabled";
|
|
1985
|
+
DeviceSessionErrorCode[DeviceSessionErrorCode["DeviceSessionError_Busy"] = 5] = "DeviceSessionError_Busy";
|
|
1986
|
+
})(exports.DeviceSessionErrorCode || (exports.DeviceSessionErrorCode = {}));
|
|
1987
|
+
exports.DeviceSessionSeedDomain = void 0;
|
|
1988
|
+
(function (DeviceSessionSeedDomain) {
|
|
1989
|
+
DeviceSessionSeedDomain[DeviceSessionSeedDomain["SeedDomain_Standard"] = 1] = "SeedDomain_Standard";
|
|
1990
|
+
DeviceSessionSeedDomain[DeviceSessionSeedDomain["SeedDomain_Cardano"] = 2] = "SeedDomain_Cardano";
|
|
1991
|
+
})(exports.DeviceSessionSeedDomain || (exports.DeviceSessionSeedDomain = {}));
|
|
1992
|
+
exports.DeviceSessionPinType = void 0;
|
|
1993
|
+
(function (DeviceSessionPinType) {
|
|
1994
|
+
DeviceSessionPinType[DeviceSessionPinType["Any"] = 1] = "Any";
|
|
1995
|
+
DeviceSessionPinType[DeviceSessionPinType["Main"] = 2] = "Main";
|
|
1996
|
+
DeviceSessionPinType[DeviceSessionPinType["AttachToPin"] = 3] = "AttachToPin";
|
|
1997
|
+
})(exports.DeviceSessionPinType || (exports.DeviceSessionPinType = {}));
|
|
1998
|
+
exports.DeviceSessionAskPin_FailureSubCodes = void 0;
|
|
1999
|
+
(function (DeviceSessionAskPin_FailureSubCodes) {
|
|
2000
|
+
DeviceSessionAskPin_FailureSubCodes[DeviceSessionAskPin_FailureSubCodes["UserCancel"] = 1] = "UserCancel";
|
|
2001
|
+
})(exports.DeviceSessionAskPin_FailureSubCodes || (exports.DeviceSessionAskPin_FailureSubCodes = {}));
|
|
2002
|
+
exports.OnboardingStep = void 0;
|
|
2003
|
+
(function (OnboardingStep) {
|
|
2004
|
+
OnboardingStep[OnboardingStep["ONBOARDING_STEP_UNKNOWN"] = 0] = "ONBOARDING_STEP_UNKNOWN";
|
|
2005
|
+
OnboardingStep[OnboardingStep["ONBOARDING_STEP_CHECKING"] = 1] = "ONBOARDING_STEP_CHECKING";
|
|
2006
|
+
OnboardingStep[OnboardingStep["ONBOARDING_STEP_PERSONALIZATION"] = 2] = "ONBOARDING_STEP_PERSONALIZATION";
|
|
2007
|
+
OnboardingStep[OnboardingStep["ONBOARDING_STEP_PIN"] = 3] = "ONBOARDING_STEP_PIN";
|
|
2008
|
+
OnboardingStep[OnboardingStep["ONBOARDING_STEP_SETUP"] = 4] = "ONBOARDING_STEP_SETUP";
|
|
2009
|
+
OnboardingStep[OnboardingStep["ONBOARDING_STEP_DONE"] = 5] = "ONBOARDING_STEP_DONE";
|
|
2010
|
+
})(exports.OnboardingStep || (exports.OnboardingStep = {}));
|
|
2011
|
+
exports.OnboardingPhase = void 0;
|
|
2012
|
+
(function (OnboardingPhase) {
|
|
2013
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_UNKNOWN"] = 0] = "ONBOARDING_PHASE_UNKNOWN";
|
|
2014
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_SAFETY_CHECK"] = 1] = "ONBOARDING_PHASE_SAFETY_CHECK";
|
|
2015
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_PIN_SETUP"] = 2] = "ONBOARDING_PHASE_PIN_SETUP";
|
|
2016
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_FINGERPRINT_SETUP"] = 3] = "ONBOARDING_PHASE_FINGERPRINT_SETUP";
|
|
2017
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_SETUP_CHOICE"] = 4] = "ONBOARDING_PHASE_SETUP_CHOICE";
|
|
2018
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_WALLET_CREATE_START"] = 5] = "ONBOARDING_PHASE_WALLET_CREATE_START";
|
|
2019
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW"] = 6] = "ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW";
|
|
2020
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM"] = 7] = "ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM";
|
|
2021
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_RESTORE_METHOD_CHOICE"] = 8] = "ONBOARDING_PHASE_RESTORE_METHOD_CHOICE";
|
|
2022
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE"] = 9] = "ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE";
|
|
2023
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_SEEDCARD_RESTORE"] = 10] = "ONBOARDING_PHASE_SEEDCARD_RESTORE";
|
|
2024
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_WALLET_READY"] = 11] = "ONBOARDING_PHASE_WALLET_READY";
|
|
2025
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT"] = 12] = "ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT";
|
|
2026
|
+
OnboardingPhase[OnboardingPhase["ONBOARDING_PHASE_SEEDCARD_BACKUP"] = 13] = "ONBOARDING_PHASE_SEEDCARD_BACKUP";
|
|
2027
|
+
})(exports.OnboardingPhase || (exports.OnboardingPhase = {}));
|
|
2028
|
+
exports.OnboardingSetupKind = void 0;
|
|
2029
|
+
(function (OnboardingSetupKind) {
|
|
2030
|
+
OnboardingSetupKind[OnboardingSetupKind["ONBOARDING_SETUP_KIND_UNKNOWN"] = 0] = "ONBOARDING_SETUP_KIND_UNKNOWN";
|
|
2031
|
+
OnboardingSetupKind[OnboardingSetupKind["ONBOARDING_SETUP_KIND_CHOICE"] = 1] = "ONBOARDING_SETUP_KIND_CHOICE";
|
|
2032
|
+
OnboardingSetupKind[OnboardingSetupKind["ONBOARDING_SETUP_KIND_CREATE"] = 2] = "ONBOARDING_SETUP_KIND_CREATE";
|
|
2033
|
+
OnboardingSetupKind[OnboardingSetupKind["ONBOARDING_SETUP_KIND_RESTORE"] = 3] = "ONBOARDING_SETUP_KIND_RESTORE";
|
|
2034
|
+
})(exports.OnboardingSetupKind || (exports.OnboardingSetupKind = {}));
|
|
2035
|
+
exports.OnboardingSetupMethod = void 0;
|
|
2036
|
+
(function (OnboardingSetupMethod) {
|
|
2037
|
+
OnboardingSetupMethod[OnboardingSetupMethod["ONBOARDING_SETUP_METHOD_UNKNOWN"] = 0] = "ONBOARDING_SETUP_METHOD_UNKNOWN";
|
|
2038
|
+
OnboardingSetupMethod[OnboardingSetupMethod["ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE"] = 1] = "ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE";
|
|
2039
|
+
OnboardingSetupMethod[OnboardingSetupMethod["ONBOARDING_SETUP_METHOD_SEEDCARD"] = 2] = "ONBOARDING_SETUP_METHOD_SEEDCARD";
|
|
2040
|
+
})(exports.OnboardingSetupMethod || (exports.OnboardingSetupMethod = {}));
|
|
2041
|
+
exports.ViewTipType = void 0;
|
|
2042
|
+
(function (ViewTipType) {
|
|
2043
|
+
ViewTipType[ViewTipType["Default"] = 0] = "Default";
|
|
2044
|
+
ViewTipType[ViewTipType["Highlight"] = 1] = "Highlight";
|
|
2045
|
+
ViewTipType[ViewTipType["Recommend"] = 2] = "Recommend";
|
|
2046
|
+
ViewTipType[ViewTipType["Warning"] = 3] = "Warning";
|
|
2047
|
+
ViewTipType[ViewTipType["Danger"] = 4] = "Danger";
|
|
2048
|
+
})(exports.ViewTipType || (exports.ViewTipType = {}));
|
|
2049
|
+
exports.ViewSignLayout = void 0;
|
|
2050
|
+
(function (ViewSignLayout) {
|
|
2051
|
+
ViewSignLayout[ViewSignLayout["LayoutDefault"] = 0] = "LayoutDefault";
|
|
2052
|
+
ViewSignLayout[ViewSignLayout["LayoutSafeTxCreate"] = 1] = "LayoutSafeTxCreate";
|
|
2053
|
+
ViewSignLayout[ViewSignLayout["LayoutFinalConfirm"] = 2] = "LayoutFinalConfirm";
|
|
2054
|
+
ViewSignLayout[ViewSignLayout["Layout7702"] = 3] = "Layout7702";
|
|
2055
|
+
ViewSignLayout[ViewSignLayout["LayoutFlat"] = 4] = "LayoutFlat";
|
|
2056
|
+
ViewSignLayout[ViewSignLayout["LayoutEthApprove"] = 5] = "LayoutEthApprove";
|
|
2057
|
+
})(exports.ViewSignLayout || (exports.ViewSignLayout = {}));
|
|
2058
|
+
exports.ProtocolV2FailureType = void 0;
|
|
2059
|
+
(function (ProtocolV2FailureType) {
|
|
2060
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_InvalidMessage"] = 1] = "Failure_InvalidMessage";
|
|
2061
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_UndefinedError"] = 2] = "Failure_UndefinedError";
|
|
2062
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_UsageError"] = 3] = "Failure_UsageError";
|
|
2063
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_DataError"] = 4] = "Failure_DataError";
|
|
2064
|
+
ProtocolV2FailureType[ProtocolV2FailureType["Failure_ProcessError"] = 5] = "Failure_ProcessError";
|
|
2065
|
+
})(exports.ProtocolV2FailureType || (exports.ProtocolV2FailureType = {}));
|
|
2066
|
+
exports.Enum_ProtocolV2Capability = void 0;
|
|
2067
|
+
(function (Enum_ProtocolV2Capability) {
|
|
2068
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Bitcoin"] = 1] = "Capability_Bitcoin";
|
|
2069
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Bitcoin_like"] = 2] = "Capability_Bitcoin_like";
|
|
2070
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Binance"] = 3] = "Capability_Binance";
|
|
2071
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Cardano"] = 4] = "Capability_Cardano";
|
|
2072
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Crypto"] = 5] = "Capability_Crypto";
|
|
2073
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_EOS"] = 6] = "Capability_EOS";
|
|
2074
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Ethereum"] = 7] = "Capability_Ethereum";
|
|
2075
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Lisk"] = 8] = "Capability_Lisk";
|
|
2076
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Monero"] = 9] = "Capability_Monero";
|
|
2077
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_NEM"] = 10] = "Capability_NEM";
|
|
2078
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Ripple"] = 11] = "Capability_Ripple";
|
|
2079
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Stellar"] = 12] = "Capability_Stellar";
|
|
2080
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Tezos"] = 13] = "Capability_Tezos";
|
|
2081
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_U2F"] = 14] = "Capability_U2F";
|
|
2082
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_Shamir"] = 15] = "Capability_Shamir";
|
|
2083
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_ShamirGroups"] = 16] = "Capability_ShamirGroups";
|
|
2084
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_PassphraseEntry"] = 17] = "Capability_PassphraseEntry";
|
|
2085
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_AttachToPin"] = 18] = "Capability_AttachToPin";
|
|
2086
|
+
Enum_ProtocolV2Capability[Enum_ProtocolV2Capability["Capability_EthereumTypedData"] = 1000] = "Capability_EthereumTypedData";
|
|
2087
|
+
})(exports.Enum_ProtocolV2Capability || (exports.Enum_ProtocolV2Capability = {}));
|
|
1893
2088
|
|
|
1894
2089
|
var messages = /*#__PURE__*/Object.freeze({
|
|
1895
2090
|
__proto__: null,
|
|
@@ -1922,6 +2117,9 @@ var messages = /*#__PURE__*/Object.freeze({
|
|
|
1922
2117
|
get EthereumGnosisSafeTxOperation () { return exports.EthereumGnosisSafeTxOperation; },
|
|
1923
2118
|
get EthereumDataTypeOneKey () { return exports.EthereumDataTypeOneKey; },
|
|
1924
2119
|
get EthereumDataType () { return exports.EthereumDataType; },
|
|
2120
|
+
get Enum_KaspaInputScriptType () { return exports.Enum_KaspaInputScriptType; },
|
|
2121
|
+
get Enum_KaspaOutputScriptType () { return exports.Enum_KaspaOutputScriptType; },
|
|
2122
|
+
get Enum_KaspaRequestType () { return exports.Enum_KaspaRequestType; },
|
|
1925
2123
|
get Enum_BackupType () { return exports.Enum_BackupType; },
|
|
1926
2124
|
get Enum_SafetyCheckLevel () { return exports.Enum_SafetyCheckLevel; },
|
|
1927
2125
|
get OneKeyDeviceType () { return exports.OneKeyDeviceType; },
|
|
@@ -1953,20 +2151,114 @@ var messages = /*#__PURE__*/Object.freeze({
|
|
|
1953
2151
|
get TronResourceCode () { return exports.TronResourceCode; },
|
|
1954
2152
|
get TronMessageType () { return exports.TronMessageType; },
|
|
1955
2153
|
get CommandFlags () { return exports.CommandFlags; },
|
|
1956
|
-
get WallpaperTarget () { return exports.WallpaperTarget; },
|
|
1957
2154
|
get MoneroNetworkType () { return exports.MoneroNetworkType; },
|
|
1958
|
-
get
|
|
1959
|
-
get
|
|
2155
|
+
get UiAnimationType () { return exports.UiAnimationType; },
|
|
2156
|
+
get UiAnimationCommand () { return exports.UiAnimationCommand; },
|
|
2157
|
+
get DeviceErrorCode () { return exports.DeviceErrorCode; },
|
|
1960
2158
|
get DeviceRebootType () { return exports.DeviceRebootType; },
|
|
2159
|
+
get DeviceSettingsPage () { return exports.DeviceSettingsPage; },
|
|
2160
|
+
get DeviceFactoryAck () { return exports.DeviceFactoryAck; },
|
|
1961
2161
|
get DeviceFirmwareTargetType () { return exports.DeviceFirmwareTargetType; },
|
|
1962
2162
|
get DeviceFirmwareUpdateTaskStatus () { return exports.DeviceFirmwareUpdateTaskStatus; },
|
|
1963
|
-
get DeviceFactoryAck () { return exports.DeviceFactoryAck; },
|
|
1964
2163
|
get DeviceType () { return exports.DeviceType; },
|
|
1965
2164
|
get DeviceSeType () { return exports.DeviceSeType; },
|
|
1966
2165
|
get DeviceSEState () { return exports.DeviceSEState; },
|
|
1967
|
-
get
|
|
2166
|
+
get DeviceSessionErrorCode () { return exports.DeviceSessionErrorCode; },
|
|
2167
|
+
get DeviceSessionSeedDomain () { return exports.DeviceSessionSeedDomain; },
|
|
2168
|
+
get DeviceSessionPinType () { return exports.DeviceSessionPinType; },
|
|
2169
|
+
get DeviceSessionAskPin_FailureSubCodes () { return exports.DeviceSessionAskPin_FailureSubCodes; },
|
|
2170
|
+
get OnboardingStep () { return exports.OnboardingStep; },
|
|
2171
|
+
get OnboardingPhase () { return exports.OnboardingPhase; },
|
|
2172
|
+
get OnboardingSetupKind () { return exports.OnboardingSetupKind; },
|
|
2173
|
+
get OnboardingSetupMethod () { return exports.OnboardingSetupMethod; },
|
|
2174
|
+
get ViewTipType () { return exports.ViewTipType; },
|
|
2175
|
+
get ViewSignLayout () { return exports.ViewSignLayout; },
|
|
2176
|
+
get ProtocolV2FailureType () { return exports.ProtocolV2FailureType; },
|
|
2177
|
+
get Enum_ProtocolV2Capability () { return exports.Enum_ProtocolV2Capability; }
|
|
1968
2178
|
});
|
|
1969
2179
|
|
|
2180
|
+
const REDACTED = '[REDACTED]';
|
|
2181
|
+
const SENSITIVE_LOG_KEYS = new Set([
|
|
2182
|
+
'accesstoken',
|
|
2183
|
+
'address',
|
|
2184
|
+
'apikey',
|
|
2185
|
+
'connectid',
|
|
2186
|
+
'devicestate',
|
|
2187
|
+
'deviceid',
|
|
2188
|
+
'entropy',
|
|
2189
|
+
'expectedpassphrasestate',
|
|
2190
|
+
'mnemonic',
|
|
2191
|
+
'passphrase',
|
|
2192
|
+
'passphrasestate',
|
|
2193
|
+
'password',
|
|
2194
|
+
'pin',
|
|
2195
|
+
'privatekey',
|
|
2196
|
+
'publickey',
|
|
2197
|
+
'seed',
|
|
2198
|
+
'serialnumber',
|
|
2199
|
+
'session',
|
|
2200
|
+
'sessionid',
|
|
2201
|
+
'signature',
|
|
2202
|
+
'token',
|
|
2203
|
+
'uuid',
|
|
2204
|
+
'walletsessionid',
|
|
2205
|
+
'xprv',
|
|
2206
|
+
'xpub',
|
|
2207
|
+
]);
|
|
2208
|
+
const normalizeLogKey = (key) => key.replace(/[_-]/g, '').toLowerCase();
|
|
2209
|
+
const isSensitiveLogKey = (key) => {
|
|
2210
|
+
const normalizedKey = normalizeLogKey(key);
|
|
2211
|
+
return (SENSITIVE_LOG_KEYS.has(normalizedKey) ||
|
|
2212
|
+
normalizedKey.endsWith('address') ||
|
|
2213
|
+
normalizedKey.endsWith('privatekey') ||
|
|
2214
|
+
normalizedKey.endsWith('publickey') ||
|
|
2215
|
+
normalizedKey.endsWith('signature'));
|
|
2216
|
+
};
|
|
2217
|
+
const isSigningMessage = (messageName) => Boolean(messageName && /(?:sign|txack|transaction)/i.test(messageName));
|
|
2218
|
+
const redactLogValue = (value, seen) => {
|
|
2219
|
+
if (ArrayBuffer.isView(value)) {
|
|
2220
|
+
return `[BINARY:${value.byteLength}]`;
|
|
2221
|
+
}
|
|
2222
|
+
if (value instanceof ArrayBuffer) {
|
|
2223
|
+
return `[BINARY:${value.byteLength}]`;
|
|
2224
|
+
}
|
|
2225
|
+
if (Array.isArray(value)) {
|
|
2226
|
+
return value.map(item => redactLogValue(item, seen));
|
|
2227
|
+
}
|
|
2228
|
+
if (!value || typeof value !== 'object') {
|
|
2229
|
+
return value;
|
|
2230
|
+
}
|
|
2231
|
+
if (seen.has(value)) {
|
|
2232
|
+
return '[CIRCULAR]';
|
|
2233
|
+
}
|
|
2234
|
+
seen.add(value);
|
|
2235
|
+
const redacted = Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
2236
|
+
key,
|
|
2237
|
+
isSensitiveLogKey(key) && item !== null && item !== undefined
|
|
2238
|
+
? REDACTED
|
|
2239
|
+
: redactLogValue(item, seen),
|
|
2240
|
+
]));
|
|
2241
|
+
seen.delete(value);
|
|
2242
|
+
return redacted;
|
|
2243
|
+
};
|
|
2244
|
+
function getSafeTransportLogPayload(value, messageName) {
|
|
2245
|
+
if (isSigningMessage(messageName)) {
|
|
2246
|
+
return REDACTED;
|
|
2247
|
+
}
|
|
2248
|
+
return redactLogValue(value, new WeakSet());
|
|
2249
|
+
}
|
|
2250
|
+
function createTransportCallLog(name, protocol, data) {
|
|
2251
|
+
return {
|
|
2252
|
+
name,
|
|
2253
|
+
protocol,
|
|
2254
|
+
request: getSafeTransportLogPayload(data, name),
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
const HIGH_VOLUME_CALLS = new Set(['FileWrite', 'FilesystemFileWrite', 'EmmcFileWrite']);
|
|
2258
|
+
function shouldSuppressHighVolumeCallLog(name) {
|
|
2259
|
+
return HIGH_VOLUME_CALLS.has(name);
|
|
2260
|
+
}
|
|
2261
|
+
|
|
1970
2262
|
protobuf__namespace.util.Long = Long__default["default"];
|
|
1971
2263
|
protobuf__namespace.configure();
|
|
1972
2264
|
var index = {
|
|
@@ -2003,29 +2295,38 @@ exports.PROTOCOL_V1_REPORT_ID = PROTOCOL_V1_REPORT_ID;
|
|
|
2003
2295
|
exports.PROTOCOL_V1_USB_PACKET_SIZE = PROTOCOL_V1_USB_PACKET_SIZE;
|
|
2004
2296
|
exports.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE = PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
|
|
2005
2297
|
exports.PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE = PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE;
|
|
2298
|
+
exports.PROTOCOL_V2_BLE_FIRMWARE_FILE_CHUNK_SIZE = PROTOCOL_V2_BLE_FIRMWARE_FILE_CHUNK_SIZE;
|
|
2006
2299
|
exports.PROTOCOL_V2_BLE_FRAME_MAX_BYTES = PROTOCOL_V2_BLE_FRAME_MAX_BYTES;
|
|
2007
2300
|
exports.PROTOCOL_V2_CHANNEL_BLE_UART = PROTOCOL_V2_CHANNEL_BLE_UART;
|
|
2008
2301
|
exports.PROTOCOL_V2_CHANNEL_SOCKET = PROTOCOL_V2_CHANNEL_SOCKET;
|
|
2009
2302
|
exports.PROTOCOL_V2_CHANNEL_USB = PROTOCOL_V2_CHANNEL_USB;
|
|
2303
|
+
exports.PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS = PROTOCOL_V2_DEFAULT_RESPONSE_TIMEOUT_MS;
|
|
2010
2304
|
exports.PROTOCOL_V2_FILE_CHUNK_SIZE = PROTOCOL_V2_FILE_CHUNK_SIZE;
|
|
2011
2305
|
exports.PROTOCOL_V2_FRAME_MAX_BYTES = PROTOCOL_V2_FRAME_MAX_BYTES;
|
|
2012
2306
|
exports.PROTOCOL_V2_PACKET_SRC_COMMAND = PROTOCOL_V2_PACKET_SRC_COMMAND;
|
|
2013
2307
|
exports.PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = PROTOCOL_V2_SYS_MESSAGE_THRESHOLD;
|
|
2014
2308
|
exports.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
2015
|
-
exports.PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS = PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS;
|
|
2016
2309
|
exports.ProtocolV1 = ProtocolV1;
|
|
2017
2310
|
exports.ProtocolV2 = ProtocolV2;
|
|
2018
2311
|
exports.ProtocolV2FrameAssembler = ProtocolV2FrameAssembler;
|
|
2312
|
+
exports.ProtocolV2LinkError = ProtocolV2LinkError;
|
|
2019
2313
|
exports.ProtocolV2LinkManager = ProtocolV2LinkManager;
|
|
2020
2314
|
exports.ProtocolV2SequenceCursor = ProtocolV2SequenceCursor;
|
|
2021
2315
|
exports.ProtocolV2Session = ProtocolV2Session;
|
|
2022
2316
|
exports.ProtocolV2UsbTransportBase = ProtocolV2UsbTransportBase;
|
|
2317
|
+
exports.TRANSPORT_EVENT = TRANSPORT_EVENT;
|
|
2023
2318
|
exports.bytesToHex = bytesToHex;
|
|
2024
2319
|
exports.concatUint8Arrays = concatUint8Arrays;
|
|
2320
|
+
exports.createTransportCallLog = createTransportCallLog;
|
|
2025
2321
|
exports["default"] = index;
|
|
2026
2322
|
exports.getErrorMessage = getErrorMessage;
|
|
2323
|
+
exports.getSafeTransportLogPayload = getSafeTransportLogPayload;
|
|
2027
2324
|
exports.hexToBytes = hexToBytes;
|
|
2325
|
+
exports.isProtocolV2HighThroughputCall = isProtocolV2HighThroughputCall;
|
|
2326
|
+
exports.isProtocolV2LinkError = isProtocolV2LinkError;
|
|
2028
2327
|
exports.probeProtocolV2 = probeProtocolV2;
|
|
2029
2328
|
exports.protocolV1 = index$1;
|
|
2030
2329
|
exports.protocolV2 = protocolV2Codec;
|
|
2330
|
+
exports.shouldSuppressHighVolumeCallLog = shouldSuppressHighVolumeCallLog;
|
|
2031
2331
|
exports.withProtocolTimeout = withProtocolTimeout;
|
|
2332
|
+
exports.writeProtocolV2BleFrame = writeProtocolV2BleFrame;
|