@onekeyfe/hd-web-sdk 0.1.54 → 0.1.56

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.
@@ -4086,11 +4086,6 @@ const inject = ({
4086
4086
  connectId,
4087
4087
  method: 'getFeatures'
4088
4088
  }),
4089
- batchGetPublicKey: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
4090
- connectId,
4091
- deviceId,
4092
- method: 'batchGetPublicKey'
4093
- })),
4094
4089
  checkFirmwareRelease: connectId => call({
4095
4090
  connectId,
4096
4091
  method: 'checkFirmwareRelease'
@@ -4334,6 +4329,11 @@ const inject = ({
4334
4329
  deviceId,
4335
4330
  method: 'aptosGetAddress'
4336
4331
  })),
4332
+ aptosGetPublicKey: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
4333
+ connectId,
4334
+ deviceId,
4335
+ method: 'aptosGetPublicKey'
4336
+ })),
4337
4337
  aptosSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
4338
4338
  connectId,
4339
4339
  deviceId,
@@ -10167,7 +10167,7 @@ var nested = {
10167
10167
  }
10168
10168
  }
10169
10169
  },
10170
- BixinReboot: {
10170
+ DeviceBackToBoot: {
10171
10171
  fields: {}
10172
10172
  },
10173
10173
  BixinBackupRequest: {
@@ -10437,6 +10437,104 @@ var nested = {
10437
10437
  }
10438
10438
  }
10439
10439
  },
