@hed-hog/core 0.0.4

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 (935) hide show
  1. package/dist/auth/auth.controller.d.ts +167 -0
  2. package/dist/auth/auth.controller.d.ts.map +1 -0
  3. package/dist/auth/auth.controller.js +236 -0
  4. package/dist/auth/auth.controller.js.map +1 -0
  5. package/dist/auth/auth.module.d.ts +5 -0
  6. package/dist/auth/auth.module.d.ts.map +1 -0
  7. package/dist/auth/auth.module.js +116 -0
  8. package/dist/auth/auth.module.js.map +1 -0
  9. package/dist/auth/auth.service.d.ts +215 -0
  10. package/dist/auth/auth.service.d.ts.map +1 -0
  11. package/dist/auth/auth.service.js +493 -0
  12. package/dist/auth/auth.service.js.map +1 -0
  13. package/dist/auth/consts/body.d.ts +2 -0
  14. package/dist/auth/consts/body.d.ts.map +1 -0
  15. package/dist/auth/consts/body.js +32 -0
  16. package/dist/auth/consts/body.js.map +1 -0
  17. package/dist/auth/dto/change.dto.d.ts +7 -0
  18. package/dist/auth/dto/change.dto.d.ts.map +1 -0
  19. package/dist/auth/dto/change.dto.js +51 -0
  20. package/dist/auth/dto/change.dto.js.map +1 -0
  21. package/dist/auth/dto/create-user.dto.d.ts +12 -0
  22. package/dist/auth/dto/create-user.dto.d.ts.map +1 -0
  23. package/dist/auth/dto/create-user.dto.js +60 -0
  24. package/dist/auth/dto/create-user.dto.js.map +1 -0
  25. package/dist/auth/dto/email.dto.d.ts +6 -0
  26. package/dist/auth/dto/email.dto.d.ts.map +1 -0
  27. package/dist/auth/dto/email.dto.js +33 -0
  28. package/dist/auth/dto/email.dto.js.map +1 -0
  29. package/dist/auth/dto/forget.dto.d.ts +6 -0
  30. package/dist/auth/dto/forget.dto.d.ts.map +1 -0
  31. package/dist/auth/dto/forget.dto.js +29 -0
  32. package/dist/auth/dto/forget.dto.js.map +1 -0
  33. package/dist/auth/dto/login-with-code.dto.d.ts +6 -0
  34. package/dist/auth/dto/login-with-code.dto.d.ts.map +1 -0
  35. package/dist/auth/dto/login-with-code.dto.js +31 -0
  36. package/dist/auth/dto/login-with-code.dto.js.map +1 -0
  37. package/dist/auth/dto/login-with-recovery-code.d.ts +5 -0
  38. package/dist/auth/dto/login-with-recovery-code.d.ts.map +1 -0
  39. package/dist/auth/dto/login-with-recovery-code.js +26 -0
  40. package/dist/auth/dto/login-with-recovery-code.js.map +1 -0
  41. package/dist/auth/dto/login.dto.d.ts +8 -0
  42. package/dist/auth/dto/login.dto.d.ts.map +1 -0
  43. package/dist/auth/dto/login.dto.js +51 -0
  44. package/dist/auth/dto/login.dto.js.map +1 -0
  45. package/dist/auth/dto/resend-mfa-code.dto.d.ts +4 -0
  46. package/dist/auth/dto/resend-mfa-code.dto.d.ts.map +1 -0
  47. package/dist/auth/dto/resend-mfa-code.dto.js +21 -0
  48. package/dist/auth/dto/resend-mfa-code.dto.js.map +1 -0
  49. package/dist/auth/dto/reset.dto.d.ts +5 -0
  50. package/dist/auth/dto/reset.dto.d.ts.map +1 -0
  51. package/dist/auth/dto/reset.dto.js +29 -0
  52. package/dist/auth/dto/reset.dto.js.map +1 -0
  53. package/dist/auth/enums/multifactor-type.enum.d.ts +5 -0
  54. package/dist/auth/enums/multifactor-type.enum.d.ts.map +1 -0
  55. package/dist/auth/enums/multifactor-type.enum.js +9 -0
  56. package/dist/auth/enums/multifactor-type.enum.js.map +1 -0
  57. package/dist/auth/guards/auth.guard.d.ts +11 -0
  58. package/dist/auth/guards/auth.guard.d.ts.map +1 -0
  59. package/dist/auth/guards/auth.guard.js +65 -0
  60. package/dist/auth/guards/auth.guard.js.map +1 -0
  61. package/dist/challenge/challenge.module.d.ts +3 -0
  62. package/dist/challenge/challenge.module.d.ts.map +1 -0
  63. package/dist/challenge/challenge.module.js +33 -0
  64. package/dist/challenge/challenge.module.js.map +1 -0
  65. package/dist/challenge/challenge.service.d.ts +84 -0
  66. package/dist/challenge/challenge.service.d.ts.map +1 -0
  67. package/dist/challenge/challenge.service.js +288 -0
  68. package/dist/challenge/challenge.service.js.map +1 -0
  69. package/dist/core/core.controller.d.ts +44 -0
  70. package/dist/core/core.controller.d.ts.map +1 -0
  71. package/dist/core/core.controller.js +38 -0
  72. package/dist/core/core.controller.js.map +1 -0
  73. package/dist/core/core.module.d.ts +3 -0
  74. package/dist/core/core.module.d.ts.map +1 -0
  75. package/dist/core/core.module.js +28 -0
  76. package/dist/core/core.module.js.map +1 -0
  77. package/dist/core/core.service.d.ts +56 -0
  78. package/dist/core/core.service.d.ts.map +1 -0
  79. package/dist/core/core.service.js +320 -0
  80. package/dist/core/core.service.js.map +1 -0
  81. package/dist/core/system.controller.d.ts +44 -0
  82. package/dist/core/system.controller.d.ts.map +1 -0
  83. package/dist/core/system.controller.js +38 -0
  84. package/dist/core/system.controller.js.map +1 -0
  85. package/dist/core/system.module.d.ts +3 -0
  86. package/dist/core/system.module.d.ts.map +1 -0
  87. package/dist/core/system.module.js +28 -0
  88. package/dist/core/system.module.js.map +1 -0
  89. package/dist/core/system.service.d.ts +56 -0
  90. package/dist/core/system.service.d.ts.map +1 -0
  91. package/dist/core/system.service.js +320 -0
  92. package/dist/core/system.service.js.map +1 -0
  93. package/dist/core.module.d.ts +5 -0
  94. package/dist/core.module.d.ts.map +1 -0
  95. package/dist/core.module.js +101 -0
  96. package/dist/core.module.js.map +1 -0
  97. package/dist/dashboard/dashboard/dashboard.controller.d.ts +24 -0
  98. package/dist/dashboard/dashboard/dashboard.controller.d.ts.map +1 -0
  99. package/dist/dashboard/dashboard/dashboard.controller.js +88 -0
  100. package/dist/dashboard/dashboard/dashboard.controller.js.map +1 -0
  101. package/dist/dashboard/dashboard/dashboard.module.d.ts +3 -0
  102. package/dist/dashboard/dashboard/dashboard.module.d.ts.map +1 -0
  103. package/dist/dashboard/dashboard/dashboard.module.js +26 -0
  104. package/dist/dashboard/dashboard/dashboard.module.js.map +1 -0
  105. package/dist/dashboard/dashboard/dashboard.service.d.ts +32 -0
  106. package/dist/dashboard/dashboard/dashboard.service.d.ts.map +1 -0
  107. package/dist/dashboard/dashboard/dashboard.service.js +61 -0
  108. package/dist/dashboard/dashboard/dashboard.service.js.map +1 -0
  109. package/dist/dashboard/dashboard/dto/create.dto.d.ts +5 -0
  110. package/dist/dashboard/dashboard/dto/create.dto.d.ts.map +1 -0
  111. package/dist/dashboard/dashboard/dto/create.dto.js +23 -0
  112. package/dist/dashboard/dashboard/dto/create.dto.js.map +1 -0
  113. package/dist/dashboard/dashboard/dto/update.dto.d.ts +6 -0
  114. package/dist/dashboard/dashboard/dto/update.dto.d.ts.map +1 -0
  115. package/dist/dashboard/dashboard/dto/update.dto.js +9 -0
  116. package/dist/dashboard/dashboard/dto/update.dto.js.map +1 -0
  117. package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +24 -0
  118. package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts.map +1 -0
  119. package/dist/dashboard/dashboard-component/dashboard-component.controller.js +90 -0
  120. package/dist/dashboard/dashboard-component/dashboard-component.controller.js.map +1 -0
  121. package/dist/dashboard/dashboard-component/dashboard-component.module.d.ts +3 -0
  122. package/dist/dashboard/dashboard-component/dashboard-component.module.d.ts.map +1 -0
  123. package/dist/dashboard/dashboard-component/dashboard-component.module.js +26 -0
  124. package/dist/dashboard/dashboard-component/dashboard-component.module.js.map +1 -0
  125. package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +32 -0
  126. package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts.map +1 -0
  127. package/dist/dashboard/dashboard-component/dashboard-component.service.js +59 -0
  128. package/dist/dashboard/dashboard-component/dashboard-component.service.js.map +1 -0
  129. package/dist/dashboard/dashboard-component/dto/create.dto.d.ts +13 -0
  130. package/dist/dashboard/dashboard-component/dto/create.dto.d.ts.map +1 -0
  131. package/dist/dashboard/dashboard-component/dto/create.dto.js +59 -0
  132. package/dist/dashboard/dashboard-component/dto/create.dto.js.map +1 -0
  133. package/dist/dashboard/dashboard-component/dto/update.dto.d.ts +6 -0
  134. package/dist/dashboard/dashboard-component/dto/update.dto.d.ts.map +1 -0
  135. package/dist/dashboard/dashboard-component/dto/update.dto.js +9 -0
  136. package/dist/dashboard/dashboard-component/dto/update.dto.js.map +1 -0
  137. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +52 -0
  138. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts.map +1 -0
  139. package/dist/dashboard/dashboard-core/dashboard-core.controller.js +40 -0
  140. package/dist/dashboard/dashboard-core/dashboard-core.controller.js.map +1 -0
  141. package/dist/dashboard/dashboard-core/dashboard-core.module.d.ts +3 -0
  142. package/dist/dashboard/dashboard-core/dashboard-core.module.d.ts.map +1 -0
  143. package/dist/dashboard/dashboard-core/dashboard-core.module.js +26 -0
  144. package/dist/dashboard/dashboard-core/dashboard-core.module.js.map +1 -0
  145. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +52 -0
  146. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts.map +1 -0
  147. package/dist/dashboard/dashboard-core/dashboard-core.service.js +44 -0
  148. package/dist/dashboard/dashboard-core/dashboard-core.service.js.map +1 -0
  149. package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts +54 -0
  150. package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts.map +1 -0
  151. package/dist/dashboard/dashboard-item/dashboard-item.controller.js +88 -0
  152. package/dist/dashboard/dashboard-item/dashboard-item.controller.js.map +1 -0
  153. package/dist/dashboard/dashboard-item/dashboard-item.module.d.ts +3 -0
  154. package/dist/dashboard/dashboard-item/dashboard-item.module.d.ts.map +1 -0
  155. package/dist/dashboard/dashboard-item/dashboard-item.module.js +26 -0
  156. package/dist/dashboard/dashboard-item/dashboard-item.module.js.map +1 -0
  157. package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts +59 -0
  158. package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts.map +1 -0
  159. package/dist/dashboard/dashboard-item/dashboard-item.service.js +77 -0
  160. package/dist/dashboard/dashboard-item/dashboard-item.service.js.map +1 -0
  161. package/dist/dashboard/dashboard-item/dto/create.dto.d.ts +9 -0
  162. package/dist/dashboard/dashboard-item/dto/create.dto.d.ts.map +1 -0
  163. package/dist/dashboard/dashboard-item/dto/create.dto.js +41 -0
  164. package/dist/dashboard/dashboard-item/dto/create.dto.js.map +1 -0
  165. package/dist/dashboard/dashboard-item/dto/update.dto.d.ts +6 -0
  166. package/dist/dashboard/dashboard-item/dto/update.dto.d.ts.map +1 -0
  167. package/dist/dashboard/dashboard-item/dto/update.dto.js +9 -0
  168. package/dist/dashboard/dashboard-item/dto/update.dto.js.map +1 -0
  169. package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +54 -0
  170. package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts.map +1 -0
  171. package/dist/dashboard/dashboard-user/dashboard-user.controller.js +88 -0
  172. package/dist/dashboard/dashboard-user/dashboard-user.controller.js.map +1 -0
  173. package/dist/dashboard/dashboard-user/dashboard-user.module.d.ts +3 -0
  174. package/dist/dashboard/dashboard-user/dashboard-user.module.d.ts.map +1 -0
  175. package/dist/dashboard/dashboard-user/dashboard-user.module.js +26 -0
  176. package/dist/dashboard/dashboard-user/dashboard-user.module.js.map +1 -0
  177. package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +61 -0
  178. package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts.map +1 -0
  179. package/dist/dashboard/dashboard-user/dashboard-user.service.js +83 -0
  180. package/dist/dashboard/dashboard-user/dashboard-user.service.js.map +1 -0
  181. package/dist/dashboard/dashboard-user/dto/create.dto.d.ts +10 -0
  182. package/dist/dashboard/dashboard-user/dto/create.dto.d.ts.map +1 -0
  183. package/dist/dashboard/dashboard-user/dto/create.dto.js +42 -0
  184. package/dist/dashboard/dashboard-user/dto/create.dto.js.map +1 -0
  185. package/dist/dashboard/dashboard-user/dto/update.dto.d.ts +6 -0
  186. package/dist/dashboard/dashboard-user/dto/update.dto.d.ts.map +1 -0
  187. package/dist/dashboard/dashboard-user/dto/update.dto.js +9 -0
  188. package/dist/dashboard/dashboard-user/dto/update.dto.js.map +1 -0
  189. package/dist/dashboard/dashboard.module.d.ts +3 -0
  190. package/dist/dashboard/dashboard.module.d.ts.map +1 -0
  191. package/dist/dashboard/dashboard.module.js +37 -0
  192. package/dist/dashboard/dashboard.module.js.map +1 -0
  193. package/dist/dashboard/index.d.ts +2 -0
  194. package/dist/dashboard/index.d.ts.map +1 -0
  195. package/dist/dashboard/index.js +18 -0
  196. package/dist/dashboard/index.js.map +1 -0
  197. package/dist/decorators/inject-locale.decorator.d.ts +2 -0
  198. package/dist/decorators/inject-locale.decorator.d.ts.map +1 -0
  199. package/dist/decorators/inject-locale.decorator.js +16 -0
  200. package/dist/decorators/inject-locale.decorator.js.map +1 -0
  201. package/dist/dto/delete.dto.d.ts +4 -0
  202. package/dist/dto/delete.dto.d.ts.map +1 -0
  203. package/dist/dto/delete.dto.js +23 -0
  204. package/dist/dto/delete.dto.js.map +1 -0
  205. package/dist/dto/update-ids.dto.d.ts +4 -0
  206. package/dist/dto/update-ids.dto.d.ts.map +1 -0
  207. package/dist/dto/update-ids.dto.js +27 -0
  208. package/dist/dto/update-ids.dto.js.map +1 -0
  209. package/dist/emails/index.d.ts +3 -0
  210. package/dist/emails/index.d.ts.map +1 -0
  211. package/dist/emails/index.js +19 -0
  212. package/dist/emails/index.js.map +1 -0
  213. package/dist/emails/lib.d.ts +8 -0
  214. package/dist/emails/lib.d.ts.map +1 -0
  215. package/dist/emails/lib.js +73 -0
  216. package/dist/emails/lib.js.map +1 -0
  217. package/dist/emails/templates.d.ts +17 -0
  218. package/dist/emails/templates.d.ts.map +1 -0
  219. package/dist/emails/templates.js +70 -0
  220. package/dist/emails/templates.js.map +1 -0
  221. package/dist/file/dto/delete.dto.d.ts +4 -0
  222. package/dist/file/dto/delete.dto.d.ts.map +1 -0
  223. package/dist/file/dto/delete.dto.js +23 -0
  224. package/dist/file/dto/delete.dto.js.map +1 -0
  225. package/dist/file/dto/upload.dto.d.ts +4 -0
  226. package/dist/file/dto/upload.dto.d.ts.map +1 -0
  227. package/dist/file/dto/upload.dto.js +22 -0
  228. package/dist/file/dto/upload.dto.js.map +1 -0
  229. package/dist/file/file.controller.d.ts +45 -0
  230. package/dist/file/file.controller.d.ts.map +1 -0
  231. package/dist/file/file.controller.js +112 -0
  232. package/dist/file/file.controller.js.map +1 -0
  233. package/dist/file/file.module.d.ts +3 -0
  234. package/dist/file/file.module.d.ts.map +1 -0
  235. package/dist/file/file.module.js +40 -0
  236. package/dist/file/file.module.js.map +1 -0
  237. package/dist/file/file.service.d.ts +92 -0
  238. package/dist/file/file.service.d.ts.map +1 -0
  239. package/dist/file/file.service.js +260 -0
  240. package/dist/file/file.service.js.map +1 -0
  241. package/dist/file/provider/abstract.provider.d.ts +25 -0
  242. package/dist/file/provider/abstract.provider.d.ts.map +1 -0
  243. package/dist/file/provider/abstract.provider.js +15 -0
  244. package/dist/file/provider/abstract.provider.js.map +1 -0
  245. package/dist/file/provider/azure.provider.d.ts +16 -0
  246. package/dist/file/provider/azure.provider.d.ts.map +1 -0
  247. package/dist/file/provider/azure.provider.js +102 -0
  248. package/dist/file/provider/azure.provider.js.map +1 -0
  249. package/dist/file/provider/gcs.provider.d.ts +17 -0
  250. package/dist/file/provider/gcs.provider.d.ts.map +1 -0
  251. package/dist/file/provider/gcs.provider.js +86 -0
  252. package/dist/file/provider/gcs.provider.js.map +1 -0
  253. package/dist/file/provider/local.provider.d.ts +16 -0
  254. package/dist/file/provider/local.provider.d.ts.map +1 -0
  255. package/dist/file/provider/local.provider.js +138 -0
  256. package/dist/file/provider/local.provider.js.map +1 -0
  257. package/dist/file/provider/provider.enum.d.ts +7 -0
  258. package/dist/file/provider/provider.enum.d.ts.map +1 -0
  259. package/dist/file/provider/provider.enum.js +11 -0
  260. package/dist/file/provider/provider.enum.js.map +1 -0
  261. package/dist/file/provider/provider.factory.d.ts +6 -0
  262. package/dist/file/provider/provider.factory.d.ts.map +1 -0
  263. package/dist/file/provider/provider.factory.js +21 -0
  264. package/dist/file/provider/provider.factory.js.map +1 -0
  265. package/dist/file/provider/s3.provider.d.ts +20 -0
  266. package/dist/file/provider/s3.provider.d.ts.map +1 -0
  267. package/dist/file/provider/s3.provider.js +183 -0
  268. package/dist/file/provider/s3.provider.js.map +1 -0
  269. package/dist/index.d.ts +13 -0
  270. package/dist/index.d.ts.map +1 -0
  271. package/dist/index.js +35 -0
  272. package/dist/index.js.map +1 -0
  273. package/dist/install/dto/generate-migration.dto.d.ts +12 -0
  274. package/dist/install/dto/generate-migration.dto.d.ts.map +1 -0
  275. package/dist/install/dto/generate-migration.dto.js +51 -0
  276. package/dist/install/dto/generate-migration.dto.js.map +1 -0
  277. package/dist/install/dto/install.dto.d.ts +8 -0
  278. package/dist/install/dto/install.dto.d.ts.map +1 -0
  279. package/dist/install/dto/install.dto.js +46 -0
  280. package/dist/install/dto/install.dto.js.map +1 -0
  281. package/dist/install/install.controller.d.ts +19 -0
  282. package/dist/install/install.controller.d.ts.map +1 -0
  283. package/dist/install/install.controller.js +61 -0
  284. package/dist/install/install.controller.js.map +1 -0
  285. package/dist/install/install.module.d.ts +3 -0
  286. package/dist/install/install.module.d.ts.map +1 -0
  287. package/dist/install/install.module.js +32 -0
  288. package/dist/install/install.module.js.map +1 -0
  289. package/dist/install/install.service.d.ts +35 -0
  290. package/dist/install/install.service.d.ts.map +1 -0
  291. package/dist/install/install.service.js +332 -0
  292. package/dist/install/install.service.js.map +1 -0
  293. package/dist/mail/dto/create.dto.d.ts +15 -0
  294. package/dist/mail/dto/create.dto.d.ts.map +1 -0
  295. package/dist/mail/dto/create.dto.js +52 -0
  296. package/dist/mail/dto/create.dto.js.map +1 -0
  297. package/dist/mail/dto/send.dto.d.ts +6 -0
  298. package/dist/mail/dto/send.dto.d.ts.map +1 -0
  299. package/dist/mail/dto/send.dto.js +31 -0
  300. package/dist/mail/dto/send.dto.js.map +1 -0
  301. package/dist/mail/dto/test-mail.dto.d.ts +7 -0
  302. package/dist/mail/dto/test-mail.dto.d.ts.map +1 -0
  303. package/dist/mail/dto/test-mail.dto.js +37 -0
  304. package/dist/mail/dto/test-mail.dto.js.map +1 -0
  305. package/dist/mail/dto/update.dto.d.ts +6 -0
  306. package/dist/mail/dto/update.dto.d.ts.map +1 -0
  307. package/dist/mail/dto/update.dto.js +9 -0
  308. package/dist/mail/dto/update.dto.js.map +1 -0
  309. package/dist/mail/mail.controller.d.ts +89 -0
  310. package/dist/mail/mail.controller.d.ts.map +1 -0
  311. package/dist/mail/mail.controller.js +104 -0
  312. package/dist/mail/mail.controller.js.map +1 -0
  313. package/dist/mail/mail.module.d.ts +3 -0
  314. package/dist/mail/mail.module.d.ts.map +1 -0
  315. package/dist/mail/mail.module.js +113 -0
  316. package/dist/mail/mail.module.js.map +1 -0
  317. package/dist/mail/mail.service.d.ts +122 -0
  318. package/dist/mail/mail.service.d.ts.map +1 -0
  319. package/dist/mail/mail.service.js +356 -0
  320. package/dist/mail/mail.service.js.map +1 -0
  321. package/dist/mail-sent/dto/create.dto.d.ts +10 -0
  322. package/dist/mail-sent/dto/create.dto.d.ts.map +1 -0
  323. package/dist/mail-sent/dto/create.dto.js +70 -0
  324. package/dist/mail-sent/dto/create.dto.js.map +1 -0
  325. package/dist/mail-sent/dto/update.dto.d.ts +6 -0
  326. package/dist/mail-sent/dto/update.dto.d.ts.map +1 -0
  327. package/dist/mail-sent/dto/update.dto.js +9 -0
  328. package/dist/mail-sent/dto/update.dto.js.map +1 -0
  329. package/dist/mail-sent/mail-sent.controller.d.ts +57 -0
  330. package/dist/mail-sent/mail-sent.controller.d.ts.map +1 -0
  331. package/dist/mail-sent/mail-sent.controller.js +88 -0
  332. package/dist/mail-sent/mail-sent.controller.js.map +1 -0
  333. package/dist/mail-sent/mail-sent.module.d.ts +3 -0
  334. package/dist/mail-sent/mail-sent.module.d.ts.map +1 -0
  335. package/dist/mail-sent/mail-sent.module.js +26 -0
  336. package/dist/mail-sent/mail-sent.module.js.map +1 -0
  337. package/dist/mail-sent/mail-sent.service.d.ts +62 -0
  338. package/dist/mail-sent/mail-sent.service.d.ts.map +1 -0
  339. package/dist/mail-sent/mail-sent.service.js +93 -0
  340. package/dist/mail-sent/mail-sent.service.js.map +1 -0
  341. package/dist/mail-var/dto/create.dto.d.ts +5 -0
  342. package/dist/mail-var/dto/create.dto.d.ts.map +1 -0
  343. package/dist/mail-var/dto/create.dto.js +25 -0
  344. package/dist/mail-var/dto/create.dto.js.map +1 -0
  345. package/dist/mail-var/dto/update.dto.d.ts +6 -0
  346. package/dist/mail-var/dto/update.dto.d.ts.map +1 -0
  347. package/dist/mail-var/dto/update.dto.js +9 -0
  348. package/dist/mail-var/dto/update.dto.js.map +1 -0
  349. package/dist/mail-var/mail-var.controller.d.ts +42 -0
  350. package/dist/mail-var/mail-var.controller.d.ts.map +1 -0
  351. package/dist/mail-var/mail-var.controller.js +88 -0
  352. package/dist/mail-var/mail-var.controller.js.map +1 -0
  353. package/dist/mail-var/mail-var.module.d.ts +3 -0
  354. package/dist/mail-var/mail-var.module.d.ts.map +1 -0
  355. package/dist/mail-var/mail-var.module.js +26 -0
  356. package/dist/mail-var/mail-var.module.js.map +1 -0
  357. package/dist/mail-var/mail-var.service.d.ts +47 -0
  358. package/dist/mail-var/mail-var.service.d.ts.map +1 -0
  359. package/dist/mail-var/mail-var.service.js +73 -0
  360. package/dist/mail-var/mail-var.service.js.map +1 -0
  361. package/dist/menu/dto/create.dto.d.ts +8 -0
  362. package/dist/menu/dto/create.dto.d.ts.map +1 -0
  363. package/dist/menu/dto/create.dto.js +45 -0
  364. package/dist/menu/dto/create.dto.js.map +1 -0
  365. package/dist/menu/dto/order.dto.d.ts +4 -0
  366. package/dist/menu/dto/order.dto.d.ts.map +1 -0
  367. package/dist/menu/dto/order.dto.js +23 -0
  368. package/dist/menu/dto/order.dto.js.map +1 -0
  369. package/dist/menu/dto/update.dto.d.ts +7 -0
  370. package/dist/menu/dto/update.dto.d.ts.map +1 -0
  371. package/dist/menu/dto/update.dto.js +38 -0
  372. package/dist/menu/dto/update.dto.js.map +1 -0
  373. package/dist/menu/menu.controller.d.ts +81 -0
  374. package/dist/menu/menu.controller.d.ts.map +1 -0
  375. package/dist/menu/menu.controller.js +160 -0
  376. package/dist/menu/menu.controller.js.map +1 -0
  377. package/dist/menu/menu.module.d.ts +3 -0
  378. package/dist/menu/menu.module.d.ts.map +1 -0
  379. package/dist/menu/menu.module.js +31 -0
  380. package/dist/menu/menu.module.js.map +1 -0
  381. package/dist/menu/menu.service.d.ts +85 -0
  382. package/dist/menu/menu.service.d.ts.map +1 -0
  383. package/dist/menu/menu.service.js +223 -0
  384. package/dist/menu/menu.service.js.map +1 -0
  385. package/dist/menu/menu.service.spec.d.ts +1 -0
  386. package/dist/menu/menu.service.spec.d.ts.map +1 -0
  387. package/dist/menu/menu.service.spec.js +208 -0
  388. package/dist/menu/menu.service.spec.js.map +1 -0
  389. package/dist/middlewares/locale-injection.middleware.d.ts +6 -0
  390. package/dist/middlewares/locale-injection.middleware.d.ts.map +1 -0
  391. package/dist/middlewares/locale-injection.middleware.js +25 -0
  392. package/dist/middlewares/locale-injection.middleware.js.map +1 -0
  393. package/dist/oauth/interfaces/OAuthProvider.d.ts +6 -0
  394. package/dist/oauth/interfaces/OAuthProvider.d.ts.map +1 -0
  395. package/dist/oauth/interfaces/OAuthProvider.js +3 -0
  396. package/dist/oauth/interfaces/OAuthProvider.js.map +1 -0
  397. package/dist/oauth/oauth.controller.d.ts +27 -0
  398. package/dist/oauth/oauth.controller.d.ts.map +1 -0
  399. package/dist/oauth/oauth.controller.js +151 -0
  400. package/dist/oauth/oauth.controller.js.map +1 -0
  401. package/dist/oauth/oauth.module.d.ts +3 -0
  402. package/dist/oauth/oauth.module.d.ts.map +1 -0
  403. package/dist/oauth/oauth.module.js +49 -0
  404. package/dist/oauth/oauth.module.js.map +1 -0
  405. package/dist/oauth/oauth.service.d.ts +51 -0
  406. package/dist/oauth/oauth.service.d.ts.map +1 -0
  407. package/dist/oauth/oauth.service.js +294 -0
  408. package/dist/oauth/oauth.service.js.map +1 -0
  409. package/dist/oauth/providers/abstract.provider.d.ts +18 -0
  410. package/dist/oauth/providers/abstract.provider.d.ts.map +1 -0
  411. package/dist/oauth/providers/abstract.provider.js +30 -0
  412. package/dist/oauth/providers/abstract.provider.js.map +1 -0
  413. package/dist/oauth/providers/facebook.provider.d.ts +14 -0
  414. package/dist/oauth/providers/facebook.provider.d.ts.map +1 -0
  415. package/dist/oauth/providers/facebook.provider.js +73 -0
  416. package/dist/oauth/providers/facebook.provider.js.map +1 -0
  417. package/dist/oauth/providers/github.provider.d.ts +25 -0
  418. package/dist/oauth/providers/github.provider.d.ts.map +1 -0
  419. package/dist/oauth/providers/github.provider.js +105 -0
  420. package/dist/oauth/providers/github.provider.js.map +1 -0
  421. package/dist/oauth/providers/google.provider.d.ts +15 -0
  422. package/dist/oauth/providers/google.provider.d.ts.map +1 -0
  423. package/dist/oauth/providers/google.provider.js +94 -0
  424. package/dist/oauth/providers/google.provider.js.map +1 -0
  425. package/dist/oauth/providers/microsoft.provider.d.ts +14 -0
  426. package/dist/oauth/providers/microsoft.provider.d.ts.map +1 -0
  427. package/dist/oauth/providers/microsoft.provider.js +81 -0
  428. package/dist/oauth/providers/microsoft.provider.js.map +1 -0
  429. package/dist/profile/dto/change-password.dto.d.ts +5 -0
  430. package/dist/profile/dto/change-password.dto.d.ts.map +1 -0
  431. package/dist/profile/dto/change-password.dto.js +32 -0
  432. package/dist/profile/dto/change-password.dto.js.map +1 -0
  433. package/dist/profile/dto/email-verification-confirm.dto.d.ts +7 -0
  434. package/dist/profile/dto/email-verification-confirm.dto.d.ts.map +1 -0
  435. package/dist/profile/dto/email-verification-confirm.dto.js +36 -0
  436. package/dist/profile/dto/email-verification-confirm.dto.js.map +1 -0
  437. package/dist/profile/dto/generate-webauthn-registration-options.dto.d.ts +4 -0
  438. package/dist/profile/dto/generate-webauthn-registration-options.dto.d.ts.map +1 -0
  439. package/dist/profile/dto/generate-webauthn-registration-options.dto.js +22 -0
  440. package/dist/profile/dto/generate-webauthn-registration-options.dto.js.map +1 -0
  441. package/dist/profile/dto/regenerate-recovery-codes.dto.d.ts +7 -0
  442. package/dist/profile/dto/regenerate-recovery-codes.dto.d.ts.map +1 -0
  443. package/dist/profile/dto/regenerate-recovery-codes.dto.js +36 -0
  444. package/dist/profile/dto/regenerate-recovery-codes.dto.js.map +1 -0
  445. package/dist/profile/dto/remove-email-mfa.dto.d.ts +5 -0
  446. package/dist/profile/dto/remove-email-mfa.dto.d.ts.map +1 -0
  447. package/dist/profile/dto/remove-email-mfa.dto.js +27 -0
  448. package/dist/profile/dto/remove-email-mfa.dto.js.map +1 -0
  449. package/dist/profile/dto/remove-mfa-with-recovery-code.dto.d.ts +4 -0
  450. package/dist/profile/dto/remove-mfa-with-recovery-code.dto.d.ts.map +1 -0
  451. package/dist/profile/dto/remove-mfa-with-recovery-code.dto.js +22 -0
  452. package/dist/profile/dto/remove-mfa-with-recovery-code.dto.js.map +1 -0
  453. package/dist/profile/dto/remove-mfa.dto.d.ts +7 -0
  454. package/dist/profile/dto/remove-mfa.dto.d.ts.map +1 -0
  455. package/dist/profile/dto/remove-mfa.dto.js +36 -0
  456. package/dist/profile/dto/remove-mfa.dto.js.map +1 -0
  457. package/dist/profile/dto/remove-totp-mfa.dto.d.ts +4 -0
  458. package/dist/profile/dto/remove-totp-mfa.dto.d.ts.map +1 -0
  459. package/dist/profile/dto/remove-totp-mfa.dto.js +22 -0
  460. package/dist/profile/dto/remove-totp-mfa.dto.js.map +1 -0
  461. package/dist/profile/dto/send-email-verification.dto.d.ts +4 -0
  462. package/dist/profile/dto/send-email-verification.dto.d.ts.map +1 -0
  463. package/dist/profile/dto/send-email-verification.dto.js +24 -0
  464. package/dist/profile/dto/send-email-verification.dto.js.map +1 -0
  465. package/dist/profile/dto/set-preferences.dto.d.ts +5 -0
  466. package/dist/profile/dto/set-preferences.dto.d.ts.map +1 -0
  467. package/dist/profile/dto/set-preferences.dto.js +27 -0
  468. package/dist/profile/dto/set-preferences.dto.js.map +1 -0
  469. package/dist/profile/dto/update.dto.d.ts +4 -0
  470. package/dist/profile/dto/update.dto.d.ts.map +1 -0
  471. package/dist/profile/dto/update.dto.js +24 -0
  472. package/dist/profile/dto/update.dto.js.map +1 -0
  473. package/dist/profile/dto/verify-before-add-mfa.dto.d.ts +7 -0
  474. package/dist/profile/dto/verify-before-add-mfa.dto.d.ts.map +1 -0
  475. package/dist/profile/dto/verify-before-add-mfa.dto.js +34 -0
  476. package/dist/profile/dto/verify-before-add-mfa.dto.js.map +1 -0
  477. package/dist/profile/dto/verify-mfa-totp.dto.d.ts +6 -0
  478. package/dist/profile/dto/verify-mfa-totp.dto.d.ts.map +1 -0
  479. package/dist/profile/dto/verify-mfa-totp.dto.js +35 -0
  480. package/dist/profile/dto/verify-mfa-totp.dto.js.map +1 -0
  481. package/dist/profile/dto/verify-webauthn-registration.dto.d.ts +5 -0
  482. package/dist/profile/dto/verify-webauthn-registration.dto.d.ts.map +1 -0
  483. package/dist/profile/dto/verify-webauthn-registration.dto.js +27 -0
  484. package/dist/profile/dto/verify-webauthn-registration.dto.js.map +1 -0
  485. package/dist/profile/dto/verify-webauthn.dto.d.ts +4 -0
  486. package/dist/profile/dto/verify-webauthn.dto.d.ts.map +1 -0
  487. package/dist/profile/dto/verify-webauthn.dto.js +22 -0
  488. package/dist/profile/dto/verify-webauthn.dto.js.map +1 -0
  489. package/dist/profile/profile.controller.d.ts +264 -0
  490. package/dist/profile/profile.controller.d.ts.map +1 -0
  491. package/dist/profile/profile.controller.js +359 -0
  492. package/dist/profile/profile.controller.js.map +1 -0
  493. package/dist/profile/profile.module.d.ts +3 -0
  494. package/dist/profile/profile.module.d.ts.map +1 -0
  495. package/dist/profile/profile.module.js +34 -0
  496. package/dist/profile/profile.module.js.map +1 -0
  497. package/dist/profile/profile.service.d.ts +242 -0
  498. package/dist/profile/profile.service.d.ts.map +1 -0
  499. package/dist/profile/profile.service.js +1158 -0
  500. package/dist/profile/profile.service.js.map +1 -0
  501. package/dist/role/dto/create.dto.d.ts +5 -0
  502. package/dist/role/dto/create.dto.d.ts.map +1 -0
  503. package/dist/role/dto/create.dto.js +22 -0
  504. package/dist/role/dto/create.dto.js.map +1 -0
  505. package/dist/role/dto/update.dto.d.ts +6 -0
  506. package/dist/role/dto/update.dto.d.ts.map +1 -0
  507. package/dist/role/dto/update.dto.js +9 -0
  508. package/dist/role/dto/update.dto.js.map +1 -0
  509. package/dist/role/guards/role.guard.d.ts +11 -0
  510. package/dist/role/guards/role.guard.d.ts.map +1 -0
  511. package/dist/role/guards/role.guard.js +116 -0
  512. package/dist/role/guards/role.guard.js.map +1 -0
  513. package/dist/role/role.controller.d.ts +73 -0
  514. package/dist/role/role.controller.d.ts.map +1 -0
  515. package/dist/role/role.controller.js +183 -0
  516. package/dist/role/role.controller.js.map +1 -0
  517. package/dist/role/role.module.d.ts +3 -0
  518. package/dist/role/role.module.d.ts.map +1 -0
  519. package/dist/role/role.module.js +42 -0
  520. package/dist/role/role.module.js.map +1 -0
  521. package/dist/role/role.service.d.ts +80 -0
  522. package/dist/role/role.service.d.ts.map +1 -0
  523. package/dist/role/role.service.js +241 -0
  524. package/dist/role/role.service.js.map +1 -0
  525. package/dist/route/dto/create.dto.d.ts +6 -0
  526. package/dist/route/dto/create.dto.d.ts.map +1 -0
  527. package/dist/route/dto/create.dto.js +29 -0
  528. package/dist/route/dto/create.dto.js.map +1 -0
  529. package/dist/route/dto/update.dto.d.ts +6 -0
  530. package/dist/route/dto/update.dto.d.ts.map +1 -0
  531. package/dist/route/dto/update.dto.js +31 -0
  532. package/dist/route/dto/update.dto.js.map +1 -0
  533. package/dist/route/route.controller.d.ts +50 -0
  534. package/dist/route/route.controller.d.ts.map +1 -0
  535. package/dist/route/route.controller.js +134 -0
  536. package/dist/route/route.controller.js.map +1 -0
  537. package/dist/route/route.module.d.ts +3 -0
  538. package/dist/route/route.module.d.ts.map +1 -0
  539. package/dist/route/route.module.js +31 -0
  540. package/dist/route/route.module.js.map +1 -0
  541. package/dist/route/route.service.d.ts +54 -0
  542. package/dist/route/route.service.d.ts.map +1 -0
  543. package/dist/route/route.service.js +142 -0
  544. package/dist/route/route.service.js.map +1 -0
  545. package/dist/route/route.service.spec.d.ts +1 -0
  546. package/dist/route/route.service.spec.d.ts.map +1 -0
  547. package/dist/route/route.service.spec.js +262 -0
  548. package/dist/route/route.service.spec.js.map +1 -0
  549. package/dist/screen/dto/create.dto.d.ts +5 -0
  550. package/dist/screen/dto/create.dto.d.ts.map +1 -0
  551. package/dist/screen/dto/create.dto.js +28 -0
  552. package/dist/screen/dto/create.dto.js.map +1 -0
  553. package/dist/screen/dto/update.dto.d.ts +7 -0
  554. package/dist/screen/dto/update.dto.d.ts.map +1 -0
  555. package/dist/screen/dto/update.dto.js +38 -0
  556. package/dist/screen/dto/update.dto.js.map +1 -0
  557. package/dist/screen/screen.controller.d.ts +67 -0
  558. package/dist/screen/screen.controller.d.ts.map +1 -0
  559. package/dist/screen/screen.controller.js +137 -0
  560. package/dist/screen/screen.controller.js.map +1 -0
  561. package/dist/screen/screen.module.d.ts +3 -0
  562. package/dist/screen/screen.module.d.ts.map +1 -0
  563. package/dist/screen/screen.module.js +31 -0
  564. package/dist/screen/screen.module.js.map +1 -0
  565. package/dist/screen/screen.service.d.ts +72 -0
  566. package/dist/screen/screen.service.d.ts.map +1 -0
  567. package/dist/screen/screen.service.js +153 -0
  568. package/dist/screen/screen.service.js.map +1 -0
  569. package/dist/screen/screen.service.spec.d.ts +1 -0
  570. package/dist/screen/screen.service.spec.d.ts.map +1 -0
  571. package/dist/screen/screen.service.spec.js +259 -0
  572. package/dist/screen/screen.service.spec.js.map +1 -0
  573. package/dist/security/security.module.d.ts +3 -0
  574. package/dist/security/security.module.d.ts.map +1 -0
  575. package/dist/security/security.module.js +23 -0
  576. package/dist/security/security.module.js.map +1 -0
  577. package/dist/security/security.service.d.ts +18 -0
  578. package/dist/security/security.service.d.ts.map +1 -0
  579. package/dist/security/security.service.js +141 -0
  580. package/dist/security/security.service.js.map +1 -0
  581. package/dist/session/session.controller.d.ts +33 -0
  582. package/dist/session/session.controller.d.ts.map +1 -0
  583. package/dist/session/session.controller.js +72 -0
  584. package/dist/session/session.controller.js.map +1 -0
  585. package/dist/session/session.module.d.ts +3 -0
  586. package/dist/session/session.module.d.ts.map +1 -0
  587. package/dist/session/session.module.js +39 -0
  588. package/dist/session/session.module.js.map +1 -0
  589. package/dist/session/session.service.d.ts +72 -0
  590. package/dist/session/session.service.d.ts.map +1 -0
  591. package/dist/session/session.service.js +199 -0
  592. package/dist/session/session.service.js.map +1 -0
  593. package/dist/setting/dto/confirm-import.dto.d.ts +7 -0
  594. package/dist/setting/dto/confirm-import.dto.d.ts.map +1 -0
  595. package/dist/setting/dto/confirm-import.dto.js +22 -0
  596. package/dist/setting/dto/confirm-import.dto.js.map +1 -0
  597. package/dist/setting/dto/create.dto.d.ts +9 -0
  598. package/dist/setting/dto/create.dto.d.ts.map +1 -0
  599. package/dist/setting/dto/create.dto.js +40 -0
  600. package/dist/setting/dto/create.dto.js.map +1 -0
  601. package/dist/setting/dto/delete.dto.d.ts +4 -0
  602. package/dist/setting/dto/delete.dto.d.ts.map +1 -0
  603. package/dist/setting/dto/delete.dto.js +23 -0
  604. package/dist/setting/dto/delete.dto.js.map +1 -0
  605. package/dist/setting/dto/export.dto.d.ts +4 -0
  606. package/dist/setting/dto/export.dto.d.ts.map +1 -0
  607. package/dist/setting/dto/export.dto.js +24 -0
  608. package/dist/setting/dto/export.dto.js.map +1 -0
  609. package/dist/setting/dto/import-validation.dto.d.ts +7 -0
  610. package/dist/setting/dto/import-validation.dto.d.ts.map +1 -0
  611. package/dist/setting/dto/import-validation.dto.js +7 -0
  612. package/dist/setting/dto/import-validation.dto.js.map +1 -0
  613. package/dist/setting/dto/setting-user.dto.d.ts +4 -0
  614. package/dist/setting/dto/setting-user.dto.d.ts.map +1 -0
  615. package/dist/setting/dto/setting-user.dto.js +21 -0
  616. package/dist/setting/dto/setting-user.dto.js.map +1 -0
  617. package/dist/setting/dto/setting.dto.d.ts +9 -0
  618. package/dist/setting/dto/setting.dto.d.ts.map +1 -0
  619. package/dist/setting/dto/setting.dto.js +34 -0
  620. package/dist/setting/dto/setting.dto.js.map +1 -0
  621. package/dist/setting/dto/update.dto.d.ts +6 -0
  622. package/dist/setting/dto/update.dto.d.ts.map +1 -0
  623. package/dist/setting/dto/update.dto.js +9 -0
  624. package/dist/setting/dto/update.dto.js.map +1 -0
  625. package/dist/setting/setting.controller.d.ts +126 -0
  626. package/dist/setting/setting.controller.d.ts.map +1 -0
  627. package/dist/setting/setting.controller.js +206 -0
  628. package/dist/setting/setting.controller.js.map +1 -0
  629. package/dist/setting/setting.module.d.ts +3 -0
  630. package/dist/setting/setting.module.d.ts.map +1 -0
  631. package/dist/setting/setting.module.js +34 -0
  632. package/dist/setting/setting.module.js.map +1 -0
  633. package/dist/setting/setting.service.d.ts +134 -0
  634. package/dist/setting/setting.service.d.ts.map +1 -0
  635. package/dist/setting/setting.service.js +570 -0
  636. package/dist/setting/setting.service.js.map +1 -0
  637. package/dist/task/task.module.d.ts +3 -0
  638. package/dist/task/task.module.d.ts.map +1 -0
  639. package/dist/task/task.module.js +22 -0
  640. package/dist/task/task.module.js.map +1 -0
  641. package/dist/task/task.service.d.ts +8 -0
  642. package/dist/task/task.service.d.ts.map +1 -0
  643. package/dist/task/task.service.js +75 -0
  644. package/dist/task/task.service.js.map +1 -0
  645. package/dist/token/token.module.d.ts +3 -0
  646. package/dist/token/token.module.d.ts.map +1 -0
  647. package/dist/token/token.module.js +27 -0
  648. package/dist/token/token.module.js.map +1 -0
  649. package/dist/token/token.service.d.ts +31 -0
  650. package/dist/token/token.service.d.ts.map +1 -0
  651. package/dist/token/token.service.js +121 -0
  652. package/dist/token/token.service.js.map +1 -0
  653. package/dist/types/http-method.d.ts +2 -0
  654. package/dist/types/http-method.d.ts.map +1 -0
  655. package/dist/types/http-method.js +3 -0
  656. package/dist/types/http-method.js.map +1 -0
  657. package/dist/types/multer.d.ts +26 -0
  658. package/dist/types/multer.d.ts.map +1 -0
  659. package/dist/types/multer.js +3 -0
  660. package/dist/types/multer.js.map +1 -0
  661. package/dist/user/constants/user.constants.d.ts +2 -0
  662. package/dist/user/constants/user.constants.d.ts.map +1 -0
  663. package/dist/user/constants/user.constants.js +5 -0
  664. package/dist/user/constants/user.constants.js.map +1 -0
  665. package/dist/user/dto/create-with-email-and-password.dto.d.ts +8 -0
  666. package/dist/user/dto/create-with-email-and-password.dto.d.ts.map +1 -0
  667. package/dist/user/dto/create-with-email-and-password.dto.js +39 -0
  668. package/dist/user/dto/create-with-email-and-password.dto.js.map +1 -0
  669. package/dist/user/dto/update.dto.d.ts +4 -0
  670. package/dist/user/dto/update.dto.d.ts.map +1 -0
  671. package/dist/user/dto/update.dto.js +23 -0
  672. package/dist/user/dto/update.dto.js.map +1 -0
  673. package/dist/user/user.controller.d.ts +115 -0
  674. package/dist/user/user.controller.d.ts.map +1 -0
  675. package/dist/user/user.controller.js +123 -0
  676. package/dist/user/user.controller.js.map +1 -0
  677. package/dist/user/user.module.d.ts +3 -0
  678. package/dist/user/user.module.d.ts.map +1 -0
  679. package/dist/user/user.module.js +47 -0
  680. package/dist/user/user.module.js.map +1 -0
  681. package/dist/user/user.service.d.ts +191 -0
  682. package/dist/user/user.service.d.ts.map +1 -0
  683. package/dist/user/user.service.js +243 -0
  684. package/dist/user/user.service.js.map +1 -0
  685. package/dist/user/user.service.spec.d.ts +1 -0
  686. package/dist/user/user.service.spec.d.ts.map +1 -0
  687. package/dist/user/user.service.spec.js +261 -0
  688. package/dist/user/user.service.spec.js.map +1 -0
  689. package/dist/utils/locale-context.d.ts +8 -0
  690. package/dist/utils/locale-context.d.ts.map +1 -0
  691. package/dist/utils/locale-context.js +11 -0
  692. package/dist/utils/locale-context.js.map +1 -0
  693. package/dist/validators/is-email-with-settings.validator.d.ts +10 -0
  694. package/dist/validators/is-email-with-settings.validator.d.ts.map +1 -0
  695. package/dist/validators/is-email-with-settings.validator.js +80 -0
  696. package/dist/validators/is-email-with-settings.validator.js.map +1 -0
  697. package/dist/validators/is-pin-code-with-setting.validator.d.ts +11 -0
  698. package/dist/validators/is-pin-code-with-setting.validator.d.ts.map +1 -0
  699. package/dist/validators/is-pin-code-with-setting.validator.js +73 -0
  700. package/dist/validators/is-pin-code-with-setting.validator.js.map +1 -0
  701. package/dist/validators/is-strong-password-with-settings.validator.d.ts +12 -0
  702. package/dist/validators/is-strong-password-with-settings.validator.d.ts.map +1 -0
  703. package/dist/validators/is-strong-password-with-settings.validator.js +108 -0
  704. package/dist/validators/is-strong-password-with-settings.validator.js.map +1 -0
  705. package/hedhog/data/dashboard.yaml +1 -0
  706. package/hedhog/data/dashboard_component.yaml +28 -0
  707. package/hedhog/data/dashboard_item.yaml +40 -0
  708. package/hedhog/data/file_mimetype.yaml +27 -0
  709. package/hedhog/data/file_provider.yaml +12 -0
  710. package/hedhog/data/locale.yaml +6 -0
  711. package/hedhog/data/mail.yaml +192 -0
  712. package/hedhog/data/menu.yaml +41 -0
  713. package/hedhog/data/role.yaml +21 -0
  714. package/hedhog/data/route.yaml +802 -0
  715. package/hedhog/data/setting_group.yaml +996 -0
  716. package/hedhog/data/translation_namespace.yaml +33 -0
  717. package/hedhog/query/user_mfa_challenge_active_idx.sql +4 -0
  718. package/hedhog/query/user_mfa_validate_triggers.sql +56 -0
  719. package/hedhog/table/dashboard.yaml +11 -0
  720. package/hedhog/table/dashboard_component.yaml +39 -0
  721. package/hedhog/table/dashboard_item.yaml +24 -0
  722. package/hedhog/table/dashboard_user.yaml +24 -0
  723. package/hedhog/table/file.yaml +23 -0
  724. package/hedhog/table/file_mimetype.yaml +5 -0
  725. package/hedhog/table/file_provider.yaml +10 -0
  726. package/hedhog/table/locale.yaml +15 -0
  727. package/hedhog/table/mail.yaml +15 -0
  728. package/hedhog/table/mail_sent.yaml +21 -0
  729. package/hedhog/table/mail_var.yaml +12 -0
  730. package/hedhog/table/menu.yaml +25 -0
  731. package/hedhog/table/menu_screen.yaml +16 -0
  732. package/hedhog/table/role.yaml +18 -0
  733. package/hedhog/table/role_menu.yaml +18 -0
  734. package/hedhog/table/role_route.yaml +18 -0
  735. package/hedhog/table/role_screen.yaml +18 -0
  736. package/hedhog/table/role_user.yaml +18 -0
  737. package/hedhog/table/route.yaml +22 -0
  738. package/hedhog/table/route_screen.yaml +18 -0
  739. package/hedhog/table/screen.yaml +20 -0
  740. package/hedhog/table/setting.yaml +54 -0
  741. package/hedhog/table/setting_group.yaml +20 -0
  742. package/hedhog/table/setting_list.yaml +16 -0
  743. package/hedhog/table/setting_user.yaml +21 -0
  744. package/hedhog/table/translation.yaml +24 -0
  745. package/hedhog/table/translation_namespace.yaml +5 -0
  746. package/hedhog/table/user.yaml +23 -0
  747. package/hedhog/table/user_account.yaml +29 -0
  748. package/hedhog/table/user_activity.yaml +13 -0
  749. package/hedhog/table/user_credential.yaml +24 -0
  750. package/hedhog/table/user_identifier.yaml +23 -0
  751. package/hedhog/table/user_mfa.yaml +23 -0
  752. package/hedhog/table/user_mfa_challenge.yaml +19 -0
  753. package/hedhog/table/user_mfa_email.yaml +11 -0
  754. package/hedhog/table/user_mfa_phone.yaml +11 -0
  755. package/hedhog/table/user_mfa_totp.yaml +12 -0
  756. package/hedhog/table/user_mfa_webauthn.yaml +19 -0
  757. package/hedhog/table/user_recovery_code.yaml +16 -0
  758. package/hedhog/table/user_session.yaml +18 -0
  759. package/package.json +72 -0
  760. package/src/auth/auth.controller.ts +215 -0
  761. package/src/auth/auth.module.ts +106 -0
  762. package/src/auth/auth.service.ts +554 -0
  763. package/src/auth/consts/body.ts +27 -0
  764. package/src/auth/dto/change.dto.ts +36 -0
  765. package/src/auth/dto/create-user.dto.ts +37 -0
  766. package/src/auth/dto/email.dto.ts +16 -0
  767. package/src/auth/dto/forget.dto.ts +13 -0
  768. package/src/auth/dto/login-with-code.dto.ts +14 -0
  769. package/src/auth/dto/login-with-recovery-code.ts +10 -0
  770. package/src/auth/dto/login.dto.ts +33 -0
  771. package/src/auth/dto/resend-mfa-code.dto.ts +6 -0
  772. package/src/auth/dto/reset.dto.ts +13 -0
  773. package/src/auth/enums/multifactor-type.enum.ts +4 -0
  774. package/src/auth/guards/auth.guard.ts +59 -0
  775. package/src/challenge/challenge.module.ts +20 -0
  776. package/src/challenge/challenge.service.ts +327 -0
  777. package/src/core/system.controller.ts +15 -0
  778. package/src/core/system.module.ts +17 -0
  779. package/src/core/system.service.ts +296 -0
  780. package/src/core.module.ts +89 -0
  781. package/src/dashboard/dashboard/dashboard.controller.ts +49 -0
  782. package/src/dashboard/dashboard/dashboard.module.ts +13 -0
  783. package/src/dashboard/dashboard/dashboard.service.ts +71 -0
  784. package/src/dashboard/dashboard/dto/create.dto.ts +8 -0
  785. package/src/dashboard/dashboard/dto/update.dto.ts +4 -0
  786. package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -0
  787. package/src/dashboard/dashboard-component/dashboard-component.module.ts +14 -0
  788. package/src/dashboard/dashboard-component/dashboard-component.service.ts +70 -0
  789. package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -0
  790. package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -0
  791. package/src/dashboard/dashboard-core/dashboard-core.controller.ts +13 -0
  792. package/src/dashboard/dashboard-core/dashboard-core.module.ts +14 -0
  793. package/src/dashboard/dashboard-core/dashboard-core.service.ts +27 -0
  794. package/src/dashboard/dashboard-item/dashboard-item.controller.ts +55 -0
  795. package/src/dashboard/dashboard-item/dashboard-item.module.ts +13 -0
  796. package/src/dashboard/dashboard-item/dashboard-item.service.ts +82 -0
  797. package/src/dashboard/dashboard-item/dto/create.dto.ts +22 -0
  798. package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -0
  799. package/src/dashboard/dashboard-user/dashboard-user.controller.ts +55 -0
  800. package/src/dashboard/dashboard-user/dashboard-user.module.ts +13 -0
  801. package/src/dashboard/dashboard-user/dashboard-user.service.ts +89 -0
  802. package/src/dashboard/dashboard-user/dto/create.dto.ts +22 -0
  803. package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -0
  804. package/src/dashboard/dashboard.module.ts +24 -0
  805. package/src/dashboard/index.ts +1 -0
  806. package/src/decorators/inject-locale.decorator.ts +17 -0
  807. package/src/dto/delete.dto.ts +8 -0
  808. package/src/dto/update-ids.dto.ts +12 -0
  809. package/src/emails/index.ts +2 -0
  810. package/src/emails/lib.ts +70 -0
  811. package/src/emails/templates.ts +73 -0
  812. package/src/file/dto/delete.dto.ts +8 -0
  813. package/src/file/dto/upload.dto.ts +7 -0
  814. package/src/file/file.controller.ts +78 -0
  815. package/src/file/file.module.ts +29 -0
  816. package/src/file/file.service.ts +339 -0
  817. package/src/file/provider/abstract.provider.ts +43 -0
  818. package/src/file/provider/azure.provider.ts +174 -0
  819. package/src/file/provider/gcs.provider.ts +108 -0
  820. package/src/file/provider/local.provider.ts +141 -0
  821. package/src/file/provider/provider.enum.ts +6 -0
  822. package/src/file/provider/provider.factory.ts +21 -0
  823. package/src/file/provider/s3.provider.ts +204 -0
  824. package/src/index.ts +26 -0
  825. package/src/install/dto/generate-migration.dto.ts +31 -0
  826. package/src/install/dto/install.dto.ts +27 -0
  827. package/src/install/install.controller.ts +26 -0
  828. package/src/install/install.module.ts +19 -0
  829. package/src/install/install.service.ts +345 -0
  830. package/src/language/en.json +112 -0
  831. package/src/language/pt.json +112 -0
  832. package/src/mail/dto/create.dto.ts +40 -0
  833. package/src/mail/dto/send.dto.ts +14 -0
  834. package/src/mail/dto/test-mail.dto.ts +19 -0
  835. package/src/mail/dto/update.dto.ts +4 -0
  836. package/src/mail/mail.controller.ts +67 -0
  837. package/src/mail/mail.module.ts +107 -0
  838. package/src/mail/mail.service.ts +371 -0
  839. package/src/mail-sent/dto/create.dto.ts +43 -0
  840. package/src/mail-sent/dto/update.dto.ts +4 -0
  841. package/src/mail-sent/mail-sent.controller.ts +55 -0
  842. package/src/mail-sent/mail-sent.module.ts +13 -0
  843. package/src/mail-sent/mail-sent.service.ts +103 -0
  844. package/src/mail-var/dto/create.dto.ts +9 -0
  845. package/src/mail-var/dto/update.dto.ts +4 -0
  846. package/src/mail-var/mail-var.controller.ts +55 -0
  847. package/src/mail-var/mail-var.module.ts +13 -0
  848. package/src/mail-var/mail-var.service.ts +78 -0
  849. package/src/menu/dto/create.dto.ts +26 -0
  850. package/src/menu/dto/order.dto.ts +8 -0
  851. package/src/menu/dto/update.dto.ts +20 -0
  852. package/src/menu/menu.controller.ts +105 -0
  853. package/src/menu/menu.module.ts +18 -0
  854. package/src/menu/menu.service.spec.ts +247 -0
  855. package/src/menu/menu.service.ts +264 -0
  856. package/src/middlewares/locale-injection.middleware.ts +15 -0
  857. package/src/oauth/interfaces/OAuthProvider.ts +5 -0
  858. package/src/oauth/oauth.controller.ts +116 -0
  859. package/src/oauth/oauth.module.ts +36 -0
  860. package/src/oauth/oauth.service.ts +364 -0
  861. package/src/oauth/providers/abstract.provider.ts +50 -0
  862. package/src/oauth/providers/facebook.provider.ts +69 -0
  863. package/src/oauth/providers/github.provider.ts +113 -0
  864. package/src/oauth/providers/google.provider.ts +108 -0
  865. package/src/oauth/providers/microsoft.provider.ts +76 -0
  866. package/src/profile/dto/change-password.dto.ts +16 -0
  867. package/src/profile/dto/email-verification-confirm.dto.ts +19 -0
  868. package/src/profile/dto/generate-webauthn-registration-options.dto.ts +7 -0
  869. package/src/profile/dto/regenerate-recovery-codes.dto.ts +18 -0
  870. package/src/profile/dto/remove-email-mfa.dto.ts +11 -0
  871. package/src/profile/dto/remove-mfa-with-recovery-code.dto.ts +7 -0
  872. package/src/profile/dto/remove-mfa.dto.ts +18 -0
  873. package/src/profile/dto/remove-totp-mfa.dto.ts +7 -0
  874. package/src/profile/dto/send-email-verification.dto.ts +9 -0
  875. package/src/profile/dto/set-preferences.dto.ts +11 -0
  876. package/src/profile/dto/update.dto.ts +10 -0
  877. package/src/profile/dto/verify-before-add-mfa.dto.ts +16 -0
  878. package/src/profile/dto/verify-mfa-totp.dto.ts +19 -0
  879. package/src/profile/dto/verify-webauthn-registration.dto.ts +11 -0
  880. package/src/profile/dto/verify-webauthn.dto.ts +7 -0
  881. package/src/profile/profile.controller.ts +201 -0
  882. package/src/profile/profile.module.ts +21 -0
  883. package/src/profile/profile.service.ts +1331 -0
  884. package/src/role/dto/create.dto.ts +7 -0
  885. package/src/role/dto/update.dto.ts +4 -0
  886. package/src/role/guards/role.guard.ts +121 -0
  887. package/src/role/role.controller.ts +126 -0
  888. package/src/role/role.module.ts +29 -0
  889. package/src/role/role.service.ts +289 -0
  890. package/src/route/dto/create.dto.ts +14 -0
  891. package/src/route/dto/update.dto.ts +16 -0
  892. package/src/route/route.controller.ts +91 -0
  893. package/src/route/route.module.ts +18 -0
  894. package/src/route/route.service.spec.ts +300 -0
  895. package/src/route/route.service.ts +164 -0
  896. package/src/screen/dto/create.dto.ts +12 -0
  897. package/src/screen/dto/update.dto.ts +20 -0
  898. package/src/screen/screen.controller.ts +93 -0
  899. package/src/screen/screen.module.ts +18 -0
  900. package/src/screen/screen.service.spec.ts +298 -0
  901. package/src/screen/screen.service.ts +179 -0
  902. package/src/security/security.module.ts +10 -0
  903. package/src/security/security.service.ts +103 -0
  904. package/src/session/session.controller.ts +35 -0
  905. package/src/session/session.module.ts +26 -0
  906. package/src/session/session.service.ts +207 -0
  907. package/src/setting/dto/confirm-import.dto.ts +7 -0
  908. package/src/setting/dto/create.dto.ts +21 -0
  909. package/src/setting/dto/delete.dto.ts +8 -0
  910. package/src/setting/dto/export.dto.ts +11 -0
  911. package/src/setting/dto/import-validation.dto.ts +6 -0
  912. package/src/setting/dto/setting-user.dto.ts +6 -0
  913. package/src/setting/dto/setting.dto.ts +17 -0
  914. package/src/setting/dto/update.dto.ts +4 -0
  915. package/src/setting/setting.controller.ts +136 -0
  916. package/src/setting/setting.module.ts +21 -0
  917. package/src/setting/setting.service.ts +673 -0
  918. package/src/task/task.module.ts +9 -0
  919. package/src/task/task.service.ts +55 -0
  920. package/src/token/token.module.ts +14 -0
  921. package/src/token/token.service.ts +110 -0
  922. package/src/types/http-method.ts +8 -0
  923. package/src/types/multer.d.ts +28 -0
  924. package/src/types/multer.ts +28 -0
  925. package/src/user/constants/user.constants.ts +1 -0
  926. package/src/user/dto/create-with-email-and-password.dto.ts +21 -0
  927. package/src/user/dto/update.dto.ts +11 -0
  928. package/src/user/user.controller.ts +87 -0
  929. package/src/user/user.module.ts +34 -0
  930. package/src/user/user.service.spec.ts +294 -0
  931. package/src/user/user.service.ts +269 -0
  932. package/src/utils/locale-context.ts +12 -0
  933. package/src/validators/is-email-with-settings.validator.ts +82 -0
  934. package/src/validators/is-pin-code-with-setting.validator.ts +81 -0
  935. package/src/validators/is-strong-password-with-settings.validator.ts +125 -0
