theokit 0.5.4 → 0.6.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.
- package/dist/{actions-virtual-module-DL74V6SR.js → actions-virtual-module-4WVKHQ2X.js} +5 -2
- package/dist/actions-virtual-module-4WVKHQ2X.js.map +1 -0
- package/dist/{actions-virtual-module-ZDD54ZZE.js → actions-virtual-module-LTOXBSCF.js} +16 -2
- package/dist/actions-virtual-module-LTOXBSCF.js.map +1 -0
- package/dist/{app-typed-client-4M4NVSK3.js → app-typed-client-4N5OGNOQ.js} +15 -4
- package/dist/app-typed-client-4N5OGNOQ.js.map +1 -0
- package/dist/{app-typed-client-4GIKUKRT.js → app-typed-client-SAETWZT5.js} +5 -4
- package/dist/app-typed-client-SAETWZT5.js.map +1 -0
- package/dist/{aws-lambda-SCRGTGF5.js → aws-lambda-WT4HRBNL.js} +3 -3
- package/dist/{build-R74EU6BP.js → build-KQD2EDU4.js} +10 -11
- package/dist/build-KQD2EDU4.js.map +1 -0
- package/dist/{bun-FURRCQMS.js → bun-UTDVN6R4.js} +3 -3
- package/dist/{check-NXYPLM6M.js → check-F3UDYSZ4.js} +2 -2
- package/dist/chunk-223EFY5X.js +469 -0
- package/dist/chunk-223EFY5X.js.map +1 -0
- package/dist/{chunk-KJLECZWQ.js → chunk-3FYJ7R7N.js} +57 -14
- package/dist/chunk-3FYJ7R7N.js.map +1 -0
- package/dist/{chunk-HDA6M7P4.js → chunk-3LVRAGAZ.js} +3 -5
- package/dist/{chunk-JD7AQNJS.js → chunk-4I47JW5O.js} +38 -425
- package/dist/chunk-4I47JW5O.js.map +1 -0
- package/dist/{chunk-H4J2LECY.js → chunk-6BUUZ2PK.js} +9 -9
- package/dist/chunk-6BUUZ2PK.js.map +1 -0
- package/dist/{chunk-P2RS3WWY.js → chunk-6FYD34NX.js} +194 -22
- package/dist/chunk-6FYD34NX.js.map +1 -0
- package/dist/{chunk-X3VNROZ7.js → chunk-6VSKLYT6.js} +78 -21
- package/dist/chunk-6VSKLYT6.js.map +1 -0
- package/dist/{chunk-FGOX37NB.js → chunk-BNGBG2SQ.js} +21 -2
- package/dist/chunk-BNGBG2SQ.js.map +1 -0
- package/dist/chunk-CBGRFVF5.js +421 -0
- package/dist/chunk-CBGRFVF5.js.map +1 -0
- package/dist/{chunk-X32KQH5C.js → chunk-CCVC6P6B.js} +3 -3
- package/dist/chunk-CCVC6P6B.js.map +1 -0
- package/dist/{chunk-DNMSV3R3.js → chunk-D7ZH7DTG.js} +3 -3
- package/dist/chunk-D7ZH7DTG.js.map +1 -0
- package/dist/{chunk-MWYSRZI4.js → chunk-EQV67HZL.js} +2 -2
- package/dist/{chunk-CG563V5M.js → chunk-IEES3CHD.js} +39 -5
- package/dist/chunk-IEES3CHD.js.map +1 -0
- package/dist/{chunk-DUKXQNM7.js → chunk-IHMJV2OK.js} +2 -2
- package/dist/{chunk-WGHJD6I7.js → chunk-JAIKGP3Q.js} +76 -21
- package/dist/chunk-JAIKGP3Q.js.map +1 -0
- package/dist/{chunk-B3L3TJVF.js → chunk-JBCHWRKF.js} +50 -50
- package/dist/chunk-JBCHWRKF.js.map +1 -0
- package/dist/{chunk-XMS5VRIK.js → chunk-JQSFBJR5.js} +3 -3
- package/dist/chunk-JQSFBJR5.js.map +1 -0
- package/dist/{chunk-S74FECKW.js → chunk-MV4LKTW6.js} +119 -153
- package/dist/chunk-MV4LKTW6.js.map +1 -0
- package/dist/chunk-PBEH6NXR.js +44 -0
- package/dist/chunk-PBEH6NXR.js.map +1 -0
- package/dist/chunk-PPPR5DGR.js +1 -0
- package/dist/{chunk-NZXH2LQQ.js → chunk-SJIRP73B.js} +18 -1
- package/dist/chunk-SJIRP73B.js.map +1 -0
- package/dist/cli/index.js +25 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/client/index.d.ts +4 -4
- package/dist/{cloudflare-IZ6VJ2OU.js → cloudflare-U5GYYI47.js} +3 -3
- package/dist/db-ZPDW3UCU.js +78 -0
- package/dist/db-ZPDW3UCU.js.map +1 -0
- package/dist/{deno-deploy-O73NBXIW.js → deno-deploy-3QHJ3AJQ.js} +3 -3
- package/dist/{dev-ZU46C5AZ.js → dev-NDEZA2MP.js} +21 -11
- package/dist/dev-NDEZA2MP.js.map +1 -0
- package/dist/{dev-emit-JBVINGHU.js → dev-emit-O4EGOSNV.js} +77 -24
- package/dist/dev-emit-O4EGOSNV.js.map +1 -0
- package/dist/{dev-emit-66FCOS7V.js → dev-emit-OUPI7NAQ.js} +4 -5
- package/dist/{dev-emit-66FCOS7V.js.map → dev-emit-OUPI7NAQ.js.map} +1 -1
- package/dist/devtools/entry.js +1 -0
- package/dist/devtools/entry.js.map +1 -1
- package/dist/{dist-KRW6OVD4.js → dist-6GPD6WCU.js} +10231 -8164
- package/dist/dist-6GPD6WCU.js.map +1 -0
- package/dist/generate-ODDAYXNR.js +494 -0
- package/dist/generate-ODDAYXNR.js.map +1 -0
- package/dist/{index-CuHICqb9.d.ts → index-DWZF8uQD.d.ts} +132 -132
- package/dist/index.d.ts +32 -3
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/{info-CORLCPEJ.js → info-CSGWIAXA.js} +5 -5
- package/dist/{lib-NST3PNZX.js → lib-JBI3XXH3.js} +27 -27
- package/dist/{lib-NST3PNZX.js.map → lib-JBI3XXH3.js.map} +1 -1
- package/dist/{netlify-O7G3RLK4.js → netlify-DUB7BZ4E.js} +3 -3
- package/dist/{node-LXPQLMVB.js → node-ELE236WK.js} +3 -3
- package/dist/{openapi-TEOUOIJ2.js → openapi-NXGRXABL.js} +7 -8
- package/dist/{openapi-TEOUOIJ2.js.map → openapi-NXGRXABL.js.map} +1 -1
- package/dist/registry-B7FA6KMI.js +25 -0
- package/dist/{routes-GAXVWJUK.js → routes-6A5XFGF7.js} +7 -9
- package/dist/routes-6A5XFGF7.js.map +1 -0
- package/dist/{scan-NQFI5S7P.js → scan-I5PT6TUX.js} +2 -2
- package/dist/{schema-D3v8VB7o.d.ts → schema-BpH6ivDY.d.ts} +2 -4
- package/dist/{schema-Z5VJ2I76.js → schema-NPI4NJEF.js} +3 -3
- package/dist/server/auth/index.d.ts +20 -20
- package/dist/server/auth/index.js +3 -5
- package/dist/server/define/index.d.ts +7 -0
- package/dist/server/define/index.js +1 -1
- package/dist/server/http/index.d.ts +2 -2
- package/dist/server/http/index.js +1 -2
- package/dist/server/index.d.ts +36 -3
- package/dist/server/index.js +66 -61
- package/dist/server/index.js.map +1 -1
- package/dist/server/scan/index.d.ts +13 -13
- package/dist/server/scan/index.js +8 -12
- package/dist/server/security/index.d.ts +69 -69
- package/dist/server/security/index.js +1 -1
- package/dist/{services-typed-client-ASZL7FQV.js → services-typed-client-24VBMDOF.js} +2 -2
- package/dist/{services-typed-client-KK6RHRDG.js → services-typed-client-IETY2SAK.js} +2 -2
- package/dist/{start-HGUNNF5X.js → start-SPFWOGHL.js} +95 -80
- package/dist/start-SPFWOGHL.js.map +1 -0
- package/dist/{static-EO73I4C7.js → static-YWF2M6YT.js} +4 -4
- package/dist/{theo-cloud-HBCYEODQ.js → theo-cloud-EUK56I7O.js} +2 -2
- package/dist/{vercel-GSFDMF7K.js → vercel-LGDQWYZD.js} +3 -3
- package/dist/vite-plugin/index.d.ts +1 -1
- package/dist/vite-plugin/index.js +6 -7
- package/dist/{vite-plugin-TX5H4MB6.js → vite-plugin-43KQU5S7.js} +11 -9
- package/dist/vite-plugin-43KQU5S7.js.map +1 -0
- package/package.json +22 -19
- package/dist/actions-virtual-module-DL74V6SR.js.map +0 -1
- package/dist/actions-virtual-module-ZDD54ZZE.js.map +0 -1
- package/dist/app-typed-client-4GIKUKRT.js.map +0 -1
- package/dist/app-typed-client-4M4NVSK3.js.map +0 -1
- package/dist/build-R74EU6BP.js.map +0 -1
- package/dist/chunk-4HBI7DHP.js +0 -20
- package/dist/chunk-4HBI7DHP.js.map +0 -1
- package/dist/chunk-B3L3TJVF.js.map +0 -1
- package/dist/chunk-CG563V5M.js.map +0 -1
- package/dist/chunk-DNMSV3R3.js.map +0 -1
- package/dist/chunk-FGOX37NB.js.map +0 -1
- package/dist/chunk-GPF64ENM.js +0 -73
- package/dist/chunk-H4J2LECY.js.map +0 -1
- package/dist/chunk-HDA6M7P4.js.map +0 -1
- package/dist/chunk-JD7AQNJS.js.map +0 -1
- package/dist/chunk-KJLECZWQ.js.map +0 -1
- package/dist/chunk-NZXH2LQQ.js.map +0 -1
- package/dist/chunk-OLPB36O2.js +0 -259
- package/dist/chunk-OLPB36O2.js.map +0 -1
- package/dist/chunk-P2RS3WWY.js.map +0 -1
- package/dist/chunk-P3SGM4NR.js +0 -156
- package/dist/chunk-P3SGM4NR.js.map +0 -1
- package/dist/chunk-S74FECKW.js.map +0 -1
- package/dist/chunk-UVHRD33F.js +0 -181
- package/dist/chunk-UVHRD33F.js.map +0 -1
- package/dist/chunk-WGHJD6I7.js.map +0 -1
- package/dist/chunk-X32KQH5C.js.map +0 -1
- package/dist/chunk-X3VNROZ7.js.map +0 -1
- package/dist/chunk-XMS5VRIK.js.map +0 -1
- package/dist/dev-ZU46C5AZ.js.map +0 -1
- package/dist/dev-emit-JBVINGHU.js.map +0 -1
- package/dist/dist-KRW6OVD4.js.map +0 -1
- package/dist/generate-AZ2K6Z2Z.js +0 -281
- package/dist/generate-AZ2K6Z2Z.js.map +0 -1
- package/dist/registry-KW4F4D2L.js +0 -25
- package/dist/routes-GAXVWJUK.js.map +0 -1
- package/dist/start-HGUNNF5X.js.map +0 -1
- package/dist/{aws-lambda-SCRGTGF5.js.map → aws-lambda-WT4HRBNL.js.map} +0 -0
- package/dist/{bun-FURRCQMS.js.map → bun-UTDVN6R4.js.map} +0 -0
- package/dist/{check-NXYPLM6M.js.map → check-F3UDYSZ4.js.map} +0 -0
- package/dist/{chunk-GPF64ENM.js.map → chunk-3LVRAGAZ.js.map} +0 -0
- package/dist/{chunk-MWYSRZI4.js.map → chunk-EQV67HZL.js.map} +0 -0
- package/dist/{chunk-DUKXQNM7.js.map → chunk-IHMJV2OK.js.map} +0 -0
- package/dist/{node-LXPQLMVB.js.map → chunk-PPPR5DGR.js.map} +0 -0
- package/dist/{cloudflare-IZ6VJ2OU.js.map → cloudflare-U5GYYI47.js.map} +0 -0
- package/dist/{deno-deploy-O73NBXIW.js.map → deno-deploy-3QHJ3AJQ.js.map} +0 -0
- package/dist/{info-CORLCPEJ.js.map → info-CSGWIAXA.js.map} +0 -0
- package/dist/{module-loader-Cfz7dgCP.d.ts → match-CfbEFRG4.d.ts} +4 -4
- /package/dist/{netlify-O7G3RLK4.js.map → netlify-DUB7BZ4E.js.map} +0 -0
- /package/dist/{scan-NQFI5S7P.js.map → node-ELE236WK.js.map} +0 -0
- /package/dist/{registry-KW4F4D2L.js.map → registry-B7FA6KMI.js.map} +0 -0
- /package/dist/{schema-Z5VJ2I76.js.map → scan-I5PT6TUX.js.map} +0 -0
- /package/dist/{vite-plugin-TX5H4MB6.js.map → schema-NPI4NJEF.js.map} +0 -0
- /package/dist/{services-typed-client-ASZL7FQV.js.map → services-typed-client-24VBMDOF.js.map} +0 -0
- /package/dist/{services-typed-client-KK6RHRDG.js.map → services-typed-client-IETY2SAK.js.map} +0 -0
- /package/dist/{static-EO73I4C7.js.map → static-YWF2M6YT.js.map} +0 -0
- /package/dist/{theo-cloud-HBCYEODQ.js.map → theo-cloud-EUK56I7O.js.map} +0 -0
- /package/dist/{vercel-GSFDMF7K.js.map → vercel-LGDQWYZD.js.map} +0 -0
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
runMiddlewareAndContext,
|
|
23
23
|
sendError,
|
|
24
24
|
sendJson
|
|
25
|
-
} from "../../chunk-
|
|
25
|
+
} from "../../chunk-3FYJ7R7N.js";
|
|
26
26
|
import "../../chunk-GY5Q27BJ.js";
|
|
27
27
|
import "../../chunk-Z5IGLBWE.js";
|
|
28
28
|
import "../../chunk-ZEGYW52B.js";
|
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
serializeCookie,
|
|
39
39
|
setCookie
|
|
40
40
|
} from "../../chunk-ZJQ4O76G.js";
|
|
41
|
-
import "../../chunk-4HBI7DHP.js";
|
|
42
41
|
import "../../chunk-DGUM43GV.js";
|
|
43
42
|
export {
|
|
44
43
|
BATCH_PATH,
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RouteConfig } from './define/index.js';
|
|
2
2
|
export { ActionAccept, ActionConfig, AgentEndpointConfig, AgentEndpointHandlerArgs, ChannelHandler, CustomTool, DefineAgentToolSpec, MiddlewareHandler, WebChannelHandler, defineAction, defineAgentEndpoint, defineAgentTool, defineChannel, defineMiddleware, defineRoute, defineTheoPlugin, defineWebChannel } from './define/index.js';
|
|
3
3
|
export { W as WebSocketHandler, a as WebSocketHandlerWeb, b as WebSocketLike, d as defineWebSocket, c as defineWebSocketWeb } from '../define-websocket-CdK94O-D.js';
|
|
4
|
-
export { B as BATCH_PATH, a as BatchExecuteFn, b as BatchPathConflictError, c as BatchPayload, d as BatchRequestItem, e as BatchResponse, f as BatchResultItem, C as CookieOptions, g as CorsConfig, h as CorsHandler, i as CorsOrigin, j as CorsWebHandler, k as CustomErrorPages, E as ExecuteActionOptions, l as ExecuteRouteContext, H as HandleBatchOptions, M as MAX_ERROR_HTML_BYTES, m as MiddlewareResult, S as STRIPPED_HEADERS, n as SendErrorInput, o as SendErrorOptions, T as TRACE_HEADER, p as TRACE_PARENT_HEADER, q as TheoTransformer, _ as _resetMiddlewareCacheForTests, r as appendCookieToHeaders, s as appendDeleteCookieToHeaders, t as createCorsHandler, u as createCorsWebHandler, v as deleteCookie, w as executeAction, x as executeRoute, y as extractTraceId, z as extractTraceIdFromRequest, A as getCookie, D as getCookieFromRequest, F as handleBatchRequest, G as jsonTransformer, I as loadCustomErrorPages, J as matchesOrigin, K as parseCookieHeader, L as parseTraceparent, N as resolveTransformer, O as runMiddlewareAndContext, P as sendError, Q as sendJson, R as serializeCookie, U as serveStaticFile, V as setCookie, W as superjsonTransformer } from '../index-
|
|
4
|
+
export { B as BATCH_PATH, a as BatchExecuteFn, b as BatchPathConflictError, c as BatchPayload, d as BatchRequestItem, e as BatchResponse, f as BatchResultItem, C as CookieOptions, g as CorsConfig, h as CorsHandler, i as CorsOrigin, j as CorsWebHandler, k as CustomErrorPages, E as ExecuteActionOptions, l as ExecuteRouteContext, H as HandleBatchOptions, M as MAX_ERROR_HTML_BYTES, m as MiddlewareResult, S as STRIPPED_HEADERS, n as SendErrorInput, o as SendErrorOptions, T as TRACE_HEADER, p as TRACE_PARENT_HEADER, q as TheoTransformer, _ as _resetMiddlewareCacheForTests, r as appendCookieToHeaders, s as appendDeleteCookieToHeaders, t as createCorsHandler, u as createCorsWebHandler, v as deleteCookie, w as executeAction, x as executeRoute, y as extractTraceId, z as extractTraceIdFromRequest, A as getCookie, D as getCookieFromRequest, F as handleBatchRequest, G as jsonTransformer, I as loadCustomErrorPages, J as matchesOrigin, K as parseCookieHeader, L as parseTraceparent, N as resolveTransformer, O as runMiddlewareAndContext, P as sendError, Q as sendJson, R as serializeCookie, U as serveStaticFile, V as setCookie, W as superjsonTransformer } from '../index-DWZF8uQD.js';
|
|
5
5
|
export { ActionNode, ActionScanError, LoadedManifest, ManifestAction, ManifestRoute, ManifestWebSocket, TheoManifest, WebSocketRouteNode, generateManifest, loadManifest, scanMiddlewares, scanServerActions, scanServerActionsEnriched, scanServerRoutes, scanWebSocketRoutes, writeManifest } from './scan/index.js';
|
|
6
|
-
export { L as LoadModule, S as ServerRouteNode, c as compilePattern, a as createProductionLoader, b as createViteLoader, m as matchRoute } from '../
|
|
6
|
+
export { L as LoadModule, S as ServerRouteNode, c as compilePattern, a as createProductionLoader, b as createViteLoader, m as matchRoute } from '../match-CfbEFRG4.js';
|
|
7
7
|
import { T as TheoErrorEnvelope, a as TheoErrorCode, V as ValidationFieldsExt } from '../error-envelope-BsNzzAV5.js';
|
|
8
8
|
export { AgentRunLike, AgentRunResult, AgentRunStreamMessage, ConversationHistoryArgs, ConversationHistoryResult, ConversationStorageLike, SdkAgent, SdkAgentOptions, SdkRunLike, createConversationHistory, errorToEvent, streamAgentRun } from './agent/index.js';
|
|
9
9
|
export { a as AgentErrorEvent, A as AgentEvent, b as AgentMessageEvent, e as AgentRunErrorCode, c as AgentToolCallEvent, d as AgentToolResultEvent } from '../agent-events-B3KNV9ER.js';
|
|
@@ -31,7 +31,7 @@ import { z } from 'zod';
|
|
|
31
31
|
import { IncomingMessage } from 'node:http';
|
|
32
32
|
import { W as WebOnRequestHook, b as WebPreHandlerHook, c as WebOnResponseHook, d as WebOnErrorHook } from '../plugin-types-DNJGxr4Z.js';
|
|
33
33
|
export { e as HookName, H as HookResult, O as OnErrorHook, f as OnRequestHook, g as OnResponseHook, P as PluginContext, h as PluginErrorContext, i as PreHandlerHook, R as RunHookOptions, a as TheoApp, T as TheoPlugin, j as definePlugin } from '../plugin-types-DNJGxr4Z.js';
|
|
34
|
-
export { a as ServiceDefinition, S as ServicesConfig, b as ServicesConfigInput, c as ServicesConfigOutput } from '../schema-
|
|
34
|
+
export { a as ServiceDefinition, S as ServicesConfig, b as ServicesConfigInput, c as ServicesConfigOutput } from '../schema-BpH6ivDY.js';
|
|
35
35
|
import 'vite';
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -687,6 +687,25 @@ declare function serializeResponse(data: unknown): SerializedResponse;
|
|
|
687
687
|
*/
|
|
688
688
|
declare function deserializeResponse(serialized: SerializedResponse): unknown;
|
|
689
689
|
|
|
690
|
+
/**
|
|
691
|
+
* T3.2 — Web-Standards middleware runner for the `executeWebRequest` path.
|
|
692
|
+
*
|
|
693
|
+
* The Node request path (`http/execute.ts`) runs middleware via
|
|
694
|
+
* `runMiddlewareAndContext`, which is coupled to Node `req`/`res`. Per G8
|
|
695
|
+
* (Web Standards over Node APIs) the Web path needs a `Request`-shaped runner;
|
|
696
|
+
* this is it. Extracted to a sibling so `web-handler.ts` stays under its LoC
|
|
697
|
+
* budget (G6).
|
|
698
|
+
*
|
|
699
|
+
* Ordering invariant (EC-3): the caller runs the CSRF gate BEFORE invoking this
|
|
700
|
+
* runner, mirroring the Node path (CSRF stage precedes user middleware).
|
|
701
|
+
*
|
|
702
|
+
* NOTE (D4 / EC-12): this is its own middleware contract — `(request, context)`.
|
|
703
|
+
* Full semantic parity with the Node `defineMiddleware` contract is part of the
|
|
704
|
+
* deferred Node→Web pipeline convergence, not this slice.
|
|
705
|
+
*/
|
|
706
|
+
/** A Web-path middleware: mutate `context`, or return a `Response` to short-circuit. */
|
|
707
|
+
type WebMiddleware = (request: Request, context: Record<string, unknown>) => Promise<Response | undefined> | Response | undefined | void;
|
|
708
|
+
|
|
690
709
|
/**
|
|
691
710
|
* The route module exported by a `server/routes/*.ts` file (after T2.6 G6
|
|
692
711
|
* router lockdown). Method-named exports map to `defineRoute` results.
|
|
@@ -710,6 +729,20 @@ type WebRouteModule = Partial<Record<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
|
|
|
710
729
|
*/
|
|
711
730
|
interface ExecuteWebRequestOptions {
|
|
712
731
|
csrfMode?: 'off' | 'strict';
|
|
732
|
+
/**
|
|
733
|
+
* T3.1 — route params resolved upstream by `matchRoute` (e.g. `{ id: '42' }`
|
|
734
|
+
* for `/users/:id`). Threaded to the handler's `params` input and validated
|
|
735
|
+
* against `config.params` (Zod) when declared. Defaults to `{}` — callers
|
|
736
|
+
* that don't supply params keep the prior behavior (additive, backward-compat).
|
|
737
|
+
*/
|
|
738
|
+
params?: Record<string, string>;
|
|
739
|
+
/**
|
|
740
|
+
* T3.2 — Web-Standards middleware chain. Runs in order AFTER the CSRF gate
|
|
741
|
+
* (EC-3) and BEFORE the handler. A middleware returning a `Response`
|
|
742
|
+
* short-circuits (handler not reached); mutating `context` passes data to
|
|
743
|
+
* the handler. Omitted → zero overhead (handler runs directly).
|
|
744
|
+
*/
|
|
745
|
+
middleware?: readonly WebMiddleware[];
|
|
713
746
|
/**
|
|
714
747
|
* T5a.2 Phase E — body parser strategy.
|
|
715
748
|
*
|
package/dist/server/index.js
CHANGED
|
@@ -44,11 +44,6 @@ import {
|
|
|
44
44
|
ChannelManager
|
|
45
45
|
} from "../chunk-NM4WF3XD.js";
|
|
46
46
|
import "../chunk-E3JH6YUM.js";
|
|
47
|
-
import {
|
|
48
|
-
generateManifest,
|
|
49
|
-
loadManifest,
|
|
50
|
-
writeManifest
|
|
51
|
-
} from "../chunk-GPF64ENM.js";
|
|
52
47
|
import "../chunk-JHEAWR3L.js";
|
|
53
48
|
import {
|
|
54
49
|
StorageManager,
|
|
@@ -84,16 +79,17 @@ import {
|
|
|
84
79
|
createViteLoader
|
|
85
80
|
} from "../chunk-JQSKBMXP.js";
|
|
86
81
|
import {
|
|
82
|
+
ActionScanError,
|
|
87
83
|
compilePattern,
|
|
84
|
+
generateManifest,
|
|
85
|
+
loadManifest,
|
|
88
86
|
matchRoute,
|
|
89
|
-
scanServerRoutes,
|
|
90
|
-
scanWebSocketRoutes
|
|
91
|
-
} from "../chunk-OLPB36O2.js";
|
|
92
|
-
import {
|
|
93
|
-
ActionScanError,
|
|
94
87
|
scanServerActions,
|
|
95
|
-
scanServerActionsEnriched
|
|
96
|
-
|
|
88
|
+
scanServerActionsEnriched,
|
|
89
|
+
scanServerRoutes,
|
|
90
|
+
scanWebSocketRoutes,
|
|
91
|
+
writeManifest
|
|
92
|
+
} from "../chunk-223EFY5X.js";
|
|
97
93
|
import "../chunk-WSJKACWB.js";
|
|
98
94
|
import {
|
|
99
95
|
CSP_REPORT_PATH,
|
|
@@ -110,7 +106,7 @@ import {
|
|
|
110
106
|
handleCsrfReadinessRequest,
|
|
111
107
|
normalizeLegacy,
|
|
112
108
|
normalizeNew
|
|
113
|
-
} from "../chunk-
|
|
109
|
+
} from "../chunk-JBCHWRKF.js";
|
|
114
110
|
import {
|
|
115
111
|
__resetSdkForTests,
|
|
116
112
|
__setSdkForTests,
|
|
@@ -119,6 +115,7 @@ import {
|
|
|
119
115
|
streamAgentRun
|
|
120
116
|
} from "../chunk-RESN62GB.js";
|
|
121
117
|
import {
|
|
118
|
+
AuthRequiredError,
|
|
122
119
|
_resetKeyCacheForTests,
|
|
123
120
|
assertProductionSecret,
|
|
124
121
|
checkThrottle,
|
|
@@ -135,13 +132,14 @@ import {
|
|
|
135
132
|
generateTotpSecret,
|
|
136
133
|
pkceChallengeFromVerifier,
|
|
137
134
|
recordAttempt,
|
|
135
|
+
requireAuth,
|
|
138
136
|
rotateIfNeeded,
|
|
139
137
|
rotateIfNeededWeb,
|
|
140
138
|
totpUri,
|
|
141
139
|
verifyBackupCode,
|
|
142
140
|
verifyOAuthState,
|
|
143
141
|
verifyTotp
|
|
144
|
-
} from "../chunk-
|
|
142
|
+
} from "../chunk-SJIRP73B.js";
|
|
145
143
|
import {
|
|
146
144
|
generateNonce
|
|
147
145
|
} from "../chunk-C3ZZ56YZ.js";
|
|
@@ -181,7 +179,7 @@ import {
|
|
|
181
179
|
defineWebChannel,
|
|
182
180
|
defineWebSocket,
|
|
183
181
|
defineWebSocketWeb
|
|
184
|
-
} from "../chunk-
|
|
182
|
+
} from "../chunk-6BUUZ2PK.js";
|
|
185
183
|
import {
|
|
186
184
|
MAX_ERROR_HTML_BYTES,
|
|
187
185
|
loadCustomErrorPages,
|
|
@@ -198,6 +196,7 @@ import {
|
|
|
198
196
|
_resetMiddlewareCacheForTests,
|
|
199
197
|
createCorsHandler,
|
|
200
198
|
createCorsWebHandler,
|
|
199
|
+
envelopeCodeToStatus,
|
|
201
200
|
executeAction,
|
|
202
201
|
executeRoute,
|
|
203
202
|
extractTraceId,
|
|
@@ -211,7 +210,7 @@ import {
|
|
|
211
210
|
runMiddlewareAndContext,
|
|
212
211
|
sendError,
|
|
213
212
|
sendJson
|
|
214
|
-
} from "../chunk-
|
|
213
|
+
} from "../chunk-3FYJ7R7N.js";
|
|
215
214
|
import {
|
|
216
215
|
DuplicateContextKeyError,
|
|
217
216
|
createOutbox,
|
|
@@ -252,10 +251,6 @@ import {
|
|
|
252
251
|
serializeCookie,
|
|
253
252
|
setCookie
|
|
254
253
|
} from "../chunk-ZJQ4O76G.js";
|
|
255
|
-
import {
|
|
256
|
-
AuthRequiredError,
|
|
257
|
-
requireAuth
|
|
258
|
-
} from "../chunk-4HBI7DHP.js";
|
|
259
254
|
import "../chunk-DGUM43GV.js";
|
|
260
255
|
|
|
261
256
|
// src/server/openapi/serve-docs.ts
|
|
@@ -266,12 +261,13 @@ var DEFAULT_CDN = "https://cdn.jsdelivr.net/npm/@scalar/api-reference";
|
|
|
266
261
|
function createOpenApiHandler(opts = {}) {
|
|
267
262
|
const docsPath = opts.docsPath ?? "/api/docs";
|
|
268
263
|
const jsonPath = opts.openapiJsonPath ?? "/api/docs/openapi.json";
|
|
269
|
-
const
|
|
264
|
+
const rawSpecFile = opts.specFilePath ?? ".theokit/openapi.json";
|
|
270
265
|
const title = opts.pageTitle ?? "API Reference";
|
|
271
266
|
const cdn = opts.cdnUrl ?? DEFAULT_CDN;
|
|
272
|
-
if (
|
|
273
|
-
throw new Error(`[theokit:openapi] specFilePath must not contain ".." segments: ${
|
|
267
|
+
if (hasDotDotSegment(rawSpecFile)) {
|
|
268
|
+
throw new Error(`[theokit:openapi] specFilePath must not contain ".." segments: ${rawSpecFile}`);
|
|
274
269
|
}
|
|
270
|
+
const specFile = resolve(rawSpecFile);
|
|
275
271
|
return (request) => {
|
|
276
272
|
if (request.method !== "GET") return null;
|
|
277
273
|
const url = new URL(request.url);
|
|
@@ -291,6 +287,9 @@ function createOpenApiHandler(opts = {}) {
|
|
|
291
287
|
return null;
|
|
292
288
|
};
|
|
293
289
|
}
|
|
290
|
+
function hasDotDotSegment(p) {
|
|
291
|
+
return p.split(/[/\\]/).includes("..");
|
|
292
|
+
}
|
|
294
293
|
function escapeHtml(s) {
|
|
295
294
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
296
295
|
}
|
|
@@ -1095,6 +1094,15 @@ function deserializeResponse(serialized) {
|
|
|
1095
1094
|
return superjson.deserialize(serialized);
|
|
1096
1095
|
}
|
|
1097
1096
|
|
|
1097
|
+
// src/server/http/web-middleware-runner.ts
|
|
1098
|
+
async function runWebMiddleware(request, middleware, context) {
|
|
1099
|
+
for (const mw of middleware) {
|
|
1100
|
+
const result = await mw(request, context);
|
|
1101
|
+
if (result instanceof Response) return result;
|
|
1102
|
+
}
|
|
1103
|
+
return void 0;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1098
1106
|
// src/server/web-handler.ts
|
|
1099
1107
|
function searchParamsToObject(params) {
|
|
1100
1108
|
const out = {};
|
|
@@ -1159,11 +1167,11 @@ function validationErrorResponse(zodError, field) {
|
|
|
1159
1167
|
headers: { "content-type": "application/json" }
|
|
1160
1168
|
});
|
|
1161
1169
|
}
|
|
1162
|
-
async function runHandler(config, request, bodyParser = "inline") {
|
|
1170
|
+
async function runHandler(config, request, bodyParser = "inline", paramsInput = {}, context = {}) {
|
|
1163
1171
|
const url = new URL(request.url);
|
|
1164
1172
|
const queryRaw = searchParamsToObject(url.searchParams);
|
|
1165
1173
|
const bodyRaw = bodyParser === "full" ? await parseBodyFull(request) : await parseBodyInline(request);
|
|
1166
|
-
const paramsRaw =
|
|
1174
|
+
const paramsRaw = paramsInput;
|
|
1167
1175
|
let query = queryRaw;
|
|
1168
1176
|
if (config.query !== void 0) {
|
|
1169
1177
|
const parsed = config.query.safeParse(queryRaw);
|
|
@@ -1185,7 +1193,7 @@ async function runHandler(config, request, bodyParser = "inline") {
|
|
|
1185
1193
|
return { ok: false, response: validationErrorResponse(parsed.error, "params") };
|
|
1186
1194
|
params = parsed.data;
|
|
1187
1195
|
}
|
|
1188
|
-
const result = await config.handler({ query, body, params, request });
|
|
1196
|
+
const result = await config.handler({ query, body, params, request, context });
|
|
1189
1197
|
return { ok: true, result };
|
|
1190
1198
|
}
|
|
1191
1199
|
function toResponse(result) {
|
|
@@ -1208,36 +1216,6 @@ function handlerErrorResponse(err) {
|
|
|
1208
1216
|
headers: { "content-type": "application/json" }
|
|
1209
1217
|
});
|
|
1210
1218
|
}
|
|
1211
|
-
function envelopeCodeToStatus(code) {
|
|
1212
|
-
switch (code) {
|
|
1213
|
-
case "BAD_REQUEST":
|
|
1214
|
-
return 400;
|
|
1215
|
-
case "UNAUTHORIZED":
|
|
1216
|
-
return 401;
|
|
1217
|
-
case "FORBIDDEN":
|
|
1218
|
-
return 403;
|
|
1219
|
-
case "NOT_FOUND":
|
|
1220
|
-
return 404;
|
|
1221
|
-
case "METHOD_NOT_ALLOWED":
|
|
1222
|
-
return 405;
|
|
1223
|
-
case "PAYLOAD_TOO_LARGE":
|
|
1224
|
-
return 413;
|
|
1225
|
-
case "UNPROCESSABLE_ENTITY":
|
|
1226
|
-
return 422;
|
|
1227
|
-
case "TOO_MANY_REQUESTS":
|
|
1228
|
-
case "RATE_LIMITED":
|
|
1229
|
-
return 429;
|
|
1230
|
-
case "BAD_GATEWAY":
|
|
1231
|
-
return 502;
|
|
1232
|
-
case "SERVICE_UNAVAILABLE":
|
|
1233
|
-
return 503;
|
|
1234
|
-
case "GATEWAY_TIMEOUT":
|
|
1235
|
-
return 504;
|
|
1236
|
-
case "INTERNAL_SERVER_ERROR":
|
|
1237
|
-
default:
|
|
1238
|
-
return 500;
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
1219
|
var CSRF_PROTECTED_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
1242
1220
|
function mergeHookHeaders(response, hookHeaders) {
|
|
1243
1221
|
if ([...hookHeaders].length === 0) return response;
|
|
@@ -1287,7 +1265,18 @@ async function executeWebRequest(request, routeModule, opts = {}) {
|
|
|
1287
1265
|
if (!csrfCheck.valid) return csrfFailedResponse(csrfCheck.reason);
|
|
1288
1266
|
}
|
|
1289
1267
|
try {
|
|
1290
|
-
const
|
|
1268
|
+
const context = {};
|
|
1269
|
+
if (opts.middleware?.length) {
|
|
1270
|
+
const shortCircuit = await runWebMiddleware(request, opts.middleware, context);
|
|
1271
|
+
if (shortCircuit) return shortCircuit;
|
|
1272
|
+
}
|
|
1273
|
+
const outcome = await runHandler(
|
|
1274
|
+
config,
|
|
1275
|
+
request,
|
|
1276
|
+
opts.bodyParser ?? "inline",
|
|
1277
|
+
opts.params ?? {},
|
|
1278
|
+
context
|
|
1279
|
+
);
|
|
1291
1280
|
if (!outcome.ok) return outcome.response;
|
|
1292
1281
|
return toResponse(outcome.result);
|
|
1293
1282
|
} catch (err) {
|
|
@@ -1313,13 +1302,29 @@ async function runPreHandlerPipeline(hookCtx, request, config, opts, hooks) {
|
|
|
1313
1302
|
await runList(hooks.preHandler);
|
|
1314
1303
|
}
|
|
1315
1304
|
if (hookCtx.response === void 0) {
|
|
1316
|
-
|
|
1317
|
-
|
|
1305
|
+
await runHandlerStage(hookCtx, request, config, opts, method);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
async function runHandlerStage(hookCtx, request, config, opts, method) {
|
|
1309
|
+
if (config === void 0 || typeof config.handler !== "function") {
|
|
1310
|
+
hookCtx.response = methodNotAllowedResponse(method);
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
if (opts.middleware?.length) {
|
|
1314
|
+
const shortCircuit = await runWebMiddleware(request, opts.middleware, hookCtx.ctx);
|
|
1315
|
+
if (shortCircuit) {
|
|
1316
|
+
hookCtx.response = shortCircuit;
|
|
1318
1317
|
return;
|
|
1319
1318
|
}
|
|
1320
|
-
const outcome = await runHandler(config, request, opts.bodyParser ?? "inline");
|
|
1321
|
-
hookCtx.response = outcome.ok ? toResponse(outcome.result) : outcome.response;
|
|
1322
1319
|
}
|
|
1320
|
+
const outcome = await runHandler(
|
|
1321
|
+
config,
|
|
1322
|
+
request,
|
|
1323
|
+
opts.bodyParser ?? "inline",
|
|
1324
|
+
opts.params ?? {},
|
|
1325
|
+
hookCtx.ctx
|
|
1326
|
+
);
|
|
1327
|
+
hookCtx.response = outcome.ok ? toResponse(outcome.result) : outcome.response;
|
|
1323
1328
|
}
|
|
1324
1329
|
async function runWithHooks(request, config, opts, hooks) {
|
|
1325
1330
|
const hookCtx = {
|