diff --git a/src/node/db/Pad.ts b/src/node/db/Pad.ts index fa4af994d..f448aae16 100644 --- a/src/node/db/Pad.ts +++ b/src/node/db/Pad.ts @@ -12,7 +12,7 @@ const Changeset = require('../../static/js/Changeset'); const ChatMessage = require('../../static/js/ChatMessage'); const AttributePool = require('../../static/js/AttributePool'); const Stream = require('../utils/Stream'); -const assert = require('assert').strict; +import {strict as assert} from "assert"; const db = require('./DB'); const settings = require('../utils/Settings'); const authorManager = require('./AuthorManager'); @@ -39,13 +39,13 @@ exports.cleanText = (txt:string): string => txt.replace(/\r\n/g, '\n') class Pad { private db: Database; - private atext: AText; + private readonly atext: AText; private pool: APool; private head: number; private chatHead: number; private publicStatus: boolean; private id: string; - private savedRevisions: any[]; + private readonly savedRevisions: any[]; /** * @param id * @param [database] - Database object to access this pad's records (and only this pad's records; diff --git a/src/node/db/SecurityManager.ts b/src/node/db/SecurityManager.ts index 326bf3659..20b10337a 100644 --- a/src/node/db/SecurityManager.ts +++ b/src/node/db/SecurityManager.ts @@ -28,7 +28,7 @@ const readOnlyManager = require('./ReadOnlyManager'); const sessionManager = require('./SessionManager'); const settings = require('../utils/Settings'); const webaccess = require('../hooks/express/webaccess'); -const log4js = require('log4js'); +import log4js from 'log4js'; const authLogger = log4js.getLogger('auth'); const {padutils} = require('../../static/js/pad_utils'); diff --git a/src/node/db/SessionStore.ts b/src/node/db/SessionStore.ts index 5dca5e201..109979e2b 100644 --- a/src/node/db/SessionStore.ts +++ b/src/node/db/SessionStore.ts @@ -2,8 +2,8 @@ const DB = require('./DB'); const Store = require('express-session').Store; -const log4js = require('log4js'); -const util = require('util'); +import log4js from 'log4js'; +import util from 'util'; const logger = log4js.getLogger('SessionStore'); diff --git a/src/node/eejs/index.ts b/src/node/eejs/index.ts index eb9e882f0..bbb671257 100644 --- a/src/node/eejs/index.ts +++ b/src/node/eejs/index.ts @@ -20,11 +20,11 @@ * require("./index").require("./path/to/template.ejs") */ -const ejs = require('ejs'); -const fs = require('fs'); +import ejs from 'ejs'; +import fs from 'fs'; const hooks = require('../../static/js/pluginfw/hooks.js'); -const path = require('path'); -const resolve = require('resolve'); +import path from 'path'; +import resolve from 'resolve'; const settings = require('../utils/Settings'); const templateCache = new Map(); diff --git a/src/node/handler/PadMessageHandler.ts b/src/node/handler/PadMessageHandler.ts index fc454ee14..532b7ac7e 100644 --- a/src/node/handler/PadMessageHandler.ts +++ b/src/node/handler/PadMessageHandler.ts @@ -38,7 +38,7 @@ const messageLogger = log4js.getLogger('message'); const accessLogger = log4js.getLogger('access'); const hooks = require('../../static/js/pluginfw/hooks.js'); const stats = require('../stats') -const assert = require('assert').strict; +import {strict as assert} from "assert"; import {RateLimiterMemory} from 'rate-limiter-flexible'; import {ChangesetRequest, PadUserInfo, SocketClientRequest} from "../types/SocketClientRequest"; import {APool, AText, PadAuthor, PadType} from "../types/PadType"; diff --git a/src/node/handler/SocketIORouter.ts b/src/node/handler/SocketIORouter.ts index 482276834..8ce8b9f27 100644 --- a/src/node/handler/SocketIORouter.ts +++ b/src/node/handler/SocketIORouter.ts @@ -22,7 +22,7 @@ import {MapArrayType} from "../types/MapType"; import {SocketModule} from "../types/SocketModule"; -const log4js = require('log4js'); +import log4js from 'log4js'; const settings = require('../utils/Settings'); const stats = require('../../node/stats') diff --git a/src/node/hooks/express.ts b/src/node/hooks/express.ts index 29da71ac3..c5f9f114e 100644 --- a/src/node/hooks/express.ts +++ b/src/node/hooks/express.ts @@ -119,11 +119,10 @@ exports.restartServer = async () => { options.ca.push(fs.readFileSync(caFileName)); } } - - const https = require('https'); + const https = await import('https') exports.server = https.createServer(options, app); } else { - const http = require('http'); + const http = await import('http') exports.server = http.createServer(app); } diff --git a/src/node/hooks/express/adminplugins.ts b/src/node/hooks/express/adminplugins.ts index dc34cd437..d3e84ebe1 100644 --- a/src/node/hooks/express/adminplugins.ts +++ b/src/node/hooks/express/adminplugins.ts @@ -11,7 +11,7 @@ const settings = require('../../utils/Settings'); const installer = require('../../../static/js/pluginfw/installer'); const pluginDefs = require('../../../static/js/pluginfw/plugin_defs'); const plugins = require('../../../static/js/pluginfw/plugins'); -const semver = require('semver'); +import semver from 'semver'; exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => { diff --git a/src/node/hooks/express/adminsettings.ts b/src/node/hooks/express/adminsettings.ts index 03258c584..84c7b065e 100644 --- a/src/node/hooks/express/adminsettings.ts +++ b/src/node/hooks/express/adminsettings.ts @@ -5,7 +5,7 @@ import {PadQueryResult, PadSearchQuery} from "../../types/PadSearchQuery"; import {PadType} from "../../types/PadType"; const eejs = require('../../eejs'); -const fsp = require('fs').promises; +import {promises as fsp} from 'fs' const hooks = require('../../../static/js/pluginfw/hooks'); const plugins = require('../../../static/js/pluginfw/plugins'); const settings = require('../../utils/Settings'); diff --git a/src/node/hooks/express/apicalls.ts b/src/node/hooks/express/apicalls.ts index 91c44e389..a728899da 100644 --- a/src/node/hooks/express/apicalls.ts +++ b/src/node/hooks/express/apicalls.ts @@ -1,10 +1,10 @@ 'use strict'; -const log4js = require('log4js'); +import log4js from 'log4js'; const clientLogger = log4js.getLogger('client'); -const {Formidable} = require('formidable'); +import {Formidable} from 'formidable'; const apiHandler = require('../../handler/APIHandler'); -const util = require('util'); +import util from 'util'; exports.expressPreSession = async (hookName:string, {app}:any) => { // The Etherpad client side sends information about how a disconnect happened @@ -14,17 +14,18 @@ exports.expressPreSession = async (hookName:string, {app}:any) => { res.end('OK'); }); - const parseJserrorForm = async (req:any) => { + const parseJserrorForm = async (req:any):Promise => { const form = new Formidable({ maxFileSize: 1, // Files are not expected. Not sure if 0 means unlimited, so 1 is used. }); const [fields, files] = await form.parse(req); - return fields.errorInfo; + return fields.errorInfo!; }; // The Etherpad client side sends information about client side javscript errors app.post('/jserror', (req:any, res:any, next:Function) => { (async () => { + // @ts-ignore const data = JSON.parse(await parseJserrorForm(req)); clientLogger.warn(`${data.msg} --`, { [util.inspect.custom]: (depth: number, options:any) => { diff --git a/src/node/hooks/express/importexport.ts b/src/node/hooks/express/importexport.ts index 898606e49..a38b36db4 100644 --- a/src/node/hooks/express/importexport.ts +++ b/src/node/hooks/express/importexport.ts @@ -8,7 +8,7 @@ const exportHandler = require('../../handler/ExportHandler'); const importHandler = require('../../handler/ImportHandler'); const padManager = require('../../db/PadManager'); const readOnlyManager = require('../../db/ReadOnlyManager'); -const rateLimit = require('express-rate-limit'); +import rateLimit from 'express-rate-limit'; const securityManager = require('../../db/SecurityManager'); const webaccess = require('./webaccess'); diff --git a/src/node/hooks/express/openapi.ts b/src/node/hooks/express/openapi.ts index aa2f1e483..3f5b1c2a6 100644 --- a/src/node/hooks/express/openapi.ts +++ b/src/node/hooks/express/openapi.ts @@ -19,14 +19,14 @@ import {ErrorCaused} from "../../types/ErrorCaused"; */ const OpenAPIBackend = require('openapi-backend').default; -const IncomingForm = require('formidable').IncomingForm; -const cloneDeep = require('lodash.clonedeep'); -const createHTTPError = require('http-errors'); +import {IncomingForm} from 'formidable' +import cloneDeep from 'lodash.clonedeep'; +import createHTTPError from 'http-errors'; const apiHandler = require('../../handler/APIHandler'); const settings = require('../../utils/Settings'); -const log4js = require('log4js'); +import log4js from 'log4js'; const logger = log4js.getLogger('API'); // https://github.com/OAI/OpenAPI-Specification/tree/master/schemas/v3.0 @@ -401,6 +401,7 @@ for (const [resource, actions] of Object.entries(resources)) { // add response objects const responses:OpenAPISuccessResponse = {...defaultResponseRefs}; if (responseSchema) { + // @ts-ignore responses[200] = cloneDeep(defaultResponses.Success); responses[200].content!['application/json'].schema.properties.data = { type: 'object', @@ -636,7 +637,7 @@ exports.expressPreSession = async (hookName:string, {app}:any) => { // an unknown error happened // log it and throw internal error logger.error(errCaused.stack || errCaused.toString()); - throw new createHTTPError.InternalError('internal error'); + throw new createHTTPError.InternalServerError('internal error'); } } @@ -657,7 +658,7 @@ exports.expressPreSession = async (hookName:string, {app}:any) => { } // start and bind to express - api.init(); + await api.init(); app.use(apiRoot, async (req:any, res:any) => { let response = null; try { diff --git a/src/node/hooks/express/socketio.ts b/src/node/hooks/express/socketio.ts index bbdec1c1c..904549fe2 100644 --- a/src/node/hooks/express/socketio.ts +++ b/src/node/hooks/express/socketio.ts @@ -5,7 +5,7 @@ import {ArgsExpressType} from "../../types/ArgsExpressType"; import events from 'events'; const express = require('../express'); import log4js from 'log4js'; -const proxyaddr = require('proxy-addr'); +import proxyaddr from 'proxy-addr'; const settings = require('../../utils/Settings'); import {Server, Socket} from 'socket.io' const socketIORouter = require('../../handler/SocketIORouter'); diff --git a/src/node/hooks/express/specialpages.ts b/src/node/hooks/express/specialpages.ts index 85a23479f..c336588dc 100644 --- a/src/node/hooks/express/specialpages.ts +++ b/src/node/hooks/express/specialpages.ts @@ -1,16 +1,16 @@ 'use strict'; -const path = require('path'); +import path from 'path'; const eejs = require('../../eejs'); -const fs = require('fs'); -const fsp = fs.promises; +import fs from 'fs'; +import {promises as fsp} from 'fs'; const toolbar = require('../../utils/toolbar'); const hooks = require('../../../static/js/pluginfw/hooks'); const settings = require('../../utils/Settings'); -const util = require('util'); +import util from 'util'; const webaccess = require('./webaccess'); -exports.expressPreSession = async (hookName:string, {app}:any) => { +exports.expressPreSession = async (hookName:string, {app}: { app: any }) => { // This endpoint is intended to conform to: // https://www.ietf.org/archive/id/draft-inadarei-api-health-check-06.html app.get('/health', (req:any, res:any) => { diff --git a/src/node/hooks/express/static.ts b/src/node/hooks/express/static.ts index 6b0b75593..6dbdfb692 100644 --- a/src/node/hooks/express/static.ts +++ b/src/node/hooks/express/static.ts @@ -3,9 +3,9 @@ import {MapArrayType} from "../../types/MapType"; import {PartType} from "../../types/PartType"; -const fs = require('fs').promises; +import {promises as fs} from 'fs' const minify = require('../../utils/Minify'); -const path = require('path'); +import path from 'path'; const plugins = require('../../../static/js/pluginfw/plugin_defs'); const settings = require('../../utils/Settings'); const CachingMiddleware = require('../../utils/caching_middleware'); diff --git a/src/node/hooks/express/tests.ts b/src/node/hooks/express/tests.ts index f8a1417ef..3a1329824 100644 --- a/src/node/hooks/express/tests.ts +++ b/src/node/hooks/express/tests.ts @@ -3,8 +3,8 @@ import {Dirent} from "node:fs"; import {PluginDef} from "../../types/PartType"; -const path = require('path'); -const fsp = require('fs').promises; +import path from 'path'; +import {promises as fsp} from 'fs'; const plugins = require('../../../static/js/pluginfw/plugin_defs'); const sanitizePathname = require('../../utils/sanitizePathname'); const settings = require('../../utils/Settings'); diff --git a/src/node/hooks/i18n.ts b/src/node/hooks/i18n.ts index 500f1f887..05073fdf3 100644 --- a/src/node/hooks/i18n.ts +++ b/src/node/hooks/i18n.ts @@ -4,11 +4,11 @@ import type {MapArrayType} from "../types/MapType"; import {I18nPluginDefs} from "../types/I18nPluginDefs"; const languages = require('languages4translatewiki'); -const fs = require('fs'); -const path = require('path'); -const _ = require('underscore'); +import fs from 'fs'; +import path from 'path'; +import _ from 'underscore'; const pluginDefs = require('../../static/js/pluginfw/plugin_defs.js'); -const existsSync = require('../utils/path_exists'); +import existsSync from '../utils/path_exists'; const settings = require('../utils/Settings'); // returns all existing messages merged together and grouped by langcode diff --git a/src/node/security/SecretRotator.ts b/src/node/security/SecretRotator.ts index ee5bec772..d8a53616a 100644 --- a/src/node/security/SecretRotator.ts +++ b/src/node/security/SecretRotator.ts @@ -3,14 +3,14 @@ import {DeriveModel} from "../types/DeriveModel"; import {LegacyParams} from "../types/LegacyParams"; -const {Buffer} = require('buffer'); +import {Buffer} from 'buffer'; const crypto = require('./crypto'); const db = require('../db/DB'); -const log4js = require('log4js'); +import log4js from 'log4js'; class Kdf { async generateParams(): Promise<{ salt: string; digest: string; keyLen: number; secret: string }> { throw new Error('not implemented'); } - async derive(params: DeriveModel, info: any) { throw new Error('not implemented'); } + async derive(params: DeriveModel, info: any):Promise { throw new Error('not implemented'); } } class LegacyStaticSecret extends Kdf { diff --git a/src/node/security/crypto.ts b/src/node/security/crypto.ts index 9cf0a95a0..92347a577 100644 --- a/src/node/security/crypto.ts +++ b/src/node/security/crypto.ts @@ -1,7 +1,7 @@ 'use strict'; -const crypto = require('crypto'); -const util = require('util'); +import crypto from 'crypto'; +import util from 'util'; /** diff --git a/src/node/utils/Abiword.ts b/src/node/utils/Abiword.ts index c0937fcd9..db6b09a99 100644 --- a/src/node/utils/Abiword.ts +++ b/src/node/utils/Abiword.ts @@ -22,10 +22,10 @@ import {ChildProcess} from "node:child_process"; import {AsyncQueueTask} from "../types/AsyncQueueTask"; -const spawn = require('child_process').spawn; -const async = require('async'); +import {spawn} from 'child_process' +import async from 'async'; const settings = require('./Settings'); -const os = require('os'); +import os from 'os'; // on windows we have to spawn a process for each convertion, // cause the plugin abicommand doesn't exist on this platform diff --git a/src/node/utils/AbsolutePaths.ts b/src/node/utils/AbsolutePaths.ts index c257440a1..28665e25f 100644 --- a/src/node/utils/AbsolutePaths.ts +++ b/src/node/utils/AbsolutePaths.ts @@ -18,9 +18,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const log4js = require('log4js'); -const path = require('path'); -const _ = require('underscore'); +import log4js from 'log4js'; +import path from 'path'; +import _ from 'underscore'; const absPathLogger = log4js.getLogger('AbsolutePaths'); diff --git a/src/node/utils/ExportEtherpad.ts b/src/node/utils/ExportEtherpad.ts index 292fbcec4..2b80b8fd7 100644 --- a/src/node/utils/ExportEtherpad.ts +++ b/src/node/utils/ExportEtherpad.ts @@ -16,7 +16,8 @@ */ const Stream = require('./Stream'); -const assert = require('assert').strict; +import {strict as assert} from "assert"; + const authorManager = require('../db/AuthorManager'); const hooks = require('../../static/js/pluginfw/hooks'); const padManager = require('../db/PadManager'); diff --git a/src/node/utils/ExportHtml.ts b/src/node/utils/ExportHtml.ts index 3b84c4380..8156ba58a 100644 --- a/src/node/utils/ExportHtml.ts +++ b/src/node/utils/ExportHtml.ts @@ -21,7 +21,7 @@ import {MapArrayType} from "../types/MapType"; const Changeset = require('../../static/js/Changeset'); const attributes = require('../../static/js/attributes'); const padManager = require('../db/PadManager'); -const _ = require('underscore'); +import _ from 'underscore'; const Security = require('../../static/js/security'); const hooks = require('../../static/js/pluginfw/hooks'); const eejs = require('../eejs'); diff --git a/src/node/utils/LibreOffice.ts b/src/node/utils/LibreOffice.ts index e89ebe460..c74c8a90a 100644 --- a/src/node/utils/LibreOffice.ts +++ b/src/node/utils/LibreOffice.ts @@ -17,11 +17,11 @@ * limitations under the License. */ -const async = require('async'); -const fs = require('fs').promises; -const log4js = require('log4js'); -const os = require('os'); -const path = require('path'); +import async from 'async'; +import {promises as fs} from 'fs'; +import log4js from 'log4js'; +import os from 'os'; +import path from 'path'; const runCmd = require('./run_cmd'); const settings = require('./Settings'); @@ -87,7 +87,6 @@ const queue = async.queue(doConvertTask, 1); * @param {String} srcFile The path on disk to convert * @param {String} destFile The path on disk where the converted file should be stored * @param {String} type The type to convert into - * @param {Function} callback Standard callback function */ exports.convertFile = async (srcFile: string, destFile: string, type:string) => { // Used for the moving of the file, not the conversion diff --git a/src/node/utils/NodeVersion.ts b/src/node/utils/NodeVersion.ts index 8507412d1..dd61ac7a4 100644 --- a/src/node/utils/NodeVersion.ts +++ b/src/node/utils/NodeVersion.ts @@ -19,7 +19,7 @@ * limitations under the License. */ -const semver = require('semver'); +import semver from 'semver'; /** * Quits if Etherpad is not running on a given minimum Node version diff --git a/src/node/utils/Settings.ts b/src/node/utils/Settings.ts index 8f1e058ea..a8b9611d5 100644 --- a/src/node/utils/Settings.ts +++ b/src/node/utils/Settings.ts @@ -28,17 +28,16 @@ */ const absolutePaths = require('./AbsolutePaths'); -const deepEqual = require('fast-deep-equal/es6'); -const fs = require('fs'); -const os = require('os'); -const path = require('path'); +import fs from 'fs'; +import os from 'os'; +import path from 'path'; const argv = require('./Cli').argv; -const jsonminify = require('jsonminify'); -const log4js = require('log4js'); +import jsonminify from 'jsonminify'; +import log4js from 'log4js'; const randomString = require('./randomstring'); const suppressDisableMsg = ' -- To suppress these warning messages change ' + 'suppressErrorsInPadText to true in your settings.json\n'; -const _ = require('underscore'); +import _ from 'underscore'; const logger = log4js.getLogger('settings'); diff --git a/src/node/utils/caching_middleware.ts b/src/node/utils/caching_middleware.ts index d5866b019..eac547e6b 100644 --- a/src/node/utils/caching_middleware.ts +++ b/src/node/utils/caching_middleware.ts @@ -16,14 +16,13 @@ * limitations under the License. */ -const Buffer = require('buffer').Buffer; -const fs = require('fs'); -const fsp = fs.promises; -const path = require('path'); -const zlib = require('zlib'); +import {Buffer} from "buffer"; +import fs, {promises as fsp} from 'fs'; +import path from 'path'; +import zlib from 'zlib'; const settings = require('./Settings'); -const existsSync = require('./path_exists'); -const util = require('util'); +import existsSync from './path_exists'; +import util from 'util'; /* * The crypto module can be absent on reduced node installations. @@ -37,10 +36,11 @@ const util = require('util'); */ -const _crypto = require('crypto'); +import _crypto from 'crypto'; +import {createReadStream} from "node:fs"; -let CACHE_DIR = path.join(settings.root, 'var/'); +let CACHE_DIR:string|boolean|fs.Stats|undefined = path.join(settings.root, 'var/'); CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined; type Headers = { @@ -141,7 +141,7 @@ module.exports = class CachingMiddleware { res.writeHead(304, headers); res.end(); } else if (req.method === 'GET') { - const readStream = fs.createReadStream(pathStr); + const readStream = createReadStream(pathStr); res.writeHead(statusCode, headers); readStream.pipe(res); } else { @@ -188,6 +188,7 @@ module.exports = class CachingMiddleware { await Promise.all([ fsp.writeFile(`${CACHE_DIR}minified_${cacheKey}`, buffer).catch(() => {}), util.promisify(zlib.gzip)(buffer) + // @ts-ignore .then((content: string) => fsp.writeFile(`${CACHE_DIR}minified_${cacheKey}.gz`, content)) .catch(() => {}), ]); diff --git a/src/node/utils/path_exists.ts b/src/node/utils/path_exists.ts index 354cd3cc7..ccd153393 100644 --- a/src/node/utils/path_exists.ts +++ b/src/node/utils/path_exists.ts @@ -1,10 +1,10 @@ 'use strict'; -const fs = require('fs'); +import fs from 'fs'; -const check = (path:string) => { +const check = (path:string):false|fs.Stats => { const existsSync = fs.statSync || fs.existsSync; - let result; + let result:false|fs.Stats; try { result = existsSync(path); } catch (e) { @@ -13,4 +13,4 @@ const check = (path:string) => { return result; }; -module.exports = check; +export default check; diff --git a/src/node/utils/randomstring.ts b/src/node/utils/randomstring.ts index a86d28566..7e91483eb 100644 --- a/src/node/utils/randomstring.ts +++ b/src/node/utils/randomstring.ts @@ -3,7 +3,7 @@ * Generates a random String with the given length. Is needed to generate the * Author, Group, readonly, session Ids */ -const cryptoMod = require('crypto'); +import cryptoMod from 'crypto'; const randomString = (len: number) => cryptoMod.randomBytes(len).toString('hex'); diff --git a/src/node/utils/run_cmd.ts b/src/node/utils/run_cmd.ts index 463b0f076..627362868 100644 --- a/src/node/utils/run_cmd.ts +++ b/src/node/utils/run_cmd.ts @@ -1,13 +1,13 @@ 'use strict'; import {ErrorExtended, RunCMDOptions, RunCMDPromise} from "../types/RunCMDOptions"; -import {ChildProcess} from "node:child_process"; +import {ChildProcess, SpawnOptions} from "node:child_process"; import {PromiseWithStd} from "../types/PromiseWithStd"; import {Readable} from "node:stream"; -const spawn = require('cross-spawn'); -const log4js = require('log4js'); -const path = require('path'); +import spawn from 'cross-spawn'; +import log4js from 'log4js'; +import path from 'path'; const settings = require('./Settings'); const logger = log4js.getLogger('runCmd'); @@ -32,6 +32,8 @@ const logLines = (readable: undefined | Readable | null, logLineFn: (arg0: (stri }); }; + + /** * Runs a command, logging its output to Etherpad's logs by default. * @@ -74,7 +76,7 @@ const logLines = (readable: undefined | Readable | null, logLineFn: (arg0: (stri * - `stderr`: Similar to `stdout` but for stderr. * - `child`: The ChildProcess object. */ -module.exports = exports = (args: string[], opts:RunCMDOptions = {}) => { +module.exports = exports = (args: string[], opts:SpawnOptions= {}) => { logger.debug(`Executing command: ${args.join(' ')}`); opts = {cwd: settings.root, ...opts}; @@ -84,7 +86,8 @@ module.exports = exports = (args: string[], opts:RunCMDOptions = {}) => { const stdio = Array.isArray(opts.stdio) ? opts.stdio.slice() // Copy to avoid mutating the caller's array. : typeof opts.stdio === 'function' ? [null, opts.stdio, opts.stdio] - : opts.stdio === 'string' ? [null, 'string', 'string'] + // @ts-ignore + : opts.stdio === 'string' ? [null, 'string', 'string'] : Array(3).fill(opts.stdio); const cmdLogger = log4js.getLogger(`runCmd|${args[0]}`); if (stdio[1] == null) stdio[1] = (line: string) => cmdLogger.info(line); diff --git a/src/node/utils/sanitizePathname.ts b/src/node/utils/sanitizePathname.ts index 2932b913d..82dc461cf 100644 --- a/src/node/utils/sanitizePathname.ts +++ b/src/node/utils/sanitizePathname.ts @@ -1,6 +1,6 @@ 'use strict'; -const path = require('path'); +import path from 'path'; // Normalizes p and ensures that it is a relative path that does not reach outside. See // https://nvd.nist.gov/vuln/detail/CVE-2015-3297 for additional context. diff --git a/src/package.json b/src/package.json index 62050ce96..0151d9965 100644 --- a/src/package.json +++ b/src/package.json @@ -30,6 +30,8 @@ } ], "dependencies": { + "@manypkg/find-root": "^2.2.1", + "@types/proxy-addr": "^2.0.3", "async": "^3.2.5", "axios": "^1.6.7", "clean-css": "^5.3.3", @@ -41,7 +43,6 @@ "express": "4.18.3", "express-rate-limit": "^7.2.0", "express-session": "npm:@etherpad/express-session@^1.18.2", - "fast-deep-equal": "^3.1.3", "find-root": "1.1.0", "formidable": "^3.5.1", "http-errors": "^2.0.0", @@ -79,12 +80,21 @@ "etherpad-lite": "node/server.ts" }, "devDependencies": { + "@playwright/test": "^1.42.1", "@types/async": "^3.2.24", + "@types/cross-spawn": "^6.0.6", + "@types/ejs": "^3.1.5", "@types/express": "^4.17.21", + "@types/formidable": "^3.4.5", "@types/http-errors": "^2.0.4", "@types/jsdom": "^21.1.6", + "@types/jsonminify": "^0.4.3", + "@types/lodash.clonedeep": "^4.5.9", "@types/mocha": "^10.0.6", "@types/node": "^20.11.26", + "@types/resolve": "^1.20.6", + "@types/semver": "^7.5.8", + "@types/set-cookie-parser": "^2.4.7", "@types/sinon": "^17.0.3", "@types/supertest": "^6.0.2", "@types/underscore": "^1.11.15", @@ -95,7 +105,6 @@ "mocha-froth": "^0.2.10", "nodeify": "^1.0.1", "openapi-schema-validation": "^0.4.2", - "@playwright/test": "^1.42.1", "set-cookie-parser": "^2.6.0", "sinon": "^17.0.1", "split-grid": "^1.0.11", diff --git a/src/tests/backend/common.ts b/src/tests/backend/common.ts index c0cfd1377..534cf19b2 100644 --- a/src/tests/backend/common.ts +++ b/src/tests/backend/common.ts @@ -5,12 +5,12 @@ import {MapArrayType} from "../../node/types/MapType"; const AttributePool = require('../../static/js/AttributePool'); const apiHandler = require('../../node/handler/APIHandler'); const assert = require('assert').strict; -const io = require('socket.io-client'); -const log4js = require('log4js'); +import {io} from 'socket.io-client'; +import log4js from 'log4js'; const {padutils} = require('../../static/js/pad_utils'); -const process = require('process'); +import process from 'process'; const server = require('../../node/server'); -const setCookieParser = require('set-cookie-parser'); +import setCookieParser from 'set-cookie-parser'; const settings = require('../../node/utils/Settings'); import supertest from 'supertest'; const webaccess = require('../../node/hooks/express/webaccess');