studiocms 0.1.0-beta.25 → 0.1.0-beta.26
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/CHANGELOG.md +91 -0
- package/dist/cli/users/steps/libsqlCreateUsers.js +1 -3
- package/dist/cli/users/steps/libsqlModifyUsers.js +1 -3
- package/dist/components/auth/OAuthButton.astro +1 -1
- package/dist/components/auth/OAuthButtonStack.astro +1 -1
- package/dist/components/auth/component-scripts/formListener.js +1 -1
- package/dist/components/dashboard/BaseHead.astro +6 -17
- package/dist/components/dashboard/DashboardGrid.astro +2 -2
- package/dist/components/dashboard/DashboardGridItem.astro +2 -1
- package/dist/components/dashboard/DashboardPageHeader.astro +8 -4
- package/dist/components/dashboard/DoubleSidebar.astro +2 -2
- package/dist/components/dashboard/LoginChecker.astro +3 -2
- package/dist/components/dashboard/MainSidebarContent.astro +16 -12
- package/dist/components/dashboard/PageHeader.astro +3 -2
- package/dist/components/dashboard/SidebarLink.astro +5 -5
- package/dist/components/dashboard/SidebarPluginLink.astro +3 -3
- package/dist/components/dashboard/SingleSidebar.astro +2 -2
- package/dist/components/dashboard/configuration/ConfigForm.astro +49 -47
- package/dist/components/dashboard/configuration/LoginPreview.astro +6 -4
- package/dist/components/dashboard/content-mgmt/CreateFolder.astro +3 -2
- package/dist/components/dashboard/content-mgmt/CreatePage.astro +8 -5
- package/dist/components/dashboard/content-mgmt/EditFolder.astro +3 -2
- package/dist/components/dashboard/content-mgmt/EditPage.astro +25 -13
- package/dist/components/dashboard/content-mgmt/InnerSidebarElement.astro +23 -15
- package/dist/components/dashboard/content-mgmt/PageHeader.astro +23 -14
- package/dist/components/dashboard/content-mgmt/PluginFields.astro +6 -1
- package/dist/components/dashboard/content-mgmt/TreeRenderer.astro +6 -6
- package/dist/components/dashboard/content-mgmt/TreeSidebarFolder.astro +4 -4
- package/dist/components/dashboard/content-mgmt/TreeSidebarLink.astro +4 -4
- package/dist/components/dashboard/plugins/SettingsRenderer.astro +6 -1
- package/dist/components/dashboard/profile/APITokens.astro +14 -8
- package/dist/components/dashboard/profile/BasicInfo.astro +8 -4
- package/dist/components/dashboard/profile/Notifications.astro +7 -4
- package/dist/components/dashboard/profile/SocialSignin.astro +8 -5
- package/dist/components/dashboard/profile/UpdatePassword.astro +6 -3
- package/dist/components/dashboard/sidebar/UserAccount.astro +1 -2
- package/dist/components/dashboard/sidebar/VersionCheck.astro +7 -7
- package/dist/components/dashboard/sidebar/VersionCheckChangelog.astro +28 -6
- package/dist/components/dashboard/sidebar-modals/UserManagementModals.astro +8 -3
- package/dist/components/dashboard/sidebar-modals/VersionModal.astro +16 -15
- package/dist/components/dashboard/sidebarConfig.d.ts +2 -2
- package/dist/components/dashboard/sidebarConfig.js +6 -6
- package/dist/components/dashboard/user-mgmt/InnerSidebarElement.astro +16 -9
- package/dist/components/dashboard/user-mgmt/RankCheck.astro +6 -8
- package/dist/components/dashboard/user-mgmt/SocialSignin.astro +9 -10
- package/dist/components/dashboard/user-mgmt/UserListItem.astro +8 -6
- package/dist/components/default-grid-items/Recently-created-pages.astro +11 -9
- package/dist/components/default-grid-items/Recently-signed-up.astro +8 -8
- package/dist/components/default-grid-items/Recently-updated-pages.astro +11 -9
- package/dist/components/default-grid-items/Totals.astro +7 -6
- package/dist/components/first-time-setup/PageHeader.astro +4 -3
- package/dist/components/shared/SSRUser.astro +200 -0
- package/dist/components/shared/head/Favicons.astro +6 -0
- package/dist/components/shared/head/Global.astro +4 -0
- package/dist/components/shared/head/TitleTags.astro +14 -0
- package/dist/config.d.ts +1 -4
- package/dist/consts.d.ts +34 -1
- package/dist/consts.js +42 -1
- package/dist/db/config.d.ts +22 -37
- package/dist/db/config.js +14 -2
- package/dist/handlers/astroConfigCheck.js +1 -1
- package/dist/handlers/changelog.d.ts +1 -0
- package/dist/handlers/changelog.js +54 -0
- package/dist/handlers/index.d.ts +1 -2
- package/dist/handlers/index.js +2 -4
- package/dist/handlers/pluginHandler.d.ts +2 -1
- package/dist/handlers/pluginHandler.js +14 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +115 -107
- package/dist/integrations/dynamic-sitemap/index.js +1 -1
- package/dist/integrations/webVitals/checkForWebVitalsPlugin.js +3 -3
- package/dist/integrations/webVitals/dashboard-grid-items/CoreVitals.astro +1 -1
- package/dist/integrations/webVitals/dashboard-grid-items/MetricCard.astro +3 -2
- package/dist/integrations/webVitals/dashboard-grid-items/SummaryCard.astro +2 -2
- package/dist/integrations/webVitals/dashboard-grid-items/metric.css +17 -17
- package/dist/integrations/webVitals/dashboard-grid-items/shared.d.ts +4 -4
- package/dist/integrations/webVitals/dashboard-grid-items/shared.js +3 -3
- package/dist/integrations/webVitals/pages/analytics/body.astro +10 -9
- package/dist/integrations/webVitals/utils/webVitalsUtils.d.ts +9 -9
- package/dist/layouts/AuthLayout.astro +7 -18
- package/dist/layouts/DashboardLayout.astro +3 -2
- package/dist/layouts/FirstTimeSetupLayout.astro +7 -18
- package/dist/middleware/index.js +3 -13
- package/dist/middleware/utils.d.ts +1 -1
- package/dist/middleware/utils.js +8 -5
- package/dist/routes/api/auth/login.js +1 -6
- package/dist/routes/api/auth/logout.js +3 -2
- package/dist/routes/api/auth/register.js +1 -7
- package/dist/routes/api/dashboard/content/page.js +5 -5
- package/dist/routes/api/dashboard/create-user-invite.js +1 -1
- package/dist/routes/api/dashboard/create-user.d.ts +0 -7
- package/dist/routes/api/dashboard/create-user.js +18 -23
- package/dist/routes/api/dashboard/email-notification-settings-site.js +10 -0
- package/dist/routes/api/dashboard/profile.js +1 -1
- package/dist/routes/api/dashboard/reset-password.js +1 -1
- package/dist/routes/api/dashboard/users.js +27 -10
- package/dist/routes/api/dashboard/verify-email.js +5 -2
- package/dist/routes/api/dashboard/verify-session.js +3 -2
- package/dist/routes/api/rest/utils/auth-token.d.ts +1 -1
- package/dist/routes/api/rest/v1/pages/[id]/index.js +3 -10
- package/dist/routes/api/rest/v1/users/[id].js +24 -23
- package/dist/routes/api/rest/v1/users/index.js +1 -1
- package/dist/routes/api/sdk/utils/changelog.d.ts +0 -15
- package/dist/routes/api/sdk/utils/changelog.js +9 -112
- package/dist/routes/auth/login.astro +16 -9
- package/dist/routes/auth/signup.astro +2 -1
- package/dist/routes/dashboard/configuration.astro +3 -2
- package/dist/routes/dashboard/content-management/createfolder.astro +1 -1
- package/dist/routes/dashboard/content-management/createpage.astro +1 -1
- package/dist/routes/dashboard/content-management/diff.astro +8 -5
- package/dist/routes/dashboard/content-management/index.astro +1 -1
- package/dist/routes/dashboard/password-reset.astro +8 -5
- package/dist/routes/dashboard/plugins/[plugin].astro +4 -3
- package/dist/routes/dashboard/smtp-configuration.astro +21 -10
- package/dist/routes/dashboard/unverified-email.astro +2 -4
- package/dist/routes/dashboard/user-management/edit.astro +30 -22
- package/dist/routes/dashboard/user-management/index.astro +2 -2
- package/dist/routes/error-pages/404.astro +1 -1
- package/dist/routes/firstTimeSetupRoutes/1-start.astro +15 -14
- package/dist/routes/firstTimeSetupRoutes/2-next.astro +14 -11
- package/dist/routes/firstTimeSetupRoutes/3-done.astro +3 -2
- package/dist/routes/firstTimeSetupRoutes/api/step-2.js +1 -1
- package/dist/schemas/plugins/index.d.ts +64 -64
- package/dist/schemas/plugins/shared.d.ts +84 -84
- package/dist/schemas/plugins/shared.js +10 -16
- package/dist/styles/404.css +1 -1
- package/dist/styles/code-component.css +8 -8
- package/dist/styles/dashboard-base.css +29 -29
- package/dist/styles/dashboard-diff.css +31 -31
- package/dist/types.d.ts +2 -22
- package/dist/utils/effects/smtp.d.ts +2 -3
- package/dist/utils/effects/smtp.js +5 -1
- package/dist/utils/safeString.d.ts +1 -1
- package/dist/utils/safeString.js +1 -3
- package/dist/utils/stripIconify.d.ts +13 -0
- package/dist/utils/stripIconify.js +11 -0
- package/dist/utils/tinyMDParser.js +5 -5
- package/dist/virtual.d.ts +17 -60
- package/dist/virtuals/auth/core.d.ts +91 -0
- package/dist/virtuals/auth/core.js +45 -0
- package/dist/virtuals/auth/index.d.ts +1 -4
- package/dist/virtuals/auth/index.js +1 -4
- package/dist/virtuals/auth/verify-email.d.ts +3 -3
- package/dist/virtuals/i18n/LanguageSelector.astro +1 -1
- package/dist/virtuals/i18n/client.d.ts +100 -4
- package/dist/virtuals/i18n/client.js +11 -10
- package/dist/virtuals/i18n/config.d.ts +417 -3
- package/dist/virtuals/i18n/config.js +22 -1
- package/dist/virtuals/i18n/server.d.ts +116 -0
- package/dist/virtuals/i18n/{index.js → server.js} +6 -19
- package/dist/virtuals/i18n/v-files.d.ts +30 -0
- package/dist/virtuals/i18n/v-files.js +46 -0
- package/dist/virtuals/lib/head.d.ts +1 -25
- package/dist/virtuals/lib/head.js +1 -73
- package/dist/virtuals/lib/headDefaults.d.ts +2 -2
- package/dist/virtuals/lib/pathGenerators.d.ts +1 -20
- package/dist/virtuals/lib/pathGenerators.js +1 -66
- package/dist/virtuals/lib/urlGen.d.ts +2 -1
- package/dist/virtuals/lib/urlGen.js +4 -24
- package/dist/virtuals/mailer/index.d.ts +4 -34
- package/dist/virtuals/mailer/index.js +3 -16
- package/dist/virtuals/plugins/dashboard-pages.d.ts +8 -8
- package/dist/virtuals/scripts/user-quick-tools.d.ts +3 -2
- package/dist/virtuals/scripts/user-quick-tools.js +135 -53
- package/dist/virtuals/sdk/effect/collectors.d.ts +1 -1
- package/dist/virtuals/sdk/effect/foldertree.d.ts +1 -1
- package/dist/virtuals/sdk/effect/parsers.js +1 -1
- package/dist/virtuals/sdk/index.d.ts +2 -1
- package/dist/virtuals/sdk/modules/auth.d.ts +6 -5
- package/dist/virtuals/sdk/modules/config.d.ts +272 -0
- package/dist/virtuals/sdk/modules/config.js +205 -0
- package/dist/virtuals/sdk/modules/get.d.ts +10 -23
- package/dist/virtuals/sdk/modules/get.js +27 -40
- package/dist/virtuals/sdk/modules/init.d.ts +4 -18
- package/dist/virtuals/sdk/modules/init.js +7 -8
- package/dist/virtuals/sdk/modules/notificationSettings.d.ts +5 -22
- package/dist/virtuals/sdk/modules/notificationSettings.js +7 -29
- package/dist/virtuals/sdk/modules/post.d.ts +5 -5
- package/dist/virtuals/sdk/modules/post.js +14 -9
- package/dist/virtuals/sdk/modules/rest_api.d.ts +3 -3
- package/dist/virtuals/sdk/modules/update.d.ts +19 -19
- package/dist/virtuals/sdk/modules/update.js +28 -25
- package/dist/virtuals/sdk/sdkCore.d.ts +5 -3
- package/dist/virtuals/sdk/sdkCore.js +9 -4
- package/dist/virtuals/sdk/types/index.d.ts +4 -3
- package/dist/virtuals/sdk/types/tableDefs.d.ts +5 -4
- package/dist/virtuals/sdk/types/tsAlias.d.ts +4 -0
- package/dist/virtuals/sdk/utils.d.ts +3 -2
- package/dist/virtuals/utils.d.ts +21 -17
- package/dist/virtuals/utils.js +10 -6
- package/package.json +15 -20
- package/src/cli/users/steps/libsqlCreateUsers.ts +2 -4
- package/src/cli/users/steps/libsqlModifyUsers.ts +2 -4
- package/src/components/auth/OAuthButton.astro +1 -1
- package/src/components/auth/OAuthButtonStack.astro +1 -1
- package/src/components/auth/component-scripts/formListener.ts +1 -1
- package/src/components/dashboard/BaseHead.astro +6 -17
- package/src/components/dashboard/DashboardGrid.astro +2 -2
- package/src/components/dashboard/DashboardGridItem.astro +2 -1
- package/src/components/dashboard/DashboardPageHeader.astro +8 -4
- package/src/components/dashboard/DoubleSidebar.astro +2 -2
- package/src/components/dashboard/LoginChecker.astro +3 -2
- package/src/components/dashboard/MainSidebarContent.astro +16 -12
- package/src/components/dashboard/PageHeader.astro +3 -2
- package/src/components/dashboard/SidebarLink.astro +5 -5
- package/src/components/dashboard/SidebarPluginLink.astro +3 -3
- package/src/components/dashboard/SingleSidebar.astro +2 -2
- package/src/components/dashboard/configuration/ConfigForm.astro +49 -47
- package/src/components/dashboard/configuration/LoginPreview.astro +6 -4
- package/src/components/dashboard/content-mgmt/CreateFolder.astro +3 -2
- package/src/components/dashboard/content-mgmt/CreatePage.astro +8 -5
- package/src/components/dashboard/content-mgmt/EditFolder.astro +3 -2
- package/src/components/dashboard/content-mgmt/EditPage.astro +25 -13
- package/src/components/dashboard/content-mgmt/InnerSidebarElement.astro +23 -15
- package/src/components/dashboard/content-mgmt/PageHeader.astro +23 -14
- package/src/components/dashboard/content-mgmt/PluginFields.astro +6 -1
- package/src/components/dashboard/content-mgmt/TreeRenderer.astro +6 -6
- package/src/components/dashboard/content-mgmt/TreeSidebarFolder.astro +4 -4
- package/src/components/dashboard/content-mgmt/TreeSidebarLink.astro +4 -4
- package/src/components/dashboard/plugins/SettingsRenderer.astro +6 -1
- package/src/components/dashboard/profile/APITokens.astro +14 -8
- package/src/components/dashboard/profile/BasicInfo.astro +8 -4
- package/src/components/dashboard/profile/Notifications.astro +7 -4
- package/src/components/dashboard/profile/SocialSignin.astro +8 -5
- package/src/components/dashboard/profile/UpdatePassword.astro +6 -3
- package/src/components/dashboard/sidebar/UserAccount.astro +1 -2
- package/src/components/dashboard/sidebar/VersionCheck.astro +7 -7
- package/src/components/dashboard/sidebar/VersionCheckChangelog.astro +28 -6
- package/src/components/dashboard/sidebar-modals/UserManagementModals.astro +8 -3
- package/src/components/dashboard/sidebar-modals/VersionModal.astro +16 -15
- package/src/components/dashboard/sidebarConfig.ts +8 -8
- package/src/components/dashboard/user-mgmt/InnerSidebarElement.astro +16 -9
- package/src/components/dashboard/user-mgmt/RankCheck.astro +6 -8
- package/src/components/dashboard/user-mgmt/SocialSignin.astro +9 -10
- package/src/components/dashboard/user-mgmt/UserListItem.astro +8 -6
- package/src/components/default-grid-items/Recently-created-pages.astro +11 -9
- package/src/components/default-grid-items/Recently-signed-up.astro +8 -8
- package/src/components/default-grid-items/Recently-updated-pages.astro +11 -9
- package/src/components/default-grid-items/Totals.astro +7 -6
- package/src/components/first-time-setup/PageHeader.astro +4 -3
- package/src/components/shared/SSRUser.astro +200 -0
- package/src/components/shared/head/Favicons.astro +6 -0
- package/src/components/shared/head/Global.astro +4 -0
- package/src/components/shared/head/TitleTags.astro +14 -0
- package/src/config.ts +1 -4
- package/src/consts.ts +67 -1
- package/src/db/config.ts +43 -2
- package/src/handlers/astroConfigCheck.ts +1 -1
- package/src/handlers/changelog.ts +67 -0
- package/src/handlers/index.ts +1 -2
- package/src/handlers/pluginHandler.ts +16 -9
- package/src/index.ts +142 -121
- package/src/integrations/dynamic-sitemap/index.ts +1 -1
- package/src/integrations/webVitals/checkForWebVitalsPlugin.ts +3 -3
- package/src/integrations/webVitals/dashboard-grid-items/CoreVitals.astro +1 -1
- package/src/integrations/webVitals/dashboard-grid-items/MetricCard.astro +3 -2
- package/src/integrations/webVitals/dashboard-grid-items/SummaryCard.astro +2 -2
- package/src/integrations/webVitals/dashboard-grid-items/metric.css +17 -17
- package/src/integrations/webVitals/dashboard-grid-items/shared.ts +7 -7
- package/src/integrations/webVitals/pages/analytics/body.astro +10 -9
- package/src/layouts/AuthLayout.astro +7 -18
- package/src/layouts/DashboardLayout.astro +3 -2
- package/src/layouts/FirstTimeSetupLayout.astro +7 -18
- package/src/middleware/index.ts +3 -19
- package/src/middleware/utils.ts +7 -4
- package/src/routes/api/auth/login.ts +1 -6
- package/src/routes/api/auth/logout.ts +3 -2
- package/src/routes/api/auth/register.ts +1 -7
- package/src/routes/api/dashboard/config.ts +3 -2
- package/src/routes/api/dashboard/content/page.ts +6 -6
- package/src/routes/api/dashboard/create-user-invite.ts +3 -2
- package/src/routes/api/dashboard/create-user.ts +21 -23
- package/src/routes/api/dashboard/email-notification-settings-site.ts +27 -2
- package/src/routes/api/dashboard/profile.ts +1 -1
- package/src/routes/api/dashboard/reset-password.ts +1 -1
- package/src/routes/api/dashboard/users.ts +33 -15
- package/src/routes/api/dashboard/verify-email.ts +5 -2
- package/src/routes/api/dashboard/verify-session.ts +3 -2
- package/src/routes/api/rest/v1/pages/[id]/index.ts +3 -13
- package/src/routes/api/rest/v1/users/[id].ts +24 -23
- package/src/routes/api/rest/v1/users/index.ts +1 -1
- package/src/routes/api/sdk/utils/changelog.ts +2 -143
- package/src/routes/auth/login.astro +16 -9
- package/src/routes/auth/signup.astro +2 -1
- package/src/routes/dashboard/configuration.astro +3 -2
- package/src/routes/dashboard/content-management/createfolder.astro +1 -1
- package/src/routes/dashboard/content-management/createpage.astro +1 -1
- package/src/routes/dashboard/content-management/diff.astro +8 -5
- package/src/routes/dashboard/content-management/index.astro +1 -1
- package/src/routes/dashboard/password-reset.astro +8 -5
- package/src/routes/dashboard/plugins/[plugin].astro +4 -3
- package/src/routes/dashboard/smtp-configuration.astro +21 -10
- package/src/routes/dashboard/unverified-email.astro +2 -4
- package/src/routes/dashboard/user-management/edit.astro +30 -22
- package/src/routes/dashboard/user-management/index.astro +2 -2
- package/src/routes/error-pages/404.astro +1 -1
- package/src/routes/firstTimeSetupRoutes/1-start.astro +15 -14
- package/src/routes/firstTimeSetupRoutes/2-next.astro +14 -11
- package/src/routes/firstTimeSetupRoutes/3-done.astro +3 -2
- package/src/routes/firstTimeSetupRoutes/api/step-2.ts +1 -1
- package/src/schemas/plugins/shared.ts +13 -25
- package/src/styles/404.css +1 -1
- package/src/styles/code-component.css +8 -8
- package/src/styles/dashboard-base.css +29 -29
- package/src/styles/dashboard-diff.css +31 -31
- package/src/types.ts +3 -20
- package/src/utils/effects/smtp.ts +8 -4
- package/src/utils/safeString.ts +1 -6
- package/src/utils/stripIconify.ts +20 -0
- package/src/utils/tinyMDParser.ts +7 -7
- package/src/virtual.d.ts +17 -60
- package/src/virtuals/auth/core.ts +82 -0
- package/src/virtuals/auth/index.ts +1 -4
- package/src/virtuals/i18n/LanguageSelector.astro +1 -1
- package/src/virtuals/i18n/client.ts +115 -11
- package/src/virtuals/i18n/config.ts +154 -3
- package/src/virtuals/i18n/{index.ts → server.ts} +42 -46
- package/src/virtuals/i18n/v-files.ts +122 -0
- package/src/virtuals/lib/head.ts +1 -114
- package/src/virtuals/lib/pathGenerators.ts +1 -72
- package/src/virtuals/lib/urlGen.ts +4 -29
- package/src/virtuals/mailer/index.ts +7 -34
- package/src/virtuals/scripts/user-quick-tools.ts +151 -59
- package/src/virtuals/sdk/effect/parsers.ts +1 -1
- package/src/virtuals/sdk/modules/auth.ts +2 -1
- package/src/virtuals/sdk/modules/config.ts +602 -0
- package/src/virtuals/sdk/modules/get.ts +32 -48
- package/src/virtuals/sdk/modules/init.ts +18 -26
- package/src/virtuals/sdk/modules/notificationSettings.ts +8 -44
- package/src/virtuals/sdk/modules/post.ts +17 -18
- package/src/virtuals/sdk/modules/update.ts +31 -29
- package/src/virtuals/sdk/sdkCore.ts +5 -0
- package/src/virtuals/sdk/types/index.ts +4 -8
- package/src/virtuals/sdk/types/tableDefs.ts +4 -4
- package/src/virtuals/sdk/types/tsAlias.ts +4 -0
- package/src/virtuals/sdk/utils.ts +2 -2
- package/src/virtuals/utils.ts +29 -25
- package/ui.d.ts +1301 -274
- package/dist/components/first-time-setup/TabItem.astro +0 -44
- package/dist/components/first-time-setup/Tabs.astro +0 -170
- package/dist/handlers/changelog/changelogLoader.d.ts +0 -15
- package/dist/handlers/changelog/changelogLoader.js +0 -104
- package/dist/handlers/changelog/index.d.ts +0 -1
- package/dist/handlers/changelog/index.js +0 -53
- package/dist/handlers/scriptHandler.d.ts +0 -30
- package/dist/handlers/scriptHandler.js +0 -25
- package/dist/utils/addIntegrationArray.d.ts +0 -24
- package/dist/utils/addIntegrationArray.js +0 -11
- package/dist/utils/getLatestVersion.d.ts +0 -12
- package/dist/utils/getLatestVersion.js +0 -36
- package/dist/utils/integrationLogger.d.ts +0 -8
- package/dist/utils/integrationLogger.js +0 -23
- package/dist/utils/jsonUtils.d.ts +0 -13
- package/dist/utils/jsonUtils.js +0 -11
- package/dist/utils/pageTypeFilter.d.ts +0 -2
- package/dist/utils/pageTypeFilter.js +0 -16
- package/dist/virtuals/auth/encryption.d.ts +0 -46
- package/dist/virtuals/auth/encryption.js +0 -82
- package/dist/virtuals/auth/password.d.ts +0 -47
- package/dist/virtuals/auth/password.js +0 -147
- package/dist/virtuals/auth/session.d.ts +0 -77
- package/dist/virtuals/auth/session.js +0 -146
- package/dist/virtuals/auth/user.d.ts +0 -155
- package/dist/virtuals/auth/user.js +0 -251
- package/dist/virtuals/auth/utils/lists/passwords.d.ts +0 -2
- package/dist/virtuals/auth/utils/lists/passwords.js +0 -10006
- package/dist/virtuals/auth/utils/lists/usernames.d.ts +0 -2
- package/dist/virtuals/auth/utils/lists/usernames.js +0 -547
- package/dist/virtuals/auth/utils/scrypt.d.ts +0 -17
- package/dist/virtuals/auth/utils/scrypt.js +0 -30
- package/dist/virtuals/auth/utils/unsafeCheck.d.ts +0 -34
- package/dist/virtuals/auth/utils/unsafeCheck.js +0 -39
- package/dist/virtuals/i18n/index.d.ts +0 -2471
- package/dist/virtuals/lib/jsonUtils.d.ts +0 -2
- package/dist/virtuals/lib/jsonUtils.js +0 -14
- package/dist/virtuals/lib/removeLeadingTrailingSlashes.d.ts +0 -10
- package/dist/virtuals/lib/removeLeadingTrailingSlashes.js +0 -5
- package/src/components/first-time-setup/TabItem.astro +0 -44
- package/src/components/first-time-setup/Tabs.astro +0 -170
- package/src/handlers/changelog/changelogLoader.ts +0 -138
- package/src/handlers/changelog/index.ts +0 -67
- package/src/handlers/scriptHandler.ts +0 -86
- package/src/utils/addIntegrationArray.ts +0 -35
- package/src/utils/getLatestVersion.ts +0 -67
- package/src/utils/integrationLogger.ts +0 -29
- package/src/utils/jsonUtils.ts +0 -20
- package/src/utils/pageTypeFilter.ts +0 -13
- package/src/virtuals/auth/encryption.ts +0 -148
- package/src/virtuals/auth/password.ts +0 -279
- package/src/virtuals/auth/session.ts +0 -290
- package/src/virtuals/auth/user.ts +0 -501
- package/src/virtuals/auth/utils/lists/passwords.ts +0 -10004
- package/src/virtuals/auth/utils/lists/usernames.ts +0 -546
- package/src/virtuals/auth/utils/scrypt.ts +0 -42
- package/src/virtuals/auth/utils/unsafeCheck.ts +0 -72
- package/src/virtuals/lib/jsonUtils.ts +0 -11
- package/src/virtuals/lib/removeLeadingTrailingSlashes.ts +0 -11
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { UserSessionData } from 'studiocms:auth/lib/types';
|
|
3
3
|
import type { SiteConfigCacheObject } from 'studiocms:sdk/types';
|
|
4
|
-
import { Toaster } from 'studiocms:ui/components';
|
|
4
|
+
import { Toaster } from 'studiocms:ui/components/toaster';
|
|
5
|
+
import type { AvailablePermissionRanks } from '@withstudiocms/auth-kit/types';
|
|
5
6
|
import BaseHead from '../components/dashboard/BaseHead.astro';
|
|
6
7
|
import DoubleSidebar from '../components/dashboard/DoubleSidebar.astro';
|
|
7
8
|
import LoginChecker from '../components/dashboard/LoginChecker.astro';
|
|
@@ -28,7 +29,7 @@ type Props = {
|
|
|
28
29
|
description?: string;
|
|
29
30
|
lang?: string;
|
|
30
31
|
sidebar?: false | 'single' | 'double';
|
|
31
|
-
requiredPermission?:
|
|
32
|
+
requiredPermission?: AvailablePermissionRanks | 'none';
|
|
32
33
|
currentUser: UserSessionData | null;
|
|
33
34
|
};
|
|
34
35
|
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import 'studiocms:ui/global-css';
|
|
3
3
|
import '../styles/dashboard-base.css';
|
|
4
4
|
import '../styles/dashboard-diff.css';
|
|
5
|
-
import { Toaster } from 'studiocms:ui/components';
|
|
5
|
+
import { Toaster } from 'studiocms:ui/components/toaster';
|
|
6
|
+
import Favicons from '../components/shared/head/Favicons.astro';
|
|
7
|
+
import Global from '../components/shared/head/Global.astro';
|
|
8
|
+
import TitleTags from '../components/shared/head/TitleTags.astro';
|
|
6
9
|
import ThemeManager from '../components/shared/ThemeManager.astro';
|
|
7
|
-
import { FAVICON_ASSETS, STUDIOCMS_THEME_COLOR } from '../consts.js';
|
|
8
10
|
|
|
9
11
|
type Props = {
|
|
10
12
|
title?: string;
|
|
@@ -23,22 +25,9 @@ const {
|
|
|
23
25
|
<html {lang}>
|
|
24
26
|
|
|
25
27
|
<head>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{/* Favicon */}
|
|
31
|
-
<link rel="icon" href={FAVICON_ASSETS.svg} type="image/svg+xml" />
|
|
32
|
-
<link rel="icon" href={FAVICON_ASSETS.png.light} type="image/png" media="(prefers-color-scheme: dark)" />
|
|
33
|
-
<link rel="icon" href={FAVICON_ASSETS.png.dark} type="image/png" media="(prefers-color-scheme: light)" />
|
|
34
|
-
|
|
35
|
-
{/* Primary Meta Tags */}
|
|
36
|
-
<title>{title}</title>
|
|
37
|
-
<meta name="title" content={title} />
|
|
38
|
-
<meta name="description" content={description} />
|
|
39
|
-
<meta name="theme-color" content={STUDIOCMS_THEME_COLOR} />
|
|
40
|
-
|
|
41
|
-
{/* Theme Manager */}
|
|
28
|
+
<Global />
|
|
29
|
+
<Favicons />
|
|
30
|
+
<TitleTags {title} {description} />
|
|
42
31
|
<ThemeManager />
|
|
43
32
|
</head>
|
|
44
33
|
<body>
|
package/dist/middleware/index.js
CHANGED
|
@@ -40,12 +40,6 @@ const onRequest = defineMiddlewareRouter([
|
|
|
40
40
|
defaultLang,
|
|
41
41
|
latestVersion
|
|
42
42
|
});
|
|
43
|
-
context.locals.SCMSGenerator = `StudioCMS v${SCMSVersion}`;
|
|
44
|
-
context.locals.SCMSUiGenerator = `StudioCMS UI v${SCMSUiVersion}`;
|
|
45
|
-
context.locals.latestVersion = latestVersion;
|
|
46
|
-
context.locals.siteConfig = siteConfig ?? makeFallbackSiteConfig();
|
|
47
|
-
context.locals.defaultLang = defaultLang;
|
|
48
|
-
context.locals.routeMap = StudioCMSRoutes;
|
|
49
43
|
return next();
|
|
50
44
|
})
|
|
51
45
|
},
|
|
@@ -64,20 +58,17 @@ const onRequest = defineMiddlewareRouter([
|
|
|
64
58
|
VerifyEmail
|
|
65
59
|
]);
|
|
66
60
|
return { getUserData: getUserData2, isEmailVerificationEnabled: isEmailVerificationEnabled2 };
|
|
67
|
-
}).pipe(
|
|
61
|
+
}).pipe(VerifyEmail.Provide);
|
|
68
62
|
const [userSessionData, emailVerificationEnabled] = yield* Effect.all([
|
|
69
63
|
getUserData(context),
|
|
70
64
|
isEmailVerificationEnabled()
|
|
71
65
|
]);
|
|
72
|
-
const userPermissionLevel = yield* getUserPermissions(userSessionData)
|
|
66
|
+
const userPermissionLevel = yield* getUserPermissions(userSessionData);
|
|
73
67
|
yield* setLocals(context, SetLocal.SECURITY, {
|
|
74
68
|
userSessionData,
|
|
75
69
|
emailVerificationEnabled,
|
|
76
70
|
userPermissionLevel
|
|
77
71
|
});
|
|
78
|
-
context.locals.userSessionData = userSessionData;
|
|
79
|
-
context.locals.emailVerificationEnabled = emailVerificationEnabled;
|
|
80
|
-
context.locals.userPermissionLevel = userPermissionLevel;
|
|
81
72
|
return next();
|
|
82
73
|
})
|
|
83
74
|
},
|
|
@@ -104,7 +95,7 @@ const onRequest = defineMiddlewareRouter([
|
|
|
104
95
|
const getUserData = yield* Effect.gen(function* () {
|
|
105
96
|
const { getUserData: getUserData2 } = yield* User;
|
|
106
97
|
return getUserData2;
|
|
107
|
-
})
|
|
98
|
+
});
|
|
108
99
|
const userSessionData = context.locals.StudioCMS.security?.userSessionData ?? (yield* getUserData(context));
|
|
109
100
|
if (!userSessionData.isLoggedIn) return context.redirect(StudioCMSRoutes.authLinks.loginURL);
|
|
110
101
|
return next();
|
|
@@ -133,7 +124,6 @@ const onRequest = defineMiddlewareRouter([
|
|
|
133
124
|
yield* setLocals(context, SetLocal.PLUGINS, {
|
|
134
125
|
editorCSRFToken: csrfToken
|
|
135
126
|
});
|
|
136
|
-
context.locals.wysiwygCsrfToken = csrfToken;
|
|
137
127
|
return next();
|
|
138
128
|
})
|
|
139
129
|
}
|
|
@@ -17,7 +17,7 @@ export declare const getUserPermissions: (userData: UserSessionData) => Effect.E
|
|
|
17
17
|
isEditor: boolean;
|
|
18
18
|
isAdmin: boolean;
|
|
19
19
|
isOwner: boolean;
|
|
20
|
-
}, import("
|
|
20
|
+
}, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, never>;
|
|
21
21
|
/**
|
|
22
22
|
* Creates a fallback site configuration object with default values.
|
|
23
23
|
*
|
package/dist/middleware/utils.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { User } from "studiocms:auth/lib";
|
|
2
|
+
import { UserPermissionLevel } from "@withstudiocms/auth-kit/types";
|
|
2
3
|
import { deepmerge, Effect, genLogger } from "../effect.js";
|
|
4
|
+
import { CURRENT_CONFIG_VERSION } from "../virtuals/sdk/modules/config.js";
|
|
3
5
|
const getUserPermissions = (userData) => genLogger("studiocms/middleware/utils/getUserPermissions")(function* () {
|
|
4
6
|
const { getUserPermissionLevel } = yield* User;
|
|
5
7
|
const userPermissionLevel = yield* getUserPermissionLevel(userData);
|
|
6
8
|
return {
|
|
7
|
-
isVisitor: userPermissionLevel >=
|
|
8
|
-
isEditor: userPermissionLevel >=
|
|
9
|
-
isAdmin: userPermissionLevel >=
|
|
10
|
-
isOwner: userPermissionLevel >=
|
|
9
|
+
isVisitor: userPermissionLevel >= UserPermissionLevel.visitor,
|
|
10
|
+
isEditor: userPermissionLevel >= UserPermissionLevel.editor,
|
|
11
|
+
isAdmin: userPermissionLevel >= UserPermissionLevel.admin,
|
|
12
|
+
isOwner: userPermissionLevel >= UserPermissionLevel.owner
|
|
11
13
|
};
|
|
12
14
|
});
|
|
13
15
|
const makeFallbackSiteConfig = () => ({
|
|
@@ -23,7 +25,8 @@ const makeFallbackSiteConfig = () => ({
|
|
|
23
25
|
loginPageBackground: "studiocms-curves",
|
|
24
26
|
loginPageCustomImage: null,
|
|
25
27
|
siteIcon: null,
|
|
26
|
-
title: "StudioCMS-Setup"
|
|
28
|
+
title: "StudioCMS-Setup",
|
|
29
|
+
_config_version: CURRENT_CONFIG_VERSION
|
|
27
30
|
}
|
|
28
31
|
});
|
|
29
32
|
var SetLocal = /* @__PURE__ */ ((SetLocal2) => {
|
|
@@ -11,12 +11,7 @@ import {
|
|
|
11
11
|
pipeLogger
|
|
12
12
|
} from "../../../effect.js";
|
|
13
13
|
import { AuthAPIUtils } from "./shared.js";
|
|
14
|
-
const deps = Layer.mergeAll(
|
|
15
|
-
Password.Default,
|
|
16
|
-
AuthAPIUtils.Default,
|
|
17
|
-
VerifyEmail.Default,
|
|
18
|
-
Session.Default
|
|
19
|
-
);
|
|
14
|
+
const deps = Layer.mergeAll(AuthAPIUtils.Default, VerifyEmail.Default);
|
|
20
15
|
const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
21
16
|
{
|
|
22
17
|
POST: (ctx) => genLogger("studiocms/routes/api/auth/login/POST")(function* () {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Session } from "studiocms:auth/lib";
|
|
2
2
|
import { StudioCMSRoutes } from "studiocms:lib";
|
|
3
|
+
import { AuthSessionCookieName } from "../../../consts.js";
|
|
3
4
|
import {
|
|
4
5
|
AllResponse,
|
|
5
6
|
createEffectAPIRoutes,
|
|
@@ -13,7 +14,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
13
14
|
POST: (ctx) => genLogger("studiocms/routes/api/auth/logout/POST")(function* () {
|
|
14
15
|
const { validateSessionToken, deleteSessionTokenCookie, invalidateSession } = yield* Session;
|
|
15
16
|
const { cookies, redirect } = ctx;
|
|
16
|
-
const sessionToken = cookies.get(
|
|
17
|
+
const sessionToken = cookies.get(AuthSessionCookieName)?.value ?? null;
|
|
17
18
|
if (!sessionToken) return redirect(StudioCMSRoutes.authLinks.loginURL);
|
|
18
19
|
const { session, user } = yield* validateSessionToken(sessionToken);
|
|
19
20
|
if (session === null) {
|
|
@@ -26,7 +27,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
26
27
|
}
|
|
27
28
|
yield* Effect.all([invalidateSession(session.id), deleteSessionTokenCookie(ctx)]);
|
|
28
29
|
return redirect(StudioCMSRoutes.mainLinks.baseSiteURL);
|
|
29
|
-
})
|
|
30
|
+
}),
|
|
30
31
|
OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["GET", "POST"] })),
|
|
31
32
|
ALL: () => Effect.try(() => AllResponse())
|
|
32
33
|
},
|
|
@@ -11,13 +11,7 @@ import {
|
|
|
11
11
|
pipeLogger
|
|
12
12
|
} from "../../../effect.js";
|
|
13
13
|
import { AuthAPIUtils } from "./shared.js";
|
|
14
|
-
const deps = Layer.mergeAll(
|
|
15
|
-
AuthAPIUtils.Default,
|
|
16
|
-
User.Default,
|
|
17
|
-
VerifyEmail.Default,
|
|
18
|
-
Password.Default,
|
|
19
|
-
Session.Default
|
|
20
|
-
);
|
|
14
|
+
const deps = Layer.mergeAll(AuthAPIUtils.Default, VerifyEmail.Default);
|
|
21
15
|
const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
22
16
|
{
|
|
23
17
|
POST: (ctx) => genLogger("studiocms/routes/api/auth/register/POST")(function* () {
|
|
@@ -135,10 +135,10 @@ const { POST, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
135
135
|
return apiResponseLogger(400, "Invalid form data, contentId is required");
|
|
136
136
|
}
|
|
137
137
|
const currentPageData = yield* sdk.GET.page.byId(data.id);
|
|
138
|
-
if (!currentPageData
|
|
138
|
+
if (!currentPageData) {
|
|
139
139
|
return apiResponseLogger(404, "Page not found");
|
|
140
140
|
}
|
|
141
|
-
const { authorId, contributorIds } = currentPageData.data;
|
|
141
|
+
const { authorId, contributorIds, defaultContent } = currentPageData.data;
|
|
142
142
|
let AuthorId = authorId;
|
|
143
143
|
if (!authorId) {
|
|
144
144
|
AuthorId = userData.user?.id || null;
|
|
@@ -153,9 +153,6 @@ const { POST, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
153
153
|
const startMetaData = (yield* sdk.GET.databaseTable.pageData()).find(
|
|
154
154
|
(metaData) => metaData.id === data.id
|
|
155
155
|
);
|
|
156
|
-
const {
|
|
157
|
-
data: { defaultContent }
|
|
158
|
-
} = yield* sdk.GET.page.byId(data.id);
|
|
159
156
|
const apiRoute = getPageTypeEndpoints(data.package, "onEdit");
|
|
160
157
|
yield* sdk.UPDATE.page.byId(data.id, {
|
|
161
158
|
pageData: data,
|
|
@@ -208,6 +205,9 @@ const { POST, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
208
205
|
return apiResponseLogger(400, "Invalid request");
|
|
209
206
|
}
|
|
210
207
|
const pageToDelete = yield* sdk.GET.page.byId(id);
|
|
208
|
+
if (!pageToDelete) {
|
|
209
|
+
return apiResponseLogger(404, "Page not found");
|
|
210
|
+
}
|
|
211
211
|
const apiRoute = getPageTypeEndpoints(pageToDelete.data.package, "onDelete");
|
|
212
212
|
yield* sdk.DELETE.page(id);
|
|
213
213
|
if (apiRoute) {
|
|
@@ -133,7 +133,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
133
133
|
return apiResponseLogger(200, "User invite created and email sent");
|
|
134
134
|
}
|
|
135
135
|
return apiResponseLogger(200, resetLink.toString());
|
|
136
|
-
}).pipe(
|
|
136
|
+
}).pipe(Mailer.Provide, Notifications.Provide),
|
|
137
137
|
OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
|
|
138
138
|
ALL: () => Effect.try(() => AllResponse())
|
|
139
139
|
},
|
|
@@ -2,7 +2,9 @@ import { Password, User } from "studiocms:auth/lib";
|
|
|
2
2
|
import { apiResponseLogger } from "studiocms:logger";
|
|
3
3
|
import { Notifications } from "studiocms:notifier";
|
|
4
4
|
import { SDKCore } from "studiocms:sdk";
|
|
5
|
+
import { UserPermissionLevel } from "@withstudiocms/auth-kit/types";
|
|
5
6
|
import { z } from "astro/zod";
|
|
7
|
+
import { ValidRanks } from "../../../consts.js";
|
|
6
8
|
import {
|
|
7
9
|
AllResponse,
|
|
8
10
|
createEffectAPIRoutes,
|
|
@@ -12,14 +14,6 @@ import {
|
|
|
12
14
|
OptionsResponse,
|
|
13
15
|
readAPIContextJson
|
|
14
16
|
} from "../../../effect.js";
|
|
15
|
-
var UserPermissionLevel = /* @__PURE__ */ ((UserPermissionLevel2) => {
|
|
16
|
-
UserPermissionLevel2[UserPermissionLevel2["visitor"] = 1] = "visitor";
|
|
17
|
-
UserPermissionLevel2[UserPermissionLevel2["editor"] = 2] = "editor";
|
|
18
|
-
UserPermissionLevel2[UserPermissionLevel2["admin"] = 3] = "admin";
|
|
19
|
-
UserPermissionLevel2[UserPermissionLevel2["owner"] = 4] = "owner";
|
|
20
|
-
UserPermissionLevel2[UserPermissionLevel2["unknown"] = 0] = "unknown";
|
|
21
|
-
return UserPermissionLevel2;
|
|
22
|
-
})(UserPermissionLevel || {});
|
|
23
17
|
const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
24
18
|
{
|
|
25
19
|
POST: (ctx) => genLogger("studiocms/routes/api/dashboard/create-user.POST")(function* () {
|
|
@@ -53,41 +47,43 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
53
47
|
if (!rank) {
|
|
54
48
|
return apiResponseLogger(400, "Missing field: Rank is required");
|
|
55
49
|
}
|
|
56
|
-
|
|
57
|
-
if (!allowedRanks.has(rank)) {
|
|
50
|
+
if (!ValidRanks.has(rank) || rank === "unknown") {
|
|
58
51
|
return apiResponseLogger(400, "Invalid rank");
|
|
59
52
|
}
|
|
60
53
|
const callerPerm = yield* userHelper.getUserPermissionLevel(userData);
|
|
61
54
|
const rankToPerm = (r) => {
|
|
62
55
|
switch (r) {
|
|
63
56
|
case "owner":
|
|
64
|
-
return
|
|
57
|
+
return UserPermissionLevel.owner;
|
|
65
58
|
case "admin":
|
|
66
|
-
return
|
|
59
|
+
return UserPermissionLevel.admin;
|
|
67
60
|
case "editor":
|
|
68
|
-
return
|
|
61
|
+
return UserPermissionLevel.editor;
|
|
69
62
|
case "visitor":
|
|
70
|
-
return
|
|
63
|
+
return UserPermissionLevel.visitor;
|
|
71
64
|
default:
|
|
72
|
-
return
|
|
65
|
+
return UserPermissionLevel.unknown;
|
|
73
66
|
}
|
|
74
67
|
};
|
|
75
68
|
const targetPerm = rankToPerm(rank);
|
|
76
69
|
const permWeight = (lvl) => {
|
|
77
70
|
switch (lvl) {
|
|
78
|
-
case
|
|
71
|
+
case UserPermissionLevel.owner:
|
|
79
72
|
return 4;
|
|
80
|
-
case
|
|
73
|
+
case UserPermissionLevel.admin:
|
|
81
74
|
return 3;
|
|
82
|
-
case
|
|
75
|
+
case UserPermissionLevel.editor:
|
|
83
76
|
return 2;
|
|
84
|
-
case
|
|
77
|
+
case UserPermissionLevel.visitor:
|
|
85
78
|
return 1;
|
|
86
79
|
default:
|
|
87
80
|
return 0;
|
|
88
81
|
}
|
|
89
82
|
};
|
|
90
|
-
if (
|
|
83
|
+
if (rank === "owner" && callerPerm !== UserPermissionLevel.owner) {
|
|
84
|
+
return createJsonResponse({ error: "Forbidden" }, { status: 403 });
|
|
85
|
+
}
|
|
86
|
+
if (permWeight(callerPerm) < permWeight(targetPerm)) {
|
|
91
87
|
return createJsonResponse({ error: "Forbidden" }, { status: 403 });
|
|
92
88
|
}
|
|
93
89
|
const checkEmail = z.coerce.string().email({ message: "Email address is invalid" }).safeParse(email);
|
|
@@ -124,7 +120,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
124
120
|
200,
|
|
125
121
|
JSON.stringify({ username, email, displayname, rank, password })
|
|
126
122
|
);
|
|
127
|
-
}).pipe(
|
|
123
|
+
}).pipe(Notifications.Provide),
|
|
128
124
|
OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
|
|
129
125
|
ALL: () => Effect.try(() => AllResponse())
|
|
130
126
|
},
|
|
@@ -144,6 +140,5 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
144
140
|
export {
|
|
145
141
|
ALL,
|
|
146
142
|
OPTIONS,
|
|
147
|
-
POST
|
|
148
|
-
UserPermissionLevel
|
|
143
|
+
POST
|
|
149
144
|
};
|
|
@@ -23,6 +23,16 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
23
23
|
return apiResponseLogger(403, "Unauthorized");
|
|
24
24
|
}
|
|
25
25
|
yield* readAPIContextJson(ctx).pipe(
|
|
26
|
+
Effect.map((raw) => {
|
|
27
|
+
const rawData = raw ?? {};
|
|
28
|
+
const safe = {
|
|
29
|
+
emailVerification: typeof rawData.emailVerification === "boolean" ? rawData.emailVerification : void 0,
|
|
30
|
+
requireAdminVerification: typeof rawData.requireAdminVerification === "boolean" ? rawData.requireAdminVerification : void 0,
|
|
31
|
+
requireEditorVerification: typeof rawData.requireEditorVerification === "boolean" ? rawData.requireEditorVerification : void 0,
|
|
32
|
+
oAuthBypassVerification: typeof rawData.oAuthBypassVerification === "boolean" ? rawData.oAuthBypassVerification : void 0
|
|
33
|
+
};
|
|
34
|
+
return safe;
|
|
35
|
+
}),
|
|
26
36
|
Effect.flatMap((data) => sdk.notificationSettings.site.update(data))
|
|
27
37
|
);
|
|
28
38
|
return apiResponseLogger(200, "Notification settings updated");
|
|
@@ -129,7 +129,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
129
129
|
default:
|
|
130
130
|
return apiResponseLogger(400, "Invalid form data, mode is required or unsupported");
|
|
131
131
|
}
|
|
132
|
-
}).pipe(
|
|
132
|
+
}).pipe(Notifications.Provide),
|
|
133
133
|
OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
|
|
134
134
|
ALL: () => Effect.try(() => AllResponse())
|
|
135
135
|
},
|
|
@@ -64,7 +64,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
64
64
|
notify.sendAdminNotification("user_updated", userData.username)
|
|
65
65
|
]);
|
|
66
66
|
return apiResponseLogger(200, "User password updated successfully");
|
|
67
|
-
}).pipe(Notifications.Provide
|
|
67
|
+
}).pipe(Notifications.Provide),
|
|
68
68
|
OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
|
|
69
69
|
ALL: () => Effect.try(() => AllResponse())
|
|
70
70
|
},
|
|
@@ -3,6 +3,8 @@ import { developerConfig } from "studiocms:config";
|
|
|
3
3
|
import { apiResponseLogger } from "studiocms:logger";
|
|
4
4
|
import { Notifications } from "studiocms:notifier";
|
|
5
5
|
import { SDKCore } from "studiocms:sdk";
|
|
6
|
+
import { UserPermissionLevel } from "@withstudiocms/auth-kit/types";
|
|
7
|
+
import { ValidRanks } from "../../../consts.js";
|
|
6
8
|
import {
|
|
7
9
|
AllResponse,
|
|
8
10
|
createEffectAPIRoutes,
|
|
@@ -28,8 +30,7 @@ const { POST, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
28
30
|
if (!id || !rank) {
|
|
29
31
|
return apiResponseLogger(400, "Invalid request");
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
if (!validRanks.has(rank)) {
|
|
33
|
+
if (!ValidRanks.has(rank) || rank === "unknown") {
|
|
33
34
|
return apiResponseLogger(400, "Invalid rank supplied");
|
|
34
35
|
}
|
|
35
36
|
const insertData = {
|
|
@@ -44,20 +45,36 @@ const { POST, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
44
45
|
const toLevel = (r) => {
|
|
45
46
|
switch (r) {
|
|
46
47
|
case "owner":
|
|
47
|
-
return
|
|
48
|
+
return UserPermissionLevel.owner;
|
|
48
49
|
case "admin":
|
|
49
|
-
return
|
|
50
|
+
return UserPermissionLevel.admin;
|
|
50
51
|
case "editor":
|
|
51
|
-
return
|
|
52
|
+
return UserPermissionLevel.editor;
|
|
52
53
|
case "visitor":
|
|
53
|
-
return
|
|
54
|
+
return UserPermissionLevel.visitor;
|
|
54
55
|
default:
|
|
55
|
-
return
|
|
56
|
+
return UserPermissionLevel.unknown;
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
|
-
const targetCurrentLevel = toLevel(
|
|
59
|
+
const targetCurrentLevel = toLevel(
|
|
60
|
+
user.permissionsData?.rank
|
|
61
|
+
);
|
|
59
62
|
const targetNewLevel = toLevel(rank);
|
|
60
|
-
const
|
|
63
|
+
const weight = (lvl) => {
|
|
64
|
+
switch (lvl) {
|
|
65
|
+
case UserPermissionLevel.owner:
|
|
66
|
+
return 4;
|
|
67
|
+
case UserPermissionLevel.admin:
|
|
68
|
+
return 3;
|
|
69
|
+
case UserPermissionLevel.editor:
|
|
70
|
+
return 2;
|
|
71
|
+
case UserPermissionLevel.visitor:
|
|
72
|
+
return 1;
|
|
73
|
+
default:
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const isAllowedToUpdateRank = weight(userPermissionLevel) > weight(targetCurrentLevel) && weight(userPermissionLevel) >= weight(targetNewLevel) && (rank !== "owner" || userPermissionLevel === UserPermissionLevel.owner);
|
|
61
78
|
if (!isAllowedToUpdateRank) {
|
|
62
79
|
return apiResponseLogger(403, "Unauthorized");
|
|
63
80
|
}
|
|
@@ -75,7 +92,7 @@ const { POST, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
75
92
|
notifications.sendAdminNotification("user_updated", user.username)
|
|
76
93
|
]);
|
|
77
94
|
return apiResponseLogger(200, "User rank updated successfully");
|
|
78
|
-
}).pipe(
|
|
95
|
+
}).pipe(Notifications.Provide),
|
|
79
96
|
DELETE: (ctx) => genLogger("studiocms/routes/api/dashboard/users.DELETE")(function* () {
|
|
80
97
|
const [notifications, sdk] = yield* Effect.all([Notifications, SDKCore]);
|
|
81
98
|
if (developerConfig.demoMode !== false) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VerifyEmail } from "studiocms:auth/lib";
|
|
2
|
-
import {
|
|
2
|
+
import { stripLeadingAndTrailingSlashes } from "studiocms:lib";
|
|
3
3
|
import { apiResponseLogger } from "studiocms:logger";
|
|
4
4
|
import { SDKCore } from "studiocms:sdk";
|
|
5
5
|
import {
|
|
@@ -37,8 +37,11 @@ const { GET, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
37
37
|
}),
|
|
38
38
|
sdk.AUTH.verifyEmail.delete(userId)
|
|
39
39
|
]);
|
|
40
|
+
if (!ctx.site) {
|
|
41
|
+
return apiResponseLogger(400, "Site URL is not configured");
|
|
42
|
+
}
|
|
40
43
|
return ctx.redirect(
|
|
41
|
-
|
|
44
|
+
stripLeadingAndTrailingSlashes(ctx.site.toString()) + ctx.locals.StudioCMS.routeMap.mainLinks.dashboardIndex
|
|
42
45
|
);
|
|
43
46
|
}).pipe(VerifyEmail.Provide),
|
|
44
47
|
OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["GET"] })),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Session } from "studiocms:auth/lib";
|
|
2
2
|
import { logger as _logger } from "studiocms:logger";
|
|
3
3
|
import { SDKCore } from "studiocms:sdk";
|
|
4
|
+
import { AuthSessionCookieName } from "../../../consts.js";
|
|
4
5
|
import {
|
|
5
6
|
AllResponse,
|
|
6
7
|
createEffectAPIRoutes,
|
|
@@ -42,7 +43,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
42
43
|
const logger = _logger.fork("studiocms:runtime:api:verify-session");
|
|
43
44
|
const { cookies } = ctx;
|
|
44
45
|
const { originPathname } = yield* parseAPIContextJson(ctx, JsonData);
|
|
45
|
-
const sessionToken = cookies.get(
|
|
46
|
+
const sessionToken = cookies.get(AuthSessionCookieName)?.value ?? null;
|
|
46
47
|
if (!sessionToken) {
|
|
47
48
|
logger.info(
|
|
48
49
|
`No session token found in cookies, returning unknown session status. Origin: ${originPathname}`
|
|
@@ -89,7 +90,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
89
90
|
break;
|
|
90
91
|
}
|
|
91
92
|
return responseBuilder(ctx, true, user, permissionLevel);
|
|
92
|
-
})
|
|
93
|
+
}),
|
|
93
94
|
OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
|
|
94
95
|
ALL: () => Effect.try(() => AllResponse())
|
|
95
96
|
},
|
|
@@ -13,5 +13,5 @@ import { Effect } from '../../../../effect.js';
|
|
|
13
13
|
export declare const verifyAuthTokenFromHeader: (context: APIContext) => Effect.Effect<Response | {
|
|
14
14
|
userId: string;
|
|
15
15
|
key: string;
|
|
16
|
-
rank:
|
|
16
|
+
rank: "unknown" | "owner" | "admin" | "editor" | "visitor";
|
|
17
17
|
}, import("effect/Cause").UnknownException | import("../../../../virtuals/sdk/errors.js").SDKCoreError, never>;
|
|
@@ -70,7 +70,7 @@ const { GET, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
70
70
|
if (!currentPageData) {
|
|
71
71
|
return apiResponseLogger(404, "Page not found");
|
|
72
72
|
}
|
|
73
|
-
const { authorId, contributorIds } = currentPageData.data;
|
|
73
|
+
const { authorId, contributorIds, defaultContent } = currentPageData.data;
|
|
74
74
|
let AuthorId = authorId;
|
|
75
75
|
if (!authorId) {
|
|
76
76
|
AuthorId = userId || null;
|
|
@@ -80,15 +80,12 @@ const { GET, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
80
80
|
ContributorIds.push(userId);
|
|
81
81
|
}
|
|
82
82
|
data.authorId = AuthorId;
|
|
83
|
-
data.contributorIds =
|
|
83
|
+
data.contributorIds = ContributorIds;
|
|
84
84
|
data.updatedAt = /* @__PURE__ */ new Date();
|
|
85
85
|
const startMetaData = (yield* sdk.GET.databaseTable.pageData()).find(
|
|
86
86
|
(metaData) => metaData.id === data.id
|
|
87
87
|
);
|
|
88
|
-
|
|
89
|
-
data: { defaultContent }
|
|
90
|
-
} = yield* sdk.GET.page.byId(data.id);
|
|
91
|
-
const _updated = yield* sdk.UPDATE.page.byId(data.id, {
|
|
88
|
+
yield* sdk.UPDATE.page.byId(data.id, {
|
|
92
89
|
pageData: data,
|
|
93
90
|
pageContent: content
|
|
94
91
|
});
|
|
@@ -141,10 +138,6 @@ const { GET, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
|
|
|
141
138
|
if (!slug) {
|
|
142
139
|
return apiResponseLogger(400, "Invalid request");
|
|
143
140
|
}
|
|
144
|
-
const isHomePage = yield* sdk.GET.page.bySlug("index");
|
|
145
|
-
if (isHomePage.data && isHomePage.data.id === id) {
|
|
146
|
-
return apiResponseLogger(400, "Cannot delete home page");
|
|
147
|
-
}
|
|
148
141
|
const page = yield* sdk.GET.page.byId(id);
|
|
149
142
|
if (!page) {
|
|
150
143
|
return apiResponseLogger(404, "Page not found");
|