@north-light/cli 0.3.775 → 0.3.777
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,6 +1,6 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x=Object.defineProperty;var c=(s,e)=>x(s,"name",{value:e,configurable:!0});import{parsePrincipal as I}from"@north-light/identity";import{isCloudRole as _,personIdAsync as k}from"../canvas/person.js";import{requestPersonId as H}from"../canvas/person-state.js";import{OBJECT_TYPE as W,GROUP_TYPE as w}from"./builtin.js";import{ceilingFrag as M,resolveCeiling as U}from"./ceiling.js";import{compilePermission as S}from"./compile.js";import{PermissionError as j}from"./errors.js";import{loadDefinitions as y}from"./schemas.js";import{TRUE as D,and as F,f as d,or as P,raw as u}from"./sql.js";const q=["read","edit","message","use","share"],v={read:"read",use:"read",edit:"write",share:"write",message:"message"},f=c(s=>s.replace(/^user:/,""),"bareUser"),E=c(s=>{const e=I(s);return e?.kind==="user"?f(e.namespace):null},"personSub");async function J(s,e){const n=await O(s,e);if(n!==null)return n;const t=e.class==="app"&&e.sub===void 0;if(e.class==="app"&&!(t&&!_()))throw new j(403,"no_person","an app reader that names no person acts for no one");return f(await k())}c(J,"userOf");async function O(s,e){if(e.class==="person"){const o=await s.prepare("SELECT external_id FROM identities WHERE object = ? AND scheme = 'user'").get(e.person.id);return o===void 0?null:f(o.external_id)}if(e.class==="app")return e.sub===void 0?null:E(e.sub);if(e.class==="object"&&e.sub!==void 0||e.class==="node"&&e.sub!==void 0)return E(e.sub);const n=e.class==="node"?e.node.id:e.object.id,t=await s.prepare("SELECT sub FROM nodes WHERE node_id = ?").get(n);return t?.sub==null?null:E(t.sub)}c(O,"namedUserOf");async function $(s,e){const n=[e,"*"],t=await s.prepareUncached(`WITH RECURSIVE g(id) AS (
|
|
2
2
|
SELECT resource_id FROM relations WHERE resource_type = ? AND relation = 'member' AND subject_type = 'user' AND subject_id = ANY(?::text[])
|
|
3
3
|
UNION
|
|
4
4
|
SELECT r.resource_id FROM relations r JOIN g ON r.subject_type = ? AND r.subject_id = g.id AND r.subject_relation = 'member'
|
|
5
5
|
WHERE r.resource_type = ? AND r.relation = 'member')
|
|
6
|
-
SELECT id FROM g`).all(w,n,w,w);return{userIds:n,groupIds:t.map(o=>o.id)}}c(
|
|
6
|
+
SELECT id FROM g`).all(w,n,w,w);return{userIds:n,groupIds:t.map(o=>o.id)}}c($,"subjectSet");const p=new WeakMap,ie=c(s=>(p.has(s)||p.set(s,null),s),"shareReads");function Y(s,e){const n=p.get(e);if(n)return n;const t=(async()=>{const o=_()&&(H()===void 0||G(e))?await O(s,e):await J(s,e);return{reader:e,userId:o,subjects:o===null?{userIds:["*"],groupIds:[]}:await $(s,o),defs:await y(s)}})();return n===null&&(p.set(e,t),t.catch(()=>p.set(e,null))),t}c(Y,"resolveReader");const B=c(s=>"subjects"in s,"isEval"),G=c(s=>s.class==="app"&&s.sub!==void 0&&I(s.sub)?.kind==="app","appActsAsApp");async function V(s,e,n,t="o",o={}){if(!q.includes(n))throw new j(400,"unknown_permission",`unknown permission ${n}`);const r=B(e)?e:await Y(s,e),{defs:a}=r,m=u(`${t}.id`),b=S(a,r.subjects,W,n,m),N=n==="read"?P([b,u(`${t}.type = 'app'`)]):b,h=r.reader.class==="person"?null:r.reader.app.id,C=r.reader.class==="app"&&r.reader.place===void 0&&h!==null?await K(s,h):new Set,l=[];for(const[i,R]of a){if(i.startsWith("crtr/")||i==="user"||i==="app"||!(n in R.permissions)&&!(n in R.relations))continue;const L=i.split("/")[0];l.push(d`WHEN ${u(t)}.schema_type = ${i} THEN ${C.has(L)?D:S(a,r.subjects,i,n,m)}`)}const g=l.length===0?d`(CASE WHEN ${u(t)}.schema_type IS NULL THEN ${N} ELSE FALSE END)`:d`(CASE WHEN ${u(t)}.schema_type IS NULL THEN ${N} ${{sql:l.map(i=>i.sql).join(" "),params:l.flatMap(i=>i.params)}} ELSE FALSE END)`,A=await z(s,r,v[n],o);return A===null?g:F([M(A,t),g])}c(V,"permits");const T=new WeakMap;function z(s,e,n,t={}){let o=T.get(e.reader);o===void 0&&T.set(e.reader,o=new Map);const r=`${n} ${t.verb??""} ${e.userId} ${e.subjects.groupIds.join(",")}`;let a=o.get(r);return a===void 0&&(a=U(s,e.reader,e.userId,n,t),o.set(r,a),a.catch(()=>o.delete(r))),a}c(z,"ceilingOf");async function K(s,e){const n=await s.prepare("SELECT s.namespace FROM schemas s JOIN identities i ON i.external_id = s.app AND i.scheme = 'app' WHERE i.object = ?").all(e);return new Set(n.map(t=>t.namespace))}c(K,"ownNamespaceTypes");async function ue(s,e,n,t,o={}){const r=await V(s,e,n,"o",o);return(await s.prepareUncached(`SELECT ${r.sql} AS ok FROM objects o WHERE o.id = ?`).get(...r.params,t))?.ok===!0}c(ue,"check");async function pe(s,e,n,t){const o=await $(s,f(e)),r=await y(s),a=S(r,o,t.type,n,d`${t.id}::text`);return(await s.prepareUncached(`SELECT ${a.sql} AS ok`).get(...a.params))?.ok===!0}c(pe,"checkUser");export{q as PERMISSIONS,z as ceilingOf,ue as check,pe as checkUser,V as permits,Y as resolveReader,ie as shareReads,$ as subjectSet,J as userOf};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.777",
|
|
4
4
|
"description": "crtr — agent runtime with memory, plugins, and marketplaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -157,8 +157,8 @@
|
|
|
157
157
|
},
|
|
158
158
|
"license": "UNLICENSED",
|
|
159
159
|
"dependencies": {
|
|
160
|
-
"@north-light/identity": "0.3.
|
|
161
|
-
"@north-light/plugin": "0.3.
|
|
160
|
+
"@north-light/identity": "0.3.777",
|
|
161
|
+
"@north-light/plugin": "0.3.777",
|
|
162
162
|
"@earendil-works/chord": "1.5.2",
|
|
163
163
|
"@earendil-works/pi-agent-core": "1.5.2",
|
|
164
164
|
"@earendil-works/pi-ai": "1.5.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.777",
|
|
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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.777",
|
|
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.777",
|
|
31
|
+
"@north-light/identity": "0.3.777"
|
|
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.777",
|
|
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.777",
|
|
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.777",
|
|
32
|
+
"@north-light/plugin": "0.3.777",
|
|
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.777",
|
|
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.777",
|
|
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.777",
|
|
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.777",
|
|
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.777",
|
|
11927
|
+
"@north-light/identity": "0.3.777"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.777",
|
|
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.777",
|
|
11936
|
+
"@north-light/identity": "0.3.777",
|
|
11937
|
+
"@north-light/plugin": "0.3.777",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|