@vitnode/core 1.2.0-canary.10 → 1.2.0-canary.11
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 +16 -0
- package/package.json +19 -2
- package/dist/emails/my-email.d.ts +0 -2
- package/dist/emails/my-email.d.ts.map +0 -1
- package/dist/scripts/get-config.d.ts +0 -3
- package/dist/scripts/get-config.d.ts.map +0 -1
- package/dist/scripts/plugin.d.ts +0 -4
- package/dist/scripts/plugin.d.ts.map +0 -1
- package/dist/scripts/prepare-database.d.ts +0 -7
- package/dist/scripts/prepare-database.d.ts.map +0 -1
- package/dist/scripts/prepare-plugins-files.d.ts +0 -2
- package/dist/scripts/prepare-plugins-files.d.ts.map +0 -1
- package/dist/scripts/run-interactive-shell-command.d.ts +0 -2
- package/dist/scripts/run-interactive-shell-command.d.ts.map +0 -1
- package/dist/scripts/scripts.d.ts +0 -3
- package/dist/scripts/scripts.d.ts.map +0 -1
- package/dist/scripts/shared/file-utils.d.ts +0 -14
- package/dist/scripts/shared/file-utils.d.ts.map +0 -1
- package/dist/src/api/config.d.ts +0 -24
- package/dist/src/api/config.d.ts.map +0 -1
- package/dist/src/api/config.js +0 -50
- package/dist/src/api/lib/check-plugin-id.d.ts +0 -15
- package/dist/src/api/lib/check-plugin-id.d.ts.map +0 -1
- package/dist/src/api/lib/check-plugin-id.js +0 -15
- package/dist/src/api/lib/get-user-ip.d.ts +0 -3
- package/dist/src/api/lib/get-user-ip.d.ts.map +0 -1
- package/dist/src/api/lib/get-user-ip.js +0 -8
- package/dist/src/api/lib/module.d.ts +0 -23
- package/dist/src/api/lib/module.d.ts.map +0 -1
- package/dist/src/api/lib/module.js +0 -21
- package/dist/src/api/lib/plugin.d.ts +0 -11
- package/dist/src/api/lib/plugin.d.ts.map +0 -1
- package/dist/src/api/lib/plugin.js +0 -14
- package/dist/src/api/lib/route.d.ts +0 -26
- package/dist/src/api/lib/route.d.ts.map +0 -1
- package/dist/src/api/lib/route.js +0 -23
- package/dist/src/api/lib/with-pagination.d.ts +0 -72
- package/dist/src/api/lib/with-pagination.d.ts.map +0 -1
- package/dist/src/api/lib/with-pagination.js +0 -70
- package/dist/src/api/middlewares/global/global.d.ts +0 -66
- package/dist/src/api/middlewares/global/global.d.ts.map +0 -1
- package/dist/src/api/middlewares/global/global.js +0 -47
- package/dist/src/api/models/device.d.ts +0 -10
- package/dist/src/api/models/device.d.ts.map +0 -1
- package/dist/src/api/models/device.js +0 -54
- package/dist/src/api/models/email.d.ts +0 -22
- package/dist/src/api/models/email.d.ts.map +0 -1
- package/dist/src/api/models/email.js +0 -30
- package/dist/src/api/models/password.d.ts +0 -5
- package/dist/src/api/models/password.d.ts.map +0 -1
- package/dist/src/api/models/password.js +0 -21
- package/dist/src/api/models/session-admin.d.ts +0 -24
- package/dist/src/api/models/session-admin.d.ts.map +0 -1
- package/dist/src/api/models/session-admin.js +0 -73
- package/dist/src/api/models/session.d.ts +0 -23
- package/dist/src/api/models/session.d.ts.map +0 -1
- package/dist/src/api/models/session.js +0 -60
- package/dist/src/api/models/sso.d.ts +0 -38
- package/dist/src/api/models/sso.d.ts.map +0 -1
- package/dist/src/api/models/sso.js +0 -120
- package/dist/src/api/models/user/get-user-by-id.d.ts +0 -17
- package/dist/src/api/models/user/get-user-by-id.d.ts.map +0 -1
- package/dist/src/api/models/user/get-user-by-id.js +0 -18
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts +0 -10
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts.map +0 -1
- package/dist/src/api/models/user/sign-in-with-passwords.js +0 -22
- package/dist/src/api/models/user/sign-up.d.ts +0 -21
- package/dist/src/api/models/user/sign-up.d.ts.map +0 -1
- package/dist/src/api/models/user/sign-up.js +0 -75
- package/dist/src/api/models/user.d.ts +0 -45
- package/dist/src/api/models/user.d.ts.map +0 -1
- package/dist/src/api/models/user.js +0 -8
- package/dist/src/api/modules/admin/admin.module.d.ts +0 -294
- package/dist/src/api/modules/admin/admin.module.d.ts.map +0 -1
- package/dist/src/api/modules/admin/admin.module.js +0 -14
- package/dist/src/api/modules/admin/routes/session.route.d.ts +0 -108
- package/dist/src/api/modules/admin/routes/session.route.d.ts.map +0 -1
- package/dist/src/api/modules/admin/routes/session.route.js +0 -51
- package/dist/src/api/modules/admin/users/routes/list.route.d.ts +0 -190
- package/dist/src/api/modules/admin/users/routes/list.route.d.ts.map +0 -1
- package/dist/src/api/modules/admin/users/routes/list.route.js +0 -79
- package/dist/src/api/modules/admin/users/routes/users.route.d.ts +0 -193
- package/dist/src/api/modules/admin/users/routes/users.route.d.ts.map +0 -1
- package/dist/src/api/modules/admin/users/routes/users.route.js +0 -84
- package/dist/src/api/modules/admin/users/users.admin.module.d.ts +0 -189
- package/dist/src/api/modules/admin/users/users.admin.module.d.ts.map +0 -1
- package/dist/src/api/modules/admin/users/users.admin.module.js +0 -10
- package/dist/src/api/modules/middleware/middleware.module.d.ts +0 -52
- package/dist/src/api/modules/middleware/middleware.module.d.ts.map +0 -1
- package/dist/src/api/modules/middleware/middleware.module.js +0 -10
- package/dist/src/api/modules/middleware/route.d.ts +0 -53
- package/dist/src/api/modules/middleware/route.d.ts.map +0 -1
- package/dist/src/api/modules/middleware/route.js +0 -39
- package/dist/src/api/modules/users/avatar-color.d.ts +0 -2
- package/dist/src/api/modules/users/avatar-color.d.ts.map +0 -1
- package/dist/src/api/modules/users/avatar-color.js +0 -43
- package/dist/src/api/modules/users/routes/session.route.d.ts +0 -103
- package/dist/src/api/modules/users/routes/session.route.d.ts.map +0 -1
- package/dist/src/api/modules/users/routes/session.route.js +0 -46
- package/dist/src/api/modules/users/routes/sign-in.route.d.ts +0 -88
- package/dist/src/api/modules/users/routes/sign-in.route.d.ts.map +0 -1
- package/dist/src/api/modules/users/routes/sign-in.route.js +0 -71
- package/dist/src/api/modules/users/routes/sign-out.route.d.ts +0 -47
- package/dist/src/api/modules/users/routes/sign-out.route.d.ts.map +0 -1
- package/dist/src/api/modules/users/routes/sign-out.route.js +0 -43
- package/dist/src/api/modules/users/routes/sign-up.route.d.ts +0 -89
- package/dist/src/api/modules/users/routes/sign-up.route.d.ts.map +0 -1
- package/dist/src/api/modules/users/routes/sign-up.route.js +0 -60
- package/dist/src/api/modules/users/routes/test.route.d.ts +0 -31
- package/dist/src/api/modules/users/routes/test.route.d.ts.map +0 -1
- package/dist/src/api/modules/users/routes/test.route.js +0 -32
- package/dist/src/api/modules/users/sso/routes/callback.route.d.ts +0 -78
- package/dist/src/api/modules/users/sso/routes/callback.route.d.ts.map +0 -1
- package/dist/src/api/modules/users/sso/routes/callback.route.js +0 -49
- package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts +0 -51
- package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts.map +0 -1
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +0 -36
- package/dist/src/api/modules/users/sso/sso.module.d.ts +0 -125
- package/dist/src/api/modules/users/sso/sso.module.d.ts.map +0 -1
- package/dist/src/api/modules/users/sso/sso.module.js +0 -12
- package/dist/src/api/modules/users/users.module.d.ts +0 -439
- package/dist/src/api/modules/users/users.module.d.ts.map +0 -1
- package/dist/src/api/modules/users/users.module.js +0 -22
- package/dist/src/api/plugin.d.ts +0 -2
- package/dist/src/api/plugin.d.ts.map +0 -1
- package/dist/src/api/plugin.js +0 -13
- package/dist/src/api/plugins/email/nodemailer.d.ts +0 -10
- package/dist/src/api/plugins/email/nodemailer.d.ts.map +0 -1
- package/dist/src/api/plugins/email/nodemailer.js +0 -30
- package/dist/src/api/plugins/email/resend.d.ts +0 -6
- package/dist/src/api/plugins/email/resend.d.ts.map +0 -1
- package/dist/src/api/plugins/email/resend.js +0 -21
- package/dist/src/api/plugins/sso/discord.d.ts +0 -6
- package/dist/src/api/plugins/sso/discord.d.ts.map +0 -1
- package/dist/src/api/plugins/sso/discord.js +0 -77
- package/dist/src/api/plugins/sso/facebook.d.ts +0 -6
- package/dist/src/api/plugins/sso/facebook.d.ts.map +0 -1
- package/dist/src/api/plugins/sso/facebook.js +0 -76
- package/dist/src/api/plugins/sso/google.d.ts +0 -6
- package/dist/src/api/plugins/sso/google.d.ts.map +0 -1
- package/dist/src/api/plugins/sso/google.js +0 -87
- package/dist/src/app/login/page.d.ts +0 -6
- package/dist/src/app/login/page.d.ts.map +0 -1
- package/dist/src/app/login/page.js +0 -15
- package/dist/src/app/login/sso/[providerId]/page.d.ts +0 -7
- package/dist/src/app/login/sso/[providerId]/page.d.ts.map +0 -1
- package/dist/src/app/login/sso/[providerId]/page.js +0 -10
- package/dist/src/app/register/page.d.ts +0 -6
- package/dist/src/app/register/page.d.ts.map +0 -1
- package/dist/src/app/register/page.js +0 -15
- package/dist/src/app_admin/core/page.d.ts +0 -2
- package/dist/src/app_admin/core/page.d.ts.map +0 -1
- package/dist/src/app_admin/core/page.js +0 -5
- package/dist/src/app_admin/core/test/page.d.ts +0 -2
- package/dist/src/app_admin/core/test/page.d.ts.map +0 -1
- package/dist/src/app_admin/core/test/page.js +0 -5
- package/dist/src/app_admin/core/users/page.d.ts +0 -6
- package/dist/src/app_admin/core/users/page.d.ts.map +0 -1
- package/dist/src/app_admin/core/users/page.js +0 -35
- package/dist/src/components/avatar.d.ts +0 -10
- package/dist/src/components/avatar.d.ts.map +0 -1
- package/dist/src/components/avatar.js +0 -14
- package/dist/src/components/date-format.d.ts +0 -5
- package/dist/src/components/date-format.d.ts.map +0 -1
- package/dist/src/components/date-format.js +0 -38
- package/dist/src/components/form/auto-form.d.ts +0 -12
- package/dist/src/components/form/auto-form.d.ts.map +0 -1
- package/dist/src/components/form/auto-form.js +0 -57
- package/dist/src/components/form/common/desc.d.ts +0 -2
- package/dist/src/components/form/common/desc.d.ts.map +0 -1
- package/dist/src/components/form/common/desc.js +0 -9
- package/dist/src/components/form/common/label.d.ts +0 -3
- package/dist/src/components/form/common/label.d.ts.map +0 -1
- package/dist/src/components/form/common/label.js +0 -8
- package/dist/src/components/form/fields/checkbox.d.ts +0 -8
- package/dist/src/components/form/fields/checkbox.d.ts.map +0 -1
- package/dist/src/components/form/fields/checkbox.js +0 -35
- package/dist/src/components/form/fields/combobox.d.ts +0 -14
- package/dist/src/components/form/fields/combobox.d.ts.map +0 -1
- package/dist/src/components/form/fields/combobox.js +0 -88
- package/dist/src/components/form/fields/input.d.ts +0 -9
- package/dist/src/components/form/fields/input.d.ts.map +0 -1
- package/dist/src/components/form/fields/input.js +0 -34
- package/dist/src/components/form/fields/item.d.ts +0 -14
- package/dist/src/components/form/fields/item.d.ts.map +0 -1
- package/dist/src/components/form/fields/item.js +0 -22
- package/dist/src/components/form/fields/radio-group.d.ts +0 -13
- package/dist/src/components/form/fields/radio-group.d.ts.map +0 -1
- package/dist/src/components/form/fields/radio-group.js +0 -51
- package/dist/src/components/form/fields/select.d.ts +0 -14
- package/dist/src/components/form/fields/select.d.ts.map +0 -1
- package/dist/src/components/form/fields/select.js +0 -59
- package/dist/src/components/form/fields/switch.d.ts +0 -8
- package/dist/src/components/form/fields/switch.d.ts.map +0 -1
- package/dist/src/components/form/fields/switch.js +0 -35
- package/dist/src/components/form/fields/textarea.d.ts +0 -9
- package/dist/src/components/form/fields/textarea.d.ts.map +0 -1
- package/dist/src/components/form/fields/textarea.js +0 -34
- package/dist/src/components/i18n-provider.d.ts +0 -7
- package/dist/src/components/i18n-provider.d.ts.map +0 -1
- package/dist/src/components/i18n-provider.js +0 -43
- package/dist/src/components/logo-vitnode.d.ts +0 -4
- package/dist/src/components/logo-vitnode.d.ts.map +0 -1
- package/dist/src/components/logo-vitnode.js +0 -113
- package/dist/src/components/switchers/theme-switcher.d.ts +0 -2
- package/dist/src/components/switchers/theme-switcher.d.ts.map +0 -1
- package/dist/src/components/switchers/theme-switcher.js +0 -25
- package/dist/src/components/table/content.d.ts +0 -3
- package/dist/src/components/table/content.d.ts.map +0 -1
- package/dist/src/components/table/content.js +0 -84
- package/dist/src/components/table/data-table.d.ts +0 -37
- package/dist/src/components/table/data-table.d.ts.map +0 -1
- package/dist/src/components/table/data-table.js +0 -69
- package/dist/src/components/table/order-table-head.d.ts +0 -7
- package/dist/src/components/table/order-table-head.d.ts.map +0 -1
- package/dist/src/components/table/order-table-head.js +0 -39
- package/dist/src/components/table/pagination.d.ts +0 -11
- package/dist/src/components/table/pagination.d.ts.map +0 -1
- package/dist/src/components/table/pagination.js +0 -122
- package/dist/src/components/ui/accordion.d.ts +0 -8
- package/dist/src/components/ui/accordion.d.ts.map +0 -1
- package/dist/src/components/ui/accordion.js +0 -47
- package/dist/src/components/ui/alert-dialog.d.ts +0 -15
- package/dist/src/components/ui/alert-dialog.d.ts.map +0 -1
- package/dist/src/components/ui/alert-dialog.js +0 -86
- package/dist/src/components/ui/alert.d.ts +0 -10
- package/dist/src/components/ui/alert.d.ts.map +0 -1
- package/dist/src/components/ui/alert.js +0 -40
- package/dist/src/components/ui/badge.d.ts +0 -10
- package/dist/src/components/ui/badge.d.ts.map +0 -1
- package/dist/src/components/ui/badge.js +0 -29
- package/dist/src/components/ui/button.d.ts +0 -13
- package/dist/src/components/ui/button.d.ts.map +0 -1
- package/dist/src/components/ui/button.js +0 -66
- package/dist/src/components/ui/card.d.ts +0 -10
- package/dist/src/components/ui/card.d.ts.map +0 -1
- package/dist/src/components/ui/card.js +0 -53
- package/dist/src/components/ui/checkbox.d.ts +0 -5
- package/dist/src/components/ui/checkbox.d.ts.map +0 -1
- package/dist/src/components/ui/checkbox.js +0 -21
- package/dist/src/components/ui/collapsible.d.ts +0 -6
- package/dist/src/components/ui/collapsible.d.ts.map +0 -1
- package/dist/src/components/ui/collapsible.js +0 -22
- package/dist/src/components/ui/command.d.ts +0 -19
- package/dist/src/components/ui/command.d.ts.map +0 -1
- package/dist/src/components/ui/command.js +0 -99
- package/dist/src/components/ui/context-menu.d.ts +0 -26
- package/dist/src/components/ui/context-menu.d.ts.map +0 -1
- package/dist/src/components/ui/context-menu.js +0 -141
- package/dist/src/components/ui/dialog.d.ts +0 -23
- package/dist/src/components/ui/dialog.d.ts.map +0 -1
- package/dist/src/components/ui/dialog.js +0 -181
- package/dist/src/components/ui/drawer.d.ts +0 -14
- package/dist/src/components/ui/drawer.d.ts.map +0 -1
- package/dist/src/components/ui/drawer.js +0 -84
- package/dist/src/components/ui/dropdown-menu.d.ts +0 -26
- package/dist/src/components/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/src/components/ui/dropdown-menu.js +0 -142
- package/dist/src/components/ui/form.d.ts +0 -33
- package/dist/src/components/ui/form.d.ts.map +0 -1
- package/dist/src/components/ui/form.js +0 -142
- package/dist/src/components/ui/header-content.d.ts +0 -17
- package/dist/src/components/ui/header-content.d.ts.map +0 -1
- package/dist/src/components/ui/header-content.js +0 -30
- package/dist/src/components/ui/hover-card.d.ts +0 -7
- package/dist/src/components/ui/hover-card.d.ts.map +0 -1
- package/dist/src/components/ui/hover-card.js +0 -30
- package/dist/src/components/ui/input-otp.d.ts +0 -12
- package/dist/src/components/ui/input-otp.d.ts.map +0 -1
- package/dist/src/components/ui/input-otp.js +0 -49
- package/dist/src/components/ui/input.d.ts +0 -4
- package/dist/src/components/ui/input.d.ts.map +0 -1
- package/dist/src/components/ui/input.js +0 -12
- package/dist/src/components/ui/label.d.ts +0 -5
- package/dist/src/components/ui/label.d.ts.map +0 -1
- package/dist/src/components/ui/label.js +0 -13
- package/dist/src/components/ui/loader.d.ts +0 -5
- package/dist/src/components/ui/loader.d.ts.map +0 -1
- package/dist/src/components/ui/loader.js +0 -16
- package/dist/src/components/ui/menubar.d.ts +0 -27
- package/dist/src/components/ui/menubar.d.ts.map +0 -1
- package/dist/src/components/ui/menubar.js +0 -152
- package/dist/src/components/ui/navigation-menu.d.ts +0 -15
- package/dist/src/components/ui/navigation-menu.d.ts.map +0 -1
- package/dist/src/components/ui/navigation-menu.js +0 -83
- package/dist/src/components/ui/popover.d.ts +0 -8
- package/dist/src/components/ui/popover.d.ts.map +0 -1
- package/dist/src/components/ui/popover.js +0 -35
- package/dist/src/components/ui/progress.d.ts +0 -5
- package/dist/src/components/ui/progress.d.ts.map +0 -1
- package/dist/src/components/ui/progress.js +0 -20
- package/dist/src/components/ui/radio-group.d.ts +0 -6
- package/dist/src/components/ui/radio-group.d.ts.map +0 -1
- package/dist/src/components/ui/radio-group.js +0 -28
- package/dist/src/components/ui/select.d.ts +0 -16
- package/dist/src/components/ui/select.d.ts.map +0 -1
- package/dist/src/components/ui/select.js +0 -114
- package/dist/src/components/ui/separator.d.ts +0 -5
- package/dist/src/components/ui/separator.d.ts.map +0 -1
- package/dist/src/components/ui/separator.js +0 -15
- package/dist/src/components/ui/sheet.d.ts +0 -14
- package/dist/src/components/ui/sheet.d.ts.map +0 -1
- package/dist/src/components/ui/sheet.js +0 -93
- package/dist/src/components/ui/sidebar.d.ts +0 -70
- package/dist/src/components/ui/sidebar.d.ts.map +0 -1
- package/dist/src/components/ui/sidebar.js +0 -437
- package/dist/src/components/ui/skeleton.d.ts +0 -3
- package/dist/src/components/ui/skeleton.d.ts.map +0 -1
- package/dist/src/components/ui/skeleton.js +0 -10
- package/dist/src/components/ui/slider.d.ts +0 -5
- package/dist/src/components/ui/slider.d.ts.map +0 -1
- package/dist/src/components/ui/slider.js +0 -42
- package/dist/src/components/ui/sonner.d.ts +0 -4
- package/dist/src/components/ui/sonner.d.ts.map +0 -1
- package/dist/src/components/ui/sonner.js +0 -26
- package/dist/src/components/ui/switch.d.ts +0 -5
- package/dist/src/components/ui/switch.d.ts.map +0 -1
- package/dist/src/components/ui/switch.js +0 -17
- package/dist/src/components/ui/table.d.ts +0 -11
- package/dist/src/components/ui/table.d.ts.map +0 -1
- package/dist/src/components/ui/table.js +0 -64
- package/dist/src/components/ui/tabs.d.ts +0 -8
- package/dist/src/components/ui/tabs.d.ts.map +0 -1
- package/dist/src/components/ui/tabs.js +0 -34
- package/dist/src/components/ui/textarea.d.ts +0 -4
- package/dist/src/components/ui/textarea.d.ts.map +0 -1
- package/dist/src/components/ui/textarea.js +0 -11
- package/dist/src/components/ui/toggle-group.d.ts +0 -8
- package/dist/src/components/ui/toggle-group.d.ts.map +0 -1
- package/dist/src/components/ui/toggle-group.js +0 -41
- package/dist/src/components/ui/toggle.d.ts +0 -10
- package/dist/src/components/ui/toggle.d.ts.map +0 -1
- package/dist/src/components/ui/toggle.js +0 -35
- package/dist/src/components/ui/tooltip.d.ts +0 -8
- package/dist/src/components/ui/tooltip.d.ts.map +0 -1
- package/dist/src/components/ui/tooltip.js +0 -43
- package/dist/src/components/ui/unsaved-changes-dialog.d.ts +0 -1
- package/dist/src/components/ui/unsaved-changes-dialog.d.ts.map +0 -1
- package/dist/src/config.d.ts +0 -5
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js +0 -4
- package/dist/src/database/admins.d.ts +0 -246
- package/dist/src/database/admins.d.ts.map +0 -1
- package/dist/src/database/admins.js +0 -74
- package/dist/src/database/languages.d.ts +0 -321
- package/dist/src/database/languages.d.ts.map +0 -1
- package/dist/src/database/languages.js +0 -52
- package/dist/src/database/moderators.d.ts +0 -114
- package/dist/src/database/moderators.d.ts.map +0 -1
- package/dist/src/database/moderators.js +0 -37
- package/dist/src/database/roles.d.ts +0 -146
- package/dist/src/database/roles.d.ts.map +0 -1
- package/dist/src/database/roles.js +0 -13
- package/dist/src/database/sessions.d.ts +0 -196
- package/dist/src/database/sessions.d.ts.map +0 -1
- package/dist/src/database/sessions.js +0 -57
- package/dist/src/database/users.d.ts +0 -562
- package/dist/src/database/users.d.ts.map +0 -1
- package/dist/src/database/users.js +0 -142
- package/dist/src/drizzle.config.d.ts +0 -6
- package/dist/src/drizzle.config.d.ts.map +0 -1
- package/dist/src/drizzle.config.js +0 -37
- package/dist/src/hooks/use-before-unload-with-dialog.d.ts +0 -1
- package/dist/src/hooks/use-before-unload-with-dialog.d.ts.map +0 -1
- package/dist/src/hooks/use-before-unload.d.ts +0 -2
- package/dist/src/hooks/use-before-unload.d.ts.map +0 -1
- package/dist/src/hooks/use-before-unload.js +0 -30
- package/dist/src/hooks/use-mobile.d.ts +0 -2
- package/dist/src/hooks/use-mobile.d.ts.map +0 -1
- package/dist/src/hooks/use-mobile.js +0 -15
- package/dist/src/hooks/use-unsaved-changes.d.ts +0 -1
- package/dist/src/hooks/use-unsaved-changes.d.ts.map +0 -1
- package/dist/src/lib/api/get-middleware-api.d.ts +0 -8
- package/dist/src/lib/api/get-middleware-api.d.ts.map +0 -1
- package/dist/src/lib/api/get-middleware-api.js +0 -13
- package/dist/src/lib/api/get-session-admin-api.d.ts +0 -16
- package/dist/src/lib/api/get-session-admin-api.d.ts.map +0 -1
- package/dist/src/lib/api/get-session-admin-api.js +0 -19
- package/dist/src/lib/api/get-session-api.d.ts +0 -17
- package/dist/src/lib/api/get-session-api.d.ts.map +0 -1
- package/dist/src/lib/api/get-session-api.js +0 -14
- package/dist/src/lib/colors.d.ts +0 -23
- package/dist/src/lib/colors.d.ts.map +0 -1
- package/dist/src/lib/colors.js +0 -131
- package/dist/src/lib/colors.test.d.ts +0 -2
- package/dist/src/lib/colors.test.d.ts.map +0 -1
- package/dist/src/lib/colors.test.js +0 -173
- package/dist/src/lib/config.d.ts +0 -6
- package/dist/src/lib/config.d.ts.map +0 -1
- package/dist/src/lib/config.js +0 -15
- package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts +0 -10
- package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts.map +0 -1
- package/dist/src/lib/fetcher/cookie-from-string-to-object.js +0 -12
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.d.ts +0 -2
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.d.ts.map +0 -1
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +0 -78
- package/dist/src/lib/fetcher/fetcher.d.ts +0 -9
- package/dist/src/lib/fetcher/fetcher.d.ts.map +0 -1
- package/dist/src/lib/fetcher/helpers.d.ts +0 -3
- package/dist/src/lib/fetcher/helpers.d.ts.map +0 -1
- package/dist/src/lib/fetcher/helpers.js +0 -33
- package/dist/src/lib/fetcher/helpers.test.d.ts +0 -2
- package/dist/src/lib/fetcher/helpers.test.d.ts.map +0 -1
- package/dist/src/lib/fetcher/helpers.test.js +0 -37
- package/dist/src/lib/fetcher/index.d.ts +0 -34
- package/dist/src/lib/fetcher/index.d.ts.map +0 -1
- package/dist/src/lib/fetcher/types.d.ts +0 -120
- package/dist/src/lib/fetcher/types.d.ts.map +0 -1
- package/dist/src/lib/fetcher/types.js +0 -1
- package/dist/src/lib/fetcher.d.ts +0 -9
- package/dist/src/lib/fetcher.d.ts.map +0 -1
- package/dist/src/lib/fetcher.js +0 -47
- package/dist/src/lib/helpers/auto-form.d.ts +0 -10
- package/dist/src/lib/helpers/auto-form.d.ts.map +0 -1
- package/dist/src/lib/helpers/auto-form.js +0 -82
- package/dist/src/lib/helpers/auto-form.test.d.ts +0 -2
- package/dist/src/lib/helpers/auto-form.test.d.ts.map +0 -1
- package/dist/src/lib/helpers/auto-form.test.js +0 -126
- package/dist/src/lib/navigation.d.ts +0 -339
- package/dist/src/lib/navigation.d.ts.map +0 -1
- package/dist/src/lib/navigation.js +0 -11
- package/dist/src/lib/plugin.d.ts +0 -15
- package/dist/src/lib/plugin.d.ts.map +0 -1
- package/dist/src/lib/plugin.js +0 -3
- package/dist/src/lib/special-characters.d.ts +0 -3
- package/dist/src/lib/special-characters.d.ts.map +0 -1
- package/dist/src/lib/special-characters.js +0 -4
- package/dist/src/lib/special-characters.test.d.ts +0 -2
- package/dist/src/lib/special-characters.test.d.ts.map +0 -1
- package/dist/src/lib/special-characters.test.js +0 -56
- package/dist/src/lib/utils.d.ts +0 -3
- package/dist/src/lib/utils.d.ts.map +0 -1
- package/dist/src/lib/utils.js +0 -5
- package/dist/src/tests/setup.d.ts +0 -2
- package/dist/src/tests/setup.d.ts.map +0 -1
- package/dist/src/tests/setup.js +0 -6
- package/dist/src/views/admin/layouts/admin-layout.d.ts +0 -8
- package/dist/src/views/admin/layouts/admin-layout.d.ts.map +0 -1
- package/dist/src/views/admin/layouts/admin-layout.js +0 -70
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts +0 -11
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +0 -1
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +0 -70
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts +0 -10
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts.map +0 -1
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +0 -49
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts +0 -3
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts.map +0 -1
- package/dist/src/views/admin/layouts/sidebar/sidebar.js +0 -30
- package/dist/src/views/admin/layouts/sidebar/sign-out.d.ts +0 -4
- package/dist/src/views/admin/layouts/sidebar/sign-out.d.ts.map +0 -1
- package/dist/src/views/admin/layouts/sidebar/sign-out.js +0 -14
- package/dist/src/views/admin/layouts/user-bar/client.d.ts +0 -7
- package/dist/src/views/admin/layouts/user-bar/client.d.ts.map +0 -1
- package/dist/src/views/admin/layouts/user-bar/client.js +0 -61
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts +0 -3
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts.map +0 -1
- package/dist/src/views/admin/layouts/user-bar/user-bar.js +0 -31
- package/dist/src/views/admin/sign-in/sign-in-admin-view.d.ts +0 -2
- package/dist/src/views/admin/sign-in/sign-in-admin-view.d.ts.map +0 -1
- package/dist/src/views/admin/sign-in/sign-in-admin-view.js +0 -26
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.d.ts +0 -2
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.d.ts.map +0 -1
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +0 -44
- package/dist/src/views/admin/views/core/test.d.ts +0 -2
- package/dist/src/views/admin/views/core/test.d.ts.map +0 -1
- package/dist/src/views/admin/views/core/test.js +0 -146
- package/dist/src/views/admin/views/core/users/users-admin-view.d.ts +0 -4
- package/dist/src/views/admin/views/core/users/users-admin-view.d.ts.map +0 -1
- package/dist/src/views/admin/views/core/users/users-admin-view.js +0 -90
- package/dist/src/views/auth/components/password-input.d.ts +0 -4
- package/dist/src/views/auth/components/password-input.d.ts.map +0 -1
- package/dist/src/views/auth/components/password-input.js +0 -89
- package/dist/src/views/auth/sign-in/form/form.d.ts +0 -4
- package/dist/src/views/auth/sign-in/form/form.d.ts.map +0 -1
- package/dist/src/views/auth/sign-in/form/form.js +0 -59
- package/dist/src/views/auth/sign-in/form/hooks/mutation-api.d.ts +0 -10
- package/dist/src/views/auth/sign-in/form/hooks/mutation-api.d.ts.map +0 -1
- package/dist/src/views/auth/sign-in/form/hooks/mutation-api.js +0 -33
- package/dist/src/views/auth/sign-in/form/hooks/use-form.d.ts +0 -27
- package/dist/src/views/auth/sign-in/form/hooks/use-form.d.ts.map +0 -1
- package/dist/src/views/auth/sign-in/form/hooks/use-form.js +0 -38
- package/dist/src/views/auth/sign-in/sign-in-view.d.ts +0 -2
- package/dist/src/views/auth/sign-in/sign-in-view.d.ts.map +0 -1
- package/dist/src/views/auth/sign-in/sign-in-view.js +0 -55
- package/dist/src/views/auth/sign-up/form/form.d.ts +0 -4
- package/dist/src/views/auth/sign-up/form/form.d.ts.map +0 -1
- package/dist/src/views/auth/sign-up/form/form.js +0 -88
- package/dist/src/views/auth/sign-up/form/hooks/mutation-api.d.ts +0 -6
- package/dist/src/views/auth/sign-up/form/hooks/mutation-api.d.ts.map +0 -1
- package/dist/src/views/auth/sign-up/form/hooks/mutation-api.js +0 -18
- package/dist/src/views/auth/sign-up/form/hooks/use-form.d.ts +0 -61
- package/dist/src/views/auth/sign-up/form/hooks/use-form.d.ts.map +0 -1
- package/dist/src/views/auth/sign-up/form/hooks/use-form.js +0 -57
- package/dist/src/views/auth/sign-up/sign-up-view.d.ts +0 -2
- package/dist/src/views/auth/sign-up/sign-up-view.d.ts.map +0 -1
- package/dist/src/views/auth/sign-up/sign-up-view.js +0 -61
- package/dist/src/views/auth/sso/buttons/client.d.ts +0 -5
- package/dist/src/views/auth/sso/buttons/client.d.ts.map +0 -1
- package/dist/src/views/auth/sso/buttons/client.js +0 -22
- package/dist/src/views/auth/sso/buttons/mutation-api.d.ts +0 -4
- package/dist/src/views/auth/sso/buttons/mutation-api.d.ts.map +0 -1
- package/dist/src/views/auth/sso/buttons/mutation-api.js +0 -24
- package/dist/src/views/auth/sso/buttons/sso-buttons.d.ts +0 -3
- package/dist/src/views/auth/sso/buttons/sso-buttons.d.ts.map +0 -1
- package/dist/src/views/auth/sso/buttons/sso-buttons.js +0 -51
- package/dist/src/views/auth/sso/callback/callback-sso-view.d.ts +0 -5
- package/dist/src/views/auth/sso/callback/callback-sso-view.d.ts.map +0 -1
- package/dist/src/views/auth/sso/callback/callback-sso-view.js +0 -18
- package/dist/src/views/auth/sso/callback/client/client.d.ts +0 -6
- package/dist/src/views/auth/sso/callback/client/client.d.ts.map +0 -1
- package/dist/src/views/auth/sso/callback/client/client.js +0 -39
- package/dist/src/views/auth/sso/callback/client/mutation-api.d.ts +0 -8
- package/dist/src/views/auth/sso/callback/client/mutation-api.d.ts.map +0 -1
- package/dist/src/views/auth/sso/callback/client/mutation-api.js +0 -27
- package/dist/src/views/error/back-button.d.ts +0 -5
- package/dist/src/views/error/back-button.d.ts.map +0 -1
- package/dist/src/views/error/back-button.js +0 -14
- package/dist/src/views/error/error-view.d.ts +0 -5
- package/dist/src/views/error/error-view.d.ts.map +0 -1
- package/dist/src/views/error/error-view.js +0 -56
- package/dist/src/views/error/global-error-view.d.ts +0 -6
- package/dist/src/views/error/global-error-view.d.ts.map +0 -1
- package/dist/src/views/error/global-error-view.js +0 -57
- package/dist/src/views/layouts/provider.d.ts +0 -11
- package/dist/src/views/layouts/provider.d.ts.map +0 -1
- package/dist/src/views/layouts/provider.js +0 -43
- package/dist/src/views/layouts/root-layout.d.ts +0 -16
- package/dist/src/views/layouts/root-layout.d.ts.map +0 -1
- package/dist/src/views/layouts/root-layout.js +0 -38
- package/dist/src/views/layouts/theme/header/header.d.ts +0 -4
- package/dist/src/views/layouts/theme/header/header.d.ts.map +0 -1
- package/dist/src/views/layouts/theme/header/header.js +0 -32
- package/dist/src/views/layouts/theme/header/user/auth/auth.d.ts +0 -2
- package/dist/src/views/layouts/theme/header/user/auth/auth.d.ts.map +0 -1
- package/dist/src/views/layouts/theme/header/user/auth/auth.js +0 -33
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts +0 -5
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts.map +0 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.js +0 -47
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.d.ts +0 -4
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.d.ts.map +0 -1
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +0 -27
- package/dist/src/views/layouts/theme/header/user/user.d.ts +0 -2
- package/dist/src/views/layouts/theme/header/user/user.d.ts.map +0 -1
- package/dist/src/views/layouts/theme/header/user/user.js +0 -34
- package/dist/src/views/layouts/theme/layout.d.ts +0 -5
- package/dist/src/views/layouts/theme/layout.d.ts.map +0 -1
- package/dist/src/views/layouts/theme/layout.js +0 -15
- package/dist/src/vitnode.config.d.ts +0 -50
- package/dist/src/vitnode.config.d.ts.map +0 -1
- package/dist/src/vitnode.config.js +0 -39
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/tsup.config.d.ts +0 -3
- package/dist/tsup.config.d.ts.map +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { HTTPException } from "hono/http-exception";
|
|
2
|
-
import { DeviceModel } from "../../models/device";
|
|
3
|
-
import { SessionModel } from "../../models/session";
|
|
4
|
-
import { SessionAdminModel } from "../../models/session-admin";
|
|
5
|
-
export const globalMiddleware = ({ authorization, metadata, emailProvider, dbProvider })=>{
|
|
6
|
-
return async (c, next)=>{
|
|
7
|
-
c.set('db', dbProvider);
|
|
8
|
-
c.set('core', {
|
|
9
|
-
metadata,
|
|
10
|
-
emailProvider,
|
|
11
|
-
authorization: {
|
|
12
|
-
cookieName: authorization?.cookieName ?? 'vitnode_auth',
|
|
13
|
-
cookie_expires: authorization?.cookieExpires ?? 1000 * 60 * 60 * 24 * 90,
|
|
14
|
-
ssoPlugins: authorization?.ssoPlugins ?? [],
|
|
15
|
-
deviceCookieName: authorization?.deviceCookieName ?? 'vitnode_device',
|
|
16
|
-
deviceCookieExpires: authorization?.deviceCookieExpires ?? 1000 * 60 * 60 * 24 * 365,
|
|
17
|
-
adminCookieName: authorization?.adminCookieName ?? 'vitnode_auth_admin',
|
|
18
|
-
adminCookieExpires: authorization?.adminCookieExpires ?? 1000 * 60 * 60 * 24 * 1,
|
|
19
|
-
cookieSecure: authorization?.cookieSecure ?? true
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const deviceId = await new DeviceModel(c).getDeviceId();
|
|
23
|
-
c.set('deviceId', deviceId);
|
|
24
|
-
const user = await new SessionModel(c).getUser();
|
|
25
|
-
c.set('user', user);
|
|
26
|
-
c.set('admin', null);
|
|
27
|
-
await next();
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export const pluginMiddleware = (pluginId)=>{
|
|
31
|
-
return async (c, next)=>{
|
|
32
|
-
c.set('plugin', {
|
|
33
|
-
id: pluginId
|
|
34
|
-
});
|
|
35
|
-
await next();
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export const globalAdminMiddleware = ()=>{
|
|
39
|
-
return async (c, next)=>{
|
|
40
|
-
const user = await new SessionAdminModel(c).getUser();
|
|
41
|
-
if (!user) throw new HTTPException(403);
|
|
42
|
-
c.set('admin', {
|
|
43
|
-
user
|
|
44
|
-
});
|
|
45
|
-
await next();
|
|
46
|
-
};
|
|
47
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono';
|
|
2
|
-
export declare class DeviceModel {
|
|
3
|
-
constructor(c: Context);
|
|
4
|
-
protected readonly c: Context;
|
|
5
|
-
private createDevice;
|
|
6
|
-
private getUserAgent;
|
|
7
|
-
private setCookieDevice;
|
|
8
|
-
getDeviceId(): Promise<number>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=device.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../../src/api/models/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAUpC,qBAAa,WAAW;gBACV,CAAC,EAAE,OAAO;IAGtB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;YAEhB,YAAY;IAe1B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAiBjB,WAAW;CAoClB"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { eq } from "drizzle-orm";
|
|
2
|
-
import { getCookie, setCookie } from "hono/cookie";
|
|
3
|
-
import { core_sessions_known_devices } from "../../database/sessions";
|
|
4
|
-
import { CONFIG } from "../../lib/config";
|
|
5
|
-
import { getUserIp } from "../lib/get-user-ip";
|
|
6
|
-
export class DeviceModel {
|
|
7
|
-
constructor(c){
|
|
8
|
-
this.c = c;
|
|
9
|
-
}
|
|
10
|
-
c;
|
|
11
|
-
async createDevice() {
|
|
12
|
-
const [device] = await this.c.get('db').insert(core_sessions_known_devices).values({
|
|
13
|
-
ipAddress: getUserIp(this.c),
|
|
14
|
-
userAgent: this.getUserAgent()
|
|
15
|
-
}).returning({
|
|
16
|
-
id: core_sessions_known_devices.id
|
|
17
|
-
});
|
|
18
|
-
this.setCookieDevice(device.id);
|
|
19
|
-
return device.id;
|
|
20
|
-
}
|
|
21
|
-
getUserAgent() {
|
|
22
|
-
return this.c.req.header('User-Agent') ?? 'node';
|
|
23
|
-
}
|
|
24
|
-
setCookieDevice(deviceId) {
|
|
25
|
-
setCookie(this.c, this.c.get('core').authorization.deviceCookieName, deviceId.toString(), {
|
|
26
|
-
httpOnly: true,
|
|
27
|
-
secure: this.c.get('core').authorization.cookieSecure,
|
|
28
|
-
path: '/',
|
|
29
|
-
domain: CONFIG.frontend.hostname,
|
|
30
|
-
expires: new Date(Date.now() + this.c.get('core').authorization.deviceCookieExpires)
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async getDeviceId() {
|
|
34
|
-
const deviceIdFromCookie = Number(getCookie(this.c, this.c.get('core').authorization.deviceCookieName));
|
|
35
|
-
try {
|
|
36
|
-
if (deviceIdFromCookie) {
|
|
37
|
-
const [device] = await this.c.get('db').select({
|
|
38
|
-
id: core_sessions_known_devices.id
|
|
39
|
-
}).from(core_sessions_known_devices).where(eq(core_sessions_known_devices.id, deviceIdFromCookie));
|
|
40
|
-
if (!device) {
|
|
41
|
-
return await this.createDevice();
|
|
42
|
-
}
|
|
43
|
-
await this.c.get('db').update(core_sessions_known_devices).set({
|
|
44
|
-
ipAddress: getUserIp(this.c),
|
|
45
|
-
userAgent: this.getUserAgent()
|
|
46
|
-
}).where(eq(core_sessions_known_devices.id, deviceIdFromCookie));
|
|
47
|
-
return device.id;
|
|
48
|
-
}
|
|
49
|
-
} catch (_) {
|
|
50
|
-
return await this.createDevice();
|
|
51
|
-
}
|
|
52
|
-
return await this.createDevice();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Context, ContextVariableMap } from 'hono';
|
|
2
|
-
export interface EmailApiPlugin {
|
|
3
|
-
sendEmail: (args: {
|
|
4
|
-
html: string;
|
|
5
|
-
metadata: ContextVariableMap['core']['metadata'];
|
|
6
|
-
replyTo?: string;
|
|
7
|
-
subject: string;
|
|
8
|
-
to: string;
|
|
9
|
-
}) => Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export declare class EmailModel {
|
|
12
|
-
constructor(c: Context);
|
|
13
|
-
protected readonly c: Context;
|
|
14
|
-
isAvailable(): boolean;
|
|
15
|
-
send(args: {
|
|
16
|
-
html: string;
|
|
17
|
-
replyTo?: string;
|
|
18
|
-
subject: string;
|
|
19
|
-
to: string;
|
|
20
|
-
}): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=email.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../../src/api/models/email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAIxD,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,EAAE,EAAE,MAAM,CAAC;KACZ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED,qBAAa,UAAU;gBACT,CAAC,EAAE,OAAO;IAItB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IAE9B,WAAW;IAIL,IAAI,CAAC,IAAI,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,EAAE,MAAM,CAAC;KACZ;CAqBF"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { HTTPException } from "hono/http-exception";
|
|
2
|
-
export class EmailModel {
|
|
3
|
-
constructor(c){
|
|
4
|
-
this.c = c;
|
|
5
|
-
}
|
|
6
|
-
c;
|
|
7
|
-
isAvailable() {
|
|
8
|
-
return !!this.c.get('core').emailProvider;
|
|
9
|
-
}
|
|
10
|
-
async send(args) {
|
|
11
|
-
const core = this.c.get('core');
|
|
12
|
-
const provider = core.emailProvider;
|
|
13
|
-
if (!provider) {
|
|
14
|
-
throw new HTTPException(500, {
|
|
15
|
-
message: 'Email provider not found'
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
await provider.sendEmail({
|
|
20
|
-
...args,
|
|
21
|
-
metadata: core.metadata
|
|
22
|
-
});
|
|
23
|
-
} catch (e) {
|
|
24
|
-
const error = e;
|
|
25
|
-
throw new HTTPException(500, {
|
|
26
|
-
message: error.message
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../../../src/api/models/password.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IAClB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYlD,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CASvE"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
|
-
export class PasswordModel {
|
|
3
|
-
async encryptPassword(password) {
|
|
4
|
-
return new Promise((resolve, reject)=>{
|
|
5
|
-
const salt = crypto.randomBytes(8).toString('hex');
|
|
6
|
-
crypto.scrypt(password, salt, 64, (err, derivedKey)=>{
|
|
7
|
-
if (err) reject(err);
|
|
8
|
-
resolve(salt + ':' + derivedKey.toString('hex'));
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
async verifyPassword(password, hash) {
|
|
13
|
-
return new Promise((resolve, reject)=>{
|
|
14
|
-
const [salt, key] = hash.split(':');
|
|
15
|
-
crypto.scrypt(password, salt, 64, (err, derivedKey)=>{
|
|
16
|
-
if (err) reject(err);
|
|
17
|
-
resolve(key == derivedKey.toString('hex'));
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono';
|
|
2
|
-
export declare class SessionAdminModel {
|
|
3
|
-
constructor(c: Context);
|
|
4
|
-
protected readonly c: Context;
|
|
5
|
-
checkIfUserIsAdmin(userId: number): Promise<boolean>;
|
|
6
|
-
createSessionByUserId(userId: number): Promise<{
|
|
7
|
-
token: string;
|
|
8
|
-
deviceId: number;
|
|
9
|
-
}>;
|
|
10
|
-
deleteSession(): Promise<void>;
|
|
11
|
-
getUser(): Promise<{
|
|
12
|
-
id: number;
|
|
13
|
-
email: string;
|
|
14
|
-
name: string;
|
|
15
|
-
nameCode: string;
|
|
16
|
-
createdAt: Date;
|
|
17
|
-
newsletter: boolean;
|
|
18
|
-
avatarColor: string;
|
|
19
|
-
emailVerified: boolean;
|
|
20
|
-
roleId: number;
|
|
21
|
-
birthday: Date | null;
|
|
22
|
-
} | null>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=session-admin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-admin.d.ts","sourceRoot":"","sources":["../../../../src/api/models/session-admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAWpC,qBAAa,iBAAiB;gBAChB,CAAC,EAAE,OAAO;IAGtB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IAExB,kBAAkB,CAAC,MAAM,EAAE,MAAM;IAmBjC,qBAAqB,CAAC,MAAM,EAAE,MAAM;;;;IAsCpC,aAAa;IAgBb,OAAO;;;;;;;;;;;;CAgCd"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { and, eq, gt, or } from "drizzle-orm";
|
|
2
|
-
import { deleteCookie, getCookie, setCookie } from "hono/cookie";
|
|
3
|
-
import { HTTPException } from "hono/http-exception";
|
|
4
|
-
import { core_admin_permissions, core_admin_sessions } from "../../database/admins";
|
|
5
|
-
import { CONFIG } from "../../lib/config";
|
|
6
|
-
import { UserModel } from "./user";
|
|
7
|
-
export class SessionAdminModel {
|
|
8
|
-
constructor(c){
|
|
9
|
-
this.c = c;
|
|
10
|
-
}
|
|
11
|
-
c;
|
|
12
|
-
async checkIfUserIsAdmin(userId) {
|
|
13
|
-
const user = await new UserModel().getUserById({
|
|
14
|
-
id: userId,
|
|
15
|
-
c: this.c
|
|
16
|
-
});
|
|
17
|
-
if (!user) return false;
|
|
18
|
-
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);
|
|
19
|
-
return !!permission;
|
|
20
|
-
}
|
|
21
|
-
async createSessionByUserId(userId) {
|
|
22
|
-
const isAdmin = await this.checkIfUserIsAdmin(userId);
|
|
23
|
-
if (!isAdmin) throw new HTTPException(403);
|
|
24
|
-
// Generate secure random bytes using Web Crypto API
|
|
25
|
-
const randomBytes = new Uint8Array(64);
|
|
26
|
-
crypto.getRandomValues(randomBytes);
|
|
27
|
-
const token = Array.from(randomBytes).map((b)=>b.toString(16).padStart(2, '0')).join('');
|
|
28
|
-
const deviceId = this.c.get('deviceId');
|
|
29
|
-
await this.c.get('db').insert(core_admin_sessions).values({
|
|
30
|
-
token,
|
|
31
|
-
userId,
|
|
32
|
-
expiresAt: new Date(Date.now() + this.c.get('core').authorization.adminCookieExpires),
|
|
33
|
-
deviceId
|
|
34
|
-
});
|
|
35
|
-
setCookie(this.c, this.c.get('core').authorization.adminCookieName, token, {
|
|
36
|
-
httpOnly: true,
|
|
37
|
-
secure: this.c.get('core').authorization.cookieSecure,
|
|
38
|
-
path: '/admin',
|
|
39
|
-
expires: new Date(Date.now() + this.c.get('core').authorization.adminCookieExpires),
|
|
40
|
-
domain: CONFIG.frontend.hostname
|
|
41
|
-
});
|
|
42
|
-
return {
|
|
43
|
-
token,
|
|
44
|
-
deviceId
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
async deleteSession() {
|
|
48
|
-
const token = getCookie(this.c, this.c.get('core').authorization.adminCookieName);
|
|
49
|
-
if (!token) return;
|
|
50
|
-
await this.c.get('db').delete(core_admin_sessions).where(eq(core_admin_sessions.token, token));
|
|
51
|
-
deleteCookie(this.c, this.c.get('core').authorization.adminCookieName, {
|
|
52
|
-
path: '/admin'
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
async getUser() {
|
|
56
|
-
const { authorization } = this.c.get('core');
|
|
57
|
-
const token = getCookie(this.c, authorization.adminCookieName);
|
|
58
|
-
if (!token) return null;
|
|
59
|
-
const deviceId = this.c.get('deviceId');
|
|
60
|
-
if (!deviceId) return null;
|
|
61
|
-
const [session] = await this.c.get('db').select({
|
|
62
|
-
token: core_admin_sessions.token,
|
|
63
|
-
userId: core_admin_sessions.userId
|
|
64
|
-
}).from(core_admin_sessions).where(and(eq(core_admin_sessions.token, token), eq(core_admin_sessions.deviceId, deviceId), gt(core_admin_sessions.expiresAt, new Date()))).limit(1);
|
|
65
|
-
if (!session) return null;
|
|
66
|
-
const user = await new UserModel().getUserById({
|
|
67
|
-
id: session.userId,
|
|
68
|
-
c: this.c
|
|
69
|
-
});
|
|
70
|
-
if (!user) return null;
|
|
71
|
-
return user;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono';
|
|
2
|
-
export declare class SessionModel {
|
|
3
|
-
constructor(c: Context);
|
|
4
|
-
protected readonly c: Context;
|
|
5
|
-
createSessionByUserId(userId: number): Promise<{
|
|
6
|
-
token: string;
|
|
7
|
-
deviceId: number;
|
|
8
|
-
}>;
|
|
9
|
-
deleteSession(): Promise<void>;
|
|
10
|
-
getUser(): Promise<{
|
|
11
|
-
id: number;
|
|
12
|
-
email: string;
|
|
13
|
-
name: string;
|
|
14
|
-
nameCode: string;
|
|
15
|
-
createdAt: Date;
|
|
16
|
-
newsletter: boolean;
|
|
17
|
-
avatarColor: string;
|
|
18
|
-
emailVerified: boolean;
|
|
19
|
-
roleId: number;
|
|
20
|
-
birthday: Date | null;
|
|
21
|
-
} | null>;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/api/models/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAUpC,qBAAa,YAAY;gBACX,CAAC,EAAE,OAAO;IAGtB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IAExB,qBAAqB,CAAC,MAAM,EAAE,MAAM;;;;IAqCpC,aAAa;IAcb,OAAO;;;;;;;;;;;;CAoCd"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { and, eq, gt } from "drizzle-orm";
|
|
2
|
-
import { deleteCookie, getCookie, setCookie } from "hono/cookie";
|
|
3
|
-
import { core_sessions } from "../../database/sessions";
|
|
4
|
-
import { CONFIG } from "../../lib/config";
|
|
5
|
-
import { UserModel } from "./user";
|
|
6
|
-
export class SessionModel {
|
|
7
|
-
constructor(c){
|
|
8
|
-
this.c = c;
|
|
9
|
-
}
|
|
10
|
-
c;
|
|
11
|
-
async createSessionByUserId(userId) {
|
|
12
|
-
// Generate secure random bytes using Web Crypto API
|
|
13
|
-
const randomBytes = new Uint8Array(64);
|
|
14
|
-
crypto.getRandomValues(randomBytes);
|
|
15
|
-
const token = Array.from(randomBytes).map((b)=>b.toString(16).padStart(2, '0')).join('');
|
|
16
|
-
const deviceId = this.c.get('deviceId');
|
|
17
|
-
await this.c.get('db').insert(core_sessions).values({
|
|
18
|
-
token,
|
|
19
|
-
userId,
|
|
20
|
-
expiresAt: new Date(Date.now() + this.c.get('core').authorization.cookie_expires),
|
|
21
|
-
deviceId
|
|
22
|
-
});
|
|
23
|
-
setCookie(this.c, this.c.get('core').authorization.cookieName, token, {
|
|
24
|
-
httpOnly: true,
|
|
25
|
-
secure: this.c.get('core').authorization.cookieSecure,
|
|
26
|
-
path: '/',
|
|
27
|
-
expires: this.c.get('core').authorization.cookie_expires > 0 ? new Date(Date.now() + this.c.get('core').authorization.cookie_expires) : undefined,
|
|
28
|
-
domain: CONFIG.frontend.hostname
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
token,
|
|
32
|
-
deviceId
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
async deleteSession() {
|
|
36
|
-
const token = getCookie(this.c, this.c.get('core').authorization.cookieName);
|
|
37
|
-
if (!token) return;
|
|
38
|
-
await this.c.get('db').delete(core_sessions).where(eq(core_sessions.token, token));
|
|
39
|
-
deleteCookie(this.c, this.c.get('core').authorization.cookieName);
|
|
40
|
-
}
|
|
41
|
-
async getUser() {
|
|
42
|
-
const token = getCookie(this.c, this.c.get('core').authorization.cookieName);
|
|
43
|
-
if (!token) return null;
|
|
44
|
-
const deviceId = this.c.get('deviceId');
|
|
45
|
-
if (!deviceId) return null;
|
|
46
|
-
const [session] = await this.c.get('db').select({
|
|
47
|
-
token: core_sessions.token,
|
|
48
|
-
userId: core_sessions.userId
|
|
49
|
-
}).from(core_sessions).where(and(eq(core_sessions.token, token), eq(core_sessions.deviceId, deviceId), gt(core_sessions.expiresAt, new Date()))).limit(1);
|
|
50
|
-
if (!session || session.token !== token) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const user = await new UserModel().getUserById({
|
|
54
|
-
id: session.userId,
|
|
55
|
-
c: this.c
|
|
56
|
-
});
|
|
57
|
-
if (!user) return null;
|
|
58
|
-
return user;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono';
|
|
2
|
-
export interface SSOApiPlugin {
|
|
3
|
-
fetchToken: (code: string) => Promise<{
|
|
4
|
-
access_token: string;
|
|
5
|
-
token_type: string;
|
|
6
|
-
}>;
|
|
7
|
-
fetchUser: (args: {
|
|
8
|
-
access_token: string;
|
|
9
|
-
token_type: string;
|
|
10
|
-
}) => Promise<{
|
|
11
|
-
email: string;
|
|
12
|
-
id: string;
|
|
13
|
-
username: string;
|
|
14
|
-
}>;
|
|
15
|
-
getUrl: (props: {
|
|
16
|
-
state: string;
|
|
17
|
-
}) => string;
|
|
18
|
-
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
}
|
|
21
|
-
export declare const getRedirectUri: (code: string) => string;
|
|
22
|
-
export declare class SSOModel {
|
|
23
|
-
constructor(c: Context);
|
|
24
|
-
private readonly c;
|
|
25
|
-
private readonly plugins;
|
|
26
|
-
private readonly signUpUser;
|
|
27
|
-
callback({ code, providerId, state, }: {
|
|
28
|
-
code: string;
|
|
29
|
-
providerId: string;
|
|
30
|
-
state: string;
|
|
31
|
-
}): Promise<{
|
|
32
|
-
userId: number;
|
|
33
|
-
}>;
|
|
34
|
-
encryptState(): Promise<string>;
|
|
35
|
-
getUrl(providerId: string): Promise<string>;
|
|
36
|
-
verifyState(state: string): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=sso.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sso.d.ts","sourceRoot":"","sources":["../../../../src/api/models/sso.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAapC,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,WACqB,CAAC;AAEjE,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;IA+DI,YAAY;IA2BZ,MAAM,CAAC,UAAU,EAAE,MAAM;IASzB,WAAW,CAAC,KAAK,EAAE,MAAM;CA+BhC"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
|
-
import { and, eq } from "drizzle-orm";
|
|
3
|
-
import { deleteCookie, getCookie, setCookie } from "hono/cookie";
|
|
4
|
-
import { HTTPException } from "hono/http-exception";
|
|
5
|
-
import { core_users, core_users_sso } from "../../database/users";
|
|
6
|
-
import { CONFIG } from "../../lib/config";
|
|
7
|
-
import { removeSpecialCharacters } from "../../lib/special-characters";
|
|
8
|
-
import { UserModel } from "./user";
|
|
9
|
-
export const getRedirectUri = (code)=>new URL(`${CONFIG.frontend.href}login/sso/${code}`).toString();
|
|
10
|
-
export class SSOModel {
|
|
11
|
-
constructor(c){
|
|
12
|
-
this.c = c;
|
|
13
|
-
this.plugins = c.get('core').authorization.ssoPlugins;
|
|
14
|
-
}
|
|
15
|
-
c;
|
|
16
|
-
plugins;
|
|
17
|
-
signUpUser = async ({ providerId, user, c })=>{
|
|
18
|
-
const data = await new UserModel().signUp({
|
|
19
|
-
email: user.email,
|
|
20
|
-
name: removeSpecialCharacters(user.username, false),
|
|
21
|
-
newsletter: false,
|
|
22
|
-
hashedPassword: undefined
|
|
23
|
-
}, c);
|
|
24
|
-
await c.get('db').insert(core_users_sso).values({
|
|
25
|
-
userId: data.id,
|
|
26
|
-
providerId: providerId,
|
|
27
|
-
providerAccountId: user.id
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
userId: data.id
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
async callback({ code, providerId, state }) {
|
|
34
|
-
await this.verifyState(state);
|
|
35
|
-
const provider = this.plugins.find((p)=>p.id === providerId);
|
|
36
|
-
if (!provider) {
|
|
37
|
-
throw new HTTPException(404);
|
|
38
|
-
}
|
|
39
|
-
const ssoToken = await provider.fetchToken(code);
|
|
40
|
-
const userFromSSO = await provider.fetchUser(ssoToken);
|
|
41
|
-
return await this.c.get('db').transaction(async (tx)=>{
|
|
42
|
-
const [dataSSOFromDb] = await tx.select({
|
|
43
|
-
userId: core_users_sso.userId
|
|
44
|
-
}).from(core_users_sso).leftJoin(core_users, eq(core_users.id, core_users_sso.userId)).where(and(eq(core_users_sso.providerId, providerId), eq(core_users_sso.providerAccountId, userFromSSO.id))).limit(1);
|
|
45
|
-
if (!dataSSOFromDb) {
|
|
46
|
-
const [userWithEmail] = await tx.select({
|
|
47
|
-
id: core_users.id,
|
|
48
|
-
email: core_users.email
|
|
49
|
-
}).from(core_users).where(eq(core_users.email, userFromSSO.email)).limit(1);
|
|
50
|
-
if (!userWithEmail) {
|
|
51
|
-
const signUpUser = await this.signUpUser({
|
|
52
|
-
providerId,
|
|
53
|
-
user: userFromSSO,
|
|
54
|
-
c: this.c
|
|
55
|
-
});
|
|
56
|
-
return signUpUser;
|
|
57
|
-
}
|
|
58
|
-
// If email exists, register SSO
|
|
59
|
-
await tx.insert(core_users_sso).values({
|
|
60
|
-
providerId: providerId,
|
|
61
|
-
providerAccountId: userFromSSO.id,
|
|
62
|
-
userId: userWithEmail.id
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
userId: userWithEmail.id
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
userId: dataSSOFromDb.userId
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
async encryptState() {
|
|
74
|
-
const state = crypto.randomBytes(8).toString('hex');
|
|
75
|
-
const encryptedState = await new Promise((resolve, reject)=>{
|
|
76
|
-
const salt = crypto.randomBytes(4).toString('hex');
|
|
77
|
-
crypto.scrypt(state, salt, 16, (err, derivedKey)=>{
|
|
78
|
-
if (err) reject(err);
|
|
79
|
-
resolve(salt + ':' + derivedKey.toString('hex'));
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
setCookie(this.c, `${this.c.get('core').authorization.cookieName}--state-sso`, encryptedState, {
|
|
83
|
-
httpOnly: true,
|
|
84
|
-
secure: this.c.get('core').authorization.cookieSecure,
|
|
85
|
-
path: '/',
|
|
86
|
-
domain: CONFIG.frontend.hostname
|
|
87
|
-
});
|
|
88
|
-
return state;
|
|
89
|
-
}
|
|
90
|
-
async getUrl(providerId) {
|
|
91
|
-
const provider = this.plugins.find((p)=>p.id === providerId);
|
|
92
|
-
if (!provider) {
|
|
93
|
-
throw new HTTPException(404);
|
|
94
|
-
}
|
|
95
|
-
return provider.getUrl({
|
|
96
|
-
state: await this.encryptState()
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
async verifyState(state) {
|
|
100
|
-
const storedState = getCookie(this.c, `${this.c.get('core').authorization.cookieName}--state-sso`);
|
|
101
|
-
if (!storedState) {
|
|
102
|
-
throw new HTTPException(400, {
|
|
103
|
-
message: 'Invalid state'
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
const isValid = await new Promise((resolve, reject)=>{
|
|
107
|
-
const [salt, storedHash] = storedState.split(':');
|
|
108
|
-
crypto.scrypt(state, salt, 16, (err, derivedKey)=>{
|
|
109
|
-
if (err) reject(err);
|
|
110
|
-
resolve(storedHash === derivedKey.toString('hex'));
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
if (!isValid) {
|
|
114
|
-
throw new HTTPException(400, {
|
|
115
|
-
message: 'Invalid state'
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
deleteCookie(this.c, `${this.c.get('core').authorization.cookieName}--state-sso`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono';
|
|
2
|
-
export declare const getUserById: ({ id, c }: {
|
|
3
|
-
c: Context;
|
|
4
|
-
id: number;
|
|
5
|
-
}) => Promise<{
|
|
6
|
-
id: number;
|
|
7
|
-
email: string;
|
|
8
|
-
name: string;
|
|
9
|
-
nameCode: string;
|
|
10
|
-
createdAt: Date;
|
|
11
|
-
newsletter: boolean;
|
|
12
|
-
avatarColor: string;
|
|
13
|
-
emailVerified: boolean;
|
|
14
|
-
roleId: number;
|
|
15
|
-
birthday: Date | null;
|
|
16
|
-
} | null>;
|
|
17
|
-
//# sourceMappingURL=get-user-by-id.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-user-by-id.d.ts","sourceRoot":"","sources":["../../../../../src/api/models/user/get-user-by-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAMpC,eAAO,MAAM,WAAW,GAAU,WAAW;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;SAqBtE,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { eq } from "drizzle-orm";
|
|
2
|
-
import { core_users } from "../../../database/users";
|
|
3
|
-
export const getUserById = async ({ id, c })=>{
|
|
4
|
-
const [user] = await c.get('db').select({
|
|
5
|
-
id: core_users.id,
|
|
6
|
-
email: core_users.email,
|
|
7
|
-
name: core_users.name,
|
|
8
|
-
nameCode: core_users.nameCode,
|
|
9
|
-
createdAt: core_users.createdAt,
|
|
10
|
-
newsletter: core_users.newsletter,
|
|
11
|
-
avatarColor: core_users.avatarColor,
|
|
12
|
-
emailVerified: core_users.emailVerified,
|
|
13
|
-
roleId: core_users.roleId,
|
|
14
|
-
birthday: core_users.birthday
|
|
15
|
-
}).from(core_users).where(eq(core_users.id, id)).limit(1);
|
|
16
|
-
if (!user) return null;
|
|
17
|
-
return user;
|
|
18
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono';
|
|
2
|
-
export declare const signInWithPassword: ({ email, password, c, }: {
|
|
3
|
-
c: Context;
|
|
4
|
-
email: string;
|
|
5
|
-
password: string;
|
|
6
|
-
}) => Promise<{
|
|
7
|
-
id: number;
|
|
8
|
-
email: string;
|
|
9
|
-
}>;
|
|
10
|
-
//# sourceMappingURL=sign-in-with-passwords.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sign-in-with-passwords.d.ts","sourceRoot":"","sources":["../../../../../src/api/models/user/sign-in-with-passwords.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AASpC,eAAO,MAAM,kBAAkB,GAAU,yBAItC;IACD,CAAC,EAAE,OAAO,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;;;EA0BA,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { eq } from "drizzle-orm";
|
|
2
|
-
import { HTTPException } from "hono/http-exception";
|
|
3
|
-
import { core_users } from "../../../database/users";
|
|
4
|
-
import { PasswordModel } from "../password";
|
|
5
|
-
export const signInWithPassword = async ({ email, password, c })=>{
|
|
6
|
-
const [user] = await c.get('db').select({
|
|
7
|
-
id: core_users.id,
|
|
8
|
-
email: core_users.email,
|
|
9
|
-
password: core_users.password
|
|
10
|
-
}).from(core_users).where(eq(core_users.email, email)).limit(1);
|
|
11
|
-
if (!user?.password) {
|
|
12
|
-
throw new HTTPException(403);
|
|
13
|
-
}
|
|
14
|
-
const validPassword = await new PasswordModel().verifyPassword(password, user.password);
|
|
15
|
-
if (!validPassword) {
|
|
16
|
-
throw new HTTPException(403);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
id: user.id,
|
|
20
|
-
email: user.email
|
|
21
|
-
};
|
|
22
|
-
};
|