@onekeyfe/hd-web-sdk 0.1.57 → 0.1.59
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/build/data/messages/messages.json +173 -0
- package/build/iframe.html +1 -1
- package/build/js/iframe.36966284354c2b9823e0.js +3 -0
- package/build/js/{iframe.d7e734522cce67a6c71c.js.LICENSE.txt → iframe.36966284354c2b9823e0.js.LICENSE.txt} +0 -0
- package/build/js/iframe.36966284354c2b9823e0.js.map +1 -0
- package/build/onekey-js-sdk.js +1061 -207
- package/build/onekey-js-sdk.js.map +1 -1
- package/build/onekey-js-sdk.min.js +1 -1
- package/build/onekey-js-sdk.min.js.map +1 -1
- package/package.json +6 -6
- package/build/js/iframe.d7e734522cce67a6c71c.js +0 -3
- package/build/js/iframe.d7e734522cce67a6c71c.js.map +0 -1
package/build/onekey-js-sdk.js
CHANGED
|
@@ -5359,10 +5359,35 @@ const inject = ({
|
|
|
5359
5359
|
deviceId,
|
|
5360
5360
|
method: 'aptosGetPublicKey'
|
|
5361
5361
|
})),
|
|
5362
|
+
aptosSignMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
5363
|
+
connectId,
|
|
5364
|
+
deviceId,
|
|
5365
|
+
method: 'aptosSignMessage'
|
|
5366
|
+
})),
|
|
5362
5367
|
aptosSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
5363
5368
|
connectId,
|
|
5364
5369
|
deviceId,
|
|
5365
5370
|
method: 'aptosSignTransaction'
|
|
5371
|
+
})),
|
|
5372
|
+
algoGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
5373
|
+
connectId,
|
|
5374
|
+
deviceId,
|
|
5375
|
+
method: 'algoGetAddress'
|
|
5376
|
+
})),
|
|
5377
|
+
algoSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
5378
|
+
connectId,
|
|
5379
|
+
deviceId,
|
|
5380
|
+
method: 'algoSignTransaction'
|
|
5381
|
+
})),
|
|
5382
|
+
cosmosGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
5383
|
+
connectId,
|
|
5384
|
+
deviceId,
|
|
5385
|
+
method: 'cosmosGetAddress'
|
|
5386
|
+
})),
|
|
5387
|
+
cosmosSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
5388
|
+
connectId,
|
|
5389
|
+
deviceId,
|
|
5390
|
+
method: 'cosmosSignTransaction'
|
|
5366
5391
|
}))
|
|
5367
5392
|
};
|
|
5368
5393
|
return api;
|
|
@@ -6177,10 +6202,66 @@ const getPassphraseState = (features, commands) => __awaiter(void 0, void 0, voi
|
|
|
6177
6202
|
const supportBatchPublicKey = features => {
|
|
6178
6203
|
if (!features) return false;
|
|
6179
6204
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
6205
|
+
const deviceType = getDeviceType(features);
|
|
6206
|
+
|
|
6207
|
+
if (deviceType === 'touch' || deviceType === 'pro') {
|
|
6208
|
+
return semver__default["default"].gte(currentVersion, '3.1.0');
|
|
6209
|
+
}
|
|
6210
|
+
|
|
6180
6211
|
return semver__default["default"].gte(currentVersion, '2.6.0');
|
|
6181
6212
|
};
|
|
6182
6213
|
|
|
6183
6214
|
var nested = {
|
|
6215
|
+
AlgorandGetAddress: {
|
|
6216
|
+
fields: {
|
|
6217
|
+
address_n: {
|
|
6218
|
+
rule: "repeated",
|
|
6219
|
+
type: "uint32",
|
|
6220
|
+
id: 1,
|
|
6221
|
+
options: {
|
|
6222
|
+
packed: false
|
|
6223
|
+
}
|
|
6224
|
+
},
|
|
6225
|
+
show_display: {
|
|
6226
|
+
type: "bool",
|
|
6227
|
+
id: 3
|
|
6228
|
+
}
|
|
6229
|
+
}
|
|
6230
|
+
},
|
|
6231
|
+
AlgorandAddress: {
|
|
6232
|
+
fields: {
|
|
6233
|
+
address: {
|
|
6234
|
+
type: "string",
|
|
6235
|
+
id: 1
|
|
6236
|
+
}
|
|
6237
|
+
}
|
|
6238
|
+
},
|
|
6239
|
+
AlgorandSignTx: {
|
|
6240
|
+
fields: {
|
|
6241
|
+
address_n: {
|
|
6242
|
+
rule: "repeated",
|
|
6243
|
+
type: "uint32",
|
|
6244
|
+
id: 1,
|
|
6245
|
+
options: {
|
|
6246
|
+
packed: false
|
|
6247
|
+
}
|
|
6248
|
+
},
|
|
6249
|
+
raw_tx: {
|
|
6250
|
+
rule: "required",
|
|
6251
|
+
type: "bytes",
|
|
6252
|
+
id: 2
|
|
6253
|
+
}
|
|
6254
|
+
}
|
|
6255
|
+
},
|
|
6256
|
+
AlgorandSignedTx: {
|
|
6257
|
+
fields: {
|
|
6258
|
+
signature: {
|
|
6259
|
+
rule: "required",
|
|
6260
|
+
type: "bytes",
|
|
6261
|
+
id: 1
|
|
6262
|
+
}
|
|
6263
|
+
}
|
|
6264
|
+
},
|
|
6184
6265
|
AptosGetAddress: {
|
|
6185
6266
|
fields: {
|
|
6186
6267
|
address_n: {
|
|
@@ -6236,6 +6317,65 @@ var nested = {
|
|
|
6236
6317
|
}
|
|
6237
6318
|
}
|
|
6238
6319
|
},
|
|
6320
|
+
AptosSignMessage: {
|
|
6321
|
+
fields: {
|
|
6322
|
+
address_n: {
|
|
6323
|
+
rule: "repeated",
|
|
6324
|
+
type: "uint32",
|
|
6325
|
+
id: 1,
|
|
6326
|
+
options: {
|
|
6327
|
+
packed: false
|
|
6328
|
+
}
|
|
6329
|
+
},
|
|
6330
|
+
payload: {
|
|
6331
|
+
rule: "required",
|
|
6332
|
+
type: "AptosMessagePayload",
|
|
6333
|
+
id: 2
|
|
6334
|
+
}
|
|
6335
|
+
},
|
|
6336
|
+
nested: {
|
|
6337
|
+
AptosMessagePayload: {
|
|
6338
|
+
fields: {
|
|
6339
|
+
address: {
|
|
6340
|
+
type: "string",
|
|
6341
|
+
id: 2
|
|
6342
|
+
},
|
|
6343
|
+
chain_id: {
|
|
6344
|
+
type: "string",
|
|
6345
|
+
id: 3
|
|
6346
|
+
},
|
|
6347
|
+
application: {
|
|
6348
|
+
type: "string",
|
|
6349
|
+
id: 4
|
|
6350
|
+
},
|
|
6351
|
+
nonce: {
|
|
6352
|
+
rule: "required",
|
|
6353
|
+
type: "string",
|
|
6354
|
+
id: 5
|
|
6355
|
+
},
|
|
6356
|
+
message: {
|
|
6357
|
+
rule: "required",
|
|
6358
|
+
type: "string",
|
|
6359
|
+
id: 6
|
|
6360
|
+
}
|
|
6361
|
+
}
|
|
6362
|
+
}
|
|
6363
|
+
}
|
|
6364
|
+
},
|
|
6365
|
+
AptosMessageSignature: {
|
|
6366
|
+
fields: {
|
|
6367
|
+
signature: {
|
|
6368
|
+
rule: "required",
|
|
6369
|
+
type: "bytes",
|
|
6370
|
+
id: 1
|
|
6371
|
+
},
|
|
6372
|
+
address: {
|
|
6373
|
+
rule: "required",
|
|
6374
|
+
type: "string",
|
|
6375
|
+
id: 2
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
},
|
|
6239
6379
|
BinanceGetAddress: {
|
|
6240
6380
|
fields: {
|
|
6241
6381
|
address_n: {
|
|
@@ -9008,6 +9148,60 @@ var nested = {
|
|
|
9008
9148
|
}
|
|
9009
9149
|
}
|
|
9010
9150
|
},
|
|
9151
|
+
CosmosGetAddress: {
|
|
9152
|
+
fields: {
|
|
9153
|
+
address_n: {
|
|
9154
|
+
rule: "repeated",
|
|
9155
|
+
type: "uint32",
|
|
9156
|
+
id: 1,
|
|
9157
|
+
options: {
|
|
9158
|
+
packed: false
|
|
9159
|
+
}
|
|
9160
|
+
},
|
|
9161
|
+
hrp: {
|
|
9162
|
+
type: "string",
|
|
9163
|
+
id: 2
|
|
9164
|
+
},
|
|
9165
|
+
show_display: {
|
|
9166
|
+
type: "bool",
|
|
9167
|
+
id: 3
|
|
9168
|
+
}
|
|
9169
|
+
}
|
|
9170
|
+
},
|
|
9171
|
+
CosmosAddress: {
|
|
9172
|
+
fields: {
|
|
9173
|
+
address: {
|
|
9174
|
+
type: "string",
|
|
9175
|
+
id: 1
|
|
9176
|
+
}
|
|
9177
|
+
}
|
|
9178
|
+
},
|
|
9179
|
+
CosmosSignTx: {
|
|
9180
|
+
fields: {
|
|
9181
|
+
address_n: {
|
|
9182
|
+
rule: "repeated",
|
|
9183
|
+
type: "uint32",
|
|
9184
|
+
id: 1,
|
|
9185
|
+
options: {
|
|
9186
|
+
packed: false
|
|
9187
|
+
}
|
|
9188
|
+
},
|
|
9189
|
+
raw_tx: {
|
|
9190
|
+
rule: "required",
|
|
9191
|
+
type: "bytes",
|
|
9192
|
+
id: 2
|
|
9193
|
+
}
|
|
9194
|
+
}
|
|
9195
|
+
},
|
|
9196
|
+
CosmosSignedTx: {
|
|
9197
|
+
fields: {
|
|
9198
|
+
signature: {
|
|
9199
|
+
rule: "required",
|
|
9200
|
+
type: "bytes",
|
|
9201
|
+
id: 1
|
|
9202
|
+
}
|
|
9203
|
+
}
|
|
9204
|
+
},
|
|
9011
9205
|
CipherKeyValue: {
|
|
9012
9206
|
fields: {
|
|
9013
9207
|
address_n: {
|
|
@@ -14689,6 +14883,8 @@ var nested = {
|
|
|
14689
14883
|
MessageType_AptosAddress: 10601,
|
|
14690
14884
|
MessageType_AptosSignTx: 10602,
|
|
14691
14885
|
MessageType_AptosSignedTx: 10603,
|
|
14886
|
+
MessageType_AptosSignMessage: 10604,
|
|
14887
|
+
MessageType_AptosMessageSignature: 10605,
|
|
14692
14888
|
MessageType_WebAuthnListResidentCredentials: 800,
|
|
14693
14889
|
MessageType_WebAuthnCredentials: 801,
|
|
14694
14890
|
MessageType_WebAuthnAddResidentCredential: 802,
|
|
@@ -14729,6 +14925,14 @@ var nested = {
|
|
|
14729
14925
|
MessageType_NearAddress: 10702,
|
|
14730
14926
|
MessageType_NearSignTx: 10703,
|
|
14731
14927
|
MessageType_NearSignedTx: 10704,
|
|
14928
|
+
MessageType_CosmosGetAddress: 10800,
|
|
14929
|
+
MessageType_CosmosAddress: 10801,
|
|
14930
|
+
MessageType_CosmosSignTx: 10802,
|
|
14931
|
+
MessageType_CosmosSignedTx: 10803,
|
|
14932
|
+
MessageType_AlgorandGetAddress: 10900,
|
|
14933
|
+
MessageType_AlgorandAddress: 10901,
|
|
14934
|
+
MessageType_AlgorandSignTx: 10902,
|
|
14935
|
+
MessageType_AlgorandSignedTx: 10903,
|
|
14732
14936
|
MessageType_DeviceBackToBoot: 903,
|
|
14733
14937
|
MessageType_DeviceInfoSettings: 10001,
|
|
14734
14938
|
MessageType_GetDeviceInfo: 10002,
|
|
@@ -15863,7 +16067,7 @@ DataManager.getFirmwareStatus = features => {
|
|
|
15863
16067
|
return getReleaseStatus(targetDeviceConfigList, currentVersion);
|
|
15864
16068
|
};
|
|
15865
16069
|
|
|
15866
|
-
DataManager.getSysResourcesLatestRelease = features => {
|
|
16070
|
+
DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
|
|
15867
16071
|
var _b, _c, _d;
|
|
15868
16072
|
|
|
15869
16073
|
const deviceType = getDeviceType(features);
|
|
@@ -15871,7 +16075,7 @@ DataManager.getSysResourcesLatestRelease = features => {
|
|
|
15871
16075
|
if (deviceType !== 'pro' && deviceType !== 'touch') return undefined;
|
|
15872
16076
|
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.firmware) !== null && _c !== void 0 ? _c : [];
|
|
15873
16077
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
15874
|
-
const targetDeviceConfig = targetDeviceConfigList.filter(item => semver__default["default"].gt(item.version.join('.'), currentVersion) && !!item.resource);
|
|
16078
|
+
const targetDeviceConfig = targetDeviceConfigList.filter(item => forcedUpdateRes ? !!item.resource : semver__default["default"].gt(item.version.join('.'), currentVersion) && !!item.resource);
|
|
15875
16079
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.resource;
|
|
15876
16080
|
};
|
|
15877
16081
|
|
|
@@ -16540,7 +16744,13 @@ class DeviceCommands {
|
|
|
16540
16744
|
}
|
|
16541
16745
|
|
|
16542
16746
|
_filterCommonTypes(res, callType) {
|
|
16543
|
-
|
|
16747
|
+
try {
|
|
16748
|
+
if (DataManager.getSettings('env') === 'react-native') {
|
|
16749
|
+
Log$6.debug('_filterCommonTypes: ', JSON.stringify(res));
|
|
16750
|
+
} else {
|
|
16751
|
+
Log$6.debug('_filterCommonTypes: ', res);
|
|
16752
|
+
}
|
|
16753
|
+
} catch (error) {}
|
|
16544
16754
|
|
|
16545
16755
|
if (res.type === 'Failure') {
|
|
16546
16756
|
const {
|
|
@@ -18257,7 +18467,7 @@ const getInfo = ({
|
|
|
18257
18467
|
return findLatestRelease(releaseInfo);
|
|
18258
18468
|
};
|
|
18259
18469
|
|
|
18260
|
-
|
|
18470
|
+
getLogger(exports.d0.Device);
|
|
18261
18471
|
|
|
18262
18472
|
const postConfirmationMessage = device => {
|
|
18263
18473
|
var _a;
|
|
@@ -18394,12 +18604,7 @@ const updateResources = (typedCall, postMessage, device, source) => __awaiter(vo
|
|
|
18394
18604
|
|
|
18395
18605
|
if (!file.dir && fileName.indexOf('__MACOSX') === -1 && name) {
|
|
18396
18606
|
const data = yield file.async('arraybuffer');
|
|
18397
|
-
|
|
18398
|
-
try {
|
|
18399
|
-
yield updateResource(typedCall, name, data);
|
|
18400
|
-
} catch (error) {
|
|
18401
|
-
Log$3.error(error);
|
|
18402
|
-
}
|
|
18607
|
+
yield updateResource(typedCall, name, data);
|
|
18403
18608
|
}
|
|
18404
18609
|
|
|
18405
18610
|
progress += stepProgress;
|
|
@@ -18485,6 +18690,8 @@ class FirmwareUpdate$1 extends BaseMethod {
|
|
|
18485
18690
|
|
|
18486
18691
|
}
|
|
18487
18692
|
|
|
18693
|
+
const Log$3 = getLogger(exports.d0.Method);
|
|
18694
|
+
|
|
18488
18695
|
class FirmwareUpdate extends BaseMethod {
|
|
18489
18696
|
constructor() {
|
|
18490
18697
|
super(...arguments);
|
|
@@ -18513,6 +18720,9 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
18513
18720
|
}, {
|
|
18514
18721
|
name: 'binary',
|
|
18515
18722
|
type: 'buffer'
|
|
18723
|
+
}, {
|
|
18724
|
+
name: 'forcedUpdateRes',
|
|
18725
|
+
type: 'boolean'
|
|
18516
18726
|
}]);
|
|
18517
18727
|
|
|
18518
18728
|
if (!payload.updateType) {
|
|
@@ -18520,7 +18730,8 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
18520
18730
|
}
|
|
18521
18731
|
|
|
18522
18732
|
this.params = {
|
|
18523
|
-
updateType: payload.updateType
|
|
18733
|
+
updateType: payload.updateType,
|
|
18734
|
+
forcedUpdateRes: payload.forcedUpdateRes
|
|
18524
18735
|
};
|
|
18525
18736
|
|
|
18526
18737
|
if ('version' in payload) {
|
|
@@ -18536,25 +18747,37 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
18536
18747
|
}
|
|
18537
18748
|
}
|
|
18538
18749
|
|
|
18539
|
-
checkDeviceToBootloader() {
|
|
18750
|
+
checkDeviceToBootloader(connectId) {
|
|
18540
18751
|
this.checkPromise = hdShared.createDeferred();
|
|
18752
|
+
const env = DataManager.getSettings('env');
|
|
18753
|
+
const isBleReconnect = connectId && env === 'react-native';
|
|
18754
|
+
Log$3.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
18541
18755
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
18542
|
-
var _a, _b, _c, _d;
|
|
18756
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
18543
18757
|
|
|
18544
|
-
|
|
18545
|
-
|
|
18546
|
-
|
|
18547
|
-
deviceList
|
|
18548
|
-
} = yield DevicePool.getDevices(devicesDescriptor, this.connectId);
|
|
18549
|
-
console.log('device list: ', deviceList);
|
|
18758
|
+
if (isBleReconnect) {
|
|
18759
|
+
yield this.device.acquire();
|
|
18760
|
+
yield this.device.initialize();
|
|
18550
18761
|
|
|
18551
|
-
|
|
18552
|
-
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
|
|
18762
|
+
if ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.bootloader_mode) {
|
|
18763
|
+
clearInterval(intervalTimer);
|
|
18764
|
+
(_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.resolve(true);
|
|
18765
|
+
}
|
|
18766
|
+
} else {
|
|
18767
|
+
const deviceDiff = yield (_c = this.device.deviceConnector) === null || _c === void 0 ? void 0 : _c.enumerate();
|
|
18768
|
+
const devicesDescriptor = (_d = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _d !== void 0 ? _d : [];
|
|
18769
|
+
const {
|
|
18770
|
+
deviceList
|
|
18771
|
+
} = yield DevicePool.getDevices(devicesDescriptor, connectId);
|
|
18772
|
+
|
|
18773
|
+
if (deviceList.length === 1 && ((_f = (_e = deviceList[0]) === null || _e === void 0 ? void 0 : _e.features) === null || _f === void 0 ? void 0 : _f.bootloader_mode)) {
|
|
18774
|
+
this.device.updateFromCache(deviceList[0]);
|
|
18775
|
+
this.device.commands.disposed = false;
|
|
18776
|
+
clearInterval(intervalTimer);
|
|
18777
|
+
(_g = this.checkPromise) === null || _g === void 0 ? void 0 : _g.resolve(true);
|
|
18778
|
+
}
|
|
18556
18779
|
}
|
|
18557
|
-
}), 2000);
|
|
18780
|
+
}), isBleReconnect ? 3000 : 2000);
|
|
18558
18781
|
setTimeout(() => {
|
|
18559
18782
|
if (this.checkPromise) {
|
|
18560
18783
|
clearInterval(intervalTimer);
|
|
@@ -18601,7 +18824,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
18601
18824
|
|
|
18602
18825
|
if (features && this.isSupportResourceUpdate(features, params.updateType)) {
|
|
18603
18826
|
this.postTipMessage('CheckLatestUiResource');
|
|
18604
|
-
const resourceUrl = DataManager.getSysResourcesLatestRelease(features);
|
|
18827
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease(features, params.forcedUpdateRes);
|
|
18605
18828
|
|
|
18606
18829
|
if (resourceUrl) {
|
|
18607
18830
|
this.postTipMessage('DownloadLatestUiResource');
|
|
@@ -18618,7 +18841,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
18618
18841
|
this.postTipMessage('AutoRebootToBootloader');
|
|
18619
18842
|
yield commands.typedCall('DeviceBackToBoot', 'Success');
|
|
18620
18843
|
this.postTipMessage('GoToBootloaderSuccess');
|
|
18621
|
-
this.checkDeviceToBootloader();
|
|
18844
|
+
this.checkDeviceToBootloader(this.payload.connectId);
|
|
18622
18845
|
|
|
18623
18846
|
if (deviceType === 'classic') {
|
|
18624
18847
|
DevicePool.clearDeviceCache(uuid);
|
|
@@ -22226,21 +22449,304 @@ class NearSignTransaction extends BaseMethod {
|
|
|
22226
22449
|
getVersionRange() {
|
|
22227
22450
|
return {
|
|
22228
22451
|
model_mini: {
|
|
22229
|
-
min: '2.5.0'
|
|
22452
|
+
min: '2.5.0'
|
|
22453
|
+
}
|
|
22454
|
+
};
|
|
22455
|
+
}
|
|
22456
|
+
|
|
22457
|
+
run() {
|
|
22458
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22459
|
+
const res = yield this.device.commands.typedCall('NearSignTx', 'NearSignedTx', Object.assign({}, this.params));
|
|
22460
|
+
return Promise.resolve(res.message);
|
|
22461
|
+
});
|
|
22462
|
+
}
|
|
22463
|
+
|
|
22464
|
+
}
|
|
22465
|
+
|
|
22466
|
+
class AptosGetAddress extends BaseMethod {
|
|
22467
|
+
constructor() {
|
|
22468
|
+
super(...arguments);
|
|
22469
|
+
this.hasBundle = false;
|
|
22470
|
+
}
|
|
22471
|
+
|
|
22472
|
+
init() {
|
|
22473
|
+
var _a;
|
|
22474
|
+
|
|
22475
|
+
this.checkDeviceId = true;
|
|
22476
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
22477
|
+
this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
|
|
22478
|
+
const payload = this.hasBundle ? this.payload : {
|
|
22479
|
+
bundle: [this.payload]
|
|
22480
|
+
};
|
|
22481
|
+
validateParams(payload, [{
|
|
22482
|
+
name: 'bundle',
|
|
22483
|
+
type: 'array'
|
|
22484
|
+
}]);
|
|
22485
|
+
this.params = [];
|
|
22486
|
+
payload.bundle.forEach(batch => {
|
|
22487
|
+
var _a;
|
|
22488
|
+
|
|
22489
|
+
const addressN = validatePath(batch.path, 3);
|
|
22490
|
+
validateParams(batch, [{
|
|
22491
|
+
name: 'path',
|
|
22492
|
+
required: true
|
|
22493
|
+
}, {
|
|
22494
|
+
name: 'showOnOneKey',
|
|
22495
|
+
type: 'boolean'
|
|
22496
|
+
}]);
|
|
22497
|
+
const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
|
|
22498
|
+
this.params.push({
|
|
22499
|
+
address_n: addressN,
|
|
22500
|
+
show_display: showOnOneKey
|
|
22501
|
+
});
|
|
22502
|
+
});
|
|
22503
|
+
}
|
|
22504
|
+
|
|
22505
|
+
publicKeyToAddress(publicKey) {
|
|
22506
|
+
const hash = sha3.sha3_256.create();
|
|
22507
|
+
hash.update(hexToBytes(publicKey));
|
|
22508
|
+
hash.update('\x00');
|
|
22509
|
+
return `0x${utils.bytesToHex(hash.digest())}`;
|
|
22510
|
+
}
|
|
22511
|
+
|
|
22512
|
+
getVersionRange() {
|
|
22513
|
+
return {
|
|
22514
|
+
model_mini: {
|
|
22515
|
+
min: '2.6.0'
|
|
22516
|
+
}
|
|
22517
|
+
};
|
|
22518
|
+
}
|
|
22519
|
+
|
|
22520
|
+
run() {
|
|
22521
|
+
var _a;
|
|
22522
|
+
|
|
22523
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22524
|
+
if (this.hasBundle && supportBatchPublicKey((_a = this.device) === null || _a === void 0 ? void 0 : _a.features)) {
|
|
22525
|
+
const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
22526
|
+
paths: this.params,
|
|
22527
|
+
ecdsa_curve_name: 'ed25519'
|
|
22528
|
+
});
|
|
22529
|
+
const result = res.message.public_keys.map((publicKey, index) => ({
|
|
22530
|
+
path: serializedPath(this.params[index].address_n),
|
|
22531
|
+
publicKey,
|
|
22532
|
+
address: this.publicKeyToAddress(publicKey)
|
|
22533
|
+
}));
|
|
22534
|
+
return Promise.resolve(result);
|
|
22535
|
+
}
|
|
22536
|
+
|
|
22537
|
+
const responses = [];
|
|
22538
|
+
|
|
22539
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
22540
|
+
const param = this.params[i];
|
|
22541
|
+
const res = yield this.device.commands.typedCall('AptosGetAddress', 'AptosAddress', Object.assign({}, param));
|
|
22542
|
+
const {
|
|
22543
|
+
address
|
|
22544
|
+
} = res.message;
|
|
22545
|
+
responses.push({
|
|
22546
|
+
path: serializedPath(param.address_n),
|
|
22547
|
+
address: address === null || address === void 0 ? void 0 : address.toLowerCase()
|
|
22548
|
+
});
|
|
22549
|
+
}
|
|
22550
|
+
|
|
22551
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
22552
|
+
});
|
|
22553
|
+
}
|
|
22554
|
+
|
|
22555
|
+
}
|
|
22556
|
+
|
|
22557
|
+
class AptosGetPublicKey extends BaseMethod {
|
|
22558
|
+
constructor() {
|
|
22559
|
+
super(...arguments);
|
|
22560
|
+
this.hasBundle = false;
|
|
22561
|
+
}
|
|
22562
|
+
|
|
22563
|
+
init() {
|
|
22564
|
+
var _a;
|
|
22565
|
+
|
|
22566
|
+
this.checkDeviceId = true;
|
|
22567
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
22568
|
+
this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
|
|
22569
|
+
const payload = this.hasBundle ? this.payload : {
|
|
22570
|
+
bundle: [this.payload]
|
|
22571
|
+
};
|
|
22572
|
+
validateParams(payload, [{
|
|
22573
|
+
name: 'bundle',
|
|
22574
|
+
type: 'array'
|
|
22575
|
+
}]);
|
|
22576
|
+
this.params = [];
|
|
22577
|
+
payload.bundle.forEach(batch => {
|
|
22578
|
+
var _a;
|
|
22579
|
+
|
|
22580
|
+
const addressN = validatePath(batch.path, 3);
|
|
22581
|
+
validateParams(batch, [{
|
|
22582
|
+
name: 'path',
|
|
22583
|
+
required: true
|
|
22584
|
+
}, {
|
|
22585
|
+
name: 'showOnOneKey',
|
|
22586
|
+
type: 'boolean'
|
|
22587
|
+
}]);
|
|
22588
|
+
const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
|
|
22589
|
+
this.params.push({
|
|
22590
|
+
address_n: addressN,
|
|
22591
|
+
show_display: showOnOneKey
|
|
22592
|
+
});
|
|
22593
|
+
});
|
|
22594
|
+
}
|
|
22595
|
+
|
|
22596
|
+
getVersionRange() {
|
|
22597
|
+
return {
|
|
22598
|
+
model_mini: {
|
|
22599
|
+
min: '2.6.0'
|
|
22600
|
+
}
|
|
22601
|
+
};
|
|
22602
|
+
}
|
|
22603
|
+
|
|
22604
|
+
run() {
|
|
22605
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22606
|
+
const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
22607
|
+
paths: this.params,
|
|
22608
|
+
ecdsa_curve_name: 'ed25519'
|
|
22609
|
+
});
|
|
22610
|
+
const responses = res.message.public_keys.map((publicKey, index) => ({
|
|
22611
|
+
path: serializedPath(this.params[index].address_n),
|
|
22612
|
+
publicKey
|
|
22613
|
+
}));
|
|
22614
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
22615
|
+
});
|
|
22616
|
+
}
|
|
22617
|
+
|
|
22618
|
+
}
|
|
22619
|
+
|
|
22620
|
+
class AptosSignTransaction extends BaseMethod {
|
|
22621
|
+
init() {
|
|
22622
|
+
this.checkDeviceId = true;
|
|
22623
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
22624
|
+
validateParams(this.payload, [{
|
|
22625
|
+
name: 'path',
|
|
22626
|
+
required: true
|
|
22627
|
+
}, {
|
|
22628
|
+
name: 'rawTx',
|
|
22629
|
+
type: 'hexString',
|
|
22630
|
+
required: true
|
|
22631
|
+
}]);
|
|
22632
|
+
const {
|
|
22633
|
+
path,
|
|
22634
|
+
rawTx
|
|
22635
|
+
} = this.payload;
|
|
22636
|
+
const addressN = validatePath(path, 3);
|
|
22637
|
+
this.params = {
|
|
22638
|
+
address_n: addressN,
|
|
22639
|
+
raw_tx: formatAnyHex(rawTx)
|
|
22640
|
+
};
|
|
22641
|
+
}
|
|
22642
|
+
|
|
22643
|
+
getVersionRange() {
|
|
22644
|
+
return {
|
|
22645
|
+
model_mini: {
|
|
22646
|
+
min: '2.6.0'
|
|
22230
22647
|
}
|
|
22231
22648
|
};
|
|
22232
22649
|
}
|
|
22233
22650
|
|
|
22234
22651
|
run() {
|
|
22235
22652
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22236
|
-
const res = yield this.device.commands.typedCall('
|
|
22653
|
+
const res = yield this.device.commands.typedCall('AptosSignTx', 'AptosSignedTx', Object.assign({}, this.params));
|
|
22237
22654
|
return Promise.resolve(res.message);
|
|
22238
22655
|
});
|
|
22239
22656
|
}
|
|
22240
22657
|
|
|
22241
22658
|
}
|
|
22242
22659
|
|
|
22243
|
-
class
|
|
22660
|
+
class AptosSignMessage extends BaseMethod {
|
|
22661
|
+
init() {
|
|
22662
|
+
this.checkDeviceId = true;
|
|
22663
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
22664
|
+
validateParams(this.payload, [{
|
|
22665
|
+
name: 'path',
|
|
22666
|
+
required: true
|
|
22667
|
+
}, {
|
|
22668
|
+
name: 'payload',
|
|
22669
|
+
type: 'object',
|
|
22670
|
+
required: true
|
|
22671
|
+
}]);
|
|
22672
|
+
const {
|
|
22673
|
+
path,
|
|
22674
|
+
payload
|
|
22675
|
+
} = this.payload;
|
|
22676
|
+
const addressN = validatePath(path, 3);
|
|
22677
|
+
validateParams(payload, [{
|
|
22678
|
+
name: 'address',
|
|
22679
|
+
type: 'string'
|
|
22680
|
+
}, {
|
|
22681
|
+
name: 'chainId',
|
|
22682
|
+
type: 'string'
|
|
22683
|
+
}, {
|
|
22684
|
+
name: 'application',
|
|
22685
|
+
type: 'string'
|
|
22686
|
+
}, {
|
|
22687
|
+
name: 'nonce',
|
|
22688
|
+
type: 'string',
|
|
22689
|
+
required: true
|
|
22690
|
+
}, {
|
|
22691
|
+
name: 'message',
|
|
22692
|
+
type: 'string',
|
|
22693
|
+
required: true
|
|
22694
|
+
}]);
|
|
22695
|
+
this.params = {
|
|
22696
|
+
address_n: addressN,
|
|
22697
|
+
payload: {
|
|
22698
|
+
address: payload.address,
|
|
22699
|
+
chain_id: payload.chainId,
|
|
22700
|
+
application: payload.application,
|
|
22701
|
+
nonce: payload.nonce,
|
|
22702
|
+
message: payload.message
|
|
22703
|
+
}
|
|
22704
|
+
};
|
|
22705
|
+
}
|
|
22706
|
+
|
|
22707
|
+
getVersionRange() {
|
|
22708
|
+
return {
|
|
22709
|
+
model_mini: {
|
|
22710
|
+
min: '2.6.0'
|
|
22711
|
+
}
|
|
22712
|
+
};
|
|
22713
|
+
}
|
|
22714
|
+
|
|
22715
|
+
run() {
|
|
22716
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22717
|
+
let fullMessage = 'APTOS\n';
|
|
22718
|
+
|
|
22719
|
+
if (this.params.payload.address) {
|
|
22720
|
+
fullMessage += `address: ${this.params.payload.address}\n`;
|
|
22721
|
+
}
|
|
22722
|
+
|
|
22723
|
+
if (this.params.payload.application) {
|
|
22724
|
+
fullMessage += `application: ${this.params.payload.application}\n`;
|
|
22725
|
+
}
|
|
22726
|
+
|
|
22727
|
+
if (this.params.payload.chain_id) {
|
|
22728
|
+
fullMessage += `chainId: ${this.params.payload.chain_id}\n`;
|
|
22729
|
+
}
|
|
22730
|
+
|
|
22731
|
+
fullMessage += `message: ${this.params.payload.message}\n`;
|
|
22732
|
+
fullMessage += `nonce: ${this.params.payload.nonce}`;
|
|
22733
|
+
const res = yield this.device.commands.typedCall('AptosSignMessage', 'AptosMessageSignature', Object.assign({}, this.params));
|
|
22734
|
+
const {
|
|
22735
|
+
address,
|
|
22736
|
+
signature
|
|
22737
|
+
} = res.message;
|
|
22738
|
+
return Promise.resolve({
|
|
22739
|
+
path: serializedPath(this.params.address_n),
|
|
22740
|
+
address,
|
|
22741
|
+
signature,
|
|
22742
|
+
fullMessage
|
|
22743
|
+
});
|
|
22744
|
+
});
|
|
22745
|
+
}
|
|
22746
|
+
|
|
22747
|
+
}
|
|
22748
|
+
|
|
22749
|
+
class AlgoGetAddress extends BaseMethod {
|
|
22244
22750
|
constructor() {
|
|
22245
22751
|
super(...arguments);
|
|
22246
22752
|
this.hasBundle = false;
|
|
@@ -22250,7 +22756,7 @@ class AptosGetAddress extends BaseMethod {
|
|
|
22250
22756
|
var _a;
|
|
22251
22757
|
|
|
22252
22758
|
this.checkDeviceId = true;
|
|
22253
|
-
this.allowDeviceMode = [...this.allowDeviceMode
|
|
22759
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
22254
22760
|
this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
|
|
22255
22761
|
const payload = this.hasBundle ? this.payload : {
|
|
22256
22762
|
bundle: [this.payload]
|
|
@@ -22279,13 +22785,6 @@ class AptosGetAddress extends BaseMethod {
|
|
|
22279
22785
|
});
|
|
22280
22786
|
}
|
|
22281
22787
|
|
|
22282
|
-
publicKeyToAddress(publicKey) {
|
|
22283
|
-
const hash = sha3.sha3_256.create();
|
|
22284
|
-
hash.update(hexToBytes(publicKey));
|
|
22285
|
-
hash.update('\x00');
|
|
22286
|
-
return `0x${utils.bytesToHex(hash.digest())}`;
|
|
22287
|
-
}
|
|
22288
|
-
|
|
22289
22788
|
getVersionRange() {
|
|
22290
22789
|
return {
|
|
22291
22790
|
model_mini: {
|
|
@@ -22295,33 +22794,18 @@ class AptosGetAddress extends BaseMethod {
|
|
|
22295
22794
|
}
|
|
22296
22795
|
|
|
22297
22796
|
run() {
|
|
22298
|
-
var _a;
|
|
22299
|
-
|
|
22300
22797
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22301
|
-
if (this.hasBundle && supportBatchPublicKey((_a = this.device) === null || _a === void 0 ? void 0 : _a.features)) {
|
|
22302
|
-
const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
22303
|
-
paths: this.params,
|
|
22304
|
-
ecdsa_curve_name: 'ed25519'
|
|
22305
|
-
});
|
|
22306
|
-
const result = res.message.public_keys.map((publicKey, index) => ({
|
|
22307
|
-
path: serializedPath(this.params[index].address_n),
|
|
22308
|
-
publicKey,
|
|
22309
|
-
address: this.publicKeyToAddress(publicKey)
|
|
22310
|
-
}));
|
|
22311
|
-
return Promise.resolve(result);
|
|
22312
|
-
}
|
|
22313
|
-
|
|
22314
22798
|
const responses = [];
|
|
22315
22799
|
|
|
22316
22800
|
for (let i = 0; i < this.params.length; i++) {
|
|
22317
22801
|
const param = this.params[i];
|
|
22318
|
-
const res = yield this.device.commands.typedCall('
|
|
22802
|
+
const res = yield this.device.commands.typedCall('AlgorandGetAddress', 'AlgorandAddress', Object.assign({}, param));
|
|
22319
22803
|
const {
|
|
22320
22804
|
address
|
|
22321
22805
|
} = res.message;
|
|
22322
22806
|
responses.push({
|
|
22323
22807
|
path: serializedPath(param.address_n),
|
|
22324
|
-
address
|
|
22808
|
+
address
|
|
22325
22809
|
});
|
|
22326
22810
|
}
|
|
22327
22811
|
|
|
@@ -22331,7 +22815,58 @@ class AptosGetAddress extends BaseMethod {
|
|
|
22331
22815
|
|
|
22332
22816
|
}
|
|
22333
22817
|
|
|
22334
|
-
class
|
|
22818
|
+
class AlgoSignTransaction extends BaseMethod {
|
|
22819
|
+
constructor() {
|
|
22820
|
+
super(...arguments);
|
|
22821
|
+
this.hasBundle = false;
|
|
22822
|
+
}
|
|
22823
|
+
|
|
22824
|
+
init() {
|
|
22825
|
+
this.checkDeviceId = true;
|
|
22826
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
22827
|
+
validateParams(this.payload, [{
|
|
22828
|
+
name: 'path',
|
|
22829
|
+
required: true
|
|
22830
|
+
}, {
|
|
22831
|
+
name: 'rawTx',
|
|
22832
|
+
type: 'hexString',
|
|
22833
|
+
required: true
|
|
22834
|
+
}]);
|
|
22835
|
+
const {
|
|
22836
|
+
path,
|
|
22837
|
+
rawTx
|
|
22838
|
+
} = this.payload;
|
|
22839
|
+
const addressN = validatePath(path, 3);
|
|
22840
|
+
this.params = {
|
|
22841
|
+
address_n: addressN,
|
|
22842
|
+
raw_tx: formatAnyHex(rawTx)
|
|
22843
|
+
};
|
|
22844
|
+
}
|
|
22845
|
+
|
|
22846
|
+
getVersionRange() {
|
|
22847
|
+
return {
|
|
22848
|
+
model_mini: {
|
|
22849
|
+
min: '2.6.0'
|
|
22850
|
+
}
|
|
22851
|
+
};
|
|
22852
|
+
}
|
|
22853
|
+
|
|
22854
|
+
run() {
|
|
22855
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22856
|
+
const res = yield this.device.commands.typedCall('AlgorandSignTx', 'AlgorandSignedTx', Object.assign({}, this.params));
|
|
22857
|
+
const {
|
|
22858
|
+
signature
|
|
22859
|
+
} = res.message;
|
|
22860
|
+
return {
|
|
22861
|
+
path: serializedPath(this.params.address_n),
|
|
22862
|
+
signature
|
|
22863
|
+
};
|
|
22864
|
+
});
|
|
22865
|
+
}
|
|
22866
|
+
|
|
22867
|
+
}
|
|
22868
|
+
|
|
22869
|
+
class CosmosGetAddress extends BaseMethod {
|
|
22335
22870
|
constructor() {
|
|
22336
22871
|
super(...arguments);
|
|
22337
22872
|
this.hasBundle = false;
|
|
@@ -22341,7 +22876,7 @@ class AptosGetPublicKey extends BaseMethod {
|
|
|
22341
22876
|
var _a;
|
|
22342
22877
|
|
|
22343
22878
|
this.checkDeviceId = true;
|
|
22344
|
-
this.allowDeviceMode = [...this.allowDeviceMode
|
|
22879
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
22345
22880
|
this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
|
|
22346
22881
|
const payload = this.hasBundle ? this.payload : {
|
|
22347
22882
|
bundle: [this.payload]
|
|
@@ -22380,24 +22915,35 @@ class AptosGetPublicKey extends BaseMethod {
|
|
|
22380
22915
|
|
|
22381
22916
|
run() {
|
|
22382
22917
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22383
|
-
const
|
|
22384
|
-
|
|
22385
|
-
|
|
22386
|
-
|
|
22387
|
-
|
|
22388
|
-
|
|
22389
|
-
|
|
22390
|
-
|
|
22918
|
+
const responses = [];
|
|
22919
|
+
|
|
22920
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
22921
|
+
const param = this.params[i];
|
|
22922
|
+
const res = yield this.device.commands.typedCall('CosmosGetAddress', 'CosmosAddress', Object.assign({}, param));
|
|
22923
|
+
const {
|
|
22924
|
+
address
|
|
22925
|
+
} = res.message;
|
|
22926
|
+
responses.push({
|
|
22927
|
+
path: serializedPath(param.address_n),
|
|
22928
|
+
address
|
|
22929
|
+
});
|
|
22930
|
+
}
|
|
22931
|
+
|
|
22391
22932
|
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
22392
22933
|
});
|
|
22393
22934
|
}
|
|
22394
22935
|
|
|
22395
22936
|
}
|
|
22396
22937
|
|
|
22397
|
-
class
|
|
22938
|
+
class CosmosSignTransaction extends BaseMethod {
|
|
22939
|
+
constructor() {
|
|
22940
|
+
super(...arguments);
|
|
22941
|
+
this.hasBundle = false;
|
|
22942
|
+
}
|
|
22943
|
+
|
|
22398
22944
|
init() {
|
|
22399
22945
|
this.checkDeviceId = true;
|
|
22400
|
-
this.allowDeviceMode = [...this.allowDeviceMode
|
|
22946
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
22401
22947
|
validateParams(this.payload, [{
|
|
22402
22948
|
name: 'path',
|
|
22403
22949
|
required: true
|
|
@@ -22427,8 +22973,14 @@ class AptosSignTransaction extends BaseMethod {
|
|
|
22427
22973
|
|
|
22428
22974
|
run() {
|
|
22429
22975
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22430
|
-
const res = yield this.device.commands.typedCall('
|
|
22431
|
-
|
|
22976
|
+
const res = yield this.device.commands.typedCall('CosmosSignTx', 'CosmosSignedTx', Object.assign({}, this.params));
|
|
22977
|
+
const {
|
|
22978
|
+
signature
|
|
22979
|
+
} = res.message;
|
|
22980
|
+
return {
|
|
22981
|
+
path: serializedPath(this.params.address_n),
|
|
22982
|
+
signature
|
|
22983
|
+
};
|
|
22432
22984
|
});
|
|
22433
22985
|
}
|
|
22434
22986
|
|
|
@@ -22494,7 +23046,12 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
22494
23046
|
nearSignTransaction: NearSignTransaction,
|
|
22495
23047
|
aptosGetAddress: AptosGetAddress,
|
|
22496
23048
|
aptosGetPublicKey: AptosGetPublicKey,
|
|
22497
|
-
aptosSignTransaction: AptosSignTransaction
|
|
23049
|
+
aptosSignTransaction: AptosSignTransaction,
|
|
23050
|
+
aptosSignMessage: AptosSignMessage,
|
|
23051
|
+
algoGetAddress: AlgoGetAddress,
|
|
23052
|
+
algoSignTransaction: AlgoSignTransaction,
|
|
23053
|
+
cosmosGetAddress: CosmosGetAddress,
|
|
23054
|
+
cosmosSignTransaction: CosmosSignTransaction
|
|
22498
23055
|
});
|
|
22499
23056
|
|
|
22500
23057
|
function findMethod(message) {
|
|
@@ -22750,6 +23307,12 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
22750
23307
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
22751
23308
|
|
|
22752
23309
|
if (semver__default["default"].valid(versionRange.min) && semver__default["default"].lt(currentVersion, versionRange.min)) {
|
|
23310
|
+
const newVersionUnReleased = DataManager.getFirmwareStatus(device.features);
|
|
23311
|
+
|
|
23312
|
+
if (newVersionUnReleased === 'none' || newVersionUnReleased === 'valid') {
|
|
23313
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NewFirmwareUnRelease);
|
|
23314
|
+
}
|
|
23315
|
+
|
|
22753
23316
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware, `Device firmware version is too low, please update to ${versionRange.min}`, {
|
|
22754
23317
|
current: currentVersion,
|
|
22755
23318
|
require: versionRange.min
|
|
@@ -24628,6 +25191,7 @@ const HardwareErrorCode = {
|
|
|
24628
25191
|
FirmwareUpdateLimitOneDevice: 409,
|
|
24629
25192
|
FirmwareUpdateManuallyEnterBoot: 410,
|
|
24630
25193
|
FirmwareUpdateAutoEnterBootFailure: 411,
|
|
25194
|
+
NewFirmwareUnRelease: 412,
|
|
24631
25195
|
NetworkError: 500,
|
|
24632
25196
|
TransportNotConfigured: 600,
|
|
24633
25197
|
TransportCallInProgress: 601,
|
|
@@ -24691,6 +25255,7 @@ const HardwareErrorCodeMessage = {
|
|
|
24691
25255
|
[HardwareErrorCode.FirmwareUpdateLimitOneDevice]: 'Only one device can be connected during firmware upgrade',
|
|
24692
25256
|
[HardwareErrorCode.FirmwareUpdateManuallyEnterBoot]: 'You need to manually enter boot',
|
|
24693
25257
|
[HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure]: 'Description Failed to automatically enter boot',
|
|
25258
|
+
[HardwareErrorCode.NewFirmwareUnRelease]: 'new firmware has not been released yet',
|
|
24694
25259
|
[HardwareErrorCode.NetworkError]: 'Network request error',
|
|
24695
25260
|
[HardwareErrorCode.TransportNotConfigured]: 'Transport not configured',
|
|
24696
25261
|
[HardwareErrorCode.TransportCallInProgress]: 'Transport call in progress',
|
|
@@ -27859,9 +28424,9 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalObject) {
|
|
|
27859
28424
|
|
|
27860
28425
|
|
|
27861
28426
|
|
|
27862
|
-
|
|
27863
|
-
|
|
27864
|
-
|
|
28427
|
+
const base64 = __webpack_require__(5766)
|
|
28428
|
+
const ieee754 = __webpack_require__(2333)
|
|
28429
|
+
const customInspectSymbol =
|
|
27865
28430
|
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
27866
28431
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
27867
28432
|
: null
|
|
@@ -27870,7 +28435,7 @@ exports.Buffer = Buffer
|
|
|
27870
28435
|
exports.SlowBuffer = SlowBuffer
|
|
27871
28436
|
exports.INSPECT_MAX_BYTES = 50
|
|
27872
28437
|
|
|
27873
|
-
|
|
28438
|
+
const K_MAX_LENGTH = 0x7fffffff
|
|
27874
28439
|
exports.kMaxLength = K_MAX_LENGTH
|
|
27875
28440
|
|
|
27876
28441
|
/**
|
|
@@ -27900,8 +28465,8 @@ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
|
|
27900
28465
|
function typedArraySupport () {
|
|
27901
28466
|
// Can typed array instances can be augmented?
|
|
27902
28467
|
try {
|
|
27903
|
-
|
|
27904
|
-
|
|
28468
|
+
const arr = new Uint8Array(1)
|
|
28469
|
+
const proto = { foo: function () { return 42 } }
|
|
27905
28470
|
Object.setPrototypeOf(proto, Uint8Array.prototype)
|
|
27906
28471
|
Object.setPrototypeOf(arr, proto)
|
|
27907
28472
|
return arr.foo() === 42
|
|
@@ -27931,7 +28496,7 @@ function createBuffer (length) {
|
|
|
27931
28496
|
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
27932
28497
|
}
|
|
27933
28498
|
// Return an augmented `Uint8Array` instance
|
|
27934
|
-
|
|
28499
|
+
const buf = new Uint8Array(length)
|
|
27935
28500
|
Object.setPrototypeOf(buf, Buffer.prototype)
|
|
27936
28501
|
return buf
|
|
27937
28502
|
}
|
|
@@ -27994,19 +28559,17 @@ function from (value, encodingOrOffset, length) {
|
|
|
27994
28559
|
)
|
|
27995
28560
|
}
|
|
27996
28561
|
|
|
27997
|
-
|
|
28562
|
+
const valueOf = value.valueOf && value.valueOf()
|
|
27998
28563
|
if (valueOf != null && valueOf !== value) {
|
|
27999
28564
|
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
28000
28565
|
}
|
|
28001
28566
|
|
|
28002
|
-
|
|
28567
|
+
const b = fromObject(value)
|
|
28003
28568
|
if (b) return b
|
|
28004
28569
|
|
|
28005
28570
|
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
28006
28571
|
typeof value[Symbol.toPrimitive] === 'function') {
|
|
28007
|
-
return Buffer.from(
|
|
28008
|
-
value[Symbol.toPrimitive]('string'), encodingOrOffset, length
|
|
28009
|
-
)
|
|
28572
|
+
return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
|
|
28010
28573
|
}
|
|
28011
28574
|
|
|
28012
28575
|
throw new TypeError(
|
|
@@ -28091,10 +28654,10 @@ function fromString (string, encoding) {
|
|
|
28091
28654
|
throw new TypeError('Unknown encoding: ' + encoding)
|
|
28092
28655
|
}
|
|
28093
28656
|
|
|
28094
|
-
|
|
28095
|
-
|
|
28657
|
+
const length = byteLength(string, encoding) | 0
|
|
28658
|
+
let buf = createBuffer(length)
|
|
28096
28659
|
|
|
28097
|
-
|
|
28660
|
+
const actual = buf.write(string, encoding)
|
|
28098
28661
|
|
|
28099
28662
|
if (actual !== length) {
|
|
28100
28663
|
// Writing a hex string, for example, that contains invalid characters will
|
|
@@ -28107,9 +28670,9 @@ function fromString (string, encoding) {
|
|
|
28107
28670
|
}
|
|
28108
28671
|
|
|
28109
28672
|
function fromArrayLike (array) {
|
|
28110
|
-
|
|
28111
|
-
|
|
28112
|
-
for (
|
|
28673
|
+
const length = array.length < 0 ? 0 : checked(array.length) | 0
|
|
28674
|
+
const buf = createBuffer(length)
|
|
28675
|
+
for (let i = 0; i < length; i += 1) {
|
|
28113
28676
|
buf[i] = array[i] & 255
|
|
28114
28677
|
}
|
|
28115
28678
|
return buf
|
|
@@ -28117,7 +28680,7 @@ function fromArrayLike (array) {
|
|
|
28117
28680
|
|
|
28118
28681
|
function fromArrayView (arrayView) {
|
|
28119
28682
|
if (isInstance(arrayView, Uint8Array)) {
|
|
28120
|
-
|
|
28683
|
+
const copy = new Uint8Array(arrayView)
|
|
28121
28684
|
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
|
|
28122
28685
|
}
|
|
28123
28686
|
return fromArrayLike(arrayView)
|
|
@@ -28132,7 +28695,7 @@ function fromArrayBuffer (array, byteOffset, length) {
|
|
|
28132
28695
|
throw new RangeError('"length" is outside of buffer bounds')
|
|
28133
28696
|
}
|
|
28134
28697
|
|
|
28135
|
-
|
|
28698
|
+
let buf
|
|
28136
28699
|
if (byteOffset === undefined && length === undefined) {
|
|
28137
28700
|
buf = new Uint8Array(array)
|
|
28138
28701
|
} else if (length === undefined) {
|
|
@@ -28149,8 +28712,8 @@ function fromArrayBuffer (array, byteOffset, length) {
|
|
|
28149
28712
|
|
|
28150
28713
|
function fromObject (obj) {
|
|
28151
28714
|
if (Buffer.isBuffer(obj)) {
|
|
28152
|
-
|
|
28153
|
-
|
|
28715
|
+
const len = checked(obj.length) | 0
|
|
28716
|
+
const buf = createBuffer(len)
|
|
28154
28717
|
|
|
28155
28718
|
if (buf.length === 0) {
|
|
28156
28719
|
return buf
|
|
@@ -28205,10 +28768,10 @@ Buffer.compare = function compare (a, b) {
|
|
|
28205
28768
|
|
|
28206
28769
|
if (a === b) return 0
|
|
28207
28770
|
|
|
28208
|
-
|
|
28209
|
-
|
|
28771
|
+
let x = a.length
|
|
28772
|
+
let y = b.length
|
|
28210
28773
|
|
|
28211
|
-
for (
|
|
28774
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
28212
28775
|
if (a[i] !== b[i]) {
|
|
28213
28776
|
x = a[i]
|
|
28214
28777
|
y = b[i]
|
|
@@ -28249,7 +28812,7 @@ Buffer.concat = function concat (list, length) {
|
|
|
28249
28812
|
return Buffer.alloc(0)
|
|
28250
28813
|
}
|
|
28251
28814
|
|
|
28252
|
-
|
|
28815
|
+
let i
|
|
28253
28816
|
if (length === undefined) {
|
|
28254
28817
|
length = 0
|
|
28255
28818
|
for (i = 0; i < list.length; ++i) {
|
|
@@ -28257,13 +28820,14 @@ Buffer.concat = function concat (list, length) {
|
|
|
28257
28820
|
}
|
|
28258
28821
|
}
|
|
28259
28822
|
|
|
28260
|
-
|
|
28261
|
-
|
|
28823
|
+
const buffer = Buffer.allocUnsafe(length)
|
|
28824
|
+
let pos = 0
|
|
28262
28825
|
for (i = 0; i < list.length; ++i) {
|
|
28263
|
-
|
|
28826
|
+
let buf = list[i]
|
|
28264
28827
|
if (isInstance(buf, Uint8Array)) {
|
|
28265
28828
|
if (pos + buf.length > buffer.length) {
|
|
28266
|
-
Buffer.
|
|
28829
|
+
if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
|
|
28830
|
+
buf.copy(buffer, pos)
|
|
28267
28831
|
} else {
|
|
28268
28832
|
Uint8Array.prototype.set.call(
|
|
28269
28833
|
buffer,
|
|
@@ -28295,12 +28859,12 @@ function byteLength (string, encoding) {
|
|
|
28295
28859
|
)
|
|
28296
28860
|
}
|
|
28297
28861
|
|
|
28298
|
-
|
|
28299
|
-
|
|
28862
|
+
const len = string.length
|
|
28863
|
+
const mustMatch = (arguments.length > 2 && arguments[2] === true)
|
|
28300
28864
|
if (!mustMatch && len === 0) return 0
|
|
28301
28865
|
|
|
28302
28866
|
// Use a for loop to avoid recursion
|
|
28303
|
-
|
|
28867
|
+
let loweredCase = false
|
|
28304
28868
|
for (;;) {
|
|
28305
28869
|
switch (encoding) {
|
|
28306
28870
|
case 'ascii':
|
|
@@ -28331,7 +28895,7 @@ function byteLength (string, encoding) {
|
|
|
28331
28895
|
Buffer.byteLength = byteLength
|
|
28332
28896
|
|
|
28333
28897
|
function slowToString (encoding, start, end) {
|
|
28334
|
-
|
|
28898
|
+
let loweredCase = false
|
|
28335
28899
|
|
|
28336
28900
|
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
28337
28901
|
// property of a typed array.
|
|
@@ -28409,28 +28973,28 @@ function slowToString (encoding, start, end) {
|
|
|
28409
28973
|
Buffer.prototype._isBuffer = true
|
|
28410
28974
|
|
|
28411
28975
|
function swap (b, n, m) {
|
|
28412
|
-
|
|
28976
|
+
const i = b[n]
|
|
28413
28977
|
b[n] = b[m]
|
|
28414
28978
|
b[m] = i
|
|
28415
28979
|
}
|
|
28416
28980
|
|
|
28417
28981
|
Buffer.prototype.swap16 = function swap16 () {
|
|
28418
|
-
|
|
28982
|
+
const len = this.length
|
|
28419
28983
|
if (len % 2 !== 0) {
|
|
28420
28984
|
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
28421
28985
|
}
|
|
28422
|
-
for (
|
|
28986
|
+
for (let i = 0; i < len; i += 2) {
|
|
28423
28987
|
swap(this, i, i + 1)
|
|
28424
28988
|
}
|
|
28425
28989
|
return this
|
|
28426
28990
|
}
|
|
28427
28991
|
|
|
28428
28992
|
Buffer.prototype.swap32 = function swap32 () {
|
|
28429
|
-
|
|
28993
|
+
const len = this.length
|
|
28430
28994
|
if (len % 4 !== 0) {
|
|
28431
28995
|
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
28432
28996
|
}
|
|
28433
|
-
for (
|
|
28997
|
+
for (let i = 0; i < len; i += 4) {
|
|
28434
28998
|
swap(this, i, i + 3)
|
|
28435
28999
|
swap(this, i + 1, i + 2)
|
|
28436
29000
|
}
|
|
@@ -28438,11 +29002,11 @@ Buffer.prototype.swap32 = function swap32 () {
|
|
|
28438
29002
|
}
|
|
28439
29003
|
|
|
28440
29004
|
Buffer.prototype.swap64 = function swap64 () {
|
|
28441
|
-
|
|
29005
|
+
const len = this.length
|
|
28442
29006
|
if (len % 8 !== 0) {
|
|
28443
29007
|
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
28444
29008
|
}
|
|
28445
|
-
for (
|
|
29009
|
+
for (let i = 0; i < len; i += 8) {
|
|
28446
29010
|
swap(this, i, i + 7)
|
|
28447
29011
|
swap(this, i + 1, i + 6)
|
|
28448
29012
|
swap(this, i + 2, i + 5)
|
|
@@ -28452,7 +29016,7 @@ Buffer.prototype.swap64 = function swap64 () {
|
|
|
28452
29016
|
}
|
|
28453
29017
|
|
|
28454
29018
|
Buffer.prototype.toString = function toString () {
|
|
28455
|
-
|
|
29019
|
+
const length = this.length
|
|
28456
29020
|
if (length === 0) return ''
|
|
28457
29021
|
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
28458
29022
|
return slowToString.apply(this, arguments)
|
|
@@ -28467,8 +29031,8 @@ Buffer.prototype.equals = function equals (b) {
|
|
|
28467
29031
|
}
|
|
28468
29032
|
|
|
28469
29033
|
Buffer.prototype.inspect = function inspect () {
|
|
28470
|
-
|
|
28471
|
-
|
|
29034
|
+
let str = ''
|
|
29035
|
+
const max = exports.INSPECT_MAX_BYTES
|
|
28472
29036
|
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
|
|
28473
29037
|
if (this.length > max) str += ' ... '
|
|
28474
29038
|
return '<Buffer ' + str + '>'
|
|
@@ -28522,14 +29086,14 @@ Buffer.prototype.compare = function compare (target, start, end, thisStart, this
|
|
|
28522
29086
|
|
|
28523
29087
|
if (this === target) return 0
|
|
28524
29088
|
|
|
28525
|
-
|
|
28526
|
-
|
|
28527
|
-
|
|
29089
|
+
let x = thisEnd - thisStart
|
|
29090
|
+
let y = end - start
|
|
29091
|
+
const len = Math.min(x, y)
|
|
28528
29092
|
|
|
28529
|
-
|
|
28530
|
-
|
|
29093
|
+
const thisCopy = this.slice(thisStart, thisEnd)
|
|
29094
|
+
const targetCopy = target.slice(start, end)
|
|
28531
29095
|
|
|
28532
|
-
for (
|
|
29096
|
+
for (let i = 0; i < len; ++i) {
|
|
28533
29097
|
if (thisCopy[i] !== targetCopy[i]) {
|
|
28534
29098
|
x = thisCopy[i]
|
|
28535
29099
|
y = targetCopy[i]
|
|
@@ -28608,9 +29172,9 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
|
28608
29172
|
}
|
|
28609
29173
|
|
|
28610
29174
|
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
28611
|
-
|
|
28612
|
-
|
|
28613
|
-
|
|
29175
|
+
let indexSize = 1
|
|
29176
|
+
let arrLength = arr.length
|
|
29177
|
+
let valLength = val.length
|
|
28614
29178
|
|
|
28615
29179
|
if (encoding !== undefined) {
|
|
28616
29180
|
encoding = String(encoding).toLowerCase()
|
|
@@ -28634,9 +29198,9 @@ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
|
28634
29198
|
}
|
|
28635
29199
|
}
|
|
28636
29200
|
|
|
28637
|
-
|
|
29201
|
+
let i
|
|
28638
29202
|
if (dir) {
|
|
28639
|
-
|
|
29203
|
+
let foundIndex = -1
|
|
28640
29204
|
for (i = byteOffset; i < arrLength; i++) {
|
|
28641
29205
|
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
28642
29206
|
if (foundIndex === -1) foundIndex = i
|
|
@@ -28649,8 +29213,8 @@ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
|
28649
29213
|
} else {
|
|
28650
29214
|
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
|
28651
29215
|
for (i = byteOffset; i >= 0; i--) {
|
|
28652
|
-
|
|
28653
|
-
for (
|
|
29216
|
+
let found = true
|
|
29217
|
+
for (let j = 0; j < valLength; j++) {
|
|
28654
29218
|
if (read(arr, i + j) !== read(val, j)) {
|
|
28655
29219
|
found = false
|
|
28656
29220
|
break
|
|
@@ -28677,7 +29241,7 @@ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding)
|
|
|
28677
29241
|
|
|
28678
29242
|
function hexWrite (buf, string, offset, length) {
|
|
28679
29243
|
offset = Number(offset) || 0
|
|
28680
|
-
|
|
29244
|
+
const remaining = buf.length - offset
|
|
28681
29245
|
if (!length) {
|
|
28682
29246
|
length = remaining
|
|
28683
29247
|
} else {
|
|
@@ -28687,13 +29251,14 @@ function hexWrite (buf, string, offset, length) {
|
|
|
28687
29251
|
}
|
|
28688
29252
|
}
|
|
28689
29253
|
|
|
28690
|
-
|
|
29254
|
+
const strLen = string.length
|
|
28691
29255
|
|
|
28692
29256
|
if (length > strLen / 2) {
|
|
28693
29257
|
length = strLen / 2
|
|
28694
29258
|
}
|
|
28695
|
-
|
|
28696
|
-
|
|
29259
|
+
let i
|
|
29260
|
+
for (i = 0; i < length; ++i) {
|
|
29261
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16)
|
|
28697
29262
|
if (numberIsNaN(parsed)) return i
|
|
28698
29263
|
buf[offset + i] = parsed
|
|
28699
29264
|
}
|
|
@@ -28743,7 +29308,7 @@ Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
|
28743
29308
|
)
|
|
28744
29309
|
}
|
|
28745
29310
|
|
|
28746
|
-
|
|
29311
|
+
const remaining = this.length - offset
|
|
28747
29312
|
if (length === undefined || length > remaining) length = remaining
|
|
28748
29313
|
|
|
28749
29314
|
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
@@ -28752,7 +29317,7 @@ Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
|
28752
29317
|
|
|
28753
29318
|
if (!encoding) encoding = 'utf8'
|
|
28754
29319
|
|
|
28755
|
-
|
|
29320
|
+
let loweredCase = false
|
|
28756
29321
|
for (;;) {
|
|
28757
29322
|
switch (encoding) {
|
|
28758
29323
|
case 'hex':
|
|
@@ -28802,13 +29367,13 @@ function base64Slice (buf, start, end) {
|
|
|
28802
29367
|
|
|
28803
29368
|
function utf8Slice (buf, start, end) {
|
|
28804
29369
|
end = Math.min(buf.length, end)
|
|
28805
|
-
|
|
29370
|
+
const res = []
|
|
28806
29371
|
|
|
28807
|
-
|
|
29372
|
+
let i = start
|
|
28808
29373
|
while (i < end) {
|
|
28809
|
-
|
|
28810
|
-
|
|
28811
|
-
|
|
29374
|
+
const firstByte = buf[i]
|
|
29375
|
+
let codePoint = null
|
|
29376
|
+
let bytesPerSequence = (firstByte > 0xEF)
|
|
28812
29377
|
? 4
|
|
28813
29378
|
: (firstByte > 0xDF)
|
|
28814
29379
|
? 3
|
|
@@ -28817,7 +29382,7 @@ function utf8Slice (buf, start, end) {
|
|
|
28817
29382
|
: 1
|
|
28818
29383
|
|
|
28819
29384
|
if (i + bytesPerSequence <= end) {
|
|
28820
|
-
|
|
29385
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint
|
|
28821
29386
|
|
|
28822
29387
|
switch (bytesPerSequence) {
|
|
28823
29388
|
case 1:
|
|
@@ -28879,17 +29444,17 @@ function utf8Slice (buf, start, end) {
|
|
|
28879
29444
|
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
28880
29445
|
// the lowest limit is Chrome, with 0x10000 args.
|
|
28881
29446
|
// We go 1 magnitude less, for safety
|
|
28882
|
-
|
|
29447
|
+
const MAX_ARGUMENTS_LENGTH = 0x1000
|
|
28883
29448
|
|
|
28884
29449
|
function decodeCodePointsArray (codePoints) {
|
|
28885
|
-
|
|
29450
|
+
const len = codePoints.length
|
|
28886
29451
|
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
28887
29452
|
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
28888
29453
|
}
|
|
28889
29454
|
|
|
28890
29455
|
// Decode in chunks to avoid "call stack size exceeded".
|
|
28891
|
-
|
|
28892
|
-
|
|
29456
|
+
let res = ''
|
|
29457
|
+
let i = 0
|
|
28893
29458
|
while (i < len) {
|
|
28894
29459
|
res += String.fromCharCode.apply(
|
|
28895
29460
|
String,
|
|
@@ -28900,50 +29465,50 @@ function decodeCodePointsArray (codePoints) {
|
|
|
28900
29465
|
}
|
|
28901
29466
|
|
|
28902
29467
|
function asciiSlice (buf, start, end) {
|
|
28903
|
-
|
|
29468
|
+
let ret = ''
|
|
28904
29469
|
end = Math.min(buf.length, end)
|
|
28905
29470
|
|
|
28906
|
-
for (
|
|
29471
|
+
for (let i = start; i < end; ++i) {
|
|
28907
29472
|
ret += String.fromCharCode(buf[i] & 0x7F)
|
|
28908
29473
|
}
|
|
28909
29474
|
return ret
|
|
28910
29475
|
}
|
|
28911
29476
|
|
|
28912
29477
|
function latin1Slice (buf, start, end) {
|
|
28913
|
-
|
|
29478
|
+
let ret = ''
|
|
28914
29479
|
end = Math.min(buf.length, end)
|
|
28915
29480
|
|
|
28916
|
-
for (
|
|
29481
|
+
for (let i = start; i < end; ++i) {
|
|
28917
29482
|
ret += String.fromCharCode(buf[i])
|
|
28918
29483
|
}
|
|
28919
29484
|
return ret
|
|
28920
29485
|
}
|
|
28921
29486
|
|
|
28922
29487
|
function hexSlice (buf, start, end) {
|
|
28923
|
-
|
|
29488
|
+
const len = buf.length
|
|
28924
29489
|
|
|
28925
29490
|
if (!start || start < 0) start = 0
|
|
28926
29491
|
if (!end || end < 0 || end > len) end = len
|
|
28927
29492
|
|
|
28928
|
-
|
|
28929
|
-
for (
|
|
29493
|
+
let out = ''
|
|
29494
|
+
for (let i = start; i < end; ++i) {
|
|
28930
29495
|
out += hexSliceLookupTable[buf[i]]
|
|
28931
29496
|
}
|
|
28932
29497
|
return out
|
|
28933
29498
|
}
|
|
28934
29499
|
|
|
28935
29500
|
function utf16leSlice (buf, start, end) {
|
|
28936
|
-
|
|
28937
|
-
|
|
29501
|
+
const bytes = buf.slice(start, end)
|
|
29502
|
+
let res = ''
|
|
28938
29503
|
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
|
|
28939
|
-
for (
|
|
29504
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
28940
29505
|
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
|
|
28941
29506
|
}
|
|
28942
29507
|
return res
|
|
28943
29508
|
}
|
|
28944
29509
|
|
|
28945
29510
|
Buffer.prototype.slice = function slice (start, end) {
|
|
28946
|
-
|
|
29511
|
+
const len = this.length
|
|
28947
29512
|
start = ~~start
|
|
28948
29513
|
end = end === undefined ? len : ~~end
|
|
28949
29514
|
|
|
@@ -28963,7 +29528,7 @@ Buffer.prototype.slice = function slice (start, end) {
|
|
|
28963
29528
|
|
|
28964
29529
|
if (end < start) end = start
|
|
28965
29530
|
|
|
28966
|
-
|
|
29531
|
+
const newBuf = this.subarray(start, end)
|
|
28967
29532
|
// Return an augmented `Uint8Array` instance
|
|
28968
29533
|
Object.setPrototypeOf(newBuf, Buffer.prototype)
|
|
28969
29534
|
|
|
@@ -28984,9 +29549,9 @@ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert)
|
|
|
28984
29549
|
byteLength = byteLength >>> 0
|
|
28985
29550
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
28986
29551
|
|
|
28987
|
-
|
|
28988
|
-
|
|
28989
|
-
|
|
29552
|
+
let val = this[offset]
|
|
29553
|
+
let mul = 1
|
|
29554
|
+
let i = 0
|
|
28990
29555
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
28991
29556
|
val += this[offset + i] * mul
|
|
28992
29557
|
}
|
|
@@ -29002,8 +29567,8 @@ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert)
|
|
|
29002
29567
|
checkOffset(offset, byteLength, this.length)
|
|
29003
29568
|
}
|
|
29004
29569
|
|
|
29005
|
-
|
|
29006
|
-
|
|
29570
|
+
let val = this[offset + --byteLength]
|
|
29571
|
+
let mul = 1
|
|
29007
29572
|
while (byteLength > 0 && (mul *= 0x100)) {
|
|
29008
29573
|
val += this[offset + --byteLength] * mul
|
|
29009
29574
|
}
|
|
@@ -29054,14 +29619,58 @@ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
|
29054
29619
|
this[offset + 3])
|
|
29055
29620
|
}
|
|
29056
29621
|
|
|
29622
|
+
Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
|
|
29623
|
+
offset = offset >>> 0
|
|
29624
|
+
validateNumber(offset, 'offset')
|
|
29625
|
+
const first = this[offset]
|
|
29626
|
+
const last = this[offset + 7]
|
|
29627
|
+
if (first === undefined || last === undefined) {
|
|
29628
|
+
boundsError(offset, this.length - 8)
|
|
29629
|
+
}
|
|
29630
|
+
|
|
29631
|
+
const lo = first +
|
|
29632
|
+
this[++offset] * 2 ** 8 +
|
|
29633
|
+
this[++offset] * 2 ** 16 +
|
|
29634
|
+
this[++offset] * 2 ** 24
|
|
29635
|
+
|
|
29636
|
+
const hi = this[++offset] +
|
|
29637
|
+
this[++offset] * 2 ** 8 +
|
|
29638
|
+
this[++offset] * 2 ** 16 +
|
|
29639
|
+
last * 2 ** 24
|
|
29640
|
+
|
|
29641
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32))
|
|
29642
|
+
})
|
|
29643
|
+
|
|
29644
|
+
Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
|
|
29645
|
+
offset = offset >>> 0
|
|
29646
|
+
validateNumber(offset, 'offset')
|
|
29647
|
+
const first = this[offset]
|
|
29648
|
+
const last = this[offset + 7]
|
|
29649
|
+
if (first === undefined || last === undefined) {
|
|
29650
|
+
boundsError(offset, this.length - 8)
|
|
29651
|
+
}
|
|
29652
|
+
|
|
29653
|
+
const hi = first * 2 ** 24 +
|
|
29654
|
+
this[++offset] * 2 ** 16 +
|
|
29655
|
+
this[++offset] * 2 ** 8 +
|
|
29656
|
+
this[++offset]
|
|
29657
|
+
|
|
29658
|
+
const lo = this[++offset] * 2 ** 24 +
|
|
29659
|
+
this[++offset] * 2 ** 16 +
|
|
29660
|
+
this[++offset] * 2 ** 8 +
|
|
29661
|
+
last
|
|
29662
|
+
|
|
29663
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo)
|
|
29664
|
+
})
|
|
29665
|
+
|
|
29057
29666
|
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
29058
29667
|
offset = offset >>> 0
|
|
29059
29668
|
byteLength = byteLength >>> 0
|
|
29060
29669
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
29061
29670
|
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29671
|
+
let val = this[offset]
|
|
29672
|
+
let mul = 1
|
|
29673
|
+
let i = 0
|
|
29065
29674
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
29066
29675
|
val += this[offset + i] * mul
|
|
29067
29676
|
}
|
|
@@ -29077,9 +29686,9 @@ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
|
29077
29686
|
byteLength = byteLength >>> 0
|
|
29078
29687
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
29079
29688
|
|
|
29080
|
-
|
|
29081
|
-
|
|
29082
|
-
|
|
29689
|
+
let i = byteLength
|
|
29690
|
+
let mul = 1
|
|
29691
|
+
let val = this[offset + --i]
|
|
29083
29692
|
while (i > 0 && (mul *= 0x100)) {
|
|
29084
29693
|
val += this[offset + --i] * mul
|
|
29085
29694
|
}
|
|
@@ -29100,14 +29709,14 @@ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
|
29100
29709
|
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
29101
29710
|
offset = offset >>> 0
|
|
29102
29711
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
29103
|
-
|
|
29712
|
+
const val = this[offset] | (this[offset + 1] << 8)
|
|
29104
29713
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
29105
29714
|
}
|
|
29106
29715
|
|
|
29107
29716
|
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
29108
29717
|
offset = offset >>> 0
|
|
29109
29718
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
29110
|
-
|
|
29719
|
+
const val = this[offset + 1] | (this[offset] << 8)
|
|
29111
29720
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
29112
29721
|
}
|
|
29113
29722
|
|
|
@@ -29131,6 +29740,48 @@ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
|
29131
29740
|
(this[offset + 3])
|
|
29132
29741
|
}
|
|
29133
29742
|
|
|
29743
|
+
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
|
|
29744
|
+
offset = offset >>> 0
|
|
29745
|
+
validateNumber(offset, 'offset')
|
|
29746
|
+
const first = this[offset]
|
|
29747
|
+
const last = this[offset + 7]
|
|
29748
|
+
if (first === undefined || last === undefined) {
|
|
29749
|
+
boundsError(offset, this.length - 8)
|
|
29750
|
+
}
|
|
29751
|
+
|
|
29752
|
+
const val = this[offset + 4] +
|
|
29753
|
+
this[offset + 5] * 2 ** 8 +
|
|
29754
|
+
this[offset + 6] * 2 ** 16 +
|
|
29755
|
+
(last << 24) // Overflow
|
|
29756
|
+
|
|
29757
|
+
return (BigInt(val) << BigInt(32)) +
|
|
29758
|
+
BigInt(first +
|
|
29759
|
+
this[++offset] * 2 ** 8 +
|
|
29760
|
+
this[++offset] * 2 ** 16 +
|
|
29761
|
+
this[++offset] * 2 ** 24)
|
|
29762
|
+
})
|
|
29763
|
+
|
|
29764
|
+
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
|
|
29765
|
+
offset = offset >>> 0
|
|
29766
|
+
validateNumber(offset, 'offset')
|
|
29767
|
+
const first = this[offset]
|
|
29768
|
+
const last = this[offset + 7]
|
|
29769
|
+
if (first === undefined || last === undefined) {
|
|
29770
|
+
boundsError(offset, this.length - 8)
|
|
29771
|
+
}
|
|
29772
|
+
|
|
29773
|
+
const val = (first << 24) + // Overflow
|
|
29774
|
+
this[++offset] * 2 ** 16 +
|
|
29775
|
+
this[++offset] * 2 ** 8 +
|
|
29776
|
+
this[++offset]
|
|
29777
|
+
|
|
29778
|
+
return (BigInt(val) << BigInt(32)) +
|
|
29779
|
+
BigInt(this[++offset] * 2 ** 24 +
|
|
29780
|
+
this[++offset] * 2 ** 16 +
|
|
29781
|
+
this[++offset] * 2 ** 8 +
|
|
29782
|
+
last)
|
|
29783
|
+
})
|
|
29784
|
+
|
|
29134
29785
|
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
29135
29786
|
offset = offset >>> 0
|
|
29136
29787
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
@@ -29167,12 +29818,12 @@ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength,
|
|
|
29167
29818
|
offset = offset >>> 0
|
|
29168
29819
|
byteLength = byteLength >>> 0
|
|
29169
29820
|
if (!noAssert) {
|
|
29170
|
-
|
|
29821
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1
|
|
29171
29822
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
|
29172
29823
|
}
|
|
29173
29824
|
|
|
29174
|
-
|
|
29175
|
-
|
|
29825
|
+
let mul = 1
|
|
29826
|
+
let i = 0
|
|
29176
29827
|
this[offset] = value & 0xFF
|
|
29177
29828
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
29178
29829
|
this[offset + i] = (value / mul) & 0xFF
|
|
@@ -29187,12 +29838,12 @@ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength,
|
|
|
29187
29838
|
offset = offset >>> 0
|
|
29188
29839
|
byteLength = byteLength >>> 0
|
|
29189
29840
|
if (!noAssert) {
|
|
29190
|
-
|
|
29841
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1
|
|
29191
29842
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
|
29192
29843
|
}
|
|
29193
29844
|
|
|
29194
|
-
|
|
29195
|
-
|
|
29845
|
+
let i = byteLength - 1
|
|
29846
|
+
let mul = 1
|
|
29196
29847
|
this[offset + i] = value & 0xFF
|
|
29197
29848
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
29198
29849
|
this[offset + i] = (value / mul) & 0xFF
|
|
@@ -29254,18 +29905,70 @@ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert
|
|
|
29254
29905
|
return offset + 4
|
|
29255
29906
|
}
|
|
29256
29907
|
|
|
29908
|
+
function wrtBigUInt64LE (buf, value, offset, min, max) {
|
|
29909
|
+
checkIntBI(value, min, max, buf, offset, 7)
|
|
29910
|
+
|
|
29911
|
+
let lo = Number(value & BigInt(0xffffffff))
|
|
29912
|
+
buf[offset++] = lo
|
|
29913
|
+
lo = lo >> 8
|
|
29914
|
+
buf[offset++] = lo
|
|
29915
|
+
lo = lo >> 8
|
|
29916
|
+
buf[offset++] = lo
|
|
29917
|
+
lo = lo >> 8
|
|
29918
|
+
buf[offset++] = lo
|
|
29919
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
|
|
29920
|
+
buf[offset++] = hi
|
|
29921
|
+
hi = hi >> 8
|
|
29922
|
+
buf[offset++] = hi
|
|
29923
|
+
hi = hi >> 8
|
|
29924
|
+
buf[offset++] = hi
|
|
29925
|
+
hi = hi >> 8
|
|
29926
|
+
buf[offset++] = hi
|
|
29927
|
+
return offset
|
|
29928
|
+
}
|
|
29929
|
+
|
|
29930
|
+
function wrtBigUInt64BE (buf, value, offset, min, max) {
|
|
29931
|
+
checkIntBI(value, min, max, buf, offset, 7)
|
|
29932
|
+
|
|
29933
|
+
let lo = Number(value & BigInt(0xffffffff))
|
|
29934
|
+
buf[offset + 7] = lo
|
|
29935
|
+
lo = lo >> 8
|
|
29936
|
+
buf[offset + 6] = lo
|
|
29937
|
+
lo = lo >> 8
|
|
29938
|
+
buf[offset + 5] = lo
|
|
29939
|
+
lo = lo >> 8
|
|
29940
|
+
buf[offset + 4] = lo
|
|
29941
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
|
|
29942
|
+
buf[offset + 3] = hi
|
|
29943
|
+
hi = hi >> 8
|
|
29944
|
+
buf[offset + 2] = hi
|
|
29945
|
+
hi = hi >> 8
|
|
29946
|
+
buf[offset + 1] = hi
|
|
29947
|
+
hi = hi >> 8
|
|
29948
|
+
buf[offset] = hi
|
|
29949
|
+
return offset + 8
|
|
29950
|
+
}
|
|
29951
|
+
|
|
29952
|
+
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
|
|
29953
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
29954
|
+
})
|
|
29955
|
+
|
|
29956
|
+
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
|
|
29957
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
29958
|
+
})
|
|
29959
|
+
|
|
29257
29960
|
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
29258
29961
|
value = +value
|
|
29259
29962
|
offset = offset >>> 0
|
|
29260
29963
|
if (!noAssert) {
|
|
29261
|
-
|
|
29964
|
+
const limit = Math.pow(2, (8 * byteLength) - 1)
|
|
29262
29965
|
|
|
29263
29966
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
29264
29967
|
}
|
|
29265
29968
|
|
|
29266
|
-
|
|
29267
|
-
|
|
29268
|
-
|
|
29969
|
+
let i = 0
|
|
29970
|
+
let mul = 1
|
|
29971
|
+
let sub = 0
|
|
29269
29972
|
this[offset] = value & 0xFF
|
|
29270
29973
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
29271
29974
|
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
@@ -29281,14 +29984,14 @@ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, no
|
|
|
29281
29984
|
value = +value
|
|
29282
29985
|
offset = offset >>> 0
|
|
29283
29986
|
if (!noAssert) {
|
|
29284
|
-
|
|
29987
|
+
const limit = Math.pow(2, (8 * byteLength) - 1)
|
|
29285
29988
|
|
|
29286
29989
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
29287
29990
|
}
|
|
29288
29991
|
|
|
29289
|
-
|
|
29290
|
-
|
|
29291
|
-
|
|
29992
|
+
let i = byteLength - 1
|
|
29993
|
+
let mul = 1
|
|
29994
|
+
let sub = 0
|
|
29292
29995
|
this[offset + i] = value & 0xFF
|
|
29293
29996
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
29294
29997
|
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
@@ -29350,6 +30053,14 @@ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert)
|
|
|
29350
30053
|
return offset + 4
|
|
29351
30054
|
}
|
|
29352
30055
|
|
|
30056
|
+
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
|
|
30057
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
30058
|
+
})
|
|
30059
|
+
|
|
30060
|
+
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
|
|
30061
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
30062
|
+
})
|
|
30063
|
+
|
|
29353
30064
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
29354
30065
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
29355
30066
|
if (offset < 0) throw new RangeError('Index out of range')
|
|
@@ -29417,7 +30128,7 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
|
29417
30128
|
end = target.length - targetStart + start
|
|
29418
30129
|
}
|
|
29419
30130
|
|
|
29420
|
-
|
|
30131
|
+
const len = end - start
|
|
29421
30132
|
|
|
29422
30133
|
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
|
29423
30134
|
// Use built-in when available, missing from IE11
|
|
@@ -29455,7 +30166,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
|
29455
30166
|
throw new TypeError('Unknown encoding: ' + encoding)
|
|
29456
30167
|
}
|
|
29457
30168
|
if (val.length === 1) {
|
|
29458
|
-
|
|
30169
|
+
const code = val.charCodeAt(0)
|
|
29459
30170
|
if ((encoding === 'utf8' && code < 128) ||
|
|
29460
30171
|
encoding === 'latin1') {
|
|
29461
30172
|
// Fast path: If `val` fits into a single byte, use that numeric value.
|
|
@@ -29482,16 +30193,16 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
|
29482
30193
|
|
|
29483
30194
|
if (!val) val = 0
|
|
29484
30195
|
|
|
29485
|
-
|
|
30196
|
+
let i
|
|
29486
30197
|
if (typeof val === 'number') {
|
|
29487
30198
|
for (i = start; i < end; ++i) {
|
|
29488
30199
|
this[i] = val
|
|
29489
30200
|
}
|
|
29490
30201
|
} else {
|
|
29491
|
-
|
|
30202
|
+
const bytes = Buffer.isBuffer(val)
|
|
29492
30203
|
? val
|
|
29493
30204
|
: Buffer.from(val, encoding)
|
|
29494
|
-
|
|
30205
|
+
const len = bytes.length
|
|
29495
30206
|
if (len === 0) {
|
|
29496
30207
|
throw new TypeError('The value "' + val +
|
|
29497
30208
|
'" is invalid for argument "value"')
|
|
@@ -29504,10 +30215,143 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
|
29504
30215
|
return this
|
|
29505
30216
|
}
|
|
29506
30217
|
|
|
30218
|
+
// CUSTOM ERRORS
|
|
30219
|
+
// =============
|
|
30220
|
+
|
|
30221
|
+
// Simplified versions from Node, changed for Buffer-only usage
|
|
30222
|
+
const errors = {}
|
|
30223
|
+
function E (sym, getMessage, Base) {
|
|
30224
|
+
errors[sym] = class NodeError extends Base {
|
|
30225
|
+
constructor () {
|
|
30226
|
+
super()
|
|
30227
|
+
|
|
30228
|
+
Object.defineProperty(this, 'message', {
|
|
30229
|
+
value: getMessage.apply(this, arguments),
|
|
30230
|
+
writable: true,
|
|
30231
|
+
configurable: true
|
|
30232
|
+
})
|
|
30233
|
+
|
|
30234
|
+
// Add the error code to the name to include it in the stack trace.
|
|
30235
|
+
this.name = `${this.name} [${sym}]`
|
|
30236
|
+
// Access the stack to generate the error message including the error code
|
|
30237
|
+
// from the name.
|
|
30238
|
+
this.stack // eslint-disable-line no-unused-expressions
|
|
30239
|
+
// Reset the name to the actual name.
|
|
30240
|
+
delete this.name
|
|
30241
|
+
}
|
|
30242
|
+
|
|
30243
|
+
get code () {
|
|
30244
|
+
return sym
|
|
30245
|
+
}
|
|
30246
|
+
|
|
30247
|
+
set code (value) {
|
|
30248
|
+
Object.defineProperty(this, 'code', {
|
|
30249
|
+
configurable: true,
|
|
30250
|
+
enumerable: true,
|
|
30251
|
+
value,
|
|
30252
|
+
writable: true
|
|
30253
|
+
})
|
|
30254
|
+
}
|
|
30255
|
+
|
|
30256
|
+
toString () {
|
|
30257
|
+
return `${this.name} [${sym}]: ${this.message}`
|
|
30258
|
+
}
|
|
30259
|
+
}
|
|
30260
|
+
}
|
|
30261
|
+
|
|
30262
|
+
E('ERR_BUFFER_OUT_OF_BOUNDS',
|
|
30263
|
+
function (name) {
|
|
30264
|
+
if (name) {
|
|
30265
|
+
return `${name} is outside of buffer bounds`
|
|
30266
|
+
}
|
|
30267
|
+
|
|
30268
|
+
return 'Attempt to access memory outside buffer bounds'
|
|
30269
|
+
}, RangeError)
|
|
30270
|
+
E('ERR_INVALID_ARG_TYPE',
|
|
30271
|
+
function (name, actual) {
|
|
30272
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
|
|
30273
|
+
}, TypeError)
|
|
30274
|
+
E('ERR_OUT_OF_RANGE',
|
|
30275
|
+
function (str, range, input) {
|
|
30276
|
+
let msg = `The value of "${str}" is out of range.`
|
|
30277
|
+
let received = input
|
|
30278
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
30279
|
+
received = addNumericalSeparator(String(input))
|
|
30280
|
+
} else if (typeof input === 'bigint') {
|
|
30281
|
+
received = String(input)
|
|
30282
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
30283
|
+
received = addNumericalSeparator(received)
|
|
30284
|
+
}
|
|
30285
|
+
received += 'n'
|
|
30286
|
+
}
|
|
30287
|
+
msg += ` It must be ${range}. Received ${received}`
|
|
30288
|
+
return msg
|
|
30289
|
+
}, RangeError)
|
|
30290
|
+
|
|
30291
|
+
function addNumericalSeparator (val) {
|
|
30292
|
+
let res = ''
|
|
30293
|
+
let i = val.length
|
|
30294
|
+
const start = val[0] === '-' ? 1 : 0
|
|
30295
|
+
for (; i >= start + 4; i -= 3) {
|
|
30296
|
+
res = `_${val.slice(i - 3, i)}${res}`
|
|
30297
|
+
}
|
|
30298
|
+
return `${val.slice(0, i)}${res}`
|
|
30299
|
+
}
|
|
30300
|
+
|
|
30301
|
+
// CHECK FUNCTIONS
|
|
30302
|
+
// ===============
|
|
30303
|
+
|
|
30304
|
+
function checkBounds (buf, offset, byteLength) {
|
|
30305
|
+
validateNumber(offset, 'offset')
|
|
30306
|
+
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
30307
|
+
boundsError(offset, buf.length - (byteLength + 1))
|
|
30308
|
+
}
|
|
30309
|
+
}
|
|
30310
|
+
|
|
30311
|
+
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
30312
|
+
if (value > max || value < min) {
|
|
30313
|
+
const n = typeof min === 'bigint' ? 'n' : ''
|
|
30314
|
+
let range
|
|
30315
|
+
if (byteLength > 3) {
|
|
30316
|
+
if (min === 0 || min === BigInt(0)) {
|
|
30317
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`
|
|
30318
|
+
} else {
|
|
30319
|
+
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
30320
|
+
`${(byteLength + 1) * 8 - 1}${n}`
|
|
30321
|
+
}
|
|
30322
|
+
} else {
|
|
30323
|
+
range = `>= ${min}${n} and <= ${max}${n}`
|
|
30324
|
+
}
|
|
30325
|
+
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
30326
|
+
}
|
|
30327
|
+
checkBounds(buf, offset, byteLength)
|
|
30328
|
+
}
|
|
30329
|
+
|
|
30330
|
+
function validateNumber (value, name) {
|
|
30331
|
+
if (typeof value !== 'number') {
|
|
30332
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
30333
|
+
}
|
|
30334
|
+
}
|
|
30335
|
+
|
|
30336
|
+
function boundsError (value, length, type) {
|
|
30337
|
+
if (Math.floor(value) !== value) {
|
|
30338
|
+
validateNumber(value, type)
|
|
30339
|
+
throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)
|
|
30340
|
+
}
|
|
30341
|
+
|
|
30342
|
+
if (length < 0) {
|
|
30343
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
30344
|
+
}
|
|
30345
|
+
|
|
30346
|
+
throw new errors.ERR_OUT_OF_RANGE(type || 'offset',
|
|
30347
|
+
`>= ${type ? 1 : 0} and <= ${length}`,
|
|
30348
|
+
value)
|
|
30349
|
+
}
|
|
30350
|
+
|
|
29507
30351
|
// HELPER FUNCTIONS
|
|
29508
30352
|
// ================
|
|
29509
30353
|
|
|
29510
|
-
|
|
30354
|
+
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
|
|
29511
30355
|
|
|
29512
30356
|
function base64clean (str) {
|
|
29513
30357
|
// Node takes equal signs as end of the Base64 encoding
|
|
@@ -29525,12 +30369,12 @@ function base64clean (str) {
|
|
|
29525
30369
|
|
|
29526
30370
|
function utf8ToBytes (string, units) {
|
|
29527
30371
|
units = units || Infinity
|
|
29528
|
-
|
|
29529
|
-
|
|
29530
|
-
|
|
29531
|
-
|
|
30372
|
+
let codePoint
|
|
30373
|
+
const length = string.length
|
|
30374
|
+
let leadSurrogate = null
|
|
30375
|
+
const bytes = []
|
|
29532
30376
|
|
|
29533
|
-
for (
|
|
30377
|
+
for (let i = 0; i < length; ++i) {
|
|
29534
30378
|
codePoint = string.charCodeAt(i)
|
|
29535
30379
|
|
|
29536
30380
|
// is surrogate component
|
|
@@ -29604,8 +30448,8 @@ function utf8ToBytes (string, units) {
|
|
|
29604
30448
|
}
|
|
29605
30449
|
|
|
29606
30450
|
function asciiToBytes (str) {
|
|
29607
|
-
|
|
29608
|
-
for (
|
|
30451
|
+
const byteArray = []
|
|
30452
|
+
for (let i = 0; i < str.length; ++i) {
|
|
29609
30453
|
// Node's code seems to be doing this and not & 0x7F..
|
|
29610
30454
|
byteArray.push(str.charCodeAt(i) & 0xFF)
|
|
29611
30455
|
}
|
|
@@ -29613,9 +30457,9 @@ function asciiToBytes (str) {
|
|
|
29613
30457
|
}
|
|
29614
30458
|
|
|
29615
30459
|
function utf16leToBytes (str, units) {
|
|
29616
|
-
|
|
29617
|
-
|
|
29618
|
-
for (
|
|
30460
|
+
let c, hi, lo
|
|
30461
|
+
const byteArray = []
|
|
30462
|
+
for (let i = 0; i < str.length; ++i) {
|
|
29619
30463
|
if ((units -= 2) < 0) break
|
|
29620
30464
|
|
|
29621
30465
|
c = str.charCodeAt(i)
|
|
@@ -29633,7 +30477,8 @@ function base64ToBytes (str) {
|
|
|
29633
30477
|
}
|
|
29634
30478
|
|
|
29635
30479
|
function blitBuffer (src, dst, offset, length) {
|
|
29636
|
-
|
|
30480
|
+
let i
|
|
30481
|
+
for (i = 0; i < length; ++i) {
|
|
29637
30482
|
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
29638
30483
|
dst[i + offset] = src[i]
|
|
29639
30484
|
}
|
|
@@ -29655,18 +30500,27 @@ function numberIsNaN (obj) {
|
|
|
29655
30500
|
|
|
29656
30501
|
// Create lookup table for `toString('hex')`
|
|
29657
30502
|
// See: https://github.com/feross/buffer/issues/219
|
|
29658
|
-
|
|
29659
|
-
|
|
29660
|
-
|
|
29661
|
-
for (
|
|
29662
|
-
|
|
29663
|
-
for (
|
|
30503
|
+
const hexSliceLookupTable = (function () {
|
|
30504
|
+
const alphabet = '0123456789abcdef'
|
|
30505
|
+
const table = new Array(256)
|
|
30506
|
+
for (let i = 0; i < 16; ++i) {
|
|
30507
|
+
const i16 = i * 16
|
|
30508
|
+
for (let j = 0; j < 16; ++j) {
|
|
29664
30509
|
table[i16 + j] = alphabet[i] + alphabet[j]
|
|
29665
30510
|
}
|
|
29666
30511
|
}
|
|
29667
30512
|
return table
|
|
29668
30513
|
})()
|
|
29669
30514
|
|
|
30515
|
+
// Return not function with Error if BigInt not supported
|
|
30516
|
+
function defineBigIntMethod (fn) {
|
|
30517
|
+
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
30518
|
+
}
|
|
30519
|
+
|
|
30520
|
+
function BufferBigIntNotDefined () {
|
|
30521
|
+
throw new Error('BigInt not supported')
|
|
30522
|
+
}
|
|
30523
|
+
|
|
29670
30524
|
|
|
29671
30525
|
/***/ }),
|
|
29672
30526
|
|
|
@@ -46941,7 +47795,7 @@ try {
|
|
|
46941
47795
|
/***/ ((module) => {
|
|
46942
47796
|
|
|
46943
47797
|
"use strict";
|
|
46944
|
-
module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.
|
|
47798
|
+
module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.59","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.1.59","@onekeyfe/hd-transport":"^0.1.59","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"}}');
|
|
46945
47799
|
|
|
46946
47800
|
/***/ })
|
|
46947
47801
|
|
|
@@ -49468,7 +50322,7 @@ const src_init = async settings => {
|
|
|
49468
50322
|
|
|
49469
50323
|
try {
|
|
49470
50324
|
await init({ ..._settings,
|
|
49471
|
-
version: "0.1.
|
|
50325
|
+
version: "0.1.59"
|
|
49472
50326
|
});
|
|
49473
50327
|
return true;
|
|
49474
50328
|
} catch (e) {
|