@simple-auth-kit/cli 1.5.1 → 1.6.1

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 (182) hide show
  1. package/package.json +1 -1
  2. package/registry/combos/express-drizzle/shared/src/{ability.ts → ability/ability.ts} +8 -2
  3. package/registry/combos/express-drizzle/shared/src/{permission-cache.ts → cache/permission-cache.ts} +25 -9
  4. package/registry/combos/express-drizzle/shared/src/{rate-limit.store.ts → cache/rate-limit.store.ts} +4 -1
  5. package/registry/combos/{express-prisma/shared/src → express-drizzle/shared/src/config}/auth.config.ts +1 -1
  6. package/registry/combos/express-drizzle/shared/src/{db.ts → config/db.ts} +1 -1
  7. package/registry/combos/express-drizzle/shared/src/{key-provider.ts → config/key-provider.ts} +6 -2
  8. package/registry/combos/express-drizzle/shared/src/{id.helper.ts → helpers/id.helper.ts} +6 -2
  9. package/registry/combos/{nestjs-drizzle/shared/src → express-drizzle/shared/src/helpers}/pagination.ts +17 -3
  10. package/registry/combos/express-drizzle/shared/src/middleware/auth-core-error.middleware.ts +6 -8
  11. package/registry/combos/express-drizzle/shared/src/middleware/auth.middleware.ts +6 -8
  12. package/registry/combos/{express-prisma/shared/src → express-drizzle/shared/src/openapi}/openapi-fragment.ts +13 -4
  13. package/registry/combos/express-drizzle/shared/src/{openapi-spec.ts → openapi/openapi-spec.ts} +251 -52
  14. package/registry/combos/express-drizzle/shared/src/repositories/oauth.repository.ts +2 -2
  15. package/registry/combos/express-drizzle/shared/src/repositories/password-reset.repository.ts +2 -4
  16. package/registry/combos/express-drizzle/shared/src/repositories/session.repository.ts +3 -3
  17. package/registry/combos/express-drizzle/shared/src/request-context.ts +1 -1
  18. package/registry/combos/express-drizzle/shared/src/route-tiers.ts +52 -11
  19. package/registry/combos/express-drizzle/shared/src/routers/auth.router.ts +2 -2
  20. package/registry/combos/express-drizzle/test/bootstrap.ts +4 -2
  21. package/registry/combos/express-drizzle/test/prove-cycle.ts +1095 -308
  22. package/registry/combos/express-drizzle/variants/base/src/create-auth-app.ts +5 -5
  23. package/registry/combos/express-drizzle/variants/base/src/index.ts +8 -0
  24. package/registry/combos/express-drizzle/variants/base/src/middleware/authz.middleware.ts +2 -2
  25. package/registry/combos/express-drizzle/variants/base/src/openapi/openapi-admin.ts +1082 -0
  26. package/registry/combos/express-drizzle/variants/base/src/rbac.defaults.ts +60 -17
  27. package/registry/combos/express-drizzle/variants/base/src/repositories/audit-log.repository.ts +2 -2
  28. package/registry/combos/express-drizzle/variants/base/src/repositories/rbac.repository.ts +5 -5
  29. package/registry/combos/express-drizzle/variants/base/src/routers/admin.router.ts +18 -22
  30. package/registry/combos/express-drizzle/variants/base/src/seed.ts +76 -17
  31. package/registry/combos/express-drizzle/variants/base/src/services/auth.service.ts +7 -9
  32. package/registry/combos/express-drizzle/variants/base/test/variant-hooks.ts +167 -45
  33. package/registry/combos/express-drizzle/variants/workspaces/src/create-auth-app.ts +5 -5
  34. package/registry/combos/express-drizzle/variants/workspaces/src/index.ts +8 -0
  35. package/registry/combos/express-drizzle/variants/workspaces/src/middleware/authz.middleware.ts +3 -3
  36. package/registry/combos/express-drizzle/variants/workspaces/src/openapi/openapi-admin.ts +1176 -0
  37. package/registry/combos/express-drizzle/variants/workspaces/src/openapi-workspace.ts +1 -1
  38. package/registry/combos/express-drizzle/variants/workspaces/src/rbac.defaults.ts +66 -19
  39. package/registry/combos/express-drizzle/variants/workspaces/src/repositories/audit-log.repository.ts +2 -2
  40. package/registry/combos/express-drizzle/variants/workspaces/src/repositories/rbac.repository.ts +5 -5
  41. package/registry/combos/express-drizzle/variants/workspaces/src/repositories/workspace.repository.ts +9 -11
  42. package/registry/combos/express-drizzle/variants/workspaces/src/routers/admin.router.ts +18 -22
  43. package/registry/combos/express-drizzle/variants/workspaces/src/routers/workspace.router.ts +1 -1
  44. package/registry/combos/express-drizzle/variants/workspaces/src/seed.ts +168 -35
  45. package/registry/combos/express-drizzle/variants/workspaces/src/services/auth.service.ts +7 -9
  46. package/registry/combos/express-drizzle/variants/workspaces/test/variant-hooks.ts +539 -133
  47. package/registry/combos/express-prisma/shared/src/{ability.ts → ability/ability.ts} +8 -2
  48. package/registry/combos/express-prisma/shared/src/{permission-cache.ts → cache/permission-cache.ts} +25 -9
  49. package/registry/combos/express-prisma/shared/src/{rate-limit.store.ts → cache/rate-limit.store.ts} +4 -1
  50. package/registry/combos/{express-drizzle/shared/src → express-prisma/shared/src/config}/auth.config.ts +1 -1
  51. package/registry/combos/express-prisma/shared/src/{key-provider.ts → config/key-provider.ts} +6 -2
  52. package/registry/combos/{nestjs-prisma/shared/src → express-prisma/shared/src/helpers}/id.helper.ts +6 -2
  53. package/registry/combos/{express-drizzle/shared/src → express-prisma/shared/src/helpers}/pagination.ts +17 -3
  54. package/registry/combos/express-prisma/shared/src/middleware/auth-core-error.middleware.ts +6 -8
  55. package/registry/combos/express-prisma/shared/src/middleware/auth.middleware.ts +6 -8
  56. package/registry/combos/{express-drizzle/shared/src → express-prisma/shared/src/openapi}/openapi-fragment.ts +13 -4
  57. package/registry/combos/express-prisma/shared/src/{openapi-spec.ts → openapi/openapi-spec.ts} +313 -55
  58. package/registry/combos/express-prisma/shared/src/repositories/oauth.repository.ts +2 -2
  59. package/registry/combos/express-prisma/shared/src/repositories/password-reset.repository.ts +2 -4
  60. package/registry/combos/express-prisma/shared/src/repositories/session.repository.ts +2 -2
  61. package/registry/combos/express-prisma/shared/src/request-context.ts +1 -1
  62. package/registry/combos/express-prisma/shared/src/route-tiers.ts +52 -11
  63. package/registry/combos/express-prisma/shared/src/routers/auth.router.ts +2 -2
  64. package/registry/combos/express-prisma/test/bootstrap.ts +7 -3
  65. package/registry/combos/express-prisma/test/prove-cycle.ts +1095 -308
  66. package/registry/combos/express-prisma/variants/base/src/create-auth-app.ts +6 -6
  67. package/registry/combos/express-prisma/variants/base/src/index.ts +8 -0
  68. package/registry/combos/express-prisma/variants/base/src/middleware/authz.middleware.ts +2 -2
  69. package/registry/combos/express-prisma/variants/base/src/openapi/openapi-admin.ts +1102 -0
  70. package/registry/combos/express-prisma/variants/base/src/rbac.defaults.ts +1 -1
  71. package/registry/combos/express-prisma/variants/base/src/repositories/audit-log.repository.ts +2 -2
  72. package/registry/combos/express-prisma/variants/base/src/repositories/rbac.repository.ts +4 -4
  73. package/registry/combos/express-prisma/variants/base/src/routers/admin.router.ts +18 -22
  74. package/registry/combos/express-prisma/variants/base/src/seed.ts +1 -1
  75. package/registry/combos/express-prisma/variants/base/src/services/auth.service.ts +6 -8
  76. package/registry/combos/express-prisma/variants/base/test/variant-hooks.ts +176 -47
  77. package/registry/combos/express-prisma/variants/workspaces/src/create-auth-app.ts +6 -6
  78. package/registry/combos/express-prisma/variants/workspaces/src/index.ts +8 -0
  79. package/registry/combos/express-prisma/variants/workspaces/src/middleware/authz.middleware.ts +3 -3
  80. package/registry/combos/express-prisma/variants/workspaces/src/openapi/openapi-admin.ts +1218 -0
  81. package/registry/combos/express-prisma/variants/workspaces/src/openapi-workspace.ts +1 -1
  82. package/registry/combos/express-prisma/variants/workspaces/src/rbac.defaults.ts +1 -1
  83. package/registry/combos/express-prisma/variants/workspaces/src/repositories/audit-log.repository.ts +2 -2
  84. package/registry/combos/express-prisma/variants/workspaces/src/repositories/rbac.repository.ts +4 -4
  85. package/registry/combos/express-prisma/variants/workspaces/src/repositories/workspace.repository.ts +2 -2
  86. package/registry/combos/express-prisma/variants/workspaces/src/routers/admin.router.ts +18 -22
  87. package/registry/combos/express-prisma/variants/workspaces/src/routers/workspace.router.ts +1 -1
  88. package/registry/combos/express-prisma/variants/workspaces/src/seed.ts +1 -1
  89. package/registry/combos/express-prisma/variants/workspaces/src/services/auth.service.ts +6 -8
  90. package/registry/combos/express-prisma/variants/workspaces/test/variant-hooks.ts +538 -134
  91. package/registry/combos/nestjs-drizzle/shared/src/{guards → ability}/ability.guard.ts +1 -1
  92. package/registry/combos/nestjs-drizzle/shared/src/{ability.ts → ability/ability.ts} +8 -2
  93. package/registry/combos/nestjs-drizzle/shared/src/{permission-cache.ts → cache/permission-cache.ts} +27 -10
  94. package/registry/combos/{nestjs-prisma/shared/src → nestjs-drizzle/shared/src/cache}/rate-limit.store.ts +4 -1
  95. package/registry/combos/nestjs-drizzle/shared/src/{auth.config.ts → config/auth.config.ts} +1 -1
  96. package/registry/combos/nestjs-drizzle/shared/src/{db.ts → config/db.ts} +1 -1
  97. package/registry/combos/nestjs-drizzle/shared/src/{key-provider.ts → config/key-provider.ts} +6 -2
  98. package/registry/combos/nestjs-drizzle/shared/src/controllers/auth.controller.ts +1 -1
  99. package/registry/combos/nestjs-drizzle/shared/src/guards/auth.guard.ts +1 -1
  100. package/registry/combos/nestjs-drizzle/shared/src/{id.helper.ts → helpers/id.helper.ts} +6 -2
  101. package/registry/combos/{express-prisma/shared/src → nestjs-drizzle/shared/src/helpers}/pagination.ts +17 -3
  102. package/registry/combos/nestjs-drizzle/shared/src/repositories/oauth.repository.ts +2 -2
  103. package/registry/combos/nestjs-drizzle/shared/src/repositories/password-reset.repository.ts +8 -12
  104. package/registry/combos/nestjs-drizzle/shared/src/repositories/session.repository.ts +3 -3
  105. package/registry/combos/nestjs-drizzle/shared/src/repositories/two-factor.repository.ts +1 -1
  106. package/registry/combos/nestjs-drizzle/shared/src/request-context.ts +1 -1
  107. package/registry/combos/nestjs-drizzle/test/bootstrap.ts +1 -1
  108. package/registry/combos/nestjs-drizzle/test/prove-cycle.ts +1 -1
  109. package/registry/combos/nestjs-drizzle/variants/base/src/auth.module.ts +10 -6
  110. package/registry/combos/nestjs-drizzle/variants/base/src/controllers/admin.controller.ts +1 -1
  111. package/registry/combos/nestjs-drizzle/variants/base/src/guards/authz.guard.ts +2 -2
  112. package/registry/combos/nestjs-drizzle/variants/base/src/index.ts +9 -0
  113. package/registry/combos/nestjs-drizzle/variants/base/src/rbac.defaults.ts +58 -16
  114. package/registry/combos/nestjs-drizzle/variants/base/src/repositories/audit-log.repository.ts +3 -3
  115. package/registry/combos/nestjs-drizzle/variants/base/src/repositories/rbac.repository.ts +4 -4
  116. package/registry/combos/nestjs-drizzle/variants/base/src/seed.ts +76 -17
  117. package/registry/combos/nestjs-drizzle/variants/base/src/services/auth.service.ts +7 -9
  118. package/registry/combos/nestjs-drizzle/variants/base/test/variant-hooks.ts +167 -45
  119. package/registry/combos/nestjs-drizzle/variants/workspaces/src/auth.module.ts +10 -6
  120. package/registry/combos/nestjs-drizzle/variants/workspaces/src/controllers/admin.controller.ts +1 -1
  121. package/registry/combos/nestjs-drizzle/variants/workspaces/src/controllers/workspace.controller.ts +1 -1
  122. package/registry/combos/nestjs-drizzle/variants/workspaces/src/guards/authz.guard.ts +2 -2
  123. package/registry/combos/nestjs-drizzle/variants/workspaces/src/index.ts +9 -0
  124. package/registry/combos/nestjs-drizzle/variants/workspaces/src/rbac.defaults.ts +64 -18
  125. package/registry/combos/nestjs-drizzle/variants/workspaces/src/repositories/audit-log.repository.ts +3 -3
  126. package/registry/combos/nestjs-drizzle/variants/workspaces/src/repositories/rbac.repository.ts +4 -4
  127. package/registry/combos/nestjs-drizzle/variants/workspaces/src/repositories/workspace.repository.ts +8 -10
  128. package/registry/combos/nestjs-drizzle/variants/workspaces/src/seed.ts +171 -36
  129. package/registry/combos/nestjs-drizzle/variants/workspaces/src/services/auth.service.ts +7 -9
  130. package/registry/combos/nestjs-drizzle/variants/workspaces/test/variant-hooks.ts +539 -133
  131. package/registry/combos/nestjs-prisma/shared/src/{guards → ability}/ability.guard.ts +1 -1
  132. package/registry/combos/nestjs-prisma/shared/src/{ability.ts → ability/ability.ts} +8 -2
  133. package/registry/combos/nestjs-prisma/shared/src/{permission-cache.ts → cache/permission-cache.ts} +27 -10
  134. package/registry/combos/{nestjs-drizzle/shared/src → nestjs-prisma/shared/src/cache}/rate-limit.store.ts +4 -1
  135. package/registry/combos/nestjs-prisma/shared/src/{auth.config.ts → config/auth.config.ts} +1 -1
  136. package/registry/combos/nestjs-prisma/shared/src/{key-provider.ts → config/key-provider.ts} +6 -2
  137. package/registry/combos/nestjs-prisma/shared/src/controllers/auth.controller.ts +1 -1
  138. package/registry/combos/nestjs-prisma/shared/src/guards/auth.guard.ts +1 -1
  139. package/registry/combos/{express-prisma/shared/src → nestjs-prisma/shared/src/helpers}/id.helper.ts +6 -2
  140. package/registry/combos/nestjs-prisma/shared/src/{pagination.ts → helpers/pagination.ts} +17 -3
  141. package/registry/combos/nestjs-prisma/shared/src/repositories/oauth.repository.ts +1 -1
  142. package/registry/combos/nestjs-prisma/shared/src/repositories/password-reset.repository.ts +2 -4
  143. package/registry/combos/nestjs-prisma/shared/src/repositories/session.repository.ts +2 -2
  144. package/registry/combos/nestjs-prisma/shared/src/request-context.ts +1 -1
  145. package/registry/combos/nestjs-prisma/test/bootstrap.ts +1 -1
  146. package/registry/combos/nestjs-prisma/test/prove-cycle.ts +1 -1
  147. package/registry/combos/nestjs-prisma/variants/base/src/auth.module.ts +10 -6
  148. package/registry/combos/nestjs-prisma/variants/base/src/controllers/admin.controller.ts +1 -1
  149. package/registry/combos/nestjs-prisma/variants/base/src/gateways/audit-log.gateway.ts +1 -1
  150. package/registry/combos/nestjs-prisma/variants/base/src/guards/authz.guard.ts +2 -2
  151. package/registry/combos/nestjs-prisma/variants/base/src/index.ts +9 -0
  152. package/registry/combos/nestjs-prisma/variants/base/src/{docs.ts → openapi/docs.ts} +23 -6
  153. package/registry/combos/nestjs-prisma/variants/base/src/rbac.defaults.ts +1 -1
  154. package/registry/combos/nestjs-prisma/variants/base/src/repositories/audit-log.repository.ts +2 -2
  155. package/registry/combos/nestjs-prisma/variants/base/src/repositories/country.repository.ts +2 -2
  156. package/registry/combos/nestjs-prisma/variants/base/src/repositories/customer.repository.ts +6 -5
  157. package/registry/combos/nestjs-prisma/variants/base/src/repositories/language.repository.ts +2 -2
  158. package/registry/combos/nestjs-prisma/variants/base/src/repositories/rbac.repository.ts +3 -3
  159. package/registry/combos/nestjs-prisma/variants/base/src/seed.ts +1 -1
  160. package/registry/combos/nestjs-prisma/variants/base/src/services/auth.service.ts +6 -8
  161. package/registry/combos/nestjs-prisma/variants/base/test/variant-hooks.ts +176 -47
  162. package/registry/combos/nestjs-prisma/variants/workspaces/src/auth.module.ts +10 -6
  163. package/registry/combos/nestjs-prisma/variants/workspaces/src/controllers/admin.controller.ts +1 -1
  164. package/registry/combos/nestjs-prisma/variants/workspaces/src/controllers/workspace.controller.ts +1 -1
  165. package/registry/combos/nestjs-prisma/variants/workspaces/src/guards/authz.guard.ts +2 -2
  166. package/registry/combos/nestjs-prisma/variants/workspaces/src/index.ts +9 -0
  167. package/registry/combos/nestjs-prisma/variants/workspaces/src/rbac.defaults.ts +1 -1
  168. package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/audit-log.repository.ts +2 -2
  169. package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/country.repository.ts +2 -2
  170. package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/customer.repository.ts +6 -5
  171. package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/language.repository.ts +2 -2
  172. package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/rbac.repository.ts +3 -3
  173. package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/workspace.repository.ts +1 -1
  174. package/registry/combos/nestjs-prisma/variants/workspaces/src/seed.ts +1 -1
  175. package/registry/combos/nestjs-prisma/variants/workspaces/src/services/auth.service.ts +6 -8
  176. package/registry/combos/nestjs-prisma/variants/workspaces/test/variant-hooks.ts +538 -134
  177. package/registry/combos/express-drizzle/variants/base/src/openapi-admin.ts +0 -565
  178. package/registry/combos/express-drizzle/variants/workspaces/src/openapi-admin.ts +0 -596
  179. package/registry/combos/express-prisma/variants/base/src/openapi-admin.ts +0 -569
  180. package/registry/combos/express-prisma/variants/workspaces/src/openapi-admin.ts +0 -601
  181. /package/registry/combos/express-drizzle/shared/src/{http-error.ts → errors/http-error.ts} +0 -0
  182. /package/registry/combos/express-prisma/shared/src/{http-error.ts → errors/http-error.ts} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  Injectable,
