@matter/node 0.16.0-alpha.0-20250902-38a7cc156 → 0.16.0-alpha.0-20250909-aecad94f3

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.
Files changed (191) hide show
  1. package/dist/cjs/behavior/Behavior.d.ts +0 -18
  2. package/dist/cjs/behavior/Behavior.d.ts.map +1 -1
  3. package/dist/cjs/behavior/Behavior.js +0 -34
  4. package/dist/cjs/behavior/Behavior.js.map +1 -1
  5. package/dist/cjs/behavior/Transitions.js +2 -2
  6. package/dist/cjs/behavior/Transitions.js.map +1 -1
  7. package/dist/cjs/behavior/context/ActionContext.d.ts +4 -29
  8. package/dist/cjs/behavior/context/ActionContext.d.ts.map +1 -1
  9. package/dist/cjs/behavior/context/server/{OfflineContext.d.ts → LocalActorContext.d.ts} +16 -12
  10. package/dist/cjs/behavior/context/server/LocalActorContext.d.ts.map +1 -0
  11. package/dist/cjs/behavior/context/server/{OfflineContext.js → LocalActorContext.js} +10 -9
  12. package/dist/cjs/behavior/context/server/LocalActorContext.js.map +6 -0
  13. package/dist/cjs/behavior/context/server/RemoteActorContext.d.ts +80 -0
  14. package/dist/cjs/behavior/context/server/RemoteActorContext.d.ts.map +1 -0
  15. package/dist/cjs/behavior/context/server/{OnlineContext.js → RemoteActorContext.js} +15 -27
  16. package/dist/cjs/behavior/context/server/RemoteActorContext.js.map +6 -0
  17. package/dist/cjs/behavior/context/server/index.d.ts +2 -2
  18. package/dist/cjs/behavior/context/server/index.d.ts.map +1 -1
  19. package/dist/cjs/behavior/context/server/index.js +2 -2
  20. package/dist/cjs/behavior/context/server/index.js.map +1 -1
  21. package/dist/cjs/behavior/internal/Reactors.d.ts.map +1 -1
  22. package/dist/cjs/behavior/internal/Reactors.js +4 -3
  23. package/dist/cjs/behavior/internal/Reactors.js.map +1 -1
  24. package/dist/cjs/behavior/state/managed/Datasource.d.ts.map +1 -1
  25. package/dist/cjs/behavior/state/managed/Datasource.js +1 -6
  26. package/dist/cjs/behavior/state/managed/Datasource.js.map +1 -1
  27. package/dist/cjs/behavior/state/managed/values/ListManager.d.ts.map +1 -1
  28. package/dist/cjs/behavior/state/managed/values/ListManager.js +4 -4
  29. package/dist/cjs/behavior/state/managed/values/ListManager.js.map +1 -1
  30. package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts +16 -9
  31. package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
  32. package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
  33. package/dist/cjs/behaviors/access-control/AccessControlServer.js +19 -15
  34. package/dist/cjs/behaviors/access-control/AccessControlServer.js.map +1 -1
  35. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
  36. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +5 -5
  37. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
  38. package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.d.ts.map +1 -1
  39. package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.js +6 -6
  40. package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.js.map +1 -1
  41. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  42. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +2 -4
  43. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  44. package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.d.ts.map +1 -1
  45. package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.js +9 -6
  46. package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.js.map +1 -1
  47. package/dist/cjs/behaviors/groups/GroupsServer.d.ts.map +1 -1
  48. package/dist/cjs/behaviors/groups/GroupsServer.js +12 -9
  49. package/dist/cjs/behaviors/groups/GroupsServer.js.map +2 -2
  50. package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.d.ts.map +1 -1
  51. package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.js +16 -9
  52. package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.js.map +1 -1
  53. package/dist/cjs/behaviors/window-covering/WindowCoveringServer.js +1 -1
  54. package/dist/cjs/behaviors/window-covering/WindowCoveringServer.js.map +1 -1
  55. package/dist/cjs/endpoint/Agent.d.ts +14 -0
  56. package/dist/cjs/endpoint/Agent.d.ts.map +1 -1
  57. package/dist/cjs/endpoint/Agent.js +32 -0
  58. package/dist/cjs/endpoint/Agent.js.map +1 -1
  59. package/dist/cjs/endpoint/Endpoint.js +2 -2
  60. package/dist/cjs/endpoint/Endpoint.js.map +1 -1
  61. package/dist/cjs/endpoint/properties/Behaviors.js +4 -4
  62. package/dist/cjs/endpoint/properties/Behaviors.js.map +1 -1
  63. package/dist/cjs/endpoint/properties/Commands.js +2 -2
  64. package/dist/cjs/endpoint/properties/Commands.js.map +1 -1
  65. package/dist/cjs/node/server/IdentityService.js +2 -2
  66. package/dist/cjs/node/server/IdentityService.js.map +1 -1
  67. package/dist/cjs/node/server/InteractionServer.js.map +1 -1
  68. package/dist/cjs/node/server/OnlineServerInteraction.d.ts +6 -6
  69. package/dist/cjs/node/server/OnlineServerInteraction.d.ts.map +1 -1
  70. package/dist/cjs/node/server/OnlineServerInteraction.js +4 -4
  71. package/dist/cjs/node/server/OnlineServerInteraction.js.map +1 -1
  72. package/dist/cjs/node/server/ProtocolService.js +1 -1
  73. package/dist/cjs/node/server/ProtocolService.js.map +1 -1
  74. package/dist/cjs/node/server/ServerSubscription.d.ts +2 -2
  75. package/dist/cjs/node/server/ServerSubscription.d.ts.map +1 -1
  76. package/dist/cjs/node/server/ServerSubscription.js +3 -3
  77. package/dist/cjs/node/server/ServerSubscription.js.map +1 -1
  78. package/dist/esm/behavior/Behavior.d.ts +0 -18
  79. package/dist/esm/behavior/Behavior.d.ts.map +1 -1
  80. package/dist/esm/behavior/Behavior.js +0 -35
  81. package/dist/esm/behavior/Behavior.js.map +1 -1
  82. package/dist/esm/behavior/Transitions.js +2 -2
  83. package/dist/esm/behavior/Transitions.js.map +1 -1
  84. package/dist/esm/behavior/context/ActionContext.d.ts +4 -29
  85. package/dist/esm/behavior/context/ActionContext.d.ts.map +1 -1
  86. package/dist/esm/behavior/context/server/{OfflineContext.d.ts → LocalActorContext.d.ts} +16 -12
  87. package/dist/esm/behavior/context/server/LocalActorContext.d.ts.map +1 -0
  88. package/dist/esm/behavior/context/server/{OfflineContext.js → LocalActorContext.js} +7 -6
  89. package/dist/esm/behavior/context/server/LocalActorContext.js.map +6 -0
  90. package/dist/esm/behavior/context/server/RemoteActorContext.d.ts +80 -0
  91. package/dist/esm/behavior/context/server/RemoteActorContext.d.ts.map +1 -0
  92. package/dist/esm/behavior/context/server/{OnlineContext.js → RemoteActorContext.js} +14 -31
  93. package/dist/esm/behavior/context/server/RemoteActorContext.js.map +6 -0
  94. package/dist/esm/behavior/context/server/index.d.ts +2 -2
  95. package/dist/esm/behavior/context/server/index.d.ts.map +1 -1
  96. package/dist/esm/behavior/context/server/index.js +2 -2
  97. package/dist/esm/behavior/internal/Reactors.d.ts.map +1 -1
  98. package/dist/esm/behavior/internal/Reactors.js +4 -3
  99. package/dist/esm/behavior/internal/Reactors.js.map +1 -1
  100. package/dist/esm/behavior/state/managed/Datasource.d.ts.map +1 -1
  101. package/dist/esm/behavior/state/managed/Datasource.js +2 -7
  102. package/dist/esm/behavior/state/managed/Datasource.js.map +1 -1
  103. package/dist/esm/behavior/state/managed/values/ListManager.d.ts.map +1 -1
  104. package/dist/esm/behavior/state/managed/values/ListManager.js +13 -5
  105. package/dist/esm/behavior/state/managed/values/ListManager.js.map +1 -1
  106. package/dist/esm/behavior/supervision/ValueSupervisor.d.ts +16 -9
  107. package/dist/esm/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
  108. package/dist/esm/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
  109. package/dist/esm/behaviors/access-control/AccessControlServer.js +21 -15
  110. package/dist/esm/behaviors/access-control/AccessControlServer.js.map +1 -1
  111. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
  112. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +13 -6
  113. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
  114. package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.d.ts.map +1 -1
  115. package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.js +15 -7
  116. package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.js.map +1 -1
  117. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  118. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +3 -5
  119. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  120. package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.d.ts.map +1 -1
  121. package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.js +10 -7
  122. package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.js.map +1 -1
  123. package/dist/esm/behaviors/groups/GroupsServer.d.ts.map +1 -1
  124. package/dist/esm/behaviors/groups/GroupsServer.js +12 -9
  125. package/dist/esm/behaviors/groups/GroupsServer.js.map +2 -2
  126. package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.d.ts.map +1 -1
  127. package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.js +17 -9
  128. package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.js.map +1 -1
  129. package/dist/esm/behaviors/window-covering/WindowCoveringServer.js +1 -1
  130. package/dist/esm/behaviors/window-covering/WindowCoveringServer.js.map +1 -1
  131. package/dist/esm/endpoint/Agent.d.ts +14 -0
  132. package/dist/esm/endpoint/Agent.d.ts.map +1 -1
  133. package/dist/esm/endpoint/Agent.js +32 -0
  134. package/dist/esm/endpoint/Agent.js.map +1 -1
  135. package/dist/esm/endpoint/Endpoint.js +2 -2
  136. package/dist/esm/endpoint/Endpoint.js.map +1 -1
  137. package/dist/esm/endpoint/properties/Behaviors.js +4 -4
  138. package/dist/esm/endpoint/properties/Behaviors.js.map +1 -1
  139. package/dist/esm/endpoint/properties/Commands.js +2 -2
  140. package/dist/esm/endpoint/properties/Commands.js.map +1 -1
  141. package/dist/esm/node/server/IdentityService.js +2 -2
  142. package/dist/esm/node/server/IdentityService.js.map +1 -1
  143. package/dist/esm/node/server/InteractionServer.js.map +1 -1
  144. package/dist/esm/node/server/OnlineServerInteraction.d.ts +6 -6
  145. package/dist/esm/node/server/OnlineServerInteraction.d.ts.map +1 -1
  146. package/dist/esm/node/server/OnlineServerInteraction.js +4 -4
  147. package/dist/esm/node/server/OnlineServerInteraction.js.map +1 -1
  148. package/dist/esm/node/server/ProtocolService.js +2 -2
  149. package/dist/esm/node/server/ProtocolService.js.map +1 -1
  150. package/dist/esm/node/server/ServerSubscription.d.ts +2 -2
  151. package/dist/esm/node/server/ServerSubscription.d.ts.map +1 -1
  152. package/dist/esm/node/server/ServerSubscription.js +3 -3
  153. package/dist/esm/node/server/ServerSubscription.js.map +1 -1
  154. package/package.json +7 -7
  155. package/src/behavior/Behavior.ts +0 -41
  156. package/src/behavior/Transitions.ts +2 -2
  157. package/src/behavior/context/ActionContext.ts +4 -35
  158. package/src/behavior/context/server/{OfflineContext.ts → LocalActorContext.ts} +17 -14
  159. package/src/behavior/context/server/{OnlineContext.ts → RemoteActorContext.ts} +65 -52
  160. package/src/behavior/context/server/index.ts +2 -2
  161. package/src/behavior/internal/Reactors.ts +5 -4
  162. package/src/behavior/state/managed/Datasource.ts +3 -9
  163. package/src/behavior/state/managed/values/ListManager.ts +14 -11
  164. package/src/behavior/supervision/ValueSupervisor.ts +18 -10
  165. package/src/behaviors/access-control/AccessControlServer.ts +25 -20
  166. package/src/behaviors/administrator-commissioning/AdministratorCommissioningServer.ts +14 -6
  167. package/src/behaviors/general-commissioning/GeneralCommissioningServer.ts +15 -8
  168. package/src/behaviors/general-diagnostics/GeneralDiagnosticsServer.ts +3 -5
  169. package/src/behaviors/group-key-management/GroupKeyManagementServer.ts +13 -7
  170. package/src/behaviors/groups/GroupsServer.ts +16 -11
  171. package/src/behaviors/operational-credentials/OperationalCredentialsServer.ts +21 -9
  172. package/src/behaviors/window-covering/WindowCoveringServer.ts +1 -1
  173. package/src/endpoint/Agent.ts +34 -0
  174. package/src/endpoint/Endpoint.ts +2 -2
  175. package/src/endpoint/properties/Behaviors.ts +4 -4
  176. package/src/endpoint/properties/Commands.ts +2 -2
  177. package/src/node/server/IdentityService.ts +2 -2
  178. package/src/node/server/InteractionServer.ts +2 -2
  179. package/src/node/server/OnlineServerInteraction.ts +9 -9
  180. package/src/node/server/ProtocolService.ts +2 -2
  181. package/src/node/server/ServerSubscription.ts +5 -5
  182. package/dist/cjs/behavior/context/server/OfflineContext.d.ts.map +0 -1
  183. package/dist/cjs/behavior/context/server/OfflineContext.js.map +0 -6
  184. package/dist/cjs/behavior/context/server/OnlineContext.d.ts +0 -61
  185. package/dist/cjs/behavior/context/server/OnlineContext.d.ts.map +0 -1
  186. package/dist/cjs/behavior/context/server/OnlineContext.js.map +0 -6
  187. package/dist/esm/behavior/context/server/OfflineContext.d.ts.map +0 -1
  188. package/dist/esm/behavior/context/server/OfflineContext.js.map +0 -6
  189. package/dist/esm/behavior/context/server/OnlineContext.d.ts +0 -61
  190. package/dist/esm/behavior/context/server/OnlineContext.d.ts.map +0 -1
  191. package/dist/esm/behavior/context/server/OnlineContext.js.map +0 -6
