settings.defaults.js 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. const Path = require('node:path')
  2. const { merge } = require('@overleaf/settings/merge')
  3. let defaultFeatures, siteUrl
  4. // Make time interval config easier.
  5. const seconds = 1000
  6. const minutes = 60 * seconds
  7. // These credentials are used for authenticating api requests
  8. // between services that may need to go over public channels
  9. const httpAuthUser = process.env.WEB_API_USER
  10. const httpAuthPass = process.env.WEB_API_PASSWORD
  11. const httpAuthUsers = {}
  12. if (httpAuthUser && httpAuthPass) {
  13. httpAuthUsers[httpAuthUser] = httpAuthPass
  14. }
  15. const intFromEnv = function (name, defaultValue) {
  16. if (
  17. [null, undefined].includes(defaultValue) ||
  18. typeof defaultValue !== 'number'
  19. ) {
  20. throw new Error(
  21. `Bad default integer value for setting: ${name}, ${defaultValue}`
  22. )
  23. }
  24. return parseInt(process.env[name], 10) || defaultValue
  25. }
  26. const defaultTextExtensions = [
  27. 'tex',
  28. 'latex',
  29. 'sty',
  30. 'cls',
  31. 'bst',
  32. 'bib',
  33. 'bibtex',
  34. 'txt',
  35. 'tikz',
  36. 'mtx',
  37. 'rtex',
  38. 'md',
  39. 'asy',
  40. 'lbx',
  41. 'bbx',
  42. 'cbx',
  43. 'm',
  44. 'lco',
  45. 'dtx',
  46. 'ins',
  47. 'ist',
  48. 'def',
  49. 'clo',
  50. 'ldf',
  51. 'rmd',
  52. 'lua',
  53. 'gv',
  54. 'mf',
  55. 'yml',
  56. 'yaml',
  57. 'lhs',
  58. 'mk',
  59. 'xmpdata',
  60. 'cfg',
  61. 'rnw',
  62. 'ltx',
  63. 'inc',
  64. ]
  65. const parseTextExtensions = function (extensions) {
  66. if (extensions) {
  67. return extensions.split(',').map(ext => ext.trim())
  68. } else {
  69. return []
  70. }
  71. }
  72. const httpPermissionsPolicy = {
  73. blocked: [
  74. 'accelerometer',
  75. 'attribution-reporting',
  76. 'browsing-topics',
  77. 'camera',
  78. 'display-capture',
  79. 'encrypted-media',
  80. 'gamepad',
  81. 'geolocation',
  82. 'gyroscope',
  83. 'hid',
  84. 'identity-credentials-get',
  85. 'idle-detection',
  86. 'local-fonts',
  87. 'magnetometer',
  88. 'midi',
  89. 'otp-credentials',
  90. 'payment',
  91. 'picture-in-picture',
  92. 'screen-wake-lock',
  93. 'serial',
  94. 'storage-access',
  95. 'usb',
  96. 'window-management',
  97. 'xr-spatial-tracking',
  98. ],
  99. allowed: {
  100. autoplay: 'self "https://videos.ctfassets.net"',
  101. fullscreen: 'self',
  102. 'on-device-speech-recognition': 'self',
  103. },
  104. }
  105. module.exports = {
  106. env: 'server-ce',
  107. limits: {
  108. httpGlobalAgentMaxSockets: 300,
  109. httpsGlobalAgentMaxSockets: 300,
  110. },
  111. allowAnonymousReadAndWriteSharing:
  112. process.env.OVERLEAF_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING === 'true',
  113. // Databases
  114. // ---------
  115. mongo: {
  116. options: {
  117. appname: 'web',
  118. maxPoolSize: parseInt(process.env.MONGO_POOL_SIZE, 10) || 100,
  119. serverSelectionTimeoutMS:
  120. parseInt(process.env.MONGO_SERVER_SELECTION_TIMEOUT, 10) || 60000,
  121. // Setting socketTimeoutMS to 0 means no timeout
  122. socketTimeoutMS: parseInt(
  123. process.env.MONGO_SOCKET_TIMEOUT ?? '60000',
  124. 10
  125. ),
  126. monitorCommands: true,
  127. },
  128. url:
  129. process.env.MONGO_CONNECTION_STRING ||
  130. process.env.MONGO_URL ||
  131. `mongodb://${process.env.MONGO_HOST || '127.0.0.1'}/sharelatex`,
  132. hasSecondaries: process.env.MONGO_HAS_SECONDARIES === 'true',
  133. },
  134. redis: {
  135. web: {
  136. host: process.env.REDIS_HOST || '127.0.0.1',
  137. port: process.env.REDIS_PORT || '6379',
  138. password: process.env.REDIS_PASSWORD || '',
  139. db: process.env.REDIS_DB,
  140. maxRetriesPerRequest: parseInt(
  141. process.env.REDIS_MAX_RETRIES_PER_REQUEST || '20'
  142. ),
  143. },
  144. // websessions:
  145. // cluster: [
  146. // {host: '127.0.0.1', port: 7000}
  147. // {host: '127.0.0.1', port: 7001}
  148. // {host: '127.0.0.1', port: 7002}
  149. // {host: '127.0.0.1', port: 7003}
  150. // {host: '127.0.0.1', port: 7004}
  151. // {host: '127.0.0.1', port: 7005}
  152. // ]
  153. // ratelimiter:
  154. // cluster: [
  155. // {host: '127.0.0.1', port: 7000}
  156. // {host: '127.0.0.1', port: 7001}
  157. // {host: '127.0.0.1', port: 7002}
  158. // {host: '127.0.0.1', port: 7003}
  159. // {host: '127.0.0.1', port: 7004}
  160. // {host: '127.0.0.1', port: 7005}
  161. // ]
  162. // cooldown:
  163. // cluster: [
  164. // {host: '127.0.0.1', port: 7000}
  165. // {host: '127.0.0.1', port: 7001}
  166. // {host: '127.0.0.1', port: 7002}
  167. // {host: '127.0.0.1', port: 7003}
  168. // {host: '127.0.0.1', port: 7004}
  169. // {host: '127.0.0.1', port: 7005}
  170. // ]
  171. api: {
  172. host: process.env.REDIS_HOST || '127.0.0.1',
  173. port: process.env.REDIS_PORT || '6379',
  174. password: process.env.REDIS_PASSWORD || '',
  175. maxRetriesPerRequest: parseInt(
  176. process.env.REDIS_MAX_RETRIES_PER_REQUEST || '20'
  177. ),
  178. },
  179. },
  180. // Service locations
  181. // -----------------
  182. // Configure which ports to run each service on. Generally you
  183. // can leave these as they are unless you have some other services
  184. // running which conflict, or want to run the web process on port 80.
  185. internal: {
  186. web: {
  187. port: process.env.WEB_PORT || 3000,
  188. host: process.env.LISTEN_ADDRESS || '127.0.0.1',
  189. },
  190. },
  191. // Tell each service where to find the other services. If everything
  192. // is running locally then this is easy, but they exist as separate config
  193. // options incase you want to run some services on remote hosts.
  194. apis: {
  195. web: {
  196. url: `http://${
  197. process.env.WEB_API_HOST || process.env.WEB_HOST || '127.0.0.1'
  198. }:${process.env.WEB_API_PORT || process.env.WEB_PORT || 3000}`,
  199. user: httpAuthUser,
  200. pass: httpAuthPass,
  201. },
  202. documentupdater: {
  203. url: `http://${
  204. process.env.DOCUPDATER_HOST ||
  205. process.env.DOCUMENT_UPDATER_HOST ||
  206. '127.0.0.1'
  207. }:3003`,
  208. },
  209. docstore: {
  210. url: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`,
  211. pubUrl: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`,
  212. },
  213. chat: {
  214. internal_url: `http://${process.env.CHAT_HOST || '127.0.0.1'}:3010`,
  215. },
  216. filestore: {
  217. url: `http://${process.env.FILESTORE_HOST || '127.0.0.1'}:3009`,
  218. },
  219. clsi: {
  220. url: `http://${process.env.CLSI_HOST || '127.0.0.1'}:3013`,
  221. downloadHost: process.env.CLSI_LB_IP
  222. ? `http://${process.env.CLSI_LB_IP}:80`
  223. : `http://${process.env.DOWNLOAD_HOST || '127.0.0.1'}:8080`,
  224. backendGroupName: undefined,
  225. submissionBackendClass:
  226. process.env.CLSI_SUBMISSION_BACKEND_CLASS || 'c3d',
  227. },
  228. clsiCache: {
  229. instances: JSON.parse(process.env.CLSI_CACHE_INSTANCES || '[]'),
  230. },
  231. project_history: {
  232. sendProjectStructureOps: true,
  233. url: `http://${process.env.PROJECT_HISTORY_HOST || '127.0.0.1'}:3054`,
  234. },
  235. historyBackupDeletion: {
  236. enabled: false,
  237. url: `http://${process.env.HISTORY_BACKUP_DELETION_HOST || '127.0.0.1'}:3101`,
  238. user: process.env.HISTORY_BACKUP_DELETION_USER || 'staging',
  239. pass: process.env.HISTORY_BACKUP_DELETION_PASS,
  240. },
  241. realTime: {
  242. url: `http://${process.env.REALTIME_HOST || '127.0.0.1'}:3026`,
  243. },
  244. contacts: {
  245. url: `http://${process.env.CONTACTS_HOST || '127.0.0.1'}:3036`,
  246. },
  247. notifications: {
  248. url: `http://${process.env.NOTIFICATIONS_HOST || '127.0.0.1'}:3042`,
  249. },
  250. webpack: {
  251. url: `http://${process.env.WEBPACK_HOST || '127.0.0.1'}:3808`,
  252. },
  253. wiki: {
  254. url: process.env.WIKI_URL || 'https://learnwiki.overleaf.com',
  255. maxCacheAge: parseInt(process.env.WIKI_MAX_CACHE_AGE || 5 * minutes, 10),
  256. },
  257. haveIBeenPwned: {
  258. enabled: process.env.HAVE_I_BEEN_PWNED_ENABLED === 'true',
  259. url:
  260. process.env.HAVE_I_BEEN_PWNED_URL || 'https://api.pwnedpasswords.com',
  261. timeout: parseInt(process.env.HAVE_I_BEEN_PWNED_TIMEOUT, 10) || 5 * 1000,
  262. },
  263. v1_history: {
  264. url:
  265. process.env.V1_HISTORY_URL ||
  266. `http://${process.env.V1_HISTORY_HOST || '127.0.0.1'}:${
  267. process.env.V1_HISTORY_PORT || '3100'
  268. }/api`,
  269. urlForGitBridge: process.env.V1_HISTORY_URL_FOR_GIT_BRIDGE,
  270. user: process.env.V1_HISTORY_USER || 'staging',
  271. pass:
  272. process.env.V1_HISTORY_PASS ||
  273. process.env.V1_HISTORY_PASSWORD ||
  274. 'password',
  275. buckets: {
  276. globalBlobs: process.env.OVERLEAF_EDITOR_BLOBS_BUCKET,
  277. projectBlobs: process.env.OVERLEAF_EDITOR_PROJECT_BLOBS_BUCKET,
  278. },
  279. },
  280. // For legacy reasons, we need to populate the below objects.
  281. v1: {},
  282. recurly: {},
  283. },
  284. // Defines which features are allowed in the
  285. // Permissions-Policy HTTP header
  286. httpPermissions: httpPermissionsPolicy,
  287. useHttpPermissionsPolicy: true,
  288. jwt: {
  289. key: process.env.OT_JWT_AUTH_KEY,
  290. algorithm: process.env.OT_JWT_AUTH_ALG || 'HS256',
  291. },
  292. devToolbar: {
  293. enabled: false,
  294. },
  295. splitTests: [],
  296. // Where your instance of Overleaf Community Edition/Server Pro can be found publicly. Used in emails
  297. // that are sent out, generated links, etc.
  298. siteUrl: (siteUrl = process.env.PUBLIC_URL || 'http://127.0.0.1:3000'),
  299. lockManager: {
  300. lockTestInterval: intFromEnv('LOCK_MANAGER_LOCK_TEST_INTERVAL', 50),
  301. maxTestInterval: intFromEnv('LOCK_MANAGER_MAX_TEST_INTERVAL', 1000),
  302. maxLockWaitTime: intFromEnv('LOCK_MANAGER_MAX_LOCK_WAIT_TIME', 10000),
  303. redisLockExpiry: intFromEnv('LOCK_MANAGER_REDIS_LOCK_EXPIRY', 30),
  304. slowExecutionThreshold: intFromEnv(
  305. 'LOCK_MANAGER_SLOW_EXECUTION_THRESHOLD',
  306. 5000
  307. ),
  308. },
  309. // Optional separate location for websocket connections, if unset defaults to siteUrl.
  310. wsUrl: process.env.WEBSOCKET_URL,
  311. wsUrlV2: process.env.WEBSOCKET_URL_V2,
  312. wsUrlBeta: process.env.WEBSOCKET_URL_BETA,
  313. wsUrlV2Percentage: parseInt(
  314. process.env.WEBSOCKET_URL_V2_PERCENTAGE || '0',
  315. 10
  316. ),
  317. wsRetryHandshake: parseInt(process.env.WEBSOCKET_RETRY_HANDSHAKE || '5', 10),
  318. // cookie domain
  319. // use full domain for cookies to only be accessible from that domain,
  320. // replace subdomain with dot to have them accessible on all subdomains
  321. cookieDomain: process.env.COOKIE_DOMAIN,
  322. cookieName: process.env.COOKIE_NAME || 'overleaf.sid',
  323. cookieRollingSession: true,
  324. // this is only used if cookies are used for clsi backend
  325. // clsiCookieKey: "clsiserver"
  326. robotsNoindex: process.env.ROBOTS_NOINDEX === 'true' || false,
  327. maxEntitiesPerProject: parseInt(
  328. process.env.MAX_ENTITIES_PER_PROJECT || '2000',
  329. 10
  330. ),
  331. projectUploadTimeout: parseInt(
  332. process.env.PROJECT_UPLOAD_TIMEOUT || '120000',
  333. 10
  334. ),
  335. maxUploadSize: 50 * 1024 * 1024, // 50 MB
  336. multerOptions: {
  337. preservePath: process.env.MULTER_PRESERVE_PATH,
  338. },
  339. notifyOnSystemMessageChanges:
  340. process.env.NOTIFY_ON_SYSTEM_MESSAGE_CHANGES === 'true',
  341. // start failing the health check if active handles exceeds this limit
  342. maxActiveHandles: process.env.MAX_ACTIVE_HANDLES
  343. ? parseInt(process.env.MAX_ACTIVE_HANDLES, 10)
  344. : undefined,
  345. // Security
  346. // --------
  347. security: {
  348. sessionSecret: process.env.SESSION_SECRET,
  349. sessionSecretUpcoming: process.env.SESSION_SECRET_UPCOMING,
  350. sessionSecretFallback: process.env.SESSION_SECRET_FALLBACK,
  351. bcryptRounds: parseInt(process.env.BCRYPT_ROUNDS, 10) || 12,
  352. }, // number of rounds used to hash user passwords (raised to power 2)
  353. adminUrl: process.env.ADMIN_URL,
  354. adminOnlyLogin: process.env.ADMIN_ONLY_LOGIN === 'true',
  355. adminPrivilegeAvailable: process.env.ADMIN_PRIVILEGE_AVAILABLE === 'true',
  356. adminRolesEnabled: false,
  357. blockCrossOriginRequests: process.env.BLOCK_CROSS_ORIGIN_REQUESTS === 'true',
  358. allowedOrigins: (process.env.ALLOWED_ORIGINS || siteUrl).split(','),
  359. httpAuthUsers,
  360. // Default features
  361. // ----------------
  362. //
  363. // You can select the features that are enabled by default for new
  364. // new users.
  365. defaultFeatures: (defaultFeatures = {
  366. collaborators: -1,
  367. dropbox: true,
  368. github: true,
  369. gitBridge: true,
  370. versioning: true,
  371. compileTimeout: 180,
  372. compileGroup: 'standard',
  373. references: true,
  374. trackChanges: true,
  375. }),
  376. // featuresEpoch: 'YYYY-MM-DD',
  377. features: {
  378. personal: defaultFeatures,
  379. },
  380. aiFeatures: {
  381. freeTrialQuota: 'basic',
  382. unlimitedQuota: 'unlimited',
  383. },
  384. groupPlanModalOptions: {
  385. plan_codes: [],
  386. currencies: [],
  387. sizes: [],
  388. usages: [],
  389. },
  390. plans: [
  391. {
  392. planCode: 'personal',
  393. name: 'Personal',
  394. price_in_cents: 0,
  395. features: defaultFeatures,
  396. },
  397. ],
  398. disableChat: process.env.OVERLEAF_DISABLE_CHAT === 'true',
  399. disableLinkSharing: process.env.OVERLEAF_DISABLE_LINK_SHARING === 'true',
  400. enableSubscriptions: false,
  401. restrictedCountries: [],
  402. enableOnboardingEmails: process.env.ENABLE_ONBOARDING_EMAILS === 'true',
  403. enabledLinkedFileTypes: (process.env.ENABLED_LINKED_FILE_TYPES || '').split(
  404. ','
  405. ),
  406. // i18n
  407. // ------
  408. //
  409. i18n: {
  410. checkForHTMLInVars: process.env.I18N_CHECK_FOR_HTML_IN_VARS === 'true',
  411. escapeHTMLInVars: process.env.I18N_ESCAPE_HTML_IN_VARS === 'true',
  412. subdomainLang: {
  413. www: { lngCode: 'en', url: siteUrl },
  414. },
  415. defaultLng: 'en',
  416. },
  417. // Spelling languages
  418. // dic = available in client
  419. // server: false = not available on server
  420. // ------------------
  421. languages: [
  422. { code: 'en', name: 'English' },
  423. { code: 'en_US', dic: 'en_US', name: 'English (American)' },
  424. { code: 'en_GB', dic: 'en_GB', name: 'English (British)' },
  425. { code: 'en_CA', dic: 'en_CA', name: 'English (Canadian)' },
  426. {
  427. code: 'en_AU',
  428. dic: 'en_AU',
  429. name: 'English (Australian)',
  430. server: false,
  431. },
  432. {
  433. code: 'en_ZA',
  434. dic: 'en_ZA',
  435. name: 'English (South African)',
  436. server: false,
  437. },
  438. { code: 'af', dic: 'af_ZA', name: 'Afrikaans' },
  439. { code: 'an', dic: 'an_ES', name: 'Aragonese', server: false },
  440. { code: 'ar', dic: 'ar', name: 'Arabic' },
  441. { code: 'be_BY', dic: 'be_BY', name: 'Belarusian', server: false },
  442. { code: 'eu', dic: 'eu', name: 'Basque' },
  443. { code: 'bn_BD', dic: 'bn_BD', name: 'Bengali', server: false },
  444. { code: 'bs_BA', dic: 'bs_BA', name: 'Bosnian', server: false },
  445. { code: 'br', dic: 'br_FR', name: 'Breton' },
  446. { code: 'bg', dic: 'bg_BG', name: 'Bulgarian' },
  447. { code: 'ca', dic: 'ca', name: 'Catalan' },
  448. { code: 'hr', dic: 'hr_HR', name: 'Croatian' },
  449. { code: 'cs', dic: 'cs_CZ', name: 'Czech' },
  450. { code: 'da', dic: 'da_DK', name: 'Danish' },
  451. { code: 'nl', dic: 'nl', name: 'Dutch' },
  452. { code: 'dz', dic: 'dz', name: 'Dzongkha', server: false },
  453. { code: 'eo', dic: 'eo', name: 'Esperanto' },
  454. { code: 'et', dic: 'et_EE', name: 'Estonian' },
  455. { code: 'fo', dic: 'fo', name: 'Faroese' },
  456. { code: 'fr', dic: 'fr', name: 'French' },
  457. { code: 'gl', dic: 'gl_ES', name: 'Galician' },
  458. { code: 'de', dic: 'de_DE', name: 'German' },
  459. { code: 'de_AT', dic: 'de_AT', name: 'German (Austria)', server: false },
  460. {
  461. code: 'de_CH',
  462. dic: 'de_CH',
  463. name: 'German (Switzerland)',
  464. server: false,
  465. },
  466. { code: 'el', dic: 'el_GR', name: 'Greek' },
  467. { code: 'gug_PY', dic: 'gug_PY', name: 'Guarani', server: false },
  468. { code: 'gu_IN', dic: 'gu_IN', name: 'Gujarati', server: false },
  469. { code: 'he_IL', dic: 'he_IL', name: 'Hebrew', server: false },
  470. { code: 'hi_IN', dic: 'hi_IN', name: 'Hindi', server: false },
  471. { code: 'hu_HU', dic: 'hu_HU', name: 'Hungarian', server: false },
  472. { code: 'is_IS', dic: 'is_IS', name: 'Icelandic', server: false },
  473. { code: 'id', dic: 'id_ID', name: 'Indonesian' },
  474. { code: 'ga', dic: 'ga_IE', name: 'Irish' },
  475. { code: 'it', dic: 'it_IT', name: 'Italian' },
  476. { code: 'kk', dic: 'kk_KZ', name: 'Kazakh' },
  477. { code: 'ko', dic: 'ko', name: 'Korean', server: false },
  478. { code: 'ku', name: 'Kurdish' },
  479. { code: 'kmr', dic: 'kmr_Latn', name: 'Kurmanji', server: false },
  480. { code: 'lv', dic: 'lv_LV', name: 'Latvian' },
  481. { code: 'lt', dic: 'lt_LT', name: 'Lithuanian' },
  482. { code: 'lo_LA', dic: 'lo_LA', name: 'Laotian', server: false },
  483. { code: 'ml_IN', dic: 'ml_IN', name: 'Malayalam', server: false },
  484. { code: 'mn_MN', dic: 'mn_MN', name: 'Mongolian', server: false },
  485. { code: 'nr', name: 'Ndebele' },
  486. { code: 'ne_NP', dic: 'ne_NP', name: 'Nepali', server: false },
  487. { code: 'ns', name: 'Northern Sotho' },
  488. { code: 'no', name: 'Norwegian' },
  489. { code: 'nb_NO', dic: 'nb_NO', name: 'Norwegian (Bokmål)', server: false },
  490. { code: 'nn_NO', dic: 'nn_NO', name: 'Norwegian (Nynorsk)', server: false },
  491. { code: 'oc_FR', dic: 'oc_FR', name: 'Occitan', server: false },
  492. { code: 'fa', dic: 'fa_IR', name: 'Persian' },
  493. { code: 'pl', dic: 'pl_PL', name: 'Polish' },
  494. { code: 'pt_BR', dic: 'pt_BR', name: 'Portuguese (Brazilian)' },
  495. {
  496. code: 'pt_PT',
  497. dic: 'pt_PT',
  498. name: 'Portuguese (European)',
  499. },
  500. { code: 'pa', name: 'Punjabi' },
  501. { code: 'ro', dic: 'ro_RO', name: 'Romanian' },
  502. { code: 'ru', dic: 'ru_RU', name: 'Russian' },
  503. { code: 'gd_GB', dic: 'gd_GB', name: 'Scottish Gaelic', server: false },
  504. { code: 'sr_RS', dic: 'sr_RS', name: 'Serbian', server: false },
  505. { code: 'si_LK', dic: 'si_LK', name: 'Sinhala', server: false },
  506. { code: 'sk', dic: 'sk_SK', name: 'Slovak' },
  507. { code: 'sl', dic: 'sl_SI', name: 'Slovenian' },
  508. { code: 'st', name: 'Southern Sotho' },
  509. { code: 'es', dic: 'es_ES', name: 'Spanish' },
  510. { code: 'sw_TZ', dic: 'sw_TZ', name: 'Swahili', server: false },
  511. { code: 'sv', dic: 'sv_SE', name: 'Swedish' },
  512. { code: 'tl', dic: 'tl', name: 'Tagalog' },
  513. { code: 'te_IN', dic: 'te_IN', name: 'Telugu', server: false },
  514. { code: 'th_TH', dic: 'th_TH', name: 'Thai', server: false },
  515. { code: 'bo', dic: 'bo', name: 'Tibetan', server: false },
  516. { code: 'ts', name: 'Tsonga' },
  517. { code: 'tn', name: 'Tswana' },
  518. { code: 'tr_TR', dic: 'tr_TR', name: 'Turkish', server: false },
  519. { code: 'uk_UA', dic: 'uk_UA', name: 'Ukrainian', server: false },
  520. { code: 'hsb', name: 'Upper Sorbian' },
  521. { code: 'uz_UZ', dic: 'uz_UZ', name: 'Uzbek', server: false },
  522. { code: 'vi_VN', dic: 'vi_VN', name: 'Vietnamese', server: false },
  523. { code: 'cy', name: 'Welsh' },
  524. { code: 'xh', name: 'Xhosa' },
  525. ],
  526. translatedLanguages: {
  527. cn: '简体中文',
  528. cs: 'Čeština',
  529. da: 'Dansk',
  530. de: 'Deutsch',
  531. en: 'English',
  532. es: 'Español',
  533. fi: 'Suomi',
  534. fr: 'Français',
  535. it: 'Italiano',
  536. ja: '日本語',
  537. ko: '한국어',
  538. nl: 'Nederlands',
  539. no: 'Norsk',
  540. pl: 'Polski',
  541. pt: 'Português',
  542. ro: 'Română',
  543. ru: 'Русский',
  544. sv: 'Svenska',
  545. tr: 'Türkçe',
  546. uk: 'Українська',
  547. 'zh-CN': '简体中文',
  548. },
  549. maxDictionarySize: 1024 * 1024, // 1 MB
  550. // Password Settings
  551. // -----------
  552. // These restrict the passwords users can use when registering
  553. // opts are from http://antelle.github.io/passfield
  554. passwordStrengthOptions: {
  555. length: {
  556. min: 8,
  557. // Bcrypt does not support longer passwords than that.
  558. max: 72,
  559. },
  560. },
  561. elevateAccountSecurityAfterFailedLogin:
  562. parseInt(process.env.ELEVATED_ACCOUNT_SECURITY_AFTER_FAILED_LOGIN_MS, 10) ||
  563. 24 * 60 * 60 * 1000,
  564. deviceHistory: {
  565. cookieName: process.env.DEVICE_HISTORY_COOKIE_NAME || 'deviceHistory',
  566. entryExpiry:
  567. parseInt(process.env.DEVICE_HISTORY_ENTRY_EXPIRY_MS, 10) ||
  568. 90 * 24 * 60 * 60 * 1000,
  569. maxEntries: parseInt(process.env.DEVICE_HISTORY_MAX_ENTRIES, 10) || 10,
  570. secret: process.env.DEVICE_HISTORY_SECRET,
  571. },
  572. // Email support
  573. // -------------
  574. //
  575. // Overleaf uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
  576. // To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
  577. // email:
  578. // fromAddress: ""
  579. // replyTo: ""
  580. // lifecycle: false
  581. // # Example transport and parameter settings for Amazon SES
  582. // transport: "SES"
  583. // parameters:
  584. // AWSAccessKeyID: ""
  585. // AWSSecretKey: ""
  586. // For legacy reasons, we need to populate this object.
  587. sentry: {},
  588. // Production Settings
  589. // -------------------
  590. debugPugTemplates: process.env.DEBUG_PUG_TEMPLATES === 'true',
  591. precompilePugTemplatesAtBootTime: process.env
  592. .PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME
  593. ? process.env.PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME === 'true'
  594. : process.env.NODE_ENV === 'production',
  595. // Should javascript assets be served minified or not.
  596. useMinifiedJs: process.env.MINIFIED_JS === 'true' || false,
  597. // Should static assets be sent with a header to tell the browser to cache
  598. // them.
  599. cacheStaticAssets: false,
  600. // If you are running Overleaf over https, set this to true to send the
  601. // cookie with a secure flag (recommended).
  602. secureCookie: false,
  603. // 'SameSite' cookie setting. Can be set to 'lax', 'none' or 'strict'
  604. // 'lax' is recommended, as 'strict' will prevent people linking to projects
  605. // https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
  606. sameSiteCookie: 'lax',
  607. // If you are running Overleaf behind a proxy (like Apache, Nginx, etc)
  608. // then set this to true to allow it to correctly detect the forwarded IP
  609. // address and http/https protocol information.
  610. behindProxy: true,
  611. trustedProxyIps: process.env.TRUSTED_PROXY_IPS || 'loopback',
  612. // Delay before closing the http server upon receiving a SIGTERM process signal.
  613. gracefulShutdownDelayInMs:
  614. parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '5', 10) * seconds,
  615. maxReconnectGracefullyIntervalMs: parseInt(
  616. process.env.MAX_RECONNECT_GRACEFULLY_INTERVAL_MS ?? '30000',
  617. 10
  618. ),
  619. // Expose the hostname in the `X-Served-By` response header
  620. exposeHostname: process.env.EXPOSE_HOSTNAME === 'true',
  621. // Cookie max age (in milliseconds). Set to false for a browser session.
  622. cookieSessionLength: 5 * 24 * 60 * 60 * 1000, // 5 days
  623. // When true, only allow invites to be sent to email addresses that
  624. // already have user accounts
  625. restrictInvitesToExistingAccounts: false,
  626. // Should we allow access to any page without logging in? This includes
  627. // public projects, /learn, /templates, about pages, etc.
  628. allowPublicAccess: process.env.OVERLEAF_ALLOW_PUBLIC_ACCESS === 'true',
  629. // editor should be open by default
  630. editorIsOpen: process.env.EDITOR_OPEN !== 'false',
  631. // site should be open by default
  632. siteIsOpen: process.env.SITE_OPEN !== 'false',
  633. // status file for closing/opening the site at run-time, polled every 5s
  634. siteMaintenanceFile: process.env.SITE_MAINTENANCE_FILE,
  635. // Use a single compile directory for all users in a project
  636. // (otherwise each user has their own directory)
  637. // disablePerUserCompiles: true
  638. // Domain the client (pdfjs) should download the compiled pdf from
  639. pdfDownloadDomain: process.env.COMPILES_USER_CONTENT_DOMAIN, // "http://clsi-lb:3014"
  640. // By default turn on feature flag, can be overridden per request.
  641. enablePdfCaching: process.env.ENABLE_PDF_CACHING === 'true',
  642. // Maximum size of text documents in the real-time editing system.
  643. max_doc_length: 2 * 1024 * 1024, // 2mb
  644. primary_email_check_expiration: 1000 * 60 * 60 * 24 * 90, // 90 days
  645. userHardDeletionDelay:
  646. parseInt(process.env.OVERLEAF_USER_HARD_DELETION_DELAY, 10) ||
  647. 1000 * 60 * 60 * 24 * 90, // 90 days
  648. projectHardDeletionDelay:
  649. parseInt(process.env.OVERLEAF_PROJECT_HARD_DELETION_DELAY, 10) ||
  650. 1000 * 60 * 60 * 24 * 90, // 90 days
  651. // Maximum Delay before sending comment mention notifications
  652. notificationMaxDelay:
  653. parseInt(process.env.COMMENT_MENTION_DELAY_MINUTES) || 30 * 60 * 1000, // 30 minutes
  654. // Comment mention notifications will wait at least this long before being sent
  655. notificationMinDelay:
  656. parseInt(process.env.COMMENT_MENTION_DELAY_MINUTES) || 10 * 60 * 1000, // 10 minutes
  657. // Maximum JSON size in HTTP requests
  658. // We should be able to process twice the max doc length, to allow for
  659. // - the doc content
  660. // - text ranges spanning the whole doc
  661. //
  662. // There's also overhead required for the JSON encoding and the UTF-8
  663. // encoding, theoretically up to 6 times the max doc length (e.g. a document
  664. // entirely filled with "\u0011" characters). On the other hand, we don't want
  665. // to block the event loop with JSON parsing, so we try to find a practical
  666. // compromise.
  667. max_json_request_size:
  668. parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 12 * 1024 * 1024, // 12 MB
  669. // Internal configs
  670. // ----------------
  671. path: {
  672. // If we ever need to write something to disk (e.g. incoming requests
  673. // that need processing but may be too big for memory, then write
  674. // them to disk here).
  675. dumpFolder: Path.resolve(__dirname, '../data/dumpFolder'),
  676. uploadFolder: Path.resolve(__dirname, '../data/uploads'),
  677. },
  678. // Automatic Snapshots
  679. // -------------------
  680. automaticSnapshots: {
  681. // How long should we wait after the user last edited to
  682. // take a snapshot?
  683. waitTimeAfterLastEdit: 5 * minutes,
  684. // Even if edits are still taking place, this is maximum
  685. // time to wait before taking another snapshot.
  686. maxTimeBetweenSnapshots: 30 * minutes,
  687. },
  688. // Smoke test
  689. // ----------
  690. // Provide log in credentials and a project to be able to run
  691. // some basic smoke tests to check the core functionality.
  692. //
  693. smokeTest: {
  694. user: process.env.SMOKE_TEST_USER,
  695. userId: process.env.SMOKE_TEST_USER_ID,
  696. password: process.env.SMOKE_TEST_PASSWORD,
  697. projectId: process.env.SMOKE_TEST_PROJECT_ID,
  698. rateLimitSubject: process.env.SMOKE_TEST_RATE_LIMIT_SUBJECT || '127.0.0.1',
  699. stepTimeout: parseInt(process.env.SMOKE_TEST_STEP_TIMEOUT || '10000', 10),
  700. },
  701. appName: process.env.APP_NAME || 'Overleaf (Community Edition)',
  702. adminEmail: process.env.ADMIN_EMAIL || 'placeholder@example.com',
  703. adminDomains: process.env.ADMIN_DOMAINS
  704. ? JSON.parse(process.env.ADMIN_DOMAINS)
  705. : undefined,
  706. nav: {
  707. title: process.env.APP_NAME || 'Overleaf Community Edition',
  708. hide_powered_by: process.env.NAV_HIDE_POWERED_BY === 'true',
  709. left_footer: [],
  710. right_footer: [
  711. {
  712. text: '<a href="https://github.com/overleaf/overleaf">Fork on GitHub!</a>',
  713. },
  714. ],
  715. showSubscriptionLink: false,
  716. header_extras: [],
  717. },
  718. // Example:
  719. // header_extras: [{text: "Some Page", url: "http://example.com/some/page", class: "subdued"}]
  720. recaptcha: {
  721. endpoint:
  722. process.env.RECAPTCHA_ENDPOINT ||
  723. 'https://www.google.com/recaptcha/api/siteverify',
  724. trustedUsers: (process.env.CAPTCHA_TRUSTED_USERS || '')
  725. .split(',')
  726. .map(x => x.trim())
  727. .filter(x => x !== ''),
  728. trustedUsersRegex: process.env.CAPTCHA_TRUSTED_USERS_REGEX
  729. ? // Enforce matching of the entire input.
  730. new RegExp(`^${process.env.CAPTCHA_TRUSTED_USERS_REGEX}$`)
  731. : null,
  732. disabled: {
  733. invite: true,
  734. login: true,
  735. passwordReset: true,
  736. register: true,
  737. addEmail: true,
  738. },
  739. },
  740. customisation: {},
  741. redirects: {
  742. '/templates/index': '/templates/',
  743. },
  744. enablePugCache: process.env.ENABLE_PUG_CACHE === 'true',
  745. reloadModuleViewsOnEachRequest:
  746. process.env.ENABLE_PUG_CACHE !== 'true' &&
  747. process.env.NODE_ENV === 'development',
  748. rateLimit: {
  749. subnetRateLimiterDisabled:
  750. process.env.SUBNET_RATE_LIMITER_DISABLED === 'true',
  751. autoCompile: {
  752. everyone: process.env.RATE_LIMIT_AUTO_COMPILE_EVERYONE || 100,
  753. standard: process.env.RATE_LIMIT_AUTO_COMPILE_STANDARD || 25,
  754. },
  755. login: {
  756. ip: { points: 20, subnetPoints: 200, duration: 60 },
  757. email: { points: 10, duration: 120 },
  758. },
  759. },
  760. analytics: {
  761. enabled: false,
  762. },
  763. compileBodySizeLimitMb: process.env.COMPILE_BODY_SIZE_LIMIT_MB || 7,
  764. textExtensions: defaultTextExtensions.concat(
  765. parseTextExtensions(process.env.ADDITIONAL_TEXT_EXTENSIONS)
  766. ),
  767. // case-insensitive file names that is editable (doc) in the editor
  768. editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
  769. fileIgnorePattern:
  770. process.env.FILE_IGNORE_PATTERN ||
  771. '**/{{__MACOSX,.git,.texpadtmp,.R}{,/**},.!(latexmkrc),*.{dvi,aux,log,toc,out,pdfsync,synctex,synctex(busy),fdb_latexmk,fls,nlo,ind,glo,gls,glg,bbl,blg,doc,docx,gz,swp}}',
  772. validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
  773. emailConfirmationDisabled:
  774. process.env.EMAIL_CONFIRMATION_DISABLED === 'true' || false,
  775. emailAddressLimit: intFromEnv('EMAIL_ADDRESS_LIMIT', 10),
  776. enabledServices: (process.env.ENABLED_SERVICES || 'web,api')
  777. .split(',')
  778. .map(s => s.trim()),
  779. // module options
  780. // ----------
  781. modules: {
  782. sanitize: {
  783. options: {
  784. allowedTags: [
  785. 'h1',
  786. 'h2',
  787. 'h3',
  788. 'h4',
  789. 'h5',
  790. 'h6',
  791. 'blockquote',
  792. 'p',
  793. 'a',
  794. 'ul',
  795. 'ol',
  796. 'nl',
  797. 'li',
  798. 'b',
  799. 'i',
  800. 'strong',
  801. 'em',
  802. 'strike',
  803. 'code',
  804. 'hr',
  805. 'br',
  806. 'div',
  807. 'table',
  808. 'thead',
  809. 'col',
  810. 'caption',
  811. 'tbody',
  812. 'tr',
  813. 'th',
  814. 'td',
  815. 'tfoot',
  816. 'pre',
  817. 'iframe',
  818. 'img',
  819. 'figure',
  820. 'figcaption',
  821. 'span',
  822. 'source',
  823. 'track',
  824. 'video',
  825. 'del',
  826. ],
  827. allowedAttributes: {
  828. a: [
  829. 'href',
  830. 'name',
  831. 'target',
  832. 'class',
  833. 'event-tracking',
  834. 'event-tracking-ga',
  835. 'event-tracking-label',
  836. 'event-tracking-trigger',
  837. ],
  838. div: ['class', 'id', 'style'],
  839. h1: ['class', 'id'],
  840. h2: ['class', 'id'],
  841. h3: ['class', 'id'],
  842. h4: ['class', 'id'],
  843. h5: ['class', 'id'],
  844. h6: ['class', 'id'],
  845. p: ['class'],
  846. col: ['width'],
  847. figure: ['class', 'id', 'style'],
  848. figcaption: ['class', 'id', 'style'],
  849. i: ['aria-hidden', 'aria-label', 'class', 'id', 'translate'],
  850. iframe: [
  851. 'allowfullscreen',
  852. 'frameborder',
  853. 'height',
  854. 'src',
  855. 'style',
  856. 'width',
  857. ],
  858. img: ['alt', 'class', 'src', 'style'],
  859. source: ['src', 'type'],
  860. span: ['class', 'id', 'style'],
  861. strong: ['style'],
  862. table: ['border', 'class', 'id', 'style'],
  863. td: ['colspan', 'rowspan', 'headers', 'style'],
  864. th: [
  865. 'abbr',
  866. 'headers',
  867. 'colspan',
  868. 'rowspan',
  869. 'scope',
  870. 'sorted',
  871. 'style',
  872. ],
  873. tr: ['class'],
  874. track: ['src', 'kind', 'srcLang', 'label'],
  875. video: ['alt', 'class', 'controls', 'height', 'width'],
  876. },
  877. },
  878. },
  879. },
  880. overleafModuleImports: {
  881. // modules to import (an empty array for each set of modules)
  882. //
  883. // Restart webpack after making changes.
  884. //
  885. createFileModes: [],
  886. devToolbar: [],
  887. gitBridge: [],
  888. publishModal: [],
  889. tprFileViewInfo: [],
  890. tprFileViewRefreshError: [],
  891. tprFileViewRefreshButton: [],
  892. tprFileViewNotOriginalImporter: [],
  893. contactUsModal: [],
  894. sourceEditorExtensions: [],
  895. sourceEditorComponents: [],
  896. pdfLogEntryHeaderActionComponents: [],
  897. pdfLogEntryComponents: [],
  898. pdfLogEntriesComponents: [],
  899. pdfPreviewPromotions: [],
  900. diagnosticActions: [],
  901. sourceEditorCompletionSources: [],
  902. sourceEditorSymbolPalette: [],
  903. sourceEditorToolbarComponents: [],
  904. sourceEditorToolbarEndButtons: [],
  905. rootContextProviders: [],
  906. mainEditorLayoutModals: [],
  907. mainEditorLayoutPanels: [],
  908. langFeedbackLinkingWidgets: [],
  909. labsExperiments: [],
  910. integrationLinkingWidgets: [],
  911. referenceLinkingWidgets: [],
  912. importProjectFromGithubModalWrapper: [],
  913. importProjectFromGithubMenu: [],
  914. editorLeftMenuSync: [],
  915. editorLeftMenuManageTemplate: [],
  916. menubarExtraComponents: [],
  917. oauth2Server: [],
  918. managedGroupSubscriptionEnrollmentNotification: [],
  919. managedGroupEnrollmentInvite: [],
  920. ssoCertificateInfo: [],
  921. v1ImportDataScreen: [],
  922. snapshotUtils: [],
  923. visualEditorProviders: [],
  924. usGovBanner: [],
  925. rollingBuildsUpdatedAlert: [],
  926. offlineModeToolbarButtons: [],
  927. settingsEntries: [],
  928. autoCompleteExtensions: [],
  929. sectionTitleGenerators: [],
  930. toastGenerators: [
  931. Path.resolve(
  932. __dirname,
  933. '../frontend/js/features/pdf-preview/components/synctex-toasts'
  934. ),
  935. ],
  936. editorSidebarComponents: [
  937. Path.resolve(
  938. __dirname,
  939. '../modules/full-project-search/frontend/js/components/full-project-search.tsx'
  940. ),
  941. ],
  942. fileTreeToolbarComponents: [
  943. Path.resolve(
  944. __dirname,
  945. '../modules/full-project-search/frontend/js/components/full-project-search-button.tsx'
  946. ),
  947. ],
  948. fullProjectSearchPanel: [
  949. Path.resolve(
  950. __dirname,
  951. '../modules/full-project-search/frontend/js/components/full-project-search.tsx'
  952. ),
  953. ],
  954. integrationPanelComponents: [],
  955. referenceSearchSetting: [],
  956. errorLogsComponents: [],
  957. referenceIndices: [],
  958. railEntries: [],
  959. railPopovers: [],
  960. },
  961. moduleImportSequence: [
  962. 'history-v1',
  963. 'launchpad',
  964. 'server-ce-scripts',
  965. 'user-activate',
  966. ],
  967. viewIncludes: {},
  968. csp: {
  969. enabled: process.env.CSP_ENABLED === 'true',
  970. reportOnly: process.env.CSP_REPORT_ONLY === 'true',
  971. reportPercentage: parseFloat(process.env.CSP_REPORT_PERCENTAGE) || 0,
  972. reportUri: process.env.CSP_REPORT_URI,
  973. exclude: [],
  974. viewDirectives: {
  975. 'app/views/project/ide-react': [`img-src 'self' data: blob:`],
  976. },
  977. },
  978. unsupportedBrowsers: {
  979. ie: '<=11',
  980. safari: '<=14',
  981. firefox: '<=78',
  982. },
  983. // ID of the IEEE brand in the rails app
  984. ieeeBrandId: intFromEnv('IEEE_BRAND_ID', 15),
  985. managedUsers: {
  986. enabled: false,
  987. },
  988. }
  989. module.exports.mergeWith = function (overrides) {
  990. return merge(overrides, module.exports)
  991. }