@feltdb/feltkit 0.3.17 → 0.3.18
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 +195 -5
- package/dist/app.js +150 -3
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +45 -0
- package/dist/appboundry/build.js +52 -1
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +39 -1
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.js +4 -0
- package/dist/appboundry/host.js.map +1 -1
- package/dist/authorize.js +1 -0
- package/dist/authorize.js.map +1 -1
- package/dist/cli/deploy-appboundry-self-hosted.d.ts +2 -0
- package/dist/cli/deploy-appboundry-self-hosted.js +1 -1
- package/dist/cli/deploy-appboundry-self-hosted.js.map +1 -1
- package/dist/cli/deploy-appboundry.js +3 -0
- package/dist/cli/deploy-appboundry.js.map +1 -1
- package/dist/cli/main.js +6 -1
- package/dist/cli/main.js.map +1 -1
- package/dist/client/index.d.ts +192 -5
- package/dist/client/index.js +301 -28
- package/dist/client/index.js.map +1 -1
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -0
- package/dist/docs.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/react/auth.d.ts +131 -0
- package/dist/react/auth.js +830 -0
- package/dist/react/auth.js.map +1 -0
- package/dist/react/context.d.ts +8 -0
- package/dist/react/context.js +14 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/index.d.ts +3 -18
- package/dist/react/index.js +5 -13
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/accounts.d.ts +33 -2
- package/dist/runtime/accounts.js +167 -27
- package/dist/runtime/accounts.js.map +1 -1
- package/dist/runtime/authority.d.ts +8 -1
- package/dist/runtime/authority.js +11 -2
- package/dist/runtime/authority.js.map +1 -1
- package/dist/runtime/challenges.d.ts +51 -0
- package/dist/runtime/challenges.js +121 -0
- package/dist/runtime/challenges.js.map +1 -0
- package/dist/runtime/changes.d.ts +22 -0
- package/dist/runtime/changes.js +51 -3
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/context.d.ts +41 -0
- package/dist/runtime/contract.js +14 -3
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/data.d.ts +36 -2
- package/dist/runtime/data.js +56 -17
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/live.d.ts +48 -0
- package/dist/runtime/live.js +154 -0
- package/dist/runtime/live.js.map +1 -0
- package/dist/runtime/outbox.js +3 -0
- package/dist/runtime/outbox.js.map +1 -1
- package/dist/runtime/runtime.d.ts +70 -5
- package/dist/runtime/runtime.js +290 -35
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/search.d.ts +54 -0
- package/dist/runtime/search.js +66 -0
- package/dist/runtime/search.js.map +1 -0
- package/dist/runtime/sessions.d.ts +16 -2
- package/dist/runtime/sessions.js +40 -4
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/tenancy.d.ts +189 -0
- package/dist/runtime/tenancy.js +376 -0
- package/dist/runtime/tenancy.js.map +1 -0
- package/dist/runtime/tenant-scope.d.ts +9 -0
- package/dist/runtime/tenant-scope.js +127 -0
- package/dist/runtime/tenant-scope.js.map +1 -0
- package/dist/runtime/transactions.d.ts +45 -2
- package/dist/runtime/transactions.js +36 -9
- package/dist/runtime/transactions.js.map +1 -1
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +300 -58
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp.js +6 -3
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/session-http.d.ts +48 -0
- package/dist/server/session-http.js +116 -0
- package/dist/server/session-http.js.map +1 -0
- package/dist/server/tenancy.d.ts +40 -0
- package/dist/server/tenancy.js +191 -0
- package/dist/server/tenancy.js.map +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.js +7 -2
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-OPERATIONS.md +1 -0
- package/docs/APPBOUNDRY.md +11 -1
- package/docs/ARCHITECTURE.md +4 -2
- package/docs/AUTH.md +262 -0
- package/docs/GUARANTEES.md +50 -3
- package/docs/README.md +3 -2
- package/docs/SECURITY.md +3 -2
- package/docs/TRANSACTIONS.md +98 -1
- package/docs/UPSTREAM-GAPS.md +2 -0
- package/package.json +11 -10
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-data/SKILL.md +6 -0
- package/dist/runtime/account-links.d.ts +0 -19
- package/dist/runtime/account-links.js +0 -45
- package/dist/runtime/account-links.js.map +0 -1
package/docs/AUTH.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# Accounts, sessions, workspaces and the sign-in screens
|
|
2
|
+
|
|
3
|
+
FeltKit gives an application its people and their workspaces:
|
|
4
|
+
- sign-in (password, e-mailed links, Google, GitHub, any OpenID Connect provider);
|
|
5
|
+
- the account (profile, address, password, connected providers, sessions);
|
|
6
|
+
- tenancy (workspaces, roles, invitations, switching);
|
|
7
|
+
- the React screens for all of it.
|
|
8
|
+
|
|
9
|
+
Everything is enforced on the server. The state lives in the application's own FeltDB instance, and
|
|
10
|
+
e-mail goes through AppPort Services' notifications and Mailerport. A complete app built only from these
|
|
11
|
+
pieces is `examples/teams`.
|
|
12
|
+
|
|
13
|
+
## Configure
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { feltkit, s } from "@feltdb/feltkit";
|
|
17
|
+
|
|
18
|
+
export const app = feltkit({
|
|
19
|
+
name: "teams",
|
|
20
|
+
// One authorization model: workspace roles are ordinary roles.
|
|
21
|
+
roles: {
|
|
22
|
+
person: [], // every account, before it joins a workspace
|
|
23
|
+
owner: ["notes.*", "tenant.*"], // tenant.* = manage members and rename
|
|
24
|
+
admin: ["notes.*", "tenant.members.manage"],
|
|
25
|
+
member: ["notes.*"],
|
|
26
|
+
guest: ["notes.read"],
|
|
27
|
+
},
|
|
28
|
+
auth: {
|
|
29
|
+
accounts: {
|
|
30
|
+
roles: ["person"], // what every account holds everywhere
|
|
31
|
+
password: true, // default
|
|
32
|
+
magicLink: true, // e-mailed sign-in link + 8-digit code
|
|
33
|
+
email: { from: "auth@example.com", verify: "optional", templates: { /* optional */ } },
|
|
34
|
+
},
|
|
35
|
+
providers: { google: { clientId: "…" }, github: { clientId: "…" }, oidc: [{ id: "okta", issuer: "https://…", clientId: "…" }] },
|
|
36
|
+
session: { cookie: "auto", trustProxy: 1 },
|
|
37
|
+
tenant: {
|
|
38
|
+
name: "workspace", // the word the screens and messages use
|
|
39
|
+
roles: ["owner", "admin", "member", "guest"], // highest first; each a declared role
|
|
40
|
+
claims: { plan: s.optional(s.enum(["free", "pro"])) },
|
|
41
|
+
create: "anyone", // or "none"
|
|
42
|
+
invitations: { ttlMs: 7 * 24 * 3_600_000 }, // default 7 days, at most 30
|
|
43
|
+
switching: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`feltkit()` refuses a configuration that cannot work, and says what to change:
|
|
50
|
+
- a role that is not declared;
|
|
51
|
+
- `magicLink` without `email`;
|
|
52
|
+
- no way to sign in;
|
|
53
|
+
- a tenant with no role granting `tenant.members.manage`;
|
|
54
|
+
- `role` declared as a claim;
|
|
55
|
+
- an unknown e-mail template;
|
|
56
|
+
- an inline client secret.
|
|
57
|
+
|
|
58
|
+
Provider client secrets are credentials: `credential-ref:<id>-client-secret`, for example `FELTKIT_CREDENTIAL_GOOGLE_CLIENT_SECRET`.
|
|
59
|
+
|
|
60
|
+
### Mapping from `use auth`
|
|
61
|
+
|
|
62
|
+
If you know AuthBoundry's `use auth { … }` block, this is the same configuration in FeltKit's one
|
|
63
|
+
configuration language:
|
|
64
|
+
|
|
65
|
+
| `use auth` | `feltkit({ auth })` |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `providers=[email]` | `accounts` (password) |
|
|
68
|
+
| `providers=[magic-link]` | `accounts.magicLink` |
|
|
69
|
+
| `providers=[google,github]` | `providers.google`, `providers.github` |
|
|
70
|
+
| `tenant=true` | `tenant` |
|
|
71
|
+
| `claims={role=enum[…]}` | `tenant.roles` |
|
|
72
|
+
| `claims={plan=enum[…]}` | `tenant.claims.plan` |
|
|
73
|
+
| `use mail { identities … }` | `accounts.email.from` and `identity` |
|
|
74
|
+
| `use mail { templates … }` | `accounts.email.templates` |
|
|
75
|
+
|
|
76
|
+
## Sign-in methods and account e-mail
|
|
77
|
+
|
|
78
|
+
| Method | How |
|
|
79
|
+
|---|---|
|
|
80
|
+
| Password | `POST /api/auth/signup`, `POST /api/auth/signin`. scrypt hashes. One answer for an unknown address and a wrong password, which take the same time. 10 failures per address and per client address in 15 minutes. |
|
|
81
|
+
| Magic link | `POST /api/auth/magic/request { email }` sends a link and an 8-digit code. `POST /api/auth/magic { token }` or `{ email, code }` redeems them. A new address gets a verified account when sign-up is open. |
|
|
82
|
+
| Google, GitHub, OIDC | Authorization code with PKCE (S256) and a `state` bound to the browser. Only a verified e-mail address is accepted. |
|
|
83
|
+
| Verify address | `POST /api/auth/verify/request { email }`, then `POST /api/auth/verify { token }`. |
|
|
84
|
+
| Reset password | `POST /api/auth/reset/request { email }`, then `POST /api/auth/reset { token, password }`. Signs the account out everywhere. |
|
|
85
|
+
|
|
86
|
+
**Sign-up and enumeration.** With `email.verify: "required"`, sign-up answers the same for a taken address
|
|
87
|
+
as for a new one: the address's owner gets a password-reset link instead. With optional verification, a new
|
|
88
|
+
account gets its session at once, so sign-up necessarily reveals a taken address (`CONFLICT`). Use
|
|
89
|
+
`verify: "required"`, or magic links alone, when that matters.
|
|
90
|
+
|
|
91
|
+
Every e-mailed secret (verify, reset, magic link, address change) is a **challenge**:
|
|
92
|
+
- **Lifetime:** durable in FeltDB, at most 15 minutes, single use, and superseded when another is requested for the same purpose.
|
|
93
|
+
- **Codes:** a code allows 5 wrong attempts, then the challenge is void.
|
|
94
|
+
- **Volume:** 5 challenges per address and purpose per hour.
|
|
95
|
+
- **Storage:** the record holds a nonce and digests only. The link token and the code are `HMAC(FELTKIT_AUTH_SECRET, nonce)`, computed when the e-mail is delivered, so neither the notification record nor the challenge record holds a usable secret.
|
|
96
|
+
- **Answers:** requests answer the same whether or not the address has an account, and whether or not it is over its limit.
|
|
97
|
+
|
|
98
|
+
E-mail goes through AppPort Services' notifications to Mailerport:
|
|
99
|
+
- **Development:** the message is printed by `feltkit dev`.
|
|
100
|
+
- **Production:** it goes to the Mailerport service at `MAILPORT_URL` with `MAILPORT_API_KEY`, as the identity you register there (default `auth`).
|
|
101
|
+
|
|
102
|
+
Your own text: `accounts.email.templates[purpose](input) → { subject, text, html? }`, where `purpose` is one of `verify`, `reset`, `magic-link`, `email-change` or `invitation`.
|
|
103
|
+
|
|
104
|
+
## Sessions
|
|
105
|
+
|
|
106
|
+
- **Browsers: an HttpOnly cookie.**
|
|
107
|
+
- **Cookie:** `createClient()` in a browser uses cookie mode. The cookie is `__Host-fk_session` over HTTPS (Secure, Path=/, no Domain), or `fk_session` on plain-HTTP development, with `HttpOnly; SameSite=Lax`. Page script never sees the token, and nothing is kept in `localStorage`.
|
|
108
|
+
- **Migration:** an older client's `localStorage` token is moved into the cookie once (`POST /api/auth/cookie`), then removed.
|
|
109
|
+
- **CSRF.**
|
|
110
|
+
- A cookie-authenticated `POST`, `PUT` or `DELETE` must send `X-FeltKit-CSRF`, an HMAC of the session's digest that `GET /api/session` hands the page. The client does this for you.
|
|
111
|
+
- A request with a foreign `Origin` is refused.
|
|
112
|
+
- Cross-site pages cannot read the token, and cannot send the header without a CORS preflight, which FeltKit never grants.
|
|
113
|
+
- **CLI, services, API keys: bearer tokens, unchanged.** `Authorization: Bearer <token>`, with no CSRF token: a bearer token is not an ambient credential. `createClient({ session: "bearer" })` keeps the bearer behaviour in a browser.
|
|
114
|
+
- **Lifetime and revocation.**
|
|
115
|
+
- Lifetime: 7 days by default (`auth.sessionTtlMs`).
|
|
116
|
+
- Signing out deletes the session and clears the cookie.
|
|
117
|
+
- `GET /api/auth/sessions` lists your sessions.
|
|
118
|
+
- `POST /api/auth/sessions/revoke` takes `{ ref }` for one, or `{ all: true, keepCurrent }` for all of them.
|
|
119
|
+
- **Rotation.** A password change, and switching, creating, leaving or joining a workspace, replace the session (a new token; the old one ends).
|
|
120
|
+
- **Always current.** An account session is resolved again on every request: the account as it is now, plus the live membership in its workspace. Changed roles, a disabled account, a removed membership or a changed role in a workspace take effect on the next request, not at expiry. Roles are never trusted as copied at sign-in. Dev, CLI and agent sessions carry the roles their issuer gave them.
|
|
121
|
+
- **Trusted proxies.** `auth.session.trustProxy` is the number of reverse proxies in front that append to `X-Forwarded-For` and set `X-Forwarded-Proto`. With the default (0) both headers are ignored, because a client could forge them; the client address used for throttling is then the socket's.
|
|
122
|
+
|
|
123
|
+
## Workspaces (tenancy)
|
|
124
|
+
|
|
125
|
+
A tenant ("workspace", or whatever `tenant.name` says) has members.
|
|
126
|
+
- **Membership.** Each member has one of `tenant.roles` and typed claims.
|
|
127
|
+
- **Where a role applies.** A session works in one tenant at a time. In it, the member holds their role's permissions: the same `roles`, `access` and `authorize` hook as everything else. There is no second policy.
|
|
128
|
+
|
|
129
|
+
| Operation | Route | Who |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| Your workspaces, the current one, what you may do | `GET /api/tenants` | signed in |
|
|
132
|
+
| Create (you hold the top role) and switch to it | `POST /api/tenants { name }` | `tenant.create: "anyone"` |
|
|
133
|
+
| Switch (`null`: none) | `POST /api/tenants/switch { tenantId }` | members of it only |
|
|
134
|
+
| Members | `GET /api/tenants/current/members` | members |
|
|
135
|
+
| Change a role | `POST …/members/role { principalId, role }` | `tenant.members.manage` |
|
|
136
|
+
| Set claims | `POST …/members/claims { principalId, claims }` | `tenant.members.manage` |
|
|
137
|
+
| Remove | `POST …/members/remove { principalId }` | `tenant.members.manage` |
|
|
138
|
+
| Add an agent or service | `POST …/members/add { principalId, role }` | `tenant.members.manage` |
|
|
139
|
+
| Leave | `POST /api/tenants/current/leave` | members |
|
|
140
|
+
| Rename | `POST /api/tenants/current/rename { name }` | `tenant.update` |
|
|
141
|
+
| Invite, list, withdraw | `POST`/`GET …/invitations`, `POST …/invitations/revoke` | `tenant.members.manage` |
|
|
142
|
+
| What an invitation is for | `POST /api/invitations/preview { token }` | its holder |
|
|
143
|
+
| Accept | `POST /api/invitations/accept { token }` | the invited, verified address |
|
|
144
|
+
|
|
145
|
+
Rules the server enforces:
|
|
146
|
+
- **The tenant is the session's.** A tenant id in a request is only ever a request to switch, checked against your memberships. A tenant you are not a member of does not exist for you (`NOT_FOUND`).
|
|
147
|
+
- **Rank.** `tenant.roles` is ordered, highest first. A manager assigns and changes only roles below their own, and only the top role assigns the top role. Nobody raises their own role. A workspace always keeps a holder of the top role. A role that is not declared cannot be assigned, so a workspace administrator cannot create a capability.
|
|
148
|
+
- **Invitations.**
|
|
149
|
+
- **Token:** a random token derived with the auth secret, never stored.
|
|
150
|
+
- **Use:** single use, and expiring.
|
|
151
|
+
- **Who may accept:** only an account whose verified address is the invited one (development identities may accept in development).
|
|
152
|
+
- **Withdrawn or expired:** refused.
|
|
153
|
+
- **Delivery:** e-mailed when the app sends account e-mail, and the inviter also gets the link to share.
|
|
154
|
+
- **Agents and services** are added directly, with a role, only when they hold an operator-issued identity (`feltkit session create --type agent`) or are application agents the app declares (`app.agent`). People join only by invitation.
|
|
155
|
+
An application agent (`app.agent`) works in the tenant of the call that triggered it only if it is an active member there itself, with its own membership role; otherwise it runs with no tenant (docs/TRANSACTIONS.md §8).
|
|
156
|
+
- **Claims** are typed by `tenant.claims`, validated on write, and set only by the server. A request never supplies them, and `role` is the membership's role, not a claim you set.
|
|
157
|
+
|
|
158
|
+
### Data that belongs to a workspace
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
export const notes = app.collection("notes", { title: s.string() }, { tenant: true }); // field tenantId
|
|
162
|
+
export const channels = app.collection("channels", { … }, { tenant: { field: "workspaceId" } });
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
FeltKit treats each operation as follows:
|
|
166
|
+
- **insert:** sets the field to the session's tenant, and refuses a different value (`FORBIDDEN`, hint `TENANT_MISMATCH`).
|
|
167
|
+
- **get:** returns `null` for another tenant's record.
|
|
168
|
+
- **find, count, query:** return only the session's tenant's records.
|
|
169
|
+
- **patch, replace, delete:** another tenant's record is `NOT_FOUND`.
|
|
170
|
+
- **No tenant in the call:** these collections are closed (`FAILED_PRECONDITION`, hint `NO_TENANT`).
|
|
171
|
+
|
|
172
|
+
FeltKit adds an index on the field. Records written before a collection was scoped have no tenant, so they are visible to none.
|
|
173
|
+
|
|
174
|
+
### In your functions
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
handler: async (ctx) => {
|
|
178
|
+
const tenant = app.requireTenant(ctx); // { id, name, role, claims } — typed by auth.tenant
|
|
179
|
+
if (tenant.claims.role === "owner") { … }
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`ctx.auth.tenant` is the same value, untyped. The `authorize` hook sees it on `request.principal.tenant`.
|
|
184
|
+
In tests, `createTestApp()` provides:
|
|
185
|
+
- `t.tenancy`, the store, for setup;
|
|
186
|
+
- `t.as(who, { tenant })`, which works in a tenant exactly as a session does.
|
|
187
|
+
|
|
188
|
+
## React screens (`@feltdb/feltkit/react`)
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
import { SignIn, AcceptInvitation, CreateTenant, TenantSwitcher, TenantSettings, AccountSettings,
|
|
192
|
+
AuthNotices, VerifyEmailBanner, useAuth, useTenant, useAuthRedirect } from "@feltdb/feltkit/react";
|
|
193
|
+
|
|
194
|
+
function App() {
|
|
195
|
+
const auth = useAuth();
|
|
196
|
+
const tenant = useTenant();
|
|
197
|
+
const { redirect } = useAuthRedirect();
|
|
198
|
+
if (auth.loading) return null;
|
|
199
|
+
if (redirect?.kind === "invitation") return <AcceptInvitation />; // signs in first when needed
|
|
200
|
+
if (!auth.user) return <SignIn brand={{ name: "Teams", logo: "/logo.png" }} />;
|
|
201
|
+
if (!tenant.current) return <CreateTenant />;
|
|
202
|
+
return (
|
|
203
|
+
<>
|
|
204
|
+
<TenantSwitcher />
|
|
205
|
+
<AuthNotices /><VerifyEmailBanner />
|
|
206
|
+
{/* your app; tenant.current is the workspace; switching re-runs every live query */}
|
|
207
|
+
</>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
| Component | What it does |
|
|
213
|
+
|---|---|
|
|
214
|
+
| `SignIn` | Offers what the app enables: password, sign-up, magic link and code, providers, forgot and reset. Also handles the links that come back into the app: reset, verified, expired or used links. `returnTo` accepts only a path on this site. |
|
|
215
|
+
| `AcceptInvitation` | Shows what the invitation is for. Signs in first, with the invited address prefilled, when needed. Handles expired, withdrawn, used and wrong-account invitations. Keeps the invitation for the tab until it is accepted. |
|
|
216
|
+
| `TenantSwitcher` | The current workspace, with a keyboard-accessible menu to switch to another or create one. |
|
|
217
|
+
| `CreateTenant` | First-run screen: open one of your workspaces, or create one. |
|
|
218
|
+
| `TenantSettings` (`MembersPanel`, `InvitationsPanel`) | Name, members, roles, removal, leaving, invitations (copy link, withdraw). Shows only what the server says you may do. |
|
|
219
|
+
| `AccountSettings` | Profile, address and verification, address change, password, connected providers, sessions, sign out of other sessions, sign out. |
|
|
220
|
+
| `AuthNotices`, `VerifyEmailBanner` | What a link opened while signed in did; a reminder to verify. |
|
|
221
|
+
|
|
222
|
+
All of them include:
|
|
223
|
+
- loading, empty, error and expired states;
|
|
224
|
+
- labelled form controls and `aria-live` status;
|
|
225
|
+
- keyboard operation and visible focus;
|
|
226
|
+
- layouts that work from phones to desktops.
|
|
227
|
+
|
|
228
|
+
**Styling.**
|
|
229
|
+
- **Stylesheet:** the components add one small stylesheet (`fk-*` classes) to the page, before your own CSS, so your rules win.
|
|
230
|
+
- **Theming:** use CSS custom properties on any ancestor: `--fk-accent`, `--fk-accent-ink`, `--fk-surface`, `--fk-ink`, `--fk-muted`, `--fk-line`, `--fk-danger`, `--fk-radius`, `--fk-font`. They default to your app's `--accent`, `--surface`, `--ink`, `--muted`, `--line` and `--radius` when it defines them, and to the system's colours (light and dark) otherwise.
|
|
231
|
+
- **Overrides:** every component takes `className`. Render `<FeltKitAuthStyles disabled />` once to style everything yourself.
|
|
232
|
+
|
|
233
|
+
## AppBoundry
|
|
234
|
+
|
|
235
|
+
An artifact built with `feltkit build --target appboundry` behaves as follows:
|
|
236
|
+
- **Collections:** it carries the tenant-scoped collections, and the guest applies the same scope to the tenant its host resolves.
|
|
237
|
+
- **Closed by default:** a host that resolves no tenant leaves those collections closed.
|
|
238
|
+
- **What AppBoundry lacks today:** AppBoundry's host issues operator sessions and has no accounts or tenancy (FK-GAP-013). Sign-in, invitations and switching therefore need FeltKit's Node server (`feltkit dev`, `feltkit start`, `feltkit deploy`) until it does.
|
|
239
|
+
- **Declared and warned:** the build declares `auth.accounts` as `identity.accounts` and `auth.tenant` as `identity.tenancy` in the manifest, lists them under `omitted`, and warns. An AppBoundry host that knows the declaration refuses the artifact unless its operator accepts operator-issued sessions (`appboundry run --accounts operator-sessions`).
|
|
240
|
+
- **File links:** these, and the routes above, are Node-server routes.
|
|
241
|
+
|
|
242
|
+
## Deploying
|
|
243
|
+
|
|
244
|
+
| Setting | Why |
|
|
245
|
+
|---|---|
|
|
246
|
+
| `FELTKIT_AUTH_SECRET` (32+ bytes, the same on every process) | Derives challenge, invitation and CSRF tokens and signs provider state. In development, and with local production state, it is generated and kept beside the state. Changing it invalidates outstanding links and CSRF tokens, not sessions. |
|
|
247
|
+
| HTTPS in front | `__Host-` cookies need it, and production cookies are always `Secure`. |
|
|
248
|
+
| `auth.session.trustProxy` | The number of proxies that set `X-Forwarded-For` and `-Proto`. |
|
|
249
|
+
| `FELTKIT_PUBLIC_URL` (https in production) | The origin that e-mailed links and provider callbacks use, never the request's `Host`. |
|
|
250
|
+
| `MAILPORT_URL`, `MAILPORT_API_KEY` | Account e-mail and invitations in production. |
|
|
251
|
+
| One public origin for the app and its API | Cookie sessions are same-origin. A frontend on another origin uses `createClient({ url, session: "bearer" })`. |
|
|
252
|
+
|
|
253
|
+
## Migrating from the earlier auth API
|
|
254
|
+
|
|
255
|
+
- **Existing configuration:** `auth.accounts` and `auth.providers` work unchanged. Existing bearer sessions stay valid.
|
|
256
|
+
- **Browser client:** it now uses cookies. A token an older version left in `localStorage` is moved into the cookie on the first load. Pass `session: "bearer"` to keep the old behaviour.
|
|
257
|
+
- **Old links:** verification and reset links sent before this version stop working. They were stateless HMAC links (verification for 7 days); they are now durable 15-minute challenges. People ask for a new one.
|
|
258
|
+
- **Session response:** `GET /api/session` adds `transport`, `csrf` (cookie sessions), `tenant` and `tenancy`. `accounts` adds `password` and `magicLink`.
|
|
259
|
+
- **Workspaces you built yourself:** move them to `auth.tenant`.
|
|
260
|
+
- Make the workspace data `{ tenant: { field: "<your field>" } }`, so your records keep their field.
|
|
261
|
+
- Drop your membership and invitation collections.
|
|
262
|
+
- Take the workspace and role from `ctx.auth.tenant`, not from an argument.
|
package/docs/GUARANTEES.md
CHANGED
|
@@ -208,16 +208,50 @@ published contract declares (`appport.integration/1` `failures`). Tests:
|
|
|
208
208
|
|
|
209
209
|
- The change stream requires a session unless the application has a public query.
|
|
210
210
|
- Within one server process, every committed write produces a change notification
|
|
211
|
-
naming its collection, at least once, typically within 150 ms
|
|
212
|
-
|
|
211
|
+
naming its collection, at least once, typically within 150 ms, to every subscriber
|
|
212
|
+
that could see it. Data is always re-read through the authorized query endpoint.
|
|
213
213
|
- After a reconnect, clients re-run every watched query.
|
|
214
|
-
-
|
|
214
|
+
- **Invalidation by predicate (local state).** A query's `reads` lists the collections it
|
|
215
|
+
read, then `collection#key` for each equality predicate of a collection it read only
|
|
216
|
+
through predicates (`get` by id; the equality clauses of `find`, `count`, `query`,
|
|
217
|
+
`search`; of a conjunction, one clause stands for it: `id`, else another keyed field,
|
|
218
|
+
else the tenant field). A change event for a write committed through FeltKit carries,
|
|
219
|
+
per collection, the keys of every changed record's keyed values before and after the
|
|
220
|
+
write. A watched query re-runs when a change's keys meet its predicates, when a
|
|
221
|
+
collection it read wholly changed, or when a change has no keys for a collection it
|
|
222
|
+
read. So inserts, updates (including a record moving out of a predicate) and deletes
|
|
223
|
+
re-run exactly the predicates they touch, and never fewer.
|
|
224
|
+
- **Keyed fields** are `id`, the fields of declared indexes and unique constraints,
|
|
225
|
+
references (`s.ref`) and the tenant field. A read filtering only on other fields counts
|
|
226
|
+
as a whole-collection read. Values of other fields never leave the server in any form.
|
|
227
|
+
- **Keys, not values.** A key is `HMAC-SHA256(K, collection‖field‖value)` (128 bits) with
|
|
228
|
+
K drawn at random per server process and never sent: a client cannot compute a key, only
|
|
229
|
+
compare the ones it is given, so it cannot test guessed values against the stream
|
|
230
|
+
offline. What a key it holds (from one of its own query results) can tell it is that a
|
|
231
|
+
record with that keyed value changed: the timing of changes, which the collection-level
|
|
232
|
+
stream already revealed per collection, now per keyed value.
|
|
233
|
+
- **Tenant isolation of the stream.** For a tenant-scoped collection the server sends a
|
|
234
|
+
change only for records whose tenant (before or after) is the subscriber's session's
|
|
235
|
+
tenant; another tenant's writes are not sent at all. If a change is withheld, the
|
|
236
|
+
session is looked up again (at most every 2 s) and, when it switched tenant, the client
|
|
237
|
+
is told to re-run everything.
|
|
238
|
+
- **When in doubt, re-run.** Writes FeltKit did not commit (`ctx.unsafe.feltdb`, AppPort
|
|
239
|
+
Services' stores, agent state), a description that reached the change feed after its
|
|
240
|
+
journal operation, an unreadable journal, every change on a FeltDB server (whose feed is
|
|
241
|
+
collection markers), and a restart (new key; the client re-runs on reconnect) all fall
|
|
242
|
+
back to per-collection invalidation. Clients that understand only collection names keep
|
|
243
|
+
working unchanged.
|
|
215
244
|
|
|
216
245
|
## Queries
|
|
217
246
|
|
|
218
247
|
- Queries cannot write through `ctx.db`. FeltKit does not sandbox handlers, so a query
|
|
219
248
|
can still make network calls or other side effects; FeltKit does not claim purity.
|
|
220
249
|
- `count` reads all matching records.
|
|
250
|
+
- `search` reads the records matching its equality `where` in pages, in the requested
|
|
251
|
+
order, until `limit` (≤ 100) match: cost is linear in the records matching `where`, not
|
|
252
|
+
in the result. It examines at most 50,000 records and then fails with
|
|
253
|
+
`FAILED_PRECONDITION` rather than answering incompletely. FeltDB has no text index yet
|
|
254
|
+
(docs/UPSTREAM-GAPS.md F23).
|
|
221
255
|
|
|
222
256
|
## Identity
|
|
223
257
|
|
|
@@ -297,6 +331,19 @@ no completion is reported as outcome unknown, never as success or failure. Enabl
|
|
|
297
331
|
the SHA-256 of a link token is stored (`_feltkit_file_links` on the `feltkit.files` handle).
|
|
298
332
|
Links are not revoked when membership changes; they expire.
|
|
299
333
|
|
|
334
|
+
## Accounts, sessions and workspaces
|
|
335
|
+
|
|
336
|
+
Full contract: AUTH.md.
|
|
337
|
+
- **Account sessions are current.** On every request (HTTP, AppPort, MCP) an account session is resolved from the account as it is now, and its workspace from the live membership. A disabled account, a removed membership or a changed role applies on the next request.
|
|
338
|
+
- **Browser sessions** are an HttpOnly cookie. A cookie-authenticated unsafe request needs the session's CSRF token, and a foreign `Origin` is refused. Bearer clients are unchanged.
|
|
339
|
+
- **Account e-mail secrets** are durable challenges: digest-only, at most 15 minutes, single use, superseded, with 5 code attempts and 5 issues per address and purpose per hour. Their tokens are derived with `FELTKIT_AUTH_SECRET` when delivered, and never stored.
|
|
340
|
+
- **Workspace data** (`{ tenant }` collections) is scoped to the session's workspace for every read and write, in FeltKit's runtime and in AppBoundry artifacts. No workspace means closed. A request cannot name another workspace's data into existence.
|
|
341
|
+
- **Workspace roles** are declared `roles`, ranked. Managers assign only below their own rank, nobody raises their own, and a workspace keeps a holder of its top role. Invitations are single use, expire, and are accepted only by the invited, verified address.
|
|
342
|
+
- **Known limits.**
|
|
343
|
+
- Throttling counters are per process, and in memory.
|
|
344
|
+
- Jobs, schedules and agent actions run as their principal without a workspace, so they cannot reach `{ tenant }` collections yet.
|
|
345
|
+
- AppBoundry hosts resolve no workspace (FK-GAP-013).
|
|
346
|
+
|
|
300
347
|
## Agents
|
|
301
348
|
|
|
302
349
|
The FeltKit agent is FeltDB's agent runtime and agent state on the shared instance
|
package/docs/README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
# FeltKit 0.3.
|
|
1
|
+
# FeltKit 0.3.18 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.18/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
|
+
- [AUTH.md](AUTH.md): Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens
|
|
10
11
|
- [AGENT-OPERATIONS.md](AGENT-OPERATIONS.md): Agents: MCP, tasks, proposals, approvals, and evidence
|
|
11
12
|
- [RESOLVER.md](RESOLVER.md): Model references: change the model a deployed app uses through Resolver, without a redeploy
|
|
12
13
|
- [PATH-TO-PRODUCTION.md](PATH-TO-PRODUCTION.md): From a local app to production: deploy targets and what you must provide
|
package/docs/SECURITY.md
CHANGED
|
@@ -64,8 +64,9 @@
|
|
|
64
64
|
`feltkit.operations.read`; actions need `feltkit.operations.write` and then whatever
|
|
65
65
|
the operation itself needs (the action's capability permission and `feltkit.agent.write`
|
|
66
66
|
for agent actions; the services' `jobs.retry` for job retry).
|
|
67
|
-
- **Not supported:** OIDC/SAML
|
|
68
|
-
|
|
67
|
+
- **Not supported for Studio operators:** OIDC/SAML sign-in to Studio (an application's own
|
|
68
|
+
users can sign in with Google, GitHub or any OpenID Connect provider: docs/AUTH.md; for Studio use
|
|
69
|
+
the `auth.authenticate` hook with your own verification), operator session listing or
|
|
69
70
|
revocation from Studio (sessions expire; rotating the operator key invalidates unused
|
|
70
71
|
grants, not existing sessions — revoke with `feltkit session revoke` while the server is
|
|
71
72
|
stopped), and MFA.
|
package/docs/TRANSACTIONS.md
CHANGED
|
@@ -180,7 +180,7 @@ Creation, not execution: a job's run and a webhook's delivery to its endpoint st
|
|
|
180
180
|
source build and the packed package (extending `tests/e2e/state-contract-parity.test.mjs`).
|
|
181
181
|
- Existing applications keep their ordering: `test/sequence.test.ts` passes unchanged.
|
|
182
182
|
|
|
183
|
-
## 7. Evidence
|
|
183
|
+
## 7. Evidence (sequences and after-commit effects)
|
|
184
184
|
|
|
185
185
|
- `packages/sdk/test/transactions.test.ts` (FeltKit runtime, local state directory) covers:
|
|
186
186
|
- 10 concurrent streams, 3 rounds, all committed and each `[1, 2, 3]`;
|
|
@@ -214,3 +214,100 @@ Creation, not execution: a job's run and a webhook's delivery to its endpoint st
|
|
|
214
214
|
- `tests/e2e/transactions-parity.test.mjs` runs one FeltKit application on FeltKit's runtime,
|
|
215
215
|
AppBoundry's source build and the packed 1.5.0, each on persisted state, with concurrent calls
|
|
216
216
|
and a restart. All three must give the same results.
|
|
217
|
+
|
|
218
|
+
## 8. Application agents (`app.agent`)
|
|
219
|
+
|
|
220
|
+
Added for FK-GAP-008 ("@assistant mention → the agent reads the conversation and acts, as itself,
|
|
221
|
+
through the app's capabilities"). It is one more after-commit effect, not a second agent runtime and
|
|
222
|
+
not a new worker: the outbox above is the queue, the services worker is the executor, and the
|
|
223
|
+
handler is ordinary application code run through the runtime's call path.
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
export const assistant = app.agent("assistant", {
|
|
227
|
+
principal: { id: "assistant", displayName: "Assistant" }, // type "agent"
|
|
228
|
+
roles: ["assistant"], // declared in feltkit({ roles }): its whole authority
|
|
229
|
+
access: "messages.write", // checked against those roles (default "authenticated")
|
|
230
|
+
on: mentioned, // optional: app.event(s) that trigger it
|
|
231
|
+
retry: { maxAttempts: 5, backoffMs: 1000 }, // defaults
|
|
232
|
+
leaseMs: 300_000, // default
|
|
233
|
+
handler: async (ctx, input) => {
|
|
234
|
+
// ctx is a mutation's context, as the agent; ctx.trigger = { agent, idempotencyKey, attempt, by, event?, requestedTenantId? }
|
|
235
|
+
const recent = await ctx.db.find(messages, { roomId: input.roomId });
|
|
236
|
+
await ctx.db.insert(messages, { roomId: input.roomId, author: ctx.auth.principal!.id, text: summarize(recent) });
|
|
237
|
+
// a model decision among options: ctx.agent.start({ objective, decision }) (FeltKit's agent, as this principal)
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// In a mutation: the app decides when (deterministic, testable).
|
|
242
|
+
if (text.includes("@assistant")) ctx.afterCommit.agent("assistant", { roomId });
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Triggers, and why these two
|
|
246
|
+
|
|
247
|
+
- **`ctx.afterCommit.agent(name, input)`** is the general one. The application decides, in the
|
|
248
|
+
mutation that made the change, whether an agent should act (a mention, a status change), with
|
|
249
|
+
exactly the input it needs. It is staged like every other after-commit effect, so it inherits the
|
|
250
|
+
outbox's guarantee: recorded if and only if the mutation commits.
|
|
251
|
+
- **`on: event`** is sugar over an existing primitive: when a mutation publishes an `app.event` named
|
|
252
|
+
in an agent's `on`, the run is staged at that moment, in the same transaction. The handler's input
|
|
253
|
+
is `{ event, payload, scope? }` and `ctx.trigger.event` names the event. The event itself stays
|
|
254
|
+
ephemeral (at most once, to current subscribers); the agent's run is durable.
|
|
255
|
+
|
|
256
|
+
Data-change triggers ("whenever a record matches X") are not offered: they would need a durable
|
|
257
|
+
change feed with its own cursor and ordering, which is the control plane this design avoids. A
|
|
258
|
+
mutation that writes the record can call `ctx.afterCommit.agent` itself.
|
|
259
|
+
|
|
260
|
+
### Execution
|
|
261
|
+
|
|
262
|
+
| Step | Behavior |
|
|
263
|
+
|---|---|
|
|
264
|
+
| Staging | An `_feltkit_outbox` record (`effect: { service: "agent", method: "run", agent, input, tenantId?, event? }`), `principalId` = the caller (or `anonymous`), in the mutation's transaction. An unknown agent name is INVALID_ARGUMENT in the mutation. |
|
|
265
|
+
| Rollback | A handler that throws, or a refused commit: no record, no run. |
|
|
266
|
+
| After commit | The runtime starts the run at once, detached: the caller's response does not wait for it, and the caller's services binding is not used. |
|
|
267
|
+
| Claim (lease) | `pending → performing`, version-checked (one performer at a time). A claim older than the agent's `leaseMs` is taken over by the services worker. |
|
|
268
|
+
| Identity | `{ id: principal.id, type: "agent", roles }`, plus a tenant only by its own membership (below). The triggering caller's roles, session and tenant role are never used. |
|
|
269
|
+
| Authority | `Runtime#call("agent/<name>", input, { principal, via: "agent" })`: roles → `access` → `feltkit({ authorize })` (it sees `function: "agent/<name>"`), then the handler with a mutation's `ctx` (`db`, `services`, `afterCommit`, `events`, `agent`) plus `ctx.trigger`. Nobody can call `agent/<name>` by name from outside. |
|
|
270
|
+
| Writes | Commit under a FeltDB transaction id derived from the record (`agent:<outboxId>`). An attempt repeated after an earlier one committed (the done mark was lost) is refused by FeltDB's transaction-id binding and recorded done with `result.committedEarlier`: **the run's writes commit at most once per trigger.** |
|
|
271
|
+
| Success | `done`, `result: { requestId, tenantId? }`; the activity entry carries `detail.agentRun` (agent, idempotency key, attempt, who triggered it, from which function, event). |
|
|
272
|
+
| Failure | `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `INVALID_ARGUMENT`, `FUNCTION_NOT_FOUND`: `failed` at once (retrying cannot change an authority decision). Anything else: back to `pending` with `error` and `notBefore = now + backoffMs·2^(attempt−1)` (at most 10 min), until `maxAttempts`, then `failed`. A run whose claim expired more than `maxAttempts` times is failed as abandoned. |
|
|
273
|
+
| Recovery | The services worker (`runServices`, every second by default) performs due agent records: `pending` past `notBefore` (or 30 s after creation if never started), and `performing` past the lease. Records are FeltDB records: they survive restarts. |
|
|
274
|
+
| Operator | `feltkit outbox list` shows them (`agent <name>`); `feltkit outbox retry <id>` runs a failed one again at once. |
|
|
275
|
+
|
|
276
|
+
**Delivery is at least once.** The handler can run more than once for one trigger (a retry, a
|
|
277
|
+
lease taken over from a slow or stopped process). FeltKit makes the run's own FeltDB writes
|
|
278
|
+
commit at most once; anything else the handler does (a model call, `ctx.services.*`, an
|
|
279
|
+
integration) should be keyed by `ctx.trigger.idempotencyKey`, which is the same on every attempt.
|
|
280
|
+
`ctx.afterCommit.*` inside the handler is part of its transaction, so it follows the writes.
|
|
281
|
+
|
|
282
|
+
### Tenancy
|
|
283
|
+
|
|
284
|
+
The record keeps the tenant the triggering call worked in (`effect.tenantId`;
|
|
285
|
+
`ctx.trigger.requestedTenantId`). When the run starts, the agent works in that tenant **only if
|
|
286
|
+
the agent's own principal is an active member there** (`TenancyStore.context`, the same check as
|
|
287
|
+
any session, via `runtime.withTenant`): it then holds its membership's role in addition to its
|
|
288
|
+
declared roles. Otherwise it runs with **no tenant**: `ctx.auth.tenant` is null and tenant-scoped
|
|
289
|
+
collections are closed to it. Add an agent to a workspace like any agent
|
|
290
|
+
(`TenancyStore.addPrincipal`, a manager's action). The trigger never carries the caller's tenant
|
|
291
|
+
role to the agent.
|
|
292
|
+
|
|
293
|
+
### Limits
|
|
294
|
+
|
|
295
|
+
- **AppBoundry artifacts cannot run application agents.** The guest/host protocol runs guest code
|
|
296
|
+
only inside a call, as that call's principal; running a handler later as another principal needs a
|
|
297
|
+
host interface AppBoundry does not have. `feltkit build --target appboundry` refuses `app.agent`
|
|
298
|
+
(naming the agents), the guest's `ctx.afterCommit.agent` answers CONFIGURATION, and FeltKit's
|
|
299
|
+
reference host refuses an `agent` effect. Run such an application on FeltKit's runtime.
|
|
300
|
+
- An agent that triggers itself (directly or through an event it publishes) loops; FeltKit does not
|
|
301
|
+
detect it.
|
|
302
|
+
- Order between runs is not guaranteed (as for every after-commit effect).
|
|
303
|
+
- The lease bounds how long one attempt may run before another process may start it again; set
|
|
304
|
+
`leaseMs` above the handler's longest run (model calls included).
|
|
305
|
+
|
|
306
|
+
Evidence: `packages/sdk/test/agents.test.ts`: a mention runs the agent once, as the agent, writing with
|
|
307
|
+
its own authority (principal id, type and roles, activity entry, record done, no re-run, not callable
|
|
308
|
+
by name); refused without the permission and by the authorize hook (failed, nothing written); a failed
|
|
309
|
+
attempt is retried with the same key and succeeds, `maxAttempts` failures are recorded and an operator
|
|
310
|
+
retry runs it; a run repeated after its writes committed writes nothing again; a failed mutation
|
|
311
|
+
triggers nothing; an `app.event` in `on` triggers it; tenancy (non-member → no tenant; member → its
|
|
312
|
+
tenant with its own role); a pending run survives a restart and the next process performs it;
|
|
313
|
+
declarations are checked; an AppBoundry build refuses `app.agent`.
|
package/docs/UPSTREAM-GAPS.md
CHANGED
|
@@ -76,6 +76,8 @@ Per-candidate mapping, removed code and verification: `packages/sdk/test/feltdb-
|
|
|
76
76
|
| F21 | `AgentStateStore.recallForTask` returns at most the 100 newest active memories per scope and has no cursor | Open (found 2026-11-03) | FeltKit read a task's actions and decision request through it, so a task with more than 100 active memories lost its oldest actions: proposed actions awaiting approval disappeared from the task (measured: 105 proposed, 100 listed). FeltKit now pages `recall({ scope: task })` (`runtime/agent.ts` `#taskMemories`). Test: "a task with more than 100 active memories…" in `test/agent-lifecycle.test.ts`. Ask: a cursor on `recallForTask`, or a documented cap |
|
|
77
77
|
| F22 | On the local runtimes, `collection.find()` and `db.query()` return the stored objects, not copies (`collection.get()` copies). A caller that changes a returned record changes what every later read in the process sees, with no write, version or commit | Open (found 2026-11-03, FeltDB 0.20.0) | Found by the SupplyDesk evaluation as a false `CONFLICT`: the change also altered the read basis FeltKit fences at commit. FeltKit's `ctx.db` now returns its own copies and copies values written (`runtime/data.ts` `owned`); `packages/sdk/test/data-isolation.test.ts` shows a query's change no longer leaks. Ask: copy in `find`/`query` (or freeze). |
|
|
78
78
|
|
|
79
|
+
| F23 | No text search: `db.query` takes only `eq`/`neq`/`lt`/`lte`/`gt`/`gte` (the query planner's `contains`/`startsWith` are internal, not part of `AuthorityQueryRequest`), and there is no text index | Open (found 2026-11-05, @feltdb/core 0.21.0) | `ctx.db.search` (FK-GAP-006, `runtime/search.ts`) pushes the equality `where` down and scans its matches page by page in FeltKit, testing normalized substrings, until `limit` match; at most 50,000 records are examined. Cost is linear in the `where` matches. Ask: a declared text index (normalized tokens, per collection and field) and a `contains`/`matches` clause on `db.query` that uses it, with the same cursor paging |
|
|
80
|
+
|
|
79
81
|
## AppPort (`rkendel1/appport`)
|
|
80
82
|
|
|
81
83
|
A1–A4 are closed by the released `@appport/core` 1.4.0 / `@appport/sdk` 1.4.0 / `@appport/testing` 1.2.0, which FeltKit pins. Two gaps remain: A5, found while adopting them, and A6 (rkendel1/feltkit#27). Per-candidate evidence: the AppPort rows of the migration audit and `packages/sdk/test/appport-idempotency.test.ts`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feltdb/feltkit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
4
4
|
"description": "FeltKit: one application, one FeltDB instance, one developer experience. SDK, runtime, CLI, and dashboard.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -54,16 +54,16 @@
|
|
|
54
54
|
"prepack": "npm run build"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@appport/authorization": "1.0
|
|
58
|
-
"@appport/integration": "1.2.
|
|
59
|
-
"@appport/protocol": "1.4.
|
|
60
|
-
"@appport/resolver-client": "0.2.
|
|
61
|
-
"@appport/schema": "1.1.
|
|
62
|
-
"@appport/sdk": "1.
|
|
63
|
-
"@appport/server": "1.
|
|
57
|
+
"@appport/authorization": "1.1.0",
|
|
58
|
+
"@appport/integration": "1.2.4",
|
|
59
|
+
"@appport/protocol": "1.4.1",
|
|
60
|
+
"@appport/resolver-client": "0.2.2",
|
|
61
|
+
"@appport/schema": "1.1.5",
|
|
62
|
+
"@appport/sdk": "1.6.0",
|
|
63
|
+
"@appport/server": "1.3.0",
|
|
64
64
|
"@appport/services": ">=0.15.0 <1.0.0",
|
|
65
65
|
"@feltdb/core": ">=0.21.0 <1.0.0",
|
|
66
|
-
"create-feltkit": "0.3.
|
|
66
|
+
"create-feltkit": "0.3.18",
|
|
67
67
|
"esbuild": "0.25.12",
|
|
68
68
|
"express": "4.22.3",
|
|
69
69
|
"mailerport": ">=0.1.0 <1.0.0",
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@appport/testing": "1.2.
|
|
85
|
+
"@appport/testing": "1.2.3",
|
|
86
|
+
"@mailerport/service": "0.1.0",
|
|
86
87
|
"@feltdb/webllm": ">=0.20.0 <1.0.0",
|
|
87
88
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
88
89
|
"@stack-ui/core": "file:dashboard/vendor/stack-ui/core",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://anthropic.com/claude-code/plugin.schema.json",
|
|
3
3
|
"name": "feltkit",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.18",
|
|
5
5
|
"description": "Skills for building and operating FeltKit applications: project structure and SDK, AppPort Services, FeltDB data and consistency, the FeltKit agent over MCP, and operations. Guidance only: they grant no permission.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "FeltKit"
|
|
@@ -42,8 +42,14 @@ await ctx.db.find(contacts, { stage: "lead" }, { orderBy: [{ field: "name", dire
|
|
|
42
42
|
await ctx.db.count(contacts, { ownerId });
|
|
43
43
|
const page = await ctx.db.query(contacts, { where: [{ field: "stage", eq: "lead" }], orderBy: [{ field: "name", direction: "asc" }], limit: 25, cursor });
|
|
44
44
|
// page.records, page.nextCursor, page.exhausted
|
|
45
|
+
await ctx.db.search(messages, { text: "deploy café", where: { channelId }, limit: 20 }); // needs { search: ["text"] } on the collection
|
|
45
46
|
```
|
|
46
47
|
|
|
48
|
+
`search` returns records whose declared `search` fields contain every word (case- and accent-insensitive),
|
|
49
|
+
newest first, at most `limit` (≤ 100). It scans the records matching `where`, so always narrow it with an
|
|
50
|
+
equality `where` on large collections. For live queries, filter by `id`, indexed, unique, reference or
|
|
51
|
+
tenant fields: a query that reads `find(messages, { channelId })` re-runs only when that channel changes.
|
|
52
|
+
|
|
47
53
|
`find` returns **every** match unless you pass `limit` (FeltKit reads FeltDB's pages for you), and `count`
|
|
48
54
|
counts every match. `query` returns **one page** of at most 1,000 records: follow `nextCursor` until it
|
|
49
55
|
is absent. For a large collection, page with `query` on a request path rather than `find` everything.
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type LinkPurpose = "verify" | "reset";
|
|
2
|
-
/** How long a link works. */
|
|
3
|
-
export declare const LINK_TTL_MS: Record<LinkPurpose, number>;
|
|
4
|
-
export declare function signLink(key: string, input: {
|
|
5
|
-
purpose: LinkPurpose;
|
|
6
|
-
accountId: string;
|
|
7
|
-
bind: string;
|
|
8
|
-
now?: number;
|
|
9
|
-
}): string;
|
|
10
|
-
/** The account a link names, before its MAC is checked against that account's state. */
|
|
11
|
-
export declare function readLink(token: unknown, purpose: LinkPurpose, now?: number): {
|
|
12
|
-
accountId: string;
|
|
13
|
-
payload: string;
|
|
14
|
-
mac: Buffer;
|
|
15
|
-
};
|
|
16
|
-
export declare function checkLink(key: string, link: {
|
|
17
|
-
payload: string;
|
|
18
|
-
mac: Buffer;
|
|
19
|
-
}, purpose: LinkPurpose, bind: string): boolean;
|