@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
|
@@ -13,7 +13,7 @@ export default class StarcoinGetPublicKey extends BaseMethod<HardwareStarcoinGet
|
|
|
13
13
|
|
|
14
14
|
init() {
|
|
15
15
|
this.checkDeviceId = true;
|
|
16
|
-
this.
|
|
16
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
17
17
|
|
|
18
18
|
this.hasBundle = !!this.payload?.bundle;
|
|
19
19
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -8,7 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
8
8
|
export default class StarcoinSignMessage extends BaseMethod<HardwareStarcoinSignMessage> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
// check payload
|
|
14
14
|
validateParams(this.payload, [
|
|
@@ -8,7 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
8
8
|
export default class StarcoinSignTransaction extends BaseMethod<StarcoinSignTx> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
// check payload
|
|
14
14
|
validateParams(this.payload, [
|
|
@@ -7,7 +7,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
7
7
|
export default class EVMSignMessage extends BaseMethod<HardwareStarcoinVerifyMessage> {
|
|
8
8
|
init() {
|
|
9
9
|
this.checkDeviceId = true;
|
|
10
|
-
this.
|
|
10
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
11
11
|
|
|
12
12
|
validateParams(this.payload, [
|
|
13
13
|
{ name: 'publicKey', type: 'string', required: true },
|
|
@@ -10,7 +10,7 @@ export default class StellarGetAddress extends BaseMethod<HardwareStellarGetAddr
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -149,7 +149,7 @@ export default class StellarSignTransaction extends BaseMethod<HardwareStellarSi
|
|
|
149
149
|
|
|
150
150
|
init() {
|
|
151
151
|
this.checkDeviceId = true;
|
|
152
|
-
this.
|
|
152
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
153
153
|
|
|
154
154
|
// check payload
|
|
155
155
|
validateParams(this.payload, [
|
|
@@ -16,7 +16,7 @@ export default class SuiGetAddress extends BaseMethod<HardwareSuiGetAddress[]> {
|
|
|
16
16
|
|
|
17
17
|
init() {
|
|
18
18
|
this.checkDeviceId = true;
|
|
19
|
-
this.
|
|
19
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
20
20
|
|
|
21
21
|
this.hasBundle = !!this.payload?.bundle;
|
|
22
22
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -10,7 +10,7 @@ export default class SuiGetPublicKey extends BaseMethod<any> {
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -8,7 +8,7 @@ import { stripHexPrefix } from '../helpers/hexUtils';
|
|
|
8
8
|
export default class SuiSignMessage extends BaseMethod<HardwareSuiSignMessage> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
// check payload
|
|
14
14
|
validateParams(this.payload, [
|
|
@@ -15,7 +15,7 @@ type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> &
|
|
|
15
15
|
export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
|
|
16
16
|
init() {
|
|
17
17
|
this.checkDeviceId = true;
|
|
18
|
-
this.
|
|
18
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
19
19
|
|
|
20
20
|
// check payload
|
|
21
21
|
validateParams(this.payload, [
|
|
@@ -3,9 +3,9 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
3
3
|
|
|
4
4
|
export default class TestInitializeDeviceDuration extends BaseMethod {
|
|
5
5
|
init() {
|
|
6
|
-
this.
|
|
7
|
-
...this.
|
|
8
|
-
UI_REQUEST.
|
|
6
|
+
this.allowDeviceMode = [
|
|
7
|
+
...this.allowDeviceMode,
|
|
8
|
+
UI_REQUEST.NOT_INITIALIZE,
|
|
9
9
|
UI_REQUEST.BOOTLOADER,
|
|
10
10
|
];
|
|
11
11
|
this.useDevicePassphraseState = false;
|
|
@@ -14,7 +14,7 @@ export default class TonGetAddress extends BaseMethod<HardwareTonGetAddress[]> {
|
|
|
14
14
|
init() {
|
|
15
15
|
this.strictCheckDeviceSupport = true;
|
|
16
16
|
this.checkDeviceId = true;
|
|
17
|
-
this.
|
|
17
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
18
18
|
|
|
19
19
|
this.hasBundle = !!this.payload?.bundle;
|
|
20
20
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -22,7 +22,7 @@ export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
|
|
|
22
22
|
init() {
|
|
23
23
|
this.strictCheckDeviceSupport = true;
|
|
24
24
|
this.checkDeviceId = true;
|
|
25
|
-
this.
|
|
25
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
26
26
|
|
|
27
27
|
// init params
|
|
28
28
|
validateParams(this.payload, [
|
|
@@ -10,7 +10,7 @@ export default class TonSignProof extends BaseMethod<HardwareTonSignProof> {
|
|
|
10
10
|
init() {
|
|
11
11
|
this.strictCheckDeviceSupport = true;
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
// init params
|
|
16
16
|
validateParams(this.payload, [
|
|
@@ -10,7 +10,7 @@ export default class TronGetAddress extends BaseMethod<HardwareTronGetAddress[]>
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -8,7 +8,7 @@ import { stripHexPrefix } from '../helpers/hexUtils';
|
|
|
8
8
|
export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
// check payload
|
|
14
14
|
validateParams(this.payload, [
|
|
@@ -119,7 +119,7 @@ export default class TronSignTransaction extends BaseMethod<TronSignTx> {
|
|
|
119
119
|
|
|
120
120
|
init() {
|
|
121
121
|
this.checkDeviceId = true;
|
|
122
|
-
this.
|
|
122
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
123
123
|
|
|
124
124
|
// check payload
|
|
125
125
|
validateParams(this.payload, [
|
|
@@ -19,7 +19,7 @@ export default class XrpGetAddress extends BaseMethod<
|
|
|
19
19
|
|
|
20
20
|
init() {
|
|
21
21
|
this.checkDeviceId = true;
|
|
22
|
-
this.
|
|
22
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
23
23
|
|
|
24
24
|
this.hasBundle = !!this.payload?.bundle;
|
|
25
25
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -9,7 +9,7 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
|
|
|
9
9
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
|
-
this.
|
|
12
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
13
|
|
|
14
14
|
const { payload } = this;
|
|
15
15
|
validateParams(payload, [
|
package/src/core/index.ts
CHANGED
|
@@ -285,7 +285,7 @@ const onCallDevice = async (
|
|
|
285
285
|
|
|
286
286
|
// check call method mode
|
|
287
287
|
const unexpectedMode = device.hasUnexpectedMode(
|
|
288
|
-
method.
|
|
288
|
+
method.allowDeviceMode,
|
|
289
289
|
method.requireDeviceMode
|
|
290
290
|
);
|
|
291
291
|
if (unexpectedMode) {
|
|
@@ -837,12 +837,12 @@ const onDevicePinHandler = async (...[device, type, callback]: DeviceEvents['pin
|
|
|
837
837
|
const onDeviceButtonHandler = (...[device, request]: [...DeviceEvents['button']]) => {
|
|
838
838
|
postMessage(createDeviceMessage(DEVICE.BUTTON, { ...request, device: device.toMessageObject() }));
|
|
839
839
|
|
|
840
|
-
if (request.code === 'ButtonRequest_PinEntry') {
|
|
841
|
-
Log.log('request Confirm Input PIN');
|
|
840
|
+
if (request.code === 'ButtonRequest_PinEntry' || request.code === 'ButtonRequest_AttachPin') {
|
|
841
|
+
Log.log('request Confirm Input PIN or Attach PIN');
|
|
842
842
|
postMessage(
|
|
843
843
|
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
844
844
|
device: device.toMessageObject() as KnownDevice,
|
|
845
|
-
type:
|
|
845
|
+
type: request.code,
|
|
846
846
|
})
|
|
847
847
|
);
|
|
848
848
|
} else {
|
|
@@ -855,27 +855,31 @@ const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]
|
|
|
855
855
|
postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
|
|
856
856
|
};
|
|
857
857
|
|
|
858
|
-
const onDevicePassphraseHandler = async (
|
|
858
|
+
const onDevicePassphraseHandler = async (
|
|
859
|
+
...[device, requestPayload, callback]: DeviceEvents['passphrase']
|
|
860
|
+
) => {
|
|
859
861
|
Log.debug('onDevicePassphraseHandler');
|
|
860
862
|
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
|
|
861
863
|
postMessage(
|
|
862
864
|
createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE, {
|
|
863
865
|
device: device.toMessageObject() as KnownDevice,
|
|
864
866
|
passphraseState: device.passphraseState,
|
|
867
|
+
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
865
868
|
})
|
|
866
869
|
);
|
|
867
870
|
// wait for passphrase
|
|
868
871
|
const uiResp = await uiPromise.promise;
|
|
869
|
-
const { value, passphraseOnDevice, save } = uiResp.payload;
|
|
872
|
+
const { value, passphraseOnDevice, save, attachPinOnDevice } = uiResp.payload;
|
|
870
873
|
// send as PassphrasePromptResponse
|
|
871
874
|
callback({
|
|
872
875
|
passphrase: value.normalize('NFKD'),
|
|
873
876
|
passphraseOnDevice,
|
|
877
|
+
attachPinOnDevice,
|
|
874
878
|
cache: save,
|
|
875
879
|
});
|
|
876
880
|
};
|
|
877
881
|
|
|
878
|
-
const onEmptyPassphraseHandler = (...[_, callback]: DeviceEvents['passphrase']) => {
|
|
882
|
+
const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']) => {
|
|
879
883
|
Log.debug('onEmptyPassphraseHandler');
|
|
880
884
|
// send as PassphrasePromptResponse
|
|
881
885
|
callback({ passphrase: '' });
|
|
@@ -3021,7 +3021,8 @@
|
|
|
3021
3021
|
"ButtonRequest_Success": 17,
|
|
3022
3022
|
"ButtonRequest_Warning": 18,
|
|
3023
3023
|
"ButtonRequest_PassphraseEntry": 19,
|
|
3024
|
-
"ButtonRequest_PinEntry": 20
|
|
3024
|
+
"ButtonRequest_PinEntry": 20,
|
|
3025
|
+
"ButtonRequest_AttachPin": 8000
|
|
3025
3026
|
}
|
|
3026
3027
|
}
|
|
3027
3028
|
}
|
|
@@ -3071,6 +3072,10 @@
|
|
|
3071
3072
|
"options": {
|
|
3072
3073
|
"deprecated": true
|
|
3073
3074
|
}
|
|
3075
|
+
},
|
|
3076
|
+
"exists_attach_pin_user": {
|
|
3077
|
+
"type": "bool",
|
|
3078
|
+
"id": 8000
|
|
3074
3079
|
}
|
|
3075
3080
|
}
|
|
3076
3081
|
},
|
|
@@ -3090,6 +3095,10 @@
|
|
|
3090
3095
|
"on_device": {
|
|
3091
3096
|
"type": "bool",
|
|
3092
3097
|
"id": 3
|
|
3098
|
+
},
|
|
3099
|
+
"on_device_attach_pin": {
|
|
3100
|
+
"type": "bool",
|
|
3101
|
+
"id": 8000
|
|
3093
3102
|
}
|
|
3094
3103
|
}
|
|
3095
3104
|
},
|
|
@@ -3146,38 +3155,6 @@
|
|
|
3146
3155
|
"BixinPinInputOnDevice": {
|
|
3147
3156
|
"fields": {}
|
|
3148
3157
|
},
|
|
3149
|
-
"GetPassphraseState": {
|
|
3150
|
-
"fields": {
|
|
3151
|
-
"btc_test": {
|
|
3152
|
-
"type": "string",
|
|
3153
|
-
"id": 1
|
|
3154
|
-
},
|
|
3155
|
-
"only_main_pin": {
|
|
3156
|
-
"type": "bool",
|
|
3157
|
-
"id": 2
|
|
3158
|
-
},
|
|
3159
|
-
"session_id": {
|
|
3160
|
-
"type": "bytes",
|
|
3161
|
-
"id": 3
|
|
3162
|
-
}
|
|
3163
|
-
}
|
|
3164
|
-
},
|
|
3165
|
-
"PassphraseState": {
|
|
3166
|
-
"fields": {
|
|
3167
|
-
"btc_test": {
|
|
3168
|
-
"type": "string",
|
|
3169
|
-
"id": 1
|
|
3170
|
-
},
|
|
3171
|
-
"session_id": {
|
|
3172
|
-
"type": "bytes",
|
|
3173
|
-
"id": 2
|
|
3174
|
-
},
|
|
3175
|
-
"attach_to_pin_user": {
|
|
3176
|
-
"type": "bool",
|
|
3177
|
-
"id": 3
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
},
|
|
3181
3158
|
"ConfluxGetAddress": {
|
|
3182
3159
|
"fields": {
|
|
3183
3160
|
"address_n": {
|
|
@@ -6086,7 +6063,7 @@
|
|
|
6086
6063
|
},
|
|
6087
6064
|
"btc_test": {
|
|
6088
6065
|
"type": "string",
|
|
6089
|
-
"id":
|
|
6066
|
+
"id": 8000
|
|
6090
6067
|
}
|
|
6091
6068
|
}
|
|
6092
6069
|
},
|
|
@@ -6465,10 +6442,6 @@
|
|
|
6465
6442
|
"onekey_se04_state": {
|
|
6466
6443
|
"type": "OneKeySEState",
|
|
6467
6444
|
"id": 624
|
|
6468
|
-
},
|
|
6469
|
-
"attach_to_pin_user": {
|
|
6470
|
-
"type": "bool",
|
|
6471
|
-
"id": 625
|
|
6472
6445
|
}
|
|
6473
6446
|
},
|
|
6474
6447
|
"nested": {
|
|
@@ -7573,6 +7546,38 @@
|
|
|
7573
7546
|
}
|
|
7574
7547
|
}
|
|
7575
7548
|
},
|
|
7549
|
+
"GetPassphraseState": {
|
|
7550
|
+
"fields": {
|
|
7551
|
+
"passphrase_state": {
|
|
7552
|
+
"type": "string",
|
|
7553
|
+
"id": 1
|
|
7554
|
+
},
|
|
7555
|
+
"_only_main_pin": {
|
|
7556
|
+
"type": "bool",
|
|
7557
|
+
"id": 2
|
|
7558
|
+
},
|
|
7559
|
+
"allow_create_attach_pin": {
|
|
7560
|
+
"type": "bool",
|
|
7561
|
+
"id": 3
|
|
7562
|
+
}
|
|
7563
|
+
}
|
|
7564
|
+
},
|
|
7565
|
+
"PassphraseState": {
|
|
7566
|
+
"fields": {
|
|
7567
|
+
"passphrase_state": {
|
|
7568
|
+
"type": "string",
|
|
7569
|
+
"id": 1
|
|
7570
|
+
},
|
|
7571
|
+
"session_id": {
|
|
7572
|
+
"type": "bytes",
|
|
7573
|
+
"id": 2
|
|
7574
|
+
},
|
|
7575
|
+
"unlocked_attach_pin": {
|
|
7576
|
+
"type": "bool",
|
|
7577
|
+
"id": 3
|
|
7578
|
+
}
|
|
7579
|
+
}
|
|
7580
|
+
},
|
|
7576
7581
|
"MoneroTransactionSourceEntry": {
|
|
7577
7582
|
"fields": {
|
|
7578
7583
|
"outputs": {
|
package/src/device/Device.ts
CHANGED
|
@@ -33,7 +33,13 @@ import {
|
|
|
33
33
|
type Features,
|
|
34
34
|
type UnavailableCapabilities,
|
|
35
35
|
} from '../types';
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
DEVICE,
|
|
38
|
+
DeviceButtonRequestPayload,
|
|
39
|
+
DeviceFeaturesPayload,
|
|
40
|
+
PassphraseRequestPayload,
|
|
41
|
+
UI_REQUEST,
|
|
42
|
+
} from '../events';
|
|
37
43
|
import { PROTO } from '../constants';
|
|
38
44
|
import { DataManager } from '../data-manager';
|
|
39
45
|
import TransportManager from '../data-manager/TransportManager';
|
|
@@ -61,7 +67,11 @@ export interface DeviceEvents {
|
|
|
61
67
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
62
68
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
63
69
|
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
64
|
-
[DEVICE.PASSPHRASE]: [
|
|
70
|
+
[DEVICE.PASSPHRASE]: [
|
|
71
|
+
Device,
|
|
72
|
+
PassphraseRequestPayload,
|
|
73
|
+
(response: PassphrasePromptResponse, error?: Error) => void
|
|
74
|
+
];
|
|
65
75
|
[DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE]: [
|
|
66
76
|
Device,
|
|
67
77
|
(err: any, deviceId: string) => void
|
|
@@ -398,7 +408,7 @@ export class Device extends EventEmitter {
|
|
|
398
408
|
if (options?.deriveCardano) {
|
|
399
409
|
payload.derive_cardano = true;
|
|
400
410
|
}
|
|
401
|
-
payload.
|
|
411
|
+
payload.passphrase_state = options?.passphraseState;
|
|
402
412
|
|
|
403
413
|
// Log.debug('initialize payload:', payload);
|
|
404
414
|
console.log('=====>>>>>> initialize device begin: ', payload, {
|
|
@@ -689,8 +699,8 @@ export class Device extends EventEmitter {
|
|
|
689
699
|
if (this.isBootloader() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
690
700
|
return UI_REQUEST.BOOTLOADER;
|
|
691
701
|
}
|
|
692
|
-
if (!this.isInitialized() && !allow.includes(UI_REQUEST.
|
|
693
|
-
return UI_REQUEST.
|
|
702
|
+
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
703
|
+
return UI_REQUEST.NOT_INITIALIZE;
|
|
694
704
|
}
|
|
695
705
|
if (this.isSeedless() && !allow.includes(UI_REQUEST.SEEDLESS)) {
|
|
696
706
|
return UI_REQUEST.SEEDLESS;
|
|
@@ -722,13 +732,17 @@ export class Device extends EventEmitter {
|
|
|
722
732
|
|
|
723
733
|
async checkPassphraseStateSafety(passphraseState?: string, useEmptyPassphraseState?: boolean) {
|
|
724
734
|
if (!this.features) return false;
|
|
725
|
-
const { passphraseState: newPassphraseState } =
|
|
726
|
-
this,
|
|
727
|
-
{
|
|
735
|
+
const { passphraseState: newPassphraseState, unlockedAttachPin } =
|
|
736
|
+
await getPassphraseStateWithRefreshDeviceInfo(this, {
|
|
728
737
|
expectPassphraseState: passphraseState,
|
|
729
738
|
onlyMainPin: useEmptyPassphraseState,
|
|
730
|
-
}
|
|
731
|
-
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// Main wallet and unlock Attach Pin, throw safe error
|
|
742
|
+
if (unlockedAttachPin && useEmptyPassphraseState) {
|
|
743
|
+
this.clearInternalState();
|
|
744
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceCheckUnlockTypeError));
|
|
745
|
+
}
|
|
732
746
|
|
|
733
747
|
// When exists passphraseState, check passphraseState
|
|
734
748
|
if (passphraseState && passphraseState !== newPassphraseState) {
|
|
@@ -4,12 +4,13 @@ import TransportManager from '../data-manager/TransportManager';
|
|
|
4
4
|
import DataManager from '../data-manager/DataManager';
|
|
5
5
|
import { patchFeatures, getLogger, LoggerNames, getDeviceType } from '../utils';
|
|
6
6
|
import type { Device } from './Device';
|
|
7
|
-
import { DEVICE } from '../events';
|
|
7
|
+
import { DEVICE, type PassphraseRequestPayload } from '../events';
|
|
8
8
|
import { DeviceModelToTypes } from '../types';
|
|
9
9
|
|
|
10
10
|
export type PassphrasePromptResponse = {
|
|
11
11
|
passphrase?: string;
|
|
12
12
|
passphraseOnDevice?: boolean;
|
|
13
|
+
attachPinOnDevice?: boolean;
|
|
13
14
|
cache?: boolean;
|
|
14
15
|
};
|
|
15
16
|
|
|
@@ -438,8 +439,17 @@ export class DeviceCommands {
|
|
|
438
439
|
}
|
|
439
440
|
|
|
440
441
|
if (res.type === 'PassphraseRequest') {
|
|
441
|
-
|
|
442
|
-
|
|
442
|
+
const existsAttachPinUser = res.message.exists_attach_pin_user;
|
|
443
|
+
return this._promptPassphrase({
|
|
444
|
+
existsAttachPinUser,
|
|
445
|
+
}).then(response => {
|
|
446
|
+
const { passphrase, passphraseOnDevice, attachPinOnDevice } = response;
|
|
447
|
+
|
|
448
|
+
// Attach PIN on device
|
|
449
|
+
if (attachPinOnDevice && existsAttachPinUser) {
|
|
450
|
+
return this._commonCall('PassphraseAck', { on_device_attach_pin: true });
|
|
451
|
+
}
|
|
452
|
+
|
|
443
453
|
return !passphraseOnDevice
|
|
444
454
|
? this._commonCall('PassphraseAck', { passphrase })
|
|
445
455
|
: this._commonCall('PassphraseAck', { on_device: true });
|
|
@@ -501,7 +511,7 @@ export class DeviceCommands {
|
|
|
501
511
|
});
|
|
502
512
|
}
|
|
503
513
|
|
|
504
|
-
_promptPassphrase() {
|
|
514
|
+
_promptPassphrase(options: PassphraseRequestPayload) {
|
|
505
515
|
return new Promise<PassphrasePromptResponse>((resolve, reject) => {
|
|
506
516
|
const cancelAndReject = (_error?: Error) =>
|
|
507
517
|
cancelDeviceInPrompt(this.device, false)
|
|
@@ -527,6 +537,7 @@ export class DeviceCommands {
|
|
|
527
537
|
this.device.emit(
|
|
528
538
|
DEVICE.PASSPHRASE,
|
|
529
539
|
this.device,
|
|
540
|
+
options,
|
|
530
541
|
(response: PassphrasePromptResponse, error?: Error) => {
|
|
531
542
|
this.device.clearCancelableAction();
|
|
532
543
|
if (error) {
|
package/src/events/device.ts
CHANGED
|
@@ -44,6 +44,10 @@ export interface DeviceButtonRequestPayload extends Omit<PROTO.ButtonRequest, 'c
|
|
|
44
44
|
code?: PROTO.ButtonRequest['code'] | 'ButtonRequest_FirmwareUpdate';
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
export type PassphraseRequestPayload = {
|
|
48
|
+
existsAttachPinUser?: boolean;
|
|
49
|
+
};
|
|
50
|
+
|
|
47
51
|
export interface DeviceButtonRequest {
|
|
48
52
|
type: typeof DEVICE.BUTTON;
|
|
49
53
|
payload: DeviceButtonRequestPayload & { device: Device | null };
|
package/src/events/ui-request.ts
CHANGED
|
@@ -34,7 +34,7 @@ export const UI_REQUEST = {
|
|
|
34
34
|
BOOTLOADER: 'ui-device_bootloader_mode',
|
|
35
35
|
NOT_IN_BOOTLOADER: 'ui-device_not_in_bootloader_mode',
|
|
36
36
|
REQUIRE_MODE: 'ui-device_require_mode',
|
|
37
|
-
|
|
37
|
+
NOT_INITIALIZE: 'ui-device_not_initialized',
|
|
38
38
|
SEEDLESS: 'ui-device_seedless',
|
|
39
39
|
FIRMWARE_OLD: 'ui-device_firmware_old',
|
|
40
40
|
FIRMWARE_NOT_SUPPORTED: 'ui-device_firmware_unsupported',
|
|
@@ -66,7 +66,7 @@ export type UiRequestDeviceAction = {
|
|
|
66
66
|
type: typeof UI_REQUEST.REQUEST_PIN;
|
|
67
67
|
payload: {
|
|
68
68
|
device: Device;
|
|
69
|
-
type?: PROTO.PinMatrixRequestType | 'ButtonRequest_PinEntry';
|
|
69
|
+
type?: PROTO.PinMatrixRequestType | 'ButtonRequest_PinEntry' | 'ButtonRequest_AttachPin';
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
|
|
@@ -80,6 +80,7 @@ export interface UiRequestPassphrase {
|
|
|
80
80
|
payload: {
|
|
81
81
|
device: Device;
|
|
82
82
|
passphraseState?: string;
|
|
83
|
+
existsAttachPinUser?: boolean;
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
|