ovr 6.2.5 → 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 +289 -123
  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 +360 -148
  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 -265
  136. package/src/render/index.ts +0 -318
@@ -0,0 +1,152 @@
1
+ import { agents, mount } from "../app/index.js";
2
+ import { sessions } from "../context/index.js";
3
+ import { references } from "../database/index.js";
4
+ import { Limiter } from "../limiter/index.js";
5
+ import { Codec, noStore } from "../util/index.js";
6
+ import { configure } from "./configure.js";
7
+ import { Metadata } from "./metadata.js";
8
+ import { oauth } from "./oauth.js";
9
+ import { State } from "./state.js";
10
+ import { Storage } from "./storage.js";
11
+ /**
12
+ * Complete passkey authentication stored in the application's Postgres database.
13
+ *
14
+ * @template U Users table, whose form fields are the registration form
15
+ */
16
+ export class Auth {
17
+ /**
18
+ * Tables Auth stores its data in, include them in the database's tables.
19
+ * `database.migrate` then creates them, and `database.check` checks them.
20
+ */
21
+ static tables = [
22
+ Storage.credentials,
23
+ Storage.sessions,
24
+ Storage.challenges,
25
+ Limiter.table,
26
+ Storage.tokens,
27
+ ];
28
+ #options;
29
+ #states = new WeakMap();
30
+ /** Auth's tables in its database */
31
+ #storage;
32
+ /** The OAuth endpoints are mounted */
33
+ #mounted = new WeakSet();
34
+ /** Generated endpoints, mounted with `app.use(auth)`. */
35
+ #routes;
36
+ /**
37
+ * Read an agent's authorization request on the consent page, with the form
38
+ * to allow or deny it. `null` when the request is invalid or expired.
39
+ */
40
+ consent;
41
+ /** Signs agents in for an MCP endpoint given this `auth`, internal to ovr. */
42
+ [agents];
43
+ /** Prepare request-scoped UI in the handler before returning JSX. */
44
+ forms;
45
+ /** Configure passkeys, session helpers, and automatic authentication rate limits. */
46
+ constructor(options) {
47
+ const origin = new URL(options.origin);
48
+ if (origin.protocol !== "https:" || origin.origin !== options.origin)
49
+ throw new TypeError("Auth origin must be an HTTPS origin without a path");
50
+ // often from the environment, so its length is checked here
51
+ if ([options.secret].flat().some((secret) => Codec.encode(secret).length < 32))
52
+ throw new TypeError("Auth secret must contain at least 32 bytes");
53
+ // the users table Auth's tables reference in this database, for its check
54
+ const chosen = references.get(options.database) ?? new Map();
55
+ for (const table of Storage.owners) {
56
+ const other = chosen.get(table);
57
+ if (other && other !== options.users)
58
+ throw new TypeError(`Auth's tables in this database already belong to the ${other.name} table`);
59
+ chosen.set(table, options.users);
60
+ }
61
+ references.set(options.database, chosen);
62
+ const storage = Storage.of(options.database);
63
+ this.#storage = storage;
64
+ this.#options = {
65
+ origin: options.origin,
66
+ secret: typeof options.secret === "string"
67
+ ? options.secret
68
+ : [options.secret[0], ...options.secret.slice(1)],
69
+ ...(options.idle === undefined ? {} : { idle: options.idle }),
70
+ ...(options.lifetime === undefined ? {} : { lifetime: options.lifetime }),
71
+ challenges: storage.challenges,
72
+ sessions: storage.sessions,
73
+ };
74
+ const service = configure(options, storage, (c) => this.#state(c));
75
+ // resources tokens can be issued for, the MCP endpoints mounted with this auth
76
+ const resources = new Set();
77
+ const signin = oauth(options, storage, (c) => this.#state(c), resources);
78
+ this.#routes = service.routes;
79
+ this.forms = service.forms;
80
+ this.consent = signin.consent;
81
+ this[agents] = {
82
+ origin: options.origin,
83
+ bearer: signin.bearer,
84
+ // the OAuth endpoints, once per app when several endpoints share them
85
+ mount: (app, resource) => {
86
+ resources.add(resource);
87
+ if (this.#mounted.has(app.routes))
88
+ return [];
89
+ if (!Metadata.supported)
90
+ throw new TypeError("Connecting agents requires Node.js or Bun to fetch client ID metadata documents safely");
91
+ // only once mounting succeeds, so a failed attempt is not skipped next time
92
+ this.#mounted.add(app.routes);
93
+ return this.#host(signin.routes);
94
+ },
95
+ };
96
+ }
97
+ /** Mounted by `app.use(auth)`, and lets every request read its session. */
98
+ [mount]() {
99
+ return [
100
+ (c, next) => {
101
+ c[sessions] = () => this.#state(c).session();
102
+ return next();
103
+ },
104
+ this.#host(this.#routes),
105
+ ];
106
+ }
107
+ /**
108
+ * @param endpoints Generated endpoints
109
+ * @returns The endpoints, which reject alternate hosts before their handlers run
110
+ */
111
+ #host(endpoints) {
112
+ const routes = new Set(endpoints);
113
+ return [
114
+ (c, next) => {
115
+ if (c.route &&
116
+ routes.has(c.route) &&
117
+ c.url.origin !== this.#options.origin) {
118
+ noStore(c.res.headers);
119
+ return c.text("Misdirected Request", 421);
120
+ }
121
+ return next();
122
+ },
123
+ ...endpoints,
124
+ ];
125
+ }
126
+ #state(c) {
127
+ return this.#states.getOrInsertComputed(c, () => new State(c, this.#options));
128
+ }
129
+ /** Establish a session for an already-authorized user with a non-blank ID of at most 1024 UTF-8 bytes. Built-in passkey handlers do this automatically. */
130
+ login = (c, user) => {
131
+ return this.#state(c).login(user);
132
+ };
133
+ /** Revoke the current session and expire its cookie. Always await this method. */
134
+ logout = (c) => {
135
+ return this.#state(c).logout();
136
+ };
137
+ /**
138
+ * Disconnect one of the signed-in user's agents. Once it resolves, the
139
+ * agent's codes and tokens no longer work, including ones a refresh was
140
+ * issuing meanwhile, and connecting again needs the user's consent.
141
+ *
142
+ * @param c Request context of the signed-in user
143
+ * @param client Agent's client ID, from `auth_tokens`
144
+ * @throws When nobody is signed in
145
+ */
146
+ disconnect = async (c, client) => {
147
+ const session = await this.#state(c).session();
148
+ if (!session)
149
+ throw new Error("Sign in to disconnect an agent");
150
+ await this.#storage.tokens.revoke(session.user, client);
151
+ };
152
+ }
@@ -0,0 +1,36 @@
1
+ import type { Context } from "../context/index.js";
2
+ /**
3
+ * Auth validation issue.
4
+ *
5
+ * Used for non-schema auth/passkey validation failures.
6
+ */
7
+ export declare class Issue extends Error {
8
+ /**
9
+ * Read the body in Auth's handlers, bounded in size. A body that is too
10
+ * large or not form data is answered like any other failed form.
11
+ *
12
+ * @template T Parsed form data
13
+ * @param c Request context
14
+ * @returns The parsed form data, or `null` for a body the client got wrong
15
+ * @throws Any other error
16
+ */
17
+ static data<T>(c: {
18
+ data: (options: {
19
+ payload: number;
20
+ }) => Promise<T>;
21
+ }): Promise<T | null>;
22
+ /**
23
+ * Answer a request over one of Auth's limits.
24
+ *
25
+ * @param c Request context
26
+ * @param seconds When to try again
27
+ */
28
+ static limited(c: Pick<Context, "res" | "text">, seconds: number): void;
29
+ /**
30
+ * Create a new auth issue.
31
+ *
32
+ * @param expected Expected auth value/state
33
+ */
34
+ constructor(expected: string);
35
+ }
36
+ //# sourceMappingURL=issue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../src/auth/issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,KAAK;IAC/B;;;;;;;;OAQG;IACH,OAAa,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE;QACvB,IAAI,EAAE,CAAC,OAAO,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;KACnD,qBAOA;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,QAG/D;IAED;;;;OAIG;IACH,YAAY,QAAQ,EAAE,MAAM,EAI3B;CACD"}
@@ -0,0 +1,47 @@
1
+ import { Limit, Malformed } from "../multipart/index.js";
2
+ import { Size } from "../util/index.js";
3
+ /**
4
+ * Auth validation issue.
5
+ *
6
+ * Used for non-schema auth/passkey validation failures.
7
+ */
8
+ export class Issue extends Error {
9
+ /**
10
+ * Read the body in Auth's handlers, bounded in size. A body that is too
11
+ * large or not form data is answered like any other failed form.
12
+ *
13
+ * @template T Parsed form data
14
+ * @param c Request context
15
+ * @returns The parsed form data, or `null` for a body the client got wrong
16
+ * @throws Any other error
17
+ */
18
+ static async data(c) {
19
+ try {
20
+ return await c.data({ payload: 128 * Size.kb });
21
+ }
22
+ catch (error) {
23
+ if (error instanceof Limit || error instanceof Malformed)
24
+ return null;
25
+ throw error;
26
+ }
27
+ }
28
+ /**
29
+ * Answer a request over one of Auth's limits.
30
+ *
31
+ * @param c Request context
32
+ * @param seconds When to try again
33
+ */
34
+ static limited(c, seconds) {
35
+ c.res.headers.set("retry-after", String(seconds));
36
+ c.text("Too many authentication requests. Try again later.", 429);
37
+ }
38
+ /**
39
+ * Create a new auth issue.
40
+ *
41
+ * @param expected Expected auth value/state
42
+ */
43
+ constructor(expected) {
44
+ super(`Invalid ${expected}`);
45
+ this.name = "Auth.Issue";
46
+ }
47
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Fetches OAuth client ID metadata documents, from public addresses only.
3
+ *
4
+ * A client ID is a URL the agent chooses, so a hostname could resolve to the
5
+ * server's own network. The address is checked when the connection resolves
6
+ * it, so the name cannot pass the check and then resolve somewhere else.
7
+ * This needs Node.js or Bun, other runtimes cannot check the connection's
8
+ * address.
9
+ */
10
+ export declare class Metadata {
11
+ #private;
12
+ /** `true` in Node.js and Bun, where the connection's address can be checked */
13
+ static get supported(): boolean;
14
+ /**
15
+ * @param url Client ID
16
+ * @returns The parsed document, `undefined` when the host's answer is final,
17
+ * such as a 404 or an invalid document, or `null` when a retry may succeed:
18
+ * a timeout, a network error, or a 5xx or 429 response
19
+ */
20
+ static fetch(url: URL): Promise<unknown>;
21
+ }
22
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/auth/metadata.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,qBAAa,QAAQ;;IAsCpB,+EAA+E;IAC/E,MAAM,KAAK,SAAS,YAEnB;IAED;;;;;OAKG;IACH,OAAa,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAsF7C;CACD"}
@@ -0,0 +1,134 @@
1
+ /// <reference types="node" />
2
+ import { Codec, Mime, Size, Time } from "../util/index.js";
3
+ /**
4
+ * Fetches OAuth client ID metadata documents, from public addresses only.
5
+ *
6
+ * A client ID is a URL the agent chooses, so a hostname could resolve to the
7
+ * server's own network. The address is checked when the connection resolves
8
+ * it, so the name cannot pass the check and then resolve somewhere else.
9
+ * This needs Node.js or Bun, other runtimes cannot check the connection's
10
+ * address.
11
+ */
12
+ export class Metadata {
13
+ /** Largest document, as the specification recommends */
14
+ static #limit = 5 * Size.kb;
15
+ /**
16
+ * Special-use addresses, RFC 6890 and the IANA registries. IPv4-mapped
17
+ * addresses are checked against the IPv4 ranges, so `::ffff:0:0/96` is not
18
+ * listed, it would block every IPv4 address.
19
+ */
20
+ static #special = [
21
+ "0.0.0.0/8",
22
+ "10.0.0.0/8",
23
+ "100.64.0.0/10",
24
+ "127.0.0.0/8",
25
+ "169.254.0.0/16",
26
+ "172.16.0.0/12",
27
+ "192.0.0.0/24",
28
+ "192.0.2.0/24",
29
+ "192.88.99.0/24",
30
+ "192.168.0.0/16",
31
+ "198.18.0.0/15",
32
+ "198.51.100.0/24",
33
+ "203.0.113.0/24",
34
+ "224.0.0.0/4",
35
+ "240.0.0.0/4",
36
+ "::/128",
37
+ "::1/128",
38
+ "64:ff9b::/96",
39
+ "64:ff9b:1::/48",
40
+ "100::/64",
41
+ "2001::/23",
42
+ "2001:db8::/32",
43
+ "2002::/16",
44
+ "fc00::/7",
45
+ "fe80::/10",
46
+ "ff00::/8",
47
+ ];
48
+ /** `true` in Node.js and Bun, where the connection's address can be checked */
49
+ static get supported() {
50
+ return /^(?:Node\.js|Bun)\//.test(navigator.userAgent);
51
+ }
52
+ /**
53
+ * @param url Client ID
54
+ * @returns The parsed document, `undefined` when the host's answer is final,
55
+ * such as a 404 or an invalid document, or `null` when a retry may succeed:
56
+ * a timeout, a network error, or a 5xx or 429 response
57
+ */
58
+ static async fetch(url) {
59
+ const https = process.getBuiltinModule("node:https");
60
+ const dns = process.getBuiltinModule("node:dns");
61
+ const net = process.getBuiltinModule("node:net");
62
+ const family = (address) => (net.isIPv6(address) ? "ipv6" : "ipv4");
63
+ const blocked = new net.BlockList();
64
+ for (const subnet of Metadata.#special) {
65
+ const [address = "", prefix] = subnet.split("/");
66
+ blocked.addSubnet(address, Number(prefix), family(address));
67
+ }
68
+ const special = (address) => blocked.check(address, family(address));
69
+ // an address in the URL is connected to without a lookup
70
+ const host = url.hostname.replace(/^\[|\]$/g, "");
71
+ if (net.isIP(host) && special(host))
72
+ return;
73
+ // set when the failure is the host's final answer, not a passing one
74
+ let final = false;
75
+ const bytes = await new Promise((resolve) => {
76
+ // for the whole download, a response sent slowly cannot hold it open
77
+ const deadline = setTimeout(() => {
78
+ req.destroy();
79
+ done();
80
+ }, 5 * Time.second);
81
+ const done = (bytes) => {
82
+ clearTimeout(deadline);
83
+ resolve(bytes);
84
+ };
85
+ const req = https.get(url, {
86
+ // a new connection, a pooled one may not have had its address checked
87
+ agent: false,
88
+ headers: { accept: Mime.type.json },
89
+ lookup: (hostname, options, callback) => dns.lookup(hostname, { ...options, all: true }, (error, all) => {
90
+ if (error)
91
+ return callback(error, "", 0);
92
+ if (!all.length || all.some(({ address }) => special(address))) {
93
+ final = true;
94
+ return callback(new Error("Special-use address"), "", 0);
95
+ }
96
+ if (options.all)
97
+ return callback(null, all);
98
+ callback(null, all[0].address, all[0].family);
99
+ }),
100
+ }, (res) => {
101
+ // redirects are not followed
102
+ if (res.statusCode !== 200) {
103
+ const status = res.statusCode ?? 0;
104
+ final = status < 500 && status !== 429;
105
+ res.destroy();
106
+ return done();
107
+ }
108
+ const chunks = [];
109
+ let size = 0;
110
+ res.on("data", (chunk) => {
111
+ if ((size += chunk.length) > Metadata.#limit) {
112
+ final = true;
113
+ res.destroy();
114
+ return done();
115
+ }
116
+ chunks.push(chunk);
117
+ });
118
+ res.on("end", () => done(Buffer.concat(chunks)));
119
+ // the first of these settles the download, closing early is a failure
120
+ res.on("close", () => done());
121
+ });
122
+ req.on("error", () => done());
123
+ });
124
+ if (!bytes)
125
+ return final ? undefined : null;
126
+ try {
127
+ // a document of `null` is invalid, not a passing failure
128
+ return JSON.parse(Codec.decode(bytes)) ?? undefined;
129
+ }
130
+ catch {
131
+ return;
132
+ }
133
+ }
134
+ }
@@ -0,0 +1,29 @@
1
+ import type { Context } from "../context/index.js";
2
+ import { Route } from "../route/index.js";
3
+ import type { Auth } from "./index.js";
4
+ import type { State } from "./state.js";
5
+ import { Storage } from "./storage.js";
6
+ /**
7
+ * OAuth 2.1 authorization server for agents. The user signs in with a passkey
8
+ * and approves the agent on the app's consent page; the agent receives tokens.
9
+ *
10
+ * @param options Auth options
11
+ * @param storage Auth storage
12
+ * @param state Request state
13
+ * @returns Endpoints, the consent form, and bearer token verification
14
+ */
15
+ export declare function oauth(options: Auth.Options<any>, storage: Storage, state: (c: State.Context) => State, resources: ReadonlySet<string>): {
16
+ routes: Route<string, any, any, any>[];
17
+ /**
18
+ * @param c Request context
19
+ * @returns The authorization request on the consent page, with its form
20
+ */
21
+ consent(c: Auth.Context): Promise<Auth.Consent | null>;
22
+ /**
23
+ * @param c Request context
24
+ * @param resource Resource the token must be issued for
25
+ * @returns Session for the user the token acts for
26
+ */
27
+ bearer(c: Pick<Context, "req">, resource: string): Promise<Auth.Session | null>;
28
+ };
29
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/auth/oauth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAgEvC;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CACpB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAC1B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,KAAK,KAAK,EAClC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC;;IAwlB7B;;;OAGG;eACc,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IAmC5D;;;;OAIG;cAEC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,YACb,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;EAgBhC"}