hazo_auth 1.3.0 → 1.4.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.
- package/README.md +383 -774
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +23 -0
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -0
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +44 -0
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts +31 -0
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -0
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +222 -0
- package/dist/components/layouts/email_verification/index.d.ts +23 -0
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -0
- package/dist/components/layouts/email_verification/index.js +61 -0
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +10 -0
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -0
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +33 -0
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts +22 -0
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -0
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +127 -0
- package/dist/components/layouts/forgot_password/index.d.ts +18 -0
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -0
- package/dist/components/layouts/forgot_password/index.js +43 -0
- package/dist/components/layouts/index.d.ts +16 -0
- package/dist/components/layouts/index.d.ts.map +1 -0
- package/dist/components/layouts/index.js +11 -0
- package/dist/components/layouts/login/config/login_field_config.d.ts +11 -0
- package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -0
- package/dist/components/layouts/login/config/login_field_config.js +42 -0
- package/dist/components/layouts/login/hooks/use_login_form.d.ts +34 -0
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -0
- package/dist/components/layouts/login/hooks/use_login_form.js +196 -0
- package/dist/components/layouts/login/index.d.ts +31 -0
- package/dist/components/layouts/login/index.d.ts.map +1 -0
- package/dist/components/layouts/login/index.js +58 -0
- package/dist/components/layouts/my_settings/components/editable_field.d.ts +19 -0
- package/dist/components/layouts/my_settings/components/editable_field.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/editable_field.js +73 -0
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts +28 -0
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/password_change_dialog.js +138 -0
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts +42 -0
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +198 -0
- package/dist/components/layouts/my_settings/components/profile_picture_display.d.ts +16 -0
- package/dist/components/layouts/my_settings/components/profile_picture_display.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_display.js +33 -0
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts +17 -0
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +48 -0
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.d.ts +21 -0
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +144 -0
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts +23 -0
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +169 -0
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +19 -0
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +26 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +46 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +354 -0
- package/dist/components/layouts/my_settings/index.d.ts +64 -0
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/index.js +65 -0
- package/dist/components/layouts/register/config/register_field_config.d.ts +14 -0
- package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -0
- package/dist/components/layouts/register/config/register_field_config.js +69 -0
- package/dist/components/layouts/register/hooks/use_register_form.d.ts +30 -0
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -0
- package/dist/components/layouts/register/hooks/use_register_form.js +184 -0
- package/dist/components/layouts/register/index.d.ts +23 -0
- package/dist/components/layouts/register/index.d.ts.map +1 -0
- package/dist/components/layouts/register/index.js +58 -0
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +13 -0
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -0
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +53 -0
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts +28 -0
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -0
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +201 -0
- package/dist/components/layouts/reset_password/index.d.ts +23 -0
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -0
- package/dist/components/layouts/reset_password/index.js +53 -0
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts +20 -0
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +32 -0
- package/dist/components/layouts/shared/components/auth_page_shell.d.ts +7 -0
- package/dist/components/layouts/shared/components/auth_page_shell.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/auth_page_shell.js +12 -0
- package/dist/components/layouts/shared/components/field_error_message.d.ts +7 -0
- package/dist/components/layouts/shared/components/field_error_message.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/field_error_message.js +6 -0
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts +14 -0
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/form_action_buttons.js +15 -0
- package/dist/components/layouts/shared/components/form_field_wrapper.d.ts +11 -0
- package/dist/components/layouts/shared/components/form_field_wrapper.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/form_field_wrapper.js +9 -0
- package/dist/components/layouts/shared/components/form_header.d.ts +10 -0
- package/dist/components/layouts/shared/components/form_header.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/form_header.js +5 -0
- package/dist/components/layouts/shared/components/logout_button.d.ts +7 -0
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/logout_button.js +44 -0
- package/dist/components/layouts/shared/components/password_field.d.ts +13 -0
- package/dist/components/layouts/shared/components/password_field.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/password_field.js +13 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts +22 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.js +169 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts +12 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +16 -0
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts +6 -0
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +15 -0
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts +11 -0
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +10 -0
- package/dist/components/layouts/shared/components/two_column_auth_layout.d.ts +12 -0
- package/dist/components/layouts/shared/components/two_column_auth_layout.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/two_column_auth_layout.js +8 -0
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts +14 -0
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/unauthorized_guard.js +30 -0
- package/dist/components/layouts/shared/components/visual_panel.d.ts +9 -0
- package/dist/components/layouts/shared/components/visual_panel.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/visual_panel.js +10 -0
- package/dist/components/layouts/shared/config/layout_customization.d.ts +38 -0
- package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -0
- package/dist/components/layouts/shared/config/layout_customization.js +19 -0
- package/dist/components/layouts/shared/data/layout_data_client.d.ts +6 -0
- package/dist/components/layouts/shared/data/layout_data_client.d.ts.map +1 -0
- package/dist/components/layouts/shared/data/layout_data_client.js +9 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +20 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.js +71 -0
- package/dist/components/layouts/shared/hooks/use_hazo_auth.d.ts +48 -0
- package/dist/components/layouts/shared/hooks/use_hazo_auth.d.ts.map +1 -0
- package/dist/components/layouts/shared/hooks/use_hazo_auth.js +90 -0
- package/dist/components/layouts/shared/index.d.ts +24 -0
- package/dist/components/layouts/shared/index.d.ts.map +1 -0
- package/dist/components/layouts/shared/index.js +27 -0
- package/dist/components/layouts/shared/utils/ip_address.d.ts +7 -0
- package/dist/components/layouts/shared/utils/ip_address.d.ts.map +1 -0
- package/dist/components/layouts/shared/utils/ip_address.js +34 -0
- package/dist/components/layouts/shared/utils/validation.d.ts +15 -0
- package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -0
- package/dist/components/layouts/shared/utils/validation.js +45 -0
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts +29 -0
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -0
- package/dist/components/layouts/user_management/components/roles_matrix.js +287 -0
- package/dist/components/layouts/user_management/index.d.ts +13 -0
- package/dist/components/layouts/user_management/index.d.ts.map +1 -0
- package/dist/components/layouts/user_management/index.js +495 -0
- package/dist/components/ui/alert-dialog.d.ts +21 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +62 -0
- package/dist/components/ui/avatar.d.ts +7 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +32 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +45 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +23 -0
- package/dist/components/ui/dialog.d.ts +20 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +52 -0
- package/dist/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +72 -0
- package/dist/components/ui/hazo_ui_tooltip.d.ts +26 -0
- package/dist/components/ui/hazo_ui_tooltip.d.ts.map +1 -0
- package/dist/components/ui/hazo_ui_tooltip.js +17 -0
- package/dist/components/ui/index.d.ts +20 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +21 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +20 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +24 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +22 -0
- package/dist/components/ui/sheet.d.ts +23 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +66 -0
- package/dist/components/ui/sidebar.d.ts +66 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +267 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +18 -0
- package/dist/components/ui/sonner.d.ts +5 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +28 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +22 -0
- package/dist/components/ui/table.d.ts +11 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +55 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +33 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +25 -0
- package/dist/components/ui/vertical-tabs.d.ts +8 -0
- package/dist/components/ui/vertical-tabs.d.ts.map +1 -0
- package/dist/components/ui/vertical-tabs.js +37 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/lib/already_logged_in_config.server.d.ts +14 -0
- package/dist/lib/already_logged_in_config.server.d.ts.map +1 -0
- package/dist/lib/already_logged_in_config.server.js +29 -0
- package/dist/lib/app_logger.d.ts +12 -0
- package/dist/lib/app_logger.d.ts.map +1 -0
- package/dist/lib/app_logger.js +14 -0
- package/dist/lib/auth/auth_cache.d.ts +83 -0
- package/dist/lib/auth/auth_cache.d.ts.map +1 -0
- package/dist/lib/auth/auth_cache.js +158 -0
- package/dist/lib/auth/auth_rate_limiter.d.ts +39 -0
- package/dist/lib/auth/auth_rate_limiter.d.ts.map +1 -0
- package/dist/lib/auth/auth_rate_limiter.js +95 -0
- package/dist/lib/auth/auth_types.d.ts +53 -0
- package/dist/lib/auth/auth_types.d.ts.map +1 -0
- package/dist/lib/auth/auth_types.js +16 -0
- package/dist/lib/auth/auth_utils.server.d.ts +47 -0
- package/dist/lib/auth/auth_utils.server.d.ts.map +1 -0
- package/dist/lib/auth/auth_utils.server.js +150 -0
- package/dist/lib/auth/hazo_get_auth.server.d.ts +12 -0
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -0
- package/dist/lib/auth/hazo_get_auth.server.js +256 -0
- package/dist/lib/auth/index.d.ts +9 -0
- package/dist/lib/auth/index.d.ts.map +1 -0
- package/dist/lib/auth/index.js +12 -0
- package/dist/lib/auth/server_auth.d.ts +26 -0
- package/dist/lib/auth/server_auth.d.ts.map +1 -0
- package/dist/lib/auth/server_auth.js +62 -0
- package/dist/lib/auth_utility_config.server.d.ts +20 -0
- package/dist/lib/auth_utility_config.server.d.ts.map +1 -0
- package/dist/lib/auth_utility_config.server.js +64 -0
- package/dist/lib/config/config_loader.server.d.ts +44 -0
- package/dist/lib/config/config_loader.server.d.ts.map +1 -0
- package/dist/lib/config/config_loader.server.js +122 -0
- package/dist/lib/email_verification_config.server.d.ts +14 -0
- package/dist/lib/email_verification_config.server.d.ts.map +1 -0
- package/dist/lib/email_verification_config.server.js +20 -0
- package/dist/lib/file_types_config.server.d.ts +11 -0
- package/dist/lib/file_types_config.server.d.ts.map +1 -0
- package/dist/lib/file_types_config.server.js +16 -0
- package/dist/lib/forgot_password_config.server.d.ts +14 -0
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -0
- package/dist/lib/forgot_password_config.server.js +20 -0
- package/dist/lib/hazo_connect_instance.server.d.ts +17 -0
- package/dist/lib/hazo_connect_instance.server.d.ts.map +1 -0
- package/dist/lib/hazo_connect_instance.server.js +88 -0
- package/dist/lib/hazo_connect_setup.d.ts +2 -0
- package/dist/lib/hazo_connect_setup.d.ts.map +1 -0
- package/dist/lib/hazo_connect_setup.js +49 -0
- package/dist/lib/hazo_connect_setup.server.d.ts +20 -0
- package/dist/lib/hazo_connect_setup.server.d.ts.map +1 -0
- package/dist/lib/hazo_connect_setup.server.js +138 -0
- package/dist/lib/index.d.ts +28 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +35 -0
- package/dist/lib/login_config.server.d.ts +20 -0
- package/dist/lib/login_config.server.d.ts.map +1 -0
- package/dist/lib/login_config.server.js +37 -0
- package/dist/lib/messages_config.server.d.ts +13 -0
- package/dist/lib/messages_config.server.d.ts.map +1 -0
- package/dist/lib/messages_config.server.js +18 -0
- package/dist/lib/migrations/apply_migration.d.ts +22 -0
- package/dist/lib/migrations/apply_migration.d.ts.map +1 -0
- package/dist/lib/migrations/apply_migration.js +78 -0
- package/dist/lib/my_settings_config.server.d.ts +65 -0
- package/dist/lib/my_settings_config.server.d.ts.map +1 -0
- package/dist/lib/my_settings_config.server.js +67 -0
- package/dist/lib/password_requirements_config.server.d.ts +15 -0
- package/dist/lib/password_requirements_config.server.d.ts.map +1 -0
- package/dist/lib/password_requirements_config.server.js +26 -0
- package/dist/lib/profile_pic_menu_config.server.d.ts +26 -0
- package/dist/lib/profile_pic_menu_config.server.d.ts.map +1 -0
- package/dist/lib/profile_pic_menu_config.server.js +95 -0
- package/dist/lib/profile_picture_config.server.d.ts +16 -0
- package/dist/lib/profile_picture_config.server.d.ts.map +1 -0
- package/dist/lib/profile_picture_config.server.js +40 -0
- package/dist/lib/register_config.server.d.ts +24 -0
- package/dist/lib/register_config.server.d.ts.map +1 -0
- package/dist/lib/register_config.server.js +39 -0
- package/dist/lib/reset_password_config.server.d.ts +25 -0
- package/dist/lib/reset_password_config.server.d.ts.map +1 -0
- package/dist/lib/reset_password_config.server.js +38 -0
- package/dist/lib/services/email_service.d.ts +44 -0
- package/dist/lib/services/email_service.d.ts.map +1 -0
- package/dist/lib/services/email_service.js +480 -0
- package/dist/lib/services/email_verification_service.d.ts +35 -0
- package/dist/lib/services/email_verification_service.d.ts.map +1 -0
- package/dist/lib/services/email_verification_service.js +208 -0
- package/dist/lib/services/index.d.ts +13 -0
- package/dist/lib/services/index.d.ts.map +1 -0
- package/dist/lib/services/index.js +14 -0
- package/dist/lib/services/login_service.d.ts +20 -0
- package/dist/lib/services/login_service.d.ts.map +1 -0
- package/dist/lib/services/login_service.js +94 -0
- package/dist/lib/services/password_change_service.d.ts +19 -0
- package/dist/lib/services/password_change_service.d.ts.map +1 -0
- package/dist/lib/services/password_change_service.js +118 -0
- package/dist/lib/services/password_reset_service.d.ts +52 -0
- package/dist/lib/services/password_reset_service.d.ts.map +1 -0
- package/dist/lib/services/password_reset_service.js +318 -0
- package/dist/lib/services/profile_picture_remove_service.d.ts +15 -0
- package/dist/lib/services/profile_picture_remove_service.d.ts.map +1 -0
- package/dist/lib/services/profile_picture_remove_service.js +94 -0
- package/dist/lib/services/profile_picture_service.d.ts +45 -0
- package/dist/lib/services/profile_picture_service.d.ts.map +1 -0
- package/dist/lib/services/profile_picture_service.js +183 -0
- package/dist/lib/services/profile_picture_source_mapper.d.ts +23 -0
- package/dist/lib/services/profile_picture_source_mapper.d.ts.map +1 -0
- package/dist/lib/services/profile_picture_source_mapper.js +45 -0
- package/dist/lib/services/registration_service.d.ts +20 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -0
- package/dist/lib/services/registration_service.js +147 -0
- package/dist/lib/services/token_service.d.ts +20 -0
- package/dist/lib/services/token_service.d.ts.map +1 -0
- package/dist/lib/services/token_service.js +201 -0
- package/dist/lib/services/user_profiles_service.d.ts +31 -0
- package/dist/lib/services/user_profiles_service.d.ts.map +1 -0
- package/dist/lib/services/user_profiles_service.js +99 -0
- package/dist/lib/services/user_update_service.d.ts +23 -0
- package/dist/lib/services/user_update_service.d.ts.map +1 -0
- package/dist/lib/services/user_update_service.js +103 -0
- package/dist/lib/ui_shell_config.server.d.ts +16 -0
- package/dist/lib/ui_shell_config.server.d.ts.map +1 -0
- package/dist/lib/ui_shell_config.server.js +28 -0
- package/dist/lib/ui_sizes_config.server.d.ts +17 -0
- package/dist/lib/ui_sizes_config.server.d.ts.map +1 -0
- package/dist/lib/ui_sizes_config.server.js +22 -0
- package/dist/lib/user_fields_config.server.d.ts +13 -0
- package/dist/lib/user_fields_config.server.d.ts.map +1 -0
- package/dist/lib/user_fields_config.server.js +21 -0
- package/dist/lib/user_management_config.server.d.ts +10 -0
- package/dist/lib/user_management_config.server.d.ts.map +1 -0
- package/dist/lib/user_management_config.server.js +26 -0
- package/dist/lib/utils/api_route_helpers.d.ts +13 -0
- package/dist/lib/utils/api_route_helpers.d.ts.map +1 -0
- package/dist/lib/utils/api_route_helpers.js +58 -0
- package/dist/lib/utils/error_sanitizer.d.ts +16 -0
- package/dist/lib/utils/error_sanitizer.d.ts.map +1 -0
- package/dist/lib/utils/error_sanitizer.js +39 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +9 -0
- package/dist/server/config/config_loader.d.ts +26 -0
- package/dist/server/config/config_loader.d.ts.map +1 -0
- package/dist/server/config/config_loader.js +329 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +32 -0
- package/dist/server/logging/logger_service.d.ts +3 -0
- package/dist/server/logging/logger_service.d.ts.map +1 -0
- package/dist/server/logging/logger_service.js +37 -0
- package/dist/server/routes/root_router.d.ts +3 -0
- package/dist/server/routes/root_router.d.ts.map +1 -0
- package/dist/server/routes/root_router.js +14 -0
- package/dist/server/server.d.ts +3 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +25 -0
- package/dist/server/types/app_types.d.ts +53 -0
- package/dist/server/types/app_types.d.ts.map +1 -0
- package/dist/server/types/app_types.js +1 -0
- package/migrations/003_add_url_on_logon_to_hazo_users.sql +8 -0
- package/next.config.mjs +12 -0
- package/package.json +38 -1
- package/src/components/index.ts +7 -0
- package/src/components/layouts/email_verification/config/email_verification_field_config.ts +2 -2
- package/src/components/layouts/email_verification/hooks/use_email_verification.ts +3 -3
- package/src/components/layouts/email_verification/index.tsx +11 -11
- package/src/components/layouts/forgot_password/config/forgot_password_field_config.ts +2 -2
- package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +3 -3
- package/src/components/layouts/forgot_password/index.tsx +10 -10
- package/src/components/layouts/index.ts +26 -0
- package/src/components/layouts/login/config/login_field_config.ts +2 -2
- package/src/components/layouts/login/hooks/use_login_form.ts +5 -5
- package/src/components/layouts/login/index.tsx +11 -11
- package/src/components/layouts/my_settings/components/editable_field.tsx +3 -3
- package/src/components/layouts/my_settings/components/password_change_dialog.tsx +5 -5
- package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +7 -7
- package/src/components/layouts/my_settings/components/profile_picture_display.tsx +2 -2
- package/src/components/layouts/my_settings/components/profile_picture_gravatar_tab.tsx +3 -3
- package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +5 -5
- package/src/components/layouts/my_settings/components/profile_picture_upload_tab.tsx +4 -4
- package/src/components/layouts/my_settings/config/my_settings_field_config.ts +2 -2
- package/src/components/layouts/my_settings/hooks/use_my_settings.ts +2 -2
- package/src/components/layouts/my_settings/index.tsx +10 -10
- package/src/components/layouts/register/config/register_field_config.ts +2 -2
- package/src/components/layouts/register/hooks/use_register_form.ts +4 -4
- package/src/components/layouts/register/index.tsx +11 -11
- package/src/components/layouts/reset_password/config/reset_password_field_config.ts +2 -2
- package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +4 -4
- package/src/components/layouts/reset_password/index.tsx +10 -10
- package/src/components/layouts/shared/components/already_logged_in_guard.tsx +4 -4
- package/src/components/layouts/shared/components/auth_page_shell.tsx +3 -3
- package/src/components/layouts/shared/components/form_action_buttons.tsx +2 -2
- package/src/components/layouts/shared/components/form_field_wrapper.tsx +2 -2
- package/src/components/layouts/shared/components/logout_button.tsx +2 -2
- package/src/components/layouts/shared/components/password_field.tsx +3 -3
- package/src/components/layouts/shared/components/profile_pic_menu.tsx +5 -5
- package/src/components/layouts/shared/components/profile_pic_menu_wrapper.tsx +2 -2
- package/src/components/layouts/shared/components/sidebar_layout_wrapper.tsx +3 -3
- package/src/components/layouts/shared/components/standalone_layout_wrapper.tsx +1 -1
- package/src/components/layouts/shared/components/two_column_auth_layout.tsx +1 -1
- package/src/components/layouts/shared/components/unauthorized_guard.tsx +2 -2
- package/src/components/layouts/shared/hooks/use_hazo_auth.ts +1 -1
- package/src/components/layouts/shared/index.ts +34 -0
- package/src/components/layouts/shared/utils/validation.ts +1 -1
- package/src/components/layouts/user_management/components/roles_matrix.tsx +7 -7
- package/src/components/layouts/user_management/index.tsx +11 -11
- package/src/components/ui/alert-dialog.tsx +2 -2
- package/src/components/ui/avatar.tsx +1 -1
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/dropdown-menu.tsx +1 -1
- package/src/components/ui/hazo_ui_tooltip.tsx +1 -1
- package/src/components/ui/index.ts +22 -0
- package/src/components/ui/input.tsx +1 -1
- package/src/components/ui/label.tsx +1 -1
- package/src/components/ui/separator.tsx +1 -1
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +8 -8
- package/src/components/ui/skeleton.tsx +1 -1
- package/src/components/ui/switch.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tabs.tsx +1 -1
- package/src/components/ui/tooltip.tsx +1 -1
- package/src/components/ui/vertical-tabs.tsx +1 -1
- package/src/index.ts +7 -0
- package/src/lib/already_logged_in_config.server.ts +1 -1
- package/src/lib/app_logger.ts +1 -1
- package/src/lib/auth/auth_cache.ts +1 -1
- package/src/lib/auth/auth_utils.server.ts +2 -2
- package/src/lib/auth/hazo_get_auth.server.ts +8 -8
- package/src/lib/auth/index.ts +23 -0
- package/src/lib/auth/server_auth.ts +2 -2
- package/src/lib/auth_utility_config.server.ts +1 -1
- package/src/lib/config/config_loader.server.ts +1 -1
- package/src/lib/email_verification_config.server.ts +1 -1
- package/src/lib/file_types_config.server.ts +1 -1
- package/src/lib/forgot_password_config.server.ts +1 -1
- package/src/lib/hazo_connect_instance.server.ts +2 -2
- package/src/lib/hazo_connect_setup.server.ts +2 -2
- package/src/lib/index.ts +44 -0
- package/src/lib/login_config.server.ts +2 -2
- package/src/lib/messages_config.server.ts +1 -1
- package/src/lib/my_settings_config.server.ts +7 -7
- package/src/lib/password_requirements_config.server.ts +1 -1
- package/src/lib/profile_pic_menu_config.server.ts +1 -1
- package/src/lib/profile_picture_config.server.ts +2 -2
- package/src/lib/register_config.server.ts +4 -4
- package/src/lib/reset_password_config.server.ts +3 -3
- package/src/lib/services/email_service.ts +2 -2
- package/src/lib/services/email_verification_service.ts +3 -3
- package/src/lib/services/index.ts +15 -0
- package/src/lib/services/login_service.ts +3 -3
- package/src/lib/services/password_change_service.ts +3 -3
- package/src/lib/services/password_reset_service.ts +3 -3
- package/src/lib/services/profile_picture_remove_service.ts +3 -3
- package/src/lib/services/profile_picture_service.ts +5 -5
- package/src/lib/services/registration_service.ts +8 -8
- package/src/lib/services/token_service.ts +2 -2
- package/src/lib/services/user_profiles_service.ts +2 -2
- package/src/lib/services/user_update_service.ts +4 -4
- package/src/lib/ui_shell_config.server.ts +1 -1
- package/src/lib/ui_sizes_config.server.ts +1 -1
- package/src/lib/user_fields_config.server.ts +1 -1
- package/src/lib/user_management_config.server.ts +1 -2
- package/src/lib/utils/error_sanitizer.ts +1 -1
- package/src/routes/index.ts +34 -0
- package/src/server/config/config_loader.ts +2 -2
- package/src/server/index.ts +2 -2
- package/src/server/logging/logger_service.ts +1 -1
- package/src/server/server.ts +2 -2
- package/src/server/types/express.d.ts +1 -1
- package/tsconfig.build.json +39 -0
- package/tsconfig.json +5 -1
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
// file_description: service for sending emails with template support
|
|
2
|
+
// section: imports
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { create_app_logger } from "hazo_auth/lib/app_logger";
|
|
6
|
+
import { read_config_section } from "hazo_auth/lib/config/config_loader.server";
|
|
7
|
+
// section: constants
|
|
8
|
+
const DEFAULT_EMAIL_FROM = "noreply@hazo_auth.local";
|
|
9
|
+
const DEFAULT_EMAIL_TEMPLATE_DIR = path.resolve(process.cwd(), "email_templates");
|
|
10
|
+
// section: singleton
|
|
11
|
+
/**
|
|
12
|
+
* Singleton instance for hazo_notify emailer configuration
|
|
13
|
+
* This is initialized once in instrumentation.ts and reused across all email sends
|
|
14
|
+
*/
|
|
15
|
+
let hazo_notify_config = null;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the hazo_notify emailer configuration instance
|
|
18
|
+
* This is called from instrumentation.ts during initialization
|
|
19
|
+
* @param config - The hazo_notify emailer configuration instance
|
|
20
|
+
*/
|
|
21
|
+
export function set_hazo_notify_instance(config) {
|
|
22
|
+
hazo_notify_config = config;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the hazo_notify emailer configuration instance
|
|
26
|
+
* If not set, loads it from config file as fallback
|
|
27
|
+
* @returns The hazo_notify emailer configuration instance
|
|
28
|
+
*/
|
|
29
|
+
async function get_hazo_notify_instance() {
|
|
30
|
+
if (!hazo_notify_config) {
|
|
31
|
+
// Fallback: load from config file if not initialized
|
|
32
|
+
const logger = create_app_logger();
|
|
33
|
+
logger.warn("hazo_notify_instance_not_initialized", {
|
|
34
|
+
filename: "email_service.ts",
|
|
35
|
+
line_number: 0,
|
|
36
|
+
note: "hazo_notify instance not initialized in instrumentation.ts, loading from config file as fallback",
|
|
37
|
+
});
|
|
38
|
+
try {
|
|
39
|
+
// Dynamic import to avoid build-time issues with hazo_notify
|
|
40
|
+
const hazo_notify_module = await import("hazo_notify");
|
|
41
|
+
const { load_emailer_config } = hazo_notify_module;
|
|
42
|
+
hazo_notify_config = load_emailer_config();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
46
|
+
logger.error("hazo_notify_config_load_failed", {
|
|
47
|
+
filename: "email_service.ts",
|
|
48
|
+
line_number: 0,
|
|
49
|
+
error: error_message,
|
|
50
|
+
});
|
|
51
|
+
throw new Error(`Failed to load hazo_notify config: ${error_message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return hazo_notify_config;
|
|
55
|
+
}
|
|
56
|
+
// section: helpers
|
|
57
|
+
/**
|
|
58
|
+
* Gets email template directory from config
|
|
59
|
+
* @returns Email template directory path
|
|
60
|
+
*/
|
|
61
|
+
function get_email_template_directory() {
|
|
62
|
+
const email_section = read_config_section("hazo_auth__email");
|
|
63
|
+
const template_dir = email_section === null || email_section === void 0 ? void 0 : email_section.email_template_main_directory;
|
|
64
|
+
if (template_dir) {
|
|
65
|
+
return path.isAbsolute(template_dir)
|
|
66
|
+
? template_dir
|
|
67
|
+
: path.resolve(process.cwd(), template_dir);
|
|
68
|
+
}
|
|
69
|
+
return DEFAULT_EMAIL_TEMPLATE_DIR;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gets email from address from config
|
|
73
|
+
* Priority: 1. hazo_auth__email.from_email, 2. hazo_notify_config.from_email
|
|
74
|
+
* @param notify_config - The hazo_notify configuration instance (for fallback)
|
|
75
|
+
* @returns Email from address
|
|
76
|
+
*/
|
|
77
|
+
async function get_email_from(notify_config) {
|
|
78
|
+
const email_section = read_config_section("hazo_auth__email");
|
|
79
|
+
const hazo_auth_from_email = email_section === null || email_section === void 0 ? void 0 : email_section.from_email;
|
|
80
|
+
// If set in hazo_auth_config.ini, use it (overrides hazo_notify config)
|
|
81
|
+
if (hazo_auth_from_email) {
|
|
82
|
+
return hazo_auth_from_email;
|
|
83
|
+
}
|
|
84
|
+
// Fall back to hazo_notify config
|
|
85
|
+
return notify_config.from_email;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets email from name from config
|
|
89
|
+
* Priority: 1. hazo_auth__email.from_name, 2. hazo_notify_config.from_name
|
|
90
|
+
* @param notify_config - The hazo_notify configuration instance (for fallback)
|
|
91
|
+
* @returns Email from name
|
|
92
|
+
*/
|
|
93
|
+
async function get_email_from_name(notify_config) {
|
|
94
|
+
const email_section = read_config_section("hazo_auth__email");
|
|
95
|
+
const hazo_auth_from_name = email_section === null || email_section === void 0 ? void 0 : email_section.from_name;
|
|
96
|
+
// If set in hazo_auth_config.ini, use it (overrides hazo_notify config)
|
|
97
|
+
if (hazo_auth_from_name) {
|
|
98
|
+
return hazo_auth_from_name;
|
|
99
|
+
}
|
|
100
|
+
// Fall back to hazo_notify config
|
|
101
|
+
return notify_config.from_name;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gets base URL for email links from config or environment variable
|
|
105
|
+
* Priority: 1. hazo_auth__email.base_url, 2. APP_DOMAIN_NAME, 3. NEXT_PUBLIC_APP_URL/APP_URL
|
|
106
|
+
* @returns Base URL for email links
|
|
107
|
+
*/
|
|
108
|
+
function get_base_url() {
|
|
109
|
+
const email_section = read_config_section("hazo_auth__email");
|
|
110
|
+
const base_url = email_section === null || email_section === void 0 ? void 0 : email_section.base_url;
|
|
111
|
+
if (base_url) {
|
|
112
|
+
return base_url.endsWith("/") ? base_url.slice(0, -1) : base_url;
|
|
113
|
+
}
|
|
114
|
+
// Try to get from APP_DOMAIN_NAME environment variable (adds protocol if needed)
|
|
115
|
+
const app_domain_name = process.env.APP_DOMAIN_NAME;
|
|
116
|
+
if (app_domain_name) {
|
|
117
|
+
// Ensure protocol is included (default to https if not specified)
|
|
118
|
+
const domain = app_domain_name.trim();
|
|
119
|
+
if (domain.startsWith("http://") || domain.startsWith("https://")) {
|
|
120
|
+
return domain.endsWith("/") ? domain.slice(0, -1) : domain;
|
|
121
|
+
}
|
|
122
|
+
// If no protocol, default to https
|
|
123
|
+
return `https://${domain}`;
|
|
124
|
+
}
|
|
125
|
+
// Try to get from other environment variables (fallback)
|
|
126
|
+
const env_base_url = process.env.NEXT_PUBLIC_APP_URL || process.env.APP_URL;
|
|
127
|
+
if (env_base_url) {
|
|
128
|
+
return env_base_url.endsWith("/") ? env_base_url.slice(0, -1) : env_base_url;
|
|
129
|
+
}
|
|
130
|
+
// Default to empty string (will use relative URLs)
|
|
131
|
+
return "";
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Constructs verification URL from token
|
|
135
|
+
* @param token - Verification token
|
|
136
|
+
* @returns Verification URL
|
|
137
|
+
*/
|
|
138
|
+
function get_verification_url(token) {
|
|
139
|
+
const base_url = get_base_url();
|
|
140
|
+
const path = "/hazo_auth/verify_email";
|
|
141
|
+
const url = base_url ? `${base_url}${path}?token=${encodeURIComponent(token)}` : `${path}?token=${encodeURIComponent(token)}`;
|
|
142
|
+
return url;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Constructs reset password URL from token
|
|
146
|
+
* @param token - Password reset token
|
|
147
|
+
* @returns Reset password URL
|
|
148
|
+
*/
|
|
149
|
+
function get_reset_password_url(token) {
|
|
150
|
+
const base_url = get_base_url();
|
|
151
|
+
const path = "/hazo_auth/reset_password";
|
|
152
|
+
const url = base_url ? `${base_url}${path}?token=${encodeURIComponent(token)}` : `${path}?token=${encodeURIComponent(token)}`;
|
|
153
|
+
return url;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Gets default HTML template for a given template type
|
|
157
|
+
* @param template_type - Type of email template
|
|
158
|
+
* @param data - Template data for variable substitution
|
|
159
|
+
* @returns Default HTML template content
|
|
160
|
+
*/
|
|
161
|
+
function get_default_html_template(template_type, data) {
|
|
162
|
+
switch (template_type) {
|
|
163
|
+
case "email_verification":
|
|
164
|
+
return `
|
|
165
|
+
<!DOCTYPE html>
|
|
166
|
+
<html>
|
|
167
|
+
<head>
|
|
168
|
+
<meta charset="UTF-8">
|
|
169
|
+
<title>Verify Your Email</title>
|
|
170
|
+
</head>
|
|
171
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
172
|
+
<h1 style="color: #0f172a;">Verify Your Email Address</h1>
|
|
173
|
+
<p>Thank you for registering! Please click the link below to verify your email address:</p>
|
|
174
|
+
<p style="margin: 20px 0;">
|
|
175
|
+
<a href="${data.verification_url || "#"}" style="display: inline-block; padding: 12px 24px; background-color: #0f172a; color: #ffffff; text-decoration: none; border-radius: 4px;">Verify Email Address</a>
|
|
176
|
+
</p>
|
|
177
|
+
<p>Or copy and paste this link into your browser:</p>
|
|
178
|
+
<p style="word-break: break-all; color: #666;">${data.verification_url || data.token || ""}</p>
|
|
179
|
+
<p>This link will expire in 48 hours.</p>
|
|
180
|
+
<p style="margin-top: 30px; color: #666; font-size: 12px;">If you didn't create an account, you can safely ignore this email.</p>
|
|
181
|
+
</body>
|
|
182
|
+
</html>
|
|
183
|
+
`.trim();
|
|
184
|
+
case "forgot_password":
|
|
185
|
+
return `
|
|
186
|
+
<!DOCTYPE html>
|
|
187
|
+
<html>
|
|
188
|
+
<head>
|
|
189
|
+
<meta charset="UTF-8">
|
|
190
|
+
<title>Reset Your Password</title>
|
|
191
|
+
</head>
|
|
192
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
193
|
+
<h1 style="color: #0f172a;">Reset Your Password</h1>
|
|
194
|
+
<p>We received a request to reset your password. Click the link below to reset it:</p>
|
|
195
|
+
<p style="margin: 20px 0;">
|
|
196
|
+
<a href="${data.reset_url || "#"}" style="display: inline-block; padding: 12px 24px; background-color: #0f172a; color: #ffffff; text-decoration: none; border-radius: 4px;">Reset Password</a>
|
|
197
|
+
</p>
|
|
198
|
+
<p>Or copy and paste this link into your browser:</p>
|
|
199
|
+
<p style="word-break: break-all; color: #666;">${data.reset_url || data.token || ""}</p>
|
|
200
|
+
<p>This link will expire in 10 minutes.</p>
|
|
201
|
+
<p style="margin-top: 30px; color: #666; font-size: 12px;">If you didn't request a password reset, you can safely ignore this email.</p>
|
|
202
|
+
</body>
|
|
203
|
+
</html>
|
|
204
|
+
`.trim();
|
|
205
|
+
case "password_changed":
|
|
206
|
+
return `
|
|
207
|
+
<!DOCTYPE html>
|
|
208
|
+
<html>
|
|
209
|
+
<head>
|
|
210
|
+
<meta charset="UTF-8">
|
|
211
|
+
<title>Password Changed</title>
|
|
212
|
+
</head>
|
|
213
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
214
|
+
<h1 style="color: #0f172a;">Password Changed Successfully</h1>
|
|
215
|
+
<p>Hello${data.user_name ? ` ${data.user_name}` : ""},</p>
|
|
216
|
+
<p>This email confirms that your password has been changed successfully.</p>
|
|
217
|
+
<p>If you did not make this change, please contact support immediately to secure your account.</p>
|
|
218
|
+
<p style="margin-top: 30px; color: #666; font-size: 12px;">This is an automated notification. Please do not reply to this email.</p>
|
|
219
|
+
</body>
|
|
220
|
+
</html>
|
|
221
|
+
`.trim();
|
|
222
|
+
default:
|
|
223
|
+
return "<p>Email content</p>";
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Gets default text template for a given template type
|
|
228
|
+
* @param template_type - Type of email template
|
|
229
|
+
* @param data - Template data for variable substitution
|
|
230
|
+
* @returns Default text template content
|
|
231
|
+
*/
|
|
232
|
+
function get_default_text_template(template_type, data) {
|
|
233
|
+
switch (template_type) {
|
|
234
|
+
case "email_verification":
|
|
235
|
+
return `
|
|
236
|
+
Verify Your Email Address
|
|
237
|
+
|
|
238
|
+
Thank you for registering! Please click the link below to verify your email address:
|
|
239
|
+
|
|
240
|
+
${data.verification_url || data.token || ""}
|
|
241
|
+
|
|
242
|
+
This link will expire in 48 hours.
|
|
243
|
+
|
|
244
|
+
If you didn't create an account, you can safely ignore this email.
|
|
245
|
+
`.trim();
|
|
246
|
+
case "forgot_password":
|
|
247
|
+
return `
|
|
248
|
+
Reset Your Password
|
|
249
|
+
|
|
250
|
+
We received a request to reset your password. Click the link below to reset it:
|
|
251
|
+
|
|
252
|
+
${data.reset_url || data.token || ""}
|
|
253
|
+
|
|
254
|
+
This link will expire in 10 minutes.
|
|
255
|
+
|
|
256
|
+
If you didn't request a password reset, you can safely ignore this email.
|
|
257
|
+
`.trim();
|
|
258
|
+
case "password_changed":
|
|
259
|
+
return `
|
|
260
|
+
Password Changed Successfully
|
|
261
|
+
|
|
262
|
+
Hello${data.user_name ? ` ${data.user_name}` : ""},
|
|
263
|
+
|
|
264
|
+
This email confirms that your password has been changed successfully.
|
|
265
|
+
|
|
266
|
+
If you did not make this change, please contact support immediately to secure your account.
|
|
267
|
+
|
|
268
|
+
This is an automated notification. Please do not reply to this email.
|
|
269
|
+
`.trim();
|
|
270
|
+
default:
|
|
271
|
+
return "Email content";
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Loads email template from file system
|
|
276
|
+
* @param template_type - Type of email template
|
|
277
|
+
* @param extension - File extension (html or txt)
|
|
278
|
+
* @returns Template content or undefined if not found
|
|
279
|
+
*/
|
|
280
|
+
function load_template_file(template_type, extension) {
|
|
281
|
+
const template_dir = get_email_template_directory();
|
|
282
|
+
const template_filename = `${template_type}.${extension}`;
|
|
283
|
+
const template_path = path.join(template_dir, template_filename);
|
|
284
|
+
if (!fs.existsSync(template_path)) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
return fs.readFileSync(template_path, "utf-8");
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
const logger = create_app_logger();
|
|
292
|
+
logger.error("email_service_template_load_failed", {
|
|
293
|
+
filename: "email_service.ts",
|
|
294
|
+
line_number: 0,
|
|
295
|
+
template_path,
|
|
296
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
297
|
+
});
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Simple template variable substitution
|
|
303
|
+
* Replaces {{variable_name}} with values from data object
|
|
304
|
+
* @param template - Template string with variables
|
|
305
|
+
* @param data - Data object for variable substitution
|
|
306
|
+
* @returns Template with variables substituted
|
|
307
|
+
*/
|
|
308
|
+
function substitute_template_variables(template, data) {
|
|
309
|
+
let result = template;
|
|
310
|
+
// Replace {{variable}} with values from data
|
|
311
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
312
|
+
if (value !== undefined) {
|
|
313
|
+
const regex = new RegExp(`{{\\s*${key}\\s*}}`, "g");
|
|
314
|
+
result = result.replace(regex, value);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Gets email subject for a given template type
|
|
321
|
+
* @param template_type - Type of email template
|
|
322
|
+
* @returns Email subject
|
|
323
|
+
*/
|
|
324
|
+
function get_email_subject(template_type) {
|
|
325
|
+
const email_section = read_config_section("hazo_auth__email");
|
|
326
|
+
const template_config_key = `email_template__${template_type}`;
|
|
327
|
+
const subject_key = `${template_config_key}__subject`;
|
|
328
|
+
// Try to get subject from config
|
|
329
|
+
const subject = email_section === null || email_section === void 0 ? void 0 : email_section[subject_key];
|
|
330
|
+
if (subject) {
|
|
331
|
+
return subject;
|
|
332
|
+
}
|
|
333
|
+
// Default subjects
|
|
334
|
+
switch (template_type) {
|
|
335
|
+
case "email_verification":
|
|
336
|
+
return "Verify Your Email Address";
|
|
337
|
+
case "forgot_password":
|
|
338
|
+
return "Reset Your Password";
|
|
339
|
+
case "password_changed":
|
|
340
|
+
return "Password Changed Successfully";
|
|
341
|
+
default:
|
|
342
|
+
return "Email from hazo_auth";
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Gets email templates (HTML and text) for a given template type
|
|
347
|
+
* Falls back to default templates if custom templates are not found
|
|
348
|
+
* @param template_type - Type of email template
|
|
349
|
+
* @param data - Template data for variable substitution
|
|
350
|
+
* @returns Object with html_body and text_body
|
|
351
|
+
*/
|
|
352
|
+
function get_email_templates(template_type, data) {
|
|
353
|
+
// Try to load custom templates
|
|
354
|
+
const html_template = load_template_file(template_type, "html");
|
|
355
|
+
const text_template = load_template_file(template_type, "txt");
|
|
356
|
+
// Use custom templates if found, otherwise use defaults
|
|
357
|
+
const html_body = html_template
|
|
358
|
+
? substitute_template_variables(html_template, data)
|
|
359
|
+
: get_default_html_template(template_type, data);
|
|
360
|
+
const text_body = text_template
|
|
361
|
+
? substitute_template_variables(text_template, data)
|
|
362
|
+
: get_default_text_template(template_type, data);
|
|
363
|
+
return { html_body, text_body };
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Sends an email using hazo_notify
|
|
367
|
+
* @param options - Email options (to, from, subject, html_body, text_body)
|
|
368
|
+
* @returns Promise that resolves when email is sent
|
|
369
|
+
*/
|
|
370
|
+
export async function send_email(options) {
|
|
371
|
+
const logger = create_app_logger();
|
|
372
|
+
try {
|
|
373
|
+
// Get hazo_notify configuration instance
|
|
374
|
+
const notify_config = await get_hazo_notify_instance();
|
|
375
|
+
// Dynamic import to avoid build-time issues with hazo_notify
|
|
376
|
+
const hazo_notify_module = await import("hazo_notify");
|
|
377
|
+
const { send_email: hazo_notify_send_email } = hazo_notify_module;
|
|
378
|
+
// Get from email and from name (hazo_auth_config overrides hazo_notify_config)
|
|
379
|
+
// Priority: 1. options.from (explicit parameter), 2. hazo_auth_config.from_email, 3. hazo_notify_config.from_email
|
|
380
|
+
const from_email = options.from || await get_email_from(notify_config);
|
|
381
|
+
const from_name = await get_email_from_name(notify_config);
|
|
382
|
+
// Prepare hazo_notify email options
|
|
383
|
+
const hazo_notify_options = {
|
|
384
|
+
to: options.to,
|
|
385
|
+
subject: options.subject,
|
|
386
|
+
content: Object.assign(Object.assign({}, (options.html_body && { html: options.html_body })), (options.text_body && { text: options.text_body })),
|
|
387
|
+
// Use from_email and from_name (hazo_notify will use these instead of config defaults)
|
|
388
|
+
from: from_email,
|
|
389
|
+
from_name: from_name,
|
|
390
|
+
};
|
|
391
|
+
// Send email using hazo_notify
|
|
392
|
+
const result = await hazo_notify_send_email(hazo_notify_options, notify_config);
|
|
393
|
+
if (result.success) {
|
|
394
|
+
logger.info("email_sent", {
|
|
395
|
+
filename: "email_service.ts",
|
|
396
|
+
line_number: 0,
|
|
397
|
+
to: options.to,
|
|
398
|
+
from: options.from || notify_config.from_email,
|
|
399
|
+
subject: options.subject,
|
|
400
|
+
message_id: result.message_id,
|
|
401
|
+
});
|
|
402
|
+
return { success: true };
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
const error_message = result.error || result.message || "Unknown error";
|
|
406
|
+
logger.error("email_send_failed", {
|
|
407
|
+
filename: "email_service.ts",
|
|
408
|
+
line_number: 0,
|
|
409
|
+
to: options.to,
|
|
410
|
+
from: options.from || notify_config.from_email,
|
|
411
|
+
subject: options.subject,
|
|
412
|
+
error: error_message,
|
|
413
|
+
raw_response: result.raw_response,
|
|
414
|
+
});
|
|
415
|
+
return { success: false, error: error_message };
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
420
|
+
logger.error("email_send_failed", {
|
|
421
|
+
filename: "email_service.ts",
|
|
422
|
+
line_number: 0,
|
|
423
|
+
to: options.to,
|
|
424
|
+
from: options.from,
|
|
425
|
+
subject: options.subject,
|
|
426
|
+
error: error_message,
|
|
427
|
+
});
|
|
428
|
+
return { success: false, error: error_message };
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Sends an email using a template
|
|
433
|
+
* @param template_type - Type of email template
|
|
434
|
+
* @param to - Recipient email address
|
|
435
|
+
* @param data - Template data for variable substitution
|
|
436
|
+
* @returns Promise that resolves when email is sent
|
|
437
|
+
*/
|
|
438
|
+
export async function send_template_email(template_type, to, data) {
|
|
439
|
+
const logger = create_app_logger();
|
|
440
|
+
try {
|
|
441
|
+
// Enhance data with URLs if token is provided
|
|
442
|
+
const enhanced_data = Object.assign({}, data);
|
|
443
|
+
if (data.token) {
|
|
444
|
+
if (template_type === "email_verification") {
|
|
445
|
+
enhanced_data.verification_url = get_verification_url(data.token);
|
|
446
|
+
}
|
|
447
|
+
else if (template_type === "forgot_password") {
|
|
448
|
+
enhanced_data.reset_url = get_reset_password_url(data.token);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
// Get email templates
|
|
452
|
+
const { html_body, text_body } = get_email_templates(template_type, enhanced_data);
|
|
453
|
+
// Get email subject
|
|
454
|
+
const subject = get_email_subject(template_type);
|
|
455
|
+
// Get hazo_notify config instance
|
|
456
|
+
const notify_config = await get_hazo_notify_instance();
|
|
457
|
+
// Get email from address and from name
|
|
458
|
+
// Priority: 1. hazo_auth_config.from_email/from_name, 2. hazo_notify_config.from_email/from_name
|
|
459
|
+
const from = await get_email_from(notify_config);
|
|
460
|
+
// Send email (from_name is handled inside send_email function)
|
|
461
|
+
return await send_email({
|
|
462
|
+
to,
|
|
463
|
+
from,
|
|
464
|
+
subject,
|
|
465
|
+
html_body,
|
|
466
|
+
text_body,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
catch (error) {
|
|
470
|
+
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
471
|
+
logger.error("email_template_send_failed", {
|
|
472
|
+
filename: "email_service.ts",
|
|
473
|
+
line_number: 0,
|
|
474
|
+
template_type,
|
|
475
|
+
to,
|
|
476
|
+
error: error_message,
|
|
477
|
+
});
|
|
478
|
+
return { success: false, error: error_message };
|
|
479
|
+
}
|
|
480
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HazoConnectAdapter } from "hazo_connect";
|
|
2
|
+
export type EmailVerificationTokenData = {
|
|
3
|
+
token: string;
|
|
4
|
+
};
|
|
5
|
+
export type EmailVerificationResult = {
|
|
6
|
+
success: boolean;
|
|
7
|
+
user_id?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
};
|
|
11
|
+
export type ResendVerificationData = {
|
|
12
|
+
email: string;
|
|
13
|
+
};
|
|
14
|
+
export type ResendVerificationResult = {
|
|
15
|
+
success: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Verifies an email verification token
|
|
20
|
+
* Updates email_verified to true in hazo_users and deletes the token
|
|
21
|
+
* @param adapter - The hazo_connect adapter instance
|
|
22
|
+
* @param data - Email verification token data (token)
|
|
23
|
+
* @returns Email verification result with success status, user_id, email, or error
|
|
24
|
+
*/
|
|
25
|
+
export declare function verify_email_token(adapter: HazoConnectAdapter, data: EmailVerificationTokenData): Promise<EmailVerificationResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Resends an email verification token for a user
|
|
28
|
+
* Creates a new email verification token and stores it in hazo_refresh_tokens
|
|
29
|
+
* Invalidates any existing email verification tokens for the user before creating a new one
|
|
30
|
+
* @param adapter - The hazo_connect adapter instance
|
|
31
|
+
* @param data - Resend verification data (email)
|
|
32
|
+
* @returns Resend verification result with success status or error
|
|
33
|
+
*/
|
|
34
|
+
export declare function resend_verification_email(adapter: HazoConnectAdapter, data: ResendVerificationData): Promise<ResendVerificationResult>;
|
|
35
|
+
//# sourceMappingURL=email_verification_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email_verification_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/email_verification_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAQvD,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CAoIlC;AAED;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,wBAAwB,CAAC,CAkFnC"}
|