@onekeyfe/hd-transport 1.2.0-alpha.34 → 1.2.0-alpha.35
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 +37 -29
- package/__tests__/protocol-v2.test.js +14 -14
- package/__tests__/transport-log.test.js +79 -0
- package/dist/index.d.ts +219 -242
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +153 -74
- package/dist/types/messages.d.ts +155 -177
- package/dist/types/messages.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 +393 -485
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/types/messages.ts +196 -225
- package/src/utils/transportLog.ts +102 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.35",
|
|
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": "638bd33030686c4a3321e4feb4924c3f9f5c81a8"
|
|
32
32
|
}
|
package/src/index.ts
CHANGED
package/src/types/messages.ts
CHANGED
|
@@ -4596,21 +4596,6 @@ export type EthereumSignTypedDataQR = {
|
|
|
4596
4596
|
request_id?: string;
|
|
4597
4597
|
};
|
|
4598
4598
|
|
|
4599
|
-
// InternalMyAddressRequest
|
|
4600
|
-
export type InternalMyAddressRequest = {
|
|
4601
|
-
coin_type: number;
|
|
4602
|
-
chain_id: number;
|
|
4603
|
-
account_index: number;
|
|
4604
|
-
derive_type: number;
|
|
4605
|
-
};
|
|
4606
|
-
|
|
4607
|
-
// StartSession
|
|
4608
|
-
export type StartSession = {
|
|
4609
|
-
session_id?: string;
|
|
4610
|
-
_skip_passphrase?: boolean;
|
|
4611
|
-
derive_cardano?: boolean;
|
|
4612
|
-
};
|
|
4613
|
-
|
|
4614
4599
|
// SetBusy
|
|
4615
4600
|
export type SetBusy = {
|
|
4616
4601
|
expiry_ms?: number;
|
|
@@ -4639,28 +4624,6 @@ export type WriteSEPrivateKey = {
|
|
|
4639
4624
|
private_key: string;
|
|
4640
4625
|
};
|
|
4641
4626
|
|
|
4642
|
-
export enum WallpaperTarget {
|
|
4643
|
-
Home = 0,
|
|
4644
|
-
Lock = 1,
|
|
4645
|
-
}
|
|
4646
|
-
|
|
4647
|
-
// SetWallpaper
|
|
4648
|
-
export type SetWallpaper = {
|
|
4649
|
-
target: WallpaperTarget;
|
|
4650
|
-
path: string;
|
|
4651
|
-
};
|
|
4652
|
-
|
|
4653
|
-
// GetWallpaper
|
|
4654
|
-
export type GetWallpaper = {
|
|
4655
|
-
target: WallpaperTarget;
|
|
4656
|
-
};
|
|
4657
|
-
|
|
4658
|
-
// Wallpaper
|
|
4659
|
-
export type Wallpaper = {
|
|
4660
|
-
target: WallpaperTarget;
|
|
4661
|
-
path: string;
|
|
4662
|
-
};
|
|
4663
|
-
|
|
4664
4627
|
// UnlockPath
|
|
4665
4628
|
export type UnlockPath = {
|
|
4666
4629
|
address_n: number[];
|
|
@@ -4697,70 +4660,6 @@ export type UiAnimationRequest = {
|
|
|
4697
4660
|
type?: UiAnimationType;
|
|
4698
4661
|
};
|
|
4699
4662
|
|
|
4700
|
-
// ViewAmount
|
|
4701
|
-
export type ViewAmount = {
|
|
4702
|
-
is_unlimited: boolean;
|
|
4703
|
-
num: string;
|
|
4704
|
-
};
|
|
4705
|
-
|
|
4706
|
-
// ViewDetail
|
|
4707
|
-
export type ViewDetail = {
|
|
4708
|
-
key: number;
|
|
4709
|
-
value: string;
|
|
4710
|
-
is_overview: boolean;
|
|
4711
|
-
has_icon: boolean;
|
|
4712
|
-
};
|
|
4713
|
-
|
|
4714
|
-
export enum ViewTipType {
|
|
4715
|
-
Default = 0,
|
|
4716
|
-
Highlight = 1,
|
|
4717
|
-
Recommend = 2,
|
|
4718
|
-
Warning = 3,
|
|
4719
|
-
Danger = 4,
|
|
4720
|
-
}
|
|
4721
|
-
|
|
4722
|
-
// ViewTip
|
|
4723
|
-
export type ViewTip = {
|
|
4724
|
-
type: ViewTipType;
|
|
4725
|
-
text: string;
|
|
4726
|
-
};
|
|
4727
|
-
|
|
4728
|
-
// ViewRawData
|
|
4729
|
-
export type ViewRawData = {
|
|
4730
|
-
initial_data: string;
|
|
4731
|
-
placeholder: number;
|
|
4732
|
-
};
|
|
4733
|
-
|
|
4734
|
-
export enum ViewSignLayout {
|
|
4735
|
-
LayoutDefault = 0,
|
|
4736
|
-
LayoutSafeTxCreate = 1,
|
|
4737
|
-
LayoutFinalConfirm = 2,
|
|
4738
|
-
Layout7702 = 3,
|
|
4739
|
-
LayoutFlat = 4,
|
|
4740
|
-
LayoutEthApprove = 5,
|
|
4741
|
-
}
|
|
4742
|
-
|
|
4743
|
-
// ViewSignPage
|
|
4744
|
-
export type ViewSignPage = {
|
|
4745
|
-
title: string;
|
|
4746
|
-
amount?: UintType;
|
|
4747
|
-
general: ViewDetail[];
|
|
4748
|
-
tip?: ViewTip;
|
|
4749
|
-
raw_data?: ViewRawData;
|
|
4750
|
-
slide_to_confirm?: boolean;
|
|
4751
|
-
layout?: ViewSignLayout;
|
|
4752
|
-
};
|
|
4753
|
-
|
|
4754
|
-
// ViewVerifyPage
|
|
4755
|
-
export type ViewVerifyPage = {
|
|
4756
|
-
title: string;
|
|
4757
|
-
address: string;
|
|
4758
|
-
path: string;
|
|
4759
|
-
network?: string;
|
|
4760
|
-
derive_type?: string;
|
|
4761
|
-
value_key?: number;
|
|
4762
|
-
};
|
|
4763
|
-
|
|
4764
4663
|
// ProtocolInfoRequest
|
|
4765
4664
|
export type ProtocolInfoRequest = {
|
|
4766
4665
|
eventless_wallet_session?: boolean;
|
|
@@ -4769,8 +4668,8 @@ export type ProtocolInfoRequest = {
|
|
|
4769
4668
|
// ProtocolInfo
|
|
4770
4669
|
export type ProtocolInfo = {
|
|
4771
4670
|
version: number;
|
|
4671
|
+
build_fingerprint: string;
|
|
4772
4672
|
supported_messages: number[];
|
|
4773
|
-
protobuf_definition?: string;
|
|
4774
4673
|
};
|
|
4775
4674
|
|
|
4776
4675
|
export enum DeviceErrorCode {
|
|
@@ -4862,6 +4761,54 @@ export type DeviceCertificateSign = {
|
|
|
4862
4761
|
data: string;
|
|
4863
4762
|
};
|
|
4864
4763
|
|
|
4764
|
+
// DeviceMiscUsbMscControl
|
|
4765
|
+
export type DeviceMiscUsbMscControl = {
|
|
4766
|
+
enable: boolean;
|
|
4767
|
+
};
|
|
4768
|
+
|
|
4769
|
+
export enum DeviceFactoryAck {
|
|
4770
|
+
FACTORY_ACK_SUCCESS = 0,
|
|
4771
|
+
FACTORY_ACK_FAIL = 1,
|
|
4772
|
+
}
|
|
4773
|
+
|
|
4774
|
+
// DeviceFactoryInfoManufactureTime
|
|
4775
|
+
export type DeviceFactoryInfoManufactureTime = {
|
|
4776
|
+
year: number;
|
|
4777
|
+
month: number;
|
|
4778
|
+
day: number;
|
|
4779
|
+
hour: number;
|
|
4780
|
+
minute: number;
|
|
4781
|
+
second: number;
|
|
4782
|
+
};
|
|
4783
|
+
|
|
4784
|
+
// DeviceFactoryInfo
|
|
4785
|
+
export type DeviceFactoryInfo = {
|
|
4786
|
+
version?: number;
|
|
4787
|
+
serial_number?: string;
|
|
4788
|
+
burn_in_completed?: boolean;
|
|
4789
|
+
factory_test_completed?: boolean;
|
|
4790
|
+
manufacture_time?: DeviceFactoryInfoManufactureTime;
|
|
4791
|
+
};
|
|
4792
|
+
|
|
4793
|
+
// DeviceFactoryInfoSet
|
|
4794
|
+
export type DeviceFactoryInfoSet = {
|
|
4795
|
+
info: DeviceFactoryInfo;
|
|
4796
|
+
};
|
|
4797
|
+
|
|
4798
|
+
// DeviceFactoryInfoGet
|
|
4799
|
+
export type DeviceFactoryInfoGet = {};
|
|
4800
|
+
|
|
4801
|
+
// DeviceFactoryPermanentLock
|
|
4802
|
+
export type DeviceFactoryPermanentLock = {
|
|
4803
|
+
check_a: string;
|
|
4804
|
+
check_b: string;
|
|
4805
|
+
};
|
|
4806
|
+
|
|
4807
|
+
// DeviceFactoryTest
|
|
4808
|
+
export type DeviceFactoryTest = {
|
|
4809
|
+
burn_in_test: boolean;
|
|
4810
|
+
};
|
|
4811
|
+
|
|
4865
4812
|
export enum DeviceFirmwareTargetType {
|
|
4866
4813
|
FW_MGMT_TARGET_INVALID = 0,
|
|
4867
4814
|
FW_MGMT_TARGET_CRATE = 1,
|
|
@@ -4926,49 +4873,6 @@ export type DeviceFirmwareUpdateStatus = {
|
|
|
4926
4873
|
records: DeviceFirmwareUpdateRecord[];
|
|
4927
4874
|
};
|
|
4928
4875
|
|
|
4929
|
-
export enum DeviceFactoryAck {
|
|
4930
|
-
FACTORY_ACK_SUCCESS = 0,
|
|
4931
|
-
FACTORY_ACK_FAIL = 1,
|
|
4932
|
-
}
|
|
4933
|
-
|
|
4934
|
-
// DeviceFactoryInfoManufactureTime
|
|
4935
|
-
export type DeviceFactoryInfoManufactureTime = {
|
|
4936
|
-
year: number;
|
|
4937
|
-
month: number;
|
|
4938
|
-
day: number;
|
|
4939
|
-
hour: number;
|
|
4940
|
-
minute: number;
|
|
4941
|
-
second: number;
|
|
4942
|
-
};
|
|
4943
|
-
|
|
4944
|
-
// DeviceFactoryInfo
|
|
4945
|
-
export type DeviceFactoryInfo = {
|
|
4946
|
-
version?: number;
|
|
4947
|
-
serial_number?: string;
|
|
4948
|
-
burn_in_completed?: boolean;
|
|
4949
|
-
factory_test_completed?: boolean;
|
|
4950
|
-
manufacture_time?: DeviceFactoryInfoManufactureTime;
|
|
4951
|
-
};
|
|
4952
|
-
|
|
4953
|
-
// DeviceFactoryInfoSet
|
|
4954
|
-
export type DeviceFactoryInfoSet = {
|
|
4955
|
-
info: DeviceFactoryInfo;
|
|
4956
|
-
};
|
|
4957
|
-
|
|
4958
|
-
// DeviceFactoryInfoGet
|
|
4959
|
-
export type DeviceFactoryInfoGet = {};
|
|
4960
|
-
|
|
4961
|
-
// DeviceFactoryPermanentLock
|
|
4962
|
-
export type DeviceFactoryPermanentLock = {
|
|
4963
|
-
check_a: string;
|
|
4964
|
-
check_b: string;
|
|
4965
|
-
};
|
|
4966
|
-
|
|
4967
|
-
// DeviceFactoryTest
|
|
4968
|
-
export type DeviceFactoryTest = {
|
|
4969
|
-
burn_in_test: boolean;
|
|
4970
|
-
};
|
|
4971
|
-
|
|
4972
4876
|
export enum DeviceType {
|
|
4973
4877
|
CLASSIC1 = 0,
|
|
4974
4878
|
CLASSIC1S = 1,
|
|
@@ -5039,7 +4943,6 @@ export type DeviceInfoTargets = {
|
|
|
5039
4943
|
se2?: boolean;
|
|
5040
4944
|
se3?: boolean;
|
|
5041
4945
|
se4?: boolean;
|
|
5042
|
-
status?: boolean;
|
|
5043
4946
|
};
|
|
5044
4947
|
|
|
5045
4948
|
// DeviceInfoTypes
|
|
@@ -5066,7 +4969,6 @@ export type ProtocolV2DeviceInfo = {
|
|
|
5066
4969
|
se2?: DeviceSEInfo;
|
|
5067
4970
|
se3?: DeviceSEInfo;
|
|
5068
4971
|
se4?: DeviceSEInfo;
|
|
5069
|
-
status?: DeviceStatus;
|
|
5070
4972
|
};
|
|
5071
4973
|
|
|
5072
4974
|
export enum DeviceSessionErrorCode {
|
|
@@ -5103,7 +5005,7 @@ export type DeviceSessionAskPin = {
|
|
|
5103
5005
|
// DeviceSessionAskPassphrase
|
|
5104
5006
|
export type DeviceSessionAskPassphrase = {
|
|
5105
5007
|
passphrase?: string;
|
|
5106
|
-
on_device
|
|
5008
|
+
on_device: boolean;
|
|
5107
5009
|
};
|
|
5108
5010
|
|
|
5109
5011
|
export enum DeviceSessionAskPin_FailureSubCodes {
|
|
@@ -5124,63 +5026,6 @@ export type DeviceStatus = {
|
|
|
5124
5026
|
// DeviceStatusGet
|
|
5125
5027
|
export type DeviceStatusGet = {};
|
|
5126
5028
|
|
|
5127
|
-
export enum DevOnboardingStep {
|
|
5128
|
-
DEV_ONBOARDING_STEP_UNKNOWN = 0,
|
|
5129
|
-
DEV_ONBOARDING_STEP_CHECKING = 1,
|
|
5130
|
-
DEV_ONBOARDING_STEP_PERSONALIZATION = 2,
|
|
5131
|
-
DEV_ONBOARDING_STEP_PIN = 3,
|
|
5132
|
-
DEV_ONBOARDING_STEP_SETUP = 4,
|
|
5133
|
-
DEV_ONBOARDING_STEP_DONE = 5,
|
|
5134
|
-
}
|
|
5135
|
-
|
|
5136
|
-
export enum DevOnboardingPhase {
|
|
5137
|
-
DEV_ONBOARDING_PHASE_UNKNOWN = 0,
|
|
5138
|
-
DEV_ONBOARDING_PHASE_SAFETY_CHECK = 1,
|
|
5139
|
-
DEV_ONBOARDING_PHASE_PIN_SETUP = 2,
|
|
5140
|
-
DEV_ONBOARDING_PHASE_FINGERPRINT_SETUP = 3,
|
|
5141
|
-
DEV_ONBOARDING_PHASE_SETUP_CHOICE = 4,
|
|
5142
|
-
DEV_ONBOARDING_PHASE_WALLET_CREATE_START = 5,
|
|
5143
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW = 6,
|
|
5144
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM = 7,
|
|
5145
|
-
DEV_ONBOARDING_PHASE_RESTORE_METHOD_CHOICE = 8,
|
|
5146
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE = 9,
|
|
5147
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_RESTORE = 10,
|
|
5148
|
-
DEV_ONBOARDING_PHASE_WALLET_READY = 11,
|
|
5149
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT = 12,
|
|
5150
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP = 13,
|
|
5151
|
-
}
|
|
5152
|
-
|
|
5153
|
-
export enum DevOnboardingSetupKind {
|
|
5154
|
-
DEV_ONBOARDING_SETUP_KIND_UNKNOWN = 0,
|
|
5155
|
-
DEV_ONBOARDING_SETUP_KIND_CHOICE = 1,
|
|
5156
|
-
DEV_ONBOARDING_SETUP_KIND_CREATE = 2,
|
|
5157
|
-
DEV_ONBOARDING_SETUP_KIND_RESTORE = 3,
|
|
5158
|
-
}
|
|
5159
|
-
|
|
5160
|
-
export enum DevOnboardingSetupMethod {
|
|
5161
|
-
DEV_ONBOARDING_SETUP_METHOD_UNKNOWN = 0,
|
|
5162
|
-
DEV_ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE = 1,
|
|
5163
|
-
DEV_ONBOARDING_SETUP_METHOD_SEEDCARD = 2,
|
|
5164
|
-
}
|
|
5165
|
-
|
|
5166
|
-
// DevOnboardingSetupStatus
|
|
5167
|
-
export type DevOnboardingSetupStatus = {
|
|
5168
|
-
kind?: DevOnboardingSetupKind;
|
|
5169
|
-
method?: DevOnboardingSetupMethod;
|
|
5170
|
-
};
|
|
5171
|
-
|
|
5172
|
-
// DevGetOnboardingStatus
|
|
5173
|
-
export type DevGetOnboardingStatus = {};
|
|
5174
|
-
|
|
5175
|
-
// DevOnboardingStatus
|
|
5176
|
-
export type DevOnboardingStatus = {
|
|
5177
|
-
step?: DevOnboardingStep;
|
|
5178
|
-
phase?: DevOnboardingPhase;
|
|
5179
|
-
setup?: DevOnboardingSetupStatus;
|
|
5180
|
-
pin_set?: boolean;
|
|
5181
|
-
wallet_initialized?: boolean;
|
|
5182
|
-
};
|
|
5183
|
-
|
|
5184
5029
|
// FilesystemPermissionFix
|
|
5185
5030
|
export type FilesystemPermissionFix = {};
|
|
5186
5031
|
|
|
@@ -5265,9 +5110,138 @@ export type FilesystemFormat = {
|
|
|
5265
5110
|
user: boolean;
|
|
5266
5111
|
};
|
|
5267
5112
|
|
|
5113
|
+
// InternalMyAddressRequest
|
|
5114
|
+
export type InternalMyAddressRequest = {
|
|
5115
|
+
coin_type: number;
|
|
5116
|
+
chain_id: number;
|
|
5117
|
+
account_index: number;
|
|
5118
|
+
derive_type: number;
|
|
5119
|
+
};
|
|
5120
|
+
|
|
5121
|
+
export enum OnboardingStep {
|
|
5122
|
+
ONBOARDING_STEP_UNKNOWN = 0,
|
|
5123
|
+
ONBOARDING_STEP_CHECKING = 1,
|
|
5124
|
+
ONBOARDING_STEP_PERSONALIZATION = 2,
|
|
5125
|
+
ONBOARDING_STEP_PIN = 3,
|
|
5126
|
+
ONBOARDING_STEP_SETUP = 4,
|
|
5127
|
+
ONBOARDING_STEP_DONE = 5,
|
|
5128
|
+
}
|
|
5129
|
+
|
|
5130
|
+
export enum OnboardingPhase {
|
|
5131
|
+
ONBOARDING_PHASE_UNKNOWN = 0,
|
|
5132
|
+
ONBOARDING_PHASE_SAFETY_CHECK = 1,
|
|
5133
|
+
ONBOARDING_PHASE_PIN_SETUP = 2,
|
|
5134
|
+
ONBOARDING_PHASE_FINGERPRINT_SETUP = 3,
|
|
5135
|
+
ONBOARDING_PHASE_SETUP_CHOICE = 4,
|
|
5136
|
+
ONBOARDING_PHASE_WALLET_CREATE_START = 5,
|
|
5137
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW = 6,
|
|
5138
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM = 7,
|
|
5139
|
+
ONBOARDING_PHASE_RESTORE_METHOD_CHOICE = 8,
|
|
5140
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE = 9,
|
|
5141
|
+
ONBOARDING_PHASE_SEEDCARD_RESTORE = 10,
|
|
5142
|
+
ONBOARDING_PHASE_WALLET_READY = 11,
|
|
5143
|
+
ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT = 12,
|
|
5144
|
+
ONBOARDING_PHASE_SEEDCARD_BACKUP = 13,
|
|
5145
|
+
}
|
|
5146
|
+
|
|
5147
|
+
export enum OnboardingSetupKind {
|
|
5148
|
+
ONBOARDING_SETUP_KIND_UNKNOWN = 0,
|
|
5149
|
+
ONBOARDING_SETUP_KIND_CHOICE = 1,
|
|
5150
|
+
ONBOARDING_SETUP_KIND_CREATE = 2,
|
|
5151
|
+
ONBOARDING_SETUP_KIND_RESTORE = 3,
|
|
5152
|
+
}
|
|
5153
|
+
|
|
5154
|
+
export enum OnboardingSetupMethod {
|
|
5155
|
+
ONBOARDING_SETUP_METHOD_UNKNOWN = 0,
|
|
5156
|
+
ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE = 1,
|
|
5157
|
+
ONBOARDING_SETUP_METHOD_SEEDCARD = 2,
|
|
5158
|
+
}
|
|
5159
|
+
|
|
5160
|
+
// OnboardingSetupStatus
|
|
5161
|
+
export type OnboardingSetupStatus = {
|
|
5162
|
+
kind?: OnboardingSetupKind;
|
|
5163
|
+
method?: OnboardingSetupMethod;
|
|
5164
|
+
};
|
|
5165
|
+
|
|
5166
|
+
// OnboardingStatusGet
|
|
5167
|
+
export type OnboardingStatusGet = {};
|
|
5168
|
+
|
|
5169
|
+
// OnboardingStatus
|
|
5170
|
+
export type OnboardingStatus = {
|
|
5171
|
+
step?: OnboardingStep;
|
|
5172
|
+
phase?: OnboardingPhase;
|
|
5173
|
+
setup?: OnboardingSetupStatus;
|
|
5174
|
+
pin_set?: boolean;
|
|
5175
|
+
wallet_initialized?: boolean;
|
|
5176
|
+
};
|
|
5177
|
+
|
|
5268
5178
|
// PortfolioUpdate
|
|
5269
5179
|
export type PortfolioUpdate = {};
|
|
5270
5180
|
|
|
5181
|
+
// ViewAmount
|
|
5182
|
+
export type ViewAmount = {
|
|
5183
|
+
is_unlimited: boolean;
|
|
5184
|
+
num: string;
|
|
5185
|
+
};
|
|
5186
|
+
|
|
5187
|
+
// ViewDetail
|
|
5188
|
+
export type ViewDetail = {
|
|
5189
|
+
key: number;
|
|
5190
|
+
value: string;
|
|
5191
|
+
is_overview: boolean;
|
|
5192
|
+
has_icon: boolean;
|
|
5193
|
+
};
|
|
5194
|
+
|
|
5195
|
+
export enum ViewTipType {
|
|
5196
|
+
Default = 0,
|
|
5197
|
+
Highlight = 1,
|
|
5198
|
+
Recommend = 2,
|
|
5199
|
+
Warning = 3,
|
|
5200
|
+
Danger = 4,
|
|
5201
|
+
}
|
|
5202
|
+
|
|
5203
|
+
// ViewTip
|
|
5204
|
+
export type ViewTip = {
|
|
5205
|
+
type: ViewTipType;
|
|
5206
|
+
text: string;
|
|
5207
|
+
};
|
|
5208
|
+
|
|
5209
|
+
// ViewRawData
|
|
5210
|
+
export type ViewRawData = {
|
|
5211
|
+
initial_data: string;
|
|
5212
|
+
placeholder: number;
|
|
5213
|
+
};
|
|
5214
|
+
|
|
5215
|
+
export enum ViewSignLayout {
|
|
5216
|
+
LayoutDefault = 0,
|
|
5217
|
+
LayoutSafeTxCreate = 1,
|
|
5218
|
+
LayoutFinalConfirm = 2,
|
|
5219
|
+
Layout7702 = 3,
|
|
5220
|
+
LayoutFlat = 4,
|
|
5221
|
+
LayoutEthApprove = 5,
|
|
5222
|
+
}
|
|
5223
|
+
|
|
5224
|
+
// ViewSignPage
|
|
5225
|
+
export type ViewSignPage = {
|
|
5226
|
+
title: string;
|
|
5227
|
+
amount?: UintType;
|
|
5228
|
+
general: ViewDetail[];
|
|
5229
|
+
tip?: ViewTip;
|
|
5230
|
+
raw_data?: ViewRawData;
|
|
5231
|
+
slide_to_confirm?: boolean;
|
|
5232
|
+
layout?: ViewSignLayout;
|
|
5233
|
+
};
|
|
5234
|
+
|
|
5235
|
+
// ViewVerifyPage
|
|
5236
|
+
export type ViewVerifyPage = {
|
|
5237
|
+
title: string;
|
|
5238
|
+
address: string;
|
|
5239
|
+
path: string;
|
|
5240
|
+
network?: string;
|
|
5241
|
+
derive_type?: string;
|
|
5242
|
+
value_key?: number;
|
|
5243
|
+
};
|
|
5244
|
+
|
|
5271
5245
|
export enum ProtocolV2FailureType {
|
|
5272
5246
|
Failure_InvalidMessage = 1,
|
|
5273
5247
|
Failure_UndefinedError = 2,
|
|
@@ -5873,26 +5847,15 @@ export type MessageType = {
|
|
|
5873
5847
|
PaymentRequestMemo: PaymentRequestMemo;
|
|
5874
5848
|
TxAckPaymentRequest: TxAckPaymentRequest;
|
|
5875
5849
|
EthereumSignTypedDataQR: EthereumSignTypedDataQR;
|
|
5876
|
-
InternalMyAddressRequest: InternalMyAddressRequest;
|
|
5877
|
-
StartSession: StartSession;
|
|
5878
5850
|
SetBusy: SetBusy;
|
|
5879
5851
|
GetFirmwareHash: GetFirmwareHash;
|
|
5880
5852
|
FirmwareHash: FirmwareHash;
|
|
5881
5853
|
GetNonce: GetNonce;
|
|
5882
5854
|
Nonce: Nonce;
|
|
5883
5855
|
WriteSEPrivateKey: WriteSEPrivateKey;
|
|
5884
|
-
SetWallpaper: SetWallpaper;
|
|
5885
|
-
GetWallpaper: GetWallpaper;
|
|
5886
|
-
Wallpaper: Wallpaper;
|
|
5887
5856
|
UnlockPath: UnlockPath;
|
|
5888
5857
|
UnlockedPathRequest: UnlockedPathRequest;
|
|
5889
5858
|
UiAnimationRequest: UiAnimationRequest;
|
|
5890
|
-
ViewAmount: ViewAmount;
|
|
5891
|
-
ViewDetail: ViewDetail;
|
|
5892
|
-
ViewTip: ViewTip;
|
|
5893
|
-
ViewRawData: ViewRawData;
|
|
5894
|
-
ViewSignPage: ViewSignPage;
|
|
5895
|
-
ViewVerifyPage: ViewVerifyPage;
|
|
5896
5859
|
ProtocolInfoRequest: ProtocolInfoRequest;
|
|
5897
5860
|
ProtocolInfo: ProtocolInfo;
|
|
5898
5861
|
DeviceReboot: DeviceReboot;
|
|
@@ -5905,18 +5868,19 @@ export type MessageType = {
|
|
|
5905
5868
|
DeviceCertificateRead: DeviceCertificateRead;
|
|
5906
5869
|
DeviceCertificateSignature: DeviceCertificateSignature;
|
|
5907
5870
|
DeviceCertificateSign: DeviceCertificateSign;
|
|
5908
|
-
|
|
5909
|
-
DeviceFirmwareUpdateRequest: DeviceFirmwareUpdateRequest;
|
|
5910
|
-
DeviceFirmwareUpdateRecord: DeviceFirmwareUpdateRecord;
|
|
5911
|
-
DeviceFirmwareUpdateRecordFields: DeviceFirmwareUpdateRecordFields;
|
|
5912
|
-
DeviceFirmwareUpdateStatusGet: DeviceFirmwareUpdateStatusGet;
|
|
5913
|
-
DeviceFirmwareUpdateStatus: DeviceFirmwareUpdateStatus;
|
|
5871
|
+
DeviceMiscUsbMscControl: DeviceMiscUsbMscControl;
|
|
5914
5872
|
DeviceFactoryInfoManufactureTime: DeviceFactoryInfoManufactureTime;
|
|
5915
5873
|
DeviceFactoryInfo: DeviceFactoryInfo;
|
|
5916
5874
|
DeviceFactoryInfoSet: DeviceFactoryInfoSet;
|
|
5917
5875
|
DeviceFactoryInfoGet: DeviceFactoryInfoGet;
|
|
5918
5876
|
DeviceFactoryPermanentLock: DeviceFactoryPermanentLock;
|
|
5919
5877
|
DeviceFactoryTest: DeviceFactoryTest;
|
|
5878
|
+
DeviceFirmwareTarget: DeviceFirmwareTarget;
|
|
5879
|
+
DeviceFirmwareUpdateRequest: DeviceFirmwareUpdateRequest;
|
|
5880
|
+
DeviceFirmwareUpdateRecord: DeviceFirmwareUpdateRecord;
|
|
5881
|
+
DeviceFirmwareUpdateRecordFields: DeviceFirmwareUpdateRecordFields;
|
|
5882
|
+
DeviceFirmwareUpdateStatusGet: DeviceFirmwareUpdateStatusGet;
|
|
5883
|
+
DeviceFirmwareUpdateStatus: DeviceFirmwareUpdateStatus;
|
|
5920
5884
|
DeviceFirmwareImageInfo: DeviceFirmwareImageInfo;
|
|
5921
5885
|
DeviceHardwareInfo: DeviceHardwareInfo;
|
|
5922
5886
|
DeviceMainMcuInfo: DeviceMainMcuInfo;
|
|
@@ -5931,9 +5895,6 @@ export type MessageType = {
|
|
|
5931
5895
|
DeviceSessionAskPassphrase: DeviceSessionAskPassphrase;
|
|
5932
5896
|
DeviceStatus: DeviceStatus;
|
|
5933
5897
|
DeviceStatusGet: DeviceStatusGet;
|
|
5934
|
-
DevOnboardingSetupStatus: DevOnboardingSetupStatus;
|
|
5935
|
-
DevGetOnboardingStatus: DevGetOnboardingStatus;
|
|
5936
|
-
DevOnboardingStatus: DevOnboardingStatus;
|
|
5937
5898
|
FilesystemPermissionFix: FilesystemPermissionFix;
|
|
5938
5899
|
FilesystemPathInfo: FilesystemPathInfo;
|
|
5939
5900
|
FilesystemPathInfoQuery: FilesystemPathInfoQuery;
|
|
@@ -5946,7 +5907,17 @@ export type MessageType = {
|
|
|
5946
5907
|
FilesystemDirMake: FilesystemDirMake;
|
|
5947
5908
|
FilesystemDirRemove: FilesystemDirRemove;
|
|
5948
5909
|
FilesystemFormat: FilesystemFormat;
|
|
5910
|
+
InternalMyAddressRequest: InternalMyAddressRequest;
|
|
5911
|
+
OnboardingSetupStatus: OnboardingSetupStatus;
|
|
5912
|
+
OnboardingStatusGet: OnboardingStatusGet;
|
|
5913
|
+
OnboardingStatus: OnboardingStatus;
|
|
5949
5914
|
PortfolioUpdate: PortfolioUpdate;
|
|
5915
|
+
ViewAmount: ViewAmount;
|
|
5916
|
+
ViewDetail: ViewDetail;
|
|
5917
|
+
ViewTip: ViewTip;
|
|
5918
|
+
ViewRawData: ViewRawData;
|
|
5919
|
+
ViewSignPage: ViewSignPage;
|
|
5920
|
+
ViewVerifyPage: ViewVerifyPage;
|
|
5950
5921
|
};
|
|
5951
5922
|
|
|
5952
5923
|
export type MessageKey = keyof MessageType;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { ProtocolType } from '../types';
|
|
2
|
+
|
|
3
|
+
const REDACTED = '[REDACTED]';
|
|
4
|
+
|
|
5
|
+
const SENSITIVE_LOG_KEYS = new Set([
|
|
6
|
+
'accesstoken',
|
|
7
|
+
'address',
|
|
8
|
+
'apikey',
|
|
9
|
+
'connectid',
|
|
10
|
+
'devicestate',
|
|
11
|
+
'deviceid',
|
|
12
|
+
'entropy',
|
|
13
|
+
'expectedpassphrasestate',
|
|
14
|
+
'mnemonic',
|
|
15
|
+
'passphrase',
|
|
16
|
+
'passphrasestate',
|
|
17
|
+
'password',
|
|
18
|
+
'pin',
|
|
19
|
+
'privatekey',
|
|
20
|
+
'publickey',
|
|
21
|
+
'seed',
|
|
22
|
+
'serialnumber',
|
|
23
|
+
'session',
|
|
24
|
+
'sessionid',
|
|
25
|
+
'signature',
|
|
26
|
+
'token',
|
|
27
|
+
'uuid',
|
|
28
|
+
'walletsessionid',
|
|
29
|
+
'xprv',
|
|
30
|
+
'xpub',
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const normalizeLogKey = (key: string) => key.replace(/[_-]/g, '').toLowerCase();
|
|
34
|
+
|
|
35
|
+
const isSensitiveLogKey = (key: string) => {
|
|
36
|
+
const normalizedKey = normalizeLogKey(key);
|
|
37
|
+
return (
|
|
38
|
+
SENSITIVE_LOG_KEYS.has(normalizedKey) ||
|
|
39
|
+
normalizedKey.endsWith('address') ||
|
|
40
|
+
normalizedKey.endsWith('privatekey') ||
|
|
41
|
+
normalizedKey.endsWith('publickey') ||
|
|
42
|
+
normalizedKey.endsWith('signature')
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const isSigningMessage = (messageName?: string) =>
|
|
47
|
+
Boolean(messageName && /(?:sign|txack|transaction)/i.test(messageName));
|
|
48
|
+
|
|
49
|
+
const redactLogValue = (value: unknown, seen: WeakSet<object>): unknown => {
|
|
50
|
+
if (ArrayBuffer.isView(value)) {
|
|
51
|
+
return `[BINARY:${value.byteLength}]`;
|
|
52
|
+
}
|
|
53
|
+
if (value instanceof ArrayBuffer) {
|
|
54
|
+
return `[BINARY:${value.byteLength}]`;
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(value)) {
|
|
57
|
+
return value.map(item => redactLogValue(item, seen));
|
|
58
|
+
}
|
|
59
|
+
if (!value || typeof value !== 'object') {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
if (seen.has(value)) {
|
|
63
|
+
return '[CIRCULAR]';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
seen.add(value);
|
|
67
|
+
const redacted = Object.fromEntries(
|
|
68
|
+
Object.entries(value as Record<string, unknown>).map(([key, item]) => [
|
|
69
|
+
key,
|
|
70
|
+
isSensitiveLogKey(key) && item !== null && item !== undefined
|
|
71
|
+
? REDACTED
|
|
72
|
+
: redactLogValue(item, seen),
|
|
73
|
+
])
|
|
74
|
+
);
|
|
75
|
+
seen.delete(value);
|
|
76
|
+
return redacted;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export function getSafeTransportLogPayload(value: unknown, messageName?: string): unknown {
|
|
80
|
+
if (isSigningMessage(messageName)) {
|
|
81
|
+
return REDACTED;
|
|
82
|
+
}
|
|
83
|
+
return redactLogValue(value, new WeakSet());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function createTransportCallLog(
|
|
87
|
+
name: string,
|
|
88
|
+
protocol: ProtocolType,
|
|
89
|
+
data: Record<string, unknown>
|
|
90
|
+
) {
|
|
91
|
+
return {
|
|
92
|
+
name,
|
|
93
|
+
protocol,
|
|
94
|
+
request: getSafeTransportLogPayload(data, name),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const HIGH_VOLUME_CALLS = new Set(['FileWrite', 'FilesystemFileWrite', 'EmmcFileWrite']);
|
|
99
|
+
|
|
100
|
+
export function shouldSuppressHighVolumeCallLog(name: string) {
|
|
101
|
+
return HIGH_VOLUME_CALLS.has(name);
|
|
102
|
+
}
|