nucleus-core-ts 0.8.0

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 (415) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +177 -0
  3. package/dist/client.d.ts +2 -0
  4. package/dist/client.js +1 -0
  5. package/dist/dist/index-0yyw12k6.d.ts +8 -0
  6. package/dist/dist/index-tv67j5qd.d.ts +488 -0
  7. package/dist/dist/index.d.ts +40 -0
  8. package/dist/fe/components/AbstractAnimatedBackground/index.d.ts +7 -0
  9. package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.d.ts +3 -0
  10. package/dist/fe/components/AuthorizationPage/components/ClaimList.d.ts +3 -0
  11. package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.d.ts +3 -0
  12. package/dist/fe/components/AuthorizationPage/components/RoleList.d.ts +3 -0
  13. package/dist/fe/components/AuthorizationPage/index.d.ts +9 -0
  14. package/dist/fe/components/AuthorizationPage/store/index.d.ts +47 -0
  15. package/dist/fe/components/AuthorizationPage/theme/index.d.ts +82 -0
  16. package/dist/fe/components/AuthorizationPage/types/index.d.ts +64 -0
  17. package/dist/fe/components/Button/components/Button.d.ts +3 -0
  18. package/dist/fe/components/Button/components/ButtonSpinner.d.ts +3 -0
  19. package/dist/fe/components/Button/index.d.ts +6 -0
  20. package/dist/fe/components/Button/theme/index.d.ts +183 -0
  21. package/dist/fe/components/Button/types/index.d.ts +24 -0
  22. package/dist/fe/components/Button/utils/cn.d.ts +3 -0
  23. package/dist/fe/components/Captcha/components/Captcha.d.ts +4 -0
  24. package/dist/fe/components/Captcha/index.d.ts +4 -0
  25. package/dist/fe/components/Captcha/theme.d.ts +53 -0
  26. package/dist/fe/components/Captcha/types.d.ts +60 -0
  27. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.d.ts +4 -0
  28. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.d.ts +4 -0
  29. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.d.ts +4 -0
  30. package/dist/fe/components/ChangePasswordPage/index.d.ts +7 -0
  31. package/dist/fe/components/ChangePasswordPage/store/index.d.ts +16 -0
  32. package/dist/fe/components/ChangePasswordPage/theme/index.d.ts +48 -0
  33. package/dist/fe/components/ChangePasswordPage/types/index.d.ts +56 -0
  34. package/dist/fe/components/Checkbox/components/Checkbox.d.ts +3 -0
  35. package/dist/fe/components/Checkbox/components/CheckboxIcon.d.ts +3 -0
  36. package/dist/fe/components/Checkbox/components/SwitchTrack.d.ts +3 -0
  37. package/dist/fe/components/Checkbox/index.d.ts +7 -0
  38. package/dist/fe/components/Checkbox/theme/index.d.ts +218 -0
  39. package/dist/fe/components/Checkbox/types/index.d.ts +39 -0
  40. package/dist/fe/components/Checkbox/utils/cn.d.ts +3 -0
  41. package/dist/fe/components/DataTable/DataTable.d.ts +3 -0
  42. package/dist/fe/components/DataTable/components/ActionCell.d.ts +10 -0
  43. package/dist/fe/components/DataTable/components/DataCell.d.ts +18 -0
  44. package/dist/fe/components/DataTable/components/EditableCell.d.ts +14 -0
  45. package/dist/fe/components/DataTable/components/EmptyState.d.ts +8 -0
  46. package/dist/fe/components/DataTable/components/HeaderCell.d.ts +16 -0
  47. package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.d.ts +11 -0
  48. package/dist/fe/components/DataTable/components/LoadingSpinner.d.ts +7 -0
  49. package/dist/fe/components/DataTable/components/ResizeHandle.d.ts +9 -0
  50. package/dist/fe/components/DataTable/components/SelectionCell.d.ts +9 -0
  51. package/dist/fe/components/DataTable/components/SkeletonRow.d.ts +9 -0
  52. package/dist/fe/components/DataTable/components/SkeletonTable.d.ts +10 -0
  53. package/dist/fe/components/DataTable/components/SortIcon.d.ts +9 -0
  54. package/dist/fe/components/DataTable/components/TableHeader.d.ts +20 -0
  55. package/dist/fe/components/DataTable/components/TableRow.d.ts +20 -0
  56. package/dist/fe/components/DataTable/components/index.d.ts +15 -0
  57. package/dist/fe/components/DataTable/hooks/index.d.ts +3 -0
  58. package/dist/fe/components/DataTable/hooks/useAutoFitColumn.d.ts +8 -0
  59. package/dist/fe/components/DataTable/hooks/useResizeColumn.d.ts +12 -0
  60. package/dist/fe/components/DataTable/index.d.ts +6 -0
  61. package/dist/fe/components/DataTable/store/index.d.ts +52 -0
  62. package/dist/fe/components/DataTable/theme/index.d.ts +131 -0
  63. package/dist/fe/components/DataTable/types/index.d.ts +151 -0
  64. package/dist/fe/components/DataTable/utils/cn.d.ts +3 -0
  65. package/dist/fe/components/DatePicker/components/CalendarGrid.d.ts +3 -0
  66. package/dist/fe/components/DatePicker/components/CalendarHeader.d.ts +3 -0
  67. package/dist/fe/components/DatePicker/components/DatePicker.d.ts +3 -0
  68. package/dist/fe/components/DatePicker/components/MonthYearSelector.d.ts +10 -0
  69. package/dist/fe/components/DatePicker/index.d.ts +10 -0
  70. package/dist/fe/components/DatePicker/locales/index.d.ts +5 -0
  71. package/dist/fe/components/DatePicker/theme/index.d.ts +312 -0
  72. package/dist/fe/components/DatePicker/types/index.d.ts +88 -0
  73. package/dist/fe/components/DatePicker/utils/cn.d.ts +3 -0
  74. package/dist/fe/components/DatePicker/utils/date.d.ts +21 -0
  75. package/dist/fe/components/DevicesPage/components/DeviceCard.d.ts +4 -0
  76. package/dist/fe/components/DevicesPage/components/DevicesHeader.d.ts +4 -0
  77. package/dist/fe/components/DevicesPage/components/DevicesPage.d.ts +4 -0
  78. package/dist/fe/components/DevicesPage/index.d.ts +8 -0
  79. package/dist/fe/components/DevicesPage/store/index.d.ts +20 -0
  80. package/dist/fe/components/DevicesPage/theme/index.d.ts +92 -0
  81. package/dist/fe/components/DevicesPage/types/index.d.ts +147 -0
  82. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.d.ts +4 -0
  83. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.d.ts +4 -0
  84. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.d.ts +4 -0
  85. package/dist/fe/components/ForgotPasswordPage/index.d.ts +7 -0
  86. package/dist/fe/components/ForgotPasswordPage/store/index.d.ts +14 -0
  87. package/dist/fe/components/ForgotPasswordPage/theme/index.d.ts +48 -0
  88. package/dist/fe/components/ForgotPasswordPage/types/index.d.ts +48 -0
  89. package/dist/fe/components/FormBuilder/components/FormBuilder.d.ts +3 -0
  90. package/dist/fe/components/FormBuilder/components/FormField.d.ts +3 -0
  91. package/dist/fe/components/FormBuilder/hooks/useFormBuilder.d.ts +3 -0
  92. package/dist/fe/components/FormBuilder/index.d.ts +6 -0
  93. package/dist/fe/components/FormBuilder/theme/index.d.ts +136 -0
  94. package/dist/fe/components/FormBuilder/types/index.d.ts +150 -0
  95. package/dist/fe/components/FormBuilder/utils/cn.d.ts +3 -0
  96. package/dist/fe/components/FormBuilder/utils/fieldMapping.d.ts +12 -0
  97. package/dist/fe/components/FormBuilder/utils/validation.d.ts +11 -0
  98. package/dist/fe/components/LoginPage/components/LoginForm.d.ts +4 -0
  99. package/dist/fe/components/LoginPage/components/LoginHeader.d.ts +4 -0
  100. package/dist/fe/components/LoginPage/components/LoginPage.d.ts +4 -0
  101. package/dist/fe/components/LoginPage/index.d.ts +8 -0
  102. package/dist/fe/components/LoginPage/store/index.d.ts +22 -0
  103. package/dist/fe/components/LoginPage/theme/index.d.ts +55 -0
  104. package/dist/fe/components/LoginPage/types/index.d.ts +129 -0
  105. package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.d.ts +4 -0
  106. package/dist/fe/components/MagicLinkVerifyPage/index.d.ts +5 -0
  107. package/dist/fe/components/MagicLinkVerifyPage/store.d.ts +15 -0
  108. package/dist/fe/components/MagicLinkVerifyPage/theme.d.ts +37 -0
  109. package/dist/fe/components/MagicLinkVerifyPage/types.d.ts +35 -0
  110. package/dist/fe/components/NucleusEntityShowcase.d.ts +3 -0
  111. package/dist/fe/components/NucleusTextInput/components/FloatingLabel.d.ts +3 -0
  112. package/dist/fe/components/NucleusTextInput/components/InputIcons.d.ts +15 -0
  113. package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.d.ts +3 -0
  114. package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.d.ts +15 -0
  115. package/dist/fe/components/NucleusTextInput/components/TypewriterText.d.ts +3 -0
  116. package/dist/fe/components/NucleusTextInput/index.d.ts +11 -0
  117. package/dist/fe/components/NucleusTextInput/theme/index.d.ts +108 -0
  118. package/dist/fe/components/NucleusTextInput/types/index.d.ts +65 -0
  119. package/dist/fe/components/NucleusTextInput/utils/cn.d.ts +3 -0
  120. package/dist/fe/components/NucleusTextInput/utils/format.d.ts +8 -0
  121. package/dist/fe/components/NucleusTextInput/utils/validation.d.ts +23 -0
  122. package/dist/fe/components/ProfilePage/components/AddressCard.d.ts +4 -0
  123. package/dist/fe/components/ProfilePage/components/PhoneCard.d.ts +4 -0
  124. package/dist/fe/components/ProfilePage/components/ProfileHeader.d.ts +4 -0
  125. package/dist/fe/components/ProfilePage/components/ProfilePage.d.ts +4 -0
  126. package/dist/fe/components/ProfilePage/index.d.ts +10 -0
  127. package/dist/fe/components/ProfilePage/store/index.d.ts +37 -0
  128. package/dist/fe/components/ProfilePage/theme/index.d.ts +101 -0
  129. package/dist/fe/components/ProfilePage/types/index.d.ts +150 -0
  130. package/dist/fe/components/RangePicker/components/RangePicker.d.ts +3 -0
  131. package/dist/fe/components/RangePicker/components/RangeThumb.d.ts +3 -0
  132. package/dist/fe/components/RangePicker/components/RangeTooltip.d.ts +3 -0
  133. package/dist/fe/components/RangePicker/components/RangeTrack.d.ts +3 -0
  134. package/dist/fe/components/RangePicker/index.d.ts +8 -0
  135. package/dist/fe/components/RangePicker/theme/index.d.ts +90 -0
  136. package/dist/fe/components/RangePicker/types/index.d.ts +66 -0
  137. package/dist/fe/components/RangePicker/utils/cn.d.ts +3 -0
  138. package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.d.ts +14 -0
  139. package/dist/fe/components/RegisterPage/components/RegisterForm.d.ts +4 -0
  140. package/dist/fe/components/RegisterPage/components/RegisterHeader.d.ts +4 -0
  141. package/dist/fe/components/RegisterPage/components/RegisterPage.d.ts +4 -0
  142. package/dist/fe/components/RegisterPage/index.d.ts +9 -0
  143. package/dist/fe/components/RegisterPage/store/index.d.ts +19 -0
  144. package/dist/fe/components/RegisterPage/theme/index.d.ts +81 -0
  145. package/dist/fe/components/RegisterPage/types/index.d.ts +141 -0
  146. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.d.ts +4 -0
  147. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.d.ts +4 -0
  148. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.d.ts +4 -0
  149. package/dist/fe/components/ResetPasswordPage/index.d.ts +7 -0
  150. package/dist/fe/components/ResetPasswordPage/store/index.d.ts +15 -0
  151. package/dist/fe/components/ResetPasswordPage/theme/index.d.ts +56 -0
  152. package/dist/fe/components/ResetPasswordPage/types/index.d.ts +50 -0
  153. package/dist/fe/components/SearchBox/components/SearchBox.d.ts +3 -0
  154. package/dist/fe/components/SearchBox/components/SearchBoxDropdown.d.ts +3 -0
  155. package/dist/fe/components/SearchBox/index.d.ts +8 -0
  156. package/dist/fe/components/SearchBox/theme/index.d.ts +141 -0
  157. package/dist/fe/components/SearchBox/types/index.d.ts +47 -0
  158. package/dist/fe/components/SearchBox/utils/cn.d.ts +3 -0
  159. package/dist/fe/components/SearchBox/utils/debounce.d.ts +5 -0
  160. package/dist/fe/components/SearchBox/utils/sanitize.d.ts +9 -0
  161. package/dist/fe/components/SelectBox/components/SelectBox.d.ts +3 -0
  162. package/dist/fe/components/SelectBox/components/SelectDropdown.d.ts +6 -0
  163. package/dist/fe/components/SelectBox/components/SelectOptionItem.d.ts +3 -0
  164. package/dist/fe/components/SelectBox/components/SelectTrigger.d.ts +5 -0
  165. package/dist/fe/components/SelectBox/index.d.ts +8 -0
  166. package/dist/fe/components/SelectBox/theme/index.d.ts +100 -0
  167. package/dist/fe/components/SelectBox/types/index.d.ts +66 -0
  168. package/dist/fe/components/SelectBox/utils/cn.d.ts +3 -0
  169. package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.d.ts +14 -0
  170. package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.d.ts +4 -0
  171. package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.d.ts +4 -0
  172. package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.d.ts +4 -0
  173. package/dist/fe/components/SetPasswordPage/index.d.ts +9 -0
  174. package/dist/fe/components/SetPasswordPage/store/index.d.ts +16 -0
  175. package/dist/fe/components/SetPasswordPage/theme/index.d.ts +95 -0
  176. package/dist/fe/components/SetPasswordPage/types/index.d.ts +137 -0
  177. package/dist/fe/components/UsersPage/components/InviteUserModal.d.ts +10 -0
  178. package/dist/fe/components/UsersPage/components/Pagination.d.ts +13 -0
  179. package/dist/fe/components/UsersPage/components/RoleAssignmentModal.d.ts +12 -0
  180. package/dist/fe/components/UsersPage/components/StatsCards.d.ts +10 -0
  181. package/dist/fe/components/UsersPage/components/UserDetailDrawer.d.ts +24 -0
  182. package/dist/fe/components/UsersPage/components/UserFilters.d.ts +18 -0
  183. package/dist/fe/components/UsersPage/components/UserListItem.d.ts +11 -0
  184. package/dist/fe/components/UsersPage/components/UserListSkeleton.d.ts +7 -0
  185. package/dist/fe/components/UsersPage/components/UsersPage.d.ts +8 -0
  186. package/dist/fe/components/UsersPage/index.d.ts +13 -0
  187. package/dist/fe/components/UsersPage/store/index.d.ts +51 -0
  188. package/dist/fe/components/UsersPage/theme/index.d.ts +180 -0
  189. package/dist/fe/components/UsersPage/types/index.d.ts +73 -0
  190. package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.d.ts +4 -0
  191. package/dist/fe/components/VerifyEmailPage/index.d.ts +5 -0
  192. package/dist/fe/components/VerifyEmailPage/store/index.d.ts +18 -0
  193. package/dist/fe/components/VerifyEmailPage/theme/index.d.ts +49 -0
  194. package/dist/fe/components/VerifyEmailPage/types/index.d.ts +84 -0
  195. package/dist/fe/hooks/useNucleusEntity.d.ts +3 -0
  196. package/dist/fe/index.d.ts +42 -0
  197. package/dist/fe/index.js +1 -0
  198. package/dist/fe/types/index.d.ts +233 -0
  199. package/dist/fe/utils/cn.d.ts +3 -0
  200. package/dist/fe/utils/columnUtils.d.ts +63 -0
  201. package/dist/fe/utils/endpointKeys.d.ts +9 -0
  202. package/dist/index-0yyw12k6.js +1 -0
  203. package/dist/index-tv67j5qd.js +1 -0
  204. package/dist/index.d.ts +6 -0
  205. package/dist/index.js +1 -0
  206. package/dist/nucleus.config.d.ts +95 -0
  207. package/dist/public/components/CTA.d.ts +2 -0
  208. package/dist/public/components/Capabilities.d.ts +9 -0
  209. package/dist/public/components/Features.d.ts +9 -0
  210. package/dist/public/components/Footer.d.ts +2 -0
  211. package/dist/public/components/Hero.d.ts +2 -0
  212. package/dist/public/components/Managers.d.ts +7 -0
  213. package/dist/public/components/Nav.d.ts +2 -0
  214. package/dist/public/components/Stack.d.ts +7 -0
  215. package/dist/public/components/docs/Docs.d.ts +2 -0
  216. package/dist/public/components/docs/DocsContent.d.ts +19 -0
  217. package/dist/public/components/docs/DocsRightSidebar.d.ts +9 -0
  218. package/dist/public/components/docs/DocsSidebar.d.ts +8 -0
  219. package/dist/public/components/docs/content/authentication.d.ts +3 -0
  220. package/dist/public/components/docs/content/gettingStarted.d.ts +3 -0
  221. package/dist/public/components/docs/docsData.d.ts +18 -0
  222. package/dist/public/components/docs/index.d.ts +7 -0
  223. package/dist/public/components/index.d.ts +10 -0
  224. package/dist/public/index.d.ts +3 -0
  225. package/dist/public/store.d.ts +20 -0
  226. package/dist/scripts/build.d.ts +7 -0
  227. package/dist/scripts/generate-schema.d.ts +3 -0
  228. package/dist/scripts/generate-system-tables-types.d.ts +2 -0
  229. package/dist/scripts/generate-types-schema.d.ts +7 -0
  230. package/dist/scripts/publish.d.ts +7 -0
  231. package/dist/scripts/version.d.ts +7 -0
  232. package/dist/src/Client/ApiCaller/client.d.ts +5 -0
  233. package/dist/src/Client/ApiCaller/examples/usage.example.d.ts +8 -0
  234. package/dist/src/Client/ApiCaller/generator.d.ts +10 -0
  235. package/dist/src/Client/ApiCaller/index.d.ts +7 -0
  236. package/dist/src/Client/ApiCaller/server.d.ts +4 -0
  237. package/dist/src/Client/ApiCaller/system-tables.d.ts +1215 -0
  238. package/dist/src/Client/ApiCaller/types.d.ts +907 -0
  239. package/dist/src/Client/Proxy/httpProxy.d.ts +5 -0
  240. package/dist/src/Client/Proxy/index.d.ts +6 -0
  241. package/dist/src/Client/Proxy/index.js +1 -0
  242. package/dist/src/Client/Proxy/server.d.ts +5 -0
  243. package/dist/src/Client/Proxy/types.d.ts +69 -0
  244. package/dist/src/Client/Proxy/utils.d.ts +12 -0
  245. package/dist/src/Client/Proxy/wsProxy.d.ts +20 -0
  246. package/dist/src/Client/ServerFetch/index.d.ts +19 -0
  247. package/dist/src/Client/ServerFetch/types.d.ts +34 -0
  248. package/dist/src/Client/index.d.ts +4 -0
  249. package/dist/src/ElysiaPlugin/index.d.ts +12 -0
  250. package/dist/src/ElysiaPlugin/publicRoutes.d.ts +9 -0
  251. package/dist/src/ElysiaPlugin/routes/auth/captcha/index.d.ts +46 -0
  252. package/dist/src/ElysiaPlugin/routes/auth/emailVerification/index.d.ts +38 -0
  253. package/dist/src/ElysiaPlugin/routes/auth/index.d.ts +68 -0
  254. package/dist/src/ElysiaPlugin/routes/auth/invite/index.d.ts +43 -0
  255. package/dist/src/ElysiaPlugin/routes/auth/login/index.d.ts +68 -0
  256. package/dist/src/ElysiaPlugin/routes/auth/login/types.d.ts +22 -0
  257. package/dist/src/ElysiaPlugin/routes/auth/login/utils.d.ts +19 -0
  258. package/dist/src/ElysiaPlugin/routes/auth/logout/index.d.ts +33 -0
  259. package/dist/src/ElysiaPlugin/routes/auth/logout/types.d.ts +6 -0
  260. package/dist/src/ElysiaPlugin/routes/auth/logout/utils.d.ts +2 -0
  261. package/dist/src/ElysiaPlugin/routes/auth/magicLink/index.d.ts +41 -0
  262. package/dist/src/ElysiaPlugin/routes/auth/magicLink/types.d.ts +23 -0
  263. package/dist/src/ElysiaPlugin/routes/auth/magicLink/utils.d.ts +4 -0
  264. package/dist/src/ElysiaPlugin/routes/auth/me/index.d.ts +40 -0
  265. package/dist/src/ElysiaPlugin/routes/auth/passwordChange/index.d.ts +33 -0
  266. package/dist/src/ElysiaPlugin/routes/auth/passwordChange/types.d.ts +12 -0
  267. package/dist/src/ElysiaPlugin/routes/auth/passwordChange/utils.d.ts +2 -0
  268. package/dist/src/ElysiaPlugin/routes/auth/passwordReset/index.d.ts +36 -0
  269. package/dist/src/ElysiaPlugin/routes/auth/passwordReset/types.d.ts +16 -0
  270. package/dist/src/ElysiaPlugin/routes/auth/passwordReset/utils.d.ts +3 -0
  271. package/dist/src/ElysiaPlugin/routes/auth/passwordSet/index.d.ts +33 -0
  272. package/dist/src/ElysiaPlugin/routes/auth/passwordSet/types.d.ts +9 -0
  273. package/dist/src/ElysiaPlugin/routes/auth/refresh/index.d.ts +39 -0
  274. package/dist/src/ElysiaPlugin/routes/auth/refresh/types.d.ts +9 -0
  275. package/dist/src/ElysiaPlugin/routes/auth/refresh/utils.d.ts +2 -0
  276. package/dist/src/ElysiaPlugin/routes/auth/register/index.d.ts +47 -0
  277. package/dist/src/ElysiaPlugin/routes/auth/register/types.d.ts +18 -0
  278. package/dist/src/ElysiaPlugin/routes/auth/register/utils.d.ts +8 -0
  279. package/dist/src/ElysiaPlugin/routes/auth/sessions/index.d.ts +33 -0
  280. package/dist/src/ElysiaPlugin/routes/auth/sessions/types.d.ts +67 -0
  281. package/dist/src/ElysiaPlugin/routes/auth/sessions/utils.d.ts +36 -0
  282. package/dist/src/ElysiaPlugin/routes/auth/types.d.ts +153 -0
  283. package/dist/src/ElysiaPlugin/routes/entity/index.d.ts +5 -0
  284. package/dist/src/ElysiaPlugin/routes/entity/types.d.ts +50 -0
  285. package/dist/src/ElysiaPlugin/routes/entity/utils.d.ts +11 -0
  286. package/dist/src/ElysiaPlugin/routes/index.d.ts +5 -0
  287. package/dist/src/ElysiaPlugin/routes/monitoring/index.d.ts +58 -0
  288. package/dist/src/ElysiaPlugin/routes/storage/cdn.d.ts +51 -0
  289. package/dist/src/ElysiaPlugin/routes/storage/helpers.d.ts +53 -0
  290. package/dist/src/ElysiaPlugin/routes/storage/index.d.ts +3 -0
  291. package/dist/src/ElysiaPlugin/routes/verification/index.d.ts +39 -0
  292. package/dist/src/ElysiaPlugin/swagger.d.ts +28 -0
  293. package/dist/src/ElysiaPlugin/utils.d.ts +70 -0
  294. package/dist/src/Managers/Dapr/clients/binding-client.d.ts +15 -0
  295. package/dist/src/Managers/Dapr/clients/config-client.d.ts +27 -0
  296. package/dist/src/Managers/Dapr/clients/crypto-client.d.ts +27 -0
  297. package/dist/src/Managers/Dapr/clients/invoke-client.d.ts +32 -0
  298. package/dist/src/Managers/Dapr/clients/lock-client.d.ts +23 -0
  299. package/dist/src/Managers/Dapr/clients/pubsub-client.d.ts +23 -0
  300. package/dist/src/Managers/Dapr/clients/secret-client.d.ts +19 -0
  301. package/dist/src/Managers/Dapr/clients/state-client.d.ts +55 -0
  302. package/dist/src/Managers/Dapr/clients/workflow-client.d.ts +39 -0
  303. package/dist/src/Managers/Dapr/connection-manager.d.ts +51 -0
  304. package/dist/src/Managers/Dapr/constants.d.ts +49 -0
  305. package/dist/src/Managers/Dapr/dapr-manager.d.ts +160 -0
  306. package/dist/src/Managers/Dapr/error-handling.d.ts +29 -0
  307. package/dist/src/Managers/Dapr/index.d.ts +102 -0
  308. package/dist/src/Managers/Dapr/types.d.ts +121 -0
  309. package/dist/src/Managers/Dapr/utils.d.ts +44 -0
  310. package/dist/src/Managers/File/atomic.d.ts +64 -0
  311. package/dist/src/Managers/File/core.d.ts +188 -0
  312. package/dist/src/Managers/File/index.d.ts +18 -0
  313. package/dist/src/Managers/File/permissions.d.ts +72 -0
  314. package/dist/src/Managers/File/streaming.d.ts +30 -0
  315. package/dist/src/Managers/File/types.d.ts +146 -0
  316. package/dist/src/Managers/File/utils.d.ts +112 -0
  317. package/dist/src/Managers/Postgre/index.d.ts +25 -0
  318. package/dist/src/Managers/Redis/index.d.ts +33 -0
  319. package/dist/src/Managers/index.d.ts +5 -0
  320. package/dist/src/Services/Auth/Fingerprint/Generate/index.d.ts +3 -0
  321. package/dist/src/Services/Auth/Fingerprint/Validate/index.d.ts +3 -0
  322. package/dist/src/Services/Auth/Fingerprint/index.d.ts +5 -0
  323. package/dist/src/Services/Auth/Fingerprint/types.d.ts +20 -0
  324. package/dist/src/Services/Auth/Fingerprint/utils.d.ts +3 -0
  325. package/dist/src/Services/Auth/JWT/Decode/index.d.ts +3 -0
  326. package/dist/src/Services/Auth/JWT/Sign/index.d.ts +3 -0
  327. package/dist/src/Services/Auth/JWT/Verify/index.d.ts +3 -0
  328. package/dist/src/Services/Auth/JWT/index.d.ts +5 -0
  329. package/dist/src/Services/Auth/JWT/types.d.ts +38 -0
  330. package/dist/src/Services/Auth/JWT/utils.d.ts +10 -0
  331. package/dist/src/Services/Auth/Password/Generate/index.d.ts +3 -0
  332. package/dist/src/Services/Auth/Password/Validate/index.d.ts +3 -0
  333. package/dist/src/Services/Auth/Password/index.d.ts +2 -0
  334. package/dist/src/Services/Auth/Password/types.d.ts +16 -0
  335. package/dist/src/Services/Auth/RefreshToken/Delete/index.d.ts +3 -0
  336. package/dist/src/Services/Auth/RefreshToken/Generate/index.d.ts +11 -0
  337. package/dist/src/Services/Auth/RefreshToken/Read/index.d.ts +11 -0
  338. package/dist/src/Services/Auth/RefreshToken/Validate/index.d.ts +11 -0
  339. package/dist/src/Services/Auth/RefreshToken/index.d.ts +5 -0
  340. package/dist/src/Services/Auth/RefreshToken/types.d.ts +27 -0
  341. package/dist/src/Services/Auth/RefreshToken/utils.d.ts +6 -0
  342. package/dist/src/Services/Auth/Session/Issue/index.d.ts +9 -0
  343. package/dist/src/Services/Auth/Session/index.d.ts +2 -0
  344. package/dist/src/Services/Auth/Session/types.d.ts +13 -0
  345. package/dist/src/Services/Auth/SessionStore/Delete/index.d.ts +3 -0
  346. package/dist/src/Services/Auth/SessionStore/Generate/index.d.ts +11 -0
  347. package/dist/src/Services/Auth/SessionStore/Read/index.d.ts +3 -0
  348. package/dist/src/Services/Auth/SessionStore/Update/index.d.ts +24 -0
  349. package/dist/src/Services/Auth/SessionStore/Validate/index.d.ts +3 -0
  350. package/dist/src/Services/Auth/SessionStore/index.d.ts +7 -0
  351. package/dist/src/Services/Auth/SessionStore/types.d.ts +59 -0
  352. package/dist/src/Services/Auth/SessionStore/utils.d.ts +6 -0
  353. package/dist/src/Services/Auth/index.d.ts +7 -0
  354. package/dist/src/Services/Authorization/ClaimSeeder/index.d.ts +6 -0
  355. package/dist/src/Services/Authorization/GodminSetup/index.d.ts +10 -0
  356. package/dist/src/Services/Authorization/Middleware/index.d.ts +21 -0
  357. package/dist/src/Services/Authorization/index.d.ts +5 -0
  358. package/dist/src/Services/Authorization/types.d.ts +68 -0
  359. package/dist/src/Services/Captcha/index.d.ts +15 -0
  360. package/dist/src/Services/Captcha/types.d.ts +69 -0
  361. package/dist/src/Services/Gmail/index.d.ts +62 -0
  362. package/dist/src/Services/Logger/Logger.d.ts +77 -0
  363. package/dist/src/Services/Logger/index.d.ts +5 -0
  364. package/dist/src/Services/Logger/transports.d.ts +54 -0
  365. package/dist/src/Services/Logger/types.d.ts +88 -0
  366. package/dist/src/Services/Logger/utils.d.ts +8 -0
  367. package/dist/src/Services/Monitoring/AlertService.d.ts +29 -0
  368. package/dist/src/Services/Monitoring/collectors/ApplicationCollector.d.ts +30 -0
  369. package/dist/src/Services/Monitoring/collectors/SystemCollector.d.ts +13 -0
  370. package/dist/src/Services/Monitoring/collectors/index.d.ts +3 -0
  371. package/dist/src/Services/Monitoring/index.d.ts +109 -0
  372. package/dist/src/Services/Monitoring/types.d.ts +163 -0
  373. package/dist/src/Services/Notification/index.d.ts +31 -0
  374. package/dist/src/Services/Notification/types.d.ts +59 -0
  375. package/dist/src/Services/RateLimiter/index.d.ts +99 -0
  376. package/dist/src/Services/Verification/index.d.ts +23 -0
  377. package/dist/src/Services/Verification/types.d.ts +135 -0
  378. package/dist/src/Services/index.d.ts +10 -0
  379. package/dist/src/types.d.ts +588 -0
  380. package/package.json +99 -0
  381. package/public/components/CTA.tsx +25 -0
  382. package/public/components/Capabilities.tsx +69 -0
  383. package/public/components/Features.tsx +107 -0
  384. package/public/components/Footer.tsx +60 -0
  385. package/public/components/Hero.tsx +53 -0
  386. package/public/components/Managers.tsx +60 -0
  387. package/public/components/Nav.tsx +107 -0
  388. package/public/components/Stack.tsx +36 -0
  389. package/public/components/docs/Docs.tsx +62 -0
  390. package/public/components/docs/DocsContent.tsx +203 -0
  391. package/public/components/docs/DocsRightSidebar.tsx +53 -0
  392. package/public/components/docs/DocsSidebar.tsx +62 -0
  393. package/public/components/docs/content/authentication.ts +1670 -0
  394. package/public/components/docs/content/gettingStarted.ts +627 -0
  395. package/public/components/docs/docsData.ts +36 -0
  396. package/public/components/docs/index.ts +6 -0
  397. package/public/components/index.ts +9 -0
  398. package/public/docs.css +633 -0
  399. package/public/index.html +81 -0
  400. package/public/index.tsx +52 -0
  401. package/public/store.ts +79 -0
  402. package/public/styles.css +877 -0
  403. package/schemas/bckp/config.nucleus.json +1488 -0
  404. package/schemas/bckp/nucleus.tables.schema.json +24 -0
  405. package/schemas/bckp/table.schema.json +472 -0
  406. package/schemas/config.nucleus.json +1010 -0
  407. package/schemas/nucleus.tables.schema.json +19 -0
  408. package/schemas/table.schema.json +498 -0
  409. package/scripts/build.ts +197 -0
  410. package/scripts/generate-schema.ts +556 -0
  411. package/scripts/generate-system-tables-types.ts +18 -0
  412. package/scripts/generate-types-schema.ts +962 -0
  413. package/scripts/publish.ts +210 -0
  414. package/scripts/version.ts +125 -0
  415. package/src/system.tables.json +1590 -0
