mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-07 07:47:59 +01:00
feat(connect): add tryToUnlock to ThpHandshakeInitRequest
This commit is contained in:
@@ -91,6 +91,7 @@ export const thpHandshake = async (device: Device) => {
|
||||
// 2. Send the message HandshakeInitiationReq(host_ephemeral_pubkey) to the host.
|
||||
const handshakeInit = await thpCall(device, 'ThpHandshakeInitRequest', {
|
||||
key: hostEphemeralKeys.publicKey,
|
||||
tryToUnlock: 0,
|
||||
});
|
||||
|
||||
const { trezorEncryptedStaticPubkey } = handshakeInit.message;
|
||||
|
||||
@@ -38,6 +38,9 @@ const getBytesFromField = (data: Record<string, unknown>, fieldName: string) =>
|
||||
if (typeof value === 'string') {
|
||||
return Buffer.from(value, 'hex');
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
return Buffer.from([value]);
|
||||
}
|
||||
if (Buffer.isBuffer(value)) {
|
||||
return value;
|
||||
}
|
||||
@@ -58,7 +61,9 @@ const handshakeInitRequestPayload = (data: Record<string, unknown>, _thpState: T
|
||||
throw new Error('ThpHandshakeInitRequest missing key field');
|
||||
}
|
||||
|
||||
return key;
|
||||
const tryToUnlock = getBytesFromField(data, 'tryToUnlock') ?? Buffer.from([0]);
|
||||
|
||||
return Buffer.concat([key, tryToUnlock]);
|
||||
};
|
||||
|
||||
const handshakeCompletionRequestPayload = (data: Record<string, unknown>) => {
|
||||
|
||||
@@ -33,6 +33,7 @@ export type ThpCreateChannelResponse = {
|
||||
|
||||
export type ThpHandshakeInitRequest = {
|
||||
key: Buffer;
|
||||
tryToUnlock: 0 | 1;
|
||||
};
|
||||
|
||||
export type ThpHandshakeInitResponse = {
|
||||
|
||||
Reference in New Issue
Block a user