@getstrata/starter 2.2.43 → 2.2.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,7 +28,7 @@ The wizard asks for each layer. In a terminal, lists use up/down and Enter, or a
28
28
 
29
29
  Layer flags: `--frontend`, `--database`, `--auth`, `--tenancy`, `--cache`, `--queue`, `--mail`, `--spa-prefix`, plus extras (`--mfa`, `--email-verification`, `--scim`, `--metrics`) and their `--no-` forms.
30
30
 
31
- Pick one database engine. Docker Compose is optional (`--docker`, `--no-docker`, `--docker-services=postgres,redis`) and only includes services for the tools you selected. `--docker` with Postgres or MySQL also writes Adminer on port 8080.
31
+ Pick one database engine. Docker Compose is optional (`--docker`, `--no-docker`, `--docker-services=postgres,redis`) and only includes services for the tools you selected. The wizard offers optional Adminer in both Docker and Mix modes when the database is in Compose. `--docker` alone includes required services only; add Adminer explicitly with `--docker-services=mysql,mailpit,adminer` (or `postgres`). When selected, start its debug profile with `docker compose --profile debug up -d`; open http://localhost:8080.
32
32
 
33
33
  ## What you get
34
34
 
package/dist/cli.js CHANGED
@@ -171,6 +171,9 @@ function selectedDockerServices(layers) {
171
171
  }
172
172
  return selected;
173
173
  }
