@phake/mcp 0.0.1

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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +187 -0
  3. package/dist/adapters/http-node/http/app.d.ts +5 -0
  4. package/dist/adapters/http-node/http/auth-app.d.ts +5 -0
  5. package/dist/adapters/http-node/http/middlewares/auth.d.ts +39 -0
  6. package/dist/adapters/http-node/http/middlewares/cors.d.ts +8 -0
  7. package/dist/adapters/http-node/http/routes/health.d.ts +5 -0
  8. package/dist/adapters/http-node/http/routes/mcp.d.ts +11 -0
  9. package/dist/adapters/http-node/middleware.security.d.ts +6 -0
  10. package/dist/adapters/http-node/routes.discovery.d.ts +6 -0
  11. package/dist/adapters/http-node/routes.oauth.d.ts +7 -0
  12. package/dist/adapters/http-worker/index.d.ts +48 -0
  13. package/dist/adapters/http-worker/mcp.handler.d.ts +24 -0
  14. package/dist/adapters/http-worker/routes.discovery.d.ts +7 -0
  15. package/dist/adapters/http-worker/routes.oauth.d.ts +8 -0
  16. package/dist/adapters/http-worker/security.d.ts +7 -0
  17. package/dist/index-1zyem3xr.js +14893 -0
  18. package/dist/index-4f4xvtt9.js +19552 -0
  19. package/dist/index-sbqy8kgq.js +3478 -0
  20. package/dist/index.d.ts +27 -0
  21. package/dist/index.js +1083 -0
  22. package/dist/mcp-server.d.ts +18 -0
  23. package/dist/runtime/node/capabilities.d.ts +2 -0
  24. package/dist/runtime/node/context.d.ts +29 -0
  25. package/dist/runtime/node/index.d.ts +5 -0
  26. package/dist/runtime/node/index.js +27 -0
  27. package/dist/runtime/node/mcp.d.ts +28 -0
  28. package/dist/runtime/node/storage/file.d.ts +44 -0
  29. package/dist/runtime/node/storage/sqlite.d.ts +213 -0
  30. package/dist/runtime/worker/index.d.ts +1 -0
  31. package/dist/runtime/worker/index.js +12 -0
  32. package/dist/shared/auth/index.d.ts +1 -0
  33. package/dist/shared/auth/strategy.d.ts +71 -0
  34. package/dist/shared/config/env.d.ts +52 -0
  35. package/dist/shared/config/index.d.ts +2 -0
  36. package/dist/shared/config/metadata.d.ts +5 -0
  37. package/dist/shared/crypto/aes-gcm.d.ts +37 -0
  38. package/dist/shared/crypto/index.d.ts +1 -0
  39. package/dist/shared/http/cors.d.ts +20 -0
  40. package/dist/shared/http/index.d.ts +2 -0
  41. package/dist/shared/http/response.d.ts +52 -0
  42. package/dist/shared/mcp/dispatcher.d.ts +81 -0
  43. package/dist/shared/mcp/index.d.ts +3 -0
  44. package/dist/shared/mcp/security.d.ts +23 -0
  45. package/dist/shared/mcp/server-internals.d.ts +79 -0
  46. package/dist/shared/oauth/cimd.d.ts +43 -0
  47. package/dist/shared/oauth/discovery-handlers.d.ts +14 -0
  48. package/dist/shared/oauth/discovery.d.ts +26 -0
  49. package/dist/shared/oauth/endpoints.d.ts +11 -0
  50. package/dist/shared/oauth/flow.d.ts +31 -0
  51. package/dist/shared/oauth/index.d.ts +9 -0
  52. package/dist/shared/oauth/input-parsers.d.ts +43 -0
  53. package/dist/shared/oauth/refresh.d.ts +61 -0
  54. package/dist/shared/oauth/ssrf.d.ts +31 -0
  55. package/dist/shared/oauth/types.d.ts +78 -0
  56. package/dist/shared/schemas/prompts.d.ts +1 -0
  57. package/dist/shared/services/http-client.d.ts +16 -0
  58. package/dist/shared/services/index.d.ts +1 -0
  59. package/dist/shared/storage/index.d.ts +4 -0
  60. package/dist/shared/storage/interface.d.ts +99 -0
  61. package/dist/shared/storage/kv.d.ts +68 -0
  62. package/dist/shared/storage/memory.d.ts +91 -0
  63. package/dist/shared/storage/singleton.d.ts +4 -0
  64. package/dist/shared/tools/echo.d.ts +16 -0
  65. package/dist/shared/tools/health.d.ts +13 -0
  66. package/dist/shared/tools/index.d.ts +4 -0
  67. package/dist/shared/tools/registry.d.ts +64 -0
  68. package/dist/shared/tools/types.d.ts +161 -0
  69. package/dist/shared/types/auth.d.ts +35 -0
  70. package/dist/shared/types/context.d.ts +79 -0
  71. package/dist/shared/types/index.d.ts +8 -0
  72. package/dist/shared/types/provider.d.ts +28 -0
  73. package/dist/shared/utils/base64.d.ts +12 -0
  74. package/dist/shared/utils/cancellation.d.ts +13 -0
  75. package/dist/shared/utils/elicitation.d.ts +247 -0
  76. package/dist/shared/utils/formatting.d.ts +106 -0
  77. package/dist/shared/utils/index.d.ts +11 -0
  78. package/dist/shared/utils/limits.d.ts +6 -0
  79. package/dist/shared/utils/logger.d.ts +20 -0
  80. package/dist/shared/utils/pagination.d.ts +11 -0
  81. package/dist/shared/utils/progress.d.ts +56 -0
  82. package/dist/shared/utils/roots.d.ts +62 -0
  83. package/dist/shared/utils/sampling.d.ts +155 -0
  84. package/dist/shared/utils/security.d.ts +6 -0
  85. package/package.json +55 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fuongz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # @phake/mcp
