@onekeyfe/hd-core 1.0.39-alpha.1 → 1.0.39-alpha.11
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/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignMessage.d.ts +5 -0
- package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +2 -0
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +2 -0
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/events/ui-request.d.ts +3 -1
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +14 -8
- package/dist/index.js +123 -12
- package/dist/types/api/cardanoSignMessage.d.ts +3 -0
- package/dist/types/api/cardanoSignMessage.d.ts.map +1 -1
- package/dist/types/api/tronSignTransaction.d.ts +1 -0
- package/dist/types/api/tronSignTransaction.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.d.ts +5 -0
- package/dist/utils/capabilitieUtils.d.ts.map +1 -0
- package/dist/utils/deviceInfoUtils.d.ts +2 -0
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV3.ts +2 -0
- package/src/api/cardano/CardanoSignMessage.ts +15 -0
- package/src/api/device/DeviceUnlock.ts +33 -0
- package/src/api/tron/TronSignTransaction.ts +21 -0
- package/src/core/index.ts +14 -7
- package/src/data/messages/messages.json +30 -1
- package/src/data-manager/DataManager.ts +1 -1
- package/src/data-manager/TransportManager.ts +3 -0
- package/src/device/Device.ts +5 -4
- package/src/events/ui-request.ts +5 -0
- package/src/types/api/cardanoSignMessage.ts +3 -0
- package/src/types/api/tronSignTransaction.ts +1 -0
- package/src/types/settings.ts +10 -1
- package/src/utils/capabilitieUtils.ts +12 -0
- package/src/utils/deviceInfoUtils.ts +17 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/logger.ts +2 -0
package/src/events/ui-request.ts
CHANGED
|
@@ -18,6 +18,9 @@ export const UI_REQUEST = {
|
|
|
18
18
|
DEVICE_PROGRESS: 'ui-device_progress',
|
|
19
19
|
|
|
20
20
|
BLUETOOTH_PERMISSION: 'ui-bluetooth_permission',
|
|
21
|
+
BLUETOOTH_UNSUPPORTED: 'ui-bluetooth_unsupported',
|
|
22
|
+
BLUETOOTH_POWERED_OFF: 'ui-bluetooth_powered_off',
|
|
23
|
+
|
|
21
24
|
BLUETOOTH_CHARACTERISTIC_NOTIFY_CHANGE_FAILURE:
|
|
22
25
|
'ui-bluetooth_characteristic_notify_change_failure',
|
|
23
26
|
LOCATION_PERMISSION: 'ui-location_permission',
|
|
@@ -47,6 +50,8 @@ export interface UiRequestWithoutPayload {
|
|
|
47
50
|
type:
|
|
48
51
|
| typeof UI_REQUEST.CLOSE_UI_WINDOW
|
|
49
52
|
| typeof UI_REQUEST.BLUETOOTH_PERMISSION
|
|
53
|
+
| typeof UI_REQUEST.BLUETOOTH_UNSUPPORTED
|
|
54
|
+
| typeof UI_REQUEST.BLUETOOTH_POWERED_OFF
|
|
50
55
|
| typeof UI_REQUEST.BLUETOOTH_CHARACTERISTIC_NOTIFY_CHANGE_FAILURE
|
|
51
56
|
| typeof UI_REQUEST.LOCATION_PERMISSION
|
|
52
57
|
| typeof UI_REQUEST.LOCATION_SERVICE_PERMISSION
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { CardanoMessageSignature } from '@onekeyfe/hd-transport';
|
|
2
2
|
import type { CommonParams, Response } from '../params';
|
|
3
|
+
import { PROTO } from '../../constants';
|
|
3
4
|
|
|
4
5
|
export type CardanoSignMessageParams = {
|
|
5
6
|
address_n: number[];
|
|
6
7
|
message: string;
|
|
7
8
|
derivation_type: number;
|
|
8
9
|
network_id: number;
|
|
10
|
+
address_type: number;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
export type CardanoSignMessageMethodParams = {
|
|
@@ -13,6 +15,7 @@ export type CardanoSignMessageMethodParams = {
|
|
|
13
15
|
message: string;
|
|
14
16
|
derivationType: number;
|
|
15
17
|
networkId: number;
|
|
18
|
+
addressType?: PROTO.CardanoAddressType;
|
|
16
19
|
};
|
|
17
20
|
|
|
18
21
|
export declare function cardanoSignMessage(
|
package/src/types/settings.ts
CHANGED
|
@@ -14,7 +14,16 @@ export type ConnectSettings = {
|
|
|
14
14
|
priority: number;
|
|
15
15
|
trustedHost: boolean;
|
|
16
16
|
supportedBrowser?: boolean;
|
|
17
|
-
env:
|
|
17
|
+
env:
|
|
18
|
+
| 'node'
|
|
19
|
+
| 'web'
|
|
20
|
+
| 'webextension'
|
|
21
|
+
| 'electron'
|
|
22
|
+
| 'react-native'
|
|
23
|
+
| 'webusb'
|
|
24
|
+
| 'emulator'
|
|
25
|
+
| 'desktop-web-ble'
|
|
26
|
+
| 'lowlevel';
|
|
18
27
|
timestamp: number;
|
|
19
28
|
isFrame?: boolean;
|
|
20
29
|
preRelease?: boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Enum_Capability } from '@onekeyfe/hd-transport';
|
|
2
|
+
import { Features } from '../types/device';
|
|
3
|
+
|
|
4
|
+
export const existCapability = (features: Features, capability: Enum_Capability) =>
|
|
5
|
+
// @ts-expect-error
|
|
6
|
+
features?.capabilities?.includes(capability);
|
|
7
|
+
|
|
8
|
+
export const requireCapability = (features: Features, capability: Enum_Capability) => {
|
|
9
|
+
if (!existCapability(features, capability)) {
|
|
10
|
+
throw new Error(`Capability ${capability} is required`);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { isEmpty } from 'lodash';
|
|
2
|
-
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
2
|
+
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
3
|
+
import { Enum_Capability } from '@onekeyfe/hd-transport';
|
|
3
4
|
import { DeviceModelToTypes } from '../types';
|
|
4
5
|
|
|
5
6
|
import type { Features, IDeviceModel, IDeviceType, IVersionRange } from '../types';
|
|
7
|
+
import { existCapability } from './capabilitieUtils';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* get device type by features
|
|
@@ -148,3 +150,17 @@ export const getMethodVersionRange = (
|
|
|
148
150
|
|
|
149
151
|
return versionRange;
|
|
150
152
|
};
|
|
153
|
+
|
|
154
|
+
export const getFirmwareType = (features: Features | undefined) => {
|
|
155
|
+
if (!features) {
|
|
156
|
+
return EFirmwareType.Universal;
|
|
157
|
+
}
|
|
158
|
+
if (features.fw_vendor === 'OneKey Bitcoin-only') {
|
|
159
|
+
return EFirmwareType.BitcoinOnly;
|
|
160
|
+
}
|
|
161
|
+
// old firmware
|
|
162
|
+
return features?.capabilities?.length > 0 &&
|
|
163
|
+
!existCapability(features, Enum_Capability.Capability_Bitcoin_like)
|
|
164
|
+
? EFirmwareType.BitcoinOnly
|
|
165
|
+
: EFirmwareType.Universal;
|
|
166
|
+
};
|
package/src/utils/index.ts
CHANGED
package/src/utils/logger.ts
CHANGED
|
@@ -157,6 +157,7 @@ export enum LoggerNames {
|
|
|
157
157
|
HdTransportHttp = '@onekey/hd-transport-http',
|
|
158
158
|
HdTransportLowLevel = '@onekey/hd-transport-lowlevel',
|
|
159
159
|
HdBleTransport = '@onekey/hd-ble-transport',
|
|
160
|
+
HdWebBleTransport = '@onekey/hd-web-ble-transport',
|
|
160
161
|
Connect = '@onekey/connect',
|
|
161
162
|
Iframe = 'IFrame',
|
|
162
163
|
SendMessage = '[SendMessage]',
|
|
@@ -174,6 +175,7 @@ export const LoggerMap = {
|
|
|
174
175
|
[LoggerNames.HdBleSdk]: initLog(LoggerNames.HdBleSdk),
|
|
175
176
|
[LoggerNames.HdTransportHttp]: initLog(LoggerNames.HdTransportHttp),
|
|
176
177
|
[LoggerNames.HdBleTransport]: initLog(LoggerNames.HdBleTransport),
|
|
178
|
+
[LoggerNames.HdWebBleTransport]: initLog(LoggerNames.HdWebBleTransport),
|
|
177
179
|
[LoggerNames.HdTransportLowLevel]: initLog(LoggerNames.HdTransportLowLevel),
|
|
178
180
|
[LoggerNames.Connect]: initLog(LoggerNames.Connect),
|
|
179
181
|
[LoggerNames.Iframe]: initLog(LoggerNames.Iframe),
|