settings.defaults.js 34 KB

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