settings.defaults.js 31 KB

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