very-express 0.8.3 → 0.8.5

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.
Files changed (30) hide show
  1. package/AGENTS.md +21 -3
  2. package/dist/index.js +890 -396
  3. package/dist/templates/_middlewares/Authentication.ts +49 -32
  4. package/dist/templates/_middlewares/UserContext.ts +1 -18
  5. package/dist/templates/_projectSettings/env +14 -0
  6. package/dist/templates/_projectSettings/package.json +1 -0
  7. package/dist/templates/_routes/FirebaseAuthUI.gen.ts +20 -0
  8. package/dist/templates/_routes/LoginUI.ts +484 -4
  9. package/dist/templates/_services/MongooseRepositoryAdapter.ts +67 -5
  10. package/dist/templates/_services/TypeOrmRepositoryAdapter.ts +70 -4
  11. package/dist/templates/_services/oauth/OAuthProfileMap.ts +27 -8
  12. package/dist/templates/_services/oauth/OAuthStrategyService.ts +5 -5
  13. package/dist/templates/_types/auth.ts +27 -0
  14. package/dist/templates/_types/vex/VexRepository.ts +21 -0
  15. package/dist/templates/jsonSchema/User.json +8 -1
  16. package/dist/templates/jsonSchema/UserAuthProfiles.json +13 -5
  17. package/dist/templates/root/public/js/deleteaccount.js +80 -0
  18. package/docs/appGenerated/auth.md +83 -22
  19. package/docs/architecture/authAndRouting.md +9 -2
  20. package/docs/architecture/databaseTargets.md +1 -1
  21. package/docs/features/accountDeletion.md +149 -0
  22. package/docs/features/auditFields.md +2 -32
  23. package/docs/releaseNote/v0-8-4.md +131 -0
  24. package/docs/releaseNote/v0-8-5.md +98 -0
  25. package/docs/superpowers/specs/2026-09-22-usercontext-audit-enforcement-design.md +9 -9
  26. package/docs/vexJsonSchema.md +11 -1
  27. package/package.json +1 -1
  28. package/vex.config.json +4 -1
  29. /package/docs/{ForeignKey.md → features/ForeignKey.md} +0 -0
  30. /package/docs/{apiUsage.md → features/apiUsage.md} +0 -0
@@ -3,7 +3,7 @@ import { Repository, ObjectLiteral, FindOptionsWhere, DeepPartial, In, Not, Like
3
3
  import { VexRepository, Select, Filter, Join, FieldOperators, VexPagination, VexResErr } from "../_types/vex";
4
4
  import UserContext from "../_middlewares/UserContext.gen";
5
5
  import { entityIsolation } from "../_middlewares/DataIsolationRegistry.gen";
6
- import { entityVexFields, VexFieldEntry } from "../_middlewares/VexFieldRegistry.gen";
6
+ import { entityVexFields, entitySoftDeleteFields, showSoftDeleted, VexFieldEntry } from "../_middlewares/VexFieldRegistry.gen";
7
7
  import utils from "../_utils";
8
8
 
9
9
  /** When a framework-managed field is written. */
@@ -98,16 +98,36 @@ export class TypeOrmRepositoryAdapter<T extends ObjectLiteral> implements VexRep
98
98
  return { [config.field]: userId };
99
99
  }
100
100
 
101
+ /**
102
+ * Soft-delete term for this entity, or null when it declares no marker.
103
+ *
104
+ * `Not(true)` rather than `deleted: false`: the generated column is NOT NULL DEFAULT false, so
105
+ * the two are equivalent for rows written by this schema, and `Not(true)` stays correct for a
106
+ * row that predates the column (NULL) on a target where that can happen.
107
+ */
108
+ private getSoftDeleteFilter(): Record<string, unknown> | null {
109
+ if (showSoftDeleted) return null;
110
+
111
+ const field = entitySoftDeleteFields[this.getEntityName()];
112
+ if (!field) return null;
113
+
114
+ return { [field]: Not(true) };
115
+ }
116
+
101
117
  /** Merge caller filter with ownership filter. Ownership always wins. */
