@techelusive/nest-auth 0.0.0-stage → 0.2.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 (340) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/LICENSE +21 -0
  3. package/README.md +204 -2
  4. package/api/openapi.json +4399 -0
  5. package/api/techelusive-authentication.postman_collection.json +3178 -0
  6. package/dist/auth-options.d.ts +156 -0
  7. package/dist/auth-options.js +3 -0
  8. package/dist/auth-options.js.map +1 -0
  9. package/dist/auth-options.validation.d.ts +9 -0
  10. package/dist/auth-options.validation.js +74 -0
  11. package/dist/auth-options.validation.js.map +1 -0
  12. package/dist/auth.module.d.ts +38 -0
  13. package/dist/auth.module.js +173 -0
  14. package/dist/auth.module.js.map +1 -0
  15. package/dist/common/auth-error.d.ts +16 -0
  16. package/dist/common/auth-error.js +23 -0
  17. package/dist/common/auth-error.js.map +1 -0
  18. package/dist/common/auth-exception.filter.d.ts +24 -0
  19. package/dist/common/auth-exception.filter.js +66 -0
  20. package/dist/common/auth-exception.filter.js.map +1 -0
  21. package/dist/common/crypto/jwt.d.ts +89 -0
  22. package/dist/common/crypto/jwt.js +144 -0
  23. package/dist/common/crypto/jwt.js.map +1 -0
  24. package/dist/common/crypto/random-secrets.d.ts +78 -0
  25. package/dist/common/crypto/random-secrets.js +113 -0
  26. package/dist/common/crypto/random-secrets.js.map +1 -0
  27. package/dist/common/crypto/remote-public-keys.d.ts +49 -0
  28. package/dist/common/crypto/remote-public-keys.js +105 -0
  29. package/dist/common/crypto/remote-public-keys.js.map +1 -0
  30. package/dist/common/crypto/totp.d.ts +68 -0
  31. package/dist/common/crypto/totp.js +148 -0
  32. package/dist/common/crypto/totp.js.map +1 -0
  33. package/dist/common/encryption.service.d.ts +36 -0
  34. package/dist/common/encryption.service.js +111 -0
  35. package/dist/common/encryption.service.js.map +1 -0
  36. package/dist/common/identifiers.d.ts +48 -0
  37. package/dist/common/identifiers.js +89 -0
  38. package/dist/common/identifiers.js.map +1 -0
  39. package/dist/common/network-safety.d.ts +19 -0
  40. package/dist/common/network-safety.js +72 -0
  41. package/dist/common/network-safety.js.map +1 -0
  42. package/dist/common/rate-limiter.service.d.ts +63 -0
  43. package/dist/common/rate-limiter.service.js +158 -0
  44. package/dist/common/rate-limiter.service.js.map +1 -0
  45. package/dist/common/refresh-token-cookie.d.ts +78 -0
  46. package/dist/common/refresh-token-cookie.js +185 -0
  47. package/dist/common/refresh-token-cookie.js.map +1 -0
  48. package/dist/common/request-context.d.ts +14 -0
  49. package/dist/common/request-context.js +22 -0
  50. package/dist/common/request-context.js.map +1 -0
  51. package/dist/common/strict-validation.pipe.d.ts +8 -0
  52. package/dist/common/strict-validation.pipe.js +16 -0
  53. package/dist/common/strict-validation.pipe.js.map +1 -0
  54. package/dist/common/time.d.ts +15 -0
  55. package/dist/common/time.js +34 -0
  56. package/dist/common/time.js.map +1 -0
  57. package/dist/constants.d.ts +1326 -0
  58. package/dist/constants.js +1142 -0
  59. package/dist/constants.js.map +1 -0
  60. package/dist/database/create-auth-tables.migration.d.ts +26 -0
  61. package/dist/database/create-auth-tables.migration.js +291 -0
  62. package/dist/database/create-auth-tables.migration.js.map +1 -0
  63. package/dist/database/email-change-and-retention.migration.d.ts +25 -0
  64. package/dist/database/email-change-and-retention.migration.js +54 -0
  65. package/dist/database/email-change-and-retention.migration.js.map +1 -0
  66. package/dist/database/entities/api-key.entity.d.ts +17 -0
  67. package/dist/database/entities/api-key.entity.js +80 -0
  68. package/dist/database/entities/api-key.entity.js.map +1 -0
  69. package/dist/database/entities/audit-log.entity.d.ts +13 -0
  70. package/dist/database/entities/audit-log.entity.js +64 -0
  71. package/dist/database/entities/audit-log.entity.js.map +1 -0
  72. package/dist/database/entities/backup-code.entity.d.ts +9 -0
  73. package/dist/database/entities/backup-code.entity.js +52 -0
  74. package/dist/database/entities/backup-code.entity.js.map +1 -0
  75. package/dist/database/entities/index.d.ts +43 -0
  76. package/dist/database/entities/index.js +82 -0
  77. package/dist/database/entities/index.js.map +1 -0
  78. package/dist/database/entities/json-object.d.ts +12 -0
  79. package/dist/database/entities/json-object.js +3 -0
  80. package/dist/database/entities/json-object.js.map +1 -0
  81. package/dist/database/entities/link-token.entity.d.ts +15 -0
  82. package/dist/database/entities/link-token.entity.js +64 -0
  83. package/dist/database/entities/link-token.entity.js.map +1 -0
  84. package/dist/database/entities/one-time-code.entity.d.ts +16 -0
  85. package/dist/database/entities/one-time-code.entity.js +69 -0
  86. package/dist/database/entities/one-time-code.entity.js.map +1 -0
  87. package/dist/database/entities/organization-invitation.entity.d.ts +14 -0
  88. package/dist/database/entities/organization-invitation.entity.js +73 -0
  89. package/dist/database/entities/organization-invitation.entity.js.map +1 -0
  90. package/dist/database/entities/organization-member.entity.d.ts +9 -0
  91. package/dist/database/entities/organization-member.entity.js +48 -0
  92. package/dist/database/entities/organization-member.entity.js.map +1 -0
  93. package/dist/database/entities/organization.entity.d.ts +12 -0
  94. package/dist/database/entities/organization.entity.js +58 -0
  95. package/dist/database/entities/organization.entity.js.map +1 -0
  96. package/dist/database/entities/passkey.entity.d.ts +19 -0
  97. package/dist/database/entities/passkey.entity.js +78 -0
  98. package/dist/database/entities/passkey.entity.js.map +1 -0
  99. package/dist/database/entities/password.entity.d.ts +6 -0
  100. package/dist/database/entities/password.entity.js +36 -0
  101. package/dist/database/entities/password.entity.js.map +1 -0
  102. package/dist/database/entities/refresh-token.entity.d.ts +9 -0
  103. package/dist/database/entities/refresh-token.entity.js +53 -0
  104. package/dist/database/entities/refresh-token.entity.js.map +1 -0
  105. package/dist/database/entities/session.entity.d.ts +20 -0
  106. package/dist/database/entities/session.entity.js +87 -0
  107. package/dist/database/entities/session.entity.js.map +1 -0
  108. package/dist/database/entities/settings.entity.d.ts +7 -0
  109. package/dist/database/entities/settings.entity.js +41 -0
  110. package/dist/database/entities/settings.entity.js.map +1 -0
  111. package/dist/database/entities/sign-in-challenge.entity.d.ts +23 -0
  112. package/dist/database/entities/sign-in-challenge.entity.js +80 -0
  113. package/dist/database/entities/sign-in-challenge.entity.js.map +1 -0
  114. package/dist/database/entities/signing-key.entity.d.ts +11 -0
  115. package/dist/database/entities/signing-key.entity.js +54 -0
  116. package/dist/database/entities/signing-key.entity.js.map +1 -0
  117. package/dist/database/entities/social-account.entity.d.ts +13 -0
  118. package/dist/database/entities/social-account.entity.js +54 -0
  119. package/dist/database/entities/social-account.entity.js.map +1 -0
  120. package/dist/database/entities/two-factor-secret.entity.d.ts +10 -0
  121. package/dist/database/entities/two-factor-secret.entity.js +48 -0
  122. package/dist/database/entities/two-factor-secret.entity.js.map +1 -0
  123. package/dist/database/entities/user.entity.d.ts +34 -0
  124. package/dist/database/entities/user.entity.js +129 -0
  125. package/dist/database/entities/user.entity.js.map +1 -0
  126. package/dist/database/entities/webhook-delivery.entity.d.ts +17 -0
  127. package/dist/database/entities/webhook-delivery.entity.js +79 -0
  128. package/dist/database/entities/webhook-delivery.entity.js.map +1 -0
  129. package/dist/database/entities/webhook.entity.d.ts +12 -0
  130. package/dist/database/entities/webhook.entity.js +58 -0
  131. package/dist/database/entities/webhook.entity.js.map +1 -0
  132. package/dist/database/typeorm-row.d.ts +21 -0
  133. package/dist/database/typeorm-row.js +29 -0
  134. package/dist/database/typeorm-row.js.map +1 -0
  135. package/dist/features/account/account.controller.d.ts +259 -0
  136. package/dist/features/account/account.controller.js +372 -0
  137. package/dist/features/account/account.controller.js.map +1 -0
  138. package/dist/features/account/account.dto.d.ts +16 -0
  139. package/dist/features/account/account.dto.js +61 -0
  140. package/dist/features/account/account.dto.js.map +1 -0
  141. package/dist/features/account/data-export.service.d.ts +85 -0
  142. package/dist/features/account/data-export.service.js +125 -0
  143. package/dist/features/account/data-export.service.js.map +1 -0
  144. package/dist/features/account/health.service.d.ts +30 -0
  145. package/dist/features/account/health.service.js +59 -0
  146. package/dist/features/account/health.service.js.map +1 -0
  147. package/dist/features/admin/admin.controller.d.ts +382 -0
  148. package/dist/features/admin/admin.controller.js +623 -0
  149. package/dist/features/admin/admin.controller.js.map +1 -0
  150. package/dist/features/admin/admin.dto.d.ts +61 -0
  151. package/dist/features/admin/admin.dto.js +253 -0
  152. package/dist/features/admin/admin.dto.js.map +1 -0
  153. package/dist/features/admin/admin.service.d.ts +142 -0
  154. package/dist/features/admin/admin.service.js +227 -0
  155. package/dist/features/admin/admin.service.js.map +1 -0
  156. package/dist/features/api-keys/api-keys.service.d.ts +67 -0
  157. package/dist/features/api-keys/api-keys.service.js +144 -0
  158. package/dist/features/api-keys/api-keys.service.js.map +1 -0
  159. package/dist/features/email-change/email-change.controller.d.ts +38 -0
  160. package/dist/features/email-change/email-change.controller.js +85 -0
  161. package/dist/features/email-change/email-change.controller.js.map +1 -0
  162. package/dist/features/email-change/email-change.dto.d.ts +10 -0
  163. package/dist/features/email-change/email-change.dto.js +43 -0
  164. package/dist/features/email-change/email-change.dto.js.map +1 -0
  165. package/dist/features/email-change/email-change.service.d.ts +74 -0
  166. package/dist/features/email-change/email-change.service.js +179 -0
  167. package/dist/features/email-change/email-change.service.js.map +1 -0
  168. package/dist/features/email-links/email-verification.service.d.ts +46 -0
  169. package/dist/features/email-links/email-verification.service.js +94 -0
  170. package/dist/features/email-links/email-verification.service.js.map +1 -0
  171. package/dist/features/email-links/link-tokens.service.d.ts +44 -0
  172. package/dist/features/email-links/link-tokens.service.js +122 -0
  173. package/dist/features/email-links/link-tokens.service.js.map +1 -0
  174. package/dist/features/events/auth-events.service.d.ts +52 -0
  175. package/dist/features/events/auth-events.service.js +117 -0
  176. package/dist/features/events/auth-events.service.js.map +1 -0
  177. package/dist/features/maintenance/data-retention.service.d.ts +60 -0
  178. package/dist/features/maintenance/data-retention.service.js +182 -0
  179. package/dist/features/maintenance/data-retention.service.js.map +1 -0
  180. package/dist/features/notifications/notifications.service.d.ts +40 -0
  181. package/dist/features/notifications/notifications.service.js +94 -0
  182. package/dist/features/notifications/notifications.service.js.map +1 -0
  183. package/dist/features/one-time-codes/one-time-codes.service.d.ts +40 -0
  184. package/dist/features/one-time-codes/one-time-codes.service.js +102 -0
  185. package/dist/features/one-time-codes/one-time-codes.service.js.map +1 -0
  186. package/dist/features/organizations/organizations.controller.d.ts +220 -0
  187. package/dist/features/organizations/organizations.controller.js +337 -0
  188. package/dist/features/organizations/organizations.controller.js.map +1 -0
  189. package/dist/features/organizations/organizations.dto.d.ts +31 -0
  190. package/dist/features/organizations/organizations.dto.js +100 -0
  191. package/dist/features/organizations/organizations.dto.js.map +1 -0
  192. package/dist/features/organizations/organizations.service.d.ts +274 -0
  193. package/dist/features/organizations/organizations.service.js +481 -0
  194. package/dist/features/organizations/organizations.service.js.map +1 -0
  195. package/dist/features/passkeys/passkeys.controller.d.ts +92 -0
  196. package/dist/features/passkeys/passkeys.controller.js +183 -0
  197. package/dist/features/passkeys/passkeys.controller.js.map +1 -0
  198. package/dist/features/passkeys/passkeys.dto.d.ts +13 -0
  199. package/dist/features/passkeys/passkeys.dto.js +50 -0
  200. package/dist/features/passkeys/passkeys.dto.js.map +1 -0
  201. package/dist/features/passkeys/passkeys.service.d.ts +159 -0
  202. package/dist/features/passkeys/passkeys.service.js +350 -0
  203. package/dist/features/passkeys/passkeys.service.js.map +1 -0
  204. package/dist/features/passwordless/passwordless-auth.service.d.ts +152 -0
  205. package/dist/features/passwordless/passwordless-auth.service.js +304 -0
  206. package/dist/features/passwordless/passwordless-auth.service.js.map +1 -0
  207. package/dist/features/passwordless/passwordless.controller.d.ts +75 -0
  208. package/dist/features/passwordless/passwordless.controller.js +163 -0
  209. package/dist/features/passwordless/passwordless.controller.js.map +1 -0
  210. package/dist/features/passwordless/passwordless.dto.d.ts +29 -0
  211. package/dist/features/passwordless/passwordless.dto.js +101 -0
  212. package/dist/features/passwordless/passwordless.dto.js.map +1 -0
  213. package/dist/features/passwords/password-auth.service.d.ts +154 -0
  214. package/dist/features/passwords/password-auth.service.js +317 -0
  215. package/dist/features/passwords/password-auth.service.js.map +1 -0
  216. package/dist/features/passwords/password-policy.service.d.ts +63 -0
  217. package/dist/features/passwords/password-policy.service.js +175 -0
  218. package/dist/features/passwords/password-policy.service.js.map +1 -0
  219. package/dist/features/passwords/password.controller.d.ts +95 -0
  220. package/dist/features/passwords/password.controller.js +193 -0
  221. package/dist/features/passwords/password.controller.js.map +1 -0
  222. package/dist/features/passwords/password.dto.d.ts +36 -0
  223. package/dist/features/passwords/password.dto.js +140 -0
  224. package/dist/features/passwords/password.dto.js.map +1 -0
  225. package/dist/features/sessions/session.service.d.ts +132 -0
  226. package/dist/features/sessions/session.service.js +308 -0
  227. package/dist/features/sessions/session.service.js.map +1 -0
  228. package/dist/features/sessions/session.types.d.ts +34 -0
  229. package/dist/features/sessions/session.types.js +3 -0
  230. package/dist/features/sessions/session.types.js.map +1 -0
  231. package/dist/features/settings/settings.defaults.d.ts +2 -0
  232. package/dist/features/settings/settings.defaults.js +7 -0
  233. package/dist/features/settings/settings.defaults.js.map +1 -0
  234. package/dist/features/settings/settings.service.d.ts +44 -0
  235. package/dist/features/settings/settings.service.js +112 -0
  236. package/dist/features/settings/settings.service.js.map +1 -0
  237. package/dist/features/settings/settings.types.d.ts +133 -0
  238. package/dist/features/settings/settings.types.js +3 -0
  239. package/dist/features/settings/settings.types.js.map +1 -0
  240. package/dist/features/settings/settings.validation.d.ts +33 -0
  241. package/dist/features/settings/settings.validation.js +614 -0
  242. package/dist/features/settings/settings.validation.js.map +1 -0
  243. package/dist/features/sign-in/sign-in-challenges.service.d.ts +54 -0
  244. package/dist/features/sign-in/sign-in-challenges.service.js +104 -0
  245. package/dist/features/sign-in/sign-in-challenges.service.js.map +1 -0
  246. package/dist/features/sign-in/sign-in.service.d.ts +127 -0
  247. package/dist/features/sign-in/sign-in.service.js +248 -0
  248. package/dist/features/sign-in/sign-in.service.js.map +1 -0
  249. package/dist/features/sign-in/sign-in.types.d.ts +22 -0
  250. package/dist/features/sign-in/sign-in.types.js +3 -0
  251. package/dist/features/sign-in/sign-in.types.js.map +1 -0
  252. package/dist/features/signing-keys/jwks.controller.d.ts +17 -0
  253. package/dist/features/signing-keys/jwks.controller.js +51 -0
  254. package/dist/features/signing-keys/jwks.controller.js.map +1 -0
  255. package/dist/features/signing-keys/signing-keys.service.d.ts +67 -0
  256. package/dist/features/signing-keys/signing-keys.service.js +142 -0
  257. package/dist/features/signing-keys/signing-keys.service.js.map +1 -0
  258. package/dist/features/social/social-auth.service.d.ts +100 -0
  259. package/dist/features/social/social-auth.service.js +232 -0
  260. package/dist/features/social/social-auth.service.js.map +1 -0
  261. package/dist/features/social/social-providers.service.d.ts +97 -0
  262. package/dist/features/social/social-providers.service.js +214 -0
  263. package/dist/features/social/social-providers.service.js.map +1 -0
  264. package/dist/features/social/social.controller.d.ts +54 -0
  265. package/dist/features/social/social.controller.js +124 -0
  266. package/dist/features/social/social.controller.js.map +1 -0
  267. package/dist/features/social/social.dto.d.ts +11 -0
  268. package/dist/features/social/social.dto.js +38 -0
  269. package/dist/features/social/social.dto.js.map +1 -0
  270. package/dist/features/two-factor/two-factor.controller.d.ts +84 -0
  271. package/dist/features/two-factor/two-factor.controller.js +174 -0
  272. package/dist/features/two-factor/two-factor.controller.js.map +1 -0
  273. package/dist/features/two-factor/two-factor.dto.d.ts +10 -0
  274. package/dist/features/two-factor/two-factor.dto.js +37 -0
  275. package/dist/features/two-factor/two-factor.dto.js.map +1 -0
  276. package/dist/features/two-factor/two-factor.service.d.ts +171 -0
  277. package/dist/features/two-factor/two-factor.service.js +348 -0
  278. package/dist/features/two-factor/two-factor.service.js.map +1 -0
  279. package/dist/features/users/sign-in-methods.service.d.ts +40 -0
  280. package/dist/features/users/sign-in-methods.service.js +81 -0
  281. package/dist/features/users/sign-in-methods.service.js.map +1 -0
  282. package/dist/features/users/sign-up-rules.d.ts +12 -0
  283. package/dist/features/users/sign-up-rules.js +29 -0
  284. package/dist/features/users/sign-up-rules.js.map +1 -0
  285. package/dist/features/users/users.service.d.ts +246 -0
  286. package/dist/features/users/users.service.js +509 -0
  287. package/dist/features/users/users.service.js.map +1 -0
  288. package/dist/features/users/users.types.d.ts +24 -0
  289. package/dist/features/users/users.types.js +3 -0
  290. package/dist/features/users/users.types.js.map +1 -0
  291. package/dist/features/webhooks/webhook-delivery.worker.d.ts +55 -0
  292. package/dist/features/webhooks/webhook-delivery.worker.js +175 -0
  293. package/dist/features/webhooks/webhook-delivery.worker.js.map +1 -0
  294. package/dist/features/webhooks/webhook-signature.d.ts +28 -0
  295. package/dist/features/webhooks/webhook-signature.js +85 -0
  296. package/dist/features/webhooks/webhook-signature.js.map +1 -0
  297. package/dist/features/webhooks/webhooks.service.d.ts +144 -0
  298. package/dist/features/webhooks/webhooks.service.js +238 -0
  299. package/dist/features/webhooks/webhooks.service.js.map +1 -0
  300. package/dist/guards/auth.decorators.d.ts +65 -0
  301. package/dist/guards/auth.decorators.js +68 -0
  302. package/dist/guards/auth.decorators.js.map +1 -0
  303. package/dist/guards/auth.guard.d.ts +47 -0
  304. package/dist/guards/auth.guard.js +132 -0
  305. package/dist/guards/auth.guard.js.map +1 -0
  306. package/dist/index.d.ts +38 -0
  307. package/dist/index.js +95 -0
  308. package/dist/index.js.map +1 -0
  309. package/dist/integrations/console-email-sender.d.ts +15 -0
  310. package/dist/integrations/console-email-sender.js +26 -0
  311. package/dist/integrations/console-email-sender.js.map +1 -0
  312. package/dist/integrations/msg91-sms-sender.d.ts +28 -0
  313. package/dist/integrations/msg91-sms-sender.js +46 -0
  314. package/dist/integrations/msg91-sms-sender.js.map +1 -0
  315. package/docs/README.md +39 -0
  316. package/docs/admin-api-keys-webhooks.md +147 -0
  317. package/docs/api-reference.md +175 -0
  318. package/docs/architecture.md +119 -0
  319. package/docs/client-integration.md +192 -0
  320. package/docs/code-walkthrough.md +273 -0
  321. package/docs/configuration.md +229 -0
  322. package/docs/endpoints/README.md +151 -0
  323. package/docs/endpoints/account.md +363 -0
  324. package/docs/endpoints/admin.md +422 -0
  325. package/docs/endpoints/email-password.md +261 -0
  326. package/docs/endpoints/organizations.md +192 -0
  327. package/docs/endpoints/passkeys.md +195 -0
  328. package/docs/endpoints/passwordless.md +214 -0
  329. package/docs/endpoints/social.md +116 -0
  330. package/docs/endpoints/two-factor.md +146 -0
  331. package/docs/error-codes.md +100 -0
  332. package/docs/events.md +83 -0
  333. package/docs/getting-started.md +139 -0
  334. package/docs/manual-testing.md +215 -0
  335. package/docs/organizations.md +86 -0
  336. package/docs/production-checklist.md +60 -0
  337. package/docs/protecting-routes.md +147 -0
  338. package/docs/security.md +61 -0
  339. package/docs/sign-in-flows.md +294 -0
  340. package/package.json +92 -4
