diff --git a/satellite/console/consoleweb/server.go b/satellite/console/consoleweb/server.go index f03ee6fbc..49ded211a 100644 --- a/satellite/console/consoleweb/server.go +++ b/satellite/console/consoleweb/server.go @@ -251,7 +251,8 @@ func NewServer(logger *zap.Logger, config Config, service *console.Service, oidc server.withAuth(http.HandlerFunc(projectsController.GetSalt)), ).Methods(http.MethodGet) - router.HandleFunc("/config", server.frontendConfigHandler) + router.HandleFunc("/api/v0/config", server.frontendConfigHandler) + router.HandleFunc("/registrationToken/", server.createRegistrationTokenHandler) router.HandleFunc("/robots.txt", server.seoHandler) diff --git a/web/satellite/src/App.vue b/web/satellite/src/App.vue index f0eb2ec5d..5f932a87d 100644 --- a/web/satellite/src/App.vue +++ b/web/satellite/src/App.vue @@ -71,8 +71,7 @@ onMounted(async (): Promise => { try { await appStore.getConfig(); } catch (error) { - // TODO: Use a harsher error-handling approach when the config is necessary - // for the frontend to function. + appStore.setErrorPage(500, true); notify.error(error.message, null); } diff --git a/web/satellite/src/api/config.ts b/web/satellite/src/api/config.ts index b194f243e..4a7e23fd6 100644 --- a/web/satellite/src/api/config.ts +++ b/web/satellite/src/api/config.ts @@ -9,7 +9,7 @@ import { FrontendConfig, FrontendConfigApi } from '@/types/config'; */ export class FrontendConfigHttpApi implements FrontendConfigApi { private readonly http: HttpClient = new HttpClient(); - private readonly ROOT_PATH: string = '/config'; + private readonly ROOT_PATH: string = '/api/v0/config'; /** * Returns the frontend config. diff --git a/web/satellite/src/components/accessGrants/createFlow/CreateAccessGrantFlow.vue b/web/satellite/src/components/accessGrants/createFlow/CreateAccessGrantFlow.vue index 822a4d8c0..de9db6dab 100644 --- a/web/satellite/src/components/accessGrants/createFlow/CreateAccessGrantFlow.vue +++ b/web/satellite/src/components/accessGrants/createFlow/CreateAccessGrantFlow.vue @@ -124,10 +124,10 @@ import { AnalyticsErrorEventSource, AnalyticsEvent } from '@/utils/constants/ana import { LocalData } from '@/utils/localData'; import { PROJECTS_ACTIONS } from '@/store/modules/projects'; import { AccessGrant, EdgeCredentials } from '@/types/accessGrants'; -import { MetaUtils } from '@/utils/meta'; import { AnalyticsHttpApi } from '@/api/analytics'; import { OBJECTS_MUTATIONS } from '@/store/modules/objects'; import { useAccessGrantsStore } from '@/store/modules/accessGrantsStore'; +import { useAppStore } from '@/store/modules/appStore'; import VModal from '@/components/common/VModal.vue'; import CreateNewAccessStep from '@/components/accessGrants/createFlow/steps/CreateNewAccessStep.vue'; @@ -146,6 +146,7 @@ const route = useRoute(); const notify = useNotify(); const store = useStore(); const agStore = useAccessGrantsStore(); +const appStore = useAppStore(); const initPermissions = [ Permission.Read, @@ -507,7 +508,7 @@ async function createAccessGrant(): Promise { } // creates access credentials. - const satelliteNodeURL = MetaUtils.getMetaContent('satellite-nodeurl'); + const satelliteNodeURL = appStore.state.config.satelliteNodeURL; const salt = await store.dispatch(PROJECTS_ACTIONS.GET_SALT, store.getters.selectedProject.id); diff --git a/web/satellite/src/components/accessGrants/createFlow/steps/CLIAccessCreatedStep.vue b/web/satellite/src/components/accessGrants/createFlow/steps/CLIAccessCreatedStep.vue index ac2122562..fd8a75ca4 100644 --- a/web/satellite/src/components/accessGrants/createFlow/steps/CLIAccessCreatedStep.vue +++ b/web/satellite/src/components/accessGrants/createFlow/steps/CLIAccessCreatedStep.vue @@ -68,14 +68,14 @@ diff --git a/web/satellite/src/components/infoBars/ProjectInfoBar.vue b/web/satellite/src/components/infoBars/ProjectInfoBar.vue index aec5b6f2e..9029d3186 100644 --- a/web/satellite/src/components/infoBars/ProjectInfoBar.vue +++ b/web/satellite/src/components/infoBars/ProjectInfoBar.vue @@ -29,13 +29,14 @@ import { computed, onMounted, ref } from 'vue'; import { PROJECTS_ACTIONS } from '@/store/modules/projects'; -import { MetaUtils } from '@/utils/meta'; import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames'; import { useNotify, useStore } from '@/utils/hooks'; import { useUsersStore } from '@/store/modules/usersStore'; +import { useAppStore } from '@/store/modules/appStore'; import VLoader from '@/components/common/VLoader.vue'; +const appStore = useAppStore(); const usersStore = useUsersStore(); const store = useStore(); const notify = useNotify(); @@ -63,7 +64,7 @@ const projectLimit = computed((): number => { * Returns project limits increase request url from config. */ const projectLimitsIncreaseRequestURL = computed((): string => { - return MetaUtils.getMetaContent('project-limits-increase-request-url'); + return appStore.state.config.projectLimitsIncreaseRequestURL; }); /** diff --git a/web/satellite/src/components/modals/AddPaymentMethodModal.vue b/web/satellite/src/components/modals/AddPaymentMethodModal.vue index 8dd01327c..e165263b1 100644 --- a/web/satellite/src/components/modals/AddPaymentMethodModal.vue +++ b/web/satellite/src/components/modals/AddPaymentMethodModal.vue @@ -133,7 +133,6 @@ import { computed, onMounted, onBeforeMount, ref, reactive } from 'vue'; import { useNotify, useRouter, useStore } from '@/utils/hooks'; import { RouteConfig } from '@/router'; import { PROJECTS_ACTIONS } from '@/store/modules/projects'; -import { MetaUtils } from '@/utils/meta'; import { AnalyticsHttpApi } from '@/api/analytics'; import { AnalyticsErrorEventSource, AnalyticsEvent } from '@/utils/constants/analyticsEventNames'; import { MODALS } from '@/utils/constants/appStatePopUps'; @@ -171,7 +170,7 @@ const isAddCard = ref(true); const isLoading = ref(false); const isPriceFetching = ref(true); -const stripeCardInput = ref(null); +const stripeCardInput = ref(null); const extraBandwidthPriceInfo = ref(''); @@ -255,7 +254,7 @@ function setIsAddCard(): void { * Returns project limits increase request url from config. */ const limitsIncreaseRequestURL = computed((): string => { - return MetaUtils.getMetaContent('project-limits-increase-request-url'); + return appStore.state.config.projectLimitsIncreaseRequestURL; }); /** diff --git a/web/satellite/src/components/modals/ChangePasswordModal.vue b/web/satellite/src/components/modals/ChangePasswordModal.vue index 3ef60fad6..8d457515a 100644 --- a/web/satellite/src/components/modals/ChangePasswordModal.vue +++ b/web/satellite/src/components/modals/ChangePasswordModal.vue @@ -65,7 +65,6 @@ import { ref } from 'vue'; import { AuthHttpApi } from '@/api/auth'; -import { Validator } from '@/utils/validation'; import { RouteConfig } from '@/router'; import { AnalyticsHttpApi } from '@/api/analytics'; import { AnalyticsErrorEventSource, AnalyticsEvent } from '@/utils/constants/analyticsEventNames'; @@ -144,8 +143,15 @@ async function onUpdateClick(): Promise { hasError = true; } - if (!Validator.password(newPassword.value)) { - newPasswordError.value = 'Invalid password. Use 6 or more characters'; + const config = appStore.state.config; + + if (newPassword.value.length < config.passwordMinimumLength) { + newPasswordError.value = `Invalid password. Use ${config.passwordMinimumLength} or more characters`; + hasError = true; + } + + if (newPassword.value.length > config.passwordMaximumLength) { + newPasswordError.value = `Invalid password. Use ${config.passwordMaximumLength} or fewer characters`; hasError = true; } @@ -155,7 +161,7 @@ async function onUpdateClick(): Promise { } if (newPassword.value !== confirmationPassword.value) { - confirmationPasswordError.value = 'Password not match to new one'; + confirmationPasswordError.value = 'Password doesn\'t match new one'; hasError = true; } diff --git a/web/satellite/src/components/modals/CreateBucketModal.vue b/web/satellite/src/components/modals/CreateBucketModal.vue index 26d06816f..8b5a95aa8 100644 --- a/web/satellite/src/components/modals/CreateBucketModal.vue +++ b/web/satellite/src/components/modals/CreateBucketModal.vue @@ -61,7 +61,6 @@ import { BUCKET_ACTIONS } from '@/store/modules/buckets'; import { Validator } from '@/utils/validation'; import { AccessGrant, EdgeCredentials } from '@/types/accessGrants'; import { PROJECTS_ACTIONS } from '@/store/modules/projects'; -import { MetaUtils } from '@/utils/meta'; import { LocalData } from '@/utils/localData'; import { MODALS } from '@/utils/constants/appStatePopUps'; import { useAppStore } from '@/store/modules/appStore'; @@ -225,7 +224,7 @@ async function onCreate(): Promise { } const salt = await store.dispatch(PROJECTS_ACTIONS.GET_SALT, store.getters.selectedProject.id); - const satelliteNodeURL: string = MetaUtils.getMetaContent('satellite-nodeurl'); + const satelliteNodeURL: string = appStore.state.config.satelliteNodeURL; worker.value.postMessage({ 'type': 'GenerateAccess', diff --git a/web/satellite/src/components/modals/DeleteBucketModal.vue b/web/satellite/src/components/modals/DeleteBucketModal.vue index 7390c43a8..4d6735f67 100644 --- a/web/satellite/src/components/modals/DeleteBucketModal.vue +++ b/web/satellite/src/components/modals/DeleteBucketModal.vue @@ -36,7 +36,6 @@ import { AnalyticsErrorEventSource, AnalyticsEvent } from '@/utils/constants/ana import { AnalyticsHttpApi } from '@/api/analytics'; import { AccessGrant, EdgeCredentials } from '@/types/accessGrants'; import { PROJECTS_ACTIONS } from '@/store/modules/projects'; -import { MetaUtils } from '@/utils/meta'; import { BUCKET_ACTIONS } from '@/store/modules/buckets'; import { MODALS } from '@/utils/constants/appStatePopUps'; import { useNotify, useStore } from '@/utils/hooks'; @@ -113,7 +112,7 @@ async function onDelete(): Promise { } const salt = await store.dispatch(PROJECTS_ACTIONS.GET_SALT, store.getters.selectedProject.id); - const satelliteNodeURL: string = MetaUtils.getMetaContent('satellite-nodeurl'); + const satelliteNodeURL: string = appStore.state.config.satelliteNodeURL; worker.value.postMessage({ 'type': 'GenerateAccess', diff --git a/web/satellite/src/components/modals/EnableMFAModal.vue b/web/satellite/src/components/modals/EnableMFAModal.vue index 69706eb29..1f987f47d 100644 --- a/web/satellite/src/components/modals/EnableMFAModal.vue +++ b/web/satellite/src/components/modals/EnableMFAModal.vue @@ -109,7 +109,7 @@ const canvas = ref(); * Returns satellite name from store. */ const satellite = computed((): string => { - return appStore.state.satelliteName; + return appStore.state.config.satelliteName; }); /** diff --git a/web/satellite/src/components/modals/NewCreateProjectModal.vue b/web/satellite/src/components/modals/NewCreateProjectModal.vue index 9e514a8ff..c46dc1ce3 100644 --- a/web/satellite/src/components/modals/NewCreateProjectModal.vue +++ b/web/satellite/src/components/modals/NewCreateProjectModal.vue @@ -174,7 +174,7 @@ async function onCreateProjectClick(): Promise { store.commit(OBJECTS_MUTATIONS.CLEAR); - if (usersStore.shouldOnboard && appStore.state.isAllProjectsDashboard) { + if (usersStore.shouldOnboard && appStore.state.config.allProjectsDashboard) { analytics.pageVisit(RouteConfig.OnboardingTour.with(RouteConfig.OverviewStep).path); await router.push(RouteConfig.OnboardingTour.with(RouteConfig.OverviewStep).path); return; diff --git a/web/satellite/src/components/modals/PricingPlanModal.vue b/web/satellite/src/components/modals/PricingPlanModal.vue index 1b2f08931..4308600b9 100644 --- a/web/satellite/src/components/modals/PricingPlanModal.vue +++ b/web/satellite/src/components/modals/PricingPlanModal.vue @@ -108,7 +108,7 @@ const notify = useNotify(); const isLoading = ref(false); const isSuccess = ref(false); -const stripeCardInput = ref<(StripeCardInput & StripeForm) | null>(null); +const stripeCardInput = ref<(typeof StripeCardInput & StripeForm) | null>(null); /** * Returns the pricing plan selected from the onboarding tour. @@ -137,7 +137,7 @@ const isFree = computed((): boolean => { function onClose(): void { appStore.removeActiveModal(); if (isSuccess.value) { - if (appStore.state.isAllProjectsDashboard) { + if (appStore.state.config.allProjectsDashboard) { router.push(RouteConfig.AllProjectsDashboard.path); return; } diff --git a/web/satellite/src/components/modals/ShareBucketModal.vue b/web/satellite/src/components/modals/ShareBucketModal.vue index 9290e1544..72903636e 100644 --- a/web/satellite/src/components/modals/ShareBucketModal.vue +++ b/web/satellite/src/components/modals/ShareBucketModal.vue @@ -43,7 +43,6 @@ import { computed, onMounted, ref } from 'vue'; import { PROJECTS_ACTIONS } from '@/store/modules/projects'; -import { MetaUtils } from '@/utils/meta'; import { AccessGrant, EdgeCredentials } from '@/types/accessGrants'; import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames'; import { MODALS } from '@/utils/constants/appStatePopUps'; @@ -115,7 +114,7 @@ async function setShareLink(): Promise { const LINK_SHARING_AG_NAME = `${path}_shared-bucket_${now.toISOString()}`; const cleanAPIKey: AccessGrant = await agStore.createAccessGrant(LINK_SHARING_AG_NAME, store.getters.selectedProject.id); - const satelliteNodeURL = MetaUtils.getMetaContent('satellite-nodeurl'); + const satelliteNodeURL = appStore.state.config.satelliteNodeURL; const salt = await store.dispatch(PROJECTS_ACTIONS.GET_SALT, store.getters.selectedProject.id); worker.value.postMessage({ @@ -162,7 +161,7 @@ async function setShareLink(): Promise { path = encodeURIComponent(path.trim()); - const linksharingURL = MetaUtils.getMetaContent('linksharing-url'); + const linksharingURL = appStore.state.config.linksharingURL; link.value = `${linksharingURL}/${credentials.accessKeyId}/${path}`; } catch (error) { diff --git a/web/satellite/src/components/navigation/AccountArea.vue b/web/satellite/src/components/navigation/AccountArea.vue index 16360dafc..cbab3b7be 100644 --- a/web/satellite/src/components/navigation/AccountArea.vue +++ b/web/satellite/src/components/navigation/AccountArea.vue @@ -114,7 +114,7 @@ const isDropdown = computed((): boolean => { * Returns satellite name from store. */ const satellite = computed((): string => { - return appStore.state.satelliteName; + return appStore.state.config.satelliteName; }); /** diff --git a/web/satellite/src/components/navigation/MobileNavigation.vue b/web/satellite/src/components/navigation/MobileNavigation.vue index aba2b7fbc..099790d36 100644 --- a/web/satellite/src/components/navigation/MobileNavigation.vue +++ b/web/satellite/src/components/navigation/MobileNavigation.vue @@ -173,7 +173,6 @@ import { User } from '@/types/users'; import { NOTIFICATION_ACTIONS } from '@/utils/constants/actionNames'; import { AnalyticsErrorEventSource, AnalyticsEvent } from '@/utils/constants/analyticsEventNames'; import { LocalData } from '@/utils/localData'; -import { MetaUtils } from '@/utils/meta'; import { MODALS } from '@/utils/constants/appStatePopUps'; import { useNotify, useRouter, useStore } from '@/utils/hooks'; import { useABTestingStore } from '@/store/modules/abTestingStore'; @@ -243,7 +242,7 @@ const isLoading = ref(false); * Indicates if all projects dashboard should be used. */ const isAllProjectsDashboard = computed((): boolean => { - return appStore.state.isAllProjectsDashboard; + return appStore.state.config.allProjectsDashboard; }); /** @@ -271,7 +270,7 @@ const selectedProject = computed((): Project => { * Returns satellite name from store. */ const satellite = computed((): string => { - return appStore.state.satelliteName; + return appStore.state.config.satelliteName; }); /** @@ -442,7 +441,7 @@ function navigateToBilling(): void { if (router.currentRoute.path.includes(RouteConfig.Billing.path)) return; let link = RouteConfig.Account.with(RouteConfig.Billing); - if (MetaUtils.getMetaContent('new-billing-screen') === 'true') { + if (appStore.state.config.newBillingScreen) { link = link.with(RouteConfig.BillingOverview); } router.push(link.path); diff --git a/web/satellite/src/components/navigation/NavigationArea.vue b/web/satellite/src/components/navigation/NavigationArea.vue index a5eeb3826..f499c59a5 100644 --- a/web/satellite/src/components/navigation/NavigationArea.vue +++ b/web/satellite/src/components/navigation/NavigationArea.vue @@ -145,7 +145,7 @@ const isQuickStartDropdownShown = computed((): boolean => { * Indicates if all projects dashboard should be used. */ const isAllProjectsDashboard = computed((): boolean => { - return appStore.state.isAllProjectsDashboard; + return appStore.state.config.allProjectsDashboard; }); /** diff --git a/web/satellite/src/components/notifications/NotificationItem.vue b/web/satellite/src/components/notifications/NotificationItem.vue index ed9e0f1b2..e9997ca54 100644 --- a/web/satellite/src/components/notifications/NotificationItem.vue +++ b/web/satellite/src/components/notifications/NotificationItem.vue @@ -11,11 +11,11 @@

{{ notification.message }}

- {{ requestUrl }} + {{ requestURL }} @@ -28,17 +28,17 @@ diff --git a/web/satellite/src/components/onboardingTour/steps/PricingPlanStep.vue b/web/satellite/src/components/onboardingTour/steps/PricingPlanStep.vue index 65da13bc4..3bde858ec 100644 --- a/web/satellite/src/components/onboardingTour/steps/PricingPlanStep.vue +++ b/web/satellite/src/components/onboardingTour/steps/PricingPlanStep.vue @@ -25,7 +25,6 @@ import { RouteConfig } from '@/router'; import { PricingPlanInfo, PricingPlanType } from '@/types/common'; import { User } from '@/types/users'; import { useNotify, useRouter } from '@/utils/hooks'; -import { MetaUtils } from '@/utils/meta'; import { PaymentsHttpApi } from '@/api/payments'; import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames'; import { useUsersStore } from '@/store/modules/usersStore'; @@ -75,11 +74,11 @@ const plans = ref([ onBeforeMount(async () => { const user: User = usersStore.state.user; let nextPath = RouteConfig.OnboardingTour.with(RouteConfig.OverviewStep).path; - if (appStore.state.isAllProjectsDashboard) { + if (appStore.state.config.allProjectsDashboard) { nextPath = RouteConfig.AllProjectsDashboard.path; } - const pricingPkgsEnabled = Boolean(MetaUtils.getMetaContent('pricing-packages-enabled')); + const pricingPkgsEnabled = appStore.state.config.pricingPackagesEnabled; if (!pricingPkgsEnabled || user.paidTier || !user.partner) { router.push(nextPath); return; diff --git a/web/satellite/src/components/onboardingTour/steps/cliFlow/APIKey.vue b/web/satellite/src/components/onboardingTour/steps/cliFlow/APIKey.vue index cdf4b4856..d84439a80 100644 --- a/web/satellite/src/components/onboardingTour/steps/cliFlow/APIKey.vue +++ b/web/satellite/src/components/onboardingTour/steps/cliFlow/APIKey.vue @@ -24,7 +24,6 @@ import { computed, onMounted } from 'vue'; import { RouteConfig } from '@/router'; -import { MetaUtils } from '@/utils/meta'; import { AnalyticsHttpApi } from '@/api/analytics'; import { useRouter } from '@/utils/hooks'; import { useAppStore } from '@/store/modules/appStore'; @@ -37,9 +36,15 @@ import Icon from '@/../static/images/onboardingTour/apiKeyStep.svg'; const appStore = useAppStore(); const router = useRouter(); -const satelliteAddress: string = MetaUtils.getMetaContent('satellite-nodeurl'); const analytics: AnalyticsHttpApi = new AnalyticsHttpApi(); +/** + * Returns the web address of this satellite from the store. + */ +const satelliteAddress = computed((): string => { + return appStore.state.config.satelliteNodeURL; +}); + /** * Returns API key from store. */ diff --git a/web/satellite/src/components/project/EditProjectDetails.vue b/web/satellite/src/components/project/EditProjectDetails.vue index 4e633744c..8c28662e0 100644 --- a/web/satellite/src/components/project/EditProjectDetails.vue +++ b/web/satellite/src/components/project/EditProjectDetails.vue @@ -209,16 +209,17 @@ import { Project, ProjectFields, ProjectLimits, } from '@/types/projects'; -import { MetaUtils } from '@/utils/meta'; import { AnalyticsErrorEventSource, AnalyticsEvent } from '@/utils/constants/analyticsEventNames'; import { AnalyticsHttpApi } from '@/api/analytics'; import { useNotify, useRouter, useStore } from '@/utils/hooks'; import { useUsersStore } from '@/store/modules/usersStore'; +import { useAppStore } from '@/store/modules/appStore'; import VButton from '@/components/common/VButton.vue'; const usersStore = useUsersStore(); const store = useStore(); +const appStore = useAppStore(); const notify = useNotify(); const router = useRouter(); @@ -325,23 +326,21 @@ const bandwidthMeasurementFormatted = computed((): string => { * Gets current default limit for paid accounts. */ const paidBandwidthLimit = computed((): number => { - const limitVal = getLimitValue(MetaUtils.getMetaContent('default-paid-bandwidth-limit')); + const limitVal = getLimitValue(appStore.state.config.defaultPaidBandwidthLimit); const maxLimit = Math.max(currentLimits.value.bandwidthLimit / Memory.TB, limitVal); if (activeBandwidthMeasurement.value === Dimensions.GB) { return toGB(maxLimit); - } else { - return maxLimit; } + return maxLimit; }); const paidStorageLimit = computed((): number => { - const limitVal = getLimitValue(MetaUtils.getMetaContent('default-paid-storage-limit')); + const limitVal = getLimitValue(appStore.state.config.defaultPaidStorageLimit); const maxLimit = Math.max(currentLimits.value.storageLimit / Memory.TB, limitVal); if (activeStorageMeasurement.value === Dimensions.GB) { return toGB(maxLimit); - } else { - return maxLimit; } + return maxLimit; }); /** diff --git a/web/satellite/src/components/project/dashboard/ProjectDashboard.vue b/web/satellite/src/components/project/dashboard/ProjectDashboard.vue index 8254741d6..76034a531 100644 --- a/web/satellite/src/components/project/dashboard/ProjectDashboard.vue +++ b/web/satellite/src/components/project/dashboard/ProjectDashboard.vue @@ -386,7 +386,7 @@ onMounted(async (): Promise => { isServerSideEncryptionBannerHidden.value = LocalData.getServerSideEncryptionBannerHidden(); if (!store.getters.selectedProject.id) { - if (appStore.state.isAllProjectsDashboard) { + if (appStore.state.config.allProjectsDashboard) { await router.push(RouteConfig.AllProjectsDashboard.path); return; } diff --git a/web/satellite/src/views/ActivateAccount.vue b/web/satellite/src/views/ActivateAccount.vue index 170bb8a2c..749b27162 100644 --- a/web/satellite/src/views/ActivateAccount.vue +++ b/web/satellite/src/views/ActivateAccount.vue @@ -61,8 +61,8 @@ import { onMounted, reactive, ref } from 'vue'; import { AuthHttpApi } from '@/api/auth'; import { RouteConfig } from '@/router'; import { Validator } from '@/utils/validation'; -import { MetaUtils } from '@/utils/meta'; import { useNotify, useRouter } from '@/utils/hooks'; +import { useAppStore } from '@/store/modules/appStore'; import RegistrationSuccess from '@/components/common/RegistrationSuccess.vue'; import VInput from '@/components/common/VInput.vue'; @@ -73,6 +73,7 @@ import InfoIcon from '@/../static/images/notifications/info.svg'; import CloseIcon from '@/../static/images/notifications/closeSmall.svg'; const notify = useNotify(); +const appStore = useAppStore(); const nativeRouter = useRouter(); const router = reactive(nativeRouter); @@ -122,7 +123,7 @@ function setEmail(value: string): void { * Redirects to storj.io homepage. */ function onLogoClick(): void { - window.location.href = MetaUtils.getMetaContent('homepage-url'); + window.location.href = appStore.state.config.homepageURL; } onMounted((): void => { diff --git a/web/satellite/src/views/DashboardArea.vue b/web/satellite/src/views/DashboardArea.vue index c08094705..a287d4d46 100644 --- a/web/satellite/src/views/DashboardArea.vue +++ b/web/satellite/src/views/DashboardArea.vue @@ -110,7 +110,6 @@ import { FetchState } from '@/utils/constants/fetchStateEnum'; import { LocalData } from '@/utils/localData'; import { User } from '@/types/users'; import { AuthHttpApi } from '@/api/auth'; -import { MetaUtils } from '@/utils/meta'; import { AnalyticsHttpApi } from '@/api/analytics'; import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames'; import { BUCKET_ACTIONS } from '@/store/modules/buckets'; @@ -151,9 +150,6 @@ const auth: AuthHttpApi = new AuthHttpApi(); const analytics: AnalyticsHttpApi = new AnalyticsHttpApi(); const resetActivityEvents: string[] = ['keypress', 'mousemove', 'mousedown', 'touchmove']; const inactivityModalTime = 60000; -const sessionDuration: number = parseInt(MetaUtils.getMetaContent('inactivity-timer-duration')) * 1000; -const sessionRefreshInterval: number = sessionDuration / 2; -const debugTimerShown = MetaUtils.getMetaContent('inactivity-timer-viewer-enabled') === 'true'; // Minimum number of recovery codes before the recovery code warning bar is shown. const recoveryCodeWarningThreshold = 4; @@ -169,6 +165,27 @@ const debugTimerText = ref(''); const dashboardContent = ref(null); +/** + * Returns the session duration from the store. + */ +const sessionDuration = computed((): number => { + return appStore.state.config.inactivityTimerDuration * 1000; +}); + +/** + * Returns the session refresh interval from the store. + */ +const sessionRefreshInterval = computed((): number => { + return sessionDuration.value / 2; +}); + +/** + * Indicates whether to display the session timer for debugging. + */ +const debugTimerShown = computed((): boolean => { + return appStore.state.config.inactivityTimerViewerEnabled; +}); + /** * Indicates if account was frozen due to billing issues. */ @@ -260,7 +277,7 @@ const isNavigationHidden = computed((): boolean => { /* whether all projects dashboard should be used */ const isAllProjectsDashboard = computed((): boolean => { - return appStore.state.isAllProjectsDashboard; + return appStore.state.config.allProjectsDashboard; }); /* whether the project limit banner should be shown. */ @@ -314,7 +331,7 @@ const isOnboardingTour = computed((): boolean => { * Indicates if satellite is in beta. */ const isBetaSatellite = computed((): boolean => { - return appStore.state.isBetaSatellite; + return appStore.state.config.isBetaSatellite; }); /** @@ -368,9 +385,7 @@ function clearSessionTimers(): void { * Adds DOM event listeners and starts session timers. */ function setupSessionTimers(): void { - const isInactivityTimerEnabled = MetaUtils.getMetaContent('inactivity-timer-enabled'); - - if (isInactivityTimerEnabled === 'false') return; + if (!appStore.state.config.inactivityTimerEnabled) return; const expiresAt = LocalData.getSessionExpirationDate(); @@ -379,7 +394,7 @@ function setupSessionTimers(): void { document.addEventListener(eventName, onSessionActivity, false); }); - if (expiresAt.getTime() - sessionDuration + sessionRefreshInterval < Date.now()) { + if (expiresAt.getTime() - sessionDuration.value + sessionRefreshInterval.value < Date.now()) { refreshSession(); } @@ -396,7 +411,7 @@ function restartSessionTimers(): void { if (isSessionActive.value) { await refreshSession(); } - }, sessionRefreshInterval); + }, sessionRefreshInterval.value); inactivityTimerId.value = setTimeout(async () => { if (store.getters['files/uploadingLength']) { @@ -410,7 +425,7 @@ function restartSessionTimers(): void { await handleInactive(); await notify.notify('Your session was timed out.'); }, inactivityModalTime); - }, sessionDuration - inactivityModalTime); + }, sessionDuration.value - inactivityModalTime); if (!debugTimerShown) return; @@ -636,7 +651,7 @@ onMounted(async () => { return; } - if (!appStore.state.isAllProjectsDashboard) { + if (!appStore.state.config.allProjectsDashboard) { try { if (!projects.length) { await store.dispatch(PROJECTS_ACTIONS.CREATE_DEFAULT_PROJECT, usersStore.state.user.id); @@ -644,7 +659,8 @@ onMounted(async () => { selectProject(projects); } if (usersStore.shouldOnboard) { - const onboardingPath = RouteConfig.OnboardingTour.with(RouteConfig.FirstOnboardingStep).path; + const firstOnboardingStep = appStore.state.config.pricingPackagesEnabled ? RouteConfig.PricingPlanStep : RouteConfig.OverviewStep; + const onboardingPath = RouteConfig.OnboardingTour.with(firstOnboardingStep).path; await analytics.pageVisit(onboardingPath); await router.push(onboardingPath); diff --git a/web/satellite/src/views/ErrorPage.vue b/web/satellite/src/views/ErrorPage.vue index 8bf54f352..f95b2326d 100644 --- a/web/satellite/src/views/ErrorPage.vue +++ b/web/satellite/src/views/ErrorPage.vue @@ -26,7 +26,6 @@ import { computed, onMounted } from 'vue'; import { useRouter } from '@/utils/hooks'; import { useAppStore } from '@/store/modules/appStore'; -import { MetaUtils } from '@/utils/meta'; import VButton from '@/components/common/VButton.vue'; @@ -65,7 +64,7 @@ const isFatal = computed((): boolean => { * Navigates to the homepage. */ function goToHomepage(): void { - window.location.href = MetaUtils.getMetaContent('homepage-url'); + window.location.href = appStore.state.config.homepageURL || 'https://www.storj.io'; } /** @@ -83,7 +82,7 @@ function onButtonClick(): void { * Lifecycle hook after initial render. Sets page title. */ onMounted(() => { - const satName = appStore.state.satelliteName; + const satName = appStore.state.config.satelliteName; document.title = statusCode.value.toString() + (satName ? ' | ' + satName : ''); }); diff --git a/web/satellite/src/views/ForgotPassword.vue b/web/satellite/src/views/ForgotPassword.vue index a34b5653b..e671b062c 100644 --- a/web/satellite/src/views/ForgotPassword.vue +++ b/web/satellite/src/views/ForgotPassword.vue @@ -56,18 +56,18 @@ /> (''); @@ -143,14 +136,21 @@ const captcha = ref(); * Name of the current satellite. */ const satelliteName = computed((): string => { - return appStore.state.satelliteName; + return appStore.state.config.satelliteName; }); /** * Information about partnered satellites, including name and signup link. */ const partneredSatellites = computed((): PartneredSatellite[] => { - return appStore.state.partneredSatellites; + return appStore.state.config.partneredSatellites; +}); + +/** + * This component's captcha configuration. + */ +const captchaConfig = computed((): MultiCaptchaConfig => { + return appStore.state.config.captcha.login; }); /** @@ -237,7 +237,7 @@ async function onSendConfigurations(): Promise { * Redirects to storj.io homepage. */ function onLogoClick(): void { - window.location.href = MetaUtils.getMetaContent('homepage-url'); + window.location.href = appStore.state.config.homepageURL; } /** diff --git a/web/satellite/src/views/LoginArea.vue b/web/satellite/src/views/LoginArea.vue index 92301b80c..74d34d8b1 100644 --- a/web/satellite/src/views/LoginArea.vue +++ b/web/satellite/src/views/LoginArea.vue @@ -100,14 +100,14 @@ Or use recovery code -