@feltdb/feltkit 0.3.30 → 0.3.32

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 (157) hide show
  1. package/dist/app.d.ts +67 -11
  2. package/dist/app.js +58 -2
  3. package/dist/app.js.map +1 -1
  4. package/dist/appboundry/build.js +2 -0
  5. package/dist/appboundry/build.js.map +1 -1
  6. package/dist/appboundry/guest.js +23 -1
  7. package/dist/appboundry/guest.js.map +1 -1
  8. package/dist/authorize.d.ts +24 -3
  9. package/dist/authorize.js.map +1 -1
  10. package/dist/broker/assertion.d.ts +68 -0
  11. package/dist/broker/assertion.js +104 -0
  12. package/dist/broker/assertion.js.map +1 -0
  13. package/dist/broker/keys.d.ts +9 -0
  14. package/dist/broker/keys.js +47 -0
  15. package/dist/broker/keys.js.map +1 -0
  16. package/dist/broker/server.d.ts +54 -0
  17. package/dist/broker/server.js +305 -0
  18. package/dist/broker/server.js.map +1 -0
  19. package/dist/cli/broker.d.ts +11 -0
  20. package/dist/cli/broker.js +72 -0
  21. package/dist/cli/broker.js.map +1 -0
  22. package/dist/cli/deploy.js +6 -0
  23. package/dist/cli/deploy.js.map +1 -1
  24. package/dist/cli/main.js +123 -0
  25. package/dist/cli/main.js.map +1 -1
  26. package/dist/client/index.d.ts +8 -2
  27. package/dist/client/index.js +45 -1
  28. package/dist/client/index.js.map +1 -1
  29. package/dist/docs.d.ts +1 -1
  30. package/dist/docs.js +3 -0
  31. package/dist/docs.js.map +1 -1
  32. package/dist/extension/build.d.ts +50 -0
  33. package/dist/extension/build.js +205 -0
  34. package/dist/extension/build.js.map +1 -0
  35. package/dist/extension/client-shim.d.ts +7 -0
  36. package/dist/extension/client-shim.js +13 -0
  37. package/dist/extension/client-shim.js.map +1 -0
  38. package/dist/extension/connect-ui.d.ts +24 -0
  39. package/dist/extension/connect-ui.js +67 -0
  40. package/dist/extension/connect-ui.js.map +1 -0
  41. package/dist/extension/connection.d.ts +109 -0
  42. package/dist/extension/connection.js +190 -0
  43. package/dist/extension/connection.js.map +1 -0
  44. package/dist/extension/host-core.d.ts +36 -0
  45. package/dist/extension/host-core.js +50 -0
  46. package/dist/extension/host-core.js.map +1 -0
  47. package/dist/extension/host.d.ts +1 -0
  48. package/dist/extension/host.js +8 -0
  49. package/dist/extension/host.js.map +1 -0
  50. package/dist/extension/icons.d.ts +13 -0
  51. package/dist/extension/icons.js +75 -0
  52. package/dist/extension/icons.js.map +1 -0
  53. package/dist/extension/identity.d.ts +40 -0
  54. package/dist/extension/identity.js +110 -0
  55. package/dist/extension/identity.js.map +1 -0
  56. package/dist/extension/options.d.ts +1 -0
  57. package/dist/extension/options.js +57 -0
  58. package/dist/extension/options.js.map +1 -0
  59. package/dist/extension/service-worker.d.ts +1 -0
  60. package/dist/extension/service-worker.js +38 -0
  61. package/dist/extension/service-worker.js.map +1 -0
  62. package/dist/extension/validate.d.ts +7 -0
  63. package/dist/extension/validate.js +143 -0
  64. package/dist/extension/validate.js.map +1 -0
  65. package/dist/extension/zip.d.ts +7 -0
  66. package/dist/extension/zip.js +94 -0
  67. package/dist/extension/zip.js.map +1 -0
  68. package/dist/index.d.ts +6 -2
  69. package/dist/index.js +1 -0
  70. package/dist/index.js.map +1 -1
  71. package/dist/policy.d.ts +179 -0
  72. package/dist/policy.js +311 -0
  73. package/dist/policy.js.map +1 -0
  74. package/dist/runtime/activity.d.ts +16 -0
  75. package/dist/runtime/activity.js.map +1 -1
  76. package/dist/runtime/application-authority.d.ts +22 -3
  77. package/dist/runtime/application-authority.js +94 -20
  78. package/dist/runtime/application-authority.js.map +1 -1
  79. package/dist/runtime/assemble.d.ts +13 -0
  80. package/dist/runtime/assemble.js +29 -1
  81. package/dist/runtime/assemble.js.map +1 -1
  82. package/dist/runtime/authority-contract.d.ts +55 -0
  83. package/dist/runtime/authority-contract.js +60 -0
  84. package/dist/runtime/authority-contract.js.map +1 -0
  85. package/dist/runtime/content.d.ts +50 -0
  86. package/dist/runtime/content.js +98 -1
  87. package/dist/runtime/content.js.map +1 -1
  88. package/dist/runtime/context.d.ts +86 -11
  89. package/dist/runtime/contract.js +11 -2
  90. package/dist/runtime/contract.js.map +1 -1
  91. package/dist/runtime/data.d.ts +25 -0
  92. package/dist/runtime/data.js +92 -8
  93. package/dist/runtime/data.js.map +1 -1
  94. package/dist/runtime/image-variants.d.ts +48 -0
  95. package/dist/runtime/image-variants.js +295 -0
  96. package/dist/runtime/image-variants.js.map +1 -0
  97. package/dist/runtime/integrations.d.ts +2 -0
  98. package/dist/runtime/integrations.js +10 -7
  99. package/dist/runtime/integrations.js.map +1 -1
  100. package/dist/runtime/invocations.d.ts +3 -0
  101. package/dist/runtime/invocations.js +1 -1
  102. package/dist/runtime/invocations.js.map +1 -1
  103. package/dist/runtime/live.d.ts +10 -7
  104. package/dist/runtime/live.js +24 -12
  105. package/dist/runtime/live.js.map +1 -1
  106. package/dist/runtime/local-authority.d.ts +80 -5
  107. package/dist/runtime/local-authority.js +259 -14
  108. package/dist/runtime/local-authority.js.map +1 -1
  109. package/dist/runtime/policies.d.ts +89 -0
  110. package/dist/runtime/policies.js +152 -0
  111. package/dist/runtime/policies.js.map +1 -0
  112. package/dist/runtime/readiness.js +31 -1
  113. package/dist/runtime/readiness.js.map +1 -1
  114. package/dist/runtime/runtime.d.ts +21 -1
  115. package/dist/runtime/runtime.js +200 -7
  116. package/dist/runtime/runtime.js.map +1 -1
  117. package/dist/runtime/services-rules.d.ts +9 -0
  118. package/dist/runtime/services-rules.js +47 -1
  119. package/dist/runtime/services-rules.js.map +1 -1
  120. package/dist/runtime/services.d.ts +117 -9
  121. package/dist/runtime/services.js +154 -13
  122. package/dist/runtime/services.js.map +1 -1
  123. package/dist/server/admin.d.ts +21 -0
  124. package/dist/server/admin.js +114 -0
  125. package/dist/server/admin.js.map +1 -1
  126. package/dist/server/index.js +33 -6
  127. package/dist/server/index.js.map +1 -1
  128. package/dist/server/oauth.d.ts +32 -2
  129. package/dist/server/oauth.js +130 -23
  130. package/dist/server/oauth.js.map +1 -1
  131. package/dist/server/operators.d.ts +1 -0
  132. package/dist/server/operators.js +1 -1
  133. package/dist/server/operators.js.map +1 -1
  134. package/dist/server/project.d.ts +3 -0
  135. package/dist/server/project.js +2 -2
  136. package/dist/server/project.js.map +1 -1
  137. package/dist/testing/index.d.ts +11 -0
  138. package/dist/testing/index.js +7 -0
  139. package/dist/testing/index.js.map +1 -1
  140. package/docs/AGENT-OPERATIONS.md +1 -1
  141. package/docs/ARCHITECTURE.md +2 -1
  142. package/docs/CONNECTIONS.md +10 -3
  143. package/docs/EXTENSION-HOSTS.md +64 -5
  144. package/docs/GUARANTEES.md +82 -6
  145. package/docs/LOCAL-AUTHORITY.md +118 -0
  146. package/docs/POLICIES.md +121 -0
  147. package/docs/README.md +5 -2
  148. package/docs/SECURITY.md +69 -0
  149. package/docs/SIGN-IN-BROKER.md +77 -0
  150. package/docs/TRANSACTIONS.md +4 -0
  151. package/package.json +13 -9
  152. package/skills/.claude-plugin/marketplace.json +1 -1
  153. package/skills/.claude-plugin/plugin.json +1 -1
  154. package/skills/feltkit-agent/SKILL.md +1 -1
  155. package/skills/feltkit-build/SKILL.md +10 -0
  156. package/skills/feltkit-data/SKILL.md +13 -1
  157. package/skills/feltkit-services/SKILL.md +14 -1
