@onekeyfe/hd-core 0.2.39 → 0.2.41

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 (113) hide show
  1. package/dist/api/BaseMethod.d.ts +2 -1
  2. package/dist/api/BaseMethod.d.ts.map +1 -1
  3. package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
  4. package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
  5. package/dist/api/CheckBridgeStatus.d.ts.map +1 -1
  6. package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
  7. package/dist/api/CheckTransportRelease.d.ts.map +1 -1
  8. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  9. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  10. package/dist/api/GetFeatures.d.ts.map +1 -1
  11. package/dist/api/GetLogs.d.ts.map +1 -1
  12. package/dist/api/RequestWebUsbDevice.d.ts.map +1 -1
  13. package/dist/api/SearchDevices.d.ts.map +1 -1
  14. package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
  15. package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
  16. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
  17. package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
  18. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  19. package/dist/api/device/DeviceUpdateReboot.d.ts.map +1 -1
  20. package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
  21. package/dist/core/index.d.ts.map +1 -1
  22. package/dist/data-manager/DataManager.d.ts +2 -0
  23. package/dist/data-manager/DataManager.d.ts.map +1 -1
  24. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  25. package/dist/device/DeviceCommands.d.ts.map +1 -1
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +138 -85
  28. package/dist/types/params.d.ts +1 -0
  29. package/dist/types/params.d.ts.map +1 -1
  30. package/dist/types/settings.d.ts +1 -0
  31. package/dist/types/settings.d.ts.map +1 -1
  32. package/package.json +4 -4
  33. package/src/api/BaseMethod.ts +9 -3
  34. package/src/api/CheckBLEFirmwareRelease.ts +2 -1
  35. package/src/api/CheckBootloaderRelease.ts +2 -1
  36. package/src/api/CheckBridgeStatus.ts +1 -0
  37. package/src/api/CheckFirmwareRelease.ts +1 -0
  38. package/src/api/CheckTransportRelease.ts +1 -0
  39. package/src/api/CipherKeyValue.ts +1 -1
  40. package/src/api/FirmwareUpdate.ts +2 -1
  41. package/src/api/FirmwareUpdateV2.ts +2 -1
  42. package/src/api/GetFeatures.ts +6 -1
  43. package/src/api/GetLogs.ts +1 -0
  44. package/src/api/GetPassphraseState.ts +1 -1
  45. package/src/api/RequestWebUsbDevice.ts +1 -0
  46. package/src/api/SearchDevices.ts +1 -0
  47. package/src/api/algo/AlgoGetAddress.ts +1 -1
  48. package/src/api/algo/AlgoSignTransaction.ts +1 -1
  49. package/src/api/aptos/AptosGetAddress.ts +1 -1
  50. package/src/api/aptos/AptosGetPublicKey.ts +1 -1
  51. package/src/api/aptos/AptosSignMessage.ts +1 -1
  52. package/src/api/aptos/AptosSignTransaction.ts +1 -1
  53. package/src/api/btc/BTCGetAddress.ts +1 -1
  54. package/src/api/btc/BTCGetPublicKey.ts +1 -1
  55. package/src/api/btc/BTCSignMessage.ts +1 -1
  56. package/src/api/btc/BTCSignTransaction.ts +1 -1
  57. package/src/api/btc/BTCVerifyMessage.ts +1 -1
  58. package/src/api/cardano/CardanoGetAddress.ts +1 -1
  59. package/src/api/cardano/CardanoGetPublicKey.ts +1 -1
  60. package/src/api/cardano/CardanoSignMessage.ts +1 -1
  61. package/src/api/cardano/CardanoSignTransaction.ts +1 -1
  62. package/src/api/conflux/ConfluxGetAddress.ts +1 -1
  63. package/src/api/conflux/ConfluxSignMessage.ts +1 -1
  64. package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -1
  65. package/src/api/conflux/ConfluxSignTransaction.ts +1 -1
  66. package/src/api/cosmos/CosmosGetAddress.ts +1 -1
  67. package/src/api/cosmos/CosmosGetPublicKey.ts +1 -1
  68. package/src/api/cosmos/CosmosSignTransaction.ts +1 -1
  69. package/src/api/device/DeviceFullyUploadResource.ts +2 -1
  70. package/src/api/device/DeviceRebootToBoardloader.ts +1 -0
  71. package/src/api/device/DeviceRebootToBootloader.ts +1 -0
  72. package/src/api/device/DeviceSupportFeatures.ts +1 -0
  73. package/src/api/device/DeviceUpdateBootloader.ts +2 -1
  74. package/src/api/device/DeviceUpdateReboot.ts +1 -0
  75. package/src/api/device/DeviceUploadResource.ts +1 -0
  76. package/src/api/evm/EVMGetAddress.ts +1 -1
  77. package/src/api/evm/EVMGetPublicKey.ts +1 -1
  78. package/src/api/evm/EVMSignMessage.ts +1 -1
  79. package/src/api/evm/EVMSignMessageEIP712.ts +1 -1
  80. package/src/api/evm/EVMSignTransaction.ts +1 -1
  81. package/src/api/evm/EVMSignTypedData.ts +1 -1
  82. package/src/api/evm/EVMVerifyMessage.ts +1 -1
  83. package/src/api/filecoin/FilecoinGetAddress.ts +1 -1
  84. package/src/api/filecoin/FilecoinSignTransaction.ts +1 -1
  85. package/src/api/near/NearGetAddress.ts +1 -1
  86. package/src/api/near/NearSignTransaction.ts +1 -1
  87. package/src/api/nem/NEMGetAddress.ts +1 -1
  88. package/src/api/nem/NEMSignTransaction.ts +1 -1
  89. package/src/api/polkadot/PolkadotGetAddress.ts +1 -1
  90. package/src/api/polkadot/PolkadotSignTransaction.ts +1 -1
  91. package/src/api/solana/SolGetAddress.ts +1 -1
  92. package/src/api/solana/SolSignTransaction.ts +1 -1
  93. package/src/api/starcoin/StarcoinGetAddress.ts +1 -1
  94. package/src/api/starcoin/StarcoinGetPublicKey.ts +1 -1
  95. package/src/api/starcoin/StarcoinSignMessage.ts +1 -1
  96. package/src/api/starcoin/StarcoinSignTransaction.ts +1 -1
  97. package/src/api/starcoin/StarcoinVerifyMessage.ts +1 -1
  98. package/src/api/stellar/StellarGetAddress.ts +1 -1
  99. package/src/api/stellar/StellarSignTransaction.ts +1 -1
  100. package/src/api/sui/SuiGetAddress.ts +1 -1
  101. package/src/api/sui/SuiGetPublicKey.ts +1 -1
  102. package/src/api/sui/SuiSignTransaction.ts +1 -1
  103. package/src/api/tron/TronGetAddress.ts +1 -1
  104. package/src/api/tron/TronSignMessage.ts +1 -1
  105. package/src/api/tron/TronSignTransaction.ts +1 -1
  106. package/src/api/xrp/XrpGetAddress.ts +1 -1
  107. package/src/api/xrp/XrpSignTransaction.ts +1 -1
  108. package/src/core/index.ts +42 -27
  109. package/src/data-manager/DataManager.ts +15 -1
  110. package/src/data-manager/connectSettings.ts +4 -0
  111. package/src/device/DeviceCommands.ts +3 -0
  112. package/src/types/params.ts +5 -0
  113. package/src/types/settings.ts +1 -0
