@onekeyfe/hd-transport 1.2.10-alpha.2 → 1.2.10-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11034,94 +11034,6 @@
11034
11034
  }
11035
11035
  }
11036
11036
  },
11037
- "ZcashAddressType": {
11038
- "values": {
11039
- "UNIFIED_ORCHARD_P2PKH": 0,
11040
- "TRANSPARENT_P2PKH": 1,
11041
- "UNIFIED_ORCHARD": 2
11042
- }
11043
- },
11044
- "ZcashAddressScope": {
11045
- "values": {
11046
- "EXTERNAL": 0,
11047
- "INTERNAL": 1
11048
- }
11049
- },
11050
- "ZcashGetAddress": {
11051
- "fields": {
11052
- "address_n": {
11053
- "rule": "repeated",
11054
- "type": "uint32",
11055
- "id": 1,
11056
- "options": {
11057
- "packed": false
11058
- }
11059
- },
11060
- "show_display": {
11061
- "type": "bool",
11062
- "id": 2
11063
- },
11064
- "include_seed_fingerprint": {
11065
- "type": "bool",
11066
- "id": 3
11067
- },
11068
- "diversifier_index": {
11069
- "type": "uint32",
11070
- "id": 5,
11071
- "options": {
11072
- "default": 0
11073
- }
11074
- },
11075
- "address_type": {
11076
- "type": "ZcashAddressType",
11077
- "id": 6,
11078
- "options": {
11079
- "default": "UNIFIED_ORCHARD_P2PKH"
11080
- }
11081
- },
11082
- "scope": {
11083
- "type": "ZcashAddressScope",
11084
- "id": 7,
11085
- "options": {
11086
- "default": "EXTERNAL"
11087
- }
11088
- }
11089
- }
11090
- },
11091
- "ZcashAddress": {
11092
- "fields": {
11093
- "address": {
11094
- "rule": "required",
11095
- "type": "string",
11096
- "id": 1
11097
- },
11098
- "seed_fingerprint": {
11099
- "type": "bytes",
11100
- "id": 3
11101
- }
11102
- }
11103
- },
11104
- "ZcashGetFullViewingKey": {
11105
- "fields": {
11106
- "address_n": {
11107
- "rule": "repeated",
11108
- "type": "uint32",
11109
- "id": 1,
11110
- "options": {
11111
- "packed": false
11112
- }
11113
- }
11114
- }
11115
- },
11116
- "ZcashFullViewingKey": {
11117
- "fields": {
11118
- "ufvk": {
11119
- "rule": "required",
11120
- "type": "string",
11121
- "id": 1
11122
- }
11123
- }
11124
- },
11125
11037
  "ZcashSignPczt": {
11126
11038
  "fields": {
11127
11039
  "pczt_length": {
@@ -11602,15 +11514,11 @@
11602
11514
  "MessageType_NeoAddress": 12302,
11603
11515
  "MessageType_NeoSignTx": 12303,
11604
11516
  "MessageType_NeoSignedTx": 12304,
11605
- "MessageType_ZcashGetAddress": 12400,
11606
- "MessageType_ZcashAddress": 12401,
11607
11517
  "MessageType_ZcashSignPczt": 12402,
11608
11518
  "MessageType_ZcashSignedPczt": 12403,
11609
11519
  "MessageType_ZcashPcztChunkRequest": 12404,
11610
11520
  "MessageType_ZcashPcztChunkAck": 12405,
11611
11521
  "MessageType_ZcashSignedPcztChunkRequest": 12406,
11612
- "MessageType_ZcashGetFullViewingKey": 12407,
11613
- "MessageType_ZcashFullViewingKey": 12408,
11614
11522
  "MessageType_DeviceFactoryInfoSet": 60000,
11615
11523
  "MessageType_DeviceFactoryInfoGet": 60001,
11616
11524
  "MessageType_DeviceFactoryInfo": 60002,
@@ -11663,7 +11571,9 @@
11663
11571
  "MessageType_PortfolioUpdate": 61400,
11664
11572
  "MessageType_NftUpdate": 61500,
11665
11573
  "MessageType_OnboardingStatusGet": 61600,
11666
- "MessageType_OnboardingStatus": 61601
11574
+ "MessageType_OnboardingStatus": 61601,
11575
+ "MessageType_ZcashGetAddress": 12400,
11576
+ "MessageType_ZcashAddress": 12401
11667
11577
  },
11668
11578
  "reserved": [
11669
11579
  [90, 92],
@@ -13882,6 +13792,81 @@
13882
13792
  }
13883
13793
  }
13884
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
+ }
13885
13870
  }
