@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,481 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.OrganizationsService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const typeorm_1 = require("typeorm");
18
+ const auth_error_1 = require("../../common/auth-error.js");
19
+ const random_secrets_1 = require("../../common/crypto/random-secrets.js");
20
+ const identifiers_1 = require("../../common/identifiers.js");
21
+ const constants_1 = require("../../constants.js");
22
+ const entities_1 = require("../../database/entities/index.js");
23
+ const auth_events_service_1 = require("../events/auth-events.service.js");
24
+ const notifications_service_1 = require("../notifications/notifications.service.js");
25
+ const session_service_1 = require("../sessions/session.service.js");
26
+ const settings_service_1 = require("../settings/settings.service.js");
27
+ /**
28
+ * Organizations (companies, teams, workspaces) and their members.
29
+ *
30
+ * Roles inside an organization:
31
+ * owner - everything, including deleting the organization and managing other owners
32
+ * admin - manage members and invitations (but not owners)
33
+ * member - belongs to the organization
34
+ *
35
+ * A user picks the organization they are working in with switchActiveOrganization(); their access
36
+ * token then carries "org_id" and "org_role", so your API can scope data with one check.
37
+ */
38
+ let OrganizationsService = class OrganizationsService {
39
+ settingsService;
40
+ sessions;
41
+ notifications;
42
+ events;
43
+ database;
44
+ constructor(options, settingsService, sessions, notifications, events) {
45
+ this.settingsService = settingsService;
46
+ this.sessions = sessions;
47
+ this.notifications = notifications;
48
+ this.events = events;
49
+ this.database = options.dataSource;
50
+ }
51
+ // -------------------------------------------------------------------------------------------
52
+ // Organizations
53
+ // -------------------------------------------------------------------------------------------
54
+ /**
55
+ * Creates an organization; the creator becomes its owner.
56
+ *
57
+ * @param userId - The creator.
58
+ * @param details - Name and URL-friendly slug.
59
+ * @param isAppAdmin - Lets app admins create one even when users may not.
60
+ * @param request - Who is asking (for the audit log).
61
+ * @returns The new organization.
62
+ * @throws AuthError FORBIDDEN when users may not create organizations.
63
+ * @throws AuthError ORGANIZATION_SLUG_TAKEN when the slug is in use.
64
+ * @throws AuthError VALIDATION_ERROR when the user is already in too many organizations.
65
+ */
66
+ async createOrganization(userId, details, isAppAdmin, request) {
67
+ const settings = await this.assertOrganizationsEnabled();
68
+ if (!settings.organizations.allowUsersToCreate && !isAppAdmin)
69
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.forbidden);
70
+ const membershipCount = await this.database.getRepository(entities_1.OrganizationMemberEntity).count({ where: { userId } });
71
+ if (membershipCount >= constants_1.MAXIMUM_ORGANIZATIONS_PER_USER)
72
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.validationFailed, { problems: [constants_1.VALIDATION_PROBLEM.tooManyOrganizations] });
73
+ const organization = await this.database.transaction(async (transaction) => {
74
+ const createdOrganization = await this.translateUniqueViolation(transaction.save(entities_1.OrganizationEntity, { name: details.name.trim(), slug: details.slug, metadata: {}, createdByUserId: userId }), constants_1.AUTH_ERRORS.organizationSlugTaken);
75
+ await transaction.insert(entities_1.OrganizationMemberEntity, { organizationId: createdOrganization.id, userId, role: constants_1.ORGANIZATION_ROLE.owner });
76
+ return createdOrganization;
77
+ });
78
+ await this.events.record({ name: constants_1.AUTH_EVENTS.organizationCreated, userId, request, details: { organizationId: organization.id } });
79
+ return organization;
80
+ }
81
+ /**
82
+ * The organizations the user belongs to, with their role in each.
83
+ *
84
+ * @param userId - The signed-in user.
85
+ * @returns The organizations, sorted by name.
86
+ */
87
+ async listMyOrganizations(userId) {
88
+ const rows = await this.database.query(`SELECT o.id, o.name, o.slug, o.metadata, m.role, m.created_at AS joined_at
89
+ FROM auth_organization_members m
90
+ JOIN auth_organizations o ON o.id = m.organization_id
91
+ WHERE m.user_id = $1
92
+ ORDER BY o.name`, [userId]);
93
+ return rows.map((row) => ({
94
+ id: row.id,
95
+ name: row.name,
96
+ slug: row.slug,
97
+ metadata: row.metadata,
98
+ role: row.role,
99
+ joinedAt: new Date(row.joined_at).toISOString(),
100
+ }));
101
+ }
102
+ /**
103
+ * @param organizationId - The organization.
104
+ * @param userId - The signed-in user, who must be a member.
105
+ * @returns The organization plus `myRole`.
106
+ * @throws AuthError NOT_FOUND when it doesn't exist or the user isn't a member.
107
+ */
108
+ async getOrganization(organizationId, userId) {
109
+ const membership = await this.requireRole(organizationId, userId, constants_1.ORGANIZATION_ROLE.member);
110
+ const organization = await this.database.getRepository(entities_1.OrganizationEntity).findOne({ where: { id: organizationId } });
111
+ if (!organization)
112
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.notFound);
113
+ return { ...organization, myRole: membership.role };
114
+ }
115
+ /**
116
+ * Changes the name, slug or metadata. Admins and owners only.
117
+ *
118
+ * @param organizationId - The organization.
119
+ * @param userId - The signed-in user.
120
+ * @param changes - The fields to change.
121
+ * @param request - Who is asking (for the audit log).
122
+ * @returns The updated organization.
123
+ * @throws AuthError FORBIDDEN for plain members.
124
+ * @throws AuthError ORGANIZATION_SLUG_TAKEN when the new slug is in use.
125
+ */
126
+ async updateOrganization(organizationId, userId, changes, request) {
127
+ await this.requireRole(organizationId, userId, constants_1.ORGANIZATION_ROLE.admin);
128
+ const repository = this.database.getRepository(entities_1.OrganizationEntity);
129
+ const organization = await repository.findOne({ where: { id: organizationId } });
130
+ if (!organization)
131
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.notFound);
132
+ if (changes.name !== undefined)
133
+ organization.name = changes.name.trim();
134
+ if (changes.slug !== undefined)
135
+ organization.slug = changes.slug;
136
+ if (changes.metadata !== undefined)
137
+ organization.metadata = changes.metadata;
138
+ const savedOrganization = await this.translateUniqueViolation(repository.save(organization), constants_1.AUTH_ERRORS.organizationSlugTaken);
139
+ await this.events.record({ name: constants_1.AUTH_EVENTS.organizationUpdated, userId, request, details: { organizationId } });
140
+ return savedOrganization;
141
+ }
142
+ /**
143
+ * Deletes the organization. Owners only. Members, invitations and API keys of the organization go with it.
144
+ *
145
+ * @param organizationId - The organization.
146
+ * @param userId - The signed-in user.
147
+ * @param request - Who is asking (for the audit log).
148
+ * @returns `{ success: true }`.
149
+ * @throws AuthError FORBIDDEN unless the user is an owner.
150
+ */
151
+ async deleteOrganization(organizationId, userId, request) {
152
+ await this.requireRole(organizationId, userId, constants_1.ORGANIZATION_ROLE.owner);
153
+ await this.database.getRepository(entities_1.OrganizationEntity).delete({ id: organizationId });
154
+ await this.events.record({ name: constants_1.AUTH_EVENTS.organizationDeleted, userId, request, details: { organizationId } });
155
+ return { success: true };
156
+ }
157
+ // -------------------------------------------------------------------------------------------
158
+ // Members
159
+ // -------------------------------------------------------------------------------------------
160
+ /**
161
+ * @param organizationId - The organization.
162
+ * @param userId - The signed-in user, who must be a member.
163
+ * @returns The members with their names, emails and roles, oldest first.
164
+ */
165
+ async listMembers(organizationId, userId) {
166
+ await this.requireRole(organizationId, userId, constants_1.ORGANIZATION_ROLE.member);
167
+ const rows = await this.database.query(`SELECT u.id AS user_id, u.email, u.first_name, u.last_name, m.role, m.created_at AS joined_at
168
+ FROM auth_organization_members m
169
+ JOIN auth_users u ON u.id = m.user_id
170
+ WHERE m.organization_id = $1
171
+ ORDER BY m.created_at`, [organizationId]);
172
+ return rows.map((row) => ({
173
+ userId: row.user_id,
174
+ email: row.email,
175
+ firstName: row.first_name,
176
+ lastName: row.last_name,
177
+ role: row.role,
178
+ joinedAt: new Date(row.joined_at).toISOString(),
179
+ }));
180
+ }
181
+ /**
182
+ * Changes a member's role. Admins manage members and admins; only owners can make or unmake owners.
183
+ *
184
+ * @param organizationId - The organization.
185
+ * @param actorUserId - The signed-in user doing it.
186
+ * @param targetUserId - The member whose role changes.
187
+ * @param newRole - "owner", "admin" or "member".
188
+ * @param request - Who is asking (for the audit log).
189
+ * @returns `{ success: true }`.
190
+ * @throws AuthError FORBIDDEN when the actor may not make this change.
191
+ * @throws AuthError LAST_OWNER when this would leave the organization without an owner.
192
+ */
193
+ async changeMemberRole(organizationId, actorUserId, targetUserId, newRole, request) {
194
+ const actor = await this.requireRole(organizationId, actorUserId, constants_1.ORGANIZATION_ROLE.admin);
195
+ const target = await this.findMembership(organizationId, targetUserId);
196
+ if (!target)
197
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.notFound);
198
+ this.assertMayManage(actor.role, target.role, newRole);
199
+ if (target.role === constants_1.ORGANIZATION_ROLE.owner && newRole !== constants_1.ORGANIZATION_ROLE.owner)
200
+ await this.assertNotLastOwner(organizationId);
201
+ await this.database.getRepository(entities_1.OrganizationMemberEntity).update({ id: target.id }, { role: newRole });
202
+ await this.events.record({
203
+ name: constants_1.AUTH_EVENTS.organizationMemberRoleChanged,
204
+ userId: targetUserId,
205
+ performedBy: constants_1.PERFORMED_BY.user(actorUserId),
206
+ request,
207
+ details: { organizationId, previousRole: target.role, role: newRole },
208
+ });
209
+ return { success: true };
210
+ }
211
+ /**
212
+ * Removes a member. Anyone may leave by removing themselves (unless they are the last owner).
213
+ * The member's devices stop working in this organization.
214
+ *
215
+ * @param organizationId - The organization.
216
+ * @param actorUserId - The signed-in user doing it.
217
+ * @param targetUserId - The member to remove (the actor themselves to leave).
218
+ * @param request - Who is asking (for the audit log).
219
+ * @returns `{ success: true }`.
220
+ * @throws AuthError FORBIDDEN when the actor may not remove this member.
221
+ * @throws AuthError LAST_OWNER when removing the last owner.
222
+ */
223
+ async removeMember(organizationId, actorUserId, targetUserId, request) {
224
+ const target = await this.findMembership(organizationId, targetUserId);
225
+ if (!target)
226
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.notFound);
227
+ if (actorUserId !== targetUserId) {
228
+ const actor = await this.requireRole(organizationId, actorUserId, constants_1.ORGANIZATION_ROLE.admin);
229
+ this.assertMayManage(actor.role, target.role, target.role);
230
+ }
231
+ if (target.role === constants_1.ORGANIZATION_ROLE.owner)
232
+ await this.assertNotLastOwner(organizationId);
233
+ await this.database.getRepository(entities_1.OrganizationMemberEntity).delete({ id: target.id });
234
+ await this.clearActiveOrganization(targetUserId, organizationId);
235
+ await this.events.record({
236
+ name: constants_1.AUTH_EVENTS.organizationMemberRemoved,
237
+ userId: targetUserId,
238
+ performedBy: constants_1.PERFORMED_BY.user(actorUserId),
239
+ request,
240
+ details: { organizationId },
241
+ });
242
+ return { success: true };
243
+ }
244
+ // -------------------------------------------------------------------------------------------
245
+ // Invitations
246
+ // -------------------------------------------------------------------------------------------
247
+ /**
248
+ * Emails an invitation link. The invited person accepts it after signing in with that email.
249
+ * A new invitation replaces any open one for the same email.
250
+ *
251
+ * @param organizationId - The organization.
252
+ * @param actorUserId - The signed-in user doing it.
253
+ * @param typedEmail - Who to invite.
254
+ * @param role - The role they get when they accept.
255
+ * @param request - Who is asking (for the audit log).
256
+ * @returns `{ success: true }`.
257
+ * @throws AuthError FORBIDDEN for plain members, or when an admin tries to invite an owner.
258
+ */
259
+ async inviteMember(organizationId, actorUserId, typedEmail, role, request) {
260
+ const settings = await this.assertOrganizationsEnabled();
261
+ const actor = await this.requireRole(organizationId, actorUserId, constants_1.ORGANIZATION_ROLE.admin);
262
+ this.assertMayManage(actor.role, constants_1.ORGANIZATION_ROLE.member, role);
263
+ const email = (0, identifiers_1.normalizeEmail)(typedEmail);
264
+ const organization = await this.database.getRepository(entities_1.OrganizationEntity).findOneOrFail({ where: { id: organizationId } });
265
+ const inviter = await this.database.getRepository(entities_1.UserEntity).findOne({ where: { id: actorUserId } });
266
+ const { plainToken, tokenHash } = (0, random_secrets_1.createRandomToken)(constants_1.TOKEN_PREFIX.organizationInvitation);
267
+ await this.database.transaction(async (transaction) => {
268
+ // A new invitation replaces any open one for the same email.
269
+ await transaction.update(entities_1.OrganizationInvitationEntity, { organizationId, email, acceptedAt: (0, typeorm_1.IsNull)(), revokedAt: (0, typeorm_1.IsNull)() }, { revokedAt: new Date() });
270
+ await transaction.insert(entities_1.OrganizationInvitationEntity, {
271
+ organizationId,
272
+ email,
273
+ role,
274
+ tokenHash,
275
+ invitedByUserId: actorUserId,
276
+ expiresAt: new Date(Date.now() + settings.organizations.invitationExpiresInDays * constants_1.DAY_IN_SECONDS * constants_1.SECOND_IN_MILLISECONDS),
277
+ });
278
+ });
279
+ await this.notifications.sendRequiredEmail({
280
+ type: constants_1.EMAIL_TYPE.organizationInvitation,
281
+ to: email,
282
+ token: plainToken,
283
+ organizationName: organization.name,
284
+ invitedByName: [inviter?.firstName, inviter?.lastName].filter(Boolean).join(constants_1.DISPLAY_NAME_SEPARATOR) || null,
285
+ });
286
+ await this.events.record({
287
+ name: constants_1.AUTH_EVENTS.organizationInvitationSent,
288
+ userId: actorUserId,
289
+ request,
290
+ details: { organizationId, role },
291
+ });
292
+ return { success: true };
293
+ }
294
+ /**
295
+ * @param organizationId - The organization.
296
+ * @param actorUserId - The signed-in user, who must be an admin or owner.
297
+ * @returns Open invitations (not accepted or revoked), newest first, without their token hashes.
298
+ */
299
+ async listInvitations(organizationId, actorUserId) {
300
+ await this.requireRole(organizationId, actorUserId, constants_1.ORGANIZATION_ROLE.admin);
301
+ const invitations = await this.database.getRepository(entities_1.OrganizationInvitationEntity).find({
302
+ where: { organizationId, acceptedAt: (0, typeorm_1.IsNull)(), revokedAt: (0, typeorm_1.IsNull)() },
303
+ order: { createdAt: constants_1.SORT_ORDER.newestFirst },
304
+ });
305
+ return invitations.map(({ tokenHash: _hiddenHash, ...invitation }) => invitation);
306
+ }
307
+ /**
308
+ * Cancels an open invitation; its link stops working.
309
+ *
310
+ * @param organizationId - The organization.
311
+ * @param actorUserId - The signed-in user doing it.
312
+ * @param invitationId - The invitation.
313
+ * @returns `{ success: true }`.
314
+ * @throws AuthError NOT_FOUND when there is no open invitation with this id.
315
+ */
316
+ async revokeInvitation(organizationId, actorUserId, invitationId) {
317
+ await this.requireRole(organizationId, actorUserId, constants_1.ORGANIZATION_ROLE.admin);
318
+ const result = await this.database
319
+ .getRepository(entities_1.OrganizationInvitationEntity)
320
+ .update({ id: invitationId, organizationId, acceptedAt: (0, typeorm_1.IsNull)(), revokedAt: (0, typeorm_1.IsNull)() }, { revokedAt: new Date() });
321
+ if (!result.affected)
322
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.notFound);
323
+ return { success: true };
324
+ }
325
+ /**
326
+ * Accepts an invitation. The signed-in user's VERIFIED email must be the invited email, so a
327
+ * forwarded or leaked link can't be used by someone else.
328
+ *
329
+ * @param userId - The signed-in user.
330
+ * @param invitationToken - The token from the invitation link.
331
+ * @param request - Who is asking (for the audit log).
332
+ * @returns The organization joined and the role given.
333
+ * @throws AuthError INVALID_TOKEN when the link is unknown, used, expired or for another email.
334
+ * @throws AuthError ALREADY_MEMBER when the user is already in the organization.
335
+ */
336
+ async acceptInvitation(userId, invitationToken, request) {
337
+ await this.assertOrganizationsEnabled();
338
+ if (!(0, random_secrets_1.hasRandomTokenFormat)(invitationToken, constants_1.TOKEN_PREFIX.organizationInvitation))
339
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.invalidOrExpiredLink);
340
+ const invitations = this.database.getRepository(entities_1.OrganizationInvitationEntity);
341
+ const invitation = await invitations.findOne({
342
+ where: { tokenHash: (0, random_secrets_1.sha256Hex)(invitationToken), acceptedAt: (0, typeorm_1.IsNull)(), revokedAt: (0, typeorm_1.IsNull)() },
343
+ });
344
+ if (!invitation || invitation.expiresAt.getTime() <= Date.now())
345
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.invalidOrExpiredLink);
346
+ const user = await this.database.getRepository(entities_1.UserEntity).findOne({ where: { id: userId } });
347
+ if (!user || user.email !== invitation.email || !user.isEmailVerified)
348
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.invalidOrExpiredLink);
349
+ await this.database.transaction(async (transaction) => {
350
+ const claimed = await transaction.update(entities_1.OrganizationInvitationEntity, { id: invitation.id, acceptedAt: (0, typeorm_1.IsNull)() }, { acceptedAt: new Date() });
351
+ if (!claimed.affected)
352
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.invalidOrExpiredLink);
353
+ await this.translateUniqueViolation(transaction.insert(entities_1.OrganizationMemberEntity, { organizationId: invitation.organizationId, userId, role: invitation.role }), constants_1.AUTH_ERRORS.alreadyOrganizationMember);
354
+ });
355
+ await this.events.record({
356
+ name: constants_1.AUTH_EVENTS.organizationMemberAdded,
357
+ userId,
358
+ request,
359
+ details: { organizationId: invitation.organizationId, role: invitation.role },
360
+ });
361
+ return { success: true, organizationId: invitation.organizationId, role: invitation.role };
362
+ }
363
+ // -------------------------------------------------------------------------------------------
364
+ // Active organization
365
+ // -------------------------------------------------------------------------------------------
366
+ /**
367
+ * Picks the organization this device works in. The new access token carries "org_id" and "org_role".
368
+ *
369
+ * @param userId - The signed-in user.
370
+ * @param sessionId - This device's session.
371
+ * @param organizationId - The organization to switch to, or null for none.
372
+ * @returns A new access token and its lifetime.
373
+ * @throws AuthError NOT_FOUND when the user isn't a member of that organization.
374
+ */
375
+ async switchActiveOrganization(userId, sessionId, organizationId) {
376
+ const settings = await this.assertOrganizationsEnabled();
377
+ if (organizationId)
378
+ await this.requireRole(organizationId, userId, constants_1.ORGANIZATION_ROLE.member);
379
+ const { accessToken, expiresIn } = await this.sessions.switchActiveOrganization(sessionId, organizationId, settings);
380
+ return { success: true, accessToken, expiresIn, organizationId };
381
+ }
382
+ // -------------------------------------------------------------------------------------------
383
+ /**
384
+ * @returns The current settings.
385
+ * @throws AuthError FEATURE_DISABLED when organizations are turned off.
386
+ */
387
+ async assertOrganizationsEnabled() {
388
+ const settings = await this.settingsService.getSettings();
389
+ if (!settings.organizations.enabled)
390
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.featureDisabled);
391
+ return settings;
392
+ }
393
+ /**
394
+ * @param organizationId - The organization.
395
+ * @param userId - The user.
396
+ * @returns The membership row, or null if the user isn't a member.
397
+ */
398
+ findMembership(organizationId, userId) {
399
+ return this.database.getRepository(entities_1.OrganizationMemberEntity).findOne({ where: { organizationId, userId } });
400
+ }
401
+ /**
402
+ * Checks that the user is a member with at least `minimumRole` (owner > admin > member).
403
+ *
404
+ * @param organizationId - The organization.
405
+ * @param userId - The user.
406
+ * @param minimumRole - The lowest role allowed.
407
+ * @returns The user's membership.
408
+ * @throws AuthError NOT_FOUND when the user is not a member (so outsiders can't probe which organizations exist).
409
+ * @throws AuthError FORBIDDEN when their role is too low.
410
+ */
411
+ async requireRole(organizationId, userId, minimumRole) {
412
+ await this.assertOrganizationsEnabled();
413
+ const membership = await this.findMembership(organizationId, userId);
414
+ // "Not found" rather than "forbidden", so outsiders can't probe which organizations exist.
415
+ if (!membership)
416
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.notFound);
417
+ if (constants_1.ORGANIZATION_ROLE_RANK[membership.role] < constants_1.ORGANIZATION_ROLE_RANK[minimumRole])
418
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.forbidden);
419
+ return membership;
420
+ }
421
+ /**
422
+ * Admins may act on members and admins; anything touching an owner needs an owner.
423
+ *
424
+ * @param actorRole - The role of the user making the change.
425
+ * @param currentRole - The target's role now.
426
+ * @param newRole - The target's role after the change.
427
+ * @throws AuthError FORBIDDEN when the actor may not make this change.
428
+ */
429
+ assertMayManage(actorRole, currentRole, newRole) {
430
+ const touchesOwner = currentRole === constants_1.ORGANIZATION_ROLE.owner || newRole === constants_1.ORGANIZATION_ROLE.owner;
431
+ if (touchesOwner && actorRole !== constants_1.ORGANIZATION_ROLE.owner)
432
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.forbidden);
433
+ }
434
+ /**
435
+ * @param organizationId - The organization.
436
+ * @throws AuthError LAST_OWNER when the organization has only one owner left.
437
+ */
438
+ async assertNotLastOwner(organizationId) {
439
+ const ownerCount = await this.database.getRepository(entities_1.OrganizationMemberEntity).count({ where: { organizationId, role: constants_1.ORGANIZATION_ROLE.owner } });
440
+ if (ownerCount <= 1)
441
+ throw new auth_error_1.AuthError(constants_1.AUTH_ERRORS.lastOrganizationOwner);
442
+ }
443
+ /**
444
+ * A removed member's devices stop working in that organization.
445
+ *
446
+ * @param userId - The removed member.
447
+ * @param organizationId - The organization they left.
448
+ */
449
+ async clearActiveOrganization(userId, organizationId) {
450
+ await this.database.query(`UPDATE auth_sessions SET active_organization_id = NULL WHERE user_id = $1 AND active_organization_id = $2`, [userId, organizationId]);
451
+ }
452
+ /**
453
+ * Runs a database write and turns a "duplicate value" error into a friendly AuthError.
454
+ *
455
+ * @param operation - The write to wait for.
456
+ * @param errorOnDuplicate - The error to throw when Postgres refuses a duplicate.
457
+ * @returns What the write returned.
458
+ * @throws AuthError `errorOnDuplicate` on a duplicate; any other error is re-thrown as is.
459
+ */
460
+ async translateUniqueViolation(operation, errorOnDuplicate) {
461
+ try {
462
+ return await operation;
463
+ }
464
+ catch (error) {
465
+ const code = error.code;
466
+ if (error instanceof typeorm_1.QueryFailedError && code === constants_1.POSTGRES_UNIQUE_VIOLATION_CODE)
467
+ throw new auth_error_1.AuthError(errorOnDuplicate);
468
+ throw error;
469
+ }
470
+ }
471
+ };
472
+ exports.OrganizationsService = OrganizationsService;
473
+ exports.OrganizationsService = OrganizationsService = __decorate([
474
+ (0, common_1.Injectable)(),
475
+ __param(0, (0, common_1.Inject)(constants_1.AUTH_OPTIONS_TOKEN)),
476
+ __metadata("design:paramtypes", [Object, settings_service_1.SettingsService,
477
+ session_service_1.SessionService,
478
+ notifications_service_1.NotificationsService,
479
+ auth_events_service_1.AuthEventsService])
480
+ ], OrganizationsService);
481
+ //# sourceMappingURL=organizations.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.service.js","sourceRoot":"","sources":["../../../src/features/organizations/organizations.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,qCAA+D;AAE/D,oDAAgD;AAChD,mEAAoG;AACpG,sDAAsD;AAEtD,2CAkBqB;AACrB,kDAK6B;AAC7B,+EAA0E;AAC1E,0FAAsF;AACtF,yEAAqE;AACrE,2EAAuE;AASvE;;;;;;;;;;GAUG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAKZ;IACA;IACA;IACA;IAPF,QAAQ,CAAa;IAEtC,YAC8B,OAAoB,EAC/B,eAAgC,EAChC,QAAwB,EACxB,aAAmC,EACnC,MAAyB;QAHzB,oBAAe,GAAf,eAAe,CAAiB;QAChC,aAAQ,GAAR,QAAQ,CAAgB;QACxB,kBAAa,GAAb,aAAa,CAAsB;QACnC,WAAM,GAAN,MAAM,CAAmB;QAE1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IACrC,CAAC;IAED,8FAA8F;IAC9F,gBAAgB;IAChB,8FAA8F;IAE9F;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,kBAAkB,CAAC,MAAc,EAAE,OAA6D,EAAE,UAAmB,EAAE,OAAuB;QAClJ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,0BAA0B,EAAE,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ED;;;;;;;OAOG;IACK,KAAK,CAAC,wBAAwB,CAAI,SAAqB,EAAE,gBAAqC;QACpG,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,GAAI,KAA8C,CAAC,IAAI,CAAC;YAClE,IAAI,KAAK,YAAY,0BAAgB,IAAI,IAAI,KAAK,0CAA8B;gBAAE,MAAM,IAAI,sBAAS,CAAC,gBAAgB,CAAC,CAAC;YACxH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AAjdY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,8BAAkB,CAAC,CAAA;6CACO,kCAAe;QACtB,gCAAc;QACT,4CAAoB;QAC3B,uCAAiB;GARjC,oBAAoB,CAidhC"}
@@ -0,0 +1,92 @@
1
+ import { RequestContext } from '../../common/request-context.js';
2
+ import { FinishPasskeyCeremonyInput, RenamePasskeyInput } from './passkeys.dto';
3
+ import { PasskeysService } from './passkeys.service';
4
+ /**
5
+ * Passkeys.
6
+ *
7
+ * POST /auth/passkeys/register/options signed in: start adding a passkey
8
+ * POST /auth/passkeys/register/verify signed in: finish adding it
9
+ * POST /auth/passkeys/sign-in/options start signing in with a passkey
10
+ * POST /auth/passkeys/sign-in/verify finish signing in
11
+ * GET /auth/passkeys list my passkeys
12
+ * PATCH /auth/passkeys/:id rename
13
+ * DELETE /auth/passkeys/:id remove
14
+ */
15
+ export declare class PasskeysController {
16
+ private readonly passkeys;
17
+ constructor(passkeys: PasskeysService);
18
+ /**
19
+ * POST /auth/passkeys/register/options — Starts adding a passkey.
20
+ *
21
+ * @param userId - From the access token.
22
+ * @returns Options for the device and a challenge token.
23
+ */
24
+ startRegistration(userId: string): Promise<{
25
+ success: true;
26
+ challengeToken: string;
27
+ options: import("@simplewebauthn/server").PublicKeyCredentialCreationOptionsJSON;
28
+ }>;
29
+ /**
30
+ * POST /auth/passkeys/register/verify — Finishes adding a passkey.
31
+ *
32
+ * @param userId - From the access token.
33
+ * @param body - `{ challengeToken, response, name? }`.
34
+ * @param request - Who is asking.
35
+ * @returns The saved passkey.
36
+ */
37
+ finishRegistration(userId: string, body: FinishPasskeyCeremonyInput, request: RequestContext): Promise<{
38
+ success: true;
39
+ passkey: import("./passkeys.service").PasskeySummary;
40
+ }>;
41
+ /**
42
+ * POST /auth/passkeys/sign-in/options — Starts signing in with a passkey. Public.
43
+ *
44
+ * @param request - Who is asking.
45
+ * @returns Options for the device and a challenge token.
46
+ */
47
+ startSignIn(request: RequestContext): Promise<{
48
+ success: true;
49
+ challengeToken: string;
50
+ options: import("@simplewebauthn/server").PublicKeyCredentialRequestOptionsJSON;
51
+ }>;
52
+ /**
53
+ * POST /auth/passkeys/sign-in/verify — Finishes signing in with a passkey. Public.
54
+ *
55
+ * @param body - `{ challengeToken, response }`.
56
+ * @param request - Who is asking.
57
+ * @returns Tokens.
58
+ */
59
+ finishSignIn(body: FinishPasskeyCeremonyInput, request: RequestContext): Promise<import("../..").SignInResult>;
60
+ /**
61
+ * GET /auth/passkeys — The signed-in user's passkeys.
62
+ *
63
+ * @param userId - From the access token.
64
+ * @returns The passkeys.
65
+ */
66
+ list(userId: string): Promise<{
67
+ success: boolean;
68
+ passkeys: import("./passkeys.service").PasskeySummary[];
69
+ }>;
70
+ /**
71
+ * PATCH /auth/passkeys/:passkeyId — Renames a passkey.
72
+ *
73
+ * @param userId - From the access token.
74
+ * @param passkeyId - From the URL.
75
+ * @param body - `{ name }`.
76
+ * @returns `{ success: true }`.
77
+ */
78
+ rename(userId: string, passkeyId: string, body: RenamePasskeyInput): Promise<{
79
+ success: true;
80
+ }>;
81
+ /**
82
+ * DELETE /auth/passkeys/:passkeyId — Removes a passkey.
83
+ *
84
+ * @param userId - From the access token.
85
+ * @param passkeyId - From the URL.
86
+ * @param request - Who is asking.
87
+ * @returns `{ success: true }`.
88
+ */
89
+ remove(userId: string, passkeyId: string, request: RequestContext): Promise<{
90
+ success: true;
91
+ }>;
92
+ }