mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-06 23:39:38 +01:00
feat(protocol): add credentials to ThpState
This commit is contained in:
committed by
Szymon Lesisz
parent
a2922905e8
commit
c883e604c1
@@ -1,11 +1,13 @@
|
||||
import { ThpDeviceProperties } from './messages';
|
||||
import { ThpCredentials, ThpDeviceProperties } from './messages';
|
||||
|
||||
export type ThpStateSerialized = {
|
||||
properties?: ThpDeviceProperties;
|
||||
credentials: ThpCredentials[];
|
||||
};
|
||||
|
||||
export class ThpState {
|
||||
private _properties?: ThpDeviceProperties;
|
||||
private _pairingCredentials: ThpCredentials[] = [];
|
||||
|
||||
get properties() {
|
||||
return this._properties;
|
||||
@@ -15,9 +17,22 @@ export class ThpState {
|
||||
this._properties = props;
|
||||
}
|
||||
|
||||
get pairingCredentials() {
|
||||
return this._pairingCredentials;
|
||||
}
|
||||
|
||||
setPairingCredentials(credentials?: ThpCredentials[]) {
|
||||
if (credentials) {
|
||||
this._pairingCredentials.push(...credentials);
|
||||
} else {
|
||||
this._pairingCredentials = [];
|
||||
}
|
||||
}
|
||||
|
||||
serialize(): ThpStateSerialized {
|
||||
return {
|
||||
properties: this._properties,
|
||||
credentials: this._pairingCredentials,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user