@@ -0,0 +1,1331 @@
1
+ import { getLocaleText } from '@hed-hog/api-locale';
2
+ import { PrismaService, user } from '@hed-hog/api-prisma';
3
+ import { BadRequestException, forwardRef, Inject, Injectable, NotFoundException } from '@nestjs/common';
4
+ import { JwtService } from '@nestjs/jwt';
5
+ import type {
6
+ VerifiedAuthenticationResponse,
7
+ VerifiedRegistrationResponse,
8
+ } from '@simplewebauthn/server';
9
+ import {
10
+ generateAuthenticationOptions,
11
+ generateRegistrationOptions,
12
+ verifyAuthenticationResponse,
13
+ verifyRegistrationResponse,
14
+ } from '@simplewebauthn/server';
15
+ import * as qrcode from 'qrcode';
16
+ import * as speakeasy from 'speakeasy';
17
+ import { ChallengeService } from '../challenge/challenge.service';
18
+ import { SecurityService } from '../security/security.service';
19
+ import { SettingService } from '../setting/setting.service';
20
+ import { TokenService } from '../token/token.service';
21
+ import { UserService } from '../user/user.service';
22
+ import { ChangePasswordDto } from './dto/change-password.dto';
23
+ import { EmailVerificationDto } from './dto/email-verification-confirm.dto';
24
+ import { SendEmailVerificationDto } from './dto/send-email-verification.dto';
25
+ import { SetPreferencesDto } from './dto/set-preferences.dto';
26
+ import { UpdateDto } from './dto/update.dto';
27
+
28
+ @Injectable()
29
+ export class ProfileService {
30
+ public settings: Record<string, any> = {};
31
+
32
+ constructor(
33
+ private readonly prisma: PrismaService,
34
+ private readonly user: UserService,
35
+ @Inject(forwardRef(() => JwtService))
36
+ private readonly jwt: JwtService,
37
+ @Inject(forwardRef(() => SettingService))
38
+ private readonly setting: SettingService,
39
+ private readonly security: SecurityService,
40
+ private readonly challenge: ChallengeService,
41
+ @Inject(forwardRef(() => TokenService))
42
+ private readonly token: TokenService,
43
+ ) {}
44
+
45
+ async updatePreferences(locale: string, userId: number, { theme, language }: SetPreferencesDto) {
46
+ if (theme) {
47
+ await this.setting.setSettingUserValue(locale, userId, 'theme-mode', theme);
48
+ }
49
+
50
+ if (language) {
51
+ await this.setting.setSettingUserValue(locale, userId, 'language', language);
52
+ }
53
+ return { success: true };
54
+ }
55
+
56
+ async onModuleInit() {
57
+ this.settings = await this.setting.getSettingValues([
58
+ 'mfa-issuer',
59
+ 'mfa-window',
60
+ 'mfa-setp',
61
+ 'system-name',
62
+ 'google_client_id',
63
+ 'google_client_secret',
64
+ 'google_scopes',
65
+ 'url',
66
+ 'mfa-challenge-expiration-minutes',
67
+ 'access-token-expiration-minutes'
68
+ ]);
69
+ }
70
+
71
+ async confirmEmailVerification(locale: string, userId: number, { pin, hash, name, email }: EmailVerificationDto) {
72
+ const challenge = await this.challenge.verifyCode(locale, userId, pin, hash, name, email)
73
+ const updatedUser = await this.prisma.user.findFirst({ where: { id: userId }})
74
+ const codes = await this.createMfaRecoveryCodes(updatedUser.id);
75
+ const newToken = await this.getToken(updatedUser);
76
+ return { ...newToken, challenge, codes };
77
+ }
78
+
79
+ async sendEmailVerification(locale: string, userId: number, { email }: SendEmailVerificationDto) {
80
+ const { codeHash } = await this.challenge.verifyEmail(locale, userId, email);
81
+ return { codeHash };
82
+ }
83
+
84
+ async sendCodeToRemove(locale, userId, email){
85
+ return this.challenge.verifyEmail(locale, userId, email)
86
+ }
87
+
88
+ async getEmailIdentifier(userId: number) {
89
+ return this.prisma.user_identifier.findFirst({
90
+ where: { user_id: userId, type: 'email' },
91
+ });
92
+ }
93
+
94
+ async getProfile(userId: number) {
95
+ return this.prisma.user.findUnique({
96
+ where: { id: userId },
97
+ });
98
+ }
99
+
100
+ async getMFAMethods(userId: number) {
101
+ return this.prisma.user_mfa.findMany({
102
+ where: { user_id: userId },
103
+ include: {
104
+ user_mfa_email: true,
105
+ user_mfa_totp: true,
106
+ user_mfa_webauthn: true,
107
+ },
108
+ });
109
+ }
110
+
111
+ async updateMFA(userId: number, mfaId: number, { name }: UpdateDto){
112
+ return this.prisma.user_mfa.update({
113
+ where: { user_id: userId, id: mfaId },
114
+ data: { name }
115
+ })
116
+ }
117
+
118
+ async update(userid: number, { name }: UpdateDto) {
119
+ return this.prisma.user.update({
120
+ where: { id: userid },
121
+ data: {
122
+ name,
123
+ },
124
+ });
125
+ }
126
+
127
+ async updateAvatar(userId: number, file: MulterFile) {
128
+ return this.user.changeAvatar(userId, file);
129
+ }
130
+
131
+ async changePassword(locale:string, userId: number, {currentPassword, newPassword}: ChangePasswordDto) {
132
+ const credential = await this.prisma.user_credential.findFirst({
133
+ where: { user_id: userId, type: 'password' },
134
+ });
135
+
136
+ if (!credential) {
137
+ throw new NotFoundException(getLocaleText('userNotFound', locale, 'User not found.'));
138
+ }
139
+
140
+ const isValidPassowrd = await this.security.validatePassword(locale, [credential], currentPassword)
141
+ if (!isValidPassowrd) {
142
+ throw new BadRequestException(getLocaleText('accessDenied', locale, 'Access denied.'));
143
+ }
144
+
145
+ const passwordHash = await this.security.hashArgon2(newPassword);
146
+ await this.prisma.user_credential.update({
147
+ where: { id: credential.id },
148
+ data: { hash: passwordHash },
149
+ });
150
+
151
+ return { success: true };
152
+ }
153
+
154
+ generateRecoveryCodes(count = 10): string[] {
155
+ const codes = Array.from({ length: count }, () => {
156
+ const array = new Uint8Array(4);
157
+ globalThis.crypto.getRandomValues(array);
158
+ return Array.from(array)
159
+ .map((b) => b.toString(16).padStart(2, '0'))
160
+ .join('');
161
+ });
162
+ return codes;
163
+ }
164
+
165
+
166
+ async createMfaRecoveryCodes(userId: number) {
167
+ const codes = this.generateRecoveryCodes();
168
+ await this.prisma.user_recovery_code.deleteMany({
169
+ where: {
170
+ user_id: userId,
171
+ },
172
+ });
173
+
174
+ const data = await Promise.all(
175
+ codes.map(async (code) => ({
176
+ user_id: userId,
177
+ hash: await this.security.hashArgon2(code),
178
+ })),
179
+ );
180
+
181
+ await this.prisma.user_recovery_code.createMany({ data });
182
+ return codes;
183
+ }
184
+
185
+ async getToken(user: user) {
186
+ return { token: this.jwt.sign(user) };
187
+ }
188
+
189
+ async verifyMfaTotp(userId: number, token: string, secret: string, name?: string) {
190
+ const window = this.settings['mfa-window'] ?? 0;
191
+ const step = this.settings['mfa-setp'] ?? 30;
192
+ const user = await this.prisma.user.findFirst({
193
+ where: { id: userId },
194
+ include: { user_mfa: { include: { user_mfa_totp: true }}}
195
+ });
196
+
197
+ if (!user) {
198
+ throw new NotFoundException(getLocaleText('userNotFound', 'en', 'User not found'));
199
+ }
200
+
201
+ const decodedSecret = Buffer.from(secret, 'base64').toString('utf-8');
202
+ const decryptedSecret = this.security.decrypt(decodedSecret);
203
+ const isValid = speakeasy.totp.verify({
204
+ secret: decryptedSecret,
205
+ encoding: 'base32',
206
+ token,
207
+ window,
208
+ step
209
+ });
210
+
211
+ if (!isValid) {
212
+ throw new BadRequestException(getLocaleText('invalidCode', 'en', 'Invalid code'));
213
+ }
214
+
215
+ if (name){
216
+ await this.prisma.user_mfa.create({
217
+ data: {
218
+ name,
219
+ user_id: userId,
220
+ type: 'totp',
221
+ verified_at: new Date(),
222
+ user_mfa_totp: {
223
+ create: {
224
+ secret: Buffer.from(decryptedSecret, 'utf-8'),
225
+ }
226
+ },
227
+ user_mfa_challenge: {
228
+ create: {
229
+ hash: await this.security.hashArgon2(decryptedSecret),
230
+ attempts: 1,
231
+ expires_at: new Date(),
232
+ verified_at: new Date()
233
+ }
234
+ }},
235
+ });
236
+ }
237
+
238
+ const updatedUser = await this.prisma.user.findFirst({ where: { id: user.id }})
239
+ const codes = await this.createMfaRecoveryCodes(updatedUser.id);
240
+ const newToken = await this.getToken(updatedUser);
241
+ return { ...newToken, codes };
242
+ }
243
+
244
+ async generateMfaTotp(locale: string, userId: number) {
245
+ const user = await this.prisma.user.findFirst({
246
+ where: { id: userId },
247
+ select: {
248
+ user_mfa: true,
249
+ user_identifier: true
250
+ },
251
+ });
252
+
253
+ const issuer = this.settings['mfa-issuer'] ?? 'Hedhog';
254
+ const userEmail = user.user_identifier.find(ui => ui.type === 'email').value
255
+ const appName = `${issuer} (${userEmail})`;
256
+
257
+ const secret = speakeasy.generateSecret({
258
+ length: 32,
259
+ name: appName,
260
+ otpauth: { label: appName, issuer },
261
+ encoding: 'base32',
262
+ });
263
+
264
+ const step = this.settings['mfa-setp'] ?? 30;
265
+ const otpauth = speakeasy.otpauthURL({
266
+ secret: secret.base32,
267
+ label: `${issuer}:${userEmail}`,
268
+ issuer,
269
+ period: step,
270
+ encoding: 'base32',
271
+ });
272
+
273
+ const qrCode = await qrcode.toDataURL(otpauth);
274
+ const encryptedSecret = this.security.encrypt(secret.base32);
275
+ const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
276
+ return { otpauthUrl: secret.otpauth_url, qrCode, secret: encodedSecret };
277
+ }
278
+
279
+ async removeMfaTotp(userId: number, mfaId: number, token: string) {
280
+ try {
281
+ const user = await this.prisma.user.findFirst({
282
+ where: { id: userId },
283
+ include: { user_identifier: true, user_mfa: { include: { user_mfa_totp: true }} }
284
+ });
285
+
286
+
287
+ const totpMfa = user.user_mfa.find((m) => m.type === 'totp' && m.user_mfa_totp);
288
+ if (!totpMfa || !totpMfa.user_mfa_totp) {
289
+ throw new NotFoundException(getLocaleText('totpNotFound', 'en', 'TOTP method not found'));
290
+ }
291
+
292
+ const secretBuffer = totpMfa.user_mfa_totp[0].secret;
293
+ const secretBase32 = secretBuffer instanceof Uint8Array
294
+ ? Buffer.from(secretBuffer).toString('utf-8')
295
+ : String(secretBuffer);
296
+
297
+ const encryptedSecret = this.security.encrypt(secretBase32);
298
+ const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
299
+ await this.verifyMfaTotp(user.id, token, encodedSecret);
300
+ await this.prisma.$transaction(async (tx) => {
301
+ await tx.user_mfa.deleteMany({
302
+ where: {
303
+ id: mfaId,
304
+ user_id: userId,
305
+ type: 'totp',
306
+ },
307
+ });
308
+
309
+ await tx.user_recovery_code.deleteMany({
310
+ where: {
311
+ user_id: userId,
312
+ },
313
+ });
314
+ });
315
+
316
+ return this.getUserToken(userId)
317
+ } catch (error: any) {
318
+ throw new BadRequestException(`Invalid code: ${error?.message}`);
319
+ }
320
+ }
321
+
322
+ async removeMfaEmail(locale: string, userId: number, mfaId: number, token: string, providedHash: string) {
323
+ try {
324
+ await this.challenge.verifyCode(locale, userId, token, providedHash)
325
+ await this.prisma.user_mfa.deleteMany({
326
+ where: { id: mfaId, user_id: userId, type: 'email' },
327
+ });
328
+
329
+ return this.getUserToken(userId)
330
+ } catch (error: any) {
331
+ throw new BadRequestException(`Invalid code: ${error?.message}`);
332
+ }
333
+ }
334
+
335
+ async removeMfaWithRecoveryCode(locale: string, userId: number, mfaId: number, recoveryCode: string) {
336
+ try {
337
+ const user = await this.prisma.user.findUnique({
338
+ where: { id: userId },
339
+ include: {
340
+ user_recovery_code: true,
341
+ },
342
+ });
343
+
344
+ if (!user) {
345
+ throw new NotFoundException(getLocaleText('userNotFound', 'en', 'User not found'));
346
+ }
347
+
348
+ let isValid = false;
349
+ for (const code of user.user_recovery_code) {
350
+ if (await this.security.verifyArgon2(recoveryCode, code.hash)) {
351
+ isValid = true;
352
+ await this.prisma.user_recovery_code.delete({
353
+ where: { id: code.id },
354
+ });
355
+ break;
356
+ }
357
+ }
358
+
359
+ if (!isValid) {
360
+ throw new BadRequestException(
361
+ getLocaleText('invalidRecoveryCode', locale, 'Invalid recovery code.')
362
+ );
363
+ }
364
+
365
+ await this.prisma.user_mfa.deleteMany({
366
+ where: { id: mfaId, user_id: userId },
367
+ });
368
+
369
+ return this.getUserToken(userId);
370
+ } catch (error: any) {
371
+ throw new BadRequestException(`Invalid code: ${error?.message}`);
372
+ }
373
+ }
374
+
375
+ async removeMfa(locale: string, userId: number, mfaId: number, data: { token?: string; hash?: string; verificationType?: 'totp' | 'email' | 'recovery' | 'webauthn'; assertionResponse?: any }) {
376
+ try {
377
+ const user = await this.prisma.user.findUnique({
378
+ where: { id: userId },
379
+ include: {
380
+ user_mfa: {
381
+ where: { id: mfaId, verified_at: { not: null } },
382
+ include: {
383
+ user_mfa_totp: true,
384
+ user_mfa_email: true,
385
+ user_mfa_webauthn: true
386
+ }
387
+ },
388
+ user_recovery_code: true
389
+ }
390
+ });
391
+
392
+ if (!user) {
393
+ throw new BadRequestException(
394
+ getLocaleText('userNotFound', locale, 'User not found.')
395
+ );
396
+ }
397
+
398
+ const mfaToRemove = user.user_mfa.find(m => m.id === mfaId);
399
+ if (!mfaToRemove) {
400
+ throw new BadRequestException(
401
+ getLocaleText('mfaMethodNotFound', locale, 'MFA method not found.')
402
+ );
403
+ }
404
+
405
+ if (data.verificationType !== 'webauthn' && !data.token) {
406
+ throw new BadRequestException(
407
+ getLocaleText('verificationCodeRequired', locale, 'Verification code is required.')
408
+ );
409
+ }
410
+
411
+ if (data.verificationType === 'webauthn') {
412
+ if (!data.assertionResponse) {
413
+ throw new BadRequestException(
414
+ getLocaleText('assertionResponseRequired', locale, 'Assertion response is required for WebAuthn.')
415
+ );
416
+ }
417
+
418
+ try {
419
+ await this.verifyWebAuthnAuthentication(userId, data.assertionResponse);
420
+ } catch (error) {
421
+ throw new BadRequestException(
422
+ getLocaleText('invalidWebAuthn', locale, 'WebAuthn verification failed.')
423
+ );
424
+ }
425
+ } else if (data.verificationType === 'recovery') {
426
+ if (!data.token) {
427
+ throw new BadRequestException(
428
+ getLocaleText('verificationCodeRequired', locale, 'Verification code is required.')
429
+ );
430
+ }
431
+
432
+ let isValid = false;
433
+ for (const recoveryCode of user.user_recovery_code) {
434
+ if (await this.security.verifyArgon2(data.token, recoveryCode.hash)) {
435
+ isValid = true;
436
+ await this.prisma.user_recovery_code.delete({
437
+ where: { id: recoveryCode.id }
438
+ });
439
+ break;
440
+ }
441
+ }
442
+
443
+ if (!isValid) {
444
+ throw new BadRequestException(
445
+ getLocaleText('invalidRecoveryCode', locale, 'Invalid recovery code.')
446
+ );
447
+ }
448
+ } else if (data.verificationType === 'email' || mfaToRemove.type === 'email') {
449
+ if (!data.token) {
450
+ throw new BadRequestException(
451
+ getLocaleText('verificationCodeRequired', locale, 'Verification code is required.')
452
+ );
453
+ }
454
+
455
+ try {
456
+ const isValid = await this.challenge.verifyMfaEmailCode(locale, userId, data.token);
457
+ if (!isValid) {
458
+ throw new BadRequestException(
459
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
460
+ );
461
+ }
462
+ } catch (error) {
463
+ throw new BadRequestException(
464
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
465
+ );
466
+ }
467
+ } else if (data.verificationType === 'totp' || mfaToRemove.type === 'totp') {
468
+ const totpMfa = user.user_mfa.find(m => m.type === 'totp' && m.user_mfa_totp);
469
+ if (!totpMfa || !totpMfa.user_mfa_totp || !totpMfa.user_mfa_totp[0]) {
470
+ throw new BadRequestException(
471
+ getLocaleText('totpMfaNotFound', locale, 'TOTP MFA not found.')
472
+ );
473
+ }
474
+
475
+ const secretBuffer = totpMfa.user_mfa_totp[0].secret;
476
+ const secretBase32 = secretBuffer instanceof Uint8Array
477
+ ? Buffer.from(secretBuffer).toString('utf-8')
478
+ : String(secretBuffer);
479
+
480
+ const encryptedSecret = this.security.encrypt(secretBase32);
481
+ const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
482
+
483
+ try {
484
+ await this.verifyMfaTotp(userId, data.token, encodedSecret);
485
+ } catch (error) {
486
+ throw new BadRequestException(
487
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
488
+ );
489
+ }
490
+ }
491
+
492
+ await this.prisma.user_mfa.deleteMany({
493
+ where: { id: mfaId, user_id: userId },
494
+ });
495
+
496
+ return this.getUserToken(userId);
497
+ } catch (error: any) {
498
+ throw new BadRequestException(`Failed to remove MFA: ${error?.message}`);
499
+ }
500
+ }
501
+
502
+ async checkMfaBeforeAdd(locale: string, userId: number) {
503
+ try {
504
+ const mfaMethods = await this.prisma.user_mfa.findMany({
505
+ where: {
506
+ user_id: userId,
507
+ verified_at: { not: null }
508
+ },
509
+ include: {
510
+ user_mfa_totp: true,
511
+ user_mfa_email: true,
512
+ user_mfa_webauthn: true
513
+ }
514
+ });
515
+
516
+ if (mfaMethods.length === 0) {
517
+ return { requiresVerification: false };
518
+ }
519
+
520
+ const totpMfa = mfaMethods.find(m => m.type === 'totp' && m.user_mfa_totp);
521
+ const emailMfas = mfaMethods.filter(m => m.type === 'email' && m.user_mfa_email && m.user_mfa_email.length > 0);
522
+ const webauthnMfa = mfaMethods.find(m => m.type === 'webauthn' && m.user_mfa_webauthn);
523
+
524
+ const availableMethods: ('totp' | 'email')[] = [];
525
+
526
+ if (totpMfa) {
527
+ availableMethods.push('totp');
528
+ }
529
+
530
+ if (emailMfas.length > 0) {
531
+ const emails = emailMfas.map(mfa => mfa.user_mfa_email[0].email);
532
+ await this.challenge.sendMfaCodeToMultipleEmails(locale, userId, emails);
533
+ availableMethods.push('email');
534
+ }
535
+
536
+ if (availableMethods.length === 0 && !webauthnMfa) {
537
+ return { requiresVerification: false };
538
+ }
539
+
540
+ if (availableMethods.length === 0 && webauthnMfa) {
541
+ return {
542
+ requiresVerification: true,
543
+ availableMethods: [],
544
+ hasWebAuthn: true,
545
+ hasRecoveryCodes: true,
546
+ };
547
+ }
548
+
549
+ if (availableMethods.length === 2) {
550
+ return {
551
+ requiresVerification: true,
552
+ availableMethods,
553
+ hasWebAuthn: !!webauthnMfa,
554
+ hasRecoveryCodes: true,
555
+ };
556
+ }
557
+
558
+ return {
559
+ requiresVerification: true,
560
+ verificationType: availableMethods[0],
561
+ hasWebAuthn: !!webauthnMfa,
562
+ hasRecoveryCodes: true,
563
+ };
564
+ } catch (error: any) {
565
+ throw new BadRequestException(`Failed to check MFA: ${error?.message}`);
566
+ }
567
+ }
568
+
569
+ async checkMfaBeforeRemove(locale: string, userId: number) {
570
+ try {
571
+ const mfaMethods = await this.prisma.user_mfa.findMany({
572
+ where: {
573
+ user_id: userId,
574
+ verified_at: { not: null }
575
+ },
576
+ include: {
577
+ user_mfa_totp: true,
578
+ user_mfa_email: true,
579
+ user_mfa_webauthn: true
580
+ }
581
+ });
582
+
583
+ if (mfaMethods.length === 0) {
584
+ throw new BadRequestException(
585
+ getLocaleText('noMfaMethodsFound', locale, 'No MFA methods found.')
586
+ );
587
+ }
588
+
589
+ const totpMfa = mfaMethods.find(m => m.type === 'totp' && m.user_mfa_totp);
590
+ const emailMfas = mfaMethods.filter(m => m.type === 'email' && m.user_mfa_email && m.user_mfa_email.length > 0);
591
+ const webauthnMfa = mfaMethods.find(m => m.type === 'webauthn' && m.user_mfa_webauthn);
592
+ const availableMethods: ('totp' | 'email')[] = [];
593
+
594
+ if (totpMfa) {
595
+ availableMethods.push('totp');
596
+ }
597
+
598
+ if (emailMfas.length > 0) {
599
+ const emails = emailMfas.map(mfa => mfa.user_mfa_email[0].email);
600
+ await this.challenge.sendMfaCodeToMultipleEmails(locale, userId, emails);
601
+ availableMethods.push('email');
602
+ }
603
+
604
+ return {
605
+ requiresVerification: true,
606
+ availableMethods,
607
+ hasWebAuthn: !!webauthnMfa,
608
+ hasRecoveryCodes: mfaMethods.length > 0,
609
+ };
610
+ } catch (error: any) {
611
+ throw new BadRequestException(`Failed to check MFA before remove: ${error?.message}`);
612
+ }
613
+ }
614
+
615
+ async verifyBeforeAddMfa(
616
+ locale: string,
617
+ userId: number,
618
+ data: { verificationCode?: string; hash?: string; verificationType: 'totp' | 'email' | 'recovery' | 'webauthn'; assertionResponse?: any }
619
+ ) {
620
+ try {
621
+ const user = await this.prisma.user.findUnique({
622
+ where: { id: userId },
623
+ include: {
624
+ user_mfa: {
625
+ where: { verified_at: { not: null } },
626
+ include: {
627
+ user_mfa_totp: true,
628
+ user_mfa_email: true,
629
+ user_mfa_webauthn: true
630
+ }
631
+ },
632
+ user_recovery_code: true
633
+ }
634
+ });
635
+
636
+ if (!user) {
637
+ throw new BadRequestException(
638
+ getLocaleText('userNotFound', locale, 'User not found.')
639
+ );
640
+ }
641
+
642
+ if (user.user_mfa.length === 0) {
643
+ return { success: true };
644
+ }
645
+
646
+ if (data.verificationType === 'webauthn') {
647
+ if (!data.assertionResponse) {
648
+ throw new BadRequestException(
649
+ getLocaleText('assertionResponseRequired', locale, 'Assertion response is required for WebAuthn.')
650
+ );
651
+ }
652
+
653
+ try {
654
+ await this.verifyWebAuthnAuthentication(userId, data.assertionResponse);
655
+ } catch (error) {
656
+ throw new BadRequestException(
657
+ getLocaleText('invalidWebAuthn', locale, 'WebAuthn verification failed.')
658
+ );
659
+ }
660
+ } else if (data.verificationType === 'recovery') {
661
+ if (!data.verificationCode) {
662
+ throw new BadRequestException(
663
+ getLocaleText('verificationCodeRequired', locale, 'Verification code is required.')
664
+ );
665
+ }
666
+
667
+ let isValid = false;
668
+ for (const recoveryCode of user.user_recovery_code) {
669
+ if (await this.security.verifyArgon2(data.verificationCode, recoveryCode.hash)) {
670
+ isValid = true;
671
+ await this.prisma.user_recovery_code.delete({
672
+ where: { id: recoveryCode.id }
673
+ });
674
+ break;
675
+ }
676
+ }
677
+
678
+ if (!isValid) {
679
+ throw new BadRequestException(
680
+ getLocaleText('invalidRecoveryCode', locale, 'Invalid recovery code.')
681
+ );
682
+ }
683
+ } else if (data.verificationType === 'email') {
684
+ const emailMfa = user.user_mfa.find(m => m.type === 'email' && m.user_mfa_email);
685
+ if (!emailMfa) {
686
+ throw new BadRequestException(
687
+ getLocaleText('emailMfaNotFound', locale, 'Email MFA not found.')
688
+ );
689
+ }
690
+
691
+ if (!data.verificationCode) {
692
+ throw new BadRequestException(
693
+ getLocaleText('verificationCodeRequired', locale, 'Verification code is required.')
694
+ );
695
+ }
696
+
697
+ try {
698
+ const isValid = await this.challenge.verifyMfaEmailCode(locale, userId, data.verificationCode);
699
+ if (!isValid) {
700
+ throw new BadRequestException(
701
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
702
+ );
703
+ }
704
+ } catch (error) {
705
+ throw new BadRequestException(
706
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
707
+ );
708
+ }
709
+ } else {
710
+ const totpMfa = user.user_mfa.find(m => m.type === 'totp' && m.user_mfa_totp);
711
+ if (!totpMfa || !totpMfa.user_mfa_totp[0]) {
712
+ throw new BadRequestException(
713
+ getLocaleText('totpMfaNotFound', locale, 'TOTP MFA not found.')
714
+ );
715
+ }
716
+
717
+ const secretBuffer = totpMfa.user_mfa_totp[0].secret;
718
+ const secretBase32 = secretBuffer instanceof Uint8Array
719
+ ? Buffer.from(secretBuffer).toString('utf-8')
720
+ : String(secretBuffer);
721
+
722
+ const encryptedSecret = this.security.encrypt(secretBase32);
723
+ const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
724
+
725
+ try {
726
+ await this.verifyMfaTotp(userId, data.verificationCode, encodedSecret);
727
+ } catch (error) {
728
+ throw new BadRequestException(
729
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
730
+ );
731
+ }
732
+ }
733
+
734
+ return { success: true };
735
+ } catch (error: any) {
736
+ throw new BadRequestException(`Failed to verify MFA: ${error?.message}`);
737
+ }
738
+ }
739
+
740
+ async sendRecoveryCodesVerification(locale: string, userId: number) {
741
+ try {
742
+ const mfaMethods = await this.prisma.user_mfa.findMany({
743
+ where: {
744
+ user_id: userId,
745
+ verified_at: { not: null }
746
+ },
747
+ include: {
748
+ user_mfa_totp: true,
749
+ user_mfa_email: true,
750
+ user_mfa_webauthn: true
751
+ }
752
+ });
753
+
754
+ if (mfaMethods.length === 0) {
755
+ return { requiresVerification: false };
756
+ }
757
+
758
+ const totpMfa = mfaMethods.find(m => m.type === 'totp' && m.user_mfa_totp);
759
+ const emailMfas = mfaMethods.filter(m => m.type === 'email' && m.user_mfa_email && m.user_mfa_email.length > 0);
760
+ const webauthnMfa = mfaMethods.find(m => m.type === 'webauthn' && m.user_mfa_webauthn);
761
+ const availableMethods: ('totp' | 'email')[] = [];
762
+
763
+ if (totpMfa) {
764
+ availableMethods.push('totp');
765
+ }
766
+
767
+ if (emailMfas.length > 0) {
768
+ const emails = emailMfas.map(mfa => mfa.user_mfa_email[0].email);
769
+ await this.challenge.sendMfaCodeToMultipleEmails(locale, userId, emails);
770
+ availableMethods.push('email');
771
+ }
772
+
773
+ if (availableMethods.length === 0 && !webauthnMfa) {
774
+ return { requiresVerification: false };
775
+ }
776
+
777
+ if (availableMethods.length === 0 && webauthnMfa) {
778
+ return {
779
+ requiresVerification: true,
780
+ availableMethods: [],
781
+ hasWebAuthn: true,
782
+ hasRecoveryCodes: true,
783
+ };
784
+ }
785
+
786
+ if (availableMethods.length === 2) {
787
+ return {
788
+ requiresVerification: true,
789
+ availableMethods,
790
+ hasWebAuthn: !!webauthnMfa,
791
+ hasRecoveryCodes: true,
792
+ };
793
+ }
794
+
795
+ return {
796
+ requiresVerification: true,
797
+ verificationType: availableMethods[0],
798
+ hasWebAuthn: !!webauthnMfa,
799
+ hasRecoveryCodes: true,
800
+ };
801
+ } catch (error: any) {
802
+ throw new BadRequestException(`Failed to send verification: ${error?.message}`);
803
+ }
804
+ }
805
+
806
+ async regenerateRecoveryCodes(locale: string, userId: number, data: { verificationCode?: string; hash?: string; verificationType?: 'totp' | 'email' | 'recovery' | 'webauthn'; assertionResponse?: any }) {
807
+ try {
808
+ const user = await this.prisma.user.findUnique({
809
+ where: { id: userId },
810
+ include: {
811
+ user_mfa: {
812
+ where: { verified_at: { not: null } },
813
+ include: {
814
+ user_mfa_totp: true,
815
+ user_mfa_email: true,
816
+ user_mfa_webauthn: true
817
+ }
818
+ },
819
+ user_recovery_code: true
820
+ }
821
+ });
822
+
823
+ if (!user) {
824
+ throw new BadRequestException(
825
+ getLocaleText('userNotFound', locale, 'User not found.')
826
+ );
827
+ }
828
+
829
+ if (user.user_mfa.length > 0) {
830
+ if (data.verificationType !== 'webauthn' && !data.verificationCode) {
831
+ throw new BadRequestException(
832
+ getLocaleText('verificationCodeRequired', locale, 'Verification code is required.')
833
+ );
834
+ }
835
+
836
+ if (data.verificationType === 'webauthn') {
837
+ if (!data.assertionResponse) {
838
+ throw new BadRequestException(
839
+ getLocaleText('assertionResponseRequired', locale, 'Assertion response is required for WebAuthn.')
840
+ );
841
+ }
842
+
843
+ try {
844
+ await this.verifyWebAuthnAuthentication(userId, data.assertionResponse);
845
+ } catch (error) {
846
+ throw new BadRequestException(
847
+ getLocaleText('invalidWebAuthn', locale, 'WebAuthn verification failed.')
848
+ );
849
+ }
850
+ } else if (data.verificationType === 'recovery') {
851
+ if (!data.verificationCode) {
852
+ throw new BadRequestException(
853
+ getLocaleText('verificationCodeRequired', locale, 'Verification code is required.')
854
+ );
855
+ }
856
+
857
+ let isValid = false;
858
+ for (const recoveryCode of user.user_recovery_code) {
859
+ if (await this.security.verifyArgon2(data.verificationCode, recoveryCode.hash)) {
860
+ isValid = true;
861
+ await this.prisma.user_recovery_code.delete({
862
+ where: { id: recoveryCode.id }
863
+ });
864
+ break;
865
+ }
866
+ }
867
+
868
+ if (!isValid) {
869
+ throw new BadRequestException(
870
+ getLocaleText('invalidRecoveryCode', locale, 'Invalid recovery code.')
871
+ );
872
+ }
873
+ } else if (data.verificationType === 'email') {
874
+ const emailMfa = user.user_mfa.find(m => m.type === 'email' && m.user_mfa_email);
875
+ if (!emailMfa) {
876
+ throw new BadRequestException(
877
+ getLocaleText('emailMfaNotFound', locale, 'Email MFA not found.')
878
+ );
879
+ }
880
+
881
+ if (!data.verificationCode) {
882
+ throw new BadRequestException(
883
+ getLocaleText('verificationCodeRequired', locale, 'Verification code is required.')
884
+ );
885
+ }
886
+
887
+ try {
888
+ const isValid = await this.challenge.verifyMfaEmailCode(locale, userId, data.verificationCode);
889
+ if (!isValid) {
890
+ throw new BadRequestException(
891
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
892
+ );
893
+ }
894
+ } catch (error) {
895
+ throw new BadRequestException(
896
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
897
+ );
898
+ }
899
+ } else {
900
+ const totpMfa = user.user_mfa.find(m => m.type === 'totp' && m.user_mfa_totp);
901
+ if (!totpMfa || !totpMfa.user_mfa_totp[0]) {
902
+ throw new BadRequestException(
903
+ getLocaleText('totpMfaNotFound', locale, 'TOTP MFA not found.')
904
+ );
905
+ }
906
+
907
+ const secretBuffer = totpMfa.user_mfa_totp[0].secret;
908
+ const secretBase32 = secretBuffer instanceof Uint8Array
909
+ ? Buffer.from(secretBuffer).toString('utf-8')
910
+ : String(secretBuffer);
911
+
912
+ const encryptedSecret = this.security.encrypt(secretBase32);
913
+ const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
914
+
915
+ try {
916
+ await this.verifyMfaTotp(userId, data.verificationCode, encodedSecret);
917
+ } catch (error) {
918
+ throw new BadRequestException(
919
+ getLocaleText('invalidVerificationCode', locale, 'Invalid verification code.')
920
+ );
921
+ }
922
+ }
923
+ }
924
+
925
+ const codes = await this.createMfaRecoveryCodes(userId);
926
+ return { codes };
927
+ } catch (error: any) {
928
+ throw new BadRequestException(`Failed to regenerate recovery codes: ${error?.message}`);
929
+ }
930
+ }
931
+
932
+ async generateWebAuthnRegistrationOptions(locale: string, userId: number, name: string) {
933
+ try {
934
+ const user = await this.prisma.user.findFirst({
935
+ where: { id: userId },
936
+ include: {
937
+ user_identifier: true,
938
+ user_mfa: {
939
+ where: { type: 'webauthn', verified_at: { not: null } },
940
+ include: { user_mfa_webauthn: true }
941
+ }
942
+ }
943
+ });
944
+
945
+ if (!user) {
946
+ throw new NotFoundException(getLocaleText('userNotFound', locale, 'User not found.'));
947
+ }
948
+
949
+ const rpName = this.settings['system-name'] || 'HedHog';
950
+ const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
951
+ const userEmail = user.user_identifier.find(ui => ui.type === 'email')?.value || `user${userId}@example.com`;
952
+ const existingAuthenticators = user.user_mfa
953
+ .filter(mfa => mfa.user_mfa_webauthn && mfa.user_mfa_webauthn.length > 0)
954
+ .map(mfa => ({
955
+ credentialID: mfa.user_mfa_webauthn[0].credential_id,
956
+ credentialPublicKey: mfa.user_mfa_webauthn[0].public_key,
957
+ counter: mfa.user_mfa_webauthn[0].sign_count,
958
+ }));
959
+
960
+ const options = await generateRegistrationOptions({
961
+ rpName,
962
+ rpID,
963
+ userName: userEmail,
964
+ userDisplayName: user.name || userEmail,
965
+ attestationType: 'none',
966
+ excludeCredentials: existingAuthenticators.map(auth => ({
967
+ id: Buffer.from(auth.credentialID).toString('base64url'),
968
+ })),
969
+ authenticatorSelection: {
970
+ residentKey: 'preferred',
971
+ userVerification: 'preferred',
972
+ },
973
+ });
974
+
975
+ await this.prisma.user_mfa_challenge.create({
976
+ data: {
977
+ user_mfa: {
978
+ create: {
979
+ user_id: userId,
980
+ type: 'webauthn',
981
+ name: name || 'Security Key',
982
+ }
983
+ },
984
+ hash: options.challenge,
985
+ attempts: 0,
986
+ expires_at: new Date(Date.now() + 5 * 60 * 1000),
987
+ }
988
+ });
989
+
990
+ return options;
991
+ } catch (error: any) {
992
+ throw new BadRequestException(`Failed to generate registration options: ${error?.message}`);
993
+ }
994
+ }
995
+
996
+ async verifyWebAuthnRegistration(
997
+ locale: string,
998
+ userId: number,
999
+ name: string,
1000
+ attestationResponse: any
1001
+ ) {
1002
+ try {
1003
+ const challengeRecord = await this.prisma.user_mfa_challenge.findFirst({
1004
+ where: {
1005
+ user_mfa: {
1006
+ user_id: userId,
1007
+ type: 'webauthn',
1008
+ verified_at: null,
1009
+ },
1010
+ expires_at: { gt: new Date() }
1011
+ },
1012
+ include: { user_mfa: true },
1013
+ orderBy: { created_at: 'desc' }
1014
+ });
1015
+
1016
+ if (!challengeRecord) {
1017
+ throw new BadRequestException(
1018
+ getLocaleText('challengeNotFound', locale, 'Challenge not found or expired.')
1019
+ );
1020
+ }
1021
+
1022
+ const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
1023
+ const expectedOrigin = process.env.FRONTEND_URL || 'http://localhost:3200';
1024
+ const verification: VerifiedRegistrationResponse = await verifyRegistrationResponse({
1025
+ response: attestationResponse,
1026
+ expectedChallenge: challengeRecord.hash,
1027
+ expectedOrigin,
1028
+ expectedRPID: rpID,
1029
+ });
1030
+
1031
+ if (!verification.verified || !verification.registrationInfo) {
1032
+ throw new BadRequestException(
1033
+ getLocaleText('verificationFailed', locale, 'Verification failed.')
1034
+ );
1035
+ }
1036
+
1037
+ const { credential } = verification.registrationInfo;
1038
+ await this.prisma.user_mfa.update({
1039
+ where: { id: challengeRecord.user_mfa_id },
1040
+ data: {
1041
+ name,
1042
+ verified_at: new Date(),
1043
+ user_mfa_webauthn: {
1044
+ create: {
1045
+ credential_id: Buffer.from(credential.id, 'base64url'),
1046
+ public_key: credential.publicKey,
1047
+ sign_count: credential.counter,
1048
+ }
1049
+ }
1050
+ }
1051
+ });
1052
+
1053
+ await this.prisma.user_mfa_challenge.update({
1054
+ where: { id: challengeRecord.id },
1055
+ data: { verified_at: new Date() }
1056
+ });
1057
+
1058
+ const codes = await this.createMfaRecoveryCodes(userId);
1059
+ return { success: true, codes };
1060
+ } catch (error: any) {
1061
+ throw new BadRequestException(`Failed to verify registration: ${error?.message}`);
1062
+ }
1063
+ }
1064
+
1065
+ async generateWebAuthnAuthenticationOptions(locale: string, userId: number) {
1066
+ try {
1067
+ const user = await this.prisma.user.findFirst({
1068
+ where: { id: userId },
1069
+ include: {
1070
+ user_mfa: {
1071
+ where: { type: 'webauthn', verified_at: { not: null } },
1072
+ include: { user_mfa_webauthn: true }
1073
+ }
1074
+ }
1075
+ });
1076
+
1077
+ if (!user || user.user_mfa.length === 0) {
1078
+ throw new NotFoundException(
1079
+ getLocaleText('webauthnNotConfigured', locale, 'WebAuthn not configured.')
1080
+ );
1081
+ }
1082
+
1083
+ const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
1084
+ const allowCredentials = user.user_mfa
1085
+ .filter(mfa => mfa.user_mfa_webauthn && mfa.user_mfa_webauthn.length > 0)
1086
+ .map(mfa => ({
1087
+ id: Buffer.from(mfa.user_mfa_webauthn[0].credential_id).toString('base64url'),
1088
+ }));
1089
+
1090
+ const options = await generateAuthenticationOptions({
1091
+ rpID,
1092
+ allowCredentials,
1093
+ userVerification: 'preferred',
1094
+ });
1095
+
1096
+ await this.prisma.user_mfa_challenge.create({
1097
+ data: {
1098
+ user_mfa_id: user.user_mfa[0].id,
1099
+ hash: options.challenge,
1100
+ attempts: 0,
1101
+ expires_at: new Date(Date.now() + 5 * 60 * 1000),
1102
+ }
1103
+ });
1104
+
1105
+ return options;
1106
+ } catch (error: any) {
1107
+ throw new BadRequestException(`Failed to generate authentication options: ${error?.message}`);
1108
+ }
1109
+ }
1110
+
1111
+ async verifyWebAuthnAuthentication(userId: number, assertionResponse: any) {
1112
+ try {
1113
+ const challengeRecord = await this.prisma.user_mfa_challenge.findFirst({
1114
+ where: {
1115
+ user_mfa: {
1116
+ user_id: userId,
1117
+ type: 'webauthn',
1118
+ verified_at: { not: null },
1119
+ },
1120
+ verified_at: null,
1121
+ expires_at: { gt: new Date() }
1122
+ },
1123
+ include: {
1124
+ user_mfa: {
1125
+ include: { user_mfa_webauthn: true }
1126
+ }
1127
+ },
1128
+ orderBy: { created_at: 'desc' }
1129
+ });
1130
+
1131
+ if (!challengeRecord || !challengeRecord.user_mfa.user_mfa_webauthn[0]) {
1132
+ throw new BadRequestException('Challenge not found or expired.');
1133
+ }
1134
+
1135
+ const authenticator = challengeRecord.user_mfa.user_mfa_webauthn[0];
1136
+ const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
1137
+ const expectedOrigin = process.env.FRONTEND_URL || 'http://localhost:3200';
1138
+ const verification: VerifiedAuthenticationResponse = await verifyAuthenticationResponse({
1139
+ response: assertionResponse,
1140
+ expectedChallenge: challengeRecord.hash,
1141
+ expectedOrigin,
1142
+ expectedRPID: rpID,
1143
+ credential: {
1144
+ id: Buffer.from(authenticator.credential_id).toString('base64url'),
1145
+ publicKey: authenticator.public_key,
1146
+ counter: authenticator.sign_count,
1147
+ },
1148
+ });
1149
+
1150
+ if (!verification.verified) {
1151
+ throw new BadRequestException('Verification failed.');
1152
+ }
1153
+
1154
+ await this.prisma.user_mfa_webauthn.update({
1155
+ where: { id: authenticator.id },
1156
+ data: {
1157
+ sign_count: verification.authenticationInfo.newCounter,
1158
+ last_used_at: new Date(),
1159
+ }
1160
+ });
1161
+
1162
+ await this.prisma.user_mfa_challenge.update({
1163
+ where: { id: challengeRecord.id },
1164
+ data: { verified_at: new Date() }
1165
+ });
1166
+
1167
+ return { success: true };
1168
+ } catch (error: any) {
1169
+ throw new BadRequestException(`Failed to verify authentication: ${error?.message}`);
1170
+ }
1171
+ }
1172
+
1173
+ async removeWebAuthnMfa(locale: string, userId: number, mfaId: number) {
1174
+ try {
1175
+ const mfa = await this.prisma.user_mfa.findFirst({
1176
+ where: {
1177
+ id: mfaId,
1178
+ user_id: userId,
1179
+ type: 'webauthn',
1180
+ },
1181
+ });
1182
+
1183
+ if (!mfa) {
1184
+ throw new NotFoundException(
1185
+ getLocaleText('mfaNotFound', locale, 'MFA method not found.')
1186
+ );
1187
+ }
1188
+
1189
+ await this.prisma.user_mfa.delete({
1190
+ where: { id: mfaId },
1191
+ });
1192
+
1193
+ return { success: true };
1194
+ } catch (error: any) {
1195
+ throw new BadRequestException(`Failed to remove WebAuthn: ${error?.message}`);
1196
+ }
1197
+ }
1198
+
1199
+ async generateWebAuthnAuthenticationOptionsForLogin(mfaToken: string) {
1200
+ try {
1201
+ const decoded = this.jwt.decode(mfaToken) as any;
1202
+ if (!decoded || !decoded.userId) {
1203
+ throw new BadRequestException('Invalid MFA token');
1204
+ }
1205
+
1206
+ const user = await this.prisma.user.findFirst({
1207
+ where: { id: decoded.userId },
1208
+ include: {
1209
+ user_mfa: {
1210
+ where: { type: 'webauthn', verified_at: { not: null } },
1211
+ include: { user_mfa_webauthn: true }
1212
+ }
1213
+ }
1214
+ });
1215
+
1216
+ if (!user || user.user_mfa.length === 0) {
1217
+ throw new NotFoundException(getLocaleText('webauthnNotConfigured', 'en', 'WebAuthn not configured.'));
1218
+ }
1219
+
1220
+ const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
1221
+ const allowCredentials = user.user_mfa
1222
+ .filter(mfa => mfa.user_mfa_webauthn && mfa.user_mfa_webauthn.length > 0)
1223
+ .map(mfa => ({
1224
+ id: Buffer.from(mfa.user_mfa_webauthn[0].credential_id).toString('base64url'),
1225
+ }));
1226
+
1227
+ const options = await generateAuthenticationOptions({
1228
+ rpID,
1229
+ allowCredentials,
1230
+ userVerification: 'preferred',
1231
+ });
1232
+
1233
+ await this.prisma.user_mfa_challenge.create({
1234
+ data: {
1235
+ user_mfa_id: user.user_mfa[0].id,
1236
+ hash: options.challenge,
1237
+ attempts: 0,
1238
+ expires_at: new Date(Date.now() + 5 * 60 * 1000),
1239
+ }
1240
+ });
1241
+
1242
+ return options;
1243
+ } catch (error: any) {
1244
+ throw new BadRequestException(`Failed to generate authentication options: ${error?.message}`);
1245
+ }
1246
+ }
1247
+
1248
+ async verifyWebAuthnAuthenticationForLogin(mfaToken: string, assertionResponse: any) {
1249
+ try {
1250
+ const decoded = this.jwt.decode(mfaToken) as any;
1251
+ if (!decoded || !decoded.userId) {
1252
+ throw new BadRequestException('Invalid MFA token');
1253
+ }
1254
+
1255
+ const userId = decoded.userId;
1256
+ const challengeRecord = await this.prisma.user_mfa_challenge.findFirst({
1257
+ where: {
1258
+ user_mfa: {
1259
+ user_id: userId,
1260
+ type: 'webauthn',
1261
+ verified_at: { not: null },
1262
+ },
1263
+ verified_at: null,
1264
+ expires_at: { gt: new Date() }
1265
+ },
1266
+ include: {
1267
+ user_mfa: {
1268
+ include: { user_mfa_webauthn: true }
1269
+ }
1270
+ },
1271
+ orderBy: { created_at: 'desc' }
1272
+ });
1273
+
1274
+ if (!challengeRecord || !challengeRecord.user_mfa.user_mfa_webauthn[0]) {
1275
+ throw new BadRequestException('Challenge not found or expired.');
1276
+ }
1277
+
1278
+ const authenticator = challengeRecord.user_mfa.user_mfa_webauthn[0];
1279
+ const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
1280
+ const expectedOrigin = process.env.FRONTEND_URL || 'http://localhost:3200';
1281
+ const verification: VerifiedAuthenticationResponse = await verifyAuthenticationResponse({
1282
+ response: assertionResponse,
1283
+ expectedChallenge: challengeRecord.hash,
1284
+ expectedOrigin,
1285
+ expectedRPID: rpID,
1286
+ credential: {
1287
+ id: Buffer.from(authenticator.credential_id).toString('base64url'),
1288
+ publicKey: authenticator.public_key,
1289
+ counter: authenticator.sign_count,
1290
+ },
1291
+ });
1292
+
1293
+ if (!verification.verified) {
1294
+ throw new BadRequestException('Verification failed.');
1295
+ }
1296
+
1297
+ await this.prisma.user_mfa_webauthn.update({
1298
+ where: { id: authenticator.id },
1299
+ data: {
1300
+ sign_count: verification.authenticationInfo.newCounter,
1301
+ last_used_at: new Date(),
1302
+ }
1303
+ });
1304
+
1305
+ await this.prisma.user_mfa_challenge.update({
1306
+ where: { id: challengeRecord.id },
1307
+ data: { verified_at: new Date() }
1308
+ });
1309
+
1310
+ const user = await this.prisma.user.findFirst({ where: { id: userId } });
1311
+ if (!user) {
1312
+ throw new NotFoundException(getLocaleText('userNotFound', 'en', 'User not found'));
1313
+ }
1314
+ const payload = { sub: userId };
1315
+ const accessToken = await this.token.createAccessToken(payload);
1316
+ const refreshToken = this.jwt.sign({ userId, type: 'refresh' }, { expiresIn: '7d' });
1317
+
1318
+ return {
1319
+ accessToken,
1320
+ refreshToken,
1321
+ };
1322
+ } catch (error: any) {
1323
+ throw new BadRequestException(`Failed to verify authentication: ${error?.message}`);
1324
+ }
1325
+ }
1326
+
1327
+ async getUserToken(userId: number){
1328
+ const updatedUser = await this.prisma.user.findFirst({ where: { id: userId }})
1329
+ return this.getToken(updatedUser);
1330
+ }
1331
+ }