@project-chip/matter.js 0.13.1-alpha.0-20250520-d699cd56d → 0.14.0-alpha.0-20250524-51a7e1721

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 (105) hide show
  1. package/dist/cjs/CommissioningController.d.ts.map +1 -1
  2. package/dist/cjs/CommissioningController.js +18 -5
  3. package/dist/cjs/CommissioningController.js.map +1 -1
  4. package/dist/cjs/cluster/export.d.ts +1 -2
  5. package/dist/cjs/cluster/export.d.ts.map +1 -1
  6. package/dist/cjs/cluster/export.js +1 -2
  7. package/dist/cjs/cluster/export.js.map +1 -1
  8. package/dist/cjs/cluster/server/AttributeServer.d.ts +298 -0
  9. package/dist/cjs/cluster/server/AttributeServer.d.ts.map +1 -0
  10. package/dist/cjs/cluster/server/AttributeServer.js +652 -0
  11. package/dist/cjs/cluster/server/AttributeServer.js.map +6 -0
  12. package/dist/cjs/cluster/server/ClusterDatasource.d.ts +15 -0
  13. package/dist/cjs/cluster/server/ClusterDatasource.d.ts.map +1 -0
  14. package/dist/cjs/cluster/server/ClusterDatasource.js +22 -0
  15. package/dist/cjs/cluster/server/ClusterDatasource.js.map +6 -0
  16. package/dist/cjs/cluster/server/ClusterServer.d.ts +2 -2
  17. package/dist/cjs/cluster/server/ClusterServer.d.ts.map +1 -1
  18. package/dist/cjs/cluster/server/ClusterServer.js +6 -4
  19. package/dist/cjs/cluster/server/ClusterServer.js.map +1 -1
  20. package/dist/cjs/cluster/server/ClusterServerTypes.d.ts +4 -1
  21. package/dist/cjs/cluster/server/ClusterServerTypes.d.ts.map +1 -1
  22. package/dist/cjs/cluster/server/ClusterServerTypes.js.map +1 -1
  23. package/dist/cjs/cluster/server/CommandServer.d.ts +33 -0
  24. package/dist/cjs/cluster/server/CommandServer.d.ts.map +1 -0
  25. package/dist/cjs/cluster/server/CommandServer.js +76 -0
  26. package/dist/cjs/cluster/server/CommandServer.js.map +6 -0
  27. package/dist/cjs/cluster/server/EventServer.d.ts +39 -0
  28. package/dist/cjs/cluster/server/EventServer.d.ts.map +1 -0
  29. package/dist/cjs/cluster/server/EventServer.js +152 -0
  30. package/dist/cjs/cluster/server/EventServer.js.map +6 -0
  31. package/dist/cjs/cluster/server/index.d.ts +11 -0
  32. package/dist/cjs/cluster/server/index.d.ts.map +1 -0
  33. package/dist/cjs/cluster/server/index.js +28 -0
  34. package/dist/cjs/cluster/server/index.js.map +6 -0
  35. package/dist/cjs/device/Endpoint.d.ts +9 -5
  36. package/dist/cjs/device/Endpoint.d.ts.map +1 -1
  37. package/dist/cjs/device/Endpoint.js +115 -29
  38. package/dist/cjs/device/Endpoint.js.map +1 -1
  39. package/dist/cjs/device/PairedNode.d.ts +5 -4
  40. package/dist/cjs/device/PairedNode.d.ts.map +1 -1
  41. package/dist/cjs/device/PairedNode.js +26 -3
  42. package/dist/cjs/device/PairedNode.js.map +1 -1
  43. package/dist/cjs/device/export.d.ts +0 -1
  44. package/dist/cjs/device/export.d.ts.map +1 -1
  45. package/dist/cjs/device/export.js +0 -8
  46. package/dist/cjs/device/export.js.map +1 -1
  47. package/dist/esm/CommissioningController.d.ts.map +1 -1
  48. package/dist/esm/CommissioningController.js +18 -5
  49. package/dist/esm/CommissioningController.js.map +1 -1
  50. package/dist/esm/cluster/export.d.ts +1 -2
  51. package/dist/esm/cluster/export.d.ts.map +1 -1
  52. package/dist/esm/cluster/export.js +1 -2
  53. package/dist/esm/cluster/export.js.map +1 -1
  54. package/dist/esm/cluster/server/AttributeServer.d.ts +298 -0
  55. package/dist/esm/cluster/server/AttributeServer.d.ts.map +1 -0
  56. package/dist/esm/cluster/server/AttributeServer.js +636 -0
  57. package/dist/esm/cluster/server/AttributeServer.js.map +6 -0
  58. package/dist/esm/cluster/server/ClusterDatasource.d.ts +15 -0
  59. package/dist/esm/cluster/server/ClusterDatasource.d.ts.map +1 -0
  60. package/dist/esm/cluster/server/ClusterDatasource.js +6 -0
  61. package/dist/esm/cluster/server/ClusterDatasource.js.map +6 -0
  62. package/dist/esm/cluster/server/ClusterServer.d.ts +2 -2
  63. package/dist/esm/cluster/server/ClusterServer.d.ts.map +1 -1
  64. package/dist/esm/cluster/server/ClusterServer.js +3 -5
  65. package/dist/esm/cluster/server/ClusterServer.js.map +1 -1
  66. package/dist/esm/cluster/server/ClusterServerTypes.d.ts +4 -1
  67. package/dist/esm/cluster/server/ClusterServerTypes.d.ts.map +1 -1
  68. package/dist/esm/cluster/server/ClusterServerTypes.js.map +1 -1
  69. package/dist/esm/cluster/server/CommandServer.d.ts +33 -0
  70. package/dist/esm/cluster/server/CommandServer.d.ts.map +1 -0
  71. package/dist/esm/cluster/server/CommandServer.js +56 -0
  72. package/dist/esm/cluster/server/CommandServer.js.map +6 -0
  73. package/dist/esm/cluster/server/EventServer.d.ts +39 -0
  74. package/dist/esm/cluster/server/EventServer.d.ts.map +1 -0
  75. package/dist/esm/cluster/server/EventServer.js +141 -0
  76. package/dist/esm/cluster/server/EventServer.js.map +6 -0
  77. package/dist/esm/cluster/server/index.d.ts +11 -0
  78. package/dist/esm/cluster/server/index.d.ts.map +1 -0
  79. package/dist/esm/cluster/server/index.js +11 -0
  80. package/dist/esm/cluster/server/index.js.map +6 -0
  81. package/dist/esm/device/Endpoint.d.ts +9 -5
  82. package/dist/esm/device/Endpoint.d.ts.map +1 -1
  83. package/dist/esm/device/Endpoint.js +116 -31
  84. package/dist/esm/device/Endpoint.js.map +1 -1
  85. package/dist/esm/device/PairedNode.d.ts +5 -4
  86. package/dist/esm/device/PairedNode.d.ts.map +1 -1
  87. package/dist/esm/device/PairedNode.js +26 -4
  88. package/dist/esm/device/PairedNode.js.map +1 -1
  89. package/dist/esm/device/export.d.ts +0 -1
  90. package/dist/esm/device/export.d.ts.map +1 -1
  91. package/dist/esm/device/export.js +0 -4
  92. package/dist/esm/device/export.js.map +1 -1
  93. package/package.json +8 -8
  94. package/src/CommissioningController.ts +24 -6
  95. package/src/cluster/export.ts +1 -2
  96. package/src/cluster/server/AttributeServer.ts +867 -0
  97. package/src/cluster/server/ClusterDatasource.ts +16 -0
  98. package/src/cluster/server/ClusterServer.ts +6 -9
  99. package/src/cluster/server/ClusterServerTypes.ts +4 -11
  100. package/src/cluster/server/CommandServer.ts +87 -0
  101. package/src/cluster/server/EventServer.ts +198 -0
  102. package/src/cluster/server/index.ts +11 -0
  103. package/src/device/Endpoint.ts +135 -39
  104. package/src/device/PairedNode.ts +30 -7
  105. package/src/device/export.ts +0 -3
