UNPKG

@cocalc/server

Version:

CoCalc server functionality: functions used by either the hub and the next.js server

82 lines (81 loc) 4.08 kB
"use strict"; /* * This file is part of CoCalc: Copyright © 2021 Sagemath, Inc. * License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const site_defaults_1 = require("@cocalc/util/db-schema/site-defaults"); const get_strategies_1 = __importDefault(require("../auth/sso/get-strategies")); const server_settings_1 = require("./server-settings"); const site_url_1 = __importDefault(require("./site-url")); const fallback = (a, b) => typeof a == "string" && a.length > 0 ? a : `${b}`; /* Create a Javascript object that describes properties of the server. This is used on the next.js server landing pages and the share server to customize their look and behavior. This function is cached via the parameters in ./server-settings, i.e., for a few seconds. */ let cachedSettings = undefined; let cachedCustomize = undefined; async function getCustomize() { const [settings, strategies] = await Promise.all([(0, server_settings_1.getServerSettings)(), (0, get_strategies_1.default)()]); if (settings === cachedSettings && cachedCustomize != null) { return cachedCustomize; } cachedSettings = settings; cachedCustomize = { siteName: fallback(settings.site_name, "On Premises CoCalc"), siteDescription: fallback(settings.site_description, "Collaborative Calculation using Python, Sage, R, Julia, and more."), organizationName: settings.organization_name, organizationEmail: settings.organization_email, organizationURL: settings.organization_url, termsOfServiceURL: settings.terms_of_service_url, helpEmail: settings.help_email, contactEmail: fallback(settings.organization_email, settings.help_email), isCommercial: settings.commercial, kucalc: settings.kucalc, sshGateway: settings.ssh_gateway, sshGatewayDNS: settings.ssh_gateway_dns, anonymousSignup: settings.anonymous_signup, emailSignup: settings.email_signup, accountCreationInstructions: settings.account_creation_email_instructions, logoSquareURL: settings.logo_square, logoRectangularURL: settings.logo_rectangular, splashImage: settings.splash_image, shareServer: !!settings.share_server, // additionally restrict showing landing pages only in cocalc.com-mode landingPages: !!settings.landing_pages && settings.kucalc === site_defaults_1.KUCALC_COCALC_COM, googleAnalytics: settings.google_analytics, indexInfo: settings.index_info_html, imprint: settings.imprint, policies: settings.policies, // Is important for invite emails, password reset, etc. (e.g., so we can construct a url to our site). // This *can* start with http:// to explicitly use http instead of https, and can end // in something like :3594 to indicate a port. dns: settings.dns, // siteURL is derived from settings.dns and the basePath -- it combines the dns, https:// // and the basePath. It never ends in a slash. This is used in practice for // things like invite emails, password reset, etc. siteURL: await (0, site_url_1.default)(settings.dns), zendesk: settings.zendesk_token && settings.zendesk_username && settings.zendesk_uri, // obviously only the public key here! stripePublishableKey: settings.stripe_publishable_key, // obviously only the public key here too! reCaptchaKey: settings.re_captcha_v3_publishable_key, // a sandbox project sandboxProjectId: settings.sandbox_project_id, // GitHub proxy project githubProjectId: settings.github_project_id, // public info about SSO strategies strategies, }; return cachedCustomize; } exports.default = getCustomize; //# sourceMappingURL=customize.js.map