@onekeyfe/hd-core 1.0.33-alpha.8 → 1.0.33
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/dist/api/GetPassphraseState.d.ts +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts +1 -3
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts.map +1 -1
- package/dist/api/helpers/hexUtils.d.ts +1 -0
- package/dist/api/helpers/hexUtils.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +3 -8
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +5 -7
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/device.d.ts +0 -3
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +1 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +0 -1
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +8 -19
- package/dist/index.js +69 -165
- package/dist/utils/deviceFeaturesUtils.d.ts +2 -16
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/GetPassphraseState.ts +3 -19
- package/src/api/allnetwork/AllNetworkGetAddress.ts +20 -18
- package/src/api/evm/EVMSignTypedData.ts +2 -2
- package/src/api/helpers/hexUtils.ts +29 -0
- package/src/core/index.ts +7 -12
- package/src/data/messages/messages.json +2 -57
- package/src/device/Device.ts +7 -54
- package/src/device/DeviceCommands.ts +4 -15
- package/src/events/device.ts +0 -4
- package/src/events/ui-request.ts +1 -2
- package/src/events/ui-response.ts +0 -1
- package/src/utils/deviceFeaturesUtils.ts +7 -71
package/dist/index.js
CHANGED
|
@@ -4329,8 +4329,7 @@ var nested$1 = {
|
|
|
4329
4329
|
ButtonRequest_Success: 17,
|
|
4330
4330
|
ButtonRequest_Warning: 18,
|
|
4331
4331
|
ButtonRequest_PassphraseEntry: 19,
|
|
4332
|
-
ButtonRequest_PinEntry: 20
|
|
4333
|
-
ButtonRequest_AttachPin: 8000
|
|
4332
|
+
ButtonRequest_PinEntry: 20
|
|
4334
4333
|
}
|
|
4335
4334
|
}
|
|
4336
4335
|
}
|
|
@@ -4381,10 +4380,6 @@ var nested$1 = {
|
|
|
4381
4380
|
options: {
|
|
4382
4381
|
deprecated: true
|
|
4383
4382
|
}
|
|
4384
|
-
},
|
|
4385
|
-
exists_attach_pin_user: {
|
|
4386
|
-
type: "bool",
|
|
4387
|
-
id: 8000
|
|
4388
4383
|
}
|
|
4389
4384
|
}
|
|
4390
4385
|
},
|
|
@@ -4404,10 +4399,6 @@ var nested$1 = {
|
|
|
4404
4399
|
on_device: {
|
|
4405
4400
|
type: "bool",
|
|
4406
4401
|
id: 3
|
|
4407
|
-
},
|
|
4408
|
-
on_device_attach_pin: {
|
|
4409
|
-
type: "bool",
|
|
4410
|
-
id: 8000
|
|
4411
4402
|
}
|
|
4412
4403
|
}
|
|
4413
4404
|
},
|
|
@@ -7375,10 +7366,6 @@ var nested$1 = {
|
|
|
7375
7366
|
derive_cardano: {
|
|
7376
7367
|
type: "bool",
|
|
7377
7368
|
id: 3
|
|
7378
|
-
},
|
|
7379
|
-
passphrase_state: {
|
|
7380
|
-
type: "string",
|
|
7381
|
-
id: 8000
|
|
7382
7369
|
}
|
|
7383
7370
|
}
|
|
7384
7371
|
},
|
|
@@ -7759,14 +7746,6 @@ var nested$1 = {
|
|
|
7759
7746
|
onekey_se04_state: {
|
|
7760
7747
|
type: "OneKeySEState",
|
|
7761
7748
|
id: 624
|
|
7762
|
-
},
|
|
7763
|
-
attach_to_pin_user: {
|
|
7764
|
-
type: "bool",
|
|
7765
|
-
id: 625
|
|
7766
|
-
},
|
|
7767
|
-
unlocked_attach_pin: {
|
|
7768
|
-
type: "bool",
|
|
7769
|
-
id: 626
|
|
7770
7749
|
}
|
|
7771
7750
|
},
|
|
7772
7751
|
nested: {
|
|
@@ -8889,38 +8868,6 @@ var nested$1 = {
|
|
|
8889
8868
|
}
|
|
8890
8869
|
}
|
|
8891
8870
|
},
|
|
8892
|
-
GetPassphraseState: {
|
|
8893
|
-
fields: {
|
|
8894
|
-
passphrase_state: {
|
|
8895
|
-
type: "string",
|
|
8896
|
-
id: 1
|
|
8897
|
-
},
|
|
8898
|
-
_only_main_pin: {
|
|
8899
|
-
type: "bool",
|
|
8900
|
-
id: 2
|
|
8901
|
-
},
|
|
8902
|
-
allow_create_attach_pin: {
|
|
8903
|
-
type: "bool",
|
|
8904
|
-
id: 3
|
|
8905
|
-
}
|
|
8906
|
-
}
|
|
8907
|
-
},
|
|
8908
|
-
PassphraseState: {
|
|
8909
|
-
fields: {
|
|
8910
|
-
passphrase_state: {
|
|
8911
|
-
type: "string",
|
|
8912
|
-
id: 1
|
|
8913
|
-
},
|
|
8914
|
-
session_id: {
|
|
8915
|
-
type: "bytes",
|
|
8916
|
-
id: 2
|
|
8917
|
-
},
|
|
8918
|
-
unlocked_attach_pin: {
|
|
8919
|
-
type: "bool",
|
|
8920
|
-
id: 3
|
|
8921
|
-
}
|
|
8922
|
-
}
|
|
8923
|
-
},
|
|
8924
8871
|
MoneroTransactionSourceEntry: {
|
|
8925
8872
|
fields: {
|
|
8926
8873
|
outputs: {
|
|
@@ -13545,9 +13492,7 @@ var nested$1 = {
|
|
|
13545
13492
|
MessageType_ListResDir: 10023,
|
|
13546
13493
|
MessageType_FileInfoList: 10024,
|
|
13547
13494
|
MessageType_OnekeyGetFeatures: 10025,
|
|
13548
|
-
MessageType_OnekeyFeatures: 10026
|
|
13549
|
-
MessageType_GetPassphraseState: 10028,
|
|
13550
|
-
MessageType_PassphraseState: 10029
|
|
13495
|
+
MessageType_OnekeyFeatures: 10026
|
|
13551
13496
|
}
|
|
13552
13497
|
},
|
|
13553
13498
|
google: {
|
|
@@ -25010,42 +24955,21 @@ const supportNewPassphrase = (features) => {
|
|
|
25010
24955
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
25011
24956
|
return { support: semver__default["default"].gte(currentVersion, '2.4.0'), require: '2.4.0' };
|
|
25012
24957
|
};
|
|
25013
|
-
const getPassphraseStateWithRefreshDeviceInfo = (device
|
|
24958
|
+
const getPassphraseStateWithRefreshDeviceInfo = (device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25014
24959
|
const { features, commands } = device;
|
|
25015
24960
|
const locked = (features === null || features === void 0 ? void 0 : features.unlocked) === false;
|
|
25016
|
-
const
|
|
25017
|
-
if (newSession && passphraseState && (features === null || features === void 0 ? void 0 : features.device_id)) {
|
|
25018
|
-
console.log('=====>>>>>> run updateInternalState newSession:', newSession);
|
|
25019
|
-
device.updateInternalState(passphraseState, features.device_id, newSession);
|
|
25020
|
-
}
|
|
24961
|
+
const passphraseState = yield getPassphraseState(features, commands);
|
|
25021
24962
|
const isModeT = getDeviceType(features) === hdShared.EDeviceType.Touch || getDeviceType(features) === hdShared.EDeviceType.Pro;
|
|
25022
24963
|
const needRefreshWithPassphrase = passphraseState && (features === null || features === void 0 ? void 0 : features.passphrase_protection) !== true;
|
|
25023
24964
|
const needRefreshWithLocked = isModeT && locked;
|
|
25024
24965
|
if (needRefreshWithLocked || needRefreshWithPassphrase) {
|
|
25025
24966
|
yield device.getFeatures();
|
|
25026
24967
|
}
|
|
25027
|
-
return
|
|
24968
|
+
return passphraseState;
|
|
25028
24969
|
});
|
|
25029
|
-
const getPassphraseState = (features, commands
|
|
24970
|
+
const getPassphraseState = (features, commands) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25030
24971
|
if (!features)
|
|
25031
|
-
return
|
|
25032
|
-
const firmwareVersion = getDeviceFirmwareVersion(features);
|
|
25033
|
-
const deviceType = getDeviceType(features);
|
|
25034
|
-
if (deviceType === hdShared.EDeviceType.Pro && semver__default["default"].gte(firmwareVersion.join('.'), '4.13.2')) {
|
|
25035
|
-
console.log('=====>>>>>> getPassphraseState begin: ', options === null || options === void 0 ? void 0 : options.onlyMainPin, options === null || options === void 0 ? void 0 : options.expectPassphraseState);
|
|
25036
|
-
const { message, type } = yield commands.typedCall('GetPassphraseState', 'PassphraseState', {
|
|
25037
|
-
passphrase_state: (options === null || options === void 0 ? void 0 : options.onlyMainPin) ? undefined : options === null || options === void 0 ? void 0 : options.expectPassphraseState,
|
|
25038
|
-
});
|
|
25039
|
-
console.log('=====>>>>>> getPassphraseState end: result ', message);
|
|
25040
|
-
if (type === 'CallMethodError') {
|
|
25041
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
25042
|
-
}
|
|
25043
|
-
return {
|
|
25044
|
-
passphraseState: message.passphrase_state,
|
|
25045
|
-
newSession: message.session_id,
|
|
25046
|
-
unlockedAttachPin: message.unlocked_attach_pin,
|
|
25047
|
-
};
|
|
25048
|
-
}
|
|
24972
|
+
return false;
|
|
25049
24973
|
const { message, type } = yield commands.typedCall('GetAddress', 'Address', {
|
|
25050
24974
|
address_n: [toHardened(44), toHardened(1), toHardened(0), 0, 0],
|
|
25051
24975
|
coin_name: 'Testnet',
|
|
@@ -25055,11 +24979,7 @@ const getPassphraseState = (features, commands, options) => __awaiter(void 0, vo
|
|
|
25055
24979
|
if (type === 'CallMethodError') {
|
|
25056
24980
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
25057
24981
|
}
|
|
25058
|
-
return
|
|
25059
|
-
passphraseState: message.address,
|
|
25060
|
-
newSession: undefined,
|
|
25061
|
-
unlockedAttachPin: undefined,
|
|
25062
|
-
};
|
|
24982
|
+
return message.address;
|
|
25063
24983
|
});
|
|
25064
24984
|
const supportBatchPublicKey = (features, options) => {
|
|
25065
24985
|
if (!features)
|
|
@@ -26435,14 +26355,8 @@ class DeviceCommands {
|
|
|
26435
26355
|
}, error => Promise.reject(error));
|
|
26436
26356
|
}
|
|
26437
26357
|
if (res.type === 'PassphraseRequest') {
|
|
26438
|
-
|
|
26439
|
-
|
|
26440
|
-
existsAttachPinUser,
|
|
26441
|
-
}).then(response => {
|
|
26442
|
-
const { passphrase, passphraseOnDevice, attachPinOnDevice } = response;
|
|
26443
|
-
if (attachPinOnDevice && existsAttachPinUser) {
|
|
26444
|
-
return this._commonCall('PassphraseAck', { on_device_attach_pin: true });
|
|
26445
|
-
}
|
|
26358
|
+
return this._promptPassphrase().then(response => {
|
|
26359
|
+
const { passphrase, passphraseOnDevice } = response;
|
|
26446
26360
|
return !passphraseOnDevice
|
|
26447
26361
|
? this._commonCall('PassphraseAck', { passphrase })
|
|
26448
26362
|
: this._commonCall('PassphraseAck', { on_device: true });
|
|
@@ -26486,7 +26400,7 @@ class DeviceCommands {
|
|
|
26486
26400
|
}
|
|
26487
26401
|
});
|
|
26488
26402
|
}
|
|
26489
|
-
_promptPassphrase(
|
|
26403
|
+
_promptPassphrase() {
|
|
26490
26404
|
return new Promise((resolve, reject) => {
|
|
26491
26405
|
const cancelAndReject = (_error) => cancelDeviceInPrompt(this.device, false)
|
|
26492
26406
|
.then(onCancel => {
|
|
@@ -26504,7 +26418,7 @@ class DeviceCommands {
|
|
|
26504
26418
|
});
|
|
26505
26419
|
if (this.device.listenerCount(DEVICE.PASSPHRASE) > 0) {
|
|
26506
26420
|
this.device.setCancelableAction(cancelAndReject);
|
|
26507
|
-
this.device.emit(DEVICE.PASSPHRASE, this.device,
|
|
26421
|
+
this.device.emit(DEVICE.PASSPHRASE, this.device, (response, error) => {
|
|
26508
26422
|
this.device.clearCancelableAction();
|
|
26509
26423
|
if (error) {
|
|
26510
26424
|
cancelAndReject();
|
|
@@ -26700,17 +26614,6 @@ class Device extends events.exports {
|
|
|
26700
26614
|
}
|
|
26701
26615
|
Log$a.debug('tryFixInternalState session cache: ', deviceSessionCache);
|
|
26702
26616
|
}
|
|
26703
|
-
updateInternalState(state, deviceId, sessionId = null) {
|
|
26704
|
-
Log$a.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `passphraseState: ${state}`, `sessionId: ${sessionId}`);
|
|
26705
|
-
if (sessionId) {
|
|
26706
|
-
deviceSessionCache[this.generateStateKey(deviceId, state)] = sessionId;
|
|
26707
|
-
const oldKey = `${deviceId}`;
|
|
26708
|
-
if (deviceSessionCache[oldKey]) {
|
|
26709
|
-
delete deviceSessionCache[oldKey];
|
|
26710
|
-
}
|
|
26711
|
-
}
|
|
26712
|
-
Log$a.debug('updateInternalState session cache: ', deviceSessionCache);
|
|
26713
|
-
}
|
|
26714
26617
|
setInternalState(state, initSession) {
|
|
26715
26618
|
var _a, _b;
|
|
26716
26619
|
Log$a.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}`);
|
|
@@ -26742,6 +26645,7 @@ class Device extends events.exports {
|
|
|
26742
26645
|
}
|
|
26743
26646
|
initialize(options) {
|
|
26744
26647
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26648
|
+
Log$a.debug('initialize param:', options);
|
|
26745
26649
|
this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
|
|
26746
26650
|
if (options === null || options === void 0 ? void 0 : options.initSession) {
|
|
26747
26651
|
this.clearInternalState(options === null || options === void 0 ? void 0 : options.deviceId);
|
|
@@ -26754,12 +26658,7 @@ class Device extends events.exports {
|
|
|
26754
26658
|
if (options === null || options === void 0 ? void 0 : options.deriveCardano) {
|
|
26755
26659
|
payload.derive_cardano = true;
|
|
26756
26660
|
}
|
|
26757
|
-
|
|
26758
|
-
console.log('=====>>>>>> initialize device begin: ', payload, {
|
|
26759
|
-
deviceId: options === null || options === void 0 ? void 0 : options.deviceId,
|
|
26760
|
-
passphraseState: options === null || options === void 0 ? void 0 : options.passphraseState,
|
|
26761
|
-
initSession: options === null || options === void 0 ? void 0 : options.initSession,
|
|
26762
|
-
});
|
|
26661
|
+
Log$a.debug('initialize payload:', payload);
|
|
26763
26662
|
try {
|
|
26764
26663
|
const { message } = yield Promise.race([
|
|
26765
26664
|
this.commands.typedCall('Initialize', 'Features', payload),
|
|
@@ -26769,7 +26668,6 @@ class Device extends events.exports {
|
|
|
26769
26668
|
}, 25 * 1000);
|
|
26770
26669
|
}),
|
|
26771
26670
|
]);
|
|
26772
|
-
console.log('=====>>>>>> initialize device end: ', message);
|
|
26773
26671
|
this._updateFeatures(message, options === null || options === void 0 ? void 0 : options.initSession);
|
|
26774
26672
|
yield TransportManager.reconfigure(this.features);
|
|
26775
26673
|
}
|
|
@@ -27021,19 +26919,12 @@ class Device extends events.exports {
|
|
|
27021
26919
|
}
|
|
27022
26920
|
return false;
|
|
27023
26921
|
}
|
|
27024
|
-
checkPassphraseStateSafety(passphraseState
|
|
26922
|
+
checkPassphraseStateSafety(passphraseState) {
|
|
27025
26923
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27026
26924
|
if (!this.features)
|
|
27027
26925
|
return false;
|
|
27028
|
-
const
|
|
27029
|
-
|
|
27030
|
-
onlyMainPin: useEmptyPassphraseState,
|
|
27031
|
-
});
|
|
27032
|
-
if (unlockedAttachPin && useEmptyPassphraseState) {
|
|
27033
|
-
this.clearInternalState();
|
|
27034
|
-
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError));
|
|
27035
|
-
}
|
|
27036
|
-
if (passphraseState && passphraseState !== newPassphraseState) {
|
|
26926
|
+
const newState = yield getPassphraseStateWithRefreshDeviceInfo(this);
|
|
26927
|
+
if (passphraseState && passphraseState !== newState) {
|
|
27037
26928
|
this.clearInternalState();
|
|
27038
26929
|
return false;
|
|
27039
26930
|
}
|
|
@@ -27300,17 +27191,11 @@ class GetPassphraseState extends BaseMethod {
|
|
|
27300
27191
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27301
27192
|
if (!this.device.features)
|
|
27302
27193
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed));
|
|
27303
|
-
const
|
|
27304
|
-
console.log('=====>>>>>> GetPassphraseState run passphraseState: ', passphraseState);
|
|
27305
|
-
console.log('=====>>>>>> GetPassphraseState run newSession: ', newSession);
|
|
27306
|
-
console.log('=====>>>>>> GetPassphraseState run features: ', this.device.features.passphrase_protection);
|
|
27194
|
+
const passphraseState = yield getPassphraseStateWithRefreshDeviceInfo(this.device);
|
|
27307
27195
|
const { features } = this.device;
|
|
27308
27196
|
if (features && features.passphrase_protection === true) {
|
|
27309
|
-
if (
|
|
27310
|
-
|
|
27311
|
-
if (passphraseState && features.device_id) {
|
|
27312
|
-
this.device.tryFixInternalState(passphraseState, features.device_id, features.session_id);
|
|
27313
|
-
}
|
|
27197
|
+
if (passphraseState && features.device_id) {
|
|
27198
|
+
this.device.tryFixInternalState(passphraseState, features.device_id, features.session_id);
|
|
27314
27199
|
}
|
|
27315
27200
|
return Promise.resolve(passphraseState);
|
|
27316
27201
|
}
|
|
@@ -27629,6 +27514,27 @@ function hexToBytes(hex) {
|
|
|
27629
27514
|
}
|
|
27630
27515
|
return array;
|
|
27631
27516
|
}
|
|
27517
|
+
function parseChainId(chainId) {
|
|
27518
|
+
if (!chainId) {
|
|
27519
|
+
return 0;
|
|
27520
|
+
}
|
|
27521
|
+
if (typeof chainId === 'string') {
|
|
27522
|
+
if (chainId.trim() === '') {
|
|
27523
|
+
return 0;
|
|
27524
|
+
}
|
|
27525
|
+
if (chainId.match(/^[0-9]+$/)) {
|
|
27526
|
+
return new BigNumber__default["default"](chainId, 10).toNumber();
|
|
27527
|
+
}
|
|
27528
|
+
if (chainId.startsWith('0x') || chainId.match(/^[0-9a-fA-F]+$/)) {
|
|
27529
|
+
return new BigNumber__default["default"](chainId, 16).toNumber();
|
|
27530
|
+
}
|
|
27531
|
+
throw new Error(`Invalid chainId ${chainId}`);
|
|
27532
|
+
}
|
|
27533
|
+
if (typeof chainId === 'number') {
|
|
27534
|
+
return new BigNumber__default["default"](chainId).toNumber();
|
|
27535
|
+
}
|
|
27536
|
+
throw new Error(`Invalid chainId ${chainId}`);
|
|
27537
|
+
}
|
|
27632
27538
|
|
|
27633
27539
|
const invalidParameter = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
27634
27540
|
const invalidResponse = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodError, message);
|
|
@@ -29931,7 +29837,7 @@ class AllNetworkGetAddress extends BaseMethod {
|
|
|
29931
29837
|
]);
|
|
29932
29838
|
});
|
|
29933
29839
|
}
|
|
29934
|
-
generateMethodName({ network, payload,
|
|
29840
|
+
generateMethodName({ network, payload, }) {
|
|
29935
29841
|
var _a, _b;
|
|
29936
29842
|
const { name: networkName, coin } = networkAliases[network] || {
|
|
29937
29843
|
name: network,
|
|
@@ -29945,7 +29851,6 @@ class AllNetworkGetAddress extends BaseMethod {
|
|
|
29945
29851
|
methodName: config.methodName,
|
|
29946
29852
|
params: Object.assign(Object.assign({}, ((_b = (_a = config === null || config === void 0 ? void 0 : config.getParams) === null || _a === void 0 ? void 0 : _a.call(config, payload, coin, config.methodName)) !== null && _b !== void 0 ? _b : payload)), { originPayload: payload }),
|
|
29947
29853
|
_originRequestParams: payload,
|
|
29948
|
-
_originalIndex: originalIndex,
|
|
29949
29854
|
};
|
|
29950
29855
|
}
|
|
29951
29856
|
callMethod(methodName, params) {
|
|
@@ -29993,11 +29898,10 @@ class AllNetworkGetAddress extends BaseMethod {
|
|
|
29993
29898
|
const responses = [];
|
|
29994
29899
|
const resultMap = {};
|
|
29995
29900
|
const { bundle } = this.payload;
|
|
29996
|
-
const
|
|
29997
|
-
.map(
|
|
29901
|
+
const methodReduceParams = bundle
|
|
29902
|
+
.map(param => this.generateMethodName({
|
|
29998
29903
|
network: param.network,
|
|
29999
29904
|
payload: param,
|
|
30000
|
-
originalIndex: index,
|
|
30001
29905
|
}))
|
|
30002
29906
|
.reduce((acc, cur) => {
|
|
30003
29907
|
if (!acc[cur.methodName]) {
|
|
@@ -30006,25 +29910,28 @@ class AllNetworkGetAddress extends BaseMethod {
|
|
|
30006
29910
|
acc[cur.methodName].push(cur);
|
|
30007
29911
|
return acc;
|
|
30008
29912
|
}, {});
|
|
30009
|
-
|
|
30010
|
-
|
|
30011
|
-
|
|
30012
|
-
|
|
29913
|
+
const methodParamsArray = Object.values(methodReduceParams);
|
|
29914
|
+
const generateResponseKey = (payload) => `${payload.path}-${payload.network}-${payload.chainName}-${payload.prefix}`;
|
|
29915
|
+
for (let i = 0; i < methodParamsArray.length; i++) {
|
|
29916
|
+
const methodParams = methodParamsArray[i];
|
|
29917
|
+
const { methodName } = methodParams[0];
|
|
29918
|
+
const params = {
|
|
29919
|
+
bundle: methodParams.map(param => (Object.assign({}, param.params))),
|
|
30013
29920
|
};
|
|
30014
|
-
const response = yield this.callMethod(methodName,
|
|
30015
|
-
for (let i = 0; i <
|
|
30016
|
-
const { _originRequestParams
|
|
30017
|
-
const responseKey =
|
|
29921
|
+
const response = yield this.callMethod(methodName, params);
|
|
29922
|
+
for (let i = 0; i < methodParams.length; i++) {
|
|
29923
|
+
const { _originRequestParams } = methodParams[i];
|
|
29924
|
+
const responseKey = generateResponseKey(_originRequestParams);
|
|
30018
29925
|
resultMap[responseKey] = Object.assign(Object.assign({}, _originRequestParams), response[i]);
|
|
30019
29926
|
}
|
|
30020
29927
|
if (((_b = (_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle) === null || _b === void 0 ? void 0 : _b.length) > 1) {
|
|
30021
29928
|
const progress = Math.round(((i + 1) / this.payload.bundle.length) * 100);
|
|
30022
29929
|
this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, { progress }));
|
|
30023
29930
|
}
|
|
30024
|
-
i++;
|
|
30025
29931
|
}
|
|
30026
|
-
for (
|
|
30027
|
-
|
|
29932
|
+
for (const param of bundle) {
|
|
29933
|
+
const responseKey = generateResponseKey(param);
|
|
29934
|
+
responses.push(resultMap[responseKey]);
|
|
30028
29935
|
}
|
|
30029
29936
|
return Promise.resolve(responses);
|
|
30030
29937
|
});
|
|
@@ -32028,7 +31935,6 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
32028
31935
|
}
|
|
32029
31936
|
}
|
|
32030
31937
|
handleSignTypedData({ typedCall, signData, response, supportTrezor, }) {
|
|
32031
|
-
var _a;
|
|
32032
31938
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32033
31939
|
const { types, primaryType, domain, message, } = signData;
|
|
32034
31940
|
while (response.type === 'EthereumTypedDataStructRequest' ||
|
|
@@ -32120,7 +32026,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
32120
32026
|
gasToken: data.message.gasToken,
|
|
32121
32027
|
refundReceiver: data.message.refundReceiver,
|
|
32122
32028
|
nonce: formatAnyHex(new BigNumber__default["default"](data.message.nonce).toString(16)),
|
|
32123
|
-
chain_id:
|
|
32029
|
+
chain_id: parseChainId(data.domain.chainId),
|
|
32124
32030
|
verifyingContract: data.domain.verifyingContract,
|
|
32125
32031
|
};
|
|
32126
32032
|
response = yield typedCall('EthereumGnosisSafeTxAck', ['EthereumTypedDataSignature', 'EthereumTypedDataSignatureOneKey'], param);
|
|
@@ -38392,7 +38298,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
38392
38298
|
try {
|
|
38393
38299
|
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
38394
38300
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38395
|
-
var _c, _d, _e
|
|
38301
|
+
var _c, _d, _e;
|
|
38396
38302
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
38397
38303
|
if (device.features) {
|
|
38398
38304
|
yield DataManager.checkAndReloadData();
|
|
@@ -38449,7 +38355,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
38449
38355
|
require: support.require,
|
|
38450
38356
|
}));
|
|
38451
38357
|
}
|
|
38452
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_c = method.payload) === null || _c === void 0 ? void 0 : _c.passphraseState
|
|
38358
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_c = method.payload) === null || _c === void 0 ? void 0 : _c.passphraseState);
|
|
38453
38359
|
checkPassphraseEnableState(method, device.features);
|
|
38454
38360
|
if (!passphraseStateSafety) {
|
|
38455
38361
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -38465,7 +38371,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
38465
38371
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
38466
38372
|
throw error;
|
|
38467
38373
|
}
|
|
38468
|
-
(
|
|
38374
|
+
(_e = (_d = method.device) === null || _d === void 0 ? void 0 : _d.commands) === null || _e === void 0 ? void 0 : _e.checkDisposed();
|
|
38469
38375
|
try {
|
|
38470
38376
|
const response = yield method.run();
|
|
38471
38377
|
Log.debug('Call API - Inner Method Run: ');
|
|
@@ -38825,11 +38731,11 @@ const onDevicePinHandler = (...[device, type, callback]) => __awaiter(void 0, vo
|
|
|
38825
38731
|
});
|
|
38826
38732
|
const onDeviceButtonHandler = (...[device, request]) => {
|
|
38827
38733
|
postMessage(createDeviceMessage(DEVICE.BUTTON, Object.assign(Object.assign({}, request), { device: device.toMessageObject() })));
|
|
38828
|
-
if (request.code === 'ButtonRequest_PinEntry'
|
|
38829
|
-
Log.log('request Confirm Input PIN
|
|
38734
|
+
if (request.code === 'ButtonRequest_PinEntry') {
|
|
38735
|
+
Log.log('request Confirm Input PIN');
|
|
38830
38736
|
postMessage(createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
38831
38737
|
device: device.toMessageObject(),
|
|
38832
|
-
type:
|
|
38738
|
+
type: 'ButtonRequest_PinEntry',
|
|
38833
38739
|
}));
|
|
38834
38740
|
}
|
|
38835
38741
|
else {
|
|
@@ -38840,24 +38746,22 @@ const onDeviceButtonHandler = (...[device, request]) => {
|
|
|
38840
38746
|
const onDeviceFeaturesHandler = (...[_, features]) => {
|
|
38841
38747
|
postMessage(createDeviceMessage(DEVICE.FEATURES, Object.assign({}, features)));
|
|
38842
38748
|
};
|
|
38843
|
-
const onDevicePassphraseHandler = (...[device,
|
|
38749
|
+
const onDevicePassphraseHandler = (...[device, callback]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38844
38750
|
Log.debug('onDevicePassphraseHandler');
|
|
38845
38751
|
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
|
|
38846
38752
|
postMessage(createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE, {
|
|
38847
38753
|
device: device.toMessageObject(),
|
|
38848
38754
|
passphraseState: device.passphraseState,
|
|
38849
|
-
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
38850
38755
|
}));
|
|
38851
38756
|
const uiResp = yield uiPromise.promise;
|
|
38852
|
-
const { value, passphraseOnDevice, save
|
|
38757
|
+
const { value, passphraseOnDevice, save } = uiResp.payload;
|
|
38853
38758
|
callback({
|
|
38854
38759
|
passphrase: value.normalize('NFKD'),
|
|
38855
38760
|
passphraseOnDevice,
|
|
38856
|
-
attachPinOnDevice,
|
|
38857
38761
|
cache: save,
|
|
38858
38762
|
});
|
|
38859
38763
|
});
|
|
38860
|
-
const onEmptyPassphraseHandler = (...[_,
|
|
38764
|
+
const onEmptyPassphraseHandler = (...[_, callback]) => {
|
|
38861
38765
|
Log.debug('onEmptyPassphraseHandler');
|
|
38862
38766
|
callback({ passphrase: '' });
|
|
38863
38767
|
};
|
|
@@ -38966,7 +38870,7 @@ const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0,
|
|
|
38966
38870
|
yield DataManager.load(settings);
|
|
38967
38871
|
initTransport(Transport, plugin);
|
|
38968
38872
|
}
|
|
38969
|
-
catch (
|
|
38873
|
+
catch (_f) {
|
|
38970
38874
|
Log.error('DataManager.load error');
|
|
38971
38875
|
}
|
|
38972
38876
|
enableLog(DataManager.getSettings('debug'));
|
|
@@ -8,22 +8,8 @@ export declare const getSupportMessageVersion: (features: Features | undefined)
|
|
|
8
8
|
};
|
|
9
9
|
export declare const supportInputPinOnSoftware: (features: Features) => SupportFeatureType;
|
|
10
10
|
export declare const supportNewPassphrase: (features?: Features) => SupportFeatureType;
|
|
11
|
-
export declare const getPassphraseStateWithRefreshDeviceInfo: (device: Device
|
|
12
|
-
|
|
13
|
-
onlyMainPin?: boolean;
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
passphraseState: string | undefined;
|
|
16
|
-
newSession: string | undefined;
|
|
17
|
-
unlockedAttachPin: boolean | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
export declare const getPassphraseState: (features: Features | undefined, commands: DeviceCommands, options?: {
|
|
20
|
-
expectPassphraseState?: string;
|
|
21
|
-
onlyMainPin?: boolean;
|
|
22
|
-
}) => Promise<{
|
|
23
|
-
passphraseState: string | undefined;
|
|
24
|
-
newSession: string | undefined;
|
|
25
|
-
unlockedAttachPin: boolean | undefined;
|
|
26
|
-
}>;
|
|
11
|
+
export declare const getPassphraseStateWithRefreshDeviceInfo: (device: Device) => Promise<string | false>;
|
|
12
|
+
export declare const getPassphraseState: (features: Features | undefined, commands: DeviceCommands) => Promise<string | false>;
|
|
27
13
|
export declare const supportBatchPublicKey: (features?: Features, options?: {
|
|
28
14
|
includeNode?: boolean;
|
|
29
15
|
}) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,eAAO,MAAM,wBAAwB,aACzB,QAAQ,GAAG,SAAS,KAC7B;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,cAAc,CAAA;CAiClD,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAAe,QAAQ,KAAG,kBAW1D,CAAC;AAEF,eAAO,MAAM,uCAAuC,
|
|
1
|
+
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,eAAO,MAAM,wBAAwB,aACzB,QAAQ,GAAG,SAAS,KAC7B;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,cAAc,CAAA;CAiClD,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAAe,QAAQ,KAAG,kBAW1D,CAAC;AAEF,eAAO,MAAM,uCAAuC,WAAkB,MAAM,4BAqB3E,CAAC;AAEF,eAAO,MAAM,kBAAkB,aACnB,QAAQ,GAAG,SAAS,YACpB,cAAc,4BAgBzB,CAAC;AAEF,eAAO,MAAM,qBAAqB,cACrB,QAAQ,YACT;IACR,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,KACA,OAsBF,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,QAAQ,KAAG,kBAU7D,CAAC;AAKF,eAAO,MAAM,sBAAsB;cAKvB,QAAQ;gBACN,UAAU,GAAG,KAAK;;MAE5B,KAAK,GAAG,cAyBX,CAAC;AAMF,eAAO,MAAM,2BAA2B,aAC5B,QAAQ,cACN,UAAU,GAAG,KAAK,GAAG,YAAY,KAC5C,CAAC,UAAU,GAAG,KAAK,GAAG,aAAa,GAAG,aAAa,CAAC,EAkCtD,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,UASzC;AAED,eAAO,MAAM,0BAA0B,aAAc,QAAQ,KAAG,QAc/D,CAAC"}
|