@onekeyfe/hd-transport 1.2.8-alpha.10 → 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__/messages.test.js +0 -67
- package/__tests__/protocol-v2.test.js +3 -3
- package/__tests__/transport-log.test.js +44 -0
- package/dist/index.d.ts +68 -1
- package/dist/index.js +50 -252502
- package/dist/protocols/index.d.ts.map +1 -1
- package/dist/serialization/protobuf/messages.d.ts.map +1 -1
- package/dist/types/messages.d.ts +47 -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 +5 -5
- package/src/protocols/index.ts +23 -9
- package/src/serialization/protobuf/messages.ts +3 -34
- package/src/types/messages.ts +63 -0
- package/src/utils/transportLog.ts +6 -1
- package/lib/protobuf-static.d.ts +0 -5
- package/lib/protobuf-static.js +0 -252460
- package/scripts/protobuf-static.js +0 -105
|
@@ -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",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"dev": "
|
|
15
|
-
"build": "
|
|
16
|
-
"test": "
|
|
14
|
+
"dev": "rimraf dist && rollup -c ../../build/rollup.config.js -w",
|
|
15
|
+
"build": "rimraf dist && rollup -c ../../build/rollup.config.js",
|
|
16
|
+
"test": "jest",
|
|
17
17
|
"lint": "eslint .",
|
|
18
18
|
"lint:fix": "eslint . --fix",
|
|
19
19
|
"update:protobuf": "./scripts/protobuf-build.sh"
|
|
@@ -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
|
}
|
package/src/protocols/index.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import ByteBuffer from 'bytebuffer';
|
|
2
|
-
import { Reader } from 'protobufjs/light';
|
|
2
|
+
import { Reader, Type } from 'protobufjs/light';
|
|
3
3
|
|
|
4
4
|
import { encodeEnvelopeMessage, encodeMessageChunks, encodeTransportPackets } from './v1/packets';
|
|
5
5
|
import { decodeFirstChunk } from './v1/decode';
|
|
6
6
|
import { decodeMessage as decodeV1Message } from './v1/receive';
|
|
7
|
-
import {
|
|
8
|
-
createMessageFromName,
|
|
9
|
-
createMessageFromType,
|
|
10
|
-
parseConfigure,
|
|
11
|
-
} from '../serialization/protobuf/messages';
|
|
7
|
+
import { createMessageFromName, createMessageFromType } from '../serialization/protobuf/messages';
|
|
12
8
|
import { encode as encodeProtobuf } from '../serialization/protobuf/encode';
|
|
13
9
|
import { decode as decodeProtobuf } from '../serialization/protobuf/decode';
|
|
14
|
-
import { legacyProtocolInfoSchema } from '../../lib/protobuf-static';
|
|
15
10
|
import {
|
|
16
11
|
decodeFrame as decodeV2Frame,
|
|
17
12
|
encodeProtobufFrame,
|
|
@@ -35,8 +30,27 @@ type ProtocolV2FrameOptions = {
|
|
|
35
30
|
seq?: number;
|
|
36
31
|
};
|
|
37
32
|
|
|
38
|
-
const LEGACY_PROTOCOL_V2_PROTOCOL_INFO =
|
|
39
|
-
|
|
33
|
+
const LEGACY_PROTOCOL_V2_PROTOCOL_INFO = Type.fromJSON('LegacyProtocolInfo', {
|
|
34
|
+
fields: {
|
|
35
|
+
version: {
|
|
36
|
+
rule: 'required',
|
|
37
|
+
type: 'uint32',
|
|
38
|
+
id: 1,
|
|
39
|
+
},
|
|
40
|
+
supported_messages: {
|
|
41
|
+
rule: 'repeated',
|
|
42
|
+
type: 'uint32',
|
|
43
|
+
id: 2,
|
|
44
|
+
options: {
|
|
45
|
+
packed: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
protobuf_definition: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
id: 3,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
40
54
|
|
|
41
55
|
const decodeLegacyProtocolV2ProtocolInfo = (pbPayload: Uint8Array) => {
|
|
42
56
|
const byteBuffer = ByteBuffer.wrap(Buffer.from(pbPayload) as unknown as ArrayBuffer);
|
|
@@ -1,42 +1,11 @@
|
|
|
1
1
|
import * as protobuf from 'protobufjs/light';
|
|
2
2
|
|
|
3
|
-
import { schemaKey, schemas } from '../../../lib/protobuf-static';
|
|
4
|
-
|
|
5
3
|
export function parseConfigure(data: protobuf.INamespace) {
|
|
6
4
|
// @ts-ignore [compatiblity]: connect is sending stringified json
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const createConstructors = schemas[key];
|
|
10
|
-
// Field resolution mutates options; keep built-in descriptors reusable across connections.
|
|
11
|
-
const messages = protobuf.Root.fromJSON(
|
|
12
|
-
createConstructors ? JSON.parse(JSON.stringify(schema)) : schema
|
|
13
|
-
);
|
|
14
|
-
if (createConstructors) {
|
|
15
|
-
const constructors = createConstructors();
|
|
16
|
-
const types: protobuf.Type[] = [];
|
|
17
|
-
const collect = (namespace: protobuf.Namespace) => {
|
|
18
|
-
if (namespace instanceof protobuf.Type) types.push(namespace);
|
|
19
|
-
namespace.nestedArray.forEach(child => {
|
|
20
|
-
if (child instanceof protobuf.Namespace) collect(child);
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
collect(messages);
|
|
24
|
-
// Register every constructor before resolving fields, which access parent.ctor.
|
|
25
|
-
types.forEach(type => {
|
|
26
|
-
type.ctor = constructors[type.fullName];
|
|
27
|
-
});
|
|
28
|
-
types.forEach(type => {
|
|
29
|
-
const constructor = constructors[type.fullName];
|
|
30
|
-
type.encode = constructor.encode;
|
|
31
|
-
type.decode = constructor.decode;
|
|
32
|
-
type.verify = constructor.verify;
|
|
33
|
-
type.fromObject = constructor.fromObject;
|
|
34
|
-
type.toObject = constructor.toObject;
|
|
35
|
-
type.setup = () => type;
|
|
36
|
-
});
|
|
37
|
-
messages.resolveAll();
|
|
5
|
+
if (typeof data === 'string') {
|
|
6
|
+
return protobuf.Root.fromJSON(JSON.parse(data));
|
|
38
7
|
}
|
|
39
|
-
return
|
|
8
|
+
return protobuf.Root.fromJSON(data);
|
|
40
9
|
}
|
|
41
10
|
|
|
42
11
|
export const createMessageFromName = (messages: protobuf.Root, name: string) => {
|
package/src/types/messages.ts
CHANGED
|
@@ -4680,6 +4680,33 @@ 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
|
+
|
|
4683
4710
|
// experimental_message
|
|
4684
4711
|
export type experimental_message = {};
|
|
4685
4712
|
|
|
@@ -5374,6 +5401,35 @@ export type ViewVerifyPage = {
|
|
|
5374
5401
|
content?: ViewContentPreview;
|
|
5375
5402
|
};
|
|
5376
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
|
+
|
|
5377
5433
|
export enum ProtocolV2FailureType {
|
|
5378
5434
|
Failure_InvalidMessage = 1,
|
|
5379
5435
|
Failure_UndefinedError = 2,
|
|
@@ -5988,6 +6044,11 @@ export type MessageType = {
|
|
|
5988
6044
|
UnlockPath: UnlockPath;
|
|
5989
6045
|
UnlockedPathRequest: UnlockedPathRequest;
|
|
5990
6046
|
UiAnimationRequest: UiAnimationRequest;
|
|
6047
|
+
ZcashSignPczt: ZcashSignPczt;
|
|
6048
|
+
ZcashPcztChunkRequest: ZcashPcztChunkRequest;
|
|
6049
|
+
ZcashPcztChunkAck: ZcashPcztChunkAck;
|
|
6050
|
+
ZcashSignedPczt: ZcashSignedPczt;
|
|
6051
|
+
ZcashSignedPcztChunkRequest: ZcashSignedPcztChunkRequest;
|
|
5991
6052
|
experimental_message: experimental_message;
|
|
5992
6053
|
experimental_field: experimental_field;
|
|
5993
6054
|
ProtocolInfoRequest: ProtocolInfoRequest;
|
|
@@ -6064,6 +6125,8 @@ export type MessageType = {
|
|
|
6064
6125
|
ViewSignPage: ViewSignPage;
|
|
6065
6126
|
ViewWarningPage: ViewWarningPage;
|
|
6066
6127
|
ViewVerifyPage: ViewVerifyPage;
|
|
6128
|
+
ZcashGetAddress: ZcashGetAddress;
|
|
6129
|
+
ZcashAddress: ZcashAddress;
|
|
6067
6130
|
};
|
|
6068
6131
|
|
|
6069
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,16 +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',
|
|
22
24
|
'secret',
|
|
25
|
+
'seedfingerprint',
|
|
23
26
|
'serialnumber',
|
|
24
27
|
'session',
|
|
25
28
|
'sessionid',
|
|
26
29
|
'signature',
|
|
30
|
+
'signedpczt',
|
|
27
31
|
'token',
|
|
32
|
+
'ufvk',
|
|
28
33
|
'uuid',
|
|
29
34
|
'walletsessionid',
|
|
30
35
|
'xprv',
|
|
@@ -45,7 +50,7 @@ const isSensitiveLogKey = (key: string) => {
|
|
|
45
50
|
};
|
|
46
51
|
|
|
47
52
|
const isSigningMessage = (messageName?: string) =>
|
|
48
|
-
Boolean(messageName && /(?:sign|txack|transaction)/i.test(messageName));
|
|
53
|
+
Boolean(messageName && /(?:sign|txack|transaction|pczt)/i.test(messageName));
|
|
49
54
|
|
|
50
55
|
const redactLogValue = (value: unknown, seen: WeakSet<object>): unknown => {
|
|
51
56
|
if (ArrayBuffer.isView(value)) {
|
package/lib/protobuf-static.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Constructor, INamespace, Type } from 'protobufjs/light';
|
|
2
|
-
type StaticMessageConstructor = Constructor<{}> & Pick<Type, 'encode' | 'decode' | 'verify' | 'fromObject' | 'toObject'>;
|
|
3
|
-
export function schemaKey(schema: INamespace): string;
|
|
4
|
-
export const schemas: Partial<Record<string, () => Record<string, StaticMessageConstructor>>>;
|
|
5
|
-
export const legacyProtocolInfoSchema: INamespace;
|