@onekeyfe/hd-web-sdk 0.2.0 → 0.2.2-beta

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.
@@ -5174,6 +5174,10 @@ const inject = ({
5174
5174
  connectId,
5175
5175
  method: 'deviceWipe'
5176
5176
  }),
5177
+ deviceFullyUploadResource: connectId => call({
5178
+ connectId,
5179
+ method: 'deviceFullyUploadResource'
5180
+ }),
5177
5181
  getPassphraseState: (connectId, params) => call(Object.assign(Object.assign({}, params), {
5178
5182
  connectId,
5179
5183
  method: 'getPassphraseState'
@@ -6211,6 +6215,24 @@ const supportBatchPublicKey = features => {
6211
6215
  return semver__default["default"].gte(currentVersion, '2.6.0');
6212
6216
  };
6213
6217
 
6218
+ const supportModifyHomescreen = features => {
6219
+ if (!features) return {
6220
+ support: false
6221
+ };
6222
+ const currentVersion = getDeviceFirmwareVersion(features).join('.');
6223
+ const deviceType = getDeviceType(features);
6224
+
6225
+ if (deviceType === 'classic' || deviceType === 'mini') {
6226
+ return {
6227
+ support: true
6228
+ };
6229
+ }
6230
+
6231
+ return {
6232
+ support: semver__default["default"].gte(currentVersion, '3.4.0')
6233
+ };
6234
+ };
6235
+
6214
6236
  var nested = {
6215
6237
  AlgorandGetAddress: {
6216
6238
  fields: {
@@ -16079,6 +16101,16 @@ DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
16079
16101
  return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.resource;
16080
16102
  };
16081
16103
 
16104
+ DataManager.getSysFullResource = features => {
16105
+ var _b, _c, _d;
16106
+
16107
+ const deviceType = getDeviceType(features);
16108
+ if (deviceType !== 'pro' && deviceType !== 'touch') return undefined;
16109
+ const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.firmware) !== null && _c !== void 0 ? _c : [];
16110
+ const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.fullResource);
16111
+ return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.fullResource;
16112
+ };
16113
+
16082
16114
  DataManager.getFirmwareChangelog = features => {
16083
16115
  var _b, _c;
16084
16116
 
@@ -18331,6 +18363,7 @@ class DeviceUploadResource extends BaseMethod {
18331
18363
  run() {
18332
18364
  return __awaiter(this, void 0, void 0, function* () {
18333
18365
  const res = yield this.device.commands.typedCall('ResourceUpload', ['ResourceRequest', 'ZoomRequest', 'Success'], this.params);
18366
+ this.postMessage(createUiMessage(UI_REQUEST$1.CLOSE_UI_WINDOW));
18334
18367
  return this.processResourceRequest(res);
18335
18368
  });
18336
18369
  }
@@ -18345,8 +18378,10 @@ class DeviceSupportFeatures extends BaseMethod {
18345
18378
  run() {
18346
18379
  if (!this.device.features) return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device not initialized'));
18347
18380
  const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
18381
+ const modifyHomescreen = supportModifyHomescreen(this.device.features);
18348
18382
  return Promise.resolve({
18349
18383
  inputPinOnSoftware,
18384
+ modifyHomescreen,
18350
18385
  device: this.device.toMessageObject()
18351
18386
  });
18352
18387
  }
@@ -18504,9 +18539,9 @@ const waitBleInstall = updateType => __awaiter(void 0, void 0, void 0, function*
18504
18539
  const uploadFirmware = (updateType, typedCall, postMessage, device, {
18505
18540
  payload
18506
18541
  }) => __awaiter(void 0, void 0, void 0, function* () {
18507
- var _a, _b;
18542
+ const deviceModel = getDeviceModel(device.features);
18508
18543
 
18509
- if (((_a = device.features) === null || _a === void 0 ? void 0 : _a.major_version) === 1) {
18544
+ if (deviceModel === 'model_mini') {
18510
18545
  postConfirmationMessage(device);
18511
18546
  postProgressTip(device, 'ConfirmOnDevice', postMessage);
18512
18547
  const eraseCommand = updateType === 'firmware' ? 'FirmwareErase' : 'FirmwareErase_ex';
@@ -18523,7 +18558,7 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, {
18523
18558
  return message;
18524
18559
  }
18525
18560
 
18526
- if (((_b = device.features) === null || _b === void 0 ? void 0 : _b.major_version) === 2) {
18561
+ if (deviceModel === 'model_touch') {
18527
18562
  postConfirmationMessage(device);
18528
18563
  postProgressTip(device, 'ConfirmOnDevice', postMessage);
18529
18564
  const length = payload.byteLength;
@@ -18616,6 +18651,65 @@ const updateResources = (typedCall, postMessage, device, source) => __awaiter(vo
18616
18651
  return true;
18617
18652
  });
18618
18653
 
18654
+ class DeviceFullyUploadResource extends BaseMethod {
18655
+ constructor() {
18656
+ super(...arguments);
18657
+ this.checkPromise = null;
18658
+
18659
+ this.postTipMessage = message => {
18660
+ this.postMessage(createUiMessage(UI_REQUEST.FIRMWARE_TIP, {
18661
+ device: this.device.toMessageObject(),
18662
+ data: {
18663
+ message
18664
+ }
18665
+ }));
18666
+ };
18667
+ }
18668
+
18669
+ init() {
18670
+ this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.INITIALIZE];
18671
+ this.requireDeviceMode = [];
18672
+ this.useDevicePassphraseState = false;
18673
+ }
18674
+
18675
+ isSupportResourceUpdate(features, updateType) {
18676
+ if (updateType !== 'firmware') return false;
18677
+ const deviceType = getDeviceType(features);
18678
+ const isTouchMode = deviceType === 'touch' || deviceType === 'pro';
18679
+ const currentVersion = getDeviceFirmwareVersion(features).join('.');
18680
+ return isTouchMode && semver__default["default"].gte(currentVersion, '3.4.0');
18681
+ }
18682
+
18683
+ run() {
18684
+ return __awaiter(this, void 0, void 0, function* () {
18685
+ const {
18686
+ device
18687
+ } = this;
18688
+ const {
18689
+ features
18690
+ } = device;
18691
+
18692
+ if (!(features === null || features === void 0 ? void 0 : features.bootloader_mode) && features) {
18693
+ if (features) {
18694
+ this.postTipMessage('CheckLatestUiResource');
18695
+ const resourceUrl = DataManager.getSysFullResource(features);
18696
+
18697
+ if (resourceUrl) {
18698
+ this.postTipMessage('DownloadLatestUiResource');
18699
+ const resource = yield getSysResourceBinary(resourceUrl);
18700
+ this.postTipMessage('DownloadLatestUiResourceSuccess');
18701
+
18702
+ if (resource) {
18703
+ yield updateResources(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, resource.binary);
18704
+ }
18705
+ }
18706
+ }
18707
+ }
18708
+ });
18709
+ }
18710
+
18711
+ }
18712
+
18619
18713
  class FirmwareUpdate$1 extends BaseMethod {
18620
18714
  init() {
18621
18715
  this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.INITIALIZE];
@@ -23008,6 +23102,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
23008
23102
  deviceSupportFeatures: DeviceSupportFeatures,
23009
23103
  deviceVerify: DeviceVerify,
23010
23104
  deviceWipe: DeviceWipe,
23105
+ deviceFullyUploadResource: DeviceFullyUploadResource,
23011
23106
  firmwareUpdate: FirmwareUpdate$1,
23012
23107
  firmwareUpdateV2: FirmwareUpdate,
23013
23108
  requestWebUsbDevice: RequestWebUsbDevice,
@@ -47817,7 +47912,7 @@ try {
47817
47912
  /***/ ((module) => {
47818
47913
 
47819
47914
  "use strict";
47820
- module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.2.0","description":"> TODO: description","author":"OneKey","homepage":"https://github.com/OneKeyHQ/hardware-js-sdk#readme","license":"ISC","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/OneKeyHQ/hardware-js-sdk.git"},"publishConfig":{"access":"public"},"scripts":{"dev":"rimraf dist && rollup -c ../../build/rollup.config.js -w","build":"rimraf dist && rollup -c ../../build/rollup.config.js","lint":"eslint .","lint:fix":"eslint . --fix"},"bugs":{"url":"https://github.com/OneKeyHQ/hardware-js-sdk/issues"},"dependencies":{"@onekeyfe/hd-shared":"^0.2.0","@onekeyfe/hd-transport":"^0.2.0","axios":"^0.27.2","bignumber.js":"^9.0.2","jszip":"^3.10.1","parse-uri":"^1.0.7","semver":"^7.3.7"},"peerDependencies":{"@noble/hashes":"^1.1.3"},"devDependencies":{"@noble/hashes":"^1.1.3","@types/parse-uri":"^1.0.0","@types/semver":"^7.3.9"}}');
47915
+ module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.2.2-beta","description":"> TODO: description","author":"OneKey","homepage":"https://github.com/OneKeyHQ/hardware-js-sdk#readme","license":"ISC","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/OneKeyHQ/hardware-js-sdk.git"},"publishConfig":{"access":"public"},"scripts":{"dev":"rimraf dist && rollup -c ../../build/rollup.config.js -w","build":"rimraf dist && rollup -c ../../build/rollup.config.js","lint":"eslint .","lint:fix":"eslint . --fix"},"bugs":{"url":"https://github.com/OneKeyHQ/hardware-js-sdk/issues"},"dependencies":{"@onekeyfe/hd-shared":"^0.2.2-beta","@onekeyfe/hd-transport":"^0.2.2-beta","axios":"^0.27.2","bignumber.js":"^9.0.2","jszip":"^3.10.1","parse-uri":"^1.0.7","semver":"^7.3.7"},"peerDependencies":{"@noble/hashes":"^1.1.3"},"devDependencies":{"@noble/hashes":"^1.1.3","@types/parse-uri":"^1.0.0","@types/semver":"^7.3.9"}}');
47821
47916
 
47822
47917
  /***/ })
47823
47918
 
@@ -50344,7 +50439,7 @@ const src_init = async settings => {
50344
50439
 
50345
50440
  try {
50346
50441
  await init({ ..._settings,
50347
- version: "0.2.0"
50442
+ version: "0.2.2-beta"
50348
50443
  });
50349
50444
  return true;
50350
50445
  } catch (e) {