@reckona/mreact-router 0.0.152 → 0.0.154
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/README.md +1 -1
- package/dist/actions.d.ts +10 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +6 -0
- package/dist/actions.js.map +1 -1
- package/dist/adapters/aws-lambda.d.ts +18 -0
- package/dist/adapters/aws-lambda.d.ts.map +1 -1
- package/dist/adapters/aws-lambda.js +18 -0
- package/dist/adapters/aws-lambda.js.map +1 -1
- package/dist/adapters/cloudflare.d.ts +33 -0
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +33 -0
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/adapters/edge.d.ts +5 -0
- package/dist/adapters/edge.d.ts.map +1 -1
- package/dist/adapters/edge.js +5 -0
- package/dist/adapters/edge.js.map +1 -1
- package/dist/adapters/node.d.ts +5 -0
- package/dist/adapters/node.d.ts.map +1 -1
- package/dist/adapters/node.js +5 -0
- package/dist/adapters/node.js.map +1 -1
- package/dist/adapters/static.d.ts +5 -0
- package/dist/adapters/static.d.ts.map +1 -1
- package/dist/adapters/static.js +5 -0
- package/dist/adapters/static.js.map +1 -1
- package/dist/build.d.ts +15 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +85 -2
- package/dist/build.js.map +1 -1
- package/dist/cache.d.ts +15 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +15 -0
- package/dist/cache.js.map +1 -1
- package/dist/cookies.d.ts +16 -0
- package/dist/cookies.d.ts.map +1 -1
- package/dist/cookies.js +16 -0
- package/dist/cookies.js.map +1 -1
- package/dist/dev-server.d.ts +5 -0
- package/dist/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js +5 -0
- package/dist/dev-server.js.map +1 -1
- package/dist/link.d.ts +10 -0
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +5 -0
- package/dist/link.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +39 -4
- package/dist/middleware.js.map +1 -1
- package/dist/module-runner.d.ts +6 -0
- package/dist/module-runner.d.ts.map +1 -1
- package/dist/module-runner.js +71 -0
- package/dist/module-runner.js.map +1 -1
- package/dist/navigation.d.ts +53 -0
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +48 -0
- package/dist/navigation.js.map +1 -1
- package/dist/render.d.ts +34 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +161 -27
- package/dist/render.js.map +1 -1
- package/dist/route-module-loader.d.ts +6 -1
- package/dist/route-module-loader.d.ts.map +1 -1
- package/dist/route-module-loader.js +8 -1
- package/dist/route-module-loader.js.map +1 -1
- package/dist/serve.d.ts +5 -0
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +5 -0
- package/dist/serve.js.map +1 -1
- package/dist/session.d.ts +19 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +19 -0
- package/dist/session.js.map +1 -1
- package/dist/typed-routes.d.ts +5 -0
- package/dist/typed-routes.d.ts.map +1 -1
- package/dist/typed-routes.js +5 -0
- package/dist/typed-routes.js.map +1 -1
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +1 -0
- package/dist/vite.js.map +1 -1
- package/package.json +11 -11
- package/src/actions.ts +18 -0
- package/src/adapters/aws-lambda.ts +18 -0
- package/src/adapters/cloudflare.ts +33 -0
- package/src/adapters/edge.ts +5 -0
- package/src/adapters/node.ts +5 -0
- package/src/adapters/static.ts +5 -0
- package/src/build.ts +118 -1
- package/src/cache.ts +15 -0
- package/src/cookies.ts +16 -0
- package/src/dev-server.ts +5 -0
- package/src/link.ts +10 -0
- package/src/middleware.ts +54 -4
- package/src/module-runner.ts +91 -0
- package/src/navigation.ts +53 -0
- package/src/render.ts +229 -25
- package/src/route-module-loader.ts +15 -0
- package/src/serve.ts +5 -0
- package/src/session.ts +19 -0
- package/src/typed-routes.ts +5 -0
- package/src/types.ts +15 -0
- package/src/vite.ts +1 -0
package/README.md
CHANGED
|
@@ -371,7 +371,7 @@ Production adapters enforce the app-router import policy when bundling loaders,
|
|
|
371
371
|
|
|
372
372
|
For Lambda deployments, build with `mreact-router build --target=aws-lambda` or `buildApp({ targets: ["aws-lambda"] })`. The target writes Node-compatible server/client output, `.mreact/server/import-policy.json`, and `.mreact/aws-lambda/mreact-handler.mjs` while skipping `.mreact/cloudflare` route modules, so loaders and server helpers may import Node-only dependencies such as database drivers without being bundled for the Workers runtime.
|
|
373
373
|
|
|
374
|
-
Package Lambda deployments with `mreact-router package aws-lambda --from .mreact --out .lambda` instead of pointing deployment tooling at the full project checkout. AWS Lambda enforces a 250 MB unzipped deployment package limit, and the runtime only needs `.mreact/`, `mreact-handler.mjs`, `package.json` / lockfiles, and production `node_modules`; `src/`, tests, dev dependencies, build caches, and Vite/Vitest/Playwright tooling are not required. `mreact-router build --target=aws-lambda` keeps compiled server route artifacts in `.mreact/server/server-modules/*.json` instead of embedding them in one large server manifest, writes compiled module bodies as hashed `.mjs` files, and keeps request/control artifacts separate from render artifacts so loader redirects do not read page render bundles. `createAwsLambdaRequestHandler()` treats `outDir` as read-only and materializes generated runtime files under `/tmp/mreact-router/<hash>/runtime` by default, with a `node_modules` symlink back to the deployed package root. Direct `createAwsLambdaRequestHandler()` and `createAwsLambdaStreamingRequestHandler()` handlers start only middleware and shared runtime preload in the background by default, so all-route preload work does not compete with the first user request. If a request arrives before preload finishes, middleware is resolved first, middleware responses or redirects return without loading the matched page artifact, and continuing requests load only the matched route's artifact closure. Static middleware `config.matcher` and `config.id` values are checked before importing the middleware module, so unmatched health checks and route-local middleware skips avoid evaluating heavyweight middleware dependencies. Route request artifacts omit page render exports, and built loader and route metadata artifacts are split, so loader redirects do not evaluate page-only or metadata-only dependencies before render or metadata is needed. Loader redirects settle before page component server transforms and render imports for non-stream routes
|
|
374
|
+
Package Lambda deployments with `mreact-router package aws-lambda --from .mreact --out .lambda` instead of pointing deployment tooling at the full project checkout. AWS Lambda enforces a 250 MB unzipped deployment package limit, and the runtime only needs `.mreact/`, `mreact-handler.mjs`, `package.json` / lockfiles, and production `node_modules`; `src/`, tests, dev dependencies, build caches, and Vite/Vitest/Playwright tooling are not required. `mreact-router build --target=aws-lambda` keeps compiled server route artifacts in `.mreact/server/server-modules/*.json` instead of embedding them in one large server manifest, writes compiled module bodies as hashed `.mjs` files, and keeps request/control artifacts separate from render artifacts so loader redirects do not read page render bundles. `createAwsLambdaRequestHandler()` treats `outDir` as read-only and materializes generated runtime files under `/tmp/mreact-router/<hash>/runtime` by default, with a `node_modules` symlink back to the deployed package root. Direct `createAwsLambdaRequestHandler()` and `createAwsLambdaStreamingRequestHandler()` handlers start only middleware and shared runtime preload in the background by default, so all-route preload work does not compete with the first user request. If a request arrives before preload finishes, middleware is resolved first, middleware responses or redirects return without loading the matched page artifact, and continuing requests load only the matched route's artifact closure. Static middleware `config.matcher` and `config.id` values are checked before importing the middleware module, so unmatched health checks and route-local middleware skips avoid evaluating heavyweight middleware dependencies. Route request artifacts omit page render exports, and built loader and route metadata artifacts are split, so loader redirects do not evaluate page-only or metadata-only dependencies before render or metadata is needed. Loader redirects settle before page component server transforms and render imports for non-stream routes, stream routes without a loading boundary, and stream loading routes whose loader source contains router control-flow helpers such as `redirect()` or `notFound()`. Prefer `await createPreloadedAwsLambdaRequestHandler()` in Node 24 ESM Lambda handlers when first-request latency matters: it waits for the full preload during Lambda initialization by default, increasing `Init Duration` but making the first handler invocation much closer to warm steady-state. Pass `runtimeDir` only when you need to control that writable cache location. With pnpm, run `pnpm --dir .lambda install --prod --frozen-lockfile --ignore-scripts --config.node-linker=hoisted`. pnpm's default isolated linker is symlink-heavy, so verify the artifact's symlink count with `find .lambda -type l | wc -l` and measure actual file bytes in addition to `du -sh .lambda` before upload. Packages listed in the generated import policy must also be installed in that production artifact.
|
|
375
375
|
|
|
376
376
|
When a deployment needs custom adapter options such as `serverActions.authorize`, `onResponse`, `errorHandler`, or `allowedHosts`, create an app handler and package it with `mreact-router package aws-lambda --from .mreact --out .lambda --handler src/lambda.ts`. The package command bundles that handler into `.lambda/mreact-handler.mjs`, resolves app-local TypeScript imports with Vite-style extensionless paths, and keeps package imports external so production `node_modules` remains the runtime dependency boundary. If the handler imports the same app server modules that routes also import, those modules are compiled into the handler bundle separately from the mreact route artifacts; use `getServerRuntimeState()` for state that must be shared through the router runtime instead of relying on module singletons.
|
|
377
377
|
|
package/dist/actions.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ import { type AppRouterImportPolicy } from "./import-policy.js";
|
|
|
4
4
|
import { type RequestCookies } from "./navigation.js";
|
|
5
5
|
export { createFormCsrfToken, formCsrfCookie, formCsrfFieldName, serverActionCookie, validateFormCsrf, } from "./csrf.js";
|
|
6
6
|
import { type ServerActionInferenceDiagnostic } from "./server-action-inference.js";
|
|
7
|
+
/**
|
|
8
|
+
* Request context passed to authorized server actions.
|
|
9
|
+
*
|
|
10
|
+
* It exposes normalized cookies, headers, the original `Request`, and an optional client IP so authorization hooks can make request-aware decisions.
|
|
11
|
+
*/
|
|
7
12
|
export interface ServerActionContext {
|
|
8
13
|
clientIp?: string | undefined;
|
|
9
14
|
cookies: RequestCookies;
|
|
@@ -21,6 +26,11 @@ declare class BoundedReplayStore {
|
|
|
21
26
|
}
|
|
22
27
|
export declare function __clearDefaultReplayStore(): void;
|
|
23
28
|
export declare function __readDefaultReplayStore(): BoundedReplayStore;
|
|
29
|
+
/**
|
|
30
|
+
* Configures app-router server action dispatch, authorization, body limits, and replay protection.
|
|
31
|
+
*
|
|
32
|
+
* Production multi-instance deployments should provide a shared `replayStore` and a stable `MREACT_SERVER_ACTION_SECRET`.
|
|
33
|
+
*/
|
|
24
34
|
export interface AppRouterServerActionOptions {
|
|
25
35
|
allowedActions?: readonly AppRouterAllowedServerAction[] | "any" | undefined;
|
|
26
36
|
authorize?: ServerActionHandlerOptions["authorize"] | undefined;
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,0BAA0B,EAE/B,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EAElC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,YAAY,CAAC;AAExE,OAAO,EAAqC,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAMnB,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,8BAA8B,CAAC;AAiCtC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAYD,cAAM,kBAAkB;IAIpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;gBAGlC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM;IAGrC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAU3B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAsBxB,IAAI,IAAI,MAAM;CAGf;AAUD,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,wBAAgB,wBAAwB,IAAI,kBAAkB,CAE7D;AAED,MAAM,WAAW,4BAA4B;IAC3C,cAAc,CAAC,EAAE,S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|
|
793
793
|
for (const entry of entries) {
|
|
794
794
|
const path = join(directory, entry.name);
|
|
795
795
|
if (entry.isDirectory()) {
|
|
796
|
+
if (shouldSkipServerActionScanDirectory(entry.name)) {
|
|
797
|
+
continue;
|
|
798
|
+
}
|
|
796
799
|
files.push(...(await collectFiles(path)));
|
|
797
800
|
continue;
|
|
798
801
|
}
|
|
@@ -802,6 +805,9 @@ async function collectFiles(directory) {
|
|
|
802
805
|
}
|
|
803
806
|
return files;
|
|
804
807
|
}
|
|
808
|
+
function shouldSkipServerActionScanDirectory(name) {
|
|
809
|
+
return name === "node_modules" || name === "__tests__" || name.startsWith(".");
|
|
810
|
+
}
|
|
805
811
|
async function resolveSourceFile(directory, source) {
|
|
806
812
|
const base = join(directory, source);
|
|
807
813
|
const tsEsmBase = /\.[cm]?js$/.test(base) ? base.replace(/\.[cm]?js$/, "") : undefined;
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,qCAAqC,EACrC,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,yBAAyB,GAM1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAA6B,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAuB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,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AAC,KAAK,CAAC,CAAC;IACvB,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAkB;IAC7C,MAAM,OAAO,GAAG,IAAI,QAAQ,EAAE,CAAC;IAE/B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/C,IACE,IAAI,KAAK,iBAAiB;YAC1B,IAAI,KAAK,mBAAmB;YAC5B,IAAI,KAAK,iBAAiB;YAC1B,IAAI,KAAK,cAAc;YACvB,IAAI,KAAK,oBAAoB,EAC7B,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,eAAe,CAAC,KAAgC;IACvD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,SAAS,YAAY,CAAC,OAAgB,EAAE,MAAc;IACpD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QAC3C,OAAO,EAAE,EAAE,cAAc,EAAE,iCAAiC,EAAE;QAC9D,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from \"node:crypto\";\nimport { access, readdir, readFile } from \"node:fs/promises\";\nimport { dirname, join, relative, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n collectFormActionExpressionReferences,\n hasModuleDirective,\n} from \"@reckona/mreact-compiler\";\nimport {\n createServerActionHandler,\n type ServerActionHandlerOptions,\n type ServerActionRegistry,\n type ServerActionReplayStore,\n type ServerActionRequestReference,\n type ServerActionValidationResult,\n} from \"@reckona/mreact-server\";\nimport { bundleRouterModule, type RouterCompatBuildApi } from \"./bundle-pipeline.js\";\nimport { type AppRouterCache, withRouteCacheContext } from \"./cache.js\";\nimport { fileImportMetaUrlPlugin, importAppRouterSourceModule } from \"./module-runner.js\";\nimport { createAppRouterImportPolicyPlugin, type AppRouterImportPolicy } from \"./import-policy.js\";\nimport { cookies, type RequestCookies } from \"./navigation.js\";\nexport {\n createFormCsrfToken,\n formCsrfCookie,\n formCsrfFieldName,\n serverActionCookie,\n validateFormCsrf,\n} from \"./csrf.js\";\nimport {\n formCsrfFieldName,\n readExistingFormCsrfToken,\n validateFormCsrf,\n} from \"./csrf.js\";\nimport {\n collectRuntimeInferredServerActions,\n type ServerActionInferenceDiagnostic,\n} from \"./server-action-inference.js\";\n\nfunction isProductionEnvironment(): boolean {\n return process.env.NODE_ENV === \"production\";\n}\nconst formFieldModuleId = \"__mreact_module_id\";\nconst formFieldExportName = \"__mreact_export_name\";\nconst formFieldNonce = \"__mreact_action_nonce\";\nconst formFieldActionToken = \"__mreact_action_token\";\nconst actionTokenSecret = process.env.MREACT_SERVER_ACTION_SECRET ?? defaultActionTokenSecret();\n// Bounded default replay store for form-action nonces. The previous\n// implementation was an unbounded Set that grew with every successful\n// submission (Issue 069). Production callers should still pass a shared\n// store (Redis / KV) via `serverActions.replayStore` for multi-instance\n// deployments -- this default only guarantees replay protection within\n// a single process and is the safe fallback for dev / single-node setups.\n//\n// Retention model:\n// - TTL: 10 minutes. Form nonces are minted at SSR time and the user\n// has to submit before the cookie's SameSite=Lax window anyway; this\n// is generous for any realistic submit cadence.\n// - Max size: 50_000 entries. Old entries are evicted FIFO once the cap\n// is reached so a flood cannot trigger OOM.\n//\n// Both bounds are intentional defaults -- tight enough that a single\n// process cannot leak unbounded RSS, loose enough that legitimate\n// traffic does not trip false-positive 409s.\nconst DEFAULT_REPLAY_TTL_MS = 10 * 60 * 1000;\nconst DEFAULT_REPLAY_MAX_ENTRIES = 50_000;\nconst DEFAULT_ACTION_BODY_MAX_BYTES = 10 * 1024 * 1024;\nconst DEFAULT_ACTION_FORM_MAX_FIELDS = 1_000;\nlet warnedUnrestrictedServerActions = false;\n\nexport interface ServerActionContext {\n clientIp?: string | undefined;\n cookies: RequestCookies;\n headers: Headers;\n request: Request;\n}\n\nfunction defaultActionTokenSecret(): string {\n if (isProductionEnvironment()) {\n console.warn(\n \"mreact-router: MREACT_SERVER_ACTION_SECRET is not set. Inferred server action tokens use a per-process secret and may fail across multiple production instances.\",\n );\n }\n\n return randomBytes(32).toString(\"base64url\");\n}\n\nclass BoundedReplayStore {\n private readonly entries = new Map<string, number>();\n\n constructor(\n private readonly ttlMs: number,\n private readonly maxEntries: number,\n ) {}\n\n has(value: string): boolean {\n const expiresAt = this.entries.get(value);\n if (expiresAt === undefined) return false;\n if (expiresAt < Date.now()) {\n this.entries.delete(value);\n return false;\n }\n return true;\n }\n\n add(value: string): void {\n const now = Date.now();\n if (this.entries.size >= this.maxEntries) {\n const oldest = this.entries.entries().next().value;\n if (oldest !== undefined) {\n const [key, expiresAt] = oldest;\n this.entries.delete(key);\n if (expiresAt < now) {\n while (this.entries.size >= this.maxEntries) {\n const nextOldest = this.entries.entries().next().value;\n if (nextOldest === undefined || nextOldest[1] >= now) {\n break;\n }\n this.entries.delete(nextOldest[0]);\n }\n }\n }\n }\n this.entries.set(value, now + this.ttlMs);\n }\n\n // Exposed for tests; not part of the ServerActionReplayStore interface.\n size(): number {\n return this.entries.size;\n }\n}\n\nconst usedFormActionNonces = new BoundedReplayStore(\n DEFAULT_REPLAY_TTL_MS,\n DEFAULT_REPLAY_MAX_ENTRIES,\n);\n\n// Test helpers: drop all entries between cases / expose the bounded store\n// so tests can drive its eviction semantics directly. Not part of the\n// public surface (prefixed with `__`).\nexport function __clearDefaultReplayStore(): void {\n (usedFormActionNonces as unknown as { entries: Map<string, number> }).entries.clear();\n}\n\nexport function __readDefaultReplayStore(): BoundedReplayStore {\n return usedFormActionNonces;\n}\n\nexport interface AppRouterServerActionOptions {\n allowedActions?: readonly AppRouterAllowedServerAction[] | \"any\" | undefined;\n authorize?: ServerActionHandlerOptions[\"authorize\"] | undefined;\n maxBodyBytes?: number | undefined;\n maxFormFields?: number | undefined;\n replayStore?: ServerActionReplayStore | undefined;\n}\n\nexport interface AppRouterAllowedServerAction extends ServerActionRequestReference {\n inferred?: boolean | undefined;\n}\n\nexport interface PreparedRouteActions {\n actionNonce?: string;\n code: string;\n csrfToken?: string;\n diagnostics?: ServerActionInferenceDiagnostic[] | undefined;\n // True when the cookie should be (re)set on the response. False means\n // the incoming request already carried a valid CSRF cookie that the\n // render is reusing -- skipping Set-Cookie avoids cookie thrash across\n // concurrent tabs (Issue 070).\n csrfTokenIsNew?: boolean;\n hasFormActions: boolean;\n}\n\ninterface ActionReference {\n exportName: string;\n inferred: boolean;\n moduleId: string;\n}\n\nexport interface PreparedFormActionReference {\n end: number;\n expression: string;\n expressionEnd: number;\n expressionStart: number;\n exportName: string;\n inferred: boolean;\n moduleId: string;\n sourceHash: string;\n start: number;\n}\n\nconst inferredServerActionReferences = new Map<string, Map<string, Map<string, ActionReference>>>();\n\nexport async function prepareRouteServerActions(options: {\n appDir: string;\n code: string;\n formActionReferences?: readonly PreparedFormActionReference[] | undefined;\n pageFile: string;\n request?: Request | undefined;\n}): Promise<PreparedRouteActions> {\n if (options.formActionReferences !== undefined && options.formActionReferences.length === 0) {\n replaceInferredServerActionReferences(options.appDir, options.pageFile, new Map());\n return { code: options.code, hasFormActions: false };\n }\n\n if (!hasFormActionCandidate(options.code, options.pageFile)) {\n replaceInferredServerActionReferences(options.appDir, options.pageFile, new Map());\n return { code: options.code, hasFormActions: false };\n }\n\n const inference =\n options.formActionReferences === undefined\n ? await collectImportedServerActions(options)\n : {\n diagnostics: [],\n references: formActionReferenceMap(options.code, options.formActionReferences),\n };\n const { diagnostics, references } = inference;\n\n if (references.size === 0) {\n replaceInferredServerActionReferences(options.appDir, options.pageFile, new Map());\n return diagnostics.length === 0\n ? { code: options.code, hasFormActions: false }\n : { code: options.code, diagnostics, hasFormActions: false };\n }\n\n // Reuse the existing CSRF token when the browser already sent one.\n // Rotating the cookie on every render (Issue 070) broke concurrent\n // forms because the older tab's hidden input no longer matched the\n // cookie value. The actionNonce stays per-render -- that is the field\n // tied to a specific submission via replay protection.\n const existingToken = readExistingFormCsrfToken(options.request);\n const csrfToken = existingToken ?? randomUUID();\n const csrfTokenIsNew = existingToken === undefined;\n const actionNonce = randomUUID();\n const lowered = lowerFormActions({\n actionNonce,\n code: options.code,\n csrfToken,\n references,\n });\n\n if (lowered === options.code) {\n replaceInferredServerActionReferences(options.appDir, options.pageFile, new Map());\n return diagnostics.length === 0\n ? { code: options.code, hasFormActions: false }\n : { code: options.code, diagnostics, hasFormActions: false };\n }\n\n replaceInferredServerActionReferences(options.appDir, options.pageFile, references);\n\n return {\n actionNonce,\n code: lowered,\n csrfToken,\n csrfTokenIsNew,\n diagnostics,\n hasFormActions: true,\n };\n}\n\nfunction formActionReferenceMap(\n code: string,\n references: readonly PreparedFormActionReference[],\n): Map<string, ActionReference> {\n const sourceHash = formActionSourceHash(code);\n\n return new Map(\n references\n .filter((reference) => reference.sourceHash === sourceHash)\n .map((reference) => [\n formActionOccurrenceKey(reference),\n {\n exportName: reference.exportName,\n inferred: reference.inferred,\n moduleId: reference.moduleId,\n },\n ]),\n );\n}\n\nfunction hasFormActionCandidate(code: string, filename: string): boolean {\n return collectFormActionExpressionReferences({ code, filename }).length > 0;\n}\n\nexport async function dispatchServerActionRequest(options: {\n appDir: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n request: Request;\n renderSingleFlightNavigation?: ((options: {\n path: string;\n request: Request;\n revalidatedPaths: readonly string[];\n }) => Promise<Response | undefined>) | undefined;\n routeCache?: AppRouterCache | undefined;\n serverActionCacheVersion?: string | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n}): Promise<Response> {\n const { revalidatedPaths, value } = await withRouteCacheContext(options.routeCache, () =>\n dispatchServerActionRequestWithoutCacheContext(options),\n );\n const singleFlight = await renderSingleFlightActionResponse({\n render: options.renderSingleFlightNavigation,\n request: options.request,\n response: value,\n revalidatedPaths,\n });\n\n return withRevalidationHeader(singleFlight ?? value, revalidatedPaths);\n}\n\nasync function dispatchServerActionRequestWithoutCacheContext(options: {\n appDir: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n request: Request;\n serverActionCacheVersion?: string | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n}): Promise<Response> {\n // Validate everything we can statically before touching the filesystem\n // / bundler. A flood of malformed POSTs must not pay the registry-load\n // cost (Issue 067).\n if (options.request.method !== \"POST\") {\n return jsonResponse({ ok: false, error: \"Method not allowed.\" }, 405);\n }\n\n const bodySizeResponse = validateServerActionBodySize(\n options.request,\n options.serverActions?.maxBodyBytes ?? DEFAULT_ACTION_BODY_MAX_BYTES,\n );\n if (bodySizeResponse !== undefined) {\n return bodySizeResponse;\n }\n\n const originResponse = validateServerActionRequestOrigin(options.request);\n if (originResponse !== undefined) {\n return originResponse;\n }\n\n const contentType = options.request.headers.get(\"content-type\") ?? \"\";\n\n if (contentType.includes(\"application/json\")) {\n const manifestResponse = validateServerActionManifest(options.serverActions?.allowedActions);\n if (manifestResponse !== undefined) {\n return manifestResponse;\n }\n\n // JSON path delegates CSRF/replay to createServerActionHandler. The\n // registry is still needed here, but the handler short-circuits on\n // CSRF mismatch before invoking the action.\n let registry: ServerActionRegistry;\n try {\n registry = await loadServerActionRegistry({\n appDir: options.appDir,\n cacheVersion: options.serverActionCacheVersion,\n importPolicy: options.importPolicy,\n });\n } catch (error) {\n return jsonResponse(\n { ok: false, error: error instanceof Error ? error.message : String(error) },\n 500,\n );\n }\n\n const replayStore = options.serverActions?.replayStore ?? usedFormActionNonces;\n const handle = createServerActionHandler(jsonServerActionRegistry({\n allowedActions: options.serverActions?.allowedActions,\n appDir: options.appDir,\n registry,\n }), {\n ...(options.serverActions?.authorize === undefined\n ? {}\n : { authorize: options.serverActions.authorize }),\n ...(options.serverActions?.allowedActions === undefined ||\n options.serverActions.allowedActions === \"any\"\n ? {}\n : { allowedActions: jsonAllowedServerActions(options.serverActions.allowedActions) }),\n csrf: true,\n maxBodyBytes: options.serverActions?.maxBodyBytes ?? DEFAULT_ACTION_BODY_MAX_BYTES,\n replayProtection: { seen: replayStore },\n });\n\n return handle(options.request);\n }\n\n if (\n !contentType.includes(\"application/x-www-form-urlencoded\") &&\n !contentType.includes(\"multipart/form-data\")\n ) {\n return jsonResponse({ ok: false, error: \"Unsupported server action content type.\" }, 415);\n }\n\n const manifestResponse = validateServerActionManifest(options.serverActions?.allowedActions);\n if (manifestResponse !== undefined) {\n return manifestResponse;\n }\n\n const formData = await options.request.formData();\n const fieldCountResponse = validateServerActionFormFieldCount(\n formData,\n options.serverActions?.maxFormFields ?? DEFAULT_ACTION_FORM_MAX_FIELDS,\n );\n\n if (fieldCountResponse !== undefined) {\n return fieldCountResponse;\n }\n\n const csrfResponse = validateFormCsrf(options.request, formData);\n\n if (csrfResponse !== undefined) {\n return csrfResponse;\n }\n\n const moduleId = stringFormValue(formData.get(formFieldModuleId));\n const exportName = stringFormValue(formData.get(formFieldExportName));\n const nonce = stringFormValue(formData.get(formFieldNonce));\n\n if (moduleId === undefined || exportName === undefined || nonce === undefined) {\n return jsonResponse({ ok: false, error: \"Invalid server action reference.\" }, 400);\n }\n\n if (!isAllowedServerAction({ moduleId, exportName }, options.serverActions?.allowedActions)) {\n return jsonResponse({ ok: false, error: \"Unknown server action.\" }, 404);\n }\n\n if (\n isInferredServerActionReference({\n allowedActions: options.serverActions?.allowedActions,\n appDir: options.appDir,\n exportName,\n moduleId,\n }) &&\n !isValidFormActionToken({\n csrfToken: stringFormValue(formData.get(formCsrfFieldName)),\n exportName,\n moduleId,\n nonce,\n token: stringFormValue(formData.get(formFieldActionToken)),\n })\n ) {\n return jsonResponse({ ok: false, error: \"Unknown server action.\" }, 404);\n }\n\n const nonceResponse = validateFormNonce(\n formData,\n options.serverActions?.replayStore ?? usedFormActionNonces,\n );\n\n if (nonceResponse !== undefined) {\n return nonceResponse;\n }\n\n let registry: ServerActionRegistry;\n try {\n registry = await loadServerActionRegistry({\n appDir: options.appDir,\n cacheVersion: options.serverActionCacheVersion,\n importPolicy: options.importPolicy,\n });\n } catch (error) {\n return jsonResponse(\n { ok: false, error: error instanceof Error ? error.message : String(error) },\n 500,\n );\n }\n\n const action = registry[`${moduleId}#${exportName}`];\n\n if (typeof action !== \"function\") {\n return jsonResponse({ ok: false, error: \"Unknown server action.\" }, 404);\n }\n\n const actionFormData = cleanActionFormData(formData);\n const authorizationResponse = await authorizeFormAction({\n args: [actionFormData],\n authorize: options.serverActions?.authorize,\n exportName,\n moduleId,\n request: options.request,\n });\n\n if (authorizationResponse !== undefined) {\n return authorizationResponse;\n }\n\n try {\n const value = await action(actionFormData, createServerActionContext(options.request));\n\n if (value instanceof Response) {\n return value;\n }\n\n if (value === undefined || value === null) {\n return redirectToFormReferer(options.request);\n }\n\n return jsonResponse({ ok: true, value }, 200);\n } catch (error) {\n return jsonResponse(\n { ok: false, error: error instanceof Error ? error.message : String(error) },\n 500,\n );\n }\n}\n\nfunction createServerActionContext(request: Request): ServerActionContext {\n const clientIp = clientIpFromRequest(request);\n\n return {\n ...(clientIp === undefined ? {} : { clientIp }),\n cookies: cookies(request),\n headers: request.headers,\n request,\n };\n}\n\nfunction clientIpFromRequest(request: Request): string | undefined {\n const forwarded = request.headers.get(\"x-forwarded-for\")?.split(\",\")[0]?.trim();\n\n if (forwarded !== undefined && forwarded !== \"\") {\n return forwarded;\n }\n\n const realIp = request.headers.get(\"x-real-ip\")?.trim();\n return realIp === \"\" ? undefined : realIp;\n}\n\nfunction validateServerActionBodySize(\n request: Request,\n maxBodyBytes: number,\n): Response | undefined {\n if (!Number.isFinite(maxBodyBytes) || maxBodyBytes < 0) {\n return undefined;\n }\n\n const contentLength = request.headers.get(\"content-length\");\n if (contentLength === null) {\n return undefined;\n }\n\n const bytes = Number(contentLength);\n if (!Number.isFinite(bytes) || bytes < 0) {\n return jsonResponse({ ok: false, error: \"Invalid Content-Length header.\" }, 400);\n }\n\n if (bytes > maxBodyBytes) {\n return jsonResponse({ ok: false, error: \"Server action request body is too large.\" }, 413);\n }\n\n return undefined;\n}\n\nfunction validateServerActionFormFieldCount(\n formData: FormData,\n maxFormFields: number,\n): Response | undefined {\n if (!Number.isFinite(maxFormFields) || maxFormFields < 0) {\n return undefined;\n }\n\n let count = 0;\n for (const _ of formData.keys()) {\n count += 1;\n if (count > maxFormFields) {\n return jsonResponse({\n ok: false,\n error: \"Server action form field count is too large.\",\n }, 413);\n }\n }\n\n return undefined;\n}\n\nfunction redirectToFormReferer(request: Request): Response {\n return new Response(null, {\n status: 303,\n headers: {\n location: sameOriginRefererPath(request) ?? \"/\",\n },\n });\n}\n\nasync function renderSingleFlightActionResponse(options: {\n render:\n | ((options: {\n path: string;\n request: Request;\n revalidatedPaths: readonly string[];\n }) => Promise<Response | undefined>)\n | undefined;\n request: Request;\n response: Response;\n revalidatedPaths: readonly string[];\n}): Promise<Response | undefined> {\n if (\n options.render === undefined ||\n options.revalidatedPaths.length === 0 ||\n options.request.headers.get(\"x-mreact-action-single-flight\") !== \"1\" ||\n !isFormActionRedirectResponse(options.response)\n ) {\n return undefined;\n }\n\n const path = sameOriginResponseLocationPath(options.request, options.response);\n\n if (path === undefined || !options.revalidatedPaths.includes(normalizeActionPath(path))) {\n return undefined;\n }\n\n const rendered = await options.render({\n path,\n request: options.request,\n revalidatedPaths: options.revalidatedPaths,\n });\n\n if (rendered === undefined) {\n return undefined;\n }\n\n rendered.headers.set(\"x-mreact-action-single-flight\", \"1\");\n return rendered;\n}\n\nfunction isFormActionRedirectResponse(response: Response): boolean {\n return response.status >= 300 && response.status < 400 && response.headers.has(\"location\");\n}\n\nfunction sameOriginResponseLocationPath(request: Request, response: Response): string | undefined {\n const location = response.headers.get(\"location\");\n\n if (location === null) {\n return undefined;\n }\n\n try {\n const requestUrl = new URL(request.url);\n const locationUrl = new URL(location, requestUrl);\n\n return locationUrl.origin === requestUrl.origin\n ? `${locationUrl.pathname}${locationUrl.search}`\n : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction sameOriginRefererPath(request: Request): string | undefined {\n const referer = request.headers.get(\"referer\");\n\n if (referer === null) {\n return undefined;\n }\n\n try {\n const requestUrl = new URL(request.url);\n const refererUrl = new URL(referer, requestUrl);\n\n return refererUrl.origin === requestUrl.origin\n ? `${refererUrl.pathname}${refererUrl.search}`\n : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeActionPath(path: string): string {\n const pathname = path.startsWith(\"/\") ? path : `/${path}`;\n const withoutTrailing = pathname.length > 1 ? pathname.replace(/\\/+$/, \"\") : pathname;\n\n return withoutTrailing === \"\" ? \"/\" : withoutTrailing;\n}\n\nfunction withRevalidationHeader(response: Response, paths: string[]): Response {\n if (paths.length > 0) {\n response.headers.set(\"x-mreact-revalidate\", paths.join(\",\"));\n }\n\n return response;\n}\n\nasync function authorizeFormAction(options: {\n args: unknown[];\n authorize?: ServerActionHandlerOptions[\"authorize\"];\n exportName: string;\n moduleId: string;\n request: Request;\n}): Promise<Response | undefined> {\n const reference: ServerActionRequestReference = {\n exportName: options.exportName,\n moduleId: options.moduleId,\n };\n const authorizationResult = await options.authorize?.(options.request, reference, options.args);\n\n return authorizationResult !== undefined && authorizationResult !== true\n ? jsonResponse(\n {\n ok: false,\n error: authorizationError(authorizationResult),\n },\n 403,\n )\n : undefined;\n}\n\nfunction authorizationError(result: Exclude<ServerActionValidationResult, true>): string {\n return typeof result === \"string\" ? result : \"Server action not authorized.\";\n}\n\nfunction jsonAllowedServerActions(\n allowedActions: readonly AppRouterAllowedServerAction[],\n): ServerActionRequestReference[] {\n return allowedActions\n .filter((reference) => reference.inferred !== true)\n .map((reference) => ({\n exportName: reference.exportName,\n moduleId: reference.moduleId,\n }));\n}\n\nfunction jsonServerActionRegistry(options: {\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined;\n appDir: string;\n registry: ServerActionRegistry;\n}): ServerActionRegistry {\n const inferredKeys = new Set<string>();\n\n for (const reference of inferredServerActionReferencesForApp(options.appDir).values()) {\n inferredKeys.add(serverActionKey(reference));\n }\n\n if (Array.isArray(options.allowedActions)) {\n for (const reference of options.allowedActions) {\n if (reference.inferred === true) {\n inferredKeys.add(serverActionKey(reference));\n }\n }\n }\n\n if (inferredKeys.size === 0) {\n return options.registry;\n }\n\n const registry: ServerActionRegistry = {};\n\n for (const [key, value] of Object.entries(options.registry)) {\n if (!inferredKeys.has(key)) {\n registry[key] = value;\n }\n }\n\n return registry;\n}\n\nfunction serverActionKey(reference: ServerActionRequestReference): string {\n return `${reference.moduleId}#${reference.exportName}`;\n}\n\nfunction isAllowedServerAction(\n reference: ServerActionRequestReference,\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined,\n): boolean {\n if (allowedActions === undefined) {\n warnIfUnrestrictedServerActions(allowedActions);\n return true;\n }\n\n if (allowedActions === \"any\") {\n return true;\n }\n\n return allowedActions.some(\n (allowed) =>\n allowed.moduleId === reference.moduleId && allowed.exportName === reference.exportName,\n );\n}\n\nfunction warnIfUnrestrictedServerActions(\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined,\n): void {\n if (\n allowedActions !== undefined ||\n !isProductionEnvironment() ||\n warnedUnrestrictedServerActions\n ) {\n return;\n }\n\n warnedUnrestrictedServerActions = true;\n console.warn(\n \"[mreact] Server actions are running without an allowedActions manifest. Built app-router deployments generate this manifest automatically; direct production integrations should pass serverActions.allowedActions.\",\n );\n}\n\nfunction validateServerActionManifest(\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined,\n): Response | undefined {\n if (allowedActions !== undefined || !isProductionEnvironment()) {\n return undefined;\n }\n\n return jsonResponse({ ok: false, error: \"Server action manifest required.\" }, 403);\n}\n\nfunction lowerFormActions(options: {\n actionNonce: string;\n code: string;\n csrfToken: string;\n references: Map<string, ActionReference>;\n}): string {\n let code = options.code;\n const formReferences = collectFormActionExpressionReferences({ code: options.code });\n\n for (const formReference of [...formReferences].reverse()) {\n const reference = options.references.get(formActionOccurrenceKey(formReference));\n\n if (reference === undefined) {\n continue;\n }\n\n const opening = code.slice(formReference.start, formReference.end);\n const loweredOpening = lowerFormActionOpening({\n actionNonce: options.actionNonce,\n csrfToken: options.csrfToken,\n opening,\n reference,\n referenceName: formReference.expression,\n });\n\n if (loweredOpening === opening) {\n continue;\n }\n\n code = `${code.slice(0, formReference.start)}${loweredOpening}${code.slice(formReference.end)}`;\n }\n\n return code;\n}\n\nfunction formActionOccurrenceKey(reference: {\n end: number;\n expression: string;\n expressionEnd: number;\n expressionStart: number;\n start: number;\n}): string {\n return [\n reference.start,\n reference.end,\n reference.expressionStart,\n reference.expressionEnd,\n reference.expression,\n ].join(\":\");\n}\n\nfunction formActionSourceHash(code: string): string {\n return createHash(\"sha256\").update(code).digest(\"base64url\");\n}\n\nfunction lowerFormActionOpening(options: {\n actionNonce: string;\n csrfToken: string;\n opening: string;\n reference: ActionReference;\n referenceName: string;\n}): string {\n const actionPattern = new RegExp(\n `^(?<prefix><form\\\\b[\\\\s\\\\S]*?)\\\\saction=\\\\{${escapeRegExp(options.referenceName)}\\\\}(?<suffix>[\\\\s\\\\S]*?)>$`,\n \"u\",\n );\n const match = options.opening.match(actionPattern);\n const prefix = match?.groups?.prefix;\n const suffix = match?.groups?.suffix;\n\n if (prefix === undefined || suffix === undefined) {\n return options.opening;\n }\n\n const attrs = `${prefix.slice(\"<form\".length)}${suffix}`.replace(\n /\\s+method=(?:\"[^\"]*\"|'[^']*'|\\{[^}]*\\})/g,\n \"\",\n );\n const hidden = [\n hiddenInput(formFieldModuleId, options.reference.moduleId),\n hiddenInput(formFieldExportName, options.reference.exportName),\n hiddenInput(formCsrfFieldName, options.csrfToken),\n hiddenInput(formFieldNonce, options.actionNonce),\n hiddenInput(\n formFieldActionToken,\n formActionToken({\n csrfToken: options.csrfToken,\n exportName: options.reference.exportName,\n moduleId: options.reference.moduleId,\n nonce: options.actionNonce,\n }),\n ),\n ].join(\"\");\n\n return `<form${attrs} method=\"post\" action=\"/_mreact/actions\">${hidden}`;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction hiddenInput(name: string, value: string): string {\n return `<input type=\"hidden\" name=\"${escapeAttribute(name)}\" value=\"${escapeAttribute(value)}\" />`;\n}\n\nasync function collectImportedServerActions(options: {\n appDir: string;\n code: string;\n pageFile: string;\n}): Promise<{\n diagnostics: ServerActionInferenceDiagnostic[];\n references: Map<string, ActionReference>;\n}> {\n return await collectRuntimeInferredServerActions({\n appDir: options.appDir,\n code: options.code,\n fileSystem: {\n isUseServerFile,\n resolveSourceFile,\n },\n pageFile: options.pageFile,\n });\n}\n\nfunction isInferredServerActionReference(options: {\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined;\n appDir: string;\n exportName: string;\n moduleId: string;\n}): boolean {\n if (\n Array.isArray(options.allowedActions) &&\n options.allowedActions.some(\n (allowed) =>\n allowed.inferred === true &&\n allowed.moduleId === options.moduleId &&\n allowed.exportName === options.exportName,\n )\n ) {\n return true;\n }\n\n return inferredServerActionReferencesForApp(options.appDir).has(\n `${options.moduleId}#${options.exportName}`,\n );\n}\n\nfunction formActionToken(options: {\n csrfToken: string;\n exportName: string;\n moduleId: string;\n nonce: string;\n}): string {\n return createHmac(\"sha256\", actionTokenSecret)\n .update(options.moduleId)\n .update(\"\\0\")\n .update(options.exportName)\n .update(\"\\0\")\n .update(options.csrfToken)\n .update(\"\\0\")\n .update(options.nonce)\n .digest(\"base64url\");\n}\n\nfunction isValidFormActionToken(options: {\n csrfToken: string | undefined;\n exportName: string;\n moduleId: string;\n nonce: string;\n token: string | undefined;\n}): boolean {\n if (options.csrfToken === undefined || options.token === undefined) {\n return false;\n }\n\n const expected = Buffer.from(\n formActionToken({\n csrfToken: options.csrfToken,\n exportName: options.exportName,\n moduleId: options.moduleId,\n nonce: options.nonce,\n }),\n );\n const actual = Buffer.from(options.token);\n\n return actual.length === expected.length && timingSafeEqual(actual, expected);\n}\n\nfunction replaceInferredServerActionReferences(\n appDir: string,\n pageFile: string,\n references: ReadonlyMap<string, ActionReference>,\n): void {\n const nextReferences = new Map(\n Array.from(references.values())\n .filter((reference) => reference.inferred)\n .map((reference) => [`${reference.moduleId}#${reference.exportName}`, reference]),\n );\n let appReferencesByPage = inferredServerActionReferences.get(appDir);\n const previousReferences = appReferencesByPage?.get(pageFile) ?? new Map();\n const changed = !sameActionReferenceKeys(previousReferences, nextReferences);\n\n if (!changed) {\n return;\n }\n\n if (nextReferences.size === 0) {\n appReferencesByPage?.delete(pageFile);\n if (appReferencesByPage?.size === 0) {\n inferredServerActionReferences.delete(appDir);\n }\n } else {\n if (appReferencesByPage === undefined) {\n appReferencesByPage = new Map();\n inferredServerActionReferences.set(appDir, appReferencesByPage);\n }\n appReferencesByPage.set(pageFile, nextReferences);\n }\n\n clearServerActionRegistryCacheForApp(appDir);\n}\n\n// Cache the (expensive) collect+bundle+evaluate work keyed by appDir +\n// caller-supplied version. Production callers pass the build-time hash\n// (serverModuleCacheVersion) so the registry is reused for the lifetime\n// of one deployment. Dev callers omit the version; the entry is then\n// keyed on \"dev\" so the work happens once per process — restarts handle\n// invalidation. Concurrent callers share a single in-flight promise.\nconst serverActionRegistryCache = new Map<string, Promise<ServerActionRegistry>>();\n\nasync function loadServerActionRegistry(options: {\n appDir: string;\n cacheVersion?: string | undefined;\n importPolicy?: AppRouterImportPolicy | undefined;\n}): Promise<ServerActionRegistry> {\n const cacheKey = `${options.appDir}::${options.cacheVersion ?? \"dev\"}`;\n const cached = serverActionRegistryCache.get(cacheKey);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const pending = buildServerActionRegistry(options).catch((error) => {\n // Drop the failed promise so a retry can re-run the load.\n serverActionRegistryCache.delete(cacheKey);\n throw error;\n });\n serverActionRegistryCache.set(cacheKey, pending);\n return pending;\n}\n\nasync function buildServerActionRegistry(options: {\n appDir: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n}): Promise<ServerActionRegistry> {\n const files = await collectFiles(options.appDir);\n const registry: ServerActionRegistry = {};\n const inferredReferences = inferredServerActionReferencesForApp(options.appDir);\n\n for (const file of files) {\n const moduleId = moduleIdForFile(options.appDir, file);\n const inferredExportNames = inferredExportNamesForModule(inferredReferences, moduleId);\n const useServerFile = await isUseServerFile(file);\n\n if (!useServerFile && inferredExportNames.size === 0) {\n continue;\n }\n\n const module = await importServerActionModule({\n appDir: options.appDir,\n file,\n importPolicy: options.importPolicy,\n });\n\n for (const [exportName, value] of Object.entries(module)) {\n if (typeof value === \"function\" && (useServerFile || inferredExportNames.has(exportName))) {\n registry[`${moduleId}#${exportName}`] = value as (...args: unknown[]) => unknown;\n }\n }\n }\n\n return registry;\n}\n\n// Exposed for tests that need a clean slate between cases (in-process state).\nexport function __clearServerActionRegistryCache(): void {\n serverActionRegistryCache.clear();\n inferredServerActionReferences.clear();\n}\n\nfunction clearServerActionRegistryCacheForApp(appDir: string): void {\n const prefix = `${appDir}::`;\n\n for (const key of serverActionRegistryCache.keys()) {\n if (key.startsWith(prefix)) {\n serverActionRegistryCache.delete(key);\n }\n }\n}\n\nfunction sameActionReferenceKeys(\n left: ReadonlyMap<string, ActionReference>,\n right: ReadonlyMap<string, ActionReference>,\n): boolean {\n if (left.size !== right.size) {\n return false;\n }\n\n for (const key of left.keys()) {\n if (!right.has(key)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction inferredServerActionReferencesForApp(appDir: string): Map<string, ActionReference> {\n const references = new Map<string, ActionReference>();\n const appReferencesByPage = inferredServerActionReferences.get(appDir);\n\n if (appReferencesByPage === undefined) {\n return references;\n }\n\n for (const pageReferences of appReferencesByPage.values()) {\n for (const [key, reference] of pageReferences) {\n references.set(key, reference);\n }\n }\n\n return references;\n}\n\nfunction inferredExportNamesForModule(\n references: ReadonlyMap<string, ActionReference>,\n moduleId: string,\n): Set<string> {\n const names = new Set<string>();\n\n for (const reference of references.values()) {\n if (reference.moduleId === moduleId) {\n names.add(reference.exportName);\n }\n }\n\n return names;\n}\n\nasync function importServerActionModule(options: {\n appDir: string;\n file: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n}): Promise<Record<string, unknown>> {\n const bundled = await bundleRouterModule({\n code: `export * from ${JSON.stringify(options.file)};`,\n filename: options.file,\n platform: \"node\",\n plugins: [\n fileImportMetaUrlPlugin(),\n serverActionRuntimePlugin(),\n createAppRouterImportPolicyPlugin({\n appDir: options.appDir,\n importPolicy: options.importPolicy,\n label: \"Server action\",\n }),\n ],\n });\n const code = bundled.code;\n\n if (code === undefined) {\n throw new Error(`Failed to compile server action module ${options.file}.`);\n }\n\n return importAppRouterSourceModule<Record<string, unknown>>({\n code,\n label: `server-action:${options.file}`,\n });\n}\n\nfunction serverActionRuntimePlugin() {\n const currentDir = dirname(fileURLToPath(import.meta.url));\n const cachePath = join(currentDir, currentDir.endsWith(`${sep}dist`) ? \"cache.js\" : \"cache.ts\");\n\n return {\n name: \"mreact-router-server-action-runtime\",\n setup(buildApi: RouterCompatBuildApi) {\n buildApi.onResolve({ filter: /^@reckona\\/mreact-router$/ }, () => ({\n namespace: \"mreact-router-server-api\",\n path: \"index\",\n }));\n buildApi.onLoad({ filter: /^index$/, namespace: \"mreact-router-server-api\" }, () => ({\n contents: `export { revalidatePath } from ${JSON.stringify(cachePath)};`,\n loader: \"ts\",\n resolveDir: dirname(cachePath),\n }));\n },\n };\n}\n\nasync function collectFiles(directory: string): Promise<string[]> {\n const entries = await readdir(directory, { withFileTypes: true });\n const files: string[] = [];\n\n for (const entry of entries) {\n const path = join(directory, entry.name);\n\n if (entry.isDirectory()) {\n files.push(...(await collectFiles(path)));\n continue;\n }\n\n if (entry.isFile() && /\\.(?:mreact\\.tsx|tsx|ts)$/.test(entry.name)) {\n files.push(path);\n }\n }\n\n return files;\n}\n\nasync function resolveSourceFile(directory: string, source: string): Promise<string | undefined> {\n const base = join(directory, source);\n const tsEsmBase = /\\.[cm]?js$/.test(base) ? base.replace(/\\.[cm]?js$/, \"\") : undefined;\n const candidates = [\n base,\n ...(tsEsmBase === undefined\n ? []\n : [\n `${tsEsmBase}.ts`,\n `${tsEsmBase}.tsx`,\n `${tsEsmBase}.mreact.tsx`,\n join(tsEsmBase, \"index.ts\"),\n join(tsEsmBase, \"index.tsx\"),\n ]),\n `${base}.ts`,\n `${base}.tsx`,\n `${base}.mreact.tsx`,\n join(base, \"index.ts\"),\n join(base, \"index.tsx\"),\n ];\n\n for (const candidate of candidates) {\n try {\n await access(candidate);\n return candidate;\n } catch {\n // Try the next candidate.\n }\n }\n\n return undefined;\n}\n\nasync function isUseServerFile(file: string): Promise<boolean> {\n const code = await readFile(file, \"utf8\");\n\n return hasModuleDirective({ code, directive: \"use server\", filename: file });\n}\n\nfunction moduleIdForFile(appDir: string, file: string): string {\n return relative(appDir, file).split(sep).join(\"/\");\n}\n\nfunction validateServerActionRequestOrigin(request: Request): Response | undefined {\n if (!isProductionEnvironment()) {\n return undefined;\n }\n\n const expectedOrigin = new URL(request.url).origin;\n const origin = request.headers.get(\"origin\");\n\n if (origin !== null) {\n return origin === expectedOrigin\n ? undefined\n : jsonResponse({ ok: false, error: \"Origin not allowed.\" }, 403);\n }\n\n const referer = request.headers.get(\"referer\");\n\n if (referer === null) {\n return jsonResponse({ ok: false, error: \"Origin not allowed.\" }, 403);\n }\n\n try {\n return new URL(referer).origin === expectedOrigin\n ? undefined\n : jsonResponse({ ok: false, error: \"Origin not allowed.\" }, 403);\n } catch {\n return jsonResponse({ ok: false, error: \"Origin not allowed.\" }, 403);\n }\n}\n\nfunction validateFormNonce(\n formData: FormData,\n replayStore: ServerActionReplayStore,\n): Response | undefined {\n const nonce = stringFormValue(formData.get(formFieldNonce));\n\n if (nonce === undefined || nonce.length === 0) {\n return jsonResponse({ ok: false, error: \"Missing server action nonce.\" }, 400);\n }\n\n if (replayStore.has(nonce)) {\n return jsonResponse({ ok: false, error: \"Server action nonce was already used.\" }, 409);\n }\n\n replayStore.add(nonce);\n return undefined;\n}\n\nfunction cleanActionFormData(formData: FormData): FormData {\n const cleaned = new FormData();\n\n for (const [name, value] of formData.entries()) {\n if (\n name !== formFieldModuleId &&\n name !== formFieldExportName &&\n name !== formCsrfFieldName &&\n name !== formFieldNonce &&\n name !== formFieldActionToken\n ) {\n cleaned.append(name, value);\n }\n }\n\n return cleaned;\n}\n\nfunction stringFormValue(value: FormDataEntryValue | null): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction jsonResponse(payload: unknown, status: number): Response {\n return new Response(JSON.stringify(payload), {\n headers: { \"content-type\": \"application/json; charset=utf-8\" },\n status,\n });\n}\n\nfunction escapeAttribute(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll('\"', \""\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,qCAAqC,EACrC,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,yBAAyB,GAM1B,MAAM,w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CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from \"node:crypto\";\nimport { access, readdir, readFile } from \"node:fs/promises\";\nimport { dirname, join, relative, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n collectFormActionExpressionReferences,\n hasModuleDirective,\n} from \"@reckona/mreact-compiler\";\nimport {\n createServerActionHandler,\n type ServerActionHandlerOptions,\n type ServerActionRegistry,\n type ServerActionReplayStore,\n type ServerActionRequestReference,\n type ServerActionValidationResult,\n} from \"@reckona/mreact-server\";\nimport { bundleRouterModule, type RouterCompatBuildApi } from \"./bundle-pipeline.js\";\nimport { type AppRouterCache, withRouteCacheContext } from \"./cache.js\";\nimport { fileImportMetaUrlPlugin, importAppRouterSourceModule } from \"./module-runner.js\";\nimport { createAppRouterImportPolicyPlugin, type AppRouterImportPolicy } from \"./import-policy.js\";\nimport { cookies, type RequestCookies } from \"./navigation.js\";\nexport {\n createFormCsrfToken,\n formCsrfCookie,\n formCsrfFieldName,\n serverActionCookie,\n validateFormCsrf,\n} from \"./csrf.js\";\nimport {\n formCsrfFieldName,\n readExistingFormCsrfToken,\n validateFormCsrf,\n} from \"./csrf.js\";\nimport {\n collectRuntimeInferredServerActions,\n type ServerActionInferenceDiagnostic,\n} from \"./server-action-inference.js\";\n\nfunction isProductionEnvironment(): boolean {\n return process.env.NODE_ENV === \"production\";\n}\nconst formFieldModuleId = \"__mreact_module_id\";\nconst formFieldExportName = \"__mreact_export_name\";\nconst formFieldNonce = \"__mreact_action_nonce\";\nconst formFieldActionToken = \"__mreact_action_token\";\nconst actionTokenSecret = process.env.MREACT_SERVER_ACTION_SECRET ?? defaultActionTokenSecret();\n// Bounded default replay store for form-action nonces. The previous\n// implementation was an unbounded Set that grew with every successful\n// submission (Issue 069). Production callers should still pass a shared\n// store (Redis / KV) via `serverActions.replayStore` for multi-instance\n// deployments -- this default only guarantees replay protection within\n// a single process and is the safe fallback for dev / single-node setups.\n//\n// Retention model:\n// - TTL: 10 minutes. Form nonces are minted at SSR time and the user\n// has to submit before the cookie's SameSite=Lax window anyway; this\n// is generous for any realistic submit cadence.\n// - Max size: 50_000 entries. Old entries are evicted FIFO once the cap\n// is reached so a flood cannot trigger OOM.\n//\n// Both bounds are intentional defaults -- tight enough that a single\n// process cannot leak unbounded RSS, loose enough that legitimate\n// traffic does not trip false-positive 409s.\nconst DEFAULT_REPLAY_TTL_MS = 10 * 60 * 1000;\nconst DEFAULT_REPLAY_MAX_ENTRIES = 50_000;\nconst DEFAULT_ACTION_BODY_MAX_BYTES = 10 * 1024 * 1024;\nconst DEFAULT_ACTION_FORM_MAX_FIELDS = 1_000;\nlet warnedUnrestrictedServerActions = false;\n\n/**\n * Request context passed to authorized server actions.\n *\n * It exposes normalized cookies, headers, the original `Request`, and an optional client IP so authorization hooks can make request-aware decisions.\n */\nexport interface ServerActionContext {\n clientIp?: string | undefined;\n cookies: RequestCookies;\n headers: Headers;\n request: Request;\n}\n\nfunction defaultActionTokenSecret(): string {\n if (isProductionEnvironment()) {\n console.warn(\n \"mreact-router: MREACT_SERVER_ACTION_SECRET is not set. Inferred server action tokens use a per-process secret and may fail across multiple production instances.\",\n );\n }\n\n return randomBytes(32).toString(\"base64url\");\n}\n\nclass BoundedReplayStore {\n private readonly entries = new Map<string, number>();\n\n constructor(\n private readonly ttlMs: number,\n private readonly maxEntries: number,\n ) {}\n\n has(value: string): boolean {\n const expiresAt = this.entries.get(value);\n if (expiresAt === undefined) return false;\n if (expiresAt < Date.now()) {\n this.entries.delete(value);\n return false;\n }\n return true;\n }\n\n add(value: string): void {\n const now = Date.now();\n if (this.entries.size >= this.maxEntries) {\n const oldest = this.entries.entries().next().value;\n if (oldest !== undefined) {\n const [key, expiresAt] = oldest;\n this.entries.delete(key);\n if (expiresAt < now) {\n while (this.entries.size >= this.maxEntries) {\n const nextOldest = this.entries.entries().next().value;\n if (nextOldest === undefined || nextOldest[1] >= now) {\n break;\n }\n this.entries.delete(nextOldest[0]);\n }\n }\n }\n }\n this.entries.set(value, now + this.ttlMs);\n }\n\n // Exposed for tests; not part of the ServerActionReplayStore interface.\n size(): number {\n return this.entries.size;\n }\n}\n\nconst usedFormActionNonces = new BoundedReplayStore(\n DEFAULT_REPLAY_TTL_MS,\n DEFAULT_REPLAY_MAX_ENTRIES,\n);\n\n// Test helpers: drop all entries between cases / expose the bounded store\n// so tests can drive its eviction semantics directly. Not part of the\n// public surface (prefixed with `__`).\nexport function __clearDefaultReplayStore(): void {\n (usedFormActionNonces as unknown as { entries: Map<string, number> }).entries.clear();\n}\n\nexport function __readDefaultReplayStore(): BoundedReplayStore {\n return usedFormActionNonces;\n}\n\n/**\n * Configures app-router server action dispatch, authorization, body limits, and replay protection.\n *\n * Production multi-instance deployments should provide a shared `replayStore` and a stable `MREACT_SERVER_ACTION_SECRET`.\n */\nexport interface AppRouterServerActionOptions {\n allowedActions?: readonly AppRouterAllowedServerAction[] | \"any\" | undefined;\n authorize?: ServerActionHandlerOptions[\"authorize\"] | undefined;\n maxBodyBytes?: number | undefined;\n maxFormFields?: number | undefined;\n replayStore?: ServerActionReplayStore | undefined;\n}\n\nexport interface AppRouterAllowedServerAction extends ServerActionRequestReference {\n inferred?: boolean | undefined;\n}\n\nexport interface PreparedRouteActions {\n actionNonce?: string;\n code: string;\n csrfToken?: string;\n diagnostics?: ServerActionInferenceDiagnostic[] | undefined;\n // True when the cookie should be (re)set on the response. False means\n // the incoming request already carried a valid CSRF cookie that the\n // render is reusing -- skipping Set-Cookie avoids cookie thrash across\n // concurrent tabs (Issue 070).\n csrfTokenIsNew?: boolean;\n hasFormActions: boolean;\n}\n\ninterface ActionReference {\n exportName: string;\n inferred: boolean;\n moduleId: string;\n}\n\nexport interface PreparedFormActionReference {\n end: number;\n expression: string;\n expressionEnd: number;\n expressionStart: number;\n exportName: string;\n inferred: boolean;\n moduleId: string;\n sourceHash: string;\n start: number;\n}\n\nconst inferredServerActionReferences = new Map<string, Map<string, Map<string, ActionReference>>>();\n\nexport async function prepareRouteServerActions(options: {\n appDir: string;\n code: string;\n formActionReferences?: readonly PreparedFormActionReference[] | undefined;\n pageFile: string;\n request?: Request | undefined;\n}): Promise<PreparedRouteActions> {\n if (options.formActionReferences !== undefined && options.formActionReferences.length === 0) {\n replaceInferredServerActionReferences(options.appDir, options.pageFile, new Map());\n return { code: options.code, hasFormActions: false };\n }\n\n if (!hasFormActionCandidate(options.code, options.pageFile)) {\n replaceInferredServerActionReferences(options.appDir, options.pageFile, new Map());\n return { code: options.code, hasFormActions: false };\n }\n\n const inference =\n options.formActionReferences === undefined\n ? await collectImportedServerActions(options)\n : {\n diagnostics: [],\n references: formActionReferenceMap(options.code, options.formActionReferences),\n };\n const { diagnostics, references } = inference;\n\n if (references.size === 0) {\n replaceInferredServerActionReferences(options.appDir, options.pageFile, new Map());\n return diagnostics.length === 0\n ? { code: options.code, hasFormActions: false }\n : { code: options.code, diagnostics, hasFormActions: false };\n }\n\n // Reuse the existing CSRF token when the browser already sent one.\n // Rotating the cookie on every render (Issue 070) broke concurrent\n // forms because the older tab's hidden input no longer matched the\n // cookie value. The actionNonce stays per-render -- that is the field\n // tied to a specific submission via replay protection.\n const existingToken = readExistingFormCsrfToken(options.request);\n const csrfToken = existingToken ?? randomUUID();\n const csrfTokenIsNew = existingToken === undefined;\n const actionNonce = randomUUID();\n const lowered = lowerFormActions({\n actionNonce,\n code: options.code,\n csrfToken,\n references,\n });\n\n if (lowered === options.code) {\n replaceInferredServerActionReferences(options.appDir, options.pageFile, new Map());\n return diagnostics.length === 0\n ? { code: options.code, hasFormActions: false }\n : { code: options.code, diagnostics, hasFormActions: false };\n }\n\n replaceInferredServerActionReferences(options.appDir, options.pageFile, references);\n\n return {\n actionNonce,\n code: lowered,\n csrfToken,\n csrfTokenIsNew,\n diagnostics,\n hasFormActions: true,\n };\n}\n\nfunction formActionReferenceMap(\n code: string,\n references: readonly PreparedFormActionReference[],\n): Map<string, ActionReference> {\n const sourceHash = formActionSourceHash(code);\n\n return new Map(\n references\n .filter((reference) => reference.sourceHash === sourceHash)\n .map((reference) => [\n formActionOccurrenceKey(reference),\n {\n exportName: reference.exportName,\n inferred: reference.inferred,\n moduleId: reference.moduleId,\n },\n ]),\n );\n}\n\nfunction hasFormActionCandidate(code: string, filename: string): boolean {\n return collectFormActionExpressionReferences({ code, filename }).length > 0;\n}\n\nexport async function dispatchServerActionRequest(options: {\n appDir: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n request: Request;\n renderSingleFlightNavigation?: ((options: {\n path: string;\n request: Request;\n revalidatedPaths: readonly string[];\n }) => Promise<Response | undefined>) | undefined;\n routeCache?: AppRouterCache | undefined;\n serverActionCacheVersion?: string | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n}): Promise<Response> {\n const { revalidatedPaths, value } = await withRouteCacheContext(options.routeCache, () =>\n dispatchServerActionRequestWithoutCacheContext(options),\n );\n const singleFlight = await renderSingleFlightActionResponse({\n render: options.renderSingleFlightNavigation,\n request: options.request,\n response: value,\n revalidatedPaths,\n });\n\n return withRevalidationHeader(singleFlight ?? value, revalidatedPaths);\n}\n\nasync function dispatchServerActionRequestWithoutCacheContext(options: {\n appDir: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n request: Request;\n serverActionCacheVersion?: string | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n}): Promise<Response> {\n // Validate everything we can statically before touching the filesystem\n // / bundler. A flood of malformed POSTs must not pay the registry-load\n // cost (Issue 067).\n if (options.request.method !== \"POST\") {\n return jsonResponse({ ok: false, error: \"Method not allowed.\" }, 405);\n }\n\n const bodySizeResponse = validateServerActionBodySize(\n options.request,\n options.serverActions?.maxBodyBytes ?? DEFAULT_ACTION_BODY_MAX_BYTES,\n );\n if (bodySizeResponse !== undefined) {\n return bodySizeResponse;\n }\n\n const originResponse = validateServerActionRequestOrigin(options.request);\n if (originResponse !== undefined) {\n return originResponse;\n }\n\n const contentType = options.request.headers.get(\"content-type\") ?? \"\";\n\n if (contentType.includes(\"application/json\")) {\n const manifestResponse = validateServerActionManifest(options.serverActions?.allowedActions);\n if (manifestResponse !== undefined) {\n return manifestResponse;\n }\n\n // JSON path delegates CSRF/replay to createServerActionHandler. The\n // registry is still needed here, but the handler short-circuits on\n // CSRF mismatch before invoking the action.\n let registry: ServerActionRegistry;\n try {\n registry = await loadServerActionRegistry({\n appDir: options.appDir,\n cacheVersion: options.serverActionCacheVersion,\n importPolicy: options.importPolicy,\n });\n } catch (error) {\n return jsonResponse(\n { ok: false, error: error instanceof Error ? error.message : String(error) },\n 500,\n );\n }\n\n const replayStore = options.serverActions?.replayStore ?? usedFormActionNonces;\n const handle = createServerActionHandler(jsonServerActionRegistry({\n allowedActions: options.serverActions?.allowedActions,\n appDir: options.appDir,\n registry,\n }), {\n ...(options.serverActions?.authorize === undefined\n ? {}\n : { authorize: options.serverActions.authorize }),\n ...(options.serverActions?.allowedActions === undefined ||\n options.serverActions.allowedActions === \"any\"\n ? {}\n : { allowedActions: jsonAllowedServerActions(options.serverActions.allowedActions) }),\n csrf: true,\n maxBodyBytes: options.serverActions?.maxBodyBytes ?? DEFAULT_ACTION_BODY_MAX_BYTES,\n replayProtection: { seen: replayStore },\n });\n\n return handle(options.request);\n }\n\n if (\n !contentType.includes(\"application/x-www-form-urlencoded\") &&\n !contentType.includes(\"multipart/form-data\")\n ) {\n return jsonResponse({ ok: false, error: \"Unsupported server action content type.\" }, 415);\n }\n\n const manifestResponse = validateServerActionManifest(options.serverActions?.allowedActions);\n if (manifestResponse !== undefined) {\n return manifestResponse;\n }\n\n const formData = await options.request.formData();\n const fieldCountResponse = validateServerActionFormFieldCount(\n formData,\n options.serverActions?.maxFormFields ?? DEFAULT_ACTION_FORM_MAX_FIELDS,\n );\n\n if (fieldCountResponse !== undefined) {\n return fieldCountResponse;\n }\n\n const csrfResponse = validateFormCsrf(options.request, formData);\n\n if (csrfResponse !== undefined) {\n return csrfResponse;\n }\n\n const moduleId = stringFormValue(formData.get(formFieldModuleId));\n const exportName = stringFormValue(formData.get(formFieldExportName));\n const nonce = stringFormValue(formData.get(formFieldNonce));\n\n if (moduleId === undefined || exportName === undefined || nonce === undefined) {\n return jsonResponse({ ok: false, error: \"Invalid server action reference.\" }, 400);\n }\n\n if (!isAllowedServerAction({ moduleId, exportName }, options.serverActions?.allowedActions)) {\n return jsonResponse({ ok: false, error: \"Unknown server action.\" }, 404);\n }\n\n if (\n isInferredServerActionReference({\n allowedActions: options.serverActions?.allowedActions,\n appDir: options.appDir,\n exportName,\n moduleId,\n }) &&\n !isValidFormActionToken({\n csrfToken: stringFormValue(formData.get(formCsrfFieldName)),\n exportName,\n moduleId,\n nonce,\n token: stringFormValue(formData.get(formFieldActionToken)),\n })\n ) {\n return jsonResponse({ ok: false, error: \"Unknown server action.\" }, 404);\n }\n\n const nonceResponse = validateFormNonce(\n formData,\n options.serverActions?.replayStore ?? usedFormActionNonces,\n );\n\n if (nonceResponse !== undefined) {\n return nonceResponse;\n }\n\n let registry: ServerActionRegistry;\n try {\n registry = await loadServerActionRegistry({\n appDir: options.appDir,\n cacheVersion: options.serverActionCacheVersion,\n importPolicy: options.importPolicy,\n });\n } catch (error) {\n return jsonResponse(\n { ok: false, error: error instanceof Error ? error.message : String(error) },\n 500,\n );\n }\n\n const action = registry[`${moduleId}#${exportName}`];\n\n if (typeof action !== \"function\") {\n return jsonResponse({ ok: false, error: \"Unknown server action.\" }, 404);\n }\n\n const actionFormData = cleanActionFormData(formData);\n const authorizationResponse = await authorizeFormAction({\n args: [actionFormData],\n authorize: options.serverActions?.authorize,\n exportName,\n moduleId,\n request: options.request,\n });\n\n if (authorizationResponse !== undefined) {\n return authorizationResponse;\n }\n\n try {\n const value = await action(actionFormData, createServerActionContext(options.request));\n\n if (value instanceof Response) {\n return value;\n }\n\n if (value === undefined || value === null) {\n return redirectToFormReferer(options.request);\n }\n\n return jsonResponse({ ok: true, value }, 200);\n } catch (error) {\n return jsonResponse(\n { ok: false, error: error instanceof Error ? error.message : String(error) },\n 500,\n );\n }\n}\n\nfunction createServerActionContext(request: Request): ServerActionContext {\n const clientIp = clientIpFromRequest(request);\n\n return {\n ...(clientIp === undefined ? {} : { clientIp }),\n cookies: cookies(request),\n headers: request.headers,\n request,\n };\n}\n\nfunction clientIpFromRequest(request: Request): string | undefined {\n const forwarded = request.headers.get(\"x-forwarded-for\")?.split(\",\")[0]?.trim();\n\n if (forwarded !== undefined && forwarded !== \"\") {\n return forwarded;\n }\n\n const realIp = request.headers.get(\"x-real-ip\")?.trim();\n return realIp === \"\" ? undefined : realIp;\n}\n\nfunction validateServerActionBodySize(\n request: Request,\n maxBodyBytes: number,\n): Response | undefined {\n if (!Number.isFinite(maxBodyBytes) || maxBodyBytes < 0) {\n return undefined;\n }\n\n const contentLength = request.headers.get(\"content-length\");\n if (contentLength === null) {\n return undefined;\n }\n\n const bytes = Number(contentLength);\n if (!Number.isFinite(bytes) || bytes < 0) {\n return jsonResponse({ ok: false, error: \"Invalid Content-Length header.\" }, 400);\n }\n\n if (bytes > maxBodyBytes) {\n return jsonResponse({ ok: false, error: \"Server action request body is too large.\" }, 413);\n }\n\n return undefined;\n}\n\nfunction validateServerActionFormFieldCount(\n formData: FormData,\n maxFormFields: number,\n): Response | undefined {\n if (!Number.isFinite(maxFormFields) || maxFormFields < 0) {\n return undefined;\n }\n\n let count = 0;\n for (const _ of formData.keys()) {\n count += 1;\n if (count > maxFormFields) {\n return jsonResponse({\n ok: false,\n error: \"Server action form field count is too large.\",\n }, 413);\n }\n }\n\n return undefined;\n}\n\nfunction redirectToFormReferer(request: Request): Response {\n return new Response(null, {\n status: 303,\n headers: {\n location: sameOriginRefererPath(request) ?? \"/\",\n },\n });\n}\n\nasync function renderSingleFlightActionResponse(options: {\n render:\n | ((options: {\n path: string;\n request: Request;\n revalidatedPaths: readonly string[];\n }) => Promise<Response | undefined>)\n | undefined;\n request: Request;\n response: Response;\n revalidatedPaths: readonly string[];\n}): Promise<Response | undefined> {\n if (\n options.render === undefined ||\n options.revalidatedPaths.length === 0 ||\n options.request.headers.get(\"x-mreact-action-single-flight\") !== \"1\" ||\n !isFormActionRedirectResponse(options.response)\n ) {\n return undefined;\n }\n\n const path = sameOriginResponseLocationPath(options.request, options.response);\n\n if (path === undefined || !options.revalidatedPaths.includes(normalizeActionPath(path))) {\n return undefined;\n }\n\n const rendered = await options.render({\n path,\n request: options.request,\n revalidatedPaths: options.revalidatedPaths,\n });\n\n if (rendered === undefined) {\n return undefined;\n }\n\n rendered.headers.set(\"x-mreact-action-single-flight\", \"1\");\n return rendered;\n}\n\nfunction isFormActionRedirectResponse(response: Response): boolean {\n return response.status >= 300 && response.status < 400 && response.headers.has(\"location\");\n}\n\nfunction sameOriginResponseLocationPath(request: Request, response: Response): string | undefined {\n const location = response.headers.get(\"location\");\n\n if (location === null) {\n return undefined;\n }\n\n try {\n const requestUrl = new URL(request.url);\n const locationUrl = new URL(location, requestUrl);\n\n return locationUrl.origin === requestUrl.origin\n ? `${locationUrl.pathname}${locationUrl.search}`\n : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction sameOriginRefererPath(request: Request): string | undefined {\n const referer = request.headers.get(\"referer\");\n\n if (referer === null) {\n return undefined;\n }\n\n try {\n const requestUrl = new URL(request.url);\n const refererUrl = new URL(referer, requestUrl);\n\n return refererUrl.origin === requestUrl.origin\n ? `${refererUrl.pathname}${refererUrl.search}`\n : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeActionPath(path: string): string {\n const pathname = path.startsWith(\"/\") ? path : `/${path}`;\n const withoutTrailing = pathname.length > 1 ? pathname.replace(/\\/+$/, \"\") : pathname;\n\n return withoutTrailing === \"\" ? \"/\" : withoutTrailing;\n}\n\nfunction withRevalidationHeader(response: Response, paths: string[]): Response {\n if (paths.length > 0) {\n response.headers.set(\"x-mreact-revalidate\", paths.join(\",\"));\n }\n\n return response;\n}\n\nasync function authorizeFormAction(options: {\n args: unknown[];\n authorize?: ServerActionHandlerOptions[\"authorize\"];\n exportName: string;\n moduleId: string;\n request: Request;\n}): Promise<Response | undefined> {\n const reference: ServerActionRequestReference = {\n exportName: options.exportName,\n moduleId: options.moduleId,\n };\n const authorizationResult = await options.authorize?.(options.request, reference, options.args);\n\n return authorizationResult !== undefined && authorizationResult !== true\n ? jsonResponse(\n {\n ok: false,\n error: authorizationError(authorizationResult),\n },\n 403,\n )\n : undefined;\n}\n\nfunction authorizationError(result: Exclude<ServerActionValidationResult, true>): string {\n return typeof result === \"string\" ? result : \"Server action not authorized.\";\n}\n\nfunction jsonAllowedServerActions(\n allowedActions: readonly AppRouterAllowedServerAction[],\n): ServerActionRequestReference[] {\n return allowedActions\n .filter((reference) => reference.inferred !== true)\n .map((reference) => ({\n exportName: reference.exportName,\n moduleId: reference.moduleId,\n }));\n}\n\nfunction jsonServerActionRegistry(options: {\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined;\n appDir: string;\n registry: ServerActionRegistry;\n}): ServerActionRegistry {\n const inferredKeys = new Set<string>();\n\n for (const reference of inferredServerActionReferencesForApp(options.appDir).values()) {\n inferredKeys.add(serverActionKey(reference));\n }\n\n if (Array.isArray(options.allowedActions)) {\n for (const reference of options.allowedActions) {\n if (reference.inferred === true) {\n inferredKeys.add(serverActionKey(reference));\n }\n }\n }\n\n if (inferredKeys.size === 0) {\n return options.registry;\n }\n\n const registry: ServerActionRegistry = {};\n\n for (const [key, value] of Object.entries(options.registry)) {\n if (!inferredKeys.has(key)) {\n registry[key] = value;\n }\n }\n\n return registry;\n}\n\nfunction serverActionKey(reference: ServerActionRequestReference): string {\n return `${reference.moduleId}#${reference.exportName}`;\n}\n\nfunction isAllowedServerAction(\n reference: ServerActionRequestReference,\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined,\n): boolean {\n if (allowedActions === undefined) {\n warnIfUnrestrictedServerActions(allowedActions);\n return true;\n }\n\n if (allowedActions === \"any\") {\n return true;\n }\n\n return allowedActions.some(\n (allowed) =>\n allowed.moduleId === reference.moduleId && allowed.exportName === reference.exportName,\n );\n}\n\nfunction warnIfUnrestrictedServerActions(\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined,\n): void {\n if (\n allowedActions !== undefined ||\n !isProductionEnvironment() ||\n warnedUnrestrictedServerActions\n ) {\n return;\n }\n\n warnedUnrestrictedServerActions = true;\n console.warn(\n \"[mreact] Server actions are running without an allowedActions manifest. Built app-router deployments generate this manifest automatically; direct production integrations should pass serverActions.allowedActions.\",\n );\n}\n\nfunction validateServerActionManifest(\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined,\n): Response | undefined {\n if (allowedActions !== undefined || !isProductionEnvironment()) {\n return undefined;\n }\n\n return jsonResponse({ ok: false, error: \"Server action manifest required.\" }, 403);\n}\n\nfunction lowerFormActions(options: {\n actionNonce: string;\n code: string;\n csrfToken: string;\n references: Map<string, ActionReference>;\n}): string {\n let code = options.code;\n const formReferences = collectFormActionExpressionReferences({ code: options.code });\n\n for (const formReference of [...formReferences].reverse()) {\n const reference = options.references.get(formActionOccurrenceKey(formReference));\n\n if (reference === undefined) {\n continue;\n }\n\n const opening = code.slice(formReference.start, formReference.end);\n const loweredOpening = lowerFormActionOpening({\n actionNonce: options.actionNonce,\n csrfToken: options.csrfToken,\n opening,\n reference,\n referenceName: formReference.expression,\n });\n\n if (loweredOpening === opening) {\n continue;\n }\n\n code = `${code.slice(0, formReference.start)}${loweredOpening}${code.slice(formReference.end)}`;\n }\n\n return code;\n}\n\nfunction formActionOccurrenceKey(reference: {\n end: number;\n expression: string;\n expressionEnd: number;\n expressionStart: number;\n start: number;\n}): string {\n return [\n reference.start,\n reference.end,\n reference.expressionStart,\n reference.expressionEnd,\n reference.expression,\n ].join(\":\");\n}\n\nfunction formActionSourceHash(code: string): string {\n return createHash(\"sha256\").update(code).digest(\"base64url\");\n}\n\nfunction lowerFormActionOpening(options: {\n actionNonce: string;\n csrfToken: string;\n opening: string;\n reference: ActionReference;\n referenceName: string;\n}): string {\n const actionPattern = new RegExp(\n `^(?<prefix><form\\\\b[\\\\s\\\\S]*?)\\\\saction=\\\\{${escapeRegExp(options.referenceName)}\\\\}(?<suffix>[\\\\s\\\\S]*?)>$`,\n \"u\",\n );\n const match = options.opening.match(actionPattern);\n const prefix = match?.groups?.prefix;\n const suffix = match?.groups?.suffix;\n\n if (prefix === undefined || suffix === undefined) {\n return options.opening;\n }\n\n const attrs = `${prefix.slice(\"<form\".length)}${suffix}`.replace(\n /\\s+method=(?:\"[^\"]*\"|'[^']*'|\\{[^}]*\\})/g,\n \"\",\n );\n const hidden = [\n hiddenInput(formFieldModuleId, options.reference.moduleId),\n hiddenInput(formFieldExportName, options.reference.exportName),\n hiddenInput(formCsrfFieldName, options.csrfToken),\n hiddenInput(formFieldNonce, options.actionNonce),\n hiddenInput(\n formFieldActionToken,\n formActionToken({\n csrfToken: options.csrfToken,\n exportName: options.reference.exportName,\n moduleId: options.reference.moduleId,\n nonce: options.actionNonce,\n }),\n ),\n ].join(\"\");\n\n return `<form${attrs} method=\"post\" action=\"/_mreact/actions\">${hidden}`;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction hiddenInput(name: string, value: string): string {\n return `<input type=\"hidden\" name=\"${escapeAttribute(name)}\" value=\"${escapeAttribute(value)}\" />`;\n}\n\nasync function collectImportedServerActions(options: {\n appDir: string;\n code: string;\n pageFile: string;\n}): Promise<{\n diagnostics: ServerActionInferenceDiagnostic[];\n references: Map<string, ActionReference>;\n}> {\n return await collectRuntimeInferredServerActions({\n appDir: options.appDir,\n code: options.code,\n fileSystem: {\n isUseServerFile,\n resolveSourceFile,\n },\n pageFile: options.pageFile,\n });\n}\n\nfunction isInferredServerActionReference(options: {\n allowedActions: readonly AppRouterAllowedServerAction[] | \"any\" | undefined;\n appDir: string;\n exportName: string;\n moduleId: string;\n}): boolean {\n if (\n Array.isArray(options.allowedActions) &&\n options.allowedActions.some(\n (allowed) =>\n allowed.inferred === true &&\n allowed.moduleId === options.moduleId &&\n allowed.exportName === options.exportName,\n )\n ) {\n return true;\n }\n\n return inferredServerActionReferencesForApp(options.appDir).has(\n `${options.moduleId}#${options.exportName}`,\n );\n}\n\nfunction formActionToken(options: {\n csrfToken: string;\n exportName: string;\n moduleId: string;\n nonce: string;\n}): string {\n return createHmac(\"sha256\", actionTokenSecret)\n .update(options.moduleId)\n .update(\"\\0\")\n .update(options.exportName)\n .update(\"\\0\")\n .update(options.csrfToken)\n .update(\"\\0\")\n .update(options.nonce)\n .digest(\"base64url\");\n}\n\nfunction isValidFormActionToken(options: {\n csrfToken: string | undefined;\n exportName: string;\n moduleId: string;\n nonce: string;\n token: string | undefined;\n}): boolean {\n if (options.csrfToken === undefined || options.token === undefined) {\n return false;\n }\n\n const expected = Buffer.from(\n formActionToken({\n csrfToken: options.csrfToken,\n exportName: options.exportName,\n moduleId: options.moduleId,\n nonce: options.nonce,\n }),\n );\n const actual = Buffer.from(options.token);\n\n return actual.length === expected.length && timingSafeEqual(actual, expected);\n}\n\nfunction replaceInferredServerActionReferences(\n appDir: string,\n pageFile: string,\n references: ReadonlyMap<string, ActionReference>,\n): void {\n const nextReferences = new Map(\n Array.from(references.values())\n .filter((reference) => reference.inferred)\n .map((reference) => [`${reference.moduleId}#${reference.exportName}`, reference]),\n );\n let appReferencesByPage = inferredServerActionReferences.get(appDir);\n const previousReferences = appReferencesByPage?.get(pageFile) ?? new Map();\n const changed = !sameActionReferenceKeys(previousReferences, nextReferences);\n\n if (!changed) {\n return;\n }\n\n if (nextReferences.size === 0) {\n appReferencesByPage?.delete(pageFile);\n if (appReferencesByPage?.size === 0) {\n inferredServerActionReferences.delete(appDir);\n }\n } else {\n if (appReferencesByPage === undefined) {\n appReferencesByPage = new Map();\n inferredServerActionReferences.set(appDir, appReferencesByPage);\n }\n appReferencesByPage.set(pageFile, nextReferences);\n }\n\n clearServerActionRegistryCacheForApp(appDir);\n}\n\n// Cache the (expensive) collect+bundle+evaluate work keyed by appDir +\n// caller-supplied version. Production callers pass the build-time hash\n// (serverModuleCacheVersion) so the registry is reused for the lifetime\n// of one deployment. Dev callers omit the version; the entry is then\n// keyed on \"dev\" so the work happens once per process — restarts handle\n// invalidation. Concurrent callers share a single in-flight promise.\nconst serverActionRegistryCache = new Map<string, Promise<ServerActionRegistry>>();\n\nasync function loadServerActionRegistry(options: {\n appDir: string;\n cacheVersion?: string | undefined;\n importPolicy?: AppRouterImportPolicy | undefined;\n}): Promise<ServerActionRegistry> {\n const cacheKey = `${options.appDir}::${options.cacheVersion ?? \"dev\"}`;\n const cached = serverActionRegistryCache.get(cacheKey);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const pending = buildServerActionRegistry(options).catch((error) => {\n // Drop the failed promise so a retry can re-run the load.\n serverActionRegistryCache.delete(cacheKey);\n throw error;\n });\n serverActionRegistryCache.set(cacheKey, pending);\n return pending;\n}\n\nasync function buildServerActionRegistry(options: {\n appDir: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n}): Promise<ServerActionRegistry> {\n const files = await collectFiles(options.appDir);\n const registry: ServerActionRegistry = {};\n const inferredReferences = inferredServerActionReferencesForApp(options.appDir);\n\n for (const file of files) {\n const moduleId = moduleIdForFile(options.appDir, file);\n const inferredExportNames = inferredExportNamesForModule(inferredReferences, moduleId);\n const useServerFile = await isUseServerFile(file);\n\n if (!useServerFile && inferredExportNames.size === 0) {\n continue;\n }\n\n const module = await importServerActionModule({\n appDir: options.appDir,\n file,\n importPolicy: options.importPolicy,\n });\n\n for (const [exportName, value] of Object.entries(module)) {\n if (typeof value === \"function\" && (useServerFile || inferredExportNames.has(exportName))) {\n registry[`${moduleId}#${exportName}`] = value as (...args: unknown[]) => unknown;\n }\n }\n }\n\n return registry;\n}\n\n// Exposed for tests that need a clean slate between cases (in-process state).\nexport function __clearServerActionRegistryCache(): void {\n serverActionRegistryCache.clear();\n inferredServerActionReferences.clear();\n}\n\nfunction clearServerActionRegistryCacheForApp(appDir: string): void {\n const prefix = `${appDir}::`;\n\n for (const key of serverActionRegistryCache.keys()) {\n if (key.startsWith(prefix)) {\n serverActionRegistryCache.delete(key);\n }\n }\n}\n\nfunction sameActionReferenceKeys(\n left: ReadonlyMap<string, ActionReference>,\n right: ReadonlyMap<string, ActionReference>,\n): boolean {\n if (left.size !== right.size) {\n return false;\n }\n\n for (const key of left.keys()) {\n if (!right.has(key)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction inferredServerActionReferencesForApp(appDir: string): Map<string, ActionReference> {\n const references = new Map<string, ActionReference>();\n const appReferencesByPage = inferredServerActionReferences.get(appDir);\n\n if (appReferencesByPage === undefined) {\n return references;\n }\n\n for (const pageReferences of appReferencesByPage.values()) {\n for (const [key, reference] of pageReferences) {\n references.set(key, reference);\n }\n }\n\n return references;\n}\n\nfunction inferredExportNamesForModule(\n references: ReadonlyMap<string, ActionReference>,\n moduleId: string,\n): Set<string> {\n const names = new Set<string>();\n\n for (const reference of references.values()) {\n if (reference.moduleId === moduleId) {\n names.add(reference.exportName);\n }\n }\n\n return names;\n}\n\nasync function importServerActionModule(options: {\n appDir: string;\n file: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n}): Promise<Record<string, unknown>> {\n const bundled = await bundleRouterModule({\n code: `export * from ${JSON.stringify(options.file)};`,\n filename: options.file,\n platform: \"node\",\n plugins: [\n fileImportMetaUrlPlugin(),\n serverActionRuntimePlugin(),\n createAppRouterImportPolicyPlugin({\n appDir: options.appDir,\n importPolicy: options.importPolicy,\n label: \"Server action\",\n }),\n ],\n });\n const code = bundled.code;\n\n if (code === undefined) {\n throw new Error(`Failed to compile server action module ${options.file}.`);\n }\n\n return importAppRouterSourceModule<Record<string, unknown>>({\n code,\n label: `server-action:${options.file}`,\n });\n}\n\nfunction serverActionRuntimePlugin() {\n const currentDir = dirname(fileURLToPath(import.meta.url));\n const cachePath = join(currentDir, currentDir.endsWith(`${sep}dist`) ? \"cache.js\" : \"cache.ts\");\n\n return {\n name: \"mreact-router-server-action-runtime\",\n setup(buildApi: RouterCompatBuildApi) {\n buildApi.onResolve({ filter: /^@reckona\\/mreact-router$/ }, () => ({\n namespace: \"mreact-router-server-api\",\n path: \"index\",\n }));\n buildApi.onLoad({ filter: /^index$/, namespace: \"mreact-router-server-api\" }, () => ({\n contents: `export { revalidatePath } from ${JSON.stringify(cachePath)};`,\n loader: \"ts\",\n resolveDir: dirname(cachePath),\n }));\n },\n };\n}\n\nasync function collectFiles(directory: string): Promise<string[]> {\n const entries = await readdir(directory, { withFileTypes: true });\n const files: string[] = [];\n\n for (const entry of entries) {\n const path = join(directory, entry.name);\n\n if (entry.isDirectory()) {\n if (shouldSkipServerActionScanDirectory(entry.name)) {\n continue;\n }\n\n files.push(...(await collectFiles(path)));\n continue;\n }\n\n if (entry.isFile() && /\\.(?:mreact\\.tsx|tsx|ts)$/.test(entry.name)) {\n files.push(path);\n }\n }\n\n return files;\n}\n\nfunction shouldSkipServerActionScanDirectory(name: string): boolean {\n return name === \"node_modules\" || name === \"__tests__\" || name.startsWith(\".\");\n}\n\nasync function resolveSourceFile(directory: string, source: string): Promise<string | undefined> {\n const base = join(directory, source);\n const tsEsmBase = /\\.[cm]?js$/.test(base) ? base.replace(/\\.[cm]?js$/, \"\") : undefined;\n const candidates = [\n base,\n ...(tsEsmBase === undefined\n ? []\n : [\n `${tsEsmBase}.ts`,\n `${tsEsmBase}.tsx`,\n `${tsEsmBase}.mreact.tsx`,\n join(tsEsmBase, \"index.ts\"),\n join(tsEsmBase, \"index.tsx\"),\n ]),\n `${base}.ts`,\n `${base}.tsx`,\n `${base}.mreact.tsx`,\n join(base, \"index.ts\"),\n join(base, \"index.tsx\"),\n ];\n\n for (const candidate of candidates) {\n try {\n await access(candidate);\n return candidate;\n } catch {\n // Try the next candidate.\n }\n }\n\n return undefined;\n}\n\nasync function isUseServerFile(file: string): Promise<boolean> {\n const code = await readFile(file, \"utf8\");\n\n return hasModuleDirective({ code, directive: \"use server\", filename: file });\n}\n\nfunction moduleIdForFile(appDir: string, file: string): string {\n return relative(appDir, file).split(sep).join(\"/\");\n}\n\nfunction validateServerActionRequestOrigin(request: Request): Response | undefined {\n if (!isProductionEnvironment()) {\n return undefined;\n }\n\n const expectedOrigin = new URL(request.url).origin;\n const origin = request.headers.get(\"origin\");\n\n if (origin !== null) {\n return origin === expectedOrigin\n ? undefined\n : jsonResponse({ ok: false, error: \"Origin not allowed.\" }, 403);\n }\n\n const referer = request.headers.get(\"referer\");\n\n if (referer === null) {\n return jsonResponse({ ok: false, error: \"Origin not allowed.\" }, 403);\n }\n\n try {\n return new URL(referer).origin === expectedOrigin\n ? undefined\n : jsonResponse({ ok: false, error: \"Origin not allowed.\" }, 403);\n } catch {\n return jsonResponse({ ok: false, error: \"Origin not allowed.\" }, 403);\n }\n}\n\nfunction validateFormNonce(\n formData: FormData,\n replayStore: ServerActionReplayStore,\n): Response | undefined {\n const nonce = stringFormValue(formData.get(formFieldNonce));\n\n if (nonce === undefined || nonce.length === 0) {\n return jsonResponse({ ok: false, error: \"Missing server action nonce.\" }, 400);\n }\n\n if (replayStore.has(nonce)) {\n return jsonResponse({ ok: false, error: \"Server action nonce was already used.\" }, 409);\n }\n\n replayStore.add(nonce);\n return undefined;\n}\n\nfunction cleanActionFormData(formData: FormData): FormData {\n const cleaned = new FormData();\n\n for (const [name, value] of formData.entries()) {\n if (\n name !== formFieldModuleId &&\n name !== formFieldExportName &&\n name !== formCsrfFieldName &&\n name !== formFieldNonce &&\n name !== formFieldActionToken\n ) {\n cleaned.append(name, value);\n }\n }\n\n return cleaned;\n}\n\nfunction stringFormValue(value: FormDataEntryValue | null): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction jsonResponse(payload: unknown, status: number): Response {\n return new Response(JSON.stringify(payload), {\n headers: { \"content-type\": \"application/json; charset=utf-8\" },\n status,\n });\n}\n\nfunction escapeAttribute(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll('\"', \""\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\");\n}\n"]}
|
|
@@ -73,8 +73,26 @@ export type AwsLambdaPreloadStrategy = "all" | "hot-route-requests" | "middlewar
|
|
|
73
73
|
};
|
|
74
74
|
export type AwsLambdaRequestHandler = (event: AwsLambdaHttpEventV2) => Promise<AwsLambdaHttpResultV2>;
|
|
75
75
|
export type AwsLambdaStreamingRequestHandler<TContext = unknown> = (event: AwsLambdaHttpEventV2, responseStream: AwsLambdaStreamingResponseStream, context: TContext) => Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a buffered AWS Lambda HTTP API v2 handler for built app-router output.
|
|
78
|
+
*
|
|
79
|
+
* The handler materializes runtime files under `/tmp` by default, starts middleware-focused background preload, applies the generated import policy when requested, and returns API Gateway v2 response objects.
|
|
80
|
+
*/
|
|
76
81
|
export declare function createAwsLambdaRequestHandler(options: AwsLambdaRequestHandlerOptions): AwsLambdaRequestHandler;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a buffered AWS Lambda handler after eagerly preparing and preloading the built runtime.
|
|
84
|
+
*
|
|
85
|
+
* Use this when startup code can await preload work before the first request instead of letting the first invocation share that cost.
|
|
86
|
+
*/
|
|
77
87
|
export declare function createPreloadedAwsLambdaRequestHandler(options: AwsLambdaRequestHandlerOptions): Promise<AwsLambdaRequestHandler>;
|
|
88
|
+
/**
|
|
89
|
+
* Creates an AWS Lambda streaming response handler for built app-router output.
|
|
90
|
+
*
|
|
91
|
+
* Use this with Lambda response streaming runtimes when HTML or route responses should be written progressively instead of buffered into an API Gateway result.
|
|
92
|
+
*/
|
|
78
93
|
export declare function createAwsLambdaStreamingRequestHandler<TContext = unknown>(options: AwsLambdaRequestHandlerOptions): AwsLambdaStreamingRequestHandler<TContext>;
|
|
94
|
+
/**
|
|
95
|
+
* Creates a streaming AWS Lambda handler after eagerly preparing and preloading the built runtime.
|
|
96
|
+
*/
|
|
79
97
|
export declare function createPreloadedAwsLambdaStreamingRequestHandler<TContext = unknown>(options: AwsLambdaRequestHandlerOptions): Promise<AwsLambdaStreamingRequestHandler<TContext>>;
|
|
80
98
|
//# sourceMappingURL=aws-lambda.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws-lambda.d.ts","sourceRoot":"","sources":["../../src/adapters/aws-lambda.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAKjE,OAAO,EAML,KAAK,eAAe,EAErB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAKL,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IACzD,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,OAAO,CAAC,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AAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,gCAAgC,CAAC,QAAQ,CAAC,CAAC,CAWrD"}
|
|
@@ -6,6 +6,11 @@ import { dirname, join } from "node:path";
|
|
|
6
6
|
import { normalizeBuiltAppRuntimePreloadStrategy, } from "../preload-policy.js";
|
|
7
7
|
import { emitRouterLog, logDurationMs, logError, logNow, requestLogFields, } from "../logger.js";
|
|
8
8
|
import { createBuiltRequestRuntime, preloadBuiltAppRuntime, resolveRequestHost, warnIfImplicitHostTrust, } from "../serve.js";
|
|
9
|
+
/**
|
|
10
|
+
* Creates a buffered AWS Lambda HTTP API v2 handler for built app-router output.
|
|
11
|
+
*
|
|
12
|
+
* The handler materializes runtime files under `/tmp` by default, starts middleware-focused background preload, applies the generated import policy when requested, and returns API Gateway v2 response objects.
|
|
13
|
+
*/
|
|
9
14
|
export function createAwsLambdaRequestHandler(options) {
|
|
10
15
|
warnIfImplicitHostTrust(options);
|
|
11
16
|
const runtimeDirPromise = prepareAwsLambdaRuntimeDir(options);
|
|
@@ -13,6 +18,11 @@ export function createAwsLambdaRequestHandler(options) {
|
|
|
13
18
|
void runtimePreloadPromise?.catch(() => { });
|
|
14
19
|
return createAwsLambdaRequestHandlerFromRuntime(options, runtimeDirPromise, runtimePreloadPromise, "middleware");
|
|
15
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a buffered AWS Lambda handler after eagerly preparing and preloading the built runtime.
|
|
23
|
+
*
|
|
24
|
+
* Use this when startup code can await preload work before the first request instead of letting the first invocation share that cost.
|
|
25
|
+
*/
|
|
16
26
|
export async function createPreloadedAwsLambdaRequestHandler(options) {
|
|
17
27
|
warnIfImplicitHostTrust(options);
|
|
18
28
|
const runtimeDir = await prepareAwsLambdaRuntimeDir(options);
|
|
@@ -89,6 +99,11 @@ function createAwsLambdaRequestHandlerFromRuntime(options, runtimeDirPromise, ru
|
|
|
89
99
|
}
|
|
90
100
|
};
|
|
91
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates an AWS Lambda streaming response handler for built app-router output.
|
|
104
|
+
*
|
|
105
|
+
* Use this with Lambda response streaming runtimes when HTML or route responses should be written progressively instead of buffered into an API Gateway result.
|
|
106
|
+
*/
|
|
92
107
|
export function createAwsLambdaStreamingRequestHandler(options) {
|
|
93
108
|
warnIfImplicitHostTrust(options);
|
|
94
109
|
const runtime = awsLambdaRuntime();
|
|
@@ -97,6 +112,9 @@ export function createAwsLambdaStreamingRequestHandler(options) {
|
|
|
97
112
|
void runtimePreloadPromise?.catch(() => { });
|
|
98
113
|
return createAwsLambdaStreamingRequestHandlerFromRuntime(options, runtime, runtimeDirPromise, runtimePreloadPromise, "middleware");
|
|
99
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates a streaming AWS Lambda handler after eagerly preparing and preloading the built runtime.
|
|
117
|
+
*/
|
|
100
118
|
export async function createPreloadedAwsLambdaStreamingRequestHandler(options) {
|
|
101
119
|
warnIfImplicitHostTrust(options);
|
|
102
120
|
const runtime = awsLambdaRuntime();
|