13886
13871
  }
13887
13872
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport",
3
- "version": "1.2.10-alpha.2",
3
+ "version": "1.2.10-alpha.3",
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",
@@ -12,10 +12,8 @@
12
12
  },
13
13
  "scripts": {
14
14
  "dev": "rimraf dist && rollup -c ../../build/rollup.config.js -w",
15
- "build": "node scripts/protobuf-static.js --check && rimraf dist && rollup -c ../../build/rollup.config.js",
15
+ "build": "rimraf dist && rollup -c ../../build/rollup.config.js",
16
16
  "test": "jest",
17
- "test:static-csp": "node --disallow-code-generation-from-strings scripts/protobuf-static-csp.js",
18
- "check:static": "node scripts/protobuf-static.js --check",
19
17
  "lint": "eslint .",
20
18
  "lint:fix": "eslint . --fix",
21
19
  "update:protobuf": "./scripts/protobuf-build.sh"
@@ -28,7 +26,7 @@
28
26
  "dependencies": {
29
27
  "bytebuffer": "^5.0.1",
30
28
  "long": "^4.0.0",
31
- "protobufjs": "6.11.6"
29
+ "protobufjs": "^6.11.2"
32
30
  },
33
- "gitHead": "2bcc72a43379abb005405f18f914330f3f2dbfd7"
31
+ "gitHead": "7ea778fa7f33611198758436b09e26df68cbc0e8"
34
32
  }
@@ -7,11 +7,6 @@ PACKAGE_ROOT="$PARENT_PATH/.."
7
7
  REPO_ROOT="$PARENT_PATH/../../.."
8
8
  CORE_MESSAGES_DIR="$REPO_ROOT/packages/core/src/data/messages"
9
9
 
10
- if [[ "${1:-}" == "--static-only" ]]; then
11
- node "$PARENT_PATH/protobuf-static.js"
12
- exit 0
13
- fi
14
-
15
10
  SRC="../../submodules/firmware/common/protob"
16
11
  DIST="."
17
12
  LANG="typescript"
@@ -171,5 +166,3 @@ yarn --cwd "$PACKAGE_ROOT" prettier --write "$CORE_MESSAGES_DIR/messages.json"
171
166
  yarn --cwd "$PACKAGE_ROOT" prettier --write "$PACKAGE_ROOT/messages-protocol-v2.json"
172
167
  yarn --cwd "$PACKAGE_ROOT" prettier --write "$CORE_MESSAGES_DIR/messages-protocol-v2.json"
173
168
  yarn --cwd "$PACKAGE_ROOT" prettier --write "$PACKAGE_ROOT/src/types/messages.ts"
174
-
175
- node "$PARENT_PATH/protobuf-static.js"
@@ -1,14 +1,10 @@
1
1
  import ByteBuffer from 'bytebuffer';
2
- import { Reader } from 'protobufjs/minimal';
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
10
  import {
@@ -18,8 +14,6 @@ import {
18
14
  isAckFrame,
19
15
  } from './v2';
20
16
 
21
- import legacyProtocolInfo from '../serialization/protobuf/legacy-protocol-info.json';
22
-
23
17
  import type { Root } from 'protobufjs/light';
24
18
 
25
19
  export const PROTOCOL_V2_SYS_MESSAGE_THRESHOLD = 60000;
@@ -36,8 +30,27 @@ type ProtocolV2FrameOptions = {
36
30
  seq?: number;
37
31
  };
38
32
 
39
- const LEGACY_PROTOCOL_V2_PROTOCOL_INFO =
40
- parseConfigure(legacyProtocolInfo).lookupType('LegacyProtocolInfo');
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
+ });
41
54
 
