UNPKG

@cocalc/server

Version:

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

53 lines (52 loc) 2.13 kB
"use strict"; /* * This file is part of CoCalc: Copyright © 2022 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 }); exports.COLORS = void 0; const pool_1 = __importDefault(require("@cocalc/database/pool")); const auth_1 = require("@cocalc/util/auth"); /** Returns an array of public info about strategies. * Cached a bit so safe to call a lot. */ async function getStrategies() { const pool = (0, pool_1.default)("long"); // entries in "conf" were used before the "info" col existed. this is only for backwards compatibility. const { rows } = await pool.query(` SELECT strategy, COALESCE(info -> 'icon', conf -> 'icon') as icon, COALESCE(info -> 'display', conf -> 'display') as display, COALESCE(info -> 'public', conf -> 'public') as public, COALESCE(info -> 'exclusive_domains', conf -> 'exclusive_domains') as exclusive_domains, COALESCE(info -> 'do_not_hide', 'false'::JSONB) as do_not_hide FROM passport_settings WHERE strategy != 'site_conf' AND COALESCE(info ->> 'disabled', conf ->> 'disabled', 'false') != 'true'`); return rows.map((row) => { const display = (0, auth_1.ssoDispayedName)({ display: row.display, name: row.strategy, }); return { name: row.strategy, display, icon: row.icon, backgroundColor: exports.COLORS[row.strategy] ?? "", public: row.public ?? true, exclusiveDomains: row.exclusive_domains ?? [], doNotHide: row.do_not_hide ?? false, }; }); } exports.default = getStrategies; exports.COLORS = { github: "#000000", facebook: "#428bca", google: "#dc4857", twitter: "#55acee", }; //# sourceMappingURL=get-strategies.js.map