174
+ function dockerComposeUpCommand(layers) {
175
+ return selectedDockerServices(layers).includes("adminer") ? "docker compose --profile debug up -d" : "docker compose up -d";
176
+ }
174
177
  function reconcileDocker(layers) {
175
178
  const selected = selectedDockerServices(layers);
176
179
  return {
@@ -1110,12 +1113,11 @@ async function promptDockerLayer(prompter, layers) {
1110
1113
  if (mode === "local") {
1111
1114
  return dockerLayerForNeeded(layers, false);
1112
1115
  }
1113
- if (mode === "docker") {
1114
- return dockerLayerForNeeded(layers, true);
1115
- }
1116
- const services = emptyDockerServices();
1117
- for (const name of needed) {
1118
- services[name] = await prompter.confirm(`Docker Compose for ${DOCKER_SERVICE_LABELS[name]}?`, true);
1116
+ const services = mode === "docker" ? dockerLayerForNeeded(layers, true).services : emptyDockerServices();
1117
+ if (mode === "mix") {
1118
+ for (const name of needed) {
1119
+ services[name] = await prompter.confirm(`Docker Compose for ${DOCKER_SERVICE_LABELS[name]}?`, true);
1120
+ }
1119
1121
  }
1120
1122
  const databaseService = dockerDatabaseService(layers.database);
1121
1123
  if (databaseService && services[databaseService]) {
@@ -1172,7 +1174,9 @@ function renderAuthModule(layers) {
1172
1174
  const oidc = Boolean(layers.extras.oidc && cookie);
1173
1175
  const mfa = Boolean(layers.extras.mfa && cookie);
1174
1176
  const verify = Boolean(layers.extras.emailVerification);
1175
- const jsonApi = authUsesToken(layers.auth) || authUsesJwt(layers.auth);
1177
+ const bearerApi = authUsesToken(layers.auth) || authUsesJwt(layers.auth);
1178
+ const jsonCookieAccounts = cookie && (layers.frontend === "api" || layers.frontend === "spa-react");
1179
+ const jsonAccounts = bearerApi || jsonCookieAccounts;
1176
1180
  const tenantInsert = usesTenantTable(layers.tenancy);
1177
1181
  const tenantCreateField = tenantInsert ? `
1178
1182
  tenant_id: currentTenantId(),` : "";
@@ -1200,7 +1204,7 @@ function renderAuthModule(layers) {
1200
1204
  }
1201
1205
  }
1202
1206
  imports.push(`import { ConflictError } from "@getstrata/core/errors/http";`);
1203
- if (jsonApi) {
1207
+ if (bearerApi) {
1204
1208
  imports.push(`import { AuthManager } from "@getstrata/core/auth/guard";`);
1205
1209
  }
1206
1210
  if (authUsesJwt(layers.auth)) {
@@ -1213,6 +1217,9 @@ function renderAuthModule(layers) {
1213
1217
  if (mfa) {
1214
1218
  imports.push(`import { createPasswordConfirmCookie } from "@getstrata/core/auth/passwordConfirmCookie";`);
1215
1219
  }
1220
+ if (mfa && jsonCookieAccounts) {
1221
+ imports.push(`import { createRequirePasswordConfirmMiddleware } from "@getstrata/core/http/requirePasswordConfirmMiddleware";`, `import { withMiddleware } from "@getstrata/core/http/routeMiddleware";`);
1222
+ }
1216
1223
  imports.push(`import { emailRule, minLength, required, stringRule, validateObject } from "@getstrata/core/validation/rules";`);
1217
1224
  imports.push(`import { parseJsonBody } from "@getstrata/core/http/validation";`);
1218
1225
  imports.push(`import { sqlTimestamp } from "@getstrata/core/database/dialect";`);
@@ -1230,7 +1237,7 @@ function renderAuthModule(layers) {
1230
1237
  }
1231
1238
  imports.push(oidc ? `import { clearOidcPkceCookie, createOAuthState, readOidcPkceCookie, sealOidcPkceCookie, verifyOAuthState } from "@getstrata/core/security/oauthState";` : `import { createOAuthState, verifyOAuthState } from "@getstrata/core/security/oauthState";`);
1232
1239
  }
1233
- if (jsonApi || cookie) {
1240
+ if (bearerApi || cookie) {
1234
1241
  imports.push(`import { privateJsonResponse, withErrorHandling } from "@getstrata/core/http/response";`);
1235
1242
  imports.push(`import { resolveCsrfTokenForRequest } from "@getstrata/core/http/csrfToken";`);
1236
1243
  }
@@ -1501,7 +1508,7 @@ async function completeBrowserSsoLogin(
1501
1508
  });
1502
1509
  }),
1503
1510
  },` : "";
1504
- const jsonRegister = jsonApi ? `
1511
+ const jsonRegister = jsonAccounts ? `
1505
1512
  "/api/v1/auth/register": {
1506
1513
  POST: kernel.wrap("api", kernel.wrapRegister(withErrorHandling(async (request) => {
1507
1514
  if ((process.env.FEATURE_REGISTRATION ?? "true") === "false") {
@@ -1549,7 +1556,7 @@ async function completeBrowserSsoLogin(
1549
1556
  });
1550
1557
  }))),
1551
1558
  },` : "";
1552
- const apiUser = jsonApi ? `
1559
+ const apiUser = bearerApi ? `
1553
1560
  "/api/user": {
1554
1561
  GET: kernel.wrapApi(async (request) => {
1555
1562
  const user = await dependencies.container.resolve<AuthManager>(CORE_AUTH_TOKEN).requireUser(request);
@@ -1565,7 +1572,7 @@ async function completeBrowserSsoLogin(
1565
1572
  ` : ""}return payload;
1566
1573
  })),
1567
1574
  },` : "";
1568
- const jsonPassword = jsonApi ? `
1575
+ const jsonPassword = jsonAccounts ? `
1569
1576
  "/api/v1/auth/forgot-password": {
1570
1577
  POST: kernel.wrap("api", withErrorHandling(async (request) => {
1571
1578
  const email = await parseJsonBody(request, parseForgotPasswordEmail);
@@ -1578,7 +1585,7 @@ async function completeBrowserSsoLogin(
1578
1585
  },
1579
1586
  "/api/v1/auth/reset-password": {
1580
1587
  POST: kernel.wrap("api", kernel.wrapSigned(withErrorHandling(async (request) => {
1581
- const body: unknown = await request.json();
1588
+ const body = await parseJsonBody(request, (payload) => payload);
1582
1589
  const password = typeof body === "object" && body !== null && "password" in body ? body.password : undefined;
1583
1590
  if (!(await completeSignedPasswordReset(request, password))) {
1584
1591
  return privateJsonResponse({ error: "Invalid or expired reset link." }, { status: 403 });
@@ -1586,7 +1593,7 @@ async function completeBrowserSsoLogin(
1586
1593
  return privateJsonResponse({ ok: true });
1587
1594
  }))),
1588
1595
  },` : "";
1589
- const jsonVerify = jsonApi && verify ? `
1596
+ const jsonVerify = jsonAccounts && verify ? `
1590
1597
  "/api/v1/auth/verify-email": {
1591
1598
  POST: kernel.wrap("api", kernel.wrapSigned(withErrorHandling(async (request) => {
1592
1599
  if (!(await completeSignedEmailVerification(request))) {
@@ -1595,13 +1602,53 @@ async function completeBrowserSsoLogin(
1595
1602
  return privateJsonResponse({ ok: true });
1596
1603
  }))),
1597
1604
  },` : "";
1605
+ const jsonAccountManagement = jsonCookieAccounts ? `
1606
+ ${verify ? `"/api/v1/auth/verification-notification": {
1607
+ POST: kernel.wrapApi(async (request) => {
1608
+ const user = await dependencies.container.resolve<CookieSessionAuthManager>(CORE_AUTH_TOKEN).requireUser(request);
1609
+ await runWithLockedAuthUser(Number(user.id), async (record) => {
1610
+ if (!record?.is_active || record.auth_version !== user.authVersion) throw new ConflictError("Account changed. Sign in again.");
1611
+ if (!record.email_verified_at) await issueSignedAuthMail(record.email ?? "", "Verify your email", "/api/v1/auth/verify-email", AUTH_ONE_TIME_PURPOSES.emailVerify, record.id, { id: String(record.id) });
1612
+ });
1613
+ return privateJsonResponse({ ok: true });
1614
+ }),
1615
+ },` : ""}
1616
+ ${mfa ? `"/api/v1/auth/confirm-password": {
1617
+ POST: kernel.wrap("api", kernel.wrapVerified(async (request) => {
1618
+ const user = await dependencies.container.resolve<CookieSessionAuthManager>(CORE_AUTH_TOKEN).requireUser(request);
1619
+ const { password } = await parseJsonBody(request, (payload) => validateObject(payload, { password: [required(), stringRule()] }));
1620
+ return runWithLockedAuthUser(Number(user.id), async (record) => {
1621
+ if (!record?.is_active || record.auth_version !== user.authVersion) throw new ConflictError("Account changed. Sign in again.");
1622
+ if (!record.password || !(await verifyPassword(String(password), record.password))) return privateJsonResponse({ error: "That password is not correct." }, { status: 422 });
1623
+ const response = privateJsonResponse({ ok: true });
1624
+ response.headers.append("set-cookie", createPasswordConfirmCookie(Number(user.id), record.auth_version));
1625
+ return response;
1626
+ });
1627
+ })),
1628
+ },
1629
+ "/api/v1/auth/mfa": {
1630
+ GET: kernel.wrap("api", kernel.wrapVerified(async (request) => {
1631
+ const user = await dependencies.container.resolve<CookieSessionAuthManager>(CORE_AUTH_TOKEN).requireUser(request);
1632
+ const record = await starterAuthDirectory.findByIdOrThrow(Number(user.id));
1633
+ const secret = generateTotpSecret();
1634
+ return privateJsonResponse({ secret, otpauth: buildOtpauthUrl({ secret, account: record.email ?? "user", issuer: process.env.APP_NAME ?? "Strata" }) });
1635
+ })),
1636
+ POST: kernel.wrap("api", kernel.wrapVerified(withMiddleware(createRequirePasswordConfirmMiddleware())(async (request) => {
1637
+ const user = await dependencies.container.resolve<CookieSessionAuthManager>(CORE_AUTH_TOKEN).requireUser(request);
1638
+ const fields = await parseJsonBody(request, (payload) => validateObject(payload, { secret: [required(), stringRule()], code: [required(), stringRule()] }));
1639
+ const secret = String(fields.secret).trim();
1640
+ if (!verifyTotp(secret, String(fields.code).trim())) return privateJsonResponse({ error: "Could not confirm that code." }, { status: 422 });
1641
+ const recoveryCodes = await enrollMfa(user, secret);
1642
+ return privateJsonResponse({ recoveryCodes });
1643
+ }))),
1644
+ },` : ""}` : "";
1598
1645
  const csrfRoute = `
1599
1646
  "/api/v1/auth/csrf": {
1600
1647
  GET: kernel.wrap("api", withErrorHandling(async (request) => {
1601
1648
  return privateJsonResponse({ token: resolveCsrfTokenForRequest(request) });
1602
1649
  })),
1603
1650
  },`;
1604
- const cookieJsonAuth = cookie && !jsonApi ? `
1651
+ const cookieJsonAuth = cookie && !bearerApi ? `
1605
1652
  "/api/v1/auth/login": {
1606
1653
  POST: kernel.wrap("api", kernel.wrapLogin(withErrorHandling(async (request) => {
1607
1654
  const { email, password, mfa_code } = await parseJsonBody(request, parseLoginCredentials);
@@ -1775,9 +1822,9 @@ async function completeBrowserSsoLogin(
1775
1822
  return login;
1776
1823
  })),
1777
1824
  },` : "";
1778
- const apiRoutes = jsonApi || cookie ? `
1825
+ const apiRoutes = bearerApi || cookie ? `
1779
1826
  routes({ kernel, dependencies }) {
1780
- return {${csrfRoute}${samlRoutes}${githubRoutes}${oidcRoutes}${cookieJsonAuth}${tokenLogin}${jsonRegister}${jwtLogin}${apiUser}${jsonPassword}${jsonVerify}
1827
+ return {${csrfRoute}${samlRoutes}${githubRoutes}${oidcRoutes}${cookieJsonAuth}${tokenLogin}${jsonRegister}${jwtLogin}${apiUser}${jsonPassword}${jsonVerify}${jsonAccountManagement}
1781
1828
  };
1782
1829
  },` : "";
1783
1830
  const mfaLoginBranch = `const mfaResult = completePasswordLogin(user, { mfaCode: mfa_code });
@@ -2006,30 +2053,7 @@ async function completeBrowserSsoLogin(
2006
2053
  otpauth: buildOtpauthUrl({ secret, account: "user", issuer: process.env.APP_NAME ?? "Strata" }),
2007
2054
  }, { request });
2008
2055
  }
2009
- const recoveryCodes = generateRecoveryCodes();
2010
- const stored = protectMfaSecret(secret);
2011
- const previous = await runAuthWrite(Number(user.id), () => User.find(Number(user.id)));
2012
- if (!previous || previous.get("auth_version") !== user.authVersion || !(previous.get("is_active") === true || previous.get("is_active") === 1)) throw new ConflictError("MFA configuration changed. Reload and confirm again.");
2013
- await runInTransaction(async () => {
2014
- await runAuthWrite(Number(user.id), async () => {
2015
- // Trusted, pre-protected security fields: atomically replace only the state we read.
2016
- const changed = await previous.getRepository().updateWhere({
2017
- mfa_secret: stored,
2018
- mfa_enabled: true,
2019
- mfa_recovery_codes: JSON.stringify(recoveryCodes.map((item) => hashRecoveryCode(item))),
2020
- }, { where: {
2021
- id: Number(user.id),
2022
- is_active: previous.get("is_active"),
2023
- auth_version: previous.get("auth_version"),
2024
- mfa_enabled: previous.get("mfa_enabled"),
2025
- mfa_secret: previous.get("mfa_secret"),
2026
- mfa_recovery_codes: previous.get("mfa_recovery_codes"),
2027
- session_valid_after: previous.get("session_valid_after"),
2028
- } });
2029
- if (changed !== 1) throw new ConflictError("MFA configuration changed. Reload and confirm again.");
2030
- });
2031
- await revokeUserSessions(Number(user.id));
2032
- });
2056
+ const recoveryCodes = await enrollMfa(user, secret);
2033
2057
  return views.render("mfa-setup.eta", {
2034
2058
  layout: { title: "MFA" },
2035
2059
  errors: {},
@@ -2045,6 +2069,37 @@ async function completeBrowserSsoLogin(
2045
2069
  return `${imports.join(`
2046
2070
  `)}
2047
2071
  ${helpers}
2072
+
2073
+ ${mfa ? `
2074
+ async function enrollMfa(user: { id: string | number; authVersion?: number }, secret: string) {
2075
+ const recoveryCodes = generateRecoveryCodes();
2076
+ const stored = protectMfaSecret(secret);
2077
+ const previous = await runAuthWrite(Number(user.id), () => User.find(Number(user.id)));
2078
+ if (!previous || previous.get("auth_version") !== user.authVersion || !(previous.get("is_active") === true || previous.get("is_active") === 1)) throw new ConflictError("MFA configuration changed. Reload and confirm again.");
2079
+ await runInTransaction(async () => {
2080
+ await runAuthWrite(Number(user.id), async () => {
2081
+ // Trusted, pre-protected security fields: atomically replace only the state we read.
2082
+ const changed = await previous.getRepository().updateWhere({
2083
+ mfa_secret: stored,
2084
+ mfa_enabled: true,
2085
+ mfa_recovery_codes: JSON.stringify(recoveryCodes.map((item) => hashRecoveryCode(item))),
2086
+ }, { where: {
2087
+ id: Number(user.id),
2088
+ is_active: previous.get("is_active"),
2089
+ auth_version: previous.get("auth_version"),
2090
+ mfa_enabled: previous.get("mfa_enabled"),
2091
+ mfa_secret: previous.get("mfa_secret"),
2092
+ mfa_recovery_codes: previous.get("mfa_recovery_codes"),
2093
+ session_valid_after: previous.get("session_valid_after"),
2094
+ } });
2095
+ if (changed !== 1) throw new ConflictError("MFA configuration changed. Reload and confirm again.");
2096
+ });
2097
+ await revokeUserSessions(Number(user.id));
2098
+ });
2099
+ return recoveryCodes;
2100
+ }
2101
+ ` : ""}
2102
+
2048
2103
  const authModule: AppModule = {
2049
2104
  name: "auth",
2050
2105
  order: 2,${apiRoutes}${cookieRoutes}
@@ -3173,9 +3228,9 @@ function renderPackageJson(projectName, options = {}) {
3173
3228
  "@getstrata/cli": "workspace:*",
3174
3229
  "@getstrata/core": "workspace:*"
3175
3230
  } : {
3176
- "@getstrata/bootstrap": "^2.2.43",
3177
- "@getstrata/cli": "^2.2.43",
3178
- "@getstrata/core": "^2.2.43"
3231
+ "@getstrata/bootstrap": "^2.2.45",
3232
+ "@getstrata/cli": "^2.2.45",
3233
+ "@getstrata/core": "^2.2.45"
3179
3234
  };
3180
3235
  coreDeps.eta = "^4.6.0";
3181
3236
  if (options.layers?.database === "mysql") {
@@ -3245,7 +3300,7 @@ function localEnvVars(services) {
3245
3300
  }
3246
3301
  return [...new Set(vars)];
3247
3302
  }
3248
- function renderSupportingToolsReadme(layers) {
3303
+ function renderSupportingToolsReadme(projectName, layers) {
3249
3304
  const needed = neededDockerServices(layers);
3250
3305
  if (needed.length === 0) {
3251
3306
  return "";
@@ -3256,14 +3311,14 @@ function renderSupportingToolsReadme(layers) {
3256
3311
  const lines = ["## Supporting tools", ""];
3257
3312
  if (dockerOn.length > 0) {
3258
3313
  const names = dockerOn.map((name) => DOCKER_SERVICE_LABELS[name]).join(", ");
3259
- lines.push(`Docker Compose includes ${names}.`, "", "```bash", "docker compose up -d", "```", "");
3314
+ lines.push(`Docker Compose includes ${names}.`, "", "```bash", dockerComposeUpCommand(layers), "```", "");
3260
3315
  if (dockerSet.has("adminer")) {
3261
3316
  const mysql = layers.database === "mysql";
3262
3317
  const system = mysql ? "MySQL" : "PostgreSQL";
3263
3318
  const server = mysql ? "mysql" : "postgres";
3264
3319
  const username = mysql ? "root" : "postgres";
3265
3320
  const password = mysql ? GENERATED_MYSQL_ROOT_PASSWORD : GENERATED_POSTGRES_SUPERUSER_PASSWORD;
3266
- lines.push(`Adminer: http://localhost:8080 (${system}, server \`${server}\`, username \`${username}\`, password \`${password}\`).`, "");
3321
+ lines.push(`Adminer: http://localhost:8080 (${system}, server \`${server}\`, username \`${username}\`, password \`${password}\`, database \`${appDatabaseName(projectName)}\`).`, "", "Adminer is optional development tooling in the `debug` profile; plain `docker compose up -d` does not start Adminer. Use the profile command above to start it with the database.", "");
3267
3322
  if (!mysql) {
3268
3323
  lines.push("Adminer uses the Compose `postgres` superuser, which skips FORCE RLS. Application traffic should use `strata_app`.", "");
3269
3324
  }
@@ -3287,8 +3342,8 @@ function renderApiDocs(projectName, layers) {
3287
3342
  if (authUsesJwt(layers.auth)) {
3288
3343
  rows.push("| `POST` | `/api/auth/token` | Mints a short-lived JWT. Not an HTML session. Requires CSRF like JSON login. |");
3289
3344
  }
3290
- if (authUsesToken(layers.auth) || authUsesJwt(layers.auth)) {
3291
- rows.push("| `POST` | `/api/v1/auth/register` | Returns neutral `{ ok: true }` (201); sign in separately. |", "| `POST` | `/api/v1/auth/forgot-password` | Sends a signed reset link through the mail driver. |", "| `POST` | `/api/v1/auth/reset-password` | Consumes the signed link. |", "| `GET` | `/api/user` | Current user for the active guard. |");
3345
+ if (authUsesToken(layers.auth) || authUsesJwt(layers.auth) || authUsesCookie(layers.auth)) {
3346
+ rows.push("| `POST` | `/api/v1/auth/register` | Returns neutral `{ ok: true }` (201); sign in separately. |", "| `POST` | `/api/v1/auth/forgot-password` | Sends a signed reset link through the mail driver. |", "| `POST` | `/api/v1/auth/reset-password` | Consumes the signed link. |", ...authUsesToken(layers.auth) || authUsesJwt(layers.auth) ? ["| `GET` | `/api/user` | Current user for the active guard. |"] : []);
3292
3347
  }
3293
3348
  if (authNeedsUsers(layers.auth)) {
3294
3349
  rows.push("| `GET` | `/api/v1/auth/csrf` | Issues the CSRF cookie and JSON token for unauthenticated writes. |");
@@ -3297,9 +3352,13 @@ function renderApiDocs(projectName, layers) {
3297
3352
  if (!authUsesToken(layers.auth))
3298
3353
  rows.push("| `POST` | `/api/v1/auth/login` | `{ email, password }` sets the session cookie and returns `{ ok: true }`. Requires CSRF. |", "| `GET` | `/api/v1/auth/me` | Current user from the session cookie. |");
3299
3354
  }
3300
- if (layers.extras.emailVerification && (authUsesToken(layers.auth) || authUsesJwt(layers.auth))) {
3355
+ if (layers.extras.emailVerification && authNeedsUsers(layers.auth)) {
3301
3356
  rows.push("| `POST` | `/api/v1/auth/verify-email` | Consumes the signed verification token; requires CSRF. |");
3302
3357
  }
3358
+ if (authUsesCookie(layers.auth) && layers.extras.emailVerification)
3359
+ rows.push("| `POST` | `/api/v1/auth/verification-notification` | Authenticated owner resend; verification is not required. Requires CSRF. |");
3360
+ if (authUsesCookie(layers.auth) && layers.extras.mfa)
3361
+ rows.push("| `POST` | `/api/v1/auth/confirm-password` | Verify the current password and set an epoch-bound confirmation cookie. Requires verified session and CSRF. |", "| `GET` | `/api/v1/auth/mfa` | Returns a fresh proposed `{ secret, otpauth }`; requires verified session. Does not enable MFA. |", "| `POST` | `/api/v1/auth/mfa` | `{ secret, code }` enables MFA and returns `{ recoveryCodes }` once. Requires verified session, password confirmation and CSRF; revokes prior credentials. Login again with `mfa_code`. |");
3303
3362
  if (layers.extras.metrics) {
3304
3363
  rows.push("| `GET` | `/metrics` | Prometheus text. Production requires `Authorization: Bearer <METRICS_TOKEN>`. |");
3305
3364
  }
@@ -3427,7 +3486,7 @@ function renderReadme(projectName, layers, options = {}) {
3427
3486
  const docker = renderDockerCompose(projectName, layers);
3428
3487
  const next = [`cd ${projectName}`, "cp .env.example .env"];
3429
3488
  if (docker) {
3430
- next.push("docker compose up -d");
3489
+ next.push(dockerComposeUpCommand(layers));
3431
3490
  }
3432
3491
  next.push("bun install");
3433
3492
  if (needsFrontendBuild(layers.frontend)) {
@@ -3470,7 +3529,7 @@ ${layers.queue === "redis" ? "Redis jobs need `bun run queue:work` in another te
3470
3529
 
3471
3530
  `}For durable events, add listeners in \`src/outbox/registry.ts\`, apply \`bun run db:migrate\`, then run \`bun run outbox:work\` in another terminal. Apps that do not publish durable events do not need this worker. Durable cache invalidation also needs the outbox worker when explicitly configured. Use the same application environment, database, Redis URL and \`APP_KEY_PREFIX\` for HTTP and its workers. An idle worker is normal; startup output confirms entry into polling, not dependency health. Stop HTTP and workers before resetting the development database.
3472
3531
 
3473
- ${renderSupportingToolsReadme(layers)}${layers.auth !== "headers" ? `
3532
+ ${renderSupportingToolsReadme(projectName, layers)}${layers.auth !== "headers" ? `
3474
3533
  For the first production admin, apply migrations and run \`bunx strata auth:provision-admin --email operator@example.test --name "Initial Operator" --password-stdin${layers.tenancy !== "none" ? " --tenant 1" : ""} < /run/secrets/initial_admin_password\` before admitting traffic. Supply your own private secret-manager-mounted file, not a demo password. Passwords require at least 16 characters and at most 72 UTF-8 bytes. Tenant-enabled applications require an existing tenant ID; this command does not create tenants. It refuses existing admins/accounts, records a transactional one-time claim, and does not mark email verified or enroll MFA. Additional admins and recovery remain explicit application administration. The command does not migrate or seed automatically.
3475
3534
 
3476
3535
  Optional development demo accounts: run \`bun run db:seed:demo\` explicitly after migrations. This command refuses production and staging. It creates these accounts with password \`StrataDemo!ChangeMe\`:
@@ -3479,7 +3538,7 @@ Optional development demo accounts: run \`bun run db:seed:demo\` explicitly afte
3479
3538
  - \`admin@example.test\` (admin)
3480
3539
  ` : `
3481
3540
  Header auth is on for local use. Send \`x-authenticated-user-id\` (and optional \`x-authenticated-user-role\`). Production must set \`AUTH_DEV_HEADERS=false\`.
3482
- `}${authUsesCookie(layers.auth) ? `
3541
+ `}${authUsesCookie(layers.auth) && (layers.frontend === "server-htmx" || layers.frontend === "hybrid") ? `
3483
3542
  HTML auth kit (restyle \`views/\` and \`public/assets/site.css\`):
3484
3543
 
3485
3544
  - Welcome: \`/\`
@@ -3489,6 +3548,10 @@ HTML auth kit (restyle \`views/\` and \`public/assets/site.css\`):
3489
3548
  - Reset password: signed \`/reset-password\` (mail log when \`MAIL_DRIVER=log\`)
3490
3549
  ${layers.extras.emailVerification ? "- Verify email: `/email/verify`\n" : ""}${layers.extras.mfa ? "- MFA challenge: `/login/mfa` and setup: `/account/mfa`\n" : ""}${layers.extras.oauthGithub ? "- GitHub: `/auth/github` (needs `FEATURE_OAUTH=true`). Failures on the callback are JSON, not the login page. State is the signed query value from `createOAuthState()`, not `createOAuthStateCookie()`.\n" : ""}${layers.extras.oidc ? "- OIDC: `/auth/oidc` (needs `FEATURE_OAUTH=true` plus `OIDC_CLIENT_ID` and `OIDC_CLIENT_SECRET`; otherwise the login link stays hidden and the route is 404). PKCE cookie `oidc_pkce`. Callback failures are JSON, not the login page.\n" : ""}
3491
3550
  Cookie name is \`strata_session\`. Forms send CSRF as \`_token\`.
3551
+ ` : ""}${authUsesCookie(layers.auth) && (layers.frontend === "api" || layers.frontend === "spa-react") ? `
3552
+ JSON cookie account flows: fetch \`GET /api/v1/auth/csrf\`, retain the cookie and send \`X-CSRF-Token\` on writes (browser clients use credentials). Register through \`POST /api/v1/auth/register\` (neutral 201), login through \`POST /api/v1/auth/login\` (session cookie), and read \`GET /api/v1/auth/me\`. Reset through \`POST /api/v1/auth/forgot-password\` then signed \`POST /api/v1/auth/reset-password\` with \`{ password }\`.
3553
+ ${layers.extras.emailVerification ? "Verify through signed `POST /api/v1/auth/verify-email`; authenticated unverified owners resend through `POST /api/v1/auth/verification-notification`.\n" : ""}${layers.extras.mfa ? "MFA setup: `GET /api/v1/auth/mfa`, confirm the current password through `POST /api/v1/auth/confirm-password`, then submit `{ secret, code }` to `POST /api/v1/auth/mfa`. Store the returned recovery codes safely; enrollment revokes credentials. Login again with `{ email, password, mfa_code }` using a TOTP or one-use recovery code. Missing code returns JSON 401 `mfa_required`.\n" : ""}
3554
+ These routes return JSON, not account pages. The client owns account forms and handling the signed mail URL: submit to its unchanged path/query, with CSRF; opening the URL with GET does not consume a token. No HTML registration/reset page or automatic login is generated for these modes. All auth JSON is private/no-store. API docs list routes; the SPA scaffold is an example client, not a complete account-management UI.
3492
3555
  ` : ""}${authUsesToken(layers.auth) ? `
3493
3556
  Opaque token login: \`POST /api/v1/auth/login\` with \`{ "email", "password" }\`. Register: \`POST /api/v1/auth/register\`. Forgot/reset: \`POST /api/v1/auth/forgot-password\` and signed \`POST /api/v1/auth/reset-password\`. Send \`Authorization: Bearer\` after login.
3494
3557
  ` : ""}${authUsesJwt(layers.auth) ? `
@@ -5956,7 +6019,7 @@ Next steps:`);
5956
6019
  console.log(` cd ${cdTarget}`);
5957
6020
  console.log(" cp .env.example .env");
5958
6021
  if (compose) {
5959
- console.log(" docker compose up -d");
6022
+ console.log(` ${dockerComposeUpCommand(layers)}`);
5960
6023
  }
5961
6024
  if (dockerOn.includes("adminer")) {
5962
6025
  console.log(" Adminer: http://localhost:8080");
@@ -12,9 +12,9 @@
12
12
  "check": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@getstrata/bootstrap": "^2.2.43",
16
- "@getstrata/cli": "^2.2.43",
17
- "@getstrata/core": "^2.2.43",
15
+ "@getstrata/bootstrap": "^2.2.45",
16
+ "@getstrata/cli": "^2.2.45",
17
+ "@getstrata/core": "^2.2.45",
18
18
  "eta": "^4.6.0"
19
19
  },
20
20
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/starter",
3
- "version": "2.2.43",
3
+ "version": "2.2.45",
4
4
  "description": "Interactive create-strata wizard. Choose each layer; one database engine.",
5
5
  "type": "module",
6
6
  "license": "MIT",