@authup/server-auth-console 1.0.0-beta.64 → 1.0.0-beta.66

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 ADDED
@@ -0,0 +1,78 @@
1
+ # @authup/server-auth-console
2
+
3
+ [![npm version](https://badge.fury.io/js/@authup%2Fserver-auth-console.svg)](https://badge.fury.io/js/@authup%2Fserver-auth-console)
4
+ [![main](https://github.com/authup/authup/actions/workflows/main.yml/badge.svg)](https://github.com/authup/authup/actions/workflows/main.yml)
5
+ [![Known Vulnerabilities](https://snyk.io/test/github/authup/authup/badge.svg)](https://snyk.io/test/github/authup/authup)
6
+
7
+ The service behind authup's hosted auth pages: `/authorize` (login and
8
+ consent), `/register`, `/activate`, `/password-forgot`, `/password-reset`,
9
+ `/device` (device verification, RFC 8628) and `/logout`. A server-core page GET
10
+ redirects here carrying the request's own query, so the authorization request
11
+ is what identifies the flow.
12
+
13
+ It renders `@authup/client-auth-console` through that package's own render
14
+ contract, resolved out of `node_modules`: the SSR bundle per request with the
15
+ hydration payload spliced into the template, the bundle's client assets under
16
+ its own `/assets`, plus the operator theme and the security headers a login
17
+ page needs.
18
+
19
+ It hydrates ANONYMOUSLY over HTTP and holds no credential, no database and no
20
+ loopback: `/authorize` from `GET /authorize/info`, the four workflow pages and
21
+ `/device` from `GET /` plus their own query (`/device` pre-fills the `user_code`
22
+ it was called with), and `/logout` from nothing at all, since that page drives
23
+ the end-session call itself. Substituting a package that fulfills the
24
+ render contract is the supported way to replace the hosted auth UI.
25
+
26
+ ## Usage
27
+
28
+ `authup start console auth` is the supported route: the `authup` CLI reads
29
+ `authup.yml` and hands this service its own section. `authup start` composes it
30
+ onto server-core's own listener instead, which is the single-origin deployment.
31
+
32
+ The `authup-auth-console` bin is the standalone escape hatch, for a deployment
33
+ that runs a console without the CLI. It reads the environment alone.
34
+
35
+ ```bash
36
+ PUBLIC_URL=https://example.com AUTH_CONSOLE_PORT=3020 authup-auth-console
37
+ ```
38
+
39
+ ```typescript
40
+ import { createApplication } from '@authup/server-auth-console';
41
+
42
+ const application = createApplication();
43
+
44
+ await application.setup();
45
+ ```
46
+
47
+ `createApplication()` builds this console's own module graph, resolves its
48
+ configuration and listens. Pass `{ listen: false }` to be mounted on someone
49
+ else's listener, or `{ config }` to hand over a configuration.
50
+
51
+ ## Configuration
52
+
53
+ Keys are declared once in `@authup/server-config`; this service selects the ones
54
+ it reads. Its own section is `authConsole`, and it carries no `enabled` key:
55
+ the hosted login, consent and workflow pages are the issuance surface.
56
+
57
+ | Key | Environment variable | Default |
58
+ |---|---|---|
59
+ | `url` | `AUTH_CONSOLE_URL` | derived from `publicUrl` |
60
+ | `path` | `AUTH_CONSOLE_PATH` | resolve the bundle from `node_modules` |
61
+ | `port` | `AUTH_CONSOLE_PORT` | `3020` |
62
+ | `host` | `AUTH_CONSOLE_HOST` | inherits the deployment-wide `host` |
63
+
64
+ It is the one console that fetches server-side, so the API address is two keys:
65
+ `publicUrl` (`PUBLIC_URL`) is the browser's and reaches the hydration payload,
66
+ `internalUrl` (`INTERNAL_URL`) is the one this service dispatches against and
67
+ falls back to `publicUrl`. It also reads `theme.directoryPath`
68
+ (`THEME_DIRECTORY_PATH`) and `theme.fragmentsEnabled`
69
+ (`THEME_FRAGMENTS_ENABLED`). `resolveConfig()` and `readConfigFromEnv()` both
70
+ return a `Promise`.
71
+
72
+ ## License
73
+
74
+ Made with 💚
75
+
76
+ Published under the [AGPL-3.0-only License](./LICENSE).
77
+ A commercial license is available for organizations that cannot meet the AGPL's conditions.
78
+ See [LICENSING.md](../../LICENSING.md) or contact **contact@tada5hi.net**.
@@ -1,14 +1,16 @@
1
- import { THEME_ASSET_MOUNT_PATH, applyTheme, applyUIPageHeaders, createThemeAssetsHandler, createThemeProvider, readUIClientPreferences, rebaseAssetURLs, replaceTemplateMarker, stampHtmlAttributes } from "@authup/server-console-kit";
1
+ import { THEME_ASSET_MOUNT_PATH, applyTheme, applyUIPageHeaders, createApplication, createThemeAssetsHandler, createThemeProvider, readUIClientPreferences, rebaseAssetURLs, replaceTemplateMarker, stampHtmlAttributes } from "@authup/server-console-kit";
2
2
  import { AUTH_CONSOLE_SCHEMA, CORE_SCHEMA, ROOT_SCHEMA, SECTION_KEY, THEME_SCHEMA } from "@authup/server-config";
3
- import { buildSchemaDefaults, defineSchema, mergeSchemaData, readSchemaFromEnv, resolveSchemaData } from "@authup/server-config-kit";
3
+ import { buildSchemaDefaults, defineSchema, mergeSchemaData, mountSchema, readSchemaFromEnv, resolveSchemaData } from "@authup/server-config-kit";
4
+ import { Container } from "validup";
4
5
  import { createHandler } from "@routup/assets";
5
6
  import { basic } from "@routup/basic";
6
7
  import path from "node:path";
7
8
  import { App, defineCoreHandler } from "routup";
8
9
  import { Client } from "@authup/core-http-kit";
10
+ import { getURLBasePath, isUUID } from "@authup/kit";
11
+ import { OAuth2UIColorMode } from "@authup/specs";
9
12
  import { useRequestQuery } from "@routup/basic/query";
10
13
  import { InternalError } from "@authup/errors";
11
- import { getURLBasePath } from "@authup/kit";
12
14
  import { locateUpSync, read } from "locter";
13
15
  import fs from "node:fs";
14
16
  import { fileURLToPath } from "node:url";
@@ -36,17 +38,20 @@ const CONFIG_SCHEMA = defineSchema({
36
38
  })
37
39
  });
38
40
  /**
39
- * Turn the configuration namespace into the service's own shape: fill the
40
- * defaults, derive the one key that is derived rather than configured, and
41
- * rename. An empty `url` means the console sits on server-core's own origin
41
+ * Turn the configuration namespace into the service's own shape: validate the
42
+ * input against the declared zod types, fill the defaults, derive the one key
43
+ * that is derived rather than configured, and rename. An empty `url` means the console sits on server-core's own origin
42
44
  * under the default segment, which is the single-origin deployment.
43
45
  *
44
46
  * The defaults are layered SECTION-AWARE ({@link mergeSchemaData}): a spread
45
47
  * would let an input carrying one key of a section replace the whole section
46
48
  * and take every other key's default with it.
47
49
  */
48
- function resolveConfig(input) {
49
- const values = resolveSchemaData(CONFIG_SCHEMA, mergeSchemaData(CONFIG_SCHEMA, buildSchemaDefaults(CONFIG_SCHEMA), input));
50
+ async function resolveConfig(input) {
51
+ const validator = new Container();
52
+ mountSchema(validator, CONFIG_SCHEMA);
53
+ const parsed = await validator.run(input);
54
+ const values = resolveSchemaData(CONFIG_SCHEMA, mergeSchemaData(CONFIG_SCHEMA, buildSchemaDefaults(CONFIG_SCHEMA), parsed));
50
55
  return {
51
56
  url: values.url,
52
57
  apiUrl: values.publicUrl,
@@ -62,12 +67,17 @@ function resolveConfig(input) {
62
67
  * `authup.yml` reaches this service through the CLI roles, which compose this
63
68
  * very registry into the one document loader.
64
69
  */
65
- function readConfigFromEnv() {
70
+ async function readConfigFromEnv() {
66
71
  return resolveConfig(readSchemaFromEnv(CONFIG_SCHEMA));
67
72
  }
68
73
  //#endregion
69
74
  //#region src/constants.ts
70
75
  /**
76
+ * The render contract this service compiles against. The literal type fails
77
+ * the build the moment the bundle's constant moves without this one.
78
+ */
79
+ const CONTRACT_VERSION = 5;
80
+ /**
71
81
  * The vite base the auth console bundle is built with. Asset hrefs in the
72
82
  * shell are emitted against it, so the service mounts its assets there and
73
83
  * rebases them only when the deployment carries a sub-path.
@@ -89,7 +99,8 @@ const PAGES = [
89
99
  "/activate",
90
100
  "/password-forgot",
91
101
  "/password-reset",
92
- "/logout"
102
+ "/logout",
103
+ "/device"
93
104
  ];
94
105
  /**
95
106
  * Where this service mounts the bundle's `assets/` directory. The public
@@ -237,96 +248,147 @@ function buildWorkflowPageData(event, features, options = {}) {
237
248
  if (options.tokenAware) data.token = typeof query.token === "string" ? query.token : void 0;
238
249
  return data;
239
250
  }
251
+ /**
252
+ * The RP's own UI language, from the OIDC Core section 3.1.2.1 `ui_locales`
253
+ * parameter: a space-separated list of BCP47 tags in preference order.
254
+ *
255
+ * It rides the authorization request, so it survives the page GET's hop and
256
+ * the rebuild a federated round-trip makes from the stored code request. The
257
+ * four workflow pages take it straight from their own query, since an RP
258
+ * linking to one can say the same thing there.
259
+ */
260
+ function readUILocalesHint(event) {
261
+ const { ui_locales: uiLocales } = useRequestQuery(event);
262
+ if (typeof uiLocales !== "string") return;
263
+ return uiLocales.split(" ").find((tag) => /^[a-zA-Z]{2,3}(-[a-zA-Z0-9]+)*$/.test(tag));
264
+ }
265
+ /**
266
+ * The color mode the RP renders in, from authup's own `ui_color_mode`. One
267
+ * value rather than a list, since there is nothing to negotiate.
268
+ *
269
+ * Checked against the enum rather than local literals because the realm's
270
+ * discovery document ADVERTISES that same set as
271
+ * `ui_color_modes_supported`: a second spelling here would let the pages and
272
+ * the document disagree about what the deployment accepts.
273
+ */
274
+ function readUIColorModeHint(event) {
275
+ const { ui_color_mode: uiColorMode } = useRequestQuery(event);
276
+ return typeof uiColorMode === "string" && Object.values(OAuth2UIColorMode).includes(uiColorMode) ? uiColorMode : void 0;
277
+ }
278
+ /**
279
+ * The `user_code` the device page prefills (RFC 8628 section 3.3.1): the
280
+ * query value uppercased and stripped of everything outside `A-Z0-9`, or
281
+ * `undefined` when nothing bounded remains. The page renders it back, so what
282
+ * reaches the payload is at most 16 alphanumeric characters.
283
+ */
284
+ function readDeviceUserCode(event) {
285
+ const query = useRequestQuery(event);
286
+ if (typeof query.user_code !== "string") return;
287
+ const canonical = query.user_code.toUpperCase().replace(/[^A-Z0-9]/g, "");
288
+ if (canonical.length === 0 || canonical.length > 16) return;
289
+ return canonical;
290
+ }
291
+ /**
292
+ * The provider a federated login on the device page came back from (#3589).
293
+ * A routing hint and no secret: the pending login itself rides an HttpOnly
294
+ * cookie. Anything that is not a uuid is dropped, the rule `/authorize`
295
+ * reads its own hint by: the page interpolates the value into the
296
+ * completion request path.
297
+ */
298
+ function readDeviceFederatedLogin(event) {
299
+ const { provider } = useRequestQuery(event);
300
+ return typeof provider === "string" && isUUID(provider) ? { providerId: provider } : void 0;
301
+ }
302
+ /**
303
+ * The refusal marker the federated callback may attach. A closed set of one,
304
+ * so nothing request-derived is rendered.
305
+ */
306
+ function readDeviceError(event) {
307
+ return useRequestQuery(event).error === "access_denied" ? "access_denied" : void 0;
308
+ }
240
309
  //#endregion
241
310
  //#region src/path.ts
242
311
  const CODE_PATH = path.dirname(fileURLToPath(import.meta.url));
243
312
  const PACKAGE_PATH = path.join(CODE_PATH, "..");
244
313
  //#endregion
245
314
  //#region src/resolve.ts
246
- let cachedPackagePath;
247
- let cachedDistPath;
248
- let overridePackagePath;
249
315
  /**
250
- * Point the resolution at a substituted package (config `distPath`)
251
- * instead of the node_modules walk. Called once at boot.
252
- */
253
- function setPackagePath(value) {
254
- overridePackagePath = value || void 0;
255
- cachedPackagePath = void 0;
256
- cachedDistPath = void 0;
257
- }
258
- /**
259
- * Locate the auth console package. The SSR auth workflow UI ships as
260
- * `@authup/client-auth-console` (a dependency of THIS service), so the
316
+ * Locate the auth console package: a substituted one (config `distPath`)
317
+ * first, else the SSR auth workflow UI shipped as
318
+ * `@authup/client-auth-console` (a dependency of THIS service), which the
261
319
  * node_modules ancestor walk from this package's own root (locter's
262
- * `locateUp`) finds it for the workspace (symlink onto
263
- * apps/client-auth-console) and for a published install alike. Only a
264
- * positive result is cached.
320
+ * `locateUp`) finds for the workspace (symlink onto
321
+ * apps/client-auth-console) and for a published install alike.
265
322
  *
266
323
  * The `cwd` anchor is behavioural, not incidental: it decides which
267
324
  * node_modules tree is walked, so it stays pinned to this package rather
268
325
  * than to the process cwd.
269
326
  */
270
- function resolvePackagePath() {
271
- if (cachedPackagePath) return cachedPackagePath;
272
- if (overridePackagePath) {
273
- cachedPackagePath = overridePackagePath;
274
- return cachedPackagePath;
275
- }
276
- const manifest = locateUpSync("node_modules/@authup/client-auth-console/package.json", { cwd: PACKAGE_PATH });
277
- if (manifest) cachedPackagePath = manifest.directory;
278
- return cachedPackagePath;
327
+ function resolvePackagePath(distPath) {
328
+ return distPath || locateUpSync("node_modules/@authup/client-auth-console/package.json", { cwd: PACKAGE_PATH })?.directory;
279
329
  }
280
330
  /**
281
331
  * Locate the BUILT auth console bundle (`dist/client` template + assets,
282
- * `dist/server/server.js` render entry). Only a positive result is cached,
283
- * so a dev building the package after boot is picked up on the next
284
- * request.
332
+ * `dist/server/server.js` render entry). A half-built package is no bundle:
333
+ * without the render entry there is nothing to render with.
285
334
  */
286
- function resolveDistPath() {
287
- if (cachedDistPath) return cachedDistPath;
288
- const packagePath = resolvePackagePath();
289
- if (packagePath) {
290
- const distPath = path.join(packagePath, "dist");
291
- if (fs.existsSync(path.join(distPath, "client", "index.html"))) cachedDistPath = distPath;
292
- }
293
- return cachedDistPath;
335
+ function resolveDistPath(distPath) {
336
+ const packagePath = resolvePackagePath(distPath);
337
+ if (!packagePath) return;
338
+ const candidate = path.join(packagePath, "dist");
339
+ if (fs.existsSync(path.join(candidate, "client", "index.html")) && fs.existsSync(path.join(candidate, "server", "server.js"))) return candidate;
294
340
  }
295
341
  //#endregion
296
342
  //#region src/render.ts
297
- let cachedHtml;
298
- let cachedManifest;
299
- let cachedRender;
300
- const renderPage = async (event, config, ctx) => {
301
- const distPath = resolveDistPath();
302
- if (!distPath) throw new InternalError("The auth console bundle (@authup/client-auth-console) is not built or installed.");
303
- const html = cachedHtml ??= await fs.promises.readFile(path.join(distPath, "client", "index.html"), "utf-8");
304
- const manifest = cachedManifest ??= JSON.parse(await fs.promises.readFile(path.join(distPath, "client", ".vite", "ssr-manifest.json"), "utf-8"));
305
- const render = cachedRender ??= (await read(path.join(distPath, "server", "server.js"))).render;
306
- const preferences = readUIClientPreferences(event);
307
- const basePath = getURLBasePath(config.url);
308
- const payload = {
309
- config: {
310
- baseURL: config.apiUrl,
311
- basePath,
312
- colorMode: preferences.colorMode,
313
- locale: preferences.locale
314
- },
315
- data: ctx.data
343
+ /**
344
+ * Refuse a bundle built against another render contract at boot, naming the
345
+ * entry and both versions, instead of failing per request on `/authorize`.
346
+ * A bundle predating the export is version 1. Reads the module itself, which
347
+ * Node's ESM cache then hands the render for free.
348
+ */
349
+ async function assertRenderContract(distPath) {
350
+ const entry = path.join(distPath, "server", "server.js");
351
+ const version = (await read(entry)).CONTRACT_VERSION ?? 1;
352
+ if (version !== 5) throw new InternalError(`The auth console bundle "${entry}" implements render-contract version ${version}, but this service requires 5. Rebuild it against the current @authup/client-auth-console contract.`);
353
+ }
354
+ function createRenderPage(distPath) {
355
+ let cachedDistPath;
356
+ let cachedHtml;
357
+ let cachedManifest;
358
+ let cachedRender;
359
+ return async (event, config, ctx) => {
360
+ const resolved = cachedDistPath ??= resolveDistPath(distPath);
361
+ if (!resolved) throw new InternalError("The auth console bundle (@authup/client-auth-console) is not built or installed.");
362
+ const html = cachedHtml ??= await fs.promises.readFile(path.join(resolved, "client", "index.html"), "utf-8");
363
+ const manifest = cachedManifest ??= JSON.parse(await fs.promises.readFile(path.join(resolved, "client", ".vite", "ssr-manifest.json"), "utf-8"));
364
+ const render = cachedRender ??= (await read(path.join(resolved, "server", "server.js"))).render;
365
+ const preferences = readUIClientPreferences(event);
366
+ if (!preferences.locale || preferences.locale === "auto") preferences.locale = readUILocalesHint(event) || preferences.locale;
367
+ if (!preferences.colorMode || preferences.colorMode === "system") preferences.colorMode = readUIColorModeHint(event) || preferences.colorMode;
368
+ const basePath = getURLBasePath(config.url);
369
+ const payload = {
370
+ config: {
371
+ baseURL: config.apiUrl,
372
+ basePath,
373
+ colorMode: preferences.colorMode,
374
+ locale: preferences.locale
375
+ },
376
+ data: ctx.data
377
+ };
378
+ const [appHtml, preloadLinks] = await render({
379
+ url: ctx.url,
380
+ manifest,
381
+ payload
382
+ });
383
+ let body = replaceTemplateMarker(html, "<!--preload-links-->", preloadLinks);
384
+ body = replaceTemplateMarker(body, "<!--app-html-->", appHtml);
385
+ body = stampHtmlAttributes(body, preferences);
386
+ body = rebaseAssetURLs(body, VITE_BASE, `${basePath}/`);
387
+ body = await applyTheme(body, ctx.theme, basePath);
388
+ applyUIPageHeaders(event);
389
+ return body;
316
390
  };
317
- const [appHtml, preloadLinks] = await render({
318
- url: ctx.url,
319
- manifest,
320
- payload
321
- });
322
- let body = replaceTemplateMarker(html, "<!--preload-links-->", preloadLinks);
323
- body = replaceTemplateMarker(body, "<!--app-html-->", appHtml);
324
- body = stampHtmlAttributes(body, preferences);
325
- body = rebaseAssetURLs(body, VITE_BASE, `${basePath}/`);
326
- body = await applyTheme(body, ctx.theme, basePath);
327
- applyUIPageHeaders(event);
328
- return body;
329
- };
391
+ }
330
392
  //#endregion
331
393
  //#region src/handler.ts
332
394
  const WORKFLOW_PAGES = [
@@ -357,8 +419,8 @@ const WORKFLOW_PAGES = [
357
419
  * proxy, so a service published at `<origin>/console/auth` receives
358
420
  * `/authorize`, exactly as server-core received it before the split.
359
421
  */
360
- async function createHandler$1(config, themeProvider, render = renderPage) {
361
- setPackagePath(config.distPath);
422
+ async function createHandler$1(config, themeProvider, render) {
423
+ const renderPage = render ?? createRenderPage(config.distPath);
362
424
  const app = new App();
363
425
  const client = createAPIClient(config);
364
426
  const readFeatures = createFeaturesReader(client);
@@ -376,7 +438,7 @@ async function createHandler$1(config, themeProvider, render = renderPage) {
376
438
  app.use(defineCoreHandler({
377
439
  method: "get",
378
440
  path: "/authorize",
379
- fn: async (event) => render(event, config, {
441
+ fn: async (event) => renderPage(event, config, {
380
442
  url: "/authorize",
381
443
  data: await readAuthorizeInfo(client, event),
382
444
  theme
@@ -387,7 +449,7 @@ async function createHandler$1(config, themeProvider, render = renderPage) {
387
449
  path: page.url,
388
450
  fn: async (event) => {
389
451
  const features = await readFeatures();
390
- return render(event, config, {
452
+ return renderPage(event, config, {
391
453
  url: page.url,
392
454
  data: buildWorkflowPageData(event, features, page),
393
455
  theme
@@ -397,31 +459,60 @@ async function createHandler$1(config, themeProvider, render = renderPage) {
397
459
  app.use(defineCoreHandler({
398
460
  method: "get",
399
461
  path: "/logout",
400
- fn: async (event) => render(event, config, {
462
+ fn: async (event) => renderPage(event, config, {
401
463
  url: "/logout",
402
464
  data: {},
403
465
  theme
404
466
  })
405
467
  }));
406
- const distPath = resolveDistPath();
407
- if (distPath) app.use(ASSETS_PATH, createHandler(path.posix.join(distPath, "client", "assets"), {
408
- fallthrough: false,
409
- scan: false
468
+ app.use(defineCoreHandler({
469
+ method: "get",
470
+ path: "/device",
471
+ fn: async (event) => renderPage(event, config, {
472
+ url: "/device",
473
+ data: {
474
+ features: await readFeatures(),
475
+ userCode: readDeviceUserCode(event),
476
+ federatedLogin: readDeviceFederatedLogin(event),
477
+ error: readDeviceError(event)
478
+ },
479
+ theme
480
+ })
410
481
  }));
482
+ const distPath = resolveDistPath(config.distPath);
483
+ if (distPath) {
484
+ if (!render) await assertRenderContract(distPath);
485
+ app.use(ASSETS_PATH, createHandler(path.posix.join(distPath, "client", "assets"), {
486
+ fallthrough: false,
487
+ scan: false,
488
+ cacheMaxAge: 31536e3,
489
+ cacheImmutable: true
490
+ }));
491
+ }
411
492
  return app;
412
493
  }
413
494
  //#endregion
414
- //#region src/server.ts
495
+ //#region src/application.ts
415
496
  /**
416
- * The standalone service: the same handler the CLI mounts in process,
417
- * behind a listener of its own.
497
+ * This console as a runnable service: its own module graph, its own
498
+ * container, its own lifecycle, and nothing of server-core's. It is what
499
+ * `authup start console` starts, what the `authup-auth-console` bin starts, and what
500
+ * `authup start` composes onto its own listener, so no caller reaches past
501
+ * the graph for a bare handler.
502
+ *
503
+ * `config` defaults to a FACTORY, not a value: resolving it reads the
504
+ * document, and a console started alongside others must not do that at
505
+ * construction time, before the caller has said where to look. Pass
506
+ * `listen: false` to be mounted on someone else's listener.
418
507
  */
419
- async function createServer(config) {
420
- const app = new App();
421
- app.use(await createHandler$1(config));
422
- return app;
508
+ function createApplication$1(context = {}) {
509
+ return createApplication({
510
+ listen: context.listen,
511
+ config: context.config ?? readConfigFromEnv,
512
+ createHandler: (resolved, theme) => createHandler$1(resolved, theme)
513
+ });
423
514
  }
424
515
  //#endregion
425
- export { CONFIG_SCHEMA as _, resolvePackagePath as a, createAPIClient as c, sanitizeRelativeRedirect as d, ASSETS_PATH as f, VITE_BASE as g, PAGES as h, resolveDistPath as i, createFeaturesReader as l, HEALTH_PATH as m, createHandler$1 as n, setPackagePath as o, BASE_PATH as p, renderPage as r, buildWorkflowPageData as s, createServer as t, readAuthorizeInfo as u, readConfigFromEnv as v, resolveConfig as y };
516
+ export { CONFIG_SCHEMA as C, VITE_BASE as S, resolveConfig as T, ASSETS_PATH as _, resolveDistPath as a, HEALTH_PATH as b, createAPIClient as c, readDeviceError as d, readDeviceFederatedLogin as f, sanitizeRelativeRedirect as g, readUILocalesHint as h, createRenderPage as i, createFeaturesReader as l, readUIColorModeHint as m, createHandler$1 as n, resolvePackagePath as o, readDeviceUserCode as p, assertRenderContract as r, buildWorkflowPageData as s, createApplication$1 as t, readAuthorizeInfo as u, BASE_PATH as v, readConfigFromEnv as w, PAGES as x, CONTRACT_VERSION as y };
426
517
 
427
- //# sourceMappingURL=server-Brhsp_x-.mjs.map
518
+ //# sourceMappingURL=application-h8KbQSdz.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-h8KbQSdz.mjs","names":["createHandler","createAssetsHandler","createApplication","createConsoleApplication","createHandler"],"sources":["../src/config.ts","../src/constants.ts","../src/redirect.ts","../src/payload.ts","../src/path.ts","../src/resolve.ts","../src/render.ts","../src/handler.ts","../src/application.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n AUTH_CONSOLE_SCHEMA,\n CORE_SCHEMA,\n ROOT_SCHEMA,\n SECTION_KEY,\n THEME_SCHEMA,\n} from '@authup/server-config';\nimport {\n buildSchemaDefaults,\n defineSchema,\n mergeSchemaData,\n mountSchema,\n readSchemaFromEnv,\n resolveSchemaData,\n} from '@authup/server-config-kit';\nimport { Container } from 'validup';\nimport type { CoreConfig, EnvironmentVariable } from '@authup/server-config';\nimport type { Config, ConfigInput } from './types';\n\n/**\n * The keys this service reads, SELECTED out of the document schema by name.\n *\n * Nothing is declared here: every key of `authup.yml` is declared once in\n * `@authup/server-config`, so this service cannot spell a path, an\n * environment variable, a default or a reader differently from server-core,\n * which reads several of the same keys. Neither package depends on the other;\n * both depend on the declaration.\n *\n * Its own section is spread, so this service reads it in its own vocabulary\n * (`url`, `port`, `host`); every other section stays under the key the\n * document nests it at.\n */\nexport const CONFIG_SCHEMA = defineSchema<ConfigInput, 'publicUrl' | 'internalUrl' | 'db'>({\n ...AUTH_CONSOLE_SCHEMA,\n ...ROOT_SCHEMA,\n [SECTION_KEY.THEME]: THEME_SCHEMA,\n // Two keys of core, never the section. `publicUrl` derives from\n // the core listener address, which is what a console needs; selecting the\n // whole section also selects its INVARIANTS, and `resolveSchemaData` runs\n // every resolver in a registry -- so a console would refuse to start on a\n // short SECRETS_ENCRYPTION_KEY, or on mfaRequired without mfaEnabled, for\n // keys it has no database, key store or MFA to use.\n [SECTION_KEY.CORE]: defineSchema<Pick<CoreConfig, 'host' | 'port'>, never, EnvironmentVariable>({\n host: CORE_SCHEMA.host,\n port: CORE_SCHEMA.port,\n }),\n});\n\n/**\n * Turn the configuration namespace into the service's own shape: validate the\n * input against the declared zod types, fill the defaults, derive the one key\n * that is derived rather than configured, and rename. An empty `url` means the console sits on server-core's own origin\n * under the default segment, which is the single-origin deployment.\n *\n * The defaults are layered SECTION-AWARE ({@link mergeSchemaData}): a spread\n * would let an input carrying one key of a section replace the whole section\n * and take every other key's default with it.\n */\nexport async function resolveConfig(\n input: Partial<ConfigInput>,\n) : Promise<Config> {\n const validator = new Container<ConfigInput>();\n mountSchema(validator, CONFIG_SCHEMA);\n\n const parsed = await validator.run(input);\n\n const values = resolveSchemaData<ConfigInput>(\n CONFIG_SCHEMA,\n mergeSchemaData<ConfigInput>(\n CONFIG_SCHEMA,\n buildSchemaDefaults<ConfigInput>(CONFIG_SCHEMA),\n parsed,\n ),\n ) as ConfigInput;\n\n return {\n url: values.url,\n apiUrl: values.publicUrl,\n // `internalUrl` falls back to `publicUrl`, so an operator who has one\n // address for both sides configures nothing. The composed `authup\n // start` overrides this with its own listen address unless the\n // document named one.\n apiInternalUrl: values.internalUrl,\n port: values.port,\n host: values.host,\n distPath: values.path,\n theme: values.theme,\n };\n}\n\n/**\n * The standalone entry's configuration, read from the environment alone.\n * `authup.yml` reaches this service through the CLI roles, which compose this\n * very registry into the one document loader.\n */\nexport async function readConfigFromEnv() : Promise<Config> {\n // The explicit type argument is load-bearing: inferred from the schema\n // object, a key declared without a default (the derived publicUrl) comes\n // back as unknown.\n const input : Partial<ConfigInput> = readSchemaFromEnv<ConfigInput>(CONFIG_SCHEMA);\n\n return resolveConfig(input);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { CONTRACT_VERSION as BundleContractVersion } from '@authup/client-auth-console';\n\n/**\n * The render contract this service compiles against. The literal type fails\n * the build the moment the bundle's constant moves without this one.\n */\nexport const CONTRACT_VERSION : typeof BundleContractVersion = 5;\n\n/**\n * The vite base the auth console bundle is built with. Asset hrefs in the\n * shell are emitted against it, so the service mounts its assets there and\n * rebases them only when the deployment carries a sub-path.\n */\nexport const VITE_BASE = '/console/auth/';\n\n/**\n * The path the service is served under by default, i.e. the path component\n * of `authConsole.url`. It is the same segment server-core mounted\n * the assets at before the split, so a built bundle needs no rebuild.\n */\nexport const BASE_PATH = '/console/auth';\n\n/**\n * The pages the service renders. Each is a route of the console bundle's\n * own router, and each is what a server-core page GET now redirects to.\n */\nexport const PAGES = [\n '/authorize',\n '/register',\n '/activate',\n '/password-forgot',\n '/password-reset',\n '/logout',\n '/device',\n] as const;\n\n/**\n * Where this service mounts the bundle's `assets/` directory. The public\n * asset URL is the service's own public path plus this route, which is what\n * the bundle's fixed vite base is rebased onto.\n */\nexport const ASSETS_PATH = '/assets';\n\nexport const HEALTH_PATH = '/healthy';\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Open-redirect guard for the `redirect` query parameter carried by the\n * auth workflow pages: only same-origin relative paths pass through, so the\n * value can be safely reflected into an anchor href / forwarded as a\n * post-login destination.\n *\n * Rejects: non-strings, control/whitespace chars (browsers strip some,\n * shifting where the URL authority begins), protocol-relative (`//host`),\n * backslash variants (browsers normalise `\\` → `/`), and any scheme\n * (`javascript:`, `http:`) — both on the raw and once-decoded form so a\n * percent-encoded separator (`%2f`, `%5c`) can't slip past.\n */\nexport function sanitizeRelativeRedirect(input: unknown): string | undefined {\n if (typeof input !== 'string' || input.length === 0) {\n return undefined;\n }\n\n // Raw input: reject control chars AND whitespace (space/tab/newline) — a\n // raw space can shift where the URL authority begins.\n // eslint-disable-next-line no-control-regex\n if (/[\\u0000-\\u0020\\u007f]/.test(input)) {\n return undefined;\n }\n\n let decoded: string;\n try {\n decoded = decodeURIComponent(input);\n } catch {\n return undefined;\n }\n\n // Decoded form: reject C0 controls + DEL (CR/LF/NUL — the header-injection\n // vectors a `%0a`/`%0d` would smuggle past the raw check) but NOT space\n // (0x20), so a legitimate `%20` in the path still passes.\n // eslint-disable-next-line no-control-regex\n if (/[\\u0000-\\u001f\\u007f]/.test(decoded)) {\n return undefined;\n }\n\n for (const candidate of [input, decoded]) {\n if (!candidate.startsWith('/')) {\n return undefined;\n }\n if (candidate.length > 1 && (candidate[1] === '/' || candidate[1] === '\\\\')) {\n return undefined;\n }\n if (candidate.includes('\\\\')) {\n return undefined;\n }\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { AuthorizeInfo, StatusResponse, StatusResponseFeatures } from '@authup/core-http-kit';\nimport { Client } from '@authup/core-http-kit';\nimport { isUUID } from '@authup/kit';\nimport { OAuth2UIColorMode } from '@authup/specs';\nimport { useRequestQuery } from '@routup/basic/query';\nimport type { IAppEvent } from 'routup';\nimport { sanitizeRelativeRedirect } from './redirect';\nimport type { Config } from './types';\n\n/**\n * The service hydrates ANONYMOUSLY. It holds no credential of its own and\n * asks server-core only for what an unauthenticated visitor may see, which\n * is the whole of what these pages render.\n *\n * It dispatches against `apiInternalUrl`, never the browser-facing `apiUrl`:\n * this is a server-side call, so it must not depend on the public address\n * resolving from inside the deployment. Unlike server-core's own internal\n * client the swap is on `baseURL` rather than at the transport layer,\n * because nothing derived from it reaches a caller -- there is no\n * `redirect_uri` here to be compared byte for byte later.\n */\nexport function createAPIClient(config: Config) : Client {\n return new Client({ baseURL: config.apiInternalUrl });\n}\n\n/**\n * Report an outbound failure to the operator and raise one the visitor may\n * see, which is deliberately not the same error.\n *\n * hapic embeds the resolved request URL in its message, and this service has\n * no error middleware: routup answers with `event.error.message` verbatim, on\n * the public login page. That URL is `apiInternalUrl`, which on a split\n * deployment names a service on the operator's own network, so an API that is\n * merely down would publish its internal address to every anonymous visitor.\n * It was harmless while the value was `publicUrl`, an address the browser\n * already had.\n *\n * The rule and the remedy are server-core's own (`sanitizeError` /\n * `describeError`): the caller gets a message it can act on, the detail goes\n * to the log. `console.error` rather than a logger because a console handler\n * is built from a config alone and is given none -- and because this line is\n * the only trace such a failure leaves, which is how #3550 was diagnosed in\n * the first place.\n */\nfunction failWithoutAddress(error: unknown) : never {\n // eslint-disable-next-line no-console\n console.error('[authup] the auth console could not reach the API:', error);\n\n throw new Error('The identity provider could not be reached.');\n}\n\n/**\n * The feature flags every workflow page gates its form on. A page that\n * cannot reach them must not silently claim a workflow is disabled, so the\n * failure propagates rather than defaulting to false.\n *\n * Read ONCE and held for the reader's lifetime, the same shape render.ts\n * keeps for the dist template, manifest and render entry: `GET /` reports\n * the version and the boot-config feature flags, none of which changes\n * without a restart, so a TTL would be a number with nothing behind it.\n * Without it every workflow page render is an API call, and under the\n * composed `authup start` those all arrive over loopback on one shared\n * rate-limit key. Only a SUCCESS is held, so an API that was down at the\n * first render is retried rather than remembered as broken.\n *\n * The cache is instance-scoped rather than module-scoped (098 C4): the\n * answer depends on which API the client was built against, so two handlers\n * in one process must not share one, and a module slot would additionally\n * leak between test cases.\n */\nexport function createFeaturesReader(client: Client) : () => Promise<StatusResponseFeatures> {\n let cached : StatusResponseFeatures | undefined;\n let pending : Promise<StatusResponseFeatures> | undefined;\n\n return () => {\n if (cached) {\n return Promise.resolve(cached);\n }\n\n if (pending) {\n return pending;\n }\n\n pending = client.status.get()\n .then((status: StatusResponse) => {\n cached = status.features;\n\n return cached;\n })\n .catch((e) => failWithoutAddress(e));\n\n const clear = () => {\n pending = undefined;\n };\n pending.then(clear, clear);\n\n return pending;\n };\n}\n\n/**\n * The `/authorize` render input, resolved by server-core (plan 101 D2-1).\n * The browser's query is forwarded verbatim: the answer is derived from all\n * of it, the `provider` hint and the closed `error` marker set included.\n */\nexport async function readAuthorizeInfo(client: Client, event: IAppEvent) : Promise<AuthorizeInfo> {\n const { search } = new URL(event.request.url);\n\n try {\n return await client.authorize.getInfo(search);\n } catch (e) {\n return failWithoutAddress(e);\n }\n}\n\nexport type WorkflowPageOptions = {\n // Whether the page consumes the `realmId` (legacy `realm_id`) / `token`\n // query params (e.g. prefill from an email deep link). Off by default so\n // a page never reflects a param it doesn't use.\n realmAware?: boolean,\n tokenAware?: boolean,\n};\n\n/**\n * The payload the four workflow pages render from: the feature flags plus\n * the handful of query params each one declares. Unchanged from the\n * assembly server-core did before the split, including the open-redirect\n * guard on `redirect`.\n */\nexport function buildWorkflowPageData(\n event: IAppEvent,\n features: StatusResponseFeatures,\n options: WorkflowPageOptions = {},\n) : Record<string, any> {\n const query = useRequestQuery(event);\n\n const data: Record<string, any> = {\n features,\n redirect: sanitizeRelativeRedirect(query.redirect),\n };\n\n if (options.realmAware) {\n const realmId = typeof query.realmId === 'string' ? query.realmId : query.realm_id;\n data.realmId = typeof realmId === 'string' ? realmId : undefined;\n }\n\n if (options.tokenAware) {\n data.token = typeof query.token === 'string' ? query.token : undefined;\n }\n\n return data;\n}\n\n/**\n * The RP's own UI language, from the OIDC Core section 3.1.2.1 `ui_locales`\n * parameter: a space-separated list of BCP47 tags in preference order.\n *\n * It rides the authorization request, so it survives the page GET's hop and\n * the rebuild a federated round-trip makes from the stored code request. The\n * four workflow pages take it straight from their own query, since an RP\n * linking to one can say the same thing there.\n */\nexport function readUILocalesHint(event: IAppEvent) : string | undefined {\n const { ui_locales: uiLocales } = useRequestQuery(event);\n if (typeof uiLocales !== 'string') {\n return undefined;\n }\n\n // ponytail: the first well-formed tag wins, and it is NOT narrowed to a\n // locale authup has a catalog for. That is the latitude the navigator\n // path already takes -- a `de-CH` visitor is stamped `lang=\"de-CH\"` and\n // reads the `de` catalog. Narrow here (matchLocale over LOCALES) if the\n // lang attribute ever has to name only an authored locale, which costs\n // this service a dependency on @authup/i18n.\n return uiLocales\n .split(' ')\n .find((tag) => /^[a-zA-Z]{2,3}(-[a-zA-Z0-9]+)*$/.test(tag));\n}\n\n/**\n * The color mode the RP renders in, from authup's own `ui_color_mode`. One\n * value rather than a list, since there is nothing to negotiate.\n *\n * Checked against the enum rather than local literals because the realm's\n * discovery document ADVERTISES that same set as\n * `ui_color_modes_supported`: a second spelling here would let the pages and\n * the document disagree about what the deployment accepts.\n */\nexport function readUIColorModeHint(event: IAppEvent) : string | undefined {\n const { ui_color_mode: uiColorMode } = useRequestQuery(event);\n\n return typeof uiColorMode === 'string' &&\n (Object.values(OAuth2UIColorMode) as string[]).includes(uiColorMode) ?\n uiColorMode :\n undefined;\n}\n\n/**\n * The `user_code` the device page prefills (RFC 8628 section 3.3.1): the\n * query value uppercased and stripped of everything outside `A-Z0-9`, or\n * `undefined` when nothing bounded remains. The page renders it back, so what\n * reaches the payload is at most 16 alphanumeric characters.\n */\nexport function readDeviceUserCode(event: IAppEvent) : string | undefined {\n const query = useRequestQuery(event);\n if (typeof query.user_code !== 'string') {\n return undefined;\n }\n\n const canonical = query.user_code.toUpperCase().replace(/[^A-Z0-9]/g, '');\n if (canonical.length === 0 || canonical.length > 16) {\n return undefined;\n }\n\n return canonical;\n}\n\n/**\n * The provider a federated login on the device page came back from (#3589).\n * A routing hint and no secret: the pending login itself rides an HttpOnly\n * cookie. Anything that is not a uuid is dropped, the rule `/authorize`\n * reads its own hint by: the page interpolates the value into the\n * completion request path.\n */\nexport function readDeviceFederatedLogin(event: IAppEvent) : { providerId: string } | undefined {\n const { provider } = useRequestQuery(event);\n\n return typeof provider === 'string' && isUUID(provider) ?\n { providerId: provider } :\n undefined;\n}\n\n/**\n * The refusal marker the federated callback may attach. A closed set of one,\n * so nothing request-derived is rendered.\n */\nexport function readDeviceError(event: IAppEvent) : 'access_denied' | undefined {\n return useRequestQuery(event).error === 'access_denied' ? 'access_denied' : undefined;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport const CODE_PATH = path.dirname(fileURLToPath(import.meta.url));\nexport const PACKAGE_PATH = path.join(CODE_PATH, '..');\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { locateUpSync } from 'locter';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { PACKAGE_PATH } from './path';\n\n/**\n * Locate the auth console package: a substituted one (config `distPath`)\n * first, else the SSR auth workflow UI shipped as\n * `@authup/client-auth-console` (a dependency of THIS service), which the\n * node_modules ancestor walk from this package's own root (locter's\n * `locateUp`) finds for the workspace (symlink onto\n * apps/client-auth-console) and for a published install alike.\n *\n * The `cwd` anchor is behavioural, not incidental: it decides which\n * node_modules tree is walked, so it stays pinned to this package rather\n * than to the process cwd.\n */\nexport function resolvePackagePath(distPath?: string) : string | undefined {\n return distPath || locateUpSync(\n 'node_modules/@authup/client-auth-console/package.json',\n { cwd: PACKAGE_PATH },\n )?.directory;\n}\n\n/**\n * Locate the BUILT auth console bundle (`dist/client` template + assets,\n * `dist/server/server.js` render entry). A half-built package is no bundle:\n * without the render entry there is nothing to render with.\n */\nexport function resolveDistPath(distPath?: string) : string | undefined {\n const packagePath = resolvePackagePath(distPath);\n if (!packagePath) {\n return undefined;\n }\n\n const candidate = path.join(packagePath, 'dist');\n if (\n fs.existsSync(path.join(candidate, 'client', 'index.html')) &&\n fs.existsSync(path.join(candidate, 'server', 'server.js'))\n ) {\n return candidate;\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { HydrationPayload, RenderFunction } from '@authup/client-auth-console';\nimport { InternalError } from '@authup/errors';\nimport { getURLBasePath } from '@authup/kit';\nimport {\n applyTheme,\n applyUIPageHeaders,\n readUIClientPreferences,\n rebaseAssetURLs,\n replaceTemplateMarker,\n stampHtmlAttributes,\n} from '@authup/server-console-kit';\nimport { read } from 'locter';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { CONTRACT_VERSION, VITE_BASE } from './constants';\nimport { readUIColorModeHint, readUILocalesHint } from './payload';\nimport { resolveDistPath } from './resolve';\nimport type { RenderPage } from './types';\n\n/**\n * Refuse a bundle built against another render contract at boot, naming the\n * entry and both versions, instead of failing per request on `/authorize`.\n * A bundle predating the export is version 1. Reads the module itself, which\n * Node's ESM cache then hands the render for free.\n */\nexport async function assertRenderContract(distPath: string) : Promise<void> {\n const entry = path.join(distPath, 'server', 'server.js');\n const bundle = await read(entry) as Record<string, any>;\n const version = bundle.CONTRACT_VERSION ?? 1;\n\n if (version !== CONTRACT_VERSION) {\n throw new InternalError(\n `The auth console bundle \"${entry}\" implements render-contract version ${version}, ` +\n `but this service requires ${CONTRACT_VERSION}. ` +\n 'Rebuild it against the current @authup/client-auth-console contract.',\n );\n }\n}\n\nexport function createRenderPage(distPath?: string) : RenderPage {\n // Per-handler caches for the immutable production SSR assets: the dist\n // template, manifest and server bundle do not change after boot, so read\n // them once instead of per request (the auth/login routes are hot paths).\n // Held in this closure rather than at module scope so a second handler in\n // the process, with a substituted package, never renders another's\n // template. Only a resolved dist is kept, so a bundle built after boot is\n // picked up on the next request.\n let cachedDistPath: string | undefined;\n let cachedHtml: string | undefined;\n let cachedManifest: Record<string, any> | undefined;\n let cachedRender: RenderFunction | undefined;\n\n return async (event, config, ctx) => {\n const resolved = (cachedDistPath ??= resolveDistPath(distPath));\n if (!resolved) {\n throw new InternalError(\n 'The auth console bundle (@authup/client-auth-console) is not built or installed.',\n );\n }\n\n const html = (cachedHtml ??= await fs.promises.readFile(\n path.join(resolved, 'client', 'index.html'),\n 'utf-8',\n ));\n const manifest = (cachedManifest ??= JSON.parse(await fs.promises.readFile(\n path.join(resolved, 'client', '.vite', 'ssr-manifest.json'),\n 'utf-8',\n )));\n const render = (cachedRender ??= (await read(\n path.join(resolved, 'server', 'server.js'),\n )).render as RenderFunction);\n\n // The client app hydrates locale + color-mode from the payload, so it\n // adopts the same values the HTML shell is stamped with below.\n const preferences = readUIClientPreferences(event);\n\n // `ui_locales` is what the RP says the visitor is reading over there,\n // which is fresher than anything this origin knows about a visitor\n // arriving for the first time. It seeds the page only while they have\n // made no choice HERE: `vc-locale` holds `auto` until the switcher\n // writes a tag (@vuecs/locale never writes the resolved value back),\n // so an explicit choice keeps winning and the switcher cannot be\n // undone by the next authorize request carrying the hint. Seeding is\n // all it does -- the ref starts there, and nothing writes it back.\n if (!preferences.locale || preferences.locale === 'auto') {\n preferences.locale = readUILocalesHint(event) || preferences.locale;\n }\n\n // `ui_color_mode` the same way, and `system` is its `auto`: the\n // switcher is a binary toggle, so it only ever writes `light` or\n // `dark`, and anything else in the cookie means the visitor never\n // touched it here.\n if (!preferences.colorMode || preferences.colorMode === 'system') {\n preferences.colorMode = readUIColorModeHint(event) || preferences.colorMode;\n }\n\n // `baseURL` is server-core's public URL: the console derives its HTTP\n // client and its cookie path from it. `basePath` is where THIS service\n // is served, which is what the router and every inter-page href need.\n // Before the split the two were the same value; they are not any more,\n // so the console reads them separately.\n const basePath = getURLBasePath(config.url);\n\n const payload : HydrationPayload = {\n config: {\n baseURL: config.apiUrl,\n basePath,\n colorMode: preferences.colorMode,\n locale: preferences.locale,\n },\n data: ctx.data,\n };\n\n const [appHtml, preloadLinks] = await render({\n url: ctx.url,\n manifest,\n payload,\n });\n\n let body = replaceTemplateMarker(html, '<!--preload-links-->', preloadLinks);\n body = replaceTemplateMarker(body, '<!--app-html-->', appHtml);\n\n body = stampHtmlAttributes(body, preferences);\n\n // This service mounts the bundle's assets at its own /assets, so the\n // fixed vite base in every href is replaced by this service's public\n // path. The vite base was decided when the bundle was built and says\n // nothing about where the service is published.\n body = rebaseAssetURLs(body, VITE_BASE, `${basePath}/`);\n\n // The theme's own asset urls are built from the same base, and the\n // service mounts them under it, so a themed deployment needs no rule of\n // its own at the reverse proxy beyond the one that reaches this service.\n body = await applyTheme(body, ctx.theme, basePath);\n\n applyUIPageHeaders(event);\n\n return body;\n };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IThemeProvider } from '@authup/server-console-kit';\nimport {\n THEME_ASSET_MOUNT_PATH,\n createThemeAssetsHandler,\n createThemeProvider,\n} from '@authup/server-console-kit';\nimport { createHandler as createAssetsHandler } from '@routup/assets';\nimport { basic } from '@routup/basic';\nimport path from 'node:path';\nimport type { IApp } from 'routup';\nimport { App, defineCoreHandler } from 'routup';\nimport { ASSETS_PATH, HEALTH_PATH } from './constants';\nimport {\n buildWorkflowPageData,\n createAPIClient,\n createFeaturesReader,\n readAuthorizeInfo,\n readDeviceError,\n readDeviceFederatedLogin,\n readDeviceUserCode,\n} from './payload';\nimport { assertRenderContract, createRenderPage } from './render';\nimport { resolveDistPath } from './resolve';\nimport type { Config, RenderPage } from './types';\n\nconst WORKFLOW_PAGES : {\n url: string,\n realmAware?: boolean,\n tokenAware?: boolean\n}[] = [\n { url: '/register', realmAware: true },\n { url: '/activate', tokenAware: true },\n { url: '/password-forgot', realmAware: true },\n {\n url: '/password-reset',\n realmAware: true,\n tokenAware: true,\n },\n];\n\n/**\n * The service as a mountable routup handler, so the CLI can compose it onto\n * server-core's own listener for the single-container deployment while a\n * split deployment runs it behind its own server.\n *\n * The paths are prefix-free. authup assumes a prefix-stripping reverse\n * proxy, so a service published at `<origin>/console/auth` receives\n * `/authorize`, exactly as server-core received it before the split.\n */\nexport async function createHandler(\n config: Config,\n themeProvider?: IThemeProvider,\n render?: RenderPage,\n) : Promise<IApp> {\n const renderPage = render ?? createRenderPage(config.distPath);\n\n const app = new App();\n const client = createAPIClient(config);\n const readFeatures = createFeaturesReader(client);\n\n // The shell is stamped from the vc-locale / vc-color-mode cookies, and\n // without the plugin every cookie read answers undefined, which is a\n // silent flash of the wrong color mode on every full load. server-core\n // registers it globally, so a mounted handler inherits one; a standalone\n // service has nothing above it.\n app.use(basic({ cookie: true, query: true }));\n\n // A missing directory disables theming entirely: no provider is created\n // and the rendered pages are byte-identical to the un-themed ones, so the\n // default configuration pays nothing. An invalid manifest throws here and\n // fails the boot rather than surfacing per request.\n // Injected by the theme module when this runs inside the console\n // application; built here for a caller holding only a config.\n const theme = themeProvider ?? await createThemeProvider(config);\n\n app.use(defineCoreHandler({\n method: 'get',\n path: HEALTH_PATH,\n fn: () => ({ status: 'ok' }),\n }));\n\n if (theme) {\n app.use(THEME_ASSET_MOUNT_PATH, createThemeAssetsHandler(theme));\n }\n\n app.use(defineCoreHandler({\n method: 'get',\n path: '/authorize',\n fn: async (event) => renderPage(event, config, {\n url: '/authorize',\n data: await readAuthorizeInfo(client, event),\n theme,\n }),\n }));\n\n for (const page of WORKFLOW_PAGES) {\n app.use(defineCoreHandler({\n method: 'get',\n path: page.url,\n fn: async (event) => {\n const features = await readFeatures();\n\n return renderPage(event, config, {\n url: page.url,\n data: buildWorkflowPageData(event, features, page),\n theme,\n });\n },\n }));\n }\n\n // The logout page needs nothing resolved up front: it drives the\n // end-session call itself and renders from the answer, so the render\n // stays a pure shell and no request reaches server-core here.\n app.use(defineCoreHandler({\n method: 'get',\n path: '/logout',\n fn: async (event) => renderPage(event, config, {\n url: '/logout',\n data: {},\n theme,\n }),\n }));\n\n app.use(defineCoreHandler({\n method: 'get',\n path: '/device',\n fn: async (event) => renderPage(event, config, {\n url: '/device',\n data: {\n features: await readFeatures(),\n userCode: readDeviceUserCode(event),\n federatedLogin: readDeviceFederatedLogin(event),\n error: readDeviceError(event),\n },\n theme,\n }),\n }));\n\n // Only the assets directory is mounted, never dist/client itself: the\n // template and the ssr manifest are inputs of the render, not files to\n // serve. A missing bundle only disables the mount; the page routes\n // report the actionable error. A resolved one is checked against the\n // render contract here, unless a substituted render never reads it.\n const distPath = resolveDistPath(config.distPath);\n if (distPath) {\n if (!render) {\n await assertRenderContract(distPath);\n }\n\n // Every name carries a content hash, so a new build means new names.\n app.use(ASSETS_PATH, createAssetsHandler(\n path.posix.join(distPath, 'client', 'assets'),\n {\n fallthrough: false,\n scan: false,\n cacheMaxAge: 60 * 60 * 24 * 365,\n cacheImmutable: true,\n },\n ));\n }\n\n return app;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createApplication as createConsoleApplication } from '@authup/server-console-kit';\nimport type { CreateApplicationContext } from '@authup/server-console-kit';\nimport type { Application } from 'orkos';\nimport { readConfigFromEnv } from './config';\nimport { createHandler } from './handler';\nimport type { Config } from './types';\n\n/**\n * This console as a runnable service: its own module graph, its own\n * container, its own lifecycle, and nothing of server-core's. It is what\n * `authup start console` starts, what the `authup-auth-console` bin starts, and what\n * `authup start` composes onto its own listener, so no caller reaches past\n * the graph for a bare handler.\n *\n * `config` defaults to a FACTORY, not a value: resolving it reads the\n * document, and a console started alongside others must not do that at\n * construction time, before the caller has said where to look. Pass\n * `listen: false` to be mounted on someone else's listener.\n */\nexport function createApplication(\n context: Partial<Omit<CreateApplicationContext<Config>, 'createHandler'>> = {},\n) : Application {\n return createConsoleApplication<Config>({\n listen: context.listen,\n config: context.config ?? readConfigFromE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AACL"}
package/dist/bin.mjs CHANGED
@@ -1,20 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import { t as createServer, v as readConfigFromEnv } from "./server-Brhsp_x-.mjs";
3
- import { serve } from "routup/node";
2
+ import { t as createApplication } from "./application-h8KbQSdz.mjs";
3
+ import process from "node:process";
4
4
  //#region src/bin.ts
5
5
  /**
6
- * The standalone entry. It reads the keys this service declares from the
7
- * environment; `authup.yml` reaches the service through the CLI roles
8
- * (`authup start console auth`), which hand each factory its own section, and that
9
- * is also how it is started in practice.
6
+ * The standalone entry: the same application `authup start console auth`
7
+ * starts, configured from the environment alone. `authup.yml` reaches this
8
+ * service through the CLI roles, which hand each factory its own section, and
9
+ * that is also how it is started in practice.
10
10
  */
11
- const config = readConfigFromEnv();
12
- const app = await createServer(config);
13
- await serve(app, {
14
- port: config.port,
15
- hostname: config.host,
16
- silent: true
17
- }).ready();
11
+ const application = createApplication();
12
+ await application.setup();
13
+ const shutdown = () => application.teardown().then(() => process.exit(0), () => process.exit(1));
14
+ process.once("SIGINT", shutdown);
15
+ process.once("SIGTERM", shutdown);
18
16
  //#endregion
19
17
  export {};
20
18
 
package/dist/bin.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.mjs","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { serve } from 'routup/node';\nimport { readConfigFromEnv } from './config';\nimport { createServer } from './server';\n\n/**\n * The standalone entry. It reads the keys this service declares from the\n * environment; `authup.yml` reaches the service through the CLI roles\n * (`authup start console auth`), which hand each factory its own section, and that\n * is also how it is started in practice.\n */\nconst config = readConfigFromEnv();\nconst app = await createServer(config);\n\nconst server = serve(app, {\n port: config.port,\n hostname: config.host,\n silent: true,\n});\n\nawait server.ready();\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,SAAS,kBAAkB;AACjC,MAAM,MAAM,MAAM,aAAa,MAAM;AAQrC,MANe,MAAM,KAAK;CACtB,MAAM,OAAO;CACb,UAAU,OAAO;CACjB,QAAQ;AACZ,CAEW,CAAC,CAAC,MAAM"}
1
+ {"version":3,"file":"bin.mjs","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport process from 'node:process';\nimport { createApplication } from './application';\n\n/**\n * The standalone entry: the same application `authup start console auth`\n * starts, configured from the environment alone. `authup.yml` reaches this\n * service through the CLI roles, which hand each factory its own section, and\n * that is also how it is started in practice.\n */\nconst application = createApplication();\nawait application.setup();\n\nconst shutdown = () => application.teardown()\n .then(() => process.exit(0), () => process.exit(1));\nprocess.once('SIGINT', shutdown);\nprocess.once('SIGTERM', shutdown);\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,cAAc,kBAAkB;AACtC,MAAM,YAAY,MAAM;AAExB,MAAM,iBAAiB,YAAY,SAAS,CAAC,CACxC,WAAW,QAAQ,KAAK,CAAC,SAAS,QAAQ,KAAK,CAAC,CAAC;AACtD,QAAQ,KAAK,UAAU,QAAQ;AAC/B,QAAQ,KAAK,WAAW,QAAQ"}