7
7
  } from "@nestjs/common";
8
8
  import { Reflector } from "@nestjs/core";
9
- import { ABILITY_SUBJECT } from "../ability.js";
9
+ import { ABILITY_SUBJECT } from "./ability.js";
10
10
  import { CHECK_ABILITY_KEY } from "../route-tiers.js";
11
11
 
12
12
  // The authorization boundary for tier-3 routes — no role-based bypass beside it, so a role
@@ -6,7 +6,11 @@
6
6
  // A permission slug is CASL's *action*; the subject is always a constant empty string. That
7
7
  // keeps the model flat — no subject taxonomy, no (action, subject) pairing to get wrong, no
8
8
  // conditions.
9
- import { AbilityBuilder, createMongoAbility, type MongoAbility } from "@casl/ability";
9
+ import {
10
+ AbilityBuilder,
11
+ createMongoAbility,
12
+ type MongoAbility,
13
+ } from "@casl/ability";
10
14
 
11
15
  // Constant rather than a repeated string literal — `can("users:read", "")` in one place and
12
16
  // `can("users:read", "all")` in another would silently never match.
@@ -16,7 +20,9 @@ export type AppAbility = MongoAbility<[string, typeof ABILITY_SUBJECT]>;
16
20
 
17
21
  // An empty list builds an ability with no rules, which denies everything — the fail-closed
