settings.defaults.js 30 KB

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