@matter/node 0.16.0-alpha.0-20251020-3f6e46245 → 0.16.0-alpha.0-20251022-5a69ce65a
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/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js +8 -2
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js.map +1 -1
- package/dist/cjs/behavior/system/controller/ControllerBehavior.d.ts +13 -2
- package/dist/cjs/behavior/system/controller/ControllerBehavior.d.ts.map +1 -1
- package/dist/cjs/behavior/system/controller/ControllerBehavior.js +37 -23
- package/dist/cjs/behavior/system/controller/ControllerBehavior.js.map +1 -1
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js +1 -2
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js +3 -3
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
- package/dist/cjs/endpoint/properties/Endpoints.d.ts +1 -1
- package/dist/cjs/endpoint/properties/Endpoints.d.ts.map +1 -1
- package/dist/cjs/node/client/Peers.d.ts.map +1 -1
- package/dist/cjs/node/client/Peers.js +7 -10
- package/dist/cjs/node/client/Peers.js.map +2 -2
- package/dist/cjs/node/server/ServerEnvironment.d.ts.map +1 -1
- package/dist/cjs/node/server/ServerEnvironment.js +8 -2
- package/dist/cjs/node/server/ServerEnvironment.js.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js +8 -2
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js.map +1 -1
- package/dist/esm/behavior/system/controller/ControllerBehavior.d.ts +13 -2
- package/dist/esm/behavior/system/controller/ControllerBehavior.d.ts.map +1 -1
- package/dist/esm/behavior/system/controller/ControllerBehavior.js +38 -25
- package/dist/esm/behavior/system/controller/ControllerBehavior.js.map +1 -1
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.js +1 -3
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js +3 -3
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
- package/dist/esm/endpoint/properties/Endpoints.d.ts +1 -1
- package/dist/esm/endpoint/properties/Endpoints.d.ts.map +1 -1
- package/dist/esm/node/client/Peers.d.ts.map +1 -1
- package/dist/esm/node/client/Peers.js +2 -5
- package/dist/esm/node/client/Peers.js.map +1 -1
- package/dist/esm/node/server/ServerEnvironment.d.ts.map +1 -1
- package/dist/esm/node/server/ServerEnvironment.js +9 -3
- package/dist/esm/node/server/ServerEnvironment.js.map +1 -1
- package/package.json +7 -7
- package/src/behavior/system/commissioning/CommissioningClient.ts +8 -2
- package/src/behavior/system/controller/ControllerBehavior.ts +49 -32
- package/src/behavior/system/network/ServerNetworkRuntime.ts +1 -3
- package/src/behavior/system/subscriptions/SubscriptionsServer.ts +3 -3
- package/src/endpoint/properties/Endpoints.ts +1 -1
- package/src/node/client/Peers.ts +2 -6
- package/src/node/server/ServerEnvironment.ts +11 -3
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
import { Behavior } from "#behavior/Behavior.js";
|
|
8
8
|
import { BasicInformationBehavior } from "#behaviors/basic-information";
|
|
9
|
-
import { ConnectionlessTransportSet, ImplementationError } from "#general";
|
|
9
|
+
import { ConnectionlessTransportSet, ImplementationError, Logger } from "#general";
|
|
10
10
|
import { Node } from "#node/Node.js";
|
|
11
11
|
import {
|
|
12
12
|
Ble,
|
|
13
13
|
ClientSubscriptions,
|
|
14
14
|
Fabric,
|
|
15
15
|
FabricAuthority,
|
|
16
|
-
|
|
16
|
+
FabricAuthorityConfiguration,
|
|
17
17
|
FabricManager,
|
|
18
18
|
MdnsClient,
|
|
19
19
|
MdnsScannerTargetCriteria,
|
|
@@ -21,13 +21,15 @@ import {
|
|
|
21
21
|
Scanner,
|
|
22
22
|
ScannerSet,
|
|
23
23
|
} from "#protocol";
|
|
24
|
-
import { FabricId } from "
|
|
24
|
+
import { CaseAuthenticatedTag, FabricId, NodeId } from "#types";
|
|
25
25
|
import type { CommissioningClient } from "../commissioning/CommissioningClient.js";
|
|
26
26
|
import { CommissioningServer } from "../commissioning/CommissioningServer.js";
|
|
27
27
|
import { NetworkServer } from "../network/NetworkServer.js";
|
|
28
28
|
import { ActiveDiscoveries } from "./discovery/ActiveDiscoveries.js";
|
|
29
29
|
import type { Discovery } from "./discovery/Discovery.js";
|
|
30
30
|
|
|
31
|
+
const logger = Logger.get("ControllerBehavior");
|
|
32
|
+
|
|
31
33
|
/**
|
|
32
34
|
* Node controller functionality.
|
|
33
35
|
*
|
|
@@ -44,10 +46,8 @@ export class ControllerBehavior extends Behavior {
|
|
|
44
46
|
|
|
45
47
|
override async initialize() {
|
|
46
48
|
if (this.state.adminFabricLabel === undefined || this.state.adminFabricLabel === "") {
|
|
47
|
-
throw new ImplementationError("adminFabricLabel must be set for ControllerBehavior
|
|
49
|
+
throw new ImplementationError("adminFabricLabel must be set for ControllerBehavior");
|
|
48
50
|
}
|
|
49
|
-
const adminFabricLabel = this.state.adminFabricLabel;
|
|
50
|
-
const adminFabricId = this.state.adminFabricId;
|
|
51
51
|
|
|
52
52
|
// Configure discovery transports
|
|
53
53
|
if (this.state.ip === undefined) {
|
|
@@ -61,28 +61,12 @@ export class ControllerBehavior extends Behavior {
|
|
|
61
61
|
this.state.ble = (await this.agent.load(NetworkServer)).state.ble;
|
|
62
62
|
}
|
|
63
63
|
if (this.state.ble !== false) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.env.set(
|
|
71
|
-
FabricAuthorityConfigurationProvider,
|
|
72
|
-
new (class extends FabricAuthorityConfigurationProvider {
|
|
73
|
-
get vendorId() {
|
|
74
|
-
return biState.vendorId;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
override get adminFabricLabel() {
|
|
78
|
-
return adminFabricLabel;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get fabricId() {
|
|
82
|
-
return adminFabricId;
|
|
83
|
-
}
|
|
84
|
-
})(),
|
|
85
|
-
);
|
|
64
|
+
try {
|
|
65
|
+
this.env.get(ScannerSet).add(this.env.get(Ble).scanner);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
logger.error("Disabling BLE due to initialization error:", error);
|
|
68
|
+
this.state.ble = false;
|
|
69
|
+
}
|
|
86
70
|
}
|
|
87
71
|
|
|
88
72
|
// Ensure the fabric authority is fully initialized
|
|
@@ -104,6 +88,7 @@ export class ControllerBehavior extends Behavior {
|
|
|
104
88
|
if (node.lifecycle.isOnline) {
|
|
105
89
|
this.#nodeOnline();
|
|
106
90
|
}
|
|
91
|
+
this.reactTo(node.lifecycle.goingOffline, this.#nodeGoingOffline);
|
|
107
92
|
}
|
|
108
93
|
|
|
109
94
|
override async [Symbol.asyncDispose]() {
|
|
@@ -112,17 +97,22 @@ export class ControllerBehavior extends Behavior {
|
|
|
112
97
|
this.env.delete(ScannerSet);
|
|
113
98
|
}
|
|
114
99
|
|
|
100
|
+
get fabricAuthorityConfig(): FabricAuthorityConfiguration {
|
|
101
|
+
const biState = this.endpoint.stateOf(BasicInformationBehavior);
|
|
102
|
+
return {
|
|
103
|
+
adminVendorId: biState.vendorId,
|
|
104
|
+
...this.state,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
115
108
|
#nodeOnline() {
|
|
116
109
|
// Configure network connections
|
|
117
110
|
const netTransports = this.env.get(ConnectionlessTransportSet);
|
|
118
111
|
if (this.state.ble) {
|
|
112
|
+
// no try-catch needed because we already added the scanner in initialize()
|
|
119
113
|
netTransports.add(this.env.get(Ble).centralInterface);
|
|
120
114
|
}
|
|
121
115
|
|
|
122
|
-
// Clean up as the node goes offline
|
|
123
|
-
const node = Node.forEndpoint(this.endpoint);
|
|
124
|
-
this.reactTo(node.lifecycle.goingOffline, this.#nodeGoingOffline);
|
|
125
|
-
|
|
126
116
|
// Add each pre-existing fabric to discovery criteria
|
|
127
117
|
const authority = this.env.get(FabricAuthority);
|
|
128
118
|
for (const fabric of authority.fabrics) {
|
|
@@ -140,6 +130,21 @@ export class ControllerBehavior extends Behavior {
|
|
|
140
130
|
|
|
141
131
|
async #nodeGoingOffline() {
|
|
142
132
|
await this.env.close(ClientSubscriptions);
|
|
133
|
+
|
|
134
|
+
// Configure each MDNS scanner with criteria
|
|
135
|
+
const scanners = this.env.get(ScannerSet);
|
|
136
|
+
for (const scanner of scanners) {
|
|
137
|
+
if (scanner instanceof MdnsClient) {
|
|
138
|
+
scanner.targetCriteriaProviders.delete(this.internal.mdnsTargetCriteria);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Clear operational targets
|
|
142
|
+
this.internal.mdnsTargetCriteria.operationalTargets.length = 0;
|
|
143
|
+
|
|
144
|
+
const netTransports = this.env.get(ConnectionlessTransportSet);
|
|
145
|
+
if (this.state.ble) {
|
|
146
|
+
netTransports.delete(this.env.get(Ble).centralInterface);
|
|
147
|
+
}
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
#enableScanningForFabric(fabric: Fabric) {
|
|
@@ -191,5 +196,17 @@ export namespace ControllerBehavior {
|
|
|
191
196
|
* If not provided, a random FabricId will be generated.
|
|
192
197
|
*/
|
|
193
198
|
adminFabricId?: FabricId = undefined;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Contains the NodeId of the admin node when a defined number needs to be used because special Certificates
|
|
202
|
+
* are used.
|
|
203
|
+
* If not provided, a random NodeId will be generated.
|
|
204
|
+
*/
|
|
205
|
+
adminNodeId?: NodeId = undefined;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Case Authenticated Tags to be used to commission and connect to devices.
|
|
209
|
+
*/
|
|
210
|
+
caseAuthenticatedTags?: CaseAuthenticatedTag[] = undefined;
|
|
194
211
|
}
|
|
195
212
|
}
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
UdpInterface,
|
|
19
19
|
} from "#general";
|
|
20
20
|
import type { ServerNode } from "#node/ServerNode.js";
|
|
21
|
-
import { NodePeerAddressStore } from "#node/client/NodePeerAddressStore.js";
|
|
22
21
|
import { InteractionServer } from "#node/server/InteractionServer.js";
|
|
23
22
|
import {
|
|
24
23
|
Advertiser,
|
|
@@ -30,7 +29,6 @@ import {
|
|
|
30
29
|
ExchangeManager,
|
|
31
30
|
MdnsAdvertiser,
|
|
32
31
|
MdnsService,
|
|
33
|
-
PeerAddressStore,
|
|
34
32
|
PeerSet,
|
|
35
33
|
ScannerSet,
|
|
36
34
|
SecureChannelProtocol,
|
|
@@ -294,7 +292,6 @@ export class ServerNetworkRuntime extends NetworkRuntime {
|
|
|
294
292
|
// Initialize ScannerSet
|
|
295
293
|
this.owner.env.get(ScannerSet).add(mdns.client);
|
|
296
294
|
|
|
297
|
-
env.set(PeerAddressStore, new NodePeerAddressStore(owner));
|
|
298
295
|
await env.load(PeerSet);
|
|
299
296
|
|
|
300
297
|
await this.owner.act(agent => this.owner.lifecycle.online.emit(agent.context));
|
|
@@ -327,6 +324,7 @@ export class ServerNetworkRuntime extends NetworkRuntime {
|
|
|
327
324
|
await env.close(SecureChannelProtocol);
|
|
328
325
|
await env.close(ConnectionlessTransportSet);
|
|
329
326
|
await env.close(InteractionServer);
|
|
327
|
+
await env.close(PeerSet);
|
|
330
328
|
}
|
|
331
329
|
|
|
332
330
|
protected override blockNewActivity() {
|
|
@@ -227,10 +227,10 @@ export class SubscriptionsBehavior extends Behavior {
|
|
|
227
227
|
const { peerAddress: peerAddressDetails, operationalAddress, subscriptionId } = subscription;
|
|
228
228
|
const peerAddress = PeerAddress(peerAddressDetails);
|
|
229
229
|
if (peerStopList.has(peerAddress)) {
|
|
230
|
-
logger.debug(`Skip
|
|
230
|
+
logger.debug(`Skip reestablishing former subscription to ${peerAddress}`);
|
|
231
231
|
continue;
|
|
232
232
|
}
|
|
233
|
-
logger.debug(`Try to
|
|
233
|
+
logger.debug(`Try to reestablish former subscription ${subscriptionId} to ${peerAddress}`);
|
|
234
234
|
if (sessions.getSessionForNode(peerAddress) !== undefined) {
|
|
235
235
|
logger.debug(`We already have and existing session for peer ${peerAddress}`);
|
|
236
236
|
} else {
|
|
@@ -280,7 +280,7 @@ export class SubscriptionsBehavior extends Behavior {
|
|
|
280
280
|
interactionServer.subscriptionEstablishmentStarted.off(blockHandler);
|
|
281
281
|
|
|
282
282
|
logger.info(
|
|
283
|
-
`
|
|
283
|
+
`Reestablished ${successfullReEstablishments.length}${successfullReEstablishments.length ? ` (${successfullReEstablishments.join(",")})` : ""} of ${formerSubscriptions.length} former subscriptions successfully`,
|
|
284
284
|
);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
@@ -8,7 +8,7 @@ import { IndexBehavior } from "#behavior/system/index/IndexBehavior.js";
|
|
|
8
8
|
import type { Endpoint } from "#endpoint/Endpoint.js";
|
|
9
9
|
import { EndpointType } from "#endpoint/type/EndpointType.js";
|
|
10
10
|
import type { ImmutableSet } from "#general";
|
|
11
|
-
import { Node } from "#node/Node.js";
|
|
11
|
+
import type { Node } from "#node/Node.js";
|
|
12
12
|
import { StatusResponse } from "#types";
|
|
13
13
|
|
|
14
14
|
/**
|
package/src/node/client/Peers.ts
CHANGED
|
@@ -12,14 +12,12 @@ import { InstanceDiscovery } from "#behavior/system/controller/discovery/Instanc
|
|
|
12
12
|
import { EndpointContainer } from "#endpoint/properties/EndpointContainer.js";
|
|
13
13
|
import { CancelablePromise, Duration, ImplementationError, Logger, Minutes, Seconds, Time, Timestamp } from "#general";
|
|
14
14
|
import { ClientGroup } from "#node/ClientGroup.js";
|
|
15
|
-
import { InteractionServer } from "#node/
|
|
16
|
-
import { FabricManager, PeerAddress
|
|
15
|
+
import { InteractionServer } from "#node/server/InteractionServer.js";
|
|
16
|
+
import { ClientSubscriptionHandler, ClientSubscriptions, FabricManager, PeerAddress } from "#protocol";
|
|
17
17
|
import { ServerNodeStore } from "#storage/server/ServerNodeStore.js";
|
|
18
|
-
import { ClientSubscriptionHandler, ClientSubscriptions } from "@matter/protocol";
|
|
19
18
|
import { ClientNode } from "../ClientNode.js";
|
|
20
19
|
import type { ServerNode } from "../ServerNode.js";
|
|
21
20
|
import { ClientNodeFactory } from "./ClientNodeFactory.js";
|
|
22
|
-
import { NodePeerAddressStore } from "./NodePeerAddressStore.js";
|
|
23
21
|
|
|
24
22
|
const logger = Logger.get("ClientNodes");
|
|
25
23
|
|
|
@@ -44,8 +42,6 @@ export class Peers extends EndpointContainer<ClientNode> {
|
|
|
44
42
|
owner.env.set(ClientNodeFactory, new Factory(this));
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
this.owner.env.set(PeerAddressStore, new NodePeerAddressStore(owner));
|
|
48
|
-
|
|
49
45
|
owner.env.applyTo(InteractionServer, this.#configureInteractionServer.bind(this));
|
|
50
46
|
|
|
51
47
|
this.added.on(this.#handlePeerAdded.bind(this));
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
import { limitNodeDataToAllowedFabrics } from "#behavior/cluster/FabricScopedDataHandler.js";
|
|
8
8
|
import { EndpointInitializer } from "#endpoint/properties/EndpointInitializer.js";
|
|
9
9
|
import { Crypto, Observable } from "#general";
|
|
10
|
+
import { NodePeerAddressStore } from "#node/client/NodePeerAddressStore.js";
|
|
10
11
|
import { ChangeNotificationService } from "#node/integration/ChangeNotificationService.js";
|
|
11
12
|
import { ServerEndpointInitializer } from "#node/server/ServerEndpointInitializer.js";
|
|
12
13
|
import type { ServerNode } from "#node/ServerNode.js";
|
|
13
|
-
import { FabricManager, MdnsService, OccurrenceManager, SessionManager } from "#protocol";
|
|
14
|
+
import { FabricManager, MdnsService, OccurrenceManager, PeerAddressStore, SessionManager } from "#protocol";
|
|
14
15
|
import { ServerNodeStore } from "#storage/server/ServerNodeStore.js";
|
|
15
16
|
import { IdentityService } from "./IdentityService.js";
|
|
16
17
|
|
|
@@ -25,10 +26,17 @@ export namespace ServerEnvironment {
|
|
|
25
26
|
const { env } = node;
|
|
26
27
|
|
|
27
28
|
// Install support services
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if (!env.has(ServerNodeStore)) {
|
|
30
|
+
// TODO Remove the "if" once the legacy controller is removed
|
|
31
|
+
const store = await ServerNodeStore.create(env, node.id);
|
|
32
|
+
env.set(ServerNodeStore, store);
|
|
33
|
+
}
|
|
30
34
|
env.set(EndpointInitializer, new ServerEndpointInitializer(env));
|
|
31
35
|
env.set(IdentityService, new IdentityService(node));
|
|
36
|
+
if (!env.has(PeerAddressStore)) {
|
|
37
|
+
// TODO Remove the "if" once the legacy controller is removed
|
|
38
|
+
env.set(PeerAddressStore, new NodePeerAddressStore(node));
|
|
39
|
+
}
|
|
32
40
|
env.set(ChangeNotificationService, new ChangeNotificationService(node));
|
|
33
41
|
|
|
34
42
|
// Ensure these are fully initialized
|