@onekeyfe/hd-core 1.2.0-alpha.105 → 1.2.0-alpha.107

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 (67) hide show
  1. package/__tests__/DeviceCommands.test.ts +2 -10
  2. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +0 -2
  3. package/__tests__/device-lifecycle-events.test.ts +2 -113
  4. package/__tests__/device-pool-state.test.ts +0 -29
  5. package/__tests__/deviceUploadNft.test.ts +4 -33
  6. package/__tests__/get-device-state.test.ts +13 -52
  7. package/__tests__/protocol-v2.test.ts +18 -330
  8. package/__tests__/refresh-device-state.test.ts +1 -4
  9. package/__tests__/search-devices.test.ts +38 -34
  10. package/dist/api/FirmwareUpdateV4.d.ts +0 -3
  11. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  12. package/dist/api/GetDeviceState.d.ts.map +1 -1
  13. package/dist/api/SearchDevices.d.ts.map +1 -1
  14. package/dist/api/UploadPortfolio.d.ts +1 -1
  15. package/dist/api/UploadPortfolio.d.ts.map +1 -1
  16. package/dist/api/firmware/protocolV2Release.d.ts.map +1 -1
  17. package/dist/api/protocol-v2/DeviceUploadNft.d.ts +3 -2
  18. package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -1
  19. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +3 -2
  20. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
  21. package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
  22. package/dist/core/index.d.ts.map +1 -1
  23. package/dist/device/Device.d.ts +2 -10
  24. package/dist/device/Device.d.ts.map +1 -1
  25. package/dist/device/DevicePool.d.ts +1 -1
  26. package/dist/device/DevicePool.d.ts.map +1 -1
  27. package/dist/index.d.ts +16 -18
  28. package/dist/index.js +99 -277
  29. package/dist/protocols/protocol-v2/features.d.ts +0 -8
  30. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  31. package/dist/protocols/protocol-v2/index.d.ts +2 -2
  32. package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
  33. package/dist/types/api/getDeviceState.d.ts +0 -1
  34. package/dist/types/api/getDeviceState.d.ts.map +1 -1
  35. package/dist/types/api/protocolV2.d.ts +1 -1
  36. package/dist/types/api/protocolV2.d.ts.map +1 -1
  37. package/dist/types/device.d.ts.map +1 -1
  38. package/dist/utils/pro2Nft.d.ts +0 -7
  39. package/dist/utils/pro2Nft.d.ts.map +1 -1
  40. package/package.json +4 -6
  41. package/src/api/FirmwareUpdateV4.ts +24 -72
  42. package/src/api/GetDeviceState.ts +0 -1
  43. package/src/api/SearchDevices.ts +2 -4
  44. package/src/api/UploadPortfolio.ts +2 -9
  45. package/src/api/firmware/protocolV2Release.ts +0 -1
  46. package/src/api/protocol-v2/DeviceUploadNft.ts +8 -56
  47. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +18 -37
  48. package/src/api/ton/TonSignMessage.ts +3 -5
  49. package/src/core/index.ts +0 -4
  50. package/src/device/Device.ts +31 -90
  51. package/src/device/DevicePool.ts +5 -17
  52. package/src/protocols/protocol-v2/features.ts +0 -10
  53. package/src/protocols/protocol-v2/index.ts +0 -2
  54. package/src/types/api/getDeviceState.ts +0 -2
  55. package/src/types/api/protocolV2.ts +1 -1
  56. package/src/types/device.ts +2 -1
  57. package/src/utils/pro2Nft.ts +8 -31
  58. package/__tests__/base64Data.test.ts +0 -70
  59. package/__tests__/protocol-v2-legacy-recovery.test.ts +0 -29
  60. package/__tests__/resourceBase64Boundary.test.ts +0 -48
  61. package/__tests__/ton-sign-message.test.ts +0 -84
  62. package/dist/api/helpers/base64Data.d.ts +0 -16
  63. package/dist/api/helpers/base64Data.d.ts.map +0 -1
  64. package/dist/core/protocolV2LegacyRecovery.d.ts +0 -5
  65. package/dist/core/protocolV2LegacyRecovery.d.ts.map +0 -1
  66. package/src/api/helpers/base64Data.ts +0 -85
  67. package/src/core/protocolV2LegacyRecovery.ts +0 -12
package/dist/index.js CHANGED
@@ -13,10 +13,9 @@ var ByteBuffer = require('bytebuffer');
13
13
  var blake2s = require('@noble/hashes/blake2s');
14
14
  var BigNumber = require('bignumber.js');
15
15
  var JSZip = require('jszip');
16
- var buffer = require('buffer');
17
- var jpegJs = require('jpeg-js');
18
16
  var sha3 = require('@noble/hashes/sha3');
19
17
  var blake2b = require('@noble/hashes/blake2b');
18
+ var buffer = require('buffer');
20
19
 
21
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
21
 
