@onekeyfe/hd-web-sdk 0.2.1 → 0.2.2

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'
@@ -16097,6 +16101,16 @@ DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
16097
16101
  return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.resource;
16098
16102
  };
16099
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
+
16100
16114
  DataManager.getFirmwareChangelog = features => {
16101
16115
  var _b, _c;
16102
16116
 
@@ -18637,6 +18651,65 @@ const updateResources = (typedCall, postMessage, device, source) => __awaiter(vo
18637
18651
  return true;
18638
18652
  });
18639
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
+
18640
18713
  class FirmwareUpdate$1 extends BaseMethod {
18641
18714
  init() {
18642
18715
  this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.INITIALIZE];
@@ -23029,6 +23102,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
23029
23102
  deviceSupportFeatures: DeviceSupportFeatures,
23030
23103
  deviceVerify: DeviceVerify,
23031
23104
  deviceWipe: DeviceWipe,
23105
+ deviceFullyUploadResource: DeviceFullyUploadResource,
23032
23106
  firmwareUpdate: FirmwareUpdate$1,
23033
23107
  firmwareUpdateV2: FirmwareUpdate,
23034
23108
  requestWebUsbDevice: RequestWebUsbDevice,
@@ -47838,7 +47912,7 @@ try {
47838
47912
  /***/ ((module) => {
47839
47913
 
47840
47914
  "use strict";
47841
- module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.2.1","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.1","@onekeyfe/hd-transport":"^0.2.1","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","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","@onekeyfe/hd-transport":"^0.2.2","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"}}');
47842
47916
 
47843
47917
  /***/ })
47844
47918
 
@@ -50365,7 +50439,7 @@ const src_init = async settings => {
50365
50439
 
50366
50440
  try {
50367
50441
  await init({ ..._settings,
50368
- version: "0.2.1"
50442
+ version: "0.2.2"
50369
50443
  });
50370
50444
  return true;
50371
50445
  } catch (e) {