@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,13 @@
1
+ import type { SocialProvider } from '../../constants.js';
2
+ export type { SocialProvider };
3
+ /** A Google, Apple or Facebook account linked to a user. One user can link several. */
4
+ export declare class SocialAccountEntity {
5
+ id: string;
6
+ userId: string;
7
+ provider: SocialProvider;
8
+ /** The provider's id for this person (Google "sub", Apple "sub", Facebook user id). Never changes. */
9
+ providerUserId: string;
10
+ /** Email the provider reported when linked (for display only). */
11
+ email: string | null;
12
+ createdAt: Date;
13
+ }
@@ -0,0 +1,54 @@
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.SocialAccountEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ /** A Google, Apple or Facebook account linked to a user. One user can link several. */
15
+ let SocialAccountEntity = class SocialAccountEntity {
16
+ id;
17
+ userId;
18
+ provider;
19
+ /** The provider's id for this person (Google "sub", Apple "sub", Facebook user id). Never changes. */
20
+ providerUserId;
21
+ /** Email the provider reported when linked (for display only). */
22
+ email;
23
+ createdAt;
24
+ };
25
+ exports.SocialAccountEntity = SocialAccountEntity;
26
+ __decorate([
27
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
28
+ __metadata("design:type", String)
29
+ ], SocialAccountEntity.prototype, "id", void 0);
30
+ __decorate([
31
+ (0, typeorm_1.Column)({ name: 'user_id', type: 'uuid' }),
32
+ __metadata("design:type", String)
33
+ ], SocialAccountEntity.prototype, "userId", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.Column)({ type: 'text' }),
36
+ __metadata("design:type", String)
37
+ ], SocialAccountEntity.prototype, "provider", void 0);
38
+ __decorate([
39
+ (0, typeorm_1.Column)({ name: 'provider_user_id', type: 'text' }),
40
+ __metadata("design:type", String)
41
+ ], SocialAccountEntity.prototype, "providerUserId", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
44
+ __metadata("design:type", Object)
45
+ ], SocialAccountEntity.prototype, "email", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
48
+ __metadata("design:type", Date)
49
+ ], SocialAccountEntity.prototype, "createdAt", void 0);
50
+ exports.SocialAccountEntity = SocialAccountEntity = __decorate([
51
+ (0, typeorm_1.Entity)('auth_social_accounts'),
52
+ (0, typeorm_1.Index)(['provider', 'providerUserId'], { unique: true })
53
+ ], SocialAccountEntity);
54
+ //# sourceMappingURL=social-account.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"social-account.entity.js","sourceRoot":"","sources":["../../../src/database/entities/social-account.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAI1F,uFAAuF;AAGhF,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAE9B,EAAE,CAAS;IAGX,MAAM,CAAS;IAGf,QAAQ,CAAiB;IAEzB,sGAAsG;IAEtG,cAAc,CAAS;IAEvB,kEAAkE;IAElE,KAAK,CAAgB;IAGrB,SAAS,CAAO;CACjB,CAAA;AApBY,kDAAmB;AAE9B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;+CACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAC3B;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDACA;AAIzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2DAC5B;AAIvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACpB;AAGrB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;sDAAC;8BAnBL,mBAAmB;IAF/B,IAAA,gBAAM,EAAC,sBAAsB,CAAC;IAC9B,IAAA,eAAK,EAAC,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GAC3C,mBAAmB,CAoB/B"}
@@ -0,0 +1,10 @@
1
+ /** The secret shared with a user's authenticator app. Encrypted, because we must read it to check codes. */
2
+ export declare class TwoFactorSecretEntity {
3
+ userId: string;
4
+ encryptedSecret: string;
5
+ /** Null while the user is still setting up (has not typed a first code). */
6
+ confirmedAt: Date | null;
7
+ /** The last 30-second step a code was accepted for; older codes are refused (no replay). */
8
+ lastUsedTimeStep: number | null;
9
+ createdAt: Date;
10
+ }
@@ -0,0 +1,48 @@
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.TwoFactorSecretEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ /** The secret shared with a user's authenticator app. Encrypted, because we must read it to check codes. */
15
+ let TwoFactorSecretEntity = class TwoFactorSecretEntity {
16
+ userId;
17
+ encryptedSecret;
18
+ /** Null while the user is still setting up (has not typed a first code). */
19
+ confirmedAt;
20
+ /** The last 30-second step a code was accepted for; older codes are refused (no replay). */
21
+ lastUsedTimeStep;
22
+ createdAt;
23
+ };
24
+ exports.TwoFactorSecretEntity = TwoFactorSecretEntity;
25
+ __decorate([
26
+ (0, typeorm_1.PrimaryColumn)({ name: 'user_id', type: 'uuid' }),
27
+ __metadata("design:type", String)
28
+ ], TwoFactorSecretEntity.prototype, "userId", void 0);
29
+ __decorate([
30
+ (0, typeorm_1.Column)({ name: 'encrypted_secret', type: 'text' }),
31
+ __metadata("design:type", String)
32
+ ], TwoFactorSecretEntity.prototype, "encryptedSecret", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.Column)({ name: 'confirmed_at', type: 'timestamptz', nullable: true }),
35
+ __metadata("design:type", Object)
36
+ ], TwoFactorSecretEntity.prototype, "confirmedAt", void 0);
37
+ __decorate([
38
+ (0, typeorm_1.Column)({ name: 'last_used_time_step', type: 'bigint', nullable: true, transformer: { to: (v) => v, from: (v) => (v === null ? null : Number(v)) } }),
39
+ __metadata("design:type", Object)
40
+ ], TwoFactorSecretEntity.prototype, "lastUsedTimeStep", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
43
+ __metadata("design:type", Date)
44
+ ], TwoFactorSecretEntity.prototype, "createdAt", void 0);
45
+ exports.TwoFactorSecretEntity = TwoFactorSecretEntity = __decorate([
46
+ (0, typeorm_1.Entity)('auth_two_factor_secrets')
47
+ ], TwoFactorSecretEntity);
48
+ //# sourceMappingURL=two-factor-secret.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"two-factor-secret.entity.js","sourceRoot":"","sources":["../../../src/database/entities/two-factor-secret.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0E;AAE1E,4GAA4G;AAErG,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEhC,MAAM,CAAS;IAGf,eAAe,CAAS;IAExB,4EAA4E;IAE5E,WAAW,CAAc;IAEzB,4FAA4F;IAE5F,gBAAgB,CAAgB;IAGhC,SAAS,CAAO;CACjB,CAAA;AAjBY,sDAAqB;AAEhC;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDAClC;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8DAC3B;AAIxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DAC7C;AAIzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC,CAAgB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAgB,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;;+DACnJ;AAGhC;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;wDAAC;gCAhBL,qBAAqB;IADjC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;GACrB,qBAAqB,CAiBjC"}
@@ -0,0 +1,34 @@
1
+ import { type AccountStatus } from '../../constants.js';
2
+ import type { JsonObject } from './json-object';
3
+ /**
4
+ * A person who can sign in. Every way of signing in (password, phone, Google, passkey...) points here.
5
+ * Your app keeps its own profile data in its own tables, linked by `UserEntity.id` (the token's "sub").
6
+ */
7
+ export declare class UserEntity {
8
+ id: string;
9
+ /** Stored in lower case. Null for users who only signed up with a phone number, or after deletion. */
10
+ email: string | null;
11
+ isEmailVerified: boolean;
12
+ /** E.164 format, e.g. +919876543210. */
13
+ phoneNumber: string | null;
14
+ isPhoneVerified: boolean;
15
+ firstName: string | null;
16
+ lastName: string | null;
17
+ /** App-wide roles, copied into every access token, e.g. ["user"]. */
18
+ roles: string[];
19
+ /** PENDING_VERIFICATION, ACTIVE, SUSPENDED, DEACTIVATED or DELETED. Only the backend changes it. */
20
+ status: AccountStatus;
21
+ /** Why an admin suspended the account (internal; never shown to the user). */
22
+ suspensionReason: string | null;
23
+ statusChangedAt: Date | null;
24
+ termsAcceptedAt: Date | null;
25
+ privacyPolicyAcceptedAt: Date | null;
26
+ /** Set by your app (AuthService.markOnboardingComplete) once the profile setup is done. */
27
+ onboardingCompletedAt: Date | null;
28
+ isTwoFactorEnabled: boolean;
29
+ /** Free-form data your app wants to keep with the user (shown to admins, never put secrets here). */
30
+ metadata: JsonObject;
31
+ lastSignedInAt: Date | null;
32
+ createdAt: Date;
33
+ updatedAt: Date;
34
+ }
@@ -0,0 +1,129 @@
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.UserEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const constants_1 = require("../../constants.js");
15
+ /**
16
+ * A person who can sign in. Every way of signing in (password, phone, Google, passkey...) points here.
17
+ * Your app keeps its own profile data in its own tables, linked by `UserEntity.id` (the token's "sub").
18
+ */
19
+ let UserEntity = class UserEntity {
20
+ id;
21
+ /** Stored in lower case. Null for users who only signed up with a phone number, or after deletion. */
22
+ email;
23
+ isEmailVerified;
24
+ /** E.164 format, e.g. +919876543210. */
25
+ phoneNumber;
26
+ isPhoneVerified;
27
+ firstName;
28
+ lastName;
29
+ /** App-wide roles, copied into every access token, e.g. ["user"]. */
30
+ roles;
31
+ /** PENDING_VERIFICATION, ACTIVE, SUSPENDED, DEACTIVATED or DELETED. Only the backend changes it. */
32
+ status;
33
+ /** Why an admin suspended the account (internal; never shown to the user). */
34
+ suspensionReason;
35
+ statusChangedAt;
36
+ termsAcceptedAt;
37
+ privacyPolicyAcceptedAt;
38
+ /** Set by your app (AuthService.markOnboardingComplete) once the profile setup is done. */
39
+ onboardingCompletedAt;
40
+ isTwoFactorEnabled;
41
+ /** Free-form data your app wants to keep with the user (shown to admins, never put secrets here). */
42
+ metadata;
43
+ lastSignedInAt;
44
+ createdAt;
45
+ updatedAt;
46
+ };
47
+ exports.UserEntity = UserEntity;
48
+ __decorate([
49
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
50
+ __metadata("design:type", String)
51
+ ], UserEntity.prototype, "id", void 0);
52
+ __decorate([
53
+ (0, typeorm_1.Index)({ unique: true, where: 'email IS NOT NULL' }),
54
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
55
+ __metadata("design:type", Object)
56
+ ], UserEntity.prototype, "email", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.Column)({ name: 'email_verified', type: 'boolean', default: false }),
59
+ __metadata("design:type", Boolean)
60
+ ], UserEntity.prototype, "isEmailVerified", void 0);
61
+ __decorate([
62
+ (0, typeorm_1.Index)({ unique: true, where: 'phone_number IS NOT NULL' }),
63
+ (0, typeorm_1.Column)({ name: 'phone_number', type: 'text', nullable: true }),
64
+ __metadata("design:type", Object)
65
+ ], UserEntity.prototype, "phoneNumber", void 0);
66
+ __decorate([
67
+ (0, typeorm_1.Column)({ name: 'phone_verified', type: 'boolean', default: false }),
68
+ __metadata("design:type", Boolean)
69
+ ], UserEntity.prototype, "isPhoneVerified", void 0);
70
+ __decorate([
71
+ (0, typeorm_1.Column)({ name: 'first_name', type: 'text', nullable: true }),
72
+ __metadata("design:type", Object)
73
+ ], UserEntity.prototype, "firstName", void 0);
74
+ __decorate([
75
+ (0, typeorm_1.Column)({ name: 'last_name', type: 'text', nullable: true }),
76
+ __metadata("design:type", Object)
77
+ ], UserEntity.prototype, "lastName", void 0);
78
+ __decorate([
79
+ (0, typeorm_1.Column)({ type: 'text', array: true, default: '{}' }),
80
+ __metadata("design:type", Array)
81
+ ], UserEntity.prototype, "roles", void 0);
82
+ __decorate([
83
+ (0, typeorm_1.Column)({ type: 'text', default: constants_1.ACCOUNT_STATUS.pendingVerification }),
84
+ __metadata("design:type", String)
85
+ ], UserEntity.prototype, "status", void 0);
86
+ __decorate([
87
+ (0, typeorm_1.Column)({ name: 'suspension_reason', type: 'text', nullable: true }),
88
+ __metadata("design:type", Object)
89
+ ], UserEntity.prototype, "suspensionReason", void 0);
90
+ __decorate([
91
+ (0, typeorm_1.Column)({ name: 'status_changed_at', type: 'timestamptz', nullable: true }),
92
+ __metadata("design:type", Object)
93
+ ], UserEntity.prototype, "statusChangedAt", void 0);
94
+ __decorate([
95
+ (0, typeorm_1.Column)({ name: 'terms_accepted_at', type: 'timestamptz', nullable: true }),
96
+ __metadata("design:type", Object)
97
+ ], UserEntity.prototype, "termsAcceptedAt", void 0);
98
+ __decorate([
99
+ (0, typeorm_1.Column)({ name: 'privacy_policy_accepted_at', type: 'timestamptz', nullable: true }),
100
+ __metadata("design:type", Object)
101
+ ], UserEntity.prototype, "privacyPolicyAcceptedAt", void 0);
102
+ __decorate([
103
+ (0, typeorm_1.Column)({ name: 'onboarding_completed_at', type: 'timestamptz', nullable: true }),
104
+ __metadata("design:type", Object)
105
+ ], UserEntity.prototype, "onboardingCompletedAt", void 0);
106
+ __decorate([
107
+ (0, typeorm_1.Column)({ name: 'two_factor_enabled', type: 'boolean', default: false }),
108
+ __metadata("design:type", Boolean)
109
+ ], UserEntity.prototype, "isTwoFactorEnabled", void 0);
110
+ __decorate([
111
+ (0, typeorm_1.Column)({ type: 'jsonb', default: {} }),
112
+ __metadata("design:type", Object)
113
+ ], UserEntity.prototype, "metadata", void 0);
114
+ __decorate([
115
+ (0, typeorm_1.Column)({ name: 'last_signed_in_at', type: 'timestamptz', nullable: true }),
116
+ __metadata("design:type", Object)
117
+ ], UserEntity.prototype, "lastSignedInAt", void 0);
118
+ __decorate([
119
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
120
+ __metadata("design:type", Date)
121
+ ], UserEntity.prototype, "createdAt", void 0);
122
+ __decorate([
123
+ (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
124
+ __metadata("design:type", Date)
125
+ ], UserEntity.prototype, "updatedAt", void 0);
126
+ exports.UserEntity = UserEntity = __decorate([
127
+ (0, typeorm_1.Entity)('auth_users')
128
+ ], UserEntity);
129
+ //# sourceMappingURL=user.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/database/entities/user.entity.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,17 @@
1
+ import { type WebhookDeliveryStatus } from '../../constants.js';
2
+ import type { JsonObject } from './json-object';
3
+ export type { WebhookDeliveryStatus };
4
+ /** One event to send to one webhook, with its retry state. */
5
+ export declare class WebhookDeliveryEntity {
6
+ id: string;
7
+ webhookId: string;
8
+ eventName: string;
9
+ payload: JsonObject;
10
+ status: WebhookDeliveryStatus;
11
+ attemptCount: number;
12
+ nextAttemptAt: Date;
13
+ lastResponseStatus: number | null;
14
+ lastError: string | null;
15
+ createdAt: Date;
16
+ deliveredAt: Date | null;
17
+ }
@@ -0,0 +1,79 @@
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.WebhookDeliveryEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const constants_1 = require("../../constants.js");
15
+ /** One event to send to one webhook, with its retry state. */
16
+ let WebhookDeliveryEntity = class WebhookDeliveryEntity {
17
+ id;
18
+ webhookId;
19
+ eventName;
20
+ payload;
21
+ status;
22
+ attemptCount;
23
+ nextAttemptAt;
24
+ lastResponseStatus;
25
+ lastError;
26
+ createdAt;
27
+ deliveredAt;
28
+ };
29
+ exports.WebhookDeliveryEntity = WebhookDeliveryEntity;
30
+ __decorate([
31
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
32
+ __metadata("design:type", String)
33
+ ], WebhookDeliveryEntity.prototype, "id", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.Index)(),
36
+ (0, typeorm_1.Column)({ name: 'webhook_id', type: 'uuid' }),
37
+ __metadata("design:type", String)
38
+ ], WebhookDeliveryEntity.prototype, "webhookId", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.Column)({ name: 'event_name', type: 'text' }),
41
+ __metadata("design:type", String)
42
+ ], WebhookDeliveryEntity.prototype, "eventName", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({ type: 'jsonb' }),
45
+ __metadata("design:type", Object)
46
+ ], WebhookDeliveryEntity.prototype, "payload", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.Column)({ type: 'text', default: constants_1.WEBHOOK_DELIVERY_STATUS.pending }),
49
+ __metadata("design:type", String)
50
+ ], WebhookDeliveryEntity.prototype, "status", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.Column)({ name: 'attempt_count', type: 'int', default: 0 }),
53
+ __metadata("design:type", Number)
54
+ ], WebhookDeliveryEntity.prototype, "attemptCount", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.Column)({ name: 'next_attempt_at', type: 'timestamptz' }),
57
+ __metadata("design:type", Date)
58
+ ], WebhookDeliveryEntity.prototype, "nextAttemptAt", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({ name: 'last_response_status', type: 'int', nullable: true }),
61
+ __metadata("design:type", Object)
62
+ ], WebhookDeliveryEntity.prototype, "lastResponseStatus", void 0);
63
+ __decorate([
64
+ (0, typeorm_1.Column)({ name: 'last_error', type: 'text', nullable: true }),
65
+ __metadata("design:type", Object)
66
+ ], WebhookDeliveryEntity.prototype, "lastError", void 0);
67
+ __decorate([
68
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
69
+ __metadata("design:type", Date)
70
+ ], WebhookDeliveryEntity.prototype, "createdAt", void 0);
71
+ __decorate([
72
+ (0, typeorm_1.Column)({ name: 'delivered_at', type: 'timestamptz', nullable: true }),
73
+ __metadata("design:type", Object)
74
+ ], WebhookDeliveryEntity.prototype, "deliveredAt", void 0);
75
+ exports.WebhookDeliveryEntity = WebhookDeliveryEntity = __decorate([
76
+ (0, typeorm_1.Entity)('auth_webhook_deliveries'),
77
+ (0, typeorm_1.Index)(['status', 'nextAttemptAt'])
78
+ ], WebhookDeliveryEntity);
79
+ //# sourceMappingURL=webhook-delivery.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-delivery.entity.js","sourceRoot":"","sources":["../../../src/database/entities/webhook-delivery.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAE1F,2CAAkF;AAIlF,8DAA8D;AAGvD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEhC,EAAE,CAAS;IAIX,SAAS,CAAS;IAGlB,SAAS,CAAS;IAGlB,OAAO,CAAa;IAGpB,MAAM,CAAwB;IAG9B,YAAY,CAAS;IAGrB,aAAa,CAAO;IAGpB,kBAAkB,CAAgB;IAGlC,SAAS,CAAgB;IAGzB,SAAS,CAAO;IAGhB,WAAW,CAAc;CAC1B,CAAA;AAlCY,sDAAqB;AAEhC;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;iDACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDAC3B;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDAC3B;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;sDACN;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mCAAuB,CAAC,OAAO,EAAE,CAAC;;qDACrC;AAG9B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;2DACtC;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BAC1C,IAAI;4DAAC;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iEACpC;AAGlC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wDACpC;AAGzB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;wDAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DAC7C;gCAjCd,qBAAqB;IAFjC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;IACjC,IAAA,eAAK,EAAC,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;GACtB,qBAAqB,CAkCjC"}
@@ -0,0 +1,12 @@
1
+ /** An address that receives events (user.created, user.signed_in...). */
2
+ export declare class WebhookEntity {
3
+ id: string;
4
+ url: string;
5
+ /** Events to send; empty means all events. */
6
+ eventNames: string[];
7
+ /** Secret used to sign each delivery so the receiver can trust it. Encrypted at rest. */
8
+ encryptedSigningSecret: string;
9
+ isEnabled: boolean;
10
+ description: string | null;
11
+ createdAt: Date;
12
+ }
@@ -0,0 +1,58 @@
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.WebhookEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ /** An address that receives events (user.created, user.signed_in...). */
15
+ let WebhookEntity = class WebhookEntity {
16
+ id;
17
+ url;
18
+ /** Events to send; empty means all events. */
19
+ eventNames;
20
+ /** Secret used to sign each delivery so the receiver can trust it. Encrypted at rest. */
21
+ encryptedSigningSecret;
22
+ isEnabled;
23
+ description;
24
+ createdAt;
25
+ };
26
+ exports.WebhookEntity = WebhookEntity;
27
+ __decorate([
28
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
29
+ __metadata("design:type", String)
30
+ ], WebhookEntity.prototype, "id", void 0);
31
+ __decorate([
32
+ (0, typeorm_1.Column)({ type: 'text' }),
33
+ __metadata("design:type", String)
34
+ ], WebhookEntity.prototype, "url", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.Column)({ name: 'event_names', type: 'text', array: true, default: '{}' }),
37
+ __metadata("design:type", Array)
38
+ ], WebhookEntity.prototype, "eventNames", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.Column)({ name: 'encrypted_signing_secret', type: 'text' }),
41
+ __metadata("design:type", String)
42
+ ], WebhookEntity.prototype, "encryptedSigningSecret", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({ name: 'is_enabled', type: 'boolean', default: true }),
45
+ __metadata("design:type", Boolean)
46
+ ], WebhookEntity.prototype, "isEnabled", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
49
+ __metadata("design:type", Object)
50
+ ], WebhookEntity.prototype, "description", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
53
+ __metadata("design:type", Date)
54
+ ], WebhookEntity.prototype, "createdAt", void 0);
55
+ exports.WebhookEntity = WebhookEntity = __decorate([
56
+ (0, typeorm_1.Entity)('auth_webhooks')
57
+ ], WebhookEntity);
58
+ //# sourceMappingURL=webhook.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.entity.js","sourceRoot":"","sources":["../../../src/database/entities/webhook.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAmF;AAEnF,yEAAyE;AAElE,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,EAAE,CAAS;IAGX,GAAG,CAAS;IAEZ,8CAA8C;IAE9C,UAAU,CAAW;IAErB,yFAAyF;IAEzF,sBAAsB,CAAS;IAG/B,SAAS,CAAU;IAGnB,WAAW,CAAgB;IAG3B,SAAS,CAAO;CACjB,CAAA;AAvBY,sCAAa;AAExB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;yCACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACb;AAIZ;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;iDACrD;AAIrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6DAC5B;AAG/B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;gDAC5C;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACd;AAG3B;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;gDAAC;wBAtBL,aAAa;IADzB,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,aAAa,CAuBzB"}
@@ -0,0 +1,21 @@
1
+ import type { QueryDeepPartialEntity } from 'typeorm';
2
+ /**
3
+ * Hands a row to TypeORM's insert() / update().
4
+ *
5
+ * Their parameter type (QueryDeepPartialEntity) recurses into every column, which fails for jsonb
6
+ * columns holding free-form JSON ("type instantiation is excessively deep"). The row is still
7
+ * checked here as Partial<Entity>, so a wrong column name or type is caught by the compiler.
8
+ *
9
+ * @param row - The columns to write.
10
+ * @returns The same object, typed for TypeORM.
11
+ * @example
12
+ * await repository.update({ id }, typeormRow<UserEntity>({ status, statusChangedAt: new Date() }));
13
+ */
14
+ export declare function typeormRow<Entity>(row: Partial<Entity>): QueryDeepPartialEntity<Entity>;
15
+ /**
16
+ * Same as `typeormRow`, for inserting several rows at once.
17
+ *
18
+ * @param rows - The rows to insert.
19
+ * @returns The same array, typed for TypeORM.
20
+ */
21
+ export declare function typeormRows<Entity>(rows: Partial<Entity>[]): QueryDeepPartialEntity<Entity>[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typeormRow = typeormRow;
4
+ exports.typeormRows = typeormRows;
5
+ /**
6
+ * Hands a row to TypeORM's insert() / update().
7
+ *
8
+ * Their parameter type (QueryDeepPartialEntity) recurses into every column, which fails for jsonb
9
+ * columns holding free-form JSON ("type instantiation is excessively deep"). The row is still
10
+ * checked here as Partial<Entity>, so a wrong column name or type is caught by the compiler.
11
+ *
12
+ * @param row - The columns to write.
13
+ * @returns The same object, typed for TypeORM.
14
+ * @example
15
+ * await repository.update({ id }, typeormRow<UserEntity>({ status, statusChangedAt: new Date() }));
16
+ */
17
+ function typeormRow(row) {
18
+ return row;
19
+ }
20
+ /**
21
+ * Same as `typeormRow`, for inserting several rows at once.
22
+ *
23
+ * @param rows - The rows to insert.
24
+ * @returns The same array, typed for TypeORM.
25
+ */
26
+ function typeormRows(rows) {
27
+ return rows;
28
+ }
29
+ //# sourceMappingURL=typeorm-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeorm-row.js","sourceRoot":"","sources":["../../src/database/typeorm-row.ts"],"names":[],"mappings":";;AAcA,gCAEC;AAQD,kCAEC;AAxBD;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU,CAAS,GAAoB;IACrD,OAAO,GAAqC,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAS,IAAuB;IACzD,OAAO,IAAwC,CAAC;AAClD,CAAC"}