@north-light/cli 0.3.749 → 0.3.751

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.
Files changed (53) hide show
  1. package/dist/builtin-memory/crouter-sdk/release-notes.md +10 -0
  2. package/dist/core/canvas/schema-pg/037-grant-principals.sql +50 -0
  3. package/dist/core/canvas/schema-version.d.ts +1 -1
  4. package/dist/core/canvas/schema-version.js +1 -1
  5. package/dist/core/grants/local.js +1 -1
  6. package/dist/core/grants/mirror.d.ts +11 -3
  7. package/dist/core/grants/mirror.js +12 -12
  8. package/dist/core/grants/owner.d.ts +7 -0
  9. package/dist/core/grants/owner.js +1 -0
  10. package/dist/core/grants/shadow.js +1 -1
  11. package/dist/core/grants/sync.js +1 -1
  12. package/dist/core/graph/reader.js +3 -3
  13. package/dist/core/import/load/bind.d.ts +1 -1
  14. package/dist/core/import/load/bind.js +11 -8
  15. package/dist/core/ledger/payer.d.ts +4 -4
  16. package/dist/core/ledger/payer.js +1 -1
  17. package/dist/core/llm/app-rungs.js +1 -1
  18. package/dist/core/llm/run.d.ts +2 -2
  19. package/dist/core/llm/run.js +2 -2
  20. package/dist/core/runtime/start-check.js +1 -1
  21. package/dist/core/spaces/permissions.js +1 -1
  22. package/dist/core/spaces/process.js +1 -1
  23. package/dist/daemon/api/app-listener.js +12 -12
  24. package/dist/daemon/api/handlers/git-credential.js +1 -1
  25. package/dist/daemon/api/handlers/runs.js +1 -1
  26. package/dist/daemon/api/principal.d.ts +11 -5
  27. package/dist/daemon/api/principal.js +1 -1
  28. package/docs/ci-runner.md +1 -1
  29. package/docs/sdk/release-notes.md +10 -0
  30. package/package.json +3 -3
  31. package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
  32. package/packages/crouter-api/dist/core/grants/local.js +1 -1
  33. package/packages/crouter-api/dist/core/grants/mirror.js +35 -11
  34. package/packages/crouter-api/dist/core/grants/owner.js +15 -0
  35. package/packages/crouter-api/dist/core/grants/shadow.js +4 -2
  36. package/packages/crouter-api/dist/core/grants/sync.js +5 -4
  37. package/packages/crouter-api/dist/core/graph/reader.js +8 -5
  38. package/packages/crouter-api/dist/core/ledger/payer.js +8 -3
  39. package/packages/crouter-api/dist/core/llm/app-rungs.js +2 -2
  40. package/packages/crouter-api/dist/core/llm/run.js +3 -2
  41. package/packages/crouter-api/dist/core/runtime/start-check.js +2 -2
  42. package/packages/crouter-api/dist/core/spaces/permissions.js +10 -4
  43. package/packages/crouter-api/dist/core/spaces/process.js +5 -3
  44. package/packages/crouter-api/dist/daemon/api/handlers/git-credential.js +12 -2
  45. package/packages/crouter-api/dist/daemon/api/principal.js +26 -7
  46. package/packages/crouter-api/package.json +1 -1
  47. package/packages/crouter-identity/dist/index.d.ts +4 -2
  48. package/packages/crouter-identity/dist/index.js +31 -12
  49. package/packages/crouter-identity/package.json +1 -1
  50. package/packages/crouter-plugin/dist/serve.js +4 -1
  51. package/packages/crouter-plugin/dist/verify.js +36 -8
  52. package/packages/crouter-plugin/package.json +3 -3
  53. package/runtime.lock.json +14 -14
@@ -1,8 +1,7 @@
1
- import { JwksCache, verifyCallToken } from '@north-light/identity';
1
+ import { JwksCache, parsePrincipal, verifyCallToken } from '@north-light/identity';
2
2
  import { kitLeafError } from './errors.js';
3
3
  const PROVIDER_ID = /^[A-Za-z0-9_-]{1,64}$/;
4
- const PRINCIPAL = /^(app|user):[A-Za-z0-9_-]{1,64}$/;
5
- const isAppOrUser = (value) => typeof value === 'string' && PRINCIPAL.test(value);
4
+ const isPrincipal = (value) => typeof value === 'string' && parsePrincipal(value) !== null;
6
5
  const isNonEmpty = (value) => typeof value === 'string' && value !== '';
7
6
  /** Validates `auth.providerId` and returns it bare, or undefined when none is configured. */
