mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-06 23:39:38 +01:00
feat(protocol): add THP protobuf types and state
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
export * as v1 from './protocol-v1';
|
||||
export * as v2 from './protocol-v2';
|
||||
export * as bridge from './protocol-bridge';
|
||||
export * as thp from './protocol-thp';
|
||||
export * as trzd from './protocol-trzd';
|
||||
export * from './errors';
|
||||
export * from './types';
|
||||
|
||||
23
packages/protocol/src/protocol-thp/ThpState.ts
Normal file
23
packages/protocol/src/protocol-thp/ThpState.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ThpDeviceProperties } from './messages';
|
||||
|
||||
export type ThpStateSerialized = {
|
||||
properties?: ThpDeviceProperties;
|
||||
};
|
||||
|
||||
export class ThpState {
|
||||
private _properties?: ThpDeviceProperties;
|
||||
|
||||
get properties() {
|
||||
return this._properties;
|
||||
}
|
||||
|
||||
setThpProperties(props: ThpDeviceProperties) {
|
||||
this._properties = props;
|
||||
}
|
||||
|
||||
serialize(): ThpStateSerialized {
|
||||
return {
|
||||
properties: this._properties,
|
||||
};
|
||||
}
|
||||
}
|
||||
5
packages/protocol/src/protocol-thp/index.ts
Normal file
5
packages/protocol/src/protocol-thp/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './messages';
|
||||
|
||||
export { ThpState } from './ThpState';
|
||||
|
||||
export const name = 'thp';
|
||||
2
packages/protocol/src/protocol-thp/messages/index.ts
Normal file
2
packages/protocol/src/protocol-thp/messages/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './protobufTypes';
|
||||
export * from './messageTypes';
|
||||
@@ -0,0 +1,3 @@
|
||||
import type { ThpCredentialResponse } from './protobufTypes';
|
||||
|
||||
export type ThpCredentials = ThpCredentialResponse & { autoconnect?: boolean };
|
||||
21
packages/protocol/src/protocol-thp/messages/protobufTypes.ts
Normal file
21
packages/protocol/src/protocol-thp/messages/protobufTypes.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// This file is auto generated by @trezor/protobuf package
|
||||
|
||||
export enum ThpPairingMethod {
|
||||
SkipPairing = 1,
|
||||
CodeEntry = 2,
|
||||
QrCode = 3,
|
||||
NFC = 4,
|
||||
}
|
||||
|
||||
export type ThpDeviceProperties = {
|
||||
internal_model: string;
|
||||
model_variant: number;
|
||||
protocol_version_major: number;
|
||||
protocol_version_minor: number;
|
||||
pairing_methods: ThpPairingMethod[];
|
||||
};
|
||||
|
||||
export type ThpCredentialResponse = {
|
||||
trezor_static_pubkey: string;
|
||||
credential: string;
|
||||
};
|
||||
@@ -1,3 +1,10 @@
|
||||
export type {
|
||||
ThpDeviceProperties,
|
||||
ThpPairingMethod,
|
||||
ThpCredentials,
|
||||
} from './protocol-thp/messages';
|
||||
export type { ThpState, ThpStateSerialized } from './protocol-thp/ThpState';
|
||||
|
||||
export type TransportProtocolDecode = (bytes: Buffer) => {
|
||||
header: Buffer;
|
||||
length: number;
|
||||
|
||||
Reference in New Issue
Block a user