42
55
  const decodeLegacyProtocolV2ProtocolInfo = (pbPayload: Uint8Array) => {
43
56
  const byteBuffer = ByteBuffer.wrap(Buffer.from(pbPayload) as unknown as ArrayBuffer);
@@ -1,17 +1,11 @@
1
1
  import * as protobuf from 'protobufjs/light';
2
- import Long from 'long';
3
2
 
4
- import { installStaticCodecs } from './generated/codecs';
5
-
6
- // protobufjs optional dependency discovery uses Function, which CSP can disable.
7
- protobuf.util.Long = Long;
8
- protobuf.configure();
9
-
10
- export function parseConfigure(data: protobuf.INamespace | string) {
11
- const root = protobuf.Root.fromJSON(typeof data === 'string' ? JSON.parse(data) : data);
12
- // Unrecognized custom schemas retain the existing reflection-based API.
13
- installStaticCodecs(root);
14
- return root;
3
+ export function parseConfigure(data: protobuf.INamespace) {
4
+ // @ts-ignore [compatiblity]: connect is sending stringified json
5
+ if (typeof data === 'string') {
6
+ return protobuf.Root.fromJSON(JSON.parse(data));
7
+ }
8
+ return protobuf.Root.fromJSON(data);
15
9
  }
16
10
 
17
11
  export const createMessageFromName = (messages: protobuf.Root, name: string) => {
@@ -4680,43 +4680,6 @@ export type UiAnimationRequest = {
4680
4680
  type?: UiAnimationType;
4681
4681
  };
4682
4682
 
4683
- export enum ZcashAddressType {
4684
- UNIFIED_ORCHARD_P2PKH = 0,
4685
- TRANSPARENT_P2PKH = 1,
4686
- UNIFIED_ORCHARD = 2,
4687
- }
4688
-
4689
- export enum ZcashAddressScope {
4690
- EXTERNAL = 0,
4691
- INTERNAL = 1,
4692
- }
4693
-
4694
- // ZcashGetAddress
4695
- export type ZcashGetAddress = {
4696
- address_n: number[];
4697
- show_display?: boolean;
4698
- include_seed_fingerprint?: boolean;
4699
- diversifier_index?: number;
4700
- address_type?: ZcashAddressType;
4701
- scope?: ZcashAddressScope;
4702
- };
4703
-
4704
- // ZcashAddress
4705
- export type ZcashAddress = {
4706
- address: string;
4707
- seed_fingerprint?: string;
4708
- };
4709
-
4710
- // ZcashGetFullViewingKey
4711
- export type ZcashGetFullViewingKey = {
4712
- address_n: number[];
4713
- };
4714
-
4715
- // ZcashFullViewingKey
4716
- export type ZcashFullViewingKey = {
4717
- ufvk: string;
4718
- };
4719
-
4720
4683
  // ZcashSignPczt
4721
4684
  export type ZcashSignPczt = {
4722
4685
  pczt_length: number;
@@ -5438,6 +5401,35 @@ export type ViewVerifyPage = {
5438
5401
  content?: ViewContentPreview;
5439
5402
  };
5440
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
+
5441
5433
  export enum ProtocolV2FailureType {
5442
5434
  Failure_InvalidMessage = 1,
5443
5435
  Failure_UndefinedError = 2,
@@ -6052,10 +6044,6 @@ export type MessageType = {
6052
6044
  UnlockPath: UnlockPath;
6053
6045
  UnlockedPathRequest: UnlockedPathRequest;
6054
6046
  UiAnimationRequest: UiAnimationRequest;
6055
- ZcashGetAddress: ZcashGetAddress;
6056
- ZcashAddress: ZcashAddress;
6057
- ZcashGetFullViewingKey: ZcashGetFullViewingKey;
6058
- ZcashFullViewingKey: ZcashFullViewingKey;
6059
6047
  ZcashSignPczt: ZcashSignPczt;
6060
6048
  ZcashPcztChunkRequest: ZcashPcztChunkRequest;
6061
6049
  ZcashPcztChunkAck: ZcashPcztChunkAck;
@@ -6137,6 +6125,8 @@ export type MessageType = {
6137
6125
  ViewSignPage: ViewSignPage;
6138
6126
  ViewWarningPage: ViewWarningPage;
6139
6127
  ViewVerifyPage: ViewVerifyPage;
6128
+ ZcashGetAddress: ZcashGetAddress;
6129
+ ZcashAddress: ZcashAddress;
6140
6130
  };
6141
6131
 
6142
6132
  export type MessageKey = keyof MessageType;