@matter/protocol 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.
- package/dist/cjs/action/Interactable.d.ts +2 -2
- package/dist/cjs/action/Interactable.d.ts.map +1 -1
- package/dist/cjs/action/server/AccessControl.d.ts +43 -15
- package/dist/cjs/action/server/AccessControl.d.ts.map +1 -1
- package/dist/cjs/action/server/AccessControl.js +47 -36
- package/dist/cjs/action/server/AccessControl.js.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.js +24 -22
- package/dist/cjs/action/server/AttributeReadResponse.js.map +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.js +38 -26
- package/dist/cjs/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/cjs/action/server/CommandInvokeResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/CommandInvokeResponse.js +28 -19
- package/dist/cjs/action/server/CommandInvokeResponse.js.map +1 -1
- package/dist/cjs/action/server/EventReadResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/EventReadResponse.js +22 -20
- package/dist/cjs/action/server/EventReadResponse.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts +1 -1
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +4 -4
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/interaction/FabricAccessControl.d.ts +2 -2
- package/dist/cjs/interaction/FabricAccessControl.d.ts.map +1 -1
- package/dist/cjs/interaction/FabricAccessControl.js +0 -6
- package/dist/cjs/interaction/FabricAccessControl.js.map +1 -1
- package/dist/esm/action/Interactable.d.ts +2 -2
- package/dist/esm/action/Interactable.d.ts.map +1 -1
- package/dist/esm/action/server/AccessControl.d.ts +43 -15
- package/dist/esm/action/server/AccessControl.d.ts.map +1 -1
- package/dist/esm/action/server/AccessControl.js +48 -37
- package/dist/esm/action/server/AccessControl.js.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.js +25 -23
- package/dist/esm/action/server/AttributeReadResponse.js.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.js +39 -27
- package/dist/esm/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/esm/action/server/CommandInvokeResponse.d.ts.map +1 -1
- package/dist/esm/action/server/CommandInvokeResponse.js +29 -20
- package/dist/esm/action/server/CommandInvokeResponse.js.map +1 -1
- package/dist/esm/action/server/EventReadResponse.d.ts.map +1 -1
- package/dist/esm/action/server/EventReadResponse.js +23 -21
- package/dist/esm/action/server/EventReadResponse.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts +1 -1
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +4 -4
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/interaction/FabricAccessControl.d.ts +2 -2
- package/dist/esm/interaction/FabricAccessControl.d.ts.map +1 -1
- package/dist/esm/interaction/FabricAccessControl.js +0 -6
- package/dist/esm/interaction/FabricAccessControl.js.map +1 -1
- package/package.json +6 -6
- package/src/action/Interactable.ts +2 -2
- package/src/action/server/AccessControl.ts +90 -53
- package/src/action/server/AttributeReadResponse.ts +35 -29
- package/src/action/server/AttributeWriteResponse.ts +50 -38
- package/src/action/server/CommandInvokeResponse.ts +33 -24
- package/src/action/server/EventReadResponse.ts +25 -21
- package/src/fabric/Fabric.ts +4 -4
- package/src/interaction/FabricAccessControl.ts +2 -8
|
@@ -8,7 +8,7 @@ import { InteractionSession } from "#action/Interactable.js";
|
|
|
8
8
|
import { ClusterProtocol, EndpointProtocol, EventTypeProtocol, NodeProtocol } from "#action/protocols.js";
|
|
9
9
|
import { Read } from "#action/request/Read.js";
|
|
10
10
|
import { ReadResult } from "#action/response/ReadResult.js";
|
|
11
|
-
import { AccessControl } from "#action/server/AccessControl.js";
|
|
11
|
+
import { AccessControl, hasRemoteActor } from "#action/server/AccessControl.js";
|
|
12
12
|
import { DataResponse, FallbackLimits } from "#action/server/DataResponse.js";
|
|
13
13
|
import { NumberedOccurrence } from "#events/Occurrence.js";
|
|
14
14
|
import { InternalError, isObject, Logger } from "#general";
|
|
@@ -63,7 +63,7 @@ export class EventReadResponse<
|
|
|
63
63
|
eventRequests,
|
|
64
64
|
isFabricFiltered,
|
|
65
65
|
}: Read.Events): AsyncGenerator<ReadResult.Chunk, void, void> {
|
|
66
|
-
const nodeId = this.session.fabric
|
|
66
|
+
const nodeId = !this.session.fabric ? NodeId.UNSPECIFIED_NODE_ID : this.nodeId;
|
|
67
67
|
|
|
68
68
|
if (eventFilters !== undefined) {
|
|
69
69
|
for (const { nodeId: filterNodeId, eventMin } of eventFilters) {
|
|
@@ -187,28 +187,31 @@ export class EventReadResponse<
|
|
|
187
187
|
|
|
188
188
|
// Validate access. Order here prescribed by 1.4 core spec 8.4.3.2
|
|
189
189
|
// We need some fallback location if cluster is not defined
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
190
|
+
if (hasRemoteActor(this.session)) {
|
|
191
|
+
const location = {
|
|
192
|
+
...(cluster?.location ?? {
|
|
193
|
+
path: DataModelPath.none,
|
|
194
|
+
endpoint: endpointId,
|
|
195
|
+
cluster: clusterId,
|
|
196
|
+
}),
|
|
197
|
+
owningFabric: this.session.fabric,
|
|
198
|
+
};
|
|
199
|
+
const permission = this.session.authorityAt(limits.readLevel, location);
|
|
200
|
+
switch (permission) {
|
|
201
|
+
case AccessControl.Authority.Granted:
|
|
202
|
+
break;
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
case AccessControl.Authority.Unauthorized:
|
|
205
|
+
return this.#asStatus(path, Status.UnsupportedAccess);
|
|
205
206
|
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
case AccessControl.Authority.Restricted:
|
|
208
|
+
return this.#asStatus(path, Status.AccessRestricted);
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
default:
|
|
211
|
+
throw new InternalError(`Unsupported authorization state ${permission}`);
|
|
212
|
+
}
|
|
211
213
|
}
|
|
214
|
+
|
|
212
215
|
if (endpoint === undefined) {
|
|
213
216
|
return this.#asStatus(path, Status.UnsupportedEndpoint);
|
|
214
217
|
}
|
|
@@ -298,8 +301,9 @@ export class EventReadResponse<
|
|
|
298
301
|
return; // EVent is not active, so ignore
|
|
299
302
|
}
|
|
300
303
|
if (
|
|
304
|
+
hasRemoteActor(this.session) &&
|
|
301
305
|
this.session.authorityAt(event.limits.readLevel, this.#guardedCurrentCluster.location) !==
|
|
302
|
-
|
|
306
|
+
AccessControl.Authority.Granted
|
|
303
307
|
) {
|
|
304
308
|
return;
|
|
305
309
|
}
|
package/src/fabric/Fabric.ts
CHANGED
|
@@ -63,7 +63,7 @@ export class Fabric {
|
|
|
63
63
|
readonly #keyPair: Key;
|
|
64
64
|
readonly #sessions = new Set<Session>();
|
|
65
65
|
readonly #groups: FabricGroups;
|
|
66
|
-
readonly #
|
|
66
|
+
readonly #accessControl: FabricAccessControl;
|
|
67
67
|
#label: string;
|
|
68
68
|
#removeCallbacks = new Array<() => MaybePromise<void>>();
|
|
69
69
|
#persistCallback: ((isUpdate?: boolean) => MaybePromise<void>) | undefined;
|
|
@@ -85,7 +85,7 @@ export class Fabric {
|
|
|
85
85
|
this.operationalCert = config.operationalCert;
|
|
86
86
|
this.#label = config.label;
|
|
87
87
|
this.#keyPair = PrivateKey(config.keyPair);
|
|
88
|
-
this.#
|
|
88
|
+
this.#accessControl = new FabricAccessControl(this);
|
|
89
89
|
this.#groups = new FabricGroups(this);
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -140,8 +140,8 @@ export class Fabric {
|
|
|
140
140
|
return this.#groups;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
get
|
|
144
|
-
return this.#
|
|
143
|
+
get accessControl() {
|
|
144
|
+
return this.#accessControl;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
get publicKey() {
|
|
@@ -62,7 +62,8 @@ export class AccessDeniedError extends StatusResponseError {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Implements Access Control Logic For one fabric as per Matter Specification @see {@link MatterSpecification.v12.Core}
|
|
65
|
+
* Implements Access Control Logic For one fabric as per Matter Specification @see {@link MatterSpecification.v12.Core}
|
|
66
|
+
* § 6.6.5.2.
|
|
66
67
|
*/
|
|
67
68
|
export class FabricAccessControl {
|
|
68
69
|
#fabricIndex: FabricIndex;
|
|
@@ -85,13 +86,6 @@ export class FabricAccessControl {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
set fabricIndex(fabricIndex: FabricIndex) {
|
|
89
|
-
if (this.#fabricIndex === undefined || this.#fabricIndex === FabricIndex.NO_FABRIC) {
|
|
90
|
-
this.#fabricIndex = fabricIndex;
|
|
91
|
-
}
|
|
92
|
-
throw new InternalError("Can not overwrite FabricIndex");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
89
|
/**
|
|
96
90
|
* Public method used to update the Access Control List on changes.
|
|
97
91
|
*/
|