@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.
- package/dist/api/BaseMethod.d.ts +2 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckBridgeStatus.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckTransportRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetLogs.d.ts.map +1 -1
- package/dist/api/RequestWebUsbDevice.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateReboot.d.ts.map +1 -1
- package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +2 -0
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +138 -85
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +9 -3
- package/src/api/CheckBLEFirmwareRelease.ts +2 -1
- package/src/api/CheckBootloaderRelease.ts +2 -1
- package/src/api/CheckBridgeStatus.ts +1 -0
- package/src/api/CheckFirmwareRelease.ts +1 -0
- package/src/api/CheckTransportRelease.ts +1 -0
- package/src/api/CipherKeyValue.ts +1 -1
- package/src/api/FirmwareUpdate.ts +2 -1
- package/src/api/FirmwareUpdateV2.ts +2 -1
- package/src/api/GetFeatures.ts +6 -1
- package/src/api/GetLogs.ts +1 -0
- package/src/api/GetPassphraseState.ts +1 -1
- package/src/api/RequestWebUsbDevice.ts +1 -0
- package/src/api/SearchDevices.ts +1 -0
- package/src/api/algo/AlgoGetAddress.ts +1 -1
- package/src/api/algo/AlgoSignTransaction.ts +1 -1
- package/src/api/aptos/AptosGetAddress.ts +1 -1
- package/src/api/aptos/AptosGetPublicKey.ts +1 -1
- package/src/api/aptos/AptosSignMessage.ts +1 -1
- package/src/api/aptos/AptosSignTransaction.ts +1 -1
- package/src/api/btc/BTCGetAddress.ts +1 -1
- package/src/api/btc/BTCGetPublicKey.ts +1 -1
- package/src/api/btc/BTCSignMessage.ts +1 -1
- package/src/api/btc/BTCSignTransaction.ts +1 -1
- package/src/api/btc/BTCVerifyMessage.ts +1 -1
- package/src/api/cardano/CardanoGetAddress.ts +1 -1
- package/src/api/cardano/CardanoGetPublicKey.ts +1 -1
- package/src/api/cardano/CardanoSignMessage.ts +1 -1
- package/src/api/cardano/CardanoSignTransaction.ts +1 -1
- package/src/api/conflux/ConfluxGetAddress.ts +1 -1
- package/src/api/conflux/ConfluxSignMessage.ts +1 -1
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -1
- package/src/api/conflux/ConfluxSignTransaction.ts +1 -1
- package/src/api/cosmos/CosmosGetAddress.ts +1 -1
- package/src/api/cosmos/CosmosGetPublicKey.ts +1 -1
- package/src/api/cosmos/CosmosSignTransaction.ts +1 -1
- package/src/api/device/DeviceFullyUploadResource.ts +2 -1
- package/src/api/device/DeviceRebootToBoardloader.ts +1 -0
- package/src/api/device/DeviceRebootToBootloader.ts +1 -0
- package/src/api/device/DeviceSupportFeatures.ts +1 -0
- package/src/api/device/DeviceUpdateBootloader.ts +2 -1
- package/src/api/device/DeviceUpdateReboot.ts +1 -0
- package/src/api/device/DeviceUploadResource.ts +1 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +1 -1
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/filecoin/FilecoinGetAddress.ts +1 -1
- package/src/api/filecoin/FilecoinSignTransaction.ts +1 -1
- package/src/api/near/NearGetAddress.ts +1 -1
- package/src/api/near/NearSignTransaction.ts +1 -1
- package/src/api/nem/NEMGetAddress.ts +1 -1
- package/src/api/nem/NEMSignTransaction.ts +1 -1
- package/src/api/polkadot/PolkadotGetAddress.ts +1 -1
- package/src/api/polkadot/PolkadotSignTransaction.ts +1 -1
- package/src/api/solana/SolGetAddress.ts +1 -1
- package/src/api/solana/SolSignTransaction.ts +1 -1
- package/src/api/starcoin/StarcoinGetAddress.ts +1 -1
- package/src/api/starcoin/StarcoinGetPublicKey.ts +1 -1
- package/src/api/starcoin/StarcoinSignMessage.ts +1 -1
- package/src/api/starcoin/StarcoinSignTransaction.ts +1 -1
- package/src/api/starcoin/StarcoinVerifyMessage.ts +1 -1
- package/src/api/stellar/StellarGetAddress.ts +1 -1
- package/src/api/stellar/StellarSignTransaction.ts +1 -1
- package/src/api/sui/SuiGetAddress.ts +1 -1
- package/src/api/sui/SuiGetPublicKey.ts +1 -1
- package/src/api/sui/SuiSignTransaction.ts +1 -1
- package/src/api/tron/TronGetAddress.ts +1 -1
- package/src/api/tron/TronSignMessage.ts +1 -1
- package/src/api/tron/TronSignTransaction.ts +1 -1
- package/src/api/xrp/XrpGetAddress.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/core/index.ts +42 -27
- package/src/data-manager/DataManager.ts +15 -1
- package/src/data-manager/connectSettings.ts +4 -0
- package/src/device/DeviceCommands.ts +3 -0
- package/src/types/params.ts +5 -0
- 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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
semver.gte(currentVersion, versionRange.max)
|
|
159
|
+
(newVersionStatus === 'required' || bleVersionStatus === 'required') &&
|
|
160
|
+
method.skipForceUpdateCheck === false
|
|
174
161
|
) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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
|
}
|
package/src/types/params.ts
CHANGED
package/src/types/settings.ts
CHANGED