diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/index.js b/packages/client/src/pages/PortalSettings/categories/developer-tools/index.js index a653832854..4d01c32091 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/index.js +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/index.js @@ -24,32 +24,21 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -import React, { useEffect, useState, useTransition, Suspense } from "react"; +import React, { useEffect, useState, useTransition } from "react"; import { Tabs } from "@docspace/shared/components/tabs"; -import { Box } from "@docspace/shared/components/box"; import { inject, observer } from "mobx-react"; -import { combineUrl } from "@docspace/shared/utils/combineUrl"; import config from "PACKAGE_FILE"; import { useNavigate, useLocation } from "react-router-dom"; -import JavascriptSDK from "./JavascriptSDK"; -import Webhooks from "./Webhooks"; - -import Api from "./Api"; - import { useTranslation } from "react-i18next"; -import { useNavigate } from "react-router-dom"; -import { inject, observer } from "mobx-react"; import { Box } from "@docspace/shared/components/box"; import { Badge } from "@docspace/shared/components/badge"; import { SECTION_HEADER_HEIGHT } from "@docspace/shared/components/section/Section.constants"; import { combineUrl } from "@docspace/shared/utils/combineUrl"; -import config from "PACKAGE_FILE"; - import JavascriptSDK from "./JavascriptSDK"; import Webhooks from "./Webhooks"; import Api from "./Api"; diff --git a/packages/login/index.d.ts b/packages/login/index.d.ts index 2cc3bf874b..d794d2e2d7 100644 --- a/packages/login/index.d.ts +++ b/packages/login/index.d.ts @@ -1,226 +1,3 @@ -import { - IClientProps, - INoAuthClientProps, - IScope, -} from "@docspace/common/utils/oauth/interfaces"; -import { Request } from "express"; - -type WindowI18nType = { - inLoad: object[]; - loaded: { - [key: string]: { - data: { - [key: string]: string | undefined; - }; - namespaces?: string; - }; - }; -}; - -declare global { - interface Window { - authCallback?: (profile: string) => {}; - __ASC_INITIAL_LOGIN_STATE__: IInitialState; - initialI18nStoreASC: IInitialI18nStoreASC; - initialLanguage: string; - i18n: WindowI18nType; - [key: string]: object; - } - - type MatchType = { - confirmedEmail?: string; - message?: string; - messageKey?: string; - authError?: string; - type?: string; - client_id?: string; - state?: string; - }; - - type PasswordHashType = { - iterations: number; - salt: string; - size: number; - }; - - type CaptchaPublicKeyType = string | undefined; - - interface IEmailValid { - value: string; - isValid: boolean; - errors: string[]; // TODO: check type - } - - interface IPortalSettings { - culture: string; - debugInfo: boolean; - docSpace: boolean; - enableAdmMess: boolean; - enabledJoin: boolean; - greetingSettings: string; - ownerId: string; - passwordHash: PasswordHashType; - personal: boolean; - tenantAlias: string; - tenantStatus: number; - thirdpartyEnable: boolean; - trustedDomainsType: number; - utcHoursOffset: number; - utcOffset: string; - version: string; - standalone: boolean; - trustedDomains: string[]; - recaptchaPublicKey: CaptchaPublicKeyType; - } - - interface IBuildInfo { - communityServer: string; - documentServer: string; - mailServer: string; - } - - interface IProvider { - linked: boolean; - provider: string; - url: string; - } - type ProvidersType = IProvider[] | undefined; - - interface ICapabilities { - ldapEnabled: boolean; - providers: string[]; - ssoLabel: string; - ssoUrl: string; - } - - type TThemeObj = { - accent: string; - buttons: string; - }; - - interface ITheme { - id: number; - main: TThemeObj; - text: TThemeObj; - name: string; - } - interface IThemes { - limit: number; - selected: number; - themes: ITheme[]; - } - - interface IError { - status: number; - standalone: boolean; - message: string | undefined; - } - - interface ISSOSettings { - hideAuthPage: boolean; - } - - interface ISelf { - avatarMax: string; - avatarMedium: string; - avatar: string; - avatarSmall: string; - hasAvatar: boolean; - - displayName: string; - id: string; - - firstName: string; - lasName: string; - userName: string; - email: string; - } - - interface IOAuthState { - client: IClientProps | INoAuthClientProps; - clientId: string; - state: string; - self?: ISelf; - scopes?: IScope[]; - isConsent: boolean; - } - - interface IInitialState { - portalSettings?: IPortalSettings; - buildInfo?: IBuildInfo; - providers?: ProvidersType; - capabilities?: ICapabilities; - match?: MatchType; - currentColorScheme?: ITheme; - ssoSettings?: ISSOSettings; - logoUrls: ILogoUrl[]; - error?: IError; - oauth?: IOAuthState; - } - - interface DevRequest { - assets: assetsType; - } - var IS_DEVELOPMENT: boolean; - var PORT: number; - var IS_PERSONAL: boolean; - var IS_ROOMS_MODE: boolean; - var BROWSER_DETECTOR_URL: string; - var CONFIG_URL: string; - - type assetsType = { [key: string]: string } | undefined; - - interface IInitialI18nStoreASC extends Object { - en: { - [Common: string]: { [key: any]: string }; - [Login: string]: { [key: any]: string }; - }; - [key: string]: { - [Common: string]: { [key: any]: string }; - [Login: string]: { [key: any]: string }; - }; - } - - type HTMLElementEvent = Event & { - target: T; - }; - - type TFuncType = (key: string) => string; - - interface IParsedConfig extends Object { - PORT: number; - } - interface ILoginRequest extends Request { - i18n?: I18next; - t?: TFuncType; - } - type timeoutType = ReturnType; - interface IAcceptLanguage { - code?: string; - quality?: number; - } - - interface IUserTheme { - [key: string]: string; - isBase: boolean; - } - - type TLogoPath = { - light: string; - dark?: string; - }; - - type TLogoSize = { - width: number; - height: number; - isEmpty: boolean; - }; - - interface ILogoUrl { - name: string; - path: TLogoPath; - size: TLogoSize; - } // (c) Copyright Ascensio System SIA 2009-2024 // // This program is a free software product. @@ -250,9 +27,9 @@ declare global { declare module "*.ico?url" { const content: string; export default content; - } +} declare module "*.svg?url" { const content: string; export default content; - } +} diff --git a/packages/login/src/app/(root)/page.tsx b/packages/login/src/app/(root)/page.tsx index bde0b98aeb..187d2fd6be 100644 --- a/packages/login/src/app/(root)/page.tsx +++ b/packages/login/src/app/(root)/page.tsx @@ -26,7 +26,7 @@ import { INoAuthClientProps } from "@docspace/shared/utils/oauth/interfaces"; -import { getOAuthClient, getSettings } from "@/utils/actions"; +import { getConfig, getOAuthClient, getSettings } from "@/utils/actions"; import Login from "@/components/Login"; import LoginForm from "@/components/LoginForm"; import ThirdParty from "@/components/ThirdParty"; @@ -40,11 +40,16 @@ async function Page({ }) { const clientId = searchParams.clientId; - const [settings, client] = await Promise.all([ + const [settings, client, config] = await Promise.all([ getSettings(), clientId ? getOAuthClient(clientId, false) : undefined, + clientId ? getConfig() : undefined, ]); + const isPublicOAuth = clientId && config.oauth2.publicClient; + + console.log(isPublicOAuth); + return ( {settings && typeof settings !== "string" && ( diff --git a/packages/login/src/app/layout.tsx b/packages/login/src/app/layout.tsx index a30a1f8aa8..58704a18dd 100644 --- a/packages/login/src/app/layout.tsx +++ b/packages/login/src/app/layout.tsx @@ -33,7 +33,7 @@ import { LANGUAGE, SYSTEM_THEME_KEY } from "@docspace/shared/constants"; import StyledComponentsRegistry from "@/utils/registry"; import { Providers } from "@/providers"; -import { getColorTheme, getSettings } from "@/utils/actions"; +import { getColorTheme, getConfig, getSettings } from "@/utils/actions"; import "../styles/globals.scss"; @@ -55,9 +55,10 @@ export default async function RootLayout({ const startOtherOperationsDate = new Date(); - const [settings, colorTheme] = await Promise.all([ + const [settings, colorTheme, config] = await Promise.all([ getSettings(), getColorTheme(), + getConfig(), ]); timers.otherOperations = @@ -66,9 +67,6 @@ export default async function RootLayout({ if (settings === "access-restricted") redirectUrl = `/${settings}`; if (settings === "portal-not-found") { - const config = await ( - await fetch(`${baseUrl}/static/scripts/config.json`) - ).json(); const hdrs = headers(); const host = hdrs.get("host"); @@ -125,7 +123,6 @@ export default async function RootLayout({ systemTheme: systemTheme?.value as ThemeKeys, }} redirectURL={redirectUrl} - timers={timers} > {children} diff --git a/packages/login/src/utils/actions.ts b/packages/login/src/utils/actions.ts index 11ffd38517..11a253c2c5 100644 --- a/packages/login/src/utils/actions.ts +++ b/packages/login/src/utils/actions.ts @@ -28,7 +28,10 @@ import { headers } from "next/headers"; -import { createRequest } from "@docspace/shared/utils/next-ssr-helper"; +import { + createRequest, + getBaseUrl, +} from "@docspace/shared/utils/next-ssr-helper"; import { TUser } from "@docspace/shared/api/people/types"; import { TCapabilities, @@ -228,3 +231,12 @@ export async function getPortalCultures() { return cultures.response as TPortalCultures; } + +export async function getConfig() { + const baseUrl = getBaseUrl(); + const config = await ( + await fetch(`${baseUrl}/static/scripts/config.json`) + ).json(); + + return config; +} diff --git a/packages/runtime.json b/packages/runtime.json index 9c0a73efb4..faa19a7eb1 100644 --- a/packages/runtime.json +++ b/packages/runtime.json @@ -1,9 +1,9 @@ { - "date": "2024530_114536", + "date": "2024619_181025", "checksums": { "api.js": "0efbae3383bf6c6b6f26d573eee164d2", "api.poly.js": "2a2ac2c0e4a7007b61d2d1ff7b00a22e", "browserDetector.js": "d9387cce805699498e798230a8639c8a", - "config.json": "e2842b7489cfe221207e6833191246b1" + "config.json": "1cc6da8a9d43cda405c4f85b0e6039e4" } } \ No newline at end of file