@facilis.dev/nitro 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +18 -2
- package/dist/config.d.ts +30 -0
- package/dist/config.js +112 -0
- package/dist/constants.d.ts +24 -0
- package/dist/constants.js +24 -0
- package/dist/facade.d.ts +37 -0
- package/dist/facade.js +121 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +14 -0
- package/dist/middleware/context.d.ts +5 -0
- package/dist/middleware/context.js +86 -0
- package/dist/middleware/cors.d.ts +10 -0
- package/dist/middleware/cors.js +34 -0
- package/dist/middleware/session.d.ts +9 -0
- package/dist/middleware/session.js +18 -0
- package/dist/module.d.ts +7 -0
- package/dist/module.js +234 -0
- package/dist/rolldown-parser.d.ts +3 -0
- package/dist/rolldown-parser.js +66 -0
- package/dist/route-metadata.d.ts +22 -0
- package/dist/route-metadata.js +161 -0
- package/dist/routes/dev-query.post.d.ts +10 -0
- package/dist/routes/dev-query.post.js +49 -0
- package/dist/routes/dev-schema.get.d.ts +9 -0
- package/dist/routes/dev-schema.get.js +34 -0
- package/dist/routes/dev-view.post.d.ts +11 -0
- package/dist/routes/dev-view.post.js +61 -0
- package/dist/routes/health.get.d.ts +8 -0
- package/dist/routes/health.get.js +18 -0
- package/dist/routes/manifest-revision.get.d.ts +8 -0
- package/dist/routes/manifest-revision.get.js +26 -0
- package/dist/routes/manifest.get.d.ts +8 -0
- package/dist/routes/manifest.get.js +68 -0
- package/dist/routes/openapi.get.d.ts +8 -0
- package/dist/routes/openapi.get.js +29 -0
- package/dist/routes/sso.d.ts +2 -0
- package/dist/routes/sso.js +216 -0
- package/dist/routes/token.post.d.ts +10 -0
- package/dist/routes/token.post.js +75 -0
- package/dist/runtime/boot-runtimes.d.ts +21 -0
- package/dist/runtime/boot-runtimes.js +38 -0
- package/dist/runtime/bootstrap.d.ts +47 -0
- package/dist/runtime/bootstrap.js +214 -0
- package/dist/runtime/config.d.ts +27 -0
- package/dist/runtime/config.js +44 -0
- package/dist/runtime/cors-policy.d.ts +16 -0
- package/dist/runtime/cors-policy.js +88 -0
- package/dist/runtime/db-bootstrap.d.ts +9 -0
- package/dist/runtime/db-bootstrap.js +87 -0
- package/dist/runtime/db-target.d.ts +21 -0
- package/dist/runtime/db-target.js +52 -0
- package/dist/runtime/dev-db-persistence.d.ts +39 -0
- package/dist/runtime/dev-db-persistence.js +124 -0
- package/dist/runtime/dev-query.d.ts +38 -0
- package/dist/runtime/dev-query.js +87 -0
- package/dist/runtime/env.d.ts +9 -0
- package/dist/runtime/env.js +14 -0
- package/dist/runtime/http-guard.d.ts +16 -0
- package/dist/runtime/http-guard.js +42 -0
- package/dist/runtime/http.d.ts +11 -0
- package/dist/runtime/http.js +18 -0
- package/dist/runtime/jobs/boot.d.ts +20 -0
- package/dist/runtime/jobs/boot.js +77 -0
- package/dist/runtime/jobs/contracts.d.ts +161 -0
- package/dist/runtime/jobs/contracts.js +1 -0
- package/dist/runtime/jobs/db-store.d.ts +21 -0
- package/dist/runtime/jobs/db-store.js +210 -0
- package/dist/runtime/jobs/definitions.d.ts +14 -0
- package/dist/runtime/jobs/definitions.js +31 -0
- package/dist/runtime/jobs/engine-support.d.ts +22 -0
- package/dist/runtime/jobs/engine-support.js +32 -0
- package/dist/runtime/jobs/engine.d.ts +6 -0
- package/dist/runtime/jobs/engine.js +261 -0
- package/dist/runtime/jobs/executor.d.ts +11 -0
- package/dist/runtime/jobs/executor.js +27 -0
- package/dist/runtime/jobs/memory-store.d.ts +7 -0
- package/dist/runtime/jobs/memory-store.js +183 -0
- package/dist/runtime/jobs/row-mapping.d.ts +28 -0
- package/dist/runtime/jobs/row-mapping.js +61 -0
- package/dist/runtime/jobs/runtime.d.ts +24 -0
- package/dist/runtime/jobs/runtime.js +86 -0
- package/dist/runtime/logging/audit-chain.d.ts +54 -0
- package/dist/runtime/logging/audit-chain.js +102 -0
- package/dist/runtime/logging/bootstrap-logging.d.ts +28 -0
- package/dist/runtime/logging/bootstrap-logging.js +26 -0
- package/dist/runtime/logging/entry.d.ts +14 -0
- package/dist/runtime/logging/entry.js +85 -0
- package/dist/runtime/logging/file-sink.d.ts +24 -0
- package/dist/runtime/logging/file-sink.js +128 -0
- package/dist/runtime/logging/log-settings.d.ts +52 -0
- package/dist/runtime/logging/log-settings.js +93 -0
- package/dist/runtime/logging/log-sink.d.ts +18 -0
- package/dist/runtime/logging/log-sink.js +22 -0
- package/dist/runtime/logging/redact.d.ts +31 -0
- package/dist/runtime/logging/redact.js +106 -0
- package/dist/runtime/logging/runtime.d.ts +25 -0
- package/dist/runtime/logging/runtime.js +114 -0
- package/dist/runtime/logging/sudo-bridge.d.ts +13 -0
- package/dist/runtime/logging/sudo-bridge.js +38 -0
- package/dist/runtime/manifest-data.d.ts +28 -0
- package/dist/runtime/manifest-data.js +70 -0
- package/dist/runtime/manifest-response.d.ts +45 -0
- package/dist/runtime/manifest-response.js +50 -0
- package/dist/runtime/manifest-sections.d.ts +20 -0
- package/dist/runtime/manifest-sections.js +59 -0
- package/dist/runtime/manifest-service.d.ts +16 -0
- package/dist/runtime/manifest-service.js +66 -0
- package/dist/runtime/project-config.d.ts +8 -0
- package/dist/runtime/project-config.js +22 -0
- package/dist/runtime/project-files.d.ts +12 -0
- package/dist/runtime/project-files.js +99 -0
- package/dist/runtime/rate-limit.d.ts +6 -0
- package/dist/runtime/rate-limit.js +6 -0
- package/dist/runtime/revision-service.d.ts +15 -0
- package/dist/runtime/revision-service.js +26 -0
- package/dist/runtime/sql.d.ts +8 -0
- package/dist/runtime/sql.js +23 -0
- package/dist/runtime/sso.d.ts +40 -0
- package/dist/runtime/sso.js +98 -0
- package/dist/runtime/state.d.ts +7 -0
- package/dist/runtime/state.js +7 -0
- package/dist/runtime/storage-keys.d.ts +9 -0
- package/dist/runtime/storage-keys.js +82 -0
- package/dist/runtime/storage-target.d.ts +25 -0
- package/dist/runtime/storage-target.js +155 -0
- package/dist/runtime/system-role.d.ts +9 -0
- package/dist/runtime/system-role.js +21 -0
- package/dist/runtime/tasks/boot.d.ts +20 -0
- package/dist/runtime/tasks/boot.js +32 -0
- package/dist/runtime/tasks/contracts.d.ts +70 -0
- package/dist/runtime/tasks/contracts.js +1 -0
- package/dist/runtime/tasks/db-store.d.ts +18 -0
- package/dist/runtime/tasks/db-store.js +139 -0
- package/dist/runtime/tasks/row-mapping.d.ts +11 -0
- package/dist/runtime/tasks/row-mapping.js +69 -0
- package/dist/runtime/tasks/runtime.d.ts +7 -0
- package/dist/runtime/tasks/runtime.js +162 -0
- package/dist/runtime/tasks/tasks-test-harness.d.ts +16 -0
- package/dist/runtime/tasks/tasks-test-harness.js +70 -0
- package/dist/runtime/tenant.d.ts +10 -0
- package/dist/runtime/tenant.js +13 -0
- package/dist/runtime/workflows/boot.d.ts +25 -0
- package/dist/runtime/workflows/boot.js +75 -0
- package/dist/runtime/workflows/contracts.d.ts +96 -0
- package/dist/runtime/workflows/contracts.js +1 -0
- package/dist/runtime/workflows/db-store.d.ts +18 -0
- package/dist/runtime/workflows/db-store.js +128 -0
- package/dist/runtime/workflows/definitions.d.ts +14 -0
- package/dist/runtime/workflows/definitions.js +50 -0
- package/dist/runtime/workflows/dispatch.d.ts +4 -0
- package/dist/runtime/workflows/dispatch.js +119 -0
- package/dist/runtime/workflows/row-mapping.d.ts +5 -0
- package/dist/runtime/workflows/row-mapping.js +38 -0
- package/dist/runtime/workflows/runner.d.ts +15 -0
- package/dist/runtime/workflows/runner.js +89 -0
- package/dist/runtime/workflows/runtime.d.ts +14 -0
- package/dist/runtime/workflows/runtime.js +129 -0
- package/dist/runtime/workflows/steps.d.ts +14 -0
- package/dist/runtime/workflows/steps.js +49 -0
- package/dist/runtime/workflows/support.d.ts +20 -0
- package/dist/runtime/workflows/support.js +36 -0
- package/dist/runtime/workflows/transitions.d.ts +8 -0
- package/dist/runtime/workflows/transitions.js +184 -0
- package/dist/runtime/workflows/workflows-test-harness.d.ts +62 -0
- package/dist/runtime/workflows/workflows-test-harness.js +178 -0
- package/dist/session-cookie.d.ts +13 -0
- package/dist/session-cookie.js +48 -0
- package/dist/storage.d.ts +50 -0
- package/dist/storage.js +118 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.js +1 -0
- package/dist/virtual-ids.d.ts +17 -0
- package/dist/virtual-ids.js +17 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +135 -0
- package/package.json +61 -4
- package/src/config.ts +120 -0
- package/src/constants.ts +24 -0
- package/src/facade.ts +153 -0
- package/src/index.ts +44 -0
- package/src/middleware/context.ts +106 -0
- package/src/middleware/cors.ts +42 -0
- package/src/middleware/session.ts +23 -0
- package/src/module.ts +278 -0
- package/src/rolldown-parser.ts +79 -0
- package/src/route-metadata-test-harness.ts +62 -0
- package/src/route-metadata.ts +194 -0
- package/src/routes/dev-query.post.ts +53 -0
- package/src/routes/dev-schema.get.ts +43 -0
- package/src/routes/dev-view.post.ts +66 -0
- package/src/routes/health.get.ts +26 -0
- package/src/routes/manifest-revision.get.ts +38 -0
- package/src/routes/manifest.get.ts +111 -0
- package/src/routes/openapi.get.ts +34 -0
- package/src/routes/sso.ts +247 -0
- package/src/routes/token.post.ts +89 -0
- package/src/runtime/boot-runtimes.ts +69 -0
- package/src/runtime/bootstrap.ts +300 -0
- package/src/runtime/config.ts +60 -0
- package/src/runtime/cors-policy.ts +107 -0
- package/src/runtime/db-bootstrap.ts +99 -0
- package/src/runtime/db-target.ts +87 -0
- package/src/runtime/dev-db-persistence.ts +146 -0
- package/src/runtime/dev-query.ts +124 -0
- package/src/runtime/env.ts +18 -0
- package/src/runtime/http-guard.ts +50 -0
- package/src/runtime/http.ts +30 -0
- package/src/runtime/jobs/boot.ts +97 -0
- package/src/runtime/jobs/contracts.ts +165 -0
- package/src/runtime/jobs/db-store-test-harness.ts +98 -0
- package/src/runtime/jobs/db-store.ts +273 -0
- package/src/runtime/jobs/definitions.ts +42 -0
- package/src/runtime/jobs/engine-support.ts +44 -0
- package/src/runtime/jobs/engine.ts +296 -0
- package/src/runtime/jobs/executor.ts +37 -0
- package/src/runtime/jobs/memory-store.ts +222 -0
- package/src/runtime/jobs/row-mapping.ts +67 -0
- package/src/runtime/jobs/runtime.ts +110 -0
- package/src/runtime/logging/audit-chain.ts +135 -0
- package/src/runtime/logging/bootstrap-logging.ts +62 -0
- package/src/runtime/logging/entry.ts +99 -0
- package/src/runtime/logging/file-sink.ts +157 -0
- package/src/runtime/logging/log-settings.ts +166 -0
- package/src/runtime/logging/log-sink.ts +31 -0
- package/src/runtime/logging/redact.ts +108 -0
- package/src/runtime/logging/runtime.ts +163 -0
- package/src/runtime/logging/sudo-bridge.ts +41 -0
- package/src/runtime/manifest-data.ts +103 -0
- package/src/runtime/manifest-response.ts +95 -0
- package/src/runtime/manifest-sections.ts +79 -0
- package/src/runtime/manifest-service.ts +83 -0
- package/src/runtime/project-config.ts +25 -0
- package/src/runtime/project-files.ts +103 -0
- package/src/runtime/rate-limit.ts +12 -0
- package/src/runtime/revision-service.ts +38 -0
- package/src/runtime/sql.ts +24 -0
- package/src/runtime/sso.ts +153 -0
- package/src/runtime/state.ts +7 -0
- package/src/runtime/storage-keys.ts +95 -0
- package/src/runtime/storage-target.ts +238 -0
- package/src/runtime/system-role.ts +26 -0
- package/src/runtime/tasks/boot.ts +49 -0
- package/src/runtime/tasks/contracts.ts +77 -0
- package/src/runtime/tasks/db-store.ts +191 -0
- package/src/runtime/tasks/row-mapping.ts +75 -0
- package/src/runtime/tasks/runtime.ts +192 -0
- package/src/runtime/tasks/tasks-test-harness.ts +92 -0
- package/src/runtime/tenant.ts +15 -0
- package/src/runtime/workflows/boot.ts +97 -0
- package/src/runtime/workflows/contracts.ts +114 -0
- package/src/runtime/workflows/db-store.ts +156 -0
- package/src/runtime/workflows/definitions.ts +75 -0
- package/src/runtime/workflows/dispatch.ts +148 -0
- package/src/runtime/workflows/row-mapping.ts +54 -0
- package/src/runtime/workflows/runner.ts +105 -0
- package/src/runtime/workflows/runtime.ts +161 -0
- package/src/runtime/workflows/steps.ts +74 -0
- package/src/runtime/workflows/support.ts +60 -0
- package/src/runtime/workflows/transitions.ts +259 -0
- package/src/runtime/workflows/workflows-test-harness.ts +238 -0
- package/src/session-cookie.ts +69 -0
- package/src/storage.ts +173 -0
- package/src/types.ts +51 -0
- package/src/virtual-ids.ts +18 -0
- package/src/virtual-modules.d.ts +53 -0
- package/src/vite.ts +175 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FacilisManifest,
|
|
3
|
+
FacilisMetaResponse,
|
|
4
|
+
ManifestSection,
|
|
5
|
+
ManifestSummary,
|
|
6
|
+
ManifestWarning,
|
|
7
|
+
} from "@facilis.dev/core";
|
|
8
|
+
|
|
9
|
+
import { jsonResult, type HttpResult } from "./http.ts";
|
|
10
|
+
|
|
11
|
+
const NO_CACHE = "no-cache";
|
|
12
|
+
|
|
13
|
+
/** Weak ETag: the revision is stable content, not a strong representation validator. */
|
|
14
|
+
export function weakEtag(revision: string): string {
|
|
15
|
+
return `W/"${revision}"`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Split an If-None-Match list into bare revisions (weakness and quotes removed). */
|
|
19
|
+
export function parseEntityTags(header: string | null): string[] {
|
|
20
|
+
if (header === null) return [];
|
|
21
|
+
return header
|
|
22
|
+
.split(",")
|
|
23
|
+
.map((tag) => tag.trim().replace(/^W\//, "").replace(/^"|"$/g, ""))
|
|
24
|
+
.filter((tag) => tag.length > 0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* RFC 9110 conditional request handling for an ETag-based endpoint. `since` is the
|
|
29
|
+
* spec's query-parameter shortcut (SPEC §6.1) and behaves like If-None-Match.
|
|
30
|
+
*/
|
|
31
|
+
export function isNotModified(input: {
|
|
32
|
+
readonly ifNoneMatch: string | null;
|
|
33
|
+
readonly since: string | null;
|
|
34
|
+
readonly revision: string;
|
|
35
|
+
}): boolean {
|
|
36
|
+
const tags = parseEntityTags(input.ifNoneMatch);
|
|
37
|
+
if (tags.includes("*") || tags.includes(input.revision)) return true;
|
|
38
|
+
return input.since !== null && input.since !== "" && input.since === input.revision;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function manifestHeaders(revision: string, partial: boolean): Record<string, string> {
|
|
42
|
+
return {
|
|
43
|
+
"cache-control": NO_CACHE,
|
|
44
|
+
etag: weakEtag(revision),
|
|
45
|
+
"x-facilis-revision": revision,
|
|
46
|
+
...(partial ? { "x-facilis-partial": "true" } : {}),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function notModifiedResult(revision: string): HttpResult {
|
|
51
|
+
return { status: 304, headers: manifestHeaders(revision, false) };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function manifestResponse(input: {
|
|
55
|
+
readonly revision: string;
|
|
56
|
+
readonly generatedAt: string;
|
|
57
|
+
readonly sections: readonly ManifestSection[];
|
|
58
|
+
readonly manifest: Partial<FacilisManifest>;
|
|
59
|
+
readonly warnings: readonly ManifestWarning[];
|
|
60
|
+
readonly partial: boolean;
|
|
61
|
+
}): HttpResult {
|
|
62
|
+
const body: FacilisMetaResponse = {
|
|
63
|
+
revision: input.revision,
|
|
64
|
+
generatedAt: input.generatedAt,
|
|
65
|
+
sections: input.sections,
|
|
66
|
+
manifest: input.manifest,
|
|
67
|
+
warnings: input.warnings,
|
|
68
|
+
};
|
|
69
|
+
return jsonResult(200, body, manifestHeaders(input.revision, input.partial));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* `?format=summary` payload (SPEC §6.1, §14.1-11).
|
|
74
|
+
*
|
|
75
|
+
* Deviation from FacilisMetaResponse: ManifestSummary is not a Partial<FacilisManifest>,
|
|
76
|
+
* so the compact view rides under `summary` instead of pretending to be a manifest.
|
|
77
|
+
*/
|
|
78
|
+
export interface FacilisSummaryResponse {
|
|
79
|
+
readonly revision: string;
|
|
80
|
+
readonly generatedAt: string;
|
|
81
|
+
readonly sections: readonly ManifestSection[];
|
|
82
|
+
readonly summary: ManifestSummary;
|
|
83
|
+
readonly warnings: readonly ManifestWarning[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function summaryResponse(input: {
|
|
87
|
+
readonly revision: string;
|
|
88
|
+
readonly generatedAt: string;
|
|
89
|
+
readonly sections: readonly ManifestSection[];
|
|
90
|
+
readonly summary: ManifestSummary;
|
|
91
|
+
readonly warnings: readonly ManifestWarning[];
|
|
92
|
+
}): HttpResult {
|
|
93
|
+
const body: FacilisSummaryResponse = { ...input };
|
|
94
|
+
return jsonResult(200, body, manifestHeaders(input.revision, false));
|
|
95
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MANIFEST_SECTIONS,
|
|
3
|
+
isManifestSection,
|
|
4
|
+
type FacilisManifest,
|
|
5
|
+
type ManifestSection,
|
|
6
|
+
} from "@facilis.dev/core";
|
|
7
|
+
|
|
8
|
+
export interface SectionsParameter {
|
|
9
|
+
/** True when every requested section name is valid (or none were requested). */
|
|
10
|
+
readonly ok: boolean;
|
|
11
|
+
/** Undefined means "all sections" (the documented default). */
|
|
12
|
+
readonly sections?: readonly ManifestSection[];
|
|
13
|
+
readonly invalid: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Parse `?sections=config,routes` (SPEC §6.1); invalid names make the request a 400. */
|
|
17
|
+
export function parseSectionsParameter(value: string | null): SectionsParameter {
|
|
18
|
+
if (value === null || value.trim() === "") return { ok: true, invalid: [] };
|
|
19
|
+
|
|
20
|
+
const requested = value
|
|
21
|
+
.split(",")
|
|
22
|
+
.map((section) => section.trim())
|
|
23
|
+
.filter((section) => section.length > 0);
|
|
24
|
+
const invalid = requested.filter((section) => !isManifestSection(section));
|
|
25
|
+
if (invalid.length > 0) return { ok: false, invalid };
|
|
26
|
+
|
|
27
|
+
return { ok: true, sections: [...new Set(requested as ManifestSection[])], invalid: [] };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Select the manifest sections in the response envelope.
|
|
32
|
+
*
|
|
33
|
+
* `config` maps to `project` and `meta` to `framework`: those are the names the
|
|
34
|
+
* spec uses on the wire (SPEC §6.1) while the manifest type keeps its own layout
|
|
35
|
+
* (SPEC §7.3). Without a filter every section is returned.
|
|
36
|
+
*/
|
|
37
|
+
export function selectManifestSections(
|
|
38
|
+
manifest: FacilisManifest,
|
|
39
|
+
sections: readonly ManifestSection[] | undefined,
|
|
40
|
+
): Partial<FacilisManifest> {
|
|
41
|
+
if (sections === undefined) {
|
|
42
|
+
return {
|
|
43
|
+
framework: manifest.framework,
|
|
44
|
+
project: manifest.project,
|
|
45
|
+
blocks: manifest.blocks,
|
|
46
|
+
routes: manifest.routes,
|
|
47
|
+
schema: manifest.schema,
|
|
48
|
+
i18n: manifest.i18n,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const selected: Partial<FacilisManifest> = {};
|
|
53
|
+
for (const section of sections) {
|
|
54
|
+
switch (section) {
|
|
55
|
+
case "config":
|
|
56
|
+
selected.project = manifest.project;
|
|
57
|
+
break;
|
|
58
|
+
case "meta":
|
|
59
|
+
selected.framework = manifest.framework;
|
|
60
|
+
break;
|
|
61
|
+
case "blocks":
|
|
62
|
+
selected.blocks = manifest.blocks;
|
|
63
|
+
break;
|
|
64
|
+
case "routes":
|
|
65
|
+
selected.routes = manifest.routes;
|
|
66
|
+
break;
|
|
67
|
+
case "schema":
|
|
68
|
+
selected.schema = manifest.schema;
|
|
69
|
+
break;
|
|
70
|
+
case "i18n":
|
|
71
|
+
selected.i18n = manifest.i18n;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return selected;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** All section names, in the canonical order (used when no filter is supplied). */
|
|
79
|
+
export const ALL_MANIFEST_SECTIONS: readonly ManifestSection[] = MANIFEST_SECTIONS;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { schemaSnapshot } from "@facilis.dev/db";
|
|
2
|
+
import type { FacilisConfig, ManifestWarning } from "@facilis.dev/core";
|
|
3
|
+
import config, { coreVersion, nitroVersion } from "#facilis/config";
|
|
4
|
+
import routeMetadata from "#facilis/openapi-meta";
|
|
5
|
+
|
|
6
|
+
import { getBootstrap } from "./bootstrap.ts";
|
|
7
|
+
import { isFacilisConfig } from "./config.ts";
|
|
8
|
+
import {
|
|
9
|
+
buildManifestData,
|
|
10
|
+
type ManifestDataResult,
|
|
11
|
+
type ManifestDataSources,
|
|
12
|
+
} from "./manifest-data.ts";
|
|
13
|
+
import { getRevisionSnapshot } from "./revision-service.ts";
|
|
14
|
+
|
|
15
|
+
export interface ManifestSnapshot {
|
|
16
|
+
readonly data: ManifestDataResult;
|
|
17
|
+
readonly revision: string;
|
|
18
|
+
readonly generatedAt: string;
|
|
19
|
+
readonly warnings: readonly ManifestWarning[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Assemble everything `/__facilis/manifest` needs.
|
|
24
|
+
*
|
|
25
|
+
* Returns null only when the project config itself is unusable (the module cannot
|
|
26
|
+
* describe the project at all); a broken schema is a 200-partial via
|
|
27
|
+
* ManifestDataResult.partial (SPEC §6.4/§6.7).
|
|
28
|
+
*/
|
|
29
|
+
export async function getManifestSnapshot(): Promise<ManifestSnapshot | null> {
|
|
30
|
+
const [revision, bootstrap] = await Promise.all([getRevisionSnapshot(), getBootstrap()]);
|
|
31
|
+
const projectConfig = resolveConfig(bootstrap.config);
|
|
32
|
+
if (projectConfig === null) return null;
|
|
33
|
+
|
|
34
|
+
const schemaOutcome = await readSchema(bootstrap.db);
|
|
35
|
+
const sources: ManifestDataSources = {
|
|
36
|
+
config: projectConfig,
|
|
37
|
+
routeMetadata,
|
|
38
|
+
catalogs: revision.catalogs,
|
|
39
|
+
coreVersion,
|
|
40
|
+
nitroVersion,
|
|
41
|
+
...schemaOutcome,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const data = buildManifestData(sources);
|
|
45
|
+
return {
|
|
46
|
+
data,
|
|
47
|
+
revision: revision.revision,
|
|
48
|
+
generatedAt: revision.generatedAt,
|
|
49
|
+
warnings: [...bootstrap.warnings, ...data.warnings],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function resolveConfig(bootstrapped: FacilisConfig | null): FacilisConfig | null {
|
|
54
|
+
if (bootstrapped !== null) return bootstrapped;
|
|
55
|
+
// The middleware may not have run yet (e.g. a direct handler import in tests);
|
|
56
|
+
// the virtual module is still a valid config source when the bootstrap failed early.
|
|
57
|
+
return isFacilisConfig(config) ? config : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function readSchema(
|
|
61
|
+
db: Awaited<ReturnType<typeof getBootstrap>>["db"],
|
|
62
|
+
): Promise<{ schema?: Awaited<ReturnType<typeof schemaSnapshot>>; failure?: ManifestWarning }> {
|
|
63
|
+
if (db === null) {
|
|
64
|
+
return {
|
|
65
|
+
failure: {
|
|
66
|
+
code: "db_unavailable",
|
|
67
|
+
message: "The database could not be booted; the schema section is unavailable.",
|
|
68
|
+
section: "schema",
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return { schema: await schemaSnapshot(db) };
|
|
74
|
+
} catch (error) {
|
|
75
|
+
return {
|
|
76
|
+
failure: {
|
|
77
|
+
code: "schema_unavailable",
|
|
78
|
+
message: `Schema introspection failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
79
|
+
section: "schema",
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FacilisConfig, ManifestWarning } from "@facilis.dev/core";
|
|
2
|
+
import config, { configError } from "#facilis/config";
|
|
3
|
+
|
|
4
|
+
import { isFacilisConfig } from "./config.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads and validates the project's virtual config module.
|
|
8
|
+
*
|
|
9
|
+
* A broken config is a warning, never a boot failure: the rest of the bootstrap still runs
|
|
10
|
+
* (contracts §8), and the caller degrades to "no config" with a partial manifest.
|
|
11
|
+
*/
|
|
12
|
+
export function readProjectConfig(warnings: ManifestWarning[]): FacilisConfig | null {
|
|
13
|
+
if (configError !== undefined) {
|
|
14
|
+
warnings.push({ code: "config_load_failed", message: configError });
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (!isFacilisConfig(config)) {
|
|
18
|
+
warnings.push({
|
|
19
|
+
code: "config_invalid",
|
|
20
|
+
message: "facilis.config.ts must export defineConfig({ auth, db, i18n, ... }).",
|
|
21
|
+
});
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return config;
|
|
25
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
3
|
+
import type { LocaleCatalogs, SchemaFileRevisionSource } from "@facilis.dev/core";
|
|
4
|
+
|
|
5
|
+
/** SPEC §6.5 hashes db/schema.ts and the modules it imports (transitively). */
|
|
6
|
+
const SCHEMA_ENTRY = "db/schema.ts";
|
|
7
|
+
const LOCALES_DIR = "locales";
|
|
8
|
+
const MAX_SCHEMA_FILES = 32;
|
|
9
|
+
const MAX_SCHEMA_DEPTH = 8;
|
|
10
|
+
const RELATIVE_IMPORT = /(?:import|export)\s[^;]*?from\s*["'](\.[^"']+)["']/g;
|
|
11
|
+
|
|
12
|
+
export async function readTextFile(filePath: string): Promise<string | null> {
|
|
13
|
+
try {
|
|
14
|
+
return await readFile(filePath, "utf8");
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Follow db/schema.ts and its relative imports, returning path + content pairs.
|
|
22
|
+
*
|
|
23
|
+
* A static regex walk is enough here: the revision only needs the file set and its
|
|
24
|
+
* bytes (SPEC §6.5), not a resolved module graph. Missing files are skipped so a
|
|
25
|
+
* half-written schema never breaks the endpoint.
|
|
26
|
+
*/
|
|
27
|
+
export async function collectSchemaFiles(
|
|
28
|
+
rootDir: string,
|
|
29
|
+
): Promise<readonly SchemaFileRevisionSource[]> {
|
|
30
|
+
const files = new Map<string, string>();
|
|
31
|
+
await visitSchemaFile(join(rootDir, SCHEMA_ENTRY), files, 0);
|
|
32
|
+
return [...files.entries()]
|
|
33
|
+
.map(([absolute, content]) => ({
|
|
34
|
+
path: relative(rootDir, absolute).split(sep).join("/"),
|
|
35
|
+
content,
|
|
36
|
+
}))
|
|
37
|
+
.toSorted((left, right) => left.path.localeCompare(right.path));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function visitSchemaFile(
|
|
41
|
+
filePath: string,
|
|
42
|
+
files: Map<string, string>,
|
|
43
|
+
depth: number,
|
|
44
|
+
): Promise<void> {
|
|
45
|
+
if (depth > MAX_SCHEMA_DEPTH || files.has(filePath) || files.size >= MAX_SCHEMA_FILES) return;
|
|
46
|
+
const content = await readTextFile(filePath);
|
|
47
|
+
if (content === null) return;
|
|
48
|
+
files.set(filePath, content);
|
|
49
|
+
|
|
50
|
+
for (const match of content.matchAll(RELATIVE_IMPORT)) {
|
|
51
|
+
const specifier = match[1];
|
|
52
|
+
if (specifier === undefined) continue;
|
|
53
|
+
// oxlint-disable-next-line no-await-in-loop -- recursion shares the dedupe Map; parallel visits would race on it.
|
|
54
|
+
const resolved = await resolveRelativeModule(dirname(filePath), specifier);
|
|
55
|
+
// oxlint-disable-next-line no-await-in-loop -- depth-first keeps the file-count cap deterministic.
|
|
56
|
+
if (resolved !== null) await visitSchemaFile(resolved, files, depth + 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function resolveRelativeModule(fromDir: string, specifier: string): Promise<string | null> {
|
|
61
|
+
const base = join(fromDir, specifier);
|
|
62
|
+
const candidates = [base, `${base}.ts`, `${base}.tsx`, `${base}.mts`, join(base, "index.ts")];
|
|
63
|
+
for (const candidate of candidates) {
|
|
64
|
+
// oxlint-disable-next-line no-await-in-loop -- stop at the first existing candidate.
|
|
65
|
+
if ((await readTextFile(candidate)) !== null) return candidate;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Read `locales/*.json` into the manifest i18n.catalogs shape; invalid files are skipped. */
|
|
71
|
+
export async function collectLocaleCatalogs(rootDir: string): Promise<LocaleCatalogs> {
|
|
72
|
+
const dir = join(rootDir, LOCALES_DIR);
|
|
73
|
+
let entries: string[];
|
|
74
|
+
try {
|
|
75
|
+
entries = await readdir(dir);
|
|
76
|
+
} catch {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const names = entries.filter((name) => name.endsWith(".json")).toSorted();
|
|
81
|
+
const contents = await Promise.all(names.map((name) => readTextFile(join(dir, name))));
|
|
82
|
+
const catalogs: Record<string, Record<string, string>> = {};
|
|
83
|
+
for (const [index, name] of names.entries()) {
|
|
84
|
+
const content = contents[index];
|
|
85
|
+
if (content === null || content === undefined) continue;
|
|
86
|
+
try {
|
|
87
|
+
const messages = asStringRecord(JSON.parse(content));
|
|
88
|
+
if (messages !== undefined) catalogs[name.slice(0, -".json".length)] = messages;
|
|
89
|
+
} catch {
|
|
90
|
+
// A malformed locale file must not break the manifest; it is simply absent.
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return catalogs;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function asStringRecord(value: unknown): Record<string, string> | undefined {
|
|
97
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return undefined;
|
|
98
|
+
const record: Record<string, string> = {};
|
|
99
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
100
|
+
if (typeof entry === "string") record[key] = entry;
|
|
101
|
+
}
|
|
102
|
+
return record;
|
|
103
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The framework rate limiter lives in @facilis.dev/core, where the authorized-handler wrapper uses
|
|
3
|
+
* it (D-152). This module keeps the framework-owned token endpoint's import path stable and
|
|
4
|
+
* re-exports exactly the same implementation, so both surfaces share one bounded limiter type.
|
|
5
|
+
*/
|
|
6
|
+
export {
|
|
7
|
+
createFixedWindowRateLimiter,
|
|
8
|
+
MAX_WINDOWS,
|
|
9
|
+
type FixedWindowRateLimiter,
|
|
10
|
+
type RateLimitDecision,
|
|
11
|
+
type RateLimitWindow,
|
|
12
|
+
} from "@facilis.dev/core";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { computeRevision } from "@facilis.dev/core";
|
|
2
|
+
import type { LocaleCatalogs } from "@facilis.dev/core";
|
|
3
|
+
import routeMetadata from "#facilis/openapi-meta";
|
|
4
|
+
import { configPath, projectRoot } from "#facilis/config";
|
|
5
|
+
|
|
6
|
+
import { collectLocaleCatalogs, collectSchemaFiles, readTextFile } from "./project-files.ts";
|
|
7
|
+
|
|
8
|
+
export interface RevisionSnapshot {
|
|
9
|
+
readonly revision: string;
|
|
10
|
+
readonly generatedAt: string;
|
|
11
|
+
readonly catalogs: LocaleCatalogs;
|
|
12
|
+
readonly configContent: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Compute the manifest revision on demand (SPEC §6.5: no watchers required).
|
|
17
|
+
*
|
|
18
|
+
* Inputs: raw facilis.config.ts source, db/schema.ts + its relative imports, the
|
|
19
|
+
* AST-pass route metadata (the facilis-owned part of the OpenAPI document) and the
|
|
20
|
+
* locale catalogues. No block package ships (D-131); block manifests default to [].
|
|
21
|
+
*/
|
|
22
|
+
export async function getRevisionSnapshot(): Promise<RevisionSnapshot> {
|
|
23
|
+
const [configSource, schemaFiles, catalogs] = await Promise.all([
|
|
24
|
+
readTextFile(configPath),
|
|
25
|
+
collectSchemaFiles(projectRoot),
|
|
26
|
+
collectLocaleCatalogs(projectRoot),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const configContent = configSource ?? "";
|
|
30
|
+
const revision = await computeRevision({
|
|
31
|
+
configContent,
|
|
32
|
+
schemaFiles,
|
|
33
|
+
openApiSpec: routeMetadata,
|
|
34
|
+
localeCatalogs: catalogs,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return { revision, generatedAt: new Date().toISOString(), catalogs, configContent };
|
|
38
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const STATEMENT_BREAKPOINT = /-->\s*statement-breakpoint\s*/i;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Split a migration file into executable statements.
|
|
5
|
+
*
|
|
6
|
+
* drizzle-kit emits `--> statement-breakpoint` between statements; plain SQL files
|
|
7
|
+
* fall back to end-of-line semicolons. Splitting is intentionally conservative: a
|
|
8
|
+
* statement is never rewritten, only separated.
|
|
9
|
+
*/
|
|
10
|
+
export function splitSqlStatements(source: string): string[] {
|
|
11
|
+
const normalized = source.replace(/\r\n/g, "\n");
|
|
12
|
+
const chunks = normalized.includes("--> statement-breakpoint")
|
|
13
|
+
? normalized.split(STATEMENT_BREAKPOINT)
|
|
14
|
+
: normalized.split(/;\s*(?:\n|$)/);
|
|
15
|
+
return chunks.map((chunk) => chunk.trim()).filter(isExecutable);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isExecutable(statement: string): boolean {
|
|
19
|
+
if (statement.length === 0) return false;
|
|
20
|
+
return statement.split("\n").some((line) => {
|
|
21
|
+
const trimmed = line.trim();
|
|
22
|
+
return trimmed.length > 0 && !trimmed.startsWith("--");
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { FacilisConfig, FacilisHandlerEvent, FacilisLogger } from "@facilis.dev/core";
|
|
2
|
+
import {
|
|
3
|
+
completeLogin,
|
|
4
|
+
failureRedirectPath,
|
|
5
|
+
publicProviderList,
|
|
6
|
+
ssoErrorCode,
|
|
7
|
+
SsoError,
|
|
8
|
+
startLogin,
|
|
9
|
+
type CompleteLoginInput,
|
|
10
|
+
type CompleteLoginResult,
|
|
11
|
+
type FetchLike,
|
|
12
|
+
type OidcDeps,
|
|
13
|
+
type PublicSsoProvider,
|
|
14
|
+
type SamlValidatorFactory,
|
|
15
|
+
type SsoFlowDeps,
|
|
16
|
+
type SystemRunner,
|
|
17
|
+
} from "@facilis.dev/auth";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* SSO runtime glue between the framework route and @facilis.dev/auth (D-120).
|
|
21
|
+
*
|
|
22
|
+
* Everything environment-dependent lives here: the public origin (callback/ACS URL), the
|
|
23
|
+
* failure redirect, the provider list and the flow dependency bundle. The route stays a thin
|
|
24
|
+
* method+path dispatcher, which also makes this layer unit-testable without Nitro.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** Every table an SSO login can touch; must match the route's declared `dbTables`. */
|
|
28
|
+
export const SSO_ROUTE_TABLES = [
|
|
29
|
+
"auth_sso_states",
|
|
30
|
+
"auth_identities",
|
|
31
|
+
"users",
|
|
32
|
+
"user_roles",
|
|
33
|
+
"sessions",
|
|
34
|
+
] as const;
|
|
35
|
+
|
|
36
|
+
export const SSO_ROUTE_PREFIX = "/api/auth/sso";
|
|
37
|
+
|
|
38
|
+
/** A header/URL-derived origin is attacker-controlled: accept only a plain host[:port]. */
|
|
39
|
+
const HOST_PATTERN = /^[A-Za-z0-9.-]+(?::\d{1,5})?$/;
|
|
40
|
+
|
|
41
|
+
export interface SsoRequestContext {
|
|
42
|
+
readonly event: FacilisHandlerEvent;
|
|
43
|
+
readonly config: FacilisConfig;
|
|
44
|
+
readonly system: SystemRunner;
|
|
45
|
+
readonly log: FacilisLogger;
|
|
46
|
+
readonly environment?: Readonly<Record<string, string | undefined>>;
|
|
47
|
+
/** Test seam: replaced by tests so no network is touched. */
|
|
48
|
+
readonly fetch?: FetchLike;
|
|
49
|
+
readonly now?: () => number;
|
|
50
|
+
readonly oidc?: OidcDeps;
|
|
51
|
+
readonly samlValidatorFactory?: SamlValidatorFactory;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The deployment origin used in the IdP redirect URI/ACS URL.
|
|
56
|
+
*
|
|
57
|
+
* `FACILIS_PUBLIC_ORIGIN` wins; otherwise the request URL/Host is used, which works for a
|
|
58
|
+
* direct dev server. A deploy behind a proxy MUST set the variable: the callback URL registered
|
|
59
|
+
* at the IdP has to match the public origin, and the proxy may rewrite Host.
|
|
60
|
+
*/
|
|
61
|
+
export function resolvePublicOrigin(
|
|
62
|
+
event: FacilisHandlerEvent,
|
|
63
|
+
environment: Readonly<Record<string, string | undefined>> = process.env,
|
|
64
|
+
): string {
|
|
65
|
+
const configured = environment["FACILIS_PUBLIC_ORIGIN"]?.trim();
|
|
66
|
+
if (configured !== undefined && configured.length > 0) {
|
|
67
|
+
let origin: URL;
|
|
68
|
+
try {
|
|
69
|
+
origin = new URL(configured);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new SsoError("sso_internal_error", "FACILIS_PUBLIC_ORIGIN is not a URL", {
|
|
72
|
+
cause: error,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (origin.protocol !== "https:" && origin.protocol !== "http:") {
|
|
76
|
+
throw new SsoError("sso_internal_error", "FACILIS_PUBLIC_ORIGIN must be http(s)");
|
|
77
|
+
}
|
|
78
|
+
if (origin.search !== "" || origin.hash !== "") {
|
|
79
|
+
throw new SsoError(
|
|
80
|
+
"sso_internal_error",
|
|
81
|
+
"FACILIS_PUBLIC_ORIGIN must not carry a query or hash",
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
// A preview or sub-path deployment lives under a base path (/preview/<port> in the IDE);
|
|
85
|
+
// keep it so the callback/ACS URL is the one the IdP actually has to accept.
|
|
86
|
+
const basePath = origin.pathname.replace(/\/+$/, "");
|
|
87
|
+
return `${origin.origin}${basePath}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const rawUrl = event.req.url;
|
|
91
|
+
if (typeof rawUrl === "string") {
|
|
92
|
+
try {
|
|
93
|
+
return new URL(rawUrl).origin;
|
|
94
|
+
} catch {
|
|
95
|
+
// Nitro can hand a path-only URL to the handler; fall through to the Host header.
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const host = event.req.headers.get("host");
|
|
99
|
+
if (host === null || !HOST_PATTERN.test(host)) {
|
|
100
|
+
throw new SsoError("sso_internal_error", "cannot resolve the request origin");
|
|
101
|
+
}
|
|
102
|
+
const forwarded = event.req.headers.get("x-forwarded-proto");
|
|
103
|
+
const protocol = forwarded === "https" ? "https" : "http";
|
|
104
|
+
return `${protocol}://${host}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The public provider list: ids, labels, kinds and the framework start URLs; no secrets. */
|
|
108
|
+
export function listSsoProviders(
|
|
109
|
+
config: FacilisConfig,
|
|
110
|
+
environment: Readonly<Record<string, string | undefined>> = process.env,
|
|
111
|
+
): PublicSsoProvider[] {
|
|
112
|
+
return publicProviderList(config.auth.sso, environment);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The redirect target for any failed start/callback, carrying only the safe error code. */
|
|
116
|
+
export function ssoFailureLocation(config: FacilisConfig, error: unknown): string {
|
|
117
|
+
return failureRedirectPath(config.auth.sso.failureRedirect, ssoErrorCode(error));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function flowDeps(context: SsoRequestContext): SsoFlowDeps {
|
|
121
|
+
return {
|
|
122
|
+
sso: context.config.auth.sso,
|
|
123
|
+
defaultRole: context.config.auth.defaultRole,
|
|
124
|
+
verificationEnabled: context.config.auth.verification.enabled,
|
|
125
|
+
publicOrigin: resolvePublicOrigin(context.event, context.environment ?? process.env),
|
|
126
|
+
system: context.system,
|
|
127
|
+
audit: (input) => context.log.audit(input),
|
|
128
|
+
warn: (message, data) => context.log.warn(message, data),
|
|
129
|
+
...(context.fetch === undefined ? {} : { fetch: context.fetch }),
|
|
130
|
+
...(context.now === undefined ? {} : { now: context.now }),
|
|
131
|
+
...(context.environment === undefined ? {} : { environment: context.environment }),
|
|
132
|
+
...(context.oidc === undefined ? {} : { oidc: context.oidc }),
|
|
133
|
+
...(context.samlValidatorFactory === undefined
|
|
134
|
+
? {}
|
|
135
|
+
: { samlValidatorFactory: context.samlValidatorFactory }),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function startSsoLogin(
|
|
140
|
+
context: SsoRequestContext,
|
|
141
|
+
providerId: string,
|
|
142
|
+
redirectTo: string | null,
|
|
143
|
+
): Promise<{ readonly redirectUrl: string }> {
|
|
144
|
+
return startLogin(flowDeps(context), { providerId, redirectTo });
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function completeSsoLogin(
|
|
148
|
+
context: SsoRequestContext,
|
|
149
|
+
providerId: string,
|
|
150
|
+
input: CompleteLoginInput,
|
|
151
|
+
): Promise<CompleteLoginResult> {
|
|
152
|
+
return completeLogin(flowDeps(context), providerId, input);
|
|
153
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-level state shared by the dev endpoints.
|
|
3
|
+
*
|
|
4
|
+
* Boot time is captured when the Nitro worker imports this module, which is exactly the
|
|
5
|
+
* "server is up" moment `/__facilis/health` reports (SPEC §6.3/§6.7).
|
|
6
|
+
*/
|
|
7
|
+
export const bootedAt = new Date().toISOString();
|