settings.defaults.js 33 KB

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