@onekeyfe/hd-transport 1.2.8-alpha.111 → 1.2.8-alpha.113
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__/protocol-v2-file-write-pipeline.test.js +417 -0
- package/__tests__/transport-log.test.js +0 -44
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +42 -68
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +187 -57
- package/dist/protocols/v2/session.d.ts +4 -1
- package/dist/protocols/v2/session.d.ts.map +1 -1
- package/dist/types/messages.d.ts +0 -47
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/transport.d.ts +5 -0
- package/dist/types/transport.d.ts.map +1 -1
- package/dist/utils/transportLog.d.ts.map +1 -1
- package/messages-protocol-v2.json +1 -138
- package/package.json +2 -2
- package/src/constants.ts +7 -0
- package/src/index.ts +1 -0
- package/src/protocols/v2/session.ts +300 -63
- package/src/types/messages.ts +0 -63
- package/src/types/transport.ts +19 -0
- package/src/utils/transportLog.ts +1 -6
package/src/types/messages.ts
CHANGED
|
@@ -4680,33 +4680,6 @@ export type UiAnimationRequest = {
|
|
|
4680
4680
|
type?: UiAnimationType;
|
|
4681
4681
|
};
|
|
4682
4682
|
|
|
4683
|
-
// ZcashSignPczt
|
|
4684
|
-
export type ZcashSignPczt = {
|
|
4685
|
-
pczt_length: number;
|
|
4686
|
-
pczt_initial_chunk: string;
|
|
4687
|
-
};
|
|
4688
|
-
|
|
4689
|
-
// ZcashPcztChunkRequest
|
|
4690
|
-
export type ZcashPcztChunkRequest = {
|
|
4691
|
-
chunk_length: number;
|
|
4692
|
-
};
|
|
4693
|
-
|
|
4694
|
-
// ZcashPcztChunkAck
|
|
4695
|
-
export type ZcashPcztChunkAck = {
|
|
4696
|
-
data_chunk: string;
|
|
4697
|
-
};
|
|
4698
|
-
|
|
4699
|
-
// ZcashSignedPczt
|
|
4700
|
-
export type ZcashSignedPczt = {
|
|
4701
|
-
pczt_length: number;
|
|
4702
|
-
pczt_initial_chunk: string;
|
|
4703
|
-
};
|
|
4704
|
-
|
|
4705
|
-
// ZcashSignedPcztChunkRequest
|
|
4706
|
-
export type ZcashSignedPcztChunkRequest = {
|
|
4707
|
-
chunk_length: number;
|
|
4708
|
-
};
|
|
4709
|
-
|
|
4710
4683
|
// experimental_message
|
|
4711
4684
|
export type experimental_message = {};
|
|
4712
4685
|
|
|
@@ -5401,35 +5374,6 @@ export type ViewVerifyPage = {
|
|
|
5401
5374
|
content?: ViewContentPreview;
|
|
5402
5375
|
};
|
|
5403
5376
|
|
|
5404
|
-
export enum ZcashAddressType {
|
|
5405
|
-
UNIFIED_ORCHARD_P2PKH = 0,
|
|
5406
|
-
TRANSPARENT_P2PKH = 1,
|
|
5407
|
-
UNIFIED_ORCHARD = 2,
|
|
5408
|
-
}
|
|
5409
|
-
|
|
5410
|
-
export enum ZcashAddressScope {
|
|
5411
|
-
EXTERNAL = 0,
|
|
5412
|
-
INTERNAL = 1,
|
|
5413
|
-
}
|
|
5414
|
-
|
|
5415
|
-
// ZcashGetAddress
|
|
5416
|
-
export type ZcashGetAddress = {
|
|
5417
|
-
address_n: number[];
|
|
5418
|
-
show_display?: boolean;
|
|
5419
|
-
include_seed_fingerprint?: boolean;
|
|
5420
|
-
include_ufvk?: boolean;
|
|
5421
|
-
diversifier_index?: number;
|
|
5422
|
-
address_type?: ZcashAddressType;
|
|
5423
|
-
scope?: ZcashAddressScope;
|
|
5424
|
-
};
|
|
5425
|
-
|
|
5426
|
-
// ZcashAddress
|
|
5427
|
-
export type ZcashAddress = {
|
|
5428
|
-
address: string;
|
|
5429
|
-
ufvk?: string;
|
|
5430
|
-
seed_fingerprint?: string;
|
|
5431
|
-
};
|
|
5432
|
-
|
|
5433
5377
|
export enum ProtocolV2FailureType {
|
|
5434
5378
|
Failure_InvalidMessage = 1,
|
|
5435
5379
|
Failure_UndefinedError = 2,
|
|
@@ -6044,11 +5988,6 @@ export type MessageType = {
|
|
|
6044
5988
|
UnlockPath: UnlockPath;
|
|
6045
5989
|
UnlockedPathRequest: UnlockedPathRequest;
|
|
6046
5990
|
UiAnimationRequest: UiAnimationRequest;
|
|
6047
|
-
ZcashSignPczt: ZcashSignPczt;
|
|
6048
|
-
ZcashPcztChunkRequest: ZcashPcztChunkRequest;
|
|
6049
|
-
ZcashPcztChunkAck: ZcashPcztChunkAck;
|
|
6050
|
-
ZcashSignedPczt: ZcashSignedPczt;
|
|
6051
|
-
ZcashSignedPcztChunkRequest: ZcashSignedPcztChunkRequest;
|
|
6052
5991
|
experimental_message: experimental_message;
|
|
6053
5992
|
experimental_field: experimental_field;
|
|
6054
5993
|
ProtocolInfoRequest: ProtocolInfoRequest;
|
|
@@ -6125,8 +6064,6 @@ export type MessageType = {
|
|
|
6125
6064
|
ViewSignPage: ViewSignPage;
|
|
6126
6065
|
ViewWarningPage: ViewWarningPage;
|
|
6127
6066
|
ViewVerifyPage: ViewVerifyPage;
|
|
6128
|
-
ZcashGetAddress: ZcashGetAddress;
|
|
6129
|
-
ZcashAddress: ZcashAddress;
|
|
6130
6067
|
};
|
|
6131
6068
|
|
|
6132
6069
|
export type MessageKey = keyof MessageType;
|
package/src/types/transport.ts
CHANGED
|
@@ -70,6 +70,19 @@ export type TransportWriteMetrics = {
|
|
|
70
70
|
frameBytes: number;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Supplies the remaining chunks of one file for an ordered FilesystemFileWrite pipeline.
|
|
75
|
+
* The call's request data is the first chunk; `next` returns the following chunk in offset
|
|
76
|
+
* order, or undefined to stop. The call then resolves with the last confirmation (or the
|
|
77
|
+
* device Failure), so the caller must check `processed_byte` for completeness. Callbacks
|
|
78
|
+
* should not throw: an error escapes with chunks still in flight and invalidates the link.
|
|
79
|
+
*/
|
|
80
|
+
export type ProtocolV2FileWritePipeline = {
|
|
81
|
+
next: () => Promise<Record<string, unknown> | undefined>;
|
|
82
|
+
/** Called for each chunk after the device confirms it, in offset order. */
|
|
83
|
+
onResponse: (response: MessageFromOneKey) => void;
|
|
84
|
+
};
|
|
85
|
+
|
|
73
86
|
export type TransportCallOptions = {
|
|
74
87
|
timeoutMs?: number;
|
|
75
88
|
expectedTypes?: string[];
|
|
@@ -83,6 +96,12 @@ export type TransportCallOptions = {
|
|
|
83
96
|
onResponseAfterWrite?: (response: MessageFromOneKey) => void;
|
|
84
97
|
/** Prefer acknowledged BLE characteristic writes for this call when supported. */
|
|
85
98
|
writeWithResponse?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Protocol V2 only: keep up to PROTOCOL_V2_FILE_WRITE_PIPELINE_WINDOW ordered
|
|
101
|
+
* FilesystemFileWrite frames of one file in flight within this call. `timeoutMs`
|
|
102
|
+
* bounds each frame write and each response instead of the whole file.
|
|
103
|
+
*/
|
|
104
|
+
fileWritePipeline?: ProtocolV2FileWritePipeline;
|
|
86
105
|
};
|
|
87
106
|
|
|
88
107
|
type ITransportInitFn = (
|
|
@@ -7,7 +7,6 @@ const SENSITIVE_LOG_KEYS = new Set([
|
|
|
7
7
|
'address',
|
|
8
8
|
'apikey',
|
|
9
9
|
'connectid',
|
|
10
|
-
'datachunk',
|
|
11
10
|
'devicestate',
|
|
12
11
|
'deviceid',
|
|
13
12
|
'entropy',
|
|
@@ -16,20 +15,16 @@ const SENSITIVE_LOG_KEYS = new Set([
|
|
|
16
15
|
'passphrase',
|
|
17
16
|
'passphrasestate',
|
|
18
17
|
'password',
|
|
19
|
-
'pczt',
|
|
20
18
|
'pin',
|
|
21
19
|
'privatekey',
|
|
22
20
|
'publickey',
|
|
23
21
|
'seed',
|
|
24
22
|
'secret',
|
|
25
|
-
'seedfingerprint',
|
|
26
23
|
'serialnumber',
|
|
27
24
|
'session',
|
|
28
25
|
'sessionid',
|
|
29
26
|
'signature',
|
|
30
|
-
'signedpczt',
|
|
31
27
|
'token',
|
|
32
|
-
'ufvk',
|
|
33
28
|
'uuid',
|
|
34
29
|
'walletsessionid',
|
|
35
30
|
'xprv',
|
|
@@ -50,7 +45,7 @@ const isSensitiveLogKey = (key: string) => {
|
|
|
50
45
|
};
|
|
51
46
|
|
|
52
47
|
const isSigningMessage = (messageName?: string) =>
|
|
53
|
-
Boolean(messageName && /(?:sign|txack|transaction
|
|
48
|
+
Boolean(messageName && /(?:sign|txack|transaction)/i.test(messageName));
|
|
54
49
|
|
|
55
50
|
const redactLogValue = (value: unknown, seen: WeakSet<object>): unknown => {
|
|
56
51
|
if (ArrayBuffer.isView(value)) {
|