@basicbenframework/cms 0.0.0-stage → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +206 -2
- package/db/migrations/001_create_users.js +15 -0
- package/db/migrations/002_create_posts.js +18 -0
- package/db/migrations/003_create_categories.js +19 -0
- package/db/migrations/004_create_tags.js +16 -0
- package/db/migrations/005_create_post_tags.js +16 -0
- package/db/migrations/006_create_pages.js +26 -0
- package/db/migrations/007_create_comments.js +24 -0
- package/db/migrations/008_create_media.js +22 -0
- package/db/migrations/009_update_posts_blogging.js +27 -0
- package/db/migrations/010_create_settings.js +29 -0
- package/db/migrations/011_add_user_roles.js +23 -0
- package/db/migrations/012_create_auth_tokens.js +30 -0
- package/db/migrations/013_add_email_verified.js +24 -0
- package/db/migrations/014_create_user_two_factor.js +30 -0
- package/db/migrations/015_create_user_credentials.js +35 -0
- package/db/migrations/016_create_rate_limits.js +31 -0
- package/db/migrations/017_add_content_html.js +38 -0
- package/db/migrations/018_create_api_tokens.js +34 -0
- package/db/migrations/019_create_post_categories.js +40 -0
- package/db/migrations/020_add_author_profiles.js +60 -0
- package/db/migrations/021_add_page_featured_image.js +23 -0
- package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
- package/db/migrations/023_add_user_session_controls.js +25 -0
- package/db/migrations/024_add_post_status_and_trash.js +45 -0
- package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
- package/db/migrations/026_create_post_revisions.js +29 -0
- package/db/migrations/027_add_media_dimensions.js +19 -0
- package/db/migrations/028_create_navigation_menus.js +65 -0
- package/db/migrations/029_create_redirects.js +40 -0
- package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
- package/db/migrations/031_create_post_locks.js +38 -0
- package/db/migrations/032_create_snippets.js +31 -0
- package/db/migrations/033_create_members.js +70 -0
- package/db/migrations/034_add_post_visibility.js +28 -0
- package/db/migrations/035_create_newsletters.js +72 -0
- package/db/migrations/036_create_analytics.js +89 -0
- package/db/migrations/037_create_ops_heartbeats.js +30 -0
- package/db/migrations/038_create_content_types.js +84 -0
- package/db/migrations/039_create_content_type_fields.js +47 -0
- package/db/migrations/040_create_taxonomies.js +80 -0
- package/db/migrations/041_add_newsletter_handoff.js +28 -0
- package/db/migrations/042_create_mysendbox_contacts.js +63 -0
- package/lib/cli/backup.d.mts +2 -0
- package/lib/cli/backup.mjs +124 -0
- package/lib/cli/export.d.mts +2 -0
- package/lib/cli/export.mjs +54 -0
- package/lib/cli/import-ghost.d.mts +2 -0
- package/lib/cli/import-ghost.mjs +50 -0
- package/lib/cli/import-json.d.mts +2 -0
- package/lib/cli/import-json.mjs +61 -0
- package/lib/cli/import-wordpress.d.mts +2 -0
- package/lib/cli/import-wordpress.mjs +169 -0
- package/lib/cli/import-wxr.d.mts +2 -0
- package/lib/cli/import-wxr.mjs +55 -0
- package/lib/cli/index.d.mts +2 -0
- package/lib/cli/index.mjs +53 -0
- package/lib/cli/lib/backup.d.mts +112 -0
- package/lib/cli/lib/backup.mjs +297 -0
- package/lib/cli/lib/ghost.d.mts +30 -0
- package/lib/cli/lib/ghost.mjs +201 -0
- package/lib/cli/lib/html-to-markdown.d.mts +61 -0
- package/lib/cli/lib/html-to-markdown.mjs +523 -0
- package/lib/cli/lib/import-common.d.mts +100 -0
- package/lib/cli/lib/import-common.mjs +252 -0
- package/lib/cli/lib/json-import.d.mts +22 -0
- package/lib/cli/lib/json-import.mjs +422 -0
- package/lib/cli/lib/site-import.d.mts +32 -0
- package/lib/cli/lib/site-import.mjs +456 -0
- package/lib/cli/lib/wordpress-rest.d.mts +25 -0
- package/lib/cli/lib/wordpress-rest.mjs +177 -0
- package/lib/cli/lib/wxr.d.mts +18 -0
- package/lib/cli/lib/wxr.mjs +307 -0
- package/lib/cli/lib/xml.d.mts +33 -0
- package/lib/cli/lib/xml.mjs +186 -0
- package/lib/cli/restore.d.mts +2 -0
- package/lib/cli/restore.mjs +98 -0
- package/lib/client/components/Alert.d.ts +7 -0
- package/lib/client/components/Alert.js +8 -0
- package/lib/client/components/Avatar.d.ts +15 -0
- package/lib/client/components/Avatar.js +10 -0
- package/lib/client/components/BackLink.d.ts +7 -0
- package/lib/client/components/BackLink.js +6 -0
- package/lib/client/components/Button.d.ts +7 -0
- package/lib/client/components/Button.js +12 -0
- package/lib/client/components/Card.d.ts +7 -0
- package/lib/client/components/Card.js +6 -0
- package/lib/client/components/CommentThread.d.ts +15 -0
- package/lib/client/components/CommentThread.js +101 -0
- package/lib/client/components/Empty.d.ts +6 -0
- package/lib/client/components/Empty.js +6 -0
- package/lib/client/components/Input.d.ts +6 -0
- package/lib/client/components/Input.js +6 -0
- package/lib/client/components/Link.d.ts +31 -0
- package/lib/client/components/Link.js +49 -0
- package/lib/client/components/Loading.d.ts +1 -0
- package/lib/client/components/Loading.js +6 -0
- package/lib/client/components/Logo.d.ts +5 -0
- package/lib/client/components/Logo.js +4 -0
- package/lib/client/components/MarkdownEditor.d.ts +41 -0
- package/lib/client/components/MarkdownEditor.js +156 -0
- package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
- package/lib/client/components/Nav/DarkModeToggle.js +6 -0
- package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
- package/lib/client/components/Nav/DesktopNav.js +9 -0
- package/lib/client/components/Nav/MobileNav.d.ts +9 -0
- package/lib/client/components/Nav/MobileNav.js +15 -0
- package/lib/client/components/NavLink.d.ts +8 -0
- package/lib/client/components/NavLink.js +6 -0
- package/lib/client/components/PageHeader.d.ts +8 -0
- package/lib/client/components/PageHeader.js +6 -0
- package/lib/client/components/PostCard.d.ts +8 -0
- package/lib/client/components/PostCard.js +7 -0
- package/lib/client/components/Textarea.d.ts +6 -0
- package/lib/client/components/Textarea.js +6 -0
- package/lib/client/components/ThemeContext.d.ts +18 -0
- package/lib/client/components/ThemeContext.js +8 -0
- package/lib/client/components/admin/AdminIcons.d.ts +13 -0
- package/lib/client/components/admin/AdminIcons.js +66 -0
- package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
- package/lib/client/components/admin/ContentModelPanels.js +93 -0
- package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
- package/lib/client/components/admin/FeaturedImageBox.js +24 -0
- package/lib/client/components/admin/MediaGrid.d.ts +23 -0
- package/lib/client/components/admin/MediaGrid.js +69 -0
- package/lib/client/components/admin/MediaPicker.d.ts +17 -0
- package/lib/client/components/admin/MediaPicker.js +61 -0
- package/lib/client/components/admin/Pagination.d.ts +27 -0
- package/lib/client/components/admin/Pagination.js +29 -0
- package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
- package/lib/client/components/admin/SnippetPicker.js +65 -0
- package/lib/client/components/admin/TermPicker.d.ts +52 -0
- package/lib/client/components/admin/TermPicker.js +58 -0
- package/lib/client/contexts/ToastContext.d.ts +12 -0
- package/lib/client/contexts/ToastContext.js +49 -0
- package/lib/client/features.d.ts +11 -0
- package/lib/client/features.js +7 -0
- package/lib/client/hooks/useContentTypes.d.ts +48 -0
- package/lib/client/hooks/useContentTypes.js +48 -0
- package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
- package/lib/client/hooks/useMediaLibrary.js +189 -0
- package/lib/client/hooks/usePostLock.d.ts +32 -0
- package/lib/client/hooks/usePostLock.js +107 -0
- package/lib/client/host/index.d.ts +71 -0
- package/lib/client/host/index.js +58 -0
- package/lib/client/i18n/index.d.ts +79 -0
- package/lib/client/i18n/index.js +177 -0
- package/lib/client/i18n/locales/es/content.d.ts +4 -0
- package/lib/client/i18n/locales/es/content.js +220 -0
- package/lib/client/i18n/locales/es/editor.d.ts +9 -0
- package/lib/client/i18n/locales/es/editor.js +144 -0
- package/lib/client/i18n/locales/es/index.d.ts +8 -0
- package/lib/client/i18n/locales/es/index.js +7 -0
- package/lib/client/i18n/locales/es/layout.d.ts +4 -0
- package/lib/client/i18n/locales/es/layout.js +35 -0
- package/lib/client/i18n/locales/es/people.d.ts +4 -0
- package/lib/client/i18n/locales/es/people.js +187 -0
- package/lib/client/i18n/locales/es/site.d.ts +4 -0
- package/lib/client/i18n/locales/es/site.js +208 -0
- package/lib/client/layouts/AdminLayout.d.ts +7 -0
- package/lib/client/layouts/AdminLayout.js +1046 -0
- package/lib/client/layouts/AppLayout.d.ts +6 -0
- package/lib/client/layouts/AppLayout.js +19 -0
- package/lib/client/layouts/AuthLayout.d.ts +6 -0
- package/lib/client/layouts/AuthLayout.js +14 -0
- package/lib/client/layouts/DocsLayout.d.ts +6 -0
- package/lib/client/layouts/DocsLayout.js +28 -0
- package/lib/client/layouts/RootLayout.d.ts +6 -0
- package/lib/client/layouts/RootLayout.js +11 -0
- package/lib/client/pages/AcceptInvite.d.ts +8 -0
- package/lib/client/pages/AcceptInvite.js +60 -0
- package/lib/client/pages/Auth.d.ts +1 -0
- package/lib/client/pages/Auth.js +40 -0
- package/lib/client/pages/Authentication.d.ts +1 -0
- package/lib/client/pages/Authentication.js +230 -0
- package/lib/client/pages/Content.d.ts +1 -0
- package/lib/client/pages/Content.js +21 -0
- package/lib/client/pages/Database.d.ts +1 -0
- package/lib/client/pages/Database.js +264 -0
- package/lib/client/pages/Extending.d.ts +1 -0
- package/lib/client/pages/Extending.js +28 -0
- package/lib/client/pages/Feed.d.ts +1 -0
- package/lib/client/pages/Feed.js +19 -0
- package/lib/client/pages/FeedPost.d.ts +1 -0
- package/lib/client/pages/FeedPost.js +31 -0
- package/lib/client/pages/ForgotPassword.d.ts +8 -0
- package/lib/client/pages/ForgotPassword.js +38 -0
- package/lib/client/pages/GettingStarted.d.ts +1 -0
- package/lib/client/pages/GettingStarted.js +84 -0
- package/lib/client/pages/Headless.d.ts +1 -0
- package/lib/client/pages/Headless.js +49 -0
- package/lib/client/pages/Home.d.ts +1 -0
- package/lib/client/pages/Home.js +67 -0
- package/lib/client/pages/PostForm.d.ts +1 -0
- package/lib/client/pages/PostForm.js +55 -0
- package/lib/client/pages/Posts.d.ts +1 -0
- package/lib/client/pages/Posts.js +35 -0
- package/lib/client/pages/Profile.d.ts +1 -0
- package/lib/client/pages/Profile.js +153 -0
- package/lib/client/pages/ResetPassword.d.ts +8 -0
- package/lib/client/pages/ResetPassword.js +52 -0
- package/lib/client/pages/Routing.d.ts +1 -0
- package/lib/client/pages/Routing.js +192 -0
- package/lib/client/pages/Storage.d.ts +1 -0
- package/lib/client/pages/Storage.js +54 -0
- package/lib/client/pages/Testing.d.ts +1 -0
- package/lib/client/pages/Testing.js +141 -0
- package/lib/client/pages/Validation.d.ts +1 -0
- package/lib/client/pages/Validation.js +123 -0
- package/lib/client/pages/admin/Categories.d.ts +2 -0
- package/lib/client/pages/admin/Categories.js +75 -0
- package/lib/client/pages/admin/Comments.d.ts +11 -0
- package/lib/client/pages/admin/Comments.js +247 -0
- package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
- package/lib/client/pages/admin/ContentTypes.js +163 -0
- package/lib/client/pages/admin/Dashboard.d.ts +2 -0
- package/lib/client/pages/admin/Dashboard.js +66 -0
- package/lib/client/pages/admin/Health.d.ts +12 -0
- package/lib/client/pages/admin/Health.js +148 -0
- package/lib/client/pages/admin/Media.d.ts +2 -0
- package/lib/client/pages/admin/Media.js +101 -0
- package/lib/client/pages/admin/Navigation.d.ts +9 -0
- package/lib/client/pages/admin/Navigation.js +230 -0
- package/lib/client/pages/admin/Pages.d.ts +2 -0
- package/lib/client/pages/admin/Pages.js +53 -0
- package/lib/client/pages/admin/PostEditor.d.ts +17 -0
- package/lib/client/pages/admin/PostEditor.js +532 -0
- package/lib/client/pages/admin/Posts.d.ts +2 -0
- package/lib/client/pages/admin/Posts.js +152 -0
- package/lib/client/pages/admin/Redirects.d.ts +10 -0
- package/lib/client/pages/admin/Redirects.js +87 -0
- package/lib/client/pages/admin/Settings.d.ts +2 -0
- package/lib/client/pages/admin/Settings.js +111 -0
- package/lib/client/pages/admin/Snippets.d.ts +14 -0
- package/lib/client/pages/admin/Snippets.js +85 -0
- package/lib/client/pages/admin/Tags.d.ts +2 -0
- package/lib/client/pages/admin/Tags.js +74 -0
- package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
- package/lib/client/pages/admin/Taxonomies.js +130 -0
- package/lib/client/pages/admin/Tokens.d.ts +9 -0
- package/lib/client/pages/admin/Tokens.js +260 -0
- package/lib/client/pages/admin/Tools.d.ts +12 -0
- package/lib/client/pages/admin/Tools.js +111 -0
- package/lib/client/pages/admin/Users.d.ts +13 -0
- package/lib/client/pages/admin/Users.js +313 -0
- package/lib/client/pages/api-reference.d.ts +33 -0
- package/lib/client/pages/api-reference.js +198 -0
- package/lib/client/styles.css +37 -0
- package/lib/config.d.ts +24 -0
- package/lib/config.js +39 -0
- package/lib/controllers/AdminController.d.ts +46 -0
- package/lib/controllers/AdminController.js +134 -0
- package/lib/controllers/AuthController.d.ts +15 -0
- package/lib/controllers/AuthController.js +194 -0
- package/lib/controllers/AuthorController.d.ts +17 -0
- package/lib/controllers/AuthorController.js +19 -0
- package/lib/controllers/CategoryController.d.ts +10 -0
- package/lib/controllers/CategoryController.js +88 -0
- package/lib/controllers/CommentController.d.ts +68 -0
- package/lib/controllers/CommentController.js +438 -0
- package/lib/controllers/ContentTypeController.d.ts +24 -0
- package/lib/controllers/ContentTypeController.js +91 -0
- package/lib/controllers/EmailVerificationController.d.ts +33 -0
- package/lib/controllers/EmailVerificationController.js +116 -0
- package/lib/controllers/ExportController.d.ts +15 -0
- package/lib/controllers/ExportController.js +41 -0
- package/lib/controllers/FeedController.d.ts +14 -0
- package/lib/controllers/FeedController.js +246 -0
- package/lib/controllers/HealthController.d.ts +21 -0
- package/lib/controllers/HealthController.js +176 -0
- package/lib/controllers/HomeController.d.ts +12 -0
- package/lib/controllers/HomeController.js +16 -0
- package/lib/controllers/MediaController.d.ts +24 -0
- package/lib/controllers/MediaController.js +189 -0
- package/lib/controllers/NavigationController.d.ts +22 -0
- package/lib/controllers/NavigationController.js +176 -0
- package/lib/controllers/PageController.d.ts +13 -0
- package/lib/controllers/PageController.js +172 -0
- package/lib/controllers/PasskeyController.d.ts +36 -0
- package/lib/controllers/PasskeyController.js +201 -0
- package/lib/controllers/PasswordResetController.d.ts +44 -0
- package/lib/controllers/PasswordResetController.js +160 -0
- package/lib/controllers/PostController.d.ts +51 -0
- package/lib/controllers/PostController.js +538 -0
- package/lib/controllers/PostLockController.d.ts +62 -0
- package/lib/controllers/PostLockController.js +101 -0
- package/lib/controllers/ProfileController.d.ts +13 -0
- package/lib/controllers/ProfileController.js +160 -0
- package/lib/controllers/PublicApiController.d.ts +23 -0
- package/lib/controllers/PublicApiController.js +100 -0
- package/lib/controllers/RedirectController.d.ts +32 -0
- package/lib/controllers/RedirectController.js +95 -0
- package/lib/controllers/SettingsController.d.ts +28 -0
- package/lib/controllers/SettingsController.js +105 -0
- package/lib/controllers/SnippetController.d.ts +27 -0
- package/lib/controllers/SnippetController.js +123 -0
- package/lib/controllers/TagController.d.ts +9 -0
- package/lib/controllers/TagController.js +70 -0
- package/lib/controllers/TaxonomyController.d.ts +24 -0
- package/lib/controllers/TaxonomyController.js +149 -0
- package/lib/controllers/TokenController.d.ts +27 -0
- package/lib/controllers/TokenController.js +83 -0
- package/lib/controllers/TwoFactorController.d.ts +31 -0
- package/lib/controllers/TwoFactorController.js +213 -0
- package/lib/controllers/UserController.d.ts +110 -0
- package/lib/controllers/UserController.js +504 -0
- package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
- package/lib/features/analytics/AnalyticsPage.js +123 -0
- package/lib/features/analytics/admin.d.ts +3 -0
- package/lib/features/analytics/admin.js +9 -0
- package/lib/features/analytics/controller.d.ts +19 -0
- package/lib/features/analytics/controller.js +79 -0
- package/lib/features/analytics/helpers.d.ts +84 -0
- package/lib/features/analytics/helpers.js +181 -0
- package/lib/features/analytics/i18n/es.d.ts +4 -0
- package/lib/features/analytics/i18n/es.js +31 -0
- package/lib/features/analytics/index.d.ts +28 -0
- package/lib/features/analytics/index.js +91 -0
- package/lib/features/analytics/manifest.d.ts +8 -0
- package/lib/features/analytics/manifest.js +18 -0
- package/lib/features/analytics/model.d.ts +130 -0
- package/lib/features/analytics/model.js +206 -0
- package/lib/features/members/Member.d.ts +93 -0
- package/lib/features/members/Member.js +194 -0
- package/lib/features/members/MemberAdminController.d.ts +60 -0
- package/lib/features/members/MemberAdminController.js +262 -0
- package/lib/features/members/MemberController.d.ts +88 -0
- package/lib/features/members/MemberController.js +250 -0
- package/lib/features/members/MembersPage.d.ts +10 -0
- package/lib/features/members/MembersPage.js +216 -0
- package/lib/features/members/PostAccessBox.d.ts +15 -0
- package/lib/features/members/PostAccessBox.js +70 -0
- package/lib/features/members/admin.d.ts +3 -0
- package/lib/features/members/admin.js +12 -0
- package/lib/features/members/csv.d.ts +21 -0
- package/lib/features/members/csv.js +74 -0
- package/lib/features/members/events.d.ts +34 -0
- package/lib/features/members/events.js +34 -0
- package/lib/features/members/i18n/es.d.ts +4 -0
- package/lib/features/members/i18n/es.js +106 -0
- package/lib/features/members/index.d.ts +44 -0
- package/lib/features/members/index.js +106 -0
- package/lib/features/members/manifest.d.ts +8 -0
- package/lib/features/members/manifest.js +18 -0
- package/lib/features/members/middleware.d.ts +42 -0
- package/lib/features/members/middleware.js +74 -0
- package/lib/features/members/newsletter.d.ts +177 -0
- package/lib/features/members/newsletter.js +439 -0
- package/lib/features/members/rate-limits.d.ts +34 -0
- package/lib/features/members/rate-limits.js +50 -0
- package/lib/features/members/request.d.ts +13 -0
- package/lib/features/members/request.js +6 -0
- package/lib/features/members/routes.d.ts +15 -0
- package/lib/features/members/routes.js +59 -0
- package/lib/features/members/session.d.ts +102 -0
- package/lib/features/members/session.js +158 -0
- package/lib/features/members/settings.d.ts +14 -0
- package/lib/features/members/settings.js +23 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
- package/lib/features/mysendbox/admin.d.ts +3 -0
- package/lib/features/mysendbox/admin.js +9 -0
- package/lib/features/mysendbox/broadcasts.d.ts +61 -0
- package/lib/features/mysendbox/broadcasts.js +124 -0
- package/lib/features/mysendbox/client.d.ts +95 -0
- package/lib/features/mysendbox/client.js +61 -0
- package/lib/features/mysendbox/config.d.ts +27 -0
- package/lib/features/mysendbox/config.js +74 -0
- package/lib/features/mysendbox/contacts.d.ts +121 -0
- package/lib/features/mysendbox/contacts.js +378 -0
- package/lib/features/mysendbox/controller.d.ts +11 -0
- package/lib/features/mysendbox/controller.js +47 -0
- package/lib/features/mysendbox/i18n/es.d.ts +4 -0
- package/lib/features/mysendbox/i18n/es.js +28 -0
- package/lib/features/mysendbox/index.d.ts +18 -0
- package/lib/features/mysendbox/index.js +71 -0
- package/lib/features/mysendbox/manifest.d.ts +7 -0
- package/lib/features/mysendbox/manifest.js +6 -0
- package/lib/features/mysendbox/routes.d.ts +6 -0
- package/lib/features/mysendbox/routes.js +14 -0
- package/lib/features/mysendbox/webhook.d.ts +23 -0
- package/lib/features/mysendbox/webhook.js +104 -0
- package/lib/features/theme/OEmbedController.d.ts +31 -0
- package/lib/features/theme/OEmbedController.js +128 -0
- package/lib/features/theme/ThemeController.d.ts +20 -0
- package/lib/features/theme/ThemeController.js +256 -0
- package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
- package/lib/features/theme/ThemeSettingsCard.js +12 -0
- package/lib/features/theme/admin.d.ts +3 -0
- package/lib/features/theme/admin.js +9 -0
- package/lib/features/theme/html.d.ts +48 -0
- package/lib/features/theme/html.js +97 -0
- package/lib/features/theme/i18n/es.d.ts +4 -0
- package/lib/features/theme/i18n/es.js +9 -0
- package/lib/features/theme/index.d.ts +11 -0
- package/lib/features/theme/index.js +23 -0
- package/lib/features/theme/manifest.d.ts +7 -0
- package/lib/features/theme/manifest.js +6 -0
- package/lib/features/theme/oembed.d.ts +36 -0
- package/lib/features/theme/oembed.js +58 -0
- package/lib/features/theme/routes.d.ts +17 -0
- package/lib/features/theme/routes.js +54 -0
- package/lib/features/theme/templates.d.ts +103 -0
- package/lib/features/theme/templates.js +283 -0
- package/lib/features.d.ts +15 -0
- package/lib/features.js +6 -0
- package/lib/features.manifest.d.ts +10 -0
- package/lib/features.manifest.js +6 -0
- package/lib/helpers/access.d.ts +62 -0
- package/lib/helpers/access.js +92 -0
- package/lib/helpers/api.d.ts +20 -0
- package/lib/helpers/api.js +44 -0
- package/lib/helpers/comment-guard.d.ts +145 -0
- package/lib/helpers/comment-guard.js +253 -0
- package/lib/helpers/comment-mail.d.ts +53 -0
- package/lib/helpers/comment-mail.js +188 -0
- package/lib/helpers/content-model.d.ts +50 -0
- package/lib/helpers/content-model.js +84 -0
- package/lib/helpers/content-paths.d.ts +107 -0
- package/lib/helpers/content-paths.js +200 -0
- package/lib/helpers/export-data.d.ts +85 -0
- package/lib/helpers/export-data.js +229 -0
- package/lib/helpers/gating.d.ts +53 -0
- package/lib/helpers/gating.js +83 -0
- package/lib/helpers/health.d.ts +91 -0
- package/lib/helpers/health.js +279 -0
- package/lib/helpers/heartbeat.d.ts +35 -0
- package/lib/helpers/heartbeat.js +55 -0
- package/lib/helpers/image-size.d.ts +18 -0
- package/lib/helpers/image-size.js +83 -0
- package/lib/helpers/images.d.ts +29 -0
- package/lib/helpers/images.js +41 -0
- package/lib/helpers/mail-templates.d.ts +11 -0
- package/lib/helpers/mail-templates.js +42 -0
- package/lib/helpers/publish-due.d.ts +28 -0
- package/lib/helpers/publish-due.js +67 -0
- package/lib/helpers/redirects.d.ts +43 -0
- package/lib/helpers/redirects.js +80 -0
- package/lib/helpers/seo-fields.d.ts +13 -0
- package/lib/helpers/seo-fields.js +52 -0
- package/lib/helpers/session.d.ts +30 -0
- package/lib/helpers/session.js +27 -0
- package/lib/helpers/site-settings.d.ts +98 -0
- package/lib/helpers/site-settings.js +232 -0
- package/lib/helpers/site.d.ts +14 -0
- package/lib/helpers/site.js +23 -0
- package/lib/helpers/write-hooks.d.ts +33 -0
- package/lib/helpers/write-hooks.js +37 -0
- package/lib/hooks.d.ts +17 -0
- package/lib/hooks.js +101 -0
- package/lib/host/core-tasks.d.ts +4 -0
- package/lib/host/core-tasks.js +26 -0
- package/lib/host/cron.d.ts +39 -0
- package/lib/host/cron.js +85 -0
- package/lib/host/enabled.d.ts +4 -0
- package/lib/host/enabled.js +40 -0
- package/lib/host/index.d.ts +81 -0
- package/lib/host/index.js +87 -0
- package/lib/host/manifest.d.ts +34 -0
- package/lib/host/manifest.js +7 -0
- package/lib/host/menu.d.ts +18 -0
- package/lib/host/menu.js +15 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +24 -0
- package/lib/middleware/api-auth.d.ts +59 -0
- package/lib/middleware/api-auth.js +164 -0
- package/lib/middleware/auth.d.ts +49 -0
- package/lib/middleware/auth.js +112 -0
- package/lib/middleware/cache.d.ts +17 -0
- package/lib/middleware/cache.js +52 -0
- package/lib/middleware/rate-limits.d.ts +199 -0
- package/lib/middleware/rate-limits.js +276 -0
- package/lib/middleware/viewer.d.ts +13 -0
- package/lib/middleware/viewer.js +16 -0
- package/lib/models/Category.d.ts +24 -0
- package/lib/models/Category.js +102 -0
- package/lib/models/Comment.d.ts +120 -0
- package/lib/models/Comment.js +283 -0
- package/lib/models/ContentType.d.ts +142 -0
- package/lib/models/ContentType.js +462 -0
- package/lib/models/Credential.d.ts +21 -0
- package/lib/models/Credential.js +31 -0
- package/lib/models/Media.d.ts +53 -0
- package/lib/models/Media.js +132 -0
- package/lib/models/Menu.d.ts +131 -0
- package/lib/models/Menu.js +312 -0
- package/lib/models/Page.d.ts +55 -0
- package/lib/models/Page.js +218 -0
- package/lib/models/Post.d.ts +136 -0
- package/lib/models/Post.js +406 -0
- package/lib/models/PostLock.d.ts +67 -0
- package/lib/models/PostLock.js +112 -0
- package/lib/models/PostRevision.d.ts +45 -0
- package/lib/models/PostRevision.js +82 -0
- package/lib/models/PublicContent.d.ts +283 -0
- package/lib/models/PublicContent.js +577 -0
- package/lib/models/Redirect.d.ts +123 -0
- package/lib/models/Redirect.js +225 -0
- package/lib/models/Settings.d.ts +61 -0
- package/lib/models/Settings.js +128 -0
- package/lib/models/Snippet.d.ts +36 -0
- package/lib/models/Snippet.js +64 -0
- package/lib/models/Tag.d.ts +23 -0
- package/lib/models/Tag.js +117 -0
- package/lib/models/Taxonomy.d.ts +127 -0
- package/lib/models/Taxonomy.js +321 -0
- package/lib/models/TwoFactor.d.ts +26 -0
- package/lib/models/TwoFactor.js +60 -0
- package/lib/models/User.d.ts +49 -0
- package/lib/models/User.js +128 -0
- package/lib/models/derive.d.ts +69 -0
- package/lib/models/derive.js +81 -0
- package/lib/models/pagination.d.ts +30 -0
- package/lib/models/pagination.js +36 -0
- package/lib/models/visibility.d.ts +31 -0
- package/lib/models/visibility.js +47 -0
- package/lib/routes/App.d.ts +2 -0
- package/lib/routes/App.js +146 -0
- package/lib/routes/api/admin.d.ts +6 -0
- package/lib/routes/api/admin.js +11 -0
- package/lib/routes/api/auth.d.ts +6 -0
- package/lib/routes/api/auth.js +24 -0
- package/lib/routes/api/authors.d.ts +5 -0
- package/lib/routes/api/authors.js +8 -0
- package/lib/routes/api/categories.d.ts +8 -0
- package/lib/routes/api/categories.js +15 -0
- package/lib/routes/api/comments.d.ts +8 -0
- package/lib/routes/api/comments.js +35 -0
- package/lib/routes/api/content-model.d.ts +17 -0
- package/lib/routes/api/content-model.js +67 -0
- package/lib/routes/api/cron.d.ts +6 -0
- package/lib/routes/api/cron.js +9 -0
- package/lib/routes/api/export.d.ts +5 -0
- package/lib/routes/api/export.js +11 -0
- package/lib/routes/api/feed.d.ts +5 -0
- package/lib/routes/api/feed.js +16 -0
- package/lib/routes/api/media.d.ts +8 -0
- package/lib/routes/api/media.js +25 -0
- package/lib/routes/api/navigation.d.ts +12 -0
- package/lib/routes/api/navigation.js +17 -0
- package/lib/routes/api/ops.d.ts +9 -0
- package/lib/routes/api/ops.js +19 -0
- package/lib/routes/api/pages.d.ts +8 -0
- package/lib/routes/api/pages.js +21 -0
- package/lib/routes/api/passkeys.d.ts +7 -0
- package/lib/routes/api/passkeys.js +13 -0
- package/lib/routes/api/posts.d.ts +8 -0
- package/lib/routes/api/posts.js +39 -0
- package/lib/routes/api/profile.d.ts +6 -0
- package/lib/routes/api/profile.js +8 -0
- package/lib/routes/api/redirects.d.ts +12 -0
- package/lib/routes/api/redirects.js +13 -0
- package/lib/routes/api/settings.d.ts +8 -0
- package/lib/routes/api/settings.js +15 -0
- package/lib/routes/api/snippets.d.ts +15 -0
- package/lib/routes/api/snippets.js +16 -0
- package/lib/routes/api/tags.d.ts +8 -0
- package/lib/routes/api/tags.js +14 -0
- package/lib/routes/api/tokens.d.ts +7 -0
- package/lib/routes/api/tokens.js +15 -0
- package/lib/routes/api/two-factor.d.ts +7 -0
- package/lib/routes/api/two-factor.js +15 -0
- package/lib/routes/api/users.d.ts +8 -0
- package/lib/routes/api/users.js +25 -0
- package/lib/routes/api/v1.d.ts +12 -0
- package/lib/routes/api/v1.js +55 -0
- package/lib/routes/api/verification.d.ts +6 -0
- package/lib/routes/api/verification.js +11 -0
- package/lib/server/index.d.ts +24 -0
- package/lib/server/index.js +110 -0
- package/lib/types/index.d.ts +298 -0
- package/lib/types/index.js +1 -0
- package/lib/vite.d.ts +2 -0
- package/lib/vite.js +101 -0
- package/mail/comment-moderation.html +27 -0
- package/mail/comment-moderation.txt +13 -0
- package/mail/comment-reply.html +28 -0
- package/mail/comment-reply.txt +14 -0
- package/mail/invitation.html +25 -0
- package/mail/invitation.txt +11 -0
- package/mail/member-magic-link.html +23 -0
- package/mail/member-magic-link.txt +10 -0
- package/mail/newsletter.html +26 -0
- package/mail/newsletter.txt +13 -0
- package/mail/password-reset.html +26 -0
- package/mail/password-reset.txt +10 -0
- package/mail/verify-email.html +25 -0
- package/mail/verify-email.txt +8 -0
- package/package.json +85 -4
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { verifyPassword } from '@basicbenframework/core/auth';
|
|
2
|
+
import { issueSessionToken } from "../helpers/session.js";
|
|
3
|
+
import { DEFAULT_ROLE } from '@basicbenframework/core/auth/permissions';
|
|
4
|
+
import { issueToken, redeemToken, TOKEN_KINDS } from '@basicbenframework/core/auth/tokens';
|
|
5
|
+
import { generateSecret, verifyTotp, otpauthUri, encryptSecret, decryptSecret } from '@basicbenframework/core/auth/totp';
|
|
6
|
+
import { generateRecoveryCodes, hashRecoveryCodes, findRecoveryCode, lockoutState, registerFailure } from '@basicbenframework/core/auth/two-factor';
|
|
7
|
+
import { User } from "../models/User.js";
|
|
8
|
+
import { verifyPasskeyAssertion } from "./PasskeyController.js";
|
|
9
|
+
import { TwoFactor } from "../models/TwoFactor.js";
|
|
10
|
+
// A challenge is the only thing standing between a correct password and a
|
|
11
|
+
// session, so it is short-lived and single use.
|
|
12
|
+
const CHALLENGE_TTL = 5 * 60 * 1000;
|
|
13
|
+
const issuer = () => process.env.SITE_NAME || 'BasicBen';
|
|
14
|
+
/**
|
|
15
|
+
* Start the second step of a login.
|
|
16
|
+
*
|
|
17
|
+
* Returns an opaque challenge rather than a session token. It lives in
|
|
18
|
+
* auth_tokens, never as a JWT, so verifyJwt cannot return one and it can never
|
|
19
|
+
* be mistaken for a session — which would bypass the second factor entirely.
|
|
20
|
+
*/
|
|
21
|
+
export async function issueChallenge(userId) {
|
|
22
|
+
const { token, expiresAt } = await issueToken(userId, TOKEN_KINDS.TWO_FACTOR_CHALLENGE, {
|
|
23
|
+
ttl: CHALLENGE_TTL
|
|
24
|
+
});
|
|
25
|
+
return { challenge: token, expiresAt };
|
|
26
|
+
}
|
|
27
|
+
/** Mint the real session once a second factor has been satisfied. */
|
|
28
|
+
function sessionFor(user) {
|
|
29
|
+
const role = user.role ?? DEFAULT_ROLE;
|
|
30
|
+
const emailVerified = Boolean(user.email_verified);
|
|
31
|
+
return {
|
|
32
|
+
token: issueSessionToken(user),
|
|
33
|
+
user: { id: user.id, name: user.name, email: user.email, role, email_verified: emailVerified }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Enrolling or removing a factor is a credential change, so it needs the
|
|
38
|
+
* password even though the caller is already signed in. Without this a stolen
|
|
39
|
+
* session becomes permanent account takeover: the attacker enrols their own
|
|
40
|
+
* factor and locks the owner out.
|
|
41
|
+
*/
|
|
42
|
+
async function confirmPassword(req, res) {
|
|
43
|
+
const { password } = req.body;
|
|
44
|
+
const user = await User.find(req.userId);
|
|
45
|
+
if (!user) {
|
|
46
|
+
res.json({ error: 'User not found' }, 404);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (!password || !(await verifyPassword(password, user.password))) {
|
|
50
|
+
res.json({ error: 'Your current password is required.' }, 403);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return user;
|
|
54
|
+
}
|
|
55
|
+
export const TwoFactorController = {
|
|
56
|
+
/** What is enrolled, for the account settings screen. */
|
|
57
|
+
async status(req, res) {
|
|
58
|
+
const record = await TwoFactor.find(req.userId);
|
|
59
|
+
return res.json({
|
|
60
|
+
totp: {
|
|
61
|
+
enabled: TwoFactor.isEnabled(record),
|
|
62
|
+
enabledAt: record?.totp_enabled_at ?? null
|
|
63
|
+
},
|
|
64
|
+
recoveryCodesRemaining: TwoFactor.parseRecoveryCodes(record).length
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Generate a secret. Deliberately does not enable anything — enrolment is
|
|
69
|
+
* only complete once a working code proves the authenticator was configured.
|
|
70
|
+
*/
|
|
71
|
+
async setupTotp(req, res) {
|
|
72
|
+
const user = await confirmPassword(req, res);
|
|
73
|
+
if (!user)
|
|
74
|
+
return;
|
|
75
|
+
const existing = await TwoFactor.find(user.id);
|
|
76
|
+
if (TwoFactor.isEnabled(existing)) {
|
|
77
|
+
return res.json({ error: 'An authenticator app is already enrolled. Remove it first.' }, 409);
|
|
78
|
+
}
|
|
79
|
+
const secret = generateSecret();
|
|
80
|
+
await TwoFactor.findOrCreate(user.id);
|
|
81
|
+
await TwoFactor.update(user.id, {
|
|
82
|
+
totp_secret: encryptSecret(secret),
|
|
83
|
+
totp_enabled_at: null,
|
|
84
|
+
totp_last_step: null
|
|
85
|
+
});
|
|
86
|
+
// The URI is returned rather than a QR image: rendering one is the client's
|
|
87
|
+
// job, and it keeps the secret out of anything the server might cache.
|
|
88
|
+
return res.json({
|
|
89
|
+
secret,
|
|
90
|
+
uri: otpauthUri({ secret, label: user.email, issuer: issuer() })
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
/** Confirm the authenticator works, then enable and hand over recovery codes. */
|
|
94
|
+
async confirmTotp(req, res) {
|
|
95
|
+
const { code } = req.body;
|
|
96
|
+
const record = await TwoFactor.find(req.userId);
|
|
97
|
+
if (!record?.totp_secret) {
|
|
98
|
+
return res.json({ error: 'Start by generating a secret.' }, 400);
|
|
99
|
+
}
|
|
100
|
+
if (record.totp_enabled_at) {
|
|
101
|
+
return res.json({ error: 'An authenticator app is already enrolled.' }, 409);
|
|
102
|
+
}
|
|
103
|
+
const secret = decryptSecret(record.totp_secret);
|
|
104
|
+
if (!secret) {
|
|
105
|
+
return res.json({ error: 'The stored secret could not be read. Start again.' }, 500);
|
|
106
|
+
}
|
|
107
|
+
const result = verifyTotp(secret, code, { lastStep: record.totp_last_step });
|
|
108
|
+
if (!result.valid) {
|
|
109
|
+
return res.json({ error: 'That code is not right. Check your authenticator app.' }, 400);
|
|
110
|
+
}
|
|
111
|
+
const codes = generateRecoveryCodes();
|
|
112
|
+
await TwoFactor.update(req.userId, {
|
|
113
|
+
totp_enabled_at: new Date().toISOString(),
|
|
114
|
+
totp_last_step: result.step,
|
|
115
|
+
recovery_codes: JSON.stringify(await hashRecoveryCodes(codes)),
|
|
116
|
+
failed_attempts: 0,
|
|
117
|
+
locked_until: null
|
|
118
|
+
});
|
|
119
|
+
// Shown exactly once. They are hashed, so they cannot be shown again.
|
|
120
|
+
return res.json({
|
|
121
|
+
enabled: true,
|
|
122
|
+
recoveryCodes: codes
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
/** Remove the authenticator. */
|
|
126
|
+
async disableTotp(req, res) {
|
|
127
|
+
const user = await confirmPassword(req, res);
|
|
128
|
+
if (!user)
|
|
129
|
+
return;
|
|
130
|
+
await TwoFactor.delete(user.id);
|
|
131
|
+
return res.json({ enabled: false });
|
|
132
|
+
},
|
|
133
|
+
/** Replace the recovery codes, invalidating the old set. */
|
|
134
|
+
async rotateRecoveryCodes(req, res) {
|
|
135
|
+
const user = await confirmPassword(req, res);
|
|
136
|
+
if (!user)
|
|
137
|
+
return;
|
|
138
|
+
const record = await TwoFactor.find(user.id);
|
|
139
|
+
if (!TwoFactor.isEnabled(record)) {
|
|
140
|
+
return res.json({ error: 'No second factor is enrolled.' }, 400);
|
|
141
|
+
}
|
|
142
|
+
const codes = generateRecoveryCodes();
|
|
143
|
+
await TwoFactor.update(user.id, { recovery_codes: JSON.stringify(await hashRecoveryCodes(codes)) });
|
|
144
|
+
return res.json({ recoveryCodes: codes });
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* The second step of a login: exchange a challenge plus a code for a session.
|
|
148
|
+
*/
|
|
149
|
+
async verify(req, res) {
|
|
150
|
+
const { challenge, code, challengeHandle, response } = req.body;
|
|
151
|
+
// A passkey is one method behind this endpoint rather than a separate login
|
|
152
|
+
// flow, so a third factor would slot in the same way.
|
|
153
|
+
if (challengeHandle && response) {
|
|
154
|
+
const result = await verifyPasskeyAssertion({ challengeHandle, response });
|
|
155
|
+
if (!result.ok) {
|
|
156
|
+
return res.json({ error: result.error }, 401);
|
|
157
|
+
}
|
|
158
|
+
const passkeyUser = await User.find(result.userId);
|
|
159
|
+
if (!passkeyUser) {
|
|
160
|
+
return res.json({ error: 'That sign-in attempt has expired. Please start again.' }, 401);
|
|
161
|
+
}
|
|
162
|
+
return res.json(sessionFor(passkeyUser));
|
|
163
|
+
}
|
|
164
|
+
const redeemed = await redeemToken(challenge, TOKEN_KINDS.TWO_FACTOR_CHALLENGE);
|
|
165
|
+
if (!redeemed) {
|
|
166
|
+
return res.json({ error: 'That sign-in attempt has expired. Please start again.' }, 401);
|
|
167
|
+
}
|
|
168
|
+
const user = await User.find(redeemed.userId);
|
|
169
|
+
const record = await TwoFactor.find(redeemed.userId);
|
|
170
|
+
if (!user || !TwoFactor.isEnabled(record)) {
|
|
171
|
+
return res.json({ error: 'That sign-in attempt has expired. Please start again.' }, 401);
|
|
172
|
+
}
|
|
173
|
+
// Five tries against a million possibilities is the entire security
|
|
174
|
+
// argument for a six-digit code, so the lock is not optional.
|
|
175
|
+
const lock = lockoutState(record);
|
|
176
|
+
if (lock.locked) {
|
|
177
|
+
return res.json({ error: 'Too many incorrect codes. Try again shortly.', retryAfter: lock.retryAfter }, 429);
|
|
178
|
+
}
|
|
179
|
+
const secret = decryptSecret(record.totp_secret);
|
|
180
|
+
const result = secret
|
|
181
|
+
? verifyTotp(secret, code, { lastStep: record.totp_last_step })
|
|
182
|
+
: { valid: false, step: null };
|
|
183
|
+
if (result.valid) {
|
|
184
|
+
await TwoFactor.update(user.id, {
|
|
185
|
+
totp_last_step: result.step,
|
|
186
|
+
failed_attempts: 0,
|
|
187
|
+
locked_until: null
|
|
188
|
+
});
|
|
189
|
+
return res.json(sessionFor(user));
|
|
190
|
+
}
|
|
191
|
+
// A recovery code is a full second factor, for when the phone is gone.
|
|
192
|
+
const hashes = TwoFactor.parseRecoveryCodes(record);
|
|
193
|
+
const index = await findRecoveryCode(code, hashes);
|
|
194
|
+
if (index !== -1) {
|
|
195
|
+
hashes.splice(index, 1); // single use
|
|
196
|
+
await TwoFactor.update(user.id, {
|
|
197
|
+
recovery_codes: JSON.stringify(hashes),
|
|
198
|
+
failed_attempts: 0,
|
|
199
|
+
locked_until: null
|
|
200
|
+
});
|
|
201
|
+
return res.json({ ...sessionFor(user), recoveryCodeUsed: true, recoveryCodesRemaining: hashes.length });
|
|
202
|
+
}
|
|
203
|
+
const failure = registerFailure(record);
|
|
204
|
+
await TwoFactor.update(user.id, {
|
|
205
|
+
failed_attempts: failure.failedAttempts,
|
|
206
|
+
locked_until: failure.lockedUntil
|
|
207
|
+
});
|
|
208
|
+
if (failure.locked) {
|
|
209
|
+
return res.json({ error: 'Too many incorrect codes. Try again shortly.' }, 429);
|
|
210
|
+
}
|
|
211
|
+
return res.json({ error: 'That code is not right.' }, 401);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The people who can sign in: listing them, changing what they may do,
|
|
3
|
+
* switching them off, removing them, and inviting new ones.
|
|
4
|
+
*
|
|
5
|
+
* Every route here is behind `user.manage`, which only an admin holds. That
|
|
6
|
+
* makes the admin role the one thing this controller must never let go to
|
|
7
|
+
* zero: an install with no active admin has nobody who can grant the role
|
|
8
|
+
* back, and the only fix is a hand-written SQL statement on the server. So
|
|
9
|
+
* every write that can take admin away from someone — a role change, a
|
|
10
|
+
* disable, a delete — goes through a conditional statement that refuses to
|
|
11
|
+
* remove the last active admin, and refuses to let an admin do it to
|
|
12
|
+
* themselves.
|
|
13
|
+
*
|
|
14
|
+
* The last-admin rule is enforced in the UPDATE/DELETE itself rather than by
|
|
15
|
+
* counting first and writing second. Two admins demoting each other at the
|
|
16
|
+
* same moment would both count two, both proceed, and leave none; a single
|
|
17
|
+
* conditional statement cannot interleave like that.
|
|
18
|
+
*/
|
|
19
|
+
import type { Request, Response } from '../types/index.ts';
|
|
20
|
+
/**
|
|
21
|
+
* The auth_tokens kind for an invitation.
|
|
22
|
+
*
|
|
23
|
+
* Kinds are plain strings in the framework, not a closed enum, so this needs
|
|
24
|
+
* no framework change and no table of its own. The row's `user_id` is the
|
|
25
|
+
* person who sent the invitation — the invitee has no account to point at
|
|
26
|
+
* yet, and the column is NOT NULL — and who it is for travels in `metadata`.
|
|
27
|
+
* A consequence worth knowing: deleting the sender cascades their pending
|
|
28
|
+
* invitations away, which is the behaviour you would want anyway.
|
|
29
|
+
*/
|
|
30
|
+
export declare const INVITATION_KIND = "invitation";
|
|
31
|
+
export declare const UserController: {
|
|
32
|
+
/**
|
|
33
|
+
* Everyone, a page at a time, newest first.
|
|
34
|
+
*
|
|
35
|
+
* `?search=` matches name or address; `?role=` narrows to one role. The post
|
|
36
|
+
* count rides along so the delete dialog knows whether to ask where their
|
|
37
|
+
* posts should go before the admin clicks anything.
|
|
38
|
+
*/
|
|
39
|
+
index(req: Request, res: Response): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Rename someone, or change their role.
|
|
42
|
+
*
|
|
43
|
+
* A role change ends the account's sessions. The auth middleware reads the
|
|
44
|
+
* role fresh on every request, so the new role would apply anyway; revoking
|
|
45
|
+
* makes the change unmistakable — the client re-signs in and gets claims
|
|
46
|
+
* that match, rather than carrying a token whose `role` says otherwise.
|
|
47
|
+
*/
|
|
48
|
+
update(req: Request, res: Response): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Switch an account off without deleting it.
|
|
51
|
+
*
|
|
52
|
+
* Their posts keep their byline and nothing has to be reassigned. Sessions
|
|
53
|
+
* end immediately, and sign-in refuses the account until it is enabled.
|
|
54
|
+
*/
|
|
55
|
+
disable(req: Request, res: Response): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Switch an account back on.
|
|
58
|
+
*
|
|
59
|
+
* Their old sessions stay dead — disabling bumped the token version — so
|
|
60
|
+
* they sign in again, which is what you would want after a suspension.
|
|
61
|
+
*/
|
|
62
|
+
enable(req: Request, res: Response): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Remove an account.
|
|
65
|
+
*
|
|
66
|
+
* A post cannot lose its author — `posts.user_id` is NOT NULL and has no
|
|
67
|
+
* cascade, deliberately, because deleting someone should never silently
|
|
68
|
+
* delete what they published. So someone with posts is deleted only with
|
|
69
|
+
* `?reassign=<userId>`, which moves their posts (trashed ones included) and
|
|
70
|
+
* their uploads to that person first, the way WordPress asks "attribute all
|
|
71
|
+
* content to…". Pages carry no author in this schema, so there is nothing of
|
|
72
|
+
* theirs to move.
|
|
73
|
+
*
|
|
74
|
+
* Their credentials — API tokens, single-use links, second factors,
|
|
75
|
+
* passkeys — are deleted explicitly rather than left to ON DELETE CASCADE,
|
|
76
|
+
* since not every driver this runs on enforces foreign keys by default.
|
|
77
|
+
*/
|
|
78
|
+
destroy(req: Request, res: Response): Promise<void>;
|
|
79
|
+
};
|
|
80
|
+
export declare const InvitationController: {
|
|
81
|
+
/**
|
|
82
|
+
* Invite someone by address.
|
|
83
|
+
*
|
|
84
|
+
* Sending another invitation to the same address replaces the earlier one,
|
|
85
|
+
* so the newest email is always the one that works and the pending list
|
|
86
|
+
* never shows the same person twice.
|
|
87
|
+
*/
|
|
88
|
+
store(req: Request, res: Response): Promise<void>;
|
|
89
|
+
/** Invitations nobody has accepted yet, and which have not expired. */
|
|
90
|
+
index(_req: Request, res: Response): Promise<void>;
|
|
91
|
+
/** Withdraw an invitation, so its link stops working. */
|
|
92
|
+
destroy(req: Request, res: Response): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* What the accept page needs to show: who this is for, and where.
|
|
95
|
+
*
|
|
96
|
+
* Public, because the person holding the link has no account yet. The link
|
|
97
|
+
* is the credential — 32 random bytes — so answering for it reveals nothing
|
|
98
|
+
* to someone who does not already have the email.
|
|
99
|
+
*/
|
|
100
|
+
show(req: Request, res: Response): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Turn an invitation into an account and sign it in.
|
|
103
|
+
*
|
|
104
|
+
* Deliberately not subject to DISABLE_REGISTRATION: on a closed site an
|
|
105
|
+
* invitation is the *only* way a new person gets in, and it is an admin who
|
|
106
|
+
* opened the door, not the visitor. The address counts as verified because
|
|
107
|
+
* following the emailed link is exactly what verification asks for.
|
|
108
|
+
*/
|
|
109
|
+
accept(req: Request, res: Response): Promise<void>;
|
|
110
|
+
};
|