ovr 6.2.4 → 7.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +3 -1
  2. package/dist/app/index.d.ts +51 -7
  3. package/dist/app/index.d.ts.map +1 -1
  4. package/dist/app/index.js +163 -28
  5. package/dist/auth/auth-data.d.ts +26 -0
  6. package/dist/auth/auth-data.d.ts.map +1 -0
  7. package/dist/auth/auth-data.js +42 -0
  8. package/dist/auth/cbor.d.ts +50 -0
  9. package/dist/auth/cbor.d.ts.map +1 -0
  10. package/dist/auth/cbor.js +200 -0
  11. package/dist/auth/client-source.d.ts +3 -0
  12. package/dist/auth/client-source.d.ts.map +1 -0
  13. package/dist/auth/client-source.js +3 -0
  14. package/dist/auth/client.d.ts +3 -0
  15. package/dist/auth/client.d.ts.map +1 -0
  16. package/dist/auth/client.js +186 -0
  17. package/dist/auth/configure.d.ts +28 -0
  18. package/dist/auth/configure.d.ts.map +1 -0
  19. package/dist/auth/configure.js +228 -0
  20. package/dist/auth/der.d.ts +6 -0
  21. package/dist/auth/der.d.ts.map +1 -0
  22. package/dist/auth/der.js +36 -0
  23. package/dist/auth/index.d.ts +242 -0
  24. package/dist/auth/index.d.ts.map +1 -0
  25. package/dist/auth/index.js +152 -0
  26. package/dist/auth/issue.d.ts +36 -0
  27. package/dist/auth/issue.d.ts.map +1 -0
  28. package/dist/auth/issue.js +47 -0
  29. package/dist/auth/metadata.d.ts +22 -0
  30. package/dist/auth/metadata.d.ts.map +1 -0
  31. package/dist/auth/metadata.js +134 -0
  32. package/dist/auth/oauth.d.ts +29 -0
  33. package/dist/auth/oauth.d.ts.map +1 -0
  34. package/dist/auth/oauth.js +724 -0
  35. package/dist/auth/passkey.d.ts +101 -0
  36. package/dist/auth/passkey.d.ts.map +1 -0
  37. package/dist/auth/passkey.js +393 -0
  38. package/dist/auth/state.d.ts +49 -0
  39. package/dist/auth/state.d.ts.map +1 -0
  40. package/dist/auth/state.js +184 -0
  41. package/dist/auth/storage.d.ts +193 -0
  42. package/dist/auth/storage.d.ts.map +1 -0
  43. package/dist/auth/storage.js +410 -0
  44. package/dist/auth/token.d.ts +12 -0
  45. package/dist/auth/token.d.ts.map +1 -0
  46. package/dist/auth/token.js +39 -0
  47. package/dist/context/index.d.ts +86 -16
  48. package/dist/context/index.d.ts.map +1 -1
  49. package/dist/context/index.js +166 -42
  50. package/dist/cookie/index.d.ts +3 -0
  51. package/dist/cookie/index.d.ts.map +1 -1
  52. package/dist/cookie/index.js +1 -0
  53. package/dist/database/index.d.ts +262 -0
  54. package/dist/database/index.d.ts.map +1 -0
  55. package/dist/database/index.js +807 -0
  56. package/dist/form/index.d.ts +699 -0
  57. package/dist/form/index.d.ts.map +1 -0
  58. package/dist/form/index.js +901 -0
  59. package/dist/index.d.ts +10 -3
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +9 -3
  62. package/dist/jsx/elements.d.ts +28 -2
  63. package/dist/jsx/elements.d.ts.map +1 -1
  64. package/dist/jsx/index.d.ts +20 -4
  65. package/dist/jsx/index.d.ts.map +1 -1
  66. package/dist/jsx/index.js +6 -65
  67. package/dist/limiter/index.d.ts +65 -0
  68. package/dist/limiter/index.d.ts.map +1 -0
  69. package/dist/limiter/index.js +157 -0
  70. package/dist/markdown/index.d.ts +61 -0
  71. package/dist/markdown/index.d.ts.map +1 -0
  72. package/dist/markdown/index.js +1160 -0
  73. package/dist/markup/index.d.ts +188 -0
  74. package/dist/markup/index.d.ts.map +1 -0
  75. package/dist/markup/index.js +718 -0
  76. package/dist/mcp/index.d.ts +73 -0
  77. package/dist/mcp/index.d.ts.map +1 -0
  78. package/dist/mcp/index.js +988 -0
  79. package/dist/middleware/index.d.ts +3 -4
  80. package/dist/middleware/index.d.ts.map +1 -1
  81. package/dist/multipart/index.d.ts +53 -7
  82. package/dist/multipart/index.d.ts.map +1 -1
  83. package/dist/multipart/index.js +332 -124
  84. package/dist/route/index.d.ts +226 -80
  85. package/dist/route/index.d.ts.map +1 -1
  86. package/dist/route/index.js +239 -99
  87. package/dist/schema/index.d.ts +307 -734
  88. package/dist/schema/index.d.ts.map +1 -1
  89. package/dist/schema/index.js +783 -1050
  90. package/dist/table/index.d.ts +132 -0
  91. package/dist/table/index.d.ts.map +1 -0
  92. package/dist/table/index.js +188 -0
  93. package/dist/trie/index.js +4 -4
  94. package/dist/util/index.d.ts +37 -5
  95. package/dist/util/index.d.ts.map +1 -1
  96. package/dist/util/index.js +156 -41
  97. package/package.json +11 -4
  98. package/src/app/index.ts +230 -42
  99. package/src/auth/auth-data.ts +56 -0
  100. package/src/auth/cbor.ts +231 -0
  101. package/src/auth/client-source.ts +3 -0
  102. package/src/auth/client.ts +205 -0
  103. package/src/auth/configure.ts +279 -0
  104. package/src/auth/der.ts +35 -0
  105. package/src/auth/index.ts +387 -0
  106. package/src/auth/issue.ts +52 -0
  107. package/src/auth/metadata.ts +149 -0
  108. package/src/auth/oauth.ts +882 -0
  109. package/src/auth/passkey.ts +556 -0
  110. package/src/auth/state.ts +213 -0
  111. package/src/auth/storage.ts +572 -0
  112. package/src/auth/token.ts +67 -0
  113. package/src/context/index.ts +240 -65
  114. package/src/cookie/index.ts +3 -0
  115. package/src/database/index.ts +1193 -0
  116. package/src/form/index.ts +1720 -0
  117. package/src/index.ts +10 -3
  118. package/src/jsx/elements.ts +45 -25
  119. package/src/jsx/index.ts +24 -69
  120. package/src/limiter/index.ts +221 -0
  121. package/src/markdown/index.ts +1322 -0
  122. package/src/markup/index.ts +853 -0
  123. package/src/mcp/conformance.2025-11-25.yml +39 -0
  124. package/src/mcp/conformance.2026-07-28.yml +56 -0
  125. package/src/mcp/index.ts +1262 -0
  126. package/src/middleware/index.ts +5 -6
  127. package/src/multipart/index.ts +410 -158
  128. package/src/route/index.ts +559 -278
  129. package/src/schema/index.ts +1542 -2256
  130. package/src/table/index.ts +387 -0
  131. package/src/trie/index.ts +4 -4
  132. package/src/util/index.ts +163 -49
  133. package/dist/render/index.d.ts +0 -79
  134. package/dist/render/index.d.ts.map +0 -1
  135. package/dist/render/index.js +0 -257
  136. package/src/render/index.ts +0 -314