102
- private mergeFilter(callerFilter: Filter<T>): Record<string, unknown> | Array<Record<string, unknown>> {
118
+ private mergeFilter(
119
+ callerFilter: Filter<T>,
120
+ options?: { includeSoftDeleted?: boolean },
121
+ ): Record<string, unknown> | Array<Record<string, unknown>> {
103
122
  const mapped = this.mapOperators(callerFilter);
104
123
  const ownership = this.getOwnershipFilter();
124
+ const softDelete = options?.includeSoftDeleted ? null : this.getSoftDeleteFilter();
105
125
 
106
126
  if (mapped instanceof Array) {
107
- return mapped.map(branch => ({ ...branch, ...ownership }));
127
+ return mapped.map(branch => ({ ...branch, ...softDelete, ...ownership }));
108
128
  }
109
129
  else {
110
- return { ...mapped, ...ownership };
130
+ return { ...mapped, ...softDelete, ...ownership };
111
131
  }
112
132
  }
113
133
 
@@ -263,4 +283,50 @@ export class TypeOrmRepositoryAdapter<T extends ObjectLiteral> implements VexRep
263
283
  const where = this.mergeFilter(filter as unknown as Filter<T>);
264
284
  await this.repo.delete(where as FindOptionsWhere<T>);
265
285
  }
286
+
287
+ /**
288
+ * Tombstone the row: run the normal update-phase field machinery (so `updatedAt` /
289
+ * `updatedBy` record who deleted it and when), then write the marker plus any redaction
290
+ * the caller merged in.
291
+ */
292
+ async softDelete(id: string | undefined, data?: Partial<T>): Promise<T | null> {
293
+ if (!id) {
294
+ utils.log.error("TypeOrmRepositoryAdapter.softDelete called without id — refuse update entity");
295
+ return null;
296
+ }
297
+
298
+ const field = entitySoftDeleteFields[this.getEntityName()];
299
+ if (!field) {
300
+ utils.log.error(
301
+ `TypeOrmRepositoryAdapter.softDelete on ${this.getEntityName()} — entity declares no ` +
302
+ `x-vexData "softDelete" field, refuse update entity`
303
+ );
304
+ return null;
305
+ }
306
+
307
+ const enriched = { ...(data ?? {}) } as Record<string, unknown>;
308
+ this.applyVexFields(enriched as Partial<T>, "update");
309
+ enriched[field] = true;
310
+
311
+ const where = this.mergeFilter({ _id: id } as unknown as Filter<T>);
312
+ // the generic ObjectLiteral constraint makes TypeORM's own _QueryDeepPartialEntity
313
+ // unresolvable here; `update` already accepts the same shape on the ordinary path
314
+ await this.repo.update(where as FindOptionsWhere<T>, enriched as never);
315
+ return this.repo.findOne({
316
+ where: { _id: id } as unknown as T
317
+ });
318
+ }
319
+
320
+ /**
321
+ * Read a row that may be soft-deleted: skips the soft-delete term only, so the ownership
322
+ * filter still applies. Framework-internal — see VexRepository.
323
+ */
324
+ findOneWithDeleted(filter: Filter<T>, join?: Join, select?: Select): Promise<T | null> {
325
+ const where = this.mergeFilter(filter, { includeSoftDeleted: true }) as FindOptionsWhere<T>;
326
+ return this.repo.findOne({
327
+ select,
328
+ where,
329
+ relations: join
330
+ });
331
+ }
266
332
  }
@@ -1,6 +1,7 @@
1
1
  // {{headerComment}}
2
2
  import { Profile } from "passport";
3
3
  import { UserWithRelations } from "./../../_types/User.gen";
4
+ import { entitySoftDeleteFields } from "./../../_middlewares/VexFieldRegistry.gen";
4
5
 