@@ -0,0 +1,61 @@
1
+ import { AccountStatus } from '../../constants.js';
2
+ import type { JsonObject } from '../../database/entities/json-object.js';
3
+ /** Query string of GET /auth/admin/users */
4
+ export declare class SearchUsersQuery {
5
+ search?: string;
6
+ status?: AccountStatus;
7
+ role?: string;
8
+ page?: number;
9
+ pageSize?: number;
10
+ }
11
+ /** Query string of GET /auth/admin/audit-log */
12
+ export declare class SearchAuditLogQuery {
13
+ userId?: string;
14
+ eventName?: string;
15
+ page?: number;
16
+ pageSize?: number;
17
+ }
18
+ /** Query string for paged lists (webhook deliveries). */
19
+ export declare class PageQuery {
20
+ page?: number;
21
+ pageSize?: number;
22
+ }
23
+ /** PATCH /auth/admin/users/:userId */
24
+ export declare class AdminUpdateUserInput {
25
+ firstName?: string;
26
+ lastName?: string;
27
+ metadata?: JsonObject;
28
+ }
29
+ /** PUT /auth/admin/users/:userId/roles */
30
+ export declare class SetRolesInput {
31
+ roles: string[];
32
+ }
33
+ /** POST /auth/admin/users/:userId/suspend */
34
+ export declare class SuspendUserInput {
35
+ /** Kept for support staff; not shown to the user. */
36
+ reason: string;
37
+ }
38
+ /** POST /auth/admin/api-keys */
39
+ export declare class CreateApiKeyInput {
40
+ name: string;
41
+ /** What the key may do, e.g. ["rides:read"]. Your routes check them with @ApiKeyScopes(). */
42
+ scopes: string[];
43
+ organizationId?: string;
44
+ /** Optional expiry, ISO 8601, e.g. "2027-01-01T00:00:00Z". */
45
+ expiresAt?: string;
46
+ }
47
+ /** POST /auth/admin/webhooks */
48
+ export declare class CreateWebhookInput {
49
+ url: string;
50
+ /** Events to receive, e.g. ["user.created"]. Leave empty for all events. */
51
+ eventNames?: string[];
52
+ description?: string;
53
+ isEnabled?: boolean;
54
+ }
55
+ /** PATCH /auth/admin/webhooks/:webhookId */
56
+ export declare class UpdateWebhookInput {
57
+ url?: string;
58
+ eventNames?: string[];
59
+ description?: string;
60
+ isEnabled?: boolean;
61
+ }
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UpdateWebhookInput = exports.CreateWebhookInput = exports.CreateApiKeyInput = exports.SuspendUserInput = exports.SetRolesInput = exports.AdminUpdateUserInput = exports.PageQuery = exports.SearchAuditLogQuery = exports.SearchUsersQuery = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const constants_1 = require("../../constants.js");
16
+ /** Query string of GET /auth/admin/users */
17
+ class SearchUsersQuery {
18
+ search;
19
+ status;
20
+ role;
21
+ page;
22
+ pageSize;
23
+ }
24
+ exports.SearchUsersQuery = SearchUsersQuery;
25
+ __decorate([
26
+ (0, class_validator_1.IsOptional)(),
27
+ (0, class_validator_1.IsString)(),
28
+ (0, class_validator_1.MaxLength)(constants_1.DISPLAY_NAME_MAX_LENGTH),
29
+ __metadata("design:type", String)
30
+ ], SearchUsersQuery.prototype, "search", void 0);
31
+ __decorate([
32
+ (0, class_validator_1.IsOptional)(),
33
+ (0, class_validator_1.IsIn)(constants_1.ACCOUNT_STATUSES),
34
+ __metadata("design:type", String)
35
+ ], SearchUsersQuery.prototype, "status", void 0);
36
+ __decorate([
37
+ (0, class_validator_1.IsOptional)(),
38
+ (0, class_validator_1.IsString)(),
39
+ (0, class_validator_1.Matches)(constants_1.ROLE_NAME_PATTERN),
40
+ __metadata("design:type", String)
41
+ ], SearchUsersQuery.prototype, "role", void 0);
42
+ __decorate([
43
+ (0, class_validator_1.IsOptional)(),
44
+ (0, class_transformer_1.Type)(() => Number),
45
+ (0, class_validator_1.IsInt)(),
46
+ (0, class_validator_1.Min)(1),
47
+ __metadata("design:type", Number)
48
+ ], SearchUsersQuery.prototype, "page", void 0);
49
+ __decorate([
50
+ (0, class_validator_1.IsOptional)(),
51
+ (0, class_transformer_1.Type)(() => Number),
52
+ (0, class_validator_1.IsInt)(),
53
+ (0, class_validator_1.Min)(1),
54
+ (0, class_validator_1.Max)(constants_1.MAXIMUM_PAGE_SIZE),
55
+ __metadata("design:type", Number)
56
+ ], SearchUsersQuery.prototype, "pageSize", void 0);
57
+ /** Query string of GET /auth/admin/audit-log */
58
+ class SearchAuditLogQuery {
59
+ userId;
60
+ eventName;
61
+ page;
62
+ pageSize;
63
+ }
64
+ exports.SearchAuditLogQuery = SearchAuditLogQuery;
65
+ __decorate([
66
+ (0, class_validator_1.IsOptional)(),
67
+ (0, class_validator_1.IsUUID)(),
68
+ __metadata("design:type", String)
69
+ ], SearchAuditLogQuery.prototype, "userId", void 0);
70
+ __decorate([
71
+ (0, class_validator_1.IsOptional)(),
72
+ (0, class_validator_1.IsString)(),
73
+ (0, class_validator_1.MaxLength)(constants_1.DISPLAY_NAME_MAX_LENGTH),
74
+ __metadata("design:type", String)
75
+ ], SearchAuditLogQuery.prototype, "eventName", void 0);
76
+ __decorate([
77
+ (0, class_validator_1.IsOptional)(),
78
+ (0, class_transformer_1.Type)(() => Number),
79
+ (0, class_validator_1.IsInt)(),
80
+ (0, class_validator_1.Min)(1),
81
+ __metadata("design:type", Number)
82
+ ], SearchAuditLogQuery.prototype, "page", void 0);
83
+ __decorate([
84
+ (0, class_validator_1.IsOptional)(),
85
+ (0, class_transformer_1.Type)(() => Number),
86
+ (0, class_validator_1.IsInt)(),
87
+ (0, class_validator_1.Min)(1),
88
+ (0, class_validator_1.Max)(constants_1.MAXIMUM_PAGE_SIZE),
89
+ __metadata("design:type", Number)
90
+ ], SearchAuditLogQuery.prototype, "pageSize", void 0);
91
+ /** Query string for paged lists (webhook deliveries). */
92
+ class PageQuery {
93
+ page;
94
+ pageSize;
95
+ }
96
+ exports.PageQuery = PageQuery;
97
+ __decorate([
98
+ (0, class_validator_1.IsOptional)(),
99
+ (0, class_transformer_1.Type)(() => Number),
100
+ (0, class_validator_1.IsInt)(),
101
+ (0, class_validator_1.Min)(1),
102
+ __metadata("design:type", Number)
103
+ ], PageQuery.prototype, "page", void 0);
104
+ __decorate([
105
+ (0, class_validator_1.IsOptional)(),
106
+ (0, class_transformer_1.Type)(() => Number),
107
+ (0, class_validator_1.IsInt)(),
108
+ (0, class_validator_1.Min)(1),
109
+ (0, class_validator_1.Max)(constants_1.MAXIMUM_PAGE_SIZE),
110
+ __metadata("design:type", Number)
111
+ ], PageQuery.prototype, "pageSize", void 0);
112
+ /** PATCH /auth/admin/users/:userId */
113
+ class AdminUpdateUserInput {
114
+ firstName;
115
+ lastName;
116
+ metadata;
117
+ }
118
+ exports.AdminUpdateUserInput = AdminUpdateUserInput;
119
+ __decorate([
120
+ (0, class_validator_1.IsOptional)(),
121
+ (0, class_validator_1.IsString)(),
122
+ (0, class_validator_1.MaxLength)(constants_1.DISPLAY_NAME_MAX_LENGTH),
123
+ __metadata("design:type", String)
124
+ ], AdminUpdateUserInput.prototype, "firstName", void 0);
125
+ __decorate([
126
+ (0, class_validator_1.IsOptional)(),
127
+ (0, class_validator_1.IsString)(),
128
+ (0, class_validator_1.MaxLength)(constants_1.DISPLAY_NAME_MAX_LENGTH),
129
+ __metadata("design:type", String)
130
+ ], AdminUpdateUserInput.prototype, "lastName", void 0);
131
+ __decorate([
132
+ (0, class_validator_1.IsOptional)(),
133
+ (0, class_validator_1.IsObject)(),
134
+ __metadata("design:type", Object)
135
+ ], AdminUpdateUserInput.prototype, "metadata", void 0);
136
+ /** PUT /auth/admin/users/:userId/roles */
137
+ class SetRolesInput {
138
+ roles;
139
+ }
140
+ exports.SetRolesInput = SetRolesInput;
141
+ __decorate([
142
+ (0, class_validator_1.IsArray)(),
143
+ (0, class_validator_1.ArrayMaxSize)(constants_1.MAXIMUM_ROLES_PER_USER),
144
+ (0, class_validator_1.IsString)({ each: true }),
145
+ (0, class_validator_1.Matches)(constants_1.ROLE_NAME_PATTERN, { each: true }),
146
+ __metadata("design:type", Array)
147
+ ], SetRolesInput.prototype, "roles", void 0);
148
+ /** POST /auth/admin/users/:userId/suspend */
149
+ class SuspendUserInput {
150
+ /** Kept for support staff; not shown to the user. */
151
+ reason;
152
+ }
153
+ exports.SuspendUserInput = SuspendUserInput;
154
+ __decorate([
155
+ (0, class_validator_1.IsString)(),
156
+ (0, class_validator_1.MaxLength)(constants_1.SUSPENSION_REASON_MAX_LENGTH),
157
+ __metadata("design:type", String)
158
+ ], SuspendUserInput.prototype, "reason", void 0);
159
+ /** POST /auth/admin/api-keys */
160
+ class CreateApiKeyInput {
161
+ name;
162
+ /** What the key may do, e.g. ["rides:read"]. Your routes check them with @ApiKeyScopes(). */
163
+ scopes;
164
+ organizationId;
165
+ /** Optional expiry, ISO 8601, e.g. "2027-01-01T00:00:00Z". */
166
+ expiresAt;
167
+ }
168
+ exports.CreateApiKeyInput = CreateApiKeyInput;
169
+ __decorate([
170
+ (0, class_validator_1.IsString)(),
171
+ (0, class_validator_1.MaxLength)(constants_1.API_KEY_NAME_MAX_LENGTH),
172
+ __metadata("design:type", String)
173
+ ], CreateApiKeyInput.prototype, "name", void 0);
174
+ __decorate([
175
+ (0, class_validator_1.IsArray)(),
176
+ (0, class_validator_1.ArrayMaxSize)(constants_1.MAXIMUM_API_KEY_SCOPES),
177
+ (0, class_validator_1.IsString)({ each: true }),
178
+ (0, class_validator_1.Matches)(constants_1.API_KEY_SCOPE_PATTERN, { each: true }),
179
+ __metadata("design:type", Array)
180
+ ], CreateApiKeyInput.prototype, "scopes", void 0);
181
+ __decorate([
182
+ (0, class_validator_1.IsOptional)(),
183
+ (0, class_validator_1.IsUUID)(),
184
+ __metadata("design:type", String)
185
+ ], CreateApiKeyInput.prototype, "organizationId", void 0);
186
+ __decorate([
187
+ (0, class_validator_1.IsOptional)(),
188
+ (0, class_validator_1.IsDateString)(),
189
+ __metadata("design:type", String)
190
+ ], CreateApiKeyInput.prototype, "expiresAt", void 0);
191
+ /** POST /auth/admin/webhooks */
192
+ class CreateWebhookInput {
193
+ url;
194
+ /** Events to receive, e.g. ["user.created"]. Leave empty for all events. */
195
+ eventNames;
196
+ description;
197
+ isEnabled;
198
+ }
199
+ exports.CreateWebhookInput = CreateWebhookInput;
200
+ __decorate([
201
+ (0, class_validator_1.IsString)(),
202
+ (0, class_validator_1.MaxLength)(constants_1.WEBHOOK_URL_MAX_LENGTH),
203
+ __metadata("design:type", String)
204
+ ], CreateWebhookInput.prototype, "url", void 0);
205
+ __decorate([
206
+ (0, class_validator_1.IsOptional)(),
207
+ (0, class_validator_1.IsArray)(),
208
+ (0, class_validator_1.IsString)({ each: true }),
209
+ __metadata("design:type", Array)
210
+ ], CreateWebhookInput.prototype, "eventNames", void 0);
211
+ __decorate([
212
+ (0, class_validator_1.IsOptional)(),
213
+ (0, class_validator_1.IsString)(),
214
+ (0, class_validator_1.MaxLength)(constants_1.WEBHOOK_DESCRIPTION_MAX_LENGTH),
215
+ __metadata("design:type", String)
216
+ ], CreateWebhookInput.prototype, "description", void 0);
217
+ __decorate([
218
+ (0, class_validator_1.IsOptional)(),
219
+ (0, class_validator_1.IsBoolean)(),
220
+ __metadata("design:type", Boolean)
221
+ ], CreateWebhookInput.prototype, "isEnabled", void 0);
222
+ /** PATCH /auth/admin/webhooks/:webhookId */
223
+ class UpdateWebhookInput {
224
+ url;
225
+ eventNames;
226
+ description;
227
+ isEnabled;
228
+ }
229
+ exports.UpdateWebhookInput = UpdateWebhookInput;
230
+ __decorate([
231
+ (0, class_validator_1.IsOptional)(),
232
+ (0, class_validator_1.IsString)(),
233
+ (0, class_validator_1.MaxLength)(constants_1.WEBHOOK_URL_MAX_LENGTH),
234
+ __metadata("design:type", String)
235
+ ], UpdateWebhookInput.prototype, "url", void 0);
236
+ __decorate([
237
+ (0, class_validator_1.IsOptional)(),
238
+ (0, class_validator_1.IsArray)(),
239
+ (0, class_validator_1.IsString)({ each: true }),
240
+ __metadata("design:type", Array)
241
+ ], UpdateWebhookInput.prototype, "eventNames", void 0);
242
+ __decorate([
243
+ (0, class_validator_1.IsOptional)(),
244
+ (0, class_validator_1.IsString)(),
245
+ (0, class_validator_1.MaxLength)(constants_1.WEBHOOK_DESCRIPTION_MAX_LENGTH),
246
+ __metadata("design:type", String)
247
+ ], UpdateWebhookInput.prototype, "description", void 0);
248
+ __decorate([
249
+ (0, class_validator_1.IsOptional)(),
250
+ (0, class_validator_1.IsBoolean)(),
251
+ __metadata("design:type", Boolean)
252
+ ], UpdateWebhookInput.prototype, "isEnabled", void 0);
253
+ //# sourceMappingURL=admin.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.dto.js","sourceRoot":"","sources":["../../../src/features/admin/admin.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAeyB;AACzB,2CAaqB;AAGrB,4CAA4C;AAC5C,MAAa,gBAAgB;IAE3B,MAAM,CAAU;IAGhB,MAAM,CAAiB;IAGvB,IAAI,CAAU;IAGd,IAAI,CAAU;IAGd,QAAQ,CAAU;CACnB;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AS,GAAE;;qDACN;AAGtB,4CAA4C;AAC5C,MAAa,kBAAkB;IAE7B,GAAG,CAAU;IAGb,UAAU,CAAY;IAGtB,WAAW,CAAU;IAGrB,SAAS,CAAW;CACrB;AAZD,gDAYC;AAVC;IADC,IAAA,4BAAU,GAAE;IAAE,IAAA,0BAAQ,GAAE;IAAE,IAAA,2BAAS,EAAC,kCAAsB,CAAC;;+CAC/C;AAGb;IADC,IAAA,4BAAU,GAAE;IAAE,IAAA,yBAAO,GAAE;IAAE,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;sDAC5B;AAGtB;IADC,IAAA,4BAAU,GAAE;IAAE,IAAA,0BAAQ,GAAE;IAAE,IAAA,2BAAS,EAAC,0CAA8B,CAAC;;uDAC/C;AAGrB;IADC,IAAA,4BAAU,GAAE;IAAE,IAAA,2BAAS,GAAE;;qDACN"}
@@ -0,0 +1,142 @@
1
+ import { AuthOptions } from '../../auth-options.js';
2
+ import { RequestContext } from '../../common/request-context.js';
3
+ import { AccountStatus } from '../../constants.js';
4
+ import { AuditLogEntity } from '../../database/entities/index.js';
5
+ import { AuthEventsService } from '../events/auth-events.service.js';
6
+ import { SessionService } from '../sessions/session.service.js';
7
+ import { SettingsService } from '../settings/settings.service.js';
8
+ import { AuthSettings, SettingsChanges } from '../settings/settings.types.js';
9
+ import { SignInMethodsService } from '../users/sign-in-methods.service.js';
10
+ import { UsersService } from '../users/users.service.js';
11
+ export interface UserSearch {
12
+ /** Matches email, phone number, first or last name (partial, case-insensitive). */
13
+ search?: string;
14
+ status?: AccountStatus;
15
+ role?: string;
16
+ page?: number;
17
+ pageSize?: number;
18
+ }
19
+ export interface AuditLogSearch {
20
+ userId?: string;
21
+ eventName?: string;
22
+ page?: number;
23
+ pageSize?: number;
24
+ }
25
+ /** Read-heavy admin operations. Changes to a single user go through UsersService, so the rules stay in one place. */
26
+ export declare class AdminService {
27
+ private readonly settingsService;
28
+ private readonly users;
29
+ private readonly sessions;
30
+ private readonly signInMethods;
31
+ private readonly events;
32
+ private readonly database;
33
+ constructor(options: AuthOptions, settingsService: SettingsService, users: UsersService, sessions: SessionService, signInMethods: SignInMethodsService, events: AuthEventsService);
34
+ /**
35
+ * Paged user list with search and filters. Deleted accounts are excluded unless asked for
36
+ * with `status: "DELETED"`.
37
+ *
38
+ * @param filters - Search text, status, role, page and page size.
39
+ * @returns One page of public profiles, plus the total number of matches.
40
+ */
41
+ searchUsers(filters: UserSearch): Promise<{
42
+ success: true;
43
+ users: import("../..").PublicUserProfile[];
44
+ total: number;
45
+ page: number;
46
+ pageSize: number;
47
+ }>;
48
+ /**
49
+ * Everything support staff need about one user: profile, suspension reason, sign-in methods, devices.
50
+ *
51
+ * @param userId - The user.
52
+ * @returns The profile and the extra details.
53
+ * @throws AuthError NOT_FOUND when the user doesn't exist.
54
+ */
55
+ getUserDetails(userId: string): Promise<{
56
+ success: true;
57
+ user: import("../..").PublicUserProfile;
58
+ suspensionReason: string | null;
59
+ statusChangedAt: string | null;
60
+ termsAcceptedAt: string | null;
61
+ privacyPolicyAcceptedAt: string | null;
62
+ signInMethods: import("../users/sign-in-methods.service.js").UserSignInMethods;
63
+ sessions: {
64
+ id: string;
65
+ signInMethod: string;
66
+ ipAddress: string | null;
67
+ userAgent: string | null;
68
+ createdAt: string;
69
+ lastUsedAt: string;
70
+ }[];
71
+ }>;
72
+ /**
73
+ * Paged security history, newest first.
74
+ *
75
+ * @param filters - Optional user id and event name, plus page and page size.
76
+ * @returns One page of audit log entries, plus the total number of matches.
77
+ */
78
+ searchAuditLog(filters: AuditLogSearch): Promise<{
79
+ success: true;
80
+ entries: AuditLogEntity[];
81
+ total: number;
82
+ page: number;
83
+ pageSize: number;
84
+ }>;
85
+ /**
86
+ * @returns The settings in force: the code settings with any admin changes on top.
87
+ */
88
+ getSettings(): Promise<{
89
+ success: true;
90
+ settings: AuthSettings;
91
+ }>;
92
+ /**
93
+ * Saves admin changes on top of the code settings. Takes effect on every server within seconds.
94
+ *
95
+ * @param changes - Only the sections and fields to change.
96
+ * @param adminUserId - The admin doing it (for the audit log).
97
+ * @param request - Who is asking.
98
+ * @returns The settings now in force.
99
+ * @throws AuthError INVALID_SETTINGS when a value is not allowed.
100
+ */
101
+ changeSettings(changes: SettingsChanges, adminUserId: string, request: RequestContext): Promise<{
102
+ success: true;
103
+ settings: AuthSettings;
104
+ }>;
105
+ /**
106
+ * Throws away all admin changes, back to the settings in code.
107
+ *
108
+ * @param adminUserId - The admin doing it (for the audit log).
109
+ * @param request - Who is asking.
110
+ * @returns The settings now in force.
111
+ */
112
+ resetSettings(adminUserId: string, request: RequestContext): Promise<{
113
+ success: true;
114
+ settings: AuthSettings;
115
+ }>;
116
+ /**
117
+ * Numbers for an admin dashboard or monitoring: accounts by status, signed-in devices, and what
118
+ * happened in the last 24 hours (from the audit log, so it covers every server).
119
+ *
120
+ * @returns The counts and when they were generated.
121
+ */
122
+ getStats(): Promise<{
123
+ success: true;
124
+ usersByStatus: {
125
+ [k: string]: number;
126
+ };
127
+ activeSessions: number;
128
+ last24Hours: {
129
+ [k: string]: number;
130
+ };
131
+ pendingWebhookDeliveries: number;
132
+ generatedAt: string;
133
+ }>;
134
+ /**
135
+ * Turns the requested page and page size into safe values (at least 1, at most MAXIMUM_PAGE_SIZE).
136
+ *
137
+ * @param requestedPage - 1-based page number.
138
+ * @param requestedPageSize - Rows per page.
139
+ * @returns The clean page, page size, and how many rows to skip.
140
+ */
141
+ private paging;
142
+ }