create-strata 2.2.29 → 2.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1242,6 +1242,9 @@ function renderAuthModule(layers) {
1242
1242
  imports.push(`import { appUrl } from "@getstrata/core/runtime/appKeyPrefix";`);
1243
1243
  }
1244
1244
  }
1245
+ if (mfa) {
1246
+ imports.push(`import { ConflictError } from "@getstrata/core/errors/http";`);
1247
+ }
1245
1248
  if (jsonApi) {
1246
1249
  imports.push(`import { AuthManager } from "@getstrata/core/auth/guard";`);
1247
1250
  }
@@ -2019,15 +2022,26 @@ async function completeBrowserSsoLogin(
2019
2022
  }
2020
2023
  const recoveryCodes = generateRecoveryCodes();
2021
2024
  const stored = protectMfaSecret(secret);
2022
- await runAuthWrite(Number(user.id), async () => {
2023
- const record = await User.find(Number(user.id));
2024
- await record?.update({
2025
- mfa_secret: stored,
2026
- mfa_enabled: true,
2027
- mfa_recovery_codes: JSON.stringify(recoveryCodes.map((item) => hashRecoveryCode(item))),
2025
+ const previous = await runAuthWrite(Number(user.id), () => User.find(Number(user.id)));
2026
+ if (!previous) throw new ConflictError("MFA configuration changed. Reload and confirm again.");
2027
+ await runInTransaction(async () => {
2028
+ await runAuthWrite(Number(user.id), async () => {
2029
+ // Trusted, pre-protected security fields: atomically replace only the state we read.
2030
+ const changed = await previous.getRepository().updateWhere({
2031
+ mfa_secret: stored,
2032
+ mfa_enabled: true,
2033
+ mfa_recovery_codes: JSON.stringify(recoveryCodes.map((item) => hashRecoveryCode(item))),
2034
+ }, { where: {
2035
+ id: Number(user.id),
2036
+ mfa_enabled: previous.get("mfa_enabled"),
2037
+ mfa_secret: previous.get("mfa_secret"),
2038
+ mfa_recovery_codes: previous.get("mfa_recovery_codes"),
2039
+ session_valid_after: previous.get("session_valid_after"),
2040
+ } });
2041
+ if (changed !== 1) throw new ConflictError("MFA configuration changed. Reload and confirm again.");
2028
2042
  });
2043
+ await revokeUserSessions(Number(user.id));
2029
2044
  });
2030
- await revokeUserSessions(Number(user.id));
2031
2045
  return views.render("mfa-setup.eta", {
2032
2046
  layout: { title: "MFA" },
2033
2047
  errors: {},
@@ -3144,9 +3158,9 @@ function renderPackageJson(projectName, options = {}) {
3144
3158
  "@getstrata/cli": "workspace:*",
3145
3159
  "@getstrata/core": "workspace:*"
3146
3160
  } : {
3147
- "@getstrata/bootstrap": "^2.2.29",
3148
- "@getstrata/cli": "^2.2.29",
3149
- "@getstrata/core": "^2.2.29"
3161
+ "@getstrata/bootstrap": "^2.2.31",
3162
+ "@getstrata/cli": "^2.2.31",
3163
+ "@getstrata/core": "^2.2.31"
3150
3164
  };
3151
3165
  coreDeps.eta = "^4.6.0";
3152
3166
  if (options.layers?.database === "mysql") {
@@ -12,9 +12,9 @@
12
12
  "check": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@getstrata/bootstrap": "^2.2.29",
16
- "@getstrata/cli": "^2.2.29",
17
- "@getstrata/core": "^2.2.29",
15
+ "@getstrata/bootstrap": "^2.2.31",
16
+ "@getstrata/cli": "^2.2.31",
17
+ "@getstrata/core": "^2.2.31",
18
18
  "eta": "^4.6.0"
19
19
  },
20
20
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-strata",
3
- "version": "2.2.29",
3
+ "version": "2.2.31",
4
4
  "description": "Create a new Strata app. Interactive wizard; choose each layer; one database engine.",
5
5
  "type": "module",
6
6
  "license": "MIT",