5
6
  export interface IProfile extends Profile {
6
7
  [key: string]: any;
@@ -24,28 +25,46 @@ export default class OAuthProfileMap {
24
25
  return authProfile;
25
26
  }
26
27
 
28
+ /**
29
+ * Seed the soft-delete marker on a brand-new OAuth user.
30
+ *
31
+ * `User` is only soft-deletable in projects that tag a marker, and when they do the field is
32
+ * required — so the profile built here must carry it. Reusing the registry keeps this template
33
+ * correct for both kinds of project, including one whose marker is not named "deleted".
34
+ *
35
+ * The marker is assigned onto the finished profile rather than spread into its literal: the
36
+ * field name is only known at runtime, and a spread of a `Record<string, boolean>` widens the
37
+ * property to `boolean | undefined`, which the required `User` field rejects.
38
+ */
39
+ private applyNewUserMarker(user: UserWithRelations): UserWithRelations {
40
+ const field = entitySoftDeleteFields["UserEntity"];
41
+ if (field) (user as unknown as Record<string, unknown>)[field] = false;
42
+
43
+ return user;
44
+ }
45
+
27
46
  private GithubProfileMapping(oauthProfile: IProfile): UserWithRelations {
28
- const user: UserWithRelations = {
47
+ const user = {
29
48
  active: true,
30
49
  userAuthProfiles: [{
31
50
  provider: oauthProfile.provider,
32
- oauthId: oauthProfile.id,
51
+ providerUserId: oauthProfile.id,
33
52
  username: oauthProfile.username || oauthProfile.displayName
34
53
  }],
35
54
  name: oauthProfile.username || oauthProfile.displayName,
36
55
  email: oauthProfile._json.email || oauthProfile._json.notification_email || undefined,
37
56
  locale: undefined,
38
57
  profileErrors: ""
39
- };
58
+ } as unknown as UserWithRelations;
40
59
 
41
- return user;
60
+ return this.applyNewUserMarker(user);
42
61
  }
43
62
  private GoogleProfileMapping(oauthProfile: IProfile): UserWithRelations {
44
- const user: UserWithRelations = {
63
+ const user = {
45
64
  active: true,
46
65
  userAuthProfiles: [{
47
66
  provider: oauthProfile.provider,
48
- oauthId: oauthProfile.id,
67
+ providerUserId: oauthProfile.id,
49
68
  username: oauthProfile.username || oauthProfile.displayName
50
69
  }],
51
70
  name: oauthProfile.username || oauthProfile.displayName,
@@ -53,9 +72,9 @@ export default class OAuthProfileMap {
53
72
  email: oauthProfile._json.email || oauthProfile._json.notification_email || undefined,
54
73
  locale: oauthProfile._json.locale || undefined,
55
74
  profileErrors: ""
56
- };
75
+ } as unknown as UserWithRelations;
57
76
 
58
- return user;
77
+ return this.applyNewUserMarker(user);
59
78
  }
60
79
 
61
80
  }
@@ -26,11 +26,11 @@ export default class OAuthStrategyService {
26
26
  const authUser = new OAuthProfileMap().map(profile);
27
27
  const authProfile = authUser.userAuthProfiles?.[0];
28
28
 
29
- // find user by oauthId + provider, or fall back to email
29
+ // find user by providerUserId + provider, or fall back to email
30
30
  let existingUser: UserWithRelations | null = null;
31
- if (authProfile?.oauthId && authProfile?.provider) {
31
+ if (authProfile?.providerUserId && authProfile?.provider) {
32
32
  const matchedProfile = await this.uapRepo.findOneWhere(
33
- { oauthId: authProfile.oauthId, provider: authProfile.provider },
33
+ { providerUserId: authProfile.providerUserId, provider: authProfile.provider },
34
34
  );
35
35
  if (matchedProfile?.userId) {
36
36
  existingUser = await this.userRepo.findOne({ _id: matchedProfile.userId });
@@ -84,9 +84,9 @@ export default class OAuthStrategyService {
84
84
  throw new Error("Invalid OAuth Callback \"authProfile\"");
85
85
  }
86
86
 
87
- // check if this provider/oauthId already tracked
87
+ // check if this provider/providerUserId already tracked
88
88
  const existing = await this.uapRepo.findOneWhere(
89
- { userId: existingUser._id, provider: incomingProfile.provider, oauthId: incomingProfile.oauthId },
89
+ { userId: existingUser._id, provider: incomingProfile.provider, providerUserId: incomingProfile.providerUserId },
90
90
  );
91
91
 
92
92
  if (!existing) {
@@ -16,4 +16,31 @@ export interface registerResponse {
16
16
 
17
17
  export interface localLoginResponse {
18
18
  url: string;
19
+ }
20
+
21
+ /**
22
+ * `POST /auth/firebase` — the answer to a Firebase sign-in.
23
+ * `isNewUser` is true only when this call created the `User` row; a user linked by a verified email address is false.
24
+ */
25
+ export interface firebaseLoginResponse {
26
+ accessToken: string;
27
+ accessTokenIndex: string;
28
+ refreshToken: string;
29
+ refreshTokenIndex: string;
30
+ isNewUser: boolean;
31
+ }
32
+
33
+ /** Row counts removed alongside the tombstone, so the caller can log and retry. */
34
+ export interface deleteAccountCounts {
35
+ authProfiles: number;
36
+ userRoles: number;
37
+ sessions: number;
38
+ }
39
+
40
+ /** Result of a self-service account deletion. */
41
+ export interface deleteAccountResponse {
42
+ userId: string;
43
+ /** When the tombstone was written (the row's updatedAt). Empty on a repeat call. */
44
+ tombstonedAt: string;
45
+ deleted: deleteAccountCounts;
19
46
  }
@@ -20,5 +20,26 @@ export interface VexRepository<T, U=undefined> {
20
20
  update(id: string | undefined, data: Partial<T>): Promise<T | null>;
21
21
  delete(id: string | undefined): Promise<void>;
22
22
  deleteWhere(filter: Filter<T>): Promise<void>;
23
+
24
+ /**
25
+ * Mark an entity soft-deleted, optionally merging app-level redaction into the same write.
26
+ *
27
+ * Runs the normal update-phase machinery, so `updatedAt` / `updatedBy` record who tombstoned
28
+ * the row and when. No-op returning null when the entity declares no marker.
29
+ *
30
+ * Only for framework-internal callers: the marker is deliberately not part of `Filter`, and
31
+ * it is stripped from every generated request body, so no client can reach this through the API.
32
+ */
33
+ softDelete(id: string | undefined, data?: Partial<T>): Promise<[U] extends [undefined] ? T | null : U | null>;
34
+
35
+ /**
36
+ * Read a row that may be soft-deleted.
37
+ *
38
+ * Skips ONLY the adapter's soft-delete term — the ownership filter still applies, so this is
39
+ * not a way around `dataIsolation`. Exists for internal state checks (account-deletion
40
+ * idempotency, the account-state guard); a `Filter`-level escape hatch would have been part of
41
+ * every HTTP filter body, which is exactly what must not be possible.
42
+ */
43
+ findOneWithDeleted(filter: Filter<T>, join?: Join, select?: Select): Promise<[U] extends [undefined] ? T | null : U | null>;
23
44
  }
24
45
 
@@ -65,10 +65,17 @@
65
65
  "type": "string",
66
66
  "x-format": "UUID",
67
67
  "default": "onUpdateUserId"
68
+ },
69
+ "deleted": {
70
+ "type": "boolean",
71
+ "default": false,
72
+ "x-vexData": "softDelete",
73
+ "description": "Soft-delete marker. Framework-managed; never client-writable. Hides the row from every ordinary query unless app.showSoftDeleted is on."
68
74
  }
69
75
  },
70
76
  "required": [
71
77
  "name",
72
- "active"
78
+ "active",
79
+ "deleted"
73
80
  ]
74
81
  }
@@ -5,7 +5,13 @@
5
5
  "methods": [],
6
6
  "joinWhitelist": []
7
7
  },
8
- "documentName": "UserAuthProfiles"
8
+ "documentName": "UserAuthProfiles",
9
+ "uniqueIndex": [
10
+ [
11
+ "provider",
12
+ "providerUserId"
13
+ ]
14
+ ]
9
15
  },
10
16
  "properties": {
11
17
  "_id": {
@@ -25,11 +31,13 @@
25
31
  },
26
32
  "provider": {
27
33
  "type": "string",
28
- "index": true
34
+ "index": true,
35
+ "description": "Namespace label of the identity source: an upstream IdP (\"google\"), a broker (\"firebase\"), or vex's own password path (\"local\"). The value \"local\" is reserved."
29
36
  },
30
- "oauthId": {
37
+ "providerUserId": {
31
38
  "type": "string",
32
- "index": true
39
+ "index": true,
40
+ "description": "External subject within `provider`'s namespace. With `provider` it forms the account-linking key and the composite unique index. NULL for provider=\"local\". This is the subject (an OIDC `sub` or a broker user id), never a token."
33
41
  },
34
42
  "email": {
35
43
  "type": "string"
@@ -42,4 +50,4 @@
42
50
  "x-hidden": true
43
51
  }
44
52
  }
45
- }
53
+ }
@@ -0,0 +1,80 @@
1
+ // Self-service account deletion page.
2
+ //
3
+ // Sends the access token the same way the rest of the app does — Authorization + X-Auth-Index —
4
+ // and clears the stored tokens on success, because the account is gone the moment the tombstone
5
+ // is written: keeping a token the server will now reject only produces confusing 401s.
6
+
7
+ // The page loads this script from <head>, so it must wait for the DOM: at parse time the
8
+ // button does not exist yet and getElementById would return null.
9
+ document.addEventListener("DOMContentLoaded", function () {
10
+ var button = document.getElementById("deleteAccountBtn");
11
+ var input = document.getElementById("confirmInput");
12
+ var result = document.getElementById("deleteResult");
13
+
14
+ if (!button || !input || !result) return;
15
+
16
+ function clearTokens() {
17
+ localStorage.removeItem("accessToken");
18
+ localStorage.removeItem("accessTokenIndex");
19
+ localStorage.removeItem("refreshToken");
20
+ localStorage.removeItem("refreshTokenIndex");
21
+ }
22
+
23
+ function render(data) {
24
+ result.textContent = JSON.stringify(data, null, 2);
25
+ }
26
+
27
+ button.addEventListener("click", function () {
28
+ if (input.value !== "DELETE") {
29
+ render({ error: 'Type DELETE in the box to confirm.' });
30
+ return;
31
+ }
32
+
33
+ button.disabled = true;
34
+ render({ status: "Deleting…" });
35
+
36
+ fetch("/api/auth/delete-account", {
37
+ method: "POST",
38
+ credentials: "include",
39
+ headers: {
40
+ "Content-Type": "application/json",
41
+ "Authorization": "Bearer " + (localStorage.getItem("accessToken") || ""),
42
+ "X-Auth-Index": localStorage.getItem("accessTokenIndex") || "",
43
+ },
44
+ })
45
+ .then(function (response) {
46
+ // read as text first: an error response may not be JSON (a proxy or the
47
+ // express error handler can return HTML), and response.json() would then
48
+ // reject and hide the real status behind a parse error
49
+ return response.text().then(function (text) {
50
+ var body;
51
+ try {
52
+ body = text ? JSON.parse(text) : {};
53
+ }
54
+ catch (e) {
55
+ body = { raw: text };
56
+ }
57
+
58
+ return { ok: response.ok, status: response.status, body: body };
59
+ });
60
+ })
61
+ .then(function (outcome) {
62
+ if (!outcome.ok) {
63
+ render({ status: outcome.status, error: outcome.body });
64
+ button.disabled = false;
65
+ return;
66
+ }
67
+
68
+ clearTokens();
69
+ render({
70
+ status: "Account deleted. You have been signed out.",
71
+ result: outcome.body,
72
+ });
73
+ input.value = "";
74
+ })
75
+ .catch(function (err) {
76
+ render({ error: String(err) });
77
+ button.disabled = false;
78
+ });
79
+ });
80
+ });
@@ -1,23 +1,84 @@
1
1
  # Auth
2
- - Stateless JWT token
3
- - **Rolling Keys**
4
- define in `.env`,
5
- named `JWT_KEY{increment}`
6
- ```bash
7
- JWT_KEY1=aaaaa
8
- JWT_KEY2=bbbbb
9
- JWT_KEY3=ccccc
10
- ```
11
- - **OAuth2**
12
- Supported Providers:
13
- - Google
14
- - Github
15
-
16
- define in `.env`,
17
- named `OAUTH_{provider}_CLIENTID` & `OAUTH_{provider}_CLIENTSECRET`
18
- ```bash
19
- OAUTH_GOOGLE_CLIENTID=xxxxx
20
- OAUTH_GOOGLE_CLIENTSECRET=xxxxx
21
- ```
22
- - Stated
23
- - not yet implement
2
+
3
+ Stateless JWT tokens, plus three independent sign-in paths: local (email + password), OAuth2
4
+ (passport), and Firebase.
5
+
6
+ ## Tokens
7
+
8
+ Rolling keys are defined in `.env` as `JWT_KEY{increment}`:
9
+
10
+ ```bash
11
+ JWT_KEY1=aaaaa
12
+ JWT_KEY2=bbbbb
13
+ JWT_KEY3=ccccc
14
+ ```
15
+
16
+ A client sends the access token as `Authorization: Bearer <accessToken>` with
17
+ `X-Auth-Index: <accessTokenIndex>`, and refreshes at `POST /api/auth/refresh`.
18
+
19
+ ## Sign-in paths
20
+
21
+ | Path | Endpoint | Enabled by |
22
+ |---|---|---|
23
+ | Local (email + password) | `POST /api/auth/local`, `POST /api/auth/register` | `auth.localAuth` |
24
+ | OAuth2 | `GET /api/auth/<provider>` → `GET /api/auth/<provider>/callback` | `auth.oauthProviders` |
25
+ | Firebase | `POST /api/auth/firebase` | `auth.firebase` |
26
+
27
+ Local and OAuth2 answer `302` with a single-use `sessionCode`, which the client exchanges at
28
+ `POST /api/auth/token` for the token pair. Firebase answers `200` with the token pair directly.
29
+
30
+ OAuth2 credentials come from `.env`:
31
+
32
+ ```bash
33
+ OAUTH_GOOGLE_CLIENTID=xxxxx
34
+ OAUTH_GOOGLE_CLIENTSECRET=xxxxx
35
+ ```
36
+
37
+ `/login` renders a form or a button for whichever paths are enabled.
38
+
39
+ ## The identity row
40
+
41
+ A sign-in writes one `UserAuthProfiles` row, keyed by `(provider, providerUserId)` — a composite unique
42
+ index. `provider` is the namespace, `providerUserId` the subject inside it:
43
+
44
+ | Sign-in | `provider` | `providerUserId` |
45
+ |---|---|---|
46
+ | Local | `local` | — |
47
+ | passport Google | `google` | Google `sub` (`profile.id`) |
48
+ | Firebase + Google | `google` | Google `sub` |
49
+ | Firebase email/password, phone | — | `400`, no row |
50
+
51
+ A user reaching the API through Firebase and through passport Google resolves to the same `User` row.
52
+ `provider: "local"` is reserved: `verifyPassword` looks rows up by it.
53
+
54
+ ## Firebase
55
+
56
+ ```jsonc
57
+ "auth": { "firebase": true }
58
+ ```
59
+
60
+ ```bash
61
+ FIREBASE_SERVICE_ACCOUNT_JSON= # the service account JSON
62
+ FIREBASE_WEB_API_KEY= # public browser config, served to /login
63
+ FIREBASE_WEB_AUTH_DOMAIN=
64
+ FIREBASE_WEB_PROJECT_ID=
65
+ # FIREBASE_PROVIDERS=google # which buttons /login renders; default google
66
+ ```
67
+
68
+ The server verifies the ID token with `firebase-admin` against the project named by the service
69
+ account. With no usable credential the endpoint answers `503` and the app still starts.
70
+
71
+ `/login` loads the modular SDK (`firebase-app.js` / `firebase-auth.js`, ES modules from gstatic, pinned
72
+ version), preloads it on page load, and calls `signInWithPopup(getAuth(app), provider)` followed by
73
+ `user.getIdToken()`. The page sets its own CSP (script/connect/frame hosts) and its own
74
+ `Cross-Origin-Opener-Policy: same-origin-allow-popups`.
75
+
76
+ `firebase.sign_in_provider` selects the provider and `firebase.identities[<provider>][0]` supplies the
77
+ subject. A token whose provider has no entry in that map, or whose subject is missing, is answered with
78
+ `400`.
79
+
80
+ Failure modes on the page, expanded from the SDK's codes into a message on screen and in the server
81
+ log: `auth/popup-blocked`, `auth/popup-closed-by-user` (the popup closed before the handshake finished),
82
+ `auth/unauthorized-domain`, `auth/operation-not-allowed`, `auth/internal-error`.
83
+
84
+ Design record: [`docs/plan/spec-firebase-auth.md`](../plan/spec-firebase-auth.md).
@@ -65,10 +65,11 @@ Conditional emission:
65
65
 
66
66
  ```jsonc
67
67
  {
68
- "app": { "enableSwagger": true },
68
+ "app": { "enableSwagger": true, "showSoftDeleted": false },
69
69
  "auth": {
70
70
  "localAuth": true,
71
71
  "useHttpOnlyCookieToken": true,
72
+ "deleteAccount": true,
72
73
  "oauthProviders": { "google": false, "github": false }
73
74
  },
74
75
  "useRBAC": { "roles": ["visitor", "member", "admin"], "default": "admin" }
@@ -84,12 +85,18 @@ least one role (`utils.generator.isRbacEnabled`). Omitting the key, or passing
84
85
  When RBAC is on, `src/templates/jsonSchemaRBAC/` is copied over the sample schemas and
85
86
  `UserRole.role`'s enum is synced from `useRBAC.roles`.
86
87
 
88
+ Account deletion is the opposite — **opt-out**. `auth.deleteAccount` defaults to true, so
89
+ `AuthController` gains `POST /api/auth/delete-account` and the UI gains `/delete_account` unless the
90
+ project explicitly disables it (auth must also be enabled). `app.showSoftDeleted` controls whether
91
+ the repository hides soft-deleted rows; unset means hidden. See
92
+ [`docs/features/accountDeletion.md`](../features/accountDeletion.md).
93
+
87
94
  ## Auth internals
88
95
 
89
96
  JWT rolling keys and OAuth2 provider setup are documented in [`docs/appGenerated/auth.md`](../appGenerated/auth.md).
90
97
 
91
98
  ## Client-facing API behaviour
92
99
 
93
- Pagination, search and the response envelope: [`docs/apiUsage.md`](../apiUsage.md).
100
+ Pagination, search and the response envelope: [`docs/features/apiUsage.md`](../features/apiUsage.md).
94
101
 
95
102
  Filter DSL for `find` / `count`: [`docs/features/filterOperators.md`](../features/filterOperators.md).
@@ -91,7 +91,7 @@ Guide: [`docs/features/auditFields.md`](../features/auditFields.md).
91
91
 
92
92
  `src/generators/middlewares/joinWhitelistRegistry.generator.ts` emits a static entity → allowed-joins map consumed by `JoinWhitelistMiddleware.ts`. Populated from `x-documentConfig.restApi.joinWhitelist`; auto-filled by `jsonSchemaForeignKeys.ts` when unset. Controllers with a whitelist get `@Middlewares(JoinWhitelistMiddleware.middleware("<DocName>"))`.
93
93
 
94
- See [`docs/features/joinWhitelist.md`](../features/joinWhitelist.md) and [`docs/ForeignKey.md`](../ForeignKey.md).
94
+ See [`docs/features/joinWhitelist.md`](../features/joinWhitelist.md) and [`docs/features/ForeignKey.md`](../features/ForeignKey.md).
95
95
 
96
96
  ## RBAC
97
97