@adonis-agora/authkit-server 0.34.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 (389) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +158 -0
  3. package/build/assets/grafana/authkit-dashboard.json +118 -0
  4. package/build/commands/clients_create.d.ts +27 -0
  5. package/build/commands/clients_create.js +121 -0
  6. package/build/commands/commands.json +292 -0
  7. package/build/commands/configure.d.ts +2 -0
  8. package/build/commands/configure.js +45 -0
  9. package/build/commands/doctor.d.ts +10 -0
  10. package/build/commands/doctor.js +113 -0
  11. package/build/commands/eject.d.ts +11 -0
  12. package/build/commands/eject.js +96 -0
  13. package/build/commands/expire_scan.d.ts +28 -0
  14. package/build/commands/expire_scan.js +92 -0
  15. package/build/commands/import_users.d.ts +17 -0
  16. package/build/commands/import_users.js +80 -0
  17. package/build/commands/keys_rotate.d.ts +21 -0
  18. package/build/commands/keys_rotate.js +126 -0
  19. package/build/commands/main.d.ts +12 -0
  20. package/build/commands/main.js +38 -0
  21. package/build/commands/settings_get.d.ts +18 -0
  22. package/build/commands/settings_get.js +43 -0
  23. package/build/commands/settings_list.d.ts +17 -0
  24. package/build/commands/settings_list.js +39 -0
  25. package/build/commands/settings_set.d.ts +20 -0
  26. package/build/commands/settings_set.js +55 -0
  27. package/build/commands/settings_unset.d.ts +18 -0
  28. package/build/commands/settings_unset.js +46 -0
  29. package/build/commands/ui_preset.d.ts +4 -0
  30. package/build/commands/ui_preset.js +32 -0
  31. package/build/database/migrations/make_authkit_oidc_table.d.ts +6 -0
  32. package/build/database/migrations/make_authkit_oidc_table.js +19 -0
  33. package/build/host/ui/admin.html +29 -0
  34. package/build/host/views/account/apps.edge +59 -0
  35. package/build/host/views/account/confirm.edge +70 -0
  36. package/build/host/views/account/email-confirmed.edge +16 -0
  37. package/build/host/views/account/login.edge +33 -0
  38. package/build/host/views/account/mfa.edge +152 -0
  39. package/build/host/views/account/orgs.edge +58 -0
  40. package/build/host/views/account/security.edge +215 -0
  41. package/build/host/views/account/tokens.edge +75 -0
  42. package/build/host/views/consent.edge +20 -0
  43. package/build/host/views/forgot.edge +43 -0
  44. package/build/host/views/login.edge +251 -0
  45. package/build/host/views/maintenance.edge +32 -0
  46. package/build/host/views/mfa-challenge.edge +107 -0
  47. package/build/host/views/otp-unlock.edge +40 -0
  48. package/build/host/views/partials/styles.edge +2 -0
  49. package/build/host/views/reset.edge +30 -0
  50. package/build/host/views/signup.edge +62 -0
  51. package/build/host/views/verify-email.edge +17 -0
  52. package/build/index.d.ts +115 -0
  53. package/build/index.js +76 -0
  54. package/build/password/common_passwords.txt +10000 -0
  55. package/build/providers/authkit_server_provider.d.ts +27 -0
  56. package/build/providers/authkit_server_provider.js +242 -0
  57. package/build/src/accounts/account_store.d.ts +578 -0
  58. package/build/src/accounts/account_store.js +60 -0
  59. package/build/src/accounts/lucid_account_store.d.ts +156 -0
  60. package/build/src/accounts/lucid_account_store.js +294 -0
  61. package/build/src/accounts/lucid_store/core.d.ts +9 -0
  62. package/build/src/accounts/lucid_store/core.js +306 -0
  63. package/build/src/accounts/lucid_store/mfa.d.ts +15 -0
  64. package/build/src/accounts/lucid_store/mfa.js +108 -0
  65. package/build/src/accounts/lucid_store/organizations.d.ts +13 -0
  66. package/build/src/accounts/lucid_store/organizations.js +294 -0
  67. package/build/src/accounts/lucid_store/password_hygiene.d.ts +20 -0
  68. package/build/src/accounts/lucid_store/password_hygiene.js +130 -0
  69. package/build/src/accounts/lucid_store/provider_identity.d.ts +8 -0
  70. package/build/src/accounts/lucid_store/provider_identity.js +59 -0
  71. package/build/src/accounts/lucid_store/shared.d.ts +113 -0
  72. package/build/src/accounts/lucid_store/shared.js +130 -0
  73. package/build/src/accounts/lucid_store/status_profile.d.ts +34 -0
  74. package/build/src/accounts/lucid_store/status_profile.js +100 -0
  75. package/build/src/accounts/lucid_store/webauthn.d.ts +8 -0
  76. package/build/src/accounts/lucid_store/webauthn.js +140 -0
  77. package/build/src/accounts/lucid_stores.d.ts +45 -0
  78. package/build/src/accounts/lucid_stores.js +30 -0
  79. package/build/src/adapters/adapter_contract.d.ts +37 -0
  80. package/build/src/adapters/adapter_contract.js +1 -0
  81. package/build/src/adapters/database_adapter.d.ts +21 -0
  82. package/build/src/adapters/database_adapter.js +79 -0
  83. package/build/src/adapters/factory.d.ts +30 -0
  84. package/build/src/adapters/factory.js +43 -0
  85. package/build/src/adapters/redis_adapter.d.ts +24 -0
  86. package/build/src/adapters/redis_adapter.js +122 -0
  87. package/build/src/audit/audit_sink.d.ts +63 -0
  88. package/build/src/audit/audit_sink.js +1 -0
  89. package/build/src/audit/lucid_audit_sink.d.ts +10 -0
  90. package/build/src/audit/lucid_audit_sink.js +99 -0
  91. package/build/src/commands/expire_scan_command.d.ts +60 -0
  92. package/build/src/commands/expire_scan_command.js +229 -0
  93. package/build/src/commands/import_clients.d.ts +40 -0
  94. package/build/src/commands/import_clients.js +79 -0
  95. package/build/src/commands/import_users.d.ts +51 -0
  96. package/build/src/commands/import_users.js +94 -0
  97. package/build/src/commands/resolve_config.d.ts +13 -0
  98. package/build/src/commands/resolve_config.js +18 -0
  99. package/build/src/commands/settings_commands.d.ts +47 -0
  100. package/build/src/commands/settings_commands.js +270 -0
  101. package/build/src/controllers/oidc_callback_controller.d.ts +22 -0
  102. package/build/src/controllers/oidc_callback_controller.js +33 -0
  103. package/build/src/define_config.d.ts +772 -0
  104. package/build/src/define_config.js +351 -0
  105. package/build/src/doctor/checks.d.ts +197 -0
  106. package/build/src/doctor/checks.js +858 -0
  107. package/build/src/events/dispatcher.d.ts +45 -0
  108. package/build/src/events/dispatcher.js +117 -0
  109. package/build/src/host/account_api/account_api_controller.d.ts +245 -0
  110. package/build/src/host/account_api/account_api_controller.js +827 -0
  111. package/build/src/host/account_deletion_ops.d.ts +80 -0
  112. package/build/src/host/account_deletion_ops.js +118 -0
  113. package/build/src/host/account_deletion_service.d.ts +63 -0
  114. package/build/src/host/account_deletion_service.js +133 -0
  115. package/build/src/host/account_export_service.d.ts +76 -0
  116. package/build/src/host/account_export_service.js +140 -0
  117. package/build/src/host/account_home.d.ts +11 -0
  118. package/build/src/host/account_home.js +11 -0
  119. package/build/src/host/account_lockout.d.ts +86 -0
  120. package/build/src/host/account_lockout.js +185 -0
  121. package/build/src/host/active_org_cookie.d.ts +28 -0
  122. package/build/src/host/active_org_cookie.js +47 -0
  123. package/build/src/host/admin_api/admin_api_guard.d.ts +16 -0
  124. package/build/src/host/admin_api/admin_api_guard.js +59 -0
  125. package/build/src/host/admin_api/admin_orgs_service.d.ts +125 -0
  126. package/build/src/host/admin_api/admin_orgs_service.js +324 -0
  127. package/build/src/host/admin_api/admin_users_service.d.ts +163 -0
  128. package/build/src/host/admin_api/admin_users_service.js +308 -0
  129. package/build/src/host/admin_api/api_clients_controller.d.ts +54 -0
  130. package/build/src/host/admin_api/api_clients_controller.js +89 -0
  131. package/build/src/host/admin_api/api_keys_controller.d.ts +19 -0
  132. package/build/src/host/admin_api/api_keys_controller.js +36 -0
  133. package/build/src/host/admin_api/api_misc_controller.d.ts +19 -0
  134. package/build/src/host/admin_api/api_misc_controller.js +44 -0
  135. package/build/src/host/admin_api/api_orgs_controller.d.ts +108 -0
  136. package/build/src/host/admin_api/api_orgs_controller.js +189 -0
  137. package/build/src/host/admin_api/api_settings_controller.d.ts +55 -0
  138. package/build/src/host/admin_api/api_settings_controller.js +134 -0
  139. package/build/src/host/admin_api/api_users_controller.d.ts +108 -0
  140. package/build/src/host/admin_api/api_users_controller.js +187 -0
  141. package/build/src/host/admin_api/dto.d.ts +131 -0
  142. package/build/src/host/admin_api/dto.js +122 -0
  143. package/build/src/host/admin_api/token_verify_service.d.ts +34 -0
  144. package/build/src/host/admin_api/token_verify_service.js +74 -0
  145. package/build/src/host/admin_clients_service.d.ts +88 -0
  146. package/build/src/host/admin_clients_service.js +181 -0
  147. package/build/src/host/admin_console/admin_shell_controller.d.ts +27 -0
  148. package/build/src/host/admin_console/admin_shell_controller.js +167 -0
  149. package/build/src/host/admin_console/console_audit_controller.d.ts +17 -0
  150. package/build/src/host/admin_console/console_audit_controller.js +25 -0
  151. package/build/src/host/admin_console/console_clients_controller.d.ts +53 -0
  152. package/build/src/host/admin_console/console_clients_controller.js +102 -0
  153. package/build/src/host/admin_console/console_impersonation_controller.d.ts +23 -0
  154. package/build/src/host/admin_console/console_impersonation_controller.js +45 -0
  155. package/build/src/host/admin_console/console_keys_controller.d.ts +24 -0
  156. package/build/src/host/admin_console/console_keys_controller.js +41 -0
  157. package/build/src/host/admin_console/console_orgs_controller.d.ts +96 -0
  158. package/build/src/host/admin_console/console_orgs_controller.js +238 -0
  159. package/build/src/host/admin_console/console_overview_controller.d.ts +27 -0
  160. package/build/src/host/admin_console/console_overview_controller.js +44 -0
  161. package/build/src/host/admin_console/console_roles_controller.d.ts +31 -0
  162. package/build/src/host/admin_console/console_roles_controller.js +108 -0
  163. package/build/src/host/admin_console/console_sessions_controller.d.ts +91 -0
  164. package/build/src/host/admin_console/console_sessions_controller.js +125 -0
  165. package/build/src/host/admin_console/console_settings_controller.d.ts +47 -0
  166. package/build/src/host/admin_console/console_settings_controller.js +115 -0
  167. package/build/src/host/admin_console/console_users_controller.d.ts +110 -0
  168. package/build/src/host/admin_console/console_users_controller.js +212 -0
  169. package/build/src/host/admin_prefix.d.ts +50 -0
  170. package/build/src/host/admin_prefix.js +77 -0
  171. package/build/src/host/admin_sessions_service.d.ts +119 -0
  172. package/build/src/host/admin_sessions_service.js +284 -0
  173. package/build/src/host/admin_stats_service.d.ts +44 -0
  174. package/build/src/host/admin_stats_service.js +130 -0
  175. package/build/src/host/admin_validators.d.ts +247 -0
  176. package/build/src/host/admin_validators.js +197 -0
  177. package/build/src/host/augmentations.d.ts +12 -0
  178. package/build/src/host/augmentations.js +1 -0
  179. package/build/src/host/auth_host_config.d.ts +22 -0
  180. package/build/src/host/auth_host_config.js +13 -0
  181. package/build/src/host/avatar_storage.d.ts +68 -0
  182. package/build/src/host/avatar_storage.js +166 -0
  183. package/build/src/host/bot_protection.d.ts +187 -0
  184. package/build/src/host/bot_protection.js +132 -0
  185. package/build/src/host/branding.d.ts +19 -0
  186. package/build/src/host/branding.js +8 -0
  187. package/build/src/host/config_locks.d.ts +38 -0
  188. package/build/src/host/config_locks.js +70 -0
  189. package/build/src/host/console_session.d.ts +27 -0
  190. package/build/src/host/console_session.js +36 -0
  191. package/build/src/host/controllers/account_apps_controller.d.ts +15 -0
  192. package/build/src/host/controllers/account_apps_controller.js +61 -0
  193. package/build/src/host/controllers/account_confirm_controller.d.ts +24 -0
  194. package/build/src/host/controllers/account_confirm_controller.js +144 -0
  195. package/build/src/host/controllers/account_mfa_controller.d.ts +28 -0
  196. package/build/src/host/controllers/account_mfa_controller.js +208 -0
  197. package/build/src/host/controllers/account_orgs_controller.d.ts +80 -0
  198. package/build/src/host/controllers/account_orgs_controller.js +401 -0
  199. package/build/src/host/controllers/account_security_controller.d.ts +43 -0
  200. package/build/src/host/controllers/account_security_controller.js +546 -0
  201. package/build/src/host/controllers/account_session_controller.d.ts +21 -0
  202. package/build/src/host/controllers/account_session_controller.js +113 -0
  203. package/build/src/host/controllers/account_tokens_controller.d.ts +7 -0
  204. package/build/src/host/controllers/account_tokens_controller.js +67 -0
  205. package/build/src/host/controllers/interaction_controller.d.ts +125 -0
  206. package/build/src/host/controllers/interaction_controller.js +981 -0
  207. package/build/src/host/controllers/pat_introspection_controller.d.ts +22 -0
  208. package/build/src/host/controllers/pat_introspection_controller.js +46 -0
  209. package/build/src/host/controllers/registration_controller.d.ts +18 -0
  210. package/build/src/host/controllers/registration_controller.js +382 -0
  211. package/build/src/host/controllers/social_controller.d.ts +8 -0
  212. package/build/src/host/controllers/social_controller.js +89 -0
  213. package/build/src/host/csrf.d.ts +29 -0
  214. package/build/src/host/csrf.js +14 -0
  215. package/build/src/host/default_mailer.d.ts +112 -0
  216. package/build/src/host/default_mailer.js +417 -0
  217. package/build/src/host/durable/account_deletion_workflow.d.ts +48 -0
  218. package/build/src/host/durable/account_deletion_workflow.js +86 -0
  219. package/build/src/host/durable/account_export_workflow.d.ts +68 -0
  220. package/build/src/host/durable/account_export_workflow.js +93 -0
  221. package/build/src/host/durable/index.d.ts +68 -0
  222. package/build/src/host/durable/index.js +77 -0
  223. package/build/src/host/email_templates.d.ts +39 -0
  224. package/build/src/host/email_templates.js +69 -0
  225. package/build/src/host/geo.d.ts +22 -0
  226. package/build/src/host/geo.js +39 -0
  227. package/build/src/host/i18n.d.ts +1416 -0
  228. package/build/src/host/i18n.js +1583 -0
  229. package/build/src/host/impersonation.d.ts +25 -0
  230. package/build/src/host/impersonation.js +31 -0
  231. package/build/src/host/key_rotation.d.ts +14 -0
  232. package/build/src/host/key_rotation.js +27 -0
  233. package/build/src/host/key_rotation_actions.d.ts +42 -0
  234. package/build/src/host/key_rotation_actions.js +27 -0
  235. package/build/src/host/login_attempt.d.ts +98 -0
  236. package/build/src/host/login_attempt.js +211 -0
  237. package/build/src/host/login_notify.d.ts +27 -0
  238. package/build/src/host/login_notify.js +142 -0
  239. package/build/src/host/middleware/account_auth.d.ts +7 -0
  240. package/build/src/host/middleware/account_auth.js +11 -0
  241. package/build/src/host/otp_lockout.d.ts +103 -0
  242. package/build/src/host/otp_lockout.js +221 -0
  243. package/build/src/host/rate_limit.d.ts +39 -0
  244. package/build/src/host/rate_limit.js +94 -0
  245. package/build/src/host/register_auth_host.d.ts +97 -0
  246. package/build/src/host/register_auth_host.js +466 -0
  247. package/build/src/host/renderers/edge_renderer.d.ts +12 -0
  248. package/build/src/host/renderers/edge_renderer.js +38 -0
  249. package/build/src/host/renderers/inertia_renderer.d.ts +70 -0
  250. package/build/src/host/renderers/inertia_renderer.js +54 -0
  251. package/build/src/host/runtime_settings.d.ts +181 -0
  252. package/build/src/host/runtime_settings.js +307 -0
  253. package/build/src/host/runtime_toggles.d.ts +807 -0
  254. package/build/src/host/runtime_toggles.js +784 -0
  255. package/build/src/host/security_notice_service.d.ts +36 -0
  256. package/build/src/host/security_notice_service.js +87 -0
  257. package/build/src/host/session_context.d.ts +23 -0
  258. package/build/src/host/session_context.js +89 -0
  259. package/build/src/host/sudo_mode.d.ts +56 -0
  260. package/build/src/host/sudo_mode.js +99 -0
  261. package/build/src/host/svg_chart.d.ts +15 -0
  262. package/build/src/host/svg_chart.js +45 -0
  263. package/build/src/host/trusted_device.d.ts +61 -0
  264. package/build/src/host/trusted_device.js +65 -0
  265. package/build/src/host/ui-dist/assets/index-CRWcmsex.js +137 -0
  266. package/build/src/host/ui-dist/assets/index-DTSmD4RU.css +1 -0
  267. package/build/src/host/ui-dist/index.html +17 -0
  268. package/build/src/host/user_agent.d.ts +18 -0
  269. package/build/src/host/user_agent.js +50 -0
  270. package/build/src/host/validators.d.ts +127 -0
  271. package/build/src/host/validators.js +53 -0
  272. package/build/src/keys/jwks_manager.d.ts +6 -0
  273. package/build/src/keys/jwks_manager.js +11 -0
  274. package/build/src/keys/keystore.d.ts +52 -0
  275. package/build/src/keys/keystore.js +68 -0
  276. package/build/src/keys/keystore_codec.d.ts +20 -0
  277. package/build/src/keys/keystore_codec.js +42 -0
  278. package/build/src/keys/keystore_crypto.d.ts +9 -0
  279. package/build/src/keys/keystore_crypto.js +27 -0
  280. package/build/src/keys/keystore_manager.d.ts +43 -0
  281. package/build/src/keys/keystore_manager.js +104 -0
  282. package/build/src/keys/keystore_vault.d.ts +113 -0
  283. package/build/src/keys/keystore_vault.js +265 -0
  284. package/build/src/mixins/json_column.d.ts +33 -0
  285. package/build/src/mixins/json_column.js +38 -0
  286. package/build/src/mixins/with_audit_log.d.ts +19 -0
  287. package/build/src/mixins/with_audit_log.js +39 -0
  288. package/build/src/mixins/with_auth_user.d.ts +24 -0
  289. package/build/src/mixins/with_auth_user.js +46 -0
  290. package/build/src/mixins/with_credentials.d.ts +20 -0
  291. package/build/src/mixins/with_credentials.js +29 -0
  292. package/build/src/mixins/with_mfa.d.ts +35 -0
  293. package/build/src/mixins/with_mfa.js +21 -0
  294. package/build/src/mixins/with_personal_access_token.d.ts +19 -0
  295. package/build/src/mixins/with_personal_access_token.js +42 -0
  296. package/build/src/mixins/with_provider_identity.d.ts +20 -0
  297. package/build/src/mixins/with_provider_identity.js +32 -0
  298. package/build/src/mixins/with_webauthn_credential.d.ts +37 -0
  299. package/build/src/mixins/with_webauthn_credential.js +46 -0
  300. package/build/src/observability/diagnostics_bridge.d.ts +6 -0
  301. package/build/src/observability/diagnostics_bridge.js +27 -0
  302. package/build/src/observability/metrics_controller.d.ts +5 -0
  303. package/build/src/observability/metrics_controller.js +24 -0
  304. package/build/src/observability/metrics_service.d.ts +2 -0
  305. package/build/src/observability/metrics_service.js +7 -0
  306. package/build/src/observability/otel_recorder.d.ts +10 -0
  307. package/build/src/observability/otel_recorder.js +59 -0
  308. package/build/src/observability/telescope/data_providers.d.ts +24 -0
  309. package/build/src/observability/telescope/data_providers.js +235 -0
  310. package/build/src/observability/telescope/extension.d.ts +29 -0
  311. package/build/src/observability/telescope/extension.js +167 -0
  312. package/build/src/observability/telescope/index.d.ts +8 -0
  313. package/build/src/observability/telescope/index.js +8 -0
  314. package/build/src/observability/wire_provider_events.d.ts +12 -0
  315. package/build/src/observability/wire_provider_events.js +30 -0
  316. package/build/src/password/common_passwords.d.ts +31 -0
  317. package/build/src/password/common_passwords.js +73 -0
  318. package/build/src/password/password_manager.d.ts +163 -0
  319. package/build/src/password/password_manager.js +191 -0
  320. package/build/src/password/policy.d.ts +71 -0
  321. package/build/src/password/policy.js +55 -0
  322. package/build/src/password/pwned.d.ts +36 -0
  323. package/build/src/password/pwned.js +52 -0
  324. package/build/src/pat/lucid_pat_store.d.ts +6 -0
  325. package/build/src/pat/lucid_pat_store.js +62 -0
  326. package/build/src/pat/pat_store.d.ts +31 -0
  327. package/build/src/pat/pat_store.js +1 -0
  328. package/build/src/pat/pat_tokens.d.ts +4 -0
  329. package/build/src/pat/pat_tokens.js +9 -0
  330. package/build/src/provider/build_provider.d.ts +45 -0
  331. package/build/src/provider/build_provider.js +219 -0
  332. package/build/src/provider/device_sources.d.ts +6 -0
  333. package/build/src/provider/device_sources.js +65 -0
  334. package/build/src/provider/interaction_actions.d.ts +36 -0
  335. package/build/src/provider/interaction_actions.js +55 -0
  336. package/build/src/provider/key_rotation_scheduler.d.ts +28 -0
  337. package/build/src/provider/key_rotation_scheduler.js +40 -0
  338. package/build/src/provider/keystore_reload.d.ts +21 -0
  339. package/build/src/provider/keystore_reload.js +39 -0
  340. package/build/src/provider/logout_sources.d.ts +13 -0
  341. package/build/src/provider/logout_sources.js +64 -0
  342. package/build/src/provider/oidc_service.d.ts +81 -0
  343. package/build/src/provider/oidc_service.js +254 -0
  344. package/build/src/provider/single_flight_lock.d.ts +18 -0
  345. package/build/src/provider/single_flight_lock.js +31 -0
  346. package/build/src/provider/token_exchange.d.ts +21 -0
  347. package/build/src/provider/token_exchange.js +124 -0
  348. package/build/src/register_routes.d.ts +16 -0
  349. package/build/src/register_routes.js +21 -0
  350. package/build/src/schema/ensure.d.ts +41 -0
  351. package/build/src/schema/ensure.js +262 -0
  352. package/build/stubs/config/authkit.stub +20 -0
  353. package/build/stubs/config/authkit_react.stub +52 -0
  354. package/build/stubs/main.d.ts +1 -0
  355. package/build/stubs/main.js +2 -0
  356. package/build/stubs/models/auth_user.stub +22 -0
  357. package/build/stubs/ui/edge/views/consent.edge +13 -0
  358. package/build/stubs/ui/edge/views/login.edge +19 -0
  359. package/build/stubs/ui/react/components/auth_shell.tsx +67 -0
  360. package/build/stubs/ui/react/pages/account/login.tsx +56 -0
  361. package/build/stubs/ui/react/pages/account/mfa.tsx +132 -0
  362. package/build/stubs/ui/react/pages/account/tokens.tsx +88 -0
  363. package/build/stubs/ui/react/pages/consent.tsx +39 -0
  364. package/build/stubs/ui/react/pages/forgot.tsx +44 -0
  365. package/build/stubs/ui/react/pages/login.tsx +171 -0
  366. package/build/stubs/ui/react/pages/mfa-challenge.tsx +72 -0
  367. package/build/stubs/ui/react/pages/reset.tsx +58 -0
  368. package/build/stubs/ui/react/pages/signup.tsx +78 -0
  369. package/build/stubs/ui/react/pages/verify-email.tsx +24 -0
  370. package/build/types.d.ts +7 -0
  371. package/build/types.js +1 -0
  372. package/package.json +147 -0
  373. package/stubs/config/authkit.stub +20 -0
  374. package/stubs/config/authkit_react.stub +52 -0
  375. package/stubs/main.ts +2 -0
  376. package/stubs/models/auth_user.stub +22 -0
  377. package/stubs/ui/edge/views/consent.edge +13 -0
  378. package/stubs/ui/edge/views/login.edge +19 -0
  379. package/stubs/ui/react/components/auth_shell.tsx +67 -0
  380. package/stubs/ui/react/pages/account/login.tsx +56 -0
  381. package/stubs/ui/react/pages/account/mfa.tsx +132 -0
  382. package/stubs/ui/react/pages/account/tokens.tsx +88 -0
  383. package/stubs/ui/react/pages/consent.tsx +39 -0
  384. package/stubs/ui/react/pages/forgot.tsx +44 -0
  385. package/stubs/ui/react/pages/login.tsx +171 -0
  386. package/stubs/ui/react/pages/mfa-challenge.tsx +72 -0
  387. package/stubs/ui/react/pages/reset.tsx +58 -0
  388. package/stubs/ui/react/pages/signup.tsx +78 -0
  389. package/stubs/ui/react/pages/verify-email.tsx +24 -0
