@onekeyfe/hd-core 0.0.8 → 0.1.0
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/dist/api/BaseMethod.d.ts +4 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CipherKeyValue.d.ts +9 -0
- package/dist/api/CipherKeyValue.d.ts.map +1 -0
- package/dist/api/FirmwareUpdate.d.ts +14 -0
- package/dist/api/FirmwareUpdate.d.ts.map +1 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts +8 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +5 -0
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts +5 -0
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +7 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +33 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -0
- package/dist/api/firmware/uploadFirmware.d.ts +8 -0
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -0
- package/dist/api/helpers/hexUtils.d.ts.map +1 -1
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/nem/NEMGetAddress.d.ts +9 -0
- package/dist/api/nem/NEMGetAddress.d.ts.map +1 -0
- package/dist/api/nem/NEMSignTransaction.d.ts +20 -0
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -0
- package/dist/api/solana/SolGetAddress.d.ts +9 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -0
- package/dist/api/solana/SolSignTransaction.d.ts +17 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -0
- package/dist/api/stellar/StellarGetAddress.d.ts +9 -0
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -0
- package/dist/api/stellar/StellarSignTransaction.d.ts +335 -0
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -0
- package/dist/constants/errors.d.ts +1 -0
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data/version.d.ts +1 -1
- package/dist/data/version.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +1 -0
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +9 -1
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +364 -5
- package/dist/index.js +845 -21
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/cipherKeyValue.d.ts +19 -0
- package/dist/types/api/cipherKeyValue.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +7 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +13 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/nemGetAddress.d.ts +15 -0
- package/dist/types/api/nemGetAddress.d.ts.map +1 -0
- package/dist/types/api/nemSignTransaction.d.ts +93 -0
- package/dist/types/api/nemSignTransaction.d.ts.map +1 -0
- package/dist/types/api/solGetAddress.d.ts +14 -0
- package/dist/types/api/solGetAddress.d.ts.map +1 -0
- package/dist/types/api/solSignTransaction.d.ts +14 -0
- package/dist/types/api/solSignTransaction.d.ts.map +1 -0
- package/dist/types/api/stellarGetAddress.d.ts +14 -0
- package/dist/types/api/stellarGetAddress.d.ts.map +1 -0
- package/dist/types/api/stellarSignTransaction.d.ts +130 -0
- package/dist/types/api/stellarSignTransaction.d.ts.map +1 -0
- package/dist/types/device.d.ts +45 -0
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/firmware.d.ts +2 -1
- package/dist/types/firmware.d.ts.map +1 -1
- package/dist/types/params.d.ts +3 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/utils/assets.d.ts +1 -1
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +49 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/networkUtils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api/BaseMethod.ts +9 -0
- package/src/api/CipherKeyValue.ts +66 -0
- package/src/api/FirmwareUpdate.ts +78 -0
- package/src/api/device/DeviceRebootToBootloader.ts +11 -0
- package/src/api/evm/EVMSignMessageEIP712.ts +8 -0
- package/src/api/evm/EVMSignTransaction.ts +15 -0
- package/src/api/evm/EVMSignTypedData.ts +55 -15
- package/src/api/firmware/getBinary.ts +46 -0
- package/src/api/firmware/uploadFirmware.ts +72 -0
- package/src/api/helpers/hexUtils.ts +0 -1
- package/src/api/index.ts +12 -0
- package/src/api/nem/NEMGetAddress.ts +61 -0
- package/src/api/nem/NEMSignTransaction.ts +246 -0
- package/src/api/solana/SolGetAddress.ts +59 -0
- package/src/api/solana/SolSignTransaction.ts +69 -0
- package/src/api/stellar/StellarGetAddress.ts +59 -0
- package/src/api/stellar/StellarSignTransaction.ts +213 -0
- package/src/constants/errors.ts +1 -0
- package/src/core/index.ts +40 -5
- package/src/data/version.ts +1 -1
- package/src/device/Device.ts +4 -0
- package/src/device/DeviceCommands.ts +2 -0
- package/src/events/ui-request.ts +15 -1
- package/src/inject.ts +17 -0
- package/src/types/api/cipherKeyValue.ts +26 -0
- package/src/types/api/export.ts +27 -0
- package/src/types/api/firmwareUpdate.ts +21 -0
- package/src/types/api/index.ts +21 -0
- package/src/types/api/nemGetAddress.ts +22 -0
- package/src/types/api/nemSignTransaction.ts +117 -0
- package/src/types/api/solGetAddress.ts +21 -0
- package/src/types/api/solSignTransaction.ts +21 -0
- package/src/types/api/stellarGetAddress.ts +21 -0
- package/src/types/api/stellarSignTransaction.ts +153 -0
- package/src/types/device.ts +52 -0
- package/src/types/firmware.ts +2 -1
- package/src/types/params.ts +2 -0
- package/src/utils/assets.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +16 -2
- package/src/utils/networkUtils.ts +3 -1
package/src/types/device.ts
CHANGED
|
@@ -73,8 +73,60 @@ export type Features = PROTO.Features;
|
|
|
73
73
|
|
|
74
74
|
export type IDeviceType = 'classic' | 'mini' | 'touch' | 'pro';
|
|
75
75
|
|
|
76
|
+
// model_mini: 'classic' | 'mini'
|
|
77
|
+
// model_touch: 'touch' | 'pro'
|
|
78
|
+
export type IDeviceModel = 'model_mini' | 'model_touch';
|
|
79
|
+
|
|
76
80
|
export type IDeviceFirmwareStatus = 'valid' | 'outdated' | 'required' | 'unknown' | 'none';
|
|
77
81
|
|
|
78
82
|
export type IDeviceBLEFirmwareStatus = 'valid' | 'outdated' | 'required' | 'unknown' | 'none';
|
|
79
83
|
|
|
80
84
|
export type ITransportStatus = 'valid' | 'outdated';
|
|
85
|
+
|
|
86
|
+
export type DeviceFirmwareRange = {
|
|
87
|
+
[deviceType in IDeviceType | IDeviceModel]?: { min: string; max?: string };
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
type FeaturesNarrowing =
|
|
91
|
+
| {
|
|
92
|
+
major_version: 2;
|
|
93
|
+
fw_major: null;
|
|
94
|
+
fw_minor: null;
|
|
95
|
+
fw_patch: null;
|
|
96
|
+
bootloader_mode: true;
|
|
97
|
+
firmware_present: false;
|
|
98
|
+
}
|
|
99
|
+
| {
|
|
100
|
+
major_version: 2;
|
|
101
|
+
fw_major: null;
|
|
102
|
+
fw_minor: null;
|
|
103
|
+
fw_patch: null;
|
|
104
|
+
bootloader_mode: null;
|
|
105
|
+
firmware_present: null;
|
|
106
|
+
}
|
|
107
|
+
| {
|
|
108
|
+
major_version: 2;
|
|
109
|
+
fw_major: 2;
|
|
110
|
+
fw_minor: number;
|
|
111
|
+
fw_patch: number;
|
|
112
|
+
bootloader_mode: true;
|
|
113
|
+
firmware_present: true;
|
|
114
|
+
}
|
|
115
|
+
| {
|
|
116
|
+
major_version: 1;
|
|
117
|
+
fw_major: null;
|
|
118
|
+
fw_minor: null;
|
|
119
|
+
fw_patch: null;
|
|
120
|
+
bootloader_mode: true;
|
|
121
|
+
firmware_present: false;
|
|
122
|
+
}
|
|
123
|
+
| {
|
|
124
|
+
major_version: 1;
|
|
125
|
+
fw_major: null;
|
|
126
|
+
fw_minor: null;
|
|
127
|
+
fw_patch: null;
|
|
128
|
+
bootloader_mode: true;
|
|
129
|
+
firmware_present: true;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type StrictFeatures = Features & FeaturesNarrowing;
|
package/src/types/firmware.ts
CHANGED
package/src/types/params.ts
CHANGED
package/src/utils/assets.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { httpRequest as browserHttpRequest } from './networkUtils';
|
|
2
2
|
|
|
3
|
-
export const httpRequest = (url: string,
|
|
3
|
+
export const httpRequest = (url: string, type: string): any => browserHttpRequest(url, type);
|
|
4
4
|
|
|
5
5
|
export const getTimeStamp = () => new Date().getTime();
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import type { Features, IVersionArray, IDeviceType } from '../types';
|
|
1
|
+
import type { Features, IVersionArray, IDeviceType, IDeviceModel } from '../types';
|
|
2
|
+
|
|
3
|
+
export const getDeviceModel = (features?: Features): IDeviceModel => {
|
|
4
|
+
if (!features || typeof features !== 'object') {
|
|
5
|
+
return 'model_mini';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (features.model === '1') {
|
|
9
|
+
return 'model_mini';
|
|
10
|
+
}
|
|
11
|
+
// model === 'T'
|
|
12
|
+
return 'model_touch';
|
|
13
|
+
};
|
|
2
14
|
|
|
3
15
|
export const getDeviceType = (features?: Features): IDeviceType => {
|
|
4
16
|
if (!features || typeof features !== 'object' || !features.serial_no) {
|
|
@@ -49,7 +61,9 @@ export const getDeviceLabel = (features: Features) => {
|
|
|
49
61
|
/**
|
|
50
62
|
* Get Connected Device version by features
|
|
51
63
|
*/
|
|
52
|
-
export const getDeviceFirmwareVersion = (features: Features): IVersionArray => {
|
|
64
|
+
export const getDeviceFirmwareVersion = (features: Features | undefined): IVersionArray => {
|
|
65
|
+
if (!features) return [0, 0, 0];
|
|
66
|
+
|
|
53
67
|
if (features.onekey_version) {
|
|
54
68
|
return features.onekey_version.split('.') as unknown as IVersionArray;
|
|
55
69
|
}
|
|
@@ -4,13 +4,15 @@ export const httpRequest = async (url: string, type = 'text') => {
|
|
|
4
4
|
const response = await axios.request({
|
|
5
5
|
url,
|
|
6
6
|
withCredentials: false,
|
|
7
|
+
responseType: type === 'binary' ? 'arraybuffer' : 'json',
|
|
7
8
|
});
|
|
9
|
+
|
|
8
10
|
if (+response.status === 200) {
|
|
9
11
|
if (type === 'json') {
|
|
10
12
|
return response.data;
|
|
11
13
|
}
|
|
12
14
|
if (type === 'binary') {
|
|
13
|
-
return response.data
|
|
15
|
+
return response.data;
|
|
14
16
|
}
|
|
15
17
|
return response.data;
|
|
16
18
|
}
|