settings.defaults.js 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  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. 'microphone',
  89. 'midi',
  90. 'otp-credentials',
  91. 'payment',
  92. 'picture-in-picture',
  93. 'screen-wake-lock',
  94. 'serial',
  95. 'storage-access',
  96. 'usb',
  97. 'window-management',
  98. 'xr-spatial-tracking',
  99. ],
  100. allowed: {
  101. autoplay: 'self "https://videos.ctfassets.net"',
  102. fullscreen: '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. // url: "http://#{process.env['CLSI_LB_HOST']}:3014"
  222. backendGroupName: undefined,
  223. submissionBackendClass:
  224. process.env.CLSI_SUBMISSION_BACKEND_CLASS || 'n2d',
  225. },
  226. clsiCache: {
  227. instances: JSON.parse(process.env.CLSI_CACHE_INSTANCES || '[]'),
  228. },
  229. project_history: {
  230. sendProjectStructureOps: true,
  231. url: `http://${process.env.PROJECT_HISTORY_HOST || '127.0.0.1'}:3054`,
  232. },
  233. historyBackupDeletion: {
  234. enabled: false,
  235. url: `http://${process.env.HISTORY_BACKUP_DELETION_HOST || '127.0.0.1'}:3101`,
  236. user: process.env.HISTORY_BACKUP_DELETION_USER || 'staging',
  237. pass: process.env.HISTORY_BACKUP_DELETION_PASS,
  238. },
  239. realTime: {
  240. url: `http://${process.env.REALTIME_HOST || '127.0.0.1'}:3026`,
  241. },
  242. contacts: {
  243. url: `http://${process.env.CONTACTS_HOST || '127.0.0.1'}:3036`,
  244. },
  245. notifications: {
  246. url: `http://${process.env.NOTIFICATIONS_HOST || '127.0.0.1'}:3042`,
  247. },
  248. webpack: {
  249. url: `http://${process.env.WEBPACK_HOST || '127.0.0.1'}:3808`,
  250. },
  251. wiki: {
  252. url: process.env.WIKI_URL || 'https://learn.sharelatex.com',
  253. maxCacheAge: parseInt(process.env.WIKI_MAX_CACHE_AGE || 5 * minutes, 10),
  254. },
  255. haveIBeenPwned: {
  256. enabled: process.env.HAVE_I_BEEN_PWNED_ENABLED === 'true',
  257. url:
  258. process.env.HAVE_I_BEEN_PWNED_URL || 'https://api.pwnedpasswords.com',
  259. timeout: parseInt(process.env.HAVE_I_BEEN_PWNED_TIMEOUT, 10) || 5 * 1000,
  260. },
  261. v1_history: {
  262. url:
  263. process.env.V1_HISTORY_URL ||
  264. `http://${process.env.V1_HISTORY_HOST || '127.0.0.1'}:${
  265. process.env.V1_HISTORY_PORT || '3100'
  266. }/api`,
  267. urlForGitBridge: process.env.V1_HISTORY_URL_FOR_GIT_BRIDGE,
  268. user: process.env.V1_HISTORY_USER || 'staging',
  269. pass:
  270. process.env.V1_HISTORY_PASS ||
  271. process.env.V1_HISTORY_PASSWORD ||
  272. 'password',
  273. buckets: {
  274. globalBlobs: process.env.OVERLEAF_EDITOR_BLOBS_BUCKET,
  275. projectBlobs: process.env.OVERLEAF_EDITOR_PROJECT_BLOBS_BUCKET,
  276. },
  277. },
  278. // For legacy reasons, we need to populate the below objects.
  279. v1: {},
  280. recurly: {},
  281. },
  282. // Defines which features are allowed in the
  283. // Permissions-Policy HTTP header
  284. httpPermissions: httpPermissionsPolicy,
  285. useHttpPermissionsPolicy: true,
  286. jwt: {
  287. key: process.env.OT_JWT_AUTH_KEY,
  288. algorithm: process.env.OT_JWT_AUTH_ALG || 'HS256',
  289. },
  290. devToolbar: {
  291. enabled: false,
  292. },
  293. splitTests: [],
  294. // Where your instance of Overleaf Community Edition/Server Pro can be found publicly. Used in emails
  295. // that are sent out, generated links, etc.
  296. siteUrl: (siteUrl = process.env.PUBLIC_URL || 'http://127.0.0.1:3000'),
  297. lockManager: {
  298. lockTestInterval: intFromEnv('LOCK_MANAGER_LOCK_TEST_INTERVAL', 50),
  299. maxTestInterval: intFromEnv('LOCK_MANAGER_MAX_TEST_INTERVAL', 1000),
  300. maxLockWaitTime: intFromEnv('LOCK_MANAGER_MAX_LOCK_WAIT_TIME', 10000),
  301. redisLockExpiry: intFromEnv('LOCK_MANAGER_REDIS_LOCK_EXPIRY', 30),
  302. slowExecutionThreshold: intFromEnv(
  303. 'LOCK_MANAGER_SLOW_EXECUTION_THRESHOLD',
  304. 5000
  305. ),
  306. },
  307. // Optional separate location for websocket connections, if unset defaults to siteUrl.
  308. wsUrl: process.env.WEBSOCKET_URL,
  309. wsUrlV2: process.env.WEBSOCKET_URL_V2,
  310. wsUrlBeta: process.env.WEBSOCKET_URL_BETA,
  311. wsUrlV2Percentage: parseInt(
  312. process.env.WEBSOCKET_URL_V2_PERCENTAGE || '0',
  313. 10
  314. ),
  315. wsRetryHandshake: parseInt(process.env.WEBSOCKET_RETRY_HANDSHAKE || '5', 10),
  316. // cookie domain
  317. // use full domain for cookies to only be accessible from that domain,
  318. // replace subdomain with dot to have them accessible on all subdomains
  319. cookieDomain: process.env.COOKIE_DOMAIN,
  320. cookieName: process.env.COOKIE_NAME || 'overleaf.sid',
  321. cookieRollingSession: true,
  322. // this is only used if cookies are used for clsi backend
  323. // clsiCookieKey: "clsiserver"
  324. robotsNoindex: process.env.ROBOTS_NOINDEX === 'true' || false,
  325. maxEntitiesPerProject: parseInt(
  326. process.env.MAX_ENTITIES_PER_PROJECT || '2000',
  327. 10
  328. ),
  329. projectUploadTimeout: parseInt(
  330. process.env.PROJECT_UPLOAD_TIMEOUT || '120000',
  331. 10
  332. ),
  333. maxUploadSize: 50 * 1024 * 1024, // 50 MB
  334. multerOptions: {
  335. preservePath: process.env.MULTER_PRESERVE_PATH,
  336. },
  337. // start failing the health check if active handles exceeds this limit
  338. maxActiveHandles: process.env.MAX_ACTIVE_HANDLES
  339. ? parseInt(process.env.MAX_ACTIVE_HANDLES, 10)
  340. : undefined,
  341. // Security
  342. // --------
  343. security: {
  344. sessionSecret: process.env.SESSION_SECRET,
  345. sessionSecretUpcoming: process.env.SESSION_SECRET_UPCOMING,
  346. sessionSecretFallback: process.env.SESSION_SECRET_FALLBACK,
  347. bcryptRounds: parseInt(process.env.BCRYPT_ROUNDS, 10) || 12,
  348. }, // number of rounds used to hash user passwords (raised to power 2)
  349. adminUrl: process.env.ADMIN_URL,
  350. adminOnlyLogin: process.env.ADMIN_ONLY_LOGIN === 'true',
  351. adminPrivilegeAvailable: process.env.ADMIN_PRIVILEGE_AVAILABLE === 'true',
  352. adminRolesEnabled: false,
  353. blockCrossOriginRequests: process.env.BLOCK_CROSS_ORIGIN_REQUESTS === 'true',
  354. allowedOrigins: (process.env.ALLOWED_ORIGINS || siteUrl).split(','),
  355. httpAuthUsers,
  356. // Default features
  357. // ----------------
  358. //
  359. // You can select the features that are enabled by default for new
  360. // new users.
  361. defaultFeatures: (defaultFeatures = {
  362. collaborators: -1,
  363. dropbox: true,
  364. github: true,
  365. gitBridge: true,
  366. versioning: true,
  367. compileTimeout: 180,
  368. compileGroup: 'standard',
  369. references: true,
  370. trackChanges: true,
  371. }),
  372. // featuresEpoch: 'YYYY-MM-DD',
  373. features: {
  374. personal: defaultFeatures,
  375. },
  376. groupPlanModalOptions: {
  377. plan_codes: [],
  378. currencies: [],
  379. sizes: [],
  380. usages: [],
  381. },
  382. plans: [
  383. {
  384. planCode: 'personal',
  385. name: 'Personal',
  386. price_in_cents: 0,
  387. features: defaultFeatures,
  388. },
  389. ],
  390. disableChat: process.env.OVERLEAF_DISABLE_CHAT === 'true',
  391. enableSubscriptions: false,
  392. restrictedCountries: [],
  393. enableOnboardingEmails: process.env.ENABLE_ONBOARDING_EMAILS === 'true',
  394. enabledLinkedFileTypes: (process.env.ENABLED_LINKED_FILE_TYPES || '').split(
  395. ','
  396. ),
  397. filestoreMigrationLevel:
  398. parseInt(process.env.OVERLEAF_FILESTORE_MIGRATION_LEVEL, 10) || 0,
  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
  643. // encoding, theoretically up to 6 times the max doc length (e.g. a document
  644. // entirely filled with "\u0011" characters). On the other hand, we don't want
  645. // to block the event loop with JSON parsing, so we try to find a practical
  646. // compromise.
  647. max_json_request_size:
  648. parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 12 * 1024 * 1024, // 12 MB
  649. // Internal configs
  650. // ----------------
  651. path: {
  652. // If we ever need to write something to disk (e.g. incoming requests
  653. // that need processing but may be too big for memory, then write
  654. // them to disk here).
  655. dumpFolder: Path.resolve(__dirname, '../data/dumpFolder'),
  656. uploadFolder: Path.resolve(__dirname, '../data/uploads'),
  657. },
  658. // Automatic Snapshots
  659. // -------------------
  660. automaticSnapshots: {
  661. // How long should we wait after the user last edited to
  662. // take a snapshot?
  663. waitTimeAfterLastEdit: 5 * minutes,
  664. // Even if edits are still taking place, this is maximum
  665. // time to wait before taking another snapshot.
  666. maxTimeBetweenSnapshots: 30 * minutes,
  667. },
  668. // Smoke test
  669. // ----------
  670. // Provide log in credentials and a project to be able to run
  671. // some basic smoke tests to check the core functionality.
  672. //
  673. smokeTest: {
  674. user: process.env.SMOKE_TEST_USER,
  675. userId: process.env.SMOKE_TEST_USER_ID,
  676. password: process.env.SMOKE_TEST_PASSWORD,
  677. projectId: process.env.SMOKE_TEST_PROJECT_ID,
  678. rateLimitSubject: process.env.SMOKE_TEST_RATE_LIMIT_SUBJECT || '127.0.0.1',
  679. stepTimeout: parseInt(process.env.SMOKE_TEST_STEP_TIMEOUT || '10000', 10),
  680. },
  681. appName: process.env.APP_NAME || 'Overleaf (Community Edition)',
  682. adminEmail: process.env.ADMIN_EMAIL || 'placeholder@example.com',
  683. adminDomains: process.env.ADMIN_DOMAINS
  684. ? JSON.parse(process.env.ADMIN_DOMAINS)
  685. : undefined,
  686. nav: {
  687. title: process.env.APP_NAME || 'Overleaf Community Edition',
  688. hide_powered_by: process.env.NAV_HIDE_POWERED_BY === 'true',
  689. left_footer: [],
  690. right_footer: [
  691. {
  692. text: "<i class='fa fa-github-square'></i> Fork on GitHub!",
  693. url: 'https://github.com/overleaf/overleaf',
  694. },
  695. ],
  696. showSubscriptionLink: false,
  697. header_extras: [],
  698. },
  699. // Example:
  700. // header_extras: [{text: "Some Page", url: "http://example.com/some/page", class: "subdued"}]
  701. recaptcha: {
  702. endpoint:
  703. process.env.RECAPTCHA_ENDPOINT ||
  704. 'https://www.google.com/recaptcha/api/siteverify',
  705. trustedUsers: (process.env.CAPTCHA_TRUSTED_USERS || '')
  706. .split(',')
  707. .map(x => x.trim())
  708. .filter(x => x !== ''),
  709. trustedUsersRegex: process.env.CAPTCHA_TRUSTED_USERS_REGEX
  710. ? // Enforce matching of the entire input.
  711. new RegExp(`^${process.env.CAPTCHA_TRUSTED_USERS_REGEX}$`)
  712. : null,
  713. disabled: {
  714. invite: true,
  715. login: true,
  716. passwordReset: true,
  717. register: true,
  718. addEmail: true,
  719. },
  720. },
  721. customisation: {},
  722. redirects: {
  723. '/templates/index': '/templates/',
  724. },
  725. enablePugCache: process.env.ENABLE_PUG_CACHE === 'true',
  726. reloadModuleViewsOnEachRequest:
  727. process.env.ENABLE_PUG_CACHE !== 'true' &&
  728. process.env.NODE_ENV === 'development',
  729. rateLimit: {
  730. subnetRateLimiterDisabled:
  731. process.env.SUBNET_RATE_LIMITER_DISABLED === 'true',
  732. autoCompile: {
  733. everyone: process.env.RATE_LIMIT_AUTO_COMPILE_EVERYONE || 100,
  734. standard: process.env.RATE_LIMIT_AUTO_COMPILE_STANDARD || 25,
  735. },
  736. login: {
  737. ip: { points: 20, subnetPoints: 200, duration: 60 },
  738. email: { points: 10, duration: 120 },
  739. },
  740. },
  741. analytics: {
  742. enabled: false,
  743. },
  744. compileBodySizeLimitMb: process.env.COMPILE_BODY_SIZE_LIMIT_MB || 7,
  745. textExtensions: defaultTextExtensions.concat(
  746. parseTextExtensions(process.env.ADDITIONAL_TEXT_EXTENSIONS)
  747. ),
  748. // case-insensitive file names that is editable (doc) in the editor
  749. editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
  750. fileIgnorePattern:
  751. process.env.FILE_IGNORE_PATTERN ||
  752. '**/{{__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}}',
  753. validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
  754. emailConfirmationDisabled:
  755. process.env.EMAIL_CONFIRMATION_DISABLED === 'true' || false,
  756. emailAddressLimit: intFromEnv('EMAIL_ADDRESS_LIMIT', 10),
  757. enabledServices: (process.env.ENABLED_SERVICES || 'web,api')
  758. .split(',')
  759. .map(s => s.trim()),
  760. // module options
  761. // ----------
  762. modules: {
  763. sanitize: {
  764. options: {
  765. allowedTags: [
  766. 'h1',
  767. 'h2',
  768. 'h3',
  769. 'h4',
  770. 'h5',
  771. 'h6',
  772. 'blockquote',
  773. 'p',
  774. 'a',
  775. 'ul',
  776. 'ol',
  777. 'nl',
  778. 'li',
  779. 'b',
  780. 'i',
  781. 'strong',
  782. 'em',
  783. 'strike',
  784. 'code',
  785. 'hr',
  786. 'br',
  787. 'div',
  788. 'table',
  789. 'thead',
  790. 'col',
  791. 'caption',
  792. 'tbody',
  793. 'tr',
  794. 'th',
  795. 'td',
  796. 'tfoot',
  797. 'pre',
  798. 'iframe',
  799. 'img',
  800. 'figure',
  801. 'figcaption',
  802. 'span',
  803. 'source',
  804. 'track',
  805. 'video',
  806. 'del',
  807. ],
  808. allowedAttributes: {
  809. a: [
  810. 'href',
  811. 'name',
  812. 'target',
  813. 'class',
  814. 'event-tracking',
  815. 'event-tracking-ga',
  816. 'event-tracking-label',
  817. 'event-tracking-trigger',
  818. ],
  819. div: ['class', 'id', 'style'],
  820. h1: ['class', 'id'],
  821. h2: ['class', 'id'],
  822. h3: ['class', 'id'],
  823. h4: ['class', 'id'],
  824. h5: ['class', 'id'],
  825. h6: ['class', 'id'],
  826. p: ['class'],
  827. col: ['width'],
  828. figure: ['class', 'id', 'style'],
  829. figcaption: ['class', 'id', 'style'],
  830. i: ['aria-hidden', 'aria-label', 'class', 'id', 'translate'],
  831. iframe: [
  832. 'allowfullscreen',
  833. 'frameborder',
  834. 'height',
  835. 'src',
  836. 'style',
  837. 'width',
  838. ],
  839. img: ['alt', 'class', 'src', 'style'],
  840. source: ['src', 'type'],
  841. span: ['class', 'id', 'style'],
  842. strong: ['style'],
  843. table: ['border', 'class', 'id', 'style'],
  844. td: ['colspan', 'rowspan', 'headers', 'style'],
  845. th: [
  846. 'abbr',
  847. 'headers',
  848. 'colspan',
  849. 'rowspan',
  850. 'scope',
  851. 'sorted',
  852. 'style',
  853. ],
  854. tr: ['class'],
  855. track: ['src', 'kind', 'srcLang', 'label'],
  856. video: ['alt', 'class', 'controls', 'height', 'width'],
  857. },
  858. },
  859. },
  860. },
  861. overleafModuleImports: {
  862. // modules to import (an empty array for each set of modules)
  863. //
  864. // Restart webpack after making changes.
  865. //
  866. createFileModes: [],
  867. devToolbar: [],
  868. gitBridge: [],
  869. publishModal: [],
  870. tprFileViewInfo: [],
  871. tprFileViewRefreshError: [],
  872. tprFileViewRefreshButton: [],
  873. tprFileViewNotOriginalImporter: [],
  874. contactUsModal: [],
  875. editorToolbarButtons: [],
  876. sourceEditorExtensions: [],
  877. sourceEditorComponents: [],
  878. pdfLogEntryHeaderActionComponents: [],
  879. pdfLogEntryComponents: [],
  880. pdfLogEntriesComponents: [],
  881. pdfPreviewPromotions: [],
  882. diagnosticActions: [],
  883. sourceEditorCompletionSources: [],
  884. sourceEditorSymbolPalette: [],
  885. sourceEditorToolbarComponents: [],
  886. mainEditorLayoutModals: [],
  887. langFeedbackLinkingWidgets: [],
  888. labsExperiments: [],
  889. integrationLinkingWidgets: [],
  890. referenceLinkingWidgets: [],
  891. importProjectFromGithubModalWrapper: [],
  892. importProjectFromGithubMenu: [],
  893. editorLeftMenuSync: [],
  894. editorLeftMenuManageTemplate: [],
  895. oauth2Server: [],
  896. managedGroupSubscriptionEnrollmentNotification: [],
  897. managedGroupEnrollmentInvite: [],
  898. ssoCertificateInfo: [],
  899. v1ImportDataScreen: [],
  900. snapshotUtils: [],
  901. usGovBanner: [],
  902. offlineModeToolbarButtons: [],
  903. settingsEntries: [],
  904. autoCompleteExtensions: [],
  905. sectionTitleGenerators: [],
  906. toastGenerators: [
  907. Path.resolve(
  908. __dirname,
  909. '../frontend/js/features/pdf-preview/components/synctex-toasts'
  910. ),
  911. ],
  912. editorSidebarComponents: [
  913. Path.resolve(
  914. __dirname,
  915. '../modules/full-project-search/frontend/js/components/full-project-search.tsx'
  916. ),
  917. ],
  918. fileTreeToolbarComponents: [
  919. Path.resolve(
  920. __dirname,
  921. '../modules/full-project-search/frontend/js/components/full-project-search-button.tsx'
  922. ),
  923. ],
  924. fullProjectSearchPanel: [],
  925. integrationPanelComponents: [],
  926. referenceSearchSetting: [],
  927. errorLogsComponents: [],
  928. },
  929. moduleImportSequence: [
  930. 'history-v1',
  931. 'launchpad',
  932. 'server-ce-scripts',
  933. 'user-activate',
  934. ],
  935. viewIncludes: {},
  936. csp: {
  937. enabled: process.env.CSP_ENABLED === 'true',
  938. reportOnly: process.env.CSP_REPORT_ONLY === 'true',
  939. reportPercentage: parseFloat(process.env.CSP_REPORT_PERCENTAGE) || 0,
  940. reportUri: process.env.CSP_REPORT_URI,
  941. exclude: [],
  942. viewDirectives: {
  943. 'app/views/project/ide-react': [`img-src 'self' data: blob:`],
  944. },
  945. },
  946. unsupportedBrowsers: {
  947. ie: '<=11',
  948. safari: '<=14',
  949. firefox: '<=78',
  950. },
  951. // ID of the IEEE brand in the rails app
  952. ieeeBrandId: intFromEnv('IEEE_BRAND_ID', 15),
  953. managedUsers: {
  954. enabled: false,
  955. },
  956. }
  957. module.exports.mergeWith = function (overrides) {
  958. return merge(overrides, module.exports)
  959. }