18
22
  // answer whether permissions failed to resolve or the user genuinely has none.
19
- export function defineAbilitiesFor(permissions: readonly string[] = []): AppAbility {
23
+ export function defineAbilitiesFor(
24
+ permissions: readonly string[] = [],
25
+ ): AppAbility {
20
26
  const { can, build } = new AbilityBuilder<AppAbility>(createMongoAbility);
21
27
  for (const permission of permissions) can(permission, ABILITY_SUBJECT);
22
28
  return build();
@@ -14,7 +14,7 @@
14
14
  // happen on `AuthGuard`, which never reads this cache. Negative results aren't cached either —
15
15
  // "not a member of this workspace" is re-read every time.
16
16
  import { Inject, Injectable } from "@nestjs/common";
17
- import { AUTH_CONFIG, AuthConfig } from "./auth.config.js";
17
+ import { AUTH_CONFIG, AuthConfig } from "../config/auth.config.js";
18
18
 
19
19
  /** DI token for the store. Provide your own to `AuthModule.forRoot({ permissionCacheStore })`. */
20
20
  export const PERMISSION_CACHE_STORE = Symbol("PERMISSION_CACHE_STORE");
@@ -37,7 +37,10 @@ export interface PermissionCacheStore {
37
37
  // database resolution, not N.
38
38
  export class InMemoryPermissionCacheStore implements PermissionCacheStore {
39
39
  readonly stats = { hits: 0, misses: 0, writes: 0 };
40
- private readonly entries = new Map<string, { value: string; expiresAt: number }>();
40
+ private readonly entries = new Map<
41
+ string,
42
+ { value: string; expiresAt: number }
43
+ >();
41
44
 
42
45
  async get(key: string): Promise<string | undefined> {
43
46
  const entry = this.entries.get(key);
@@ -70,10 +73,14 @@ export class InMemoryPermissionCacheStore implements PermissionCacheStore {
70
73
 
71
74
  async bump(key: string): Promise<number> {
72
75
  const entry = this.entries.get(key);
73
- const next = Number(entry && entry.expiresAt > Date.now() ? entry.value : 0) + 1;
76
+ const next =
77
+ Number(entry && entry.expiresAt > Date.now() ? entry.value : 0) + 1;
74
78
  // Version counters outlive entries on purpose: a counter that expired back to 0 would make
75
79
  // every superseded entry reachable again.
76
- this.entries.set(key, { value: String(next), expiresAt: Number.MAX_SAFE_INTEGER });
80
+ this.entries.set(key, {
81
+ value: String(next),
82
+ expiresAt: Number.MAX_SAFE_INTEGER,
83
+ });
77
84
  return next;
78
85
  }
79
86
  }
@@ -82,8 +89,10 @@ export class InMemoryPermissionCacheStore implements PermissionCacheStore {
82
89
  // migration, a psql session) can bump the counter itself — otherwise an out-of-band write is
83
90
  // only picked up once the cache entry expires.
84
91
  export const POLICY_VERSION_KEY = `${CACHE_NAMESPACE}:policy-version`;
85
- export const subjectVersionKey = (subject: string) => `${CACHE_NAMESPACE}:subject-version:${subject}`;
86
- const entryKey = (subject: string, policy: string, subjectVersion: string) => `${CACHE_NAMESPACE}:entry:${subject}:p${policy}:s${subjectVersion}`;
92
+ export const subjectVersionKey = (subject: string) =>
93
+ `${CACHE_NAMESPACE}:subject-version:${subject}`;
94
+ const entryKey = (subject: string, policy: string, subjectVersion: string) =>
95
+ `${CACHE_NAMESPACE}:entry:${subject}:p${policy}:s${subjectVersion}`;
87
96
 
88
97
  // Reads through to the database once per (principal, policy version, subject version). Used by
89
98
  // each variant's `AuthzGuard` — the variants differ only in what a "subject" is (a user id in
@@ -92,7 +101,8 @@ const entryKey = (subject: string, policy: string, subjectVersion: string) => `$
92
101
  @Injectable()
93
102
  export class PermissionCache {
94
103
  constructor(
95
- @Inject(PERMISSION_CACHE_STORE) private readonly store: PermissionCacheStore,
104
+ @Inject(PERMISSION_CACHE_STORE)
105
+ private readonly store: PermissionCacheStore,
96
106
  @Inject(AUTH_CONFIG) private readonly config: AuthConfig,
97
107
  ) {}
98
108
 
@@ -100,11 +110,17 @@ export class PermissionCache {
100
110
  // under load costs one database read per instance rather than one per request.
101
111
  private readonly inFlight = new Map<string, Promise<unknown>>();
102
112
 
103
- async resolve<T>(subject: string, load: () => Promise<T | null>): Promise<T | null> {
113
+ async resolve<T>(
114
+ subject: string,
115
+ load: () => Promise<T | null>,
116
+ ): Promise<T | null> {
104
117
  const ttl = this.config.permissionCacheTtlSeconds;
105
118
  if (ttl <= 0) return load(); // caching off; the semantics are identical, only the cost differs
106
119
 
107
- const [policy = "0", version = "0"] = await this.store.getMany([POLICY_VERSION_KEY, subjectVersionKey(subject)]);
120
+ const [policy = "0", version = "0"] = await this.store.getMany([
121
+ POLICY_VERSION_KEY,
122
+ subjectVersionKey(subject),
123
+ ]);
108
124
  const key = entryKey(subject, policy, version);
109
125
 
110
126
  const cached = await this.store.get(key);
@@ -116,7 +132,8 @@ export class PermissionCache {
116
132
  const pending = (async () => {
117
133
  const resolved = await load();
118
134
  // A negative result is not written: see the module comment. Only a real answer is cached.
119
- if (resolved !== null) await this.store.set(key, JSON.stringify(resolved), ttl);
135
+ if (resolved !== null)
136
+ await this.store.set(key, JSON.stringify(resolved), ttl);
120
137
  return resolved;
121
138
  })();
122
139
 
@@ -8,7 +8,10 @@ import type { RateLimitDeps } from "@/lib/auth/core/rate-limit.js";
8
8
  */
9
9
  @Injectable()
10
10
  export class InMemoryRateLimitStore implements RateLimitDeps {
11
- private readonly windows = new Map<string, { count: number; resetAt: number }>();
11
+ private readonly windows = new Map<
12
+ string,
13
+ { count: number; resetAt: number }
14
+ >();
12
15
 
13
16
  async increment(key: string, windowMs: number): Promise<number> {
14
17
  const now = Date.now();
@@ -1,4 +1,4 @@
1
- import type { PermissionCacheStore } from "./permission-cache.js";
1
+ import type { PermissionCacheStore } from "../cache/permission-cache.js";
2
2
  import type { RateLimitDeps } from "@/lib/auth/core/rate-limit.js";
3
3
 
4
4
  export const AUTH_CONFIG = Symbol("AUTH_CONFIG");
@@ -10,11 +10,15 @@ const MIN_SECRET_BYTES = 32; // 256 bits, HS256's own minimum
10
10
  function loadSecret(): Uint8Array {
11
11
  const raw = process.env[ENV_VAR];
12
12
  if (!raw) {
13
- throw new Error(`${ENV_VAR} is not set. Generate one and set it before starting the app — e.g.: openssl rand -base64 32`);
13
+ throw new Error(
14
+ `${ENV_VAR} is not set. Generate one and set it before starting the app — e.g.: openssl rand -base64 32`,
15
+ );
14
16
  }
15
17
  const secret = Buffer.from(raw, "base64");
16
18
  if (secret.length < MIN_SECRET_BYTES) {
17
- throw new Error(`${ENV_VAR} decodes to ${secret.length} bytes — needs at least ${MIN_SECRET_BYTES} (256 bits) for HS256.`);
19
+ throw new Error(
20
+ `${ENV_VAR} decodes to ${secret.length} bytes — needs at least ${MIN_SECRET_BYTES} (256 bits) for HS256.`,
21
+ );
18
22
  }
19
23
  return secret;
20
24
  }
@@ -27,7 +27,7 @@ import {
27
27
  AUTH_CONFIG,
28
28
  AuthConfig,
29
29
  defaultThrottleBuckets,
30
- } from "../auth.config.js";
30
+ } from "../config/auth.config.js";
31
31
  import { AuthGuard } from "../guards/auth.guard.js";
32
32
  import { AuthService } from "../services/auth.service.js";
33
33
  import { AuthzGuard } from "../guards/authz.guard.js";
@@ -6,7 +6,7 @@ import {
6
6
  UnauthorizedException,
7
7
  } from "@nestjs/common";
8
8
  import { verifyAccessToken } from "@/lib/auth/core/token-service.js";
9
- import { KeyProviderService } from "../key-provider.js";
9
+ import { KeyProviderService } from "../config/key-provider.js";
10
10
  import "../request-context.js";
11
11
  import { SessionRepository } from "../repositories/session.repository.js";
12
12
 
@@ -11,12 +11,16 @@ export function toId(value: string | number | bigint): bigint {
11
11
  }
12
12
  }
13
13
 
14
- export function toIdOrUndefined(value: string | number | bigint | null | undefined): bigint | undefined {
14
+ export function toIdOrUndefined(
15
+ value: string | number | bigint | null | undefined,
16
+ ): bigint | undefined {
15
17
  if (value === null || value === undefined || value === "") return undefined;
16
18
  return toId(value);
17
19
  }
18
20
 
19
- export function toIdOrNull(value: string | number | bigint | null | undefined): bigint | null {
21
+ export function toIdOrNull(
22
+ value: string | number | bigint | null | undefined,
23
+ ): bigint | null {
20
24
  if (value === null || value === undefined || value === "") return null;
21
25
  return toId(value);
22
26
  }
@@ -21,10 +21,24 @@ export function normalizePage(page: number | undefined): number {
21
21
  }
22
22
 
23
23
  export function normalizeLimit(limit: number | undefined): number {
24
- return Math.min(limit && limit > 0 ? Math.floor(limit) : DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE);
24
+ return Math.min(
25
+ limit && limit > 0 ? Math.floor(limit) : DEFAULT_PAGE_SIZE,
26
+ MAX_PAGE_SIZE,
27
+ );
25
28
  }
26
29
 
27
- export function buildPageMeta(page: number, limit: number, total: number): PageMeta {
30
+ export function buildPageMeta(
31
+ page: number,
32
+ limit: number,
33
+ total: number,
34
+ ): PageMeta {
28
35
  const pageCount = Math.ceil(total / limit);
29
- return { page, limit, total, pageCount, hasPreviousPage: page > 1, hasNextPage: page < pageCount };
36
+ return {
37
+ page,
38
+ limit,
39
+ total,
40
+ pageCount,
41
+ hasPreviousPage: page > 1,
42
+ hasNextPage: page < pageCount,
43
+ };
30
44
  }
@@ -1,7 +1,7 @@
1
1
  import { BadRequestException, Inject, Injectable } from "@nestjs/common";
2
2
  import type { OAuthStoreDeps } from "@/lib/auth/core/oauth.js";
3
3
  import { PrismaClient } from "../../generated/prisma/client.js";
4
- import { toId } from "../id.helper.js";
4
+ import { toId } from "../helpers/id.helper.js";
5
5
 
6
6
  @Injectable()
7
7
  export class OAuthRepository implements OAuthStoreDeps {
@@ -1,7 +1,7 @@
1
1
  import { Inject, Injectable } from "@nestjs/common";
2
2
  import type { PasswordResetStoreDeps } from "@/lib/auth/core/password-reset.js";
3
3
  import { PrismaClient } from "../../generated/prisma/client.js";
4
- import { toId } from "../id.helper.js";
4
+ import { toId } from "../helpers/id.helper.js";
5
5
 
6
6
  @Injectable()
7
7
  export class PasswordResetRepository implements PasswordResetStoreDeps {
@@ -21,9 +21,7 @@ export class PasswordResetRepository implements PasswordResetStoreDeps {
21
21
  });
22
22
  }
23
23
 
24
- async findValidResetToken(
25
- tokenHash: string,
26
- ): Promise<{
24
+ async findValidResetToken(tokenHash: string): Promise<{
27
25
  userId: string;
28
26
  expiresAt: string;
29
27
  consumedAt: string | null;
@@ -7,9 +7,9 @@ import type {
7
7
  SessionRecord,
8
8
  } from "@/lib/auth/core/types.js";
9
9
  import { PrismaClient } from "../../generated/prisma/client.js";
10
- import { AUTH_CONFIG, AuthConfig } from "../auth.config.js";
10
+ import { AUTH_CONFIG, AuthConfig } from "../config/auth.config.js";
11
11
  import { AuditLogRepository } from "./audit-log.repository.js";
12
- import { toId, toIdOrNull } from "../id.helper.js";
12
+ import { toId, toIdOrNull } from "../helpers/id.helper.js";
13
13
 
14
14
  function toSessionRecord(row: {
15
15
  id: bigint;
@@ -7,7 +7,7 @@
7
7
  //
8
8
  // Importing this module for its side effect installs the Express `Request` augmentation.
9
9
  import type { AccessTokenClaims } from "@/lib/auth/core/types.js";
10
- import type { AppAbility } from "./ability.js";
10
+ import type { AppAbility } from "./ability/ability.js";
11
11
  import type { AuthzContext } from "./guards/authz.guard.js";
12
12
 
13
13
  declare module "express" {
@@ -2,7 +2,7 @@ import "reflect-metadata";
2
2
  import { Module } from "@nestjs/common";
3
3
  import { NestFactory } from "@nestjs/core";
4
4
  import { AuthModule } from "../src/auth.module.js";
5
- import { InMemoryPermissionCacheStore } from "../src/permission-cache.js";
5
+ import { InMemoryPermissionCacheStore } from "../src/cache/permission-cache.js";
6
6
 
7
7
  // No mailer is wired up for the proof, so this stands in for one — prove-cycle.ts reads the
8
8
  // raw token back out of here the same way a test inbox would, to exercise the reset flow.
@@ -11,7 +11,7 @@ import "dotenv/config";
11
11
  import { randomUUID } from "node:crypto";
12
12
  import { Get } from "@nestjs/common";
13
13
  import { generateTotpCode } from "@/lib/auth/core/two-factor.js";
14
- import { ABILITY_SUBJECT, defineAbilitiesFor } from "../src/ability.js";
14
+ import { ABILITY_SUBJECT, defineAbilitiesFor } from "../src/ability/ability.js";
15
15
  import { AuthController } from "../src/controllers/auth.controller.js";
16
16
  import { bootstrap, capturedResetTokens } from "./bootstrap.js";
17
17
  import {
@@ -2,20 +2,24 @@ import { PrismaPg } from "@prisma/adapter-pg";
2
2
  import { DynamicModule, Module } from "@nestjs/common";
3
3
  import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from "@nestjs/core";
4
4
  import { ThrottlerGuard, ThrottlerModule } from "@nestjs/throttler";
5
- import { AbilityGuard } from "./guards/ability.guard.js";
5
+ import { AbilityGuard } from "./ability/ability.guard.js";
6
6
  import { AdminController } from "./controllers/admin.controller.js";
7
7
  import { AuditLogGateway } from "./gateways/audit-log.gateway.js";
8
8
  import { AuditLogRepository } from "./repositories/audit-log.repository.js";
9
9
  import { AuthCoreErrorFilter } from "./filters/auth-core-error.filter.js";
10
- import { AUTH_CONFIG, AuthConfig, defaultAuthConfig } from "./auth.config.js";
10
+ import {
11
+ AUTH_CONFIG,
12
+ AuthConfig,
13
+ defaultAuthConfig,
14
+ } from "./config/auth.config.js";
11
15
  import { AuthController } from "./controllers/auth.controller.js";
12
16
  import { AuthGuard } from "./guards/auth.guard.js";
13
17
  import { AuthService } from "./services/auth.service.js";
14
18
  import { AuthzGuard } from "./guards/authz.guard.js";
15
- import { PrismaClient } from "../generated/prisma/client.js";
19
+ import { PrismaClient } from "./../generated/prisma/client.js";
16
20
  import { CountryRepository } from "./repositories/country.repository.js";
17
21
  import { CustomerRepository } from "./repositories/customer.repository.js";
18
- import { KeyProviderService } from "./key-provider.js";
22
+ import { KeyProviderService } from "./config/key-provider.js";
19
23
  import { LanguageRepository } from "./repositories/language.repository.js";
20
24
  import { OAuthRepository } from "./repositories/oauth.repository.js";
21
25
  import { PasswordResetRepository } from "./repositories/password-reset.repository.js";
@@ -23,11 +27,11 @@ import {
23
27
  InMemoryPermissionCacheStore,
24
28
  PERMISSION_CACHE_STORE,
25
29
  PermissionCache,
26
- } from "./permission-cache.js";
30
+ } from "./cache/permission-cache.js";
27
31
  import {
28
32
  InMemoryRateLimitStore,
29
33
  RATE_LIMIT_STORE,
30
- } from "./rate-limit.store.js";
34
+ } from "./cache/rate-limit.store.js";
31
35
  import { RbacRepository } from "./repositories/rbac.repository.js";
32
36
  import { ResponseInterceptor } from "./interceptors/response.interceptor.js";
33
37
  import { assertEveryRouteDeclaresATier } from "./route-tiers.js";
@@ -24,7 +24,7 @@ import {
24
24
  ApiTags,
25
25
  } from "@nestjs/swagger";
26
26
  import type { Request } from "express";
27
- import { AbilityGuard } from "../guards/ability.guard.js";
27
+ import { AbilityGuard } from "../ability/ability.guard.js";
28
28
  import { AuthGuard } from "../guards/auth.guard.js";
29
29
  import { AuthService } from "../services/auth.service.js";
30
30
  import { AuthzGuard } from "../guards/authz.guard.js";
@@ -10,7 +10,7 @@ import {
10
10
  AuditLogEntry,
11
11
  AuditLogRepository,
12
12
  } from "../repositories/audit-log.repository.js";
13
- import { KeyProviderService } from "../key-provider.js";
13
+ import { KeyProviderService } from "../config/key-provider.js";
14
14
  import { SessionRepository } from "../repositories/session.repository.js";
15
15
 
16
16
  // socket.io clients disagree on where a bearer token travels: `auth.token` (the socket.io-native
@@ -4,8 +4,8 @@ import {
4
4
  Inject,
5
5
  Injectable,
6
6
  } from "@nestjs/common";
7
- import { defineAbilitiesFor } from "../ability.js";
8
- import { PermissionCache } from "../permission-cache.js";
7
+ import { defineAbilitiesFor } from "../ability/ability.js";
8
+ import { PermissionCache } from "../cache/permission-cache.js";
9
9
  import { RbacRepository } from "../repositories/rbac.repository.js";
10
10
 
11
11
  // Roles and permissions are global to this deployment — one set per user, resolved from the
@@ -0,0 +1,9 @@
1
+ export * from "./auth.module.js";
2
+
3
+ export * from "./route-tiers.js";
4
+
5
+ export * from "./guards/auth.guard.js";
6
+ export * from "./guards/authz.guard.js";
7
+
8
+ export * from "./ability/ability.js";
9
+ export * from "./ability/ability.guard.js";
@@ -6,20 +6,30 @@ import type { NextFunction, Request, Response } from "express";
6
6
 
7
7
  // Production-only gate: development keeps zero-friction docs, production requires the DOCS_*
8
8
  // pair on every docs route. Credentials missing in production fail closed (503), not open.
9
- export function docsBasicAuth(req: Request, res: Response, next: NextFunction): void {
9
+ export function docsBasicAuth(
10
+ req: Request,
11
+ res: Response,
12
+ next: NextFunction,
13
+ ): void {
10
14
  if (process.env["NODE_ENV"] !== "production") return next();
11
15
 
12
16
  const username = process.env["DOCS_USERNAME"];
13
17
  const password = process.env["DOCS_PASSWORD"];
14
18
  if (!username || !password) {
15
- res.status(503).send("Docs are unavailable: DOCS_USERNAME and DOCS_PASSWORD are not set");
19
+ res
20
+ .status(503)
21
+ .send(
22
+ "Docs are unavailable: DOCS_USERNAME and DOCS_PASSWORD are not set",
23
+ );
16
24
  return;
17
25
  }
18
26
 
19
27
  const header = req.headers.authorization;
20
28
  if (header?.startsWith("Basic ")) {
21
29
  // Split on the first colon only — RFC 7617 allows colons inside the password.
22
- const [user, ...rest] = Buffer.from(header.slice("Basic ".length), "base64").toString("utf8").split(":");
30
+ const [user, ...rest] = Buffer.from(header.slice("Basic ".length), "base64")
31
+ .toString("utf8")
32
+ .split(":");
23
33
  if (user === username && rest.join(":") === password) return next();
24
34
  }
25
35
 
@@ -38,12 +48,18 @@ export interface DocsOptions {
38
48
  * Swagger registers alongside the UI) behind `docsBasicAuth`. Call after `NestFactory.create`,
39
49
  * before `listen`.
40
50
  */
41
- export function setupDocs(app: INestApplication, opts: DocsOptions = {}): OpenAPIObject {
51
+ export function setupDocs(
52
+ app: INestApplication,
53
+ opts: DocsOptions = {},
54
+ ): OpenAPIObject {
42
55
  const document = SwaggerModule.createDocument(
43
56
  app,
44
57
  new DocumentBuilder()
45
58
  .setTitle(opts.title ?? "simple-auth-kit API")
46
- .setDescription(opts.description ?? "nestjs-prisma reference combo — signup/login, sessions, TOTP 2FA, OAuth, password reset, RBAC, audit log")
59
+ .setDescription(
60
+ opts.description ??
61
+ "nestjs-prisma reference combo — signup/login, sessions, TOTP 2FA, OAuth, password reset, RBAC, audit log",
62
+ )
47
63
  .setVersion(opts.version ?? "1.0")
48
64
  .addBearerAuth()
49
65
  .build(),
@@ -52,7 +68,8 @@ export function setupDocs(app: INestApplication, opts: DocsOptions = {}): OpenAP
52
68
  // The gates must be registered before SwaggerModule.setup so they run ahead of the UI
53
69
  // middleware. `/docs-json` and `/docs-yaml` are separate express paths — a `/docs` prefix
54
70
  // mount does not cover them.
55
- for (const path of ["/docs", "/docs-json", "/docs-yaml", "/reference"]) app.use(path, docsBasicAuth);
71
+ for (const path of ["/docs", "/docs-json", "/docs-yaml", "/reference"])
72
+ app.use(path, docsBasicAuth);
56
73
 
57
74
  SwaggerModule.setup("docs", app, document);
58
75
  app.use("/reference", apiReference({ content: document }));
@@ -4,7 +4,7 @@
4
4
  // `provisionDefaultRoles` writes these rows once at seed time; from then on the database is
5
5
  // authoritative and nothing in the request path reads this file. Callers: `src/seed.ts` and
6
6
  // `variants/base/test/variant-hooks.ts`.
7
- import type { PrismaClient } from "../generated/prisma/client.js";
7
+ import type { PrismaClient } from "./../generated/prisma/client.js";
8
8
 
9
9
  export interface PermissionSeed {
10
10
  displayName: string;
@@ -1,13 +1,13 @@
1
1
  import { Inject, Injectable } from "@nestjs/common";
2
2
  import type { AuditEvent } from "@/lib/auth/core/types.js";
3
3
  import { Prisma, PrismaClient } from "../../generated/prisma/client.js";
4
- import { toIdOrNull, toIdOrUndefined } from "../id.helper.js";
4
+ import { toIdOrNull, toIdOrUndefined } from "../helpers/id.helper.js";
5
5
  import {
6
6
  buildPageMeta,
7
7
  normalizeLimit,
8
8
  normalizePage,
9
9
  type Paginated,
10
- } from "../pagination.js";
10
+ } from "../helpers/pagination.js";
11
11
 
12
12
  export interface AuditLogEntry {
13
13
  id: string;
@@ -5,13 +5,13 @@ import {
5
5
  NotFoundException,
6
6
  } from "@nestjs/common";
7
7
  import { Prisma, PrismaClient } from "../../generated/prisma/client.js";
8
- import { toId, toIdOrNull } from "../id.helper.js";
8
+ import { toId, toIdOrNull } from "../helpers/id.helper.js";
9
9
  import {
10
10
  buildPageMeta,
11
11
  normalizeLimit,
12
12
  normalizePage,
13
13
  type Paginated,
14
- } from "../pagination.js";
14
+ } from "../helpers/pagination.js";
15
15
 
16
16
  /** A `Country` row as `findUnique`/`findMany` return it. */
17
17
  export type CountryRow = Prisma.CountryGetPayload<object>;
@@ -5,13 +5,13 @@ import {
5
5
  NotFoundException,
6
6
  } from "@nestjs/common";
7
7
  import { Prisma, PrismaClient } from "../../generated/prisma/client.js";
8
- import { toId, toIdOrNull } from "../id.helper.js";
8
+ import { toId, toIdOrNull } from "../helpers/id.helper.js";
9
9
  import {
10
10
  buildPageMeta,
11
11
  normalizeLimit,
12
12
  normalizePage,
13
13
  type Paginated,
14
- } from "../pagination.js";
14
+ } from "../helpers/pagination.js";
15
15
 
16
16
  /** A `Customer` row as `findUnique`/`findMany` return it. */
17
17
  export type CustomerRow = Prisma.CustomerGetPayload<object>;
@@ -88,9 +88,10 @@ export interface CustomerInput {
88
88
  isActive?: boolean;
89
89
  }
90
90
 
91
- function toPrismaInput(
92
- input: Partial<CustomerInput>,
93
- ): Omit<Partial<CustomerInput>, "dob" | "joinedDate"> & {
91
+ function toPrismaInput(input: Partial<CustomerInput>): Omit<
92
+ Partial<CustomerInput>,
93
+ "dob" | "joinedDate"
94
+ > & {
94
95
  dob?: Date | null;
95
96
  joinedDate?: Date;
96
97
  } {
@@ -5,13 +5,13 @@ import {
5
5
  NotFoundException,
6
6
  } from "@nestjs/common";
7
7
  import { Prisma, PrismaClient } from "../../generated/prisma/client.js";
8
- import { toId, toIdOrNull } from "../id.helper.js";
8
+ import { toId, toIdOrNull } from "../helpers/id.helper.js";
9
9
  import {
10
10
  buildPageMeta,
11
11
  normalizeLimit,
12
12
  normalizePage,
13
13
  type Paginated,
14
- } from "../pagination.js";
14
+ } from "../helpers/pagination.js";
15
15
 
16
16
  /** A `Language` row as `findUnique`/`findMany` return it. */
17
17
  export type LanguageRow = Prisma.LanguageGetPayload<object>;
@@ -6,14 +6,14 @@ import {
6
6
  } from "@nestjs/common";
7
7
  import { resolvePermissions } from "@/lib/auth/core/rbac.js";
8
8
  import { Prisma, PrismaClient } from "../../generated/prisma/client.js";
9
- import { PermissionCache } from "../permission-cache.js";
10
- import { toId, toIdOrNull } from "../id.helper.js";
9
+ import { PermissionCache } from "../cache/permission-cache.js";
10
+ import { toId, toIdOrNull } from "../helpers/id.helper.js";
11
11
  import {
12
12
  buildPageMeta,
13
13
  normalizeLimit,
14
14
  normalizePage,
15
15
  type Paginated,
16
- } from "../pagination.js";
16
+ } from "../helpers/pagination.js";
17
17
 
18
18
  const USER_ROLES_INCLUDE = {
19
19
  roles: { select: { role: { select: { slug: true } } } },
@@ -5,7 +5,7 @@
5
5
  // existing admin keeps the password they already have.
6
6
  import { PrismaPg } from "@prisma/adapter-pg";
7
7
  import { hashPassword } from "@/lib/auth/core/crypto.js";
8
- import { PrismaClient } from "../generated/prisma/client.js";
8
+ import { PrismaClient } from "./../generated/prisma/client.js";
9
9
  import {
10
10
  DEFAULT_ROLES,
11
11
  PERMISSION_SLUGS,
@@ -51,7 +51,7 @@ import {
51
51
  verifyTotpCode,
52
52
  } from "@/lib/auth/core/two-factor.js";
53
53
  import type { Revoker } from "@/lib/auth/core/types.js";
54
- import { AUTH_CONFIG, AuthConfig } from "../auth.config.js";
54
+ import { AUTH_CONFIG, AuthConfig } from "../config/auth.config.js";
55
55
  import {
56
56
  AuditLogEntry,
57
57
  AuditLogListFilter,
@@ -73,7 +73,7 @@ import {
73
73
  CustomerRepository,
74
74
  CustomerSummary,
75
75
  } from "../repositories/customer.repository.js";
76
- import { KeyProviderService } from "../key-provider.js";
76
+ import { KeyProviderService } from "../config/key-provider.js";
77
77
  import {
78
78
  LanguageInput,
79
79
  LanguageListFilter,
@@ -83,8 +83,8 @@ import {
83
83
  } from "../repositories/language.repository.js";
84
84
  import { OAuthRepository } from "../repositories/oauth.repository.js";
85
85
  import { PasswordResetRepository } from "../repositories/password-reset.repository.js";
86
- import type { Paginated } from "../pagination.js";
87
- import { RATE_LIMIT_STORE } from "../rate-limit.store.js";
86
+ import type { Paginated } from "../helpers/pagination.js";
87
+ import { RATE_LIMIT_STORE } from "../cache/rate-limit.store.js";
88
88
  import {
89
89
  PermissionInput,
90
90
  PermissionSummary,
@@ -97,7 +97,7 @@ import {
97
97
  } from "../repositories/rbac.repository.js";
98
98
  import { SessionRepository } from "../repositories/session.repository.js";
99
99
  import { TwoFactorRepository } from "../repositories/two-factor.repository.js";
100
- import { toId, toIdOrNull } from "../id.helper.js";
100
+ import { toId, toIdOrNull } from "../helpers/id.helper.js";
101
101
 
102
102
  export interface AuthTokens {
103
103
  accessToken: string;
@@ -499,9 +499,7 @@ export class AuthService {
499
499
  return { twoFactorEnabled: user.twoFactorEnabled };
500
500
  }
501
501
 
502
- async listActiveSessions(
503
- userId: string,
504
- ): Promise<
502
+ async listActiveSessions(userId: string): Promise<
505
503
  Array<{
506
504
  id: string;
507
505
  createdAt: string;