@onekeyfe/hd-core 1.0.33-alpha.5 → 1.0.33-alpha.6
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/BaseMethod.d.ts +1 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +6 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +7 -5
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/device.d.ts +3 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +3 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +1 -0
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.js +323 -290
- package/dist/utils/deviceFeaturesUtils.d.ts +2 -1
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +3 -2
- package/src/api/CheckAllFirmwareRelease.ts +1 -1
- package/src/api/CheckBLEFirmwareRelease.ts +3 -3
- package/src/api/CheckBootloaderRelease.ts +1 -1
- package/src/api/CheckBridgeRelease.ts +1 -1
- package/src/api/CheckFirmwareRelease.ts +3 -3
- package/src/api/CipherKeyValue.ts +1 -1
- package/src/api/FirmwareUpdate.ts +1 -1
- package/src/api/FirmwareUpdateV2.ts +1 -1
- package/src/api/FirmwareUpdateV3.ts +1 -1
- package/src/api/GetFeatures.ts +3 -3
- package/src/api/GetOnekeyFeatures.ts +3 -3
- package/src/api/GetPassphraseState.ts +1 -1
- package/src/api/alephium/AlephiumGetAddress.ts +1 -1
- package/src/api/alephium/AlephiumSignMessage.ts +1 -1
- package/src/api/alephium/AlephiumSignTransaction.ts +1 -1
- package/src/api/algo/AlgoGetAddress.ts +1 -1
- package/src/api/algo/AlgoSignTransaction.ts +1 -1
- package/src/api/allnetwork/AllNetworkGetAddress.ts +1 -1
- package/src/api/aptos/AptosGetAddress.ts +1 -1
- package/src/api/aptos/AptosGetPublicKey.ts +1 -1
- package/src/api/aptos/AptosSignMessage.ts +1 -1
- package/src/api/aptos/AptosSignTransaction.ts +1 -1
- package/src/api/benfen/BenfenGetAddress.ts +1 -1
- package/src/api/benfen/BenfenGetPublicKey.ts +1 -1
- package/src/api/benfen/BenfenSignMessage.ts +1 -1
- package/src/api/benfen/BenfenSignTransaction.ts +1 -1
- package/src/api/btc/BTCGetAddress.ts +1 -1
- package/src/api/btc/BTCGetPublicKey.ts +1 -1
- package/src/api/btc/BTCSignMessage.ts +1 -1
- package/src/api/btc/BTCSignPsbt.ts +1 -1
- package/src/api/btc/BTCSignTransaction.ts +1 -1
- package/src/api/btc/BTCVerifyMessage.ts +1 -1
- package/src/api/cardano/CardanoGetAddress.ts +1 -1
- package/src/api/cardano/CardanoGetPublicKey.ts +1 -1
- package/src/api/cardano/CardanoSignMessage.ts +1 -1
- package/src/api/cardano/CardanoSignTransaction.ts +1 -1
- package/src/api/conflux/ConfluxGetAddress.ts +1 -1
- package/src/api/conflux/ConfluxSignMessage.ts +1 -1
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -1
- package/src/api/conflux/ConfluxSignTransaction.ts +1 -1
- package/src/api/cosmos/CosmosGetAddress.ts +1 -1
- package/src/api/cosmos/CosmosGetPublicKey.ts +1 -1
- package/src/api/cosmos/CosmosSignTransaction.ts +1 -1
- package/src/api/device/DeviceUpdateBootloader.ts +1 -1
- package/src/api/dynex/DnxGetAddress.ts +1 -1
- package/src/api/dynex/DnxSignTransaction.ts +1 -1
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +1 -1
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/filecoin/FilecoinGetAddress.ts +1 -1
- package/src/api/filecoin/FilecoinSignTransaction.ts +1 -1
- package/src/api/kaspa/KaspaGetAddress.ts +1 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +1 -1
- package/src/api/lightning/LnurlAuth.ts +1 -1
- package/src/api/near/NearGetAddress.ts +1 -1
- package/src/api/near/NearSignTransaction.ts +1 -1
- package/src/api/nem/NEMGetAddress.ts +1 -1
- package/src/api/nem/NEMSignTransaction.ts +1 -1
- package/src/api/neo/NeoGetAddress.ts +1 -1
- package/src/api/neo/NeoSignTransaction.ts +1 -1
- package/src/api/nervos/NervosGetAddress.ts +1 -1
- package/src/api/nervos/NervosSignTransaction.ts +1 -1
- package/src/api/nexa/NexaGetAddress.ts +1 -1
- package/src/api/nostr/NostrDecryptMessage.ts +1 -1
- package/src/api/nostr/NostrEncryptMessage.ts +1 -1
- package/src/api/nostr/NostrGetPublicKey.ts +1 -1
- package/src/api/nostr/NostrSignEvent.ts +1 -1
- package/src/api/nostr/NostrSignSchnorr.ts +1 -1
- package/src/api/polkadot/PolkadotGetAddress.ts +1 -1
- package/src/api/polkadot/PolkadotSignTransaction.ts +1 -1
- package/src/api/scdo/ScdoGetAddress.ts +1 -1
- package/src/api/scdo/ScdoSignMessage.ts +1 -1
- package/src/api/scdo/ScdoSignTransaction.ts +1 -1
- package/src/api/solana/SolGetAddress.ts +1 -1
- package/src/api/solana/SolSignMessage.ts +1 -1
- package/src/api/solana/SolSignOffchainMessage.ts +1 -1
- package/src/api/solana/SolSignTransaction.ts +1 -1
- package/src/api/starcoin/StarcoinGetAddress.ts +1 -1
- package/src/api/starcoin/StarcoinGetPublicKey.ts +1 -1
- package/src/api/starcoin/StarcoinSignMessage.ts +1 -1
- package/src/api/starcoin/StarcoinSignTransaction.ts +1 -1
- package/src/api/starcoin/StarcoinVerifyMessage.ts +1 -1
- package/src/api/stellar/StellarGetAddress.ts +1 -1
- package/src/api/stellar/StellarSignTransaction.ts +1 -1
- package/src/api/sui/SuiGetAddress.ts +1 -1
- package/src/api/sui/SuiGetPublicKey.ts +1 -1
- package/src/api/sui/SuiSignMessage.ts +1 -1
- package/src/api/sui/SuiSignTransaction.ts +1 -1
- package/src/api/test/TestInitializeDeviceDuration.ts +3 -3
- package/src/api/ton/TonGetAddress.ts +1 -1
- package/src/api/ton/TonSignMessage.ts +1 -1
- package/src/api/ton/TonSignProof.ts +1 -1
- package/src/api/tron/TronGetAddress.ts +1 -1
- package/src/api/tron/TronSignMessage.ts +1 -1
- package/src/api/tron/TronSignTransaction.ts +1 -1
- package/src/api/xrp/XrpGetAddress.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/core/index.ts +11 -7
- package/src/data/messages/messages.json +43 -38
- package/src/device/Device.ts +24 -10
- package/src/device/DeviceCommands.ts +15 -4
- package/src/events/device.ts +4 -0
- package/src/events/ui-request.ts +3 -2
- package/src/events/ui-response.ts +1 -0
- package/src/utils/deviceFeaturesUtils.ts +55 -49
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { isNaN } from 'lodash';
|
|
3
3
|
import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
4
|
-
|
|
4
|
+
import { toHardened } from '../api/helpers/pathUtils';
|
|
5
5
|
import { DeviceCommands } from '../device/DeviceCommands';
|
|
6
6
|
import type { Features, SupportFeatureType } from '../types';
|
|
7
7
|
import { DeviceModelToTypes, DeviceTypeToModels } from '../types';
|
|
@@ -83,11 +83,13 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
83
83
|
const { features, commands } = device;
|
|
84
84
|
const locked = features?.unlocked === false;
|
|
85
85
|
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
const { passphraseState, newSession, unlockedAttachPin } = await getPassphraseState(
|
|
87
|
+
features,
|
|
88
|
+
commands,
|
|
89
|
+
{
|
|
90
|
+
...options,
|
|
91
|
+
}
|
|
92
|
+
);
|
|
91
93
|
|
|
92
94
|
// Attach to pin try to fix internal state
|
|
93
95
|
if (newSession && passphraseState && features?.device_id) {
|
|
@@ -110,7 +112,7 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
110
112
|
await device.getFeatures();
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
return { passphraseState, newSession };
|
|
115
|
+
return { passphraseState, newSession, unlockedAttachPin };
|
|
114
116
|
};
|
|
115
117
|
|
|
116
118
|
export const getPassphraseState = async (
|
|
@@ -118,30 +120,53 @@ export const getPassphraseState = async (
|
|
|
118
120
|
commands: DeviceCommands,
|
|
119
121
|
options?: {
|
|
120
122
|
expectPassphraseState?: string;
|
|
121
|
-
sessionId?: string;
|
|
122
123
|
onlyMainPin?: boolean;
|
|
124
|
+
// createAttachPinWallet?: boolean;
|
|
123
125
|
}
|
|
124
|
-
): Promise<{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
'=====>>>>>> getPassphraseState begin: ',
|
|
132
|
-
options?.onlyMainPin,
|
|
133
|
-
options?.expectPassphraseState,
|
|
134
|
-
options?.sessionId
|
|
135
|
-
);
|
|
126
|
+
): Promise<{
|
|
127
|
+
passphraseState: string | undefined;
|
|
128
|
+
newSession: string | undefined;
|
|
129
|
+
unlockedAttachPin: boolean | undefined;
|
|
130
|
+
}> => {
|
|
131
|
+
if (!features)
|
|
132
|
+
return { passphraseState: undefined, newSession: undefined, unlockedAttachPin: undefined };
|
|
136
133
|
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
const firmwareVersion = getDeviceFirmwareVersion(features);
|
|
135
|
+
const deviceType = getDeviceType(features);
|
|
136
|
+
|
|
137
|
+
if (deviceType === EDeviceType.Pro && semver.gte(firmwareVersion.join('.'), '4.13.2')) {
|
|
138
|
+
console.log(
|
|
139
|
+
'=====>>>>>> getPassphraseState begin: ',
|
|
140
|
+
options?.onlyMainPin,
|
|
141
|
+
options?.expectPassphraseState
|
|
142
|
+
);
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
const { message, type } = await commands.typedCall('GetPassphraseState', 'PassphraseState', {
|
|
145
|
+
passphrase_state: options?.onlyMainPin ? undefined : options?.expectPassphraseState,
|
|
146
|
+
// allow_create_attach_pin: options?.createAttachPinWallet,
|
|
147
|
+
// _only_main_pin: options?.onlyMainPin,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
console.log('=====>>>>>> getPassphraseState end: result ', message);
|
|
151
|
+
|
|
152
|
+
// @ts-expect-error
|
|
153
|
+
if (type === 'CallMethodError') {
|
|
154
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
passphraseState: message.passphrase_state,
|
|
159
|
+
newSession: message.session_id,
|
|
160
|
+
unlockedAttachPin: message.unlocked_attach_pin,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const { message, type } = await commands.typedCall('GetAddress', 'Address', {
|
|
165
|
+
address_n: [toHardened(44), toHardened(1), toHardened(0), 0, 0],
|
|
166
|
+
coin_name: 'Testnet',
|
|
167
|
+
script_type: 'SPENDADDRESS',
|
|
168
|
+
show_display: false,
|
|
169
|
+
});
|
|
145
170
|
|
|
146
171
|
// @ts-expect-error
|
|
147
172
|
if (type === 'CallMethodError') {
|
|
@@ -149,29 +174,10 @@ export const getPassphraseState = async (
|
|
|
149
174
|
}
|
|
150
175
|
|
|
151
176
|
return {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
newSession: message.session_id,
|
|
177
|
+
passphraseState: message.address,
|
|
178
|
+
newSession: undefined,
|
|
179
|
+
unlockedAttachPin: undefined,
|
|
156
180
|
};
|
|
157
|
-
// }
|
|
158
|
-
|
|
159
|
-
// const { message, type } = await commands.typedCall('GetAddress', 'Address', {
|
|
160
|
-
// address_n: [toHardened(44), toHardened(1), toHardened(0), 0, 0],
|
|
161
|
-
// coin_name: 'Testnet',
|
|
162
|
-
// script_type: 'SPENDADDRESS',
|
|
163
|
-
// show_display: false,
|
|
164
|
-
// });
|
|
165
|
-
|
|
166
|
-
// // @ts-expect-error
|
|
167
|
-
// if (type === 'CallMethodError') {
|
|
168
|
-
// throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
169
|
-
// }
|
|
170
|
-
|
|
171
|
-
// return {
|
|
172
|
-
// passphraseState: message.address,
|
|
173
|
-
// newSession: undefined,
|
|
174
|
-
// };
|
|
175
181
|
};
|
|
176
182
|
|
|
177
183
|
export const supportBatchPublicKey = (
|