@@ -0,0 +1,636 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Diagnostic, ImplementationError, InternalError, Logger, MatterError, camelize, isDeepEqual } from "#general";
7
+ import { AccessLevel, AttributeModel, ClusterModel, DatatypeModel, FabricIndex, MatterModel } from "#model";
8
+ import { NoAssociatedFabricError, assertSecureSession } from "#protocol";
9
+ import {
10
+ StatusCode,
11
+ StatusResponseError,
12
+ ValidationError
13
+ } from "#types";
14
+ const logger = Logger.get("AttributeServer");
15
+ const FabricIndexName = camelize(FabricIndex.name);
16
+ class FabricScopeError extends MatterError {
17
+ }
18
+ function createAttributeServer(clusterDef, attributeDef, attributeName, initValue, datasource, getter, setter, validator) {
19
+ const {
20
+ id,
21
+ schema,
22
+ writable,
23
+ fabricScoped,
24
+ fixed,
25
+ omitChanges,
26
+ timed,
27
+ default: defaultValue,
28
+ readAcl,
29
+ writeAcl
30
+ } = attributeDef;
31
+ if (fixed) {
32
+ return new FixedAttributeServer(
33
+ id,
34
+ attributeName,
35
+ readAcl,
36
+ writeAcl,
37
+ schema,
38
+ writable,
39
+ false,
40
+ timed,
41
+ initValue,
42
+ defaultValue,
43
+ datasource,
44
+ getter
45
+ );
46
+ }
47
+ if (fabricScoped) {
48
+ return new FabricScopedAttributeServer(
49
+ id,
50
+ attributeName,
51
+ readAcl,
52
+ writeAcl,
53
+ schema,
54
+ writable,
55
+ !omitChanges,
56
+ timed,
57
+ initValue,
58
+ defaultValue,
59
+ clusterDef,
60
+ datasource,
61
+ getter,
62
+ setter,
63
+ validator
64
+ );
65
+ }
66
+ return new AttributeServer(
67
+ id,
68
+ attributeName,
69
+ readAcl,
70
+ writeAcl,
71
+ schema,
72
+ writable,
73
+ !omitChanges,
74
+ timed,
75
+ initValue,
76
+ defaultValue,
77
+ datasource,
78
+ getter,
79
+ setter,
80
+ validator
81
+ );
82
+ }
83
+ class BaseAttributeServer {
84
+ constructor(id, name, readAcl, writeAcl, schema, isWritable, isSubscribable, requiresTimedInteraction, initValue, defaultValue) {
85
+ this.id = id;
86
+ this.name = name;
87
+ this.schema = schema;
88
+ this.isWritable = isWritable;
89
+ this.isSubscribable = isSubscribable;
90
+ this.requiresTimedInteraction = requiresTimedInteraction;
91
+ this.#readAcl = readAcl;
92
+ this.#writeAcl = writeAcl;
93
+ try {
94
+ this.validateWithSchema(initValue);
95
+ this.value = initValue;
96
+ } catch (error) {
97
+ logger.warn(
98
+ `Attribute value to initialize for ${name} has an invalid value ${Diagnostic.json(
99
+ initValue
100
+ )}. Restore to default ${Diagnostic.json(defaultValue)}`
101
+ );
102
+ if (defaultValue === void 0) {
103
+ throw new ImplementationError(`Attribute value to initialize for ${name} cannot be undefined.`);
104
+ }
105
+ this.validateWithSchema(defaultValue);
106
+ this.value = defaultValue;
107
+ }
108
+ this.defaultValue = this.value;
109
+ }
110
+ /**
111
+ * The value is undefined when getter/setter are used. But we still handle the version number here.
112
+ */
113
+ value = void 0;
114
+ endpoint;
115
+ defaultValue;
116
+ #readAcl;
117
+ #writeAcl;
118
+ get hasFabricSensitiveData() {
119
+ return false;
120
+ }
121
+ validateWithSchema(value) {
122
+ try {
123
+ this.schema.validate(value);
124
+ } catch (e) {
125
+ ValidationError.accept(e);
126
+ e.message = `Validation error for attribute "${this.name}"${e.fieldName !== void 0 ? ` in field ${e.fieldName}` : ""}: ${e.message}`;
127
+ throw e;
128
+ }
129
+ }
130
+ assignToEndpoint(endpoint) {
131
+ this.endpoint = endpoint;
132
+ }
133
+ get writeAcl() {
134
+ return this.#writeAcl ?? AccessLevel.Operate;
135
+ }
136
+ get readAcl() {
137
+ return this.#readAcl ?? AccessLevel.View;
138
+ }
139
+ }
140
+ class FixedAttributeServer extends BaseAttributeServer {
141
+ constructor(id, name, readAcl, writeAcl, schema, isWritable, isSubscribable, requiresTimedInteraction, initValue, defaultValue, datasource, getter) {
142
+ super(
143
+ id,
144
+ name,
145
+ readAcl,
146
+ writeAcl,
147
+ schema,
148
+ isWritable,
149
+ isSubscribable,
150
+ requiresTimedInteraction,
151
+ initValue,
152
+ defaultValue
153
+ );
154
+ this.datasource = datasource;
155
+ if (getter === void 0) {
156
+ this.getter = () => {
157
+ if (this.value === void 0) {
158
+ throw new InternalError(`Attribute value for attribute "${name}" is not initialized.`);
159
+ }
160
+ return this.value;
161
+ };
162
+ } else {
163
+ this.getter = getter;
164
+ }
165
+ }
166
+ isFixed = true;
167
+ getter;
168
+ /**
169
+ * Get the value of the attribute. This method is used by the Interaction model to read the value of the attribute
170
+ * and includes the ACL check. It should not be used locally in the code!
171
+ *
172
+ * If a getter is defined the value is determined by that getter method.
173
+ */
174
+ get(session, isFabricFiltered, message) {
175
+ return this.getter(session, this.endpoint, isFabricFiltered, message);
176
+ }
177
+ /**
178
+ * Get the value of the attribute including the version number. This method is used by the Interaction model to read
179
+ * the value of the attribute and includes the ACL check. It should not be used locally in the code!
180
+ *
181
+ * If a getter is defined the value is determined by that getter method. The version number is always 0 for fixed
182
+ * attributes.
183
+ */
184
+ getWithVersion(session, isFabricFiltered, message) {
185
+ return { version: this.datasource.version, value: this.get(session, isFabricFiltered, message) };
186
+ }
187
+ /**
188
+ * Get the value of the attribute locally. This method should be used locally in the code and does not include the
189
+ * ACL check.
190
+ * If a getter is defined the value is determined by that getter method.
191
+ */
192
+ getLocal() {
193
+ return this.getter(void 0, this.endpoint);
194
+ }
195
+ /**
196
+ * Initialize the value of the attribute, used when a persisted value is set initially or when values needs to be
197
+ * adjusted before the Device gets announced. Do not use this method to change values when the device is in use!
198
+ * If a getter or setter is defined the value must be undefined The version number must also be undefined.
199
+ */
200
+ init(value) {
201
+ if (value === void 0) {
202
+ throw new InternalError(`Cannot initialize fixed attribute "${this.name}" with undefined value.`);
203
+ }
204
+ this.validateWithSchema(value);
205
+ this.value = value;
206
+ }
207
+ /**
208
+ * Add an internal listener that is called when the value of the attribute changes. The listener is called with the
209
+ * new value and the version number.
210
+ */
211
+ addValueChangeListener(_listener) {
212
+ }
213
+ /**
214
+ * Remove an internal listener.
215
+ */
216
+ removeValueChangeListener(_listener) {
217
+ }
218
+ /**
219
+ * Add an external listener that is called when the value of the attribute changes. The listener is called with the
220
+ * new value and the old value.
221
+ */
222
+ addValueSetListener(_listener) {
223
+ }
224
+ /**
225
+ * Add an external listener that is called when the value of the attribute changes. The listener is called with the
226
+ * new value and the old value. This method is a convenient alias for addValueSetListener.
227
+ */
228
+ subscribe(_listener) {
229
+ }
230
+ /**
231
+ * Remove an external listener.
232
+ */
233
+ removeValueSetListener(_listener) {
234
+ }
235
+ }
236
+ class AttributeServer extends FixedAttributeServer {
237
+ isFixed = false;
238
+ valueChangeListeners = new Array();
239
+ valueSetListeners = new Array();
240
+ setter;
241
+ validator;
242
+ delayedChangeData = void 0;
243
+ constructor(id, name, readAcl, writeAcl, schema, isWritable, isSubscribable, requiresTimedInteraction, initValue, defaultValue, datasource, getter, setter, validator) {
244
+ if (isWritable && (getter === void 0 || setter === void 0) && !(getter === void 0 && setter === void 0)) {
245
+ throw new ImplementationError(
246
+ `Getter and setter must be implemented together for writeable attribute "${name}".`
247
+ );
248
+ }
249
+ super(
250
+ id,
251
+ name,
252
+ readAcl,
253
+ writeAcl,
254
+ schema,
255
+ isWritable,
256
+ isSubscribable,
257
+ requiresTimedInteraction,
258
+ initValue,
259
+ defaultValue,
260
+ datasource,
261
+ getter
262
+ );
263
+ if (setter === void 0) {
264
+ this.setter = (value) => {
265
+ const oldValue = this.value;
266
+ this.value = value;
267
+ return !isDeepEqual(value, oldValue);
268
+ };
269
+ } else {
270
+ this.setter = setter;
271
+ }
272
+ this.validator = (value, session, endpoint) => {
273
+ this.validateWithSchema(value);
274
+ if (validator !== void 0) {
275
+ validator(value, session, endpoint);
276
+ }
277
+ };
278
+ }
279
+ /**
280
+ * Initialize the value of the attribute, used when a persisted value is set initially or when values needs to be
281
+ * adjusted before the Device gets announced. Do not use this method to change values when the device is in use!
282
+ */
283
+ init(value) {
284
+ if (value === void 0) {
285
+ value = this.getter(void 0, this.endpoint);
286
+ }
287
+ if (value === void 0) {
288
+ throw new InternalError(`Cannot initialize attribute "${this.name}" with undefined value.`);
289
+ }
290
+ this.validator(value, void 0, this.endpoint);
291
+ this.value = value;
292
+ }
293
+ /**
294
+ * Set the value of the attribute. This method is used by the Interaction model to write the value of the attribute
295
+ * and includes the ACL check. It should not be used locally in the code!
296
+ *
297
+ * If a setter is defined this setter method is called to store the value.
298
+ *
299
+ * Listeners are called when the value changes (internal listeners) or in any case (external listeners).
300
+ */
301
+ set(value, session, message, delayChangeEvents = false) {
302
+ if (!this.isWritable) {
303
+ throw new StatusResponseError(`Attribute "${this.name}" is not writable.`, StatusCode.UnsupportedWrite);
304
+ }
305
+ this.setRemote(value, session, message, delayChangeEvents);
306
+ }
307
+ /**
308
+ * Method that contains the logic to set a value "from remote" (e.g. from a client).
309
+ */
310
+ setRemote(value, session, message, delayChangeEvents = false) {
311
+ this.processSet(value, session, message, delayChangeEvents);
312
+ this.value = value;
313
+ }
314
+ /**
315
+ * Set the value of the attribute locally. This method should be used locally in the code and does not include the
316
+ * ACL check.
317
+ *
318
+ * If a setter is defined this setter method is called to validate and store the value.
319
+ *
320
+ * Else if a validator is defined the value is validated before it is stored.
321
+ *
322
+ * Listeners are called when the value changes (internal listeners) or in any case (external listeners).
323
+ */
324
+ setLocal(value) {
325
+ this.processSet(value, void 0);
326
+ this.value = value;
327
+ }
328
+ /**
329
+ * Helper Method to process the set of a value in a generic way. This method is used internally.
330
+ */
331
+ processSet(value, session, message, delayChangeEvents = false) {
332
+ this.validator(value, session, this.endpoint);
333
+ const oldValue = this.getter(session, this.endpoint, void 0, message);
334
+ const valueChanged = this.setter(value, session, this.endpoint, message);
335
+ if (delayChangeEvents) {
336
+ this.delayedChangeData = {
337
+ oldValue: this.delayedChangeData?.oldValue ?? oldValue,
338
+ // We keep the oldest value
339
+ newValue: value,
340
+ changed: !!this.delayedChangeData?.changed || valueChanged
341
+ // We combine the changed flag
342
+ };
343
+ logger.info(`Delay change for attribute "${this.name}" with value ${Diagnostic.json(value)}`);
344
+ } else {
345
+ this.handleVersionAndTriggerListeners(value, oldValue, valueChanged);
346
+ }
347
+ }
348
+ triggerDelayedChangeEvents() {
349
+ if (this.delayedChangeData !== void 0) {
350
+ const { oldValue, newValue, changed } = this.delayedChangeData;
351
+ this.delayedChangeData = void 0;
352
+ logger.info(`Trigger delayed change for attribute "${this.name}" with value ${Diagnostic.json(newValue)}`);
353
+ this.handleVersionAndTriggerListeners(newValue, oldValue, changed);
354
+ }
355
+ }
356
+ /**
357
+ * Helper Method to handle needed version increases and trigger the relevant listeners. This method is used
358
+ * internally.
359
+ */
360
+ handleVersionAndTriggerListeners(value, oldValue, considerVersionChanged) {
361
+ if (considerVersionChanged) {
362
+ const version = this.datasource.increaseVersion();
363
+ this.valueChangeListeners.forEach((listener) => listener(value, version));
364
+ }
365
+ if (oldValue !== void 0) {
366
+ this.valueSetListeners.forEach((listener) => listener(value, oldValue));
367
+ }
368
+ }
369
+ /**
370
+ * When the value is handled by getter or setter methods and is changed by other processes this method can be used
371
+ * to notify the attribute server that the value has changed. This will increase the version number and trigger the
372
+ * listeners.
373
+ *
374
+ * ACL checks needs to be performed before calling this method.
375
+ */
376
+ updated(session) {
377
+ const oldValue = this.value ?? this.defaultValue;
378
+ try {
379
+ this.value = this.get(session, false);
380
+ } catch (e) {
381
+ NoAssociatedFabricError.accept(e);
382
+ if (this.value === void 0) {
383
+ this.value = this.defaultValue;
384
+ }
385
+ }
386
+ this.handleVersionAndTriggerListeners(this.value, oldValue, true);
387
+ }
388
+ /**
389
+ * When the value is handled by getter or setter methods and is changed by other processes and no session from the
390
+ * originating process is known this method can be used to notify the attribute server that the value has changed.
391
+ * This will increase the version number and trigger the listeners.
392
+ *
393
+ * ACL checks needs to be performed before calling this method.
394
+ */
395
+ updatedLocal() {
396
+ const oldValue = this.value ?? this.defaultValue;
397
+ this.value = this.getLocal();
398
+ this.handleVersionAndTriggerListeners(this.value, oldValue, true);
399
+ }
400
+ /**
401
+ * Add an internal listener that is called when the value of the attribute changes. The listener is called with the
402
+ * new value and the version number.
403
+ */
404
+ addValueChangeListener(listener) {
405
+ this.valueChangeListeners.push(listener);
406
+ }
407
+ /**
408
+ * Remove an internal listener.
409
+ */
410
+ removeValueChangeListener(listener) {
411
+ const entryIndex = this.valueChangeListeners.indexOf(listener);
412
+ if (entryIndex !== -1) {
413
+ this.valueChangeListeners.splice(entryIndex, 1);
414
+ }
415
+ }
416
+ /**
417
+ * Add an external listener that is called when the value of the attribute changes. The listener is called with the
418
+ * new value and the old value.
419
+ */
420
+ addValueSetListener(listener) {
421
+ this.valueSetListeners.push(listener);
422
+ }
423
+ /**
424
+ * Add an external listener that is called when the value of the attribute changes. The listener is called with the
425
+ * new value and the old value. This method is a convenient alias for addValueSetListener.
426
+ */
427
+ subscribe(listener) {
428
+ this.addValueSetListener(listener);
429
+ }
430
+ /**
431
+ * Remove an external listener.
432
+ */
433
+ removeValueSetListener(listener) {
434
+ const entryIndex = this.valueSetListeners.indexOf(listener);
435
+ if (entryIndex !== -1) {
436
+ this.valueSetListeners.splice(entryIndex, 1);
437
+ }
438
+ }
439
+ }
440
+ class FabricScopedAttributeServer extends AttributeServer {
441
+ constructor(id, name, readAcl, writeAcl, schema, isWritable, isSubscribable, requiresTimedInteraction, initValue, defaultValue, cluster, datasource, getter, setter, validator) {
442
+ if (isWritable && (getter === void 0 || setter === void 0) && !(getter === void 0 && setter === void 0)) {
443
+ throw new ImplementationError(
444
+ `Getter and setter must be implemented together for writeable fabric scoped attribute "${name}".`
445
+ );
446
+ }
447
+ if (getter === void 0) {
448
+ getter = (session, _endpoint, isFabricFiltered) => {
449
+ if (session === void 0)
450
+ throw new FabricScopeError(`Session is required for fabric scoped attribute ${name}`);
451
+ if (isFabricFiltered === true) {
452
+ assertSecureSession(session);
453
+ return this.getLocalForFabric(session.associatedFabric);
454
+ } else {
455
+ const values = new Array();
456
+ for (const fabric of datasource.fabrics) {
457
+ const value = this.getLocalForFabric(fabric);
458
+ if (!Array.isArray(value)) {
459
+ throw new FabricScopeError(
460
+ `Fabric scoped attribute "${name}" can only be read for all fabrics if they are arrays.`
461
+ );
462
+ }
463
+ values.push(...value);
464
+ }
465
+ return values;
466
+ }
467
+ };
468
+ }
469
+ if (setter === void 0) {
470
+ setter = () => {
471
+ throw new ImplementationError("Legacy FabricScopedAttributeServer data set is not supported anymore.");
472
+ };
473
+ }
474
+ super(
475
+ id,
476
+ name,
477
+ readAcl,
478
+ writeAcl,
479
+ schema,
480
+ isWritable,
481
+ isSubscribable,
482
+ requiresTimedInteraction,
483
+ initValue,
484
+ defaultValue,
485
+ datasource,
486
+ getter,
487
+ setter,
488
+ validator
489
+ );
490
+ this.cluster = cluster;
491
+ this.#determineSensitiveFieldsToRemove();
492
+ }
493
+ fabricSensitiveElementsToRemove = new Array();
494
+ #determineSensitiveFieldsToRemove() {
495
+ const clusterFromModel = MatterModel.standard.get(ClusterModel, this.cluster.id);
496
+ if (clusterFromModel === void 0) {
497
+ logger.debug(`${this.cluster.name}: Cluster for Fabric scoped element not found in Model, ignore`);
498
+ return;
499
+ }
500
+ const attributeFromModel = clusterFromModel.get(AttributeModel, this.id);
501
+ if (attributeFromModel === void 0) {
502
+ logger.debug(
503
+ `${this.cluster.name}.${this.id}: Attribute for Fabric scoped element not found in Model, ignore`
504
+ );
505
+ return;
506
+ }
507
+ if (!attributeFromModel.fabricScoped) {
508
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute is not Fabric scoped in model, ignore`);
509
+ return;
510
+ }
511
+ if (attributeFromModel.children.length !== 1) {
512
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute has not exactly one child, ignore`);
513
+ return;
514
+ }
515
+ const type = attributeFromModel.children[0].type;
516
+ if (type === void 0) {
517
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute field has no type, ignore`);
518
+ return;
519
+ }
520
+ const dataType = clusterFromModel.get(DatatypeModel, type);
521
+ if (dataType === void 0) {
522
+ logger.debug(`${this.cluster.name}.${this.id}: DataType ${type} not found in model, ignore`);
523
+ return;
524
+ }
525
+ dataType.children.filter((field) => field.fabricSensitive).forEach((field) => this.fabricSensitiveElementsToRemove.push(camelize(field.name)));
526
+ }
527
+ get hasFabricSensitiveData() {
528
+ return this.fabricSensitiveElementsToRemove.length > 0;
529
+ }
530
+ /**
531
+ * Sanitize the value of the attribute by removing fabric sensitive fields that do not belong to the
532
+ * associated fabric
533
+ */
534
+ sanitizeFabricSensitiveFields(value, associatedFabric) {
535
+ if (this.fabricSensitiveElementsToRemove.length && Array.isArray(value)) {
536
+ const associatedFabricIndex = associatedFabric?.fabricIndex ?? -1;
537
+ return value.map((data) => {
538
+ if (data[FabricIndexName] !== associatedFabricIndex) {
539
+ const result = { ...data };
540
+ this.fabricSensitiveElementsToRemove.forEach((fieldName) => delete result[fieldName]);
541
+ return result;
542
+ }
543
+ return data;
544
+ });
545
+ }
546
+ return value;
547
+ }
548
+ /**
549
+ * Initialize the attribute with a value. Because the value is stored on fabric level this method only initializes
550
+ * the version number.
551
+ */
552
+ init(value) {
553
+ if (value !== void 0) {
554
+ throw new InternalError(`Cannot initialize fabric scoped attribute "${this.name}" with a value.`);
555
+ }
556
+ }
557
+ /**
558
+ * Fabric scoped enhancement of set to allow setting special fabricindex locally.
559
+ */
560
+ set(value, session, message, delayChangeEvents = false, preserveFabricIndex = false) {
561
+ if (!this.isWritable) {
562
+ throw new StatusResponseError(`Attribute "${this.name}" is not writable.`, StatusCode.UnsupportedWrite);
563
+ }
564
+ this.setRemote(value, session, message, delayChangeEvents, preserveFabricIndex);
565
+ }
566
+ /**
567
+ * Method that contains the logic to set a value "from remote" (e.g. from a client). For Fabric scoped attributes
568
+ * we need to inject the fabric index into the value.
569
+ */
570
+ setRemote(value, session, message, delayChangeEvents = false, preserveFabricIndex = false) {
571
+ value = this.schema.injectField(
572
+ value,
573
+ FabricIndex.id,
574
+ session.associatedFabric.fabricIndex,
575
+ () => !preserveFabricIndex
576
+ // No one should send any index and if we simply SHALL ignore it, but internally we might need it
577
+ );
578
+ logger.info(
579
+ `Set remote value for fabric scoped attribute "${this.name}" to ${Diagnostic.json(value)} (delayed=${delayChangeEvents})`
580
+ );
581
+ super.setRemote(value, session, message, delayChangeEvents);
582
+ }
583
+ /**
584
+ * Set Local is not allowed for fabric scoped attributes. Use setLocalForFabric instead.
585
+ */
586
+ setLocal(_value) {
587
+ throw new FabricScopeError(
588
+ `Fabric scoped attribute "${this.name}" can only be set locally by providing a Fabric. Use setLocalForFabric instead.`
589
+ );
590
+ }
591
+ /**
592
+ * Set the value of the attribute locally for a fabric. This method should be used locally in the code and does not
593
+ * include the ACL check.
594
+ * If a setter is defined this method cannot be used!
595
+ * If a validator is defined the value is validated before it is stored.
596
+ * Listeners are called when the value changes (internal listeners) or in any case (external listeners).
597
+ */
598
+ setLocalForFabric(_value, _fabric) {
599
+ throw new ImplementationError("Legacy FabricScopedAttributeServer data write is not supported anymore.");
600
+ }
601
+ /**
602
+ * When the value is handled by getter or setter methods and is changed by other processes and no session from the
603
+ * originating process is known this method can be used to notify the attribute server that the value has changed.
604
+ * This will increase the version number and trigger the listeners.
605
+ * ACL checks needs to be performed before calling this method.
606
+ */
607
+ updatedLocalForFabric(fabric) {
608
+ const oldValue = this.value ?? this.defaultValue;
609
+ try {
610
+ this.value = this.getLocalForFabric(fabric);
611
+ } catch (e) {
612
+ FabricScopeError.accept(e);
613
+ if (this.value === void 0) {
614
+ this.value = this.defaultValue;
615
+ }
616
+ }
617
+ this.handleVersionAndTriggerListeners(this.value, oldValue, true);
618
+ }
619
+ /**
620
+ * Get the value of the attribute locally for a special Fabric. This method should be used locally in the code and
621
+ * does not include the ACL check.
622
+ * If a getter is defined this method returns an error and the value should be retrieved directly internally.
623
+ */
624
+ getLocalForFabric(_fabric) {
625
+ throw new ImplementationError("Legacy FabricScopedAttributeServer data read is not supported anymore.");
626
+ }
627
+ }
628
+ export {
629
+ AttributeServer,
630
+ BaseAttributeServer,
631
+ FabricScopeError,
632
+ FabricScopedAttributeServer,
633
+ FixedAttributeServer,
634
+ createAttributeServer
635
+ };
636
+ //# sourceMappingURL=AttributeServer.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/cluster/server/AttributeServer.ts"],
4
+ "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,SAAS,YAAY,qBAAqB,eAAe,QAAQ,aAAa,UAAU,mBAAmB;AAC3G,SAAS,aAAa,gBAAgB,cAAc,eAAe,aAAa,mBAAmB;AACnG,SAA0B,yBAAiD,2BAA2B;AACtG;AAAA,EAQI;AAAA,EACA;AAAA,EAGA;AAAA,OACG;AAGP,MAAM,SAAS,OAAO,IAAI,iBAAiB;AAE3C,MAAM,kBAAkB,SAAS,YAAY,IAAI;AAM1C,MAAM,yBAAyB,YAAY;AAAC;AAa5C,SAAS,sBAQZ,YACA,cACA,eACA,WACA,YACA,QACA,QACA,WACF;AACE,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,MAAI,OAAO;AACP,WAAO,IAAI;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AAEA,MAAI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AAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkB,SAAoB;AAClC,UAAM,IAAI,oBAAoB,wEAAwE;AAAA,EAC1G;AACJ;",
5
+ "names": []
6
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { SupportedStorageTypes } from "#general";
7
+ import { Fabric, OccurrenceManager } from "#protocol";
8
+ export interface ClusterDatasource {
9
+ readonly version: number;
10
+ readonly eventHandler?: OccurrenceManager;
11
+ readonly fabrics: Fabric[];
12
+ increaseVersion(): number;
13
+ changed(key: string, value: SupportedStorageTypes): void;
14
+ }
15
+ //# sourceMappingURL=ClusterDatasource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClusterDatasource.d.ts","sourceRoot":"","sources":["../../../../src/cluster/server/ClusterDatasource.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,IAAI,MAAM,CAAC;IAC1B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAC;CAC5D"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ //# sourceMappingURL=ClusterDatasource.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/cluster/server/ClusterDatasource.ts"],
4
+ "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;",
5
+ "names": []
6
+ }