2
+
3
+ A TypeScript library for building MCP (Model Context Protocol) servers, designed to run on Cloudflare Workers and Node.js.
4
+
5
+ ## Features
6
+
7
+ - **Multi-runtime support** — Deploy to Cloudflare Workers (itty-router) or Node.js (Hono)
8
+ - **OAuth 2.0 authentication** — Full PKCE flow with dynamic token resolution and proactive refresh
9
+ - **5 auth strategies** — `oauth`, `bearer`, `api_key`, `custom`, `none`
10
+ - **Tool registration** — Define and register MCP tools with Zod input/output schemas
11
+ - **Session & token management** — Persistent storage with LRU eviction and TTL
12
+ - **Multiple storage backends** — Cloudflare KV, SQLite, file-based, and in-memory
13
+ - **CORS support** — Configurable CORS headers
14
+ - **Type-safe** — Full TypeScript support with Zod validation
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ bun add @phake/mcp
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ### Cloudflare Workers
25
+
26
+ ```typescript
27
+ import { createMCPServer } from "@phake/mcp";
28
+
29
+ const server = createMCPServer({
30
+ adapter: "worker",
31
+ tools: [
32
+ // your tool definitions
33
+ ],
34
+ });
35
+
36
+ export default {
37
+ fetch: (request: Request, env: unknown) => server.fetch(request, env),
38
+ };
39
+ ```
40
+
41
+ ### Node.js
42
+
43
+ ```typescript
44
+ import { createHttpApp, createAuthApp } from "@phake/mcp/runtime/node";
45
+
46
+ const { app, sessionStore } = createHttpApp({
47
+ tools: [
48
+ // your tool definitions
49
+ ],
50
+ });
51
+
52
+ const authApp = createAuthApp({ sessionStore });
53
+ ```
54
+
55
+ ## API
56
+
57
+ ### `createMCPServer(options)`
58
+
59
+ Creates an MCP server instance.
60
+
61
+ | Option | Type | Description |
62
+ |--------|------|-------------|
63
+ | `adapter` | `"worker" \| "node"` | Runtime adapter |
64
+ | `tools` | `SharedToolDefinition[]` | Array of tool definitions to register |
65
+
66
+ ### Exports
67
+
68
+ | Module | Path |
69
+ |--------|------|
70
+ | Core | `@phake/mcp` |
71
+ | Node runtime | `@phake/mcp/runtime/node` |
72
+ | Worker runtime | `@phake/mcp/runtime/worker` |
73
+
74
+ ## Authentication Strategies
75
+
76
+ | Strategy | Description | Config Env Vars |
77
+ |----------|-------------|-----------------|
78
+ | `oauth` | Full OAuth 2.1 PKCE flow with RS token → provider token mapping | `OAUTH_CLIENT_ID`, `OAUTH_CLIENT_SECRET`, `OAUTH_SCOPES`, `OAUTH_REDIRECT_URI`, `PROVIDER_CLIENT_ID`, `PROVIDER_CLIENT_SECRET`, `PROVIDER_ACCOUNTS_URL` |
79
+ | `bearer` | Static Bearer token | `BEARER_TOKEN` |
80
+ | `api_key` | Static API key in custom header (default: `x-api-key`) | `API_KEY`, `API_KEY_HEADER` |
81
+ | `custom` | Arbitrary custom headers | `CUSTOM_HEADERS` |
82
+ | `none` | No authentication required | — |
83
+
84
+ ## Storage Backends
85
+
86
+ | Backend | Stores | Key Features |
87
+ |---------|--------|--------------|
88
+ | `MemoryTokenStore` | Tokens, transactions, codes | TTL expiration, size limits (10K tokens), LRU eviction |
89
+ | `MemorySessionStore` | Sessions | TTL (24h), size limit (10K), per-API-key limits (5) |
90
+ | `KvTokenStore` | Tokens, transactions, codes | Cloudflare KV + memory fallback, AES-256-GCM encryption |
91
+ | `KvSessionStore` | Sessions | Cloudflare KV + memory fallback, encryption, API-key indexing |
92
+ | `FileTokenStore` | RS token mappings | JSON file persistence, AES-256-GCM encryption, secure permissions (0600) |
93
+ | `SqliteSessionStore` | Sessions | SQLite via better-sqlite3 + Drizzle ORM, WAL mode, atomic transactions |
94
+
95
+ ## Built-in Tools
96
+
97
+ | Tool | Input | Output | Description |
98
+ |------|-------|--------|-------------|
99
+ | `echo` | `{ message, uppercase? }` | `{ echoed, length }` | Echoes back a message, optionally uppercased |
100
+ | `health` | `{ verbose? }` | `{ status, timestamp, runtime, uptime? }` | Reports server health, uptime, runtime detection |
101
+
102
+ ## Project Structure
103
+
104
+ ```
105
+ src/
106
+ ├── adapters/
107
+ │ ├── http-node/ # Node.js adapter (Hono)
108
+ │ │ ├── http/ # MCP server app, routes, middleware
109
+ │ │ ├── routes.discovery.ts
110
+ │ │ ├── routes.oauth.ts
111
+ │ │ └── middleware.security.ts
112
+ │ └── http-worker/ # Cloudflare Workers adapter (itty-router)
113
+ │ ├── index.ts
114
+ │ ├── mcp.handler.ts
115
+ │ ├── routes.discovery.ts
116
+ │ ├── routes.oauth.ts
117
+ │ └── security.ts
118
+ ├── runtime/
119
+ │ └── node/
120
+ │ ├── capabilities.ts
121
+ │ ├── context.ts
122
+ │ ├── mcp.ts
123
+ │ └── storage/
124
+ │ ├── file.ts
125
+ │ └── sqlite.ts
126
+ ├── shared/
127
+ │ ├── auth/ # Authentication strategies
128
+ │ ├── config/ # Environment configuration (40+ fields)
129
+ │ ├── crypto/ # AES-256-GCM utilities
130
+ │ ├── http/ # CORS, JSON-RPC responses
131
+ │ ├── mcp/ # Protocol dispatcher, security, server internals
132
+ │ ├── oauth/ # Full OAuth 2.0 implementation (PKCE, CIMD, discovery)
133
+ │ ├── services/ # HTTP client
134
+ │ ├── storage/ # Token/session store interfaces and implementations
135
+ │ ├── tools/ # Tool definitions, registry, execution
136
+ │ ├── types/ # Shared type definitions
137
+ │ └── utils/ # Base64, cancellation, logger, pagination, etc.
138
+ ├── mcp-server.ts # Server factory
139
+ └── index.ts # Main entry point
140
+ ```
141
+
142
+ ## MCP Endpoints
143
+
144
+ | Method | Path | Description |
145
+ |--------|------|-------------|
146
+ | `GET` | `/mcp` | SSE stream initialization |
147
+ | `POST` | `/mcp` | JSON-RPC message handling |
148
+ | `DELETE` | `/mcp` | Session termination |
149
+ | `GET` | `/health` | Health check |
150
+
151
+ ## OAuth Endpoints
152
+
153
+ | Path | Description |
154
+ |------|-------------|
155
+ | `/.well-known/oauth-authorization-server` | OAuth discovery |
156
+ | `/.well-known/oauth-protected-resource` | Protected resource metadata |
157
+ | `/authorize` | Authorization request |
158
+ | `/token` | Token exchange |
159
+ | `/oauth/callback` | OAuth callback |
160
+ | `/oauth/provider-callback` | Provider callback |
161
+ | `/revoke` | Token revocation |
162
+ | `/register` | Dynamic client registration |
163
+
164
+ ## Scripts
165
+
166
+ | Command | Description |
167
+ |---------|-------------|
168
+ | `bun run build` | Build with Bun |
169
+ | `bun run typecheck` | Run TypeScript type checking |
170
+
171
+ ## Dependencies
172
+
173
+ - `@modelcontextprotocol/sdk` — MCP protocol implementation
174
+ - `zod` — Schema validation
175
+ - `jose` — JWT and JWS/JWE
176
+ - `oauth4webapi` — OAuth 2.0 for Web API
177
+ - `itty-router` — Lightweight router (Workers)
178
+ - `hono` / `@hono/node-server` — Node.js HTTP framework (optional)
179
+ - `drizzle-orm` / `better-sqlite3` — Database layer (optional)
180
+
181
+ ## Inspired By
182
+
183
+ This project was inspired by [streamable-mcp-server-template](https://github.com/iceener/streamable-mcp-server-template).
184
+
185
+ ## License
186
+
187
+ This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,5 @@
1
+ import type { HttpBindings } from "@hono/node-server";
2
+ import { Hono } from "hono";
3
+ export declare function buildHttpApp(): Hono<{
4
+ Bindings: HttpBindings;
5
+ }>;
@@ -0,0 +1,5 @@
1
+ import type { HttpBindings } from "@hono/node-server";
2
+ import { Hono } from "hono";
3
+ export declare function buildAuthApp(): Hono<{
4
+ Bindings: HttpBindings;
5
+ }>;
@@ -0,0 +1,39 @@
1
+ import type { HttpBindings } from "@hono/node-server";
2
+ import type { MiddlewareHandler } from "hono";
3
+ import type { AuthStrategyType } from "../../../../shared/auth/strategy.js";
4
+ import type { ProviderTokens } from "../../../../shared/storage/interface.js";
5
+ /**
6
+ * Auth context attached to Hono context.
7
+ */
8
+ export interface AuthContext {
9
+ /** Auth strategy in use */
10
+ strategy: AuthStrategyType;
11
+ /** Raw authorization headers from request */
12
+ authHeaders: Record<string, string>;
13
+ /** Resolved headers for API calls (includes static config headers) */
14
+ resolvedHeaders: Record<string, string>;
15
+ /** Provider access token (OAuth: mapped from RS token, Bearer: from config) */
16
+ providerToken?: string;
17
+ /** Full provider token info (OAuth only) */
18
+ provider?: ProviderTokens;
19
+ /** Original RS token (OAuth only) */
20
+ rsToken?: string;
21
+ }
22
+ /**
23
+ * Auth middleware that handles multiple strategies.
24
+ *
25
+ * Strategies:
26
+ * - 'oauth': Map RS token → Provider token (full OAuth flow)
27
+ * - 'bearer': Use static BEARER_TOKEN from config
28
+ * - 'api_key': Use static API_KEY in API_KEY_HEADER
29
+ * - 'custom': Use static CUSTOM_HEADERS
30
+ * - 'none': No auth, pass through
31
+ *
32
+ * After this middleware:
33
+ * - c.authContext.resolvedHeaders: Headers ready for API calls
34
+ * - c.authContext.providerToken: Access token (if available)
35
+ * - c.authContext.provider: Full token info (OAuth only)
36
+ */
37
+ export declare function createAuthHeaderMiddleware(): MiddlewareHandler<{
38
+ Bindings: HttpBindings;
39
+ }>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CORS middleware configured for MCP endpoints.
3
+ * Uses Hono's built-in cors() middleware.
4
+ *
5
+ * Note: Preflight returns 204 (Hono default) vs original 200.
6
+ * Both are valid per CORS spec - browsers accept either.
7
+ */
8
+ export declare const corsMiddleware: () => import("hono").MiddlewareHandler;
@@ -0,0 +1,5 @@
1
+ import type { HttpBindings } from "@hono/node-server";
2
+ import { Hono } from "hono";
3
+ export declare function healthRoutes(): Hono<{
4
+ Bindings: HttpBindings;
5
+ }, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,11 @@
1
+ /** biome-ignore-all lint/style/noNonNullAssertion: no need */
2
+ import type { HttpBindings } from "@hono/node-server";
3
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
5
+ import { Hono } from "hono";
6
+ export declare function buildMcpRoutes(params: {
7
+ server: McpServer;
8
+ transports: Map<string, StreamableHTTPServerTransport>;
9
+ }): Hono<{
10
+ Bindings: HttpBindings;
11
+ }, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,6 @@
1
+ import type { HttpBindings } from "@hono/node-server";
2
+ import type { MiddlewareHandler } from "hono";
3
+ import type { UnifiedConfig } from "../../shared/config/env.js";
4
+ export declare function createMcpSecurityMiddleware(config: UnifiedConfig): MiddlewareHandler<{
5
+ Bindings: HttpBindings;
6
+ }>;
@@ -0,0 +1,6 @@
1
+ import type { HttpBindings } from "@hono/node-server";
2
+ import { Hono } from "hono";
3
+ import type { UnifiedConfig } from "../../shared/config/env.js";
4
+ export declare function buildDiscoveryRoutes(config: UnifiedConfig): Hono<{
5
+ Bindings: HttpBindings;
6
+ }>;
@@ -0,0 +1,7 @@
1
+ import type { HttpBindings } from "@hono/node-server";
2
+ import { Hono } from "hono";
3
+ import type { UnifiedConfig } from "../../shared/config/env.js";
4
+ import type { TokenStore } from "../../shared/storage/interface.js";
5
+ export declare function buildOAuthRoutes(store: TokenStore, config: UnifiedConfig): Hono<{
6
+ Bindings: HttpBindings;
7
+ }>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Cloudflare Workers router factory.
3
+ * Creates a complete router with OAuth, discovery, and MCP endpoints.
4
+ */
5
+ import type { UnifiedConfig } from "../../shared/config/env.js";
6
+ import type { SessionStore, TokenStore } from "../../shared/storage/interface.js";
7
+ export interface WorkerEnv {
8
+ /** KV namespace for token storage */
9
+ TOKENS?: KVNamespace;
10
+ /** Base64url-encoded 32-byte key for AES-256-GCM encryption */
11
+ RS_TOKENS_ENC_KEY?: string;
12
+ /** All other env vars */
13
+ [key: string]: unknown;
14
+ }
15
+ interface KVNamespace {
16
+ get(key: string): Promise<string | null>;
17
+ put(key: string, value: string, options?: {
18
+ expiration?: number;
19
+ expirationTtl?: number;
20
+ }): Promise<void>;
21
+ delete(key: string): Promise<void>;
22
+ }
23
+ export interface RouterContext {
24
+ tokenStore: TokenStore;
25
+ sessionStore: SessionStore;
26
+ config: UnifiedConfig;
27
+ tools?: import("../../shared/tools/types.js").SharedToolDefinition[];
28
+ }
29
+ /**
30
+ * Initialize storage for the worker.
31
+ * Uses KV with memory fallback and optional encryption.
32
+ */
33
+ export declare function initializeWorkerStorage(env: WorkerEnv, config: UnifiedConfig): {
34
+ tokenStore: TokenStore;
35
+ sessionStore: SessionStore;
36
+ } | null;
37
+ /**
38
+ * Create a configured router for the worker.
39
+ */
40
+ export declare function createWorkerRouter(ctx: RouterContext): {
41
+ fetch: (request: Request) => Promise<Response>;
42
+ };
43
+ /**
44
+ * Shim process.env for shared modules that expect Node.js environment.
45
+ * Workers don't have process.env natively, so we polyfill it.
46
+ */
47
+ export declare function shimProcessEnv(env: WorkerEnv): void;
48
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * MCP endpoint handler for Cloudflare Workers.
3
+ * Uses the shared dispatcher for JSON-RPC processing.
4
+ */
5
+ import type { UnifiedConfig } from "../../shared/config/env.js";
6
+ import type { SessionStore, TokenStore } from "../../shared/storage/interface.js";
7
+ export interface McpHandlerDeps {
8
+ tokenStore: TokenStore;
9
+ sessionStore: SessionStore;
10
+ config: UnifiedConfig;
11
+ tools?: import("../../shared/tools/types.js").SharedToolDefinition[];
12
+ }
13
+ /**
14
+ * Handle MCP POST request.
15
+ */
16
+ export declare function handleMcpRequest(request: Request, deps: McpHandlerDeps): Promise<Response>;
17
+ /**
18
+ * Handle MCP GET request (returns 405 per spec).
19
+ */
20
+ export declare function handleMcpGet(): Response;
21
+ /**
22
+ * Handle MCP DELETE request (session termination).
23
+ */
24
+ export declare function handleMcpDelete(request: Request, deps: McpHandlerDeps): Promise<Response>;
@@ -0,0 +1,7 @@
1
+ interface IttyRouter {
2
+ get(path: string, handler: (request: Request) => Promise<Response>): void;
3
+ post(path: string, handler: (request: Request) => Promise<Response>): void;
4
+ }
5
+ import type { UnifiedConfig } from "../../shared/config/env.js";
6
+ export declare function attachDiscoveryRoutes(router: IttyRouter, config: UnifiedConfig): void;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ interface IttyRouter {
2
+ get(path: string, handler: (request: Request) => Promise<Response>): void;
3
+ post(path: string, handler: (request: Request) => Promise<Response>): void;
4
+ }
5
+ import type { UnifiedConfig } from "../../shared/config/env.js";
6
+ import type { TokenStore } from "../../shared/storage/interface.js";
7
+ export declare function attachOAuthRoutes(router: IttyRouter, store: TokenStore, config: UnifiedConfig): void;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { UnifiedConfig } from "../../shared/config/env.js";
2
+ import type { TokenStore } from "../../shared/storage/interface.js";
3
+ /**
4
+ * Check if request needs authentication and challenge if missing
5
+ * Returns null if authorized, otherwise returns 401 challenge response
6
+ */
7
+ export declare function checkAuthAndChallenge(request: Request, store: TokenStore, config: UnifiedConfig, sid: string): Promise<Response | null>;