@@ -16,9 +16,8 @@ import {
16
16
  Observable,
17
17
  Transaction,
18
18
  } from "#general";
19
- import { AccessLevel } from "#model";
20
19
  import type { Val } from "#protocol";
21
- import { AccessControl, ExpiredReferenceError } from "#protocol";
20
+ import { AccessControl, ExpiredReferenceError, hasRemoteActor } from "#protocol";
22
21
  import { RootSupervisor } from "../../supervision/RootSupervisor.js";
23
22
  import { ValueSupervisor } from "../../supervision/ValueSupervisor.js";
24
23
  import { StateType } from "../StateType.js";
@@ -125,12 +124,6 @@ export function Datasource<const T extends StateType = StateType>(options: Datas
125
124
  get view() {
126
125
  if (!readOnlyView) {
127
126
  const session: ValueSupervisor.Session = {
128
- offline: true,
129
- authorityAt(desiredAccessLevel: AccessLevel) {
130
- return desiredAccessLevel === AccessLevel.View
131
- ? AccessControl.Authority.Granted
132
- : AccessControl.Authority.Unauthorized;
133
- },
134
127
  transaction: viewTx,
135
128
  };
136
129
  readOnlyView = createReference(this, internals, session).managed as InstanceType<T>;
@@ -281,7 +274,7 @@ interface Internals extends Datasource.Options {
281
274
  primaryKey: "name" | "id";
282
275
  sessions?: Map<ValueSupervisor.Session, SessionContext>;
283
276
  featuresKey?: string;
284
- interactionObserver(session?: AccessControl.Session): MaybePromise<void>;
277
+ interactionObserver(session?: ValueSupervisor.Session): MaybePromise<void>;
285
278
  events: Datasource.InternalEvents;
286
279
  changedEventFor(key: string): undefined | Datasource.Events[any];
287
280
  persistentFields: Set<string>;
@@ -635,6 +628,7 @@ function createReference(resource: Transaction.Resource, internals: Internals, s
635
628
  transaction.beginSync();
636
629
 
637
630
  if (
631
+ hasRemoteActor(session) &&
638
632
  !session.interactionStarted &&
639
633
  session.interactionComplete &&
640
634
  !session.interactionComplete.isObservedBy(internals.interactionObserver)
@@ -7,7 +7,16 @@
7
7
  import { isObject, serialize } from "#general";
8
8
  import type { Schema } from "#model";
9
9
  import { Access, DataModelPath, ValueModel } from "#model";
10
- import { AccessControl, ExpiredReferenceError, ReadError, SchemaImplementationError, Val, WriteError } from "#protocol";
10
+ import {
11
+ AccessControl,
12
+ ExpiredReferenceError,
13
+ hasLocalActor,
14
+ hasRemoteActor,
15
+ ReadError,
16
+ SchemaImplementationError,
17
+ Val,
18
+ WriteError,
19
+ } from "#protocol";
11
20
  import { StatusCode } from "#types";
12
21
  import type { RootSupervisor } from "../../../supervision/RootSupervisor.js";
13
22
  import type { ValueSupervisor } from "../../../supervision/ValueSupervisor.js";
@@ -206,7 +215,7 @@ function createProxy(config: ListConfig, reference: Val.Reference<Val.List>, ses
206
215
  }
207
216
 
208
217
  // If there's no fabric index or it's a match, consider "in scope"
209
- if (session.offline || !entry.fabricIndex || entry.fabricIndex === session.fabric) {
218
+ if (hasLocalActor(session) || !entry.fabricIndex || entry.fabricIndex === session.fabric) {
210
219
  if (nextPos === index) {
211
220
  // Found our target
212
221
  return i;
@@ -229,7 +238,7 @@ function createProxy(config: ListConfig, reference: Val.Reference<Val.List>, ses
229
238
  throw new WriteError(reference.location, `Index ${index} would leave gaps in fabric-filtered list`);
230
239
  }
231
240
 
232
- if (session.fabricFiltered || config.fabricSensitive) {
241
+ if (hasRemoteActor(session) && (session.fabricFiltered || config.fabricSensitive)) {
233
242
  const nextReadEntry = readEntry;
234
243
 
235
244
  hasEntry = (index: number) => {
@@ -262,10 +271,7 @@ function createProxy(config: ListConfig, reference: Val.Reference<Val.List>, ses
262
271
  let length = 0;
263
272
  for (let i = 0; i < readVal().length; i++) {
264
273
  const entry = readVal()[i] as undefined | { fabricIndex?: number };
265
- if (
266
- isObject(entry) &&
267
- (session.offline || !entry.fabricIndex || entry.fabricIndex === session.fabric)
268
- ) {
274
+ if (isObject(entry) && (!entry.fabricIndex || entry.fabricIndex === session.fabric)) {
269
275
  length++;
270
276
  }
271
277
  }
@@ -278,10 +284,7 @@ function createProxy(config: ListConfig, reference: Val.Reference<Val.List>, ses
278
284
  reference.change(() => {
279
285
  for (let i = formerLength - 1; i >= length; i--) {
280
286
  const entry = writeVal()[mapScopedToActual(i, true)] as undefined | { fabricIndex?: number };
281
- if (
282
- isObject(entry) &&
283
- (session.offline || !entry.fabricIndex || entry.fabricIndex === session.fabric)
284
- ) {
287
+ if (isObject(entry) && (!entry.fabricIndex || entry.fabricIndex === session.fabric)) {
285
288
  writeVal().splice(mapScopedToActual(i, false), 1);
286
289
  } else if (entry !== undefined) {
287
290
  throw new WriteError(
@@ -4,7 +4,6 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { ActionContext } from "#behavior/context/ActionContext.js";
8
7
  import type { AsyncObservable, Transaction } from "#general";
9
8
  import { DataModelPath, Schema } from "#model";
10
9
  import type { AccessControl, Val } from "#protocol";
@@ -67,9 +66,9 @@ export interface ValueSupervisor {
67
66
 
68
67
  export namespace ValueSupervisor {
69
68
  /**
70
- * Session information required for value management.
69
+ * {@link Session} values that control supervision.
71
70
  */
72
- export interface Session extends AccessControl.Session {
71
+ export interface SupervisionSettings {
73
72
  /**
74
73
  * The transaction used for isolating state changes associated with this session.
75
74
  */
@@ -82,22 +81,31 @@ export namespace ValueSupervisor {
82
81
  acceptInvalid?: boolean;
83
82
 
84
83
  /**
85
- * If present the session is associated with an online interaction. Emits when the interaction ends.
84
+ * If true, structs initialize without named properties which are more expensive to install. This is useful
85
+ * when implementing the Matter protocol where ID is the only value necessary.
86
86
  */
87
- interactionComplete?: AsyncObservable<[session?: ActionContext]>;
87
+ protocol?: boolean;
88
+ }
88
89
 
90
+ /**
91
+ * {@link Session} information that enforces stricter controls based on an authenticated remote subject.
92
+ */
93
+ export interface RemoteActorSession extends AccessControl.RemoteActorSession, SupervisionSettings {
89
94
  /**
90
- * Set to true when the interaction has started and the interactionBegin event was emitted for this session
95
+ * If present the session is associated with an online interaction. Emits when the interaction ends.
91
96
  */
92
- interactionStarted?: boolean;
97
+ interactionComplete?: AsyncObservable<[session?: RemoteActorSession]>;
93
98
 
94
99
  /**
95
- * If true, structs initialize without named properties which are more expensive to install. This is useful
96
- * when implementing the Matter protocol where ID is the only value necessary.
100
+ * Set to true when the interaction has started and the interactionBegin event was emitted for this session
97
101
  */
98
- protocol?: boolean;
102
+ interactionStarted?: boolean;
99
103
  }
100
104
 
105
+ export interface LocalActorSession extends AccessControl.LocalActorSession, SupervisionSettings {}
106
+
107
+ export type Session = LocalActorSession | RemoteActorSession;
108
+
101
109
  export type Validate = (value: Val, session: Session, location: ValidationLocation) => void;
102
110
 
103
111
  export type Manage = (reference: Val.Reference, session: Session) => Val;
@@ -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.acl.aclList = fabricAcls;
95
- fabric.acl.extensionEntryAccessCheck = this.extensionEntryAccessCheck.bind(this);
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
- // TODO: This might be not really correct for local ACL changes because there the session fabric could be
140
- // different which would lead to missing validation of the relevant entries
141
- const relevantFabricIndex = this.context.session?.associatedFabric.fabricIndex;
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
- const { session } = this.context;
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
- // TODO: This might be not really correct for local ACL changes because there the session fabric could be
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
- const { session } = this.context;
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.acl.aclList = deepCopy(this.state.acl).filter(entry => entry.fabricIndex === fabricIndex);
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 !== undefined && !session.offline && session.fabric !== undefined) {
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 !== undefined && !session.offline && session.fabric !== undefined) {
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 === undefined || context.offline) {
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.acl.aclList = deepCopy(acl).filter(entry => entry.fabricIndex === fabricIndex);
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.acl.aclList = aclsForFabric.get(fabric.fabricIndex) ?? [];
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).acl.aclList = delayedData;
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 { DeviceCommissioner, FailsafeContext, PaseServer, SessionManager } from "#protocol";
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
- logger.debug(
159
- `Commissioning window timer started for ${commissioningTimeout} seconds for ${this.context.session?.name}.`,
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
- const adminFabric = this.session.associatedFabric;
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 { DeviceCommissioner, FabricManager, GroupSession, NodeSession, SecureSession, SessionManager } from "#protocol";
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
- return this.#armFailSafe(request, this.session);
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
- // Regulatory config is not fabric-writable so requires elevated privileges
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
- const session = this.session;
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 = this.session.associatedFabric;
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
- const exchange = this.context.exchange;
177
- if (exchange === undefined) {
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, SecureSession } from "#protocol";
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 && !context?.offline) {
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
- SecureSession.assert(this.session);
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
- const fabric = this.session.associatedFabric;
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
- const fabric = this.session.associatedFabric;
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
- const fabric = this.session.associatedFabric;
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>(act: (groupKeyManagement: GroupKeyManagementServer) => T): Promise<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
- const fabric = this.session.associatedFabric;
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
- const fabric = this.session.associatedFabric;
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
- const fabric = this.session.associatedFabric;
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(this.session.associatedFabric, this.endpoint.number, groupId),
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;