UNPKG

@cocalc/server

Version:

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

26 lines 1.25 kB
"use strict"; /* * This file is part of CoCalc: Copyright © 2022 Sagemath, Inc. * License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details */ Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitizeID = void 0; // the "id" that's coming in from OAuth2 and others must uniquely identify a user function sanitizeID(opts) { // id must be a uniquely identifying string, usually the ID of the user // sometimes just the email, but not something that's not unique for the user. // Why? The DB looks up pasports by their "passport key", which is strategyName + id, // to check if an assocated account already exists in the DB. if (opts.id == null || opts.id === "undefined" || opts.id === "null") { throw new Error(`opts.id must be uniquely identifying`); } // here, a number will be converted to a string opts.id = `${opts.id}`; if (opts.id.length == 0) { // it would be ideal if such IDs are long "random" strings, but in reality it could // be a number starting at 0. What we can't allow is an empty string. throw new Error(`opts.id must be uniquely identifying`); } } exports.sanitizeID = sanitizeID; //# sourceMappingURL=sanitize-id.js.map