@@ -0,0 +1,410 @@
1
+ import { owned, referenced, references, } from "../database/index.js";
2
+ import { Schema } from "../schema/index.js";
3
+ import { Table } from "../table/index.js";
4
+ import { Codec, Time } from "../util/index.js";
5
+ /** An exchange refused after it started writing, rolled back. */
6
+ class Refused extends Error {
7
+ }
8
+ /** Authentication persistence in the application's Postgres database. */
9
+ export class Storage {
10
+ /** Registered passkeys. */
11
+ static credentials = new Table("auth_credentials", {
12
+ id: Schema.string(),
13
+ user: Schema.string(),
14
+ publicKey: Schema.string(),
15
+ counter: Schema.number().int(),
16
+ eligible: Schema.boolean(),
17
+ backedUp: Schema.boolean(),
18
+ });
19
+ /** Revocable sessions. */
20
+ static sessions = new Table("auth_sessions", {
21
+ id: Schema.string(),
22
+ user: Schema.string(),
23
+ expiration: Schema.number().int(),
24
+ started: Schema.number().int(),
25
+ });
26
+ /** Outstanding WebAuthn ceremonies. */
27
+ static challenges = new Table("auth_challenges", {
28
+ id: Schema.string(),
29
+ challenge: Schema.string(),
30
+ browser: Schema.string(),
31
+ method: Schema.enum(["register", "login"]),
32
+ action: Schema.string(),
33
+ origin: Schema.string(),
34
+ expiration: Schema.number().int(),
35
+ user: Schema.string().nullable(),
36
+ fields: Schema.string().nullable(),
37
+ });
38
+ /** Authorization codes, access tokens, and refresh tokens, by hash. */
39
+ static tokens = new Table("auth_tokens", {
40
+ id: Schema.string(),
41
+ // a used code or refresh token is kept as "spent" to detect replays
42
+ kind: Schema.enum(["code", "access", "refresh", "spent"]),
43
+ user: Schema.string(),
44
+ client: Schema.string(),
45
+ resource: Schema.string(),
46
+ scope: Schema.string(),
47
+ redirect: Schema.string().nullable(),
48
+ challenge: Schema.string().nullable(),
49
+ family: Schema.string(),
50
+ expiration: Schema.number().int(),
51
+ });
52
+ /**
53
+ * Migrations creating Auth's tables, by version. A version never changes,
54
+ * so its checksum stays valid; later changes ship as new versions.
55
+ * `database.migrate` applies them for a database with `Auth.tables`. User IDs
56
+ * are text, so they hold any ID `auth.login` accepts.
57
+ */
58
+ static #migrations = [
59
+ {
60
+ id: "auth:1",
61
+ sql: `CREATE TABLE auth_credentials (
62
+ id text PRIMARY KEY,
63
+ "user" text NOT NULL,
64
+ "publicKey" text NOT NULL,
65
+ counter bigint NOT NULL,
66
+ eligible boolean NOT NULL,
67
+ "backedUp" boolean NOT NULL
68
+ );
69
+ CREATE INDEX auth_credentials_user ON auth_credentials ("user");
70
+
71
+ CREATE TABLE auth_sessions (
72
+ id text PRIMARY KEY,
73
+ "user" text NOT NULL,
74
+ started bigint NOT NULL,
75
+ expiration bigint NOT NULL
76
+ );
77
+ CREATE INDEX auth_sessions_user ON auth_sessions ("user");
78
+ CREATE INDEX auth_sessions_expiration ON auth_sessions (expiration);
79
+
80
+ CREATE TABLE auth_challenges (
81
+ id text PRIMARY KEY,
82
+ challenge text NOT NULL,
83
+ browser text NOT NULL,
84
+ method text NOT NULL,
85
+ action text NOT NULL,
86
+ origin text NOT NULL,
87
+ expiration bigint NOT NULL,
88
+ "user" text,
89
+ fields text
90
+ );
91
+ CREATE INDEX auth_challenges_expiration ON auth_challenges (expiration);
92
+ CREATE INDEX auth_challenges_browser ON auth_challenges (browser, expiration);
93
+
94
+ CREATE TABLE auth_tokens (
95
+ id text PRIMARY KEY,
96
+ kind text NOT NULL,
97
+ "user" text NOT NULL,
98
+ client text NOT NULL,
99
+ resource text NOT NULL,
100
+ scope text NOT NULL,
101
+ redirect text,
102
+ challenge text,
103
+ family text NOT NULL,
104
+ expiration bigint NOT NULL
105
+ );
106
+ CREATE INDEX auth_tokens_family ON auth_tokens (family);
107
+ CREATE INDEX auth_tokens_user ON auth_tokens ("user");
108
+ CREATE INDEX auth_tokens_expiration ON auth_tokens (expiration);`,
109
+ },
110
+ ];
111
+ /** Tables whose rows belong to a user, and must reference the users table. */
112
+ static owners = [
113
+ Storage.credentials,
114
+ Storage.sessions,
115
+ Storage.tokens,
116
+ ];
117
+ static {
118
+ for (const table of [...Storage.owners, Storage.challenges])
119
+ owned.set(table, Storage.#migrations);
120
+ // deleting an account deletes what signs in as it, `database.check` verifies it
121
+ for (const table of Storage.owners)
122
+ referenced.set(table, { column: "user", by: "Auth" });
123
+ }
124
+ /**
125
+ * Outstanding ceremonies for one browser. There is no cap across browsers:
126
+ * cookies are free to mint, so any cap shared by all of them is one
127
+ * attacker's to fill, and the per-IP limit already bounds each network.
128
+ */
129
+ static #capacity = 10;
130
+ /** One store per database, so instances share pruning. */
131
+ static #stores = new WeakMap();
132
+ #db;
133
+ #pruned = 0;
134
+ /**
135
+ * @param db Database containing the authentication tables
136
+ */
137
+ constructor(db) {
138
+ this.#db = db;
139
+ }
140
+ /**
141
+ * @param db Database containing the authentication tables
142
+ * @returns The database's store
143
+ */
144
+ static of(db) {
145
+ return Storage.#stores.getOrInsertComputed(db, () => new Storage(db));
146
+ }
147
+ /** Remove expired sessions and challenges, at most once a minute. */
148
+ async #prune() {
149
+ const now = Date.now();
150
+ // either direction, so a clock moving back cannot stop pruning
151
+ if (Math.abs(now - this.#pruned) < Time.minute)
152
+ return;
153
+ this.#pruned = now;
154
+ const tables = [Storage.challenges, Storage.sessions];
155
+ if (this.#oauth)
156
+ tables.push(Storage.tokens);
157
+ for (const table of tables)
158
+ await this.#db.sql `DELETE FROM ${table} WHERE expiration <= ${now}`;
159
+ }
160
+ /** OAuth tables are in use, so their rows are pruned too */
161
+ #oauth = false;
162
+ /**
163
+ * @param token Code or token
164
+ * @returns SHA-256 hash to store it by
165
+ */
166
+ static async hash(token) {
167
+ return Codec.Base64Url.encode(new Uint8Array(await crypto.subtle.digest("SHA-256", Codec.encode(token))));
168
+ }
169
+ tokens = {
170
+ /**
171
+ * @param token Code or token, stored by its hash
172
+ * @param row Token data
173
+ */
174
+ set: async (token, row) => {
175
+ this.#oauth = true;
176
+ await this.#prune();
177
+ await this.#insert(this.#db.sql, token, row);
178
+ },
179
+ /**
180
+ * Uses a code or refresh token once, in one transaction with the tokens
181
+ * it is exchanged for. Replaying a used one revokes its whole family.
182
+ *
183
+ * @param token Code or refresh token
184
+ * @param kind Kind of token
185
+ * @param exchange Checks the unexpired token, returns the tokens to issue in its family, or `undefined` to refuse
186
+ * @returns `true` if the tokens were issued
187
+ */
188
+ exchange: async (token, kind, exchange) => {
189
+ this.#oauth = true;
190
+ await this.#prune();
191
+ const id = await Storage.hash(token);
192
+ return this.#db
193
+ .sql(async (t) => {
194
+ const select = () => t.sql `SELECT * FROM ${Storage.tokens} WHERE id = ${id}`.parse(Storage.tokens);
195
+ const [found] = await select();
196
+ if (!found)
197
+ return false;
198
+ // one exchange per user at a time, so a replay or a disconnection
199
+ // waits for tokens being issued, and its snapshot, taken after the
200
+ // lock, includes them
201
+ await Storage.#lock(t.sql, Storage.tokens, found.user);
202
+ if (!(await this.#account(t.sql, found.user)))
203
+ return false;
204
+ // read again under the lock, an exchange before it may have used it
205
+ const [row] = await select();
206
+ if (!row)
207
+ return false;
208
+ if (row.kind !== kind) {
209
+ // stolen and used by someone else, so neither party keeps access
210
+ if (row.kind === "spent")
211
+ await t.sql `DELETE FROM ${Storage.tokens} WHERE family = ${row.family}`;
212
+ return false;
213
+ }
214
+ const used = Storage.#token([row]);
215
+ const issued = used && (await exchange(used));
216
+ if (!issued)
217
+ return false;
218
+ for (const [value, issue] of Object.entries(issued))
219
+ await this.#insert(t.sql, value, { ...issue, family: row.family });
220
+ // kept as long as what it was exchanged for, so replaying it later
221
+ // still finds the family and revokes it
222
+ const until = Math.max(row.expiration, ...Object.values(issued).map((issue) => issue.expiration));
223
+ const spent = await t.sql `
224
+ UPDATE ${Storage.tokens} SET kind = 'spent', expiration = ${until}
225
+ WHERE id = ${id} AND kind = ${kind}
226
+ RETURNING id
227
+ `;
228
+ // deleted meanwhile, outside Auth, so nothing is issued
229
+ if (!spent.length)
230
+ throw new Refused();
231
+ return true;
232
+ })
233
+ .catch((error) => {
234
+ if (error instanceof Refused ||
235
+ // the account was deleted meanwhile, its tokens cascade with it
236
+ error?.code === "23503")
237
+ return false;
238
+ throw error;
239
+ });
240
+ },
241
+ /**
242
+ * Disconnect one of a user's agents: its codes, access tokens, and
243
+ * refresh tokens, including ones an exchange is issuing at the same time.
244
+ *
245
+ * @param user User ID
246
+ * @param client Agent's client ID
247
+ */
248
+ revoke: async (user, client) => {
249
+ await this.#db.sql(async (t) => {
250
+ // waits for an exchange issuing this user's tokens, so the delete sees them
251
+ await Storage.#lock(t.sql, Storage.tokens, user);
252
+ await this.#account(t.sql, user);
253
+ const { columns } = Storage.tokens;
254
+ await t.sql `DELETE FROM ${Storage.tokens} WHERE ${columns.user} = ${user} AND ${columns.client} = ${client}`;
255
+ });
256
+ },
257
+ /**
258
+ * @param token Access token
259
+ * @returns The unexpired token
260
+ */
261
+ get: async (token) => Storage.#token(await this.#db
262
+ .sql `SELECT * FROM ${Storage.tokens} WHERE id = ${await Storage.hash(token)} AND kind = 'access'`.parse(Storage.tokens)),
263
+ };
264
+ /**
265
+ * Lock the account's row before any of its tokens, the order deleting the
266
+ * account takes them in, so the two wait for each other instead of
267
+ * deadlocking, whenever the foreign key is checked. The users table is the
268
+ * one `new Auth()` registered for this database.
269
+ *
270
+ * @param sql Transaction's SQL tag
271
+ * @param user User ID
272
+ * @returns `false` when the account no longer exists
273
+ */
274
+ async #account(sql, user) {
275
+ const users = references.get(this.#db)?.get(Storage.tokens);
276
+ if (!users)
277
+ return true;
278
+ const rows = await sql `SELECT 1 FROM ${users} WHERE ${users.columns.id} = ${user} FOR KEY SHARE`;
279
+ return rows.length > 0;
280
+ }
281
+ /**
282
+ * Serialize writing a table's rows for one key, until the transaction ends.
283
+ *
284
+ * @param sql Transaction's SQL tag
285
+ * @param table Table written to
286
+ * @param key What the rows are for, such as a user ID
287
+ */
288
+ static async #lock(sql, table, key) {
289
+ await sql `SELECT pg_advisory_xact_lock(hashtext(${table.name}), hashtext(${key}))`;
290
+ }
291
+ /**
292
+ * @param sql SQL tag to insert with
293
+ * @param token Code or token, stored by its hash
294
+ * @param row Token data
295
+ */
296
+ async #insert(sql, token, row) {
297
+ const id = await Storage.hash(token);
298
+ await sql `INSERT INTO ${Storage.tokens} ${sql.values(Storage.tokens, {
299
+ redirect: null,
300
+ challenge: null,
301
+ ...row,
302
+ family: row.family ?? id,
303
+ id,
304
+ })}`;
305
+ }
306
+ /**
307
+ * @param rows Token rows
308
+ * @returns The first row unless it has expired
309
+ */
310
+ static #token([row]) {
311
+ if (!row || row.expiration <= Date.now())
312
+ return;
313
+ // a spent token is never returned, its kind is checked first
314
+ return Storage.#present(row);
315
+ }
316
+ /**
317
+ * @param row Stored row
318
+ * @returns The row without its null columns, which records leave out
319
+ */
320
+ static #present(row) {
321
+ return Object.fromEntries(Object.entries(row).filter(([, value]) => value !== null));
322
+ }
323
+ challenges = {
324
+ set: async (id, challenge) => {
325
+ await this.#prune();
326
+ const table = Storage.challenges;
327
+ const now = Date.now();
328
+ return this.#db.sql(async (t) => {
329
+ // one writer at a time for each browser, so its concurrent requests
330
+ // cannot share the last slot; the insert's snapshot is taken after the lock
331
+ await Storage.#lock(t.sql, table, challenge.browser);
332
+ const rows = await t.sql `
333
+ INSERT INTO ${table} (id, challenge, browser, method, action, origin, expiration, "user", fields)
334
+ SELECT ${id}, ${challenge.challenge}, ${challenge.browser}, ${challenge.method},
335
+ ${challenge.action}, ${challenge.origin}, ${challenge.expiration}::bigint,
336
+ ${challenge.user ?? null}, ${challenge.fields ?? null}
337
+ WHERE (
338
+ SELECT count(*) FROM ${table} WHERE browser = ${challenge.browser} AND expiration > ${now}
339
+ ) < ${Storage.#capacity}
340
+ RETURNING id
341
+ `;
342
+ return rows.length === 1;
343
+ });
344
+ },
345
+ take: async (id) => {
346
+ const [row] = await this.#db
347
+ .sql `DELETE FROM ${Storage.challenges} WHERE id = ${id} RETURNING *`.parse(Storage.challenges);
348
+ if (!row)
349
+ return;
350
+ const { id: _, ...challenge } = row;
351
+ return Storage.#present(challenge);
352
+ },
353
+ };
354
+ sessions = {
355
+ set: async (_, session) => {
356
+ await this.#prune();
357
+ await this.#db
358
+ .sql `INSERT INTO ${Storage.sessions} ${this.#db.sql.values(Storage.sessions, session)}`;
359
+ },
360
+ get: async (id) => (await this.#db
361
+ .sql `SELECT * FROM ${Storage.sessions} WHERE id = ${id} AND expiration > ${Date.now()}`.parse(Storage.sessions))[0],
362
+ renew: async (id, expiration) => {
363
+ const { columns } = Storage.sessions;
364
+ await this.#db.sql `
365
+ UPDATE ${Storage.sessions} SET ${this.#db.sql.set(Storage.sessions, { expiration })}
366
+ WHERE ${columns.id} = ${id} AND ${columns.expiration} < ${expiration}
367
+ `;
368
+ },
369
+ delete: async (id) => {
370
+ await this.#db.sql `DELETE FROM ${Storage.sessions} WHERE id = ${id}`;
371
+ },
372
+ };
373
+ credentials = {
374
+ get: async (id) => (await this.#db
375
+ .sql `SELECT * FROM ${Storage.credentials} WHERE id = ${id}`.parse(Storage.credentials))[0],
376
+ list: async (user) => {
377
+ const { columns } = Storage.credentials;
378
+ const rows = await this.#db
379
+ .sql `SELECT ${columns.id} FROM ${Storage.credentials} WHERE ${columns.user} = ${user}`.parse(Schema.object({ id: Schema.string() }));
380
+ return rows.map((row) => row.id);
381
+ },
382
+ update: async (credential, previous) => {
383
+ const { columns } = Storage.credentials;
384
+ const rows = await this.#db.sql `
385
+ UPDATE ${Storage.credentials}
386
+ SET ${this.#db.sql.set(Storage.credentials, {
387
+ counter: credential.counter,
388
+ backedUp: credential.backedUp,
389
+ })}
390
+ WHERE ${columns.id} = ${previous.id} AND ${columns.user} = ${previous.user}
391
+ AND ${columns.publicKey} = ${previous.publicKey} AND ${columns.counter} = ${previous.counter}
392
+ AND ${columns.eligible} = ${previous.eligible} AND ${columns.backedUp} = ${previous.backedUp}
393
+ RETURNING id
394
+ `;
395
+ return rows.length === 1;
396
+ },
397
+ };
398
+ /**
399
+ * Create the account and its first credential in one transaction.
400
+ *
401
+ * @param create Application callback creating the account
402
+ * @param credential Verified credential
403
+ */
404
+ register(create, credential) {
405
+ return this.#db.sql(async (t) => {
406
+ await create(t, credential.user);
407
+ await t.sql `INSERT INTO ${Storage.credentials} ${t.sql.values(Storage.credentials, credential)}`;
408
+ });
409
+ }
410
+ }
@@ -0,0 +1,12 @@
1
+ import type { Auth } from "./index.js";
2
+ /** Internal integrity protection with explicit authentication purposes. */
3
+ export declare class Token {
4
+ #private;
5
+ /** @returns A new random value of 256 bits, base64url, such as a challenge or code */
6
+ static random(): string;
7
+ /** Seal a payload for exactly one authentication purpose. */
8
+ static seal(secret: Auth.Options["secret"], purpose: "session" | "passkey" | "consent", value: string): Promise<string>;
9
+ /** Verify both integrity and purpose before exposing the payload. */
10
+ static open(secret: Auth.Options["secret"], purpose: "session" | "passkey" | "consent", token: string): Promise<string>;
11
+ }
12
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/auth/token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,2EAA2E;AAC3E,qBAAa,KAAK;;IAejB,sFAAsF;IACtF,MAAM,CAAC,MAAM,WAEZ;IAED,6DAA6D;IAC7D,OAAa,IAAI,CAChB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAC9B,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,EAC1C,KAAK,EAAE,MAAM,mBAIb;IAED,qEAAqE;IACrE,OAAa,IAAI,CAChB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAC9B,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,EAC1C,KAAK,EAAE,MAAM,mBA0Bb;CACD"}
@@ -0,0 +1,39 @@
1
+ import { Codec } from "../util/index.js";
2
+ import { Issue } from "./issue.js";
3
+ /** Internal integrity protection with explicit authentication purposes. */
4
+ export class Token {
5
+ static #keys = new Map();
6
+ static #key(secret) {
7
+ return Token.#keys.getOrInsertComputed(secret, () => crypto.subtle.importKey("raw", Codec.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign", "verify"]));
8
+ }
9
+ /** @returns A new random value of 256 bits, base64url, such as a challenge or code */
10
+ static random() {
11
+ return Codec.Base64Url.encode(crypto.getRandomValues(new Uint8Array(32)));
12
+ }
13
+ /** Seal a payload for exactly one authentication purpose. */
14
+ static async seal(secret, purpose, value) {
15
+ const payload = `${purpose}:${value}`;
16
+ return `${payload}.${Codec.Base64Url.encode(new Uint8Array(await crypto.subtle.sign("HMAC", await Token.#key([secret].flat()[0]), Codec.encode(payload))))}`;
17
+ }
18
+ /** Verify both integrity and purpose before exposing the payload. */
19
+ static async open(secret, purpose, token) {
20
+ const dot = token.lastIndexOf(".");
21
+ if (dot > 0 && token.startsWith(`${purpose}:`)) {
22
+ try {
23
+ const text = token.slice(dot + 1);
24
+ const signature = Codec.Base64Url.decode(text);
25
+ // one spelling per signature, as it was issued
26
+ if (Codec.Base64Url.encode(signature) !== text)
27
+ throw new Issue("token");
28
+ const payload = Codec.encode(token.slice(0, dot));
29
+ for (const key of [secret].flat())
30
+ if (await crypto.subtle.verify("HMAC", await Token.#key(key), signature, payload))
31
+ return token.slice(purpose.length + 1, dot);
32
+ }
33
+ catch {
34
+ // Malformed signatures are authentication failures.
35
+ }
36
+ }
37
+ throw new Issue("token");
38
+ }
39
+ }
@@ -1,11 +1,27 @@
1
1
  import type { App } from "../app/index.js";
2
2
  import { Cookie } from "../cookie/index.js";
3
+ import { type Field } from "../form/index.js";
3
4
  import type { Middleware } from "../middleware/index.js";
4
5
  import { Multipart } from "../multipart/index.js";
5
6
  import { Route } from "../route/index.js";
6
- import { Form as FormSchema } from "../schema/index.js";
7
- import type { Trie } from "../trie/index.js";
8
7
  import { type Util } from "../util/index.js";
8
+ /**
9
+ * Requests an agent makes through an MCP tool, with the session its token
10
+ * authorizes. `c.data()` adds the form's issues, which the MCP endpoint
11
+ * returns to the agent instead of following the handler's redirect.
12
+ */
13
+ export declare const agent: WeakMap<Request, {
14
+ readonly session?: unknown;
15
+ issues?: readonly {
16
+ readonly path: string;
17
+ readonly message: string;
18
+ }[];
19
+ /** The tool a form submits to and its arguments, so a page points to it */
20
+ readonly tool?: (method: string, action: URL) => {
21
+ name: string;
22
+ args: Record<string, string>;
23
+ } | undefined;
24
+ }>;
9
25
  /** Properties to build the final `Response` with once middleware has run. */
10
26
  declare class PreparedResponse {
11
27
  /**
@@ -27,20 +43,38 @@ declare class PreparedResponse {
27
43
  */
28
44
  headers: Headers;
29
45
  }
46
+ /** Reads a request's session, set by a mounted `Auth` */
47
+ export declare const sessions: unique symbol;
30
48
  export declare namespace Context {
49
+ /** A signed-in user's revocable session. */
50
+ export interface Session {
51
+ /**
52
+ * Opaque session ID: a browser session's row ID in `auth_sessions`, or
53
+ * for an agent's tool call, a hash of its access token.
54
+ */
55
+ readonly id: string;
56
+ /** User ID. */
57
+ readonly user: string;
58
+ /** Time in milliseconds the session ends unless it is used, which renews it. */
59
+ readonly expiration: number;
60
+ }
31
61
  /**
32
- * Context.data return type.
62
+ * Context.data return type: `null` for a route without fields, and either
63
+ * where the fields are not known, such as in middleware written on its own.
33
64
  *
34
- * Routes without a schema return `null`.
65
+ * @template S Form shape, `any` where it is not known
66
+ */
67
+ export type Result<S extends Field.Shape> = 0 extends 1 & S ? Parsed<Field.Shape> | null : [Field.Shape] extends [S] ? null : Parsed<S>;
68
+ /**
69
+ * Parsed fields, with the URL to return to when they are invalid.
35
70
  *
36
71
  * @template S Form shape
37
72
  */
38
- type Result<S extends FormSchema.Shape> = [FormSchema.Shape] extends [
39
- S
40
- ] ? null : Util.Prettify<FormSchema.Parse.Result<S, {
73
+ type Parsed<S extends Field.Shape> = Util.Prettify<Field.Parse.Result<S, {
41
74
  /** URL with invalid field values encoded into a search parameter. */
42
75
  readonly url: URL;
43
76
  }>>;
77
+ export {};
44
78
  }
45
79
  /**
46
80
  * Request context.
@@ -48,7 +82,7 @@ export declare namespace Context {
48
82
  * @template Params Parameters created from a route match
49
83
  * @template Shape Parsed form data shape
50
84
  */
51
- export declare class Context<Params extends Trie.Params = Trie.Params, Shape extends FormSchema.Shape = FormSchema.Shape> {
85
+ export declare class Context<Params extends Record<string, unknown> = Record<string, unknown>, Shape extends Field.Shape = any> {
52
86
  #private;
53
87
  /**
54
88
  * Incoming `Request` to the server.
@@ -56,6 +90,8 @@ export declare class Context<Params extends Trie.Params = Trie.Params, Shape ext
56
90
  * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
57
91
  */
58
92
  readonly req: Request;
93
+ /** Trusted client IP supplied by the server through App.fetch; never inferred from request headers. */
94
+ readonly ip: string | undefined;
59
95
  /**
60
96
  * Parsed `URL` created from `req.url`.
61
97
  *
@@ -68,14 +104,16 @@ export declare class Context<Params extends Trie.Params = Trie.Params, Shape ext
68
104
  readonly route?: Route;
69
105
  /** Contains the arguments to used create the final `Response` */
70
106
  readonly res: PreparedResponse;
71
- /** Get, set, and delete cookies. */
107
+ /** Get and set cookies, a cookie set with `maxAge: 0` is deleted. */
72
108
  readonly cookie: Cookie;
109
+ /** Session reader, set by `app.use(auth)` */
110
+ [sessions]?: () => Promise<Context.Session | null>;
73
111
  /**
74
112
  * Creates a new `Context` with the current `Request`.
75
113
  *
76
114
  * @param req Request
77
115
  */
78
- constructor(req: Request, options: App.Options);
116
+ constructor(req: Request, options: App.Options, ip?: string);
79
117
  /**
80
118
  * Creates an HTML response.
81
119
  *
@@ -86,6 +124,7 @@ export declare class Context<Params extends Trie.Params = Trie.Params, Shape ext
86
124
  /**
87
125
  * Creates a JSON response.
88
126
  *
127
+ * @template D Data, not a `bigint`, which JSON cannot represent
89
128
  * @param data passed into JSON.stringify to create the body
90
129
  * @param status [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
91
130
  */
@@ -97,9 +136,26 @@ export declare class Context<Params extends Trie.Params = Trie.Params, Shape ext
97
136
  * @param status [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
98
137
  */
99
138
  text(body: BodyInit | null, status?: number): void;
139
+ /**
140
+ * Responds with Markdown when the request asks for Markdown, such as an
141
+ * agent's, instead of the Markdown written from the page. Use it for a page
142
+ * that is a Markdown document, so agents read its source.
143
+ *
144
+ * ```tsx
145
+ * if (c.md(post.body)) return;
146
+ *
147
+ * return <Post post={post} />;
148
+ * ```
149
+ *
150
+ * @param body Markdown body
151
+ * @param status [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
152
+ * @returns `true` if it responded, otherwise the page renders for the browser
153
+ */
154
+ md(body: BodyInit | null, status?: number): boolean;
100
155
  /**
101
156
  * Creates a redirect response.
102
157
  *
158
+ * @template L Location: a URL, or a route without parameters
103
159
  * @param location redirect `Location` header
104
160
  * @param status HTTP status code
105
161
  *
@@ -109,7 +165,7 @@ export declare class Context<Params extends Trie.Params = Trie.Params, Shape ext
109
165
  * - [307 Temporary Redirect](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307)
110
166
  * - [308 Permanent Redirect](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308)
111
167
  */
112
- redirect(location: string | URL | Route, status?: 301 | 302 | 303 | 307 | 308): void;
168
+ redirect<L extends string | URL | Route>(location: L extends Route<infer P> ? P extends `${string}${":" | "*"}${string}` ? never : L : L, status?: 301 | 302 | 303 | 307 | 308): void;
113
169
  /**
114
170
  * Generates an etag from a checksum of the string provided.
115
171
  * If the etag matches, sets the response to not modified.
@@ -132,8 +188,8 @@ export declare class Context<Params extends Trie.Params = Trie.Params, Shape ext
132
188
  * ```ts
133
189
  * import { Route } from "ovr";
134
190
  *
135
- * const post = Route.post(async (c) => {
136
- * for await (const part of c.form()) {
191
+ * const post = Route.post("/posts").use(async (c) => {
192
+ * for await (const part of c.multipart()) {
137
193
  * if (part.name === "email") {
138
194
  * // ...
139
195
  * }
@@ -141,11 +197,25 @@ export declare class Context<Params extends Trie.Params = Trie.Params, Shape ext
141
197
  * })
142
198
  * ```
143
199
  */
144
- form(options?: Multipart.Options): Multipart;
200
+ multipart(options?: Multipart.Options): Multipart;
201
+ /**
202
+ * Read the signed-in user's session before returning JSX, or `null` when
203
+ * nobody is signed in. In an agent's tool call, it is the session of the
204
+ * user who approved the agent. Requires `app.use(auth)`.
205
+ *
206
+ * ```ts
207
+ * const session = await c.session();
208
+ * if (!session) return c.redirect("/login", 303);
209
+ * ```
210
+ *
211
+ * @returns The session, or `null`
212
+ */
213
+ session(): Promise<Context.Session | null>;
145
214
  /**
146
- * Parse route form data from search params or multipart requests.
215
+ * Parse route form data: from the search params of a GET or HEAD request,
216
+ * and from the multipart body of any other.
147
217
  *
148
- * @param options Multipart options for POST requests
218
+ * @param options Multipart options for requests with a body
149
219
  * @returns Parsed form data with possible invalid redirect URL state
150
220
  */
151
221
  data(options?: Multipart.Options): Promise<Context.Result<Shape>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAkC,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7E,6EAA6E;AAC7E,cAAM,gBAAgB;IACrB;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEvB;;;;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