@onekeyfe/hd-core 0.3.23 → 0.3.25
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/firmware/getBinary.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -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/TransportManager.d.ts +3 -2
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.js +82 -42
- package/dist/types/api/getFeatures.d.ts +2 -2
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/init.d.ts +2 -1
- package/dist/types/api/init.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -2
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +6 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- 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/package.json +4 -4
- package/src/api/FirmwareUpdateV2.ts +1 -1
- package/src/api/SearchDevices.ts +1 -1
- package/src/api/firmware/getBinary.ts +6 -9
- package/src/api/firmware/uploadFirmware.ts +2 -2
- package/src/core/index.ts +15 -11
- package/src/data-manager/DataManager.ts +33 -9
- package/src/data-manager/TransportManager.ts +17 -2
- package/src/device/Device.ts +7 -7
- package/src/device/DeviceConnector.ts +1 -1
- package/src/inject.ts +1 -1
- package/src/types/api/getFeatures.ts +2 -2
- package/src/types/api/init.ts +3 -1
- package/src/types/settings.ts +1 -2
- package/src/utils/deviceFeaturesUtils.ts +16 -5
- package/src/utils/index.ts +2 -0
- package/src/utils/logger.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const inject = ({ call, cancel, dispose, eventEmitter, init, updateSettings, uiR
|
|
|
44
44
|
const createCoreApi = (call) => ({
|
|
45
45
|
getLogs: () => call({ method: 'getLogs' }),
|
|
46
46
|
searchDevices: () => call({ method: 'searchDevices' }),
|
|
47
|
-
getFeatures: connectId => call({ connectId, method: 'getFeatures' }),
|
|
47
|
+
getFeatures: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'getFeatures' })),
|
|
48
48
|
checkFirmwareRelease: connectId => call({ connectId, method: 'checkFirmwareRelease' }),
|
|
49
49
|
checkBLEFirmwareRelease: connectId => call({ connectId, method: 'checkBLEFirmwareRelease' }),
|
|
50
50
|
checkTransportRelease: () => call({ method: 'checkTransportRelease' }),
|
|
@@ -22497,6 +22497,7 @@ exports.LoggerNames = void 0;
|
|
|
22497
22497
|
LoggerNames["HdCommonConnectSdk"] = "@onekey/common-connect-sdk";
|
|
22498
22498
|
LoggerNames["HdBleSdk"] = "@onekey/hd-ble-sdk";
|
|
22499
22499
|
LoggerNames["HdTransportHttp"] = "@onekey/hd-transport-http";
|
|
22500
|
+
LoggerNames["HdTransportLowLevel"] = "@onekey/hd-transport-lowlevel";
|
|
22500
22501
|
LoggerNames["HdBleTransport"] = "@onekey/hd-ble-transport";
|
|
22501
22502
|
LoggerNames["Connect"] = "@onekey/connect";
|
|
22502
22503
|
LoggerNames["Iframe"] = "IFrame";
|
|
@@ -22514,6 +22515,7 @@ const LoggerMap = {
|
|
|
22514
22515
|
[exports.LoggerNames.HdBleSdk]: initLog(exports.LoggerNames.HdBleSdk),
|
|
22515
22516
|
[exports.LoggerNames.HdTransportHttp]: initLog(exports.LoggerNames.HdTransportHttp),
|
|
22516
22517
|
[exports.LoggerNames.HdBleTransport]: initLog(exports.LoggerNames.HdBleTransport),
|
|
22518
|
+
[exports.LoggerNames.HdTransportLowLevel]: initLog(exports.LoggerNames.HdTransportLowLevel),
|
|
22517
22519
|
[exports.LoggerNames.Connect]: initLog(exports.LoggerNames.Connect),
|
|
22518
22520
|
[exports.LoggerNames.Iframe]: initLog(exports.LoggerNames.Iframe),
|
|
22519
22521
|
[exports.LoggerNames.SendMessage]: initLog(exports.LoggerNames.SendMessage),
|
|
@@ -22763,6 +22765,7 @@ const getHomeScreenHex = (deviceType, name) => {
|
|
|
22763
22765
|
const wait = (ms) => new Promise(resolve => {
|
|
22764
22766
|
setTimeout(resolve, ms);
|
|
22765
22767
|
});
|
|
22768
|
+
const isBleConnect = (env) => env === 'react-native' || env === 'lowlevel';
|
|
22766
22769
|
|
|
22767
22770
|
const getReleaseStatus = (releases, currentVersion) => {
|
|
22768
22771
|
const newVersions = releases.filter(r => semver__default["default"].gt(r.version.join('.'), currentVersion));
|
|
@@ -22870,7 +22873,7 @@ DataManager.getFirmwareStatus = (features) => {
|
|
|
22870
22873
|
if (deviceType === 'classic' && features.bootloader_mode) {
|
|
22871
22874
|
return 'unknown';
|
|
22872
22875
|
}
|
|
22873
|
-
const firmwareUpdateField = getFirmwareUpdateField(features, 'firmware');
|
|
22876
|
+
const firmwareUpdateField = getFirmwareUpdateField({ features, updateType: 'firmware' });
|
|
22874
22877
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
22875
22878
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
22876
22879
|
return getReleaseStatus(targetDeviceConfigList, currentVersion);
|
|
@@ -22881,7 +22884,10 @@ DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
|
|
|
22881
22884
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
22882
22885
|
if (deviceType !== 'pro' && deviceType !== 'touch')
|
|
22883
22886
|
return undefined;
|
|
22884
|
-
const firmwareUpdateField = getFirmwareUpdateField(
|
|
22887
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
22888
|
+
features,
|
|
22889
|
+
updateType: 'firmware',
|
|
22890
|
+
});
|
|
22885
22891
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
22886
22892
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
22887
22893
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => forcedUpdateRes
|
|
@@ -22894,7 +22900,10 @@ DataManager.getSysFullResource = (features) => {
|
|
|
22894
22900
|
const deviceType = getDeviceType(features);
|
|
22895
22901
|
if (deviceType !== 'pro' && deviceType !== 'touch')
|
|
22896
22902
|
return undefined;
|
|
22897
|
-
const firmwareUpdateField = getFirmwareUpdateField(
|
|
22903
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
22904
|
+
features,
|
|
22905
|
+
updateType: 'firmware',
|
|
22906
|
+
});
|
|
22898
22907
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
22899
22908
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.fullResource);
|
|
22900
22909
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.fullResource;
|
|
@@ -22904,7 +22913,10 @@ DataManager.getBootloaderResource = (features) => {
|
|
|
22904
22913
|
const deviceType = getDeviceType(features);
|
|
22905
22914
|
if (deviceType !== 'pro' && deviceType !== 'touch')
|
|
22906
22915
|
return undefined;
|
|
22907
|
-
const firmwareUpdateField = getFirmwareUpdateField(
|
|
22916
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
22917
|
+
features,
|
|
22918
|
+
updateType: 'firmware',
|
|
22919
|
+
});
|
|
22908
22920
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
22909
22921
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
22910
22922
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.bootloaderResource;
|
|
@@ -22912,7 +22924,10 @@ DataManager.getBootloaderResource = (features) => {
|
|
|
22912
22924
|
DataManager.getBootloaderTargetVersion = (features) => {
|
|
22913
22925
|
var _b, _c, _d, _e;
|
|
22914
22926
|
const deviceType = getDeviceType(features);
|
|
22915
|
-
const firmwareUpdateField = getFirmwareUpdateField(
|
|
22927
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
22928
|
+
features,
|
|
22929
|
+
updateType: 'firmware',
|
|
22930
|
+
});
|
|
22916
22931
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
22917
22932
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
22918
22933
|
return (_e = (_d = targetDeviceConfig === null || targetDeviceConfig === void 0 ? void 0 : targetDeviceConfig[0]) === null || _d === void 0 ? void 0 : _d.bootloaderVersion) !== null && _e !== void 0 ? _e : undefined;
|
|
@@ -22922,7 +22937,10 @@ DataManager.getBootloaderRelatedFirmwareVersion = (features) => {
|
|
|
22922
22937
|
const deviceType = getDeviceType(features);
|
|
22923
22938
|
if (!(deviceType === 'classic' || deviceType === 'mini'))
|
|
22924
22939
|
return undefined;
|
|
22925
|
-
const firmwareUpdateField = getFirmwareUpdateField(
|
|
22940
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
22941
|
+
features,
|
|
22942
|
+
updateType: 'firmware',
|
|
22943
|
+
});
|
|
22926
22944
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
22927
22945
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderRelatedFirmwareVersion);
|
|
22928
22946
|
return (_e = (_d = targetDeviceConfig === null || targetDeviceConfig === void 0 ? void 0 : targetDeviceConfig[0]) === null || _d === void 0 ? void 0 : _d.bootloaderRelatedFirmwareVersion) !== null && _e !== void 0 ? _e : undefined;
|
|
@@ -22935,7 +22953,10 @@ DataManager.getFirmwareChangelog = (features) => {
|
|
|
22935
22953
|
(deviceType === 'classic' && features.bootloader_mode)) {
|
|
22936
22954
|
return [];
|
|
22937
22955
|
}
|
|
22938
|
-
const firmwareUpdateField = getFirmwareUpdateField(
|
|
22956
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
22957
|
+
features,
|
|
22958
|
+
updateType: 'firmware',
|
|
22959
|
+
});
|
|
22939
22960
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
22940
22961
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
22941
22962
|
return getReleaseChangelog(targetDeviceConfigList, currentVersion);
|
|
@@ -22943,7 +22964,10 @@ DataManager.getFirmwareChangelog = (features) => {
|
|
|
22943
22964
|
DataManager.getFirmwareLatestRelease = (features) => {
|
|
22944
22965
|
var _b, _c;
|
|
22945
22966
|
const deviceType = getDeviceType(features);
|
|
22946
|
-
const firmwareUpdateField = getFirmwareUpdateField(
|
|
22967
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
22968
|
+
features,
|
|
22969
|
+
updateType: 'firmware',
|
|
22970
|
+
});
|
|
22947
22971
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
22948
22972
|
const target = findLatestRelease(targetDeviceConfigList);
|
|
22949
22973
|
if (!target)
|
|
@@ -22990,6 +23014,7 @@ DataManager.getTransportStatus = (localVersion) => {
|
|
|
22990
23014
|
const isLatest = semver__default["default"].gte(localVersion, latestTransportVersion.join('.'));
|
|
22991
23015
|
return isLatest ? 'valid' : 'outdated';
|
|
22992
23016
|
};
|
|
23017
|
+
DataManager.isBleConnect = (env) => env === 'react-native' || env === 'lowlevel';
|
|
22993
23018
|
|
|
22994
23019
|
const PROTOBUF_MESSAGE_CONFIG = {
|
|
22995
23020
|
model_mini: [
|
|
@@ -23181,7 +23206,7 @@ const supportModifyHomescreen = (features) => {
|
|
|
23181
23206
|
}
|
|
23182
23207
|
return { support: semver__default["default"].gte(currentVersion, '3.4.0') };
|
|
23183
23208
|
};
|
|
23184
|
-
const getFirmwareUpdateField = (features, updateType) => {
|
|
23209
|
+
const getFirmwareUpdateField = ({ features, updateType, targetVersion, }) => {
|
|
23185
23210
|
const deviceType = getDeviceType(features);
|
|
23186
23211
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
23187
23212
|
if (updateType === 'ble') {
|
|
@@ -23191,6 +23216,12 @@ const getFirmwareUpdateField = (features, updateType) => {
|
|
|
23191
23216
|
return 'firmware-v4';
|
|
23192
23217
|
}
|
|
23193
23218
|
if (deviceType === 'touch') {
|
|
23219
|
+
if (targetVersion) {
|
|
23220
|
+
if (semver__default["default"].eq(targetVersion, '4.0.0'))
|
|
23221
|
+
return 'firmware-v2';
|
|
23222
|
+
if (semver__default["default"].gt(targetVersion, '4.0.0'))
|
|
23223
|
+
return 'firmware-v4';
|
|
23224
|
+
}
|
|
23194
23225
|
if (semver__default["default"].lt(deviceFirmwareVersion.join('.'), '3.4.0'))
|
|
23195
23226
|
return 'firmware';
|
|
23196
23227
|
return 'firmware-v4';
|
|
@@ -23515,6 +23546,7 @@ DevicePool.emitter = new events.exports();
|
|
|
23515
23546
|
const Log$7 = getLogger(exports.LoggerNames.Transport);
|
|
23516
23547
|
const BleLogger = getLogger(exports.LoggerNames.HdBleTransport);
|
|
23517
23548
|
const HttpLogger = getLogger(exports.LoggerNames.HdTransportHttp);
|
|
23549
|
+
const LowLevelLogger = getLogger(exports.LoggerNames.HdTransportLowLevel);
|
|
23518
23550
|
class TransportManager {
|
|
23519
23551
|
static load() {
|
|
23520
23552
|
Log$7.debug('transport manager load');
|
|
@@ -23536,6 +23568,12 @@ class TransportManager {
|
|
|
23536
23568
|
Log$7.debug('React Native Do Not Initializing transports');
|
|
23537
23569
|
}
|
|
23538
23570
|
}
|
|
23571
|
+
else if (env === 'lowlevel') {
|
|
23572
|
+
if (!this.plugin) {
|
|
23573
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured, 'Lowlevel transport mast have plugin');
|
|
23574
|
+
}
|
|
23575
|
+
yield this.transport.init(LowLevelLogger, DevicePool.emitter, this.plugin);
|
|
23576
|
+
}
|
|
23539
23577
|
else {
|
|
23540
23578
|
yield this.transport.init(HttpLogger);
|
|
23541
23579
|
}
|
|
@@ -23569,7 +23607,7 @@ class TransportManager {
|
|
|
23569
23607
|
}
|
|
23570
23608
|
});
|
|
23571
23609
|
}
|
|
23572
|
-
static setTransport(TransportConstructor) {
|
|
23610
|
+
static setTransport(TransportConstructor, plugin) {
|
|
23573
23611
|
const env = DataManager.getSettings('env');
|
|
23574
23612
|
if (env === 'react-native') {
|
|
23575
23613
|
this.transport = new TransportConstructor({ scanTimeout: 3000 });
|
|
@@ -23577,6 +23615,10 @@ class TransportManager {
|
|
|
23577
23615
|
else {
|
|
23578
23616
|
this.transport = new TransportConstructor();
|
|
23579
23617
|
}
|
|
23618
|
+
if (plugin) {
|
|
23619
|
+
this.plugin = plugin;
|
|
23620
|
+
Log$7.debug('set transport plugin: ', this.plugin);
|
|
23621
|
+
}
|
|
23580
23622
|
Log$7.debug('set transport: ', this.transport);
|
|
23581
23623
|
}
|
|
23582
23624
|
static getTransport() {
|
|
@@ -23594,6 +23636,7 @@ class TransportManager {
|
|
|
23594
23636
|
}
|
|
23595
23637
|
TransportManager.reactNativeInit = false;
|
|
23596
23638
|
TransportManager.messageVersion = 'latest';
|
|
23639
|
+
TransportManager.plugin = null;
|
|
23597
23640
|
|
|
23598
23641
|
const assertType = (res, resType) => {
|
|
23599
23642
|
const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
@@ -23865,7 +23908,7 @@ class Device extends events.exports {
|
|
|
23865
23908
|
return null;
|
|
23866
23909
|
const env = DataManager.getSettings('env');
|
|
23867
23910
|
return {
|
|
23868
|
-
connectId: env
|
|
23911
|
+
connectId: DataManager.isBleConnect(env) ? this.mainId || null : getDeviceUUID(this.features),
|
|
23869
23912
|
uuid: getDeviceUUID(this.features),
|
|
23870
23913
|
deviceType: this.features.bootloader_mode
|
|
23871
23914
|
? getDeviceTypeOnBootloader(this.features)
|
|
@@ -23886,7 +23929,7 @@ class Device extends events.exports {
|
|
|
23886
23929
|
connect() {
|
|
23887
23930
|
const env = DataManager.getSettings('env');
|
|
23888
23931
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
23889
|
-
if (env
|
|
23932
|
+
if (DataManager.isBleConnect(env)) {
|
|
23890
23933
|
try {
|
|
23891
23934
|
yield this.acquire();
|
|
23892
23935
|
resolve(true);
|
|
@@ -23917,9 +23960,9 @@ class Device extends events.exports {
|
|
|
23917
23960
|
var _a, _b, _c, _d;
|
|
23918
23961
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23919
23962
|
const env = DataManager.getSettings('env');
|
|
23920
|
-
const mainIdKey = env
|
|
23963
|
+
const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
|
|
23921
23964
|
try {
|
|
23922
|
-
if (env
|
|
23965
|
+
if (DataManager.isBleConnect(env)) {
|
|
23923
23966
|
const res = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id));
|
|
23924
23967
|
this.mainId = (_b = res.uuid) !== null && _b !== void 0 ? _b : '';
|
|
23925
23968
|
Log$5.debug('Expected uuid:', this.mainId);
|
|
@@ -23950,7 +23993,7 @@ class Device extends events.exports {
|
|
|
23950
23993
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23951
23994
|
const env = DataManager.getSettings('env');
|
|
23952
23995
|
if ((this.isUsedHere() && !this.keepSession && this.mainId) ||
|
|
23953
|
-
(this.mainId && env
|
|
23996
|
+
(this.mainId && DataManager.isBleConnect(env))) {
|
|
23954
23997
|
if (this.commands) {
|
|
23955
23998
|
this.commands.dispose(false);
|
|
23956
23999
|
if (this.commands.callPromise) {
|
|
@@ -24080,7 +24123,7 @@ class Device extends events.exports {
|
|
|
24080
24123
|
}
|
|
24081
24124
|
updateDescriptor(descriptor, forceUpdate = false) {
|
|
24082
24125
|
const env = DataManager.getSettings('env');
|
|
24083
|
-
if (env
|
|
24126
|
+
if (DataManager.isBleConnect(env)) {
|
|
24084
24127
|
return;
|
|
24085
24128
|
}
|
|
24086
24129
|
const originalSession = this.originalDescriptor.session;
|
|
@@ -24203,7 +24246,7 @@ class Device extends events.exports {
|
|
|
24203
24246
|
}
|
|
24204
24247
|
isUsedHere() {
|
|
24205
24248
|
const env = DataManager.getSettings('env');
|
|
24206
|
-
if (env
|
|
24249
|
+
if (DataManager.isBleConnect(env)) {
|
|
24207
24250
|
return false;
|
|
24208
24251
|
}
|
|
24209
24252
|
return this.isUsed() && this.originalDescriptor.session === this.mainId;
|
|
@@ -24391,7 +24434,7 @@ class SearchDevices extends BaseMethod {
|
|
|
24391
24434
|
const deviceDiff = yield ((_a = this.connector) === null || _a === void 0 ? void 0 : _a.enumerate());
|
|
24392
24435
|
const devicesDescriptor = (_b = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _b !== void 0 ? _b : [];
|
|
24393
24436
|
const env = DataManager.getSettings('env');
|
|
24394
|
-
if (env
|
|
24437
|
+
if (DataManager.isBleConnect(env)) {
|
|
24395
24438
|
return devicesDescriptor.map(device => {
|
|
24396
24439
|
var _a;
|
|
24397
24440
|
return (Object.assign(Object.assign({}, device), { connectId: device.id, deviceType: getDeviceTypeByBleName((_a = device.name) !== null && _a !== void 0 ? _a : '') }));
|
|
@@ -25175,15 +25218,11 @@ const getInfo = ({ features, updateType, targetVersion }) => {
|
|
|
25175
25218
|
var _a, _b;
|
|
25176
25219
|
const deviceType = getDeviceType(features);
|
|
25177
25220
|
const { deviceMap } = DataManager;
|
|
25178
|
-
|
|
25179
|
-
|
|
25180
|
-
|
|
25181
|
-
|
|
25182
|
-
|
|
25183
|
-
else if (semver__default["default"].gt(targetVersion, '4.0.0')) {
|
|
25184
|
-
firmwareUpdateField = 'firmware-v3';
|
|
25185
|
-
}
|
|
25186
|
-
}
|
|
25221
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25222
|
+
features,
|
|
25223
|
+
updateType,
|
|
25224
|
+
targetVersion,
|
|
25225
|
+
});
|
|
25187
25226
|
const releaseInfo = (_b = (_a = deviceMap === null || deviceMap === void 0 ? void 0 : deviceMap[deviceType]) === null || _a === void 0 ? void 0 : _a[firmwareUpdateField]) !== null && _b !== void 0 ? _b : [];
|
|
25188
25227
|
return findLatestRelease(releaseInfo);
|
|
25189
25228
|
};
|
|
@@ -25277,7 +25316,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }) =>
|
|
|
25277
25316
|
postProgressTip(device, 'StartTransferData', postMessage);
|
|
25278
25317
|
const filePath = `0:${updateType === 'ble' ? 'ble-' : ''}firmware.bin`;
|
|
25279
25318
|
const env = DataManager.getSettings('env');
|
|
25280
|
-
const perPackageSize = env
|
|
25319
|
+
const perPackageSize = DataManager.isBleConnect(env) ? 16 : 128;
|
|
25281
25320
|
const chunkSize = 1024 * perPackageSize;
|
|
25282
25321
|
const totalChunks = Math.ceil(payload.byteLength / chunkSize);
|
|
25283
25322
|
let offset = 0;
|
|
@@ -25341,7 +25380,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
25341
25380
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'emmc file write firmware error');
|
|
25342
25381
|
}
|
|
25343
25382
|
const env = DataManager.getSettings('env');
|
|
25344
|
-
if (env
|
|
25383
|
+
if (DataManager.isBleConnect(env)) {
|
|
25345
25384
|
yield wait(3000);
|
|
25346
25385
|
yield ((_a = device.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(device.originalDescriptor.id, null, true));
|
|
25347
25386
|
yield device.initialize();
|
|
@@ -25616,7 +25655,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
25616
25655
|
checkDeviceToBootloader(connectId) {
|
|
25617
25656
|
this.checkPromise = hdShared.createDeferred();
|
|
25618
25657
|
const env = DataManager.getSettings('env');
|
|
25619
|
-
const isBleReconnect = connectId && env
|
|
25658
|
+
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
25620
25659
|
Log$3.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
25621
25660
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
25622
25661
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -31443,7 +31482,7 @@ class DeviceConnector {
|
|
|
31443
31482
|
const env = DataManager.getSettings('env');
|
|
31444
31483
|
try {
|
|
31445
31484
|
let res;
|
|
31446
|
-
if (env
|
|
31485
|
+
if (DataManager.isBleConnect(env)) {
|
|
31447
31486
|
res = yield this.transport.acquire({ uuid: path, forceCleanRunPromise });
|
|
31448
31487
|
}
|
|
31449
31488
|
else {
|
|
@@ -31676,7 +31715,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
31676
31715
|
function initDeviceList(method) {
|
|
31677
31716
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31678
31717
|
const env = DataManager.getSettings('env');
|
|
31679
|
-
if (env
|
|
31718
|
+
if (DataManager.isBleConnect(env) && method.connectId) {
|
|
31680
31719
|
yield TransportManager.configure();
|
|
31681
31720
|
return;
|
|
31682
31721
|
}
|
|
@@ -31788,7 +31827,7 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
31788
31827
|
const env = DataManager.getSettings('env');
|
|
31789
31828
|
let device;
|
|
31790
31829
|
try {
|
|
31791
|
-
if (env
|
|
31830
|
+
if (DataManager.isBleConnect(env)) {
|
|
31792
31831
|
device = initDeviceForBle(method);
|
|
31793
31832
|
}
|
|
31794
31833
|
else {
|
|
@@ -31798,7 +31837,7 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
31798
31837
|
if (timer) {
|
|
31799
31838
|
clearTimeout(timer);
|
|
31800
31839
|
}
|
|
31801
|
-
if (env
|
|
31840
|
+
if (DataManager.isBleConnect(env)) {
|
|
31802
31841
|
bleTimeoutRetry = 0;
|
|
31803
31842
|
yield connectDeviceForBle(method, device);
|
|
31804
31843
|
}
|
|
@@ -31843,7 +31882,7 @@ const cancel = (connectId) => {
|
|
|
31843
31882
|
try {
|
|
31844
31883
|
if (connectId) {
|
|
31845
31884
|
let device;
|
|
31846
|
-
if (env
|
|
31885
|
+
if (DataManager.isBleConnect(env)) {
|
|
31847
31886
|
device = initDeviceForBle({ connectId });
|
|
31848
31887
|
}
|
|
31849
31888
|
else {
|
|
@@ -31885,12 +31924,12 @@ const closePopup = () => {
|
|
|
31885
31924
|
};
|
|
31886
31925
|
const onDeviceConnectHandler = (device) => {
|
|
31887
31926
|
const env = DataManager.getSettings('env');
|
|
31888
|
-
const deviceObject = env
|
|
31927
|
+
const deviceObject = DataManager.isBleConnect(env) ? device : device.toMessageObject();
|
|
31889
31928
|
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject }));
|
|
31890
31929
|
};
|
|
31891
31930
|
const onDeviceDisconnectHandler = (device) => {
|
|
31892
31931
|
const env = DataManager.getSettings('env');
|
|
31893
|
-
const deviceObject = env
|
|
31932
|
+
const deviceObject = DataManager.isBleConnect(env) ? device : device.toMessageObject();
|
|
31894
31933
|
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
|
31895
31934
|
};
|
|
31896
31935
|
const onDevicePinHandler = (...[device, type, callback]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -32003,14 +32042,14 @@ const initConnector = () => {
|
|
|
32003
32042
|
DevicePool.emitter.on(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
32004
32043
|
return _connector;
|
|
32005
32044
|
};
|
|
32006
|
-
const initTransport = (Transport) => {
|
|
32007
|
-
TransportManager.setTransport(Transport);
|
|
32045
|
+
const initTransport = (Transport, plugin) => {
|
|
32046
|
+
TransportManager.setTransport(Transport, plugin);
|
|
32008
32047
|
};
|
|
32009
|
-
const init = (settings, Transport) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32048
|
+
const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32010
32049
|
try {
|
|
32011
32050
|
try {
|
|
32012
32051
|
yield DataManager.load(settings);
|
|
32013
|
-
initTransport(Transport);
|
|
32052
|
+
initTransport(Transport, plugin);
|
|
32014
32053
|
}
|
|
32015
32054
|
catch (_b) {
|
|
32016
32055
|
Log.error('DataManager.load error');
|
|
@@ -32102,6 +32141,7 @@ exports.getScriptType = getScriptType;
|
|
|
32102
32141
|
exports.getTimeStamp = getTimeStamp;
|
|
32103
32142
|
exports.httpRequest = httpRequest;
|
|
32104
32143
|
exports.initCore = init;
|
|
32144
|
+
exports.isBleConnect = isBleConnect;
|
|
32105
32145
|
exports.isValidVersionArray = isValidVersionArray;
|
|
32106
32146
|
exports.isValidVersionString = isValidVersionString;
|
|
32107
32147
|
exports.normalizeVersionArray = normalizeVersionArray;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Response } from '../params';
|
|
1
|
+
import type { CommonParams, Response } from '../params';
|
|
2
2
|
import type { Features } from '../device';
|
|
3
|
-
export declare function getFeatures(connectId?: string): Response<Features>;
|
|
3
|
+
export declare function getFeatures(connectId?: string, params?: CommonParams): Response<Features>;
|
|
4
4
|
//# sourceMappingURL=getFeatures.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFeatures.d.ts","sourceRoot":"","sources":["../../../src/types/api/getFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"getFeatures.d.ts","sourceRoot":"","sources":["../../../src/types/api/getFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/types/api/init.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { LowlevelTransportSharedPlugin } from '@onekeyfe/hd-transport';
|
|
1
2
|
import { LowLevelCoreApi } from '../../lowLevelInject';
|
|
2
3
|
import type { ConnectSettings } from '../settings';
|
|
3
|
-
export declare function init(settings: Partial<ConnectSettings>, lowLevelApi?: LowLevelCoreApi): Promise<boolean>;
|
|
4
|
+
export declare function init(settings: Partial<ConnectSettings>, lowLevelApi?: LowLevelCoreApi, pulgin?: LowlevelTransportSharedPlugin): Promise<boolean>;
|
|
4
5
|
export declare function updateSettings(settings: Partial<ConnectSettings>): Promise<boolean>;
|
|
5
6
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/types/api/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,OAAO,UAAU,IAAI,CAC1B,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,EAClC,WAAW,CAAC,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/types/api/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,OAAO,UAAU,IAAI,CAC1B,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,EAClC,WAAW,CAAC,EAAE,eAAe,EAC7B,MAAM,CAAC,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/types/settings.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare type ConnectSettings = {
|
|
|
12
12
|
priority: number;
|
|
13
13
|
trustedHost: boolean;
|
|
14
14
|
supportedBrowser?: boolean;
|
|
15
|
-
env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb';
|
|
15
|
+
env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb' | 'lowlevel';
|
|
16
16
|
timestamp: number;
|
|
17
17
|
isFrame?: boolean;
|
|
18
18
|
preRelease?: boolean;
|
|
@@ -52,7 +52,6 @@ export declare type DeviceTypeMap = {
|
|
|
52
52
|
[k in IDeviceType]: {
|
|
53
53
|
firmware: IFirmwareReleaseInfo[];
|
|
54
54
|
'firmware-v2'?: IFirmwareReleaseInfo[];
|
|
55
|
-
'firmware-v3'?: IFirmwareReleaseInfo[];
|
|
56
55
|
'firmware-v4'?: IFirmwareReleaseInfo[];
|
|
57
56
|
ble: IBLEFirmwareReleaseInfo[];
|
|
58
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/types/sett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E,oBAAoB,EAAE,CAAC;QACvC,aAAa,CAAC,EAAE,oBAAoB,EAAE,CAAC;QACvC,GAAG,EAAE,uBAAuB,EAAE,CAAC;KAChC;CACF,CAAC;AAEF,oBAAY,SAAS,GAAG;IACtB,MAAM,EAAE;QACN,OAAO,EAAE,aAAa,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE;aACR,CAAC,IAAI,OAAO,GAAG,MAAM;SACvB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC7B,GAAG,aAAa,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeviceCommands } from '../device/DeviceCommands';
|
|
2
2
|
import type { Features, IDeviceModel, IDeviceType, IVersionArray, SupportFeatureType } from '../types';
|
|
3
|
-
import { MessageVersion } from '../data-manager/DataManager';
|
|
3
|
+
import { FirmwareField, MessageVersion } from '../data-manager/DataManager';
|
|
4
4
|
import { Device } from '../device/Device';
|
|
5
5
|
export declare const getDeviceModel: (features?: import("packages/hd-transport/dist").Features | undefined) => IDeviceModel;
|
|
6
6
|
export declare const getDeviceType: (features?: import("packages/hd-transport/dist").Features | undefined) => IDeviceType;
|
|
@@ -22,5 +22,9 @@ export declare const getPassphraseStateWithRefreshDeviceInfo: (device: Device) =
|
|
|
22
22
|
export declare const getPassphraseState: (features: Features | undefined, commands: DeviceCommands) => Promise<string | false>;
|
|
23
23
|
export declare const supportBatchPublicKey: (features?: import("packages/hd-transport/dist").Features | undefined) => boolean;
|
|
24
24
|
export declare const supportModifyHomescreen: (features?: import("packages/hd-transport/dist").Features | undefined) => SupportFeatureType;
|
|
25
|
-
export declare const getFirmwareUpdateField: (features
|
|
25
|
+
export declare const getFirmwareUpdateField: ({ features, updateType, targetVersion, }: {
|
|
26
|
+
features: Features;
|
|
27
|
+
updateType: 'firmware' | 'ble';
|
|
28
|
+
targetVersion?: string | undefined;
|
|
29
|
+
}) => 'ble' | FirmwareField;
|
|
26
30
|
//# sourceMappingURL=deviceFeaturesUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,aAAa,EACb,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,OAAoB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,aAAa,EACb,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,OAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAEzF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,eAAO,MAAM,cAAc,4EAA0B,YAcpD,CAAC;AAEF,eAAO,MAAM,aAAa,4EAA0B,WAUnD,CAAC;AAEF,eAAO,MAAM,yBAAyB,4EAA0B,WACvC,CAAC;AAE1B,eAAO,MAAM,sBAAsB,iCAAoB,WAAW,GAAG,IAKpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,qCAAwB,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,WAM/C,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,WAOhD,CAAC;AAKF,eAAO,MAAM,wBAAwB,aAAc,QAAQ,GAAG,SAAS,kBAOtE,CAAC;AAKF,eAAO,MAAM,2BAA2B,aAAc,QAAQ,KAAG,aAAa,GAAG,IAQhF,CAAC;AAEF,eAAO,MAAM,0BAA0B,aAAc,QAAQ,kBAW5D,CAAC;AAEF,eAAO,MAAM,wBAAwB,aACzB,QAAQ,GAAG,SAAS,KAC7B;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,cAAc,CAAA;CAiClD,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,4EAA0B,kBAW1D,CAAC;AAEF,eAAO,MAAM,uCAAuC,WAAkB,MAAM,4BAY3E,CAAC;AAEF,eAAO,MAAM,kBAAkB,aACnB,QAAQ,GAAG,SAAS,YACpB,cAAc,4BAgBzB,CAAC;AAEF,eAAO,MAAM,qBAAqB,4EAA0B,OAU3D,CAAC;AAEF,eAAO,MAAM,uBAAuB,4EAA0B,kBAU7D,CAAC;AAKF,eAAO,MAAM,sBAAsB;cAKvB,QAAQ;gBACN,UAAU,GAAG,KAAK;;MAE5B,KAAK,GAAG,aAsBX,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export { checkNeedUpdateBootForTouch, checkNeedUpdateBootForClassicAndMini, } fr
|
|
|
7
7
|
export { getLogger, enableLog, LoggerNames, getLog, setLoggerPostMessage } from './logger';
|
|
8
8
|
export { getHomeScreenHex } from './homescreen';
|
|
9
9
|
export declare const wait: (ms: number) => Promise<unknown>;
|
|
10
|
+
export declare const isBleConnect: (env: string) => boolean;
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEzF,OAAO,EACL,2BAA2B,EAC3B,oCAAoC,GACrC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,eAAO,MAAM,IAAI,OAAQ,MAAM,qBAG3B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEzF,OAAO,EACL,2BAA2B,EAC3B,oCAAoC,GACrC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,eAAO,MAAM,IAAI,OAAQ,MAAM,qBAG3B,CAAC;AAEL,eAAO,MAAM,YAAY,QAAS,MAAM,YAAiD,CAAC"}
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare enum LoggerNames {
|
|
|
32
32
|
HdCommonConnectSdk = "@onekey/common-connect-sdk",
|
|
33
33
|
HdBleSdk = "@onekey/hd-ble-sdk",
|
|
34
34
|
HdTransportHttp = "@onekey/hd-transport-http",
|
|
35
|
+
HdTransportLowLevel = "@onekey/hd-transport-lowlevel",
|
|
35
36
|
HdBleTransport = "@onekey/hd-ble-transport",
|
|
36
37
|
Connect = "@onekey/connect",
|
|
37
38
|
Iframe = "IFrame",
|
|
@@ -49,6 +50,7 @@ export declare const LoggerMap: {
|
|
|
49
50
|
"@onekey/hd-ble-sdk": Log;
|
|
50
51
|
"@onekey/hd-transport-http": Log;
|
|
51
52
|
"@onekey/hd-ble-transport": Log;
|
|
53
|
+
"@onekey/hd-transport-lowlevel": Log;
|
|
52
54
|
"@onekey/connect": Log;
|
|
53
55
|
IFrame: Log;
|
|
54
56
|
"[SendMessage]": Log;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,aAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAMF,cAAM,GAAG;IACP,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,EAAE,UAAU,EAAE,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GA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AO,EAAE,OAAO;IAM5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASlB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASnB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAQrB;AAID,eAAO,MAAM,OAAO,WAAY,MAAM,uCAIrC,CAAC;AAEF,eAAO,MAAM,SAAS,yCAIrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,MAAM,WAAW,OAAO,SAIjE,CAAC;AAEF,eAAO,MAAM,MAAM,oBAOlB,CAAC;AAEF,eAAO,MAAM,oBAAoB,4BAA6B,WAAW,KAAK,IAAI,SAEjF,CAAC;AAuCF,oBAAY,WAAW;IACrB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,kBAAkB,+BAA+B;IACjD,QAAQ,uBAAuB;IAC/B,eAAe,8BAA8B;IAC7C,mBAAmB,kCAAkC;IACrD,cAAc,6BAA6B;IAC3C,OAAO,oBAAoB;IAC3B,MAAM,WAAW;IACjB,WAAW,kBAAkB;IAC7B,MAAM,aAAa;CACpB;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CAiBrB,CAAC;AAEF,eAAO,MAAM,SAAS,QAAS,WAAW,QAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.25",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "^0.3.
|
|
29
|
-
"@onekeyfe/hd-transport": "^0.3.
|
|
28
|
+
"@onekeyfe/hd-shared": "^0.3.25",
|
|
29
|
+
"@onekeyfe/hd-transport": "^0.3.25",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/semver": "^7.3.9",
|
|
45
45
|
"ripple-keypairs": "^1.1.4"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "2d4fe6dd208db8a3fe1eb0fc35c1a916e2236590"
|
|
48
48
|
}
|
|
@@ -88,7 +88,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
88
88
|
checkDeviceToBootloader(connectId: string | undefined) {
|
|
89
89
|
this.checkPromise = createDeferred();
|
|
90
90
|
const env = DataManager.getSettings('env');
|
|
91
|
-
const isBleReconnect = connectId && env
|
|
91
|
+
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
92
92
|
|
|
93
93
|
Log.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
94
94
|
|
package/src/api/SearchDevices.ts
CHANGED
|
@@ -25,7 +25,7 @@ export default class SearchDevices extends BaseMethod {
|
|
|
25
25
|
* No need to call features during Bluetooth scaning
|
|
26
26
|
* to avoid device pairing
|
|
27
27
|
*/
|
|
28
|
-
if (env
|
|
28
|
+
if (DataManager.isBleConnect(env)) {
|
|
29
29
|
return devicesDescriptor.map(device => ({
|
|
30
30
|
...device,
|
|
31
31
|
connectId: device.id,
|
|
@@ -5,6 +5,7 @@ import { getDeviceType, httpRequest } from '../../utils';
|
|
|
5
5
|
import { DataManager } from '../../data-manager';
|
|
6
6
|
import { findLatestRelease } from '../../utils/release';
|
|
7
7
|
import { getFirmwareUpdateField } from '../../utils/deviceFeaturesUtils';
|
|
8
|
+
import { FirmwareField } from '../../data-manager/DataManager';
|
|
8
9
|
|
|
9
10
|
export interface GetInfoProps {
|
|
10
11
|
features: Features;
|
|
@@ -74,15 +75,11 @@ export const getInfo = ({ features, updateType, targetVersion }: GetInfoProps) =
|
|
|
74
75
|
const deviceType = getDeviceType(features);
|
|
75
76
|
const { deviceMap } = DataManager;
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} else if (semver.gt(targetVersion, '4.0.0')) {
|
|
83
|
-
firmwareUpdateField = 'firmware-v3';
|
|
84
|
-
}
|
|
85
|
-
}
|
|
78
|
+
const firmwareUpdateField: 'ble' | FirmwareField = getFirmwareUpdateField({
|
|
79
|
+
features,
|
|
80
|
+
updateType,
|
|
81
|
+
targetVersion,
|
|
82
|
+
});
|
|
86
83
|
|
|
87
84
|
const releaseInfo = deviceMap?.[deviceType]?.[firmwareUpdateField] ?? [];
|
|
88
85
|
return findLatestRelease(releaseInfo);
|
|
@@ -146,7 +146,7 @@ const newTouchUpdateProcess = async (
|
|
|
146
146
|
// Write File
|
|
147
147
|
const filePath = `0:${updateType === 'ble' ? 'ble-' : ''}firmware.bin`;
|
|
148
148
|
const env = DataManager.getSettings('env');
|
|
149
|
-
const perPackageSize = env
|
|
149
|
+
const perPackageSize = DataManager.isBleConnect(env) ? 16 : 128;
|
|
150
150
|
const chunkSize = 1024 * perPackageSize;
|
|
151
151
|
const totalChunks = Math.ceil(payload.byteLength / chunkSize);
|
|
152
152
|
let offset = 0;
|
|
@@ -230,7 +230,7 @@ const emmcFileWriteWithRetry = async (
|
|
|
230
230
|
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'emmc file write firmware error');
|
|
231
231
|
}
|
|
232
232
|
const env = DataManager.getSettings('env');
|
|
233
|
-
if (env
|
|
233
|
+
if (DataManager.isBleConnect(env)) {
|
|
234
234
|
await wait(3000);
|
|
235
235
|
await device.deviceConnector?.acquire(device.originalDescriptor.id, null, true);
|
|
236
236
|
await device.initialize();
|