@@ -5,15 +5,47 @@
5
5
  */
6
6
  import { authBoundryAuthority } from "./authboundry.js";
7
7
  const secretId = (ref) => ref.replace(/^credential-ref:/, "");
8
+ /** The AuthBoundry principal of an application principal (a person): `principal(id)` from the config, else `user:<id>`. */
9
+ export function authorityPrincipalOf(config, id) {
10
+ return config.principal ? config.principal(id) : `user:${id}`;
11
+ }
12
+ /**
13
+ * The AuthBoundry principal `onBehalfOf` names, or null when it is malformed. A string with a ":" is
14
+ * already an AuthBoundry principal (`<type>:<id>`, e.g. `user:ada`) and is sent unchanged, so callers
15
+ * that map it themselves keep working; one without is an application principal id, mapped as
16
+ * `ctx.authority.grants` maps the delegator. `{ person }` and `{ principal }` say which explicitly.
17
+ */
18
+ export function onBehalfOfPrincipal(config, value) {
19
+ const text = (v) => (typeof v === "string" && v.trim() ? v : null);
20
+ if (typeof value === "string") {
21
+ if (!text(value))
22
+ return null;
23
+ return value.includes(":") ? value : authorityPrincipalOf(config, value);
24
+ }
25
+ if (!value || typeof value !== "object")
26
+ return null;
27
+ const keys = Object.keys(value);
28
+ if (keys.length !== 1)
29
+ return null;
30
+ if ("person" in value) {
31
+ const id = text(value.person);
32
+ const mapped = id ? authorityPrincipalOf(config, id) : null;
33
+ return text(mapped);
34
+ }
35
+ if ("principal" in value)
36
+ return text(value.principal);
37
+ return null;
38
+ }
8
39
  /** Where the private authority's executor keeps its agent credential (authority.local; FeltKit custody, never a record). */
