diff --git a/packages/connect/src/types/index.ts b/packages/connect/src/types/index.ts index 88157b7fc0..c2391be9df 100644 --- a/packages/connect/src/types/index.ts +++ b/packages/connect/src/types/index.ts @@ -44,3 +44,4 @@ export type { } from '@trezor/blockchain-link'; export { FirmwareType, type VersionArray } from '@trezor/device-utils'; +export { ThpPairingMethod } from '@trezor/protocol/src/protocol-thp/messages'; diff --git a/packages/protocol/src/protocol-thp/index.ts b/packages/protocol/src/protocol-thp/index.ts index 749795ce0e..26b9f8c02a 100644 --- a/packages/protocol/src/protocol-thp/index.ts +++ b/packages/protocol/src/protocol-thp/index.ts @@ -15,5 +15,6 @@ export { } from './crypto/pairing'; export { ThpState } from './ThpState'; export { getCurve25519KeyPair } from './crypto/curve25519'; +export { getThpPairingMethod } from './utils'; export const name = 'thp'; diff --git a/packages/protocol/src/protocol-thp/utils.ts b/packages/protocol/src/protocol-thp/utils.ts index f3b8ca90ae..5b7eab141c 100644 --- a/packages/protocol/src/protocol-thp/utils.ts +++ b/packages/protocol/src/protocol-thp/utils.ts @@ -12,7 +12,7 @@ import { THP_HANDSHAKE_INIT_RESPONSE, THP_READ_ACK_HEADER_BYTE, } from './constants'; -import type { ThpMessageSyncBit } from './messages'; +import { ThpMessageSyncBit, ThpPairingMethod } from './messages'; export const addAckBit = (magic: number, ackBit: number) => { const result = Buffer.alloc(1); @@ -154,3 +154,6 @@ export const isThpMessageName = (name: string) => 'ThpHandshakeCompletionRequest', 'ThpReadAck', ].includes(name); + +export const getThpPairingMethod = (dm: ThpPairingMethod | keyof typeof ThpPairingMethod) => + typeof dm === 'string' ? ThpPairingMethod[dm] : dm; diff --git a/packages/protocol/src/types.ts b/packages/protocol/src/types.ts index 111b43d937..a4932c4abd 100644 --- a/packages/protocol/src/types.ts +++ b/packages/protocol/src/types.ts @@ -1,7 +1,7 @@ -export type { - ThpDeviceProperties, +export { ThpPairingMethod, - ThpCredentials, + type ThpDeviceProperties, + type ThpCredentials, } from './protocol-thp/messages'; export type { ThpState, ThpStateSerialized, ThpChannelState } from './protocol-thp/ThpState';