@north-light/cli 0.3.748 → 0.3.749
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/clients/attach/chrome/canvas-panels.d.ts +2 -0
- package/dist/clients/attach/chrome/canvas-panels.js +1 -1
- package/dist/clients/attach/chrome/roster.d.ts +2 -0
- package/dist/clients/attach/chrome/roster.js +5 -5
- package/dist/clients/attach/chrome/run-facts.d.ts +12 -0
- package/dist/clients/attach/chrome/run-facts.js +1 -0
- package/dist/clients/attach/chrome/widgets.d.ts +3 -1
- package/dist/clients/attach/chrome/widgets.js +1 -1
- package/dist/clients/attach/viewer.js +487 -487
- package/dist/core/canvas/canvas.js +16 -16
- package/dist/core/canvas/schema-pg/036-ledger-holder-app-path.sql +13 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/command.d.ts +1 -1
- package/dist/core/command.js +6 -6
- package/dist/core/graph/reader.js +1 -1
- package/dist/core/peer/envelope.js +1 -1
- package/dist/core/peer/stubs.js +1 -1
- package/dist/core/permissions/ceiling.js +10 -10
- package/dist/core/permissions/evaluator.js +2 -2
- package/dist/core/runtime/recap.js +6 -6
- package/dist/daemon/api/handlers/providers.d.ts +2 -0
- package/dist/daemon/api/handlers/providers.js +1 -1
- package/dist/daemon/peer/authority.d.ts +1 -1
- package/dist/daemon/peer/authority.js +1 -1
- package/package.json +4 -4
- package/packages/crouter-api/dist/clients/attach/chrome/canvas-panels.js +19 -1
- package/packages/crouter-api/dist/clients/attach/chrome/roster.js +1 -0
- package/packages/crouter-api/dist/clients/attach/chrome/run-facts.js +76 -0
- package/packages/crouter-api/dist/clients/attach/chrome/widgets.js +14 -5
- package/packages/crouter-api/dist/clients/attach/viewer.js +7 -1
- package/packages/crouter-api/dist/core/canvas/canvas.js +2 -1
- package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
- package/packages/crouter-api/dist/core/command.js +4 -3
- package/packages/crouter-api/dist/core/graph/reader.js +1 -1
- package/packages/crouter-api/dist/core/peer/envelope.js +2 -1
- package/packages/crouter-api/dist/core/peer/stubs.js +5 -1
- package/packages/crouter-api/dist/core/permissions/ceiling.js +4 -0
- package/packages/crouter-api/dist/core/permissions/evaluator.js +13 -4
- package/packages/crouter-api/dist/daemon/api/handlers/providers.js +5 -1
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/dist/index.d.ts +8 -0
- package/packages/crouter-identity/dist/index.js +18 -0
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
- package/scripts/lib/install-source.mjs +5 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The ceiling: what one of a person's agents may reach, computed in TypeScript from the reader's grant scopes and node row before the query,
|
|
2
2
|
// then applied inside the same query as the schema check (`ceilingFrag`). A person reader has no ceiling. Privacy (`private` per root), run
|
|
3
3
|
// confinement (`place`) and the launched own-memory narrowing are all rules here; none of them is schema text.
|
|
4
|
+
import { parsePrincipal } from '@north-light/identity';
|
|
4
5
|
import { covers } from '@north-light/identity';
|
|
5
6
|
import { isCloudRole } from '../canvas/person-state.js';
|
|
6
7
|
import { eligiblePackageApps } from '../packages/eligibility.js';
|
|
@@ -147,6 +148,9 @@ export async function resolveCeiling(db, reader, user, access, options = {}) {
|
|
|
147
148
|
const objVerb = access === 'write' ? 'write' : options.verb ?? 'read';
|
|
148
149
|
const watching = reader.class === 'object' && reader.object.type.includes('.');
|
|
149
150
|
const appRoot = async (ext, match) => {
|
|
151
|
+
const principal = parsePrincipal(ext);
|
|
152
|
+
if (principal?.kind !== 'app' || principal.path.length > 0)
|
|
153
|
+
return;
|
|
150
154
|
const id = await objectOf(db, 'app', ext);
|
|
151
155
|
if (id === null || id === reader.app.id)
|
|
152
156
|
return;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// check / permits: the reader's user (schema) AND the reader's ceiling, in one SQL condition over the candidate object.
|
|
2
|
+
import { parsePrincipal } from '@north-light/identity';
|
|
1
3
|
import { isCloudRole, personIdAsync } from '../canvas/person.js';
|
|
2
4
|
import { requestPersonId } from '../canvas/person-state.js';
|
|
3
5
|
import { OBJECT_TYPE, GROUP_TYPE } from './builtin.js';
|
|
@@ -10,11 +12,18 @@ export const PERMISSIONS = ['read', 'edit', 'message', 'use', 'share'];
|
|
|
10
12
|
/** The ceiling access class a permission asks: read/use → read, edit/share → write, message → message. */
|
|
11
13
|
const ACCESS = { read: 'read', use: 'read', edit: 'write', share: 'write', message: 'message' };
|
|
12
14
|
const bareUser = (principal) => principal.replace(/^user:/, '');
|
|
13
|
-
/** An app acting as its own subject (`app:<id>`) is no person: it never becomes a user, so no `acts_for` or subject set is built from it. */
|
|
14
|
-
const personSub = (sub) => sub
|
|
15
|
+
/** A `sub` is a person only when the shared parser says `user:<id>`; an app principal, a bare id and any unknown prefix are no person (denied). An app acting as its own subject (`app:<id>`) is no person: it never becomes a user, so no `acts_for` or subject set is built from it. */
|
|
16
|
+
const personSub = (sub) => { const p = parsePrincipal(sub); return p?.kind === 'user' ? bareUser(p.namespace) : null; };
|
|
15
17
|
/** The user a reader acts for: a person's own identity; an app call's `sub`; a node's `sub`; otherwise the install's person. */
|
|
16
18
|
export async function userOf(db, reader) {
|
|
17
|
-
|
|
19
|
+
const named = await namedUserOf(db, reader);
|
|
20
|
+
if (named !== null)
|
|
21
|
+
return named;
|
|
22
|
+
// A sub the parser rejects, or an app principal, never falls back. A reader with no sub falls back to the install's person on a local install only (one person there); a cloud role denies it.
|
|
23
|
+
const subless = reader.class === 'app' && reader.sub === undefined;
|
|
24
|
+
if (reader.class === 'app' && !(subless && !isCloudRole()))
|
|
25
|
+
throw new PermissionError(403, 'no_person', 'an app reader that names no person acts for no one');
|
|
26
|
+
return bareUser(await personIdAsync());
|
|
18
27
|
}
|
|
19
28
|
/** The user a reader names itself, without falling back to the process's person; null when it names none. */
|
|
20
29
|
async function namedUserOf(db, reader) {
|
|
@@ -53,7 +62,7 @@ export function resolveReader(db, reader) {
|
|
|
53
62
|
if (shared)
|
|
54
63
|
return shared;
|
|
55
64
|
const ev = (async () => {
|
|
56
|
-
const userId = isCloudRole() && requestPersonId() === undefined ? await namedUserOf(db, reader) : await userOf(db, reader);
|
|
65
|
+
const userId = (isCloudRole() && requestPersonId() === undefined) ? await namedUserOf(db, reader) : await userOf(db, reader);
|
|
57
66
|
return { reader, userId, subjects: userId === null ? { userIds: ['*'], groupIds: [] } : await subjectSet(db, userId), defs: await loadDefinitions(db) };
|
|
58
67
|
})();
|
|
59
68
|
if (shared === null) {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// Past the gate, the bodies are filled in by later tasks — `provider.call` by
|
|
10
10
|
// R4 (`core/providers/call.ts`), `provider.tools` by R8 — and answer
|
|
11
11
|
// `not_implemented` until then.
|
|
12
|
+
import { parsePrincipal } from '@north-light/identity';
|
|
12
13
|
import { randomUUID } from 'node:crypto';
|
|
13
14
|
import { cloudPersonScope } from '../../../core/runs/operations.js';
|
|
14
15
|
import { directoryIssuer } from '../../../core/directory/issuer.js';
|
|
@@ -140,8 +141,11 @@ export function parseCallInput(body) {
|
|
|
140
141
|
const machine = fields['machine'];
|
|
141
142
|
if (machine !== undefined && (typeof machine !== 'string' || !machine.trim()))
|
|
142
143
|
throw invalid('machine must be a machine id', 'machine');
|
|
144
|
+
const as = fields['as'];
|
|
145
|
+
if (as !== undefined && (typeof as !== 'string' || parsePrincipal(as) === null))
|
|
146
|
+
throw invalid('as must be a principal like user:<id> or app:<id>/<path>', 'as');
|
|
143
147
|
return { provider, tool: tool.trim(), arguments: args, ...(version === undefined ? {} : { version }), ...(approval === undefined ? {} : { approval }),
|
|
144
|
-
...(machine === undefined ? {} : { machine: machine.trim() }) };
|
|
148
|
+
...(machine === undefined ? {} : { machine: machine.trim() }), ...(as === undefined ? {} : { as }) };
|
|
145
149
|
}
|
|
146
150
|
async function auditList(caller, query = new URLSearchParams()) {
|
|
147
151
|
const numeric = (name, fallback, max) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.749",
|
|
4
4
|
"description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/api/index.js",
|
|
@@ -131,3 +131,11 @@ export declare function verifyIdToken(options: {
|
|
|
131
131
|
issuer: string;
|
|
132
132
|
audience: string;
|
|
133
133
|
}): Promise<IdTokenClaims>;
|
|
134
|
+
/** A parsed principal: `user:<id>`, `app:<id>`, or `app:<id>/<segment>(/<segment>)*`. `namespace` is `user:<id>` or `app:<id>`; `path` is the segments under an app (empty for a namespace root). */
|
|
135
|
+
export interface Principal {
|
|
136
|
+
kind: 'user' | 'app';
|
|
137
|
+
namespace: string;
|
|
138
|
+
path: string[];
|
|
139
|
+
}
|
|
140
|
+
/** The one principal parser: every site that reads a principal string denies a `null`. Segments may contain `:` but not `/`; a bare id, an unknown prefix, an empty segment or a path under `user:` is rejected. */
|
|
141
|
+
export declare function parsePrincipal(value: string): Principal | null;
|
|
@@ -368,3 +368,21 @@ export async function verifyIdToken(options) {
|
|
|
368
368
|
throw new Error('Invalid ID token claims');
|
|
369
369
|
return payload;
|
|
370
370
|
}
|
|
371
|
+
const PRINCIPAL_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
372
|
+
const PRINCIPAL_SEGMENT = /^[^/\s]+$/;
|
|
373
|
+
/** The one principal parser: every site that reads a principal string denies a `null`. Segments may contain `:` but not `/`; a bare id, an unknown prefix, an empty segment or a path under `user:` is rejected. */
|
|
374
|
+
export function parsePrincipal(value) {
|
|
375
|
+
const m = /^(user|app):([^/]*)((?:\/.*)?)$/.exec(value);
|
|
376
|
+
if (m === null || !PRINCIPAL_ID.test(m[2]))
|
|
377
|
+
return null;
|
|
378
|
+
const kind = m[1];
|
|
379
|
+
const rest = m[3];
|
|
380
|
+
if (rest === '')
|
|
381
|
+
return { kind, namespace: `${kind}:${m[2]}`, path: [] };
|
|
382
|
+
if (kind === 'user')
|
|
383
|
+
return null;
|
|
384
|
+
const path = rest.slice(1).split('/');
|
|
385
|
+
if (!path.every((s) => PRINCIPAL_SEGMENT.test(s)))
|
|
386
|
+
return null;
|
|
387
|
+
return { kind, namespace: `app:${m[2]}`, path };
|
|
388
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.749",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"postpack": "node ../../scripts/pack-minify.mjs postpack packages/crouter-plugin"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@north-light/api": "0.3.
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
30
|
+
"@north-light/api": "0.3.749",
|
|
31
|
+
"@north-light/identity": "0.3.749"
|
|
32
32
|
},
|
|
33
33
|
"license": "UNLICENSED",
|
|
34
34
|
"publishConfig": {
|
package/runtime.lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.749",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@north-light/cli",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.749",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"workspaces": [
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@milkdown/preset-gfm": "^7.22.3",
|
|
29
29
|
"@milkdown/prose": "^7.22.3",
|
|
30
30
|
"@milkdown/utils": "^7.22.3",
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
32
|
-
"@north-light/plugin": "0.3.
|
|
31
|
+
"@north-light/identity": "0.3.749",
|
|
32
|
+
"@north-light/plugin": "0.3.749",
|
|
33
33
|
"cron-parser": "^5.6.0",
|
|
34
34
|
"esbuild": "0.28.2",
|
|
35
35
|
"jose": "^6.2.12",
|
|
@@ -11902,17 +11902,17 @@
|
|
|
11902
11902
|
},
|
|
11903
11903
|
"packages/crouter-api": {
|
|
11904
11904
|
"name": "@north-light/api",
|
|
11905
|
-
"version": "0.3.
|
|
11905
|
+
"version": "0.3.749",
|
|
11906
11906
|
"license": "UNLICENSED"
|
|
11907
11907
|
},
|
|
11908
11908
|
"packages/crouter-env-docker": {
|
|
11909
11909
|
"name": "@north-light/env-docker",
|
|
11910
|
-
"version": "0.3.
|
|
11910
|
+
"version": "0.3.749",
|
|
11911
11911
|
"license": "UNLICENSED"
|
|
11912
11912
|
},
|
|
11913
11913
|
"packages/crouter-identity": {
|
|
11914
11914
|
"name": "@north-light/identity",
|
|
11915
|
-
"version": "0.3.
|
|
11915
|
+
"version": "0.3.749",
|
|
11916
11916
|
"license": "UNLICENSED",
|
|
11917
11917
|
"dependencies": {
|
|
11918
11918
|
"jose": "^6.2.1"
|
|
@@ -11920,21 +11920,21 @@
|
|
|
11920
11920
|
},
|
|
11921
11921
|
"packages/crouter-plugin": {
|
|
11922
11922
|
"name": "@north-light/plugin",
|
|
11923
|
-
"version": "0.3.
|
|
11923
|
+
"version": "0.3.749",
|
|
11924
11924
|
"license": "UNLICENSED",
|
|
11925
11925
|
"dependencies": {
|
|
11926
|
-
"@north-light/api": "0.3.
|
|
11927
|
-
"@north-light/identity": "0.3.
|
|
11926
|
+
"@north-light/api": "0.3.749",
|
|
11927
|
+
"@north-light/identity": "0.3.749"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.749",
|
|
11933
11933
|
"license": "UNLICENSED",
|
|
11934
11934
|
"dependencies": {
|
|
11935
|
-
"@north-light/api": "0.3.
|
|
11936
|
-
"@north-light/identity": "0.3.
|
|
11937
|
-
"@north-light/plugin": "0.3.
|
|
11935
|
+
"@north-light/api": "0.3.749",
|
|
11936
|
+
"@north-light/identity": "0.3.749",
|
|
11937
|
+
"@north-light/plugin": "0.3.749",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// is the explicit bypass. A package root that is not a git checkout (the npm package, image builds)
|
|
6
6
|
// is not checked.
|
|
7
7
|
import { spawnSync } from 'node:child_process';
|
|
8
|
+
import { realpathSync } from 'node:fs';
|
|
8
9
|
|
|
9
10
|
export const ALLOW_UNLANDED_FLAG = '--allow-unlanded';
|
|
10
11
|
|
|
@@ -15,7 +16,10 @@ function git(root, args) {
|
|
|
15
16
|
|
|
16
17
|
/** The checkout's commit, branch, and how it differs from origin/main; undefined when `root` is not a git checkout. */
|
|
17
18
|
export function readInstallSource(root) {
|
|
18
|
-
|
|
19
|
+
// Only a checkout whose own top level is `root` counts: the npm package can sit inside an unrelated
|
|
20
|
+
// repo (Homebrew's prefix is one on Apple Silicon).
|
|
21
|
+
const top = git(root, ['rev-parse', '--show-toplevel']);
|
|
22
|
+
if (top === undefined || realpathSync(top) !== realpathSync(root)) return undefined;
|
|
19
23
|
const fetched = spawnSync('git', ['fetch', '--quiet', 'origin', 'main'], { cwd: root, stdio: 'ignore', timeout: 30_000 }).status === 0;
|
|
20
24
|
const commit = git(root, ['rev-parse', 'HEAD']);
|
|
21
25
|
const branch = git(root, ['branch', '--show-current']) || '(detached)';
|