@@ -10,7 +10,7 @@ export default class FilecoinSignTransaction extends BaseMethod<HardwareFilecoin
10
10
 
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
- this.allowDeviceMode = [...this.allowDeviceMode];
13
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode];
14
14
 
15
15
  // check payload
16
16
  validateParams(this.payload, [
@@ -10,7 +10,7 @@ export default class NearGetAddress extends BaseMethod<HardwareNearGetAddress[]>
10
10
 
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
13
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
14
14
 
15
15
  this.hasBundle = !!this.payload?.bundle;
16
16
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -8,7 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
8
8
  export default class NearSignTransaction extends BaseMethod<HardwareNearSignTx> {
9
9
  init() {
10
10
  this.checkDeviceId = true;
11
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
11
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
12
12
 
13
13
  // check payload
14
14
  validateParams(this.payload, [
@@ -12,7 +12,7 @@ export default class NEMGetAddress extends BaseMethod<HardwareNEMGetAddress[]> {
12
12
 
13
13
  init() {
14
14
  this.checkDeviceId = true;
15
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
16
16
 
17
17
  this.hasBundle = !!this.payload?.bundle;
18
18
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -228,7 +228,7 @@ export default class NEMSignTransaction extends BaseMethod<NEMSignTx> {
228
228
 
229
229
  init() {
230
230
  this.checkDeviceId = true;
231
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
231
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
232
232
 
233
233
  validateParams(this.payload, [
234
234
  { name: 'path', required: true },
@@ -10,7 +10,7 @@ export default class PolkadotGetAddress extends BaseMethod<HardwarePolkadotGetAd
10
10
 
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
- this.allowDeviceMode = [...this.allowDeviceMode];
13
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode];
14
14
 
15
15
  this.hasBundle = !!this.payload?.bundle;
16
16
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -10,7 +10,7 @@ export default class PolkadotSignTransaction extends BaseMethod<HardwarePolkadot
10
10
 
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
- this.allowDeviceMode = [...this.allowDeviceMode];
13
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode];
14
14
 
15
15
  // check payload
16
16
  validateParams(this.payload, [
@@ -10,7 +10,7 @@ export default class SolGetAddress extends BaseMethod<SolanaGetAddress[]> {
10
10
 
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
13
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
14
14
 
15
15
  this.hasBundle = !!this.payload?.bundle;
16
16
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -11,7 +11,7 @@ export default class SolSignTransaction extends BaseMethod<HardwareSolanaSignTx[
11
11
 
12
12
  init() {
13
13
  this.checkDeviceId = true;
14
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
14
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
15
15
 
16
16
  this.hasBundle = !!this.payload?.bundle;
17
17
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -10,7 +10,7 @@ export default class StarcoinGetAddress extends BaseMethod<HardwareStarcoinGetAd
10
10
 
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
13
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
14
14
 
15
15
  this.hasBundle = !!this.payload?.bundle;
16
16
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -13,7 +13,7 @@ export default class StarcoinGetPublicKey extends BaseMethod<HardwareStarcoinGet
13
13
 
14
14
  init() {
15
15
  this.checkDeviceId = true;
16
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
17
17
 
18
18
  this.hasBundle = !!this.payload?.bundle;
19
19
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -8,7 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
8
8
  export default class StarcoinSignMessage extends BaseMethod<HardwareStarcoinSignMessage> {
9
9
  init() {
10
10
  this.checkDeviceId = true;
11
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
11
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
12
12
 
13
13
  // check payload
14
14
  validateParams(this.payload, [
@@ -8,7 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
8
8
  export default class StarcoinSignTransaction extends BaseMethod<StarcoinSignTx> {
9
9
  init() {
10
10
  this.checkDeviceId = true;
11
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
11
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
12
12
 
13
13
  // check payload
14
14
  validateParams(this.payload, [
@@ -7,7 +7,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
7
7
  export default class EVMSignMessage extends BaseMethod<HardwareStarcoinVerifyMessage> {
8
8
  init() {
9
9
  this.checkDeviceId = true;
10
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
10
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
11
11
 
12
12
  validateParams(this.payload, [
13
13
  { name: 'publicKey', type: 'string', required: true },
@@ -10,7 +10,7 @@ export default class StellarGetAddress extends BaseMethod<HardwareStellarGetAddr
10
10
 
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
13
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
14
14
 
15
15
  this.hasBundle = !!this.payload?.bundle;
16
16
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -149,7 +149,7 @@ export default class StellarSignTransaction extends BaseMethod<HardwareStellarSi
149
149
 
150
150
  init() {
151
151
  this.checkDeviceId = true;
152
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
152
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
153
153
 
154
154
  // check payload
155
155
  validateParams(this.payload, [
@@ -15,7 +15,7 @@ export default class SuiGetAddress extends BaseMethod<HardwareSuiGetAddress[]> {
15
15
 
16
16
  init() {
17
17
  this.checkDeviceId = true;
18
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
19
19
 
20
20
  this.hasBundle = !!this.payload?.bundle;
21
21
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -9,7 +9,7 @@ export default class SuiGetPublicKey extends BaseMethod<any> {
9
9
 
10
10
  init() {
11
11
  this.checkDeviceId = true;
12
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
12
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
13
13
 
14
14
  this.hasBundle = !!this.payload?.bundle;
15
15
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -8,7 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
8
8
  export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
9
9
  init() {
10
10
  this.checkDeviceId = true;
11
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
11
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
12
12
 
13
13
  // check payload
14
14
  validateParams(this.payload, [
@@ -10,7 +10,7 @@ export default class TronGetAddress extends BaseMethod<HardwareTronGetAddress[]>
10
10
 
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
13
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
14
14
 
15
15
  this.hasBundle = !!this.payload?.bundle;
16
16
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -8,7 +8,7 @@ import { stripHexPrefix } from '../helpers/hexUtils';
8
8
  export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage> {
9
9
  init() {
10
10
  this.checkDeviceId = true;
11
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
11
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
12
12
 
13
13
  // check payload
14
14
  validateParams(this.payload, [
@@ -46,7 +46,7 @@ export default class TronSignTransaction extends BaseMethod<TronSignTx> {
46
46
 
47
47
  init() {
48
48
  this.checkDeviceId = true;
49
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
49
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
50
50
 
51
51
  // check payload
52
52
  validateParams(this.payload, [
@@ -16,7 +16,7 @@ export default class XrpGetAddress extends BaseMethod<
16
16
 
17
17
  init() {
18
18
  this.checkDeviceId = true;
19
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
19
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
20
20
 
21
21
  this.hasBundle = !!this.payload?.bundle;
22
22
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -9,7 +9,7 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
9
9
 
10
10
  init() {
11
11
  this.checkDeviceId = true;
12
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
12
+ this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
13
13
 
14
14
  const { payload } = this;
15
15
  validateParams(payload, [
package/src/core/index.ts CHANGED
@@ -45,7 +45,7 @@ const parseInitOptions = (method?: BaseMethod): InitOptions => ({
45
45
  initSession: method?.payload.initSession,
46
46
  passphraseState: method?.payload.passphraseState,
47
47
  deviceId: method?.payload.deviceId,
48
- deriveCardano: method?.name.startsWith('cardano'),
48
+ deriveCardano: method?.name.startsWith('cardano') || method?.payload?.deriveCardano,
49
49
  });
50
50
 
51
51
  let _core: Core;
@@ -151,40 +151,55 @@ export const callAPI = async (message: CoreMessage) => {
151
151
  // Type has a higher priority than Model
152
152
  const versionRange = versionRangeType ?? versionRangeModel;
153
153
 
154
- if (versionRange && device.features) {
155
- const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
156
- if (semver.valid(versionRange.min) && semver.lt(currentVersion, versionRange.min)) {
157
- const newVersionUnReleased = DataManager.getFirmwareStatus(device.features);
158
- if (newVersionUnReleased === 'none' || newVersionUnReleased === 'valid') {
159
- throw ERRORS.TypedError(HardwareErrorCode.NewFirmwareUnRelease);
160
- }
161
-
162
- return Promise.reject(
163
- ERRORS.TypedError(
164
- HardwareErrorCode.CallMethodNeedUpgradeFirmware,
165
- `Device firmware version is too low, please update to ${versionRange.min}`,
166
- { current: currentVersion, require: versionRange.min }
167
- )
168
- );
169
- }
154
+ if (device.features) {
155
+ await DataManager.checkAndReloadData();
156
+ const newVersionStatus = DataManager.getFirmwareStatus(device.features);
157
+ const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
170
158
  if (
171
- versionRange.max &&
172
- semver.valid(versionRange.max) &&
173
- semver.gte(currentVersion, versionRange.max)
159
+ (newVersionStatus === 'required' || bleVersionStatus === 'required') &&
160
+ method.skipForceUpdateCheck === false
174
161
  ) {
175
- return Promise.reject(
176
- ERRORS.TypedError(
177
- HardwareErrorCode.CallMethodDeprecated,
178
- `Device firmware version is too high, this method has been deprecated in ${versionRange.max}`,
179
- { current: currentVersion, deprecated: versionRange.max }
180
- )
162
+ throw ERRORS.TypedError(
163
+ HardwareErrorCode.NewFirmwareForceUpdate,
164
+ 'Device firmware version is too low, please update to the latest version',
165
+ { connectId: method.connectId, deviceId: method.deviceId }
181
166
  );
182
167
  }
168
+
169
+ if (versionRange) {
170
+ const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
171
+ if (semver.valid(versionRange.min) && semver.lt(currentVersion, versionRange.min)) {
172
+ if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
173
+ throw ERRORS.TypedError(HardwareErrorCode.NewFirmwareUnRelease);
174
+ }
175
+
176
+ return Promise.reject(
177
+ ERRORS.TypedError(
178
+ HardwareErrorCode.CallMethodNeedUpgradeFirmware,
179
+ `Device firmware version is too low, please update to ${versionRange.min}`,
180
+ { current: currentVersion, require: versionRange.min }
181
+ )
182
+ );
183
+ }
184
+ if (
185
+ versionRange.max &&
186
+ semver.valid(versionRange.max) &&
187
+ semver.gte(currentVersion, versionRange.max)
188
+ ) {
189
+ return Promise.reject(
190
+ ERRORS.TypedError(
191
+ HardwareErrorCode.CallMethodDeprecated,
192
+ `Device firmware version is too high, this method has been deprecated in ${versionRange.max}`,
193
+ { current: currentVersion, deprecated: versionRange.max }
194
+ )
195
+ );
196
+ }
197
+ }
183
198
  }
184
199
 
185
200
  // check call method mode
186
201
  const unexpectedMode = device.hasUnexpectedMode(
187
- method.allowDeviceMode,
202
+ method.notAllowDeviceMode,
188
203
  method.requireDeviceMode
189
204
  );
190
205
  if (unexpectedMode) {
@@ -52,6 +52,8 @@ export default class DataManager {
52
52
  default: MessagesJSON as unknown as JSON,
53
53
  };
54
54
 
55
+ static lastCheckTimestamp = 0;
56
+
55
57
  static getFirmwareStatus = (features: Features): IDeviceFirmwareStatus => {
56
58
  const deviceType = getDeviceType(features);
57
59
  const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
@@ -207,8 +209,12 @@ export default class DataManager {
207
209
  static async load(settings: ConnectSettings) {
208
210
  this.settings = settings;
209
211
  try {
212
+ const url = settings.preRelease
213
+ ? 'https://data.onekey.so/pre-config.json'
214
+ : 'https://data.onekey.so/config.json';
215
+
210
216
  const { data } = await axios.get<RemoteConfigResponse>(
211
- `https://data.onekey.so/config.json?noCache=${getTimeStamp()}`,
217
+ `${url}?noCache=${getTimeStamp()}`,
212
218
  // because of iframe timeout is 10000
213
219
  {
214
220
  timeout: 7000,
@@ -228,6 +234,14 @@ export default class DataManager {
228
234
  }
229
235
  }
230
236
 
237
+ static async checkAndReloadData() {
238
+ if (getTimeStamp() - this.lastCheckTimestamp > 1000 * 60 * 60 * 3) {
239
+ await this.load(this.settings).then(() => {
240
+ this.lastCheckTimestamp = getTimeStamp();
241
+ });
242
+ }
243
+ }
244
+
231
245
  static getProtobufMessages() {
232
246
  return this.messages.default;
233
247
  }
@@ -105,6 +105,10 @@ export const parseConnectSettings = (input: Partial<ConnectSettings> = {}) => {
105
105
  settings.timestamp = input.timestamp;
106
106
  }
107
107
 
108
+ if (input.preRelease) {
109
+ settings.preRelease = input.preRelease;
110
+ }
111
+
108
112
  return settings;
109
113
  };
110
114
 
@@ -82,6 +82,9 @@ export class DeviceCommands {
82
82
  if (error?.response?.data?.error === 'device disconnected during action') {
83
83
  return { type: 'BridgeNetworkError', message: {} } as any;
84
84
  }
85
+ if (error?.response?.data?.error?.indexOf('Request failed with status code') !== -1) {
86
+ return { type: 'CallMethodError', message: {} } as any;
87
+ }
85
88
  throw error;
86
89
  }
87
90
  }
@@ -24,6 +24,11 @@ export interface CommonParams {
24
24
  * Every init session
25
25
  */
26
26
  initSession?: boolean;
27
+
28
+ /**
29
+ * Use derive cardano
30
+ */
31
+ deriveCardano?: boolean;
27
32
  }
28
33
 
29
34
  export type Params<T> = CommonParams & T & { bundle?: undefined };
@@ -17,6 +17,7 @@ export type ConnectSettings = {
17
17
  env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb';
18
18
  timestamp: number;
19
19
  isFrame?: boolean;
20
+ preRelease?: boolean;
20
21
  };
21
22
 
22
23
  export type IVersionArray = [number, number, number];