@segmentstream-cloud/app 0.11.0 → 0.12.0

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.
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Permissions are `<entity>:<verb>` strings, such as `lead:changeStatus`. A role may use `*` for the
3
3
  * entity (`*:read`), the verb (`lead:*`) or both (`*:*`); what an action or a read requires never
4
- * holds a wildcard.
4
+ * holds a wildcard. A wildcard entity does not cover the built-in `agent_chat`: only a permission
5
+ * that names it does.
5
6
  *
6
7
  * The matching rule is the ontology service's, copied from `@segmentstream-cloud/ontology`
7
8
  * (`src/permissions.ts`) so that the app SDK and its browser components do not depend on the
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Permissions are `<entity>:<verb>` strings, such as `lead:changeStatus`. A role may use `*` for the
3
3
  * entity (`*:read`), the verb (`lead:*`) or both (`*:*`); what an action or a read requires never
4
- * holds a wildcard.
4
+ * holds a wildcard. A wildcard entity does not cover the built-in `agent_chat`: only a permission
5
+ * that names it does.
5
6
  *
6
7
  * The matching rule is the ontology service's, copied from `@segmentstream-cloud/ontology`
7
8
  * (`src/permissions.ts`) so that the app SDK and its browser components do not depend on the
@@ -9,6 +10,8 @@
9
10
  */
10
11
  import { toSnakeCase } from "./ontology-names.js";
11
12
  const WILDCARD = "*";
13
+ /** Entities only a permission that names them covers; `*:read` and `*:*` grant nothing on them. */
14
+ const EXPLICIT_GRANT_ENTITIES = new Set(["agent_chat"]);
12
15
  /** `<entity>:<verb>` with lowercase snake_case entities and lowercase snake_case verbs, or `*` for either. */
13
16
  const PERMISSION = /^(\*|[a-z][a-zA-Z0-9]*(?:_[a-z0-9]+)*):(\*|[a-z][a-zA-Z0-9]*(?:_[a-z0-9]+)*)$/;
14
17
  function parsePermission(value) {
@@ -27,7 +30,9 @@ export function grants(granted, required) {
27
30
  if (held === undefined || wanted === undefined) {
28
31
  return false;
29
32
  }
30
- return ((held.entity === WILDCARD || held.entity === wanted.entity) &&
33
+ return ((held.entity === WILDCARD
34
+ ? !EXPLICIT_GRANT_ENTITIES.has(wanted.entity)
35
+ : held.entity === wanted.entity) &&
31
36
  (held.verb === WILDCARD || held.verb === wanted.verb));
32
37
  }
33
38
  /** Whether one of the holder's permissions equals `required` or covers it through a wildcard. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream-cloud/app",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Sign-in, users, permissions, the ontology client and warehouse data access for SegmentStream workspace apps built with Next.js.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",