@matterbridge/core 3.11.3-dev-20261107-92e4713 → 3.11.3-dev-20261109-ca46ffb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,352 @@
1
+ import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, sign, X509Certificate } from 'node:crypto';
2
+ import { Bytes, Time } from '@matter/general';
3
+ import { AttributeModel, FieldElement } from '@matter/main/model';
4
+ import { Node } from '@matter/node';
5
+ import { OperationalCredentialsServer } from '@matter/node/behaviors/operational-credentials';
6
+ import { TimeSynchronizationServer } from '@matter/node/behaviors/time-synchronization';
7
+ import { TlsCertificateManagementServer } from '@matter/node/behaviors/tls-certificate-management';
8
+ import { TlsClientManagementServer } from '@matter/node/behaviors/tls-client-management';
9
+ import { FabricManager, Val } from '@matter/protocol';
10
+ import { TlsCertificateManagement } from '@matter/types/clusters/tls-certificate-management';
11
+ import { StatusResponseError } from '@matter/types/common';
12
+ import { FabricIndex } from '@matter/types/datatype';
13
+ import { Status } from '@matter/types/globals';
14
+ import { AnsiLogger, MAGENTA } from 'node-ansi-logger';
15
+ export const MAX_TLS_CERTIFICATE_ID = 65534;
16
+ export const MAX_CERTIFICATE_BYTES = 3000;
17
+ export const MAX_FINGERPRINT_BYTES = 64;
18
+ export const CLIENT_CSR_NONCE_BYTES = 32;
19
+ export const MAX_INTERMEDIATE_CERTIFICATES = 10;
20
+ const OID_COMMON_NAME = Buffer.from([0x06, 0x03, 0x55, 0x04, 0x03]);
21
+ const OID_ECDSA_WITH_SHA256 = Buffer.from([0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02]);
22
+ const CSR_COMMON_NAME = 'Matterbridge TLS Client';
23
+ const log = new AnsiLogger({ logName: 'TlsCertificates', logLevel: "info", logNameColor: MAGENTA, logTimestampFormat: 4 });
24
+ function der(tag, content) {
25
+ const { length } = content;
26
+ if (length < 0x80)
27
+ return Buffer.concat([Buffer.from([tag, length]), content]);
28
+ const lengthBytes = [];
29
+ for (let remaining = length; remaining > 0; remaining = Math.floor(remaining / 256))
30
+ lengthBytes.unshift(remaining % 256);
31
+ return Buffer.concat([Buffer.from([tag, 0x80 + lengthBytes.length, ...lengthBytes]), content]);
32
+ }
33
+ export function createClientCsr(privateKey) {
34
+ const key = createPrivateKey({ key: Buffer.from(privateKey), format: 'der', type: 'pkcs8' });
35
+ const publicKeyInfo = createPublicKey(key).export({ type: 'spki', format: 'der' });
36
+ const subject = der(0x30, der(0x31, der(0x30, Buffer.concat([OID_COMMON_NAME, der(0x0c, Buffer.from(CSR_COMMON_NAME, 'utf8'))]))));
37
+ const requestInfo = der(0x30, Buffer.concat([der(0x02, Buffer.from([0x00])), subject, publicKeyInfo, Buffer.from([0xa0, 0x00])]));
38
+ const signature = sign('sha256', requestInfo, key);
39
+ return der(0x30, Buffer.concat([requestInfo, der(0x30, OID_ECDSA_WITH_SHA256), der(0x03, Buffer.concat([Buffer.from([0x00]), signature]))]));
40
+ }
41
+ export function signClientCsrNonce(privateKey, nonce) {
42
+ const key = createPrivateKey({ key: Buffer.from(privateKey), format: 'der', type: 'pkcs8' });
43
+ return sign('sha256', nonce, { key, dsaEncoding: 'ieee-p1363' });
44
+ }
45
+ export function publicKeyPoint(privateKey) {
46
+ const spki = createPublicKey(createPrivateKey({ key: Buffer.from(privateKey), format: 'der', type: 'pkcs8' })).export({ type: 'spki', format: 'der' });
47
+ return spki.subarray(spki.length - 65);
48
+ }
49
+ export function certificateFingerprint(certificate) {
50
+ return createHash('sha256').update(certificate).digest();
51
+ }
52
+ export function parseValidCertificate(certificate) {
53
+ let x509;
54
+ try {
55
+ x509 = new X509Certificate(Buffer.from(certificate));
56
+ }
57
+ catch {
58
+ return undefined;
59
+ }
60
+ if (!x509.raw.equals(Buffer.from(certificate)))
61
+ return undefined;
62
+ const now = Time.nowMs;
63
+ if (now < Date.parse(x509.validFrom) || now > Date.parse(x509.validTo))
64
+ return undefined;
65
+ return x509;
66
+ }
67
+ export function allocateId(used, next) {
68
+ for (let i = 0; i <= MAX_TLS_CERTIFICATE_ID; i++) {
69
+ const id = (next + i) % (MAX_TLS_CERTIFICATE_ID + 1);
70
+ if (!used.has(id))
71
+ return id;
72
+ }
73
+ throw new StatusResponseError('No ID available', Status.ResourceExhausted);
74
+ }
75
+ const { schema } = TlsCertificateManagement;
76
+ const TlsCertificateManagementSchema = schema.extend(undefined, schema.require(AttributeModel, 'provisionedRootCertificates').extend({ constraint: 'none' }), schema.require(AttributeModel, 'provisionedClientCertificates').extend({ constraint: 'none' }), FieldElement({ name: 'RootCertificateStore', type: 'list', quality: 'N' }, FieldElement({ name: 'entry', type: 'struct' }, FieldElement({ name: 'Caid', id: 0, type: 'uint16' }), FieldElement({ name: 'Fabric', id: 1, type: 'uint8' }), FieldElement({ name: 'Certificate', id: 2, type: 'octstr' }))), FieldElement({ name: 'ClientCertificateStore', type: 'list', quality: 'N' }, FieldElement({ name: 'entry', type: 'struct' }, FieldElement({ name: 'Ccdid', id: 0, type: 'uint16' }), FieldElement({ name: 'Fabric', id: 1, type: 'uint8' }), FieldElement({ name: 'ClientCertificate', id: 2, type: 'octstr', quality: 'X' }), FieldElement({ name: 'IntermediateCertificates', id: 3, type: 'list' }, FieldElement({ name: 'entry', type: 'octstr' })), FieldElement({ name: 'PrivateKey', id: 4, type: 'octstr' }))), FieldElement({ name: 'NextCaid', type: 'uint16', quality: 'N' }), FieldElement({ name: 'NextCcdid', type: 'uint16', quality: 'N' }));
77
+ const MatterbridgeTlsCertificateManagementServerBase = TlsCertificateManagementServer.for(TlsCertificateManagement, TlsCertificateManagementSchema);
78
+ export class MatterbridgeTlsCertificateManagementServer extends MatterbridgeTlsCertificateManagementServerBase {
79
+ initialize() {
80
+ this.#updateAttributes();
81
+ const node = Node.forEndpoint(this.endpoint);
82
+ this.reactTo(node.eventsOf(OperationalCredentialsServer).fabrics$Changed, this.#handleFabricsChanged, { offline: true, lock: true });
83
+ }
84
+ provisionRootCertificate(request) {
85
+ const certificate = Bytes.of(request.certificate);
86
+ const { caid } = request;
87
+ const fabric = this.#accessingFabric();
88
+ if (certificate.byteLength > MAX_CERTIFICATE_BYTES) {
89
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: certificate of ${certificate.byteLength} octets exceeds ${MAX_CERTIFICATE_BYTES} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
90
+ }
91
+ if (caid !== null && caid > MAX_TLS_CERTIFICATE_ID) {
92
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: the CAID ${caid} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
93
+ }
94
+ if (this.endpoint.behaviors.has(TimeSynchronizationServer) && this.endpoint.stateOf(TimeSynchronizationServer).utcTime === null) {
95
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: time synchronization has not yet occurred (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.InvalidInState);
96
+ }
97
+ if (parseValidCertificate(certificate) === undefined) {
98
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: not a valid DER encoded X.509 certificate (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.DynamicConstraintError);
99
+ }
100
+ const store = this.state.rootCertificateStore;
101
+ const fingerprint = certificateFingerprint(certificate);
102
+ if (store.some((entry) => entry.fabric === fabric && certificateFingerprint(entry.certificate).equals(fingerprint))) {
103
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: certificate already provisioned (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.AlreadyExists);
104
+ }
105
+ if (caid !== null) {
106
+ if (!store.some((entry) => entry.fabric === fabric && entry.caid === caid)) {
107
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: the CAID ${caid} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
108
+ }
109
+ this.state.rootCertificateStore = store.map((entry) => (entry.fabric === fabric && entry.caid === caid ? { caid, fabric, certificate } : entry));
110
+ this.#updateAttributes();
111
+ log.info(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: root certificate CAID ${caid} updated on fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
112
+ return { caid };
113
+ }
114
+ if (store.filter((entry) => entry.fabric === fabric).length >= this.state.maxRootCertificates) {
115
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: fabric ${fabric} already has ${this.state.maxRootCertificates} root certificates (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ResourceExhausted);
116
+ }
117
+ const id = allocateId(new Set(store.map((entry) => entry.caid)), this.state.nextCaid);
118
+ this.state.nextCaid = (id + 1) % (MAX_TLS_CERTIFICATE_ID + 1);
119
+ this.state.rootCertificateStore = [...store, { caid: id, fabric, certificate }];
120
+ this.#updateAttributes();
121
+ log.info(`MatterbridgeTlsCertificateManagementServer.provisionRootCertificate: root certificate CAID ${id} provisioned on fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
122
+ return { caid: id };
123
+ }
124
+ findRootCertificate(request) {
125
+ const { caid } = request;
126
+ const fabric = this.#accessingFabric();
127
+ if (caid !== null && caid > MAX_TLS_CERTIFICATE_ID)
128
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.findRootCertificate: the CAID ${caid} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
129
+ const certificateDetails = this.state.rootCertificateStore
130
+ .filter((entry) => entry.fabric === fabric && (caid === null || entry.caid === caid))
131
+ .map((entry) => ({ caid: entry.caid, certificate: entry.certificate, fabricIndex: FabricIndex(fabric) }));
132
+ if (certificateDetails.length === 0)
133
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.findRootCertificate: the CAID ${caid ?? 'null'} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
134
+ return { certificateDetails };
135
+ }
136
+ lookupRootCertificate(request) {
137
+ const fingerprint = Buffer.from(Bytes.of(request.fingerprint));
138
+ const fabric = this.#accessingFabric();
139
+ if (fingerprint.byteLength > MAX_FINGERPRINT_BYTES) {
140
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.lookupRootCertificate: fingerprint of ${fingerprint.byteLength} octets exceeds ${MAX_FINGERPRINT_BYTES} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
141
+ }
142
+ const found = this.state.rootCertificateStore.find((entry) => entry.fabric === fabric && certificateFingerprint(entry.certificate).equals(fingerprint));
143
+ if (found === undefined)
144
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.lookupRootCertificate: fingerprint not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
145
+ return { caid: found.caid };
146
+ }
147
+ removeRootCertificate(request) {
148
+ const { caid } = request;
149
+ const fabric = this.#accessingFabric();
150
+ if (caid > MAX_TLS_CERTIFICATE_ID)
151
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.removeRootCertificate: the CAID ${caid} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
152
+ const store = this.state.rootCertificateStore;
153
+ const remaining = store.filter((entry) => !(entry.fabric === fabric && entry.caid === caid));
154
+ if (remaining.length === store.length)
155
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.removeRootCertificate: the CAID ${caid} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
156
+ if (this.#tlsEndpoints(fabric).some((endpoint) => endpoint.caid === caid)) {
157
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.removeRootCertificate: the CAID ${caid} is used by a TLS endpoint (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.InvalidInState);
158
+ }
159
+ this.state.rootCertificateStore = remaining;
160
+ this.#updateAttributes();
161
+ log.info(`MatterbridgeTlsCertificateManagementServer.removeRootCertificate: root certificate CAID ${caid} removed from fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
162
+ }
163
+ clientCsr(request) {
164
+ const nonce = Bytes.of(request.nonce);
165
+ const { ccdid } = request;
166
+ const fabric = this.#accessingFabric();
167
+ if (nonce.byteLength !== CLIENT_CSR_NONCE_BYTES) {
168
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.clientCsr: nonce of ${nonce.byteLength} octets is not ${CLIENT_CSR_NONCE_BYTES} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
169
+ }
170
+ const store = this.state.clientCertificateStore;
171
+ let id;
172
+ let privateKey;
173
+ if (ccdid === null) {
174
+ if (store.filter((entry) => entry.fabric === fabric).length >= this.state.maxClientCertificates) {
175
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.clientCsr: fabric ${fabric} already has ${this.state.maxClientCertificates} client certificates (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ResourceExhausted);
176
+ }
177
+ privateKey = this.generateClientKey();
178
+ const point = publicKeyPoint(privateKey);
179
+ const tlsKeys = store.map((entry) => publicKeyPoint(entry.privateKey));
180
+ const operationalKeys = [...this.env.get(FabricManager)].map((operationalFabric) => Bytes.of(operationalFabric.publicKey));
181
+ if ([...tlsKeys, ...operationalKeys].some((key) => Bytes.areEqual(key, point))) {
182
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.clientCsr: the new key pair collides with an existing key pair (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.DynamicConstraintError);
183
+ }
184
+ id = allocateId(new Set(store.map((entry) => entry.ccdid)), this.state.nextCcdid);
185
+ this.state.nextCcdid = (id + 1) % (MAX_TLS_CERTIFICATE_ID + 1);
186
+ this.state.clientCertificateStore = [...store, { ccdid: id, fabric, clientCertificate: null, intermediateCertificates: [], privateKey }];
187
+ this.#updateAttributes();
188
+ log.info(`MatterbridgeTlsCertificateManagementServer.clientCsr: client certificate CCDID ${id} created on fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
189
+ }
190
+ else {
191
+ if (ccdid > MAX_TLS_CERTIFICATE_ID)
192
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.clientCsr: the CCDID ${ccdid} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
193
+ const existing = store.find((entry) => entry.fabric === fabric && entry.ccdid === ccdid);
194
+ if (existing === undefined)
195
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.clientCsr: the CCDID ${ccdid} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
196
+ id = ccdid;
197
+ privateKey = existing.privateKey;
198
+ log.info(`MatterbridgeTlsCertificateManagementServer.clientCsr: client certificate CCDID ${id} CSR generated for rotation on fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
199
+ }
200
+ return { ccdid: id, csr: createClientCsr(privateKey), nonceSignature: signClientCsrNonce(privateKey, nonce) };
201
+ }
202
+ generateClientKey() {
203
+ return generateKeyPairSync('ec', { namedCurve: 'prime256v1' }).privateKey.export({ type: 'pkcs8', format: 'der' });
204
+ }
205
+ provisionClientCertificate(request) {
206
+ const { ccdid } = request;
207
+ const clientCertificate = Bytes.of(request.clientCertificate);
208
+ const intermediateCertificates = request.intermediateCertificates.map((certificate) => Bytes.of(certificate));
209
+ const fabric = this.#accessingFabric();
210
+ if (ccdid > MAX_TLS_CERTIFICATE_ID) {
211
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: the CCDID ${ccdid} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
212
+ }
213
+ if (clientCertificate.byteLength > MAX_CERTIFICATE_BYTES) {
214
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: certificate of ${clientCertificate.byteLength} octets exceeds ${MAX_CERTIFICATE_BYTES} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
215
+ }
216
+ if (intermediateCertificates.length > MAX_INTERMEDIATE_CERTIFICATES) {
217
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: ${intermediateCertificates.length} intermediate certificates exceed ${MAX_INTERMEDIATE_CERTIFICATES} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
218
+ }
219
+ const bigIntermediate = intermediateCertificates.find((intermediate) => intermediate.byteLength > MAX_CERTIFICATE_BYTES);
220
+ if (bigIntermediate !== undefined) {
221
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: intermediate certificate of ${bigIntermediate.byteLength} octets exceeds ${MAX_CERTIFICATE_BYTES} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
222
+ }
223
+ const store = this.state.clientCertificateStore;
224
+ const fingerprint = certificateFingerprint(clientCertificate);
225
+ if (store.some((entry) => entry.fabric === fabric && entry.clientCertificate !== null && certificateFingerprint(entry.clientCertificate).equals(fingerprint))) {
226
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: certificate already provisioned (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.AlreadyExists);
227
+ }
228
+ const existing = store.find((entry) => entry.fabric === fabric && entry.ccdid === ccdid);
229
+ if (existing === undefined) {
230
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: the CCDID ${ccdid} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
231
+ }
232
+ const x509 = parseValidCertificate(clientCertificate);
233
+ if (x509 === undefined) {
234
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: not a valid DER encoded X.509 certificate (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.DynamicConstraintError);
235
+ }
236
+ if (intermediateCertificates.some((intermediate) => parseValidCertificate(intermediate) === undefined)) {
237
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: intermediate certificate not a valid DER encoded X.509 certificate (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.DynamicConstraintError);
238
+ }
239
+ const keyPublicKey = createPublicKey(createPrivateKey({ key: Buffer.from(existing.privateKey), format: 'der', type: 'pkcs8' })).export({ type: 'spki', format: 'der' });
240
+ if (!x509.publicKey.export({ type: 'spki', format: 'der' }).equals(keyPublicKey)) {
241
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: certificate not issued for the key pair of CCDID ${ccdid} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.DynamicConstraintError);
242
+ }
243
+ this.state.clientCertificateStore = store.map((entry) => entry.fabric === fabric && entry.ccdid === ccdid ? { ccdid, fabric, clientCertificate, intermediateCertificates, privateKey: existing.privateKey } : entry);
244
+ this.#updateAttributes();
245
+ log.info(`MatterbridgeTlsCertificateManagementServer.provisionClientCertificate: client certificate CCDID ${ccdid} provisioned on fabric ${fabric} with ${intermediateCertificates.length} intermediate certificates (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
246
+ }
247
+ findClientCertificate(request) {
248
+ const { ccdid } = request;
249
+ const fabric = this.#accessingFabric();
250
+ if (ccdid !== null && ccdid > MAX_TLS_CERTIFICATE_ID)
251
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.findClientCertificate: the CCDID ${ccdid} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
252
+ const certificateDetails = this.state.clientCertificateStore
253
+ .filter((entry) => entry.fabric === fabric && (ccdid === null || entry.ccdid === ccdid))
254
+ .map((entry) => ({
255
+ ccdid: entry.ccdid,
256
+ clientCertificate: entry.clientCertificate,
257
+ intermediateCertificates: entry.intermediateCertificates,
258
+ fabricIndex: FabricIndex(fabric),
259
+ }));
260
+ if (certificateDetails.length === 0)
261
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.findClientCertificate: the CCDID ${ccdid ?? 'null'} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
262
+ return { certificateDetails };
263
+ }
264
+ lookupClientCertificate(request) {
265
+ const fingerprint = Buffer.from(Bytes.of(request.fingerprint));
266
+ const fabric = this.#accessingFabric();
267
+ if (fingerprint.byteLength > MAX_FINGERPRINT_BYTES) {
268
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.lookupClientCertificate: fingerprint of ${fingerprint.byteLength} octets exceeds ${MAX_FINGERPRINT_BYTES} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
269
+ }
270
+ const found = this.state.clientCertificateStore.find((entry) => entry.fabric === fabric && entry.clientCertificate !== null && certificateFingerprint(entry.clientCertificate).equals(fingerprint));
271
+ if (found === undefined)
272
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.lookupClientCertificate: fingerprint not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
273
+ return { ccdid: found.ccdid };
274
+ }
275
+ removeClientCertificate(request) {
276
+ const { ccdid } = request;
277
+ const fabric = this.#accessingFabric();
278
+ if (ccdid > MAX_TLS_CERTIFICATE_ID)
279
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.removeClientCertificate: the CCDID ${ccdid} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
280
+ const store = this.state.clientCertificateStore;
281
+ const remaining = store.filter((entry) => !(entry.fabric === fabric && entry.ccdid === ccdid));
282
+ if (remaining.length === store.length)
283
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.removeClientCertificate: the CCDID ${ccdid} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
284
+ if (this.#tlsEndpoints(fabric).some((endpoint) => endpoint.ccdid === ccdid)) {
285
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer.removeClientCertificate: the CCDID ${ccdid} is used by a TLS endpoint (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.InvalidInState);
286
+ }
287
+ this.state.clientCertificateStore = remaining;
288
+ this.#updateAttributes();
289
+ log.info(`MatterbridgeTlsCertificateManagementServer.removeClientCertificate: client certificate CCDID ${ccdid} removed from fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
290
+ }
291
+ #accessingFabric() {
292
+ const fabric = this.context.fabric;
293
+ if (fabric === undefined || fabric === FabricIndex.NO_FABRIC)
294
+ throw new StatusResponseError(`MatterbridgeTlsCertificateManagementServer: an accessing fabric is required (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.UnsupportedAccess);
295
+ return fabric;
296
+ }
297
+ #tlsEndpoints(fabric) {
298
+ if (!this.endpoint.behaviors.has(TlsClientManagementServer))
299
+ return [];
300
+ return this.endpoint.stateOf(TlsClientManagementServer).provisionedEndpoints.filter((endpoint) => endpoint.fabricIndex === fabric);
301
+ }
302
+ #updateAttributes() {
303
+ this.state.provisionedRootCertificates = this.state.rootCertificateStore.map((entry) => ({
304
+ caid: entry.caid,
305
+ certificate: entry.certificate,
306
+ fabricIndex: FabricIndex(entry.fabric),
307
+ }));
308
+ this.state.provisionedClientCertificates = this.state.clientCertificateStore.map((entry) => ({
309
+ ccdid: entry.ccdid,
310
+ clientCertificate: entry.clientCertificate,
311
+ intermediateCertificates: entry.intermediateCertificates,
312
+ fabricIndex: FabricIndex(entry.fabric),
313
+ }));
314
+ }
315
+ #handleFabricsChanged(fabrics) {
316
+ const fabricIndexes = new Set(fabrics.map((fabric) => fabric.fabricIndex));
317
+ const rootCertificateStore = this.state.rootCertificateStore.filter((entry) => fabricIndexes.has(entry.fabric));
318
+ const clientCertificateStore = this.state.clientCertificateStore.filter((entry) => fabricIndexes.has(entry.fabric));
319
+ if (rootCertificateStore.length === this.state.rootCertificateStore.length && clientCertificateStore.length === this.state.clientCertificateStore.length)
320
+ return;
321
+ this.state.rootCertificateStore = rootCertificateStore;
322
+ this.state.clientCertificateStore = clientCertificateStore;
323
+ this.#updateAttributes();
324
+ log.info(`MatterbridgeTlsCertificateManagementServer: a fabric was removed, the certificates of the removed fabrics were deleted (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
325
+ }
326
+ }
327
+ (function (MatterbridgeTlsCertificateManagementServer) {
328
+ class State extends MatterbridgeTlsCertificateManagementServerBase.State {
329
+ rootCertificateStore = [];
330
+ clientCertificateStore = [];
331
+ nextCaid = 0;
332
+ nextCcdid = 0;
333
+ [Val.properties](_owner, session) {
334
+ if (session.subject === undefined || session.largeMessage === true)
335
+ return {};
336
+ const state = this;
337
+ return {
338
+ get provisionedRootCertificates() {
339
+ return state.provisionedRootCertificates.map(({ certificate: _certificate, ...entry }) => entry);
340
+ },
341
+ get provisionedClientCertificates() {
342
+ return state.provisionedClientCertificates.map(({ clientCertificate, intermediateCertificates, ...entry }) => ({
343
+ ...entry,
344
+ ...(clientCertificate === null ? { clientCertificate } : {}),
345
+ ...(intermediateCertificates?.length === 0 ? { intermediateCertificates } : {}),
346
+ }));
347
+ },
348
+ };
349
+ }
350
+ }
351
+ MatterbridgeTlsCertificateManagementServer.State = State;
352
+ })(MatterbridgeTlsCertificateManagementServer || (MatterbridgeTlsCertificateManagementServer = {}));
@@ -0,0 +1,21 @@
1
+ import { TlsClientManagementServer } from '@matter/node/behaviors/tls-client-management';
2
+ import { TlsClientManagement } from '@matter/types/clusters/tls-client-management';
3
+ export declare const MAX_TLS_ENDPOINT_ID = 65534;
4
+ export declare const MIN_HOSTNAME_BYTES = 4;
5
+ export declare const MAX_HOSTNAME_BYTES = 253;
6
+ declare const MatterbridgeTlsClientManagementServerBase: import("@matter/node").ClusterBehavior.Type<typeof TlsClientManagementServer, TlsClientManagement, typeof TlsClientManagement, new () => {}, "tlsClientManagement"> & {
7
+ readonly id: "tlsClientManagement";
8
+ };
9
+ export declare class MatterbridgeTlsClientManagementServer extends MatterbridgeTlsClientManagementServerBase {
10
+ #private;
11
+ state: MatterbridgeTlsClientManagementServer.State;
12
+ provisionEndpoint(request: TlsClientManagement.ProvisionEndpointRequest): TlsClientManagement.ProvisionEndpointResponse;
13
+ findEndpoint(request: TlsClientManagement.FindEndpointRequest): TlsClientManagement.FindEndpointResponse;
14
+ removeEndpoint(request: TlsClientManagement.RemoveEndpointRequest): void;
15
+ }
16
+ export declare namespace MatterbridgeTlsClientManagementServer {
17
+ class State extends MatterbridgeTlsClientManagementServerBase.State {
18
+ nextEndpointId: number;
19
+ }
20
+ }
21
+ export {};
@@ -0,0 +1,110 @@
1
+ import { Bytes } from '@matter/general';
2
+ import { FieldElement } from '@matter/main/model';
3
+ import { TimeSynchronizationServer } from '@matter/node/behaviors/time-synchronization';
4
+ import { TlsCertificateManagementServer } from '@matter/node/behaviors/tls-certificate-management';
5
+ import { TlsClientManagementServer } from '@matter/node/behaviors/tls-client-management';
6
+ import { TlsClientManagement } from '@matter/types/clusters/tls-client-management';
7
+ import { StatusResponseError } from '@matter/types/common';
8
+ import { FabricIndex } from '@matter/types/datatype';
9
+ import { Status } from '@matter/types/globals';
10
+ import { AnsiLogger, MAGENTA } from 'node-ansi-logger';
11
+ import { allocateId } from './tlsCertificateManagementServer.js';
12
+ export const MAX_TLS_ENDPOINT_ID = 65534;
13
+ export const MIN_HOSTNAME_BYTES = 4;
14
+ export const MAX_HOSTNAME_BYTES = 253;
15
+ const log = new AnsiLogger({ logName: 'TlsClient', logLevel: "info", logNameColor: MAGENTA, logTimestampFormat: 4 });
16
+ const TlsClientManagementSchema = TlsClientManagement.schema.extend(undefined, FieldElement({ name: 'NextEndpointId', type: 'uint16', quality: 'N' }));
17
+ const MatterbridgeTlsClientManagementServerBase = TlsClientManagementServer.for(TlsClientManagement, TlsClientManagementSchema);
18
+ function bytesEqual(a, b) {
19
+ return Buffer.from(Bytes.of(a)).equals(Buffer.from(Bytes.of(b)));
20
+ }
21
+ export class MatterbridgeTlsClientManagementServer extends MatterbridgeTlsClientManagementServerBase {
22
+ provisionEndpoint(request) {
23
+ const hostname = Bytes.of(request.hostname);
24
+ const { port, caid, ccdid, endpointId } = request;
25
+ const fabric = this.#accessingFabric();
26
+ if (hostname.byteLength < MIN_HOSTNAME_BYTES || hostname.byteLength > MAX_HOSTNAME_BYTES) {
27
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: hostname of ${hostname.byteLength} octets is not ${MIN_HOSTNAME_BYTES} to ${MAX_HOSTNAME_BYTES} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
28
+ }
29
+ if (port < 1)
30
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: the port 0 is not valid (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
31
+ if (caid > MAX_TLS_ENDPOINT_ID || (ccdid !== null && ccdid > MAX_TLS_ENDPOINT_ID) || (endpointId !== null && endpointId > MAX_TLS_ENDPOINT_ID)) {
32
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: the CAID, CCDID or EndpointID is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
33
+ }
34
+ if (this.endpoint.behaviors.has(TimeSynchronizationServer) && this.endpoint.stateOf(TimeSynchronizationServer).utcTime === null) {
35
+ throw new TlsClientManagement.InvalidTimeError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: time synchronization has not yet occurred (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
36
+ }
37
+ const certificates = this.endpoint.stateOf(TlsCertificateManagementServer);
38
+ if (!certificates.provisionedRootCertificates.some((entry) => entry.fabricIndex === fabric && entry.caid === caid)) {
39
+ throw new TlsClientManagement.RootCertificateNotFoundError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: the CAID ${caid} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
40
+ }
41
+ if (ccdid !== null && !certificates.provisionedClientCertificates.some((entry) => entry.fabricIndex === fabric && entry.ccdid === ccdid)) {
42
+ throw new TlsClientManagement.ClientCertificateNotFoundError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: the CCDID ${ccdid} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
43
+ }
44
+ const endpoints = this.state.provisionedEndpoints;
45
+ const fabricEndpoints = endpoints.filter((endpoint) => endpoint.fabricIndex === fabric);
46
+ const duplicate = fabricEndpoints.some((endpoint) => endpoint.port === port && bytesEqual(endpoint.hostname, hostname) && endpoint.endpointId !== endpointId);
47
+ if (endpointId === null) {
48
+ if (fabricEndpoints.length >= this.state.maxProvisioned) {
49
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: fabric ${fabric} already has ${this.state.maxProvisioned} endpoints (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ResourceExhausted);
50
+ }
51
+ if (duplicate) {
52
+ throw new TlsClientManagement.EndpointAlreadyInstalledError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: an endpoint with the same hostname and port is already installed (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
53
+ }
54
+ const id = allocateId(new Set(endpoints.map((endpoint) => endpoint.endpointId)), this.state.nextEndpointId);
55
+ this.state.nextEndpointId = (id + 1) % (MAX_TLS_ENDPOINT_ID + 1);
56
+ this.state.provisionedEndpoints = [...endpoints, { endpointId: id, hostname, port, caid, ccdid, referenceCount: 0, fabricIndex: FabricIndex(fabric) }];
57
+ log.info(`MatterbridgeTlsClientManagementServer.provisionEndpoint: the TLS endpoint ${id} provisioned on fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
58
+ return { endpointId: id };
59
+ }
60
+ const existing = fabricEndpoints.find((endpoint) => endpoint.endpointId === endpointId);
61
+ if (existing === undefined)
62
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: the EndpointID ${endpointId} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
63
+ if (duplicate) {
64
+ throw new TlsClientManagement.EndpointAlreadyInstalledError(`MatterbridgeTlsClientManagementServer.provisionEndpoint: an endpoint with the same hostname and port is already installed (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
65
+ }
66
+ const { referenceCount } = existing;
67
+ this.state.provisionedEndpoints = endpoints.map((endpoint) => endpoint.fabricIndex === fabric && endpoint.endpointId === endpointId
68
+ ? { endpointId, hostname, port, caid, ccdid, referenceCount, fabricIndex: FabricIndex(fabric) }
69
+ : endpoint);
70
+ log.info(`MatterbridgeTlsClientManagementServer.provisionEndpoint: the TLS endpoint ${endpointId} updated on fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
71
+ return { endpointId };
72
+ }
73
+ findEndpoint(request) {
74
+ const { endpointId } = request;
75
+ const fabric = this.#accessingFabric();
76
+ if (endpointId > MAX_TLS_ENDPOINT_ID)
77
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.findEndpoint: the EndpointID ${endpointId} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
78
+ const endpoint = this.state.provisionedEndpoints.find((entry) => entry.fabricIndex === fabric && entry.endpointId === endpointId);
79
+ if (endpoint === undefined)
80
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.findEndpoint: the EndpointID ${endpointId} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
81
+ return { endpoint };
82
+ }
83
+ removeEndpoint(request) {
84
+ const { endpointId } = request;
85
+ const fabric = this.#accessingFabric();
86
+ if (endpointId > MAX_TLS_ENDPOINT_ID)
87
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.removeEndpoint: the EndpointID ${endpointId} is out of range (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.ConstraintError);
88
+ const endpoints = this.state.provisionedEndpoints;
89
+ const endpoint = endpoints.find((entry) => entry.fabricIndex === fabric && entry.endpointId === endpointId);
90
+ if (endpoint === undefined)
91
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.removeEndpoint: the EndpointID ${endpointId} was not found (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
92
+ if (endpoint.referenceCount > 0) {
93
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer.removeEndpoint: the EndpointID ${endpointId} is in use by ${endpoint.referenceCount} clusters (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.InvalidInState);
94
+ }
95
+ this.state.provisionedEndpoints = endpoints.filter((entry) => !(entry.fabricIndex === fabric && entry.endpointId === endpointId));
96
+ log.info(`MatterbridgeTlsClientManagementServer.removeEndpoint: the TLS endpoint ${endpointId} removed from fabric ${fabric} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
97
+ }
98
+ #accessingFabric() {
99
+ const fabric = this.context.fabric;
100
+ if (fabric === undefined || fabric === FabricIndex.NO_FABRIC)
101
+ throw new StatusResponseError(`MatterbridgeTlsClientManagementServer: an accessing fabric is required (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.UnsupportedAccess);
102
+ return fabric;
103
+ }
104
+ }
105
+ (function (MatterbridgeTlsClientManagementServer) {
106
+ class State extends MatterbridgeTlsClientManagementServerBase.State {
107
+ nextEndpointId = 0;
108
+ }
109
+ MatterbridgeTlsClientManagementServer.State = State;
110
+ })(MatterbridgeTlsClientManagementServer || (MatterbridgeTlsClientManagementServer = {}));
@@ -44,4 +44,67 @@ export declare namespace MatterbridgeWindowCoveringServer {
44
44
  movementDuration: number;
45
45
  }
46
46
  }
47
+ export declare const MatterbridgeLiftWindowCoveringServer: import("@matter/node").ClusterBehavior.Type<typeof MatterbridgeWindowCoveringServer, import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<WindowCovering, {
48
+ lift: true;
49
+ positionAwareLift: true;
50
+ positionAwareTilt: true;
51
+ tilt: true;
52
+ }>, {
53
+ lift: false;
54
+ positionAwareLift: false;
55
+ positionAwareTilt: false;
56
+ tilt: false;
57
+ }>, {
58
+ lift: true;
59
+ positionAwareLift: true;
60
+ positionAwareTilt: true;
61
+ tilt: true;
62
+ }>, {
63
+ lift: true;
64
+ positionAwareLift: true;
65
+ positionAwareTilt: false;
66
+ tilt: false;
67
+ }>, import("@matter/types").ClusterType.Concrete, typeof MatterbridgeWindowCoveringServer.Internal, "windowCovering">;
68
+ export declare const MatterbridgeLiftTiltWindowCoveringServer: import("@matter/node").ClusterBehavior.Type<typeof MatterbridgeWindowCoveringServer, import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<WindowCovering, {
69
+ lift: true;
70
+ positionAwareLift: true;
71
+ positionAwareTilt: true;
72
+ tilt: true;
73
+ }>, {
74
+ lift: false;
75
+ positionAwareLift: false;
76
+ positionAwareTilt: false;
77
+ tilt: false;
78
+ }>, {
79
+ lift: true;
80
+ positionAwareLift: true;
81
+ positionAwareTilt: true;
82
+ tilt: true;
83
+ }>, {
84
+ lift: true;
85
+ positionAwareLift: true;
86
+ positionAwareTilt: true;
87
+ tilt: true;
88
+ }>, import("@matter/types").ClusterType.Concrete, typeof MatterbridgeWindowCoveringServer.Internal, "windowCovering">;
89
+ export declare const MatterbridgeTiltWindowCoveringServer: import("@matter/node").ClusterBehavior.Type<typeof MatterbridgeWindowCoveringServer, import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<WindowCovering, {
90
+ lift: true;
91
+ positionAwareLift: true;
92
+ positionAwareTilt: true;
93
+ tilt: true;
94
+ }>, {
95
+ lift: false;
96
+ positionAwareLift: false;
97
+ positionAwareTilt: false;
98
+ tilt: false;
99
+ }>, {
100
+ lift: true;
101
+ positionAwareLift: true;
102
+ positionAwareTilt: true;
103
+ tilt: true;
104
+ }>, {
105
+ lift: false;
106
+ positionAwareLift: false;
107
+ positionAwareTilt: true;
108
+ tilt: true;
109
+ }>, import("@matter/types").ClusterType.Concrete, typeof MatterbridgeWindowCoveringServer.Internal, "windowCovering">;
47
110
  export {};
@@ -202,3 +202,6 @@ export class MatterbridgeWindowCoveringServer extends WindowCoveringServer.with(
202
202
  }
203
203
  MatterbridgeWindowCoveringServer.State = State;
204
204
  })(MatterbridgeWindowCoveringServer || (MatterbridgeWindowCoveringServer = {}));
205
+ export const MatterbridgeLiftWindowCoveringServer = MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift);
206
+ export const MatterbridgeLiftTiltWindowCoveringServer = MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt);
207
+ export const MatterbridgeTiltWindowCoveringServer = MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt);
package/dist/cli.js CHANGED
@@ -201,7 +201,7 @@ function help() {
201
201
  --nosudo: force not to use sudo to install or update packages if the internal logic fails
202
202
  --norestore: force not to automatically restore the matterbridge node storage and the matter storage from backup if it is corrupted
203
203
  --novirtual: disable the creation of the virtual devices Restart, Update and Reboot Matterbridge
204
- --root-power-source: add a Power Source cluster for the mains power feed on the Root endpoint
204
+ --root-camera: add the Power Source, Time Synchronization, TLS Certificate Management and TLS Client Management clusters on the Root endpoint, required by the camera device types
205
205
  --ssl: enable SSL for the frontend and the WebSocketServer (the server will use the certificates and switch to https)
206
206
  --tls: enable SSL for the frontend and the WebSocketServer (the server will use the certificates and switch to https)
207
207
  --mtls: enable mTLS for the frontend and the WebSocketServer (both server and client will use and require the certificates and switch to https); it also enables https, so --ssl --tls is not needed
@@ -1,5 +1,5 @@
1
1
  import EventEmitter from 'node:events';
2
- import type { ApiClusters, ApiMatter, BridgeStatus, PluginStatusUpdate, RefreshRequiredChanged, WsMessageBroadcast } from '@matterbridge/types';
2
+ import type { ApiClusters, ApiMatter, ArchiveCommand, BridgeStatus, PluginStatusUpdate, RefreshRequiredChanged, WsMessageBroadcast } from '@matterbridge/types';
3
3
  import { LogLevel } from 'node-ansi-logger';
4
4
  import type { Matterbridge } from './matterbridge.js';
5
5
  interface FrontendEvents {
@@ -53,6 +53,6 @@ export declare class Frontend extends EventEmitter<FrontendEvents> {
53
53
  wssSendAttributeChangedMessage(plugin: string, serialNumber: string, uniqueId: string, number: number, id: string, cluster: string, attribute: string, value: number | string | boolean | null): void;
54
54
  wssBroadcastMessage(msg: WsMessageBroadcast): void;
55
55
  spawn(command: 'install' | 'uninstall', packageName: string): void;
56
- zip(command: 'zip' | 'verify' | 'unzip', archivePath: string, sourcePaths: string[], destinationPath: string): void;
56
+ zip(command: ArchiveCommand, archivePath: string, sourcePaths: string[], destinationPath: string, archiveNames?: string[]): void;
57
57
  }
58
58
  export {};