@cosmicdrift/kumiko-server-runtime 0.422.0 → 0.424.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,8 +37,8 @@ export declare function applyStandardBootSeeds(deps: {
37
37
  }>;
38
38
  type SharedAuthFlowFields = Pick<RunProdAppAuthOptions, "passwordReset" | "emailVerification" | "accountUnlock" | "signup" | "invite">;
39
39
  type AuthFlowRoutes = Pick<AuthRoutesConfig, "passwordReset" | "emailVerification" | "accountUnlock" | "signup" | "invite">;
40
- export type SharedAuthRouteSource = SharedAuthFlowFields & Pick<RunProdAppAuthOptions, "loginErrorStatusMap" | "cookieDomain" | "retiredCookieDomains" | "allowedOrigins" | "unsafeSkipOriginCheck" | "postAuthLanding">;
41
- export type SharedAuthRoutes = AuthFlowRoutes & Pick<AuthRoutesConfig, "membershipQuery" | "loginHandler" | "loginErrorStatusMap" | "cookieDomain" | "retiredCookieDomains" | "allowedOrigins" | "unsafeSkipOriginCheck" | "postAuthLanding" | "mfaVerifyHandler" | "switchTenantMfaGateHandler" | "mfaPreauthEnableStartHandler" | "mfaPreauthConfirmHandler">;
40
+ export type SharedAuthRouteSource = SharedAuthFlowFields & Pick<RunProdAppAuthOptions, "loginErrorStatusMap" | "sessionExchangeHandlers" | "sessionExchangeRateLimit" | "cookieDomain" | "retiredCookieDomains" | "allowedOrigins" | "unsafeSkipOriginCheck" | "postAuthLanding">;
41
+ export type SharedAuthRoutes = AuthFlowRoutes & Pick<AuthRoutesConfig, "membershipQuery" | "loginHandler" | "loginErrorStatusMap" | "sessionExchangeHandlers" | "sessionExchangeRateLimit" | "cookieDomain" | "retiredCookieDomains" | "allowedOrigins" | "unsafeSkipOriginCheck" | "postAuthLanding" | "mfaVerifyHandler" | "switchTenantMfaGateHandler" | "mfaPreauthEnableStartHandler" | "mfaPreauthConfirmHandler">;
42
42
  export declare function buildSharedAuthRoutes(effectiveAuth: SharedAuthRouteSource, hasMfa: boolean): SharedAuthRoutes;
43
43
  export declare function waitForKmsHealthy(kms: KmsAdapter, processName: string, deadline: number, clock?: DatabaseWaitClock): Promise<void>;
44
44
  export declare function openDatabasePools(databaseUrl: string, envSource: Record<string, string | undefined>, rowLevelSecurity: RowLevelSecurityMode): {
@@ -119,6 +119,12 @@ function buildAuthFlowRoutes(effectiveAuth) {
119
119
  };
120
120
  }
121
121
  export function buildSharedAuthRoutes(effectiveAuth, hasMfa) {
122
+ // The exchange route mints sessions without a second factor, so with auth-mfa
123
+ // mounted it would be a way around MFA.
124
+ if (hasMfa && Object.keys(effectiveAuth.sessionExchangeHandlers ?? {}).length > 0) {
125
+ throw new Error("[kumiko:boot] session-exchange handlers cannot enforce MFA yet; " +
126
+ "unmount auth-mfa or remove sessionExchangeHandlers.");
127
+ }
122
128
  return {
123
129
  membershipQuery: TenantQueries.memberships,
124
130
  loginHandler: AuthHandlers.login,
@@ -126,6 +132,12 @@ export function buildSharedAuthRoutes(effectiveAuth, hasMfa) {
126
132
  [AuthErrors.invalidCredentials]: 401,
127
133
  [AuthErrors.noMembership]: 403,
128
134
  },
135
+ ...(effectiveAuth.sessionExchangeRateLimit !== undefined && {
136
+ sessionExchangeRateLimit: effectiveAuth.sessionExchangeRateLimit,
137
+ }),
138
+ ...(effectiveAuth.sessionExchangeHandlers !== undefined && {
139
+ sessionExchangeHandlers: effectiveAuth.sessionExchangeHandlers,
140
+ }),
129
141
  ...(effectiveAuth.cookieDomain !== undefined && {
130
142
  cookieDomain: effectiveAuth.cookieDomain,
131
143
  }),
@@ -65,6 +65,7 @@ import { CSP_HASHES_FILE, inlineScriptHashes } from "./csp-hashes.js";
65
65
  import { RENDERER_WEB_FONT_FILE_PATTERN, RENDERER_WEB_FONTS_DIST_DIR, resolveRendererWebFontsDir, } from "./renderer-web-fonts.js";
66
66
  import { resolveInstalledSync } from "./resolve-installed-package.js";
67
67
  import { canResolveTailwindStylesheet, resolveTailwindCli } from "./resolve-tailwind-cli.js";
68
+ import { ZOD_JITLESS_BANNER } from "./security-headers.js";
68
69
  // Bun runtime check as a module-level constant: every build step (Tailwind via
69
70
  // Bun.spawn, client bundling via Bun.build, and stylesheet resolution via
70
71
  // Bun.resolveSync) is Bun-only. Per-function inline checks could diverge; one
@@ -618,6 +619,7 @@ async function buildClientBundles(entries, outDir) {
618
619
  // reverse-engineerable source code. Development has its own sourcemaps via
619
620
  // create-kumiko-server.ts.
620
621
  sourcemap: "none",
622
+ banner: ZOD_JITLESS_BANNER,
621
623
  naming: {
622
624
  entry: "[name]-[hash].[ext]",
623
625
  chunk: "[name]-[hash].[ext]",
package/dist/index.d.ts CHANGED
@@ -23,6 +23,6 @@ export { parseRunMode, requireEnv, runProdApp } from "./run-prod-app.ts";
23
23
  export type { RunWorkerAppOptions, WorkerAppHandle, WorkerWireDeps, } from "./run-worker-app.ts";
24
24
  export { runWorkerApp } from "./run-worker-app.ts";
25
25
  export type { CspExtension, CspOption, SecurityHeadersOption } from "./security-headers.ts";
26
- export { buildDefaultCsp } from "./security-headers.ts";
26
+ export { buildDefaultCsp, ZOD_JITLESS_BANNER } from "./security-headers.ts";
27
27
  export { makeSeedCreateFileRef, type SeedCreateFileRef } from "./seed-dispatcher.ts";
28
28
  export { type StaticHtmlPage, writeStaticHtmlPages } from "./static-html-pages.ts";
package/dist/index.js CHANGED
@@ -17,6 +17,6 @@ export { installFatalErrorHandlers, } from "./fatal-error-handlers.js";
17
17
  export { runBootstrap } from "./run-bootstrap.js";
18
18
  export { parseRunMode, requireEnv, runProdApp } from "./run-prod-app.js";
19
19
  export { runWorkerApp } from "./run-worker-app.js";
20
- export { buildDefaultCsp } from "./security-headers.js";
20
+ export { buildDefaultCsp, ZOD_JITLESS_BANNER } from "./security-headers.js";
21
21
  export { makeSeedCreateFileRef } from "./seed-dispatcher.js";
22
22
  export { writeStaticHtmlPages } from "./static-html-pages.js";
@@ -1,7 +1,7 @@
1
1
  /// <reference types="bun-types" preserve="true" />
2
2
  import type { AccountLockoutOptions, AccountUnlockOptions, AuthMailLocale, AuthPaths, EmailVerificationOptions, InviteOptions, PasswordResetOptions, SignupOptions } from "@cosmicdrift/kumiko-bundled-features/auth-email-password";
3
3
  import type { SeedAdminOptions } from "@cosmicdrift/kumiko-bundled-features/auth-email-password/seeding";
4
- import type { ExtraRouteDefinition, KumikoServeEnv, PostAuthLandingResolver, SseBroker } from "@cosmicdrift/kumiko-framework/api";
4
+ import type { ExtraRouteDefinition, KumikoServeEnv, LoginRateLimiter, PostAuthLandingResolver, SseBroker } from "@cosmicdrift/kumiko-framework/api";
5
5
  import type { KmsAdapter } from "@cosmicdrift/kumiko-framework/crypto";
6
6
  import { type RowLevelSecurityMode } from "@cosmicdrift/kumiko-framework/db";
7
7
  import type { BundledListsOptions, FeatureDefinition, ValidateBootOptions } from "@cosmicdrift/kumiko-framework/engine";
@@ -107,6 +107,12 @@ export type RunProdAppAuthOptions = {
107
107
  readonly admin?: SeedAdminOptions;
108
108
  /** Optional override of the login error → HTTP status map. */
109
109
  readonly loginErrorStatusMap?: Readonly<Record<string, number>>;
110
+ /** Method → QN of an anonymous write handler that verifies the identity itself
111
+ * and returns `{ kind: "auth-session", session }`; served by POST /auth/session-exchange. */
112
+ readonly sessionExchangeHandlers?: Readonly<Record<string, string>>;
113
+ /** Rate limit for POST /auth/session-exchange (IP + method, no reset). Unset reuses the login
114
+ * limiter; `null` disables. */
115
+ readonly sessionExchangeRateLimit?: LoginRateLimiter | null;
110
116
  /** Wires all five mail flows (passwordReset, emailVerification, signup,
111
117
  * invite, accountUnlock) from `auth.mail.baseUrl` plus the default paths,
112
118
  * mailing via delivery (ctx.notify).
@@ -25,6 +25,7 @@ export type CspOption = false | string | {
25
25
  readonly extend: CspExtension;
26
26
  };
27
27
  export declare const DEFAULT_CSP_DIRECTIVES: Readonly<Record<string, readonly string[]>>;
28
+ export declare const ZOD_JITLESS_BANNER = "(globalThis.__zod_globalConfig??={}).jitless=true;";
28
29
  export declare function isScriptHash(value: unknown): value is string;
29
30
  export declare function buildDefaultCsp(scriptHashes: readonly string[], extend?: CspExtension): string;
30
31
  export declare function resolveSecurityHeaders(option: SecurityHeadersOption | undefined, scriptHashes?: readonly string[]): ReadonlyArray<readonly [string, string]>;
@@ -12,6 +12,10 @@ export const DEFAULT_CSP_DIRECTIVES = {
12
12
  "form-action": ["'self'"],
13
13
  "object-src": ["'none'"],
14
14
  };
15
+ // zod probes `new Function` once to choose its JIT parser; under script-src 'self' the browser
16
+ // reports that caught probe as a CSP violation. Prepended to every client chunk so the flag is
17
+ // set before zod builds its first schema.
18
+ export const ZOD_JITLESS_BANNER = "(globalThis.__zod_globalConfig??={}).jitless=true;";
15
19
  const SCRIPT_HASH_PATTERN = /^sha256-[A-Za-z0-9+/]{43}=$/;
16
20
  const DIRECTIVE_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
17
21
  // Separators that would let an extension value end its own
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-server-runtime",
3
- "version": "0.422.0",
3
+ "version": "0.424.1",
4
4
  "description": "Production server-boot runtime for Kumiko apps: connections, schema-drift-gate, seeds, lifecycle, graceful shutdown. Symmetric to kumiko-dev-server's runDevApp, without dev/scaffold tooling.",
5
5
  "license": "MIT",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -100,11 +100,11 @@
100
100
  }
101
101
  },
102
102
  "dependencies": {
103
- "@cosmicdrift/kumiko-bundled-features": "0.422.0",
104
- "@cosmicdrift/kumiko-framework": "0.422.0",
105
- "@cosmicdrift/kumiko-renderer": "0.422.0",
106
- "@cosmicdrift/kumiko-renderer-mail-html": "0.422.0",
107
- "@cosmicdrift/kumiko-types": "0.422.0",
103
+ "@cosmicdrift/kumiko-bundled-features": "0.424.1",
104
+ "@cosmicdrift/kumiko-framework": "0.424.1",
105
+ "@cosmicdrift/kumiko-renderer": "0.424.1",
106
+ "@cosmicdrift/kumiko-renderer-mail-html": "0.424.1",
107
+ "@cosmicdrift/kumiko-types": "0.424.1",
108
108
  "ioredis": "^5.11.1",
109
109
  "temporal-polyfill": "^0.3.2",
110
110
  "zod": "^4.6.7"
@@ -113,7 +113,7 @@
113
113
  "bun-types": "^1.4.4"
114
114
  },
115
115
  "devDependencies": {
116
- "@cosmicdrift/kumiko-testing": "0.422.0",
116
+ "@cosmicdrift/kumiko-testing": "0.424.1",
117
117
  "bun-types": "^1.4.4"
118
118
  },
119
119
  "publishConfig": {
package/src/changes.json CHANGED
@@ -1,4 +1,10 @@
1
1
  [
2
+ {
3
+ "version": "0.423.0",
4
+ "type": "fix",
5
+ "title": "No more CSP eval warning in the browser",
6
+ "detail": "The web client no longer triggers the DevTools message \"Content Security Policy of your site blocks the use of 'eval' in JavaScript\". Nothing to change in the app; rebuild with this version."
7
+ },
2
8
  {
3
9
  "version": "0.421.0",
4
10
  "type": "improvement",