@onekeyfe/hd-core 1.2.0-alpha.101 → 1.2.0-alpha.103
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/__tests__/base64Data.test.ts +70 -0
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +2 -0
- package/__tests__/device-pool-state.test.ts +29 -0
- package/__tests__/deviceUploadNft.test.ts +33 -4
- package/__tests__/get-device-state.test.ts +102 -13
- package/__tests__/protocol-v2-legacy-recovery.test.ts +29 -0
- package/__tests__/protocol-v2.test.ts +309 -17
- package/__tests__/refresh-device-state.test.ts +4 -1
- package/__tests__/resourceBase64Boundary.test.ts +48 -0
- package/__tests__/search-devices.test.ts +2 -0
- package/__tests__/ton-sign-message.test.ts +84 -0
- package/dist/api/FirmwareUpdateV4.d.ts +3 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +1 -1
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/firmware/protocolV2Release.d.ts.map +1 -1
- package/dist/api/helpers/base64Data.d.ts +16 -0
- package/dist/api/helpers/base64Data.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +2 -3
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +2 -3
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/protocolV2LegacyRecovery.d.ts +5 -0
- package/dist/core/protocolV2LegacyRecovery.d.ts.map +1 -0
- package/dist/device/Device.d.ts +9 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/index.d.ts +16 -14
- package/dist/index.js +266 -86
- package/dist/protocols/protocol-v2/features.d.ts +8 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/types/api/getDeviceState.d.ts +1 -0
- package/dist/types/api/getDeviceState.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +1 -1
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/utils/pro2Nft.d.ts +7 -0
- package/dist/utils/pro2Nft.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/api/FirmwareUpdateV4.ts +70 -23
- package/src/api/GetDeviceState.ts +1 -0
- package/src/api/SearchDevices.ts +2 -0
- package/src/api/UploadPortfolio.ts +9 -2
- package/src/api/firmware/protocolV2Release.ts +1 -0
- package/src/api/helpers/base64Data.ts +85 -0
- package/src/api/protocol-v2/DeviceUploadNft.ts +56 -8
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +37 -18
- package/src/api/ton/TonSignMessage.ts +5 -3
- package/src/core/index.ts +4 -0
- package/src/core/protocolV2LegacyRecovery.ts +12 -0
- package/src/device/Device.ts +78 -20
- package/src/device/DevicePool.ts +17 -5
- package/src/protocols/protocol-v2/features.ts +10 -0
- package/src/protocols/protocol-v2/index.ts +2 -0
- package/src/types/api/getDeviceState.ts +2 -0
- package/src/types/api/protocolV2.ts +1 -1
- package/src/utils/pro2Nft.ts +31 -8
package/dist/index.js
CHANGED
|
@@ -13,9 +13,10 @@ 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');
|
|
16
18
|
var sha3 = require('@noble/hashes/sha3');
|
|
17
19
|
var blake2b = require('@noble/hashes/blake2b');
|
|
18
|
-
var buffer = require('buffer');
|
|
19
20
|
|
|
20
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
22
|
|
|
@@ -42723,18 +42724,14 @@ function getCompletePro2NftBasenames(childFiles) {
|
|
|
42723
42724
|
function utf8Length(value) {
|
|
42724
42725
|
return new TextEncoder().encode(value).byteLength;
|
|
42725
42726
|
}
|
|
42726
|
-
function
|
|
42727
|
-
|
|
42728
|
-
|
|
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.');
|
|
42729
42731
|
}
|
|
42730
|
-
if (!(
|
|
42731
|
-
throw invalidParameter$1(
|
|
42732
|
+
if (!(thumbnail instanceof Uint8Array) || thumbnail.byteLength === 0) {
|
|
42733
|
+
throw invalidParameter$1('Parameter [thumbnail] must contain encoded NFT thumbnail data.');
|
|
42732
42734
|
}
|
|
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);
|
|
42738
42735
|
const titleLength = typeof title === 'string' ? utf8Length(title) : 0;
|
|
42739
42736
|
const subtitleLength = typeof subtitle === 'string' ? utf8Length(subtitle) : Number.POSITIVE_INFINITY;
|
|
42740
42737
|
if (titleLength < 1 || titleLength > 63) {
|
|
@@ -42746,17 +42743,15 @@ function buildPro2NftBundle(options) {
|
|
|
42746
42743
|
if (!Number.isSafeInteger(timestampMs) || timestampMs <= 0) {
|
|
42747
42744
|
throw invalidParameter$1('Parameter [timestampMs] must be a positive safe integer.');
|
|
42748
42745
|
}
|
|
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;
|
|
42751
42746
|
const metadata = new TextEncoder().encode(JSON.stringify({ title, subtitle }));
|
|
42752
42747
|
if (metadata.byteLength === 0 || metadata.byteLength > 512) {
|
|
42753
42748
|
throw invalidParameter$1('Pro2 NFT metadata must contain 1 to 512 UTF-8 bytes.');
|
|
42754
42749
|
}
|
|
42755
|
-
const hash8 = utils.bytesToHex(blake2s.blake2s(
|
|
42750
|
+
const hash8 = utils.bytesToHex(blake2s.blake2s(image)).slice(0, 8);
|
|
42756
42751
|
return {
|
|
42757
42752
|
basename: `nft-${hash8}-${timestampMs}`,
|
|
42758
|
-
image
|
|
42759
|
-
thumbnail
|
|
42753
|
+
image,
|
|
42754
|
+
thumbnail,
|
|
42760
42755
|
metadata,
|
|
42761
42756
|
};
|
|
42762
42757
|
}
|
|
@@ -43242,7 +43237,7 @@ class DevicePool extends events.exports {
|
|
|
43242
43237
|
try {
|
|
43243
43238
|
yield device.initialize(initOptions);
|
|
43244
43239
|
if ((initOptions === null || initOptions === void 0 ? void 0 : initOptions.refreshRuntimeState) && device.isProtocolV2()) {
|
|
43245
|
-
yield this._refreshProtocolV2DiscoveryState(device);
|
|
43240
|
+
yield this._refreshProtocolV2DiscoveryState(device, initOptions);
|
|
43246
43241
|
}
|
|
43247
43242
|
}
|
|
43248
43243
|
finally {
|
|
@@ -43259,26 +43254,28 @@ class DevicePool extends events.exports {
|
|
|
43259
43254
|
let refreshError;
|
|
43260
43255
|
yield device.run(() => __awaiter(this, void 0, void 0, function* () {
|
|
43261
43256
|
try {
|
|
43262
|
-
yield this._refreshProtocolV2DiscoveryState(device);
|
|
43257
|
+
yield this._refreshProtocolV2DiscoveryState(device, initOptions);
|
|
43263
43258
|
}
|
|
43264
43259
|
catch (error) {
|
|
43265
43260
|
refreshError = error;
|
|
43266
43261
|
}
|
|
43267
|
-
}), {
|
|
43268
|
-
|
|
43269
|
-
|
|
43270
|
-
});
|
|
43262
|
+
}), Object.assign({ connectProtocol: initOptions.connectProtocol, forceProtocolDetection: initOptions.forceProtocolDetection }, (initOptions.allowLegacyProtocolV2ProtocolInfo
|
|
43263
|
+
? { allowLegacyProtocolV2ProtocolInfo: true }
|
|
43264
|
+
: {})));
|
|
43271
43265
|
if (refreshError instanceof Error)
|
|
43272
43266
|
throw refreshError;
|
|
43273
43267
|
if (refreshError)
|
|
43274
43268
|
throw new Error(String(refreshError));
|
|
43275
43269
|
});
|
|
43276
43270
|
}
|
|
43277
|
-
static _refreshProtocolV2DiscoveryState(device) {
|
|
43271
|
+
static _refreshProtocolV2DiscoveryState(device, initOptions) {
|
|
43278
43272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43279
|
-
|
|
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));
|
|
43280
43277
|
try {
|
|
43281
|
-
yield device.getDeviceState({ refreshSections: ['settings'] });
|
|
43278
|
+
yield device.getDeviceState(Object.assign({ refreshSections: ['settings'] }, stateReadOptions));
|
|
43282
43279
|
}
|
|
43283
43280
|
catch (error) {
|
|
43284
43281
|
Log$j.debug('Unable to refresh Protocol V2 device label during discovery', error);
|
|
@@ -44226,6 +44223,7 @@ const getProtocolV2SeState = (se) => {
|
|
|
44226
44223
|
}
|
|
44227
44224
|
};
|
|
44228
44225
|
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');
|
|
44229
44227
|
const parseProtocolV2BuildFingerprint = (buildFingerprint) => {
|
|
44230
44228
|
if (!buildFingerprint)
|
|
44231
44229
|
return null;
|
|
@@ -45641,7 +45639,9 @@ class Device extends events.exports {
|
|
|
45641
45639
|
commands: this.commands,
|
|
45642
45640
|
timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
|
|
45643
45641
|
});
|
|
45644
|
-
const features =
|
|
45642
|
+
const features = (options === null || options === void 0 ? void 0 : options.allowLegacyProtocolV2ProtocolInfo)
|
|
45643
|
+
? yield this.probeProtocolV2RuntimeState(deviceInfo, options.protocolV2DeviceInfoTimeoutMs, { allowLegacyProtocolV2ProtocolInfo: true })
|
|
45644
|
+
: yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
|
|
45645
45645
|
Log$g.debug('Protocol V2 features:', features);
|
|
45646
45646
|
}
|
|
45647
45647
|
catch (error) {
|
|
@@ -45664,7 +45664,7 @@ class Device extends events.exports {
|
|
|
45664
45664
|
});
|
|
45665
45665
|
}
|
|
45666
45666
|
getDeviceState(params = {}) {
|
|
45667
|
-
var _a, _b, _c;
|
|
45667
|
+
var _a, _b, _c, _d;
|
|
45668
45668
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45669
45669
|
const refresh = new Set((_a = params.refreshSections) !== null && _a !== void 0 ? _a : []);
|
|
45670
45670
|
const getProtocolV2DeviceInfoRequest = () => {
|
|
@@ -45682,7 +45682,14 @@ class Device extends events.exports {
|
|
|
45682
45682
|
commands: this.commands,
|
|
45683
45683
|
request: getProtocolV2DeviceInfoRequest(),
|
|
45684
45684
|
});
|
|
45685
|
-
|
|
45685
|
+
if (params.allowLegacyProtocolV2ProtocolInfo) {
|
|
45686
|
+
yield this.probeProtocolV2RuntimeState(deviceInfo, undefined, {
|
|
45687
|
+
allowLegacyProtocolV2ProtocolInfo: true,
|
|
45688
|
+
});
|
|
45689
|
+
}
|
|
45690
|
+
else {
|
|
45691
|
+
yield this.probeProtocolV2RuntimeState(deviceInfo);
|
|
45692
|
+
}
|
|
45686
45693
|
refreshedDeviceInfo = deviceInfo;
|
|
45687
45694
|
initializedWithDeviceInfo = true;
|
|
45688
45695
|
}
|
|
@@ -45712,9 +45719,12 @@ class Device extends events.exports {
|
|
|
45712
45719
|
}
|
|
45713
45720
|
}
|
|
45714
45721
|
if (refresh.has('status') && !initializedWithDeviceInfo) {
|
|
45715
|
-
|
|
45722
|
+
const cachedMode = (_c = this.state) === null || _c === void 0 ? void 0 : _c.status.mode;
|
|
45723
|
+
yield this.probeProtocolV2RuntimeState(refreshedDeviceInfo, undefined, Object.assign({ forceRuntimeContextRefresh: cachedMode === 'bootloader' || cachedMode === 'romloader' }, (params.allowLegacyProtocolV2ProtocolInfo
|
|
45724
|
+
? { allowLegacyProtocolV2ProtocolInfo: true }
|
|
45725
|
+
: {})));
|
|
45716
45726
|
}
|
|
45717
|
-
if (refresh.has('settings') && ((
|
|
45727
|
+
if (refresh.has('settings') && ((_d = this.state) === null || _d === void 0 ? void 0 : _d.status.mode) === 'normal') {
|
|
45718
45728
|
const { message } = yield this.commands.typedCall('DeviceSettingsGet', 'DeviceSettings', {});
|
|
45719
45729
|
this.updateState(mapDeviceSettingsToState(message), 'settings-read');
|
|
45720
45730
|
}
|
|
@@ -45772,18 +45782,27 @@ class Device extends events.exports {
|
|
|
45772
45782
|
this.updateState(mapFeaturesToState(normalized), source);
|
|
45773
45783
|
return this.features;
|
|
45774
45784
|
}
|
|
45775
|
-
ensureProtocolV2RuntimeContext(timeoutMs) {
|
|
45785
|
+
ensureProtocolV2RuntimeContext(timeoutMs, options) {
|
|
45776
45786
|
var _a, _b, _c, _d;
|
|
45777
45787
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45778
|
-
const
|
|
45779
|
-
|
|
45780
|
-
|
|
45788
|
+
const assertProtocolInfoAllowed = (protocolInfo) => {
|
|
45789
|
+
if (isLegacyProtocolV2ProtocolInfo(protocolInfo) &&
|
|
45790
|
+
(options === null || options === void 0 ? void 0 : options.allowLegacyProtocolV2ProtocolInfo) !== true) {
|
|
45791
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, 'Legacy Protocol V2 ProtocolInfo is supported only during device discovery and firmware update.');
|
|
45792
|
+
}
|
|
45793
|
+
return protocolInfo;
|
|
45794
|
+
};
|
|
45795
|
+
const cachedProtocolInfo = (options === null || options === void 0 ? void 0 : options.forceRefresh) === true
|
|
45796
|
+
? undefined
|
|
45797
|
+
: (_a = this.protocolV2RuntimeContext) !== null && _a !== void 0 ? _a : (!this.protocolV2StateNeedsReload
|
|
45798
|
+
? (_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
|
|
45799
|
+
: undefined);
|
|
45781
45800
|
if (cachedProtocolInfo) {
|
|
45782
45801
|
this.protocolV2RuntimeContext = cachedProtocolInfo;
|
|
45783
|
-
return cachedProtocolInfo;
|
|
45802
|
+
return assertProtocolInfoAllowed(cachedProtocolInfo);
|
|
45784
45803
|
}
|
|
45785
45804
|
if (this.protocolV2RuntimeContextPromise) {
|
|
45786
|
-
return this.protocolV2RuntimeContextPromise;
|
|
45805
|
+
return assertProtocolInfoAllowed(yield this.protocolV2RuntimeContextPromise);
|
|
45787
45806
|
}
|
|
45788
45807
|
const requestToken = {};
|
|
45789
45808
|
const pendingRequest = (() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -45800,7 +45819,7 @@ class Device extends events.exports {
|
|
|
45800
45819
|
this.protocolV2RuntimeContextRequestToken = requestToken;
|
|
45801
45820
|
this.protocolV2RuntimeContextPromise = pendingRequest;
|
|
45802
45821
|
try {
|
|
45803
|
-
return yield pendingRequest;
|
|
45822
|
+
return assertProtocolInfoAllowed(yield pendingRequest);
|
|
45804
45823
|
}
|
|
45805
45824
|
finally {
|
|
45806
45825
|
if (this.protocolV2RuntimeContextPromise === pendingRequest) {
|
|
@@ -45812,11 +45831,15 @@ class Device extends events.exports {
|
|
|
45812
45831
|
}
|
|
45813
45832
|
});
|
|
45814
45833
|
}
|
|
45815
|
-
probeProtocolV2RuntimeState(deviceInfo, timeoutMs) {
|
|
45834
|
+
probeProtocolV2RuntimeState(deviceInfo, timeoutMs, options) {
|
|
45816
45835
|
var _a, _b, _c;
|
|
45817
45836
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45818
|
-
const protocolInfo = yield this.ensureProtocolV2RuntimeContext(timeoutMs
|
|
45837
|
+
const protocolInfo = yield this.ensureProtocolV2RuntimeContext(timeoutMs, {
|
|
45838
|
+
forceRefresh: options === null || options === void 0 ? void 0 : options.forceRuntimeContextRefresh,
|
|
45839
|
+
allowLegacyProtocolV2ProtocolInfo: options === null || options === void 0 ? void 0 : options.allowLegacyProtocolV2ProtocolInfo,
|
|
45840
|
+
});
|
|
45819
45841
|
const runtimeMode = getProtocolV2RuntimeMode(protocolInfo);
|
|
45842
|
+
const legacyProtocolInfo = isLegacyProtocolV2ProtocolInfo(protocolInfo);
|
|
45820
45843
|
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;
|
|
45821
45844
|
const protocolV2DeviceType = runtimeDeviceInfo
|
|
45822
45845
|
? resolveProtocolV2DeviceIdentity((_c = runtimeDeviceInfo.hw) === null || _c === void 0 ? void 0 : _c.Device_type).deviceType
|
|
@@ -45826,7 +45849,8 @@ class Device extends events.exports {
|
|
|
45826
45849
|
protocolV2DeviceType !== hdShared.EDeviceType.Neo) {
|
|
45827
45850
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, 'Protocol V2 romloader mode is only supported for Pro2 and Neo.');
|
|
45828
45851
|
}
|
|
45829
|
-
const deviceStatusSupported =
|
|
45852
|
+
const deviceStatusSupported = legacyProtocolInfo ||
|
|
45853
|
+
supportsProtocolV2Message(protocolInfo, PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE);
|
|
45830
45854
|
if (runtimeMode === 'bootloader' || runtimeMode === 'romloader') {
|
|
45831
45855
|
return this.updateProtocolV2Features(deviceInfo, null, runtimeMode, protocolInfo);
|
|
45832
45856
|
}
|
|
@@ -46078,6 +46102,7 @@ class Device extends events.exports {
|
|
|
46078
46102
|
var _a, _b;
|
|
46079
46103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46080
46104
|
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
46105
|
+
this.markTransportDisconnected();
|
|
46081
46106
|
yield ((_a = this.cancelableAction) === null || _a === void 0 ? void 0 : _a.call(this, error));
|
|
46082
46107
|
yield ((_b = this.commands) === null || _b === void 0 ? void 0 : _b.cancel());
|
|
46083
46108
|
if (this.runPromise) {
|
|
@@ -46832,6 +46857,7 @@ class SearchDevices extends BaseMethod {
|
|
|
46832
46857
|
connectProtocol: undefined,
|
|
46833
46858
|
forceProtocolDetection: true,
|
|
46834
46859
|
refreshRuntimeState: true,
|
|
46860
|
+
allowLegacyProtocolV2ProtocolInfo: true,
|
|
46835
46861
|
});
|
|
46836
46862
|
deviceList.push(...result.deviceList);
|
|
46837
46863
|
}
|
|
@@ -46915,9 +46941,7 @@ class GetDeviceState extends BaseMethod {
|
|
|
46915
46941
|
}
|
|
46916
46942
|
run() {
|
|
46917
46943
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46918
|
-
const state = yield this.device.getDeviceState({
|
|
46919
|
-
refreshSections: SCOPE_SECTIONS[this.params.scope],
|
|
46920
|
-
});
|
|
46944
|
+
const state = yield this.device.getDeviceState(Object.assign({ refreshSections: SCOPE_SECTIONS[this.params.scope] }, (this.params.scope === 'firmware' ? { allowLegacyProtocolV2ProtocolInfo: true } : {})));
|
|
46921
46945
|
if (this.params.scope === 'settings' &&
|
|
46922
46946
|
this.device.isProtocolV2() &&
|
|
46923
46947
|
isLoaderMode(state.status.mode)) {
|
|
@@ -47456,6 +47480,7 @@ function loadProtocolV2FirmwareReleaseContext({ device, firmwareType: firmwareTy
|
|
|
47456
47480
|
refreshSections: checkFirmwareHash
|
|
47457
47481
|
? ['identity', 'versions', 'verification']
|
|
47458
47482
|
: ['identity', 'versions'],
|
|
47483
|
+
allowLegacyProtocolV2ProtocolInfo: true,
|
|
47459
47484
|
});
|
|
47460
47485
|
if (state.identity.deviceType !== 'pro2' && state.identity.deviceType !== 'neo') {
|
|
47461
47486
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod, `${methodName} requires a Pro2 or Neo device for Protocol V2`);
|
|
@@ -51819,6 +51844,10 @@ const isProtocolV2FirmwareStatusEndpointUnavailable = (error) => {
|
|
|
51819
51844
|
message.includes('message handler not found') ||
|
|
51820
51845
|
message.includes('unsupported message'));
|
|
51821
51846
|
};
|
|
51847
|
+
const isProtocolV2FirmwareUpdateEndpointUnavailable = (error) => {
|
|
51848
|
+
const message = getProtocolV2UnknownErrorText(error).toLowerCase();
|
|
51849
|
+
return (message.includes('handler not registered') || message.includes('message handler not found'));
|
|
51850
|
+
};
|
|
51822
51851
|
const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
51823
51852
|
var _a;
|
|
51824
51853
|
return error instanceof hdShared.HardwareError &&
|
|
@@ -51951,6 +51980,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51951
51980
|
this.protocolV2HasExplicitTargetSelection = false;
|
|
51952
51981
|
this.protocolV2PreparedSources = [];
|
|
51953
51982
|
this.protocolV2ExecutionInLoader = false;
|
|
51983
|
+
this.protocolV2LegacyDirectUpdate = false;
|
|
51954
51984
|
this.protocolV2BootResourceStagingSafe = false;
|
|
51955
51985
|
this.protocolV2CompletedTargetVersions = new Map();
|
|
51956
51986
|
this.protocolV2FinalStatusVerified = false;
|
|
@@ -53056,19 +53086,13 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53056
53086
|
}
|
|
53057
53087
|
return ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.mode) === 'romloader';
|
|
53058
53088
|
}
|
|
53059
|
-
|
|
53089
|
+
isLegacyProtocolV2Runtime() {
|
|
53090
|
+
var _a, _b;
|
|
53091
|
+
const protocolInfo = (_b = (_a = this.device.state) === null || _a === void 0 ? void 0 : _a.raw) === null || _b === void 0 ? void 0 : _b.protocolV2ProtocolInfo;
|
|
53092
|
+
return protocolInfo ? isLegacyProtocolV2ProtocolInfo(protocolInfo) : false;
|
|
53093
|
+
}
|
|
53094
|
+
rebootProtocolV2ToBootloader() {
|
|
53060
53095
|
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
|
-
}
|
|
53072
53096
|
try {
|
|
53073
53097
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.AutoRebootToBootloader);
|
|
53074
53098
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Bootloader);
|
|
@@ -53087,6 +53111,25 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53087
53111
|
}
|
|
53088
53112
|
});
|
|
53089
53113
|
}
|
|
53114
|
+
enterProtocolV2BootloaderMode() {
|
|
53115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53116
|
+
this.protocolV2LegacyDirectUpdate = false;
|
|
53117
|
+
if (this.isProtocolV2RomloaderMode()) {
|
|
53118
|
+
Log$6.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
53119
|
+
this.protocolV2LegacyDirectUpdate = this.isLegacyProtocolV2Runtime();
|
|
53120
|
+
this.protocolV2ExecutionInLoader = true;
|
|
53121
|
+
return false;
|
|
53122
|
+
}
|
|
53123
|
+
if (this.isProtocolV2BootloaderMode()) {
|
|
53124
|
+
Log$6.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
53125
|
+
this.protocolV2LegacyDirectUpdate = this.isLegacyProtocolV2Runtime();
|
|
53126
|
+
this.protocolV2ExecutionInLoader = true;
|
|
53127
|
+
this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
|
|
53128
|
+
return false;
|
|
53129
|
+
}
|
|
53130
|
+
return this.rebootProtocolV2ToBootloader();
|
|
53131
|
+
});
|
|
53132
|
+
}
|
|
53090
53133
|
waitForProtocolV2BootloaderMode(timeout = PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT, retryInterval = 1000) {
|
|
53091
53134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53092
53135
|
const startTime = Date.now();
|
|
@@ -53103,7 +53146,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53103
53146
|
timeoutMs: this.getProtocolV2DeviceInfoTimeout(),
|
|
53104
53147
|
});
|
|
53105
53148
|
this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
|
|
53106
|
-
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
|
|
53149
|
+
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT, { allowLegacyProtocolV2ProtocolInfo: true });
|
|
53107
53150
|
if ((features === null || features === void 0 ? void 0 : features.mode) === 'bootloader') {
|
|
53108
53151
|
return features;
|
|
53109
53152
|
}
|
|
@@ -53597,7 +53640,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53597
53640
|
}
|
|
53598
53641
|
probeProtocolV2NormalMode(deviceInfo) {
|
|
53599
53642
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53600
|
-
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
|
|
53643
|
+
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT, { allowLegacyProtocolV2ProtocolInfo: true });
|
|
53601
53644
|
return features.mode === 'normal' && !features.bootloaderMode;
|
|
53602
53645
|
});
|
|
53603
53646
|
}
|
|
@@ -53650,7 +53693,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53650
53693
|
request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
|
|
53651
53694
|
});
|
|
53652
53695
|
this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
|
|
53653
|
-
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
|
|
53696
|
+
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT, { allowLegacyProtocolV2ProtocolInfo: true });
|
|
53654
53697
|
if (features.mode === 'normal' && !features.bootloaderMode) {
|
|
53655
53698
|
return features;
|
|
53656
53699
|
}
|
|
@@ -53777,7 +53820,22 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53777
53820
|
protocolV2StartFirmwareUpdate({ targets, }) {
|
|
53778
53821
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53779
53822
|
const commands = this.device.getCommands();
|
|
53780
|
-
const
|
|
53823
|
+
const startUpdate = () => commands.typedCall('DeviceFirmwareUpdateRequest', 'Success', { targets }, { timeoutMs: PROTOCOL_V2_START_UPDATE_TIMEOUT });
|
|
53824
|
+
let response;
|
|
53825
|
+
try {
|
|
53826
|
+
response = yield startUpdate();
|
|
53827
|
+
}
|
|
53828
|
+
catch (error) {
|
|
53829
|
+
if (!this.protocolV2LegacyDirectUpdate ||
|
|
53830
|
+
!isProtocolV2FirmwareUpdateEndpointUnavailable(error)) {
|
|
53831
|
+
throw error;
|
|
53832
|
+
}
|
|
53833
|
+
this.protocolV2LegacyDirectUpdate = false;
|
|
53834
|
+
Log$6.debug('[FirmwareUpdateV4] legacy App does not expose DeviceFirmwareUpdateRequest; rebooting to bootloader');
|
|
53835
|
+
yield this.rebootProtocolV2ToBootloader();
|
|
53836
|
+
response = yield startUpdate();
|
|
53837
|
+
}
|
|
53838
|
+
this.protocolV2LegacyDirectUpdate = false;
|
|
53781
53839
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.FirmwareUpdating);
|
|
53782
53840
|
this.postProgressMessage(0, 'installingFirmware');
|
|
53783
53841
|
return response;
|
|
@@ -53913,6 +53971,61 @@ class DeviceGetOnboardingStatus extends BaseMethod {
|
|
|
53913
53971
|
}
|
|
53914
53972
|
}
|
|
53915
53973
|
|
|
53974
|
+
const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
53975
|
+
const JPEG_CONTAINER_OVERHEAD_BYTES = 64 * 1024;
|
|
53976
|
+
const JPEG_MAX_MEMORY_USAGE_IN_MB = 32;
|
|
53977
|
+
const JPEG_MAX_RESOLUTION_IN_MP = 1;
|
|
53978
|
+
function decodeCanonicalBase64({ value, parameterName, maxBytes, }) {
|
|
53979
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
53980
|
+
throw invalidParameter$1(`Parameter [${parameterName}] must be a non-empty Base64 string.`);
|
|
53981
|
+
}
|
|
53982
|
+
if (value.length > Math.ceil(maxBytes / 3) * 4) {
|
|
53983
|
+
throw invalidParameter$1(`Parameter [${parameterName}] exceeds the maximum supported size.`);
|
|
53984
|
+
}
|
|
53985
|
+
if (value.length % 4 !== 0 || !BASE64_PATTERN.test(value)) {
|
|
53986
|
+
throw invalidParameter$1(`Parameter [${parameterName}] must use canonical Base64 encoding.`);
|
|
53987
|
+
}
|
|
53988
|
+
const decoded = buffer.Buffer.from(value, 'base64');
|
|
53989
|
+
if (decoded.byteLength === 0 || decoded.byteLength > maxBytes) {
|
|
53990
|
+
throw invalidParameter$1(`Parameter [${parameterName}] exceeds the maximum supported size.`);
|
|
53991
|
+
}
|
|
53992
|
+
if (decoded.toString('base64') !== value) {
|
|
53993
|
+
throw invalidParameter$1(`Parameter [${parameterName}] must use canonical Base64 encoding.`);
|
|
53994
|
+
}
|
|
53995
|
+
return Uint8Array.from(decoded);
|
|
53996
|
+
}
|
|
53997
|
+
function decodeJpegBase64ToRgba({ jpegBase64, parameterName, expectedWidth, expectedHeight, }) {
|
|
53998
|
+
const jpegBytes = decodeCanonicalBase64({
|
|
53999
|
+
value: jpegBase64,
|
|
54000
|
+
parameterName,
|
|
54001
|
+
maxBytes: expectedWidth * expectedHeight * 8 + JPEG_CONTAINER_OVERHEAD_BYTES,
|
|
54002
|
+
});
|
|
54003
|
+
if (jpegBytes[0] !== 0xff || jpegBytes[1] !== 0xd8) {
|
|
54004
|
+
throw invalidParameter$1(`Parameter [${parameterName}] must contain a JPEG image.`);
|
|
54005
|
+
}
|
|
54006
|
+
let decoded;
|
|
54007
|
+
try {
|
|
54008
|
+
decoded = jpegJs.decode(jpegBytes, {
|
|
54009
|
+
useTArray: true,
|
|
54010
|
+
formatAsRGBA: true,
|
|
54011
|
+
tolerantDecoding: false,
|
|
54012
|
+
maxResolutionInMP: JPEG_MAX_RESOLUTION_IN_MP,
|
|
54013
|
+
maxMemoryUsageInMB: JPEG_MAX_MEMORY_USAGE_IN_MB,
|
|
54014
|
+
});
|
|
54015
|
+
}
|
|
54016
|
+
catch (_a) {
|
|
54017
|
+
throw invalidParameter$1(`Parameter [${parameterName}] must contain a valid JPEG image.`);
|
|
54018
|
+
}
|
|
54019
|
+
if (decoded.width !== expectedWidth || decoded.height !== expectedHeight) {
|
|
54020
|
+
throw invalidParameter$1(`Parameter [${parameterName}] must contain a ${expectedWidth}x${expectedHeight} JPEG image.`);
|
|
54021
|
+
}
|
|
54022
|
+
const expectedLength = expectedWidth * expectedHeight * 4;
|
|
54023
|
+
if (decoded.data.byteLength !== expectedLength) {
|
|
54024
|
+
throw invalidParameter$1(`Decoded parameter [${parameterName}] must contain ${expectedLength} RGBA bytes.`);
|
|
54025
|
+
}
|
|
54026
|
+
return decoded;
|
|
54027
|
+
}
|
|
54028
|
+
|
|
53916
54029
|
const Log$4 = getLogger(exports.LoggerNames.Core);
|
|
53917
54030
|
const MIN_FILE_CHUNK_SIZE = 64;
|
|
53918
54031
|
const FILE_TRANSFER_RATE_WINDOW_MS = 1000;
|
|
@@ -54189,6 +54302,9 @@ function writeProtocolV2File(options) {
|
|
|
54189
54302
|
|
|
54190
54303
|
const WALLPAPER_DIRECTORY = 'vol1:/wallpapers';
|
|
54191
54304
|
const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
|
|
54305
|
+
const DEVICE_SETTINGS_SET_MESSAGE_TYPE = 60412;
|
|
54306
|
+
const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2 = 60805;
|
|
54307
|
+
const FILESYSTEM_DIR_MAKE_MESSAGE_TYPE = 60809;
|
|
54192
54308
|
function normalizeFileName(fileName, data) {
|
|
54193
54309
|
if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
|
|
54194
54310
|
throw invalidParameter$1('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
|
|
@@ -54207,26 +54323,40 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
54207
54323
|
return ['V2'];
|
|
54208
54324
|
}
|
|
54209
54325
|
init() {
|
|
54210
|
-
const {
|
|
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
|
-
}
|
|
54326
|
+
const { jpegBase64, fileName, chunkSize } = this.payload;
|
|
54217
54327
|
if (chunkSize !== undefined && (!Number.isInteger(chunkSize) || chunkSize <= 0)) {
|
|
54218
54328
|
throw invalidParameter$1('Parameter [chunkSize] must be a positive integer.');
|
|
54219
54329
|
}
|
|
54220
|
-
const
|
|
54221
|
-
|
|
54222
|
-
:
|
|
54223
|
-
|
|
54330
|
+
const decoded = decodeJpegBase64ToRgba({
|
|
54331
|
+
jpegBase64,
|
|
54332
|
+
parameterName: 'jpegBase64',
|
|
54333
|
+
expectedWidth: PRO2_WALLPAPER_WIDTH,
|
|
54334
|
+
expectedHeight: PRO2_WALLPAPER_HEIGHT,
|
|
54335
|
+
});
|
|
54336
|
+
this.encoded = encodePro2Wallpaper({
|
|
54337
|
+
width: PRO2_WALLPAPER_WIDTH,
|
|
54338
|
+
height: PRO2_WALLPAPER_HEIGHT,
|
|
54339
|
+
rgba: decoded.data,
|
|
54340
|
+
});
|
|
54224
54341
|
this.path = `${WALLPAPER_DIRECTORY}/${normalizeFileName(fileName, this.encoded.data)}`;
|
|
54225
|
-
this.params = {
|
|
54342
|
+
this.params = { jpegBase64, fileName, chunkSize };
|
|
54226
54343
|
this.unlockPolicy = 'none';
|
|
54227
54344
|
this.skipForceUpdateCheck = true;
|
|
54228
54345
|
this.useDevicePassphraseState = false;
|
|
54229
54346
|
}
|
|
54347
|
+
assertCapabilities() {
|
|
54348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54349
|
+
const protocolInfo = yield this.device.ensureProtocolV2RuntimeContext();
|
|
54350
|
+
const requiredMessageTypes = [
|
|
54351
|
+
DEVICE_SETTINGS_SET_MESSAGE_TYPE,
|
|
54352
|
+
FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2,
|
|
54353
|
+
FILESYSTEM_DIR_MAKE_MESSAGE_TYPE,
|
|
54354
|
+
];
|
|
54355
|
+
if (requiredMessageTypes.some(messageType => !supportsProtocolV2Message(protocolInfo, messageType))) {
|
|
54356
|
+
throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
54357
|
+
}
|
|
54358
|
+
});
|
|
54359
|
+
}
|
|
54230
54360
|
ensureDirectory() {
|
|
54231
54361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54232
54362
|
if (this.directoryReady)
|
|
@@ -54276,6 +54406,7 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
54276
54406
|
const { encoded } = this;
|
|
54277
54407
|
if (!encoded)
|
|
54278
54408
|
throw invalidParameter$1('Wallpaper data has not been initialized.');
|
|
54409
|
+
yield this.assertCapabilities();
|
|
54279
54410
|
yield this.ensureDirectory();
|
|
54280
54411
|
yield this.upload();
|
|
54281
54412
|
const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
@@ -54300,7 +54431,7 @@ class DeviceUploadNft extends BaseMethod {
|
|
|
54300
54431
|
return ['V2'];
|
|
54301
54432
|
}
|
|
54302
54433
|
init() {
|
|
54303
|
-
const {
|
|
54434
|
+
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;
|
|
54304
54435
|
if (!Number.isInteger(chunkSize) ||
|
|
54305
54436
|
chunkSize < PRO2_NFT_MIN_CHUNK_SIZE ||
|
|
54306
54437
|
chunkSize > PRO2_NFT_MAX_CHUNK_SIZE) {
|
|
@@ -54312,8 +54443,51 @@ class DeviceUploadNft extends BaseMethod {
|
|
|
54312
54443
|
if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
|
|
54313
54444
|
throw invalidParameter$1('Parameter [timeoutMs] must be a positive integer.');
|
|
54314
54445
|
}
|
|
54315
|
-
|
|
54316
|
-
|
|
54446
|
+
const encodedImage = (() => {
|
|
54447
|
+
const decoded = decodeJpegBase64ToRgba({
|
|
54448
|
+
jpegBase64: imageJpegBase64,
|
|
54449
|
+
parameterName: 'imageJpegBase64',
|
|
54450
|
+
expectedWidth: PRO2_NFT_IMAGE_WIDTH,
|
|
54451
|
+
expectedHeight: PRO2_NFT_IMAGE_HEIGHT,
|
|
54452
|
+
});
|
|
54453
|
+
return encodePro2Image({
|
|
54454
|
+
width: PRO2_NFT_IMAGE_WIDTH,
|
|
54455
|
+
height: PRO2_NFT_IMAGE_HEIGHT,
|
|
54456
|
+
rgba: decoded.data,
|
|
54457
|
+
alphaMode: 'black-background',
|
|
54458
|
+
}).data;
|
|
54459
|
+
})();
|
|
54460
|
+
const encodedThumbnail = (() => {
|
|
54461
|
+
const decoded = decodeJpegBase64ToRgba({
|
|
54462
|
+
jpegBase64: thumbnailJpegBase64,
|
|
54463
|
+
parameterName: 'thumbnailJpegBase64',
|
|
54464
|
+
expectedWidth: PRO2_NFT_THUMBNAIL_WIDTH,
|
|
54465
|
+
expectedHeight: PRO2_NFT_THUMBNAIL_HEIGHT,
|
|
54466
|
+
});
|
|
54467
|
+
return encodePro2Image({
|
|
54468
|
+
width: PRO2_NFT_THUMBNAIL_WIDTH,
|
|
54469
|
+
height: PRO2_NFT_THUMBNAIL_HEIGHT,
|
|
54470
|
+
rgba: decoded.data,
|
|
54471
|
+
alphaMode: 'black-background',
|
|
54472
|
+
}).data;
|
|
54473
|
+
})();
|
|
54474
|
+
this.bundle = buildPro2NftBundleFromEncodedImages({
|
|
54475
|
+
image: encodedImage,
|
|
54476
|
+
thumbnail: encodedThumbnail,
|
|
54477
|
+
title,
|
|
54478
|
+
subtitle,
|
|
54479
|
+
timestampMs,
|
|
54480
|
+
});
|
|
54481
|
+
this.params = {
|
|
54482
|
+
imageJpegBase64,
|
|
54483
|
+
thumbnailJpegBase64,
|
|
54484
|
+
title,
|
|
54485
|
+
subtitle,
|
|
54486
|
+
timestampMs,
|
|
54487
|
+
chunkSize,
|
|
54488
|
+
paceMs,
|
|
54489
|
+
timeoutMs,
|
|
54490
|
+
};
|
|
54317
54491
|
this.unlockPolicy = 'none';
|
|
54318
54492
|
this.skipForceUpdateCheck = true;
|
|
54319
54493
|
this.useDevicePassphraseState = false;
|
|
@@ -54456,11 +54630,17 @@ class FileWrite extends BaseMethod {
|
|
|
54456
54630
|
|
|
54457
54631
|
const PORTFOLIO_PENDING_PATH = 'vol1:/portfolio/portfolio.okpkg.pending';
|
|
54458
54632
|
const PORTFOLIO_CHUNK_SIZE = 2048;
|
|
54633
|
+
const PORTFOLIO_PACKAGE_MAX_BYTES = 128 * 1024;
|
|
54459
54634
|
const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE = 60805;
|
|
54460
54635
|
const PORTFOLIO_UPDATE_MESSAGE_TYPE = 61400;
|
|
54461
54636
|
class UploadPortfolio extends FileWrite {
|
|
54462
54637
|
init() {
|
|
54463
|
-
const {
|
|
54638
|
+
const { packageBase64, timeoutMs } = this.payload;
|
|
54639
|
+
const packageBytes = decodeCanonicalBase64({
|
|
54640
|
+
value: packageBase64,
|
|
54641
|
+
parameterName: 'packageBase64',
|
|
54642
|
+
maxBytes: PORTFOLIO_PACKAGE_MAX_BYTES,
|
|
54643
|
+
});
|
|
54464
54644
|
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 });
|
|
54465
54645
|
super.init();
|
|
54466
54646
|
this.unlockPolicy = 'none';
|
|
@@ -63230,11 +63410,13 @@ class TonSignMessage extends BaseMethod {
|
|
|
63230
63410
|
super(...arguments);
|
|
63231
63411
|
this.initState = null;
|
|
63232
63412
|
this.processTxRequest = (request, data) => __awaiter(this, void 0, void 0, function* () {
|
|
63413
|
+
var _a;
|
|
63233
63414
|
if (!request.init_data_length) {
|
|
63234
63415
|
const deviceType = this.device.getCurrentDeviceType();
|
|
63235
63416
|
const hasClassic = DeviceModelToTypes.model_classic1s.includes(deviceType);
|
|
63236
|
-
const
|
|
63237
|
-
|
|
63417
|
+
const signingMessage = (_a = request.signing_message) !== null && _a !== void 0 ? _a : request.signning_message;
|
|
63418
|
+
const shouldSkipValidation = signingMessage == null;
|
|
63419
|
+
return Promise.resolve(Object.assign(Object.assign({}, request), { signing_message: signingMessage, skip_validate: hasClassic || shouldSkipValidation }));
|
|
63238
63420
|
}
|
|
63239
63421
|
const [first, rest] = cutString(data, request.init_data_length * 2);
|
|
63240
63422
|
const response = yield this.device.commands.typedCall('TonTxAck', 'TonSignedMessage', {
|
|
@@ -64739,6 +64921,10 @@ const createUiProgressMessageFilter = (intervalMs = DEFAULT_UI_PROGRESS_INTERVAL
|
|
|
64739
64921
|
};
|
|
64740
64922
|
};
|
|
64741
64923
|
|
|
64924
|
+
const isLegacyProtocolV2FirmwareRecoveryMethod = (method) => (method === null || method === void 0 ? void 0 : method.name) === 'firmwareUpdateV4' ||
|
|
64925
|
+
(method === null || method === void 0 ? void 0 : method.name) === 'checkAllFirmwareRelease' ||
|
|
64926
|
+
((method === null || method === void 0 ? void 0 : method.name) === 'getDeviceState' && method.payload.scope === 'firmware');
|
|
64927
|
+
|
|
64742
64928
|
const Log = getLogger(exports.LoggerNames.Core);
|
|
64743
64929
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
64744
64930
|
const preWarmInflight = new Map();
|
|
@@ -64753,15 +64939,9 @@ function hasDeriveCardano(method) {
|
|
|
64753
64939
|
}
|
|
64754
64940
|
return method.name.startsWith('cardano') || ((_a = method.payload) === null || _a === void 0 ? void 0 : _a.deriveCardano);
|
|
64755
64941
|
}
|
|
64756
|
-
const parseInitOptions = (method) => ({
|
|
64757
|
-
|
|
64758
|
-
|
|
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
|
-
});
|
|
64942
|
+
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)
|
|
64943
|
+
? { allowLegacyProtocolV2ProtocolInfo: true }
|
|
64944
|
+
: {})));
|
|
64765
64945
|
let _core;
|
|
64766
64946
|
let _deviceList;
|
|
64767
64947
|
let _connector;
|