@@ -42724,14 +42723,18 @@ function getCompletePro2NftBasenames(childFiles) {
42724
42723
  function utf8Length(value) {
42725
42724
  return new TextEncoder().encode(value).byteLength;
42726
42725
  }
42727
- function buildPro2NftBundleFromEncodedImages(options) {
42728
- const { image, thumbnail, title, subtitle, timestampMs } = options;
42729
- if (!(image instanceof Uint8Array) || image.byteLength === 0) {
42730
- throw invalidParameter$1('Parameter [image] must contain encoded NFT image data.');
42726
+ function assertImage(name, image, expectedWidth, expectedHeight) {
42727
+ if (image.width !== expectedWidth || image.height !== expectedHeight) {
42728
+ throw invalidParameter$1(`Pro2 NFT ${name} dimensions must be ${expectedWidth}x${expectedHeight}.`);
42731
42729
  }
42732
- if (!(thumbnail instanceof Uint8Array) || thumbnail.byteLength === 0) {
42733
- throw invalidParameter$1('Parameter [thumbnail] must contain encoded NFT thumbnail data.');
42730
+ if (!(image.rgba instanceof ArrayBuffer) && !ArrayBuffer.isView(image.rgba)) {
42731
+ throw invalidParameter$1(`Parameter [${name}.rgba] must be an ArrayBuffer or Uint8Array.`);
42734
42732
  }
42733
+ }
42734
+ function buildPro2NftBundle(options) {
42735
+ const { image, thumbnail, title, subtitle, timestampMs } = options;
42736
+ assertImage('image', image, PRO2_NFT_IMAGE_WIDTH, PRO2_NFT_IMAGE_HEIGHT);
42737
+ assertImage('thumbnail', thumbnail, PRO2_NFT_THUMBNAIL_WIDTH, PRO2_NFT_THUMBNAIL_HEIGHT);
42735
42738
  const titleLength = typeof title === 'string' ? utf8Length(title) : 0;
42736
42739
  const subtitleLength = typeof subtitle === 'string' ? utf8Length(subtitle) : Number.POSITIVE_INFINITY;
42737
42740
  if (titleLength < 1 || titleLength > 63) {
@@ -42743,15 +42746,17 @@ function buildPro2NftBundleFromEncodedImages(options) {
42743
42746
  if (!Number.isSafeInteger(timestampMs) || timestampMs <= 0) {
42744
42747
  throw invalidParameter$1('Parameter [timestampMs] must be a positive safe integer.');
42745
42748
  }
42749
+ const encodedImage = encodePro2Image(Object.assign(Object.assign({}, image), { alphaMode: 'black-background' })).data;
42750
+ const encodedThumbnail = encodePro2Image(Object.assign(Object.assign({}, thumbnail), { alphaMode: 'black-background' })).data;
42746
42751
  const metadata = new TextEncoder().encode(JSON.stringify({ title, subtitle }));
42747
42752
  if (metadata.byteLength === 0 || metadata.byteLength > 512) {
42748
42753
  throw invalidParameter$1('Pro2 NFT metadata must contain 1 to 512 UTF-8 bytes.');
42749
42754
  }
42750
- const hash8 = utils.bytesToHex(blake2s.blake2s(image)).slice(0, 8);
42755
+ const hash8 = utils.bytesToHex(blake2s.blake2s(encodedImage)).slice(0, 8);
42751
42756
  return {
42752
42757
  basename: `nft-${hash8}-${timestampMs}`,
42753
- image,
42754
- thumbnail,
42758
+ image: encodedImage,
42759
+ thumbnail: encodedThumbnail,
42755
42760
  metadata,
42756
42761
  };
42757
42762
  }
@@ -43237,7 +43242,7 @@ class DevicePool extends events.exports {
43237
43242
  try {
43238
43243
  yield device.initialize(initOptions);
43239
43244
  if ((initOptions === null || initOptions === void 0 ? void 0 : initOptions.refreshRuntimeState) && device.isProtocolV2()) {
43240
- yield this._refreshProtocolV2DiscoveryState(device, initOptions);
43245
+ yield this._refreshProtocolV2DiscoveryState(device);
43241
43246
  }
43242
43247
  }
43243
43248
  finally {
@@ -43254,28 +43259,26 @@ class DevicePool extends events.exports {
43254
43259
  let refreshError;
43255
43260
  yield device.run(() => __awaiter(this, void 0, void 0, function* () {
43256
43261
  try {
43257
- yield this._refreshProtocolV2DiscoveryState(device, initOptions);
43262
+ yield this._refreshProtocolV2DiscoveryState(device);
43258
43263
  }
43259
43264
  catch (error) {
43260
43265
  refreshError = error;
43261
43266
  }
43262
- }), Object.assign({ connectProtocol: initOptions.connectProtocol, forceProtocolDetection: initOptions.forceProtocolDetection }, (initOptions.allowLegacyProtocolV2ProtocolInfo
43263
- ? { allowLegacyProtocolV2ProtocolInfo: true }
43264
- : {})));
43267
+ }), {
43268
+ connectProtocol: initOptions.connectProtocol,
43269
+ forceProtocolDetection: initOptions.forceProtocolDetection,
43270
+ });
43265
43271
  if (refreshError instanceof Error)
43266
43272
  throw refreshError;
43267
43273
  if (refreshError)
43268
43274
  throw new Error(String(refreshError));
43269
43275
  });
43270
43276
  }
43271
- static _refreshProtocolV2DiscoveryState(device, initOptions) {
43277
+ static _refreshProtocolV2DiscoveryState(device) {
43272
43278
  return __awaiter(this, void 0, void 0, function* () {
43273
- const stateReadOptions = (initOptions === null || initOptions === void 0 ? void 0 : initOptions.allowLegacyProtocolV2ProtocolInfo)
43274
- ? { allowLegacyProtocolV2ProtocolInfo: true }
43275
- : {};
43276
- yield device.getDeviceState(Object.assign({ refreshSections: ['status'] }, stateReadOptions));
43279
+ yield device.getDeviceState({ refreshSections: ['status'] });
43277
43280
  try {
43278
- yield device.getDeviceState(Object.assign({ refreshSections: ['settings'] }, stateReadOptions));
43281
+ yield device.getDeviceState({ refreshSections: ['settings'] });
43279
43282
  }
43280
43283
  catch (error) {
43281
43284
  Log$j.debug('Unable to refresh Protocol V2 device label during discovery', error);
@@ -44223,7 +44226,6 @@ const getProtocolV2SeState = (se) => {
44223
44226
  }
44224
44227
  };
44225
44228
  const getProtocolV2SeType = (se) => normalizeEnumValue(hdTransport.DeviceSeType, se === null || se === void 0 ? void 0 : se.type);
44226
- const isLegacyProtocolV2ProtocolInfo = (protocolInfo) => Object.prototype.hasOwnProperty.call(protocolInfo, 'protobuf_definition');
44227
44229
  const parseProtocolV2BuildFingerprint = (buildFingerprint) => {
44228
44230
  if (!buildFingerprint)
44229
44231
  return null;
@@ -45245,7 +45247,6 @@ class Device extends events.exports {
45245
45247
  yield this.commands.dispose(false);
45246
45248
  }
45247
45249
  this.commands = new DeviceCommands(this, (_g = this.mainId) !== null && _g !== void 0 ? _g : '');
45248
- this.invalidateProtocolV2RuntimeState();
45249
45250
  }
45250
45251
  catch (error) {
45251
45252
  if (options === null || options === void 0 ? void 0 : options.forceProtocolDetection) {
@@ -45640,9 +45641,7 @@ class Device extends events.exports {
45640
45641
  commands: this.commands,
45641
45642
  timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
45642
45643
  });
45643
- const features = (options === null || options === void 0 ? void 0 : options.allowLegacyProtocolV2ProtocolInfo)
45644
- ? yield this.probeProtocolV2RuntimeState(deviceInfo, options.protocolV2DeviceInfoTimeoutMs, { allowLegacyProtocolV2ProtocolInfo: true })
45645
- : yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
45644
+ const features = yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
45646
45645
  Log$g.debug('Protocol V2 features:', features);
45647
45646
  }
45648
45647
  catch (error) {
@@ -45665,7 +45664,7 @@ class Device extends events.exports {
45665
45664
  });
45666
45665
  }
45667
45666
  getDeviceState(params = {}) {
45668
- var _a, _b, _c, _d;
45667
+ var _a, _b, _c;
45669
45668
  return __awaiter(this, void 0, void 0, function* () {
45670
45669
  const refresh = new Set((_a = params.refreshSections) !== null && _a !== void 0 ? _a : []);
45671
45670
  const getProtocolV2DeviceInfoRequest = () => {
@@ -45683,14 +45682,7 @@ class Device extends events.exports {
45683
45682
  commands: this.commands,
45684
45683
  request: getProtocolV2DeviceInfoRequest(),
45685
45684
  });
45686
- if (params.allowLegacyProtocolV2ProtocolInfo) {
45687
- yield this.probeProtocolV2RuntimeState(deviceInfo, undefined, {
45688
- allowLegacyProtocolV2ProtocolInfo: true,
45689
- });
45690
- }
45691
- else {
45692
- yield this.probeProtocolV2RuntimeState(deviceInfo);
45693
- }
45685
+ yield this.probeProtocolV2RuntimeState(deviceInfo);
45694
45686
  refreshedDeviceInfo = deviceInfo;
45695
45687
  initializedWithDeviceInfo = true;
45696
45688
  }
@@ -45720,12 +45712,9 @@ class Device extends events.exports {
45720
45712
  }
45721
45713
  }
45722
45714
  if (refresh.has('status') && !initializedWithDeviceInfo) {
45723
- const cachedMode = (_c = this.state) === null || _c === void 0 ? void 0 : _c.status.mode;
45724
- yield this.probeProtocolV2RuntimeState(refreshedDeviceInfo, undefined, Object.assign({ forceRuntimeContextRefresh: cachedMode === 'bootloader' || cachedMode === 'romloader' }, (params.allowLegacyProtocolV2ProtocolInfo
45725
- ? { allowLegacyProtocolV2ProtocolInfo: true }
45726
- : {})));
45715
+ yield this.probeProtocolV2RuntimeState(refreshedDeviceInfo);
45727
45716
  }
45728
- if (refresh.has('settings') && ((_d = this.state) === null || _d === void 0 ? void 0 : _d.status.mode) === 'normal') {
45717
+ if (refresh.has('settings') && ((_c = this.state) === null || _c === void 0 ? void 0 : _c.status.mode) === 'normal') {
45729
45718
  const { message } = yield this.commands.typedCall('DeviceSettingsGet', 'DeviceSettings', {});
45730
45719
  this.updateState(mapDeviceSettingsToState(message), 'settings-read');
45731
45720
  }
@@ -45783,27 +45772,18 @@ class Device extends events.exports {
45783
45772
  this.updateState(mapFeaturesToState(normalized), source);
45784
45773
  return this.features;
45785
45774
  }
45786
- ensureProtocolV2RuntimeContext(timeoutMs, options) {
45775
+ ensureProtocolV2RuntimeContext(timeoutMs) {
45787
45776
  var _a, _b, _c, _d;
45788
45777
  return __awaiter(this, void 0, void 0, function* () {
45789
- const assertProtocolInfoAllowed = (protocolInfo) => {
45790
- if (isLegacyProtocolV2ProtocolInfo(protocolInfo) &&
45791
- (options === null || options === void 0 ? void 0 : options.allowLegacyProtocolV2ProtocolInfo) !== true) {
45792
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, 'Legacy Protocol V2 ProtocolInfo is supported only during device discovery and firmware update.');
45793
- }
45794
- return protocolInfo;
45795
- };
45796
- const cachedProtocolInfo = (options === null || options === void 0 ? void 0 : options.forceRefresh) === true
45797
- ? undefined
45798
- : (_a = this.protocolV2RuntimeContext) !== null && _a !== void 0 ? _a : (!this.protocolV2StateNeedsReload
45799
- ? (_d = (_c = (_b = this.state) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.protocolV2ProtocolInfo) !== null && _d !== void 0 ? _d : undefined
45800
- : undefined);
45778
+ const cachedProtocolInfo = (_a = this.protocolV2RuntimeContext) !== null && _a !== void 0 ? _a : (!this.protocolV2StateNeedsReload
45779
+ ? (_d = (_c = (_b = this.state) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.protocolV2ProtocolInfo) !== null && _d !== void 0 ? _d : undefined
45780
+ : undefined);
45801
45781
  if (cachedProtocolInfo) {
45802
45782
  this.protocolV2RuntimeContext = cachedProtocolInfo;
45803
- return assertProtocolInfoAllowed(cachedProtocolInfo);
45783
+ return cachedProtocolInfo;
45804
45784
  }
45805
45785
  if (this.protocolV2RuntimeContextPromise) {
45806
- return assertProtocolInfoAllowed(yield this.protocolV2RuntimeContextPromise);
45786
+ return this.protocolV2RuntimeContextPromise;
45807
45787
  }
45808
45788
  const requestToken = {};
45809
45789
  const pendingRequest = (() => __awaiter(this, void 0, void 0, function* () {
@@ -45820,7 +45800,7 @@ class Device extends events.exports {
45820
45800
  this.protocolV2RuntimeContextRequestToken = requestToken;
45821
45801
  this.protocolV2RuntimeContextPromise = pendingRequest;
45822
45802
  try {
45823
- return assertProtocolInfoAllowed(yield pendingRequest);
45803
+ return yield pendingRequest;
45824
45804
  }
45825
45805
  finally {
45826
45806
  if (this.protocolV2RuntimeContextPromise === pendingRequest) {
@@ -45832,15 +45812,11 @@ class Device extends events.exports {
45832
45812
  }
45833
45813
  });
45834
45814
  }
45835
- probeProtocolV2RuntimeState(deviceInfo, timeoutMs, options) {
45815
+ probeProtocolV2RuntimeState(deviceInfo, timeoutMs) {
45836
45816
  var _a, _b, _c;
45837
45817
  return __awaiter(this, void 0, void 0, function* () {
45838
- const protocolInfo = yield this.ensureProtocolV2RuntimeContext(timeoutMs, {
45839
- forceRefresh: options === null || options === void 0 ? void 0 : options.forceRuntimeContextRefresh,
45840
- allowLegacyProtocolV2ProtocolInfo: options === null || options === void 0 ? void 0 : options.allowLegacyProtocolV2ProtocolInfo,
45841
- });
45818
+ const protocolInfo = yield this.ensureProtocolV2RuntimeContext(timeoutMs);
45842
45819
  const runtimeMode = getProtocolV2RuntimeMode(protocolInfo);
45843
- const legacyProtocolInfo = isLegacyProtocolV2ProtocolInfo(protocolInfo);
45844
45820
  const runtimeDeviceInfo = deviceInfo !== null && deviceInfo !== void 0 ? deviceInfo : (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.raw) === null || _b === void 0 ? void 0 : _b.protocolV2DeviceInfo;
45845
45821
  const protocolV2DeviceType = runtimeDeviceInfo
45846
45822
  ? resolveProtocolV2DeviceIdentity((_c = runtimeDeviceInfo.hw) === null || _c === void 0 ? void 0 : _c.Device_type).deviceType
@@ -45850,8 +45826,7 @@ class Device extends events.exports {
45850
45826
  protocolV2DeviceType !== hdShared.EDeviceType.Neo) {
45851
45827
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, 'Protocol V2 romloader mode is only supported for Pro2 and Neo.');
45852
45828
  }
45853
- const deviceStatusSupported = legacyProtocolInfo ||
45854
- supportsProtocolV2Message(protocolInfo, PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE);
45829
+ const deviceStatusSupported = supportsProtocolV2Message(protocolInfo, PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE);
45855
45830
  if (runtimeMode === 'bootloader' || runtimeMode === 'romloader') {
45856
45831
  return this.updateProtocolV2Features(deviceInfo, null, runtimeMode, protocolInfo);
45857
45832
  }
@@ -45899,7 +45874,8 @@ class Device extends events.exports {
45899
45874
  const previousStatus = (_d = (_c = this.state) === null || _c === void 0 ? void 0 : _c.raw) === null || _d === void 0 ? void 0 : _d.protocolV2DeviceStatus;
45900
45875
  return this.updateProtocolV2Features(previousDeviceInfo, Object.assign(Object.assign({}, previousStatus), status));
45901
45876
  }
45902
- invalidateProtocolV2RuntimeState() {
45877
+ markTransportDisconnected() {
45878
+ this.deviceAcquired = false;
45903
45879
  if (!this.isProtocolV2())
45904
45880
  return;
45905
45881
  this.protocolV2StateNeedsReload = true;
@@ -45908,10 +45884,6 @@ class Device extends events.exports {
45908
45884
  this.protocolV2RuntimeContextRequestToken = undefined;
45909
45885
  this.clearPreInitialized();
45910
45886
  }
45911
- markTransportDisconnected() {
45912
- this.deviceAcquired = false;
45913
- this.invalidateProtocolV2RuntimeState();
45914
- }
45915
45887
  invalidateAfterWipe() {
45916
45888
  const deviceId = this.getCurrentDeviceId();
45917
45889
  if (deviceId) {
@@ -45921,7 +45893,10 @@ class Device extends events.exports {
45921
45893
  if (this.originalDescriptor.path !== deviceId) {
45922
45894
  deviceWalletSessionStore.deleteDevice(this.originalDescriptor.path);
45923
45895
  }
45924
- this.invalidateProtocolV2RuntimeState();
45896
+ this.protocolV2StateNeedsReload = true;
45897
+ this.protocolV2RuntimeContext = undefined;
45898
+ this.protocolV2RuntimeContextPromise = undefined;
45899
+ this.protocolV2RuntimeContextRequestToken = undefined;
45925
45900
  }
45926
45901
  this.passphraseState = undefined;
45927
45902
  this.stateStore = new DeviceStateStore();
@@ -45931,7 +45906,11 @@ class Device extends events.exports {
45931
45906
  markProtocolV2Reboot(rebootType) {
45932
45907
  if (!this.isProtocolV2())
45933
45908
  return;
45934
- this.invalidateProtocolV2RuntimeState();
45909
+ this.protocolV2StateNeedsReload = true;
45910
+ this.protocolV2RuntimeContext = undefined;
45911
+ this.protocolV2RuntimeContextPromise = undefined;
45912
+ this.protocolV2RuntimeContextRequestToken = undefined;
45913
+ this.clearPreInitialized();
45935
45914
  let loaderMode;
45936
45915
  if (rebootType === hdTransport.DeviceRebootType.Bootloader) {
45937
45916
  loaderMode = 'bootloader';
@@ -45987,7 +45966,6 @@ class Device extends events.exports {
45987
45966
  if (device.features) {
45988
45967
  this._updateFeatures(device.features);
45989
45968
  }
45990
- this.invalidateProtocolV2RuntimeState();
45991
45969
  }
45992
45970
  run(fn, options) {
45993
45971
  return __awaiter(this, void 0, void 0, function* () {
@@ -46842,7 +46820,7 @@ class SearchDevices extends BaseMethod {
46842
46820
  if (!seenIds.has(lowerId)) {
46843
46821
  seenIds.add(lowerId);
46844
46822
  const bleName = (_e = (_d = device.name) !== null && _d !== void 0 ? _d : device.localName) !== null && _e !== void 0 ? _e : '';
46845
- devices.push(Object.assign(Object.assign({}, device), { connectId: device.id, serialNo: null, uuid: device.id, deviceId: null, name: bleName || device.name, deviceType: getDeviceTypeByBleName(bleName) }));
46823
+ devices.push(Object.assign(Object.assign({}, device), { connectId: device.id, serialNo: null, uuid: '', deviceId: null, name: bleName || device.name, deviceType: getDeviceTypeByBleName(bleName) }));
46846
46824
  }
46847
46825
  }
46848
46826
  return devices;
@@ -46854,7 +46832,6 @@ class SearchDevices extends BaseMethod {
46854
46832
  connectProtocol: undefined,
46855
46833
  forceProtocolDetection: true,
46856
46834
  refreshRuntimeState: true,
46857
- allowLegacyProtocolV2ProtocolInfo: true,
46858
46835
  });
46859
46836
  deviceList.push(...result.deviceList);
46860
46837
  }
@@ -46938,7 +46915,9 @@ class GetDeviceState extends BaseMethod {
46938
46915
  }
46939
46916
  run() {
46940
46917
  return __awaiter(this, void 0, void 0, function* () {
46941
- const state = yield this.device.getDeviceState(Object.assign({ refreshSections: SCOPE_SECTIONS[this.params.scope] }, (this.params.scope === 'firmware' ? { allowLegacyProtocolV2ProtocolInfo: true } : {})));
46918
+ const state = yield this.device.getDeviceState({
46919
+ refreshSections: SCOPE_SECTIONS[this.params.scope],
46920
+ });
46942
46921
  if (this.params.scope === 'settings' &&
46943
46922
  this.device.isProtocolV2() &&
46944
46923
  isLoaderMode(state.status.mode)) {
@@ -47477,7 +47456,6 @@ function loadProtocolV2FirmwareReleaseContext({ device, firmwareType: firmwareTy
47477
47456
  refreshSections: checkFirmwareHash
47478
47457
  ? ['identity', 'versions', 'verification']
47479
47458
  : ['identity', 'versions'],
47480
- allowLegacyProtocolV2ProtocolInfo: true,
47481
47459
  });
47482
47460
  if (state.identity.deviceType !== 'pro2' && state.identity.deviceType !== 'neo') {
47483
47461
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod, `${methodName} requires a Pro2 or Neo device for Protocol V2`);
@@ -51841,10 +51819,6 @@ const isProtocolV2FirmwareStatusEndpointUnavailable = (error) => {
51841
51819
  message.includes('message handler not found') ||
51842
51820
  message.includes('unsupported message'));
51843
51821
  };
51844
- const isProtocolV2FirmwareUpdateEndpointUnavailable = (error) => {
51845
- const message = getProtocolV2UnknownErrorText(error).toLowerCase();
51846
- return (message.includes('handler not registered') || message.includes('message handler not found'));
51847
- };
51848
51822
  const isProtocolV2TerminalInstallStatusError = (error) => {
51849
51823
  var _a;
51850
51824
  return error instanceof hdShared.HardwareError &&
@@ -51977,7 +51951,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
51977
51951
  this.protocolV2HasExplicitTargetSelection = false;
51978
51952
  this.protocolV2PreparedSources = [];
51979
51953
  this.protocolV2ExecutionInLoader = false;
51980
- this.protocolV2LegacyDirectUpdate = false;
51981
51954
  this.protocolV2BootResourceStagingSafe = false;
51982
51955
  this.protocolV2CompletedTargetVersions = new Map();
51983
51956
  this.protocolV2FinalStatusVerified = false;
@@ -53083,13 +53056,19 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53083
53056
  }
53084
53057
  return ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.mode) === 'romloader';
53085
53058
  }
53086
- isLegacyProtocolV2Runtime() {
53087
- var _a, _b;
53088
- const protocolInfo = (_b = (_a = this.device.state) === null || _a === void 0 ? void 0 : _a.raw) === null || _b === void 0 ? void 0 : _b.protocolV2ProtocolInfo;
53089
- return protocolInfo ? isLegacyProtocolV2ProtocolInfo(protocolInfo) : false;
53090
- }
53091
- rebootProtocolV2ToBootloader() {
53059
+ enterProtocolV2BootloaderMode() {
53092
53060
  return __awaiter(this, void 0, void 0, function* () {
53061
+ if (this.isProtocolV2RomloaderMode()) {
53062
+ Log$6.debug('Protocol V2 device is in romloader mode; start firmware update directly');
53063
+ this.protocolV2ExecutionInLoader = true;
53064
+ return false;
53065
+ }
53066
+ if (this.isProtocolV2BootloaderMode()) {
53067
+ Log$6.debug('Protocol V2 device is already in bootloader mode, skip reboot');
53068
+ this.protocolV2ExecutionInLoader = true;
53069
+ this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
53070
+ return false;
53071
+ }
53093
53072
  try {
53094
53073
  this.postTipMessage(exports.FirmwareUpdateTipMessage.AutoRebootToBootloader);
53095
53074
  yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Bootloader);
@@ -53108,25 +53087,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53108
53087
  }
53109
53088
  });
53110
53089
  }
53111
- enterProtocolV2BootloaderMode() {
53112
- return __awaiter(this, void 0, void 0, function* () {
53113
- this.protocolV2LegacyDirectUpdate = false;
53114
- if (this.isProtocolV2RomloaderMode()) {
53115
- Log$6.debug('Protocol V2 device is in romloader mode; start firmware update directly');
53116
- this.protocolV2LegacyDirectUpdate = this.isLegacyProtocolV2Runtime();
53117
- this.protocolV2ExecutionInLoader = true;
53118
- return false;
53119
- }
53120
- if (this.isProtocolV2BootloaderMode()) {
53121
- Log$6.debug('Protocol V2 device is already in bootloader mode, skip reboot');
53122
- this.protocolV2LegacyDirectUpdate = this.isLegacyProtocolV2Runtime();
53123
- this.protocolV2ExecutionInLoader = true;
53124
- this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
53125
- return false;
53126
- }
53127
- return this.rebootProtocolV2ToBootloader();
53128
- });
53129
- }
53130
53090
  waitForProtocolV2BootloaderMode(timeout = PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT, retryInterval = 1000) {
53131
53091
  return __awaiter(this, void 0, void 0, function* () {
53132
53092
  const startTime = Date.now();
@@ -53143,7 +53103,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53143
53103
  timeoutMs: this.getProtocolV2DeviceInfoTimeout(),
53144
53104
  });
53145
53105
  this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
53146
- const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT, { allowLegacyProtocolV2ProtocolInfo: true });
53106
+ const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
53147
53107
  if ((features === null || features === void 0 ? void 0 : features.mode) === 'bootloader') {
53148
53108
  return features;
53149
53109
  }
@@ -53637,7 +53597,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53637
53597
  }
53638
53598
  probeProtocolV2NormalMode(deviceInfo) {
53639
53599
  return __awaiter(this, void 0, void 0, function* () {
53640
- const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT, { allowLegacyProtocolV2ProtocolInfo: true });
53600
+ const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
53641
53601
  return features.mode === 'normal' && !features.bootloaderMode;
53642
53602
  });
53643
53603
  }
@@ -53690,7 +53650,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53690
53650
  request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
53691
53651
  });
53692
53652
  this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
53693
- const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT, { allowLegacyProtocolV2ProtocolInfo: true });
53653
+ const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
53694
53654
  if (features.mode === 'normal' && !features.bootloaderMode) {
53695
53655
  return features;
53696
53656
  }
@@ -53816,24 +53776,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53816
53776
  }
53817
53777
  protocolV2StartFirmwareUpdate({ targets, }) {
53818
53778
  return __awaiter(this, void 0, void 0, function* () {
53819
- const startUpdate = () => this.device
53820
- .getCommands()
53821
- .typedCall('DeviceFirmwareUpdateRequest', 'Success', { targets }, { timeoutMs: PROTOCOL_V2_START_UPDATE_TIMEOUT });
53822
- let response;
53823
- try {
53824
- response = yield startUpdate();
53825
- }
53826
- catch (error) {
53827
- if (!this.protocolV2LegacyDirectUpdate ||
53828
- !isProtocolV2FirmwareUpdateEndpointUnavailable(error)) {
53829
- throw error;
53830
- }
53831
- this.protocolV2LegacyDirectUpdate = false;
53832
- Log$6.debug('[FirmwareUpdateV4] legacy App does not expose DeviceFirmwareUpdateRequest; rebooting to bootloader');
53833
- yield this.rebootProtocolV2ToBootloader();
53834
- response = yield startUpdate();
53835
- }
53836
- this.protocolV2LegacyDirectUpdate = false;
53779
+ const commands = this.device.getCommands();
53780
+ const response = yield commands.typedCall('DeviceFirmwareUpdateRequest', 'Success', { targets }, { timeoutMs: PROTOCOL_V2_START_UPDATE_TIMEOUT });
53837
53781
  this.postTipMessage(exports.FirmwareUpdateTipMessage.FirmwareUpdating);
53838
53782
  this.postProgressMessage(0, 'installingFirmware');
53839
53783
  return response;
@@ -53969,61 +53913,6 @@ class DeviceGetOnboardingStatus extends BaseMethod {
53969
53913
  }
53970
53914
  }
53971
53915
 
53972
- const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
53973
- const JPEG_CONTAINER_OVERHEAD_BYTES = 64 * 1024;
53974
- const JPEG_MAX_MEMORY_USAGE_IN_MB = 32;
53975
- const JPEG_MAX_RESOLUTION_IN_MP = 1;
53976
- function decodeCanonicalBase64({ value, parameterName, maxBytes, }) {
53977
- if (typeof value !== 'string' || value.length === 0) {
53978
- throw invalidParameter$1(`Parameter [${parameterName}] must be a non-empty Base64 string.`);
53979
- }
53980
- if (value.length > Math.ceil(maxBytes / 3) * 4) {
53981
- throw invalidParameter$1(`Parameter [${parameterName}] exceeds the maximum supported size.`);
53982
- }
53983
- if (value.length % 4 !== 0 || !BASE64_PATTERN.test(value)) {
53984
- throw invalidParameter$1(`Parameter [${parameterName}] must use canonical Base64 encoding.`);
53985
- }
53986
- const decoded = buffer.Buffer.from(value, 'base64');
53987
- if (decoded.byteLength === 0 || decoded.byteLength > maxBytes) {
53988
- throw invalidParameter$1(`Parameter [${parameterName}] exceeds the maximum supported size.`);
53989
- }
53990
- if (decoded.toString('base64') !== value) {
53991
- throw invalidParameter$1(`Parameter [${parameterName}] must use canonical Base64 encoding.`);
53992
- }
53993
- return Uint8Array.from(decoded);
53994
- }
53995
- function decodeJpegBase64ToRgba({ jpegBase64, parameterName, expectedWidth, expectedHeight, }) {
53996
- const jpegBytes = decodeCanonicalBase64({
53997
- value: jpegBase64,
53998
- parameterName,
53999
- maxBytes: expectedWidth * expectedHeight * 8 + JPEG_CONTAINER_OVERHEAD_BYTES,
54000
- });
54001
- if (jpegBytes[0] !== 0xff || jpegBytes[1] !== 0xd8) {
54002
- throw invalidParameter$1(`Parameter [${parameterName}] must contain a JPEG image.`);
54003
- }
54004
- let decoded;
54005
- try {
54006
- decoded = jpegJs.decode(jpegBytes, {
54007
- useTArray: true,
54008
- formatAsRGBA: true,
54009
- tolerantDecoding: false,
54010
- maxResolutionInMP: JPEG_MAX_RESOLUTION_IN_MP,
54011
- maxMemoryUsageInMB: JPEG_MAX_MEMORY_USAGE_IN_MB,
54012
- });
54013
- }
54014
- catch (_a) {
54015
- throw invalidParameter$1(`Parameter [${parameterName}] must contain a valid JPEG image.`);
54016
- }
54017
- if (decoded.width !== expectedWidth || decoded.height !== expectedHeight) {
54018
- throw invalidParameter$1(`Parameter [${parameterName}] must contain a ${expectedWidth}x${expectedHeight} JPEG image.`);
54019
- }
54020
- const expectedLength = expectedWidth * expectedHeight * 4;
54021
- if (decoded.data.byteLength !== expectedLength) {
54022
- throw invalidParameter$1(`Decoded parameter [${parameterName}] must contain ${expectedLength} RGBA bytes.`);
54023
- }
54024
- return decoded;
54025
- }
54026
-
54027
53916
  const Log$4 = getLogger(exports.LoggerNames.Core);
54028
53917
  const MIN_FILE_CHUNK_SIZE = 64;
54029
53918
  const FILE_TRANSFER_RATE_WINDOW_MS = 1000;
@@ -54300,9 +54189,6 @@ function writeProtocolV2File(options) {
54300
54189
 
54301
54190
  const WALLPAPER_DIRECTORY = 'vol1:/wallpapers';
54302
54191
  const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
54303
- const DEVICE_SETTINGS_SET_MESSAGE_TYPE = 60412;
54304
- const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2 = 60805;
54305
- const FILESYSTEM_DIR_MAKE_MESSAGE_TYPE = 60809;
54306
54192
  function normalizeFileName(fileName, data) {
54307
54193
  if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
54308
54194
  throw invalidParameter$1('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
@@ -54321,40 +54207,26 @@ class DeviceUploadWallpaper extends BaseMethod {
54321
54207
  return ['V2'];
54322
54208
  }
54323
54209
  init() {
54324
- const { jpegBase64, fileName, chunkSize } = this.payload;
54210
+ const { width, height, rgba, fileName, chunkSize } = this.payload;
54211
+ if (width !== PRO2_WALLPAPER_WIDTH || height !== PRO2_WALLPAPER_HEIGHT) {
54212
+ throw invalidParameter$1(`Pro2 wallpaper dimensions must be ${PRO2_WALLPAPER_WIDTH}x${PRO2_WALLPAPER_HEIGHT}.`);
54213
+ }
54214
+ if (!(rgba instanceof ArrayBuffer) && !ArrayBuffer.isView(rgba)) {
54215
+ throw invalidParameter$1('Parameter [rgba] must be an ArrayBuffer or Uint8Array.');
54216
+ }
54325
54217
  if (chunkSize !== undefined && (!Number.isInteger(chunkSize) || chunkSize <= 0)) {
54326
54218
  throw invalidParameter$1('Parameter [chunkSize] must be a positive integer.');
54327
54219
  }
54328
- const decoded = decodeJpegBase64ToRgba({
54329
- jpegBase64,
54330
- parameterName: 'jpegBase64',
54331
- expectedWidth: PRO2_WALLPAPER_WIDTH,
54332
- expectedHeight: PRO2_WALLPAPER_HEIGHT,
54333
- });
54334
- this.encoded = encodePro2Wallpaper({
54335
- width: PRO2_WALLPAPER_WIDTH,
54336
- height: PRO2_WALLPAPER_HEIGHT,
54337
- rgba: decoded.data,
54338
- });
54220
+ const rgbaBytes = rgba instanceof ArrayBuffer
54221
+ ? rgba
54222
+ : new Uint8Array(rgba.buffer, rgba.byteOffset, rgba.byteLength);
54223
+ this.encoded = encodePro2Wallpaper({ width, height, rgba: rgbaBytes });
54339
54224
  this.path = `${WALLPAPER_DIRECTORY}/${normalizeFileName(fileName, this.encoded.data)}`;
54340
- this.params = { jpegBase64, fileName, chunkSize };
54225
+ this.params = { width, height, rgba: rgbaBytes, fileName, chunkSize };
54341
54226
  this.unlockPolicy = 'none';
54342
54227
  this.skipForceUpdateCheck = true;
54343
54228
  this.useDevicePassphraseState = false;
54344
54229
  }
54345
- assertCapabilities() {
54346
- return __awaiter(this, void 0, void 0, function* () {
54347
- const protocolInfo = yield this.device.ensureProtocolV2RuntimeContext();
54348
- const requiredMessageTypes = [
54349
- DEVICE_SETTINGS_SET_MESSAGE_TYPE,
54350
- FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2,
54351
- FILESYSTEM_DIR_MAKE_MESSAGE_TYPE,
54352
- ];
54353
- if (requiredMessageTypes.some(messageType => !supportsProtocolV2Message(protocolInfo, messageType))) {
54354
- throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
54355
- }
54356
- });
54357
- }
54358
54230
  ensureDirectory() {
54359
54231
  return __awaiter(this, void 0, void 0, function* () {
54360
54232
  if (this.directoryReady)
@@ -54404,7 +54276,6 @@ class DeviceUploadWallpaper extends BaseMethod {
54404
54276
  const { encoded } = this;
54405
54277
  if (!encoded)
54406
54278
  throw invalidParameter$1('Wallpaper data has not been initialized.');
54407
- yield this.assertCapabilities();
54408
54279
  yield this.ensureDirectory();
54409
54280
  yield this.upload();
54410
54281
  const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
@@ -54429,7 +54300,7 @@ class DeviceUploadNft extends BaseMethod {
54429
54300
  return ['V2'];
54430
54301
  }
54431
54302
  init() {
54432
- const { imageJpegBase64, thumbnailJpegBase64, title, subtitle, timestampMs = Date.now(), chunkSize = PRO2_NFT_DEFAULT_CHUNK_SIZE, paceMs = PRO2_NFT_DEFAULT_PACE_MS, timeoutMs = PRO2_NFT_DEFAULT_TIMEOUT_MS, } = this.payload;
54303
+ const { image, thumbnail, title, subtitle, timestampMs = Date.now(), chunkSize = PRO2_NFT_DEFAULT_CHUNK_SIZE, paceMs = PRO2_NFT_DEFAULT_PACE_MS, timeoutMs = PRO2_NFT_DEFAULT_TIMEOUT_MS, } = this.payload;
54433
54304
  if (!Number.isInteger(chunkSize) ||
54434
54305
  chunkSize < PRO2_NFT_MIN_CHUNK_SIZE ||
54435
54306
  chunkSize > PRO2_NFT_MAX_CHUNK_SIZE) {
@@ -54441,51 +54312,8 @@ class DeviceUploadNft extends BaseMethod {
54441
54312
  if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
54442
54313
  throw invalidParameter$1('Parameter [timeoutMs] must be a positive integer.');
54443
54314
  }
54444
- const encodedImage = (() => {
54445
- const decoded = decodeJpegBase64ToRgba({
54446
- jpegBase64: imageJpegBase64,
54447
- parameterName: 'imageJpegBase64',
54448
- expectedWidth: PRO2_NFT_IMAGE_WIDTH,
54449
- expectedHeight: PRO2_NFT_IMAGE_HEIGHT,
54450
- });
54451
- return encodePro2Image({
54452
- width: PRO2_NFT_IMAGE_WIDTH,
54453
- height: PRO2_NFT_IMAGE_HEIGHT,
54454
- rgba: decoded.data,
54455
- alphaMode: 'black-background',
54456
- }).data;
54457
- })();
54458
- const encodedThumbnail = (() => {
54459
- const decoded = decodeJpegBase64ToRgba({
54460
- jpegBase64: thumbnailJpegBase64,
54461
- parameterName: 'thumbnailJpegBase64',
54462
- expectedWidth: PRO2_NFT_THUMBNAIL_WIDTH,
54463
- expectedHeight: PRO2_NFT_THUMBNAIL_HEIGHT,
54464
- });
54465
- return encodePro2Image({
54466
- width: PRO2_NFT_THUMBNAIL_WIDTH,
54467
- height: PRO2_NFT_THUMBNAIL_HEIGHT,
54468
- rgba: decoded.data,
54469
- alphaMode: 'black-background',
54470
- }).data;
54471
- })();
54472
- this.bundle = buildPro2NftBundleFromEncodedImages({
54473
- image: encodedImage,
54474
- thumbnail: encodedThumbnail,
54475
- title,
54476
- subtitle,
54477
- timestampMs,
54478
- });
54479
- this.params = {
54480
- imageJpegBase64,
54481
- thumbnailJpegBase64,
54482
- title,
54483
- subtitle,
54484
- timestampMs,
54485
- chunkSize,
54486
- paceMs,
54487
- timeoutMs,
54488
- };
54315
+ this.bundle = buildPro2NftBundle({ image, thumbnail, title, subtitle, timestampMs });
54316
+ this.params = { image, thumbnail, title, subtitle, timestampMs, chunkSize, paceMs, timeoutMs };
54489
54317
  this.unlockPolicy = 'none';
54490
54318
  this.skipForceUpdateCheck = true;
54491
54319
  this.useDevicePassphraseState = false;
@@ -54628,17 +54456,11 @@ class FileWrite extends BaseMethod {
54628
54456
 
54629
54457
  const PORTFOLIO_PENDING_PATH = 'vol1:/portfolio/portfolio.okpkg.pending';
54630
54458
  const PORTFOLIO_CHUNK_SIZE = 2048;
54631
- const PORTFOLIO_PACKAGE_MAX_BYTES = 128 * 1024;
54632
54459
  const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE = 60805;
54633
54460
  const PORTFOLIO_UPDATE_MESSAGE_TYPE = 61400;
54634
54461
  class UploadPortfolio extends FileWrite {
54635
54462
  init() {
54636
- const { packageBase64, timeoutMs } = this.payload;
54637
- const packageBytes = decodeCanonicalBase64({
54638
- value: packageBase64,
54639
- parameterName: 'packageBase64',
54640
- maxBytes: PORTFOLIO_PACKAGE_MAX_BYTES,
54641
- });
54463
+ const { packageBytes, timeoutMs } = this.payload;
54642
54464
  this.payload = Object.assign(Object.assign({}, this.payload), { path: PORTFOLIO_PENDING_PATH, offset: 0, data: packageBytes, chunkSize: PORTFOLIO_CHUNK_SIZE, overwrite: true, append: false, emitProgress: false, timeoutMs });
54643
54465
  super.init();
54644
54466
  this.unlockPolicy = 'none';
@@ -63408,13 +63230,11 @@ class TonSignMessage extends BaseMethod {
63408
63230
  super(...arguments);
63409
63231
  this.initState = null;
63410
63232
  this.processTxRequest = (request, data) => __awaiter(this, void 0, void 0, function* () {
63411
- var _a;
63412
63233
  if (!request.init_data_length) {
63413
63234
  const deviceType = this.device.getCurrentDeviceType();
63414
63235
  const hasClassic = DeviceModelToTypes.model_classic1s.includes(deviceType);
63415
- const signingMessage = (_a = request.signing_message) !== null && _a !== void 0 ? _a : request.signning_message;
63416
- const shouldSkipValidation = signingMessage == null;
63417
- return Promise.resolve(Object.assign(Object.assign({}, request), { signing_message: signingMessage, skip_validate: hasClassic || shouldSkipValidation }));
63236
+ const hasSigningMessageRepr = request.signning_message == null;
63237
+ return Promise.resolve(Object.assign(Object.assign({}, request), { skip_validate: hasClassic || hasSigningMessageRepr }));
63418
63238
  }
63419
63239
  const [first, rest] = cutString(data, request.init_data_length * 2);
63420
63240
  const response = yield this.device.commands.typedCall('TonTxAck', 'TonSignedMessage', {
@@ -64919,10 +64739,6 @@ const createUiProgressMessageFilter = (intervalMs = DEFAULT_UI_PROGRESS_INTERVAL
64919
64739
  };
64920
64740
  };
64921
64741
 
64922
- const isLegacyProtocolV2FirmwareRecoveryMethod = (method) => (method === null || method === void 0 ? void 0 : method.name) === 'firmwareUpdateV4' ||
64923
- (method === null || method === void 0 ? void 0 : method.name) === 'checkAllFirmwareRelease' ||
64924
- ((method === null || method === void 0 ? void 0 : method.name) === 'getDeviceState' && method.payload.scope === 'firmware');
64925
-
64926
64742
  const Log = getLogger(exports.LoggerNames.Core);
64927
64743
  const PRE_INITIALIZE_TTL_MS = 60 * 1000;
64928
64744
  const preWarmInflight = new Map();
@@ -64937,9 +64753,15 @@ function hasDeriveCardano(method) {
64937
64753
  }
64938
64754
  return method.name.startsWith('cardano') || ((_a = method.payload) === null || _a === void 0 ? void 0 : _a.deriveCardano);
64939
64755
  }
64940
- const parseInitOptions = (method) => (Object.assign({ initSession: method === null || method === void 0 ? void 0 : method.payload.initSession, passphraseState: (method === null || method === void 0 ? void 0 : method.payload.useEmptyPassphrase) ? undefined : method === null || method === void 0 ? void 0 : method.payload.passphraseState, deviceId: method === null || method === void 0 ? void 0 : method.payload.deviceId, deriveCardano: method && hasDeriveCardano(method), connectProtocol: method === null || method === void 0 ? void 0 : method.payload.connectProtocol, forceProtocolDetection: method === null || method === void 0 ? void 0 : method.payload.forceProtocolDetection, protocolV2DeviceInfoTimeoutMs: method === null || method === void 0 ? void 0 : method.payload.protocolV2DeviceInfoTimeoutMs }, (isLegacyProtocolV2FirmwareRecoveryMethod(method)
64941
- ? { allowLegacyProtocolV2ProtocolInfo: true }
64942
- : {})));
64756
+ const parseInitOptions = (method) => ({
64757
+ initSession: method === null || method === void 0 ? void 0 : method.payload.initSession,
64758
+ passphraseState: (method === null || method === void 0 ? void 0 : method.payload.useEmptyPassphrase) ? undefined : method === null || method === void 0 ? void 0 : method.payload.passphraseState,
64759
+ deviceId: method === null || method === void 0 ? void 0 : method.payload.deviceId,
64760
+ deriveCardano: method && hasDeriveCardano(method),
64761
+ connectProtocol: method === null || method === void 0 ? void 0 : method.payload.connectProtocol,
64762
+ forceProtocolDetection: method === null || method === void 0 ? void 0 : method.payload.forceProtocolDetection,
64763
+ protocolV2DeviceInfoTimeoutMs: method === null || method === void 0 ? void 0 : method.payload.protocolV2DeviceInfoTimeoutMs,
64764
+ });
64943
64765
  let _core;
64944
64766
  let _deviceList;
64945
64767
  let _connector;