@project-chip/matter.js 0.14.0-alpha.0-20250521-979eda05d → 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.
- package/dist/cjs/CommissioningController.d.ts.map +1 -1
- package/dist/cjs/CommissioningController.js +18 -5
- package/dist/cjs/CommissioningController.js.map +1 -1
- package/dist/cjs/cluster/server/AttributeServer.d.ts +2 -8
- package/dist/cjs/cluster/server/AttributeServer.d.ts.map +1 -1
- package/dist/cjs/cluster/server/AttributeServer.js +8 -92
- package/dist/cjs/cluster/server/AttributeServer.js.map +1 -1
- package/dist/cjs/device/PairedNode.js +1 -1
- package/dist/cjs/device/PairedNode.js.map +1 -1
- package/dist/esm/CommissioningController.d.ts.map +1 -1
- package/dist/esm/CommissioningController.js +18 -5
- package/dist/esm/CommissioningController.js.map +1 -1
- package/dist/esm/cluster/server/AttributeServer.d.ts +2 -8
- package/dist/esm/cluster/server/AttributeServer.d.ts.map +1 -1
- package/dist/esm/cluster/server/AttributeServer.js +9 -102
- package/dist/esm/cluster/server/AttributeServer.js.map +1 -1
- package/dist/esm/device/PairedNode.js +1 -1
- package/dist/esm/device/PairedNode.js.map +1 -1
- package/package.json +8 -8
- package/src/CommissioningController.ts +24 -6
- package/src/cluster/server/AttributeServer.ts +8 -130
- package/src/device/PairedNode.ts +1 -1
|
@@ -5,16 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Endpoint } from "#device/Endpoint.js";
|
|
8
|
-
import {
|
|
9
|
-
Diagnostic,
|
|
10
|
-
ImplementationError,
|
|
11
|
-
InternalError,
|
|
12
|
-
Logger,
|
|
13
|
-
MatterError,
|
|
14
|
-
MaybePromise,
|
|
15
|
-
camelize,
|
|
16
|
-
isDeepEqual,
|
|
17
|
-
} from "#general";
|
|
8
|
+
import { Diagnostic, ImplementationError, InternalError, Logger, MatterError, camelize, isDeepEqual } from "#general";
|
|
18
9
|
import { AccessLevel, AttributeModel, ClusterModel, DatatypeModel, FabricIndex, MatterModel } from "#model";
|
|
19
10
|
import { Fabric, Message, NoAssociatedFabricError, SecureSession, Session, assertSecureSession } from "#protocol";
|
|
20
11
|
import {
|
|
@@ -634,95 +625,11 @@ export class AttributeServer<T> extends FixedAttributeServer<T> {
|
|
|
634
625
|
}
|
|
635
626
|
}
|
|
636
627
|
|
|
637
|
-
export function genericFabricScopedAttributeGetterFromFabric<T>(
|
|
638
|
-
fabric: Fabric,
|
|
639
|
-
cluster: Cluster<any, any, any, any, any>,
|
|
640
|
-
attributeName: string,
|
|
641
|
-
defaultValue: T,
|
|
642
|
-
) {
|
|
643
|
-
const data = fabric.getScopedClusterDataValue<{ value: T }>(cluster, attributeName);
|
|
644
|
-
return data?.value ?? defaultValue;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
export function genericFabricScopedAttributeGetter<T>(
|
|
648
|
-
session: Session | undefined,
|
|
649
|
-
isFabricFiltered: boolean,
|
|
650
|
-
cluster: Cluster<any, any, any, any, any>,
|
|
651
|
-
attributeName: string,
|
|
652
|
-
defaultValue: T,
|
|
653
|
-
fabrics: Fabric[],
|
|
654
|
-
) {
|
|
655
|
-
if (session === undefined) {
|
|
656
|
-
throw new FabricScopeError(`Session is required for fabric scoped attribute ${attributeName}`);
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
if (isFabricFiltered) {
|
|
660
|
-
assertSecureSession(session);
|
|
661
|
-
return genericFabricScopedAttributeGetterFromFabric(
|
|
662
|
-
session.associatedFabric,
|
|
663
|
-
cluster,
|
|
664
|
-
attributeName,
|
|
665
|
-
defaultValue,
|
|
666
|
-
);
|
|
667
|
-
} else {
|
|
668
|
-
const values = new Array<any>();
|
|
669
|
-
for (const fabric of fabrics) {
|
|
670
|
-
const value = genericFabricScopedAttributeGetterFromFabric(fabric, cluster, attributeName, defaultValue);
|
|
671
|
-
if (!Array.isArray(value)) {
|
|
672
|
-
throw new FabricScopeError(
|
|
673
|
-
`Fabric scoped attribute "${attributeName}" can only be read for all fabrics if they are arrays.`,
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
values.push(...value);
|
|
677
|
-
}
|
|
678
|
-
return values as T;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
export function genericFabricScopedAttributeSetterForFabric<T>(
|
|
683
|
-
fabric: Fabric,
|
|
684
|
-
cluster: Cluster<any, any, any, any, any>,
|
|
685
|
-
attributeName: string,
|
|
686
|
-
value: T,
|
|
687
|
-
defaultValue?: T,
|
|
688
|
-
) {
|
|
689
|
-
const oldValue = genericFabricScopedAttributeGetterFromFabric(fabric, cluster, attributeName, defaultValue);
|
|
690
|
-
if (!isDeepEqual(value, oldValue)) {
|
|
691
|
-
const setResult = fabric.setScopedClusterDataValue(cluster, attributeName, { value });
|
|
692
|
-
if (MaybePromise.is(setResult)) {
|
|
693
|
-
throw new ImplementationError(
|
|
694
|
-
"Seems like an Asynchronous Storage is used with Legacy code paths which is forbidden!",
|
|
695
|
-
);
|
|
696
|
-
}
|
|
697
|
-
return true;
|
|
698
|
-
}
|
|
699
|
-
return false;
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
export function genericFabricScopedAttributeSetter<T>(
|
|
703
|
-
value: T,
|
|
704
|
-
session: Session | undefined,
|
|
705
|
-
cluster: Cluster<any, any, any, any, any>,
|
|
706
|
-
attributeName: string,
|
|
707
|
-
defaultValue?: T,
|
|
708
|
-
) {
|
|
709
|
-
if (session === undefined) {
|
|
710
|
-
throw new FabricScopeError(`Session is required for fabric scoped attribute "${attributeName}".`);
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
assertSecureSession(session);
|
|
714
|
-
const fabric = session.associatedFabric;
|
|
715
|
-
|
|
716
|
-
return genericFabricScopedAttributeSetterForFabric(fabric, cluster, attributeName, value, defaultValue);
|
|
717
|
-
}
|
|
718
|
-
|
|
719
628
|
/**
|
|
720
629
|
* Attribute server which is getting and setting the value for a defined fabric. The values are automatically persisted
|
|
721
630
|
* on fabric level if no custom getter or setter is defined.
|
|
722
631
|
*/
|
|
723
632
|
export class FabricScopedAttributeServer<T> extends AttributeServer<T> {
|
|
724
|
-
private readonly isCustomGetter: boolean;
|
|
725
|
-
private readonly isCustomSetter: boolean;
|
|
726
633
|
private readonly fabricSensitiveElementsToRemove = new Array<string>();
|
|
727
634
|
|
|
728
635
|
constructor(
|
|
@@ -752,7 +659,6 @@ export class FabricScopedAttributeServer<T> extends AttributeServer<T> {
|
|
|
752
659
|
);
|
|
753
660
|
}
|
|
754
661
|
|
|
755
|
-
let isCustomGetter = false;
|
|
756
662
|
if (getter === undefined) {
|
|
757
663
|
getter = (session, _endpoint, isFabricFiltered) => {
|
|
758
664
|
if (session === undefined)
|
|
@@ -775,16 +681,12 @@ export class FabricScopedAttributeServer<T> extends AttributeServer<T> {
|
|
|
775
681
|
return values as T;
|
|
776
682
|
}
|
|
777
683
|
};
|
|
778
|
-
} else {
|
|
779
|
-
isCustomGetter = true;
|
|
780
684
|
}
|
|
781
685
|
|
|
782
|
-
let isCustomSetter = false;
|
|
783
686
|
if (setter === undefined) {
|
|
784
|
-
setter = (
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
isCustomSetter = true;
|
|
687
|
+
setter = () => {
|
|
688
|
+
throw new ImplementationError("Legacy FabricScopedAttributeServer data set is not supported anymore.");
|
|
689
|
+
};
|
|
788
690
|
}
|
|
789
691
|
|
|
790
692
|
super(
|
|
@@ -803,8 +705,6 @@ export class FabricScopedAttributeServer<T> extends AttributeServer<T> {
|
|
|
803
705
|
setter,
|
|
804
706
|
validator,
|
|
805
707
|
);
|
|
806
|
-
this.isCustomGetter = isCustomGetter;
|
|
807
|
-
this.isCustomSetter = isCustomSetter;
|
|
808
708
|
|
|
809
709
|
this.#determineSensitiveFieldsToRemove();
|
|
810
710
|
}
|
|
@@ -932,25 +832,8 @@ export class FabricScopedAttributeServer<T> extends AttributeServer<T> {
|
|
|
932
832
|
* If a validator is defined the value is validated before it is stored.
|
|
933
833
|
* Listeners are called when the value changes (internal listeners) or in any case (external listeners).
|
|
934
834
|
*/
|
|
935
|
-
setLocalForFabric(
|
|
936
|
-
|
|
937
|
-
throw new FabricScopeError(
|
|
938
|
-
`Fabric scoped attribute "${this.name}" cannot be set locally when a custom setter is defined.`,
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
this.validator(value, undefined, this.endpoint);
|
|
942
|
-
|
|
943
|
-
const oldValue = this.getLocalForFabric(fabric);
|
|
944
|
-
const valueChanged = !isDeepEqual(value, oldValue);
|
|
945
|
-
if (valueChanged) {
|
|
946
|
-
const setResult = fabric.setScopedClusterDataValue(this.cluster, this.name, { value });
|
|
947
|
-
if (MaybePromise.is(setResult)) {
|
|
948
|
-
throw new ImplementationError(
|
|
949
|
-
"Seems like an Asynchronous Storage is used with Legacy code paths which is forbidden!",
|
|
950
|
-
);
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
this.handleVersionAndTriggerListeners(value, oldValue, valueChanged); // TODO Make callbacks sense without fabric, but then they would have other signature?
|
|
835
|
+
setLocalForFabric(_value: T, _fabric: Fabric) {
|
|
836
|
+
throw new ImplementationError("Legacy FabricScopedAttributeServer data write is not supported anymore.");
|
|
954
837
|
}
|
|
955
838
|
|
|
956
839
|
/**
|
|
@@ -978,12 +861,7 @@ export class FabricScopedAttributeServer<T> extends AttributeServer<T> {
|
|
|
978
861
|
* does not include the ACL check.
|
|
979
862
|
* If a getter is defined this method returns an error and the value should be retrieved directly internally.
|
|
980
863
|
*/
|
|
981
|
-
getLocalForFabric(
|
|
982
|
-
|
|
983
|
-
throw new FabricScopeError(
|
|
984
|
-
`Fabric scoped attribute "${this.name}" cannot be read locally when a custom getter is defined.`,
|
|
985
|
-
);
|
|
986
|
-
}
|
|
987
|
-
return genericFabricScopedAttributeGetterFromFabric(fabric, this.cluster, this.name, this.defaultValue);
|
|
864
|
+
getLocalForFabric(_fabric: Fabric): T {
|
|
865
|
+
throw new ImplementationError("Legacy FabricScopedAttributeServer data read is not supported anymore.");
|
|
988
866
|
}
|
|
989
867
|
}
|
package/src/device/PairedNode.ts
CHANGED
|
@@ -526,7 +526,7 @@ export class PairedNode {
|
|
|
526
526
|
}
|
|
527
527
|
if (this.#reconnectionInProgress || this.#remoteInitializationInProgress) {
|
|
528
528
|
logger.debug(
|
|
529
|
-
`Node ${this.nodeId}: Ignoring reconnect request because ${this.#remoteInitializationInProgress ? "
|
|
529
|
+
`Node ${this.nodeId}: Ignoring reconnect request because ${this.#remoteInitializationInProgress ? "initialization" : "reconnect"} already underway.`,
|
|
530
530
|
);
|
|
531
531
|
return;
|
|
532
532
|
}
|