@matter/node 0.16.0-alpha.0-20250906-463912bd0 → 0.16.0-alpha.0-20250912-0d12bf718
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/Behavior.d.ts +0 -18
- package/dist/cjs/behavior/Behavior.d.ts.map +1 -1
- package/dist/cjs/behavior/Behavior.js +0 -34
- package/dist/cjs/behavior/Behavior.js.map +1 -1
- package/dist/cjs/behavior/Transitions.js +2 -2
- package/dist/cjs/behavior/Transitions.js.map +1 -1
- package/dist/cjs/behavior/context/ActionContext.d.ts +4 -29
- package/dist/cjs/behavior/context/ActionContext.d.ts.map +1 -1
- package/dist/cjs/behavior/context/server/{OfflineContext.d.ts → LocalActorContext.d.ts} +16 -12
- package/dist/cjs/behavior/context/server/LocalActorContext.d.ts.map +1 -0
- package/dist/cjs/behavior/context/server/{OfflineContext.js → LocalActorContext.js} +10 -9
- package/dist/cjs/behavior/context/server/LocalActorContext.js.map +6 -0
- package/dist/cjs/behavior/context/server/RemoteActorContext.d.ts +80 -0
- package/dist/cjs/behavior/context/server/RemoteActorContext.d.ts.map +1 -0
- package/dist/cjs/behavior/context/server/{OnlineContext.js → RemoteActorContext.js} +15 -27
- package/dist/cjs/behavior/context/server/RemoteActorContext.js.map +6 -0
- package/dist/cjs/behavior/context/server/index.d.ts +2 -2
- package/dist/cjs/behavior/context/server/index.d.ts.map +1 -1
- package/dist/cjs/behavior/context/server/index.js +2 -2
- package/dist/cjs/behavior/context/server/index.js.map +1 -1
- package/dist/cjs/behavior/internal/Reactors.d.ts.map +1 -1
- package/dist/cjs/behavior/internal/Reactors.js +4 -3
- package/dist/cjs/behavior/internal/Reactors.js.map +1 -1
- package/dist/cjs/behavior/state/managed/Datasource.d.ts.map +1 -1
- package/dist/cjs/behavior/state/managed/Datasource.js +1 -6
- package/dist/cjs/behavior/state/managed/Datasource.js.map +1 -1
- package/dist/cjs/behavior/state/managed/values/ListManager.d.ts.map +1 -1
- package/dist/cjs/behavior/state/managed/values/ListManager.js +4 -4
- package/dist/cjs/behavior/state/managed/values/ListManager.js.map +1 -1
- package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts +16 -9
- package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts +12 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js +1 -0
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js.map +1 -1
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.js +3 -1
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.js.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkClient.d.ts +9 -0
- package/dist/cjs/behavior/system/network/NetworkClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkClient.js +20 -0
- package/dist/cjs/behavior/system/network/NetworkClient.js.map +1 -1
- package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/access-control/AccessControlServer.js +19 -15
- package/dist/cjs/behaviors/access-control/AccessControlServer.js.map +1 -1
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +5 -5
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
- package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.js +6 -6
- package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.js.map +1 -1
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +2 -4
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
- package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.js +9 -6
- package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.js.map +1 -1
- package/dist/cjs/behaviors/groups/GroupsServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/groups/GroupsServer.js +12 -9
- package/dist/cjs/behaviors/groups/GroupsServer.js.map +2 -2
- package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.js +16 -9
- package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.js.map +1 -1
- package/dist/cjs/behaviors/window-covering/WindowCoveringServer.js +1 -1
- package/dist/cjs/behaviors/window-covering/WindowCoveringServer.js.map +1 -1
- package/dist/cjs/endpoint/Agent.d.ts +14 -0
- package/dist/cjs/endpoint/Agent.d.ts.map +1 -1
- package/dist/cjs/endpoint/Agent.js +32 -0
- package/dist/cjs/endpoint/Agent.js.map +1 -1
- package/dist/cjs/endpoint/Endpoint.js +2 -2
- package/dist/cjs/endpoint/Endpoint.js.map +1 -1
- package/dist/cjs/endpoint/properties/Behaviors.js +4 -4
- package/dist/cjs/endpoint/properties/Behaviors.js.map +1 -1
- package/dist/cjs/endpoint/properties/Commands.js +2 -2
- package/dist/cjs/endpoint/properties/Commands.js.map +1 -1
- package/dist/cjs/node/server/IdentityService.js +2 -2
- package/dist/cjs/node/server/IdentityService.js.map +1 -1
- package/dist/cjs/node/server/InteractionServer.js.map +1 -1
- package/dist/cjs/node/server/OnlineServerInteraction.d.ts +6 -6
- package/dist/cjs/node/server/OnlineServerInteraction.d.ts.map +1 -1
- package/dist/cjs/node/server/OnlineServerInteraction.js +4 -4
- package/dist/cjs/node/server/OnlineServerInteraction.js.map +1 -1
- package/dist/cjs/node/server/ProtocolService.js +1 -1
- package/dist/cjs/node/server/ProtocolService.js.map +1 -1
- package/dist/cjs/node/server/ServerSubscription.d.ts +2 -2
- package/dist/cjs/node/server/ServerSubscription.d.ts.map +1 -1
- package/dist/cjs/node/server/ServerSubscription.js +3 -3
- package/dist/cjs/node/server/ServerSubscription.js.map +1 -1
- package/dist/esm/behavior/Behavior.d.ts +0 -18
- package/dist/esm/behavior/Behavior.d.ts.map +1 -1
- package/dist/esm/behavior/Behavior.js +0 -35
- package/dist/esm/behavior/Behavior.js.map +1 -1
- package/dist/esm/behavior/Transitions.js +2 -2
- package/dist/esm/behavior/Transitions.js.map +1 -1
- package/dist/esm/behavior/context/ActionContext.d.ts +4 -29
- package/dist/esm/behavior/context/ActionContext.d.ts.map +1 -1
- package/dist/esm/behavior/context/server/{OfflineContext.d.ts → LocalActorContext.d.ts} +16 -12
- package/dist/esm/behavior/context/server/LocalActorContext.d.ts.map +1 -0
- package/dist/esm/behavior/context/server/{OfflineContext.js → LocalActorContext.js} +7 -6
- package/dist/esm/behavior/context/server/LocalActorContext.js.map +6 -0
- package/dist/esm/behavior/context/server/RemoteActorContext.d.ts +80 -0
- package/dist/esm/behavior/context/server/RemoteActorContext.d.ts.map +1 -0
- package/dist/esm/behavior/context/server/{OnlineContext.js → RemoteActorContext.js} +14 -31
- package/dist/esm/behavior/context/server/RemoteActorContext.js.map +6 -0
- package/dist/esm/behavior/context/server/index.d.ts +2 -2
- package/dist/esm/behavior/context/server/index.d.ts.map +1 -1
- package/dist/esm/behavior/context/server/index.js +2 -2
- package/dist/esm/behavior/internal/Reactors.d.ts.map +1 -1
- package/dist/esm/behavior/internal/Reactors.js +4 -3
- package/dist/esm/behavior/internal/Reactors.js.map +1 -1
- package/dist/esm/behavior/state/managed/Datasource.d.ts.map +1 -1
- package/dist/esm/behavior/state/managed/Datasource.js +2 -7
- package/dist/esm/behavior/state/managed/Datasource.js.map +1 -1
- package/dist/esm/behavior/state/managed/values/ListManager.d.ts.map +1 -1
- package/dist/esm/behavior/state/managed/values/ListManager.js +13 -5
- package/dist/esm/behavior/state/managed/values/ListManager.js.map +1 -1
- package/dist/esm/behavior/supervision/ValueSupervisor.d.ts +16 -9
- package/dist/esm/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts +12 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js +1 -0
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js.map +1 -1
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.js +3 -1
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.js.map +1 -1
- package/dist/esm/behavior/system/network/NetworkClient.d.ts +9 -0
- package/dist/esm/behavior/system/network/NetworkClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/NetworkClient.js +20 -0
- package/dist/esm/behavior/system/network/NetworkClient.js.map +1 -1
- package/dist/esm/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
- package/dist/esm/behaviors/access-control/AccessControlServer.js +21 -15
- package/dist/esm/behaviors/access-control/AccessControlServer.js.map +1 -1
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +13 -6
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
- package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.d.ts.map +1 -1
- package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.js +15 -7
- package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.js.map +1 -1
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +3 -5
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
- package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.d.ts.map +1 -1
- package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.js +10 -7
- package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.js.map +1 -1
- package/dist/esm/behaviors/groups/GroupsServer.d.ts.map +1 -1
- package/dist/esm/behaviors/groups/GroupsServer.js +12 -9
- package/dist/esm/behaviors/groups/GroupsServer.js.map +2 -2
- package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.d.ts.map +1 -1
- package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.js +17 -9
- package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.js.map +1 -1
- package/dist/esm/behaviors/window-covering/WindowCoveringServer.js +1 -1
- package/dist/esm/behaviors/window-covering/WindowCoveringServer.js.map +1 -1
- package/dist/esm/endpoint/Agent.d.ts +14 -0
- package/dist/esm/endpoint/Agent.d.ts.map +1 -1
- package/dist/esm/endpoint/Agent.js +32 -0
- package/dist/esm/endpoint/Agent.js.map +1 -1
- package/dist/esm/endpoint/Endpoint.js +2 -2
- package/dist/esm/endpoint/Endpoint.js.map +1 -1
- package/dist/esm/endpoint/properties/Behaviors.js +4 -4
- package/dist/esm/endpoint/properties/Behaviors.js.map +1 -1
- package/dist/esm/endpoint/properties/Commands.js +2 -2
- package/dist/esm/endpoint/properties/Commands.js.map +1 -1
- package/dist/esm/node/server/IdentityService.js +2 -2
- package/dist/esm/node/server/IdentityService.js.map +1 -1
- package/dist/esm/node/server/InteractionServer.js.map +1 -1
- package/dist/esm/node/server/OnlineServerInteraction.d.ts +6 -6
- package/dist/esm/node/server/OnlineServerInteraction.d.ts.map +1 -1
- package/dist/esm/node/server/OnlineServerInteraction.js +4 -4
- package/dist/esm/node/server/OnlineServerInteraction.js.map +1 -1
- package/dist/esm/node/server/ProtocolService.js +2 -2
- package/dist/esm/node/server/ProtocolService.js.map +1 -1
- package/dist/esm/node/server/ServerSubscription.d.ts +2 -2
- package/dist/esm/node/server/ServerSubscription.d.ts.map +1 -1
- package/dist/esm/node/server/ServerSubscription.js +3 -3
- package/dist/esm/node/server/ServerSubscription.js.map +1 -1
- package/package.json +7 -7
- package/src/behavior/Behavior.ts +0 -41
- package/src/behavior/Transitions.ts +2 -2
- package/src/behavior/context/ActionContext.ts +4 -35
- package/src/behavior/context/server/{OfflineContext.ts → LocalActorContext.ts} +17 -14
- package/src/behavior/context/server/{OnlineContext.ts → RemoteActorContext.ts} +65 -52
- package/src/behavior/context/server/index.ts +2 -2
- package/src/behavior/internal/Reactors.ts +5 -4
- package/src/behavior/state/managed/Datasource.ts +3 -9
- package/src/behavior/state/managed/values/ListManager.ts +14 -11
- package/src/behavior/supervision/ValueSupervisor.ts +18 -10
- package/src/behavior/system/commissioning/CommissioningClient.ts +15 -0
- package/src/behavior/system/network/ClientNetworkRuntime.ts +5 -1
- package/src/behavior/system/network/NetworkClient.ts +23 -0
- package/src/behaviors/access-control/AccessControlServer.ts +25 -20
- package/src/behaviors/administrator-commissioning/AdministratorCommissioningServer.ts +14 -6
- package/src/behaviors/general-commissioning/GeneralCommissioningServer.ts +15 -8
- package/src/behaviors/general-diagnostics/GeneralDiagnosticsServer.ts +3 -5
- package/src/behaviors/group-key-management/GroupKeyManagementServer.ts +13 -7
- package/src/behaviors/groups/GroupsServer.ts +16 -11
- package/src/behaviors/operational-credentials/OperationalCredentialsServer.ts +21 -9
- package/src/behaviors/window-covering/WindowCoveringServer.ts +1 -1
- package/src/endpoint/Agent.ts +34 -0
- package/src/endpoint/Endpoint.ts +2 -2
- package/src/endpoint/properties/Behaviors.ts +4 -4
- package/src/endpoint/properties/Commands.ts +2 -2
- package/src/node/ClientNode.ts +1 -1
- package/src/node/server/IdentityService.ts +2 -2
- package/src/node/server/InteractionServer.ts +2 -2
- package/src/node/server/OnlineServerInteraction.ts +9 -9
- package/src/node/server/ProtocolService.ts +2 -2
- package/src/node/server/ServerSubscription.ts +5 -5
- package/dist/cjs/behavior/context/server/OfflineContext.d.ts.map +0 -1
- package/dist/cjs/behavior/context/server/OfflineContext.js.map +0 -6
- package/dist/cjs/behavior/context/server/OnlineContext.d.ts +0 -61
- package/dist/cjs/behavior/context/server/OnlineContext.d.ts.map +0 -1
- package/dist/cjs/behavior/context/server/OnlineContext.js.map +0 -6
- package/dist/esm/behavior/context/server/OfflineContext.d.ts.map +0 -1
- package/dist/esm/behavior/context/server/OfflineContext.js.map +0 -6
- package/dist/esm/behavior/context/server/OnlineContext.d.ts +0 -61
- package/dist/esm/behavior/context/server/OnlineContext.d.ts.map +0 -1
- package/dist/esm/behavior/context/server/OnlineContext.js.map +0 -6
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
Subscribe,
|
|
34
34
|
} from "#protocol";
|
|
35
35
|
import {
|
|
36
|
+
CaseAuthenticatedTag,
|
|
36
37
|
DeviceTypeId,
|
|
37
38
|
DiscoveryCapabilitiesBitmap,
|
|
38
39
|
ManualPairingCodeCodec,
|
|
@@ -56,6 +57,7 @@ export class CommissioningClient extends Behavior {
|
|
|
56
57
|
static override readonly early = true;
|
|
57
58
|
|
|
58
59
|
static override readonly id = "commissioning";
|
|
60
|
+
|
|
59
61
|
override initialize(options: { descriptor?: RemoteDescriptor }) {
|
|
60
62
|
const descriptor = options?.descriptor;
|
|
61
63
|
if (descriptor) {
|
|
@@ -151,6 +153,7 @@ export class CommissioningClient extends Behavior {
|
|
|
151
153
|
|
|
152
154
|
const network = this.agent.get(NetworkClient);
|
|
153
155
|
network.state.startupSubscription = opts.startupSubscription;
|
|
156
|
+
network.state.caseAuthenticatedTags = opts.caseAuthenticatedTags;
|
|
154
157
|
|
|
155
158
|
node.lifecycle.commissioned.emit(this.context);
|
|
156
159
|
|
|
@@ -433,6 +436,18 @@ export namespace CommissioningClient {
|
|
|
433
436
|
* read omits them then the node will only be partially functional once initialized.
|
|
434
437
|
*/
|
|
435
438
|
startupSubscription?: Subscribe | null;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Case Authenticated Tags (CATs) to use for operational CASE sessions with this node.
|
|
442
|
+
*
|
|
443
|
+
* CATs provide additional authentication context for Matter operational sessions. They are only used
|
|
444
|
+
* for operational CASE connections after commissioning is complete, not during the initial PASE
|
|
445
|
+
* commissioning process.
|
|
446
|
+
*
|
|
447
|
+
* Note: CATs only make sense when additional ACLs (Access Control Lists) are also configured on
|
|
448
|
+
* the target device to grant specific permissions based on these tags.
|
|
449
|
+
*/
|
|
450
|
+
caseAuthenticatedTags?: CaseAuthenticatedTag[];
|
|
436
451
|
}
|
|
437
452
|
|
|
438
453
|
export interface PasscodeOptions extends BaseCommissioningOptions {
|
|
@@ -51,9 +51,13 @@ export class ClientNetworkRuntime extends NetworkRuntime {
|
|
|
51
51
|
const { env, lifecycle } = this.owner;
|
|
52
52
|
const peers = env.get(PeerSet);
|
|
53
53
|
const commissioningState = this.owner.stateOf(CommissioningClient);
|
|
54
|
+
const networkState = this.owner.state.network;
|
|
54
55
|
|
|
55
56
|
const exchangeProvider = await peers.exchangeProviderFor(address, {
|
|
56
|
-
discoveryData: RemoteDescriptor.fromLongForm(commissioningState),
|
|
57
|
+
discoveryOptions: { discoveryData: RemoteDescriptor.fromLongForm(commissioningState) },
|
|
58
|
+
caseAuthenticatedTags: networkState.caseAuthenticatedTags
|
|
59
|
+
? [...networkState.caseAuthenticatedTags] // needed because the tags are readonly
|
|
60
|
+
: undefined,
|
|
57
61
|
});
|
|
58
62
|
env.set(ExchangeProvider, exchangeProvider);
|
|
59
63
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { DatatypeModel, FieldElement } from "#model";
|
|
8
8
|
import { Node } from "#node/Node.js";
|
|
9
9
|
import { DEFAULT_MIN_INTERVAL_FLOOR, Subscribe } from "#protocol";
|
|
10
|
+
import { CaseAuthenticatedTag } from "#types";
|
|
10
11
|
import { ClientNetworkRuntime } from "./ClientNetworkRuntime.js";
|
|
11
12
|
import { NetworkBehavior } from "./NetworkBehavior.js";
|
|
12
13
|
|
|
@@ -62,6 +63,19 @@ export class NetworkClient extends NetworkBehavior {
|
|
|
62
63
|
type: "bool",
|
|
63
64
|
quality: "N",
|
|
64
65
|
}),
|
|
66
|
+
|
|
67
|
+
FieldElement({
|
|
68
|
+
name: "caseAuthenticatedTags",
|
|
69
|
+
type: "list",
|
|
70
|
+
quality: "N",
|
|
71
|
+
conformance: "O",
|
|
72
|
+
children: [
|
|
73
|
+
FieldElement({
|
|
74
|
+
name: "entry",
|
|
75
|
+
type: "uint32",
|
|
76
|
+
}),
|
|
77
|
+
],
|
|
78
|
+
}),
|
|
65
79
|
],
|
|
66
80
|
});
|
|
67
81
|
}
|
|
@@ -86,5 +100,14 @@ export namespace NetworkClient {
|
|
|
86
100
|
* If true, the matter.js will not perform network communication with the node.
|
|
87
101
|
*/
|
|
88
102
|
isDisabled = false;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Case Authenticated Tags (CATs) to use for operational CASE sessions with this node.
|
|
106
|
+
*
|
|
107
|
+
* CATs provide additional authentication context for Matter operational sessions. They are only used
|
|
108
|
+
* for operational CASE connections after commissioning is complete, not during the initial PASE
|
|
109
|
+
* commissioning process.
|
|
110
|
+
*/
|
|
111
|
+
caseAuthenticatedTags?: CaseAuthenticatedTag[];
|
|
89
112
|
}
|
|
90
113
|
}
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
AclList,
|
|
16
16
|
Fabric,
|
|
17
17
|
FabricManager,
|
|
18
|
+
hasLocalActor,
|
|
19
|
+
hasRemoteActor,
|
|
18
20
|
IncomingSubjectDescriptor,
|
|
19
21
|
MessageExchange,
|
|
20
22
|
NodeSession,
|
|
@@ -91,8 +93,8 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
91
93
|
". This should only happen once after upgrading to matter.js 0.9.1",
|
|
92
94
|
);
|
|
93
95
|
}
|
|
94
|
-
fabric.
|
|
95
|
-
fabric.
|
|
96
|
+
fabric.accessControl.aclList = fabricAcls;
|
|
97
|
+
fabric.accessControl.extensionEntryAccessCheck = this.extensionEntryAccessCheck.bind(this);
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
// TODO handle delete fabric more generically later to remove fabric scoped data
|
|
@@ -134,11 +136,14 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
134
136
|
#validateAccessControlListChanges(
|
|
135
137
|
value: AccessControlTypes.AccessControlEntry[],
|
|
136
138
|
_oldValue: AccessControlTypes.AccessControlEntry[],
|
|
137
|
-
context?: ActionContext,
|
|
138
139
|
) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
const { context } = this;
|
|
141
|
+
|
|
142
|
+
if (!hasRemoteActor(context)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const relevantFabricIndex = context.session.associatedFabric.fabricIndex;
|
|
142
147
|
|
|
143
148
|
if (relevantFabricIndex === undefined) {
|
|
144
149
|
return;
|
|
@@ -276,7 +281,8 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
276
281
|
if (!this.internal.initialized) {
|
|
277
282
|
return; // Too early to send events
|
|
278
283
|
}
|
|
279
|
-
|
|
284
|
+
|
|
285
|
+
const session = hasRemoteActor(this.context) ? this.context.session : undefined;
|
|
280
286
|
|
|
281
287
|
// TODO: This might be not really correct for local ACL changes because there the session fabric could be
|
|
282
288
|
// different which would lead to missing events
|
|
@@ -327,14 +333,12 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
327
333
|
}
|
|
328
334
|
|
|
329
335
|
#validateAccessControlExtensionChanges(value: AccessControlTypes.AccessControlExtension[]) {
|
|
330
|
-
|
|
331
|
-
// different which would lead to missing validation of the relevant entries
|
|
332
|
-
const relevantFabricIndex = this.context.session?.associatedFabric.fabricIndex;
|
|
333
|
-
|
|
334
|
-
if (relevantFabricIndex === undefined) {
|
|
336
|
+
if (!hasRemoteActor(this.context)) {
|
|
335
337
|
return;
|
|
336
338
|
}
|
|
337
339
|
|
|
340
|
+
const relevantFabricIndex = this.context.session.associatedFabric.fabricIndex;
|
|
341
|
+
|
|
338
342
|
const fabricExtensions = value.filter(entry => entry.fabricIndex === relevantFabricIndex);
|
|
339
343
|
|
|
340
344
|
if (fabricExtensions.length === 0) {
|
|
@@ -355,7 +359,8 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
355
359
|
if (!this.internal.initialized) {
|
|
356
360
|
return; // Too early to send events
|
|
357
361
|
}
|
|
358
|
-
|
|
362
|
+
|
|
363
|
+
const session = hasRemoteActor(this.context) ? this.context.session : undefined;
|
|
359
364
|
|
|
360
365
|
// TODO: This might be not really correct for local ACL changes because there the session fabric could be
|
|
361
366
|
// different which would lead to missing events of the relevant entries
|
|
@@ -437,7 +442,7 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
437
442
|
/** A fabric was added or updated, so we need to initialize the ACL for this fabric */
|
|
438
443
|
#updateFabricAcls(fabric: Fabric) {
|
|
439
444
|
const fabricIndex = fabric.fabricIndex;
|
|
440
|
-
fabric.
|
|
445
|
+
fabric.accessControl.aclList = deepCopy(this.state.acl).filter(entry => entry.fabricIndex === fabricIndex);
|
|
441
446
|
}
|
|
442
447
|
|
|
443
448
|
/**
|
|
@@ -445,7 +450,7 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
445
450
|
* fabric index. If ACL data are really changed later, the exchange gets added then.
|
|
446
451
|
*/
|
|
447
452
|
#handleInteractionBegin(session?: AccessControl.Session) {
|
|
448
|
-
if (session
|
|
453
|
+
if (hasRemoteActor(session)) {
|
|
449
454
|
this.#prepareAclUpdateFor(session.fabric);
|
|
450
455
|
}
|
|
451
456
|
}
|
|
@@ -456,7 +461,7 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
456
461
|
* not changing the ACL.
|
|
457
462
|
*/
|
|
458
463
|
#handleInteractionEnd(session?: AccessControl.Session) {
|
|
459
|
-
if (session
|
|
464
|
+
if (hasRemoteActor(session)) {
|
|
460
465
|
if (this.internal.aclUpdateDelayed.get(session.fabric) !== undefined) {
|
|
461
466
|
this.#applyDelayedAclUpdateFor(session.fabric);
|
|
462
467
|
}
|
|
@@ -469,7 +474,7 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
469
474
|
_oldAcl: AccessControlTypes.AccessControlEntry[],
|
|
470
475
|
context?: ActionContext,
|
|
471
476
|
) {
|
|
472
|
-
if (context
|
|
477
|
+
if (hasLocalActor(context)) {
|
|
473
478
|
// local or offline ACL change, so we update all fabrics because we do not know better
|
|
474
479
|
this.#updateAllFabricsAcls();
|
|
475
480
|
} else {
|
|
@@ -498,7 +503,7 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
498
503
|
// No interaction registered, so we apply directly because local/offline change
|
|
499
504
|
logger.debug("ACL attribute updated, applying update to ACL manager", fabricIndex);
|
|
500
505
|
|
|
501
|
-
fabric.
|
|
506
|
+
fabric.accessControl.aclList = deepCopy(acl).filter(entry => entry.fabricIndex === fabricIndex);
|
|
502
507
|
}
|
|
503
508
|
}
|
|
504
509
|
|
|
@@ -522,7 +527,7 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
522
527
|
const fabrics = this.env.get(FabricManager);
|
|
523
528
|
for (const fabric of fabrics) {
|
|
524
529
|
// Update all Fabrics and set the ACL list for each fabric, empty ACLs when none are present
|
|
525
|
-
fabric.
|
|
530
|
+
fabric.accessControl.aclList = aclsForFabric.get(fabric.fabricIndex) ?? [];
|
|
526
531
|
}
|
|
527
532
|
}
|
|
528
533
|
|
|
@@ -564,7 +569,7 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
|
|
|
564
569
|
this.internal.delayedAclData.delete(fabricIndex);
|
|
565
570
|
this.internal.aclUpdateDelayed.delete(fabricIndex);
|
|
566
571
|
if (updateDelayed && delayedData !== undefined) {
|
|
567
|
-
this.env.get(FabricManager).for(fabricIndex).
|
|
572
|
+
this.env.get(FabricManager).for(fabricIndex).accessControl.aclList = delayedData;
|
|
568
573
|
}
|
|
569
574
|
}
|
|
570
575
|
}
|
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
import { AdministratorCommissioning } from "#clusters/administrator-commissioning";
|
|
8
8
|
import { Duration, InternalError, Logger, Seconds, Time, Timer } from "#general";
|
|
9
9
|
import { AccessLevel } from "#model";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
assertRemoteActor,
|
|
12
|
+
DeviceCommissioner,
|
|
13
|
+
FailsafeContext,
|
|
14
|
+
hasRemoteActor,
|
|
15
|
+
PaseServer,
|
|
16
|
+
SessionManager,
|
|
17
|
+
} from "#protocol";
|
|
11
18
|
import {
|
|
12
19
|
Command,
|
|
13
20
|
MINIMUM_COMMISSIONING_TIMEOUT,
|
|
@@ -155,16 +162,17 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
|
|
|
155
162
|
// Should never happen, but let's make sure
|
|
156
163
|
throw new InternalError("Commissioning window already initialized.");
|
|
157
164
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
);
|
|
165
|
+
const actor = hasRemoteActor(this.context) ? this.context.session.name : "local actor";
|
|
166
|
+
logger.debug(`Commissioning window timer started for ${commissioningTimeout} seconds for ${actor}.`);
|
|
161
167
|
this.internal.commissioningWindowTimeout = Time.getTimer(
|
|
162
168
|
"Commissioning timeout",
|
|
163
169
|
commissioningTimeout,
|
|
164
170
|
this.callback(this.#commissioningTimeout),
|
|
165
171
|
).start();
|
|
166
172
|
|
|
167
|
-
|
|
173
|
+
assertRemoteActor(this.context);
|
|
174
|
+
|
|
175
|
+
const adminFabric = this.context.session.associatedFabric;
|
|
168
176
|
|
|
169
177
|
this.state.windowStatus = windowStatus;
|
|
170
178
|
this.state.adminFabricIndex = adminFabric.fabricIndex;
|
|
@@ -176,7 +184,7 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
|
|
|
176
184
|
adminFabric.deleteRemoveCallback(removeCallback);
|
|
177
185
|
};
|
|
178
186
|
|
|
179
|
-
this.session.associatedFabric.addRemoveCallback(removeCallback);
|
|
187
|
+
this.context.session.associatedFabric.addRemoveCallback(removeCallback);
|
|
180
188
|
}
|
|
181
189
|
|
|
182
190
|
/**
|
|
@@ -10,7 +10,15 @@ import { AdministratorCommissioning } from "#clusters/administrator-commissionin
|
|
|
10
10
|
import { GeneralCommissioning } from "#clusters/general-commissioning";
|
|
11
11
|
import { Bytes, Diagnostic, Logger, MatterFlowError, MaybePromise, Seconds } from "#general";
|
|
12
12
|
import type { ServerNode } from "#node/ServerNode.js";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
assertRemoteActor,
|
|
15
|
+
DeviceCommissioner,
|
|
16
|
+
FabricManager,
|
|
17
|
+
GroupSession,
|
|
18
|
+
NodeSession,
|
|
19
|
+
SecureSession,
|
|
20
|
+
SessionManager,
|
|
21
|
+
} from "#protocol";
|
|
14
22
|
import { GeneralCommissioningBehavior } from "./GeneralCommissioningBehavior.js";
|
|
15
23
|
import { ServerNodeFailsafeContext } from "./ServerNodeFailsafeContext.js";
|
|
16
24
|
|
|
@@ -121,7 +129,8 @@ export class GeneralCommissioningServer extends GeneralCommissioningBehavior {
|
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
override armFailSafe(request: GeneralCommissioning.ArmFailSafeRequest) {
|
|
124
|
-
|
|
132
|
+
assertRemoteActor(this.context);
|
|
133
|
+
return this.#armFailSafe(request, this.context.session);
|
|
125
134
|
}
|
|
126
135
|
|
|
127
136
|
override async setRegulatoryConfig({
|
|
@@ -191,10 +200,7 @@ export class GeneralCommissioningServer extends GeneralCommissioningBehavior {
|
|
|
191
200
|
};
|
|
192
201
|
}
|
|
193
202
|
|
|
194
|
-
|
|
195
|
-
this.asAdmin(() => {
|
|
196
|
-
this.state.regulatoryConfig = newRegulatoryConfig;
|
|
197
|
-
});
|
|
203
|
+
this.state.regulatoryConfig = newRegulatoryConfig;
|
|
198
204
|
|
|
199
205
|
this.state.breadcrumb = breadcrumb;
|
|
200
206
|
|
|
@@ -202,7 +208,8 @@ export class GeneralCommissioningServer extends GeneralCommissioningBehavior {
|
|
|
202
208
|
}
|
|
203
209
|
|
|
204
210
|
override async commissioningComplete() {
|
|
205
|
-
|
|
211
|
+
assertRemoteActor(this.context);
|
|
212
|
+
const { session } = this.context;
|
|
206
213
|
if ((NodeSession.is(session) && session.isPase) || GroupSession.is(session)) {
|
|
207
214
|
return {
|
|
208
215
|
errorCode: GeneralCommissioning.CommissioningError.InvalidAuthentication,
|
|
@@ -210,7 +217,7 @@ export class GeneralCommissioningServer extends GeneralCommissioningBehavior {
|
|
|
210
217
|
};
|
|
211
218
|
}
|
|
212
219
|
|
|
213
|
-
const fabric =
|
|
220
|
+
const fabric = session.associatedFabric;
|
|
214
221
|
|
|
215
222
|
const commissioner = this.env.get(DeviceCommissioner);
|
|
216
223
|
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "#general";
|
|
29
29
|
import { FieldElement, Specification } from "#model";
|
|
30
30
|
import type { NodeLifecycle } from "#node/NodeLifecycle.js";
|
|
31
|
-
import { MdnsService, Val } from "#protocol";
|
|
31
|
+
import { assertRemoteActor, MdnsService, Val } from "#protocol";
|
|
32
32
|
import { CommandId, StatusCode, StatusResponseError, TlvInvokeResponse } from "#types";
|
|
33
33
|
import { GeneralDiagnosticsBehavior } from "./GeneralDiagnosticsBehavior.js";
|
|
34
34
|
|
|
@@ -173,10 +173,8 @@ export class GeneralDiagnosticsServer extends Base {
|
|
|
173
173
|
],
|
|
174
174
|
}).byteLength;
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
throw new ImplementationError(`Illegal operation outside exchange context`);
|
|
179
|
-
}
|
|
176
|
+
assertRemoteActor(this.context);
|
|
177
|
+
const { exchange } = this.context;
|
|
180
178
|
|
|
181
179
|
if (responseSize > exchange.maxPayloadSize) {
|
|
182
180
|
throw new StatusResponseError("Response too large", StatusCode.ResourceExhausted);
|
|
@@ -9,7 +9,7 @@ import { GroupKeyManagement } from "#clusters/group-key-management";
|
|
|
9
9
|
import { deepCopy, ImplementationError, Logger, MaybePromise } from "#general";
|
|
10
10
|
import { DatatypeModel, FieldElement } from "#model";
|
|
11
11
|
import { NodeLifecycle } from "#node/NodeLifecycle.js";
|
|
12
|
-
import { Fabric, FabricManager,
|
|
12
|
+
import { assertRemoteActor, Fabric, FabricManager, hasRemoteActor } from "#protocol";
|
|
13
13
|
import { EndpointNumber, FabricIndex, GroupId, StatusCode, StatusResponseError } from "#types";
|
|
14
14
|
import { GroupKeyManagementBehavior } from "./GroupKeyManagementBehavior.js";
|
|
15
15
|
|
|
@@ -217,7 +217,7 @@ export class GroupKeyManagementServer extends GroupKeyManagementBehavior {
|
|
|
217
217
|
_oldMap?: GroupKeyManagement.GroupKeyMap[],
|
|
218
218
|
context?: ActionContext,
|
|
219
219
|
) {
|
|
220
|
-
if (context !== undefined &&
|
|
220
|
+
if (context !== undefined && hasRemoteActor(context)) {
|
|
221
221
|
const fabric = context.session?.associatedFabric;
|
|
222
222
|
const fabricIndex = fabric?.fabricIndex;
|
|
223
223
|
|
|
@@ -252,7 +252,7 @@ export class GroupKeyManagementServer extends GroupKeyManagementBehavior {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
override async keySetWrite({ groupKeySet }: GroupKeyManagement.KeySetWriteRequest) {
|
|
255
|
-
|
|
255
|
+
assertRemoteActor(this.context);
|
|
256
256
|
|
|
257
257
|
const {
|
|
258
258
|
groupKeySetId,
|
|
@@ -324,7 +324,7 @@ export class GroupKeyManagementServer extends GroupKeyManagementBehavior {
|
|
|
324
324
|
throw new StatusResponseError("GroupKeyMulticastPolicy must be PerGroupId", StatusCode.InvalidCommand);
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
const fabric = this.session.associatedFabric;
|
|
327
|
+
const fabric = this.context.session.associatedFabric;
|
|
328
328
|
const fabricIndex = fabric.fabricIndex;
|
|
329
329
|
|
|
330
330
|
// Replace or add the group key set to the internal persisted state
|
|
@@ -356,7 +356,9 @@ export class GroupKeyManagementServer extends GroupKeyManagementBehavior {
|
|
|
356
356
|
override keySetRead({
|
|
357
357
|
groupKeySetId,
|
|
358
358
|
}: GroupKeyManagement.KeySetReadRequest): GroupKeyManagement.KeySetReadResponse {
|
|
359
|
-
|
|
359
|
+
assertRemoteActor(this.context);
|
|
360
|
+
|
|
361
|
+
const fabric = this.context.session.associatedFabric;
|
|
360
362
|
|
|
361
363
|
// We use the fabric group manager to retrieve the group key set because he also has the id 0 and is synced anyway
|
|
362
364
|
const groupKeySet = fabric.groups.keySets.asGroupKeySet(groupKeySetId);
|
|
@@ -379,7 +381,9 @@ export class GroupKeyManagementServer extends GroupKeyManagementBehavior {
|
|
|
379
381
|
throw new StatusResponseError(`GroupKeySet ${groupKeySetId} cannot be removed`, StatusCode.InvalidCommand);
|
|
380
382
|
}
|
|
381
383
|
|
|
382
|
-
|
|
384
|
+
assertRemoteActor(this.context);
|
|
385
|
+
|
|
386
|
+
const fabric = this.context.session.associatedFabric;
|
|
383
387
|
const fabricIndex = fabric.fabricIndex;
|
|
384
388
|
|
|
385
389
|
// Replace or add the group key set to the internal persisted state
|
|
@@ -402,7 +406,9 @@ export class GroupKeyManagementServer extends GroupKeyManagementBehavior {
|
|
|
402
406
|
}
|
|
403
407
|
|
|
404
408
|
override keySetReadAllIndices(): GroupKeyManagement.KeySetReadAllIndicesResponse {
|
|
405
|
-
|
|
409
|
+
assertRemoteActor(this.context);
|
|
410
|
+
|
|
411
|
+
const fabric = this.context.session.associatedFabric;
|
|
406
412
|
const fabricIndex = fabric.fabricIndex;
|
|
407
413
|
|
|
408
414
|
const groupKeySetIDs = this.state.groupKeySets
|
|
@@ -11,6 +11,7 @@ import { Endpoint } from "#endpoint/Endpoint.js";
|
|
|
11
11
|
import { RootEndpoint } from "#endpoints/root";
|
|
12
12
|
import { InternalError, Logger } from "#general";
|
|
13
13
|
import { AccessLevel } from "#model";
|
|
14
|
+
import { assertRemoteActor, Fabric } from "#protocol";
|
|
14
15
|
import {
|
|
15
16
|
Command,
|
|
16
17
|
StatusCode,
|
|
@@ -75,16 +76,20 @@ export class GroupsServer extends GroupsBase {
|
|
|
75
76
|
return rootEndpoint;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
async #actOnGroupKeyManagement<T>(
|
|
79
|
+
async #actOnGroupKeyManagement<T>(
|
|
80
|
+
act: (fabric: Fabric, groupKeyManagement: GroupKeyManagementServer) => T,
|
|
81
|
+
): Promise<T> {
|
|
82
|
+
assertRemoteActor(this.context);
|
|
79
83
|
const agent = this.#rootEndpoint.agentFor(this.context);
|
|
80
84
|
const gkm = agent.get(GroupKeyManagementServer);
|
|
81
85
|
await agent.context.transaction.addResources(gkm);
|
|
82
86
|
await agent.context.transaction.begin();
|
|
83
|
-
return act(gkm);
|
|
87
|
+
return act(this.context.session.associatedFabric, gkm);
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
override async addGroup({ groupId, groupName }: Groups.AddGroupRequest): Promise<Groups.AddGroupResponse> {
|
|
87
|
-
|
|
91
|
+
assertRemoteActor(this.context);
|
|
92
|
+
const fabric = this.context.session.associatedFabric;
|
|
88
93
|
|
|
89
94
|
if (groupId < 1) {
|
|
90
95
|
return { status: StatusCode.ConstraintError, groupId };
|
|
@@ -100,7 +105,7 @@ export class GroupsServer extends GroupsBase {
|
|
|
100
105
|
const endpointNumber = this.endpoint.number;
|
|
101
106
|
|
|
102
107
|
try {
|
|
103
|
-
await this.#actOnGroupKeyManagement(gkm =>
|
|
108
|
+
await this.#actOnGroupKeyManagement((fabric, gkm) =>
|
|
104
109
|
gkm.addEndpointForGroup(fabric, groupId, endpointNumber, groupName),
|
|
105
110
|
);
|
|
106
111
|
} catch (error) {
|
|
@@ -113,7 +118,8 @@ export class GroupsServer extends GroupsBase {
|
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
override viewGroup({ groupId }: Groups.ViewGroupRequest): Groups.ViewGroupResponse {
|
|
116
|
-
|
|
121
|
+
assertRemoteActor(this.context);
|
|
122
|
+
const fabric = this.context.session.associatedFabric;
|
|
117
123
|
|
|
118
124
|
if (groupId < 1) {
|
|
119
125
|
return { status: StatusCode.ConstraintError, groupId, groupName: "" };
|
|
@@ -133,7 +139,8 @@ export class GroupsServer extends GroupsBase {
|
|
|
133
139
|
override async getGroupMembership({
|
|
134
140
|
groupList,
|
|
135
141
|
}: Groups.GetGroupMembershipRequest): Promise<Groups.GetGroupMembershipResponse> {
|
|
136
|
-
|
|
142
|
+
assertRemoteActor(this.context);
|
|
143
|
+
const fabric = this.context.session.associatedFabric;
|
|
137
144
|
const fabricIndex = fabric.fabricIndex;
|
|
138
145
|
const endpointNumber = this.endpoint.number;
|
|
139
146
|
|
|
@@ -158,8 +165,8 @@ export class GroupsServer extends GroupsBase {
|
|
|
158
165
|
|
|
159
166
|
try {
|
|
160
167
|
if (
|
|
161
|
-
await this.#actOnGroupKeyManagement(gkm =>
|
|
162
|
-
gkm.removeEndpoint(
|
|
168
|
+
await this.#actOnGroupKeyManagement((fabric, gkm) =>
|
|
169
|
+
gkm.removeEndpoint(fabric, this.endpoint.number, groupId),
|
|
163
170
|
)
|
|
164
171
|
) {
|
|
165
172
|
return { status: StatusCode.Success, groupId };
|
|
@@ -174,9 +181,7 @@ export class GroupsServer extends GroupsBase {
|
|
|
174
181
|
// TODO ScenesManagement cluster is also affected by this command
|
|
175
182
|
override async removeAllGroups() {
|
|
176
183
|
try {
|
|
177
|
-
await this.#actOnGroupKeyManagement(gkm =>
|
|
178
|
-
gkm.removeEndpoint(this.session.associatedFabric, this.endpoint.number),
|
|
179
|
-
);
|
|
184
|
+
await this.#actOnGroupKeyManagement((fabric, gkm) => gkm.removeEndpoint(fabric, this.endpoint.number));
|
|
180
185
|
} catch (error) {
|
|
181
186
|
StatusResponseError.accept(error);
|
|
182
187
|
throw error;
|
|
@@ -14,6 +14,7 @@ import { Crypto, CryptoVerifyError, Logger, MatterFlowError, MaybePromise, Unexp
|
|
|
14
14
|
import { AccessLevel } from "#model";
|
|
15
15
|
import type { Node } from "#node/Node.js";
|
|
16
16
|
import {
|
|
17
|
+
assertRemoteActor,
|
|
17
18
|
CertificateError,
|
|
18
19
|
DeviceCertification,
|
|
19
20
|
DeviceCommissioner,
|
|
@@ -94,13 +95,15 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
override async attestationRequest({ attestationNonce }: OperationalCredentials.AttestationRequest) {
|
|
98
|
+
assertRemoteActor(this.context);
|
|
99
|
+
|
|
97
100
|
if (attestationNonce.byteLength !== 32) {
|
|
98
101
|
throw new StatusResponseError("Invalid attestation nonce length", StatusCode.InvalidCommand);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
const certification = await this.getCertification();
|
|
102
105
|
|
|
103
|
-
const session = this.session;
|
|
106
|
+
const session = this.context.session;
|
|
104
107
|
NodeSession.assert(session);
|
|
105
108
|
|
|
106
109
|
const attestationElements = TlvAttestation.encode({
|
|
@@ -115,11 +118,13 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
override async csrRequest({ csrNonce, isForUpdateNoc }: OperationalCredentials.CsrRequest) {
|
|
121
|
+
assertRemoteActor(this.context);
|
|
122
|
+
|
|
118
123
|
if (csrNonce.byteLength !== 32) {
|
|
119
124
|
throw new StatusResponseError("Invalid csr nonce length", StatusCode.InvalidCommand);
|
|
120
125
|
}
|
|
121
126
|
|
|
122
|
-
const session = this.session;
|
|
127
|
+
const session = this.context.session;
|
|
123
128
|
NodeSession.assert(session);
|
|
124
129
|
if (isForUpdateNoc && session.isPase) {
|
|
125
130
|
throw new StatusResponseError(
|
|
@@ -139,9 +144,10 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
139
144
|
|
|
140
145
|
const certification = await this.getCertification();
|
|
141
146
|
|
|
147
|
+
assertRemoteActor(this.context);
|
|
142
148
|
const certSigningRequest = await failsafeContext.createCertificateSigningRequest(
|
|
143
149
|
isForUpdateNoc ?? false,
|
|
144
|
-
this.session.id,
|
|
150
|
+
this.context.session.id,
|
|
145
151
|
);
|
|
146
152
|
const nocsrElements = TlvCertSigningRequest.encode({ certSigningRequest, csrNonce });
|
|
147
153
|
return { nocsrElements, attestationSignature: await certification.sign(session, nocsrElements) };
|
|
@@ -205,6 +211,8 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
205
211
|
caseAdminSubject,
|
|
206
212
|
adminVendorId,
|
|
207
213
|
}: OperationalCredentials.AddNocRequest) {
|
|
214
|
+
assertRemoteActor(this.context);
|
|
215
|
+
|
|
208
216
|
const failsafeContext = this.#failsafeContext;
|
|
209
217
|
|
|
210
218
|
if (failsafeContext.fabricIndex !== undefined) {
|
|
@@ -221,7 +229,7 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
221
229
|
};
|
|
222
230
|
}
|
|
223
231
|
|
|
224
|
-
if (failsafeContext.csrSessionId !== this.session.id) {
|
|
232
|
+
if (failsafeContext.csrSessionId !== this.context.session.id) {
|
|
225
233
|
return {
|
|
226
234
|
statusCode: OperationalCredentials.NodeOperationalCertStatus.MissingCsr,
|
|
227
235
|
debugText: "CSR not found in failsafe context",
|
|
@@ -261,7 +269,7 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
261
269
|
// subsequent Administer access to an Administrator member of the new Fabric.
|
|
262
270
|
await this.endpoint.act(agent => agent.get(AccessControlServer).addDefaultCaseAcl(fabric, [caseAdminSubject]));
|
|
263
271
|
|
|
264
|
-
const session = this.session;
|
|
272
|
+
const session = this.context.session;
|
|
265
273
|
NodeSession.assert(session);
|
|
266
274
|
|
|
267
275
|
await failsafeContext.addFabric(fabric);
|
|
@@ -302,7 +310,8 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
302
310
|
}
|
|
303
311
|
|
|
304
312
|
override async updateNoc({ nocValue, icacValue }: OperationalCredentials.UpdateNocRequest) {
|
|
305
|
-
|
|
313
|
+
assertRemoteActor(this.context);
|
|
314
|
+
NodeSession.assert(this.context.session);
|
|
306
315
|
|
|
307
316
|
const timedOp = this.#failsafeContext;
|
|
308
317
|
|
|
@@ -338,7 +347,7 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
338
347
|
};
|
|
339
348
|
}
|
|
340
349
|
|
|
341
|
-
if (this.session.associatedFabric.fabricIndex !== timedOp.associatedFabric?.fabricIndex) {
|
|
350
|
+
if (this.context.session.associatedFabric.fabricIndex !== timedOp.associatedFabric?.fabricIndex) {
|
|
342
351
|
throw new StatusResponseError(
|
|
343
352
|
"Fabric of this session and the failsafe context do not match",
|
|
344
353
|
StatusCode.ConstraintError,
|
|
@@ -363,7 +372,8 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
363
372
|
}
|
|
364
373
|
|
|
365
374
|
override async updateFabricLabel({ label }: OperationalCredentials.UpdateFabricLabelRequest) {
|
|
366
|
-
|
|
375
|
+
assertRemoteActor(this.context);
|
|
376
|
+
const fabric = this.context.session.associatedFabric;
|
|
367
377
|
|
|
368
378
|
const currentFabricIndex = fabric.fabricIndex;
|
|
369
379
|
const fabrics = this.env.get(FabricManager);
|
|
@@ -381,6 +391,8 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
381
391
|
}
|
|
382
392
|
|
|
383
393
|
override async removeFabric({ fabricIndex }: OperationalCredentials.RemoveFabricRequest) {
|
|
394
|
+
assertRemoteActor(this.context);
|
|
395
|
+
|
|
384
396
|
const fabric = this.env.get(FabricManager).findByIndex(fabricIndex);
|
|
385
397
|
|
|
386
398
|
if (fabric === undefined) {
|
|
@@ -390,7 +402,7 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
|
|
|
390
402
|
};
|
|
391
403
|
}
|
|
392
404
|
|
|
393
|
-
await fabric.remove(this.session.id);
|
|
405
|
+
await fabric.remove(this.context.session.id);
|
|
394
406
|
// The state is updated on removal via commissionedFabricChanged event, see constructor
|
|
395
407
|
|
|
396
408
|
return {
|
|
@@ -187,7 +187,7 @@ export class WindowCoveringBaseServer extends WindowCoveringBase {
|
|
|
187
187
|
!mode.maintenanceMode || (mode.calibrationMode && !this.internal.supportsCalibration);
|
|
188
188
|
configStatus.liftMovementReversed = !!mode.motorDirectionReversed;
|
|
189
189
|
if (isDeepEqual(configStatus, this.state.configStatus)) {
|
|
190
|
-
this.
|
|
190
|
+
this.agent.asLocalActor(() => {
|
|
191
191
|
this.state.configStatus = configStatus;
|
|
192
192
|
});
|
|
193
193
|
}
|