settings.defaults.js 33 KB

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