@@ -0,0 +1,235 @@
1
+ /** The Telescope entry `type` the generic diagnostics watcher records under. */
2
+ const DIAGNOSTIC_TYPE = "diagnostic";
3
+ /** The tag the diagnostics watcher stamps for authkit-emitted events. */
4
+ const AUTHKIT_TAG = "lib:authkit";
5
+ /** Default rolling window for the entry-backed providers (24h). */
6
+ const DEFAULT_WINDOW_MS = 24 * 60 * 60 * 1000;
7
+ /** Fetch captured `agora:authkit:*` audit entries from Telescope (newest-first). */
8
+ async function fetchEntries(ctx, limit = 5_000) {
9
+ return ctx.store.list({
10
+ type: DIAGNOSTIC_TYPE,
11
+ tag: AUTHKIT_TAG,
12
+ limit,
13
+ });
14
+ }
15
+ /** The `AuditEventType` an entry carries (under `content.event`), or `''`. */
16
+ function eventOf(e) {
17
+ return e.content?.event ?? "";
18
+ }
19
+ /** Epoch millis the entry was recorded at, or `0` when absent/unparsable. */
20
+ function timeOf(e) {
21
+ return e.createdAt ? +new Date(e.createdAt) : 0;
22
+ }
23
+ /** Count entries whose `content.event` is one of `types`. */
24
+ function countByType(entries, types) {
25
+ const set = new Set(types);
26
+ let n = 0;
27
+ for (const e of entries)
28
+ if (set.has(eventOf(e)))
29
+ n += 1;
30
+ return n;
31
+ }
32
+ /** Split entries into the current `(now-window, now]` and previous window. */
33
+ function splitWindows(entries, windowMs, now) {
34
+ const start = now - windowMs;
35
+ const prevStart = start - windowMs;
36
+ return {
37
+ current: entries.filter((e) => timeOf(e) > start && timeOf(e) <= now),
38
+ previous: entries.filter((e) => timeOf(e) > prevStart && timeOf(e) <= start),
39
+ };
40
+ }
41
+ // The audit event groupings the dashboard rolls up.
42
+ const LOGIN_SUCCESS = ["login.success"];
43
+ const LOGIN_FAILURE = [
44
+ "login.failure",
45
+ "bot_protection.rejected",
46
+ ];
47
+ const MFA_ENROLLMENTS = [
48
+ "mfa.enabled",
49
+ "passkey.registered",
50
+ ];
51
+ const LOCKOUTS = ["account.locked", "otp.locked"];
52
+ const PAT_EVENTS = [
53
+ "pat.issued",
54
+ "pat.revoked",
55
+ "pat.used",
56
+ ];
57
+ const IMPERSONATION_EVENTS = [
58
+ "impersonation",
59
+ "impersonation.started",
60
+ ];
61
+ /**
62
+ * A stat (`{ value, delta?, spark? }`) over a window for a set of event types.
63
+ * `query.metric` chooses the grouping; `query.windowMs` the window (default 24h).
64
+ */
65
+ export function authkitEventCountProvider() {
66
+ return {
67
+ name: "authkit.eventCount",
68
+ async resolve(query, ctx) {
69
+ const entries = await fetchEntries(ctx);
70
+ const windowMs = Number(query?.windowMs ?? DEFAULT_WINDOW_MS);
71
+ const now = Date.now();
72
+ const types = typesForMetric(query?.metric);
73
+ const { current, previous } = splitWindows(entries, windowMs, now);
74
+ const value = countByType(current, types);
75
+ const delta = previous.length > 0 ? value - countByType(previous, types) : undefined;
76
+ const sparkBuckets = 8;
77
+ const bucketSize = windowMs / sparkBuckets;
78
+ const sparkStart = now - windowMs;
79
+ const spark = Array.from({ length: sparkBuckets }, (_, i) => {
80
+ const bStart = sparkStart + i * bucketSize;
81
+ const bEntries = current.filter((e) => {
82
+ const t = timeOf(e);
83
+ return t > bStart && t <= bStart + bucketSize;
84
+ });
85
+ return countByType(bEntries, types);
86
+ });
87
+ return delta === undefined ? { value, spark } : { value, delta, spark };
88
+ },
89
+ };
90
+ }
91
+ /** Map a panel `metric` to the set of `AuditEventType`s it aggregates. */
92
+ function typesForMetric(metric) {
93
+ switch (metric) {
94
+ case "loginFailure":
95
+ return LOGIN_FAILURE;
96
+ case "mfaEnrollments":
97
+ return MFA_ENROLLMENTS;
98
+ case "lockouts":
99
+ return LOCKOUTS;
100
+ case "pat":
101
+ return PAT_EVENTS;
102
+ case "impersonation":
103
+ return IMPERSONATION_EVENTS;
104
+ case "loginSuccess":
105
+ default:
106
+ return LOGIN_SUCCESS;
107
+ }
108
+ }
109
+ /**
110
+ * Login success rate as a gauge (`{ value, min, max }`), over `query.windowMs`
111
+ * (default 24h). `1` when there were no logins in the window.
112
+ */
113
+ export function authkitLoginSuccessRateProvider() {
114
+ return {
115
+ name: "authkit.loginSuccessRate",
116
+ async resolve(query, ctx) {
117
+ const entries = await fetchEntries(ctx);
118
+ const windowMs = Number(query?.windowMs ?? DEFAULT_WINDOW_MS);
119
+ const { current } = splitWindows(entries, windowMs, Date.now());
120
+ const ok = countByType(current, LOGIN_SUCCESS);
121
+ const bad = countByType(current, LOGIN_FAILURE);
122
+ const total = ok + bad;
123
+ return { value: total === 0 ? 1 : ok / total, min: 0, max: 1 };
124
+ },
125
+ };
126
+ }
127
+ /**
128
+ * Logins over time as `timeseries` rows (`{ rows: [{ label, success, failure }] }`),
129
+ * bucketed into `query.buckets ?? 24` equal time buckets across the captured span.
130
+ */
131
+ export function authkitLoginsOverTimeProvider() {
132
+ return {
133
+ name: "authkit.loginsOverTime",
134
+ async resolve(query, ctx) {
135
+ const entries = await fetchEntries(ctx);
136
+ const n = Math.max(1, Number(query?.buckets ?? 24));
137
+ const now = Date.now();
138
+ let minT = now;
139
+ for (const e of entries) {
140
+ const t = timeOf(e);
141
+ if (t > 0)
142
+ minT = Math.min(minT, t);
143
+ }
144
+ const span = Math.max(now - minT, 1);
145
+ const bucketSize = span / n;
146
+ const rows = Array.from({ length: n }, (_, i) => ({
147
+ label: new Date(minT + i * bucketSize).toISOString().slice(11, 16),
148
+ success: 0,
149
+ failure: 0,
150
+ }));
151
+ const successSet = new Set(LOGIN_SUCCESS);
152
+ const failureSet = new Set(LOGIN_FAILURE);
153
+ for (const e of entries) {
154
+ const event = eventOf(e);
155
+ const isSuccess = successSet.has(event);
156
+ const isFailure = failureSet.has(event);
157
+ if (!isSuccess && !isFailure)
158
+ continue;
159
+ const row = rows[Math.min(n - 1, Math.floor((timeOf(e) - minT) / bucketSize))];
160
+ if (row) {
161
+ if (isSuccess)
162
+ row.success += 1;
163
+ else
164
+ row.failure += 1;
165
+ }
166
+ }
167
+ return { rows };
168
+ },
169
+ };
170
+ }
171
+ /** Donut/bar `breakdown` segments — a count per top-level audit event family. */
172
+ const BREAKDOWN_GROUPS = [
173
+ { label: "Login OK", types: LOGIN_SUCCESS, color: "#34d399" },
174
+ { label: "Login fail", types: LOGIN_FAILURE, color: "#f87171" },
175
+ { label: "MFA", types: MFA_ENROLLMENTS, color: "#38bdf8" },
176
+ { label: "Lockouts", types: LOCKOUTS, color: "#fbbf24" },
177
+ { label: "PAT", types: PAT_EVENTS, color: "#a78bfa" },
178
+ { label: "Impersonation", types: IMPERSONATION_EVENTS, color: "#fb923c" },
179
+ ];
180
+ export function authkitEventBreakdownProvider() {
181
+ return {
182
+ name: "authkit.eventBreakdown",
183
+ async resolve(query, ctx) {
184
+ const entries = await fetchEntries(ctx);
185
+ const windowMs = Number(query?.windowMs ?? DEFAULT_WINDOW_MS);
186
+ const { current } = splitWindows(entries, windowMs, Date.now());
187
+ const segments = BREAKDOWN_GROUPS.map((g) => ({
188
+ label: g.label,
189
+ value: countByType(current, g.types),
190
+ color: g.color,
191
+ }));
192
+ return { segments };
193
+ },
194
+ };
195
+ }
196
+ /**
197
+ * Recent PAT + impersonation activity as `table` rows (newest-first), bounded by
198
+ * `query.limit` (default 50). Each row exposes the event, subject and actor.
199
+ */
200
+ export function authkitTokenActivityProvider() {
201
+ return {
202
+ name: "authkit.tokenActivity",
203
+ async resolve(query, ctx) {
204
+ const entries = await fetchEntries(ctx);
205
+ const limit = Math.min(200, Math.max(10, Number(query?.limit ?? 50)));
206
+ const watched = new Set([...PAT_EVENTS, ...IMPERSONATION_EVENTS]);
207
+ const rows = entries
208
+ .filter((e) => watched.has(eventOf(e)))
209
+ .slice(0, limit)
210
+ .map((e) => {
211
+ const p = e.content?.payload;
212
+ return {
213
+ at: e.createdAt
214
+ ? `${new Date(e.createdAt).toISOString().replace("T", " ").slice(0, 16)}Z`
215
+ : "",
216
+ event: eventOf(e),
217
+ subject: p?.accountId ?? "",
218
+ actor: p?.actorId ?? "",
219
+ ip: p?.ip ?? "",
220
+ };
221
+ });
222
+ return { rows };
223
+ },
224
+ };
225
+ }
226
+ /** Every authkit data provider, in registration order. */
227
+ export function authkitDataProviders() {
228
+ return [
229
+ authkitEventCountProvider(),
230
+ authkitLoginSuccessRateProvider(),
231
+ authkitLoginsOverTimeProvider(),
232
+ authkitEventBreakdownProvider(),
233
+ authkitTokenActivityProvider(),
234
+ ];
235
+ }
@@ -0,0 +1,29 @@
1
+ import type { TelescopeExtension } from "@adonis-agora/telescope";
2
+ /** Options for {@link defineAuthkitTelescopeExtension}. */
3
+ export interface AuthkitTelescopeOptions {
4
+ /**
5
+ * Rolling window (ms) the "Security" stat/gauge/breakdown panels aggregate
6
+ * over. Default 24h.
7
+ */
8
+ windowMs?: number;
9
+ }
10
+ /**
11
+ * The first-class `@adonis-agora/telescope` extension for `@adonis-agora/authkit-server`:
12
+ * a "Security" auth dashboard (login health, MFA, lockouts, PAT / impersonation)
13
+ * plus the data providers it binds to. Wire it into `config/telescope.ts`:
14
+ *
15
+ * ```ts
16
+ * import { defineConfig } from "@adonis-agora/telescope"
17
+ * import { defineAuthkitTelescopeExtension } from "@adonis-agora/authkit-server/telescope"
18
+ *
19
+ * export default defineConfig({ extensions: [defineAuthkitTelescopeExtension()] })
20
+ * ```
21
+ *
22
+ * No watcher is contributed — the authkit provider already bridges every audit
23
+ * event onto the diagnostics bus (`agora:authkit:<AuditEventType>`), and
24
+ * Telescope's generic diagnostics watcher records them as `diagnostic` entries
25
+ * tagged `lib:authkit`. The providers aggregate those captured entries; the
26
+ * baseline (events on the bus) works without this extension — registering it
27
+ * just adds the dedicated dashboard.
28
+ */
29
+ export declare function defineAuthkitTelescopeExtension(opts?: AuthkitTelescopeOptions): TelescopeExtension;
@@ -0,0 +1,167 @@
1
+ import { authkitDataProviders } from "./data_providers.js";
2
+ /**
3
+ * The navigable entry type the extension contributes: it scopes Telescope's
4
+ * entry-type nav to authkit's audit events (recorded as `diagnostic` entries
5
+ * tagged `lib:authkit`).
6
+ */
7
+ function authkitEntryType() {
8
+ return { id: "authkit", label: "Auth", dot: "bg-emerald-400" };
9
+ }
10
+ /**
11
+ * The authkit "Security" dashboard — a golden-signals layout for auth: login
12
+ * health up top, then what-needs-attention (lockouts, failed logins, PAT /
13
+ * impersonation activity), then trends. Pure data: panels bind to the
14
+ * `authkit.*` data providers by name.
15
+ */
16
+ function authkitSecurityDashboard(opts) {
17
+ const windowMs = opts.windowMs ?? 24 * 60 * 60 * 1000;
18
+ return {
19
+ id: "authkit.security",
20
+ label: "Security",
21
+ navGroup: "Auth",
22
+ panels: [],
23
+ sections: [
24
+ {
25
+ title: "Logins",
26
+ cols: 4,
27
+ panels: [
28
+ {
29
+ kind: "gauge",
30
+ title: "Login success rate",
31
+ data: { provider: "authkit.loginSuccessRate", query: { windowMs } },
32
+ max: 1,
33
+ format: "percent",
34
+ thresholds: { warn: 0.9, bad: 0.75, direction: "down-bad" },
35
+ },
36
+ {
37
+ kind: "stat",
38
+ title: "Successful logins",
39
+ data: {
40
+ provider: "authkit.eventCount",
41
+ query: { metric: "loginSuccess", windowMs },
42
+ },
43
+ spark: true,
44
+ },
45
+ {
46
+ kind: "stat",
47
+ title: "Failed logins",
48
+ data: {
49
+ provider: "authkit.eventCount",
50
+ query: { metric: "loginFailure", windowMs },
51
+ },
52
+ spark: true,
53
+ thresholds: { warn: 25, bad: 100, direction: "up-bad" },
54
+ },
55
+ {
56
+ kind: "stat",
57
+ title: "Account lockouts",
58
+ data: {
59
+ provider: "authkit.eventCount",
60
+ query: { metric: "lockouts", windowMs },
61
+ },
62
+ spark: true,
63
+ thresholds: { warn: 5, bad: 25, direction: "up-bad" },
64
+ },
65
+ ],
66
+ },
67
+ {
68
+ title: "MFA & tokens",
69
+ cols: 3,
70
+ panels: [
71
+ {
72
+ kind: "stat",
73
+ title: "MFA / passkey enrollments",
74
+ data: {
75
+ provider: "authkit.eventCount",
76
+ query: { metric: "mfaEnrollments", windowMs },
77
+ },
78
+ spark: true,
79
+ },
80
+ {
81
+ kind: "stat",
82
+ title: "Impersonation events",
83
+ data: {
84
+ provider: "authkit.eventCount",
85
+ query: { metric: "impersonation", windowMs },
86
+ },
87
+ spark: true,
88
+ thresholds: { warn: 1, bad: 10, direction: "up-bad" },
89
+ },
90
+ {
91
+ kind: "stat",
92
+ title: "PAT activity",
93
+ data: {
94
+ provider: "authkit.eventCount",
95
+ query: { metric: "pat", windowMs },
96
+ },
97
+ spark: true,
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ title: "Trends",
103
+ cols: 2,
104
+ panels: [
105
+ {
106
+ kind: "timeseries",
107
+ title: "Logins over time",
108
+ data: { provider: "authkit.loginsOverTime" },
109
+ series: ["success", "failure"],
110
+ style: "stacked",
111
+ },
112
+ {
113
+ kind: "breakdown",
114
+ title: "Events by family",
115
+ data: { provider: "authkit.eventBreakdown", query: { windowMs } },
116
+ style: "donut",
117
+ },
118
+ ],
119
+ },
120
+ {
121
+ title: "PAT & impersonation activity",
122
+ cols: 2,
123
+ panels: [
124
+ {
125
+ kind: "table",
126
+ title: "Recent token & impersonation events",
127
+ data: { provider: "authkit.tokenActivity" },
128
+ columns: [
129
+ { key: "at", label: "When" },
130
+ { key: "event", label: "Event" },
131
+ { key: "subject", label: "Subject" },
132
+ { key: "actor", label: "Actor" },
133
+ { key: "ip", label: "IP" },
134
+ ],
135
+ },
136
+ ],
137
+ },
138
+ ],
139
+ };
140
+ }
141
+ /**
142
+ * The first-class `@adonis-agora/telescope` extension for `@adonis-agora/authkit-server`:
143
+ * a "Security" auth dashboard (login health, MFA, lockouts, PAT / impersonation)
144
+ * plus the data providers it binds to. Wire it into `config/telescope.ts`:
145
+ *
146
+ * ```ts
147
+ * import { defineConfig } from "@adonis-agora/telescope"
148
+ * import { defineAuthkitTelescopeExtension } from "@adonis-agora/authkit-server/telescope"
149
+ *
150
+ * export default defineConfig({ extensions: [defineAuthkitTelescopeExtension()] })
151
+ * ```
152
+ *
153
+ * No watcher is contributed — the authkit provider already bridges every audit
154
+ * event onto the diagnostics bus (`agora:authkit:<AuditEventType>`), and
155
+ * Telescope's generic diagnostics watcher records them as `diagnostic` entries
156
+ * tagged `lib:authkit`. The providers aggregate those captured entries; the
157
+ * baseline (events on the bus) works without this extension — registering it
158
+ * just adds the dedicated dashboard.
159
+ */
160
+ export function defineAuthkitTelescopeExtension(opts = {}) {
161
+ return {
162
+ name: "authkit",
163
+ entryTypes: () => [authkitEntryType()],
164
+ dashboards: () => [authkitSecurityDashboard(opts)],
165
+ dataProviders: () => authkitDataProviders(),
166
+ };
167
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The optional `@adonis-agora/telescope` integration for authkit, isolated to this
3
+ * subpath (`@adonis-agora/authkit-server/telescope`) so the main barrel never
4
+ * pulls in telescope. Import it ONLY from `config/telescope.ts`, where both
5
+ * `@adonis-agora/telescope` and `@adonis-agora/authkit-server` are installed.
6
+ */
7
+ export { defineAuthkitTelescopeExtension, type AuthkitTelescopeOptions, } from "./extension.js";
8
+ export { authkitDataProviders, authkitEventCountProvider, authkitLoginSuccessRateProvider, authkitLoginsOverTimeProvider, authkitEventBreakdownProvider, authkitTokenActivityProvider, } from "./data_providers.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The optional `@adonis-agora/telescope` integration for authkit, isolated to this
3
+ * subpath (`@adonis-agora/authkit-server/telescope`) so the main barrel never
4
+ * pulls in telescope. Import it ONLY from `config/telescope.ts`, where both
5
+ * `@adonis-agora/telescope` and `@adonis-agora/authkit-server` are installed.
6
+ */
7
+ export { defineAuthkitTelescopeExtension, } from "./extension.js";
8
+ export { authkitDataProviders, authkitEventCountProvider, authkitLoginSuccessRateProvider, authkitLoginsOverTimeProvider, authkitEventBreakdownProvider, authkitTokenActivityProvider, } from "./data_providers.js";
@@ -0,0 +1,12 @@
1
+ import { type MetricsRecorder } from "@adonis-agora/authkit-core";
2
+ /**
3
+ * Liga eventos do oidc-provider aos counters do recorder. Usa só eventos reais
4
+ * do v9 (verificados em node_modules/oidc-provider/lib):
5
+ * - `grant.success` (actions/token.js) -> loginSuccess
6
+ * - `server_error` (shared/error_handler.js) -> loginFailure
7
+ * - `access_token.saved` (models/base_model.js: <kind>.saved) -> tokenIssued
8
+ * - `access_token.issued` (models/base_model.js: <kind>.issued) -> tokenIssued
9
+ * - `refresh_token.saved` (models/base_model.js: <kind>.saved) -> refreshRotated
10
+ * - `grant.revoked` (helpers/revoke.js) -> grantRevoked
11
+ */
12
+ export declare function wireProviderEvents(provider: any, recorder: MetricsRecorder): void;
@@ -0,0 +1,30 @@
1
+ import { AUTHKIT_METRICS, } from "@adonis-agora/authkit-core";
2
+ import { emitDiagnostic } from "./diagnostics_bridge.js";
3
+ /**
4
+ * Liga eventos do oidc-provider aos counters do recorder. Usa só eventos reais
5
+ * do v9 (verificados em node_modules/oidc-provider/lib):
6
+ * - `grant.success` (actions/token.js) -> loginSuccess
7
+ * - `server_error` (shared/error_handler.js) -> loginFailure
8
+ * - `access_token.saved` (models/base_model.js: <kind>.saved) -> tokenIssued
9
+ * - `access_token.issued` (models/base_model.js: <kind>.issued) -> tokenIssued
10
+ * - `refresh_token.saved` (models/base_model.js: <kind>.saved) -> refreshRotated
11
+ * - `grant.revoked` (helpers/revoke.js) -> grantRevoked
12
+ */
13
+ export function wireProviderEvents(provider, recorder) {
14
+ provider.on("grant.success", () => recorder.increment(AUTHKIT_METRICS.loginSuccess));
15
+ provider.on("server_error", () => recorder.increment(AUTHKIT_METRICS.loginFailure));
16
+ provider.on("access_token.saved", () => {
17
+ recorder.increment(AUTHKIT_METRICS.tokenIssued);
18
+ // Emit estrutural irmão (best-effort, no-op sem o slot de diagnostics).
19
+ emitDiagnostic("token.issued", { kind: "access_token" });
20
+ });
21
+ provider.on("access_token.issued", () => {
22
+ recorder.increment(AUTHKIT_METRICS.tokenIssued);
23
+ emitDiagnostic("token.issued", { kind: "access_token" });
24
+ });
25
+ provider.on("refresh_token.saved", () => {
26
+ recorder.increment(AUTHKIT_METRICS.refreshRotated);
27
+ emitDiagnostic("token.refreshed", { kind: "refresh_token" });
28
+ });
29
+ provider.on("grant.revoked", () => recorder.increment(AUTHKIT_METRICS.grantRevoked));
30
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Verificação offline de senhas comuns (common-password block).
3
+ *
4
+ * Carrega um arquivo embutido com as ~10 000 senhas mais comuns (derivado de
5
+ * datasets públicos: rockyou, SecLists Common-Credentials, NIST SP 800-63B).
6
+ * A checagem é case-insensitive e roda ANTES do HIBP em `assertAcceptable`.
7
+ *
8
+ * Armazenamento: Set<string> em memória, carregado UMA vez via lazy init.
9
+ * Custo: ~50–80 KB de strings; carregamento é síncrono após a primeira chamada.
10
+ *
11
+ * Fonte dos dados: compilação de senhas comuns de domínio público.
12
+ * Licença do arquivo de dados: CC0 / Public Domain.
13
+ */
14
+ /**
15
+ * Verifica se a senha fornecida consta na lista offline de senhas comuns.
16
+ *
17
+ * A checagem é case-insensitive: "Password123" é tratado como "password123"
18
+ * para fins de comparação. O carregamento da lista ocorre na primeira chamada.
19
+ *
20
+ * @returns `true` se a senha for considerada comum (deve ser rejeitada).
21
+ */
22
+ export declare function isCommonPassword(plain: string): boolean;
23
+ /**
24
+ * Número de entradas na lista de senhas comuns. Útil para testes e diagnóstico.
25
+ */
26
+ export declare function commonPasswordsCount(): number;
27
+ /**
28
+ * Permite substituir o Set de senhas comuns (usado em testes).
29
+ * @internal
30
+ */
31
+ export declare function __setCommonPasswordsForTests(passwords: Set<string> | null): void;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Verificação offline de senhas comuns (common-password block).
3
+ *
4
+ * Carrega um arquivo embutido com as ~10 000 senhas mais comuns (derivado de
5
+ * datasets públicos: rockyou, SecLists Common-Credentials, NIST SP 800-63B).
6
+ * A checagem é case-insensitive e roda ANTES do HIBP em `assertAcceptable`.
7
+ *
8
+ * Armazenamento: Set<string> em memória, carregado UMA vez via lazy init.
9
+ * Custo: ~50–80 KB de strings; carregamento é síncrono após a primeira chamada.
10
+ *
11
+ * Fonte dos dados: compilação de senhas comuns de domínio público.
12
+ * Licença do arquivo de dados: CC0 / Public Domain.
13
+ */
14
+ import { readFileSync } from 'node:fs';
15
+ import { fileURLToPath } from 'node:url';
16
+ import { join, dirname } from 'node:path';
17
+ /**
18
+ * Set em memória das senhas comuns (minúsculas). Inicializado na primeira
19
+ * chamada a `isCommonPassword`. O módulo garante que o carregamento ocorre
20
+ * apenas uma vez (lazy singleton).
21
+ */
22
+ let _commonPasswordsSet = null;
23
+ /**
24
+ * Carrega o arquivo de senhas comuns uma única vez (lazy).
25
+ *
26
+ * FAIL-SAFE: se o arquivo não existir ou não puder ser lido (ex.: bundle sem
27
+ * assets), retorna um Set vazio — a checagem vira no-op sem quebrar o fluxo.
28
+ */
29
+ function loadCommonPasswords() {
30
+ if (_commonPasswordsSet !== null)
31
+ return _commonPasswordsSet;
32
+ try {
33
+ const __filename = fileURLToPath(import.meta.url);
34
+ const __dir = dirname(__filename);
35
+ const filePath = join(__dir, 'common_passwords.txt');
36
+ const content = readFileSync(filePath, 'utf-8');
37
+ const entries = content
38
+ .split('\n')
39
+ .map((l) => l.trim().toLowerCase())
40
+ .filter((l) => l.length > 0 && !l.startsWith('#'));
41
+ _commonPasswordsSet = new Set(entries);
42
+ }
43
+ catch {
44
+ // Fail-safe: arquivo ausente → Set vazio (no-op check).
45
+ _commonPasswordsSet = new Set();
46
+ }
47
+ return _commonPasswordsSet;
48
+ }
49
+ /**
50
+ * Verifica se a senha fornecida consta na lista offline de senhas comuns.
51
+ *
52
+ * A checagem é case-insensitive: "Password123" é tratado como "password123"
53
+ * para fins de comparação. O carregamento da lista ocorre na primeira chamada.
54
+ *
55
+ * @returns `true` se a senha for considerada comum (deve ser rejeitada).
56
+ */
57
+ export function isCommonPassword(plain) {
58
+ const set = loadCommonPasswords();
59
+ return set.has(plain.toLowerCase());
60
+ }
61
+ /**
62
+ * Número de entradas na lista de senhas comuns. Útil para testes e diagnóstico.
63
+ */
64
+ export function commonPasswordsCount() {
65
+ return loadCommonPasswords().size;
66
+ }
67
+ /**
68
+ * Permite substituir o Set de senhas comuns (usado em testes).
69
+ * @internal
70
+ */
71
+ export function __setCommonPasswordsForTests(passwords) {
72
+ _commonPasswordsSet = passwords;
73
+ }