@onekeyfe/hd-web-sdk 0.1.58 → 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.
@@ -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;
@@ -6187,6 +6212,56 @@ const supportBatchPublicKey = features => {
6187
6212
  };
6188
6213
 
6189
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
+ },
6190
6265
  AptosGetAddress: {
6191
6266
  fields: {
6192
6267
  address_n: {
@@ -6242,6 +6317,65 @@ var nested = {
6242
6317
  }
6243
6318
  }
6244
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
+ },
6245
6379
  BinanceGetAddress: {
6246
6380
  fields: {
6247
6381
  address_n: {
@@ -9014,6 +9148,60 @@ var nested = {
9014
9148
  }
9015
9149
  }
9016
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
+ },
9017
9205
  CipherKeyValue: {
9018
9206
  fields: {
9019
9207
  address_n: {
@@ -14695,6 +14883,8 @@ var nested = {
14695
14883
  MessageType_AptosAddress: 10601,
14696
14884
  MessageType_AptosSignTx: 10602,
14697
14885
  MessageType_AptosSignedTx: 10603,
14886
+ MessageType_AptosSignMessage: 10604,
14887
+ MessageType_AptosMessageSignature: 10605,
14698
14888
  MessageType_WebAuthnListResidentCredentials: 800,
14699
14889
  MessageType_WebAuthnCredentials: 801,
14700
14890
  MessageType_WebAuthnAddResidentCredential: 802,
@@ -14735,6 +14925,14 @@ var nested = {
14735
14925
  MessageType_NearAddress: 10702,
14736
14926
  MessageType_NearSignTx: 10703,
14737
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,
14738
14936
  MessageType_DeviceBackToBoot: 903,
14739
14937
  MessageType_DeviceInfoSettings: 10001,
14740
14938
  MessageType_GetDeviceInfo: 10002,
@@ -15869,7 +16067,7 @@ DataManager.getFirmwareStatus = features => {
15869
16067
  return getReleaseStatus(targetDeviceConfigList, currentVersion);
15870
16068
  };
15871
16069
 
15872
- DataManager.getSysResourcesLatestRelease = features => {
16070
+ DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
15873
16071
  var _b, _c, _d;
15874
16072
 
15875
16073
  const deviceType = getDeviceType(features);
@@ -15877,7 +16075,7 @@ DataManager.getSysResourcesLatestRelease = features => {
15877
16075
  if (deviceType !== 'pro' && deviceType !== 'touch') return undefined;
15878
16076
  const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.firmware) !== null && _c !== void 0 ? _c : [];
15879
16077
  const currentVersion = deviceFirmwareVersion.join('.');
15880
- 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);
15881
16079
  return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.resource;
15882
16080
  };
15883
16081
 
@@ -18522,6 +18720,9 @@ class FirmwareUpdate extends BaseMethod {
18522
18720
  }, {
18523
18721
  name: 'binary',
18524
18722
  type: 'buffer'
18723
+ }, {
18724
+ name: 'forcedUpdateRes',
18725
+ type: 'boolean'
18525
18726
  }]);
18526
18727
 
18527
18728
  if (!payload.updateType) {
@@ -18529,7 +18730,8 @@ class FirmwareUpdate extends BaseMethod {
18529
18730
  }
18530
18731
 
18531
18732
  this.params = {
18532
- updateType: payload.updateType
18733
+ updateType: payload.updateType,
18734
+ forcedUpdateRes: payload.forcedUpdateRes
18533
18735
  };
18534
18736
 
18535
18737
  if ('version' in payload) {
@@ -18622,7 +18824,7 @@ class FirmwareUpdate extends BaseMethod {
18622
18824
 
18623
18825
  if (features && this.isSupportResourceUpdate(features, params.updateType)) {
18624
18826
  this.postTipMessage('CheckLatestUiResource');
18625
- const resourceUrl = DataManager.getSysResourcesLatestRelease(features);
18827
+ const resourceUrl = DataManager.getSysResourcesLatestRelease(features, params.forcedUpdateRes);
18626
18828
 
18627
18829
  if (resourceUrl) {
18628
18830
  this.postTipMessage('DownloadLatestUiResource');
@@ -22247,21 +22449,304 @@ class NearSignTransaction extends BaseMethod {
22247
22449
  getVersionRange() {
22248
22450
  return {
22249
22451
  model_mini: {
22250
- 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'
22251
22647
  }
22252
22648
  };
22253
22649
  }
22254
22650
 
22255
22651
  run() {
22256
22652
  return __awaiter(this, void 0, void 0, function* () {
22257
- const res = yield this.device.commands.typedCall('NearSignTx', 'NearSignedTx', Object.assign({}, this.params));
22653
+ const res = yield this.device.commands.typedCall('AptosSignTx', 'AptosSignedTx', Object.assign({}, this.params));
22258
22654
  return Promise.resolve(res.message);
22259
22655
  });
22260
22656
  }
22261
22657
 
22262
22658
  }
22263
22659
 
22264
- class AptosGetAddress extends BaseMethod {
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 {
22265
22750
  constructor() {
22266
22751
  super(...arguments);
22267
22752
  this.hasBundle = false;
@@ -22271,7 +22756,7 @@ class AptosGetAddress extends BaseMethod {
22271
22756
  var _a;
22272
22757
 
22273
22758
  this.checkDeviceId = true;
22274
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
22759
+ this.allowDeviceMode = [...this.allowDeviceMode];
22275
22760
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
22276
22761
  const payload = this.hasBundle ? this.payload : {
22277
22762
  bundle: [this.payload]
@@ -22300,13 +22785,6 @@ class AptosGetAddress extends BaseMethod {
22300
22785
  });
22301
22786
  }
22302
22787
 
22303
- publicKeyToAddress(publicKey) {
22304
- const hash = sha3.sha3_256.create();
22305
- hash.update(hexToBytes(publicKey));
22306
- hash.update('\x00');
22307
- return `0x${utils.bytesToHex(hash.digest())}`;
22308
- }
22309
-
22310
22788
  getVersionRange() {
22311
22789
  return {
22312
22790
  model_mini: {
@@ -22316,33 +22794,18 @@ class AptosGetAddress extends BaseMethod {
22316
22794
  }
22317
22795
 
22318
22796
  run() {
22319
- var _a;
22320
-
22321
22797
  return __awaiter(this, void 0, void 0, function* () {
22322
- if (this.hasBundle && supportBatchPublicKey((_a = this.device) === null || _a === void 0 ? void 0 : _a.features)) {
22323
- const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
22324
- paths: this.params,
22325
- ecdsa_curve_name: 'ed25519'
22326
- });
22327
- const result = res.message.public_keys.map((publicKey, index) => ({
22328
- path: serializedPath(this.params[index].address_n),
22329
- publicKey,
22330
- address: this.publicKeyToAddress(publicKey)
22331
- }));
22332
- return Promise.resolve(result);
22333
- }
22334
-
22335
22798
  const responses = [];
22336
22799
 
22337
22800
  for (let i = 0; i < this.params.length; i++) {
22338
22801
  const param = this.params[i];
22339
- const res = yield this.device.commands.typedCall('AptosGetAddress', 'AptosAddress', Object.assign({}, param));
22802
+ const res = yield this.device.commands.typedCall('AlgorandGetAddress', 'AlgorandAddress', Object.assign({}, param));
22340
22803
  const {
22341
22804
  address
22342
22805
  } = res.message;
22343
22806
  responses.push({
22344
22807
  path: serializedPath(param.address_n),
22345
- address: address === null || address === void 0 ? void 0 : address.toLowerCase()
22808
+ address
22346
22809
  });
22347
22810
  }
22348
22811
 
@@ -22352,7 +22815,58 @@ class AptosGetAddress extends BaseMethod {
22352
22815
 
22353
22816
  }
22354
22817
 
22355
- class AptosGetPublicKey extends BaseMethod {
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 {
22356
22870
  constructor() {
22357
22871
  super(...arguments);
22358
22872
  this.hasBundle = false;
@@ -22362,7 +22876,7 @@ class AptosGetPublicKey extends BaseMethod {
22362
22876
  var _a;
22363
22877
 
22364
22878
  this.checkDeviceId = true;
22365
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
22879
+ this.allowDeviceMode = [...this.allowDeviceMode];
22366
22880
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
22367
22881
  const payload = this.hasBundle ? this.payload : {
22368
22882
  bundle: [this.payload]
@@ -22401,24 +22915,35 @@ class AptosGetPublicKey extends BaseMethod {
22401
22915
 
22402
22916
  run() {
22403
22917
  return __awaiter(this, void 0, void 0, function* () {
22404
- const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
22405
- paths: this.params,
22406
- ecdsa_curve_name: 'ed25519'
22407
- });
22408
- const responses = res.message.public_keys.map((publicKey, index) => ({
22409
- path: serializedPath(this.params[index].address_n),
22410
- publicKey
22411
- }));
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
+
22412
22932
  return Promise.resolve(this.hasBundle ? responses : responses[0]);
22413
22933
  });
22414
22934
  }
22415
22935
 
22416
22936
  }
22417
22937
 
22418
- class AptosSignTransaction extends BaseMethod {
22938
+ class CosmosSignTransaction extends BaseMethod {
22939
+ constructor() {
22940
+ super(...arguments);
22941
+ this.hasBundle = false;
22942
+ }
22943
+
22419
22944
  init() {
22420
22945
  this.checkDeviceId = true;
22421
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
22946
+ this.allowDeviceMode = [...this.allowDeviceMode];
22422
22947
  validateParams(this.payload, [{
22423
22948
  name: 'path',
22424
22949
  required: true
@@ -22448,8 +22973,14 @@ class AptosSignTransaction extends BaseMethod {
22448
22973
 
22449
22974
  run() {
22450
22975
  return __awaiter(this, void 0, void 0, function* () {
22451
- const res = yield this.device.commands.typedCall('AptosSignTx', 'AptosSignedTx', Object.assign({}, this.params));
22452
- return Promise.resolve(res.message);
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
+ };
22453
22984
  });
22454
22985
  }
22455
22986
 
@@ -22515,7 +23046,12 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
22515
23046
  nearSignTransaction: NearSignTransaction,
22516
23047
  aptosGetAddress: AptosGetAddress,
22517
23048
  aptosGetPublicKey: AptosGetPublicKey,
22518
- aptosSignTransaction: AptosSignTransaction
23049
+ aptosSignTransaction: AptosSignTransaction,
23050
+ aptosSignMessage: AptosSignMessage,
23051
+ algoGetAddress: AlgoGetAddress,
23052
+ algoSignTransaction: AlgoSignTransaction,
23053
+ cosmosGetAddress: CosmosGetAddress,
23054
+ cosmosSignTransaction: CosmosSignTransaction
22519
23055
  });
22520
23056
 
22521
23057
  function findMethod(message) {
@@ -27888,9 +28424,9 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalObject) {
27888
28424
 
27889
28425
 
27890
28426
 
27891
- var base64 = __webpack_require__(5766)
27892
- var ieee754 = __webpack_require__(2333)
27893
- var customInspectSymbol =
28427
+ const base64 = __webpack_require__(5766)
28428
+ const ieee754 = __webpack_require__(2333)
28429
+ const customInspectSymbol =
27894
28430
  (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
27895
28431
  ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
27896
28432
  : null
@@ -27899,7 +28435,7 @@ exports.Buffer = Buffer
27899
28435
  exports.SlowBuffer = SlowBuffer
27900
28436
  exports.INSPECT_MAX_BYTES = 50
27901
28437
 
27902
- var K_MAX_LENGTH = 0x7fffffff
28438
+ const K_MAX_LENGTH = 0x7fffffff
27903
28439
  exports.kMaxLength = K_MAX_LENGTH
27904
28440
 
27905
28441
  /**
@@ -27929,8 +28465,8 @@ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
27929
28465
  function typedArraySupport () {
27930
28466
  // Can typed array instances can be augmented?
27931
28467
  try {
27932
- var arr = new Uint8Array(1)
27933
- var proto = { foo: function () { return 42 } }
28468
+ const arr = new Uint8Array(1)
28469
+ const proto = { foo: function () { return 42 } }
27934
28470
  Object.setPrototypeOf(proto, Uint8Array.prototype)
27935
28471
  Object.setPrototypeOf(arr, proto)
27936
28472
  return arr.foo() === 42
@@ -27960,7 +28496,7 @@ function createBuffer (length) {
27960
28496
  throw new RangeError('The value "' + length + '" is invalid for option "size"')
27961
28497
  }
27962
28498
  // Return an augmented `Uint8Array` instance
27963
- var buf = new Uint8Array(length)
28499
+ const buf = new Uint8Array(length)
27964
28500
  Object.setPrototypeOf(buf, Buffer.prototype)
27965
28501
  return buf
27966
28502
  }
@@ -28023,19 +28559,17 @@ function from (value, encodingOrOffset, length) {
28023
28559
  )
28024
28560
  }
28025
28561
 
28026
- var valueOf = value.valueOf && value.valueOf()
28562
+ const valueOf = value.valueOf && value.valueOf()
28027
28563
  if (valueOf != null && valueOf !== value) {
28028
28564
  return Buffer.from(valueOf, encodingOrOffset, length)
28029
28565
  }
28030
28566
 
28031
- var b = fromObject(value)
28567
+ const b = fromObject(value)
28032
28568
  if (b) return b
28033
28569
 
28034
28570
  if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
28035
28571
  typeof value[Symbol.toPrimitive] === 'function') {
28036
- return Buffer.from(
28037
- value[Symbol.toPrimitive]('string'), encodingOrOffset, length
28038
- )
28572
+ return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
28039
28573
  }
28040
28574
 
28041
28575
  throw new TypeError(
@@ -28120,10 +28654,10 @@ function fromString (string, encoding) {
28120
28654
  throw new TypeError('Unknown encoding: ' + encoding)
28121
28655
  }
28122
28656
 
28123
- var length = byteLength(string, encoding) | 0
28124
- var buf = createBuffer(length)
28657
+ const length = byteLength(string, encoding) | 0
28658
+ let buf = createBuffer(length)
28125
28659
 
28126
- var actual = buf.write(string, encoding)
28660
+ const actual = buf.write(string, encoding)
28127
28661
 
28128
28662
  if (actual !== length) {
28129
28663
  // Writing a hex string, for example, that contains invalid characters will
@@ -28136,9 +28670,9 @@ function fromString (string, encoding) {
28136
28670
  }
28137
28671
 
28138
28672
  function fromArrayLike (array) {
28139
- var length = array.length < 0 ? 0 : checked(array.length) | 0
28140
- var buf = createBuffer(length)
28141
- for (var i = 0; i < length; i += 1) {
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) {
28142
28676
  buf[i] = array[i] & 255
28143
28677
  }
28144
28678
  return buf
@@ -28146,7 +28680,7 @@ function fromArrayLike (array) {
28146
28680
 
28147
28681
  function fromArrayView (arrayView) {
28148
28682
  if (isInstance(arrayView, Uint8Array)) {
28149
- var copy = new Uint8Array(arrayView)
28683
+ const copy = new Uint8Array(arrayView)
28150
28684
  return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
28151
28685
  }
28152
28686
  return fromArrayLike(arrayView)
@@ -28161,7 +28695,7 @@ function fromArrayBuffer (array, byteOffset, length) {
28161
28695
  throw new RangeError('"length" is outside of buffer bounds')
28162
28696
  }
28163
28697
 
28164
- var buf
28698
+ let buf
28165
28699
  if (byteOffset === undefined && length === undefined) {
28166
28700
  buf = new Uint8Array(array)
28167
28701
  } else if (length === undefined) {
@@ -28178,8 +28712,8 @@ function fromArrayBuffer (array, byteOffset, length) {
28178
28712
 
28179
28713
  function fromObject (obj) {
28180
28714
  if (Buffer.isBuffer(obj)) {
28181
- var len = checked(obj.length) | 0
28182
- var buf = createBuffer(len)
28715
+ const len = checked(obj.length) | 0
28716
+ const buf = createBuffer(len)
28183
28717
 
28184
28718
  if (buf.length === 0) {
28185
28719
  return buf
@@ -28234,10 +28768,10 @@ Buffer.compare = function compare (a, b) {
28234
28768
 
28235
28769
  if (a === b) return 0
28236
28770
 
28237
- var x = a.length
28238
- var y = b.length
28771
+ let x = a.length
28772
+ let y = b.length
28239
28773
 
28240
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
28774
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
28241
28775
  if (a[i] !== b[i]) {
28242
28776
  x = a[i]
28243
28777
  y = b[i]
@@ -28278,7 +28812,7 @@ Buffer.concat = function concat (list, length) {
28278
28812
  return Buffer.alloc(0)
28279
28813
  }
28280
28814
 
28281
- var i
28815
+ let i
28282
28816
  if (length === undefined) {
28283
28817
  length = 0
28284
28818
  for (i = 0; i < list.length; ++i) {
@@ -28286,13 +28820,14 @@ Buffer.concat = function concat (list, length) {
28286
28820
  }
28287
28821
  }
28288
28822
 
28289
- var buffer = Buffer.allocUnsafe(length)
28290
- var pos = 0
28823
+ const buffer = Buffer.allocUnsafe(length)
28824
+ let pos = 0
28291
28825
  for (i = 0; i < list.length; ++i) {
28292
- var buf = list[i]
28826
+ let buf = list[i]
28293
28827
  if (isInstance(buf, Uint8Array)) {
28294
28828
  if (pos + buf.length > buffer.length) {
28295
- Buffer.from(buf).copy(buffer, pos)
28829
+ if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
28830
+ buf.copy(buffer, pos)
28296
28831
  } else {
28297
28832
  Uint8Array.prototype.set.call(
28298
28833
  buffer,
@@ -28324,12 +28859,12 @@ function byteLength (string, encoding) {
28324
28859
  )
28325
28860
  }
28326
28861
 
28327
- var len = string.length
28328
- var mustMatch = (arguments.length > 2 && arguments[2] === true)
28862
+ const len = string.length
28863
+ const mustMatch = (arguments.length > 2 && arguments[2] === true)
28329
28864
  if (!mustMatch && len === 0) return 0
28330
28865
 
28331
28866
  // Use a for loop to avoid recursion
28332
- var loweredCase = false
28867
+ let loweredCase = false
28333
28868
  for (;;) {
28334
28869
  switch (encoding) {
28335
28870
  case 'ascii':
@@ -28360,7 +28895,7 @@ function byteLength (string, encoding) {
28360
28895
  Buffer.byteLength = byteLength
28361
28896
 
28362
28897
  function slowToString (encoding, start, end) {
28363
- var loweredCase = false
28898
+ let loweredCase = false
28364
28899
 
28365
28900
  // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
28366
28901
  // property of a typed array.
@@ -28438,28 +28973,28 @@ function slowToString (encoding, start, end) {
28438
28973
  Buffer.prototype._isBuffer = true
28439
28974
 
28440
28975
  function swap (b, n, m) {
28441
- var i = b[n]
28976
+ const i = b[n]
28442
28977
  b[n] = b[m]
28443
28978
  b[m] = i
28444
28979
  }
28445
28980
 
28446
28981
  Buffer.prototype.swap16 = function swap16 () {
28447
- var len = this.length
28982
+ const len = this.length
28448
28983
  if (len % 2 !== 0) {
28449
28984
  throw new RangeError('Buffer size must be a multiple of 16-bits')
28450
28985
  }
28451
- for (var i = 0; i < len; i += 2) {
28986
+ for (let i = 0; i < len; i += 2) {
28452
28987
  swap(this, i, i + 1)
28453
28988
  }
28454
28989
  return this
28455
28990
  }
28456
28991
 
28457
28992
  Buffer.prototype.swap32 = function swap32 () {
28458
- var len = this.length
28993
+ const len = this.length
28459
28994
  if (len % 4 !== 0) {
28460
28995
  throw new RangeError('Buffer size must be a multiple of 32-bits')
28461
28996
  }
28462
- for (var i = 0; i < len; i += 4) {
28997
+ for (let i = 0; i < len; i += 4) {
28463
28998
  swap(this, i, i + 3)
28464
28999
  swap(this, i + 1, i + 2)
28465
29000
  }
@@ -28467,11 +29002,11 @@ Buffer.prototype.swap32 = function swap32 () {
28467
29002
  }
28468
29003
 
28469
29004
  Buffer.prototype.swap64 = function swap64 () {
28470
- var len = this.length
29005
+ const len = this.length
28471
29006
  if (len % 8 !== 0) {
28472
29007
  throw new RangeError('Buffer size must be a multiple of 64-bits')
28473
29008
  }
28474
- for (var i = 0; i < len; i += 8) {
29009
+ for (let i = 0; i < len; i += 8) {
28475
29010
  swap(this, i, i + 7)
28476
29011
  swap(this, i + 1, i + 6)
28477
29012
  swap(this, i + 2, i + 5)
@@ -28481,7 +29016,7 @@ Buffer.prototype.swap64 = function swap64 () {
28481
29016
  }
28482
29017
 
28483
29018
  Buffer.prototype.toString = function toString () {
28484
- var length = this.length
29019
+ const length = this.length
28485
29020
  if (length === 0) return ''
28486
29021
  if (arguments.length === 0) return utf8Slice(this, 0, length)
28487
29022
  return slowToString.apply(this, arguments)
@@ -28496,8 +29031,8 @@ Buffer.prototype.equals = function equals (b) {
28496
29031
  }
28497
29032
 
28498
29033
  Buffer.prototype.inspect = function inspect () {
28499
- var str = ''
28500
- var max = exports.INSPECT_MAX_BYTES
29034
+ let str = ''
29035
+ const max = exports.INSPECT_MAX_BYTES
28501
29036
  str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
28502
29037
  if (this.length > max) str += ' ... '
28503
29038
  return '<Buffer ' + str + '>'
@@ -28551,14 +29086,14 @@ Buffer.prototype.compare = function compare (target, start, end, thisStart, this
28551
29086
 
28552
29087
  if (this === target) return 0
28553
29088
 
28554
- var x = thisEnd - thisStart
28555
- var y = end - start
28556
- var len = Math.min(x, y)
29089
+ let x = thisEnd - thisStart
29090
+ let y = end - start
29091
+ const len = Math.min(x, y)
28557
29092
 
28558
- var thisCopy = this.slice(thisStart, thisEnd)
28559
- var targetCopy = target.slice(start, end)
29093
+ const thisCopy = this.slice(thisStart, thisEnd)
29094
+ const targetCopy = target.slice(start, end)
28560
29095
 
28561
- for (var i = 0; i < len; ++i) {
29096
+ for (let i = 0; i < len; ++i) {
28562
29097
  if (thisCopy[i] !== targetCopy[i]) {
28563
29098
  x = thisCopy[i]
28564
29099
  y = targetCopy[i]
@@ -28637,9 +29172,9 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
28637
29172
  }
28638
29173
 
28639
29174
  function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
28640
- var indexSize = 1
28641
- var arrLength = arr.length
28642
- var valLength = val.length
29175
+ let indexSize = 1
29176
+ let arrLength = arr.length
29177
+ let valLength = val.length
28643
29178
 
28644
29179
  if (encoding !== undefined) {
28645
29180
  encoding = String(encoding).toLowerCase()
@@ -28663,9 +29198,9 @@ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
28663
29198
  }
28664
29199
  }
28665
29200
 
28666
- var i
29201
+ let i
28667
29202
  if (dir) {
28668
- var foundIndex = -1
29203
+ let foundIndex = -1
28669
29204
  for (i = byteOffset; i < arrLength; i++) {
28670
29205
  if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
28671
29206
  if (foundIndex === -1) foundIndex = i
@@ -28678,8 +29213,8 @@ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
28678
29213
  } else {
28679
29214
  if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
28680
29215
  for (i = byteOffset; i >= 0; i--) {
28681
- var found = true
28682
- for (var j = 0; j < valLength; j++) {
29216
+ let found = true
29217
+ for (let j = 0; j < valLength; j++) {
28683
29218
  if (read(arr, i + j) !== read(val, j)) {
28684
29219
  found = false
28685
29220
  break
@@ -28706,7 +29241,7 @@ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding)
28706
29241
 
28707
29242
  function hexWrite (buf, string, offset, length) {
28708
29243
  offset = Number(offset) || 0
28709
- var remaining = buf.length - offset
29244
+ const remaining = buf.length - offset
28710
29245
  if (!length) {
28711
29246
  length = remaining
28712
29247
  } else {
@@ -28716,13 +29251,14 @@ function hexWrite (buf, string, offset, length) {
28716
29251
  }
28717
29252
  }
28718
29253
 
28719
- var strLen = string.length
29254
+ const strLen = string.length
28720
29255
 
28721
29256
  if (length > strLen / 2) {
28722
29257
  length = strLen / 2
28723
29258
  }
28724
- for (var i = 0; i < length; ++i) {
28725
- var parsed = parseInt(string.substr(i * 2, 2), 16)
29259
+ let i
29260
+ for (i = 0; i < length; ++i) {
29261
+ const parsed = parseInt(string.substr(i * 2, 2), 16)
28726
29262
  if (numberIsNaN(parsed)) return i
28727
29263
  buf[offset + i] = parsed
28728
29264
  }
@@ -28772,7 +29308,7 @@ Buffer.prototype.write = function write (string, offset, length, encoding) {
28772
29308
  )
28773
29309
  }
28774
29310
 
28775
- var remaining = this.length - offset
29311
+ const remaining = this.length - offset
28776
29312
  if (length === undefined || length > remaining) length = remaining
28777
29313
 
28778
29314
  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
@@ -28781,7 +29317,7 @@ Buffer.prototype.write = function write (string, offset, length, encoding) {
28781
29317
 
28782
29318
  if (!encoding) encoding = 'utf8'
28783
29319
 
28784
- var loweredCase = false
29320
+ let loweredCase = false
28785
29321
  for (;;) {
28786
29322
  switch (encoding) {
28787
29323
  case 'hex':
@@ -28831,13 +29367,13 @@ function base64Slice (buf, start, end) {
28831
29367
 
28832
29368
  function utf8Slice (buf, start, end) {
28833
29369
  end = Math.min(buf.length, end)
28834
- var res = []
29370
+ const res = []
28835
29371
 
28836
- var i = start
29372
+ let i = start
28837
29373
  while (i < end) {
28838
- var firstByte = buf[i]
28839
- var codePoint = null
28840
- var bytesPerSequence = (firstByte > 0xEF)
29374
+ const firstByte = buf[i]
29375
+ let codePoint = null
29376
+ let bytesPerSequence = (firstByte > 0xEF)
28841
29377
  ? 4
28842
29378
  : (firstByte > 0xDF)
28843
29379
  ? 3
@@ -28846,7 +29382,7 @@ function utf8Slice (buf, start, end) {
28846
29382
  : 1
28847
29383
 
28848
29384
  if (i + bytesPerSequence <= end) {
28849
- var secondByte, thirdByte, fourthByte, tempCodePoint
29385
+ let secondByte, thirdByte, fourthByte, tempCodePoint
28850
29386
 
28851
29387
  switch (bytesPerSequence) {
28852
29388
  case 1:
@@ -28908,17 +29444,17 @@ function utf8Slice (buf, start, end) {
28908
29444
  // Based on http://stackoverflow.com/a/22747272/680742, the browser with
28909
29445
  // the lowest limit is Chrome, with 0x10000 args.
28910
29446
  // We go 1 magnitude less, for safety
28911
- var MAX_ARGUMENTS_LENGTH = 0x1000
29447
+ const MAX_ARGUMENTS_LENGTH = 0x1000
28912
29448
 
28913
29449
  function decodeCodePointsArray (codePoints) {
28914
- var len = codePoints.length
29450
+ const len = codePoints.length
28915
29451
  if (len <= MAX_ARGUMENTS_LENGTH) {
28916
29452
  return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
28917
29453
  }
28918
29454
 
28919
29455
  // Decode in chunks to avoid "call stack size exceeded".
28920
- var res = ''
28921
- var i = 0
29456
+ let res = ''
29457
+ let i = 0
28922
29458
  while (i < len) {
28923
29459
  res += String.fromCharCode.apply(
28924
29460
  String,
@@ -28929,50 +29465,50 @@ function decodeCodePointsArray (codePoints) {
28929
29465
  }
28930
29466
 
28931
29467
  function asciiSlice (buf, start, end) {
28932
- var ret = ''
29468
+ let ret = ''
28933
29469
  end = Math.min(buf.length, end)
28934
29470
 
28935
- for (var i = start; i < end; ++i) {
29471
+ for (let i = start; i < end; ++i) {
28936
29472
  ret += String.fromCharCode(buf[i] & 0x7F)
28937
29473
  }
28938
29474
  return ret
28939
29475
  }
28940
29476
 
28941
29477
  function latin1Slice (buf, start, end) {
28942
- var ret = ''
29478
+ let ret = ''
28943
29479
  end = Math.min(buf.length, end)
28944
29480
 
28945
- for (var i = start; i < end; ++i) {
29481
+ for (let i = start; i < end; ++i) {
28946
29482
  ret += String.fromCharCode(buf[i])
28947
29483
  }
28948
29484
  return ret
28949
29485
  }
28950
29486
 
28951
29487
  function hexSlice (buf, start, end) {
28952
- var len = buf.length
29488
+ const len = buf.length
28953
29489
 
28954
29490
  if (!start || start < 0) start = 0
28955
29491
  if (!end || end < 0 || end > len) end = len
28956
29492
 
28957
- var out = ''
28958
- for (var i = start; i < end; ++i) {
29493
+ let out = ''
29494
+ for (let i = start; i < end; ++i) {
28959
29495
  out += hexSliceLookupTable[buf[i]]
28960
29496
  }
28961
29497
  return out
28962
29498
  }
28963
29499
 
28964
29500
  function utf16leSlice (buf, start, end) {
28965
- var bytes = buf.slice(start, end)
28966
- var res = ''
29501
+ const bytes = buf.slice(start, end)
29502
+ let res = ''
28967
29503
  // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
28968
- for (var i = 0; i < bytes.length - 1; i += 2) {
29504
+ for (let i = 0; i < bytes.length - 1; i += 2) {
28969
29505
  res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
28970
29506
  }
28971
29507
  return res
28972
29508
  }
28973
29509
 
28974
29510
  Buffer.prototype.slice = function slice (start, end) {
28975
- var len = this.length
29511
+ const len = this.length
28976
29512
  start = ~~start
28977
29513
  end = end === undefined ? len : ~~end
28978
29514
 
@@ -28992,7 +29528,7 @@ Buffer.prototype.slice = function slice (start, end) {
28992
29528
 
28993
29529
  if (end < start) end = start
28994
29530
 
28995
- var newBuf = this.subarray(start, end)
29531
+ const newBuf = this.subarray(start, end)
28996
29532
  // Return an augmented `Uint8Array` instance
28997
29533
  Object.setPrototypeOf(newBuf, Buffer.prototype)
28998
29534
 
@@ -29013,9 +29549,9 @@ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert)
29013
29549
  byteLength = byteLength >>> 0
29014
29550
  if (!noAssert) checkOffset(offset, byteLength, this.length)
29015
29551
 
29016
- var val = this[offset]
29017
- var mul = 1
29018
- var i = 0
29552
+ let val = this[offset]
29553
+ let mul = 1
29554
+ let i = 0
29019
29555
  while (++i < byteLength && (mul *= 0x100)) {
29020
29556
  val += this[offset + i] * mul
29021
29557
  }
@@ -29031,8 +29567,8 @@ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert)
29031
29567
  checkOffset(offset, byteLength, this.length)
29032
29568
  }
29033
29569
 
29034
- var val = this[offset + --byteLength]
29035
- var mul = 1
29570
+ let val = this[offset + --byteLength]
29571
+ let mul = 1
29036
29572
  while (byteLength > 0 && (mul *= 0x100)) {
29037
29573
  val += this[offset + --byteLength] * mul
29038
29574
  }
@@ -29083,14 +29619,58 @@ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
29083
29619
  this[offset + 3])
29084
29620
  }
29085
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
+
29086
29666
  Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
29087
29667
  offset = offset >>> 0
29088
29668
  byteLength = byteLength >>> 0
29089
29669
  if (!noAssert) checkOffset(offset, byteLength, this.length)
29090
29670
 
29091
- var val = this[offset]
29092
- var mul = 1
29093
- var i = 0
29671
+ let val = this[offset]
29672
+ let mul = 1
29673
+ let i = 0
29094
29674
  while (++i < byteLength && (mul *= 0x100)) {
29095
29675
  val += this[offset + i] * mul
29096
29676
  }
@@ -29106,9 +29686,9 @@ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
29106
29686
  byteLength = byteLength >>> 0
29107
29687
  if (!noAssert) checkOffset(offset, byteLength, this.length)
29108
29688
 
29109
- var i = byteLength
29110
- var mul = 1
29111
- var val = this[offset + --i]
29689
+ let i = byteLength
29690
+ let mul = 1
29691
+ let val = this[offset + --i]
29112
29692
  while (i > 0 && (mul *= 0x100)) {
29113
29693
  val += this[offset + --i] * mul
29114
29694
  }
@@ -29129,14 +29709,14 @@ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
29129
29709
  Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
29130
29710
  offset = offset >>> 0
29131
29711
  if (!noAssert) checkOffset(offset, 2, this.length)
29132
- var val = this[offset] | (this[offset + 1] << 8)
29712
+ const val = this[offset] | (this[offset + 1] << 8)
29133
29713
  return (val & 0x8000) ? val | 0xFFFF0000 : val
29134
29714
  }
29135
29715
 
29136
29716
  Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
29137
29717
  offset = offset >>> 0
29138
29718
  if (!noAssert) checkOffset(offset, 2, this.length)
29139
- var val = this[offset + 1] | (this[offset] << 8)
29719
+ const val = this[offset + 1] | (this[offset] << 8)
29140
29720
  return (val & 0x8000) ? val | 0xFFFF0000 : val
29141
29721
  }
29142
29722
 
@@ -29160,6 +29740,48 @@ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
29160
29740
  (this[offset + 3])
29161
29741
  }
29162
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
+
29163
29785
  Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
29164
29786
  offset = offset >>> 0
29165
29787
  if (!noAssert) checkOffset(offset, 4, this.length)
@@ -29196,12 +29818,12 @@ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength,
29196
29818
  offset = offset >>> 0
29197
29819
  byteLength = byteLength >>> 0
29198
29820
  if (!noAssert) {
29199
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
29821
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1
29200
29822
  checkInt(this, value, offset, byteLength, maxBytes, 0)
29201
29823
  }
29202
29824
 
29203
- var mul = 1
29204
- var i = 0
29825
+ let mul = 1
29826
+ let i = 0
29205
29827
  this[offset] = value & 0xFF
29206
29828
  while (++i < byteLength && (mul *= 0x100)) {
29207
29829
  this[offset + i] = (value / mul) & 0xFF
@@ -29216,12 +29838,12 @@ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength,
29216
29838
  offset = offset >>> 0
29217
29839
  byteLength = byteLength >>> 0
29218
29840
  if (!noAssert) {
29219
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
29841
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1
29220
29842
  checkInt(this, value, offset, byteLength, maxBytes, 0)
29221
29843
  }
29222
29844
 
29223
- var i = byteLength - 1
29224
- var mul = 1
29845
+ let i = byteLength - 1
29846
+ let mul = 1
29225
29847
  this[offset + i] = value & 0xFF
29226
29848
  while (--i >= 0 && (mul *= 0x100)) {
29227
29849
  this[offset + i] = (value / mul) & 0xFF
@@ -29283,18 +29905,70 @@ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert
29283
29905
  return offset + 4
29284
29906
  }
29285
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
+
29286
29960
  Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
29287
29961
  value = +value
29288
29962
  offset = offset >>> 0
29289
29963
  if (!noAssert) {
29290
- var limit = Math.pow(2, (8 * byteLength) - 1)
29964
+ const limit = Math.pow(2, (8 * byteLength) - 1)
29291
29965
 
29292
29966
  checkInt(this, value, offset, byteLength, limit - 1, -limit)
29293
29967
  }
29294
29968
 
29295
- var i = 0
29296
- var mul = 1
29297
- var sub = 0
29969
+ let i = 0
29970
+ let mul = 1
29971
+ let sub = 0
29298
29972
  this[offset] = value & 0xFF
29299
29973
  while (++i < byteLength && (mul *= 0x100)) {
29300
29974
  if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
@@ -29310,14 +29984,14 @@ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, no
29310
29984
  value = +value
29311
29985
  offset = offset >>> 0
29312
29986
  if (!noAssert) {
29313
- var limit = Math.pow(2, (8 * byteLength) - 1)
29987
+ const limit = Math.pow(2, (8 * byteLength) - 1)
29314
29988
 
29315
29989
  checkInt(this, value, offset, byteLength, limit - 1, -limit)
29316
29990
  }
29317
29991
 
29318
- var i = byteLength - 1
29319
- var mul = 1
29320
- var sub = 0
29992
+ let i = byteLength - 1
29993
+ let mul = 1
29994
+ let sub = 0
29321
29995
  this[offset + i] = value & 0xFF
29322
29996
  while (--i >= 0 && (mul *= 0x100)) {
29323
29997
  if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
@@ -29379,6 +30053,14 @@ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert)
29379
30053
  return offset + 4
29380
30054
  }
29381
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
+
29382
30064
  function checkIEEE754 (buf, value, offset, ext, max, min) {
29383
30065
  if (offset + ext > buf.length) throw new RangeError('Index out of range')
29384
30066
  if (offset < 0) throw new RangeError('Index out of range')
@@ -29446,7 +30128,7 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
29446
30128
  end = target.length - targetStart + start
29447
30129
  }
29448
30130
 
29449
- var len = end - start
30131
+ const len = end - start
29450
30132
 
29451
30133
  if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
29452
30134
  // Use built-in when available, missing from IE11
@@ -29484,7 +30166,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
29484
30166
  throw new TypeError('Unknown encoding: ' + encoding)
29485
30167
  }
29486
30168
  if (val.length === 1) {
29487
- var code = val.charCodeAt(0)
30169
+ const code = val.charCodeAt(0)
29488
30170
  if ((encoding === 'utf8' && code < 128) ||
29489
30171
  encoding === 'latin1') {
29490
30172
  // Fast path: If `val` fits into a single byte, use that numeric value.
@@ -29511,16 +30193,16 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
29511
30193
 
29512
30194
  if (!val) val = 0
29513
30195
 
29514
- var i
30196
+ let i
29515
30197
  if (typeof val === 'number') {
29516
30198
  for (i = start; i < end; ++i) {
29517
30199
  this[i] = val
29518
30200
  }
29519
30201
  } else {
29520
- var bytes = Buffer.isBuffer(val)
30202
+ const bytes = Buffer.isBuffer(val)
29521
30203
  ? val
29522
30204
  : Buffer.from(val, encoding)
29523
- var len = bytes.length
30205
+ const len = bytes.length
29524
30206
  if (len === 0) {
29525
30207
  throw new TypeError('The value "' + val +
29526
30208
  '" is invalid for argument "value"')
@@ -29533,10 +30215,143 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
29533
30215
  return this
29534
30216
  }
29535
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
+
29536
30351
  // HELPER FUNCTIONS
29537
30352
  // ================
29538
30353
 
29539
- var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
30354
+ const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
29540
30355
 
29541
30356
  function base64clean (str) {
29542
30357
  // Node takes equal signs as end of the Base64 encoding
@@ -29554,12 +30369,12 @@ function base64clean (str) {
29554
30369
 
29555
30370
  function utf8ToBytes (string, units) {
29556
30371
  units = units || Infinity
29557
- var codePoint
29558
- var length = string.length
29559
- var leadSurrogate = null
29560
- var bytes = []
30372
+ let codePoint
30373
+ const length = string.length
30374
+ let leadSurrogate = null
30375
+ const bytes = []
29561
30376
 
29562
- for (var i = 0; i < length; ++i) {
30377
+ for (let i = 0; i < length; ++i) {
29563
30378
  codePoint = string.charCodeAt(i)
29564
30379
 
29565
30380
  // is surrogate component
@@ -29633,8 +30448,8 @@ function utf8ToBytes (string, units) {
29633
30448
  }
29634
30449
 
29635
30450
  function asciiToBytes (str) {
29636
- var byteArray = []
29637
- for (var i = 0; i < str.length; ++i) {
30451
+ const byteArray = []
30452
+ for (let i = 0; i < str.length; ++i) {
29638
30453
  // Node's code seems to be doing this and not & 0x7F..
29639
30454
  byteArray.push(str.charCodeAt(i) & 0xFF)
29640
30455
  }
@@ -29642,9 +30457,9 @@ function asciiToBytes (str) {
29642
30457
  }
29643
30458
 
29644
30459
  function utf16leToBytes (str, units) {
29645
- var c, hi, lo
29646
- var byteArray = []
29647
- for (var i = 0; i < str.length; ++i) {
30460
+ let c, hi, lo
30461
+ const byteArray = []
30462
+ for (let i = 0; i < str.length; ++i) {
29648
30463
  if ((units -= 2) < 0) break
29649
30464
 
29650
30465
  c = str.charCodeAt(i)
@@ -29662,7 +30477,8 @@ function base64ToBytes (str) {
29662
30477
  }
29663
30478
 
29664
30479
  function blitBuffer (src, dst, offset, length) {
29665
- for (var i = 0; i < length; ++i) {
30480
+ let i
30481
+ for (i = 0; i < length; ++i) {
29666
30482
  if ((i + offset >= dst.length) || (i >= src.length)) break
29667
30483
  dst[i + offset] = src[i]
29668
30484
  }
@@ -29684,18 +30500,27 @@ function numberIsNaN (obj) {
29684
30500
 
29685
30501
  // Create lookup table for `toString('hex')`
29686
30502
  // See: https://github.com/feross/buffer/issues/219
29687
- var hexSliceLookupTable = (function () {
29688
- var alphabet = '0123456789abcdef'
29689
- var table = new Array(256)
29690
- for (var i = 0; i < 16; ++i) {
29691
- var i16 = i * 16
29692
- for (var j = 0; j < 16; ++j) {
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) {
29693
30509
  table[i16 + j] = alphabet[i] + alphabet[j]
29694
30510
  }
29695
30511
  }
29696
30512
  return table
29697
30513
  })()
29698
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
+
29699
30524
 
29700
30525
  /***/ }),
29701
30526
 
@@ -46970,7 +47795,7 @@ try {
46970
47795
  /***/ ((module) => {
46971
47796
 
46972
47797
  "use strict";
46973
- module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.58","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.58","@onekeyfe/hd-transport":"^0.1.58","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"}}');
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"}}');
46974
47799
 
46975
47800
  /***/ })
46976
47801
 
@@ -49497,7 +50322,7 @@ const src_init = async settings => {
49497
50322
 
49498
50323
  try {
49499
50324
  await init({ ..._settings,
49500
- version: "0.1.58"
50325
+ version: "0.1.59"
49501
50326
  });
49502
50327
  return true;
49503
50328
  } catch (e) {