8
7
  export function normalizeProviderId(auth) {
@@ -42,27 +41,56 @@ export function createCallerVerifier(auth) {
42
41
  const { claims, chain, scope } = verified;
43
42
  const { grantee, initiating_app: initiatingApp, jti, act } = claims;
44
43
  const actor = act;
45
- if (scope === undefined || !isAppOrUser(grantee) || !isAppOrUser(initiatingApp) || !isNonEmpty(jti) || chain.length === 0 ||
44
+ if (scope === undefined || !isPrincipal(grantee) || !isPrincipal(initiatingApp) || !isNonEmpty(jti) || chain.length === 0 ||
46
45
  typeof actor !== 'object' || actor === null || Array.isArray(actor) || !isNonEmpty(actor.sub)) {
47
46
  throw unauthorized('The bearer token is not a valid outbound token for this provider.');
48
47
  }
49
- // A token from a directory that predates payers has no claim; its payer is the user.
50
- const payer = claims.payer;
51
- if (payer !== undefined && !/^(user|app):[A-Za-z0-9_-]{1,64}$/.test(String(payer))) {
48
+ // An absent payer claim means the namespace owner of the grantee, never `sub`.
49
+ const payerClaim = claims.payer;
50
+ if (payerClaim !== undefined && !isPrincipal(payerClaim)) {
52
51
  throw unauthorized('The bearer token is not a valid outbound token for this provider.');
53
52
  }
53
+ const payer = payerClaim ?? parsePrincipal(grantee).namespace;
54
+ const accounts = parseAccounts(claims.accounts);
55
+ const tools = parseTools(claims.tools);
56
+ let innermost = act;
57
+ while (innermost.act !== undefined)
58
+ innermost = innermost.act;
54
59
  return Object.freeze({
55
60
  sub: verified.sub,
56
61
  grantee,
57
- payer: payer === undefined ? verified.sub : String(payer),
62
+ payer,
58
63
  clientId: claims.client_id,
59
64
  scope: Object.freeze(scope.split(' ').filter((entry) => entry.length > 0)),
60
65
  initiatingApp,
61
66
  act: act,
62
67
  jti,
68
+ actor: innermost.sub,
69
+ ...(accounts !== undefined ? { accounts } : {}),
70
+ ...(tools !== undefined ? { tools } : {}),
63
71
  });
64
72
  };
65
73
  }
74
+ function parseAccounts(value) {
75
+ if (value === undefined)
76
+ return undefined;
77
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
78
+ throw unauthorized('The bearer token is not a valid outbound token for this provider.');
79
+ const out = {};
80
+ for (const [service, labels] of Object.entries(value)) {
81
+ if (!Array.isArray(labels) || !labels.every(isNonEmpty))
82
+ throw unauthorized('The bearer token is not a valid outbound token for this provider.');
83
+ out[service] = Object.freeze([...labels]);
84
+ }
85
+ return Object.freeze(out);
86
+ }
87
+ function parseTools(value) {
88
+ if (value === undefined)
89
+ return undefined;
90
+ if (!Array.isArray(value) || !value.every(isNonEmpty))
91
+ throw unauthorized('The bearer token is not a valid outbound token for this provider.');
92
+ return Object.freeze([...value]);
93
+ }
66
94
  /** The 403 for a leaf whose `<provider>:<group>` the verified token does not carry. */
67
95
  export function scopeMissing(scope, heldByOtherProvider) {
68
96
  return kitLeafError({
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/plugin",
3
- "version": "0.3.749",
3
+ "version": "0.3.751",
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.749",
31
- "@north-light/identity": "0.3.749"
30
+ "@north-light/api": "0.3.751",
31
+ "@north-light/identity": "0.3.751"
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.749",
3
+ "version": "0.3.751",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.749",
9
+ "version": "0.3.751",
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.749",
32
- "@north-light/plugin": "0.3.749",
31
+ "@north-light/identity": "0.3.751",
32
+ "@north-light/plugin": "0.3.751",
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.749",
11905
+ "version": "0.3.751",
11906
11906
  "license": "UNLICENSED"
11907
11907
  },
11908
11908
  "packages/crouter-env-docker": {
11909
11909
  "name": "@north-light/env-docker",
11910
- "version": "0.3.749",
11910
+ "version": "0.3.751",
11911
11911
  "license": "UNLICENSED"
11912
11912
  },
11913
11913
  "packages/crouter-identity": {
11914
11914
  "name": "@north-light/identity",
11915
- "version": "0.3.749",
11915
+ "version": "0.3.751",
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.749",
11923
+ "version": "0.3.751",
11924
11924
  "license": "UNLICENSED",
11925
11925
  "dependencies": {
11926
- "@north-light/api": "0.3.749",
11927
- "@north-light/identity": "0.3.749"
11926
+ "@north-light/api": "0.3.751",
11927
+ "@north-light/identity": "0.3.751"
11928
11928
  }
11929
11929
  },
11930
11930
  "packages/crouter-sdk": {
11931
11931
  "name": "@north-light/sdk",
11932
- "version": "0.3.749",
11932
+ "version": "0.3.751",
11933
11933
  "license": "UNLICENSED",
11934
11934
  "dependencies": {
11935
- "@north-light/api": "0.3.749",
11936
- "@north-light/identity": "0.3.749",
11937
- "@north-light/plugin": "0.3.749",
11935
+ "@north-light/api": "0.3.751",
11936
+ "@north-light/identity": "0.3.751",
11937
+ "@north-light/plugin": "0.3.751",
11938
11938
  "jose": "^6.2.1"
11939
11939
  },
11940
11940
  "bin": {