settings.defaults.js 30 KB

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