@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.
- package/dist/app.d.ts +67 -11
- package/dist/app.js +58 -2
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.js +2 -0
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +23 -1
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/authorize.d.ts +24 -3
- package/dist/authorize.js.map +1 -1
- package/dist/broker/assertion.d.ts +68 -0
- package/dist/broker/assertion.js +104 -0
- package/dist/broker/assertion.js.map +1 -0
- package/dist/broker/keys.d.ts +9 -0
- package/dist/broker/keys.js +47 -0
- package/dist/broker/keys.js.map +1 -0
- package/dist/broker/server.d.ts +54 -0
- package/dist/broker/server.js +305 -0
- package/dist/broker/server.js.map +1 -0
- package/dist/cli/broker.d.ts +11 -0
- package/dist/cli/broker.js +72 -0
- package/dist/cli/broker.js.map +1 -0
- package/dist/cli/deploy.js +6 -0
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.js +123 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/client/index.d.ts +8 -2
- package/dist/client/index.js +45 -1
- package/dist/client/index.js.map +1 -1
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +3 -0
- package/dist/docs.js.map +1 -1
- package/dist/extension/build.d.ts +50 -0
- package/dist/extension/build.js +205 -0
- package/dist/extension/build.js.map +1 -0
- package/dist/extension/client-shim.d.ts +7 -0
- package/dist/extension/client-shim.js +13 -0
- package/dist/extension/client-shim.js.map +1 -0
- package/dist/extension/connect-ui.d.ts +24 -0
- package/dist/extension/connect-ui.js +67 -0
- package/dist/extension/connect-ui.js.map +1 -0
- package/dist/extension/connection.d.ts +109 -0
- package/dist/extension/connection.js +190 -0
- package/dist/extension/connection.js.map +1 -0
- package/dist/extension/host-core.d.ts +36 -0
- package/dist/extension/host-core.js +50 -0
- package/dist/extension/host-core.js.map +1 -0
- package/dist/extension/host.d.ts +1 -0
- package/dist/extension/host.js +8 -0
- package/dist/extension/host.js.map +1 -0
- package/dist/extension/icons.d.ts +13 -0
- package/dist/extension/icons.js +75 -0
- package/dist/extension/icons.js.map +1 -0
- package/dist/extension/identity.d.ts +40 -0
- package/dist/extension/identity.js +110 -0
- package/dist/extension/identity.js.map +1 -0
- package/dist/extension/options.d.ts +1 -0
- package/dist/extension/options.js +57 -0
- package/dist/extension/options.js.map +1 -0
- package/dist/extension/service-worker.d.ts +1 -0
- package/dist/extension/service-worker.js +38 -0
- package/dist/extension/service-worker.js.map +1 -0
- package/dist/extension/validate.d.ts +7 -0
- package/dist/extension/validate.js +143 -0
- package/dist/extension/validate.js.map +1 -0
- package/dist/extension/zip.d.ts +7 -0
- package/dist/extension/zip.js +94 -0
- package/dist/extension/zip.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/policy.d.ts +179 -0
- package/dist/policy.js +311 -0
- package/dist/policy.js.map +1 -0
- package/dist/runtime/activity.d.ts +16 -0
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/application-authority.d.ts +22 -3
- package/dist/runtime/application-authority.js +94 -20
- package/dist/runtime/application-authority.js.map +1 -1
- package/dist/runtime/assemble.d.ts +13 -0
- package/dist/runtime/assemble.js +29 -1
- package/dist/runtime/assemble.js.map +1 -1
- package/dist/runtime/authority-contract.d.ts +55 -0
- package/dist/runtime/authority-contract.js +60 -0
- package/dist/runtime/authority-contract.js.map +1 -0
- package/dist/runtime/content.d.ts +50 -0
- package/dist/runtime/content.js +98 -1
- package/dist/runtime/content.js.map +1 -1
- package/dist/runtime/context.d.ts +86 -11
- package/dist/runtime/contract.js +11 -2
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/data.d.ts +25 -0
- package/dist/runtime/data.js +92 -8
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/image-variants.d.ts +48 -0
- package/dist/runtime/image-variants.js +295 -0
- package/dist/runtime/image-variants.js.map +1 -0
- package/dist/runtime/integrations.d.ts +2 -0
- package/dist/runtime/integrations.js +10 -7
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/invocations.d.ts +3 -0
- package/dist/runtime/invocations.js +1 -1
- package/dist/runtime/invocations.js.map +1 -1
- package/dist/runtime/live.d.ts +10 -7
- package/dist/runtime/live.js +24 -12
- package/dist/runtime/live.js.map +1 -1
- package/dist/runtime/local-authority.d.ts +80 -5
- package/dist/runtime/local-authority.js +259 -14
- package/dist/runtime/local-authority.js.map +1 -1
- package/dist/runtime/policies.d.ts +89 -0
- package/dist/runtime/policies.js +152 -0
- package/dist/runtime/policies.js.map +1 -0
- package/dist/runtime/readiness.js +31 -1
- package/dist/runtime/readiness.js.map +1 -1
- package/dist/runtime/runtime.d.ts +21 -1
- package/dist/runtime/runtime.js +200 -7
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services-rules.d.ts +9 -0
- package/dist/runtime/services-rules.js +47 -1
- package/dist/runtime/services-rules.js.map +1 -1
- package/dist/runtime/services.d.ts +117 -9
- package/dist/runtime/services.js +154 -13
- package/dist/runtime/services.js.map +1 -1
- package/dist/server/admin.d.ts +21 -0
- package/dist/server/admin.js +114 -0
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.js +33 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server/oauth.d.ts +32 -2
- package/dist/server/oauth.js +130 -23
- package/dist/server/oauth.js.map +1 -1
- package/dist/server/operators.d.ts +1 -0
- package/dist/server/operators.js +1 -1
- package/dist/server/operators.js.map +1 -1
- package/dist/server/project.d.ts +3 -0
- package/dist/server/project.js +2 -2
- package/dist/server/project.js.map +1 -1
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-OPERATIONS.md +1 -1
- package/docs/ARCHITECTURE.md +2 -1
- package/docs/CONNECTIONS.md +10 -3
- package/docs/EXTENSION-HOSTS.md +64 -5
- package/docs/GUARANTEES.md +82 -6
- package/docs/LOCAL-AUTHORITY.md +118 -0
- package/docs/POLICIES.md +121 -0
- package/docs/README.md +5 -2
- package/docs/SECURITY.md +69 -0
- package/docs/SIGN-IN-BROKER.md +77 -0
- package/docs/TRANSACTIONS.md +4 -0
- package/package.json +13 -9
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-agent/SKILL.md +1 -1
- package/skills/feltkit-build/SKILL.md +10 -0
- package/skills/feltkit-data/SKILL.md +13 -1
- package/skills/feltkit-services/SKILL.md +14 -1
package/docs/GUARANTEES.md
CHANGED
|
@@ -69,6 +69,7 @@ this inside its commit lock; a failed check rejects the whole transaction with
|
|
|
69
69
|
| `get(id)` | `ifVersion` / `requireAbsent` precondition on that record | The record changed, appeared, or was deleted |
|
|
70
70
|
| `find(filter)`, `count(filter)` with at least one field | FeltDB read basis on the equality predicate, captured before the read | Any matching record changed, appeared (phantom), disappeared, or stopped matching — by any writer |
|
|
71
71
|
| `query({ where })` with some `eq` clauses | Read basis on the `eq` clauses only (range clauses dropped) | Same as above, for a superset of the read: may report conflicts the range would have excluded, never misses one |
|
|
72
|
+
| `query({ where })` with an `in` clause (non-empty) | One read basis per distinct value: that value as an equality, with the read's `eq` clauses (a second `in` is dropped) | Any record whose field is in the set changed, appeared or disappeared; a write outside the set does not conflict. An empty `in` is checked as a read without it |
|
|
72
73
|
| `find()`/`count()` with no filter, or `query` with only range clauses | The collection's change marker (`_feltkit_collections`), touched by every commit made through `ctx.db` or the dashboard | Any commit to the collection through FeltKit. **Not** writes made through `ctx.unsafe.feltdb`. |
|
|
73
74
|
| Records the mutation wrote | `ifVersion` on updates and deletes, at the version the mutation **first read** (a `get` before the `patch`); `requireAbsent` on inserts | Lost updates, including a change committed between the handler's read and its write |
|
|
74
75
|
|
|
@@ -155,7 +156,7 @@ writes the new one in the mutation's transaction, conditioned on the version it
|
|
|
155
156
|
- File bytes are stored in the same FeltDB instance (`_feltkit_file_content`, with
|
|
156
157
|
their SHA-256, re-hashed on every read) before the file record is committed, so a
|
|
157
158
|
record never points at bytes that were not stored; if the record cannot be committed
|
|
158
|
-
the bytes are removed. Deleting a file removes its bytes. FeltDB 0.15's content store
|
|
159
|
+
the bytes are removed. Deleting a file removes its bytes and the image variants derived from them. FeltDB 0.15's content store
|
|
159
160
|
is not used: it cannot delete content, and the memory runtime has none (UPSTREAM-GAPS
|
|
160
161
|
F6, F8, F9).
|
|
161
162
|
- Files are capped at 1 MiB by default (`services.files.maxBytes`).
|
|
@@ -225,7 +226,10 @@ published contract declares (`appport.integration/1` `failures`). Tests:
|
|
|
225
226
|
write. A watched query re-runs when a change's keys meet its predicates, when a
|
|
226
227
|
collection it read wholly changed, or when a change has no keys for a collection it
|
|
227
228
|
read. So inserts, updates (including a record moving out of a predicate) and deletes
|
|
228
|
-
re-run exactly the predicates they touch, and never fewer.
|
|
229
|
+
re-run exactly the predicates they touch, and never fewer. A set membership (`in`) on a
|
|
230
|
+
keyed field is one predicate per value (preferred after an equality on `id` or another
|
|
231
|
+
keyed field, before the tenant field), so a change to a record in the set re-runs the
|
|
232
|
+
query and one outside it does not.
|
|
229
233
|
- **Keyed fields** are `id`, the fields of declared indexes and unique constraints,
|
|
230
234
|
references (`s.ref`) and the tenant field. A read filtering only on other fields counts
|
|
231
235
|
as a whole-collection read. Values of other fields never leave the server in any form.
|
|
@@ -252,6 +256,17 @@ published contract declares (`appport.integration/1` `failures`). Tests:
|
|
|
252
256
|
- Queries cannot write through `ctx.db`. FeltKit does not sandbox handlers, so a query
|
|
253
257
|
can still make network calls or other side effects; FeltKit does not claim purity.
|
|
254
258
|
- `count` reads all matching records.
|
|
259
|
+
- **Set membership** (`where: [{ field, in: [...] }]`, FRAME-GAP-05): at most 256 strings, finite numbers,
|
|
260
|
+
booleans or nulls, with `eq`'s equality; an empty list matches nothing; checked before FeltDB sees it
|
|
261
|
+
(`INVALID_ARGUMENT`). A FeltDB without `in` (0.21.0 and before) is `FAILED_PRECONDITION`, never a wrong
|
|
262
|
+
answer. A cursor continues only the same set. Inside a mutation, pending writes are matched too.
|
|
263
|
+
- **Index directions** (`indexes: [{ fields, directions }]`): FeltDB's state contract declares index fields
|
|
264
|
+
only (ascending), so FeltKit also declares an index with a `desc` direction to an embedded FeltDB (local,
|
|
265
|
+
memory) as `<name>_ordered`, at start and reload (idempotent; durable across restarts). With
|
|
266
|
+
`{ fields: ["authorId", "createdAt"], directions: ["asc", "desc"] }`, `where authorId in [...] orderBy
|
|
267
|
+
createdAt desc` is an index merge: a page examines about `limit + 1` records, whatever the authors have
|
|
268
|
+
written (`test/membership-query.test.ts`, by `explain` and `plan.recordsExamined`). A FeltDB server serves
|
|
269
|
+
`in` as a predicate (same results; cost as an unindexed predicate).
|
|
255
270
|
- `search` reads the records matching its equality `where` in pages, in the requested
|
|
256
271
|
order, until `limit` (≤ 100) match: cost is linear in the records matching `where`, not
|
|
257
272
|
in the result. It examines at most 50,000 records and then fails with
|
|
@@ -323,8 +338,8 @@ no completion is reported as outcome unknown, never as success or failure. Enabl
|
|
|
323
338
|
|
|
324
339
|
| Service | What runs | Verified (packages/sdk/test) |
|
|
325
340
|
|---|---|---|
|
|
326
|
-
| Files | records with audit; bytes in the same instance | persistence, authorization, upload/read/delete, restart (`services`) |
|
|
327
|
-
| Notifications | in-app channel, delivered inline; recipient-only | persistence, delivery, recipient-only access, restart (`services`) |
|
|
341
|
+
| Files | records with audit; bytes in the same instance; links (cacheable on request), image variants | persistence, authorization, upload/read/delete, restart (`services`); links (`file-links`); cacheable links and variants (`file-cache-variants`) |
|
|
342
|
+
| Notifications | in-app channel, delivered inline; recipient-only; inbox paging (`page`, `unreadCount`, `markAllRead`) on the recipient timeline index | persistence, delivery, recipient-only access, restart (`services`); paging, cursors bound to the walk, counts, mark-all-read as the caller, the contract's indexes (`notification-paging`) |
|
|
328
343
|
| Configuration | variables and credential references for the running environment | persistence, environment separation; the console page edits the environment the application reads (`services`, `console`) |
|
|
329
344
|
| API keys | created, rotated, revoked on the package's page; accepted on `/appport` and `/mcp` with `services.apiKeys.roles` | secret shown once, never listed, revocation → 401, survives restart (`console`) |
|
|
330
345
|
| Webhooks | signed delivery to registered endpoints; history | signed with the environment's secret, delivered as the emitter, secret in no record or log (`console`) |
|
|
@@ -349,6 +364,14 @@ no completion is reported as outcome unknown, never as success or failure. Enabl
|
|
|
349
364
|
- FeltKit is single-tenant per application: the Services tenant is the application
|
|
350
365
|
name. Configuration environments map `development`/`test` → `development`,
|
|
351
366
|
`production` → `production`.
|
|
367
|
+
- **Notification inbox** (`ctx.services.notifications.page / unreadCount / markAllRead`, FRAME-GAP-08):
|
|
368
|
+
AppPort Services' `inbox`, `unreadCount` and `markAllRead`, as the caller, for the caller's own
|
|
369
|
+
notifications. Pages are newest first (`createdAt` desc, `id` asc) from the
|
|
370
|
+
`notifications_by_recipient(_type)` indexes (in FeltKit's contract with Services' contract version 4):
|
|
371
|
+
a page reads about `limit` records. A cursor works only for the walk that issued it. With `unread` a page
|
|
372
|
+
may be short or empty and still carry `nextCursor`. `unreadCount` stops at `max` (`complete: false`).
|
|
373
|
+
`markAllRead` marks at most 1,000 per call, each as `markRead` does, and is not atomic. A Services
|
|
374
|
+
release without them: `FAILED_PRECONDITION` naming it. Artifacts: `UNAVAILABLE`.
|
|
352
375
|
- Files belong to the workspace they were uploaded in (`metadata["feltkit.tenant"]`, set by
|
|
353
376
|
FeltKit): a caller with `files.read` reads the files of its own workspace, or, working in none,
|
|
354
377
|
those uploaded in none; any other is NOT_FOUND. Per-resource access is the application's: a function checks the resource
|
|
@@ -357,7 +380,57 @@ no completion is reported as outcome unknown, never as success or failure. Enabl
|
|
|
357
380
|
until then. Upload links are single use, create the file as the issuing principal (the role
|
|
358
381
|
snapshot taken at issue), with the metadata the function fixed, and within its `maxBytes`. Only
|
|
359
382
|
the SHA-256 of a link token is stored (`_feltkit_file_links` on the `feltkit.files` handle).
|
|
360
|
-
Links are not revoked when membership changes; they expire.
|
|
383
|
+
Links are not revoked when membership changes; they expire. A link serves only the content it was
|
|
384
|
+
issued for: if the record comes to name other bytes (another checksum), the link is refused.
|
|
385
|
+
- **Cacheable file links** (`files.link(id, { cache: true })`, opt-in; FRAME-GAP-01). By default a
|
|
386
|
+
download is `Cache-Control: private, no-store` and every call is a new URL. With `cache`:
|
|
387
|
+
- **Same URL in a window.** Time is cut into windows of half the link's lifetime
|
|
388
|
+
(`expiresInSeconds`, default 3600 with `cache`, at most 3600). Within one window, the same caller
|
|
389
|
+
(principal and workspace) asking for the same file, content (checksum and storage key), variant and
|
|
390
|
+
disposition gets the same URL; `stableUntil` says when the next call will be a new one. Each URL
|
|
391
|
+
lives until the end of the following window, so it is issued with at least half its lifetime left
|
|
392
|
+
and never lives longer than asked (`expiresAt`).
|
|
393
|
+
- **No cross-principal reuse.** The token is HMAC-SHA256, under a random per-process key that is never
|
|
394
|
+
stored, of that scope; another principal (or the same person in another workspace) gets another URL.
|
|
395
|
+
Nothing a URL contains is derived from the bytes alone, so identical bytes in two workspaces never
|
|
396
|
+
share an address. Only the token's digest is stored, as for every link. A restart changes the key:
|
|
397
|
+
URLs issued after it are new (one more download each), never weaker.
|
|
398
|
+
- **Headers.** `Cache-Control: private, max-age=<seconds until expiresAt>, immutable` and a strong
|
|
399
|
+
`ETag` (the SHA-256 of the bytes served). `If-None-Match` answers `304` only after the link was
|
|
400
|
+
redeemed (valid, unexpired, the file still exists with the same content). `private`: never a
|
|
401
|
+
shared cache.
|
|
402
|
+
- **The tradeoff, bounded.** A copy a browser already holds is shown until its `max-age` runs out,
|
|
403
|
+
even if the file is removed or the caller loses access meanwhile: at most `expiresInSeconds`
|
|
404
|
+
(≤ 1 hour) after the link was issued. New downloads through the link stop at once (removed file,
|
|
405
|
+
changed content, expiry: `404`). Use the default (`no-store`) for content whose access must end
|
|
406
|
+
the moment it is revoked, or a shorter `expiresInSeconds`.
|
|
407
|
+
- **Image variants** (`services.files.variants`, `files.link(id, { variant })`; FRAME-GAP-06).
|
|
408
|
+
- **Declared, fixed set.** `variants: { w640: { width: 640 }, avatar64: { width: 64, height: 64, fit:
|
|
409
|
+
"cover" } }`: `width`/`height` 1-4096, `fit` `inside` (default: fits the box) or `cover` (fills it,
|
|
410
|
+
centre-cropped), `format` `auto` (default: PNG when the result has transparency, else JPEG), `jpeg` or
|
|
411
|
+
`png`, `quality` 1-100 (JPEG, default 80). Checked when the application is declared. Never upscaled.
|
|
412
|
+
A link names a declared variant or is refused (`INVALID_ARGUMENT`).
|
|
413
|
+
- **Authorized exactly as the original.** A variant is reachable only through a link to its file, issued
|
|
414
|
+
by `files.link` after the same checks (`files.read`, the file's workspace, the application's own
|
|
415
|
+
check); it is never a file record of its own.
|
|
416
|
+
- **Derived once,** on the first download through a variant link (concurrent first downloads in a process
|
|
417
|
+
derive once), and kept as derived content in `_feltkit_file_variants`, keyed by the original's storage
|
|
418
|
+
key and the variant's name, with a digest of its spec and codec (a changed declaration derives it again)
|
|
419
|
+
and the SHA-256 of its bytes (verified on every read).
|
|
420
|
+
- **Removed with the original's bytes.** The recorded byte release of `files.remove` (above) removes every
|
|
421
|
+
variant of the bytes it releases (`{ released: true, variantsReleased }`), also when an earlier attempt
|
|
422
|
+
already removed the bytes; a variant derived while its bytes were being released is removed by the
|
|
423
|
+
derivation itself.
|
|
424
|
+
- **Never silent.** JPEG (EXIF orientation applied) and PNG are resized. Any other format, an image over
|
|
425
|
+
`services.files.maxVariantPixels` (default 24,000,000, checked from the header before decoding),
|
|
426
|
+
bytes that do not decode, or an image already within the variant are served as the original:
|
|
427
|
+
`X-FeltKit-Variant: original` and `X-FeltKit-Variant-Reason: …` on the download, and the link's
|
|
428
|
+
`variant: { status: "original", reason }` once known (`pending` before the first download, `ready`
|
|
429
|
+
with `width`, `height`, `contentType` after). A served variant is `X-FeltKit-Variant: <name>`.
|
|
430
|
+
- **Costs.** Codecs are pure JavaScript (`jpeg-js`, `pngjs`): the first download of each file and
|
|
431
|
+
variant decodes on the server's event loop (roughly 50-150 ms per megapixel).
|
|
432
|
+
- **AppBoundry artifacts:** `files.link` (variants and cacheable links included) is refused
|
|
433
|
+
(`UNAVAILABLE`), as before; `feltkit build --target appboundry` warns that variants are not served.
|
|
361
434
|
- **Removing a file does not strand its bytes, and does not release bytes another live file uses,**
|
|
362
435
|
except in one documented window (below: a reference made the instant after the removal, and a
|
|
363
436
|
stop before the bytes are put back), which is recorded, not hidden. A file is
|
|
@@ -614,7 +687,10 @@ across environments. Nothing is copied from development.
|
|
|
614
687
|
|
|
615
688
|
| Primitive | Guarantee | Verified by |
|
|
616
689
|
|---|---|---|
|
|
617
|
-
| `ctx.authority.decide({ capability, onBehalfOf?, resource?, context? })` | AuthBoundry through the same `authBoundryAuthority` the platform uses. The asking principal is
|
|
690
|
+
| `ctx.authority.decide({ capability, onBehalfOf?, agent?, resource?, context? })` | AuthBoundry through the same `authBoundryAuthority` the platform uses. The asking principal is `feltkit({ authority }).executor`, except where an agent decides as itself (the per-agent row below; `authorityMode` says which); `onBehalfOf` names the requester, and an allow for it must echo that requester and a `delegation_id`. `onBehalfOf` is mapped as `ctx.authority.grants` maps the delegator (FRAME-GAP-11): an application principal id (no `:`, e.g. `"ada"`) goes through `authority.principal` (default `user:<id>`); an AuthBoundry principal (`<type>:<id>`, e.g. `"user:ada"`) is sent unchanged; `{ person }` always maps and `{ principal }` never does, for ids that break that rule. The decision's `onBehalfOf` is the principal asked about. Fails closed (unconfigured, unreachable, slow, malformed, inexact, missing credential). Credentials are custody references resolved per decision; each decision is in the activity log with its ids, never a credential | `test/application-platform.test.ts`, `test/local-authority.test.ts` (both forms against a real local AuthBoundry) |
|
|
691
|
+
| Per-agent delegation (`authority.local`) | Every `app.agent` is an AuthBoundry agent of the application (`agent:<id>`), registered at each start with its own credential in custody; agents registered at run time (`ctx.authority.agents.register`, needs `feltkit.authority.agents`, never by an agent) are registered again too. A grant may name an agent (`grants.grant({ agent })`) and then allows only that agent. **An agent caller decides as itself, always**, with its own credential: a grant to another agent or to the executor never allows it, and naming another agent is a deny. Anyone else decides as the executor unless it names a registered agent. An unregistered agent is a deny. Revoking a grant stops that grant only; revoking an agent stops all of its grants. With a hosted AuthBoundry (no `authority.local`, or an authority url that resolves), agent callers decide as the executor, with its grants (no per-agent credentials; `authorityMode: "hosted-executor-grants"`); `agentCallers` does not govern hosted authority. With an `@authboundry/local` without per-agent delegation (0.1.0), an agent caller is `unavailable` (`lasting`), unless the owner set `authority.local.agentCallers: "executor-grants"`: then an agent caller naming no agent decides as the executor with its grants (wider authority, as through 0.3.30; `authorityMode: "local-executor-grants-opt-in"`), with a readiness warning; naming an agent is `unavailable` either way. "Per-agent delegation installed" means the started authority offers `registerAgent`, `revokeAgent`, `agentCredentialOf` and `agents` (`runtime/authority-contract.ts`, also used by the release gate) | `test/local-authority.test.ts` (real local AuthBoundry), `test/authority-compat.test.ts` (never skipped) |
|
|
692
|
+
| Authority evaluation evidence (`authorityMode`) | Every authority decision says how it was evaluated: `local-executor`, `local-per-agent`, `local-executor-grants-opt-in`, `hosted-executor` or `hosted-executor-grants` (null when FeltKit evaluated nothing: no address, a local authority not running, an invalid request, an unreadable credential; when AuthBoundry is unreachable the mode says how the decision was being evaluated). It is in the returned decision and in each record FeltKit keeps of it, with that record's own durability: policy decision records (`delegations[].authorityMode`, with the refusal's `reason`; durable for every refusal and for allows of policies with `evidence: "durable"`), integration call records (`authority.authorityMode`; durable for every call that was sent; a refused call is not an integration call record, its decision is in the activity log and, during an invocation attempt, in its decision notes), the invocation attempt's decision notes (decisions made while an attempt runs), and the activity log (`authority.decide`, every decision including refusals FeltKit makes itself; best effort and bounded: a failed write only warns, `mode: "errors"` keeps no allows, the newest entries are kept). It is evidence only: nothing reads it to authorize | `test/authority-compat.test.ts`, `test/executor-proof.test.ts`, `test/connections.test.ts` |
|
|
693
|
+
| Readiness `authority.agent-callers` | Reports the mode in effect, never assumed from configuration: hosted (pass, the hosted contract), not yet started (warn: not known), failed start or no authority address (fail), per-agent installed (pass), refused (warn), shared executor grants (warn) | `test/authority-compat.test.ts` |
|
|
618
694
|
| `ctx.integrations.invoke(capability, input)` | A declared integration operation from application code, as the caller, under the operation's own `access`; the input is validated against the operation's declared schema before anything is sent (`INVALID_ARGUMENT`), as AppPort validates a capability call; its credential resolved for the request only; the call recorded before and after; never in results, records or errors; rotation applies to the next call; a removed credential fails the call | `test/application-platform.test.ts` |
|
|
619
695
|
| The agent's catalog (`ctx.agent.catalog()` in actions, `runtime.agent.tools(principal)`; `ctx.agent.tools()` is its allowed subset, shaped as model tools) | Every capability the application and its services offer, not a model's tool list: for each, whether this principal may use it (`allowed`, the policy's decision) and how (`invoke`); for an integration operation, its `integration`, its input schema, and `readiness` (not ready while the base URL or the credential's value is missing, with what to fix; never a value). Permission and readiness are separate answers | `test/application-platform.test.ts` |
|
|
620
696
|
| Integration exposure (`expose: false`, per operation or integration) | The operation is not an AppPort capability: no session can call it on `/appport`, whatever it holds; application code still can, under `access`. A `verify` probe must stay exposed (verification runs it through AppPort), checked when the app is defined | `test/application-platform.test.ts` |
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# A private AuthBoundry for your application
|
|
2
|
+
|
|
3
|
+
`authority: { local: true }` gives your application an AuthBoundry that needs no setup. FeltKit starts it,
|
|
4
|
+
sets it up and supervises it, so the people who use the application never see AuthBoundry.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
feltkit({
|
|
8
|
+
authority: {
|
|
9
|
+
local: true,
|
|
10
|
+
url: { env: "AUTHBOUNDRY_URL" }, // optional: a hosted AuthBoundry, when set, is used instead
|
|
11
|
+
application: "myapp",
|
|
12
|
+
checkCredential: "credential-ref:authboundry-check",
|
|
13
|
+
executor: { principal: "agent:myapp" },
|
|
14
|
+
capabilities: ["tasks.create", "notes.write"],
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @authboundry/local
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## What FeltKit does
|
|
24
|
+
|
|
25
|
+
- **Starts it.** If no `url` resolves, FeltKit starts `@authboundry/local` (the AuthBoundry server, Linux and
|
|
26
|
+
macOS) on loopback. Its state lives in `authority.local.dataDir`, else `FELTKIT_AUTHORITY_DIR`, else
|
|
27
|
+
beside `FELTKIT_STATE_DIR` (`<state>.authority`), else `.feltkit/<env>/authority`.
|
|
28
|
+
- **Keeps its secrets in FeltKit's custody (the vault).** The administrator's secret
|
|
29
|
+
(`credential-ref:authboundry-local-admin`) is generated once. The check credential is issued once and
|
|
30
|
+
kept, then reissued only if it stops working.
|
|
31
|
+
- **Sets it up on every start.** This covers the application, its capability contract (a new version only
|
|
32
|
+
when `capabilities` change), the executor agent, and each person's policy. Running it again changes
|
|
33
|
+
nothing.
|
|
34
|
+
- **Decides through it.** `ctx.authority.decide` works exactly as with a hosted AuthBoundry: the same
|
|
35
|
+
contract, and the same fail-closed rules. If the local authority isn't running, every decision is
|
|
36
|
+
refused and readiness says why.
|
|
37
|
+
- **Restarts it if it exits, and stops it with the application.**
|
|
38
|
+
- **In the test environment it starts on first use** (a decision or a grant), not with every test
|
|
39
|
+
application. Starting takes most of a second, and most tests never ask.
|
|
40
|
+
|
|
41
|
+
## Grants: what a person lets your application do for them
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
await ctx.authority.grants.grant({ capabilities: ["tasks.create"], expiresAt });
|
|
45
|
+
await ctx.authority.grants.list();
|
|
46
|
+
await ctx.authority.grants.revoke(id);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- **Only the signed-in person's own grants.** The delegator is always the caller; it's never an argument.
|
|
50
|
+
Another person's grant doesn't exist for them, and a service or agent can't grant.
|
|
51
|
+
- **Decisions on someone's behalf** (`decide({ capability, onBehalfOf: "<id>" })`) are allowed only by
|
|
52
|
+
that person's grants. `onBehalfOf` is the person's application id (`"ada"`), mapped through
|
|
53
|
+
`authority.principal` exactly as grants map the delegator, or the AuthBoundry principal (`"user:ada"`),
|
|
54
|
+
sent unchanged: a value with a `:` is taken as already mapped. `{ person: id }` and `{ principal }`
|
|
55
|
+
say which explicitly (an application id containing `:`, or a custom `authority.principal` whose
|
|
56
|
+
principals have none).
|
|
57
|
+
- **Recorded.** Grants and revocations are activity in FeltKit and evidence in AuthBoundry.
|
|
58
|
+
|
|
59
|
+
## Several agents: a grant for one agent
|
|
60
|
+
|
|
61
|
+
Needs `@authboundry/local` 0.1.1 or later (per-agent delegation). Without it (0.1.0), grants and decisions that
|
|
62
|
+
name an agent are refused, naming that release, and agent callers are denied.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
await ctx.authority.grants.grant({ capabilities: ["posts.read"], agent: "scout" }); // Scout only
|
|
66
|
+
await ctx.authority.grants.list(); // each grant: { id, agent: "agent:scout" | null, ... }
|
|
67
|
+
await ctx.authority.decide({ capability: "posts.read", onBehalfOf: "ada" }); // in Scout's handler: as Scout
|
|
68
|
+
await ctx.authority.decide({ capability: "posts.read", onBehalfOf: "ada", agent: "scout" }); // from a person's function
|
|
69
|
+
await ctx.authority.agents.register({ id: "mcp-bot" }); // an agent that arrives at run time (operator only)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- **Every `app.agent` is an agent of the application at the authority**, `agent:<principal id>` (or the id
|
|
73
|
+
itself if it has a `:`), registered at every start with its own agent credential. FeltKit keeps each
|
|
74
|
+
credential in custody (`credential-ref:authboundry-local-agent:<agent>`), never in a record, and gives it
|
|
75
|
+
back at the next start; the authority renews it while it runs.
|
|
76
|
+
- **A grant names the agent it is for**, or none (the executor, as before). It allows only that agent: a
|
|
77
|
+
grant to Scout never allows Concierge or the executor, and the executor's grants never allow an agent.
|
|
78
|
+
Revoking a grant stops that grant; `agents.revoke(id)` stops the agent for good.
|
|
79
|
+
- **An agent decides as itself, always.** When the caller is an agent (an `app.agent` run, or an agent
|
|
80
|
+
session such as an MCP client authenticated as an agent), `decide` uses that agent's own credential;
|
|
81
|
+
`agent` may only name itself, and naming another agent (or wanting the executor) is a deny.
|
|
82
|
+
- Why not the executor by default: the person granted *that agent*. If an agent's handler used the
|
|
83
|
+
executor, every agent of the application would share every executor grant, which is what per-agent
|
|
84
|
+
grants exist to prevent. The executor remains the default for everyone who is not an agent: a
|
|
85
|
+
person's or a service's function, a job.
|
|
86
|
+
- A person's function may name an agent (`agent: "scout"`), to ask "may Scout do this for me?".
|
|
87
|
+
- An agent that is not registered is a deny (`not an agent registered with this application's
|
|
88
|
+
authority`), never an error.
|
|
89
|
+
- **Without per-agent delegation installed** (`@authboundry/local` 0.1.0; 0.1.1 and later have it) no agent can be
|
|
90
|
+
registered and no grant can name an agent. By default an agent caller is then refused (`unavailable`): it may
|
|
91
|
+
decide only as itself, and here it cannot. That is deliberate: falling back to the executor would let every agent
|
|
92
|
+
use every grant people gave the executor.
|
|
93
|
+
- **Opt-in, an owner's decision:** `authority: { local: { agentCallers: "executor-grants" } }` lets an agent caller
|
|
94
|
+
that names no agent be decided as the executor, with the executor's grants, as through FeltKit 0.3.30. This
|
|
95
|
+
widens authority and is not equivalent to per-agent delegation. Each such decision records
|
|
96
|
+
`authorityMode: "local-executor-grants-opt-in"` (in the decision and the records kept of it; SECURITY.md, "Evidence"),
|
|
97
|
+
and readiness warns (`authority.agent-callers`). A decision that names an agent is still `unavailable`.
|
|
98
|
+
- **Hosted AuthBoundry is different:** with an authority url that resolves, agent callers are decided as the
|
|
99
|
+
executor (`hosted-executor-grants`), the documented hosted contract; `agentCallers` does not govern it.
|
|
100
|
+
- **Moving to per-agent delegation:** install an `@authboundry/local` with `registerAgent`, register agents (an
|
|
101
|
+
operator's act; `app.agent`s register at each start), have people grant each agent, then remove `agentCallers`
|
|
102
|
+
(it has no effect once per-agent delegation is installed; readiness says so).
|
|
103
|
+
- **Agents that arrive at run time** (`ctx.authority.agents.register({ id, name? })`, `list()`,
|
|
104
|
+
`revoke(id)`): only a caller holding `feltkit.authority.agents`, and never an agent, itself included
|
|
105
|
+
(registration is an operator's act, as AuthBoundry's own rule says; an agent able to register itself or
|
|
106
|
+
others could make principals no operator decided on). Registering grants nothing: a person still
|
|
107
|
+
grants the agent. The authority keeps registered agents across restarts and FeltKit registers each
|
|
108
|
+
active one again at every start, with its kept credential.
|
|
109
|
+
- **With a hosted AuthBoundry** FeltKit holds no agent credentials: agent callers decide as the executor,
|
|
110
|
+
as before, and naming an agent is refused (`unavailable`).
|
|
111
|
+
|
|
112
|
+
## Limits
|
|
113
|
+
|
|
114
|
+
- **One machine.** The local authority's state is on that machine. For several machines, use a hosted
|
|
115
|
+
AuthBoundry (`AUTHBOUNDRY_URL`).
|
|
116
|
+
- **Server version.** It needs a server that keeps granted policy across restarts: after
|
|
117
|
+
`@authboundry/core` 1.17.3.
|
|
118
|
+
- **No move to a hosted AuthBoundry yet.** Nothing exports grants from the local authority to a hosted one.
|
package/docs/POLICIES.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Policies
|
|
2
|
+
|
|
3
|
+
FeltKit decides who may call a function in layers. Every layer must allow, and the first refusal
|
|
4
|
+
wins. All of them run at the one execution boundary every interface goes through: HTTP functions,
|
|
5
|
+
AppPort capabilities, MCP tools, agent actions, jobs, approved actions, and AppBoundry artifacts.
|
|
6
|
+
|
|
7
|
+
| Order | Layer | Declared with | Decides |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| 1 | Roles | `roles` and each function's `access` | May this caller call this function at all? Checked before the arguments are read. |
|
|
10
|
+
| 2 | Approval | `approval: "required"` | A non-person caller needs a person's approval for this exact action. |
|
|
11
|
+
| 3 | Ownership | `owner` on the function | The record named by an argument belongs to the caller. |
|
|
12
|
+
| 4 | **Policies** | `app.policy(rule)`, plus managed versions | Owner, shared-with, record state, input, role, tenant role, agent delegation. |
|
|
13
|
+
| 5 | Hook | `feltkit({ authorize })` | Anything else, in code. It sees the policy decision. |
|
|
14
|
+
|
|
15
|
+
Evaluation is deterministic. No model takes part in any decision. Delegated authority is decided by
|
|
16
|
+
AuthBoundry, the owner of delegation, whose decision id is kept as evidence.
|
|
17
|
+
|
|
18
|
+
## Declaring policies
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { app, docs } from "./app.js";
|
|
22
|
+
import * as d from "./docs.js";
|
|
23
|
+
|
|
24
|
+
app.policy({
|
|
25
|
+
id: "docs.read.owner-or-shared",
|
|
26
|
+
effect: "allow",
|
|
27
|
+
functions: [d.read], // definitions, not strings: renaming breaks the import
|
|
28
|
+
resource: { collection: docs, id: "docId" }, // the record, loaded by the "docId" argument
|
|
29
|
+
when: [{ any: [{ owner: "ownerId" }, { sharedWith: "sharedWith" }, { role: "admin" }] }],
|
|
30
|
+
});
|
|
31
|
+
app.policy({ id: "docs.remove.kept", description: "published documents are kept", effect: "deny",
|
|
32
|
+
functions: [d.remove], resource: { collection: docs, id: "docId" }, when: [{ field: "status", eq: "published" }] });
|
|
33
|
+
app.policy({ id: "refund.small", effect: "allow", functions: [refund], principals: { roles: ["member"] },
|
|
34
|
+
resource: { collection: invoices, id: "invoiceId" }, when: [{ owner: "ownerId" }, { arg: "amount", gt: 0, lte: 100 }],
|
|
35
|
+
evidence: "durable" });
|
|
36
|
+
app.policy({ id: "docs.publish.delegated", effect: "allow", functions: [d.publish], principals: { types: ["agent", "service"] },
|
|
37
|
+
resource: { collection: docs, id: "docId" }, when: [{ delegated: { capability: "docs.publish", onBehalfOf: { field: "ownerId" } } }] });
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Conditions:
|
|
41
|
+
|
|
42
|
+
| Condition | Holds when |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `{ owner: "<field>" }` | the resource's field is the caller's id |
|
|
45
|
+
| `{ owner: "<field>", via: { collection, field } }` | the resource's field references a record whose `field` is the caller's id (e.g. `createdBy` → `participants.principalId`) |
|
|
46
|
+
| `{ sharedWith: "<field>" }` | the resource's field is a list containing the caller's id |
|
|
47
|
+
| `{ field: "<f>", eq / ne / in / notIn / lt / lte / gt / gte }` | the resource's field compares as given |
|
|
48
|
+
| `{ arg: "<a>", …same operators }` | the validated argument compares as given |
|
|
49
|
+
| `{ role: r \| [r…] }` | the caller holds the application role |
|
|
50
|
+
| `{ tenantRole: r \| [r…] }` | the caller's role in their current workspace is one of these |
|
|
51
|
+
| `{ delegated: { capability, onBehalfOf: { field, via? } \| { arg } } }` | the caller is an agent or service, and AuthBoundry allows it to exercise `capability` for that person (a delegation that exists, is in force, and covers it). A service is decided as the application's executor. An agent caller is decided as itself with a local authority (`authority.local`): only a grant to that agent counts; without per-agent delegation installed it is refused, unless the owner set `authority.local.agentCallers: "executor-grants"` (then the executor's grants). With a hosted AuthBoundry an agent caller is decided as the executor, with its grants. The durable decision record keeps how each was evaluated (`delegations[].authorityMode`; SECURITY.md) |
|
|
52
|
+
| `{ any: [...] }`, `{ not: c }` | composition |
|
|
53
|
+
|
|
54
|
+
`principals` limits which callers a rule applies to: `types`, `roles`, and `anonymous: true`.
|
|
55
|
+
|
|
56
|
+
## Semantics
|
|
57
|
+
|
|
58
|
+
- **Deny overrides.** If an applicable deny rule's conditions all hold, the call is refused, whatever else allows it.
|
|
59
|
+
- **Deny by default once governed.** A function named by any allow rule runs only if an applicable
|
|
60
|
+
allow rule's conditions all hold. A function no policy names is decided by the other layers only.
|
|
61
|
+
- **Unevaluable means not held.** A missing record, a missing field, or an authority that cannot be
|
|
62
|
+
reached never allows. A deny rule that depends on it does not apply. So an unreachable AuthBoundry
|
|
63
|
+
refuses a delegated call.
|
|
64
|
+
- A person acts with their own authority. A `delegated` condition never holds for a `user` principal.
|
|
65
|
+
- A refusal is `FORBIDDEN` (`UNAUTHORIZED` for an anonymous caller). Its details name the deny rule
|
|
66
|
+
that `matched`, or each allow rule's first `unmet` condition.
|
|
67
|
+
|
|
68
|
+
## Managed policies: changed without a redeploy
|
|
69
|
+
|
|
70
|
+
A managed version is a complete, immutable set of rules stored in the application's own FeltDB. The
|
|
71
|
+
active version applies on top of the code policies. It adds rules and cannot remove a code rule.
|
|
72
|
+
Activating, or deactivating, takes effect on the next call in every process: the active pointer is
|
|
73
|
+
read for each decision (compare-and-swap writes, cached only by its record version).
|
|
74
|
+
|
|
75
|
+
Managed rules name functions as `"<module>:<export>"`, and may also name an integration operation
|
|
76
|
+
by its capability (`"registry.lookup"`). Every rule is validated against the deployed project when
|
|
77
|
+
it is stored and again when it is activated. A rule that names a missing function or collection is
|
|
78
|
+
refused.
|
|
79
|
+
|
|
80
|
+
| Route (admin API) | Development | Production |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| `GET /policies`, `/policies/versions`, `/policies/history`, `GET /decisions` | admin token | `feltkit.operations.read` |
|
|
83
|
+
| `POST /policies/simulate` `{ function, principal, args }` | admin token | `feltkit.operations.read` |
|
|
84
|
+
| `POST /policies/versions` `{ rules, note? }` | admin token | **`feltkit.policies.manage`** |
|
|
85
|
+
| `POST /policies/active` `{ version: n \| null }` | admin token | **`feltkit.policies.manage`** |
|
|
86
|
+
|
|
87
|
+
Changing policy changes who may do what, so production requires its own permission, separate from
|
|
88
|
+
`feltkit.operations.write`. History records the signed-in operator, and a client-chosen `by` is refused.
|
|
89
|
+
|
|
90
|
+
## Simulation and evidence
|
|
91
|
+
|
|
92
|
+
- `runtime.simulatePolicy({ function, principal, args })`, or `POST /policies/simulate`, runs the
|
|
93
|
+
policies in force against the real records. Nothing runs and nothing is recorded.
|
|
94
|
+
- Decision evidence (`_feltkit_decisions`, append-only) records:
|
|
95
|
+
- every refusal, from any layer (role, approval, ownership, policy or hook) and for signed-in callers;
|
|
96
|
+
- every allow of a rule marked `evidence: "durable"`.
|
|
97
|
+
|
|
98
|
+
Each record names the layer, the policy version (`code:<digest>[+managed:<n>]`), the matched and
|
|
99
|
+
unmet rules, AuthBoundry's delegation decisions, and the argument names. It never holds argument
|
|
100
|
+
values. A durable allow whose record cannot be written does not run.
|
|
101
|
+
- The activity log carries the policy decision too (`authority.policy`).
|
|
102
|
+
|
|
103
|
+
## Integration operations
|
|
104
|
+
|
|
105
|
+
An integration operation reaches the same managed policies and hook (`kind: "integration"`), whether
|
|
106
|
+
it is called through its AppPort/MCP capability or through `ctx.integrations.invoke`. A refused call
|
|
107
|
+
never reaches the remote API.
|
|
108
|
+
|
|
109
|
+
## Testing
|
|
110
|
+
|
|
111
|
+
`createTestApp()` exposes `app.policies.simulate(fn, who, args)`, `app.policies.decisions(filter)`,
|
|
112
|
+
and `app.policies.store` (create and activate managed versions).
|
|
113
|
+
|
|
114
|
+
## Limits (current)
|
|
115
|
+
|
|
116
|
+
- **AppBoundry artifacts** enforce the code policies they carry, with the same evaluator.
|
|
117
|
+
- Managed versions live in the host's FeltDB and are not part of `appboundry-guest/1`, so an
|
|
118
|
+
artifact does not apply them.
|
|
119
|
+
- A `delegated` condition has no authority to ask in the guest, so it does not hold there.
|
|
120
|
+
- Code policies cannot name integration operations: managed rules can.
|
|
121
|
+
- Managed versions add rules. Removing a code rule needs a deploy.
|
package/docs/README.md
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
# FeltKit 0.3.
|
|
1
|
+
# FeltKit 0.3.32 documentation
|
|
2
2
|
|
|
3
3
|
Shipped with `@feltdb/feltkit`. In a project: `node_modules/@feltdb/feltkit/docs/`, or run `npx feltkit docs`.
|
|
4
|
-
Public copy: https://cdn.jsdelivr.net/npm/@feltdb/feltkit@0.3.
|
|
4
|
+
Public copy: https://cdn.jsdelivr.net/npm/@feltdb/feltkit@0.3.32/docs/README.md
|
|
5
5
|
|
|
6
6
|
- [ARCHITECTURE.md](ARCHITECTURE.md): How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services
|
|
7
7
|
- [GUARANTEES.md](GUARANTEES.md): What FeltKit guarantees, and its known limitations
|
|
8
8
|
- [TRANSACTIONS.md](TRANSACTIONS.md): Mutations, ctx.db.sequence and ctx.afterCommit: the transaction contract
|
|
9
9
|
- [SECURITY.md](SECURITY.md): Authorization, sessions, credentials, and production Studio
|
|
10
10
|
- [AUTH.md](AUTH.md): Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens
|
|
11
|
+
- [POLICIES.md](POLICIES.md): Declarative policies (owner, sharing, state, input, roles, delegation), managed versions without a redeploy, simulation, decision evidence
|
|
12
|
+
- [SIGN-IN-BROKER.md](SIGN-IN-BROKER.md): Sign in with GitHub and Google with nothing to register: the FeltKit broker, the assertion it signs, the extension flow, running and rotating it
|
|
11
13
|
- [EXTENSION-HOSTS.md](EXTENSION-HOSTS.md): Running the app in a browser extension: ownership, token storage, session end, lifecycle, gaps
|
|
12
14
|
- [INVOCATIONS.md](INVOCATIONS.md): Surfaces and invocations: registering entry points, the feltkit.invocation/1 contract, the durable lifecycle, dispatch and recovery
|
|
13
15
|
- [EXECUTION.md](EXECUTION.md): Placement-neutral execution: the control plane and execution environments, the execution contract, adapters, placement, authority and evidence
|
|
16
|
+
- [LOCAL-AUTHORITY.md](LOCAL-AUTHORITY.md): The private AuthBoundry beside the application (authority.local): grants, agents, per-agent delegation and the agentCallers opt-in
|
|
14
17
|
- [CONNECTIONS.md](CONNECTIONS.md): People's own connections to integrations (credential.owner: person): connecting, isolation, AuthBoundry at every call (reference implementation)
|
|
15
18
|
- [AGENT-OPERATIONS.md](AGENT-OPERATIONS.md): Agents: MCP, tasks, proposals, approvals, and evidence
|
|
16
19
|
- [GENERATION.md](GENERATION.md): Model generation in an application: actions, streaming, tools as proposals, in-app approvals, caller context
|
package/docs/SECURITY.md
CHANGED
|
@@ -112,6 +112,11 @@ Every entry point was exercised by `packages/sdk/test/auth.test.ts`.
|
|
|
112
112
|
|
|
113
113
|
### Credentials and API keys
|
|
114
114
|
|
|
115
|
+
- **Agent credentials (local authority).** Each registered agent's AuthBoundry credential is kept in
|
|
116
|
+
custody (`credential-ref:authboundry-local-agent:<agent>`), resolved only for that agent's decisions,
|
|
117
|
+
never recorded, logged or returned. An agent caller can decide only as itself; registering agents needs
|
|
118
|
+
`feltkit.authority.agents` and is refused to agents (docs/LOCAL-AUTHORITY.md).
|
|
119
|
+
|
|
115
120
|
- Service credentials are references (`credential-ref:<id>`) resolved only inside the
|
|
116
121
|
effect that needs them, from `FELTKIT_CREDENTIAL_<ID>` when it is set, else (development
|
|
117
122
|
and test) from the environment's encrypted vault. Studio shows whether each reference is
|
|
@@ -163,6 +168,67 @@ Every entry point was exercised by `packages/sdk/test/auth.test.ts`.
|
|
|
163
168
|
`integrations.test.ts` (discovery without authority, no credential in records),
|
|
164
169
|
`platform.test.ts` (production routes).
|
|
165
170
|
|
|
171
|
+
## Agent callers and per-agent delegation (FK-16, 0.3.32)
|
|
172
|
+
|
|
173
|
+
How an agent caller (an `app.agent` run, an agent session such as an MCP client) is decided depends on which
|
|
174
|
+
authority the application uses. Every decision records which applied (`authorityMode`); readiness
|
|
175
|
+
(`authority.agent-callers`) reports the mode in effect.
|
|
176
|
+
|
|
177
|
+
**Local authority (`authority.local`).** An agent caller asks AuthBoundry **as itself**: only what a person granted
|
|
178
|
+
*that agent* allows it (`local-per-agent`). That needs an `@authboundry/local` with per-agent delegation
|
|
179
|
+
(`registerAgent`, `revokeAgent`, `agentCredentialOf`, `agents` on the started authority). `@authboundry/local` 0.1.1 and later have
|
|
180
|
+
them; 0.1.0 has none.
|
|
181
|
+
|
|
182
|
+
- **Default: fail closed.** Without per-agent delegation installed, every decision by an agent caller is
|
|
183
|
+
`unavailable` (marked `lasting`: retrying does not change it). People's and services' decisions are unaffected
|
|
184
|
+
(`local-executor`). FeltKit does not fall back to the executor on its own: that would let every agent of the
|
|
185
|
+
application use every grant people gave the executor.
|
|
186
|
+
- **Opt-in: `authority: { local: { agentCallers: "executor-grants" } }`.** The application owner may choose the
|
|
187
|
+
model FeltKit had through 0.3.30: an agent caller that names no agent is decided as the executor, with the
|
|
188
|
+
executor's grants (`local-executor-grants-opt-in`). **This widens authority** and is not equivalent to
|
|
189
|
+
per-agent delegation: one person's grant to the application is usable by every agent. Readiness warns, so
|
|
190
|
+
operators see it without reading logs. An invalid `agentCallers` fails when the app is defined.
|
|
191
|
+
- **Never widened by the opt-in:** a decision that names an agent stays `unavailable`; an agent can never decide
|
|
192
|
+
as another agent; grants naming an agent and `ctx.authority.agents` stay refused without per-agent delegation.
|
|
193
|
+
- **Once per-agent delegation is installed** the setting has no effect (readiness says so): agents decide as
|
|
194
|
+
themselves. To move: install it, register agents (an operator's act; `app.agent`s register at start), have
|
|
195
|
+
people grant each agent (`grants.grant({ agent })`), then remove `agentCallers`.
|
|
196
|
+
|
|
197
|
+
**Hosted AuthBoundry** (no `authority.local`, or an authority url that resolves in this environment). An agent
|
|
198
|
+
caller is decided as the application's executor, with the executor's grants (`hosted-executor-grants`), as
|
|
199
|
+
documented since before 0.3.31: a hosted AuthBoundry holds no per-agent credentials for FeltKit. This is wider
|
|
200
|
+
than per-agent delegation, and `authority.local.agentCallers` does **not** govern it. Naming an agent there is
|
|
201
|
+
`unavailable`. A later minor release is expected to give hosted and local authority one explicit opt-in policy,
|
|
202
|
+
with a migration path; 0.3.32 does not change the hosted contract.
|
|
203
|
+
|
|
204
|
+
**Evidence.** `authorityMode` is in the returned decision and in each record FeltKit keeps of it, each with its own
|
|
205
|
+
durability: policy decision records (`delegations[].authorityMode`; durable for refusals, and for allows with
|
|
206
|
+
`evidence: "durable"`), integration call records (`authority.authorityMode`; every call sent), invocation attempt
|
|
207
|
+
decision notes (while an attempt runs), and the activity log (`authority.decide`, refusals included; best effort and
|
|
208
|
+
bounded). It is null when nothing was evaluated. It is evidence only, never an input to authorization.
|
|
209
|
+
|
|
210
|
+
## File links
|
|
211
|
+
|
|
212
|
+
- A file link is a capability: holding it downloads that file until it expires (≤ 1 hour). The function
|
|
213
|
+
that issues it authorizes the resource first; the route reads no session, so links work as `<img src>`.
|
|
214
|
+
Only the SHA-256 of a token is stored.
|
|
215
|
+
- **Default:** `Cache-Control: private, no-store`, a new URL every call.
|
|
216
|
+
- **Cacheable links (`cache: true`, opt-in):** `private, max-age=<remaining>, immutable`, ETag/304.
|
|
217
|
+
- Tokens are HMAC-SHA256 of { file, content, variant, disposition, principal, workspace, window } under a
|
|
218
|
+
random per-process key that is never stored. Another principal never receives the same URL, and no
|
|
219
|
+
URL is derived from the bytes alone, so identical bytes in two workspaces never share an address.
|
|
220
|
+
- **Accepted risk:** a browser that already downloaded a file keeps showing its copy until `max-age`
|
|
221
|
+
runs out (at most the link's `expiresInSeconds`, ≤ 1 hour), after a removal or a loss of access.
|
|
222
|
+
`private` keeps it out of shared caches; new downloads through the link stop at once.
|
|
223
|
+
- A link serves only the content it was issued for: a record that comes to name other bytes refuses it.
|
|
224
|
+
- **Image variants** are served only through a link to their original, so they are authorized exactly as
|
|
225
|
+
it is. Decoding untrusted images: the format is sniffed from the bytes (never the declared type), the
|
|
226
|
+
pixel count is checked from the header before decoding (`services.files.maxVariantPixels`), the JPEG
|
|
227
|
+
decoder runs with its own resolution and memory limits, and anything that fails is served as the
|
|
228
|
+
original, saying so. The codecs are pure JavaScript (no native code). Every download, variant or not,
|
|
229
|
+
keeps `Content-Security-Policy: …; sandbox`; reasons in `X-FeltKit-Variant-Reason` are FeltKit's own
|
|
230
|
+
text, reduced to printable ASCII.
|
|
231
|
+
|
|
166
232
|
## Known gaps
|
|
167
233
|
|
|
168
234
|
- No rate limiting on FeltKit's own endpoints. Put a reverse proxy in front of
|
|
@@ -179,5 +245,8 @@ Every entry point was exercised by `packages/sdk/test/auth.test.ts`.
|
|
|
179
245
|
- Production operator sessions cannot be listed or revoked from Studio; there is no MFA
|
|
180
246
|
and no external identity-provider integration beyond the `auth.authenticate` hook.
|
|
181
247
|
- Production Studio has no rate limiting of its own, like every FeltKit endpoint.
|
|
248
|
+
- The first download of an image variant decodes on the server's event loop. With a large
|
|
249
|
+
`maxVariantPixels`, many first downloads at once slow other requests; the default (24 MP) and the files
|
|
250
|
+
byte cap (1 MiB by default) bound it.
|
|
182
251
|
|
|
183
252
|
Report vulnerabilities privately to the repository owner.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Sign in with GitHub and Google, with nothing to register
|
|
2
|
+
|
|
3
|
+
A FeltKit app can sign people in with GitHub or Google by naming the provider and nothing else:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
feltkit({
|
|
7
|
+
auth: {
|
|
8
|
+
accounts: { roles: ["member"] },
|
|
9
|
+
providers: { github: { broker: true }, google: { broker: true } },
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
There is no OAuth client to register, no client secret to keep, and no redirect URI to configure at the provider. The same works in the app's [browser extension](EXTENSION-HOSTS.md). An app that wants its own client, its own consent screen, or any other OpenID Connect issuer keeps using `{ clientId, clientSecret }` and `oidc`: nothing about that changes.
|
|
15
|
+
|
|
16
|
+
## What happens
|
|
17
|
+
|
|
18
|
+
FeltKit runs one **broker**: one GitHub app and one Google client with fixed callback URLs on the broker's own address. It does one job and keeps nothing.
|
|
19
|
+
|
|
20
|
+
1. The person clicks "Sign in with GitHub". The app's own server sends the browser to the broker, naming itself (its sign-in callback), a one-time `state`, and a one-time `nonce`.
|
|
21
|
+
2. The broker shows a page that says **which site is asking** and what it receives (the person's name and verified e-mail address), and asks the person to continue. Then it sends them to the provider with *its own* client.
|
|
22
|
+
3. The provider signs the person in and returns to the broker. The broker reads who they are, **only if the provider calls the e-mail address verified**, and signs a short statement of it.
|
|
23
|
+
4. The browser returns to the app's callback with that statement. The app checks the signature against the keys the broker publishes, makes (or finds) the account for that verified address, and issues **its own session**.
|
|
24
|
+
|
|
25
|
+
The statement (an *assertion*, a compact EdDSA-signed token) says: who vouches (`iss`), the one origin it is for (`aud`), the provider and the provider's own id for the person (`provider`, `sub`), the verified e-mail (`email`), the app's one-time value for this attempt (`nonce`), and that it expires within a minute. An app refuses an assertion that is for another site, another provider, another attempt, from another issuer, signed by a key the broker does not publish, expired, or missing. An assertion cannot be carried to another sign-in or another app.
|
|
26
|
+
|
|
27
|
+
### What the broker is trusted with, and what it is not
|
|
28
|
+
|
|
29
|
+
| | |
|
|
30
|
+
|---|---|
|
|
31
|
+
| Sees | That a person signed in to a given site, and their provider id, name and verified e-mail, for the length of one redirect. |
|
|
32
|
+
| Keeps | Nothing. Its only state is a signed, short-lived cookie in the browser that is signing in. |
|
|
33
|
+
| Issues | Assertions. Never a session: every session is the app's own. |
|
|
34
|
+
| Holds | The GitHub and Google client secrets, and its signing key. **No app ever holds a provider secret.** |
|
|
35
|
+
| Cannot | Sign anyone in to an app on its own: the app's own checks (state cookie, nonce, audience) must pass. |
|
|
36
|
+
|
|
37
|
+
The broker only sends an assertion to an instance's own sign-in callback (`https://<host>/api/auth/providers/<provider>/callback`): https (http only for this machine in development), no other path, no query, no credentials in the address, no IP address. If the app is not who the person thought, the consent page names the host before the provider is ever shown.
|
|
38
|
+
|
|
39
|
+
## In the app's browser extension
|
|
40
|
+
|
|
41
|
+
`feltkit target:browser-extension` gives the extension a **stable ID**: its public key is in the manifest, so Chrome derives the same ID on every machine and every build. That ID makes `https://<id>.chromiumapp.org/` a fixed OAuth return address (`chrome.identity.getRedirectURL()`), and the app trusts exactly that origin.
|
|
42
|
+
|
|
43
|
+
In an extension page, `client.signInWith("github")` opens Chrome's sign-in window (`chrome.identity.launchWebAuthFlow`) at the app, which sends it through the broker as above. At the end the app returns the session to `https://<id>.chromiumapp.org/…`, where Chrome hands it to that extension and no one else, and `signInWith` resolves `{ kind: "signed-in" }` (or `{ kind: "error", message }`). In a web page `signInWith` is unchanged: it leaves the page and the session comes back in the URL fragment.
|
|
44
|
+
|
|
45
|
+
**Which extensions an app trusts.** An app trusts the identity its project keeps in `extension/identity.json` (made on the first build, committed, and carried into the deployed artifact), and any ID listed in `auth.extensions`. A sign-in that asks to return to any other extension ID, or to anything that only looks like a trusted address, returns to the app's own page instead: the session is never sent to an address the app has not named. If you publish to the Chrome Web Store, the store assigns the published ID: build once with `--public-key` (Package → View public key in the dashboard) so the unpacked and published extensions share one ID, or list the published ID in `auth.extensions`.
|
|
46
|
+
|
|
47
|
+
## Running the broker
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
npx feltkit broker keygen --out ./broker-keys # Ed25519 signing key (PEM, 0600), its id, and a secret
|
|
51
|
+
npx feltkit broker serve # configured by the environment, below
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
| Variable | |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `FELTKIT_BROKER_URL` | The public address with its path. Default `https://getfeltkit.com/broker`. |
|
|
57
|
+
| `FELTKIT_BROKER_SIGNING_KEY`, `FELTKIT_BROKER_KID` | The private key (PEM text, or the path of the file) and its id, from `keygen`. |
|
|
58
|
+
| `FELTKIT_BROKER_SECRET` | 32 or more random bytes, as text: signs the broker's cookies and request tokens. |
|
|
59
|
+
| `FELTKIT_BROKER_GITHUB_CLIENT_ID` / `_SECRET` | The GitHub OAuth app registered for this broker. |
|
|
60
|
+
| `FELTKIT_BROKER_GOOGLE_CLIENT_ID` / `_SECRET` | The Google OAuth client registered for this broker. |
|
|
61
|
+
| `FELTKIT_BROKER_RETIRED_KEYS` | A JSON array of earlier public keys, still published while apps' caches turn over. |
|
|
62
|
+
|
|
63
|
+
`serve` prints the callback URL to register at each provider: `<FELTKIT_BROKER_URL>/v1/callback/github` and `…/google`. It listens on `--port` (or `PORT`, default 8787) and answers only under its address's path, so route `https://getfeltkit.com/broker/*` to it with the path kept. Register the apps with the provider's callback exactly as printed; the broker needs at least one provider.
|
|
64
|
+
|
|
65
|
+
The broker publishes its public keys at `<issuer>/.well-known/feltkit-broker-keys.json` (cached five minutes by an app; looked up once more when an assertion names a key the cache does not have). **To rotate**: `keygen` a new key, move the old public key into `FELTKIT_BROKER_RETIRED_KEYS`, set the new `SIGNING_KEY` and `KID`, restart; later drop the retired key. A broker that is down stops brokered sign-in only: apps keep their cached keys, and every other way of signing in keeps working.
|
|
66
|
+
|
|
67
|
+
### Pointing an app at another broker
|
|
68
|
+
|
|
69
|
+
`providers: { github: { broker: { issuer: "https://auth.example.com/broker" } } }`, or `FELTKIT_BROKER_URL` in the app's environment. An app may pin the broker's public keys with `broker: { issuer, keys: [...] }` instead of fetching them. The issuer must be https (an `http://localhost` issuer only outside production).
|
|
70
|
+
|
|
71
|
+
## Guarantees and limits
|
|
72
|
+
|
|
73
|
+
- Only an e-mail address the provider calls verified becomes an account (GitHub's primary verified address; Google's `email_verified`). An account made through the broker and one made with an app's own client for the same provider are the same account: the provider's own id is the subject either way.
|
|
74
|
+
- The broker is rate-limited per address (60 requests a minute by default), and its pages cannot be framed.
|
|
75
|
+
- Sessions, roles and everything after sign-in are the app's: the broker has no say in them and no way to revoke them.
|
|
76
|
+
- The consent page is the person's one chance to see which site receives their identity; the broker cannot know whether the site is trustworthy, only that it is a FeltKit-shaped callback on https.
|
|
77
|
+
- E-mail links (magic link, verification, password reset, invitations) are separate from provider sign-in and are not handled by the broker; see [Browser extensions as a FeltKit host](EXTENSION-HOSTS.md).
|
package/docs/TRANSACTIONS.md
CHANGED
|
@@ -251,6 +251,10 @@ export const assistant = app.agent("assistant", {
|
|
|
251
251
|
if (text.includes("@assistant")) ctx.afterCommit.agent("assistant", { roomId });
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
+
An agent's handler that asks AuthBoundry (`ctx.authority.decide`) decides **as the agent**, with its
|
|
255
|
+
own credential, when the application uses a local authority (docs/LOCAL-AUTHORITY.md, "Several agents"):
|
|
256
|
+
only a person's grant to that agent allows it, never a grant to the executor or to another agent.
|
|
257
|
+
|
|
254
258
|
### Triggers, and why these two
|
|
255
259
|
|
|
256
260
|
- **`ctx.afterCommit.agent(name, input)`** is the general one. The application decides, in the
|