settings.defaults.js 31 KB

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