@north-light/identity 0.3.548 → 0.3.550

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/README.md CHANGED
@@ -71,7 +71,7 @@ The grammar `parseScope` accepts:
71
71
  |---|---|
72
72
  | `crtr:llm`, `crtr:act`, `crtr:schedule` | Model calls and starting runs; acting on nodes, files and bash; scheduling crons |
73
73
  | `crtr:memory:read:user[:path]`, `crtr:memory:rw:user[:path]`, `crtr:memory:manage:user` | The person's documents, optionally limited to a path; `manage` covers both access levels |
74
- | `crtr:memory:read_private:user` | Read-only access to `public` and `private` documents, never `friends`; no path; covered by `manage`, covers only itself |
74
+ | `crtr:memory:read_private:user` | Read-only access to `public` and `private` documents; no path; covered by `manage`, covers only itself |
75
75
  | `crtr:memory:read\|rw:app:<id>[:profile:<profile>[:path]]` | An app's documents |
76
76
  | `crtr:files:read\|rw:user:<dir>`, `crtr:files:read\|rw:app:<id>:<dir>`, `crtr:files:share` | Host files a run may mount, and sharing them |
77
77
  | `crtr:conversations:read:app:<id>`, `crtr:objects:read:app:<id>` | Reading another app's conversations or node objects |
package/dist/index.js CHANGED
@@ -14,14 +14,27 @@ function validPath(path, directoryOnly = false) {
14
14
  !path.split('/').some((part, index, parts) => part === '.' || (part === '' && index !== parts.length - 1)) &&
15
15
  (!directoryOnly || !path.endsWith('/'));
16
16
  }
17
+ // `covers` parses both sides on every call, and a grant can hold thousands of scopes: parse each string once. A parse is pure; a throw is not cached.
18
+ const selectorCache = new Map();
19
+ const SELECTOR_CACHE_MAX = 20_000;
17
20
  function selector(value) {
21
+ let s = selectorCache.get(value);
22
+ if (s === undefined) {
23
+ s = parseSelector(value);
24
+ if (selectorCache.size >= SELECTOR_CACHE_MAX)
25
+ selectorCache.clear();
26
+ selectorCache.set(value, s);
27
+ }
28
+ return s;
29
+ }
30
+ function parseSelector(value) {
18
31
  if (value === 'crtr:llm' || value === 'crtr:act' || value === 'crtr:schedule')
19
32
  return { kind: value.slice(5), value };
20
33
  if (value === 'crtr:files:share')
21
34
  return { kind: 'share', value };
22
35
  if (value === 'crtr:memory:manage:user')
23
36
  return { kind: 'memory', access: 'manage', holder: 'user' };
24
- // Read-only access to the person's `public` and `private` memory (never `friends`). It names no document path.
37
+ // Read-only access to the person's `public` and `private` memory. It names no document path.
25
38
  if (value === 'crtr:memory:read_private:user')
26
39
  return { kind: 'memory', access: 'read_private', holder: 'user' };
27
40
  let match = /^crtr:memory:(read|rw):user(?::(.+))?$/.exec(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/identity",
3
- "version": "0.3.548",
3
+ "version": "0.3.550",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",