fix: initialize configured auth in production builds
Quality / quality (ubuntu-latest) (push) Failing after 9m54s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-22 23:36:31 +05:30
parent 37439188ca
commit 9332522614
5 changed files with 18 additions and 4 deletions
+2 -2
View File
@@ -235,7 +235,7 @@
}, },
"packages/auth": { "packages/auth": {
"name": "@wrnexus/auth", "name": "@wrnexus/auth",
"version": "0.8.16", "version": "0.8.17",
"dependencies": { "dependencies": {
"@wrnexus/authz": "workspace:*", "@wrnexus/authz": "workspace:*",
"@wrnexus/captcha": "workspace:*", "@wrnexus/captcha": "workspace:*",
@@ -292,7 +292,7 @@
}, },
"packages/cli": { "packages/cli": {
"name": "@wrnexus/cli", "name": "@wrnexus/cli",
"version": "0.8.50", "version": "0.8.51",
"bin": { "bin": {
"wrnexus": "src/index.ts", "wrnexus": "src/index.ts",
}, },
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@wrnexus/auth", "name": "@wrnexus/auth",
"version": "0.8.16", "version": "0.8.17",
"description": "Complete authentication, account security, MFA, passkeys, recovery, devices, risk, and audit system for WRNexusJS.", "description": "Complete authentication, account security, MFA, passkeys, recovery, devices, risk, and audit system for WRNexusJS.",
"type": "module", "type": "module",
"sideEffects": false, "sideEffects": false,
+5
View File
@@ -11,6 +11,7 @@ import {
import { inferIdentityType, normalizeIdentity, publicUser } from "./normalize.ts"; import { inferIdentityType, normalizeIdentity, publicUser } from "./normalize.ts";
import { assertPasskeyProvider, MemoryPasskeyChallengeStore } from "./passkeys/index.ts"; import { assertPasskeyProvider, MemoryPasskeyChallengeStore } from "./passkeys/index.ts";
import { evaluateAuthRisk } from "./risk.ts"; import { evaluateAuthRisk } from "./risk.ts";
import { setDefaultAuthEngine } from "./runtime.ts";
import type { AuthStore } from "./store.ts"; import type { AuthStore } from "./store.ts";
import { generateTotpSecret, totpUri, verifyTotp } from "./totp/index.ts"; import { generateTotpSecret, totpUri, verifyTotp } from "./totp/index.ts";
import type { import type {
@@ -2298,5 +2299,9 @@ export function createAuthEngine(options: AuthEngineOptions): AuthEngine {
}, },
}; };
// The application config is evaluated in both dev and generated production
// runtimes. Registering here makes that configured engine available to the
// package-owned routes without an application startup shim.
setDefaultAuthEngine(engine);
return engine; return engine;
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@wrnexus/cli", "name": "@wrnexus/cli",
"version": "0.8.50", "version": "0.8.51",
"type": "module", "type": "module",
"main": "src/index.ts", "main": "src/index.ts",
"exports": { "exports": {
+9
View File
@@ -702,6 +702,15 @@ applyAuthzManifestEarly([${authzSetupEntries}]);
imports.push(`import "./.authz-setup.ts";`); imports.push(`import "./.authz-setup.ts";`);
} }
// Runtime plugin state (notably the configured auth engine and OAuth
// providers) is established by evaluating the application config. The build
// process runs in a different process, so its globals cannot serve the
// generated production server.
const runtimeConfigPath = ["wrnexus.config.ts", "wrnexus.config.js", "wrnexus.config.mjs"]
.map((name) => join(appRoot, name))
.find(existsSync);
if (runtimeConfigPath) imports.push(`import ${JSON.stringify(fwd(runtimeConfigPath))};`);
const manifestRoutes = (routes: Route[]): string => { const manifestRoutes = (routes: Route[]): string => {
const parts = routes.map((r) => { const parts = routes.map((r) => {
const v = `m${counter++}`; const v = `m${counter++}`;