@drfed/drfed 0.2.0-dev.714 → 0.2.0-dev.717
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/account-create.d.mts +1 -1
- package/dist/commands/account-create.mjs +3 -3
- package/dist/commands/account-create.mjs.map +1 -1
- package/dist/commands/account-program.mjs +1 -1
- package/dist/commands/account.mjs +1 -1
- package/dist/commands/migrate-program.mjs +1 -1
- package/dist/commands/migrate.mjs +1 -1
- package/dist/commands/web.mjs +1 -1
- package/dist/database-runtime.d.mts +1 -1
- package/dist/diagnostics.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +43 -3
- package/dist/index.mjs.map +1 -1
- package/dist/package-CkHM-SS9.mjs +6 -0
- package/dist/package-CkHM-SS9.mjs.map +1 -0
- package/dist/{parser-C0dRu62q.d.mts → parser-CjemP44P.d.mts} +9 -1
- package/dist/parser-CjemP44P.d.mts.map +1 -0
- package/dist/{parser-Czr4z4-a.mjs → parser-Dq9PWT_s.mjs} +26 -1
- package/dist/parser-Dq9PWT_s.mjs.map +1 -0
- package/package.json +10 -10
- package/dist/package-CeHzXSlM.mjs +0 -6
- package/dist/package-CeHzXSlM.mjs.map +0 -1
- package/dist/parser-C0dRu62q.d.mts.map +0 -1
- package/dist/parser-Czr4z4-a.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValueParser } from "@optique/core/valueparser";
|
|
2
1
|
import { Database } from "@drfed/models";
|
|
2
|
+
import { ValueParser } from "@optique/core/valueparser";
|
|
3
3
|
//#region src/commands/account-create.d.ts
|
|
4
4
|
/** Email validation with the same case-preserving normalization as login. */
|
|
5
5
|
declare const accountEmail: ValueParser<"sync", string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { message } from "@optique/core/message";
|
|
2
2
|
import { schema } from "@drfed/models";
|
|
3
|
-
import { normalizeEmail } from "@drfed/models/email";
|
|
4
3
|
import { uuidV7 } from "@drfed/models/uuid";
|
|
4
|
+
import { normalizeEmail as normalizeEmail$1 } from "@drfed/models/email";
|
|
5
5
|
//#region src/commands/account-create.ts
|
|
6
6
|
/** Email validation with the same case-preserving normalization as login. */
|
|
7
7
|
const accountEmail = {
|
|
@@ -13,7 +13,7 @@ const accountEmail = {
|
|
|
13
13
|
const value = input.trim();
|
|
14
14
|
const [local, host, extra] = value.split("@");
|
|
15
15
|
if (local == null || host == null || extra !== void 0 || /[\u0000-\u001f\u007f]/u.test(input) || /[\s/\\:#?%\[\]]/u.test(host) || !/^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[^"\\\u0000-\u001f\u007f]|\\[\u0020-\u007e])*")$/iu.test(local)) throw new Error();
|
|
16
|
-
const normalized = normalizeEmail(value);
|
|
16
|
+
const normalized = normalizeEmail$1(value);
|
|
17
17
|
const domain = normalized.slice(normalized.lastIndexOf("@") + 1);
|
|
18
18
|
if (domain.length > 253 || !domain.includes(".") || !domain.split(".").every((label) => label.length <= 63 && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/iu.test(label))) throw new Error();
|
|
19
19
|
return {
|
|
@@ -36,7 +36,7 @@ const accountEmail = {
|
|
|
36
36
|
function resolveAccountInput(email, name) {
|
|
37
37
|
const parsed = accountEmail.parse(email);
|
|
38
38
|
if (!parsed.success) throw new Error("Invalid account email.");
|
|
39
|
-
const normalizedEmail = normalizeEmail(parsed.value);
|
|
39
|
+
const normalizedEmail = normalizeEmail$1(parsed.value);
|
|
40
40
|
const normalizedName = name.trim();
|
|
41
41
|
if (Array.from(normalizedEmail).length > 255) throw new Error("Account email must be at most 255 characters.");
|
|
42
42
|
if (!normalizedName || normalizedName.includes("\0") || Array.from(normalizedName).length > 100) throw new Error("Account name must contain 1 to 100 characters.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-create.mjs","names":[],"sources":["../../src/commands/account-create.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\n// oxlint-disable no-control-regex no-useless-escape\n// Email syntax requires explicit control-character rejection and slash literals.\n\nimport { type Database, schema } from \"@drfed/models\";\nimport { normalizeEmail } from \"@drfed/models/email\";\nimport { uuidV7 } from \"@drfed/models/uuid\";\nimport { message } from \"@optique/core/message\";\nimport type { ValueParser } from \"@optique/core/valueparser\";\n\n/** Email validation with the same case-preserving normalization as login. */\nexport const accountEmail: ValueParser<\"sync\", string> = {\n mode: \"sync\",\n metavar: \"EMAIL\",\n placeholder: \"user@example.com\",\n parse(input) {\n try {\n const value = input.trim();\n const [local, host, extra] = value.split(\"@\");\n if (\n local == null ||\n host == null ||\n extra !== undefined ||\n /[\\u0000-\\u001f\\u007f]/u.test(input) ||\n /[\\s/\\\\:#?%\\[\\]]/u.test(host) ||\n !/^(?:[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+)*|\"(?:[^\"\\\\\\u0000-\\u001f\\u007f]|\\\\[\\u0020-\\u007e])*\")$/iu.test(\n local,\n )\n ) {\n throw new Error();\n }\n const normalized = normalizeEmail(value);\n const domain = normalized.slice(normalized.lastIndexOf(\"@\") + 1);\n if (\n domain.length > 253 ||\n !domain.includes(\".\") ||\n !domain\n .split(\".\")\n .every(\n (label) =>\n label.length <= 63 &&\n /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/iu.test(label),\n )\n ) {\n throw new Error();\n }\n return { success: true, value: normalized };\n } catch {\n return { success: false, error: message`Invalid account email.` };\n }\n },\n format: (value) => value,\n};\n\n/**\n * Validate and normalize account inputs before database acquisition.\n * @returns Email and trimmed name within the database column limits.\n */\nexport function resolveAccountInput(email: string, name: string) {\n const parsed = accountEmail.parse(email);\n if (!parsed.success) throw new Error(\"Invalid account email.\");\n const normalizedEmail = normalizeEmail(parsed.value);\n const normalizedName = name.trim();\n if (Array.from(normalizedEmail).length > 255) {\n throw new Error(\"Account email must be at most 255 characters.\");\n }\n if (\n !normalizedName ||\n normalizedName.includes(\"\\0\") ||\n Array.from(normalizedName).length > 100\n ) {\n throw new Error(\"Account name must contain 1 to 100 characters.\");\n }\n return { email: normalizedEmail, name: normalizedName };\n}\n\n/**\n * Create an unprivileged account, preserving every existing account field.\n * @returns Whether the account was created, with its stored public identity.\n */\nexport async function createAccount(\n db: Database,\n input: ReturnType<typeof resolveAccountInput>,\n) {\n const columns = {\n id: schema.accounts.id,\n email: schema.accounts.email,\n name: schema.accounts.name,\n admin: schema.accounts.admin,\n };\n const [created] = await db\n .insert(schema.accounts)\n .values({\n id: uuidV7(),\n email: input.email,\n name: input.name,\n admin: false,\n })\n .onConflictDoNothing({ target: schema.accounts.email })\n .returning(columns);\n if (created !== undefined) {\n return { status: \"created\" as const, account: created };\n }\n const existing = await db.query.accounts.findFirst({\n columns: { id: true, email: true, name: true, admin: true },\n where: { email: input.email },\n });\n if (existing === undefined) {\n throw new Error(\"Could not read the existing account.\");\n }\n return { status: \"exists\" as const, account: existing };\n}\n"],"mappings":";;;;;;AA0BA,MAAa,eAA4C;CACvD,MAAM;CACN,SAAS;CACT,aAAa;CACb,MAAM,OAAO;EACX,IAAI;GACF,MAAM,QAAQ,MAAM,KAAK;GACzB,MAAM,CAAC,OAAO,MAAM,SAAS,MAAM,MAAM,GAAG;GAC5C,IACE,SAAS,QACT,QAAQ,QACR,UAAU,KAAA,KACV,yBAAyB,KAAK,KAAK,KACnC,mBAAmB,KAAK,IAAI,KAC5B,CAAC,+HAA+H,KAC9H,KACF,GAEA,MAAM,IAAI,MAAM;GAElB,MAAM,
|
|
1
|
+
{"version":3,"file":"account-create.mjs","names":["normalizeEmail"],"sources":["../../src/commands/account-create.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\n// oxlint-disable no-control-regex no-useless-escape\n// Email syntax requires explicit control-character rejection and slash literals.\n\nimport { type Database, schema } from \"@drfed/models\";\nimport { normalizeEmail } from \"@drfed/models/email\";\nimport { uuidV7 } from \"@drfed/models/uuid\";\nimport { message } from \"@optique/core/message\";\nimport type { ValueParser } from \"@optique/core/valueparser\";\n\n/** Email validation with the same case-preserving normalization as login. */\nexport const accountEmail: ValueParser<\"sync\", string> = {\n mode: \"sync\",\n metavar: \"EMAIL\",\n placeholder: \"user@example.com\",\n parse(input) {\n try {\n const value = input.trim();\n const [local, host, extra] = value.split(\"@\");\n if (\n local == null ||\n host == null ||\n extra !== undefined ||\n /[\\u0000-\\u001f\\u007f]/u.test(input) ||\n /[\\s/\\\\:#?%\\[\\]]/u.test(host) ||\n !/^(?:[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+)*|\"(?:[^\"\\\\\\u0000-\\u001f\\u007f]|\\\\[\\u0020-\\u007e])*\")$/iu.test(\n local,\n )\n ) {\n throw new Error();\n }\n const normalized = normalizeEmail(value);\n const domain = normalized.slice(normalized.lastIndexOf(\"@\") + 1);\n if (\n domain.length > 253 ||\n !domain.includes(\".\") ||\n !domain\n .split(\".\")\n .every(\n (label) =>\n label.length <= 63 &&\n /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/iu.test(label),\n )\n ) {\n throw new Error();\n }\n return { success: true, value: normalized };\n } catch {\n return { success: false, error: message`Invalid account email.` };\n }\n },\n format: (value) => value,\n};\n\n/**\n * Validate and normalize account inputs before database acquisition.\n * @returns Email and trimmed name within the database column limits.\n */\nexport function resolveAccountInput(email: string, name: string) {\n const parsed = accountEmail.parse(email);\n if (!parsed.success) throw new Error(\"Invalid account email.\");\n const normalizedEmail = normalizeEmail(parsed.value);\n const normalizedName = name.trim();\n if (Array.from(normalizedEmail).length > 255) {\n throw new Error(\"Account email must be at most 255 characters.\");\n }\n if (\n !normalizedName ||\n normalizedName.includes(\"\\0\") ||\n Array.from(normalizedName).length > 100\n ) {\n throw new Error(\"Account name must contain 1 to 100 characters.\");\n }\n return { email: normalizedEmail, name: normalizedName };\n}\n\n/**\n * Create an unprivileged account, preserving every existing account field.\n * @returns Whether the account was created, with its stored public identity.\n */\nexport async function createAccount(\n db: Database,\n input: ReturnType<typeof resolveAccountInput>,\n) {\n const columns = {\n id: schema.accounts.id,\n email: schema.accounts.email,\n name: schema.accounts.name,\n admin: schema.accounts.admin,\n };\n const [created] = await db\n .insert(schema.accounts)\n .values({\n id: uuidV7(),\n email: input.email,\n name: input.name,\n admin: false,\n })\n .onConflictDoNothing({ target: schema.accounts.email })\n .returning(columns);\n if (created !== undefined) {\n return { status: \"created\" as const, account: created };\n }\n const existing = await db.query.accounts.findFirst({\n columns: { id: true, email: true, name: true, admin: true },\n where: { email: input.email },\n });\n if (existing === undefined) {\n throw new Error(\"Could not read the existing account.\");\n }\n return { status: \"exists\" as const, account: existing };\n}\n"],"mappings":";;;;;;AA0BA,MAAa,eAA4C;CACvD,MAAM;CACN,SAAS;CACT,aAAa;CACb,MAAM,OAA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S;EACtB,OAAO,OAAO,SAAS;CACzB;CACA,MAAM,CAAC,WAAW,MAAM,GACrB,OAAO,OAAO,QAAQ,CAAC,CACvB,OAAO;EACN,IAAI,OAAO;EACX,OAAO,MAAM;EACb,MAAM,MAAM;EACZ,OAAO;CACT,CAAC,CAAC,CACD,oBAAoB,EAAE,QAAQ,OAAO,SAAS,MAAM,CAAC,CAAC,CACtD,UAAU,OAAO;CACpB,IAAI,YAAY,KAAA,GACd,OAAO;EAAE,QAAQ;EAAoB,SAAS;CAAQ;CAExD,MAAM,WAAW,MAAM,GAAG,MAAM,SAAS,UAAU;EACjD,SAAS;GAAE,IAAI;GAAM,OAAO;GAAM,MAAM;GAAM,OAAO;EAAK;EAC1D,OAAO,EAAE,OAAO,MAAM,MAAM;CAC9B,CAAC;CACD,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MAAM,sCAAsC;CAExD,OAAO;EAAE,QAAQ;EAAmB,SAAS;CAAS;AACxD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { configurationBoolean, configurationProjection, configurationProvenance, configurationSettings, createConfigurationBindings } from "../configuration.mjs";
|
|
2
2
|
import { resolveDatabaseSettings } from "../database-settings.mjs";
|
|
3
|
-
import { r as valueOptionNames } from "../parser-
|
|
3
|
+
import { r as valueOptionNames } from "../parser-Dq9PWT_s.mjs";
|
|
4
4
|
import { accountEmail, resolveAccountInput } from "./account-create.mjs";
|
|
5
5
|
import { message } from "@optique/core/message";
|
|
6
6
|
import { map, optional, withDefault } from "@optique/core/modifiers";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "../package-
|
|
1
|
+
import { t as version } from "../package-CkHM-SS9.mjs";
|
|
2
2
|
import { OperationRegistry } from "../operations.mjs";
|
|
3
3
|
import { ResourceOwner } from "../resources.mjs";
|
|
4
4
|
import { openDatabaseRuntime } from "../database-runtime.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { configurationProjection, configurationProvenance, configurationSettings, createConfigurationBindings } from "../configuration.mjs";
|
|
2
2
|
import { resolveDatabaseSettings } from "../database-settings.mjs";
|
|
3
|
-
import { r as valueOptionNames } from "../parser-
|
|
3
|
+
import { r as valueOptionNames } from "../parser-Dq9PWT_s.mjs";
|
|
4
4
|
import { message } from "@optique/core/message";
|
|
5
5
|
import { map, optional, withDefault } from "@optique/core/modifiers";
|
|
6
6
|
import { integer, string, url } from "@optique/core/valueparser";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "../package-
|
|
1
|
+
import { t as version } from "../package-CkHM-SS9.mjs";
|
|
2
2
|
import { OperationRegistry } from "../operations.mjs";
|
|
3
3
|
import { ResourceOwner } from "../resources.mjs";
|
|
4
4
|
import { openDatabaseRuntime } from "../database-runtime.mjs";
|
package/dist/commands/web.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "../package-
|
|
1
|
+
import { t as version } from "../package-CkHM-SS9.mjs";
|
|
2
2
|
import { OperationRegistry } from "../operations.mjs";
|
|
3
3
|
import { ResourceOwner } from "../resources.mjs";
|
|
4
4
|
import { createWebProgram, describeWebConfiguration, resolveWebOptions } from "./web-program.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ServerOptions } from "./parser-
|
|
1
|
+
import { t as ServerOptions } from "./parser-CjemP44P.mjs";
|
|
2
2
|
import { ResourceOwner } from "./resources.mjs";
|
|
3
3
|
import { Database, inspectMigrationState } from "@drfed/models";
|
|
4
4
|
import postgres from "postgres";
|
package/dist/diagnostics.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as ConfigurationSource, t as ConfigurationArea } from "./configuration-368lwC4r.mjs";
|
|
2
|
-
import { t as ServerOptions } from "./parser-
|
|
2
|
+
import { t as ServerOptions } from "./parser-CjemP44P.mjs";
|
|
3
3
|
//#region src/diagnostics.d.ts
|
|
4
4
|
/** A value and its provenance in safe configuration diagnostics. */
|
|
5
5
|
interface ConfigurationDiagnosticSetting {
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";iBAsSsB,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-CkHM-SS9.mjs";
|
|
2
2
|
import { createConfigurationBindings } from "./configuration.mjs";
|
|
3
3
|
import { describeServerConfiguration } from "./diagnostics.mjs";
|
|
4
4
|
import { OperationRegistry } from "./operations.mjs";
|
|
5
|
-
import { n as resolveOptions, r as valueOptionNames, t as createParser } from "./parser-
|
|
5
|
+
import { n as resolveOptions, r as valueOptionNames, t as createParser } from "./parser-Dq9PWT_s.mjs";
|
|
6
6
|
import { ResourceOwner } from "./resources.mjs";
|
|
7
7
|
import { openDatabaseRuntime } from "./database-runtime.mjs";
|
|
8
8
|
import { n as prepareMail, t as createMailRuntime } from "./mail-runtime-YROIQ8up.mjs";
|
|
@@ -21,12 +21,38 @@ import { message, text } from "@optique/core/message";
|
|
|
21
21
|
import { createLoggingConfig } from "@optique/logtape";
|
|
22
22
|
import { printError, run } from "@optique/run";
|
|
23
23
|
import { serve } from "srvx";
|
|
24
|
+
import { MigrationPreparationError, normalizeEmail, schema } from "@drfed/models";
|
|
25
|
+
import { generateLoginChallengeCode } from "@drfed/models/login";
|
|
26
|
+
import { loginChallenges } from "@drfed/models/schema";
|
|
27
|
+
import { uuidV7 } from "@drfed/models/uuid";
|
|
24
28
|
import { multiple } from "@optique/core/modifiers";
|
|
25
29
|
import { string } from "@optique/core/valueparser";
|
|
26
30
|
import { object } from "@optique/core/constructs";
|
|
27
31
|
import { argument, option, passThrough } from "@optique/core/primitives";
|
|
28
32
|
import { parse } from "@optique/core/parser";
|
|
29
|
-
|
|
33
|
+
//#region src/dev-login.ts
|
|
34
|
+
/**
|
|
35
|
+
* Creates a login challenge for an existing account and composes the link
|
|
36
|
+
* that completes it on the web frontend, without sending any mail. The link
|
|
37
|
+
* follows the verify URL the frontend's sign-in page sends to `loginByEmail`.
|
|
38
|
+
* @param db The database to look the account up in and store the challenge.
|
|
39
|
+
* @param email The email address of the account to log in as.
|
|
40
|
+
* @param origin The web frontend origin that serves the confirmation page.
|
|
41
|
+
* @returns The login link, or `undefined` if no account has the address.
|
|
42
|
+
*/
|
|
43
|
+
async function createLoginLink(db, email, origin) {
|
|
44
|
+
const account = await db.query.accounts.findFirst({ where: { email: normalizeEmail(email) } });
|
|
45
|
+
if (account == null) return void 0;
|
|
46
|
+
const id = uuidV7();
|
|
47
|
+
const code = generateLoginChallengeCode();
|
|
48
|
+
await db.insert(loginChallenges).values({
|
|
49
|
+
id,
|
|
50
|
+
accountId: account.id,
|
|
51
|
+
code
|
|
52
|
+
});
|
|
53
|
+
return new URL(`/confirm/${id}?code=${code}`, origin);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
30
56
|
//#region src/program.ts
|
|
31
57
|
/**
|
|
32
58
|
* Select operational vs schema bindings through a resource-free Optique pass.
|
|
@@ -259,6 +285,8 @@ async function runServer(configuration) {
|
|
|
259
285
|
await ownedServer.serve();
|
|
260
286
|
});
|
|
261
287
|
if (options.publicOrigin !== void 0) getLogger(["drfed", "server"]).info("Web frontend is available at {origin}.", { origin: options.publicOrigin.origin });
|
|
288
|
+
const { loginLink } = options;
|
|
289
|
+
if (loginLink !== void 0) await operations.run(() => logLoginLink(db, loginLink.email, loginLink.origin));
|
|
262
290
|
} catch (error) {
|
|
263
291
|
process.off("SIGINT", shutdown);
|
|
264
292
|
process.off("SIGTERM", shutdown);
|
|
@@ -274,6 +302,18 @@ async function runServer(configuration) {
|
|
|
274
302
|
throw new Error("Could not start the server.", { cause: error });
|
|
275
303
|
}
|
|
276
304
|
}
|
|
305
|
+
async function logLoginLink(db, email, origin) {
|
|
306
|
+
const logger = getLogger(["drfed", "server"]);
|
|
307
|
+
const link = await createLoginLink(db, email, origin);
|
|
308
|
+
if (link === void 0) {
|
|
309
|
+
logger.warn("Cannot create a login link; no account has {email}.", { email });
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
logger.info("Log in as {email} at {link}.", {
|
|
313
|
+
email,
|
|
314
|
+
link: link.href
|
|
315
|
+
});
|
|
316
|
+
}
|
|
277
317
|
async function runSchemaGenerator(options) {
|
|
278
318
|
const [{ schema }, { printSchema }] = await Promise.all([import("@drfed/graphql/schema"), import("graphql")]);
|
|
279
319
|
const schemaCode = printSchema(schema);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["metadata.version"],"sources":["../src/program.ts","../src/runtime-options.ts","../src/seed.ts","../src/index.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { object } from \"@optique/core/constructs\";\nimport { message } from \"@optique/core/message\";\nimport { multiple } from \"@optique/core/modifiers\";\nimport { type InferValue, parse } from \"@optique/core/parser\";\nimport { argument, option, passThrough } from \"@optique/core/primitives\";\nimport type { Program } from \"@optique/core/program\";\nimport { string } from \"@optique/core/valueparser\";\n\nimport { createConfigurationBindings } from \"./configuration.ts\";\nimport { createParser, valueOptionNames } from \"./parser.ts\";\n\n/**\n * Select operational vs schema bindings through a resource-free Optique pass.\n * The final parser still strictly validates every token. This pass consumes no\n * environment/config values and honors Optique's option terminator semantics.\n * @returns The mode whose setting bindings the complete invocation needs.\n */\nexport function selectInvocationMode(\n args: readonly string[],\n): \"server\" | \"schema\" {\n const [first, ...aliases] = Object.values(valueOptionNames).flat();\n if (first === undefined) {\n throw new Error(\"Missing CLI value-option definitions.\");\n }\n const selected = parse(\n object({\n schema: option(\"--generate-graphql-schema\"),\n optionValues: multiple(option(first, ...aliases, string())),\n extra: passThrough({ format: \"nextToken\" }),\n values: multiple(argument(string())),\n }),\n args,\n );\n return selected.success && selected.value.schema ? \"schema\" : \"server\";\n}\n\n/**\n * Create independent CLI bindings for one invocation.\n * @returns The program, its source contexts and explicit configuration loader.\n */\nexport function createProgram(\n options: Parameters<typeof createConfigurationBindings>[0] & {\n readonly mode?: \"server\" | \"schema\";\n } = {},\n) {\n const bindings = createConfigurationBindings(options);\n const parser = createParser(bindings, options.mode);\n const program: Program<\"sync\", InferValue<typeof parser>> = {\n metadata: {\n description: message`Run a DrFed server.`,\n name: \"drfed-server\",\n },\n parser,\n };\n return { program, contexts: bindings.contexts, load: bindings.load };\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { MigrationPreparationError } from \"@drfed/models\";\nimport type { Transport } from \"@upyo/core\";\n\nimport {\n type DatabaseRuntime,\n openDatabaseRuntime,\n} from \"./database-runtime.ts\";\nimport { createMailRuntime, prepareMail } from \"./mail-runtime.ts\";\nimport type { ServerOptions } from \"./parser.ts\";\nimport type { ResourceOwner } from \"./resources.ts\";\n\ninterface ServerRuntime extends Omit<ServerOptions, \"drizzle\"> {\n readonly drizzle: DatabaseRuntime & { readonly migrate: boolean };\n readonly mailer: Transport;\n}\n\n/**\n * Create resources only after the server command has been parsed successfully.\n * @returns Runtime resources owned by the selected server command.\n */\nexport async function createServerRuntime(\n options: ServerOptions,\n owner: ResourceOwner,\n signal?: AbortSignal,\n): Promise<ServerRuntime> {\n const preparedMail = await prepareMail(options.mail, signal);\n const database = await openDatabaseRuntime(\n options.drizzle,\n owner,\n options.drizzle.migrate ? \"apply\" : \"inspect\",\n signal,\n );\n if (database.state.status !== \"ready\") {\n throw new MigrationPreparationError(\"incompatible-history\", database.state);\n }\n if (signal?.aborted) throw new MigrationPreparationError(\"aborted\");\n const mail = createMailRuntime(preparedMail);\n owner.register(mail, (runtime) => runtime.close(), { owned: true });\n return {\n ...options,\n drizzle: { ...database, migrate: options.drizzle.migrate },\n mailer: mail.transport,\n };\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { type Database, schema } from \"@drfed/models\";\n\nexport default async function seedData(db: Database): Promise<void> {\n await db.transaction(async (tx) => {\n await seedAccounts(tx);\n });\n}\n\nconst sessionId = \"00000000-0000-4000-8000-000000000000\";\nconst accountId = \"00000000-0000-4000-8000-000000000001\";\nconst memberId = \"00000000-0000-4000-8000-000000000002\";\nconst pendingMemberId = \"00000000-0000-4000-8000-000000000003\";\nconst created = Temporal.Instant.from(\"2026-06-24T00:00:00.000Z\");\nconst tokenHash = \"dev-token-hash\";\n\nasync function seedAccounts(db: Database): Promise<void> {\n await db\n .insert(schema.accounts)\n .values([\n {\n id: accountId,\n email: \"owner@example.com\",\n name: \"Owner\",\n created,\n },\n {\n id: memberId,\n email: \"member@example.com\",\n name: \"Member\",\n created,\n },\n {\n id: pendingMemberId,\n email: \"pending@example.com\",\n name: \"Pending\",\n created,\n },\n ])\n .onConflictDoNothing();\n await db\n .insert(schema.sessions)\n .values([\n {\n id: sessionId,\n accountId,\n tokenHash,\n },\n ])\n .onConflictDoUpdate({\n target: schema.sessions.id,\n set: { tokenHash },\n });\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { writeFile } from \"node:fs/promises\";\nimport process from \"node:process\";\n\nimport createFederation, { createInboundRecorder } from \"@drfed/federation\";\nimport { KeyGenerationQueue } from \"@drfed/federation/task-queue\";\nimport { createYogaServer } from \"@drfed/graphql\";\nimport { type WebRuntime, createWebRuntime } from \"@drfed/web\";\nimport { PgliteKvStore } from \"@fedify/pglite\";\nimport { PostgresKvStore } from \"@fedify/postgres\";\nimport {\n configure,\n dispose,\n getConsoleSink,\n getLogger,\n} from \"@logtape/logtape\";\nimport { text } from \"@optique/core/message\";\nimport { createLoggingConfig } from \"@optique/logtape\";\nimport { printError, run } from \"@optique/run\";\nimport { serve } from \"srvx\";\n\nimport metadata from \"../package.json\" with { type: \"json\" };\nimport { describeServerConfiguration } from \"./diagnostics.ts\";\nimport { OperationRegistry } from \"./operations.ts\";\nimport {\n type Options,\n type SchemaGeneratorOptions,\n type ServerOptions,\n resolveOptions,\n} from \"./parser.ts\";\nimport { createProgram, selectInvocationMode } from \"./program.ts\";\nimport { ResourceOwner } from \"./resources.ts\";\nimport { createServerRuntime } from \"./runtime-options.ts\";\nimport seedData from \"./seed.ts\";\nimport {\n createControlSurface,\n createFetchHandler,\n getIngressMetadata,\n warnAboutStrandedInstances,\n} from \"./serving.ts\";\n\nasync function runServer(configuration: ServerOptions) {\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n owner.register(null, () => dispose(), { owned: true });\n let server: ReturnType<typeof serve> | undefined;\n let closing: Promise<void> | undefined;\n let signalled = false;\n\n async function cleanup(): Promise<void> {\n operations.abort();\n const errors: unknown[] = [];\n let forced: Promise<void> | undefined;\n const forceTimer = setTimeout(() => {\n if (server == null) return;\n const currentServer = server;\n forced = (async () => {\n try {\n await currentServer.close(true);\n } catch (error) {\n errors.push(error);\n }\n })();\n }, 5000);\n try {\n const results = await Promise.allSettled([\n server?.close(),\n operations.drain(),\n ]);\n for (const result of results) {\n if (result.status === \"rejected\") errors.push(result.reason);\n }\n if (forced != null) await forced;\n } finally {\n clearTimeout(forceTimer);\n try {\n await owner.close();\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(errors, \"Server cleanup failed.\");\n }\n }\n\n function stop(): Promise<void> {\n // Assign before invoking abort callbacks so reentrant cleanup is shared.\n // oxlint-disable-next-line promise/prefer-await-to-then\n return (closing ??= Promise.resolve().then(cleanup));\n }\n\n function shutdown(): void {\n if (signalled) process.exit(1);\n signalled = true;\n const deadline = setTimeout(() => process.exit(1), 10_000);\n // oxlint-disable promise/prefer-await-to-then\n void stop().then(\n () => {\n clearTimeout(deadline);\n process.exit(0);\n },\n () => process.exit(1),\n );\n // oxlint-enable promise/prefer-await-to-then\n }\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n try {\n const options = await operations.run((signal) =>\n createServerRuntime(configuration, owner, signal),\n );\n const { credentials, db } = options.drizzle;\n if (options.seed) await operations.run(() => seedData(db));\n const kv =\n \"driver\" in credentials\n ? new PgliteKvStore(credentials.client)\n : new PostgresKvStore(credentials.client);\n const federation = await operations.run(() =>\n createFederation(db, {\n kv,\n queue: { task: new KeyGenerationQueue() },\n taskQueueResolution: \"strict\",\n manuallyStartQueue: true,\n allowPrivateAddress: true,\n }),\n );\n // The registry drains the worker before owned database cleanup.\n void (async () => {\n try {\n await operations.run((signal) =>\n federation.startQueue(undefined, { queue: \"task\", signal }),\n );\n } catch {\n if (!operations.signal.aborted) {\n getLogger([\"drfed\", \"server\"]).error(\n \"Actor key worker stopped unexpectedly.\",\n );\n }\n }\n })();\n const { emailFrom, mailer, rootOrigin, loginOrigins } = options;\n const yogaServer = createYogaServer(db, federation, {\n rootOrigin,\n emailFrom,\n mailer,\n loginOrigins,\n trackOperation: (operation) => operations.track(operation),\n shutdownSignal: operations.signal,\n });\n await operations.run(() => warnAboutStrandedInstances(db, rootOrigin));\n let web: WebRuntime | undefined;\n if (options.web) {\n const { publicOrigin } = options;\n if (publicOrigin === undefined) {\n throw new Error(\"Missing public web origin.\");\n }\n web = await operations.run(async (signal) => {\n const runtime = owner.register(\n await createWebRuntime({\n publicOrigin,\n graphqlFetch: (request) =>\n operations.track(() => yogaServer.fetch(request)),\n }),\n (resource) => resource.close(),\n { owned: true },\n );\n signal.throwIfAborted();\n return runtime;\n });\n }\n const fetchHandler = createFetchHandler({\n federation: createInboundRecorder({\n db,\n federation,\n rootOrigin,\n ingressMetadata: getIngressMetadata,\n }),\n rootOrigin,\n serveControlSurface: createControlSurface({\n graphql: yogaServer.fetch,\n ...(web === undefined ? {} : { web: web.fetch }),\n }),\n });\n const ownedServer = owner.register(\n serve({\n async fetch(request) {\n if (operations.signal.aborted) {\n return new Response(\"Server is stopping.\", { status: 503 });\n }\n try {\n return await operations.run(() => fetchHandler(request));\n } catch (error) {\n if (operations.signal.aborted) {\n return new Response(\"Server is stopping.\", { status: 503 });\n }\n throw error;\n }\n },\n hostname: options.address.host,\n manual: true,\n gracefulShutdown: false,\n port: options.address.port,\n }),\n (resource) => resource.close(true),\n { owned: true },\n );\n server = ownedServer;\n await operations.run(async () => {\n await ownedServer.serve();\n });\n if (options.publicOrigin !== undefined) {\n getLogger([\"drfed\", \"server\"]).info(\n \"Web frontend is available at {origin}.\",\n { origin: options.publicOrigin.origin },\n );\n }\n } catch (error) {\n process.off(\"SIGINT\", shutdown);\n process.off(\"SIGTERM\", shutdown);\n const deadline = Promise.withResolvers<never>();\n const timeout = setTimeout(\n () => deadline.reject(new Error(\"Startup cleanup timed out.\")),\n 10_000,\n );\n try {\n await Promise.race([stop(), deadline.promise]);\n } catch {\n throw new Error(\"Database cleanup after startup failure failed.\", {\n cause: error,\n });\n } finally {\n clearTimeout(timeout);\n }\n throw new Error(\"Could not start the server.\", { cause: error });\n }\n}\n\nasync function runSchemaGenerator(\n options: SchemaGeneratorOptions,\n): Promise<void> {\n const [{ schema }, { printSchema }] = await Promise.all([\n import(\"@drfed/graphql/schema\"),\n import(\"graphql\"),\n ]);\n const schemaCode = printSchema(schema);\n if (options.outputFile === \"-\") {\n // oxlint-disable-next-line no-console\n console.log(schemaCode);\n return;\n }\n await writeFile(options.outputFile, schemaCode, { encoding: \"utf-8\" });\n}\n\nexport async function main(): Promise<void> {\n const invocation = createProgram({\n mode: selectInvocationMode(process.argv.slice(2)),\n });\n let options: Options;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: {\n load: (parsed) =>\n parsed.mode[0] === \"schema\" ? undefined : invocation.load(parsed),\n },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: {\n option: true,\n value: metadata.version,\n },\n });\n options = resolveOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (\"generateGraphqlSchema\" in options) {\n await runSchemaGenerator(options);\n return;\n }\n if (options.printConfig) {\n console.log(JSON.stringify(describeServerConfiguration(options), null, 2));\n return;\n }\n let loggingConfig: Awaited<ReturnType<typeof createLoggingConfig>>;\n try {\n loggingConfig = await createLoggingConfig(\n options.logging,\n {},\n {\n contextLocalStorage: new AsyncLocalStorage(),\n sinks: {\n stderr: getConsoleSink({\n levelMap: {\n trace: \"error\",\n debug: \"error\",\n info: \"error\",\n warning: \"error\",\n error: \"error\",\n fatal: \"error\",\n },\n }),\n },\n loggers: [\n {\n category: [\"logtape\", \"meta\"],\n lowestLevel: \"warning\",\n sinks: [\"stderr\"],\n },\n ],\n },\n );\n } catch {\n printError([\n text(\"Could not initialize logging; check the log output path.\"),\n ]);\n process.exitCode = 1;\n return;\n }\n await configure(loggingConfig);\n\n await runServer(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,qBACd,MACqB;CACrB,MAAM,CAAC,OAAO,GAAG,WAAW,OAAO,OAAO,gBAAgB,CAAC,CAAC,KAAK;CACjE,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,uCAAuC;CAEzD,MAAM,WAAW,MACf,OAAO;EACL,QAAQ,OAAO,2BAA2B;EAC1C,cAAc,SAAS,OAAO,OAAO,GAAG,SAAS,OAAO,CAAC,CAAC;EAC1D,OAAO,YAAY,EAAE,QAAQ,YAAY,CAAC;EAC1C,QAAQ,SAAS,SAAS,OAAO,CAAC,CAAC;CACrC,CAAC,GACD,IACF;CACA,OAAO,SAAS,WAAW,SAAS,MAAM,SAAS,WAAW;AAChE;;;;;AAMA,SAAgB,cACd,UAEI,CAAC,GACL;CACA,MAAM,WAAW,4BAA4B,OAAO;CACpD,MAAM,SAAS,aAAa,UAAU,QAAQ,IAAI;CAQlD,OAAO;EAAE,SAAA;GANP,UAAU;IACR,aAAa,OAAO;IACpB,MAAM;GAC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M,oBACpB,QAAQ,SACR,CAAC,GACD;GACE,qBAAqB,IAAI,kBAAkB;GAC3C,OAAO,EACL,QAAQ,eAAe,EACrB,UAAU;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;GACT,EACF,CAAC,EACH;GACA,SAAS,CACP;IACE,UAAU,CAAC,WAAW,MAAM;IAC5B,aAAa;IACb,OAAO,CAAC,QAAQ;GAClB,CACF;EACF,CACF;CACF,QAAQ;EACN,WAAW,CACT,KAAK,0DAA0D,CACjE,CAAC;EACD,QAAQ,WAAW;EACnB;CACF;CACA,MAAM,UAAU,aAAa;CAE7B,MAAM,UAAU,OAAO;AACzB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["metadata.version"],"sources":["../src/dev-login.ts","../src/program.ts","../src/runtime-options.ts","../src/seed.ts","../src/index.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { type Database, normalizeEmail } from \"@drfed/models\";\nimport { generateLoginChallengeCode } from \"@drfed/models/login\";\nimport { loginChallenges } from \"@drfed/models/schema\";\nimport { uuidV7 } from \"@drfed/models/uuid\";\n\n/**\n * Creates a login challenge for an existing account and composes the link\n * that completes it on the web frontend, without sending any mail. The link\n * follows the verify URL the frontend's sign-in page sends to `loginByEmail`.\n * @param db The database to look the account up in and store the challenge.\n * @param email The email address of the account to log in as.\n * @param origin The web frontend origin that serves the confirmation page.\n * @returns The login link, or `undefined` if no account has the address.\n */\nexport async function createLoginLink(\n db: Database,\n email: string,\n origin: string,\n): Promise<URL | undefined> {\n const account = await db.query.accounts.findFirst({\n where: { email: normalizeEmail(email) },\n });\n if (account == null) return undefined;\n const id = uuidV7();\n const code = generateLoginChallengeCode();\n await db.insert(loginChallenges).values({ id, accountId: account.id, code });\n return new URL(`/confirm/${id}?code=${code}`, origin);\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { object } from \"@optique/core/constructs\";\nimport { message } from \"@optique/core/message\";\nimport { multiple } from \"@optique/core/modifiers\";\nimport { type InferValue, parse } from \"@optique/core/parser\";\nimport { argument, option, passThrough } from \"@optique/core/primitives\";\nimport type { Program } from \"@optique/core/program\";\nimport { string } from \"@optique/core/valueparser\";\n\nimport { createConfigurationBindings } from \"./configuration.ts\";\nimport { createParser, valueOptionNames } from \"./parser.ts\";\n\n/**\n * Select operational vs schema bindings through a resource-free Optique pass.\n * The final parser still strictly validates every token. This pass consumes no\n * environment/config values and honors Optique's option terminator semantics.\n * @returns The mode whose setting bindings the complete invocation needs.\n */\nexport function selectInvocationMode(\n args: readonly string[],\n): \"server\" | \"schema\" {\n const [first, ...aliases] = Object.values(valueOptionNames).flat();\n if (first === undefined) {\n throw new Error(\"Missing CLI value-option definitions.\");\n }\n const selected = parse(\n object({\n schema: option(\"--generate-graphql-schema\"),\n optionValues: multiple(option(first, ...aliases, string())),\n extra: passThrough({ format: \"nextToken\" }),\n values: multiple(argument(string())),\n }),\n args,\n );\n return selected.success && selected.value.schema ? \"schema\" : \"server\";\n}\n\n/**\n * Create independent CLI bindings for one invocation.\n * @returns The program, its source contexts and explicit configuration loader.\n */\nexport function createProgram(\n options: Parameters<typeof createConfigurationBindings>[0] & {\n readonly mode?: \"server\" | \"schema\";\n } = {},\n) {\n const bindings = createConfigurationBindings(options);\n const parser = createParser(bindings, options.mode);\n const program: Program<\"sync\", InferValue<typeof parser>> = {\n metadata: {\n description: message`Run a DrFed server.`,\n name: \"drfed-server\",\n },\n parser,\n };\n return { program, contexts: bindings.contexts, load: bindings.load };\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { MigrationPreparationError } from \"@drfed/models\";\nimport type { Transport } from \"@upyo/core\";\n\nimport {\n type DatabaseRuntime,\n openDatabaseRuntime,\n} from \"./database-runtime.ts\";\nimport { createMailRuntime, prepareMail } from \"./mail-runtime.ts\";\nimport type { ServerOptions } from \"./parser.ts\";\nimport type { ResourceOwner } from \"./resources.ts\";\n\ninterface ServerRuntime extends Omit<ServerOptions, \"drizzle\"> {\n readonly drizzle: DatabaseRuntime & { readonly migrate: boolean };\n readonly mailer: Transport;\n}\n\n/**\n * Create resources only after the server command has been parsed successfully.\n * @returns Runtime resources owned by the selected server command.\n */\nexport async function createServerRuntime(\n options: ServerOptions,\n owner: ResourceOwner,\n signal?: AbortSignal,\n): Promise<ServerRuntime> {\n const preparedMail = await prepareMail(options.mail, signal);\n const database = await openDatabaseRuntime(\n options.drizzle,\n owner,\n options.drizzle.migrate ? \"apply\" : \"inspect\",\n signal,\n );\n if (database.state.status !== \"ready\") {\n throw new MigrationPreparationError(\"incompatible-history\", database.state);\n }\n if (signal?.aborted) throw new MigrationPreparationError(\"aborted\");\n const mail = createMailRuntime(preparedMail);\n owner.register(mail, (runtime) => runtime.close(), { owned: true });\n return {\n ...options,\n drizzle: { ...database, migrate: options.drizzle.migrate },\n mailer: mail.transport,\n };\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { type Database, schema } from \"@drfed/models\";\n\nexport default async function seedData(db: Database): Promise<void> {\n await db.transaction(async (tx) => {\n await seedAccounts(tx);\n });\n}\n\nconst sessionId = \"00000000-0000-4000-8000-000000000000\";\nconst accountId = \"00000000-0000-4000-8000-000000000001\";\nconst memberId = \"00000000-0000-4000-8000-000000000002\";\nconst pendingMemberId = \"00000000-0000-4000-8000-000000000003\";\nconst created = Temporal.Instant.from(\"2026-06-24T00:00:00.000Z\");\nconst tokenHash = \"dev-token-hash\";\n\nasync function seedAccounts(db: Database): Promise<void> {\n await db\n .insert(schema.accounts)\n .values([\n {\n id: accountId,\n email: \"owner@example.com\",\n name: \"Owner\",\n created,\n },\n {\n id: memberId,\n email: \"member@example.com\",\n name: \"Member\",\n created,\n },\n {\n id: pendingMemberId,\n email: \"pending@example.com\",\n name: \"Pending\",\n created,\n },\n ])\n .onConflictDoNothing();\n await db\n .insert(schema.sessions)\n .values([\n {\n id: sessionId,\n accountId,\n tokenHash,\n },\n ])\n .onConflictDoUpdate({\n target: schema.sessions.id,\n set: { tokenHash },\n });\n}\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { writeFile } from \"node:fs/promises\";\nimport process from \"node:process\";\n\nimport createFederation, { createInboundRecorder } from \"@drfed/federation\";\nimport { KeyGenerationQueue } from \"@drfed/federation/task-queue\";\nimport { createYogaServer } from \"@drfed/graphql\";\nimport type { Database } from \"@drfed/models\";\nimport { type WebRuntime, createWebRuntime } from \"@drfed/web\";\nimport { PgliteKvStore } from \"@fedify/pglite\";\nimport { PostgresKvStore } from \"@fedify/postgres\";\nimport {\n configure,\n dispose,\n getConsoleSink,\n getLogger,\n} from \"@logtape/logtape\";\nimport { text } from \"@optique/core/message\";\nimport { createLoggingConfig } from \"@optique/logtape\";\nimport { printError, run } from \"@optique/run\";\nimport { serve } from \"srvx\";\n\nimport metadata from \"../package.json\" with { type: \"json\" };\nimport { createLoginLink } from \"./dev-login.ts\";\nimport { describeServerConfiguration } from \"./diagnostics.ts\";\nimport { OperationRegistry } from \"./operations.ts\";\nimport {\n type Options,\n type SchemaGeneratorOptions,\n type ServerOptions,\n resolveOptions,\n} from \"./parser.ts\";\nimport { createProgram, selectInvocationMode } from \"./program.ts\";\nimport { ResourceOwner } from \"./resources.ts\";\nimport { createServerRuntime } from \"./runtime-options.ts\";\nimport seedData from \"./seed.ts\";\nimport {\n createControlSurface,\n createFetchHandler,\n getIngressMetadata,\n warnAboutStrandedInstances,\n} from \"./serving.ts\";\n\nasync function runServer(configuration: ServerOptions) {\n const owner = new ResourceOwner();\n const operations = new OperationRegistry();\n owner.register(null, () => dispose(), { owned: true });\n let server: ReturnType<typeof serve> | undefined;\n let closing: Promise<void> | undefined;\n let signalled = false;\n\n async function cleanup(): Promise<void> {\n operations.abort();\n const errors: unknown[] = [];\n let forced: Promise<void> | undefined;\n const forceTimer = setTimeout(() => {\n if (server == null) return;\n const currentServer = server;\n forced = (async () => {\n try {\n await currentServer.close(true);\n } catch (error) {\n errors.push(error);\n }\n })();\n }, 5000);\n try {\n const results = await Promise.allSettled([\n server?.close(),\n operations.drain(),\n ]);\n for (const result of results) {\n if (result.status === \"rejected\") errors.push(result.reason);\n }\n if (forced != null) await forced;\n } finally {\n clearTimeout(forceTimer);\n try {\n await owner.close();\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(errors, \"Server cleanup failed.\");\n }\n }\n\n function stop(): Promise<void> {\n // Assign before invoking abort callbacks so reentrant cleanup is shared.\n // oxlint-disable-next-line promise/prefer-await-to-then\n return (closing ??= Promise.resolve().then(cleanup));\n }\n\n function shutdown(): void {\n if (signalled) process.exit(1);\n signalled = true;\n const deadline = setTimeout(() => process.exit(1), 10_000);\n // oxlint-disable promise/prefer-await-to-then\n void stop().then(\n () => {\n clearTimeout(deadline);\n process.exit(0);\n },\n () => process.exit(1),\n );\n // oxlint-enable promise/prefer-await-to-then\n }\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n try {\n const options = await operations.run((signal) =>\n createServerRuntime(configuration, owner, signal),\n );\n const { credentials, db } = options.drizzle;\n if (options.seed) await operations.run(() => seedData(db));\n const kv =\n \"driver\" in credentials\n ? new PgliteKvStore(credentials.client)\n : new PostgresKvStore(credentials.client);\n const federation = await operations.run(() =>\n createFederation(db, {\n kv,\n queue: { task: new KeyGenerationQueue() },\n taskQueueResolution: \"strict\",\n manuallyStartQueue: true,\n allowPrivateAddress: true,\n }),\n );\n // The registry drains the worker before owned database cleanup.\n void (async () => {\n try {\n await operations.run((signal) =>\n federation.startQueue(undefined, { queue: \"task\", signal }),\n );\n } catch {\n if (!operations.signal.aborted) {\n getLogger([\"drfed\", \"server\"]).error(\n \"Actor key worker stopped unexpectedly.\",\n );\n }\n }\n })();\n const { emailFrom, mailer, rootOrigin, loginOrigins } = options;\n const yogaServer = createYogaServer(db, federation, {\n rootOrigin,\n emailFrom,\n mailer,\n loginOrigins,\n trackOperation: (operation) => operations.track(operation),\n shutdownSignal: operations.signal,\n });\n await operations.run(() => warnAboutStrandedInstances(db, rootOrigin));\n let web: WebRuntime | undefined;\n if (options.web) {\n const { publicOrigin } = options;\n if (publicOrigin === undefined) {\n throw new Error(\"Missing public web origin.\");\n }\n web = await operations.run(async (signal) => {\n const runtime = owner.register(\n await createWebRuntime({\n publicOrigin,\n graphqlFetch: (request) =>\n operations.track(() => yogaServer.fetch(request)),\n }),\n (resource) => resource.close(),\n { owned: true },\n );\n signal.throwIfAborted();\n return runtime;\n });\n }\n const fetchHandler = createFetchHandler({\n federation: createInboundRecorder({\n db,\n federation,\n rootOrigin,\n ingressMetadata: getIngressMetadata,\n }),\n rootOrigin,\n serveControlSurface: createControlSurface({\n graphql: yogaServer.fetch,\n ...(web === undefined ? {} : { web: web.fetch }),\n }),\n });\n const ownedServer = owner.register(\n serve({\n async fetch(request) {\n if (operations.signal.aborted) {\n return new Response(\"Server is stopping.\", { status: 503 });\n }\n try {\n return await operations.run(() => fetchHandler(request));\n } catch (error) {\n if (operations.signal.aborted) {\n return new Response(\"Server is stopping.\", { status: 503 });\n }\n throw error;\n }\n },\n hostname: options.address.host,\n manual: true,\n gracefulShutdown: false,\n port: options.address.port,\n }),\n (resource) => resource.close(true),\n { owned: true },\n );\n server = ownedServer;\n await operations.run(async () => {\n await ownedServer.serve();\n });\n if (options.publicOrigin !== undefined) {\n getLogger([\"drfed\", \"server\"]).info(\n \"Web frontend is available at {origin}.\",\n { origin: options.publicOrigin.origin },\n );\n }\n const { loginLink } = options;\n if (loginLink !== undefined) {\n await operations.run(() =>\n logLoginLink(db, loginLink.email, loginLink.origin),\n );\n }\n } catch (error) {\n process.off(\"SIGINT\", shutdown);\n process.off(\"SIGTERM\", shutdown);\n const deadline = Promise.withResolvers<never>();\n const timeout = setTimeout(\n () => deadline.reject(new Error(\"Startup cleanup timed out.\")),\n 10_000,\n );\n try {\n await Promise.race([stop(), deadline.promise]);\n } catch {\n throw new Error(\"Database cleanup after startup failure failed.\", {\n cause: error,\n });\n } finally {\n clearTimeout(timeout);\n }\n throw new Error(\"Could not start the server.\", { cause: error });\n }\n}\n\nasync function logLoginLink(\n db: Database,\n email: string,\n origin: string,\n): Promise<void> {\n const logger = getLogger([\"drfed\", \"server\"]);\n const link = await createLoginLink(db, email, origin);\n if (link === undefined) {\n logger.warn(\"Cannot create a login link; no account has {email}.\", {\n email,\n });\n return;\n }\n logger.info(\"Log in as {email} at {link}.\", { email, link: link.href });\n}\n\nasync function runSchemaGenerator(\n options: SchemaGeneratorOptions,\n): Promise<void> {\n const [{ schema }, { printSchema }] = await Promise.all([\n import(\"@drfed/graphql/schema\"),\n import(\"graphql\"),\n ]);\n const schemaCode = printSchema(schema);\n if (options.outputFile === \"-\") {\n // oxlint-disable-next-line no-console\n console.log(schemaCode);\n return;\n }\n await writeFile(options.outputFile, schemaCode, { encoding: \"utf-8\" });\n}\n\nexport async function main(): Promise<void> {\n const invocation = createProgram({\n mode: selectInvocationMode(process.argv.slice(2)),\n });\n let options: Options;\n try {\n const raw = await run(invocation.program, {\n contexts: invocation.contexts,\n contextOptions: {\n load: (parsed) =>\n parsed.mode[0] === \"schema\" ? undefined : invocation.load(parsed),\n },\n help: \"option\",\n completion: \"both\",\n showChoices: true,\n showDefault: true,\n version: {\n option: true,\n value: metadata.version,\n },\n });\n options = resolveOptions(raw);\n } catch (error) {\n printError([\n text(\n error instanceof Error\n ? error.message\n : \"Could not resolve configuration.\",\n ),\n ]);\n process.exitCode = 1;\n return;\n }\n if (\"generateGraphqlSchema\" in options) {\n await runSchemaGenerator(options);\n return;\n }\n if (options.printConfig) {\n console.log(JSON.stringify(describeServerConfiguration(options), null, 2));\n return;\n }\n let loggingConfig: Awaited<ReturnType<typeof createLoggingConfig>>;\n try {\n loggingConfig = await createLoggingConfig(\n options.logging,\n {},\n {\n contextLocalStorage: new AsyncLocalStorage(),\n sinks: {\n stderr: getConsoleSink({\n levelMap: {\n trace: \"error\",\n debug: \"error\",\n info: \"error\",\n warning: \"error\",\n error: \"error\",\n fatal: \"error\",\n },\n }),\n },\n loggers: [\n {\n category: [\"logtape\", \"meta\"],\n lowestLevel: \"warning\",\n sinks: [\"stderr\"],\n },\n ],\n },\n );\n } catch {\n printError([\n text(\"Could not initialize logging; check the log output path.\"),\n ]);\n process.exitCode = 1;\n return;\n }\n await configure(loggingConfig);\n\n await runServer(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,gBACpB,IACA,OACA,QAC0B;CAC1B,MAAM,UAAU,MAAM,GAAG,MAAM,SAAS,UAAU,EAChD,OAAO,EAAE,OAAO,eAAe,KAAK,EAAE,EACxC,CAAC;CACD,IAAI,WAAW,MAAM,OAAO,KAAA;CAC5B,MAAM,KAAK,OAAO;CAClB,MAAM,OAAO,2BAA2B;CACxC,MAAM,GAAG,OAAO,eAAe,CAAC,CAAC,OAAO;EAAE;EAAI,WAAW,QAAQ;EAAI;CAAK,CAAC;CAC3E,OAAO,IAAI,IAAI,YAAY,GAAG,QAAQ,QAAQ,MAAM;AACtD;;;;;;;;;ACVA,SAAgB,qBACd,MACqB;CACrB,MAAM,CAAC,OAAO,GAAG,WAAW,OAAO,OAAO,gBAAgB,CAAC,CAAC,KAAK;CACjE,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,uCAAuC;CAEzD,MAAM,WAAW,MACf,OAAO;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MAAM,UAAU,OAAO;AACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-CkHM-SS9.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -110,6 +110,8 @@ declare function createParser(bindings: Bindings, mode?: "server" | "schema"): i
|
|
|
110
110
|
readonly smtpKeyFile: Sourced<string | undefined> | undefined;
|
|
111
111
|
};
|
|
112
112
|
readonly seed: boolean;
|
|
113
|
+
readonly loginLink: string | undefined;
|
|
114
|
+
readonly loginLinkOrigin: URL | undefined;
|
|
113
115
|
readonly logging: {
|
|
114
116
|
readonly level: Sourced<"debug" | "error" | "fatal" | "info" | "trace" | "warning" | undefined> | undefined;
|
|
115
117
|
readonly format: Sourced<import("@logtape/logtape").TextFormatter | undefined> | undefined;
|
|
@@ -227,6 +229,8 @@ declare function createParser(bindings: Bindings, mode?: "server" | "schema"): i
|
|
|
227
229
|
readonly smtpKeyFile: Sourced<string | undefined> | undefined;
|
|
228
230
|
};
|
|
229
231
|
readonly seed: boolean;
|
|
232
|
+
readonly loginLink: string | undefined;
|
|
233
|
+
readonly loginLinkOrigin: URL | undefined;
|
|
230
234
|
readonly logging: {
|
|
231
235
|
readonly level: Sourced<"debug" | "error" | "fatal" | "info" | "trace" | "warning" | undefined> | undefined;
|
|
232
236
|
readonly format: Sourced<import("@logtape/logtape").TextFormatter | undefined> | undefined;
|
|
@@ -268,6 +272,10 @@ declare function resolveOptions(options: RawOptions, cwd?: string): SchemaGenera
|
|
|
268
272
|
};
|
|
269
273
|
};
|
|
270
274
|
seed: boolean;
|
|
275
|
+
loginLink: {
|
|
276
|
+
readonly email: string;
|
|
277
|
+
readonly origin: string;
|
|
278
|
+
} | undefined;
|
|
271
279
|
logging: {
|
|
272
280
|
logLevel: "debug" | "error" | "fatal" | "info" | "trace" | "warning";
|
|
273
281
|
logOutput: import("@optique/logtape").LogOutput;
|
|
@@ -302,4 +310,4 @@ type ServerOptions = Exclude<Options, {
|
|
|
302
310
|
}>;
|
|
303
311
|
//#endregion
|
|
304
312
|
export { ServerOptions as t };
|
|
305
|
-
//# sourceMappingURL=parser-
|
|
313
|
+
//# sourceMappingURL=parser-CjemP44P.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser-CjemP44P.d.mts","names":["_$__mail_settings_ts0.MailSettings","_$__configuration_ts0.ConfigurationSource"],"sources":["../src/parser.ts"],"mappings":";;;;KAwEK,WAAW,kBAAkB;;;;;iBAOlB,aACd,UAAU,UACV,4DAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4OrC;KAEI,aAAa,WAAW,kBAAkB;KACnC;WACD;WACA;;;;;;iBAuCK,eAAe,SAAS,YAAY,eAAmB;;;;;;;;;;;;;;;;;;aAnBlD;aAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmIlC,UAAU,kBAAkB;KAC5B,gBAAgB,QAC1B;EACE"}
|
|
@@ -32,6 +32,8 @@ const valueOptionNames = {
|
|
|
32
32
|
"-D"
|
|
33
33
|
],
|
|
34
34
|
migrationLockTimeout: ["--migration-lock-timeout"],
|
|
35
|
+
devLoginLink: ["--dev-login-link"],
|
|
36
|
+
devLoginOrigin: ["--dev-login-origin"],
|
|
35
37
|
...mailValueOptionNames,
|
|
36
38
|
logLevel: loggingValueOptionNames.logLevel,
|
|
37
39
|
logFormat: loggingValueOptionNames.logFormat,
|
|
@@ -76,6 +78,14 @@ function createParser(bindings, mode = "server") {
|
|
|
76
78
|
description: message`Seed initial development data.`,
|
|
77
79
|
hidden: true
|
|
78
80
|
}),
|
|
81
|
+
loginLink: optional(option(...valueOptionNames.devLoginLink, email(), {
|
|
82
|
+
description: message`Log a link that logs in as the account with this email address once the server is listening.`,
|
|
83
|
+
hidden: true
|
|
84
|
+
})),
|
|
85
|
+
loginLinkOrigin: optional(option(...valueOptionNames.devLoginOrigin, origin({ allowedProtocols: ["http:", "https:"] }), {
|
|
86
|
+
description: message`The web frontend origin of the logged login link. Defaults to the public web origin when serving the frontend.`,
|
|
87
|
+
hidden: true
|
|
88
|
+
})),
|
|
79
89
|
logging,
|
|
80
90
|
printConfig: withDefault(flag("--print-config", { description: message`Print effective settings and their sources, with secrets redacted, then exit without opening runtime resources.` }), false)
|
|
81
91
|
});
|
|
@@ -100,6 +110,20 @@ function required(value, error) {
|
|
|
100
110
|
return value.value;
|
|
101
111
|
}
|
|
102
112
|
/**
|
|
113
|
+
* Pair the account of a development login link with the frontend origin
|
|
114
|
+
* that confirms it, which must be allowed in login links.
|
|
115
|
+
* @returns The link to log, or `undefined` if none was requested.
|
|
116
|
+
*/
|
|
117
|
+
function resolveLoginLink(account, frontend, loginOrigins) {
|
|
118
|
+
if (account === void 0) return void 0;
|
|
119
|
+
if (frontend === void 0) throw new Error("Option --dev-login-link needs --dev-login-origin when the frontend is not served.");
|
|
120
|
+
if (!loginOrigins.has(frontend.origin)) throw new Error("The configured login origins must include the login link origin.");
|
|
121
|
+
return {
|
|
122
|
+
email: account,
|
|
123
|
+
origin: frontend.origin
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
103
127
|
* Resolve domain constraints only after the source contexts have completed.
|
|
104
128
|
* @returns Plain startup options; no database, mail or log sink is created.
|
|
105
129
|
*/
|
|
@@ -148,6 +172,7 @@ function resolveOptions(options, cwd = process.cwd()) {
|
|
|
148
172
|
mail: mail.mail,
|
|
149
173
|
mailDiagnostic: mail.diagnostic,
|
|
150
174
|
seed: server.seed,
|
|
175
|
+
loginLink: resolveLoginLink(server.loginLink, server.loginLinkOrigin ?? publicOrigin, loginOrigins),
|
|
151
176
|
logging,
|
|
152
177
|
drizzle: {
|
|
153
178
|
...database.database,
|
|
@@ -176,4 +201,4 @@ function resolveOptions(options, cwd = process.cwd()) {
|
|
|
176
201
|
//#endregion
|
|
177
202
|
export { resolveOptions as n, valueOptionNames as r, createParser as t };
|
|
178
203
|
|
|
179
|
-
//# sourceMappingURL=parser-
|
|
204
|
+
//# sourceMappingURL=parser-Dq9PWT_s.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser-Dq9PWT_s.mjs","names":["settings"],"sources":["../src/parser.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { classifyHost } from \"@drfed/federation/origin\";\nimport { conditional, merge, object, or } from \"@optique/core/constructs\";\nimport { message } from \"@optique/core/message\";\nimport { map, multiple, optional, withDefault } from \"@optique/core/modifiers\";\nimport type { InferValue } from \"@optique/core/parser\";\nimport { flag, option } from \"@optique/core/primitives\";\nimport {\n email,\n integer,\n origin,\n socketAddress,\n string,\n url,\n} from \"@optique/core/valueparser\";\nimport { path } from \"@optique/run/valueparser\";\n\nimport {\n type Sourced,\n configurationBoolean,\n configurationProvenance,\n type createConfigurationBindings,\n lazyDefault,\n configurationSettings as settings,\n stringArray,\n} from \"./configuration.ts\";\nimport { resolveDatabaseSettings } from \"./database-settings.ts\";\nimport { defaultListenHost } from \"./listen-defaults.ts\";\nimport {\n createLoggingParser,\n loggingValueOptionNames,\n resolveLogging,\n} from \"./logging.ts\";\nimport { createMailParser, mailValueOptionNames } from \"./mail-parser.ts\";\nimport { resolveMailSettings } from \"./mail-settings.ts\";\nimport { rootOrigin } from \"./valueparser.ts\";\n\n/** Shared value-option spellings for strict parsing and metadata arity. */\nexport const valueOptionNames = {\n configPath: [\"--config\"],\n address: [\"--listen\", \"-l\"],\n rootOrigin: [\"--root-origin\", \"-r\"],\n loginOrigins: [\"--login-origin\"],\n publicOrigin: [\"--public-origin\"],\n emailFrom: [\"--email-from\", \"-f\"],\n dataPath: [\"--pglite-data-path\", \"--data-path\", \"-d\"],\n postgresUrl: [\"--postgres-url\", \"--database-url\", \"-D\"],\n migrationLockTimeout: [\"--migration-lock-timeout\"],\n devLoginLink: [\"--dev-login-link\"],\n devLoginOrigin: [\"--dev-login-origin\"],\n ...mailValueOptionNames,\n logLevel: loggingValueOptionNames.logLevel,\n logFormat: loggingValueOptionNames.logFormat,\n logOutput: loggingValueOptionNames.logOutput,\n outputFile: [\"--output-file\", \"-o\"],\n} as const;\n\ntype Bindings = ReturnType<typeof createConfigurationBindings>;\nconst identity = (value: string) => value;\n\n/**\n * Construct a fresh parser from shared bindings without creating resources.\n * @returns The server and schema-output parser.\n */\nexport function createParser(\n bindings: Bindings,\n mode: \"server\" | \"schema\" = \"server\",\n) {\n const { bind } = bindings;\n const address = socketAddress({ requirePort: true });\n const root = rootOrigin({ metavar: \"ORIGIN\" });\n const lockTimeout = integer({\n min: 1,\n max: 2_147_483_647,\n metavar: \"MILLISECONDS\",\n });\n const sender = email({ lowercase: true });\n const logging = createLoggingParser(bindings);\n const server = object(\"DrFed server\", {\n address: bind(\n option(...valueOptionNames.address, address, {\n description: message`The address to listen on.`,\n }),\n settings.listen,\n address,\n identity,\n lazyDefault(() => ({\n host: defaultListenHost(bindings.env),\n port: 8888,\n })),\n ),\n rootOrigin: bind(\n option(...valueOptionNames.rootOrigin, root, {\n description: message`The root origin whose subdomains name instances. Required through CLI, environment or configuration.`,\n }),\n settings.rootOrigin,\n root,\n identity,\n ),\n web: bind(\n or(\n flag(\"--web\", {\n description: message`Serve the frontend alongside GraphQL on the same port. This is the default.`,\n }),\n map(\n flag(\"--no-web\", {\n description: message`Serve GraphQL and federation without the frontend; login origins must be explicit.`,\n }),\n () => false,\n ),\n ),\n settings.web,\n configurationBoolean(),\n String,\n true,\n ),\n publicOrigin: bind(\n map(\n option(\n ...valueOptionNames.publicOrigin,\n origin({ allowedProtocols: [\"http:\", \"https:\"] }),\n {\n description: message`The public HTTP or HTTPS frontend origin. Defaults to the root origin; unused with --no-web.`,\n },\n ),\n (value) => value.origin,\n ),\n settings.publicOrigin,\n string(),\n identity,\n ),\n loginOrigins: bind(\n multiple(\n map(\n option(\n ...valueOptionNames.loginOrigins,\n origin({ allowedProtocols: [\"http:\", \"https:\"] }),\n {\n description: message`An HTTP or HTTPS frontend origin allowed in login links. Repeat to replace the configured list. Defaults to the public web origin when serving the frontend.`,\n },\n ),\n (value) => value.origin,\n ),\n { min: 1 },\n ),\n settings.loginOrigins,\n stringArray(),\n JSON.stringify,\n ),\n emailFrom: bind(\n option(...valueOptionNames.emailFrom, sender, {\n description: message`The login mail sender. Defaults to noreply at the root origin's host name.`,\n }),\n settings.emailFrom,\n sender,\n identity,\n ),\n dataPath: bind(\n option(\n ...valueOptionNames.dataPath,\n path({ metavar: \"DIRECTORY\", type: \"directory\" }),\n {\n description: message`PGlite data directory. Cannot accompany a PostgreSQL selector at the same source.`,\n },\n ),\n settings.dataPath,\n string(),\n identity,\n ),\n postgresUrl: bind(\n map(\n option(\n ...valueOptionNames.postgresUrl,\n url({ allowedProtocols: [\"postgres:\", \"postgresql:\"] }),\n {\n description: message`PostgreSQL connection URL. Cannot accompany a PGlite selector at the same source.`,\n },\n ),\n (value) => value.href,\n ),\n settings.postgresUrl,\n string(),\n identity,\n ),\n migrate: bind(\n or(\n flag(\"--migrate\", {\n description: message`Apply database migrations on startup.`,\n }),\n map(\n flag(\"--no-migrate\", \"-M\", {\n description: message`Require exact ready migration history without applying SQL or upgrading metadata.`,\n }),\n () => false,\n ),\n ),\n settings.migrate,\n configurationBoolean(),\n String,\n true,\n ),\n migrationLockTimeout: bind(\n option(...valueOptionNames.migrationLockTimeout, lockTimeout, {\n description: message`Maximum PostgreSQL migration connection and lock wait in milliseconds. PGlite ownership conflicts fail immediately.`,\n }),\n settings.migrationLockTimeout,\n lockTimeout,\n String,\n 30_000,\n ),\n mail: createMailParser(bindings),\n seed: option(\"--dev-seed\", {\n description: message`Seed initial development data.`,\n hidden: true,\n }),\n loginLink: optional(\n option(...valueOptionNames.devLoginLink, email(), {\n description: message`Log a link that logs in as the account with this email address once the server is listening.`,\n hidden: true,\n }),\n ),\n loginLinkOrigin: optional(\n option(\n ...valueOptionNames.devLoginOrigin,\n origin({ allowedProtocols: [\"http:\", \"https:\"] }),\n {\n description: message`The web frontend origin of the logged login link. Defaults to the public web origin when serving the frontend.`,\n hidden: true,\n },\n ),\n ),\n logging,\n printConfig: withDefault(\n flag(\"--print-config\", {\n description: message`Print effective settings and their sources, with secrets redacted, then exit without opening runtime resources.`,\n }),\n false,\n ),\n });\n const schema = object(\"GraphQL schema generation\", {\n // Preserve the historical logging spellings for schema invocations,\n // but do not bind or validate operational values in this projection.\n ignoredLogging: object({\n level: optional(\n option(...valueOptionNames.logLevel, string(), { hidden: true }),\n ),\n format: optional(\n option(...valueOptionNames.logFormat, string(), { hidden: true }),\n ),\n output: optional(\n option(...valueOptionNames.logOutput, string(), { hidden: true }),\n ),\n }),\n outputFile: withDefault(\n option(\n ...valueOptionNames.outputFile,\n path({ type: \"file\", allowCreate: true }),\n {\n description: message`Schema output file. Use - for stdout.`,\n },\n ),\n \"-\",\n ),\n });\n return merge(\n object({\n configPath: optional(\n bindings.bindConfigPath(\n option(\n ...valueOptionNames.configPath,\n path({ metavar: \"FILE\", type: \"file\" }),\n {\n description: message`Read this TOML file. No configuration files are searched automatically.`,\n },\n ),\n ),\n ),\n }),\n object({\n mode:\n mode === \"schema\"\n ? map(\n merge(\n object({\n generateGraphqlSchema: flag(\"--generate-graphql-schema\"),\n }),\n schema,\n ),\n (value) => [\"schema\", value] as const,\n )\n : conditional(\n map(\n flag(\"--generate-graphql-schema\", {\n description: message`Generate GraphQL schema and exit.`,\n }),\n () => \"schema\" as const,\n ),\n { schema },\n server,\n ),\n }),\n );\n}\n\ntype RawOptions = InferValue<ReturnType<typeof createParser>>;\nexport type SchemaGeneratorOptions = {\n readonly generateGraphqlSchema: true;\n readonly outputFile: string;\n};\n\nfunction required<T>(\n value: Sourced<T | undefined> | undefined,\n error: string,\n): T {\n if (value?.value === undefined) throw new Error(error);\n return value.value;\n}\n\n/**\n * Pair the account of a development login link with the frontend origin\n * that confirms it, which must be allowed in login links.\n * @returns The link to log, or `undefined` if none was requested.\n */\nfunction resolveLoginLink(\n account: string | undefined,\n frontend: URL | undefined,\n loginOrigins: ReadonlySet<string>,\n): { readonly email: string; readonly origin: string } | undefined {\n if (account === undefined) return undefined;\n if (frontend === undefined) {\n throw new Error(\n \"Option --dev-login-link needs --dev-login-origin when the frontend is not served.\",\n );\n }\n if (!loginOrigins.has(frontend.origin)) {\n throw new Error(\n \"The configured login origins must include the login link origin.\",\n );\n }\n return { email: account, origin: frontend.origin };\n}\n\n/**\n * Resolve domain constraints only after the source contexts have completed.\n * @returns Plain startup options; no database, mail or log sink is created.\n */\nexport function resolveOptions(options: RawOptions, cwd = process.cwd()) {\n if (options.mode[0] === \"schema\") {\n const schema: SchemaGeneratorOptions = {\n generateGraphqlSchema: true,\n outputFile: options.mode[1].outputFile,\n };\n return schema;\n }\n const server = options.mode[1];\n const logging = resolveLogging(server.logging, cwd);\n const root = required(\n server.rootOrigin,\n \"Missing option --root-origin or server.root_origin (DRFED_ROOT_ORIGIN).\",\n );\n const web = required(server.web, \"Missing web serving policy.\");\n let publicOrigin: URL | undefined;\n if (web) {\n const supplied = server.publicOrigin?.value;\n if (supplied === undefined) publicOrigin = new URL(root.origin);\n else {\n const parsed = origin({ allowedProtocols: [\"http:\", \"https:\"] }).parse(\n supplied,\n );\n if (!parsed.success) {\n throw new Error(\n \"Invalid public origin; expected an HTTP or HTTPS origin without credentials.\",\n );\n }\n publicOrigin = parsed.value;\n }\n if (classifyHost(publicOrigin, root) !== \"admin\") {\n throw new Error(\n \"The public web origin cannot name an instance or a deeper subdomain.\",\n );\n }\n }\n const origins =\n server.loginOrigins?.value ??\n (publicOrigin === undefined ? [] : [publicOrigin.origin]);\n if (origins.length === 0) {\n throw new Error(\"Expected at least 1 values, but got only 0.\");\n }\n const loginOrigins = new Set<string>();\n for (const value of origins) {\n const parsed = origin({ allowedProtocols: [\"http:\", \"https:\"] }).parse(\n value,\n );\n if (!parsed.success) {\n throw new Error(\n \"Invalid login origin; expected an HTTP or HTTPS origin.\",\n );\n }\n loginOrigins.add(parsed.value.origin);\n }\n if (publicOrigin !== undefined && !loginOrigins.has(publicOrigin.origin)) {\n throw new Error(\n \"The configured login origins must include the public web origin.\",\n );\n }\n const database = resolveDatabaseSettings(\n {\n dataPath: server.dataPath,\n postgresUrl: server.postgresUrl,\n },\n cwd,\n );\n const mail = resolveMailSettings(server.mail, cwd);\n return {\n printConfig: server.printConfig,\n address: required(server.address, \"Missing listen address.\"),\n rootOrigin: root,\n web,\n publicOrigin,\n loginOrigins,\n emailFrom: server.emailFrom?.value,\n mail: mail.mail,\n mailDiagnostic: mail.diagnostic,\n seed: server.seed,\n loginLink: resolveLoginLink(\n server.loginLink,\n server.loginLinkOrigin ?? publicOrigin,\n loginOrigins,\n ),\n logging,\n drizzle: {\n ...database.database,\n migrate: required(server.migrate, \"Missing migration policy.\"),\n lockTimeoutMs: required(\n server.migrationLockTimeout,\n \"Missing migration lock timeout.\",\n ),\n },\n provenance: configurationProvenance({\n rootOrigin: server.rootOrigin,\n web: server.web,\n publicOrigin: server.publicOrigin,\n address: server.address,\n loginOrigins: server.loginOrigins,\n emailFrom: server.emailFrom,\n dataPath: server.dataPath,\n postgresUrl: server.postgresUrl,\n migrate: server.migrate,\n migrationLockTimeout: server.migrationLockTimeout,\n ...server.mail,\n logLevel: server.logging.level,\n logFormat: server.logging.format,\n logOutput: server.logging.output,\n }),\n ignored: [...database.ignored, ...mail.ignored],\n };\n}\n\nexport type Options = ReturnType<typeof resolveOptions>;\nexport type ServerOptions = Exclude<\n Options,\n { generateGraphqlSchema: unknown }\n>;\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,MAAa,mBAAmB;CAC9B,YAAY,CAAC,UAAU;CACvB,SAAS,CAAC,YAAY,IAAI;CAC1B,YAAY,CAAC,iBAAiB,IAAI;CAClC,cAAc,CAAC,gBAAgB;CAC/B,cAAc,CAAC,iBAAiB;CAChC,WAAW,CAAC,gBAAgB,IAAI;CAChC,UAAU;EAAC;EAAsB;EAAe;CAAI;CACpD,aAAa;EAAC;EAAkB;EAAkB;CAAI;CACtD,sBAAsB,CAAC,0BAA0B;CACjD,cAAc,CAAC,kBAAkB;CACjC,gBAAgB,CAAC,oBAAoB;CACrC,GAAG;CACH,UAAU,wBAAwB;CAClC,WAAW,wBAAwB;CACnC,WAAW,wBAAwB;CACnC,YAAY,CAAC,iBAAiB,IAAI;AACpC;AAGA,MAAM,YAAY,UAAkB;;;;;AAMpC,SAAgB,aACd,UACA,OAA4B,UAC5B;CACA,MAAM,EAAE,SAAS;CACjB,MAAM,UAAU,cAAc,EAAE,aAAa,KAAK,CAAC;CACnD,MAAM,OAAO,WAAW,EAAE,SAAS,SAAS,CAAC;CAC7C,MAAM,cAAc,QAAQ;EAC1B,KAAK;EACL,KAAK;EACL,SAAS;CACX,CAAC;CACD,MAAM,SAAS,MAAM,EAAE,WAAW,KAAK,CAAC;CACxC,MAAM,UAAU,oBAAoB,QAAQ;CAC5C,MAAM,SAAS,OAAO,gBAAgB;EACpC,SAAS,KACP,OAAO,GAAG,iBAAiB,SAAS,SAAS,EAC3C,aAAa,OAAO,4BACtB,CAAC,GACDA,sBAAS,QACT,SACA,UACA,mBAAmB;GACjB,MAAM,kBA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;GAClB,UAAU,OAAO;GACjB,aAAa,OAAO;GACpB,SAAS,OAAO;GAChB,sBAAsB,OAAO;GAC7B,GAAG,OAAO;GACV,UAAU,OAAO,QAAQ;GACzB,WAAW,OAAO,QAAQ;GAC1B,WAAW,OAAO,QAAQ;EAC5B,CAAC;EACD,SAAS,CAAC,GAAG,SAAS,SAAS,GAAG,KAAK,OAAO;CAChD;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drfed/drfed",
|
|
3
|
-
"version": "0.2.0-dev.
|
|
3
|
+
"version": "0.2.0-dev.717",
|
|
4
4
|
"description": "The main entrypoint program for DrFed.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ActivityPub",
|
|
@@ -232,10 +232,10 @@
|
|
|
232
232
|
"typescript": "^7.0.2"
|
|
233
233
|
},
|
|
234
234
|
"dependencies": {
|
|
235
|
-
"@drfed/federation": "0.2.0-dev.
|
|
236
|
-
"@drfed/graphql": "0.2.0-dev.
|
|
237
|
-
"@drfed/models": "0.2.0-dev.
|
|
238
|
-
"@drfed/web": "0.2.0-dev.
|
|
235
|
+
"@drfed/federation": "0.2.0-dev.717",
|
|
236
|
+
"@drfed/graphql": "0.2.0-dev.717",
|
|
237
|
+
"@drfed/models": "0.2.0-dev.717",
|
|
238
|
+
"@drfed/web": "0.2.0-dev.717",
|
|
239
239
|
"@electric-sql/pglite": "^0.5.3",
|
|
240
240
|
"@fedify/fedify": "2.4.3",
|
|
241
241
|
"@fedify/pglite": "2.4.3",
|
|
@@ -278,13 +278,13 @@
|
|
|
278
278
|
},
|
|
279
279
|
"drfedBuild": {
|
|
280
280
|
"enabled": true,
|
|
281
|
-
"version": "0.2.0-dev.
|
|
282
|
-
"fullVersion": "0.2.0-dev.
|
|
281
|
+
"version": "0.2.0-dev.717",
|
|
282
|
+
"fullVersion": "0.2.0-dev.717+8cdaaac8",
|
|
283
283
|
"baseVersion": "0.2.0",
|
|
284
284
|
"channel": "dev",
|
|
285
|
-
"sha": "
|
|
286
|
-
"runNumber": "
|
|
287
|
-
"runId": "
|
|
285
|
+
"sha": "8cdaaac8aa197260cb2d68ced23f17109cbb258e",
|
|
286
|
+
"runNumber": "717",
|
|
287
|
+
"runId": "45350451649",
|
|
288
288
|
"ref": "refs/heads/main",
|
|
289
289
|
"workflow": ".github/workflows/main.yaml"
|
|
290
290
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-CeHzXSlM.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser-C0dRu62q.d.mts","names":["_$__mail_settings_ts0.MailSettings","_$__configuration_ts0.ConfigurationSource"],"sources":["../src/parser.ts"],"mappings":";;;;KAsEK,WAAW,kBAAkB;;;;;iBAOlB,aACd,UAAU,UACV,4DAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4NrC;KAEI,aAAa,WAAW,kBAAkB;KACnC;WACD;WACA;;;;;;iBAeK,eAAe,SAAS,YAAY,eAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2G3D,UAAU,kBAAkB;KAC5B,gBAAgB,QAC1B;EACE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser-Czr4z4-a.mjs","names":["settings"],"sources":["../src/parser.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { classifyHost } from \"@drfed/federation/origin\";\nimport { conditional, merge, object, or } from \"@optique/core/constructs\";\nimport { message } from \"@optique/core/message\";\nimport { map, multiple, optional, withDefault } from \"@optique/core/modifiers\";\nimport type { InferValue } from \"@optique/core/parser\";\nimport { flag, option } from \"@optique/core/primitives\";\nimport {\n email,\n integer,\n origin,\n socketAddress,\n string,\n url,\n} from \"@optique/core/valueparser\";\nimport { path } from \"@optique/run/valueparser\";\n\nimport {\n type Sourced,\n configurationBoolean,\n configurationProvenance,\n type createConfigurationBindings,\n lazyDefault,\n configurationSettings as settings,\n stringArray,\n} from \"./configuration.ts\";\nimport { resolveDatabaseSettings } from \"./database-settings.ts\";\nimport { defaultListenHost } from \"./listen-defaults.ts\";\nimport {\n createLoggingParser,\n loggingValueOptionNames,\n resolveLogging,\n} from \"./logging.ts\";\nimport { createMailParser, mailValueOptionNames } from \"./mail-parser.ts\";\nimport { resolveMailSettings } from \"./mail-settings.ts\";\nimport { rootOrigin } from \"./valueparser.ts\";\n\n/** Shared value-option spellings for strict parsing and metadata arity. */\nexport const valueOptionNames = {\n configPath: [\"--config\"],\n address: [\"--listen\", \"-l\"],\n rootOrigin: [\"--root-origin\", \"-r\"],\n loginOrigins: [\"--login-origin\"],\n publicOrigin: [\"--public-origin\"],\n emailFrom: [\"--email-from\", \"-f\"],\n dataPath: [\"--pglite-data-path\", \"--data-path\", \"-d\"],\n postgresUrl: [\"--postgres-url\", \"--database-url\", \"-D\"],\n migrationLockTimeout: [\"--migration-lock-timeout\"],\n ...mailValueOptionNames,\n logLevel: loggingValueOptionNames.logLevel,\n logFormat: loggingValueOptionNames.logFormat,\n logOutput: loggingValueOptionNames.logOutput,\n outputFile: [\"--output-file\", \"-o\"],\n} as const;\n\ntype Bindings = ReturnType<typeof createConfigurationBindings>;\nconst identity = (value: string) => value;\n\n/**\n * Construct a fresh parser from shared bindings without creating resources.\n * @returns The server and schema-output parser.\n */\nexport function createParser(\n bindings: Bindings,\n mode: \"server\" | \"schema\" = \"server\",\n) {\n const { bind } = bindings;\n const address = socketAddress({ requirePort: true });\n const root = rootOrigin({ metavar: \"ORIGIN\" });\n const lockTimeout = integer({\n min: 1,\n max: 2_147_483_647,\n metavar: \"MILLISECONDS\",\n });\n const sender = email({ lowercase: true });\n const logging = createLoggingParser(bindings);\n const server = object(\"DrFed server\", {\n address: bind(\n option(...valueOptionNames.address, address, {\n description: message`The address to listen on.`,\n }),\n settings.listen,\n address,\n identity,\n lazyDefault(() => ({\n host: defaultListenHost(bindings.env),\n port: 8888,\n })),\n ),\n rootOrigin: bind(\n option(...valueOptionNames.rootOrigin, root, {\n description: message`The root origin whose subdomains name instances. Required through CLI, environment or configuration.`,\n }),\n settings.rootOrigin,\n root,\n identity,\n ),\n web: bind(\n or(\n flag(\"--web\", {\n description: message`Serve the frontend alongside GraphQL on the same port. This is the default.`,\n }),\n map(\n flag(\"--no-web\", {\n description: message`Serve GraphQL and federation without the frontend; login origins must be explicit.`,\n }),\n () => false,\n ),\n ),\n settings.web,\n configurationBoolean(),\n String,\n true,\n ),\n publicOrigin: bind(\n map(\n option(\n ...valueOptionNames.publicOrigin,\n origin({ allowedProtocols: [\"http:\", \"https:\"] }),\n {\n description: message`The public HTTP or HTTPS frontend origin. Defaults to the root origin; unused with --no-web.`,\n },\n ),\n (value) => value.origin,\n ),\n settings.publicOrigin,\n string(),\n identity,\n ),\n loginOrigins: bind(\n multiple(\n map(\n option(\n ...valueOptionNames.loginOrigins,\n origin({ allowedProtocols: [\"http:\", \"https:\"] }),\n {\n description: message`An HTTP or HTTPS frontend origin allowed in login links. Repeat to replace the configured list. Defaults to the public web origin when serving the frontend.`,\n },\n ),\n (value) => value.origin,\n ),\n { min: 1 },\n ),\n settings.loginOrigins,\n stringArray(),\n JSON.stringify,\n ),\n emailFrom: bind(\n option(...valueOptionNames.emailFrom, sender, {\n description: message`The login mail sender. Defaults to noreply at the root origin's host name.`,\n }),\n settings.emailFrom,\n sender,\n identity,\n ),\n dataPath: bind(\n option(\n ...valueOptionNames.dataPath,\n path({ metavar: \"DIRECTORY\", type: \"directory\" }),\n {\n description: message`PGlite data directory. Cannot accompany a PostgreSQL selector at the same source.`,\n },\n ),\n settings.dataPath,\n string(),\n identity,\n ),\n postgresUrl: bind(\n map(\n option(\n ...valueOptionNames.postgresUrl,\n url({ allowedProtocols: [\"postgres:\", \"postgresql:\"] }),\n {\n description: message`PostgreSQL connection URL. Cannot accompany a PGlite selector at the same source.`,\n },\n ),\n (value) => value.href,\n ),\n settings.postgresUrl,\n string(),\n identity,\n ),\n migrate: bind(\n or(\n flag(\"--migrate\", {\n description: message`Apply database migrations on startup.`,\n }),\n map(\n flag(\"--no-migrate\", \"-M\", {\n description: message`Require exact ready migration history without applying SQL or upgrading metadata.`,\n }),\n () => false,\n ),\n ),\n settings.migrate,\n configurationBoolean(),\n String,\n true,\n ),\n migrationLockTimeout: bind(\n option(...valueOptionNames.migrationLockTimeout, lockTimeout, {\n description: message`Maximum PostgreSQL migration connection and lock wait in milliseconds. PGlite ownership conflicts fail immediately.`,\n }),\n settings.migrationLockTimeout,\n lockTimeout,\n String,\n 30_000,\n ),\n mail: createMailParser(bindings),\n seed: option(\"--dev-seed\", {\n description: message`Seed initial development data.`,\n hidden: true,\n }),\n logging,\n printConfig: withDefault(\n flag(\"--print-config\", {\n description: message`Print effective settings and their sources, with secrets redacted, then exit without opening runtime resources.`,\n }),\n false,\n ),\n });\n const schema = object(\"GraphQL schema generation\", {\n // Preserve the historical logging spellings for schema invocations,\n // but do not bind or validate operational values in this projection.\n ignoredLogging: object({\n level: optional(\n option(...valueOptionNames.logLevel, string(), { hidden: true }),\n ),\n format: optional(\n option(...valueOptionNames.logFormat, string(), { hidden: true }),\n ),\n output: optional(\n option(...valueOptionNames.logOutput, string(), { hidden: true }),\n ),\n }),\n outputFile: withDefault(\n option(\n ...valueOptionNames.outputFile,\n path({ type: \"file\", allowCreate: true }),\n {\n description: message`Schema output file. Use - for stdout.`,\n },\n ),\n \"-\",\n ),\n });\n return merge(\n object({\n configPath: optional(\n bindings.bindConfigPath(\n option(\n ...valueOptionNames.configPath,\n path({ metavar: \"FILE\", type: \"file\" }),\n {\n description: message`Read this TOML file. No configuration files are searched automatically.`,\n },\n ),\n ),\n ),\n }),\n object({\n mode:\n mode === \"schema\"\n ? map(\n merge(\n object({\n generateGraphqlSchema: flag(\"--generate-graphql-schema\"),\n }),\n schema,\n ),\n (value) => [\"schema\", value] as const,\n )\n : conditional(\n map(\n flag(\"--generate-graphql-schema\", {\n description: message`Generate GraphQL schema and exit.`,\n }),\n () => \"schema\" as const,\n ),\n { schema },\n server,\n ),\n }),\n );\n}\n\ntype RawOptions = InferValue<ReturnType<typeof createParser>>;\nexport type SchemaGeneratorOptions = {\n readonly generateGraphqlSchema: true;\n readonly outputFile: string;\n};\n\nfunction required<T>(\n value: Sourced<T | undefined> | undefined,\n error: string,\n): T {\n if (value?.value === undefined) throw new Error(error);\n return value.value;\n}\n\n/**\n * Resolve domain constraints only after the source contexts have completed.\n * @returns Plain startup options; no database, mail or log sink is created.\n */\nexport function resolveOptions(options: RawOptions, cwd = process.cwd()) {\n if (options.mode[0] === \"schema\") {\n const schema: SchemaGeneratorOptions = {\n generateGraphqlSchema: true,\n outputFile: options.mode[1].outputFile,\n };\n return schema;\n }\n const server = options.mode[1];\n const logging = resolveLogging(server.logging, cwd);\n const root = required(\n server.rootOrigin,\n \"Missing option --root-origin or server.root_origin (DRFED_ROOT_ORIGIN).\",\n );\n const web = required(server.web, \"Missing web serving policy.\");\n let publicOrigin: URL | undefined;\n if (web) {\n const supplied = server.publicOrigin?.value;\n if (supplied === undefined) publicOrigin = new URL(root.origin);\n else {\n const parsed = origin({ allowedProtocols: [\"http:\", \"https:\"] }).parse(\n supplied,\n );\n if (!parsed.success) {\n throw new Error(\n \"Invalid public origin; expected an HTTP or HTTPS origin without credentials.\",\n );\n }\n publicOrigin = parsed.value;\n }\n if (classifyHost(publicOrigin, root) !== \"admin\") {\n throw new Error(\n \"The public web origin cannot name an instance or a deeper subdomain.\",\n );\n }\n }\n const origins =\n server.loginOrigins?.value ??\n (publicOrigin === undefined ? [] : [publicOrigin.origin]);\n if (origins.length === 0) {\n throw new Error(\"Expected at least 1 values, but got only 0.\");\n }\n const loginOrigins = new Set<string>();\n for (const value of origins) {\n const parsed = origin({ allowedProtocols: [\"http:\", \"https:\"] }).parse(\n value,\n );\n if (!parsed.success) {\n throw new Error(\n \"Invalid login origin; expected an HTTP or HTTPS origin.\",\n );\n }\n loginOrigins.add(parsed.value.origin);\n }\n if (publicOrigin !== undefined && !loginOrigins.has(publicOrigin.origin)) {\n throw new Error(\n \"The configured login origins must include the public web origin.\",\n );\n }\n const database = resolveDatabaseSettings(\n {\n dataPath: server.dataPath,\n postgresUrl: server.postgresUrl,\n },\n cwd,\n );\n const mail = resolveMailSettings(server.mail, cwd);\n return {\n printConfig: server.printConfig,\n address: required(server.address, \"Missing listen address.\"),\n rootOrigin: root,\n web,\n publicOrigin,\n loginOrigins,\n emailFrom: server.emailFrom?.value,\n mail: mail.mail,\n mailDiagnostic: mail.diagnostic,\n seed: server.seed,\n logging,\n drizzle: {\n ...database.database,\n migrate: required(server.migrate, \"Missing migration policy.\"),\n lockTimeoutMs: required(\n server.migrationLockTimeout,\n \"Missing migration lock timeout.\",\n ),\n },\n provenance: configurationProvenance({\n rootOrigin: server.rootOrigin,\n web: server.web,\n publicOrigin: server.publicOrigin,\n address: server.address,\n loginOrigins: server.loginOrigins,\n emailFrom: server.emailFrom,\n dataPath: server.dataPath,\n postgresUrl: server.postgresUrl,\n migrate: server.migrate,\n migrationLockTimeout: server.migrationLockTimeout,\n ...server.mail,\n logLevel: server.logging.level,\n logFormat: server.logging.format,\n logOutput: server.logging.output,\n }),\n ignored: [...database.ignored, ...mail.ignored],\n };\n}\n\nexport type Options = ReturnType<typeof resolveOptions>;\nexport type ServerOptions = Exclude<\n Options,\n { generateGraphqlSchema: unknown }\n>;\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,MAAa,mBAAmB;CAC9B,YAAY,CAAC,UAAU;CACvB,SAAS,CAAC,YAAY,IAAI;CAC1B,YAAY,CAAC,iBAAiB,IAAI;CAClC,cAAc,CAAC,gBAAgB;CAC/B,cAAc,CAAC,iBAAiB;CAChC,WAAW,CAAC,gBAAgB,IAAI;CAChC,UAAU;EAAC;EAAsB;EAAe;CAAI;CACpD,aAAa;EAAC;EAAkB;EAAkB;CAAI;CACtD,sBAAsB,CAAC,0BAA0B;CACjD,GAAG;CACH,UAAU,wBAAwB;CAClC,WAAW,wBAAwB;CACnC,WAAW,wBAAwB;CACnC,YAAY,CAAC,iBAAiB,IAAI;AACpC;AAGA,MAAM,YAAY,UAAkB;;;;;AAMpC,SAAgB,aACd,UACA,OAA4B,UAC5B;CACA,MAAM,EAAE,SAAS;CACjB,MAAM,UAAU,cAAc,EAAE,aAAa,KAAK,CAAC;CACnD,MAAM,OAAO,WAAW,EAAE,SAAS,SAAS,CAAC;CAC7C,MAAM,cAAc,QAAQ;EAC1B,KAAK;EACL,KAAK;EACL,SAAS;CACX,CAAC;CACD,MAAM,SAAS,MAAM,EAAE,WAAW,KAAK,CAAC;CACxC,MAAM,UAAU,oBAAoB,QAAQ;CAC5C,MAAM,SAAS,OAAO,gBAAgB;EACpC,SAAS,KACP,OAAO,GAAG,iBAAiB,SAAS,SAAS,EAC3C,aAAa,OAAO,4BACtB,CAAC,GACDA,sBAAS,QACT,SACA,UACA,mBAAmB;GACjB,MAAM,kBAAkB,SAAS,GAAG;GACpC,MAAM;EACR,EAAE,CACJ;EACA,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