mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-06 23:39:38 +01:00
feat(connect): handle channel replacement in THP pairing
This commit is contained in:
committed by
Marek Polák
parent
31f0d0e331
commit
612f40e74d
@@ -138,10 +138,11 @@ export const thpHandshake = async (device: Device, unlockPin = false) => {
|
||||
}
|
||||
}
|
||||
|
||||
thpState.setIsPaired(!!handshakeCompletion.message.state);
|
||||
thpState.setIsPaired(handshakeCompletion.message.state !== 0);
|
||||
thpState.setPhase('pairing');
|
||||
|
||||
if (thpState.isPaired && thpState.isAutoconnectPaired) {
|
||||
if (thpState.isAutoconnectPaired || handshakeCompletion.message.state === 2) {
|
||||
// State HC1 -> HC2 pairing complete
|
||||
// finish pairing. device is ready to communicate without further interaction
|
||||
await thpCall(device, 'ThpEndRequest', {});
|
||||
thpState.setPhase('paired');
|
||||
|
||||
@@ -47,6 +47,9 @@ export type ThpHandshakeCompletionRequest = {
|
||||
encryptedPayload: Buffer;
|
||||
};
|
||||
|
||||
// 0 - not paired
|
||||
// 1 - paired but will require connection confirmation (thp_connection_request)
|
||||
// 2 - paired with autoconnect. no further interaction needed
|
||||
export type ThpHandshakeCompletionResponse = {
|
||||
state: 0 | 1 | 2;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user