@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.
Files changed (51) hide show
  1. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  2. package/dist/api/cardano/CardanoSignMessage.d.ts +5 -0
  3. package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
  4. package/dist/api/device/DeviceUnlock.d.ts +2 -0
  5. package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
  6. package/dist/api/tron/TronSignTransaction.d.ts +2 -0
  7. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  8. package/dist/core/index.d.ts.map +1 -1
  9. package/dist/data-manager/DataManager.d.ts.map +1 -1
  10. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  11. package/dist/device/Device.d.ts +1 -1
  12. package/dist/device/Device.d.ts.map +1 -1
  13. package/dist/device/DeviceCommands.d.ts +4 -4
  14. package/dist/events/ui-request.d.ts +3 -1
  15. package/dist/events/ui-request.d.ts.map +1 -1
  16. package/dist/index.d.ts +14 -8
  17. package/dist/index.js +123 -12
  18. package/dist/types/api/cardanoSignMessage.d.ts +3 -0
  19. package/dist/types/api/cardanoSignMessage.d.ts.map +1 -1
  20. package/dist/types/api/tronSignTransaction.d.ts +1 -0
  21. package/dist/types/api/tronSignTransaction.d.ts.map +1 -1
  22. package/dist/types/settings.d.ts +1 -1
  23. package/dist/types/settings.d.ts.map +1 -1
  24. package/dist/utils/capabilitieUtils.d.ts +5 -0
  25. package/dist/utils/capabilitieUtils.d.ts.map +1 -0
  26. package/dist/utils/deviceInfoUtils.d.ts +2 -0
  27. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  28. package/dist/utils/index.d.ts +1 -1
  29. package/dist/utils/index.d.ts.map +1 -1
  30. package/dist/utils/logger.d.ts +2 -0
  31. package/dist/utils/logger.d.ts.map +1 -1
  32. package/dist/utils/patch.d.ts +1 -1
  33. package/dist/utils/patch.d.ts.map +1 -1
  34. package/package.json +4 -4
  35. package/src/api/FirmwareUpdateV3.ts +2 -0
  36. package/src/api/cardano/CardanoSignMessage.ts +15 -0
  37. package/src/api/device/DeviceUnlock.ts +33 -0
  38. package/src/api/tron/TronSignTransaction.ts +21 -0
  39. package/src/core/index.ts +14 -7
  40. package/src/data/messages/messages.json +30 -1
  41. package/src/data-manager/DataManager.ts +1 -1
  42. package/src/data-manager/TransportManager.ts +3 -0
  43. package/src/device/Device.ts +5 -4
  44. package/src/events/ui-request.ts +5 -0
  45. package/src/types/api/cardanoSignMessage.ts +3 -0
  46. package/src/types/api/tronSignTransaction.ts +1 -0
  47. package/src/types/settings.ts +10 -1
  48. package/src/utils/capabilitieUtils.ts +12 -0
  49. package/src/utils/deviceInfoUtils.ts +17 -1
  50. package/src/utils/index.ts +1 -0
  51. package/src/utils/logger.ts +2 -0
@@ -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(
@@ -29,6 +29,7 @@ export type TronDelegateResourceContract = {
29
29
  balance?: number;
30
30
  receiverAddress?: string;
31
31
  lock?: boolean;
32
+ lockPeriod?: number;
32
33
  };
33
34
 
34
35
  export type TronUnDelegateResourceContract = {
@@ -14,7 +14,16 @@ export type ConnectSettings = {
14
14
  priority: number;
15
15
  trustedHost: boolean;
16
16
  supportedBrowser?: boolean;
17
- env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb' | 'lowlevel';
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
+ };
@@ -10,6 +10,7 @@ export {
10
10
  getDeviceUUID,
11
11
  getDeviceLabel,
12
12
  getMethodVersionRange,
13
+ getFirmwareType,
13
14
  } from './deviceInfoUtils';
14
15
  export {
15
16
  getDeviceBoardloaderVersion,
@@ -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),