Skip to content

Commit ed6fdf9

Browse files
committed
feat(protocol): add credentials to ThpState
1 parent 67add57 commit ed6fdf9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/protocol/src/protocol-thp/ThpState.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { ThpDeviceProperties } from './messages';
1+
import { ThpCredentials, ThpDeviceProperties } from './messages';
22

33
export type ThpStateSerialized = {
44
properties?: ThpDeviceProperties;
5+
credentials: ThpCredentials[];
56
};
67

78
export class ThpState {
89
private _properties?: ThpDeviceProperties;
10+
private _pairingCredentials: ThpCredentials[] = [];
911

1012
get properties() {
1113
return this._properties;
@@ -15,9 +17,22 @@ export class ThpState {
1517
this._properties = props;
1618
}
1719

20+
get pairingCredentials() {
21+
return this._pairingCredentials;
22+
}
23+
24+
setPairingCredentials(credentials?: ThpCredentials[]) {
25+
if (credentials) {
26+
this._pairingCredentials.push(...credentials);
27+
} else {
28+
this._pairingCredentials = [];
29+
}
30+
}
31+
1832
serialize(): ThpStateSerialized {
1933
return {
2034
properties: this._properties,
35+
credentials: this._pairingCredentials,
2136
};
2237
}
2338
}

0 commit comments

Comments
 (0)