@ultimat3/cli 31.48.0 → 31.50.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/CLAUDE.md +30 -23
- package/README.md +96 -4
- package/package.json +30 -30
- package/src/api-registration.ts +45 -14
- package/src/api-routes.ts +1 -0
- package/src/app-load.ts +7 -3
- package/src/app-openapi.ts +7 -1
- package/src/app-root.ts +7 -1
- package/src/budgets.ts +2 -1
- package/src/clean-services.ts +142 -0
- package/src/cmd-auth.ts +3 -0
- package/src/cmd-clean-spec.ts +10 -3
- package/src/cmd-clean.ts +23 -9
- package/src/cmd-db-backfill.ts +6 -0
- package/src/cmd-db-branch.ts +10 -4
- package/src/cmd-db-recount.ts +5 -12
- package/src/cmd-db-rollback.ts +77 -0
- package/src/cmd-db-spec.ts +18 -2
- package/src/cmd-db-status.ts +5 -10
- package/src/cmd-db.ts +105 -33
- package/src/cmd-deploy-verify.ts +14 -6
- package/src/cmd-docs-topic.ts +94 -0
- package/src/cmd-docs.ts +15 -1
- package/src/cmd-doctor.ts +109 -41
- package/src/cmd-drill.ts +80 -18
- package/src/cmd-env.ts +30 -8
- package/src/cmd-errors-app.ts +63 -0
- package/src/cmd-errors.ts +50 -14
- package/src/cmd-generate.ts +17 -4
- package/src/cmd-heavy-spec.ts +9 -1
- package/src/cmd-heavy.ts +111 -27
- package/src/cmd-i18n.ts +33 -1
- package/src/cmd-jobs.ts +27 -1
- package/src/cmd-merge-driver-spec.ts +12 -0
- package/src/cmd-merge-driver.ts +95 -0
- package/src/cmd-new.ts +23 -3
- package/src/cmd-policy-spec.ts +9 -1
- package/src/cmd-policy.ts +72 -17
- package/src/cmd-stop.ts +18 -4
- package/src/cmd-tasks-run.ts +87 -0
- package/src/cmd-tasks-spec.ts +10 -3
- package/src/cmd-tasks.ts +8 -5
- package/src/cmd-test.ts +2 -1
- package/src/cmd-upgrade-spec.ts +8 -1
- package/src/cmd-upgrade.ts +15 -1
- package/src/cmd-verify.ts +9 -41
- package/src/codemods/agents-doc-row.ts +73 -0
- package/src/codemods/define-error-leaf.ts +37 -12
- package/src/codemods/docs-many-agents.ts +11 -15
- package/src/codemods/docs-worker-commands.ts +26 -0
- package/src/codemods/engine-fs.ts +9 -2
- package/src/codemods/index.ts +4 -0
- package/src/codemods/merge-drivers.ts +147 -0
- package/src/command.ts +3 -0
- package/src/db-applied-edits.ts +117 -0
- package/src/db-dev-wire.ts +18 -0
- package/src/db-diagnostics.ts +5 -10
- package/src/db-generate.ts +82 -7
- package/src/db-migrate-pass.ts +51 -0
- package/src/db-migrate-through-dev.ts +209 -0
- package/src/db-rollback-consent.ts +128 -0
- package/src/db-rollback-pass.ts +76 -0
- package/src/db-seed-generate.ts +5 -1
- package/src/db-seed.ts +7 -1
- package/src/deploy-verify-findings.ts +3 -0
- package/src/deploy-verify-grade.ts +3 -0
- package/src/deploy-verify-processes.ts +32 -0
- package/src/dev-boot.ts +3 -0
- package/src/dev-db-migrate.ts +155 -0
- package/src/dev-db-rollback.ts +33 -0
- package/src/dev-db-settled.ts +22 -0
- package/src/dev-lock-errors.ts +78 -0
- package/src/dev-lock-holder-dir.ts +64 -0
- package/src/dev-lock-live.ts +44 -0
- package/src/dev-lock.ts +59 -84
- package/src/dev-policy.ts +11 -8
- package/src/dev-rebuild-schema.ts +116 -13
- package/src/dev-rebuild.ts +13 -4
- package/src/dev-route-table.ts +7 -0
- package/src/dispatch.ts +21 -1
- package/src/doctor-api-listing.ts +114 -0
- package/src/doctor-guarded.ts +41 -0
- package/src/doctor-port.ts +90 -17
- package/src/doctor-probe.ts +36 -5
- package/src/doctor-processes-probe.ts +127 -0
- package/src/doctor-processes.ts +136 -0
- package/src/doctor-warnings.ts +17 -0
- package/src/error-codes-agents.ts +35 -0
- package/src/error-codes-processes.ts +30 -0
- package/src/error-codes-tooling.ts +2 -0
- package/src/error-codes.ts +12 -13
- package/src/errors-suite.ts +27 -0
- package/src/errors.ts +18 -22
- package/src/exercise-registration.ts +4 -3
- package/src/exercise-services.ts +13 -3
- package/src/framework-env.ts +7 -3
- package/src/framework-schema.ts +15 -5
- package/src/generate-files.ts +1 -0
- package/src/generate-grant-findings.ts +7 -5
- package/src/generate-grants.ts +9 -8
- package/src/generate-kinds.ts +30 -6
- package/src/generate-roles-file.ts +30 -0
- package/src/generate-slice-policy.ts +3 -3
- package/src/guard-sources.ts +1 -2
- package/src/guards.ts +2 -2
- package/src/heavy-env.ts +2 -0
- package/src/heavy-errors.ts +18 -0
- package/src/heavy-holders.ts +78 -0
- package/src/heavy-ledger.ts +56 -14
- package/src/heavy-pressure.ts +104 -0
- package/src/heavy.ts +31 -13
- package/src/i18n-registration.ts +22 -2
- package/src/island-harness.ts +2 -2
- package/src/job-budget.ts +4 -2
- package/src/job-registration.ts +64 -8
- package/src/jobs-queue-known.ts +43 -0
- package/src/mcp-errors-agents.ts +20 -0
- package/src/mcp-errors-doctor.ts +27 -0
- package/src/mcp-errors-processes.ts +23 -0
- package/src/mcp-errors.ts +15 -29
- package/src/mcp-host.ts +2 -2
- package/src/merge-driver-catalog.ts +58 -0
- package/src/merge-driver-config.ts +43 -0
- package/src/merge-driver-lines.ts +140 -0
- package/src/merge-state.ts +105 -0
- package/src/messages-db.ts +22 -1
- package/src/messages-processes.ts +13 -0
- package/src/messages-upgrade.ts +10 -0
- package/src/messages.ts +54 -4
- package/src/output-findings.ts +48 -21
- package/src/page-navigation.ts +5 -2
- package/src/parse.ts +37 -6
- package/src/policy-facts.ts +38 -21
- package/src/policy-row.ts +99 -0
- package/src/port-pair-free.ts +28 -0
- package/src/pwa-artifacts.ts +1 -1
- package/src/registry-lines.ts +110 -0
- package/src/registry.ts +2 -0
- package/src/retain-sweep.ts +1 -1
- package/src/retained-assets-boot.ts +1 -1
- package/src/role-replicator.ts +4 -1
- package/src/role-select.ts +86 -0
- package/src/role-start.ts +13 -55
- package/src/role-sync.ts +10 -5
- package/src/runtime-assets-site.ts +2 -2
- package/src/runtime-assets.ts +1 -1
- package/src/runtime-cache-frame.ts +46 -0
- package/src/runtime-cache-ttl.ts +23 -0
- package/src/runtime-cache.ts +33 -16
- package/src/runtime-database-ssl.ts +84 -0
- package/src/runtime-idempotency-scope.ts +16 -2
- package/src/runtime-jobs-share.ts +52 -0
- package/src/runtime-jobs.ts +43 -12
- package/src/runtime-queue.ts +18 -3
- package/src/runtime-render-document.ts +1 -2
- package/src/runtime-services.ts +8 -1
- package/src/schema-drift.ts +19 -2
- package/src/schema-dump-drift.ts +4 -1
- package/src/serve-boot-probe.ts +30 -2
- package/src/serve-boot.ts +11 -1
- package/src/serve-env.ts +39 -3
- package/src/serve.ts +61 -10
- package/src/site-asset-routes.ts +2 -2
- package/src/site-assets.ts +5 -158
- package/src/stop-run-start.ts +12 -0
- package/src/supervise-boot.ts +61 -0
- package/src/supervise-cgroup.ts +84 -0
- package/src/supervise-child.ts +206 -0
- package/src/supervise-count.ts +244 -0
- package/src/supervise-errors.ts +83 -0
- package/src/supervise-facts.ts +40 -0
- package/src/supervise-messages.ts +84 -0
- package/src/supervise-policy.ts +46 -0
- package/src/supervise-pool.ts +10 -0
- package/src/supervise-probe.ts +158 -0
- package/src/supervise-run.ts +54 -0
- package/src/supervise.ts +383 -0
- package/src/sw-precache-plan.ts +1 -1
- package/src/templates/generate-purge.ts +6 -6
- package/src/templates/guard-animated-layout-property.ts +2 -2
- package/src/templates/guard-bare-error.ts +1 -1
- package/src/templates/guard-error-declared.ts +2 -2
- package/src/templates/guard-focus-visible.ts +1 -1
- package/src/templates/guard-image-dimensions.ts +2 -2
- package/src/templates/guard-island-mount-clears.ts +1 -1
- package/src/templates/guard-native-confirm.ts +1 -1
- package/src/templates/guard-raw-breakpoint.ts +2 -2
- package/src/templates/guard-raw-colour.ts +2 -2
- package/src/templates/guard-raw-fetch.ts +1 -1
- package/src/templates/guard-raw-interval.ts +1 -1
- package/src/templates/guard-raw-length.ts +3 -3
- package/src/templates/guard-raw-motion.ts +97 -1
- package/src/templates/guard-raw-shadow.ts +1 -1
- package/src/templates/guard-raw-z-index.ts +1 -1
- package/src/templates/guard-released-forms.ts +58 -9
- package/src/templates/guard-repo-await-in-loop.ts +1 -1
- package/src/templates/guard-repo-raw-sql.ts +4 -4
- package/src/templates/guard-repo-unbounded.ts +1 -1
- package/src/templates/guard-runtime-pin.ts +1 -1
- package/src/templates/guard-semantic-interactive.ts +2 -2
- package/src/templates/guard-unbounded-fanout.ts +1 -1
- package/src/templates/guard-undeclared-custom-property.ts +3 -3
- package/src/templates/guard-undefined-style-class.ts +3 -3
- package/src/templates/guard-unzoned-date.ts +3 -3
- package/src/templates/query-slice.ts +82 -0
- package/src/templates/query.ts +76 -30
- package/src/templates/resource-page.ts +3 -2
- package/src/templates/scaffold-bin.ts +2 -0
- package/src/templates/scaffold-claude-commands.ts +6 -0
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +47 -7
- package/src/templates/scaffold-docs.ts +7 -3
- package/src/templates/scaffold-gitattributes.ts +18 -1
- package/src/templates/scaffold-helm-templates.ts +9 -0
- package/src/templates/scaffold-repo.ts +5 -2
- package/src/templates/scaffold-test-services.ts +33 -11
- package/src/templates/shapes/offline.ts +0 -7
- package/src/templates/shapes/realtime.ts +2 -6
- package/src/templates/sign-in-action-tests.ts +6 -4
- package/src/templates/sign-in-challenge.ts +62 -0
- package/src/templates/sign-in-oidc-mfa.ts +31 -0
- package/src/templates/sign-in-oidc.ts +11 -3
- package/src/templates/sign-in-password.ts +18 -56
- package/src/test-only-shipped.ts +29 -2
- package/src/test-shards.ts +134 -42
- package/src/test-verdict.ts +79 -0
- package/src/test-workers.ts +15 -0
- package/src/upgrade-coverage-ratchet.ts +95 -0
- package/src/upgrade-gate-codemods.ts +5 -3
- package/src/upgrade-gate.ts +42 -4
- package/src/upgrade-merge-drivers.ts +25 -0
- package/src/upgrade-report.ts +32 -4
- package/src/upgrade-scope.ts +62 -0
- package/src/verify-checks.ts +2 -8
- package/src/verify-coverage-run.ts +4 -1
- package/src/verify-e2e.ts +21 -3
- package/src/verify-live.ts +38 -14
- package/src/verify-only.ts +67 -0
- package/src/verify-progress.ts +7 -3
- package/src/verify-run.ts +20 -2
- package/src/verify-services-stack.ts +165 -0
- package/src/verify-services.ts +84 -2
- package/src/verify-test-run.ts +6 -7
- package/src/verify-tests.ts +8 -2
- package/src/verify-typecheck.ts +25 -2
- package/src/workspace-checks.ts +4 -1
- package/wiki/Actions.md +66 -3
- package/wiki/Admin-Dashboard.md +2 -2
- package/wiki/Agents.md +5 -5
- package/wiki/Auth.md +20 -6
- package/wiki/Bare-VM.md +1 -1
- package/wiki/CI-Parallel-Gate.md +2 -1
- package/wiki/CLI-Reference.md +115 -42
- package/wiki/Caching-And-Invalidation.md +1 -1
- package/wiki/Client-Navigation.md +35 -5
- package/wiki/Configuration.md +12 -10
- package/wiki/Deployment.md +44 -4
- package/wiki/Entities-And-Migrations.md +17 -3
- package/wiki/FAQ.md +1 -1
- package/wiki/Getting-Started.md +2 -2
- package/wiki/Home.md +3 -3
- package/wiki/I18n.md +6 -4
- package/wiki/Installation.md +12 -11
- package/wiki/Interface-Rules.md +3 -1
- package/wiki/Jobs-And-Workflows.md +24 -4
- package/wiki/Known-Gaps.md +2 -2
- package/wiki/MCP-And-AI.md +48 -13
- package/wiki/Many-Agents.md +69 -2
- package/wiki/Migrations-And-Backfills.md +18 -0
- package/wiki/Notify.md +5 -3
- package/wiki/Observability.md +13 -0
- package/wiki/Outbound-HTTP.md +53 -2
- package/wiki/Policies-And-Authz.md +1 -1
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +24 -7
- package/wiki/Routes-And-Render-Modes.md +2 -2
- package/wiki/Scheduled-Tasks.md +4 -1
- package/wiki/Static-Assets.md +5 -3
- package/wiki/Testing.md +64 -7
- package/wiki/Theming.md +6 -3
- package/wiki/Timezones-And-Dates.md +5 -1
- package/wiki/Troubleshooting.md +1 -0
- package/wiki/Tutorial-01-First-App.md +3 -3
- package/wiki/Tutorial-02-First-Feature.md +1 -1
- package/wiki/Tutorial-03-Auth-And-Admin.md +7 -6
- package/wiki/UI-Components.md +1 -0
- package/wiki/Upgrading.md +38 -0
|
@@ -86,6 +86,15 @@ nobody bound. Derived here rather than stated twice in values.yaml, where the tw
|
|
|
86
86
|
value: {{ $root.Values.metricsPort | quote }}
|
|
87
87
|
{{- end }}
|
|
88
88
|
{{- /*
|
|
89
|
+
One process per pod: per-pod parallelism is the HPA's. This chart sets CPU requests only, so
|
|
90
|
+
auto already resolves to 1; the pin makes the count explicit, and a CPU limit added later
|
|
91
|
+
cannot change it. env.ULTIMATE_PROCESSES wins when set.
|
|
92
|
+
*/}}
|
|
93
|
+
{{- if not (hasKey $root.Values.env "ULTIMATE_PROCESSES") }}
|
|
94
|
+
- name: ULTIMATE_PROCESSES
|
|
95
|
+
value: "1"
|
|
96
|
+
{{- end }}
|
|
97
|
+
{{- /*
|
|
89
98
|
The sync node's page origin, from the one place this chart already knows it. Undeclared, a node
|
|
90
99
|
reached over plain http behind this Ingress admits BOTH spellings of its host — the plain-http
|
|
91
100
|
page included. env.APP_URL wins when set; an APP_URL kept in the Secret is shadowed for this
|
|
@@ -29,7 +29,7 @@ import { verifyFloor } from './scaffold-verify-floor';
|
|
|
29
29
|
* config as out of date on every `bun run lint`. A formatter is a build input: a floating range
|
|
30
30
|
* is a `lint` step whose verdict depends on the day the app was installed.
|
|
31
31
|
*/
|
|
32
|
-
const BIOME_VERSION = '2.6.
|
|
32
|
+
const BIOME_VERSION = '2.6.6';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* The checker a scaffolded app typechecks with, and it must not lag the one the FRAMEWORK is built
|
|
@@ -107,6 +107,7 @@ const rootPackage = (app: NameSet, version: string): string => `{
|
|
|
107
107
|
"@ultimat3/policy": "${version}",
|
|
108
108
|
"@ultimat3/pwa": "${version}",
|
|
109
109
|
"@ultimat3/query": "${version}",
|
|
110
|
+
"@ultimat3/realtime": "${version}",
|
|
110
111
|
"@ultimat3/render": "${version}",
|
|
111
112
|
"@ultimat3/schema": "${version}",
|
|
112
113
|
"@ultimat3/seo": "${version}",
|
|
@@ -384,9 +385,11 @@ export function repoFiles(
|
|
|
384
385
|
app: NameSet,
|
|
385
386
|
version: string,
|
|
386
387
|
example: boolean,
|
|
388
|
+
/** The app's directory, when known: the test stack's name and ports (`scaffold-test-services`). */
|
|
389
|
+
root?: string,
|
|
387
390
|
): readonly GeneratedFile[] {
|
|
388
391
|
return [
|
|
389
|
-
...docsFiles(app),
|
|
392
|
+
...docsFiles(app, root),
|
|
390
393
|
{ path: 'package.json', contents: rootPackage(app, version) },
|
|
391
394
|
{ path: 'tsconfig.json', contents: rootTsconfig(app) },
|
|
392
395
|
{ path: 'biome.json', contents: biome() },
|
|
@@ -18,14 +18,19 @@ export const TEST_PORT_SPREAD = 500;
|
|
|
18
18
|
|
|
19
19
|
type TestPorts = { readonly [K in keyof typeof TEST_PORTS]: number };
|
|
20
20
|
|
|
21
|
+
/** The app's name, and the checkout's root when the scaffold knows it: what keys its own stack. */
|
|
22
|
+
const stackKey = (app: NameSet, root: string | undefined): string =>
|
|
23
|
+
root === undefined ? app.kebab : `${app.kebab}\0${root}`;
|
|
24
|
+
|
|
21
25
|
/**
|
|
22
26
|
* This app's host ports, one place: the compose file publishes them and the env file names them.
|
|
23
27
|
* One fixed set made two scaffolds on one machine share 55432, so the second app's live suites
|
|
24
|
-
* dialled the first app's container; the app's name
|
|
28
|
+
* dialled the first app's container; the app's name — and its root, when the scaffold knows it, so
|
|
29
|
+
* two scaffolds of one name differ too — picks its offset into each band.
|
|
25
30
|
*/
|
|
26
|
-
export const testPorts = (app: NameSet): TestPorts => {
|
|
27
|
-
// FNV-1a
|
|
28
|
-
const offset = fnv1a(app
|
|
31
|
+
export const testPorts = (app: NameSet, root?: string): TestPorts => {
|
|
32
|
+
// FNV-1a: stable across machines and runs.
|
|
33
|
+
const offset = fnv1a(stackKey(app, root)) % TEST_PORT_SPREAD;
|
|
29
34
|
return {
|
|
30
35
|
postgres: TEST_PORTS.postgres + offset,
|
|
31
36
|
redis: TEST_PORTS.redis + offset,
|
|
@@ -34,9 +39,21 @@ export const testPorts = (app: NameSet): TestPorts => {
|
|
|
34
39
|
};
|
|
35
40
|
};
|
|
36
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The compose project, written into the file as its `name:` — so every reader (`x verify`,
|
|
44
|
+
* `x clean --services`, CI, a hand-typed `docker compose -f`) resolves the same one, and a name
|
|
45
|
+
* an app wrote itself is never second-guessed. `<app>-test` alone made every scaffold of one name
|
|
46
|
+
* on one machine one project; with the root, each scaffold's is its own (clones of it share it).
|
|
47
|
+
*/
|
|
48
|
+
export const testProjectName = (app: NameSet, root?: string): string =>
|
|
49
|
+
root === undefined
|
|
50
|
+
? `${app.kebab}-test`
|
|
51
|
+
: `${app.kebab}-test-${fnv1a(root).toString(16).padStart(8, '0')}`;
|
|
52
|
+
|
|
37
53
|
const composeTest = (
|
|
38
54
|
app: NameSet,
|
|
39
|
-
|
|
55
|
+
root: string | undefined,
|
|
56
|
+
ports: TestPorts = testPorts(app, root),
|
|
40
57
|
): string => `# The services the test suites run against — in RAM, and silent.
|
|
41
58
|
#
|
|
42
59
|
# docker compose -f ${TEST_COMPOSE_PATH} up -d --wait
|
|
@@ -58,7 +75,7 @@ const composeTest = (
|
|
|
58
75
|
# watch one that will not start, run it attached: \`docker compose -f ${TEST_COMPOSE_PATH} up postgres\`.
|
|
59
76
|
#
|
|
60
77
|
# Every port binds 127.0.0.1: the credentials are in this file.
|
|
61
|
-
name: ${app
|
|
78
|
+
name: ${testProjectName(app, root)}
|
|
62
79
|
|
|
63
80
|
x-silent: &silent
|
|
64
81
|
logging: { driver: none }
|
|
@@ -151,7 +168,8 @@ services:
|
|
|
151
168
|
|
|
152
169
|
const testEnv = (
|
|
153
170
|
app: NameSet,
|
|
154
|
-
|
|
171
|
+
root: string | undefined,
|
|
172
|
+
ports: TestPorts = testPorts(app, root),
|
|
155
173
|
): string => `# Where the suites find the services ${TEST_COMPOSE_PATH} starts — the one place these URLs are
|
|
156
174
|
# written. A laptop sources it (\`set -a; . ${TEST_ENV_PATH}; set +a\`); CI appends it to $GITHUB_ENV.
|
|
157
175
|
# TEST_DATABASE_URL is what @ultimat3/testing clones one database per test worker from.
|
|
@@ -161,10 +179,14 @@ TEST_NATS_URL=nats://127.0.0.1:${ports.nats}
|
|
|
161
179
|
TEST_S3_URL=http://${app.kebab}:${app.kebab}-test@127.0.0.1:${ports.s3}/${app.kebab}-test
|
|
162
180
|
`;
|
|
163
181
|
|
|
164
|
-
/**
|
|
165
|
-
|
|
182
|
+
/**
|
|
183
|
+
* The test stack and its env file. `root`, the absolute directory `x new` writes into, makes the
|
|
184
|
+
* project name and ports this scaffold's own; without it the bytes are the name-only ones every
|
|
185
|
+
* earlier scaffold wrote, which the codemods compare against.
|
|
186
|
+
*/
|
|
187
|
+
export function testServicesFiles(app: NameSet, root?: string): readonly GeneratedFile[] {
|
|
166
188
|
return [
|
|
167
|
-
{ path: TEST_COMPOSE_PATH, contents: composeTest(app) },
|
|
168
|
-
{ path: TEST_ENV_PATH, contents: testEnv(app) },
|
|
189
|
+
{ path: TEST_COMPOSE_PATH, contents: composeTest(app, root) },
|
|
190
|
+
{ path: TEST_ENV_PATH, contents: testEnv(app, root) },
|
|
169
191
|
];
|
|
170
192
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// realtime's outbox, `createPost` safe to replay, both proven offline in a real browser, and the
|
|
4
4
|
// README's recipe for a phone on the LAN (`x dev --host <address> --tls`).
|
|
5
5
|
|
|
6
|
-
import { loadVersion } from '../../version-loader';
|
|
7
6
|
import { catalogJson } from '../catalog-json';
|
|
8
7
|
import { catalogPath } from '../locales';
|
|
9
8
|
import type { GeneratedFile, NameSet } from '../naming';
|
|
@@ -86,12 +85,6 @@ const edits = (): readonly ShapeEdit[] => [
|
|
|
86
85
|
replace:
|
|
87
86
|
' cache: { invalidates: [postTag] },\n // The outbox replays a write whose answer was lost under the SAME Idempotency-Key: this is what\n // makes that replay answer the first result instead of inserting a second post.\n idempotent: true,\n',
|
|
88
87
|
},
|
|
89
|
-
// The form imports `@ultimat3/realtime`; an isolated install resolves only what the app declares.
|
|
90
|
-
{
|
|
91
|
-
path: 'package.json',
|
|
92
|
-
find: ' "@ultimat3/render": ',
|
|
93
|
-
replace: ` "@ultimat3/realtime": "${loadVersion()}",\n "@ultimat3/render": `,
|
|
94
|
-
},
|
|
95
88
|
{ path: 'README.md', find: README_LAYOUT, replace: `${lan()}${README_LAYOUT}` },
|
|
96
89
|
...shapeLines(
|
|
97
90
|
'offline',
|
|
@@ -132,17 +132,13 @@ import * as recentPosts from '../app/post/queries/recent-posts';
|
|
|
132
132
|
find: ' },\n});\n',
|
|
133
133
|
replace: ` },\n${exerciseEntry('renamePost', 'post:write')}${exerciseEntry('recentPosts', 'post:read')}});\n`,
|
|
134
134
|
},
|
|
135
|
-
// The
|
|
135
|
+
// The notifier imports `@ultimat3/notify`; an isolated install resolves only what the app declares
|
|
136
|
+
// (`@ultimat3/realtime` is every scaffold's own dependency).
|
|
136
137
|
{
|
|
137
138
|
path: 'package.json',
|
|
138
139
|
find: ' "@ultimat3/policy": ',
|
|
139
140
|
replace: ` "@ultimat3/notify": "${loadVersion()}",\n "@ultimat3/policy": `,
|
|
140
141
|
},
|
|
141
|
-
{
|
|
142
|
-
path: 'package.json',
|
|
143
|
-
find: ' "@ultimat3/render": ',
|
|
144
|
-
replace: ` "@ultimat3/realtime": "${loadVersion()}",\n "@ultimat3/render": `,
|
|
145
|
-
},
|
|
146
142
|
...shapeLines(
|
|
147
143
|
'realtime',
|
|
148
144
|
"multi-user live state across nodes — a notifier tells the org's room (`apps/web/app/post/channels.ts`) of each new post over the bus; two `sync` nodes in `apps/web/app/post/channels.live.test.ts`",
|
|
@@ -77,9 +77,9 @@ export const createSessionTest =
|
|
|
77
77
|
(): string => `// createSession, run inside a real request over the app's migrated database: a wrong password is
|
|
78
78
|
// refused, a right one sets the session cookie, and a second factor still owed holds the challenge.
|
|
79
79
|
import { toRoute } from '@ultimat3/action';
|
|
80
|
-
import { generateTotpSecret, register, saveTotpSecret } from '@ultimat3/auth';
|
|
80
|
+
import { generateTotpSecret, MFA_CHALLENGE_COOKIE, register, saveTotpSecret } from '@ultimat3/auth';
|
|
81
81
|
${SHARED_IMPORTS}
|
|
82
|
-
import {
|
|
82
|
+
import { SECOND_FACTOR_PATH } from '../sign-in-challenge';
|
|
83
83
|
import { AFTER_SIGN_IN } from '../sign-in-flow';
|
|
84
84
|
import { createSession } from './create-session';
|
|
85
85
|
|
|
@@ -149,17 +149,19 @@ unitTest('a second factor still owed holds the challenge and sets no session', a
|
|
|
149
149
|
export const confirmSessionTest =
|
|
150
150
|
(): string => `// confirmSession, run inside a real request over the app's migrated database: with no challenge
|
|
151
151
|
// held it refuses, a wrong code is refused, and the held challenge plus the right code signs in.
|
|
152
|
+
// The challenge and its cookie's name are auth's, whichever shape's first leg held it.
|
|
152
153
|
import { toRoute } from '@ultimat3/action';
|
|
153
154
|
import {
|
|
154
155
|
generateTotpSecret,
|
|
155
156
|
login,
|
|
157
|
+
MFA_CHALLENGE_COOKIE,
|
|
158
|
+
mfaChallengeOf,
|
|
156
159
|
register,
|
|
157
160
|
saveTotpSecret,
|
|
158
161
|
totpCode,
|
|
159
162
|
totpStep,
|
|
160
163
|
} from '@ultimat3/auth';
|
|
161
164
|
${SHARED_IMPORTS}
|
|
162
|
-
import { challengeOf, MFA_CHALLENGE_COOKIE } from '../sign-in-challenge';
|
|
163
165
|
import { confirmSession } from './confirm-session';
|
|
164
166
|
|
|
165
167
|
${DATABASE}
|
|
@@ -184,7 +186,7 @@ const challenged = async (email: string) => {
|
|
|
184
186
|
const secret = generateTotpSecret();
|
|
185
187
|
await saveTotpSecret(appAuth(), user.id, secret);
|
|
186
188
|
const first = await login(appAuth(), { email, password: PASSWORD }).catch((e: unknown) => e);
|
|
187
|
-
const challenge =
|
|
189
|
+
const challenge = mfaChallengeOf(first);
|
|
188
190
|
expect(challenge).not.toBeNull();
|
|
189
191
|
return { secret, cookie: \`\${MFA_CHALLENGE_COOKIE}=\${challenge}\` };
|
|
190
192
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// `sign-in-challenge.ts` as both `x g sign-in` shapes write it: the second-factor challenge rides
|
|
2
|
+
// auth's ONE cookie (`__Host-x_mfa`), written, read and cleared through `@ultimat3/auth`. The
|
|
3
|
+
// password shape also holds it (its own first leg); OIDC's is held by `oauthLogin({ mfaPath })`.
|
|
4
|
+
|
|
5
|
+
import { SIGN_IN_PATH } from './sign-in-shared';
|
|
6
|
+
|
|
7
|
+
const HEADER: Readonly<Record<'password' | 'oidc', string>> = {
|
|
8
|
+
password: `// The second-factor challenge between the two legs: a sealed, five-minute credential \`login()\`
|
|
9
|
+
// hands back inside \`X_MFA_REQUIRED\`, carried in auth's own HttpOnly cookie — never a URL a log
|
|
10
|
+
// keeps — and read back by \`confirmSession\` through here.`,
|
|
11
|
+
oidc: `// The second-factor challenge between the provider's callback and the code. \`oauthLogin({ mfaPath })\`
|
|
12
|
+
// sends an enrolled user to SECOND_FACTOR_PATH with it sealed in auth's own HttpOnly cookie — never
|
|
13
|
+
// a URL a log keeps — and \`confirmSession\` reads it back through here.`,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const PATH_DOC: Readonly<Record<'password' | 'oidc', string>> = {
|
|
17
|
+
password:
|
|
18
|
+
'/** Where `createSession` sends a person who owes a code, and the page that posts it. */',
|
|
19
|
+
oidc: '/** The `mfaPath` `oidc.ts` hands `oauthLogin`, and the page that posts the code. */',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const HOLD = `
|
|
23
|
+
/** Auth's own line: the cookie a built-in callback sets, living as long as the challenge. */
|
|
24
|
+
export const holdChallenge = (challenge: string): void => {
|
|
25
|
+
useRequestContext('holdChallenge').headers.append('set-cookie', mfaChallengeCookie(challenge));
|
|
26
|
+
};
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const challengeSource = (shape: 'password' | 'oidc'): string => {
|
|
30
|
+
const names = [
|
|
31
|
+
'clearMfaChallengeCookie',
|
|
32
|
+
...(shape === 'password' ? ['mfaChallengeCookie'] : []),
|
|
33
|
+
'readMfaChallenge',
|
|
34
|
+
];
|
|
35
|
+
return `${HEADER[shape]}
|
|
36
|
+
import { ${names.join(', ')} } from '@ultimat3/auth';
|
|
37
|
+
import { useRequestContext, useRequestHeaders } from '@ultimat3/http';
|
|
38
|
+
|
|
39
|
+
${PATH_DOC[shape]}
|
|
40
|
+
export const SECOND_FACTOR_PATH = '${SIGN_IN_PATH}/second-factor';
|
|
41
|
+
${shape === 'password' ? HOLD : ''}
|
|
42
|
+
export const heldChallenge = (): string | null => {
|
|
43
|
+
const value = readMfaChallenge({ headers: useRequestHeaders() });
|
|
44
|
+
return value === null || value === '' ? null : value;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Auth's own clearing line, relayed as it is: the cookie's name and attributes are auth's. */
|
|
48
|
+
export const dropChallenge = (): void => {
|
|
49
|
+
useRequestContext('dropChallenge').headers.append('set-cookie', clearMfaChallengeCookie());
|
|
50
|
+
};
|
|
51
|
+
`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const challengeTest =
|
|
55
|
+
(): string => `// The path the second leg lives at is the page this app serves the second-factor form at.
|
|
56
|
+
import { expect, unitTest } from '@ultimat3/testing';
|
|
57
|
+
import { SECOND_FACTOR_PATH } from './sign-in-challenge';
|
|
58
|
+
|
|
59
|
+
unitTest('the second leg lives under the sign-in page', () => {
|
|
60
|
+
expect(SECOND_FACTOR_PATH).toBe('${SIGN_IN_PATH}/second-factor');
|
|
61
|
+
});
|
|
62
|
+
`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// `x g sign-in --oidc`'s second leg. An MFA-enrolled user's callback cannot finish inside
|
|
2
|
+
// `oauthLogin`: it 303s to `mfaPath` with the challenge sealed in auth's own HttpOnly cookie, so the
|
|
3
|
+
// scaffold passes that path and ships the page and the action behind it (auth README, MFA).
|
|
4
|
+
|
|
5
|
+
import type { GeneratedFile } from './naming';
|
|
6
|
+
import { confirmSessionTest } from './sign-in-action-tests';
|
|
7
|
+
import { challengeSource, challengeTest } from './sign-in-challenge';
|
|
8
|
+
import { secondFactorSource, signInPageTest } from './sign-in-pages';
|
|
9
|
+
import { confirmSessionSource, POSTS_AT } from './sign-in-password';
|
|
10
|
+
import { AUTH_DIR } from './sign-in-shared';
|
|
11
|
+
|
|
12
|
+
/** The `import` and the option `oidc.ts` gains: the callback's way to the second-factor page. */
|
|
13
|
+
export const OIDC_MFA_IMPORT = "import { SECOND_FACTOR_PATH } from './sign-in-challenge';";
|
|
14
|
+
export const OIDC_MFA_OPTION = 'mfaPath: SECOND_FACTOR_PATH,';
|
|
15
|
+
|
|
16
|
+
export function oidcSecondFactorFiles(module: string | undefined): readonly GeneratedFile[] {
|
|
17
|
+
return [
|
|
18
|
+
{ path: `${AUTH_DIR}/sign-in-challenge.ts`, contents: challengeSource('oidc') },
|
|
19
|
+
{ path: `${AUTH_DIR}/sign-in-challenge.test.ts`, contents: challengeTest() },
|
|
20
|
+
{ path: `${AUTH_DIR}/actions/confirm-session.ts`, contents: confirmSessionSource() },
|
|
21
|
+
{
|
|
22
|
+
path: `${AUTH_DIR}/actions/confirm-session.test.ts`,
|
|
23
|
+
contents: confirmSessionTest(),
|
|
24
|
+
},
|
|
25
|
+
{ path: `${AUTH_DIR}/sign-in/second-factor/page.tsx`, contents: secondFactorSource(module) },
|
|
26
|
+
{
|
|
27
|
+
path: `${AUTH_DIR}/sign-in/second-factor/page.test.ts`,
|
|
28
|
+
contents: signInPageTest(module, 'app.auth.secondFactor', POSTS_AT('confirmSession'), false),
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// `x g sign-in --oidc <provider>`: an OpenID Connect issuer, discovered when the first sign-in
|
|
2
|
-
// arrives
|
|
3
|
-
// the
|
|
4
|
-
//
|
|
2
|
+
// arrives, its two legs (`oauthLogin`) mounted on `runtime.routes`, and the page linking the first.
|
|
3
|
+
// PKCE, the sealed handshake and the account link are the framework's; which IdP group means which
|
|
4
|
+
// role stays the app's (`resolveGrants`). The second factor's leg is `sign-in-oidc-mfa.ts`'s.
|
|
5
5
|
|
|
6
6
|
// The literal the generated tests pin comes from auth itself, so the scaffold cannot drift from it.
|
|
7
7
|
import { oauthStartPath } from '@ultimat3/auth';
|
|
8
8
|
import { catalogJson } from './catalog-json';
|
|
9
9
|
import { catalogPath } from './locales';
|
|
10
10
|
import type { GeneratedFile } from './naming';
|
|
11
|
+
import { OIDC_MFA_IMPORT, OIDC_MFA_OPTION, oidcSecondFactorFiles } from './sign-in-oidc-mfa';
|
|
11
12
|
import {
|
|
12
13
|
SIGN_IN_CATALOG,
|
|
13
14
|
type SignInForm,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
signInPageSource,
|
|
16
17
|
signInPageTest,
|
|
17
18
|
} from './sign-in-pages';
|
|
19
|
+
import { SECOND_FACTOR_CATALOG } from './sign-in-password';
|
|
18
20
|
import { OIDC_RUNTIME_ROUTES } from './sign-in-runtime';
|
|
19
21
|
import { AUTH_DIR, sharedSignInFiles } from './sign-in-shared';
|
|
20
22
|
|
|
@@ -54,6 +56,7 @@ import {
|
|
|
54
56
|
registerOAuthProvider,
|
|
55
57
|
} from '@ultimat3/auth';
|
|
56
58
|
import { appAuth } from './auth';
|
|
59
|
+
${OIDC_MFA_IMPORT}
|
|
57
60
|
import { AFTER_SIGN_IN } from './sign-in-flow';
|
|
58
61
|
|
|
59
62
|
export const OIDC_PROVIDER = '${provider}';
|
|
@@ -89,6 +92,9 @@ export const oidcLegs = (env: Env = process.env): Promise<OAuthLoginRoutes> => {
|
|
|
89
92
|
return oauthLogin(signInAuth(), {
|
|
90
93
|
successPath: AFTER_SIGN_IN,
|
|
91
94
|
callbackPath: OIDC_CALLBACK_PATH,
|
|
95
|
+
// An MFA-enrolled user finishes on this app's second-factor page; without it their
|
|
96
|
+
// callback is a 401 they can never get past.
|
|
97
|
+
${OIDC_MFA_OPTION}
|
|
92
98
|
});
|
|
93
99
|
})().catch((error: unknown) => {
|
|
94
100
|
legs = undefined;
|
|
@@ -192,11 +198,13 @@ export function oidcSignInFiles(
|
|
|
192
198
|
path: `${AUTH_DIR}/sign-in/page.test.ts`,
|
|
193
199
|
contents: signInPageTest(module, 'app.auth.signIn', `'href="${oauthStartPath(provider)}"'`),
|
|
194
200
|
},
|
|
201
|
+
...oidcSecondFactorFiles(module),
|
|
195
202
|
...options.locales.map((locale) => ({
|
|
196
203
|
path: catalogPath(locale),
|
|
197
204
|
contents: catalogJson({
|
|
198
205
|
...SIGN_IN_CATALOG,
|
|
199
206
|
'app.auth.signIn.continue': `Continue with ${provider}`,
|
|
207
|
+
...SECOND_FACTOR_CATALOG,
|
|
200
208
|
}),
|
|
201
209
|
merge: 'json' as const,
|
|
202
210
|
})),
|
|
@@ -6,6 +6,7 @@ import { catalogJson } from './catalog-json';
|
|
|
6
6
|
import { catalogPath } from './locales';
|
|
7
7
|
import type { GeneratedFile } from './naming';
|
|
8
8
|
import { confirmSessionTest, createSessionTest } from './sign-in-action-tests';
|
|
9
|
+
import { challengeSource, challengeTest } from './sign-in-challenge';
|
|
9
10
|
import {
|
|
10
11
|
SIGN_IN_CATALOG,
|
|
11
12
|
type SignInForm,
|
|
@@ -14,66 +15,21 @@ import {
|
|
|
14
15
|
signInPageSource,
|
|
15
16
|
signInPageTest,
|
|
16
17
|
} from './sign-in-pages';
|
|
17
|
-
import { AUTH_DIR,
|
|
18
|
+
import { AUTH_DIR, sharedSignInFiles } from './sign-in-shared';
|
|
18
19
|
|
|
19
20
|
/** The master key seals the second-factor challenge between the two legs. */
|
|
20
21
|
export const PASSWORD_SIGN_IN_ENV: readonly string[] = ['ULTIMATE_SECRETS_KEY'];
|
|
21
22
|
|
|
22
|
-
const challengeSource =
|
|
23
|
-
(): string => `// The second-factor challenge between the two legs: a sealed, five-minute credential \`login()\`
|
|
24
|
-
// hands back inside \`X_MFA_REQUIRED\`, carried in an HttpOnly cookie rather than a URL a log keeps.
|
|
25
|
-
import { MFA_CHALLENGE_TTL_MS } from '@ultimat3/auth';
|
|
26
|
-
import { isUltimateError } from '@ultimat3/core';
|
|
27
|
-
import { deleteCookie, setCookie, useRequestCookie } from '@ultimat3/http';
|
|
28
|
-
|
|
29
|
-
export const MFA_CHALLENGE_COOKIE = 'x_mfa_challenge';
|
|
30
|
-
export const SECOND_FACTOR_PATH = '${SIGN_IN_PATH}/second-factor';
|
|
31
|
-
|
|
32
|
-
/** The sealed challenge an \`X_MFA_REQUIRED\` carries, or \`null\` for any other throw. */
|
|
33
|
-
export const challengeOf = (error: unknown): string | null => {
|
|
34
|
-
if (!isUltimateError(error) || error.code !== 'X_MFA_REQUIRED') return null;
|
|
35
|
-
const challenge = error.meta?.['challenge'];
|
|
36
|
-
return typeof challenge === 'string' && challenge !== '' ? challenge : null;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const holdChallenge = (challenge: string): void =>
|
|
40
|
-
setCookie(MFA_CHALLENGE_COOKIE, challenge, { maxAge: Math.floor(MFA_CHALLENGE_TTL_MS / 1000) });
|
|
41
|
-
|
|
42
|
-
export const heldChallenge = (): string | null => {
|
|
43
|
-
const value = useRequestCookie(MFA_CHALLENGE_COOKIE);
|
|
44
|
-
return value === null || value === '' ? null : value;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const dropChallenge = (): void => deleteCookie(MFA_CHALLENGE_COOKIE);
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
const challengeTest =
|
|
51
|
-
(): string => `// Only an X_MFA_REQUIRED carrying a challenge is a second leg; every other throw is not.
|
|
52
|
-
import { UltimateError } from '@ultimat3/core';
|
|
53
|
-
import { expect, unitTest } from '@ultimat3/testing';
|
|
54
|
-
import { challengeOf } from './sign-in-challenge';
|
|
55
|
-
|
|
56
|
-
const coded = (code: string, meta?: Record<string, unknown>) =>
|
|
57
|
-
new UltimateError({ code, cause: 'a test throw', fix: 'none', ...(meta ? { meta } : {}) });
|
|
58
|
-
|
|
59
|
-
unitTest('a sealed challenge is read off X_MFA_REQUIRED, and nothing else is one', () => {
|
|
60
|
-
expect(challengeOf(coded('X_MFA_REQUIRED', { challenge: 'sealed' }))).toBe('sealed');
|
|
61
|
-
expect(challengeOf(coded('X_MFA_REQUIRED'))).toBeNull();
|
|
62
|
-
expect(challengeOf(coded('X_UNAUTHENTICATED', { challenge: 'sealed' }))).toBeNull();
|
|
63
|
-
expect(challengeOf('X_MFA_REQUIRED')).toBeNull();
|
|
64
|
-
});
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
23
|
const createSessionSource =
|
|
68
24
|
(): string => `// Sign in with an address and a password. \`login()\` is the whole check — the hash, the lockout and
|
|
69
25
|
// one indistinguishable \`X_UNAUTHENTICATED\` for every way a credential is wrong. A second factor
|
|
70
26
|
// still owed stops here with the sealed challenge held for the next page.
|
|
71
27
|
import { action, t } from '@ultimat3/action';
|
|
72
|
-
import { login } from '@ultimat3/auth';
|
|
28
|
+
import { login, mfaChallengeOf } from '@ultimat3/auth';
|
|
73
29
|
import { useRequestContext } from '@ultimat3/http';
|
|
74
30
|
import { allow } from '@ultimat3/policy';
|
|
75
31
|
import { appAuth } from '../auth';
|
|
76
|
-
import {
|
|
32
|
+
import { holdChallenge, SECOND_FACTOR_PATH } from '../sign-in-challenge';
|
|
77
33
|
import { NEXT_PARAM, nextPath } from '../sign-in-flow';
|
|
78
34
|
|
|
79
35
|
export const createSession = action({
|
|
@@ -99,7 +55,7 @@ export const createSession = action({
|
|
|
99
55
|
request.headers.append('set-cookie', signedIn.cookie);
|
|
100
56
|
return { ok: true, next: nextPath(input[NEXT_PARAM]), secondFactor: false };
|
|
101
57
|
} catch (error) {
|
|
102
|
-
const challenge =
|
|
58
|
+
const challenge = mfaChallengeOf(error);
|
|
103
59
|
if (challenge === null) throw error;
|
|
104
60
|
holdChallenge(challenge);
|
|
105
61
|
// The way on survives the second leg: its form posts \`next\` back to \`confirmSession\`.
|
|
@@ -114,7 +70,8 @@ export const createSession = action({
|
|
|
114
70
|
});
|
|
115
71
|
`;
|
|
116
72
|
|
|
117
|
-
|
|
73
|
+
/** Both shapes' second leg: it reads the challenge through `../sign-in-challenge`, whoever held it. */
|
|
74
|
+
export const confirmSessionSource =
|
|
118
75
|
(): string => `// The second leg: the six digits (or one recovery code) against the challenge the first leg held.
|
|
119
76
|
// \`completeMfa()\` meters the guess against the same lockout a password guess spends.
|
|
120
77
|
import { action, t } from '@ultimat3/action';
|
|
@@ -168,19 +125,24 @@ const PASSWORD_FORM: SignInForm = {
|
|
|
168
125
|
</form>`,
|
|
169
126
|
};
|
|
170
127
|
|
|
128
|
+
/** The second-factor page's copy, for whichever shape reaches it. */
|
|
129
|
+
export const SECOND_FACTOR_CATALOG: Readonly<Record<string, string>> = {
|
|
130
|
+
'app.auth.secondFactor.title': 'Second factor',
|
|
131
|
+
'app.auth.secondFactor.description': 'Enter the code from your authenticator app.',
|
|
132
|
+
'app.auth.secondFactor.code': 'Code',
|
|
133
|
+
'app.auth.secondFactor.submit': 'Continue',
|
|
134
|
+
};
|
|
135
|
+
|
|
171
136
|
const CATALOG: Readonly<Record<string, string>> = {
|
|
172
137
|
...SIGN_IN_CATALOG,
|
|
173
138
|
'app.auth.signIn.email': 'Email',
|
|
174
139
|
'app.auth.signIn.password': 'Password',
|
|
175
140
|
'app.auth.signIn.submit': 'Sign in',
|
|
176
|
-
|
|
177
|
-
'app.auth.secondFactor.description': 'Enter the code from your authenticator app.',
|
|
178
|
-
'app.auth.secondFactor.code': 'Code',
|
|
179
|
-
'app.auth.secondFactor.submit': 'Continue',
|
|
141
|
+
...SECOND_FACTOR_CATALOG,
|
|
180
142
|
};
|
|
181
143
|
|
|
182
144
|
/** The test's expectation that the page's form posts at `action`'s derived route. */
|
|
183
|
-
const POSTS_AT = (action: string): string => `\`action="\${derivePath('${action}').path}"\``;
|
|
145
|
+
export const POSTS_AT = (action: string): string => `\`action="\${derivePath('${action}').path}"\``;
|
|
184
146
|
|
|
185
147
|
export function passwordSignInFiles(options: SignInTemplateOptions): readonly GeneratedFile[] {
|
|
186
148
|
const module = options.catalogModule;
|
|
@@ -189,7 +151,7 @@ export function passwordSignInFiles(options: SignInTemplateOptions): readonly Ge
|
|
|
189
151
|
PASSWORD_SIGN_IN_ENV,
|
|
190
152
|
'The master key seals the second-factor challenge between the two legs.',
|
|
191
153
|
),
|
|
192
|
-
{ path: `${AUTH_DIR}/sign-in-challenge.ts`, contents: challengeSource() },
|
|
154
|
+
{ path: `${AUTH_DIR}/sign-in-challenge.ts`, contents: challengeSource('password') },
|
|
193
155
|
{ path: `${AUTH_DIR}/sign-in-challenge.test.ts`, contents: challengeTest() },
|
|
194
156
|
{ path: `${AUTH_DIR}/actions/create-session.ts`, contents: createSessionSource() },
|
|
195
157
|
{
|
package/src/test-only-shipped.ts
CHANGED
|
@@ -15,6 +15,11 @@ export interface ShippedPackage {
|
|
|
15
15
|
readonly dir: string;
|
|
16
16
|
/** Package-relative (`src/index.ts`), and may be a glob (`src/icons/glyphs/*.ts`). */
|
|
17
17
|
readonly entries: readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* The `files` negations, without their `!` (`src/link-login.ts`): a module one matches is not in
|
|
20
|
+
* the tarball, so it ships nothing whoever imports it.
|
|
21
|
+
*/
|
|
22
|
+
readonly excluded?: readonly string[];
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export interface TestOnlyModule {
|
|
@@ -29,7 +34,12 @@ export interface TestOnlyModule {
|
|
|
29
34
|
* field: a module the manifest names is shipped on purpose, whichever field names it.
|
|
30
35
|
*/
|
|
31
36
|
export function entryPatternsOf(manifest: unknown): readonly string[] {
|
|
32
|
-
|
|
37
|
+
// A `files` negation names what the tarball leaves out, never an entry it ships.
|
|
38
|
+
const text = JSON.stringify(manifest ?? null, (key, value: unknown) =>
|
|
39
|
+
key === 'files' && Array.isArray(value)
|
|
40
|
+
? value.filter((entry) => typeof entry !== 'string' || !entry.startsWith('!'))
|
|
41
|
+
: value,
|
|
42
|
+
);
|
|
33
43
|
const found = [...text.matchAll(/(?:\.\/)?(src\/[\w./*-]+?\.tsx?)(?![\w.])/g)];
|
|
34
44
|
return [...new Set(found.map((match) => match[1] ?? ''))].sort();
|
|
35
45
|
}
|
|
@@ -135,18 +145,35 @@ export function testOnlyModules(
|
|
|
135
145
|
pkg.entries.map((entry) => new Bun.Glob(`packages/${pkg.dir}/${entry}`)),
|
|
136
146
|
]),
|
|
137
147
|
);
|
|
148
|
+
// A negation names a file or a directory (`!src/held/`): match the pattern and what is under it.
|
|
149
|
+
const excludedGlobs = new Map(
|
|
150
|
+
packages.map((pkg) => [
|
|
151
|
+
pkg.dir,
|
|
152
|
+
(pkg.excluded ?? []).flatMap((pattern) => {
|
|
153
|
+
const base = `packages/${pkg.dir}/${pattern.replace(/\/+$/, '')}`;
|
|
154
|
+
return [new Bun.Glob(base), new Bun.Glob(`${base}/**`)];
|
|
155
|
+
}),
|
|
156
|
+
]),
|
|
157
|
+
);
|
|
158
|
+
const isExcluded = (path: string): boolean => {
|
|
159
|
+
const dir = /^packages\/([^/]+)\/src\//.exec(path)?.[1];
|
|
160
|
+
return (excludedGlobs.get(dir ?? '') ?? []).some((glob) => glob.match(path));
|
|
161
|
+
};
|
|
138
162
|
const referrers = new Map<string, ReadonlySet<string>>();
|
|
139
163
|
for (const path of sources.keys()) {
|
|
140
164
|
const dir = /^packages\/([^/]+)\/src\//.exec(path)?.[1];
|
|
141
165
|
const globs = dir === undefined ? undefined : entryGlobs.get(dir);
|
|
142
166
|
if (globs === undefined || !path.endsWith('.ts') || isGenerated(path)) continue;
|
|
167
|
+
if (isExcluded(path)) continue;
|
|
143
168
|
if (isTest(path) || isFixture(path) || globs.some((glob) => glob.match(path))) continue;
|
|
144
169
|
const from = new Set([...(imports.get(path) ?? []), ...(named.get(baseName(path)) ?? [])]);
|
|
145
170
|
from.delete(path);
|
|
146
171
|
if (from.size > 0) referrers.set(path, from);
|
|
147
172
|
}
|
|
148
173
|
const testOnly = new Set(referrers.keys());
|
|
149
|
-
|
|
174
|
+
// An excluded file is not in the tarball, so what only it imports ships for no one's sake.
|
|
175
|
+
const live = (path: string): boolean =>
|
|
176
|
+
!isTest(path) && !isFixture(path) && !isExcluded(path) && !testOnly.has(path);
|
|
150
177
|
for (let changed = true; changed; ) {
|
|
151
178
|
changed = false;
|
|
152
179
|
for (const path of testOnly) {
|