matterbridge-example-camera 1.0.1-dev-20261102-a121966 → 1.0.1-dev-20261104-e24171f
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.
- package/CHANGELOG.md +18 -1
- package/README.md +3 -2
- package/dist/module.js +11 -0
- package/dist/rootNode.js +9 -7
- package/dist/timeSynchronizationServer.js +13 -3
- package/dist/tlsCertificateManagementServer.js +29 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -37,6 +37,12 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
37
37
|
- [tls]: Implement the TLS Certificate Management server (0x0801) of the Root Node per Matter 1.6.1: per fabric root certificates (ProvisionRootCertificate, FindRootCertificate, LookupRootCertificate by SHA-256 fingerprint, RemoveRootCertificate) and client certificates (ClientCSR with a P-256 key pair, a PKCS #10 CSR and the nonce signature, ProvisionClientCertificate with up to 10 intermediate certificates, FindClientCertificate, LookupClientCertificate, RemoveClientCertificate). Certificates must be DER encoded X.509 certificates valid at the current time; CAIDs and CCDIDs are unique on the node; the certificates, private keys included, are stored nonvolatile outside the attributes and deleted with their fabric. The attributes list only the CAID / CCDID and the fabric: the payloads are returned by the Find commands.
|
|
38
38
|
- [tls]: Implement the TLS Client Management server (0x0802) of the Root Node per Matter 1.6.1: per fabric TLS endpoints (ProvisionEndpoint, FindEndpoint, RemoveEndpoint) with the RootCertificateNotFound, ClientCertificateNotFound, EndpointAlreadyInstalled, EndpointInUse and InvalidTime cluster status codes. A root or client certificate used by a TLS endpoint cannot be removed (InvalidInState).
|
|
39
39
|
- [tls]: Follow the Matter 1.6.1 processing order of ProvisionRootCertificate (§ 14.4.6.1: InvalidInState before time synchronization, then DynamicConstraintError before AlreadyExists, NotFound and ResourceExhausted), ProvisionClientCertificate (§ 14.4.6.10: AlreadyExists and NotFound before DynamicConstraintError) and ProvisionEndpoint (§ 14.5.7.1: ResourceExhausted or NotFound before EndpointAlreadyInstalled).
|
|
40
|
+
- [rootNode]: Add the Server Camera, a `mode: 'server'` Camera whose own Root Node gets the Power Source, Time Synchronization, TLS Certificate Management and TLS Client Management servers from `addRootNodeCamera`.
|
|
41
|
+
- [rootNode]: Keep the Power Source that Matterbridge already adds to the Root Node with `--root-power-source` or `MATTERBRIDGE_CHIP_TEST`, instead of failing the plugin start.
|
|
42
|
+
- [tls]: Include the certificate payloads in the ProvisionedRootCertificates and ProvisionedClientCertificates attributes when read over a Large Message capable transport, and keep a null ClientCertificate and empty IntermediateCertificates over MRP (Matter 1.6.1 § 14.4.5.2 and § 14.4.5.4).
|
|
43
|
+
- [timeSync]: Generate TimeZoneStatus when a scheduled TimeZone entry changes the time zone offset or name (Matter 1.6.1 § 11.17.10.3).
|
|
44
|
+
- [timeSync]: Respond to a SetTimeZone list larger than TimeZoneListMaxSize with RESOURCE_EXHAUSTED (Matter 1.6.1 § 11.17.9.3): the TimeZone field constraint moves from the schema, where matter.js answers CONSTRAINT_ERROR before the handler, to the handler.
|
|
45
|
+
- [chip]: Wire the CHIP tests of the Server Camera Root Node (TC_PS_2_3, TC_TIMESYNC, TC_TLSCERT, TC_TLSCLIENT) with `scripts/chip/commission_node.py`, which commissions the node and resets the state left by the previous test, and `scripts/chip/root-node-camera.pics`.
|
|
40
46
|
- [package]: Upgrade package.
|
|
41
47
|
- [package]: Bump `@types/node` to v.26.6.6.
|
|
42
48
|
- [package]: Bump `oxfmt` to v.0.75.0.
|
|
@@ -47,7 +53,7 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
47
53
|
- [agents]: Update `.github/commit-message-instructions.md` to v.1.0.1.
|
|
48
54
|
- [vscode]: Update `.vscode/settings.json` to v.1.0.17.
|
|
49
55
|
- [vscode]: Update `.vscode/tasks.json` to v.1.0.4.
|
|
50
|
-
- [agents]: Update `AGENTS.md` to v.1.0.
|
|
56
|
+
- [agents]: Update `AGENTS.md` to v.1.0.9.
|
|
51
57
|
- [config]: Update `CODE_OF_CONDUCT.md` to v.1.0.0.
|
|
52
58
|
- [config]: Update `CONTRIBUTING.md` to v.1.0.1.
|
|
53
59
|
- [scripts]: Update `scripts/downloads.mjs`.
|
|
@@ -55,6 +61,17 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
55
61
|
- [scripts]: Update `scripts/prepublish-clean.mjs`.
|
|
56
62
|
- [config]: Add `SHARED-AGENTS.md`.
|
|
57
63
|
- [config]: Add `TOOLCHAIN.md` v.1.0.1.
|
|
64
|
+
- [package]: Bump `@vitest/coverage-v8` to v.5.1.0.
|
|
65
|
+
- [package]: Bump `vitest` to v.5.1.0.
|
|
66
|
+
- [agents]: Update `.agents/README.md` to v.1.0.4.
|
|
67
|
+
- [workflows]: Update `.github/workflows/build.yml` to v.2.0.8.
|
|
68
|
+
- [workflows]: Update `.github/workflows/codecov.yml` to v.2.0.8.
|
|
69
|
+
- [workflows]: Update `.github/workflows/codeql.yml` to v.2.0.0.
|
|
70
|
+
- [workflows]: Update `.github/workflows/publish.yml` to v.2.0.7.
|
|
71
|
+
- [config]: Update `.gitignore` to v.1.0.5.
|
|
72
|
+
- [config]: Update `.oxfmtrc.json` to v.1.2.0.
|
|
73
|
+
- [config]: Update `.oxlintrc.json` to v.1.2.0.
|
|
74
|
+
- [config]: Update `vitest.config.ts` to v.2.0.9.
|
|
58
75
|
|
|
59
76
|
<a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="80"></a>
|
|
60
77
|
|
package/README.md
CHANGED
|
@@ -33,9 +33,10 @@ Thanks to [Ludovic BOUÉ](https://github.com/lboue) for his contributions to thi
|
|
|
33
33
|
|
|
34
34
|
- `src/module.ts` will create all device types for easy testing;
|
|
35
35
|
- the device types and the WebRTC stack come from matterbridge (`matterbridge/devices/camera`), see the [Matterbridge cameras](https://matterbridge.io/Camera.html) guide;
|
|
36
|
-
- `src/rootNode.ts` adds the Root Node clusters a Camera requires (Power Source, Time Synchronization, TLS Certificate Management and TLS Client Management) to a `mode: 'server'` Camera;
|
|
36
|
+
- `src/rootNode.ts` adds the Root Node clusters a Camera requires (Power Source, Time Synchronization, TLS Certificate Management and TLS Client Management) to a `mode: 'server'` Camera. `src/module.ts` creates the **Server Camera** (`SERVER-CAMERA-001`) as its own Matter node and calls it on that node;
|
|
37
37
|
- `src/timeSynchronizationServer.ts` is the Time Synchronization server used there, with the TimeSyncClient, NtpClient and TimeZone features. It reports the host clock (MillisecondsGranularity) and implements SetTrustedTimeSource, SetDefaultNTP, SetTimeZone and SetDSTOffset with their validation and events; SetUTCTime is refused with TimeNotAccepted since the host clock is kept.
|
|
38
|
-
- `src/tlsCertificateManagementServer.ts` and `src/tlsClientManagementServer.ts`
|
|
38
|
+
- `src/tlsCertificateManagementServer.ts` and `src/tlsClientManagementServer.ts` are the TLS Certificate Management and TLS Client Management servers used there, per Matter 1.6.1: per fabric root and client certificates (stored nonvolatile, with the client private keys) and TLS endpoints. The certificate payloads are in the ProvisionedRootCertificates and ProvisionedClientCertificates attributes only when read over a Large Message capable transport (TCP).
|
|
39
|
+
- The Root Node servers of the Server Camera are tested with the CHIP harness (`npm run chip:test:servercamera`, see `chipTests.md`).
|
|
39
40
|
|
|
40
41
|
## Requirements
|
|
41
42
|
|
package/dist/module.js
CHANGED
|
@@ -7,6 +7,7 @@ import { CommonNumberTag, UINT16_MAX, UINT32_MAX } from 'matterbridge/matter';
|
|
|
7
7
|
import { ChimeClient } from 'matterbridge/matter/behaviors';
|
|
8
8
|
import { Identify, Chime as ChimeCluster, PowerSource } from 'matterbridge/matter/clusters';
|
|
9
9
|
import { isDocker, isValidNumber, parseVersionString } from 'matterbridge/utils';
|
|
10
|
+
import { addRootNodeCamera } from './rootNode.js';
|
|
10
11
|
export default function initializePlugin(matterbridge, log, config) {
|
|
11
12
|
return new ExampleMatterbridgeCameraPlatform(matterbridge, log, config);
|
|
12
13
|
}
|
|
@@ -161,6 +162,16 @@ export class ExampleMatterbridgeCameraPlatform extends MatterbridgeDynamicPlatfo
|
|
|
161
162
|
weriftOfferOptions: { ...this.weriftOfferOptions },
|
|
162
163
|
});
|
|
163
164
|
await this.addDevice(serverIntercom2);
|
|
165
|
+
const serverCamera = new Camera('Server Camera', 'SERVER-CAMERA-001', {
|
|
166
|
+
identifyTime: 5,
|
|
167
|
+
identifyType: Identify.IdentifyType.VisibleIndicator,
|
|
168
|
+
tagList: [getSemtag(CommonNumberTag.One, 'Server Camera')],
|
|
169
|
+
mode: 'server',
|
|
170
|
+
weriftOfferOptions: { ...this.weriftOfferOptions },
|
|
171
|
+
});
|
|
172
|
+
await this.addDevice(serverCamera);
|
|
173
|
+
if (serverCamera.serverNode)
|
|
174
|
+
await addRootNodeCamera(serverCamera);
|
|
164
175
|
this.log.info(`Platform ${this.config.name} started successfully`);
|
|
165
176
|
}
|
|
166
177
|
async onConfigure() {
|
package/dist/rootNode.js
CHANGED
|
@@ -8,13 +8,15 @@ export async function addRootNodeCamera(device) {
|
|
|
8
8
|
throw new Error(`addRootNodeCamera requires device.serverNode to be set: register the device with mode: 'server' before calling this helper.`);
|
|
9
9
|
}
|
|
10
10
|
const root = device.serverNode;
|
|
11
|
-
root.behaviors.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
if (!root.behaviors.supported.powerSource) {
|
|
12
|
+
root.behaviors.require(MatterbridgePowerSourceServer.with(PowerSource.Feature.Wired), {
|
|
13
|
+
status: PowerSource.PowerSourceStatus.Active,
|
|
14
|
+
order: 0,
|
|
15
|
+
description: 'AC Power',
|
|
16
|
+
endpointList: [],
|
|
17
|
+
wiredCurrentType: PowerSource.WiredCurrentType.Ac,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
18
20
|
root.behaviors.require(MatterbridgeTimeSynchronizationServer, {
|
|
19
21
|
utcTime: null,
|
|
20
22
|
granularity: TimeSynchronization.Granularity.NoTimeGranularity,
|
|
@@ -3,6 +3,7 @@ import { AnsiLogger, MAGENTA } from 'matterbridge/logger';
|
|
|
3
3
|
import { Node, Seconds, Time } from 'matterbridge/matter';
|
|
4
4
|
import { OperationalCredentialsServer, TimeSynchronizationServer } from 'matterbridge/matter/behaviors';
|
|
5
5
|
import { TimeSynchronization } from 'matterbridge/matter/clusters';
|
|
6
|
+
import { CommandModel, FieldModel } from 'matterbridge/matter/model';
|
|
6
7
|
import { Status, StatusResponseError } from 'matterbridge/matter/types';
|
|
7
8
|
export const MATTER_EPOCH_US = 946684800000000n;
|
|
8
9
|
const CLOCK_INTERVAL = Seconds(1);
|
|
@@ -18,7 +19,10 @@ export function isCanonicalIpv6(address) {
|
|
|
18
19
|
return true;
|
|
19
20
|
return new URL(`http://[${address}]`).hostname === `[${address}]`;
|
|
20
21
|
}
|
|
21
|
-
const
|
|
22
|
+
const { schema } = TimeSynchronization;
|
|
23
|
+
const setTimeZoneCommand = schema.require(CommandModel, 'SetTimeZone');
|
|
24
|
+
const TimeSynchronizationSchema = schema.extend(undefined, setTimeZoneCommand.extend(undefined, setTimeZoneCommand.require(FieldModel, 'TimeZone').extend({ constraint: 'none' })));
|
|
25
|
+
const MatterbridgeTimeSynchronizationServerBase = TimeSynchronizationServer.for(TimeSynchronization, TimeSynchronizationSchema).with(TimeSynchronization.Feature.TimeSyncClient, TimeSynchronization.Feature.NtpClient, TimeSynchronization.Feature.TimeZone);
|
|
22
26
|
export class MatterbridgeTimeSynchronizationServer extends MatterbridgeTimeSynchronizationServerBase {
|
|
23
27
|
initialize() {
|
|
24
28
|
if (this.state.timeZone.length === 0)
|
|
@@ -40,9 +44,15 @@ export class MatterbridgeTimeSynchronizationServer extends MatterbridgeTimeSynch
|
|
|
40
44
|
this.state.utcTime = now;
|
|
41
45
|
this.state.granularity = TimeSynchronization.Granularity.MillisecondsGranularity;
|
|
42
46
|
this.state.timeSource = TimeSynchronization.TimeSource.Unknown;
|
|
43
|
-
const [, nextTimeZone] = this.state.timeZone;
|
|
47
|
+
const [currentTimeZone, nextTimeZone] = this.state.timeZone;
|
|
44
48
|
if (nextTimeZone && BigInt(nextTimeZone.validAt) <= now) {
|
|
45
|
-
|
|
49
|
+
const { offset, name } = nextTimeZone;
|
|
50
|
+
const changed = offset !== currentTimeZone.offset || name !== currentTimeZone.name;
|
|
51
|
+
this.state.timeZone = [{ offset, validAt: MATTER_EPOCH_US, ...(name === undefined ? {} : { name }) }];
|
|
52
|
+
if (changed) {
|
|
53
|
+
log.info(`MatterbridgeTimeSynchronizationServer: the scheduled TimeZone with offset ${offset}s${name === undefined ? '' : ` (${name})`} became valid, generating TimeZoneStatus (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
54
|
+
this.events.timeZoneStatus.emit({ offset, name }, this.context);
|
|
55
|
+
}
|
|
46
56
|
}
|
|
47
57
|
const dstOffset = this.state.dstOffset.filter((entry) => entry.validUntil === null || BigInt(entry.validUntil) > now);
|
|
48
58
|
if (dstOffset.length !== this.state.dstOffset.length) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, sign, X509Certificate } from 'node:crypto';
|
|
2
2
|
import { AnsiLogger, MAGENTA } from 'matterbridge/logger';
|
|
3
|
-
import { Bytes, Node, Time } from 'matterbridge/matter';
|
|
3
|
+
import { Bytes, Node, Time, Val } from 'matterbridge/matter';
|
|
4
4
|
import { OperationalCredentialsServer, TimeSynchronizationServer, TlsCertificateManagementServer, TlsClientManagementServer } from 'matterbridge/matter/behaviors';
|
|
5
5
|
import { TlsCertificateManagement } from 'matterbridge/matter/clusters';
|
|
6
6
|
import { AttributeModel, FieldElement } from 'matterbridge/matter/model';
|
|
@@ -280,8 +280,17 @@ export class MatterbridgeTlsCertificateManagementServer extends MatterbridgeTlsC
|
|
|
280
280
|
return this.endpoint.stateOf(TlsClientManagementServer).provisionedEndpoints.filter((endpoint) => endpoint.fabricIndex === fabric);
|
|
281
281
|
}
|
|
282
282
|
#updateAttributes() {
|
|
283
|
-
this.state.provisionedRootCertificates = this.state.rootCertificateStore.map((entry) => ({
|
|
284
|
-
|
|
283
|
+
this.state.provisionedRootCertificates = this.state.rootCertificateStore.map((entry) => ({
|
|
284
|
+
caid: entry.caid,
|
|
285
|
+
certificate: entry.certificate,
|
|
286
|
+
fabricIndex: FabricIndex(entry.fabric),
|
|
287
|
+
}));
|
|
288
|
+
this.state.provisionedClientCertificates = this.state.clientCertificateStore.map((entry) => ({
|
|
289
|
+
ccdid: entry.ccdid,
|
|
290
|
+
clientCertificate: entry.clientCertificate,
|
|
291
|
+
intermediateCertificates: entry.intermediateCertificates,
|
|
292
|
+
fabricIndex: FabricIndex(entry.fabric),
|
|
293
|
+
}));
|
|
285
294
|
}
|
|
286
295
|
#handleFabricsChanged(fabrics) {
|
|
287
296
|
const fabricIndexes = new Set(fabrics.map((fabric) => fabric.fabricIndex));
|
|
@@ -301,6 +310,23 @@ export class MatterbridgeTlsCertificateManagementServer extends MatterbridgeTlsC
|
|
|
301
310
|
clientCertificateStore = [];
|
|
302
311
|
nextCaid = 0;
|
|
303
312
|
nextCcdid = 0;
|
|
313
|
+
[Val.properties](_owner, session) {
|
|
314
|
+
if (session.subject === undefined || session.largeMessage === true)
|
|
315
|
+
return {};
|
|
316
|
+
const state = this;
|
|
317
|
+
return {
|
|
318
|
+
get provisionedRootCertificates() {
|
|
319
|
+
return state.provisionedRootCertificates.map(({ certificate: _certificate, ...entry }) => entry);
|
|
320
|
+
},
|
|
321
|
+
get provisionedClientCertificates() {
|
|
322
|
+
return state.provisionedClientCertificates.map(({ clientCertificate, intermediateCertificates, ...entry }) => ({
|
|
323
|
+
...entry,
|
|
324
|
+
...(clientCertificate === null ? { clientCertificate } : {}),
|
|
325
|
+
...(intermediateCertificates?.length === 0 ? { intermediateCertificates } : {}),
|
|
326
|
+
}));
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
}
|
|
304
330
|
}
|
|
305
331
|
MatterbridgeTlsCertificateManagementServer.State = State;
|
|
306
332
|
})(MatterbridgeTlsCertificateManagementServer || (MatterbridgeTlsCertificateManagementServer = {}));
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge-example-camera",
|
|
3
|
-
"version": "1.0.1-dev-
|
|
3
|
+
"version": "1.0.1-dev-20261104-e24171f",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "matterbridge-example-camera",
|
|
9
|
-
"version": "1.0.1-dev-
|
|
9
|
+
"version": "1.0.1-dev-20261104-e24171f",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"node-ansi-logger": "3.3.1",
|
package/package.json
CHANGED