@@ -0,0 +1,1670 @@
1
+ import type { DocItem } from "../docsData";
2
+
3
+ export const authenticationItems: DocItem[] = [
4
+ {
5
+ id: "tokens",
6
+ title: "Tokens",
7
+ subItems: [
8
+ {
9
+ id: "high-overview",
10
+ title: "High Overview",
11
+ content: `
12
+ ## Token Architecture Overview
13
+
14
+ Nucleus implements a **three-token security model** designed for enterprise applications. This architecture balances security with user experience.
15
+
16
+ ### Why Three Tokens?
17
+
18
+ \`\`\`mermaid
19
+ flowchart TB
20
+ subgraph Problem["Single Token Problems"]
21
+ P1[Long-lived = Security risk]
22
+ P2[Short-lived = Poor UX]
23
+ end
24
+
25
+ subgraph Solution["Three Token Solution"]
26
+ S1[Access Token<br/>Short-lived for security]
27
+ S2[Refresh Token<br/>Long-lived for UX]
28
+ S3[Session Token<br/>Device tracking]
29
+ end
30
+
31
+ Problem --> Solution
32
+ \`\`\`
33
+
34
+ ### Token Responsibilities
35
+
36
+ | Token | Lifetime | Purpose | Revocable |
37
+ |-------|----------|---------|-----------|
38
+ | **Access Token** | 15 minutes | Authenticate API requests | No (stateless) |
39
+ | **Refresh Token** | 7 days | Obtain new access tokens | Yes (rotation) |
40
+ | **Session Token** | 30 days | Track device/session | Yes (immediate) |
41
+
42
+ ### Complete Auth Flow
43
+
44
+ \`\`\`mermaid
45
+ sequenceDiagram
46
+ participant U as User
47
+ participant C as Client
48
+ participant S as Server
49
+ participant R as Redis
50
+ participant D as Database
51
+
52
+ Note over U,D: Login Flow
53
+ U->>C: Enter credentials
54
+ C->>S: POST /auth/login
55
+ S->>D: Verify credentials
56
+ D-->>S: User data
57
+ S->>S: Generate 3 tokens
58
+ S->>R: Store session
59
+ S->>D: Save session record
60
+ S-->>C: Tokens (cookies + JSON)
61
+
62
+ Note over U,D: API Request Flow
63
+ C->>S: Request + Access Token
64
+ S->>S: Verify JWT
65
+ alt Token Valid
66
+ S->>S: Process request
67
+ S-->>C: Response
68
+ else Token Expired
69
+ S->>S: Check Refresh Token
70
+ S->>S: Generate new Access Token
71
+ S-->>C: Response + New Token
72
+ end
73
+
74
+ Note over U,D: Logout Flow
75
+ C->>S: POST /auth/logout
76
+ S->>R: Delete session
77
+ S->>D: Mark session revoked
78
+ S-->>C: Clear cookies
79
+ \`\`\`
80
+
81
+ ### Security Features
82
+
83
+ - **Short-lived access tokens** - 15 minute window limits damage from stolen tokens
84
+ - **Refresh token rotation** - New refresh token on each use, old ones invalidated
85
+ - **Session binding** - Tokens are bound to specific sessions
86
+ - **Device fingerprinting** - Track and verify device identity
87
+ - **Trust scoring** - Automatic risk assessment for each login
88
+ `,
89
+ },
90
+ {
91
+ id: "access-token",
92
+ title: "Access Token",
93
+ content: `
94
+ ## Access Token
95
+
96
+ The access token is the primary authentication credential for API requests. It's a stateless JWT that contains user identity information.
97
+
98
+ ### Configuration
99
+
100
+ \`\`\`typescript
101
+ accessToken: {
102
+ secret: string,
103
+ expiresIn: string,
104
+ algorithm: Algorithm,
105
+ issuer: string,
106
+ audience: string,
107
+ name: string,
108
+ setHeadersEnabled: boolean,
109
+ returnJson: boolean,
110
+ }
111
+ \`\`\`
112
+
113
+ ### Configuration Fields
114
+
115
+ | Field | Type | Required | Default | Description |
116
+ |-------|------|----------|---------|-------------|
117
+ | \`secret\` | string | **Yes** | - | JWT signing secret. Must be at least 32 characters. Use a cryptographically secure random string. **Never commit to version control.** |
118
+ | \`expiresIn\` | string | No | \`'15m'\` | Token lifetime. Accepts formats: \`'15m'\` (minutes), \`'1h'\` (hours), \`'7d'\` (days). Keep short (15-30 min) for security. |
119
+ | \`algorithm\` | string | No | \`'HS256'\` | JWT signing algorithm. Options: \`HS256\`, \`HS384\`, \`HS512\`. HS256 is recommended for most cases. |
120
+ | \`issuer\` | string | No | - | JWT \`iss\` claim. Identifies your application. Example: \`'my-app'\` |
121
+ | \`audience\` | string | No | - | JWT \`aud\` claim. Identifies intended recipients. Example: \`'my-api'\` |
122
+ | \`name\` | string | No | \`'access_token'\` | Cookie name when setting via HTTP headers. |
123
+ | \`setHeadersEnabled\` | boolean | No | \`true\` | If \`true\`, token is set as an HTTP-only, Secure, SameSite=Strict cookie. |
124
+ | \`returnJson\` | boolean | No | \`true\` | If \`true\`, token is included in the JSON response body for client-side storage. |
125
+
126
+ ### JWT Payload Structure
127
+
128
+ \`\`\`typescript
129
+ {
130
+ sub: string, // User ID (UUID)
131
+ iat: number, // Issued at (Unix timestamp)
132
+ exp: number, // Expiration (Unix timestamp)
133
+ iss?: string, // Issuer (if configured)
134
+ aud?: string, // Audience (if configured)
135
+ }
136
+ \`\`\`
137
+
138
+ ### Best Practices
139
+
140
+ 1. **Use environment variables** for secrets
141
+ 2. **Keep expiration short** (15 minutes recommended)
142
+ 3. **Enable both cookie and JSON** for flexibility
143
+ 4. **Use HTTPS only** in production
144
+ 5. **Rotate secrets periodically** (quarterly recommended)
145
+
146
+ ### Example
147
+
148
+ \`\`\`typescript
149
+ accessToken: {
150
+ secret: process.env.ACCESS_TOKEN_SECRET!,
151
+ expiresIn: '15m',
152
+ algorithm: 'HS256',
153
+ issuer: 'my-company-api',
154
+ audience: 'my-company-clients',
155
+ name: 'access_token',
156
+ setHeadersEnabled: true,
157
+ returnJson: true,
158
+ }
159
+ \`\`\`
160
+ `,
161
+ },
162
+ {
163
+ id: "refresh-token",
164
+ title: "Refresh Token",
165
+ content: `
166
+ ## Refresh Token
167
+
168
+ The refresh token allows obtaining new access tokens without re-authentication. It implements automatic rotation for enhanced security.
169
+
170
+ ### Configuration
171
+
172
+ \`\`\`typescript
173
+ refreshToken: {
174
+ secret: string,
175
+ expiresIn: string,
176
+ algorithm: Algorithm,
177
+ issuer: string,
178
+ audience: string,
179
+ name: string,
180
+ setHeadersEnabled: boolean,
181
+ returnJson: boolean,
182
+ }
183
+ \`\`\`
184
+
185
+ ### Configuration Fields
186
+
187
+ | Field | Type | Required | Default | Description |
188
+ |-------|------|----------|---------|-------------|
189
+ | \`secret\` | string | **Yes** | - | JWT signing secret. **Must be different from access token secret!** At least 32 characters. |
190
+ | \`expiresIn\` | string | No | \`'7d'\` | Token lifetime. Typically 7-30 days. Longer than access token but not indefinite. |
191
+ | \`algorithm\` | string | No | \`'HS256'\` | JWT signing algorithm. Should match access token for consistency. |
192
+ | \`issuer\` | string | No | - | JWT \`iss\` claim. Can be same as access token. |
193
+ | \`audience\` | string | No | - | JWT \`aud\` claim. Can be same as access token. |
194
+ | \`name\` | string | No | \`'refresh_token'\` | Cookie name. |
195
+ | \`setHeadersEnabled\` | boolean | No | \`true\` | Should be \`true\` - refresh tokens should always be in HTTP-only cookies. |
196
+ | \`returnJson\` | boolean | No | \`false\` | Should be \`false\` - don't expose refresh token in response body for security. |
197
+
198
+ ### Token Rotation
199
+
200
+ Nucleus implements **refresh token rotation** automatically:
201
+
202
+ \`\`\`mermaid
203
+ sequenceDiagram
204
+ participant C as Client
205
+ participant S as Server
206
+
207
+ Note over C,S: First Refresh
208
+ C->>S: POST /auth/refresh (RT-1)
209
+ S->>S: Verify RT-1
210
+ S->>S: Generate new Access Token
211
+ S->>S: Generate RT-2 (new refresh token)
212
+ S->>S: Invalidate RT-1
213
+ S-->>C: New tokens (AT + RT-2)
214
+
215
+ Note over C,S: Second Refresh
216
+ C->>S: POST /auth/refresh (RT-2)
217
+ S->>S: Verify RT-2
218
+ S->>S: Generate new Access Token
219
+ S->>S: Generate RT-3
220
+ S->>S: Invalidate RT-2
221
+ S-->>C: New tokens (AT + RT-3)
222
+
223
+ Note over C,S: Attempted Replay Attack
224
+ C->>S: POST /auth/refresh (RT-1 - stolen)
225
+ S->>S: RT-1 already used!
226
+ S->>S: Revoke ALL user sessions
227
+ S-->>C: 401 Unauthorized
228
+ \`\`\`
229
+
230
+ ### Security Benefits
231
+
232
+ - **Single-use tokens** - Each refresh token can only be used once
233
+ - **Replay detection** - Reusing old tokens triggers security response
234
+ - **Limited exposure** - Compromised token has limited validity window
235
+ `,
236
+ },
237
+ {
238
+ id: "session-token",
239
+ title: "Session Token",
240
+ content: `
241
+ ## Session Token
242
+
243
+ The session token uniquely identifies a user's session and enables device management, activity tracking, and remote logout capabilities.
244
+
245
+ ### Configuration
246
+
247
+ \`\`\`typescript
248
+ sessionToken: {
249
+ secret: string,
250
+ expiresIn: string,
251
+ algorithm: Algorithm,
252
+ name: string,
253
+ setHeadersEnabled: boolean,
254
+ returnJson: boolean,
255
+ }
256
+ \`\`\`
257
+
258
+ ### Configuration Fields
259
+
260
+ | Field | Type | Required | Default | Description |
261
+ |-------|------|----------|---------|-------------|
262
+ | \`secret\` | string | **Yes** | - | JWT signing secret. **Must be unique** from other token secrets. At least 32 characters. |
263
+ | \`expiresIn\` | string | No | \`'30d'\` | Session lifetime. Can be longer since sessions are tracked server-side and revocable. |
264
+ | \`algorithm\` | string | No | \`'HS256'\` | JWT signing algorithm. |
265
+ | \`name\` | string | No | \`'session_token'\` | Cookie name for the session identifier. |
266
+ | \`setHeadersEnabled\` | boolean | No | \`true\` | Should be \`true\` for cookie-based session tracking. |
267
+ | \`returnJson\` | boolean | No | \`false\` | Usually \`false\` - session ID is primarily for server-side tracking. |
268
+
269
+ ### Session Data Model
270
+
271
+ Each session stores comprehensive information:
272
+
273
+ \`\`\`mermaid
274
+ erDiagram
275
+ USER_SESSION {
276
+ uuid id PK "Session identifier"
277
+ uuid userId FK "Owner of session"
278
+ string tokenHash "Hashed session token"
279
+ string deviceFingerprint "Browser+OS+Device hash"
280
+ string deviceName "Human-readable device name"
281
+ string deviceType "desktop/mobile/tablet"
282
+ string browserName "Chrome/Firefox/Safari/etc"
283
+ string browserVersion "Browser version number"
284
+ string osName "Windows/MacOS/Linux/iOS/Android"
285
+ string osVersion "OS version number"
286
+ string ipAddress "Login IP address"
287
+ string loginMethod "password/magic-link/oauth"
288
+ int trustScore "0-100 security score"
289
+ timestamp lastActivityAt "Last API request time"
290
+ timestamp createdAt "Session creation time"
291
+ timestamp expiresAt "Session expiration time"
292
+ boolean isActive "Is session valid"
293
+ timestamp revokedAt "When revoked (if revoked)"
294
+ string revokedReason "Why revoked"
295
+ }
296
+ \`\`\`
297
+
298
+ ### Trust Score Calculation
299
+
300
+ The trust score (0-100) is calculated based on:
301
+
302
+ | Factor | Impact |
303
+ |--------|--------|
304
+ | New device | -25 points |
305
+ | Unknown IP address | -20 points |
306
+ | Missing browser info | -15 points |
307
+ | Missing OS info | -15 points |
308
+ | Unknown device type | -10 points |
309
+ | Generic device name | -5 points |
310
+ | Known device fingerprint | +20 points |
311
+ | Known IP address | +15 points |
312
+
313
+ ### Low Trust Score Actions
314
+
315
+ When trust score falls below 50:
316
+ - Email notification sent to user
317
+ - Session flagged for review
318
+ - Additional verification may be required
319
+
320
+ ### Dual Storage
321
+
322
+ Sessions are stored in both Redis and PostgreSQL:
323
+
324
+ | Storage | Purpose |
325
+ |---------|---------|
326
+ | **Redis** | Fast validation on every request |
327
+ | **PostgreSQL** | Persistent history, analytics, compliance |
328
+ `,
329
+ },
330
+ ],
331
+ },
332
+ {
333
+ id: "classic-routes",
334
+ title: "Classic Routes",
335
+ subItems: [
336
+ {
337
+ id: "login",
338
+ title: "Login",
339
+ content: `
340
+ ## Login Route
341
+
342
+ **POST** \`/auth/login\`
343
+
344
+ Authenticates a user with email and password, creating a new session.
345
+
346
+ ### Configuration
347
+
348
+ \`\`\`typescript
349
+ login: {
350
+ route: string,
351
+ enabled: boolean,
352
+ isPublic: boolean,
353
+ rememberMe: boolean,
354
+ }
355
+ \`\`\`
356
+
357
+ ### Configuration Fields
358
+
359
+ | Field | Type | Required | Default | Description |
360
+ |-------|------|----------|---------|-------------|
361
+ | \`route\` | string | No | \`'/auth/login'\` | Custom route path for the login endpoint. |
362
+ | \`enabled\` | boolean | No | \`true\` | Enable or disable the login route entirely. |
363
+ | \`isPublic\` | boolean | No | \`true\` | Must be \`true\` - unauthenticated users need to login. |
364
+ | \`rememberMe\` | boolean | No | \`true\` | Enable "remember me" option for extended session duration. |
365
+
366
+ ### Request
367
+
368
+ \`\`\`typescript
369
+ POST /auth/login
370
+ Content-Type: application/json
371
+
372
+ {
373
+ "email": "user@example.com",
374
+ "password": "userpassword123",
375
+ "rememberMe": true // Optional, extends session
376
+ }
377
+ \`\`\`
378
+
379
+ ### Success Response (200)
380
+
381
+ \`\`\`typescript
382
+ {
383
+ "success": true,
384
+ "data": {
385
+ "user": {
386
+ "id": "550e8400-e29b-41d4-a716-446655440000",
387
+ "email": "user@example.com",
388
+ "name": "John Doe",
389
+ "role": "user",
390
+ "createdAt": "2024-01-01T00:00:00.000Z"
391
+ },
392
+ "accessToken": "eyJhbGciOiJIUzI1NiIs...", // If returnJson: true
393
+ "sessionId": "660e8400-e29b-41d4-a716-446655440001"
394
+ }
395
+ }
396
+
397
+ // Also sets HTTP-only cookies:
398
+ // - access_token
399
+ // - refresh_token
400
+ // - session_token
401
+ \`\`\`
402
+
403
+ ### Error Responses
404
+
405
+ | Status | Message | Cause |
406
+ |--------|---------|-------|
407
+ | 400 | "Email and password are required" | Missing fields |
408
+ | 401 | "Invalid credentials" | Wrong email or password |
409
+ | 403 | "Account is disabled" | User account deactivated |
410
+ | 429 | "Too many attempts" | Rate limit exceeded |
411
+
412
+ ### Login Flow
413
+
414
+ \`\`\`mermaid
415
+ sequenceDiagram
416
+ participant C as Client
417
+ participant S as Server
418
+ participant D as Database
419
+ participant R as Redis
420
+
421
+ C->>S: POST /auth/login
422
+ S->>S: Validate input
423
+ S->>D: Find user by email
424
+
425
+ alt User not found
426
+ S-->>C: 401 Invalid credentials
427
+ else User found
428
+ S->>S: Verify password (bcrypt)
429
+ alt Password invalid
430
+ S-->>C: 401 Invalid credentials
431
+ else Password valid
432
+ S->>S: Generate tokens
433
+ S->>S: Calculate trust score
434
+ S->>D: Save session
435
+ S->>R: Cache session
436
+ S->>S: Set cookies
437
+ S-->>C: 200 Success + tokens
438
+ end
439
+ end
440
+ \`\`\`
441
+ `,
442
+ },
443
+ {
444
+ id: "register",
445
+ title: "Register",
446
+ content: `
447
+ ## Register Route
448
+
449
+ **POST** \`/auth/register\`
450
+
451
+ Creates a new user account.
452
+
453
+ ### Configuration
454
+
455
+ \`\`\`typescript
456
+ register: {
457
+ route: string,
458
+ enabled: boolean,
459
+ isPublic: boolean,
460
+ }
461
+ \`\`\`
462
+
463
+ ### Configuration Fields
464
+
465
+ | Field | Type | Required | Default | Description |
466
+ |-------|------|----------|---------|-------------|
467
+ | \`route\` | string | No | \`'/auth/register'\` | Custom route path for registration. |
468
+ | \`enabled\` | boolean | No | \`true\` | Enable/disable registration. Set \`false\` to prevent new signups. |
469
+ | \`isPublic\` | boolean | No | \`true\` | Must be \`true\` for self-registration. |
470
+
471
+ ### Request
472
+
473
+ \`\`\`typescript
474
+ POST /auth/register
475
+ Content-Type: application/json
476
+
477
+ {
478
+ "email": "newuser@example.com",
479
+ "password": "securepassword123",
480
+ "name": "Jane Doe" // Optional
481
+ }
482
+ \`\`\`
483
+
484
+ ### Success Response (201)
485
+
486
+ \`\`\`typescript
487
+ {
488
+ "success": true,
489
+ "data": {
490
+ "user": {
491
+ "id": "550e8400-e29b-41d4-a716-446655440000",
492
+ "email": "newuser@example.com",
493
+ "name": "Jane Doe",
494
+ "role": "user",
495
+ "createdAt": "2024-01-15T10:30:00.000Z"
496
+ }
497
+ }
498
+ }
499
+ \`\`\`
500
+
501
+ ### Error Responses
502
+
503
+ | Status | Message | Cause |
504
+ |--------|---------|-------|
505
+ | 400 | "Email and password are required" | Missing fields |
506
+ | 400 | "Invalid email format" | Email validation failed |
507
+ | 400 | "Password too weak" | Doesn't meet requirements |
508
+ | 409 | "Email already registered" | Duplicate email |
509
+
510
+ ### Password Requirements
511
+
512
+ - Minimum 8 characters
513
+ - Passwords are hashed with bcrypt (cost factor 12)
514
+ - Original password is never stored
515
+ `,
516
+ },
517
+ {
518
+ id: "logout",
519
+ title: "Logout",
520
+ content: `
521
+ ## Logout Route
522
+
523
+ **POST** \`/auth/logout\`
524
+
525
+ Terminates the current session and clears authentication cookies.
526
+
527
+ ### Configuration
528
+
529
+ \`\`\`typescript
530
+ logout: {
531
+ route: string,
532
+ enabled: boolean,
533
+ isPublic: boolean,
534
+ }
535
+ \`\`\`
536
+
537
+ ### Configuration Fields
538
+
539
+ | Field | Type | Required | Default | Description |
540
+ |-------|------|----------|---------|-------------|
541
+ | \`route\` | string | No | \`'/auth/logout'\` | Custom route path. |
542
+ | \`enabled\` | boolean | No | \`true\` | Enable/disable logout functionality. |
543
+ | \`isPublic\` | boolean | No | \`false\` | Should be \`false\` - only authenticated users can logout. |
544
+
545
+ ### Request
546
+
547
+ \`\`\`typescript
548
+ POST /auth/logout
549
+ // Cookies automatically sent by browser
550
+ \`\`\`
551
+
552
+ ### Success Response (200)
553
+
554
+ \`\`\`typescript
555
+ {
556
+ "success": true,
557
+ "message": "Logged out successfully"
558
+ }
559
+
560
+ // Clears cookies:
561
+ // - access_token (expired)
562
+ // - refresh_token (expired)
563
+ // - session_token (expired)
564
+ \`\`\`
565
+
566
+ ### What Happens
567
+
568
+ \`\`\`mermaid
569
+ sequenceDiagram
570
+ participant C as Client
571
+ participant S as Server
572
+ participant R as Redis
573
+ participant D as Database
574
+
575
+ C->>S: POST /auth/logout
576
+ S->>S: Extract session from cookie
577
+ S->>R: Delete session from cache
578
+ S->>D: Update session record
579
+ Note over D: isActive = false<br/>revokedAt = now()<br/>revokedReason = 'user_logout'
580
+ S->>S: Clear all auth cookies
581
+ S-->>C: 200 OK
582
+ \`\`\`
583
+
584
+ ### Error Responses
585
+
586
+ | Status | Message | Cause |
587
+ |--------|---------|-------|
588
+ | 401 | "Not authenticated" | No valid session |
589
+ `,
590
+ },
591
+ {
592
+ id: "refresh",
593
+ title: "Refresh",
594
+ content: `
595
+ ## Refresh Route
596
+
597
+ **POST** \`/auth/refresh\`
598
+
599
+ Obtains a new access token using the refresh token. Implements automatic token rotation.
600
+
601
+ ### Configuration
602
+
603
+ \`\`\`typescript
604
+ refresh: {
605
+ route: string,
606
+ enabled: boolean,
607
+ isPublic: boolean,
608
+ }
609
+ \`\`\`
610
+
611
+ ### Configuration Fields
612
+
613
+ | Field | Type | Required | Default | Description |
614
+ |-------|------|----------|---------|-------------|
615
+ | \`route\` | string | No | \`'/auth/refresh'\` | Custom route path. |
616
+ | \`enabled\` | boolean | No | \`true\` | Enable token refresh. |
617
+ | \`isPublic\` | boolean | No | \`true\` | Should be \`true\` - access token may be expired when refreshing. |
618
+
619
+ ### Request
620
+
621
+ \`\`\`typescript
622
+ POST /auth/refresh
623
+ // refresh_token cookie automatically sent
624
+ \`\`\`
625
+
626
+ ### Success Response (200)
627
+
628
+ \`\`\`typescript
629
+ {
630
+ "success": true,
631
+ "data": {
632
+ "accessToken": "eyJhbGciOiJIUzI1NiIs..." // If returnJson: true
633
+ }
634
+ }
635
+
636
+ // Sets new cookies:
637
+ // - access_token (new)
638
+ // - refresh_token (new - rotated)
639
+ \`\`\`
640
+
641
+ ### Token Rotation Flow
642
+
643
+ \`\`\`mermaid
644
+ sequenceDiagram
645
+ participant C as Client
646
+ participant S as Server
647
+
648
+ C->>S: POST /auth/refresh
649
+ Note over C: Sends refresh_token cookie
650
+
651
+ S->>S: Verify refresh token JWT
652
+
653
+ alt Invalid or expired
654
+ S-->>C: 401 Unauthorized
655
+ else Valid
656
+ S->>S: Generate new access token
657
+ S->>S: Generate new refresh token
658
+ S->>S: Invalidate old refresh token
659
+ S->>S: Set new cookies
660
+ S-->>C: 200 OK + new tokens
661
+ end
662
+ \`\`\`
663
+
664
+ ### Error Responses
665
+
666
+ | Status | Message | Cause |
667
+ |--------|---------|-------|
668
+ | 401 | "Invalid refresh token" | Token invalid or expired |
669
+ | 401 | "Refresh token reuse detected" | Possible token theft |
670
+ `,
671
+ },
672
+ {
673
+ id: "password-change",
674
+ title: "Password Change",
675
+ content: `
676
+ ## Password Change Route
677
+
678
+ **POST** \`/auth/password/change\`
679
+
680
+ Allows authenticated users to change their password.
681
+
682
+ ### Configuration
683
+
684
+ \`\`\`typescript
685
+ passwordChange: {
686
+ route: string,
687
+ enabled: boolean,
688
+ isPublic: boolean,
689
+ }
690
+ \`\`\`
691
+
692
+ ### Configuration Fields
693
+
694
+ | Field | Type | Required | Default | Description |
695
+ |-------|------|----------|---------|-------------|
696
+ | \`route\` | string | No | \`'/auth/password/change'\` | Custom route path. |
697
+ | \`enabled\` | boolean | No | \`true\` | Enable password change. |
698
+ | \`isPublic\` | boolean | No | \`false\` | Must be \`false\` - requires authentication. |
699
+
700
+ ### Request
701
+
702
+ \`\`\`typescript
703
+ POST /auth/password/change
704
+ Content-Type: application/json
705
+
706
+ {
707
+ "currentPassword": "oldpassword123",
708
+ "newPassword": "newsecurepassword456"
709
+ }
710
+ \`\`\`
711
+
712
+ ### Success Response (200)
713
+
714
+ \`\`\`typescript
715
+ {
716
+ "success": true,
717
+ "message": "Password changed successfully"
718
+ }
719
+ \`\`\`
720
+
721
+ ### Error Responses
722
+
723
+ | Status | Message | Cause |
724
+ |--------|---------|-------|
725
+ | 400 | "Current and new password required" | Missing fields |
726
+ | 400 | "New password too weak" | Doesn't meet requirements |
727
+ | 401 | "Current password incorrect" | Wrong current password |
728
+ | 401 | "Not authenticated" | No valid session |
729
+ `,
730
+ },
731
+ {
732
+ id: "me",
733
+ title: "Me",
734
+ content: `
735
+ ## Me Route
736
+
737
+ **GET** \`/auth/me\`
738
+
739
+ Returns information about the currently authenticated user.
740
+
741
+ ### Configuration
742
+
743
+ \`\`\`typescript
744
+ me: {
745
+ route: string,
746
+ enabled: boolean,
747
+ isPublic: boolean,
748
+ includeProfile: boolean,
749
+ includeAddresses: boolean,
750
+ includePhones: boolean,
751
+ includeFiles: boolean,
752
+ }
753
+ \`\`\`
754
+
755
+ ### Configuration Fields
756
+
757
+ | Field | Type | Required | Default | Description |
758
+ |-------|------|----------|---------|-------------|
759
+ | \`route\` | string | No | \`'/auth/me'\` | Custom route path. |
760
+ | \`enabled\` | boolean | No | \`true\` | Enable the me endpoint. |
761
+ | \`isPublic\` | boolean | No | \`false\` | Must be \`false\` - requires authentication. |
762
+ | \`includeProfile\` | boolean | No | \`true\` | Include data from \`profiles\` table if it exists. |
763
+ | \`includeAddresses\` | boolean | No | \`false\` | Include data from \`addresses\` table if it exists. |
764
+ | \`includePhones\` | boolean | No | \`false\` | Include data from \`phones\` table if it exists. |
765
+ | \`includeFiles\` | boolean | No | \`false\` | Include data from user's files if file management is enabled. |
766
+
767
+ ### Request
768
+
769
+ \`\`\`typescript
770
+ GET /auth/me
771
+ // Auth cookies automatically sent
772
+ \`\`\`
773
+
774
+ ### Success Response (200)
775
+
776
+ \`\`\`typescript
777
+ {
778
+ "success": true,
779
+ "data": {
780
+ "id": "550e8400-e29b-41d4-a716-446655440000",
781
+ "email": "user@example.com",
782
+ "name": "John Doe",
783
+ "role": "user",
784
+ "createdAt": "2024-01-01T00:00:00.000Z",
785
+ "updatedAt": "2024-01-15T10:30:00.000Z",
786
+
787
+ // If includeProfile: true
788
+ "profile": {
789
+ "bio": "Software developer",
790
+ "avatar": "https://...",
791
+ "website": "https://johndoe.com"
792
+ },
793
+
794
+ // If includeAddresses: true
795
+ "addresses": [
796
+ {
797
+ "id": "...",
798
+ "street": "123 Main St",
799
+ "city": "New York",
800
+ "country": "USA"
801
+ }
802
+ ],
803
+
804
+ // If includePhones: true
805
+ "phones": [
806
+ {
807
+ "id": "...",
808
+ "number": "+1234567890",
809
+ "type": "mobile"
810
+ }
811
+ ]
812
+ }
813
+ }
814
+ \`\`\`
815
+
816
+ ### Error Responses
817
+
818
+ | Status | Message | Cause |
819
+ |--------|---------|-------|
820
+ | 401 | "Not authenticated" | No valid session |
821
+ `,
822
+ },
823
+ ],
824
+ },
825
+ {
826
+ id: "password-reset",
827
+ title: "Password Reset",
828
+ subItems: [
829
+ {
830
+ id: "password-reset-how",
831
+ title: "How It Works",
832
+ content: `
833
+ ## Password Reset System
834
+
835
+ Password reset allows users to recover access to their account when they've forgotten their password. It uses a secure token-based flow.
836
+
837
+ ### Prerequisites
838
+
839
+ Password reset requires an **email provider** to be configured:
840
+
841
+ \`\`\`typescript
842
+ email: {
843
+ gmail: {
844
+ enabled: true,
845
+ json_file_path: './gmail-credentials.json',
846
+ }
847
+ }
848
+ \`\`\`
849
+
850
+ ### Complete Flow
851
+
852
+ \`\`\`mermaid
853
+ sequenceDiagram
854
+ participant U as User
855
+ participant C as Client App
856
+ participant S as Nucleus Server
857
+ participant E as Email Service
858
+ participant D as Database
859
+
860
+ Note over U,D: Step 1: Request Reset
861
+ U->>C: Click "Forgot Password"
862
+ U->>C: Enter email address
863
+ C->>S: POST /auth/password/reset/request
864
+ S->>D: Find user by email
865
+
866
+ alt User exists
867
+ S->>S: Generate secure token
868
+ S->>S: Hash token for storage
869
+ S->>D: Store hashed token
870
+ S->>E: Send reset email
871
+ E-->>U: Email with reset link
872
+ end
873
+
874
+ S-->>C: "Check your email"
875
+ Note over S,C: Same response whether user exists or not (security)
876
+
877
+ Note over U,D: Step 2: Reset Password
878
+ U->>U: Open email
879
+ U->>C: Click reset link
880
+ C->>C: Extract token from URL
881
+ U->>C: Enter new password
882
+ C->>S: POST /auth/password/reset/confirm
883
+ S->>D: Find token (hashed)
884
+
885
+ alt Token valid & not expired
886
+ S->>S: Hash new password
887
+ S->>D: Update user password
888
+ S->>D: Delete used token
889
+ S-->>C: "Password reset successful"
890
+ else Token invalid or expired
891
+ S-->>C: "Invalid or expired token"
892
+ end
893
+ \`\`\`
894
+
895
+ ### Configuration
896
+
897
+ \`\`\`typescript
898
+ passwordReset: {
899
+ route: string,
900
+ enabled: boolean,
901
+ isPublic: boolean,
902
+ redirectUrl: string,
903
+ }
904
+ \`\`\`
905
+
906
+ ### Configuration Fields
907
+
908
+ | Field | Type | Required | Default | Description |
909
+ |-------|------|----------|---------|-------------|
910
+ | \`route\` | string | No | \`'/auth/password/reset'\` | Base route. Creates \`/request\` and \`/confirm\` sub-routes. |
911
+ | \`enabled\` | boolean | No | \`true\` | Enable password reset. **Automatically disabled if no email provider.** |
912
+ | \`isPublic\` | boolean | No | \`true\` | Must be \`true\` - users who forgot password can't authenticate. |
913
+ | \`redirectUrl\` | string | **Yes** | - | URL for the reset link in email. Token appended as \`?token=xxx\`. Example: \`'https://myapp.com/reset-password'\` |
914
+
915
+ ### Security Features
916
+
917
+ - **Token hashing** - Only hashed tokens stored in database
918
+ - **Single use** - Tokens deleted after successful use
919
+ - **Expiration** - Tokens expire after 1 hour
920
+ - **Rate limiting** - Prevents abuse
921
+ - **Vague responses** - Same response whether email exists or not
922
+ `,
923
+ },
924
+ {
925
+ id: "password-reset-request",
926
+ title: "Request Route",
927
+ content: `
928
+ ## Request Password Reset
929
+
930
+ **POST** \`/auth/password/reset/request\`
931
+
932
+ Initiates the password reset process by sending a reset link to the user's email.
933
+
934
+ ### Request
935
+
936
+ \`\`\`typescript
937
+ POST /auth/password/reset/request
938
+ Content-Type: application/json
939
+
940
+ {
941
+ "email": "user@example.com"
942
+ }
943
+ \`\`\`
944
+
945
+ ### Success Response (200)
946
+
947
+ \`\`\`typescript
948
+ {
949
+ "success": true,
950
+ "message": "If an account exists with this email, a reset link has been sent"
951
+ }
952
+ \`\`\`
953
+
954
+ > **Security Note:** The response is intentionally vague. It doesn't reveal whether the email exists in the system. This prevents email enumeration attacks.
955
+
956
+ ### Email Sent
957
+
958
+ If the email exists, the user receives:
959
+
960
+ \`\`\`
961
+ Subject: Password Reset Request
962
+
963
+ Click the link below to reset your password:
964
+ https://yourapp.com/reset-password?token=abc123def456...
965
+
966
+ This link expires in 1 hour.
967
+
968
+ If you didn't request this, please ignore this email.
969
+ \`\`\`
970
+
971
+ ### Token Storage
972
+
973
+ \`\`\`typescript
974
+ // passwordResetTokens table
975
+ {
976
+ id: 'uuid',
977
+ userId: 'uuid',
978
+ tokenHash: 'hashed-token', // bcrypt hash
979
+ email: 'user@example.com',
980
+ expiresAt: '2024-01-15T11:30:00Z', // 1 hour from creation
981
+ createdAt: '2024-01-15T10:30:00Z'
982
+ }
983
+ \`\`\`
984
+
985
+ ### Error Responses
986
+
987
+ | Status | Message | Cause |
988
+ |--------|---------|-------|
989
+ | 400 | "Email is required" | Missing email field |
990
+ | 400 | "Invalid email format" | Email validation failed |
991
+ | 429 | "Too many requests" | Rate limit exceeded |
992
+ | 503 | "Email service unavailable" | Email provider error |
993
+ `,
994
+ },
995
+ {
996
+ id: "password-reset-confirm",
997
+ title: "Confirm Route",
998
+ content: `
999
+ ## Confirm Password Reset
1000
+
1001
+ **POST** \`/auth/password/reset/confirm\`
1002
+
1003
+ Completes the password reset using the token from the email link.
1004
+
1005
+ ### Request
1006
+
1007
+ \`\`\`typescript
1008
+ POST /auth/password/reset/confirm
1009
+ Content-Type: application/json
1010
+
1011
+ {
1012
+ "token": "abc123def456...", // From email link
1013
+ "newPassword": "mynewsecurepassword123"
1014
+ }
1015
+ \`\`\`
1016
+
1017
+ ### Success Response (200)
1018
+
1019
+ \`\`\`typescript
1020
+ {
1021
+ "success": true,
1022
+ "message": "Password has been reset successfully"
1023
+ }
1024
+ \`\`\`
1025
+
1026
+ ### Error Responses
1027
+
1028
+ | Status | Message | Cause |
1029
+ |--------|---------|-------|
1030
+ | 400 | "Token and new password required" | Missing fields |
1031
+ | 400 | "Password too weak" | Doesn't meet requirements |
1032
+ | 400 | "Invalid or expired token" | Token not found or expired |
1033
+
1034
+ ### What Happens
1035
+
1036
+ 1. Server looks up token hash in database
1037
+ 2. Verifies token hasn't expired (1 hour limit)
1038
+ 3. Hashes new password with bcrypt
1039
+ 4. Updates user's password in database
1040
+ 5. Deletes the reset token (single use)
1041
+ 6. Optionally: Revokes all existing sessions
1042
+
1043
+ ### Client Implementation
1044
+
1045
+ \`\`\`typescript
1046
+ // Your reset password page
1047
+ const ResetPasswordPage = () => {
1048
+ const token = new URLSearchParams(location.search).get('token')
1049
+
1050
+ const handleSubmit = async (newPassword: string) => {
1051
+ const response = await fetch('/auth/password/reset/confirm', {
1052
+ method: 'POST',
1053
+ headers: { 'Content-Type': 'application/json' },
1054
+ body: JSON.stringify({ token, newPassword })
1055
+ })
1056
+
1057
+ if (response.ok) {
1058
+ // Redirect to login
1059
+ window.location.href = '/login'
1060
+ }
1061
+ }
1062
+ }
1063
+ \`\`\`
1064
+ `,
1065
+ },
1066
+ ],
1067
+ },
1068
+ {
1069
+ id: "magic-link",
1070
+ title: "Magic Link",
1071
+ subItems: [
1072
+ {
1073
+ id: "magic-link-how",
1074
+ title: "How It Works",
1075
+ content: `
1076
+ ## Magic Link Authentication
1077
+
1078
+ Magic links provide **passwordless authentication** - users sign in by clicking a link sent to their email, with no password required.
1079
+
1080
+ ### Prerequisites
1081
+
1082
+ Magic link requires an **email provider**:
1083
+
1084
+ \`\`\`typescript
1085
+ email: {
1086
+ gmail: {
1087
+ enabled: true,
1088
+ json_file_path: './gmail-credentials.json',
1089
+ }
1090
+ }
1091
+ \`\`\`
1092
+
1093
+ ### Complete Flow
1094
+
1095
+ \`\`\`mermaid
1096
+ sequenceDiagram
1097
+ participant U as User
1098
+ participant C as Client App
1099
+ participant S as Nucleus Server
1100
+ participant E as Email Service
1101
+ participant D as Database
1102
+ participant R as Redis
1103
+
1104
+ Note over U,R: Step 1: Request Magic Link
1105
+ U->>C: Enter email address
1106
+ C->>S: POST /auth/magic-link
1107
+ S->>D: Check if user exists
1108
+
1109
+ alt New user
1110
+ S->>D: Create user account
1111
+ end
1112
+
1113
+ S->>S: Generate secure token
1114
+ S->>D: Store magic link token
1115
+ S->>E: Send magic link email
1116
+ E-->>U: Email with login link
1117
+ S-->>C: "Check your email"
1118
+
1119
+ Note over U,R: Step 2: Verify & Login
1120
+ U->>U: Open email
1121
+ U->>S: GET /auth/magic-link/verify?token=xxx
1122
+ S->>D: Find and validate token
1123
+
1124
+ alt Token valid
1125
+ S->>S: Generate auth tokens
1126
+ S->>R: Create session
1127
+ S->>D: Save session
1128
+ S->>D: Delete magic token
1129
+ S-->>U: Redirect to app with cookies
1130
+ else Token invalid
1131
+ S-->>U: Error page
1132
+ end
1133
+ \`\`\`
1134
+
1135
+ ### Configuration
1136
+
1137
+ \`\`\`typescript
1138
+ magicLink: {
1139
+ route: string,
1140
+ verifyRoute: string,
1141
+ enabled: boolean,
1142
+ isPublic: boolean,
1143
+ expiresIn: string,
1144
+ redirectUrl: string,
1145
+ }
1146
+ \`\`\`
1147
+
1148
+ ### Configuration Fields
1149
+
1150
+ | Field | Type | Required | Default | Description |
1151
+ |-------|------|----------|---------|-------------|
1152
+ | \`route\` | string | No | \`'/auth/magic-link'\` | Route for requesting magic link. |
1153
+ | \`verifyRoute\` | string | No | \`'/auth/magic-link/verify'\` | Route for verifying magic link token. |
1154
+ | \`enabled\` | boolean | No | \`true\` | Enable magic link. **Auto-disabled if no email provider.** |
1155
+ | \`isPublic\` | boolean | No | \`true\` | Must be \`true\` for passwordless login. |
1156
+ | \`expiresIn\` | string | No | \`'15m'\` | Token expiration. Keep short (10-30 min). |
1157
+ | \`redirectUrl\` | string | **Yes** | - | Where to redirect after successful verification. Example: \`'https://myapp.com/dashboard'\` |
1158
+
1159
+ ### Benefits
1160
+
1161
+ | Feature | Password Auth | Magic Link |
1162
+ |---------|---------------|------------|
1163
+ | Password management | Required | Not needed |
1164
+ | Credential stuffing risk | High | None |
1165
+ | Phishing resistance | Low | Higher |
1166
+ | User friction | Medium | Low |
1167
+ | Account recovery | Complex | Built-in |
1168
+
1169
+ ### Use Cases
1170
+
1171
+ - **SaaS applications** - Reduce signup friction
1172
+ - **Infrequent users** - No password to remember
1173
+ - **B2B portals** - Verified corporate emails
1174
+ - **Email verification** - Magic link = verified email
1175
+ `,
1176
+ },
1177
+ {
1178
+ id: "magic-link-request",
1179
+ title: "Request Route",
1180
+ content: `
1181
+ ## Request Magic Link
1182
+
1183
+ **POST** \`/auth/magic-link\`
1184
+
1185
+ Sends a magic link to the user's email for passwordless authentication.
1186
+
1187
+ ### Request
1188
+
1189
+ \`\`\`typescript
1190
+ POST /auth/magic-link
1191
+ Content-Type: application/json
1192
+
1193
+ {
1194
+ "email": "user@example.com"
1195
+ }
1196
+ \`\`\`
1197
+
1198
+ ### Success Response (200)
1199
+
1200
+ \`\`\`typescript
1201
+ {
1202
+ "success": true,
1203
+ "message": "Magic link sent to your email"
1204
+ }
1205
+ \`\`\`
1206
+
1207
+ ### Email Sent
1208
+
1209
+ \`\`\`
1210
+ Subject: Your Login Link
1211
+
1212
+ Click below to sign in:
1213
+ https://api.yourapp.com/auth/magic-link/verify?token=abc123...
1214
+
1215
+ This link expires in 15 minutes.
1216
+
1217
+ If you didn't request this, please ignore this email.
1218
+ \`\`\`
1219
+
1220
+ ### Auto-Registration
1221
+
1222
+ If the email doesn't exist:
1223
+ 1. A new user account is created automatically
1224
+ 2. User gets the same magic link email
1225
+ 3. Clicking the link logs them in to their new account
1226
+
1227
+ This is great for reducing signup friction!
1228
+
1229
+ ### Token Storage
1230
+
1231
+ \`\`\`typescript
1232
+ // magicLinkTokens table
1233
+ {
1234
+ id: 'uuid',
1235
+ userId: 'uuid',
1236
+ tokenHash: 'hashed-token',
1237
+ email: 'user@example.com',
1238
+ expiresAt: '2024-01-15T10:45:00Z', // 15 min from creation
1239
+ createdAt: '2024-01-15T10:30:00Z'
1240
+ }
1241
+ \`\`\`
1242
+
1243
+ ### Error Responses
1244
+
1245
+ | Status | Message | Cause |
1246
+ |--------|---------|-------|
1247
+ | 400 | "Email is required" | Missing email |
1248
+ | 400 | "Invalid email format" | Validation failed |
1249
+ | 429 | "Too many requests" | Rate limit |
1250
+ | 503 | "Email service unavailable" | Provider error |
1251
+ `,
1252
+ },
1253
+ {
1254
+ id: "magic-link-verify",
1255
+ title: "Verify Route",
1256
+ content: `
1257
+ ## Verify Magic Link
1258
+
1259
+ **GET** \`/auth/magic-link/verify?token=xxx\`
1260
+
1261
+ Verifies the magic link token and creates an authenticated session.
1262
+
1263
+ ### Request
1264
+
1265
+ \`\`\`
1266
+ GET /auth/magic-link/verify?token=abc123def456...
1267
+ \`\`\`
1268
+
1269
+ ### Success Flow
1270
+
1271
+ On successful verification:
1272
+
1273
+ 1. Token is validated against database
1274
+ 2. User session is created
1275
+ 3. Auth cookies are set
1276
+ 4. User is redirected to \`redirectUrl\`
1277
+
1278
+ \`\`\`
1279
+ HTTP/1.1 302 Found
1280
+ Location: https://myapp.com/dashboard
1281
+ Set-Cookie: access_token=...; HttpOnly; Secure; SameSite=Strict
1282
+ Set-Cookie: refresh_token=...; HttpOnly; Secure; SameSite=Strict
1283
+ Set-Cookie: session_token=...; HttpOnly; Secure; SameSite=Strict
1284
+ \`\`\`
1285
+
1286
+ ### Error Response
1287
+
1288
+ On invalid or expired token:
1289
+
1290
+ \`\`\`typescript
1291
+ {
1292
+ "success": false,
1293
+ "message": "Invalid or expired magic link"
1294
+ }
1295
+ \`\`\`
1296
+
1297
+ ### Security Notes
1298
+
1299
+ - **Single use** - Token deleted after verification
1300
+ - **Short expiration** - 15 minutes default
1301
+ - **HTTPS only** - Token in URL is sensitive
1302
+ - **Rate limited** - Prevents brute force
1303
+
1304
+ ### Client-Side Handling
1305
+
1306
+ The magic link points directly to your API. After verification, users are redirected to your app with cookies already set:
1307
+
1308
+ \`\`\`typescript
1309
+ // In your dashboard component
1310
+ useEffect(() => {
1311
+ // User arrives here already authenticated
1312
+ // Cookies are set by the redirect
1313
+ fetchUserData() // Will work immediately
1314
+ }, [])
1315
+ \`\`\`
1316
+ `,
1317
+ },
1318
+ ],
1319
+ },
1320
+ {
1321
+ id: "sessions",
1322
+ title: "Sessions",
1323
+ subItems: [
1324
+ {
1325
+ id: "sessions-how",
1326
+ title: "How It Works",
1327
+ content: `
1328
+ ## Session Management System
1329
+
1330
+ Nucleus provides enterprise-grade session management with device tracking, security monitoring, and remote control capabilities.
1331
+
1332
+ ### Architecture
1333
+
1334
+ \`\`\`mermaid
1335
+ flowchart TB
1336
+ subgraph Client
1337
+ C1[Browser]
1338
+ C2[Mobile App]
1339
+ C3[Another Browser]
1340
+ end
1341
+
1342
+ subgraph Server
1343
+ S[Session Middleware]
1344
+ end
1345
+
1346
+ subgraph Storage
1347
+ R[Redis Cache<br/>Fast validation]
1348
+ D[PostgreSQL<br/>Persistent storage]
1349
+ end
1350
+
1351
+ C1 -->|session_token| S
1352
+ C2 -->|session_token| S
1353
+ C3 -->|session_token| S
1354
+ S -->|Read/Write| R
1355
+ S -->|Persist| D
1356
+ \`\`\`
1357
+
1358
+ ### Dual Storage Strategy
1359
+
1360
+ | Storage | Purpose | Data |
1361
+ |---------|---------|------|
1362
+ | **Redis** | Fast session validation | Session ID, user ID, last activity |
1363
+ | **PostgreSQL** | Persistent record | Full session details, history |
1364
+
1365
+ ### Configuration
1366
+
1367
+ \`\`\`typescript
1368
+ sessions: {
1369
+ route: string,
1370
+ enabled: boolean,
1371
+ isPublic: boolean,
1372
+ maxActiveSessions: number,
1373
+ inactivityTimeout: string,
1374
+ allowMultipleDevices: boolean,
1375
+ trustNewDevices: boolean,
1376
+ notifyOnNewDevice: boolean,
1377
+ }
1378
+ \`\`\`
1379
+
1380
+ ### Configuration Fields
1381
+
1382
+ | Field | Type | Required | Default | Description |
1383
+ |-------|------|----------|---------|-------------|
1384
+ | \`route\` | string | No | \`'/auth/sessions'\` | Base route for session management endpoints. |
1385
+ | \`enabled\` | boolean | No | \`true\` | Enable session management features. |
1386
+ | \`isPublic\` | boolean | No | \`false\` | Must be \`false\` - requires authentication. |
1387
+ | \`maxActiveSessions\` | number | No | \`5\` | Maximum concurrent sessions per user. When exceeded, oldest session is revoked. |
1388
+ | \`inactivityTimeout\` | string | No | \`'30d'\` | Auto-expire sessions after this period of inactivity. Format: \`'1h'\`, \`'7d'\`, \`'30d'\`. |
1389
+ | \`allowMultipleDevices\` | boolean | No | \`true\` | If \`false\`, new login revokes all other sessions (single device mode). |
1390
+ | \`trustNewDevices\` | boolean | No | \`true\` | If \`false\`, new device logins require additional verification. |
1391
+ | \`notifyOnNewDevice\` | boolean | No | \`true\` | Send email alert when user logs in from new device. |
1392
+
1393
+ ### Session Lifecycle
1394
+
1395
+ \`\`\`mermaid
1396
+ stateDiagram-v2
1397
+ [*] --> Active: Login
1398
+ Active --> Active: Activity
1399
+ Active --> Expired: Inactivity Timeout
1400
+ Active --> Revoked: Manual Logout
1401
+ Active --> Revoked: Remote Revoke
1402
+ Active --> Revoked: Max Sessions Exceeded
1403
+ Expired --> [*]
1404
+ Revoked --> [*]
1405
+ \`\`\`
1406
+ `,
1407
+ },
1408
+ {
1409
+ id: "sessions-list",
1410
+ title: "List Sessions",
1411
+ content: `
1412
+ ## List User Sessions
1413
+
1414
+ **GET** \`/auth/sessions\`
1415
+
1416
+ Returns all active sessions for the authenticated user.
1417
+
1418
+ ### Request
1419
+
1420
+ \`\`\`typescript
1421
+ GET /auth/sessions
1422
+ // Auth cookies required
1423
+ \`\`\`
1424
+
1425
+ ### Success Response (200)
1426
+
1427
+ \`\`\`typescript
1428
+ {
1429
+ "success": true,
1430
+ "data": [
1431
+ {
1432
+ "id": "session-uuid-1",
1433
+ "deviceName": "Chrome on MacOS",
1434
+ "deviceType": "desktop",
1435
+ "browserName": "Chrome",
1436
+ "browserVersion": "120.0.0",
1437
+ "osName": "MacOS",
1438
+ "osVersion": "14.2",
1439
+ "ipAddress": "192.168.1.1",
1440
+ "trustScore": 85,
1441
+ "lastActivityAt": "2024-01-15T10:30:00Z",
1442
+ "createdAt": "2024-01-01T08:00:00Z",
1443
+ "isCurrent": true
1444
+ },
1445
+ {
1446
+ "id": "session-uuid-2",
1447
+ "deviceName": "Safari on iPhone",
1448
+ "deviceType": "mobile",
1449
+ "browserName": "Safari",
1450
+ "browserVersion": "17.0",
1451
+ "osName": "iOS",
1452
+ "osVersion": "17.2",
1453
+ "ipAddress": "10.0.0.5",
1454
+ "trustScore": 90,
1455
+ "lastActivityAt": "2024-01-14T15:20:00Z",
1456
+ "createdAt": "2024-01-10T12:00:00Z",
1457
+ "isCurrent": false
1458
+ }
1459
+ ]
1460
+ }
1461
+ \`\`\`
1462
+
1463
+ ### Response Fields
1464
+
1465
+ | Field | Type | Description |
1466
+ |-------|------|-------------|
1467
+ | \`id\` | string | Unique session identifier |
1468
+ | \`deviceName\` | string | Human-readable device name |
1469
+ | \`deviceType\` | string | \`'desktop'\` \\| \`'mobile'\` \\| \`'tablet'\` |
1470
+ | \`browserName\` | string | Browser name |
1471
+ | \`browserVersion\` | string | Browser version |
1472
+ | \`osName\` | string | Operating system |
1473
+ | \`osVersion\` | string | OS version |
1474
+ | \`ipAddress\` | string | Login IP address |
1475
+ | \`trustScore\` | number | Security score (0-100) |
1476
+ | \`lastActivityAt\` | string | Last API request timestamp |
1477
+ | \`createdAt\` | string | Session creation timestamp |
1478
+ | \`isCurrent\` | boolean | Is this the requesting session |
1479
+
1480
+ ### Use Cases
1481
+
1482
+ - Show user their active devices
1483
+ - Security dashboard
1484
+ - Identify suspicious sessions
1485
+ `,
1486
+ },
1487
+ {
1488
+ id: "sessions-revoke",
1489
+ title: "Revoke Session",
1490
+ content: `
1491
+ ## Revoke Single Session
1492
+
1493
+ **DELETE** \`/auth/sessions/:id\`
1494
+
1495
+ Revokes (terminates) a specific session.
1496
+
1497
+ ### Request
1498
+
1499
+ \`\`\`typescript
1500
+ DELETE /auth/sessions/session-uuid-123
1501
+ // Auth cookies required
1502
+ \`\`\`
1503
+
1504
+ ### Success Response (200)
1505
+
1506
+ \`\`\`typescript
1507
+ {
1508
+ "success": true,
1509
+ "message": "Session revoked successfully"
1510
+ }
1511
+ \`\`\`
1512
+
1513
+ ### What Happens
1514
+
1515
+ \`\`\`mermaid
1516
+ sequenceDiagram
1517
+ participant C as Client
1518
+ participant S as Server
1519
+ participant R as Redis
1520
+ participant D as Database
1521
+
1522
+ C->>S: DELETE /auth/sessions/:id
1523
+ S->>S: Verify session belongs to user
1524
+ S->>R: Delete session from cache
1525
+ S->>D: Update session record
1526
+ Note over D: isActive = false<br/>revokedAt = now()<br/>revokedReason = 'user_revoked'
1527
+ S-->>C: 200 Success
1528
+
1529
+ Note over C,D: Next request from revoked session
1530
+ C->>S: Any request with old session
1531
+ S->>R: Session not found
1532
+ S-->>C: 401 Unauthorized
1533
+ \`\`\`
1534
+
1535
+ ### Error Responses
1536
+
1537
+ | Status | Message | Cause |
1538
+ |--------|---------|-------|
1539
+ | 401 | "Not authenticated" | No valid session |
1540
+ | 403 | "Cannot revoke another user's session" | Session ownership check failed |
1541
+ | 404 | "Session not found" | Invalid session ID |
1542
+
1543
+ ### Notes
1544
+
1545
+ - Users can only revoke their own sessions
1546
+ - Revoking current session is allowed (logs user out)
1547
+ - Revoked sessions are kept in database for audit purposes
1548
+ `,
1549
+ },
1550
+ {
1551
+ id: "sessions-revoke-all",
1552
+ title: "Revoke All Sessions",
1553
+ content: `
1554
+ ## Revoke All Sessions
1555
+
1556
+ **DELETE** \`/auth/sessions\`
1557
+
1558
+ Revokes all sessions for the current user.
1559
+
1560
+ ### Request
1561
+
1562
+ \`\`\`typescript
1563
+ DELETE /auth/sessions?includeCurrent=false
1564
+ // Auth cookies required
1565
+ \`\`\`
1566
+
1567
+ ### Query Parameters
1568
+
1569
+ | Param | Type | Default | Description |
1570
+ |-------|------|---------|-------------|
1571
+ | \`includeCurrent\` | boolean | \`false\` | If \`true\`, also revokes the current session (full logout). |
1572
+
1573
+ ### Success Response (200)
1574
+
1575
+ \`\`\`typescript
1576
+ {
1577
+ "success": true,
1578
+ "message": "All sessions revoked",
1579
+ "count": 4 // Number of sessions revoked
1580
+ }
1581
+ \`\`\`
1582
+
1583
+ ### Use Cases
1584
+
1585
+ **Security Breach Response**
1586
+ \`\`\`typescript
1587
+ // User suspects account compromise
1588
+ DELETE /auth/sessions?includeCurrent=true
1589
+ // All sessions revoked, user must re-authenticate
1590
+ \`\`\`
1591
+
1592
+ **Password Change Enforcement**
1593
+ \`\`\`typescript
1594
+ // After password change, revoke other sessions
1595
+ DELETE /auth/sessions?includeCurrent=false
1596
+ // Current session remains, others logged out
1597
+ \`\`\`
1598
+
1599
+ **Account Recovery**
1600
+ \`\`\`typescript
1601
+ // Clean slate after compromise
1602
+ DELETE /auth/sessions?includeCurrent=true
1603
+ // User re-authenticates fresh
1604
+ \`\`\`
1605
+
1606
+ ### Error Responses
1607
+
1608
+ | Status | Message | Cause |
1609
+ |--------|---------|-------|
1610
+ | 401 | "Not authenticated" | No valid session |
1611
+ `,
1612
+ },
1613
+ {
1614
+ id: "sessions-stats",
1615
+ title: "Session Statistics",
1616
+ content: `
1617
+ ## Session Statistics
1618
+
1619
+ **GET** \`/auth/sessions/stats\`
1620
+
1621
+ Returns session statistics and analytics for the current user.
1622
+
1623
+ ### Request
1624
+
1625
+ \`\`\`typescript
1626
+ GET /auth/sessions/stats
1627
+ // Auth cookies required
1628
+ \`\`\`
1629
+
1630
+ ### Success Response (200)
1631
+
1632
+ \`\`\`typescript
1633
+ {
1634
+ "success": true,
1635
+ "data": {
1636
+ "totalSessions": 12,
1637
+ "activeSessions": 3,
1638
+ "revokedSessions": 9,
1639
+ "uniqueDevices": 4,
1640
+ "uniqueIPs": 6,
1641
+ "lastLoginAt": "2024-01-15T10:30:00Z",
1642
+ "oldestActiveSession": "2024-01-01T08:00:00Z",
1643
+ "averageTrustScore": 82
1644
+ }
1645
+ }
1646
+ \`\`\`
1647
+
1648
+ ### Response Fields
1649
+
1650
+ | Field | Type | Description |
1651
+ |-------|------|-------------|
1652
+ | \`totalSessions\` | number | All-time session count |
1653
+ | \`activeSessions\` | number | Currently active sessions |
1654
+ | \`revokedSessions\` | number | Revoked/expired sessions |
1655
+ | \`uniqueDevices\` | number | Distinct device fingerprints |
1656
+ | \`uniqueIPs\` | number | Distinct IP addresses |
1657
+ | \`lastLoginAt\` | string | Most recent login timestamp |
1658
+ | \`oldestActiveSession\` | string | Oldest active session timestamp |
1659
+ | \`averageTrustScore\` | number | Average trust score across active sessions |
1660
+
1661
+ ### Use Cases
1662
+
1663
+ - **User security dashboard** - Show account activity summary
1664
+ - **Anomaly detection** - Unusual number of sessions/IPs
1665
+ - **Compliance reporting** - Access pattern analysis
1666
+ `,
1667
+ },
1668
+ ],
1669
+ },
1670
+ ];