10440
+ ResourceUpload: {
10441
+ fields: {
10442
+ extension: {
10443
+ rule: "required",
10444
+ type: "string",
10445
+ id: 1
10446
+ },
10447
+ data_length: {
10448
+ rule: "required",
10449
+ type: "uint32",
10450
+ id: 2
10451
+ },
10452
+ res_type: {
10453
+ rule: "required",
10454
+ type: "ResourceType",
10455
+ id: 3
10456
+ },
10457
+ zoom_data_length: {
10458
+ rule: "required",
10459
+ type: "uint32",
10460
+ id: 5
10461
+ },
10462
+ nft_meta_data: {
10463
+ type: "bytes",
10464
+ id: 4
10465
+ }
10466
+ },
10467
+ nested: {
10468
+ ResourceType: {
10469
+ values: {
10470
+ WallPaper: 0,
10471
+ Nft: 1
10472
+ }
10473
+ }
10474
+ }
10475
+ },
10476
+ ZoomRequest: {
10477
+ fields: {
10478
+ offset: {
10479
+ type: "uint32",
10480
+ id: 1
10481
+ },
10482
+ data_length: {
10483
+ rule: "required",
10484
+ type: "uint32",
10485
+ id: 2
10486
+ }
10487
+ }
10488
+ },
10489
+ ResourceRequest: {
10490
+ fields: {
10491
+ offset: {
10492
+ type: "uint32",
10493
+ id: 1
10494
+ },
10495
+ data_length: {
10496
+ rule: "required",
10497
+ type: "uint32",
10498
+ id: 2
10499
+ }
10500
+ }
10501
+ },
10502
+ ResourceAck: {
10503
+ fields: {
10504
+ data_chunk: {
10505
+ rule: "required",
10506
+ type: "bytes",
10507
+ id: 1
10508
+ },
10509
+ hash: {
10510
+ type: "bytes",
10511
+ id: 2
10512
+ }
10513
+ }
10514
+ },
10515
+ ResourceUpdate: {
10516
+ fields: {
10517
+ file_name: {
10518
+ rule: "required",
10519
+ type: "string",
10520
+ id: 1
10521
+ },
10522
+ data_length: {
10523
+ rule: "required",
10524
+ type: "uint32",
10525
+ id: 2
10526
+ },
10527
+ initial_data_chunk: {
10528
+ rule: "required",
10529
+ type: "bytes",
10530
+ id: 3
10531
+ },
10532
+ hash: {
10533
+ type: "bytes",
10534
+ id: 4
10535
+ }
10536
+ }
10537
+ },
10440
10538
  NFTWriteInfo: {
10441
10539
  fields: {
10442
10540
  index: {
@@ -11433,6 +11531,7 @@ var nested = {
11433
11531
  }
11434
11532
  },
11435
11533
  raw_tx: {
11534
+ rule: "required",
11436
11535
  type: "bytes",
11437
11536
  id: 2
11438
11537
  }
@@ -13561,16 +13660,6 @@ var nested = {
13561
13660
  MessageType_StarcoinSignMessage: 10306,
13562
13661
  MessageType_StarcoinMessageSignature: 10307,
13563
13662
  MessageType_StarcoinVerifyMessage: 10308,
13564
- MessageType_ConfluxGetAddress: 10401,
13565
- MessageType_ConfluxAddress: 10402,
13566
- MessageType_ConfluxSignTx: 10403,
13567
- MessageType_ConfluxTxRequest: 10404,
13568
- MessageType_ConfluxTxAck: 10405,
13569
- MessageType_ConfluxSignMessage: 10406,
13570
- MessageType_ConfluxSignMessageCIP23: 10407,
13571
- MessageType_ConfluxMessageSignature: 10408,
13572
- MessageType_ConfluxVerifyMessage: 10409,
13573
- MessageType_ConfluxVerifyMessageCIP23: 10410,
13574
13663
  MessageType_AptosGetAddress: 10600,
13575
13664
  MessageType_AptosAddress: 10601,
13576
13665
  MessageType_AptosSignTx: 10602,
@@ -13581,7 +13670,6 @@ var nested = {
13581
13670
  MessageType_WebAuthnRemoveResidentCredential: 803,
13582
13671
  MessageType_BixinSeedOperate: 901,
13583
13672
  MessageType_BixinMessageSE: 902,
13584
- MessageType_BixinReboot: 903,
13585
13673
  MessageType_BixinOutMessageSE: 904,
13586
13674
  MessageType_BixinBackupRequest: 905,
13587
13675
  MessageType_BixinBackupAck: 906,
@@ -13598,6 +13686,14 @@ var nested = {
13598
13686
  MessageType_EthereumSignMessageEIP712: 10200,
13599
13687
  MessageType_GetPublicKeyMultiple: 10210,
13600
13688
  MessageType_PublicKeyMultiple: 10211,
13689
+ MessageType_ConfluxGetAddress: 10112,
13690
+ MessageType_ConfluxAddress: 10113,
13691
+ MessageType_ConfluxSignTx: 10114,
13692
+ MessageType_ConfluxTxRequest: 10115,
13693
+ MessageType_ConfluxTxAck: 10116,
13694
+ MessageType_ConfluxSignMessage: 10117,
13695
+ MessageType_ConfluxSignMessageCIP23: 10118,
13696
+ MessageType_ConfluxMessageSignature: 10119,
13601
13697
  MessageType_TronGetAddress: 10501,
13602
13698
  MessageType_TronAddress: 10502,
13603
13699
  MessageType_TronSignTx: 10503,
@@ -13608,6 +13704,7 @@ var nested = {
13608
13704
  MessageType_NearAddress: 10702,
13609
13705
  MessageType_NearSignTx: 10703,
13610
13706
  MessageType_NearSignedTx: 10704,
13707
+ MessageType_DeviceBackToBoot: 903,
13611
13708
  MessageType_DeviceInfoSettings: 10001,
13612
13709
  MessageType_GetDeviceInfo: 10002,
13613
13710
  MessageType_DeviceInfo: 10003,
@@ -13622,7 +13719,12 @@ var nested = {
13622
13719
  MessageType_SESignMessage: 10012,
13623
13720
  MessageType_SEMessageSignature: 10013,
13624
13721
  MessageType_NFTWriteInfo: 10014,
13625
- MessageType_NFTWriteData: 10015
13722
+ MessageType_NFTWriteData: 10015,
13723
+ MessageType_ResourceUpload: 10018,
13724
+ MessageType_ZoomRequest: 10019,
13725
+ MessageType_ResourceRequest: 10020,
13726
+ MessageType_ResourceAck: 10021,
13727
+ MessageType_ResourceUpdate: 10022
13626
13728
  }
13627
13729
  },
13628
13730
  google: {
@@ -15785,6 +15887,14 @@ class Device extends events.exports {
15785
15887
  return this.commands;
15786
15888
  }
15787
15889
 
15890
+ generateStateKey(deviceId, passphraseState) {
15891
+ if (passphraseState) {
15892
+ return `${deviceId}@${passphraseState}`;
15893
+ }
15894
+
15895
+ return deviceId;
15896
+ }
15897
+
15788
15898
  getInternalState(_deviceId) {
15789
15899
  var _a, _b;
15790
15900
 
@@ -15793,30 +15903,32 @@ class Device extends events.exports {
15793
15903
  const deviceId = _deviceId || ((_b = this.features) === null || _b === void 0 ? void 0 : _b.device_id);
15794
15904
  if (!deviceId) return undefined;
15795
15905
  if (!this.passphraseState) return undefined;
15796
- const usePassKey = `${deviceId}@${this.passphraseState}`;
15906
+ const usePassKey = this.generateStateKey(deviceId, this.passphraseState);
15907
+ return deviceSessionCache[usePassKey];
15908
+ }
15797
15909
 
15798
- if (!deviceSessionCache[usePassKey]) {
15799
- const key = `${deviceId}`;
15910
+ tryFixInternalState(state, deviceId) {
15911
+ Log$4.debug('tryFixInternalState session param: ', `device_id: ${deviceId}`, `passphraseState: ${state}`);
15912
+ const key = `${deviceId}`;
15913
+ const session = deviceSessionCache[key];
15800
15914
 
15801
- if (deviceSessionCache[key]) {
15802
- deviceSessionCache[usePassKey] = deviceSessionCache[key];
15803
- }
15915
+ if (session) {
15916
+ deviceSessionCache[this.generateStateKey(deviceId, state)] = session;
15917
+ delete deviceSessionCache[key];
15804
15918
  }
15805
15919
 
15806
- return deviceSessionCache[usePassKey];
15920
+ Log$4.debug('tryFixInternalState session cache: ', deviceSessionCache);
15807
15921
  }
15808
15922
 
15809
15923
  setInternalState(state, initSession) {
15810
- var _a;
15924
+ var _a, _b;
15811
15925
 
15812
15926
  Log$4.debug('setInternalState session param: ', `state: ${state}`, `initSession: ${initSession}`, `device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`);
15813
15927
  if (!this.features) return;
15814
15928
  if (!this.passphraseState && !initSession) return;
15815
- let key = `${this.features.device_id}`;
15816
-
15817
- if (this.passphraseState) {
15818
- key += `@${this.passphraseState}`;
15819
- }
15929
+ const deviceId = (_b = this.features) === null || _b === void 0 ? void 0 : _b.device_id;
15930
+ if (!deviceId) return;
15931
+ const key = this.generateStateKey(deviceId, this.passphraseState);
15820
15932
 
15821
15933
  if (state) {
15822
15934
  deviceSessionCache[key] = state;
@@ -15835,7 +15947,7 @@ class Device extends events.exports {
15835
15947
  delete deviceSessionCache[key];
15836
15948
 
15837
15949
  if (this.passphraseState) {
15838
- const usePassKey = `${deviceId}@${this.passphraseState}`;
15950
+ const usePassKey = this.generateStateKey(deviceId, this.passphraseState);
15839
15951
  delete deviceSessionCache[usePassKey];
15840
15952
  }
15841
15953
  }
@@ -16326,6 +16438,10 @@ class GetPassphraseState extends BaseMethod {
16326
16438
  }
16327
16439
 
16328
16440
  if (features && features.passphrase_protection === true) {
16441
+ if (passphraseState && features.device_id) {
16442
+ this.device.tryFixInternalState(passphraseState, features.device_id);
16443
+ }
16444
+
16329
16445
  return Promise.resolve(passphraseState);
16330
16446
  }
16331
16447
 
@@ -16494,7 +16610,7 @@ const formatAnyHex = value => {
16494
16610
 
16495
16611
  Array.from({
16496
16612
  length: 256
16497
- }, (v, i) => i.toString(16).padStart(2, '0'));
16613
+ }, (_, i) => i.toString(16).padStart(2, '0'));
16498
16614
 
16499
16615
  function hexToBytes(hex) {
16500
16616
  if (typeof hex !== 'string') {
@@ -16832,7 +16948,7 @@ class DeviceUpdateReboot extends BaseMethod {
16832
16948
 
16833
16949
  run() {
16834
16950
  return __awaiter(this, void 0, void 0, function* () {
16835
- const res = yield this.device.commands.typedCall('BixinReboot', 'Success');
16951
+ const res = yield this.device.commands.typedCall('DeviceBackToBoot', 'Success');
16836
16952
  return Promise.resolve(res.message);
16837
16953
  });
16838
16954
  }
@@ -17299,50 +17415,6 @@ class RequestWebUsbDevice extends BaseMethod {
17299
17415
 
17300
17416
  }
17301
17417
 
17302
- class BatchGetPublicKey extends BaseMethod {
17303
- init() {
17304
- this.checkDeviceId = true;
17305
- validateParams(this.payload, [{
17306
- name: 'paths',
17307
- type: 'array'
17308
- }, {
17309
- name: 'ecdsaCurveName',
17310
- type: 'string'
17311
- }]);
17312
- this.params = this.payload.paths.map(path => {
17313
- const addressN = validatePath(path, 1);
17314
- return {
17315
- address_n: addressN
17316
- };
17317
- });
17318
- }
17319
-
17320
- getVersionRange() {
17321
- return {
17322
- model_mini: {
17323
- min: '2.6.0'
17324
- }
17325
- };
17326
- }
17327
-
17328
- run() {
17329
- var _a;
17330
-
17331
- return __awaiter(this, void 0, void 0, function* () {
17332
- const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
17333
- paths: this.params,
17334
- ecdsa_curve_name: (_a = this.payload.ecdsaCurveName) !== null && _a !== void 0 ? _a : 'secp256k1'
17335
- });
17336
- const result = res.message.public_keys.map((publicKey, index) => ({
17337
- path: serializedPath(this.params[index].address_n),
17338
- publicKey
17339
- }));
17340
- return Promise.resolve(result);
17341
- });
17342
- }
17343
-
17344
- }
17345
-
17346
17418
  class CipherKeyValue extends BaseMethod {
17347
17419
  constructor() {
17348
17420
  super(...arguments);
@@ -17437,6 +17509,10 @@ var bitcoin = [{
17437
17509
  name: "Axe",
17438
17510
  label: "AXE",
17439
17511
  slip44: 4242
17512
+ }, {
17513
+ name: "Bcash",
17514
+ label: "BCH",
17515
+ slip44: 145
17440
17516
  }, {
17441
17517
  name: "Bitcore",
17442
17518
  label: "BTX",
@@ -20913,10 +20989,18 @@ class AptosGetAddress extends BaseMethod {
20913
20989
  publicKeyToAddress(publicKey) {
20914
20990
  const hash = sha3Hash.create();
20915
20991
  hash.update(hexToBytes(publicKey));
20916
- hash.update("\x00");
20992
+ hash.update('\x00');
20917
20993
  return hash.hex();
20918
20994
  }
20919
20995
 
20996
+ getVersionRange() {
20997
+ return {
20998
+ model_mini: {
20999
+ min: '2.6.0'
21000
+ }
21001
+ };
21002
+ }
21003
+
20920
21004
  run() {
20921
21005
  var _a;
20922
21006
 
@@ -20944,7 +21028,7 @@ class AptosGetAddress extends BaseMethod {
20944
21028
  } = res.message;
20945
21029
  responses.push({
20946
21030
  path: serializedPath(param.address_n),
20947
- address
21031
+ address: address === null || address === void 0 ? void 0 : address.toLowerCase()
20948
21032
  });
20949
21033
  }
20950
21034
 
@@ -20954,6 +21038,69 @@ class AptosGetAddress extends BaseMethod {
20954
21038
 
20955
21039
  }
20956
21040
 
21041
+ class AptosGetPublicKey extends BaseMethod {
21042
+ constructor() {
21043
+ super(...arguments);
21044
+ this.hasBundle = false;
21045
+ }
21046
+
21047
+ init() {
21048
+ var _a;
21049
+
21050
+ this.checkDeviceId = true;
21051
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
21052
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
21053
+ const payload = this.hasBundle ? this.payload : {
21054
+ bundle: [this.payload]
21055
+ };
21056
+ validateParams(payload, [{
21057
+ name: 'bundle',
21058
+ type: 'array'
21059
+ }]);
21060
+ this.params = [];
21061
+ payload.bundle.forEach(batch => {
21062
+ var _a;
21063
+
21064
+ const addressN = validatePath(batch.path, 3);
21065
+ validateParams(batch, [{
21066
+ name: 'path',
21067
+ required: true
21068
+ }, {
21069
+ name: 'showOnOneKey',
21070
+ type: 'boolean'
21071
+ }]);
21072
+ const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
21073
+ this.params.push({
21074
+ address_n: addressN,
21075
+ show_display: showOnOneKey
21076
+ });
21077
+ });
21078
+ }
21079
+
21080
+ getVersionRange() {
21081
+ return {
21082
+ model_mini: {
21083
+ min: '2.6.0'
21084
+ }
21085
+ };
21086
+ }
21087
+
21088
+ run() {
21089
+ return __awaiter(this, void 0, void 0, function* () {
21090
+ const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
21091
+ paths: this.params,
21092
+ ecdsa_curve_name: 'ed25519'
21093
+ });
21094
+ const responses = res.message.public_keys.map((publicKey, index) => ({
21095
+ path: serializedPath(this.params[index].address_n),
21096
+ publicKey
21097
+ }));
21098
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
21099
+ });
21100
+ }
21101
+
21102
+ }
21103
+
20957
21104
  class AptosSignTransaction extends BaseMethod {
20958
21105
  init() {
20959
21106
  this.checkDeviceId = true;
@@ -20980,7 +21127,7 @@ class AptosSignTransaction extends BaseMethod {
20980
21127
  getVersionRange() {
20981
21128
  return {
20982
21129
  model_mini: {
20983
- min: '2.4.0'
21130
+ min: '2.6.0'
20984
21131
  }
20985
21132
  };
20986
21133
  }
@@ -21018,7 +21165,6 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
21018
21165
  firmwareUpdate: FirmwareUpdate$1,
21019
21166
  firmwareUpdateV2: FirmwareUpdate,
21020
21167
  requestWebUsbDevice: RequestWebUsbDevice,
21021
- batchGetPublicKey: BatchGetPublicKey,
21022
21168
  cipherKeyValue: CipherKeyValue,
21023
21169
  btcGetAddress: BTCGetAddress,
21024
21170
  btcGetPublicKey: BTCGetPublicKey,
@@ -21053,6 +21199,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
21053
21199
  nearGetAddress: NearGetAddress,
21054
21200
  nearSignTransaction: NearSignTransaction,
21055
21201
  aptosGetAddress: AptosGetAddress,
21202
+ aptosGetPublicKey: AptosGetPublicKey,
21056
21203
  aptosSignTransaction: AptosSignTransaction
21057
21204
  });
21058
21205
 
@@ -22764,6 +22911,13 @@ exports.WL_OperationType = void 0;
22764
22911
  WL_OperationType[WL_OperationType["WL_OperationType_Inquire"] = 2] = "WL_OperationType_Inquire";
22765
22912
  })(exports.WL_OperationType || (exports.WL_OperationType = {}));
22766
22913
 
22914
+ exports.ResourceType = void 0;
22915
+
22916
+ (function (ResourceType) {
22917
+ ResourceType[ResourceType["WallPaper"] = 0] = "WallPaper";
22918
+ ResourceType[ResourceType["Nft"] = 1] = "Nft";
22919
+ })(exports.ResourceType || (exports.ResourceType = {}));
22920
+
22767
22921
  exports.NEMMosaicLevy = void 0;
22768
22922
 
22769
22923
  (function (NEMMosaicLevy) {
@@ -22963,6 +23117,10 @@ var messages = /*#__PURE__*/Object.freeze({
22963
23117
  return exports.WL_OperationType;
22964
23118
  },
22965
23119
 
23120
+ get ResourceType() {
23121
+ return exports.ResourceType;
23122
+ },
23123
+
22966
23124
  get NEMMosaicLevy() {
22967
23125
  return exports.NEMMosaicLevy;
22968
23126
  },
@@ -46656,7 +46814,7 @@ try {
46656
46814
  /***/ ((module) => {
46657
46815
 
46658
46816
  "use strict";
46659
- module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.54","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.54","@onekeyfe/hd-transport":"^0.1.54","axios":"^0.27.2","bignumber.js":"^9.0.2","js-sha256":"^0.9.0","js-sha3":"^0.8.0","parse-uri":"^1.0.7","semver":"^7.3.7"},"devDependencies":{"@types/parse-uri":"^1.0.0","@types/semver":"^7.3.9"}}');
46817
+ module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.56","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.56","@onekeyfe/hd-transport":"^0.1.56","axios":"^0.27.2","bignumber.js":"^9.0.2","js-sha256":"^0.9.0","parse-uri":"^1.0.7","semver":"^7.3.7"},"peerDependencies":{"js-sha3":"^0.8.0"},"devDependencies":{"@types/parse-uri":"^1.0.0","@types/semver":"^7.3.9","js-sha3":"^0.8.0"}}');
46660
46818
 
46661
46819
  /***/ })
46662
46820
 
@@ -49188,7 +49346,7 @@ const src_init = async settings => {
49188
49346
 
49189
49347
  try {
49190
49348
  await init({ ..._settings,
49191
- version: "0.1.54"
49349
+ version: "0.1.56"
49192
49350
  });
49193
49351
  return true;
49194
49352
  } catch (e) {