settings.defaults.js 29 KB

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