@onekeyfe/hd-transport 1.2.8-alpha.1 → 1.2.8-alpha.100
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__/babylon-context-hash.test.js +44 -0
- package/__tests__/protocol-v2.test.js +3 -3
- package/__tests__/transport-log.test.js +50 -0
- package/dist/index.d.ts +96 -1
- package/dist/index.js +28 -1
- package/dist/types/messages.d.ts +66 -0
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/utils/transportLog.d.ts.map +1 -1
- package/messages-protocol-v2.json +138 -1
- package/package.json +2 -2
- package/scripts/protobuf-build.sh +30 -0
- package/scripts/protobuf-types.js +1 -0
- package/src/types/messages.ts +87 -0
- package/src/utils/transportLog.ts +7 -1
|
@@ -11034,6 +11034,61 @@
|
|
|
11034
11034
|
}
|
|
11035
11035
|
}
|
|
11036
11036
|
},
|
|
11037
|
+
"ZcashSignPczt": {
|
|
11038
|
+
"fields": {
|
|
11039
|
+
"pczt_length": {
|
|
11040
|
+
"rule": "required",
|
|
11041
|
+
"type": "uint32",
|
|
11042
|
+
"id": 1
|
|
11043
|
+
},
|
|
11044
|
+
"pczt_initial_chunk": {
|
|
11045
|
+
"rule": "required",
|
|
11046
|
+
"type": "bytes",
|
|
11047
|
+
"id": 2
|
|
11048
|
+
}
|
|
11049
|
+
}
|
|
11050
|
+
},
|
|
11051
|
+
"ZcashPcztChunkRequest": {
|
|
11052
|
+
"fields": {
|
|
11053
|
+
"chunk_length": {
|
|
11054
|
+
"rule": "required",
|
|
11055
|
+
"type": "uint32",
|
|
11056
|
+
"id": 1
|
|
11057
|
+
}
|
|
11058
|
+
}
|
|
11059
|
+
},
|
|
11060
|
+
"ZcashPcztChunkAck": {
|
|
11061
|
+
"fields": {
|
|
11062
|
+
"data_chunk": {
|
|
11063
|
+
"rule": "required",
|
|
11064
|
+
"type": "bytes",
|
|
11065
|
+
"id": 1
|
|
11066
|
+
}
|
|
11067
|
+
}
|
|
11068
|
+
},
|
|
11069
|
+
"ZcashSignedPczt": {
|
|
11070
|
+
"fields": {
|
|
11071
|
+
"pczt_length": {
|
|
11072
|
+
"rule": "required",
|
|
11073
|
+
"type": "uint32",
|
|
11074
|
+
"id": 1
|
|
11075
|
+
},
|
|
11076
|
+
"pczt_initial_chunk": {
|
|
11077
|
+
"rule": "required",
|
|
11078
|
+
"type": "bytes",
|
|
11079
|
+
"id": 2
|
|
11080
|
+
}
|
|
11081
|
+
}
|
|
11082
|
+
},
|
|
11083
|
+
"ZcashSignedPcztChunkRequest": {
|
|
11084
|
+
"fields": {
|
|
11085
|
+
"chunk_length": {
|
|
11086
|
+
"rule": "required",
|
|
11087
|
+
"type": "uint32",
|
|
11088
|
+
"id": 1
|
|
11089
|
+
}
|
|
11090
|
+
}
|
|
11091
|
+
},
|
|
11037
11092
|
"wire_in": {
|
|
11038
11093
|
"type": "bool",
|
|
11039
11094
|
"id": 50002,
|
|
@@ -11459,6 +11514,11 @@
|
|
|
11459
11514
|
"MessageType_NeoAddress": 12302,
|
|
11460
11515
|
"MessageType_NeoSignTx": 12303,
|
|
11461
11516
|
"MessageType_NeoSignedTx": 12304,
|
|
11517
|
+
"MessageType_ZcashSignPczt": 12402,
|
|
11518
|
+
"MessageType_ZcashSignedPczt": 12403,
|
|
11519
|
+
"MessageType_ZcashPcztChunkRequest": 12404,
|
|
11520
|
+
"MessageType_ZcashPcztChunkAck": 12405,
|
|
11521
|
+
"MessageType_ZcashSignedPcztChunkRequest": 12406,
|
|
11462
11522
|
"MessageType_DeviceFactoryInfoSet": 60000,
|
|
11463
11523
|
"MessageType_DeviceFactoryInfoGet": 60001,
|
|
11464
11524
|
"MessageType_DeviceFactoryInfo": 60002,
|
|
@@ -11511,7 +11571,9 @@
|
|
|
11511
11571
|
"MessageType_PortfolioUpdate": 61400,
|
|
11512
11572
|
"MessageType_NftUpdate": 61500,
|
|
11513
11573
|
"MessageType_OnboardingStatusGet": 61600,
|
|
11514
|
-
"MessageType_OnboardingStatus": 61601
|
|
11574
|
+
"MessageType_OnboardingStatus": 61601,
|
|
11575
|
+
"MessageType_ZcashGetAddress": 12400,
|
|
11576
|
+
"MessageType_ZcashAddress": 12401
|
|
11515
11577
|
},
|
|
11516
11578
|
"reserved": [
|
|
11517
11579
|
[90, 92],
|
|
@@ -13730,6 +13792,81 @@
|
|
|
13730
13792
|
}
|
|
13731
13793
|
}
|
|
13732
13794
|
}
|
|
13795
|
+
},
|
|
13796
|
+
"ZcashAddressType": {
|
|
13797
|
+
"values": {
|
|
13798
|
+
"UNIFIED_ORCHARD_P2PKH": 0,
|
|
13799
|
+
"TRANSPARENT_P2PKH": 1,
|
|
13800
|
+
"UNIFIED_ORCHARD": 2
|
|
13801
|
+
}
|
|
13802
|
+
},
|
|
13803
|
+
"ZcashAddressScope": {
|
|
13804
|
+
"values": {
|
|
13805
|
+
"EXTERNAL": 0,
|
|
13806
|
+
"INTERNAL": 1
|
|
13807
|
+
}
|
|
13808
|
+
},
|
|
13809
|
+
"ZcashGetAddress": {
|
|
13810
|
+
"fields": {
|
|
13811
|
+
"address_n": {
|
|
13812
|
+
"rule": "repeated",
|
|
13813
|
+
"type": "uint32",
|
|
13814
|
+
"id": 1,
|
|
13815
|
+
"options": {
|
|
13816
|
+
"packed": false
|
|
13817
|
+
}
|
|
13818
|
+
},
|
|
13819
|
+
"show_display": {
|
|
13820
|
+
"type": "bool",
|
|
13821
|
+
"id": 2
|
|
13822
|
+
},
|
|
13823
|
+
"include_seed_fingerprint": {
|
|
13824
|
+
"type": "bool",
|
|
13825
|
+
"id": 3
|
|
13826
|
+
},
|
|
13827
|
+
"include_ufvk": {
|
|
13828
|
+
"type": "bool",
|
|
13829
|
+
"id": 4
|
|
13830
|
+
},
|
|
13831
|
+
"diversifier_index": {
|
|
13832
|
+
"type": "uint32",
|
|
13833
|
+
"id": 5,
|
|
13834
|
+
"options": {
|
|
13835
|
+
"default": 0
|
|
13836
|
+
}
|
|
13837
|
+
},
|
|
13838
|
+
"address_type": {
|
|
13839
|
+
"type": "ZcashAddressType",
|
|
13840
|
+
"id": 6,
|
|
13841
|
+
"options": {
|
|
13842
|
+
"default": "UNIFIED_ORCHARD_P2PKH"
|
|
13843
|
+
}
|
|
13844
|
+
},
|
|
13845
|
+
"scope": {
|
|
13846
|
+
"type": "ZcashAddressScope",
|
|
13847
|
+
"id": 7,
|
|
13848
|
+
"options": {
|
|
13849
|
+
"default": "EXTERNAL"
|
|
13850
|
+
}
|
|
13851
|
+
}
|
|
13852
|
+
}
|
|
13853
|
+
},
|
|
13854
|
+
"ZcashAddress": {
|
|
13855
|
+
"fields": {
|
|
13856
|
+
"address": {
|
|
13857
|
+
"rule": "required",
|
|
13858
|
+
"type": "string",
|
|
13859
|
+
"id": 1
|
|
13860
|
+
},
|
|
13861
|
+
"ufvk": {
|
|
13862
|
+
"type": "string",
|
|
13863
|
+
"id": 2
|
|
13864
|
+
},
|
|
13865
|
+
"seed_fingerprint": {
|
|
13866
|
+
"type": "bytes",
|
|
13867
|
+
"id": 3
|
|
13868
|
+
}
|
|
13869
|
+
}
|
|
13733
13870
|
}
|
|
13734
13871
|
}
|
|
13735
13872
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport",
|
|
3
|
-
"version": "1.2.8-alpha.
|
|
3
|
+
"version": "1.2.8-alpha.100",
|
|
4
4
|
"description": "Transport layer abstractions and utilities for OneKey hardware SDK.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"long": "^4.0.0",
|
|
29
29
|
"protobufjs": "^6.11.2"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "53ada5b79a51f0edf8a7392f70c8da063144d33c"
|
|
32
32
|
}
|
|
@@ -54,6 +54,36 @@ grep -hv -e '^import ' -e '^syntax' -e '^package' -e 'option java_' "$SRC_PATH"/
|
|
|
54
54
|
| sed 's/^option /\/\/ option /' \
|
|
55
55
|
| grep -v ' reserved ' >> "$V1_TMP_PROTO"
|
|
56
56
|
|
|
57
|
+
# Classic 1s exposes these messages before the shared firmware submodule includes them.
|
|
58
|
+
# Wire contract: https://onekeygroup.slack.com/archives/C0A7BUG1DT6/p1791598732003599
|
|
59
|
+
node - "$V1_TMP_PROTO" <<'NODE'
|
|
60
|
+
const fs = require('fs');
|
|
61
|
+
const protoPath = process.argv[2];
|
|
62
|
+
let proto = fs.readFileSync(protoPath, 'utf8');
|
|
63
|
+
proto = proto.replace('enum MessageType {', `enum MessageType {
|
|
64
|
+
MessageType_BabylonDeriveContextHash = 10054 [(bitcoin_only) = true, (wire_in) = true];
|
|
65
|
+
MessageType_BabylonDerivedContextHash = 10055 [(bitcoin_only) = true, (wire_out) = true];`);
|
|
66
|
+
proto += `
|
|
67
|
+
enum CanonicalBitcoinNetwork {
|
|
68
|
+
BITCOIN_MAINNET = 0;
|
|
69
|
+
BITCOIN_TESTNET = 1;
|
|
70
|
+
BITCOIN_SIGNET = 2;
|
|
71
|
+
BITCOIN_REGTEST = 3;
|
|
72
|
+
}
|
|
73
|
+
message BabylonDeriveContextHash {
|
|
74
|
+
repeated uint32 address_n = 1;
|
|
75
|
+
required InputScriptType script_type = 2;
|
|
76
|
+
required bytes app_name = 3;
|
|
77
|
+
required bytes context = 4;
|
|
78
|
+
required CanonicalBitcoinNetwork network = 5;
|
|
79
|
+
}
|
|
80
|
+
message BabylonDerivedContextHash {
|
|
81
|
+
required bytes secret = 1;
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
fs.writeFileSync(protoPath, proto);
|
|
85
|
+
NODE
|
|
86
|
+
|
|
57
87
|
npx pbjs -t json -p "$DIST_PATH" -o "$DIST_PATH/messages.json" --keep-case "$V1_TMP_PROTO"
|
|
58
88
|
cp "$DIST_PATH/messages.json" "$CORE_MESSAGES_DIR/messages.json"
|
|
59
89
|
|
|
@@ -55,6 +55,7 @@ const hasParsedType = name => types.some(t => t && t.name === name);
|
|
|
55
55
|
// enums used as keys (string), used as values (number) by default
|
|
56
56
|
const ENUM_KEYS = [
|
|
57
57
|
'InputScriptType',
|
|
58
|
+
'CanonicalBitcoinNetwork',
|
|
58
59
|
'OutputScriptType',
|
|
59
60
|
'RequestType',
|
|
60
61
|
'KaspaInputScriptType',
|
package/src/types/messages.ts
CHANGED
|
@@ -4554,6 +4554,28 @@ export enum CommandFlags {
|
|
|
4554
4554
|
Factory_Only = 1,
|
|
4555
4555
|
}
|
|
4556
4556
|
|
|
4557
|
+
export enum Enum_CanonicalBitcoinNetwork {
|
|
4558
|
+
BITCOIN_MAINNET = 0,
|
|
4559
|
+
BITCOIN_TESTNET = 1,
|
|
4560
|
+
BITCOIN_SIGNET = 2,
|
|
4561
|
+
BITCOIN_REGTEST = 3,
|
|
4562
|
+
}
|
|
4563
|
+
export type CanonicalBitcoinNetwork = keyof typeof Enum_CanonicalBitcoinNetwork;
|
|
4564
|
+
|
|
4565
|
+
// BabylonDeriveContextHash
|
|
4566
|
+
export type BabylonDeriveContextHash = {
|
|
4567
|
+
address_n: number[];
|
|
4568
|
+
script_type: InputScriptType;
|
|
4569
|
+
app_name: string;
|
|
4570
|
+
context: string;
|
|
4571
|
+
network: CanonicalBitcoinNetwork;
|
|
4572
|
+
};
|
|
4573
|
+
|
|
4574
|
+
// BabylonDerivedContextHash
|
|
4575
|
+
export type BabylonDerivedContextHash = {
|
|
4576
|
+
secret: string;
|
|
4577
|
+
};
|
|
4578
|
+
|
|
4557
4579
|
export type TextMemo = {
|
|
4558
4580
|
text: string;
|
|
4559
4581
|
};
|
|
@@ -4658,6 +4680,33 @@ export type UiAnimationRequest = {
|
|
|
4658
4680
|
type?: UiAnimationType;
|
|
4659
4681
|
};
|
|
4660
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
|
+
|
|
4661
4710
|
// experimental_message
|
|
4662
4711
|
export type experimental_message = {};
|
|
4663
4712
|
|
|
@@ -5352,6 +5401,35 @@ export type ViewVerifyPage = {
|
|
|
5352
5401
|
content?: ViewContentPreview;
|
|
5353
5402
|
};
|
|
5354
5403
|
|
|
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
|
+
|
|
5355
5433
|
export enum ProtocolV2FailureType {
|
|
5356
5434
|
Failure_InvalidMessage = 1,
|
|
5357
5435
|
Failure_UndefinedError = 2,
|
|
@@ -5949,6 +6027,8 @@ export type MessageType = {
|
|
|
5949
6027
|
TronSignMessage: TronSignMessage;
|
|
5950
6028
|
TronMessageSignature: TronMessageSignature;
|
|
5951
6029
|
facotry: facotry;
|
|
6030
|
+
BabylonDeriveContextHash: BabylonDeriveContextHash;
|
|
6031
|
+
BabylonDerivedContextHash: BabylonDerivedContextHash;
|
|
5952
6032
|
TextMemo: TextMemo;
|
|
5953
6033
|
RefundMemo: RefundMemo;
|
|
5954
6034
|
CoinPurchaseMemo: CoinPurchaseMemo;
|
|
@@ -5964,6 +6044,11 @@ export type MessageType = {
|
|
|
5964
6044
|
UnlockPath: UnlockPath;
|
|
5965
6045
|
UnlockedPathRequest: UnlockedPathRequest;
|
|
5966
6046
|
UiAnimationRequest: UiAnimationRequest;
|
|
6047
|
+
ZcashSignPczt: ZcashSignPczt;
|
|
6048
|
+
ZcashPcztChunkRequest: ZcashPcztChunkRequest;
|
|
6049
|
+
ZcashPcztChunkAck: ZcashPcztChunkAck;
|
|
6050
|
+
ZcashSignedPczt: ZcashSignedPczt;
|
|
6051
|
+
ZcashSignedPcztChunkRequest: ZcashSignedPcztChunkRequest;
|
|
5967
6052
|
experimental_message: experimental_message;
|
|
5968
6053
|
experimental_field: experimental_field;
|
|
5969
6054
|
ProtocolInfoRequest: ProtocolInfoRequest;
|
|
@@ -6040,6 +6125,8 @@ export type MessageType = {
|
|
|
6040
6125
|
ViewSignPage: ViewSignPage;
|
|
6041
6126
|
ViewWarningPage: ViewWarningPage;
|
|
6042
6127
|
ViewVerifyPage: ViewVerifyPage;
|
|
6128
|
+
ZcashGetAddress: ZcashGetAddress;
|
|
6129
|
+
ZcashAddress: ZcashAddress;
|
|
6043
6130
|
};
|
|
6044
6131
|
|
|
6045
6132
|
export type MessageKey = keyof MessageType;
|
|
@@ -7,6 +7,7 @@ const SENSITIVE_LOG_KEYS = new Set([
|
|
|
7
7
|
'address',
|
|
8
8
|
'apikey',
|
|
9
9
|
'connectid',
|
|
10
|
+
'datachunk',
|
|
10
11
|
'devicestate',
|
|
11
12
|
'deviceid',
|
|
12
13
|
'entropy',
|
|
@@ -15,15 +16,20 @@ const SENSITIVE_LOG_KEYS = new Set([
|
|
|
15
16
|
'passphrase',
|
|
16
17
|
'passphrasestate',
|
|
17
18
|
'password',
|
|
19
|
+
'pczt',
|
|
18
20
|
'pin',
|
|
19
21
|
'privatekey',
|
|
20
22
|
'publickey',
|
|
21
23
|
'seed',
|
|
24
|
+
'secret',
|
|
25
|
+
'seedfingerprint',
|
|
22
26
|
'serialnumber',
|
|
23
27
|
'session',
|
|
24
28
|
'sessionid',
|
|
25
29
|
'signature',
|
|
30
|
+
'signedpczt',
|
|
26
31
|
'token',
|
|
32
|
+
'ufvk',
|
|
27
33
|
'uuid',
|
|
28
34
|
'walletsessionid',
|
|
29
35
|
'xprv',
|
|
@@ -44,7 +50,7 @@ const isSensitiveLogKey = (key: string) => {
|
|
|
44
50
|
};
|
|
45
51
|
|
|
46
52
|
const isSigningMessage = (messageName?: string) =>
|
|
47
|
-
Boolean(messageName && /(?:sign|txack|transaction)/i.test(messageName));
|
|
53
|
+
Boolean(messageName && /(?:sign|txack|transaction|pczt)/i.test(messageName));
|
|
48
54
|
|
|
49
55
|
const redactLogValue = (value: unknown, seen: WeakSet<object>): unknown => {
|
|
50
56
|
if (ArrayBuffer.isView(value)) {
|