@vitnode/core 1.2.0-canary.52 → 1.2.0-canary.53
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/config/next.config.ts +3 -3
- package/dist/scripts/get-config.d.ts +2 -2
- package/dist/scripts/get-config.d.ts.map +1 -1
- package/dist/scripts/plugin.d.ts.map +1 -1
- package/dist/scripts/prepare-database.d.ts.map +1 -1
- package/dist/scripts/prepare-plugins-files.d.ts.map +1 -1
- package/dist/scripts/scripts.js +4 -4
- package/dist/scripts/shared/file-utils.d.ts.map +1 -1
- package/dist/src/api/adapters/email/nodemailer.d.ts +1 -1
- package/dist/src/api/adapters/email/nodemailer.js +3 -3
- package/dist/src/api/adapters/email/resend.d.ts +1 -1
- package/dist/src/api/adapters/email/resend.js +2 -2
- package/dist/src/api/adapters/sso/discord.d.ts +1 -1
- package/dist/src/api/adapters/sso/discord.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/discord.js +21 -21
- package/dist/src/api/adapters/sso/facebook.d.ts +1 -1
- package/dist/src/api/adapters/sso/facebook.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/facebook.js +23 -23
- package/dist/src/api/adapters/sso/google.d.ts +1 -1
- package/dist/src/api/adapters/sso/google.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/google.js +21 -21
- package/dist/src/api/config.d.ts +3 -3
- package/dist/src/api/config.d.ts.map +1 -1
- package/dist/src/api/config.js +11 -11
- package/dist/src/api/lib/check-plugin-id.js +8 -8
- package/dist/src/api/lib/logger-middleware.d.ts +1 -1
- package/dist/src/api/lib/logger-middleware.js +9 -9
- package/dist/src/api/lib/module.d.ts +2 -2
- package/dist/src/api/lib/plugin.d.ts +2 -2
- package/dist/src/api/lib/plugin.d.ts.map +1 -1
- package/dist/src/api/lib/route.d.ts +2 -2
- package/dist/src/api/lib/route.d.ts.map +1 -1
- package/dist/src/api/lib/route.js +1 -1
- package/dist/src/api/lib/with-pagination.d.ts +7 -7
- package/dist/src/api/lib/with-pagination.d.ts.map +1 -1
- package/dist/src/api/lib/with-pagination.js +37 -24
- package/dist/src/api/middlewares/captcha.middleware.d.ts +1 -1
- package/dist/src/api/middlewares/captcha.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/captcha.middleware.js +14 -13
- package/dist/src/api/middlewares/global.middleware.d.ts +12 -12
- package/dist/src/api/middlewares/global.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/global.middleware.js +29 -28
- package/dist/src/api/middlewares/rate-limiter.middleware.d.ts +3 -3
- package/dist/src/api/middlewares/rate-limiter.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/rate-limiter.middleware.js +4 -4
- package/dist/src/api/models/device.d.ts +1 -1
- package/dist/src/api/models/device.d.ts.map +1 -1
- package/dist/src/api/models/device.js +13 -13
- package/dist/src/api/models/email.d.ts +15 -15
- package/dist/src/api/models/email.d.ts.map +1 -1
- package/dist/src/api/models/email.js +11 -10
- package/dist/src/api/models/password.js +9 -9
- package/dist/src/api/models/session-admin.d.ts +1 -1
- package/dist/src/api/models/session-admin.d.ts.map +1 -1
- package/dist/src/api/models/session-admin.js +19 -19
- package/dist/src/api/models/session.d.ts +1 -1
- package/dist/src/api/models/session.d.ts.map +1 -1
- package/dist/src/api/models/session.js +17 -17
- package/dist/src/api/models/sso.d.ts +1 -1
- package/dist/src/api/models/sso.d.ts.map +1 -1
- package/dist/src/api/models/sso.js +22 -25
- package/dist/src/api/models/user/get-user-by-id.d.ts +1 -1
- package/dist/src/api/models/user/get-user-by-id.d.ts.map +1 -1
- package/dist/src/api/models/user/get-user-by-id.js +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts.map +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.js +1 -1
- package/dist/src/api/models/user/sign-up.d.ts +1 -1
- package/dist/src/api/models/user/sign-up.d.ts.map +1 -1
- package/dist/src/api/models/user/sign-up.js +11 -12
- package/dist/src/api/models/user.d.ts.map +1 -1
- package/dist/src/api/modules/admin/admin.module.d.ts +3 -3
- package/dist/src/api/modules/admin/admin.module.js +1 -1
- package/dist/src/api/modules/admin/debug/debug.admin.module.d.ts +1 -1
- package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -1
- package/dist/src/api/modules/admin/debug/routes/logs.route.d.ts +2 -2
- package/dist/src/api/modules/admin/debug/routes/logs.route.js +16 -16
- package/dist/src/api/modules/admin/routes/session.route.d.ts +2 -2
- package/dist/src/api/modules/admin/routes/session.route.js +7 -7
- package/dist/src/api/modules/admin/users/routes/list.route.d.ts +2 -2
- package/dist/src/api/modules/admin/users/routes/list.route.js +12 -12
- package/dist/src/api/modules/admin/users/routes/users.route.d.ts +2 -2
- package/dist/src/api/modules/admin/users/routes/users.route.js +15 -15
- package/dist/src/api/modules/admin/users/users.admin.module.d.ts +1 -1
- package/dist/src/api/modules/admin/users/users.admin.module.js +1 -1
- package/dist/src/api/modules/middleware/middleware.module.d.ts +1 -1
- package/dist/src/api/modules/middleware/middleware.module.js +1 -1
- package/dist/src/api/modules/middleware/route.d.ts +2 -2
- package/dist/src/api/modules/middleware/route.js +12 -12
- package/dist/src/api/modules/users/routes/change-password.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/change-password.route.js +13 -13
- package/dist/src/api/modules/users/routes/reset-passowrd.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/reset-passowrd.route.js +17 -17
- package/dist/src/api/modules/users/routes/session.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/session.route.js +6 -6
- package/dist/src/api/modules/users/routes/sign-in.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/sign-in.route.js +10 -10
- package/dist/src/api/modules/users/routes/sign-out.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/sign-out.route.js +7 -7
- package/dist/src/api/modules/users/routes/sign-up.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/sign-up.route.js +14 -14
- package/dist/src/api/modules/users/routes/test.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/test.route.js +9 -9
- package/dist/src/api/modules/users/sso/routes/callback.route.d.ts +2 -2
- package/dist/src/api/modules/users/sso/routes/callback.route.js +8 -8
- package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts +2 -2
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +6 -6
- package/dist/src/api/modules/users/sso/sso.module.d.ts +2 -2
- package/dist/src/api/modules/users/sso/sso.module.js +1 -1
- package/dist/src/api/modules/users/users.module.d.ts +12 -12
- package/dist/src/api/modules/users/users.module.js +1 -1
- package/dist/src/app/login/page.d.ts +1 -1
- package/dist/src/app/login/page.js +2 -2
- package/dist/src/app/login/reset-password/page.d.ts +2 -2
- package/dist/src/app/login/reset-password/page.js +2 -2
- package/dist/src/app/register/page.d.ts +1 -1
- package/dist/src/app/register/page.js +2 -2
- package/dist/src/app_admin/core/debug/page.d.ts +1 -1
- package/dist/src/app_admin/core/debug/page.js +8 -8
- package/dist/src/app_admin/core/users/page.d.ts +2 -2
- package/dist/src/app_admin/core/users/page.d.ts.map +1 -1
- package/dist/src/app_admin/core/users/page.js +7 -7
- package/dist/src/components/avatar.d.ts +1 -1
- package/dist/src/components/avatar.js +1 -1
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.d.ts +2 -2
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +5 -5
- package/dist/src/components/confirm-action/content.d.ts.map +1 -1
- package/dist/src/components/confirm-action/content.js +3 -4
- package/dist/src/components/date-format.js +8 -8
- package/dist/src/components/form/auto-form.d.ts +16 -16
- package/dist/src/components/form/auto-form.d.ts.map +1 -1
- package/dist/src/components/form/auto-form.js +13 -12
- package/dist/src/components/form/common/desc.js +1 -1
- package/dist/src/components/form/common/label.d.ts +1 -1
- package/dist/src/components/form/common/label.js +1 -1
- package/dist/src/components/form/fields/checkbox.d.ts +2 -2
- package/dist/src/components/form/fields/checkbox.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox-async.d.ts +3 -3
- package/dist/src/components/form/fields/combobox-async.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox-async.js +29 -23
- package/dist/src/components/form/fields/combobox.d.ts +3 -3
- package/dist/src/components/form/fields/combobox.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox.js +6 -7
- package/dist/src/components/form/fields/input.d.ts +2 -2
- package/dist/src/components/form/fields/input.d.ts.map +1 -1
- package/dist/src/components/form/fields/input.js +2 -2
- package/dist/src/components/form/fields/radio-group.d.ts +3 -3
- package/dist/src/components/form/fields/radio-group.d.ts.map +1 -1
- package/dist/src/components/form/fields/radio-group.js +0 -1
- package/dist/src/components/form/fields/select.d.ts +3 -3
- package/dist/src/components/form/fields/select.d.ts.map +1 -1
- package/dist/src/components/form/fields/select.js +2 -3
- package/dist/src/components/form/fields/switch.d.ts +2 -2
- package/dist/src/components/form/fields/switch.d.ts.map +1 -1
- package/dist/src/components/form/fields/textarea.d.ts +3 -3
- package/dist/src/components/form/fields/textarea.d.ts.map +1 -1
- package/dist/src/components/form/fields/textarea.js +1 -2
- package/dist/src/components/i18n-provider.d.ts +2 -2
- package/dist/src/components/i18n-provider.js +3 -3
- package/dist/src/components/logo-vitnode.d.ts.map +1 -1
- package/dist/src/components/logo-vitnode.js +8 -2
- package/dist/src/components/switchers/langs/language-swietcher.d.ts +1 -1
- package/dist/src/components/switchers/langs/language-swietcher.d.ts.map +1 -1
- package/dist/src/components/switchers/langs/language-swietcher.js +3 -3
- package/dist/src/components/switchers/themes/theme-switcher.js +4 -4
- package/dist/src/components/table/content.d.ts +1 -1
- package/dist/src/components/table/content.d.ts.map +1 -1
- package/dist/src/components/table/content.js +5 -5
- package/dist/src/components/table/data-table.d.ts +7 -7
- package/dist/src/components/table/data-table.d.ts.map +1 -1
- package/dist/src/components/table/data-table.js +22 -15
- package/dist/src/components/table/order-table-head.d.ts +4 -4
- package/dist/src/components/table/order-table-head.d.ts.map +1 -1
- package/dist/src/components/table/order-table-head.js +20 -9
- package/dist/src/components/table/pagination.js +19 -19
- package/dist/src/components/ui/accordion.d.ts +2 -2
- package/dist/src/components/ui/accordion.d.ts.map +1 -1
- package/dist/src/components/ui/accordion.js +4 -5
- package/dist/src/components/ui/alert-dialog.d.ts +7 -7
- package/dist/src/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/src/components/ui/alert-dialog.js +12 -12
- package/dist/src/components/ui/alert.d.ts +5 -5
- package/dist/src/components/ui/alert.d.ts.map +1 -1
- package/dist/src/components/ui/alert.js +6 -7
- package/dist/src/components/ui/badge.d.ts +3 -3
- package/dist/src/components/ui/badge.d.ts.map +1 -1
- package/dist/src/components/ui/badge.js +7 -8
- package/dist/src/components/ui/button-client.d.ts +1 -1
- package/dist/src/components/ui/button-client.js +9 -9
- package/dist/src/components/ui/button.d.ts +8 -8
- package/dist/src/components/ui/button.d.ts.map +1 -1
- package/dist/src/components/ui/button.js +13 -14
- package/dist/src/components/ui/card.d.ts +8 -8
- package/dist/src/components/ui/card.js +7 -7
- package/dist/src/components/ui/checkbox.d.ts +2 -2
- package/dist/src/components/ui/checkbox.d.ts.map +1 -1
- package/dist/src/components/ui/checkbox.js +2 -3
- package/dist/src/components/ui/collapsible.d.ts +1 -1
- package/dist/src/components/ui/collapsible.js +1 -1
- package/dist/src/components/ui/command.d.ts +4 -4
- package/dist/src/components/ui/command.d.ts.map +1 -1
- package/dist/src/components/ui/command.js +9 -10
- package/dist/src/components/ui/context-menu.d.ts +4 -4
- package/dist/src/components/ui/context-menu.d.ts.map +1 -1
- package/dist/src/components/ui/context-menu.js +7 -8
- package/dist/src/components/ui/dialog.d.ts +6 -6
- package/dist/src/components/ui/dialog.d.ts.map +1 -1
- package/dist/src/components/ui/dialog.js +16 -16
- package/dist/src/components/ui/drawer.d.ts +4 -4
- package/dist/src/components/ui/drawer.d.ts.map +1 -1
- package/dist/src/components/ui/drawer.js +7 -8
- package/dist/src/components/ui/dropdown-menu.d.ts +4 -4
- package/dist/src/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/src/components/ui/dropdown-menu.js +8 -9
- package/dist/src/components/ui/form.d.ts +10 -10
- package/dist/src/components/ui/form.d.ts.map +1 -1
- package/dist/src/components/ui/form.js +15 -15
- package/dist/src/components/ui/header-content.js +1 -1
- package/dist/src/components/ui/hover-card.d.ts +2 -2
- package/dist/src/components/ui/hover-card.d.ts.map +1 -1
- package/dist/src/components/ui/hover-card.js +3 -4
- package/dist/src/components/ui/input-otp.d.ts +5 -5
- package/dist/src/components/ui/input-otp.d.ts.map +1 -1
- package/dist/src/components/ui/input-otp.js +6 -7
- package/dist/src/components/ui/input.d.ts +2 -2
- package/dist/src/components/ui/input.d.ts.map +1 -1
- package/dist/src/components/ui/input.js +1 -2
- package/dist/src/components/ui/label.d.ts +2 -2
- package/dist/src/components/ui/label.d.ts.map +1 -1
- package/dist/src/components/ui/label.js +2 -3
- package/dist/src/components/ui/loader.js +3 -3
- package/dist/src/components/ui/menubar.d.ts +4 -4
- package/dist/src/components/ui/menubar.d.ts.map +1 -1
- package/dist/src/components/ui/menubar.js +11 -12
- package/dist/src/components/ui/navigation-menu.d.ts +2 -2
- package/dist/src/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/src/components/ui/navigation-menu.js +10 -11
- package/dist/src/components/ui/popover.d.ts +2 -2
- package/dist/src/components/ui/popover.d.ts.map +1 -1
- package/dist/src/components/ui/popover.js +3 -4
- package/dist/src/components/ui/progress.d.ts +2 -2
- package/dist/src/components/ui/progress.d.ts.map +1 -1
- package/dist/src/components/ui/progress.js +2 -3
- package/dist/src/components/ui/radio-group.d.ts +2 -2
- package/dist/src/components/ui/radio-group.d.ts.map +1 -1
- package/dist/src/components/ui/radio-group.js +3 -4
- package/dist/src/components/ui/select.d.ts +3 -3
- package/dist/src/components/ui/select.d.ts.map +1 -1
- package/dist/src/components/ui/select.js +9 -10
- package/dist/src/components/ui/separator.d.ts +2 -2
- package/dist/src/components/ui/separator.d.ts.map +1 -1
- package/dist/src/components/ui/separator.js +3 -4
- package/dist/src/components/ui/sheet.d.ts +5 -5
- package/dist/src/components/ui/sheet.d.ts.map +1 -1
- package/dist/src/components/ui/sheet.js +8 -9
- package/dist/src/components/ui/sidebar.d.ts +31 -31
- package/dist/src/components/ui/sidebar.d.ts.map +1 -1
- package/dist/src/components/ui/sidebar.js +67 -69
- package/dist/src/components/ui/skeleton.d.ts +1 -1
- package/dist/src/components/ui/skeleton.js +1 -1
- package/dist/src/components/ui/slider.d.ts +2 -2
- package/dist/src/components/ui/slider.d.ts.map +1 -1
- package/dist/src/components/ui/slider.js +16 -8
- package/dist/src/components/ui/sonner.d.ts +1 -1
- package/dist/src/components/ui/sonner.d.ts.map +1 -1
- package/dist/src/components/ui/sonner.js +6 -6
- package/dist/src/components/ui/switch.d.ts +2 -2
- package/dist/src/components/ui/switch.d.ts.map +1 -1
- package/dist/src/components/ui/switch.js +3 -4
- package/dist/src/components/ui/table.d.ts +9 -9
- package/dist/src/components/ui/table.d.ts.map +1 -1
- package/dist/src/components/ui/table.js +8 -9
- package/dist/src/components/ui/tabs.d.ts +2 -2
- package/dist/src/components/ui/tabs.d.ts.map +1 -1
- package/dist/src/components/ui/tabs.js +4 -5
- package/dist/src/components/ui/textarea.d.ts +2 -2
- package/dist/src/components/ui/textarea.d.ts.map +1 -1
- package/dist/src/components/ui/textarea.js +1 -2
- package/dist/src/components/ui/toggle-group.d.ts +4 -4
- package/dist/src/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/src/components/ui/toggle-group.js +6 -6
- package/dist/src/components/ui/toggle.d.ts +3 -3
- package/dist/src/components/ui/toggle.d.ts.map +1 -1
- package/dist/src/components/ui/toggle.js +8 -9
- package/dist/src/components/ui/tooltip.d.ts +2 -2
- package/dist/src/components/ui/tooltip.d.ts.map +1 -1
- package/dist/src/components/ui/tooltip.js +2 -3
- package/dist/src/config.js +2 -2
- package/dist/src/database/admins.js +10 -10
- package/dist/src/database/languages.js +7 -7
- package/dist/src/database/logs.js +9 -9
- package/dist/src/database/moderators.js +5 -5
- package/dist/src/database/roles.js +1 -1
- package/dist/src/database/sessions.js +6 -6
- package/dist/src/database/users.js +13 -13
- package/dist/src/drizzle.config.d.ts +2 -2
- package/dist/src/drizzle.config.d.ts.map +1 -1
- package/dist/src/drizzle.config.js +19 -12
- package/dist/src/emails/default-template.d.ts +3 -3
- package/dist/src/emails/default-template.d.ts.map +1 -1
- package/dist/src/emails/default-template.js +39 -38
- package/dist/src/emails/reset-password.d.ts +1 -1
- package/dist/src/emails/reset-password.d.ts.map +1 -1
- package/dist/src/emails/reset-password.js +51 -51
- package/dist/src/emails/ui/button.d.ts +2 -2
- package/dist/src/emails/ui/button.js +13 -13
- package/dist/src/emails/ui/card.d.ts +1 -1
- package/dist/src/emails/ui/card.js +6 -6
- package/dist/src/hooks/use-before-unload.js +3 -3
- package/dist/src/hooks/use-captcha.d.ts +2 -2
- package/dist/src/hooks/use-captcha.d.ts.map +1 -1
- package/dist/src/hooks/use-captcha.js +29 -37
- package/dist/src/hooks/use-mobile.d.ts.map +1 -1
- package/dist/src/hooks/use-mobile.js +3 -4
- package/dist/src/lib/api/get-middleware-api.js +4 -4
- package/dist/src/lib/api/get-session-admin-api.js +5 -5
- package/dist/src/lib/api/get-session-api.js +4 -4
- package/dist/src/lib/colors.js +28 -19
- package/dist/src/lib/colors.test.js +60 -60
- package/dist/src/lib/config.js +3 -3
- package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts.map +1 -1
- package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -1
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +27 -27
- package/dist/src/lib/fetcher/core.d.ts +5 -5
- package/dist/src/lib/fetcher/core.d.ts.map +1 -1
- package/dist/src/lib/fetcher/core.js +11 -10
- package/dist/src/lib/fetcher/helpers-server.d.ts +1 -1
- package/dist/src/lib/fetcher/helpers-server.js +1 -1
- package/dist/src/lib/fetcher/helpers.test.js +17 -17
- package/dist/src/lib/fetcher/types.d.ts +26 -26
- package/dist/src/lib/fetcher/types.d.ts.map +1 -1
- package/dist/src/lib/fetcher-client.d.ts +4 -4
- package/dist/src/lib/fetcher-client.d.ts.map +1 -1
- package/dist/src/lib/fetcher-client.js +3 -3
- package/dist/src/lib/fetcher.d.ts +5 -5
- package/dist/src/lib/fetcher.d.ts.map +1 -1
- package/dist/src/lib/fetcher.js +4 -4
- package/dist/src/lib/helpers/auto-form.d.ts +3 -3
- package/dist/src/lib/helpers/auto-form.d.ts.map +1 -1
- package/dist/src/lib/helpers/auto-form.js +16 -15
- package/dist/src/lib/helpers/auto-form.test.js +129 -129
- package/dist/src/lib/navigation.d.ts +2 -2
- package/dist/src/lib/navigation.d.ts.map +1 -1
- package/dist/src/lib/plugin.d.ts +3 -3
- package/dist/src/lib/special-characters.js +1 -1
- package/dist/src/lib/special-characters.test.js +36 -36
- package/dist/src/lib/utils.d.ts +1 -1
- package/dist/src/tests/setup.d.ts +1 -1
- package/dist/src/views/admin/layouts/admin-layout.d.ts +1 -1
- package/dist/src/views/admin/layouts/admin-layout.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/admin-layout.js +4 -8
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +11 -12
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +11 -11
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts +1 -1
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -2
- package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -1
- package/dist/src/views/admin/layouts/user-bar/client.js +5 -5
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts +1 -1
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -1
- package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -1
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +3 -3
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +10 -10
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +2 -2
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +15 -15
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +7 -7
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +7 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +3 -3
- package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +25 -25
- package/dist/src/views/admin/views/core/test.js +43 -43
- package/dist/src/views/admin/views/core/users/users-admin-view.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/users/users-admin-view.js +13 -14
- package/dist/src/views/auth/password-reset/change-password-form/form.js +9 -9
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +5 -5
- package/dist/src/views/auth/password-reset/change-password-form/use-form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/change-password-form/use-form.d.ts.map +1 -1
- package/dist/src/views/auth/password-reset/change-password-form/use-form.js +7 -7
- package/dist/src/views/auth/password-reset/form/form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/form/form.d.ts.map +1 -1
- package/dist/src/views/auth/password-reset/form/form.js +15 -15
- package/dist/src/views/auth/password-reset/form/mutation-api.js +5 -5
- package/dist/src/views/auth/password-reset/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/form/use-form.js +7 -7
- package/dist/src/views/auth/password-reset/password-reset-view.js +4 -4
- package/dist/src/views/auth/sign-in/form/form.js +9 -9
- package/dist/src/views/auth/sign-in/form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/sign-in/form/mutation-api.d.ts.map +1 -1
- package/dist/src/views/auth/sign-in/form/mutation-api.js +10 -10
- package/dist/src/views/auth/sign-in/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/sign-in/form/use-form.js +11 -11
- package/dist/src/views/auth/sign-in/sign-in-view.js +5 -5
- package/dist/src/views/auth/sign-up/components/password-input.d.ts +3 -3
- package/dist/src/views/auth/sign-up/components/password-input.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/components/password-input.js +9 -10
- package/dist/src/views/auth/sign-up/email-confirmation-view.js +4 -4
- package/dist/src/views/auth/sign-up/form/form.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/form.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/form/form.js +18 -18
- package/dist/src/views/auth/sign-up/form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/mutation-api.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/form/mutation-api.js +6 -6
- package/dist/src/views/auth/sign-up/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/use-form.js +21 -21
- package/dist/src/views/auth/sign-up/sign-up-view.js +5 -5
- package/dist/src/views/auth/sign-up/wrapper.d.ts +1 -1
- package/dist/src/views/auth/sign-up/wrapper.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/wrapper.js +5 -8
- package/dist/src/views/auth/sso/buttons/client.js +4 -4
- package/dist/src/views/auth/sso/buttons/mutation-api.js +5 -5
- package/dist/src/views/auth/sso/buttons/sso-buttons.js +2 -2
- package/dist/src/views/auth/sso/callback/callback-sso-view.js +6 -6
- package/dist/src/views/auth/sso/callback/client/client.d.ts +1 -1
- package/dist/src/views/auth/sso/callback/client/client.d.ts.map +1 -1
- package/dist/src/views/auth/sso/callback/client/client.js +9 -9
- package/dist/src/views/auth/sso/callback/client/mutation-api.js +7 -7
- package/dist/src/views/error/back-button.js +1 -1
- package/dist/src/views/error/error-view.js +4 -4
- package/dist/src/views/error/global-error-view.d.ts +3 -3
- package/dist/src/views/error/global-error-view.d.ts.map +1 -1
- package/dist/src/views/error/global-error-view.js +36 -44
- package/dist/src/views/layouts/provider.d.ts +4 -4
- package/dist/src/views/layouts/provider.d.ts.map +1 -1
- package/dist/src/views/layouts/provider.js +3 -3
- package/dist/src/views/layouts/root-layout.d.ts +3 -3
- package/dist/src/views/layouts/root-layout.d.ts.map +1 -1
- package/dist/src/views/layouts/root-layout.js +1 -2
- package/dist/src/views/layouts/theme/header/header.d.ts +2 -2
- package/dist/src/views/layouts/theme/header/header.d.ts.map +1 -1
- package/dist/src/views/layouts/theme/header/header.js +1 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts +1 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts.map +1 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.js +4 -4
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +8 -8
- package/dist/src/views/layouts/theme/header/user/user.js +4 -4
- package/dist/src/views/layouts/theme/layout.d.ts +2 -2
- package/dist/src/views/layouts/theme/layout.js +1 -1
- package/dist/src/vitnode.config.d.ts +16 -16
- package/dist/src/vitnode.config.d.ts.map +1 -1
- package/dist/src/vitnode.config.js +3 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -5
- package/src/app/login/page.tsx +5 -5
- package/src/app/login/reset-password/page.tsx +5 -5
- package/src/app/login/sso/[providerId]/page.tsx +1 -1
- package/src/app/register/page.tsx +5 -5
- package/src/app_admin/core/debug/page.tsx +14 -14
- package/src/app_admin/core/page.tsx +1 -1
- package/src/app_admin/core/test/page.tsx +1 -1
- package/src/app_admin/core/users/page.tsx +12 -13
|
@@ -4,25 +4,26 @@ import { SessionModel } from "../models/session.js";
|
|
|
4
4
|
import { SessionAdminModel } from "../models/session-admin.js";
|
|
5
5
|
import { loggerMiddleware } from "../lib/logger-middleware.js";
|
|
6
6
|
export const globalMiddleware = ({ authorization, metadata, email, dbProvider, captcha, plugins, pathToMessages })=>{
|
|
7
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <needed>
|
|
7
8
|
return async (c, next)=>{
|
|
8
9
|
// Collect possible IP header keys in order of trust/preference
|
|
9
10
|
const ipHeaderKeys = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
"x-forwarded-for",
|
|
12
|
+
"x-real-ip",
|
|
13
|
+
"cf-connecting-ip",
|
|
14
|
+
"x-client-ip",
|
|
15
|
+
"x-forwarded",
|
|
16
|
+
"x-cluster-client-ip",
|
|
17
|
+
"forwarded-for",
|
|
18
|
+
"forwarded",
|
|
19
|
+
"via",
|
|
20
|
+
"remote-addr",
|
|
21
|
+
"client-ip",
|
|
22
|
+
"ip",
|
|
23
|
+
"x-ip",
|
|
24
|
+
"true-client-ip",
|
|
25
|
+
"fastly-client-ip",
|
|
26
|
+
"x-fastly-client-ip"
|
|
26
27
|
];
|
|
27
28
|
let ipAddress;
|
|
28
29
|
// Try to get IP from Hono's request header method first
|
|
@@ -44,20 +45,20 @@ export const globalMiddleware = ({ authorization, metadata, email, dbProvider, c
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
// Fallback to localhost if nothing found
|
|
47
|
-
c.set(
|
|
48
|
-
c.set(
|
|
49
|
-
c.set(
|
|
50
|
-
c.set(
|
|
48
|
+
c.set("ipAddress", ipAddress ?? "127.0.0.1");
|
|
49
|
+
c.set("db", dbProvider);
|
|
50
|
+
c.set("email", new EmailModel(c));
|
|
51
|
+
c.set("core", {
|
|
51
52
|
pathToMessages,
|
|
52
53
|
metadata,
|
|
53
54
|
email,
|
|
54
55
|
authorization: {
|
|
55
|
-
cookieName: authorization?.cookieName ??
|
|
56
|
+
cookieName: authorization?.cookieName ?? "vitnode_auth",
|
|
56
57
|
cookie_expires: authorization?.cookieExpires ?? 1000 * 60 * 60 * 24 * 90,
|
|
57
58
|
ssoAdapters: authorization?.ssoAdapters ?? [],
|
|
58
|
-
deviceCookieName: authorization?.deviceCookieName ??
|
|
59
|
+
deviceCookieName: authorization?.deviceCookieName ?? "vitnode_device",
|
|
59
60
|
deviceCookieExpires: authorization?.deviceCookieExpires ?? 1000 * 60 * 60 * 24 * 365,
|
|
60
|
-
adminCookieName: authorization?.adminCookieName ??
|
|
61
|
+
adminCookieName: authorization?.adminCookieName ?? "vitnode_auth_admin",
|
|
61
62
|
adminCookieExpires: authorization?.adminCookieExpires ?? 1000 * 60 * 60 * 24 * 1,
|
|
62
63
|
cookieSecure: authorization?.cookieSecure ?? true
|
|
63
64
|
},
|
|
@@ -67,15 +68,15 @@ export const globalMiddleware = ({ authorization, metadata, email, dbProvider, c
|
|
|
67
68
|
}))
|
|
68
69
|
});
|
|
69
70
|
const user = await new SessionModel(c).getUser();
|
|
70
|
-
c.set(
|
|
71
|
-
c.set(
|
|
72
|
-
c.set(
|
|
71
|
+
c.set("user", user);
|
|
72
|
+
c.set("admin", null);
|
|
73
|
+
c.set("log", loggerMiddleware(c));
|
|
73
74
|
await next();
|
|
74
75
|
};
|
|
75
76
|
};
|
|
76
77
|
export const pluginMiddleware = (pluginId)=>{
|
|
77
78
|
return async (c, next)=>{
|
|
78
|
-
c.set(
|
|
79
|
+
c.set("plugin", {
|
|
79
80
|
id: pluginId
|
|
80
81
|
});
|
|
81
82
|
await next();
|
|
@@ -85,7 +86,7 @@ export const globalAdminMiddleware = ()=>{
|
|
|
85
86
|
return async (c, next)=>{
|
|
86
87
|
const user = await new SessionAdminModel(c).getUser();
|
|
87
88
|
if (!user) throw new HTTPException(403);
|
|
88
|
-
c.set(
|
|
89
|
+
c.set("admin", {
|
|
89
90
|
user
|
|
90
91
|
});
|
|
91
92
|
await next();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context, Next } from
|
|
2
|
-
import { type IRateLimiterOptions } from
|
|
3
|
-
export declare const rateLimiterMiddleware: (options?: Omit<IRateLimiterOptions, "keyPrefix">) => ((
|
|
1
|
+
import type { Context, Next } from "hono";
|
|
2
|
+
import { type IRateLimiterOptions } from "rate-limiter-flexible";
|
|
3
|
+
export declare const rateLimiterMiddleware: (options?: Omit<IRateLimiterOptions, "keyPrefix">) => ((_c: Context, next: Next) => Promise<void>) | ((c: Context, next: Next) => Promise<(Response & import("hono").TypedResponse<"Too Many Requests", 429, "text">) | undefined>);
|
|
4
4
|
//# sourceMappingURL=rate-limiter.middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limiter.middleware.d.ts","sourceRoot":"","sources":["../../../../src/api/middlewares/rate-limiter.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,uBAAuB,CAAC;AAoB/B,eAAO,MAAM,qBAAqB,GAChC,UAAU,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"rate-limiter.middleware.d.ts","sourceRoot":"","sources":["../../../../src/api/middlewares/rate-limiter.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,uBAAuB,CAAC;AAoB/B,eAAO,MAAM,qBAAqB,GAChC,UAAU,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,WAI5B,OAAO,QAAQ,IAAI,2BAUtB,OAAO,QAAQ,IAAI,sGAWrC,CAAC"}
|
|
@@ -12,20 +12,20 @@ const createRateLimiter = ({ keyPrefix, ...options })=>{
|
|
|
12
12
|
export const rateLimiterMiddleware = (options)=>{
|
|
13
13
|
if (CONFIG.node_development) {
|
|
14
14
|
// In development, we disable the rate limiter for easier testing
|
|
15
|
-
return async (
|
|
15
|
+
return async (_c, next)=>{
|
|
16
16
|
await next();
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
const rateLimiter = createRateLimiter({
|
|
20
20
|
...options,
|
|
21
|
-
keyPrefix:
|
|
21
|
+
keyPrefix: "vitnode-api-rate-limiter"
|
|
22
22
|
});
|
|
23
23
|
return async (c, next)=>{
|
|
24
|
-
const key = c.get(
|
|
24
|
+
const key = c.get("ipAddress");
|
|
25
25
|
try {
|
|
26
26
|
await rateLimiter.consume(key);
|
|
27
27
|
} catch {
|
|
28
|
-
return c.text(
|
|
28
|
+
return c.text("Too Many Requests", 429);
|
|
29
29
|
}
|
|
30
30
|
await next();
|
|
31
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../../src/api/models/device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../../src/api/models/device.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAMpC,qBAAa,WAAW;gBACV,CAAC,EAAE,OAAO;IAGtB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;YAEhB,YAAY;IAkB1B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAiBjB,WAAW;;;;CAwClB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomBytes } from "crypto";
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
2
|
import { eq } from "drizzle-orm";
|
|
3
3
|
import { getCookie, setCookie } from "hono/cookie";
|
|
4
4
|
import { core_sessions_known_devices } from "../../database/sessions.js";
|
|
@@ -9,10 +9,10 @@ export class DeviceModel {
|
|
|
9
9
|
}
|
|
10
10
|
c;
|
|
11
11
|
async createDevice() {
|
|
12
|
-
const publicId = randomBytes(16).toString(
|
|
13
|
-
const [device] = await this.c.get(
|
|
12
|
+
const publicId = randomBytes(16).toString("hex");
|
|
13
|
+
const [device] = await this.c.get("db").insert(core_sessions_known_devices).values({
|
|
14
14
|
publicId,
|
|
15
|
-
ipAddress: this.c.get(
|
|
15
|
+
ipAddress: this.c.get("ipAddress"),
|
|
16
16
|
userAgent: this.getUserAgent()
|
|
17
17
|
}).returning({
|
|
18
18
|
id: core_sessions_known_devices.id
|
|
@@ -24,29 +24,29 @@ export class DeviceModel {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
getUserAgent() {
|
|
27
|
-
return this.c.req.header(
|
|
27
|
+
return this.c.req.header("User-Agent") ?? "node";
|
|
28
28
|
}
|
|
29
29
|
setCookieDevice(publicDeviceId) {
|
|
30
|
-
setCookie(this.c, this.c.get(
|
|
30
|
+
setCookie(this.c, this.c.get("core").authorization.deviceCookieName, publicDeviceId, {
|
|
31
31
|
httpOnly: true,
|
|
32
|
-
secure: this.c.get(
|
|
33
|
-
path:
|
|
32
|
+
secure: this.c.get("core").authorization.cookieSecure,
|
|
33
|
+
path: "/",
|
|
34
34
|
domain: CONFIG.web.hostname,
|
|
35
|
-
expires: new Date(Date.now() + this.c.get(
|
|
35
|
+
expires: new Date(Date.now() + this.c.get("core").authorization.deviceCookieExpires)
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
async getDeviceId() {
|
|
39
|
-
const deviceIdFromCookie = getCookie(this.c, this.c.get(
|
|
39
|
+
const deviceIdFromCookie = getCookie(this.c, this.c.get("core").authorization.deviceCookieName);
|
|
40
40
|
try {
|
|
41
41
|
if (deviceIdFromCookie) {
|
|
42
|
-
const [device] = await this.c.get(
|
|
42
|
+
const [device] = await this.c.get("db").select({
|
|
43
43
|
id: core_sessions_known_devices.id
|
|
44
44
|
}).from(core_sessions_known_devices).where(eq(core_sessions_known_devices.publicId, deviceIdFromCookie));
|
|
45
45
|
if (!device) {
|
|
46
46
|
return await this.createDevice();
|
|
47
47
|
}
|
|
48
|
-
await this.c.get(
|
|
49
|
-
ipAddress: this.c.get(
|
|
48
|
+
await this.c.get("db").update(core_sessions_known_devices).set({
|
|
49
|
+
ipAddress: this.c.get("ipAddress"),
|
|
50
50
|
userAgent: this.getUserAgent()
|
|
51
51
|
}).where(eq(core_sessions_known_devices.publicId, deviceIdFromCookie));
|
|
52
52
|
return {
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import type { Context, ContextVariableMap } from
|
|
2
|
-
import type React from
|
|
3
|
-
import {
|
|
4
|
-
export interface EmailApiPlugin {
|
|
5
|
-
sendEmail: (args: {
|
|
6
|
-
html: string;
|
|
7
|
-
metadata: ContextVariableMap['core']['metadata'];
|
|
8
|
-
replyTo?: string;
|
|
9
|
-
subject: string;
|
|
10
|
-
text: string;
|
|
11
|
-
to: string;
|
|
12
|
-
}) => Promise<void>;
|
|
13
|
-
}
|
|
1
|
+
import type { Context, ContextVariableMap } from "hono";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { DefaultTemplateEmailProps } from "../../emails/default-template";
|
|
14
4
|
interface EmailModelSendArgsWithUser {
|
|
15
5
|
locale?: never;
|
|
16
6
|
to?: never;
|
|
@@ -27,12 +17,22 @@ interface EmailModelSendArgsWithEmail {
|
|
|
27
17
|
to: string;
|
|
28
18
|
user?: never;
|
|
29
19
|
}
|
|
20
|
+
export interface EmailApiPlugin {
|
|
21
|
+
sendEmail: (args: {
|
|
22
|
+
html: string;
|
|
23
|
+
metadata: ContextVariableMap["core"]["metadata"];
|
|
24
|
+
replyTo?: string;
|
|
25
|
+
subject: string;
|
|
26
|
+
text: string;
|
|
27
|
+
to: string;
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
}
|
|
30
30
|
export type EmailModelSendArgs = {
|
|
31
|
-
content: (props: Omit<DefaultTemplateEmailProps,
|
|
31
|
+
content: (props: Omit<DefaultTemplateEmailProps, "children"> & Pick<EmailModelSendArgs, "user">) => React.ReactNode;
|
|
32
32
|
html?: string;
|
|
33
33
|
locale?: string;
|
|
34
34
|
replyTo?: string;
|
|
35
|
-
subject: ((props: Pick<DefaultTemplateEmailProps,
|
|
35
|
+
subject: ((props: Pick<DefaultTemplateEmailProps, "i18n">) => string) | string;
|
|
36
36
|
} & (EmailModelSendArgsWithEmail | EmailModelSendArgsWithUser);
|
|
37
37
|
export declare class EmailModel {
|
|
38
38
|
constructor(c: Context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../../src/api/models/email.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../../src/api/models/email.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAExD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAG/E,UAAU,0BAA0B;IAClC,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,EAAE,CAAC,EAAE,KAAK,CAAC;IACX,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,UAAU,2BAA2B;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,CAAC,IAAI,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;QACjD,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;KACZ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,CACP,KAAK,EAAE,IAAI,CAAC,yBAAyB,EAAE,UAAU,CAAC,GAChD,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,KAC/B,KAAK,CAAC,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EACH,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GAC5D,MAAM,CAAC;CACZ,GAAG,CAAC,2BAA2B,GAAG,0BAA0B,CAAC,CAAC;AAE/D,qBAAa,UAAU;gBACT,CAAC,EAAE,OAAO;IAItB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IAExB,IAAI,CAAC,EACT,IAAI,EACJ,OAAO,EACP,OAAO,EACP,EAAE,EACF,IAAI,EACJ,OAAO,EACP,MAAM,EAAE,cAAc,GACvB,EAAE,kBAAkB;CAgFtB"}
|
|
@@ -7,17 +7,17 @@ export class EmailModel {
|
|
|
7
7
|
}
|
|
8
8
|
c;
|
|
9
9
|
async send({ html, replyTo, subject, to, user, content, locale: localeFromArgs }) {
|
|
10
|
-
const core = this.c.get(
|
|
10
|
+
const core = this.c.get("core");
|
|
11
11
|
const provider = core.email?.adapter;
|
|
12
12
|
if (!provider) {
|
|
13
13
|
throw new HTTPException(500, {
|
|
14
|
-
message:
|
|
14
|
+
message: "Email provider not found"
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
const locale = localeFromArgs ?? user?.language ??
|
|
17
|
+
const locale = localeFromArgs ?? user?.language ?? "en";
|
|
18
18
|
const pluginIds = [
|
|
19
|
-
|
|
20
|
-
...this.c.get(
|
|
19
|
+
"@vitnode/core",
|
|
20
|
+
...this.c.get("core").plugins.map((plugin)=>plugin.id)
|
|
21
21
|
];
|
|
22
22
|
const messagesPromises = pluginIds.map(async (pluginId)=>{
|
|
23
23
|
try {
|
|
@@ -29,7 +29,8 @@ export class EmailModel {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const allMessages = await Promise.all(messagesPromises);
|
|
32
|
-
const messages = allMessages.reduce(
|
|
32
|
+
const messages = allMessages.reduce(// biome-ignore lint/performance/noAccumulatingSpread: <needed>
|
|
33
|
+
(acc, curr)=>({
|
|
33
34
|
...acc,
|
|
34
35
|
...curr
|
|
35
36
|
}), {});
|
|
@@ -50,14 +51,14 @@ export class EmailModel {
|
|
|
50
51
|
const emailTo = user?.email ?? to;
|
|
51
52
|
if (!emailTo) {
|
|
52
53
|
throw new HTTPException(400, {
|
|
53
|
-
message:
|
|
54
|
+
message: "Email address is required"
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
try {
|
|
57
58
|
await provider.sendEmail({
|
|
58
59
|
html: await render(htmlContent),
|
|
59
60
|
to: emailTo,
|
|
60
|
-
subject: typeof subject ===
|
|
61
|
+
subject: typeof subject === "function" ? subject({
|
|
61
62
|
i18n: {
|
|
62
63
|
locale,
|
|
63
64
|
messages
|
|
@@ -70,8 +71,8 @@ export class EmailModel {
|
|
|
70
71
|
})
|
|
71
72
|
});
|
|
72
73
|
} catch (err) {
|
|
73
|
-
const error = err instanceof Error ? err : new Error(
|
|
74
|
-
await this.c.get(
|
|
74
|
+
const error = err instanceof Error ? err : new Error("Unknown error from email provider");
|
|
75
|
+
await this.c.get("log").error(`Failed to send email: ${error.message}`);
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
2
|
export class PasswordModel {
|
|
3
3
|
async encryptPassword(password) {
|
|
4
|
-
return new Promise((resolve, reject)=>{
|
|
5
|
-
const salt = crypto.randomBytes(8).toString(
|
|
4
|
+
return await new Promise((resolve, reject)=>{
|
|
5
|
+
const salt = crypto.randomBytes(8).toString("hex");
|
|
6
6
|
crypto.scrypt(password, salt, 64, (err, derivedKey)=>{
|
|
7
7
|
if (err) reject(err);
|
|
8
|
-
resolve(salt
|
|
8
|
+
resolve(`${salt}:${derivedKey.toString("hex")}`);
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
async verifyPassword(password, hash) {
|
|
13
|
-
return new Promise((resolve, reject)=>{
|
|
14
|
-
const [salt, key] = hash.split(
|
|
15
|
-
const keyBuffer = Buffer.from(key,
|
|
13
|
+
return await new Promise((resolve, reject)=>{
|
|
14
|
+
const [salt, key] = hash.split(":");
|
|
15
|
+
const keyBuffer = Buffer.from(key, "hex");
|
|
16
16
|
crypto.scrypt(password, salt, 64, (err, derivedKey)=>{
|
|
17
17
|
if (err) reject(err);
|
|
18
18
|
if (keyBuffer.length !== derivedKey.length) {
|
|
@@ -28,9 +28,9 @@ export class PasswordModel {
|
|
|
28
28
|
}
|
|
29
29
|
export class ForgotPasswordTokenModel {
|
|
30
30
|
generateResetToken() {
|
|
31
|
-
return crypto.randomBytes(32).toString(
|
|
31
|
+
return crypto.randomBytes(32).toString("base64url");
|
|
32
32
|
}
|
|
33
33
|
hashResetToken(token) {
|
|
34
|
-
return crypto.createHash(
|
|
34
|
+
return crypto.createHash("sha256").update(token).digest("hex");
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-admin.d.ts","sourceRoot":"","sources":["../../../../src/api/models/session-admin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-admin.d.ts","sourceRoot":"","sources":["../../../../src/api/models/session-admin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAUpC,qBAAa,iBAAiB;gBAChB,CAAC,EAAE,OAAO;IAGtB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;YAEhB,SAAS;IASjB,kBAAkB,CAAC,MAAM,EAAE,MAAM;IAmBjC,qBAAqB,CAAC,MAAM,EAAE,MAAM;;;IAwCpC,aAAa;IAoBb,OAAO;;;;;;;;;;;;;CAiDd"}
|
|
@@ -13,9 +13,9 @@ export class SessionAdminModel {
|
|
|
13
13
|
async hashToken(token) {
|
|
14
14
|
const encoder = new TextEncoder();
|
|
15
15
|
const data = encoder.encode(token);
|
|
16
|
-
const hashBuffer = await crypto.subtle.digest(
|
|
16
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
17
17
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
18
|
-
return hashArray.map((b)=>b.toString(16).padStart(2,
|
|
18
|
+
return hashArray.map((b)=>b.toString(16).padStart(2, "0")).join("");
|
|
19
19
|
}
|
|
20
20
|
async checkIfUserIsAdmin(userId) {
|
|
21
21
|
const user = await new UserModel().getUserById({
|
|
@@ -23,32 +23,32 @@ export class SessionAdminModel {
|
|
|
23
23
|
c: this.c
|
|
24
24
|
});
|
|
25
25
|
if (!user) return false;
|
|
26
|
-
const [permission] = await this.c.get(
|
|
26
|
+
const [permission] = await this.c.get("db").select().from(core_admin_permissions).where(or(eq(core_admin_permissions.userId, user.id), eq(core_admin_permissions.roleId, user.roleId))).limit(1);
|
|
27
27
|
return !!permission;
|
|
28
28
|
}
|
|
29
29
|
async createSessionByUserId(userId) {
|
|
30
30
|
const isAdmin = await this.checkIfUserIsAdmin(userId);
|
|
31
31
|
if (!isAdmin) {
|
|
32
32
|
throw new HTTPException(403, {
|
|
33
|
-
message:
|
|
33
|
+
message: "Forbidden"
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
const randomBytes = new Uint8Array(64);
|
|
37
37
|
crypto.getRandomValues(randomBytes);
|
|
38
|
-
const token = Array.from(randomBytes).map((b)=>b.toString(16).padStart(2,
|
|
38
|
+
const token = Array.from(randomBytes).map((b)=>b.toString(16).padStart(2, "0")).join("");
|
|
39
39
|
const hashedToken = await this.hashToken(token);
|
|
40
40
|
const device = await new DeviceModel(this.c).getDeviceId();
|
|
41
|
-
await this.c.get(
|
|
41
|
+
await this.c.get("db").insert(core_admin_sessions).values({
|
|
42
42
|
token: hashedToken,
|
|
43
43
|
userId,
|
|
44
|
-
expiresAt: new Date(Date.now() + this.c.get(
|
|
44
|
+
expiresAt: new Date(Date.now() + this.c.get("core").authorization.adminCookieExpires),
|
|
45
45
|
deviceId: device.id
|
|
46
46
|
});
|
|
47
|
-
setCookie(this.c, this.c.get(
|
|
47
|
+
setCookie(this.c, this.c.get("core").authorization.adminCookieName, token, {
|
|
48
48
|
httpOnly: true,
|
|
49
|
-
secure: this.c.get(
|
|
50
|
-
path:
|
|
51
|
-
expires: new Date(Date.now() + this.c.get(
|
|
49
|
+
secure: this.c.get("core").authorization.cookieSecure,
|
|
50
|
+
path: "/",
|
|
51
|
+
expires: new Date(Date.now() + this.c.get("core").authorization.adminCookieExpires),
|
|
52
52
|
domain: CONFIG.web.hostname
|
|
53
53
|
});
|
|
54
54
|
return {
|
|
@@ -56,28 +56,28 @@ export class SessionAdminModel {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
async deleteSession() {
|
|
59
|
-
const token = getCookie(this.c, this.c.get(
|
|
59
|
+
const token = getCookie(this.c, this.c.get("core").authorization.adminCookieName);
|
|
60
60
|
if (!token) return;
|
|
61
61
|
const hashedToken = await this.hashToken(token);
|
|
62
|
-
await this.c.get(
|
|
63
|
-
deleteCookie(this.c, this.c.get(
|
|
64
|
-
path:
|
|
62
|
+
await this.c.get("db").delete(core_admin_sessions).where(eq(core_admin_sessions.token, hashedToken));
|
|
63
|
+
deleteCookie(this.c, this.c.get("core").authorization.adminCookieName, {
|
|
64
|
+
path: "/",
|
|
65
65
|
domain: CONFIG.web.hostname
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
async getUser() {
|
|
69
|
-
const { authorization } = this.c.get(
|
|
69
|
+
const { authorization } = this.c.get("core");
|
|
70
70
|
const token = getCookie(this.c, authorization.adminCookieName);
|
|
71
71
|
if (!token) return null;
|
|
72
72
|
const device = await new DeviceModel(this.c).getDeviceId();
|
|
73
73
|
if (!device) return null;
|
|
74
74
|
const hashedToken = await this.hashToken(token);
|
|
75
|
-
const [session] = await this.c.get(
|
|
75
|
+
const [session] = await this.c.get("db").select({
|
|
76
76
|
userId: core_admin_sessions.userId
|
|
77
77
|
}).from(core_admin_sessions).where(and(eq(core_admin_sessions.token, hashedToken), eq(core_admin_sessions.deviceId, device.id), gt(core_admin_sessions.expiresAt, new Date()))).limit(1);
|
|
78
78
|
if (!session) {
|
|
79
|
-
deleteCookie(this.c, this.c.get(
|
|
80
|
-
path:
|
|
79
|
+
deleteCookie(this.c, this.c.get("core").authorization.adminCookieName, {
|
|
80
|
+
path: "/",
|
|
81
81
|
domain: CONFIG.web.hostname
|
|
82
82
|
});
|
|
83
83
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/api/models/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/api/models/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AASpC,qBAAa,YAAY;gBACX,CAAC,EAAE,OAAO;IAGtB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;YAEhB,SAAS;IASjB,qBAAqB,CAAC,MAAM,EAAE,MAAM;;;IAsCpC,aAAa;IA8Bb,OAAO;;;;;;;;;;;;;CA0Cd"}
|
|
@@ -12,28 +12,28 @@ export class SessionModel {
|
|
|
12
12
|
async hashToken(token) {
|
|
13
13
|
const encoder = new TextEncoder();
|
|
14
14
|
const data = encoder.encode(token);
|
|
15
|
-
const hashBuffer = await crypto.subtle.digest(
|
|
15
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
16
16
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
17
|
-
return hashArray.map((b)=>b.toString(16).padStart(2,
|
|
17
|
+
return hashArray.map((b)=>b.toString(16).padStart(2, "0")).join("");
|
|
18
18
|
}
|
|
19
19
|
async createSessionByUserId(userId) {
|
|
20
20
|
// Generate secure random bytes using Web Crypto API
|
|
21
21
|
const randomBytes = new Uint8Array(64);
|
|
22
22
|
crypto.getRandomValues(randomBytes);
|
|
23
|
-
const token = Array.from(randomBytes).map((b)=>b.toString(16).padStart(2,
|
|
23
|
+
const token = Array.from(randomBytes).map((b)=>b.toString(16).padStart(2, "0")).join("");
|
|
24
24
|
const device = await new DeviceModel(this.c).getDeviceId();
|
|
25
25
|
const hashedToken = await this.hashToken(token);
|
|
26
|
-
await this.c.get(
|
|
26
|
+
await this.c.get("db").insert(core_sessions).values({
|
|
27
27
|
token: hashedToken,
|
|
28
28
|
userId,
|
|
29
|
-
expiresAt: new Date(Date.now() + this.c.get(
|
|
29
|
+
expiresAt: new Date(Date.now() + this.c.get("core").authorization.cookie_expires),
|
|
30
30
|
deviceId: device.id
|
|
31
31
|
});
|
|
32
|
-
setCookie(this.c, this.c.get(
|
|
32
|
+
setCookie(this.c, this.c.get("core").authorization.cookieName, token, {
|
|
33
33
|
httpOnly: true,
|
|
34
|
-
secure: this.c.get(
|
|
35
|
-
path:
|
|
36
|
-
expires: this.c.get(
|
|
34
|
+
secure: this.c.get("core").authorization.cookieSecure,
|
|
35
|
+
path: "/",
|
|
36
|
+
expires: this.c.get("core").authorization.cookie_expires > 0 ? new Date(Date.now() + this.c.get("core").authorization.cookie_expires) : undefined,
|
|
37
37
|
domain: CONFIG.web.hostname
|
|
38
38
|
});
|
|
39
39
|
return {
|
|
@@ -41,29 +41,29 @@ export class SessionModel {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
async deleteSession() {
|
|
44
|
-
const token = getCookie(this.c, this.c.get(
|
|
44
|
+
const token = getCookie(this.c, this.c.get("core").authorization.cookieName);
|
|
45
45
|
const device = await new DeviceModel(this.c).getDeviceId();
|
|
46
46
|
// Ensure both token and deviceId exist before proceeding
|
|
47
|
-
if (!token
|
|
48
|
-
deleteCookie(this.c, this.c.get(
|
|
47
|
+
if (!(token && device.id)) {
|
|
48
|
+
deleteCookie(this.c, this.c.get("core").authorization.cookieName);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
const hashedToken = await this.hashToken(token);
|
|
52
|
-
await this.c.get(
|
|
52
|
+
await this.c.get("db").delete(core_sessions)// Harden the query to ensure a user can only delete their own device's session
|
|
53
53
|
.where(and(eq(core_sessions.token, hashedToken), eq(core_sessions.deviceId, device.id)));
|
|
54
|
-
deleteCookie(this.c, this.c.get(
|
|
54
|
+
deleteCookie(this.c, this.c.get("core").authorization.cookieName);
|
|
55
55
|
}
|
|
56
56
|
async getUser() {
|
|
57
|
-
const token = getCookie(this.c, this.c.get(
|
|
57
|
+
const token = getCookie(this.c, this.c.get("core").authorization.cookieName);
|
|
58
58
|
if (!token) return null;
|
|
59
59
|
const device = await new DeviceModel(this.c).getDeviceId();
|
|
60
60
|
if (!device) return null;
|
|
61
61
|
const hashedToken = await this.hashToken(token);
|
|
62
|
-
const [session] = await this.c.get(
|
|
62
|
+
const [session] = await this.c.get("db").select({
|
|
63
63
|
userId: core_sessions.userId
|
|
64
64
|
}).from(core_sessions).where(and(eq(core_sessions.token, hashedToken), eq(core_sessions.deviceId, device.id), gt(core_sessions.expiresAt, new Date()))).limit(1);
|
|
65
65
|
if (!session) {
|
|
66
|
-
deleteCookie(this.c, this.c.get(
|
|
66
|
+
deleteCookie(this.c, this.c.get("core").authorization.cookieName);
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
69
|
const user = await new UserModel().getUserById({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sso.d.ts","sourceRoot":"","sources":["../../../../src/api/models/sso.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sso.d.ts","sourceRoot":"","sources":["../../../../src/api/models/sso.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAUpC,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,CACV,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,SAAS,EAAE,CAAC,IAAI,EAAE;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/D,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,WACgB,CAAC;AAE5D,qBAAa,QAAQ;gBACP,CAAC,EAAE,OAAO;IAKtB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAU;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IAEzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CA6BzB;IAEI,QAAQ,CAAC,EACb,IAAI,EACJ,UAAU,EACV,KAAK,GACN,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC;QACV,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IA8DI,YAAY;IA2BZ,MAAM,CAAC,UAAU,EAAE,MAAM;IASzB,WAAW,CAAC,KAAK,EAAE,MAAM;CA+BhC"}
|