9
40
  export const LOCAL_AGENT_REF = "credential-ref:authboundry-local-agent";
10
41
  /** The configured AuthBoundry origin, or why there is none. Production never uses a development default. */
11
42
  export function authorityUrl(config, production, env = process.env) {
43
+ // An empty value (a variable set to "") is no address, for every consumer alike.
12
44
  if (config.url === undefined)
13
45
  return null;
14
46
  if (typeof config.url === "string")
15
- return config.url;
16
- return env[config.url.env] ?? (production ? null : config.url.development ?? null);
47
+ return config.url || null;
48
+ return env[config.url.env] || (production ? null : config.url.development || null);
17
49
  }
18
50
  /** The application id to ask AuthBoundry under: the literal, else the variable, else (outside production) its development value, else the app's name. */
19
51
  export function authorityApplication(config, production, appName, env = process.env) {
@@ -27,28 +59,65 @@ export function applicationAuthority(host) {
27
59
  };
28
60
  return {
29
61
  grants: host.grants ?? { list: async () => noGrants(), grant: async () => noGrants(), revoke: async () => noGrants() },
62
+ agents: host.agents ?? { register: async () => noGrants(), list: async () => noGrants(), revoke: async () => noGrants() },
30
63
  async decide(request) {
31
64
  const config = host.config;
32
- const executor = config?.executor.principal ?? "";
33
- const onBehalfOf = request.onBehalfOf ?? null;
34
- const refused = (outcome, reason) => ({ allowed: false, outcome, decisionId: null, reason, capability: request.capability, executor, onBehalfOf, delegationId: null, executorProof: { proven: false, method: "asserted", principal: executor, agentCredentialId: null } });
65
+ let executor = config?.executor.principal ?? "";
66
+ let agent = null;
67
+ // The AuthBoundry principal asked about (FRAME-GAP-11): an application id is mapped like grants' delegator.
68
+ const asked = request.onBehalfOf === undefined ? null : onBehalfOfPrincipal(config ?? {}, request.onBehalfOf);
69
+ const onBehalfOf = asked ?? (typeof request.onBehalfOf === "string" ? request.onBehalfOf : null);
70
+ let authorityMode = null;
71
+ let lasting = false;
72
+ const decisionOf = (outcome, reason) => ({ allowed: false, outcome, decisionId: null, reason, capability: request.capability, executor, agent, onBehalfOf, delegationId: null, executorProof: { proven: false, method: "asserted", principal: executor, agentCredentialId: null }, authorityMode, ...(lasting ? { lasting } : {}) });
35
73
  if (!config)
36
- return refused("unavailable", "No authority is configured (feltkit({ authority })), so nothing is allowed.");
37
- if (typeof request.capability !== "string" || !request.capability)
38
- return refused("invalid", "A capability is required.");
39
- if (request.onBehalfOf !== undefined && (typeof request.onBehalfOf !== "string" || !request.onBehalfOf.trim()))
40
- return refused("invalid", "onBehalfOf must be a principal id.");
74
+ return ((lasting = true), decisionOf("unavailable", "No authority is configured (feltkit({ authority })), so nothing is allowed.")); // a configuration state
75
+ // Every refusal FeltKit makes itself (before or instead of asking AuthBoundry) is recorded like a decision.
76
+ const refused = async (outcome, reason) => {
77
+ const r = decisionOf(outcome, reason);
78
+ await host.record?.({ capability: String(request.capability ?? ""), executor, onBehalfOf, decision: { allowed: false, decisionId: null, outcome: r.outcome, reason: r.reason, onBehalfOf, delegationId: null, executorProof: r.executorProof }, durationMs: 0, authorityMode });
79
+ return r;
80
+ };
81
+ // Which principal decides: the executor, or an agent with its own credential (never another's).
41
82
  const external = authorityUrl(config, host.production, host.env);
83
+ const resolved = host.agentFor
84
+ ? await host.agentFor(request.agent)
85
+ : request.agent !== undefined
86
+ ? { refused: "unavailable", reason: "Decisions as an agent need the local authority (authority.local).", mode: null, lasting: true }
87
+ : { decider: "executor", mode: external || !config.local ? "hosted-executor" : "local-executor" };
88
+ // How this decision is evaluated (FK-16): recorded with it, never consulted to authorize.
89
+ authorityMode = resolved.mode;
90
+ if ("refused" in resolved) {
91
+ if (request.agent !== undefined)
92
+ agent = String(request.agent);
93
+ lasting = Boolean(resolved.lasting);
94
+ return refused(resolved.refused, resolved.reason);
95
+ }
96
+ const as = resolved.decider === "agent" ? resolved : null;
97
+ if (as) {
98
+ executor = as.principal;
99
+ agent = as.principal;
100
+ }
101
+ const invalid = (reason) => ((authorityMode = null), refused("invalid", reason)); // nothing was evaluated
102
+ if (typeof request.capability !== "string" || !request.capability)
103
+ return invalid("A capability is required.");
104
+ if (request.onBehalfOf !== undefined && asked === null)
105
+ return invalid('onBehalfOf must be a principal id ("ada"), an AuthBoundry principal ("user:ada"), { person } or { principal }.');
42
106
  const url = external ?? (await host.localUrl?.()) ?? null;
43
107
  // The executor's agent credential: the one configured, or the private authority's own.
44
- const agentRef = config.executor.credential ?? (!external && config.local ? LOCAL_AGENT_REF : undefined);
45
- if (!url)
108
+ const agentRef = as ? undefined : config.executor.credential ?? (!external && config.local ? LOCAL_AGENT_REF : undefined);
109
+ if (!url) {
110
+ // Nothing was evaluated. No address configured, or a local authority that failed to start (it is not
111
+ // started again until the application restarts): configuration states, not cleared by retrying.
112
+ authorityMode = null;
113
+ lasting = !config.local || host.localState?.() === "failed";
46
114
  return refused("unavailable", config.local ? "The local authority is not running (see readiness)." : `AuthBoundry's address is not configured (${typeof config.url === "string" ? "url" : config.url?.env ?? "url"}).`);
115
+ }
47
116
  const started = Date.now();
48
117
  const ask = async (checkCredential, agentCredential) => authBoundryAuthority({ url, application: authorityApplication(config, host.production, host.appName, host.env), checkCredential, enforcementPoint: "feltkit.application", ...(config.timeoutMs ? { timeoutMs: config.timeoutMs } : {}), ...(host.fetch ? { fetch: host.fetch } : {}) }).decide({
49
- principal: { id: executor, type: config.executor.type ?? "agent" },
118
+ principal: { id: executor, type: as ? "agent" : config.executor.type ?? "agent" },
50
119
  capability: request.capability,
51
- ...(request.onBehalfOf !== undefined ? { onBehalfOf: request.onBehalfOf } : {}),
120
+ ...(asked !== null ? { onBehalfOf: asked } : {}),
52
121
  ...(request.resource ? { resource: request.resource } : {}),
53
122
  ...(request.context ? { context: request.context } : {}),
54
123
  ...(agentCredential ? { agentCredential } : {}),
@@ -56,17 +125,22 @@ export function applicationAuthority(host) {
56
125
  let decision;
57
126
  try {
58
127
  const reference = (ref) => ({ reference: { secretId: secretId(ref), ...(host.tenantId ? { tenantId: host.tenantId } : {}) }, context: { purpose: `authority decision ${request.capability}` } });
59
- decision = await host.credentials.withSecret(reference(config.checkCredential), (check) => agentRef
60
- ? host.credentials.withSecret(reference(agentRef), (agent) => ask(check.value, agent.value))
61
- : ask(check.value));
128
+ decision = await host.credentials.withSecret(reference(config.checkCredential), (check) => as
129
+ ? ask(check.value, as.credential)
130
+ : agentRef
131
+ ? host.credentials.withSecret(reference(agentRef), (held) => ask(check.value, held.value))
132
+ : ask(check.value));
62
133
  }
63
134
  catch (error) {
64
- // A credential that is missing or unreadable is a refusal, named without its value.
135
+ // A credential that is missing or unreadable is a refusal, named without its value. Nothing was evaluated.
136
+ // One that is not set (or not usable here) is a configuration state: retrying does not change it.
137
+ authorityMode = null;
138
+ lasting = ["CREDENTIAL_UNAVAILABLE", "INVALID_REQUEST"].includes(String(error.code));
65
139
  return refused("unavailable", `The authority's credential is unavailable: ${error.message}`);
66
140
  }
67
141
  // Recorded before it is returned: the evidence (and the attempt it belongs to) has it first.
68
- await host.record?.({ capability: request.capability, executor, onBehalfOf, decision, durationMs: Date.now() - started });
69
- return { ...decision, capability: request.capability, executor };
142
+ await host.record?.({ capability: request.capability, executor, onBehalfOf, decision, durationMs: Date.now() - started, authorityMode: resolved.mode });
143
+ return { ...decision, capability: request.capability, executor, agent, authorityMode: resolved.mode };
70
144
  },
71
145
  };
72
146
  }
@@ -1 +1 @@
1
- {"version":3,"file":"application-authority.js","sourceRoot":"","sources":["../../src/runtime/application-authority.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,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AAC;AACJ,CAAC"}
@@ -1,2 +1,15 @@
1
+ /**
2
+ * Assembling a project from its module namespaces: function names, the one application,
3
+ * and unique capabilities. No Node APIs, so the same code assembles the project inside
4
+ * an AppBoundry artifact (src/appboundry/guest.ts) as it does in `feltkit dev`.
5
+ */
6
+ import { type FeltKitApp, type FunctionDefinition } from "../app.js";
1
7
  import type { LoadedProject } from "./runtime.js";
8
+ import { type ResolvedPolicyRule } from "../policy.js";
2
9
  export declare function assemble(namespaces: Record<string, Record<string, unknown>>): LoadedProject;
10
+ /**
11
+ * The application's declared policies, by function name. A policy that names a function the project
12
+ * does not export is refused: a rule that silently stops applying is the failure ownership exists to
13
+ * prevent (test/ownership.test.ts, "the defect").
14
+ */
15
+ export declare function resolvePolicies(app: FeltKitApp, functions: Map<string, FunctionDefinition>): ResolvedPolicyRule[];
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { isFeltKitApp, isFunctionDefinition } from "../app.js";
7
7
  import { FeltKitError } from "../errors.js";
8
+ import { nameCollections } from "../policy.js";
8
9
  export function assemble(namespaces) {
9
10
  const apps = new Set();
10
11
  const functions = new Map();
@@ -40,6 +41,33 @@ export function assemble(namespaces) {
40
41
  throw new FeltKitError("CONFIGURATION", `Capability ${key} is exposed by both ${other} and ${name}.`);
41
42
  capabilities.set(key, name);
42
43
  }
43
- return { app, functions, modules: Object.keys(namespaces).sort(), loadedAt: new Date().toISOString() };
44
+ return { app, functions, policies: resolvePolicies(app, functions), modules: Object.keys(namespaces).sort(), loadedAt: new Date().toISOString() };
45
+ }
46
+ /**
47
+ * The application's declared policies, by function name. A policy that names a function the project
48
+ * does not export is refused: a rule that silently stops applying is the failure ownership exists to
49
+ * prevent (test/ownership.test.ts, "the defect").
50
+ */
51
+ export function resolvePolicies(app, functions) {
52
+ const names = new Map();
53
+ for (const [name, fn] of functions)
54
+ names.set(fn, [...(names.get(fn) ?? []), name]);
55
+ return app.policies.map((rule) => {
56
+ const resolved = rule.functions.flatMap((fn) => {
57
+ const found = typeof fn === "string" ? (functions.has(fn) ? [fn] : []) : names.get(fn) ?? [];
58
+ if (found.length === 0) {
59
+ throw new FeltKitError("CONFIGURATION", `Policy ${rule.id} names a function that no module in feltkit/ exports. Export it, or remove it from the policy.`);
60
+ }
61
+ return found;
62
+ });
63
+ const { functions: _f, resource, when, ...rest } = rule;
64
+ return {
65
+ ...rest,
66
+ ...(when ? { when: when.map(nameCollections) } : {}),
67
+ functions: [...new Set(resolved)].sort(),
68
+ ...(resource ? { resource: { collection: typeof resource.collection === "string" ? resource.collection : resource.collection.name, id: resource.id } } : {}),
69
+ source: "code",
70
+ };
71
+ });
44
72
  }
45
73
  //# sourceMappingURL=assemble.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"assemble.js","sourceRoot":"","sources":["../../src/runtime/assemble.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAA4C,MAAM,WAAW,CAAC;AACzG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,UAAU,QAAQ,CAAC,UAAmD;IAC1E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAc,CAAC;IACnC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA8B,CAAC;IACxD,KAAK,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACjE,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,YAAY,CAAC,eAAe,EAAE,gBAAgB,UAAU,2EAA2E,CAAC,CAAC;QACjJ,CAAC;QACD,KAAK,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5D,IAAI,YAAY,CAAC,KAAK,CAAC;gBAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;iBACp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E,gGAAgG,CAAC,CAAC;YAC7J,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QACxD,OAAO;YACL,GAAG,IAAI;YACP,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpD,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE;YACxC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,OAAO,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5J,MAAM,EAAE,MAAe;SACxB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * What FeltKit relies on from AuthBoundry, stated once (FK-16). The runtime, FeltKit's own tests and the
3
+ * release gate (scripts/release-prerequisites.mjs, which imports this module from the built package) all
4
+ * decide "is per-agent delegation installed" with this one function, on a STARTED local authority: a
5
+ * capability is what the running authority offers, not what a version number or a source text suggests.
6
+ *
7
+ * And how an authority decision was evaluated: evidence recorded with every decision (never an input to
8
+ * authorization).
9
+ */
10
+ /** The methods a started @authboundry/local must offer for per-agent delegation (each agent decides as itself). */
11
+ export declare const PER_AGENT_METHODS: readonly ["registerAgent", "revokeAgent", "agentCredentialOf", "agents"];
12
+ /** The per-agent methods a started local authority lacks (empty: per-agent delegation is installed). */
13
+ export declare function missingPerAgentMethods(authority: object | null | undefined): string[];
14
+ /** True when a started local authority offers per-agent delegation. */
15
+ export declare function perAgentDelegation(authority: object | null | undefined): boolean;
16
+ /**
17
+ * How an authority decision was evaluated (evidence; never consulted to authorize anything):
18
+ * local-executor local authority; a person, service or anonymous caller, decided as the executor
19
+ * local-per-agent local authority; an agent decided as itself, with its own grants
20
+ * local-executor-grants-opt-in local authority without per-agent delegation; an agent caller decided as the
21
+ * executor because the owner set authority.local.agentCallers: "executor-grants"
22
+ * hosted-executor hosted AuthBoundry; a non-agent caller decided as the executor
23
+ * hosted-executor-grants hosted AuthBoundry; an agent caller decided as the executor, with its grants
24
+ * (the documented hosted contract; authority.local.agentCallers does not govern it)
25
+ */
26
+ export type AuthorityMode = "local-executor" | "local-per-agent" | "local-executor-grants-opt-in" | "hosted-executor" | "hosted-executor-grants";
27
+ export declare const AUTHORITY_MODES: readonly AuthorityMode[];
28
+ /**
29
+ * Start a throwaway private AuthBoundry with an installed @authboundry/local's `startLocalAuthority`, for probing what
30
+ * it offers (the release gate and FeltKit's own tests use this, then `missingPerAgentMethods` on the result, so they
31
+ * judge per-agent delegation exactly as the runtime does). The caller must `close()` it.
32
+ */
33
+ export declare function startProbeAuthority(startLocalAuthority: (options: Record<string, unknown>) => Promise<object & {
34
+ close(): Promise<void>;
35
+ check(capability: string, onBehalfOf?: string): Promise<{
36
+ status: number;
37
+ body: any;
38
+ }>;
39
+ }>): Promise<{
40
+ authority: object & {
41
+ close(): Promise<void>;
42
+ check(capability: string, onBehalfOf?: string): Promise<{
43
+ status: number;
44
+ body: any;
45
+ }>;
46
+ };
47
+ close(): Promise<void>;
48
+ }>;
49
+ /** Per-agent delegation of the INSTALLED @authboundry/local (`load` imports it), judged on a started authority. */
50
+ export declare function installedPerAgentDelegation(load: () => Promise<{
51
+ startLocalAuthority: Parameters<typeof startProbeAuthority>[0];
52
+ }>): Promise<{
53
+ present: boolean;
54
+ missing: string[];
55
+ }>;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * What FeltKit relies on from AuthBoundry, stated once (FK-16). The runtime, FeltKit's own tests and the
3
+ * release gate (scripts/release-prerequisites.mjs, which imports this module from the built package) all
4
+ * decide "is per-agent delegation installed" with this one function, on a STARTED local authority: a
5
+ * capability is what the running authority offers, not what a version number or a source text suggests.
6
+ *
7
+ * And how an authority decision was evaluated: evidence recorded with every decision (never an input to
8
+ * authorization).
9
+ */
10
+ /** The methods a started @authboundry/local must offer for per-agent delegation (each agent decides as itself). */
11
+ export const PER_AGENT_METHODS = ["registerAgent", "revokeAgent", "agentCredentialOf", "agents"];
12
+ /** The per-agent methods a started local authority lacks (empty: per-agent delegation is installed). */
13
+ export function missingPerAgentMethods(authority) {
14
+ if (!authority)
15
+ return [...PER_AGENT_METHODS];
16
+ return PER_AGENT_METHODS.filter((m) => typeof authority[m] !== "function");
17
+ }
18
+ /** True when a started local authority offers per-agent delegation. */
19
+ export function perAgentDelegation(authority) {
20
+ return missingPerAgentMethods(authority).length === 0;
21
+ }
22
+ export const AUTHORITY_MODES = ["local-executor", "local-per-agent", "local-executor-grants-opt-in", "hosted-executor", "hosted-executor-grants"];
23
+ /**
24
+ * Start a throwaway private AuthBoundry with an installed @authboundry/local's `startLocalAuthority`, for probing what
25
+ * it offers (the release gate and FeltKit's own tests use this, then `missingPerAgentMethods` on the result, so they
26
+ * judge per-agent delegation exactly as the runtime does). The caller must `close()` it.
27
+ */
28
+ export async function startProbeAuthority(startLocalAuthority) {
29
+ const { mkdtempSync, rmSync } = await import("node:fs");
30
+ const { tmpdir } = await import("node:os");
31
+ const { join } = await import("node:path");
32
+ const { randomBytes } = await import("node:crypto");
33
+ const dataDir = mkdtempSync(join(tmpdir(), "feltkit-authority-probe-"));
34
+ try {
35
+ const authority = await startLocalAuthority({ dataDir, application: { id: "feltkit-authority-probe", capabilities: ["probe.capability"] }, executor: { id: "agent:feltkit-authority-probe" }, adminSecret: randomBytes(32).toString("base64url"), logger: { info() { }, warn() { } } });
36
+ return {
37
+ authority,
38
+ async close() {
39
+ await authority.close().catch(() => undefined);
40
+ rmSync(dataDir, { recursive: true, force: true });
41
+ },
42
+ };
43
+ }
44
+ catch (error) {
45
+ rmSync(dataDir, { recursive: true, force: true });
46
+ throw error;
47
+ }
48
+ }
49
+ /** Per-agent delegation of the INSTALLED @authboundry/local (`load` imports it), judged on a started authority. */
50
+ export async function installedPerAgentDelegation(load) {
51
+ const probe = await startProbeAuthority((await load()).startLocalAuthority);
52
+ try {
53
+ const missing = missingPerAgentMethods(probe.authority);
54
+ return { present: missing.length === 0, missing };
55
+ }
56
+ finally {
57
+ await probe.close();
58
+ }
59
+ }
60
+ //# sourceMappingURL=authority-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-contract.js","sourceRoot":"","sources":["../../src/runtime/authority-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,mHAAmH;AACnH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,mBAAmB,EAAE,QAAQ,CAAU,CAAC;AAE1G,wGAAwG;AACxG,MAAM,UAAU,sBAAsB,CAAC,SAAoC;IACzE,IAAI,CAAC,SAAS;QAAE,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAC9C,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAQ,SAAqC,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;AAC1G,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,kBAAkB,CAAC,SAAoC;IACrE,OAAO,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACxD,CAAC;AAmBD,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,wBAAwB,CAAC,CAAC;AAE5K;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAm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AED,mHAAmH;AACnH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,IAAuF;IACvI,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC5E,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACxD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IACpD,CAAC;YAAS,CAAC;QACT,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;AACH,CAAC"}
@@ -21,6 +21,12 @@ export type FileLinkGrant = {
21
21
  fileId: string;
22
22
  expiresAt: number;
23
23
  disposition: "attachment" | "inline";
24
+ /** The checksum of the content the link was issued for: other content behind the file is not served by it. */
25
+ checksum?: string;
26
+ /** A declared image variant (`services.files.variants`) to serve instead of the original. */
27
+ variant?: string;
28
+ /** A cacheable link (`files.link(id, { cache: true })`): served `private, max-age=<remaining>, immutable`. */
29
+ cache?: true;
24
30
  } | {
25
31
  kind: "upload";
26
32
  expiresAt: number;
@@ -36,8 +42,34 @@ export type FileLinkGrant = {
36
42
  maxBytes: number;
37
43
  metadata?: Record<string, string | number | boolean>;
38
44
  };
45
+ /** A cacheable link's token: the same scope (file, content, variant, caller, window…) gives the same token. */
46
+ export declare function derivedLinkToken(scope: readonly unknown[]): string;
39
47
  /** Where file bytes are kept, one row per file. */
40
48
  export declare const FILE_CONTENT_COLLECTION = "_feltkit_file_content";
49
+ /**
50
+ * Derived renditions of stored bytes (image variants), one row per source storage key and variant
51
+ * name. A row is derived content: produced from its source, released with it (`releaseVariants`),
52
+ * and never served except through a link to a file whose bytes it was derived from.
53
+ */
54
+ export declare const FILE_VARIANT_COLLECTION = "_feltkit_file_variants";
55
+ export interface StoredVariant {
56
+ id: string;
57
+ /** The storage key of the bytes it was derived from. */
58
+ source: string;
59
+ variant: string;
60
+ /** Digest of the variant's spec and codec: a changed declaration derives it again. */
61
+ spec: string;
62
+ /** derived: `data` holds it. original: it could not be derived (reason), and the original is served. */
63
+ status: "derived" | "original";
64
+ reason?: string;
65
+ data?: string;
66
+ size?: number;
67
+ checksum?: string;
68
+ width?: number;
69
+ height?: number;
70
+ contentType?: string;
71
+ storedAt: number;
72
+ }
41
73
  export declare class FileContent {
42
74
  #private;
43
75
  constructor(db: StateFirstDB);
@@ -78,11 +110,29 @@ export declare class FileContent {
78
110
  * Idempotent: `true` when this call removed them, `false` when they were already gone.
79
111
  */
80
112
  release(storageKey: string): Promise<boolean>;
113
+ /** The stored variant of `source` named `variant`, if any (whatever spec it was derived under). */
114
+ variant(source: string, variant: string): Promise<StoredVariant | null>;
115
+ /**
116
+ * Keep a derived variant (or the reason it could not be derived). Replaces a row derived under an
117
+ * older spec; if another request stored the same one first, that one is kept and returned.
118
+ */
119
+ storeVariant(input: Omit<StoredVariant, "id" | "storedAt" | "data" | "size" | "checksum"> & {
120
+ bytes?: Uint8Array;
121
+ }): Promise<StoredVariant>;
122
+ /** A derived variant's bytes, verified against their digest. */
123
+ readVariant(row: StoredVariant): Uint8Array;
124
+ /** Remove every variant derived from `source` (its bytes are being released). Returns how many were removed. */
125
+ releaseVariants(source: string): Promise<number>;
81
126
  /**
82
127
  * Issue an opaque link token for `grant`. Only its SHA-256 is stored, so the stored row cannot
83
128
  * be replayed as a link. The function that issues it has already authorized the caller.
84
129
  */
85
130
  issueLink(grant: FileLinkGrant): Promise<string>;
131
+ /**
132
+ * Store the grant for a token the caller derived (a cacheable link: the same token for the same
133
+ * file, content, caller and window). Issuing it again is idempotent; only its digest is stored.
134
+ */
135
+ issueDerivedLink(token: string, grant: FileLinkGrant): Promise<string>;
86
136
  /**
87
137
  * Resolve a link token. Unknown, expired and (for upload links) already-used tokens are all
88
138
  * NOT_FOUND. An upload link is consumed here, before its bytes are read: it works once.
@@ -1,13 +1,30 @@
1
- import { createHash, randomBytes, randomUUID } from "node:crypto";
1
+ import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
2
2
  import { FeltKitError } from "../errors.js";
3
3
  import { readAll } from "./paged-read.js";
4
4
  /** Outstanding file links (download and upload), keyed by the SHA-256 of their token. */
5
5
  export const FILE_LINK_COLLECTION = "_feltkit_file_links";
6
6
  const LINK_PREFIX = "fkf_";
7
7
  const digestOf = (token) => createHash("sha256").update(token).digest("hex");
8
+ /**
9
+ * The key cacheable link tokens are derived under: random per process, never stored. A token is
10
+ * HMAC(key, its scope), so it cannot be computed from anything in the database, and a restart
11
+ * issues new URLs (one more download per file, not a weaker link).
12
+ */
13
+ const LINK_KEY = randomBytes(32);
14
+ /** A cacheable link's token: the same scope (file, content, variant, caller, window…) gives the same token. */
15
+ export function derivedLinkToken(scope) {
16
+ return LINK_PREFIX + createHmac("sha256", LINK_KEY).update(JSON.stringify(scope)).digest("base64url");
17
+ }
8
18
  /** Where file bytes are kept, one row per file. */
9
19
  export const FILE_CONTENT_COLLECTION = "_feltkit_file_content";
10
20
  const PREFIX = "feltkit-content:";
21
+ /**
22
+ * Derived renditions of stored bytes (image variants), one row per source storage key and variant
23
+ * name. A row is derived content: produced from its source, released with it (`releaseVariants`),
24
+ * and never served except through a link to a file whose bytes it was derived from.
25
+ */
26
+ export const FILE_VARIANT_COLLECTION = "_feltkit_file_variants";
27
+ const variantId = (source, variant) => createHash("sha256").update(`${source}\0${variant}`).digest("hex");
11
28
  export class FileContent {
12
29
  #db;
13
30
  constructor(db) {
@@ -96,6 +113,68 @@ export class FileContent {
96
113
  throw error;
97
114
  }
98
115
  }
116
+ /** The stored variant of `source` named `variant`, if any (whatever spec it was derived under). */
117
+ async variant(source, variant) {
118
+ const row = await this.#db.collection(FILE_VARIANT_COLLECTION).get(variantId(source, variant));
119
+ if (!row)
120
+ return null;
121
+ const { __version: _version, ...value } = row;
122
+ return value;
123
+ }
124
+ /**
125
+ * Keep a derived variant (or the reason it could not be derived). Replaces a row derived under an
126
+ * older spec; if another request stored the same one first, that one is kept and returned.
127
+ */
128
+ async storeVariant(input) {
129
+ const id = variantId(input.source, input.variant);
130
+ const { bytes, ...rest } = input;
131
+ const value = {
132
+ ...rest,
133
+ id,
134
+ ...(bytes ? { data: Buffer.from(bytes).toString("base64"), size: bytes.byteLength, checksum: createHash("sha256").update(bytes).digest("hex") } : {}),
135
+ storedAt: Date.now(),
136
+ };
137
+ const rows = this.#db.collection(FILE_VARIANT_COLLECTION);
138
+ const existing = await rows.get(id);
139
+ try {
140
+ await this.#db.transaction({ operations: [existing ? { collection: FILE_VARIANT_COLLECTION, id, ifVersion: existing.__version, value: value } : { collection: FILE_VARIANT_COLLECTION, id, requireAbsent: true, value: value }] });
141
+ return value;
142
+ }
143
+ catch (error) {
144
+ const now = await this.variant(input.source, input.variant);
145
+ if (now && now.spec === input.spec)
146
+ return now; // produced concurrently: the same derivation
147
+ throw error;
148
+ }
149
+ }
150
+ /** A derived variant's bytes, verified against their digest. */
151
+ readVariant(row) {
152
+ const bytes = new Uint8Array(Buffer.from(row.data ?? "", "base64"));
153
+ if (!row.checksum || createHash("sha256").update(bytes).digest("hex") !== row.checksum) {
154
+ throw new FeltKitError("INTERNAL", `Variant ${row.variant} failed its checksum; the stored bytes do not match the recorded digest.`);
155
+ }
156
+ return bytes;
157
+ }
158
+ /** Remove every variant derived from `source` (its bytes are being released). Returns how many were removed. */
159
+ async releaseVariants(source) {
160
+ const rows = (await readAll(this.#db, { collection: FILE_VARIANT_COLLECTION, where: [{ field: "source", eq: source }] }));
161
+ let removed = 0;
162
+ for (const row of rows) {
163
+ const remove = (version) => this.#db.transaction({ operations: [{ collection: FILE_VARIANT_COLLECTION, id: row.id, ifVersion: version }] });
164
+ try {
165
+ await remove(row.__version);
166
+ }
167
+ catch (error) {
168
+ // Derived again meanwhile: remove what is there now; gone already is the same outcome.
169
+ const now = await this.#db.collection(FILE_VARIANT_COLLECTION).get(row.id);
170
+ if (!now)
171
+ continue;
172
+ await remove(now.__version);
173
+ }
174
+ removed += 1;
175
+ }
176
+ return removed;
177
+ }
99
178
  /**
100
179
  * Issue an opaque link token for `grant`. Only its SHA-256 is stored, so the stored row cannot
101
180
  * be replayed as a link. The function that issues it has already authorized the caller.
@@ -106,6 +185,24 @@ export class FileContent {
106
185
  await this.#db.transaction({ operations: [{ collection: FILE_LINK_COLLECTION, id, requireAbsent: true, value: { id, ...grant } }] });
107
186
  return token;
108
187
  }
188
+ /**
189
+ * Store the grant for a token the caller derived (a cacheable link: the same token for the same
190
+ * file, content, caller and window). Issuing it again is idempotent; only its digest is stored.
191
+ */
192
+ async issueDerivedLink(token, grant) {
193
+ const id = digestOf(token);
194
+ const rows = this.#db.collection(FILE_LINK_COLLECTION);
195
+ if (await rows.get(id))
196
+ return token;
197
+ try {
198
+ await this.#db.transaction({ operations: [{ collection: FILE_LINK_COLLECTION, id, requireAbsent: true, value: { id, ...grant } }] });
199
+ }
200
+ catch (error) {
201
+ if (!(await rows.get(id)))
202
+ throw error; // not a concurrent issue of the same link
203
+ }
204
+ return token;
205
+ }
109
206
  /**
110
207
  * Resolve a link token. Unknown, expired and (for upload links) already-used tokens are all
111
208
  * NOT_FOUND. An upload link is consumed here, before its bytes are read: it works once.