settings.defaults.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  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. 'midi',
  89. 'otp-credentials',
  90. 'payment',
  91. 'picture-in-picture',
  92. 'screen-wake-lock',
  93. 'serial',
  94. 'storage-access',
  95. 'usb',
  96. 'window-management',
  97. 'xr-spatial-tracking',
  98. ],
  99. allowed: {
  100. autoplay: 'self "https://videos.ctfassets.net"',
  101. fullscreen: 'self',
  102. 'on-device-speech-recognition': '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 || 'c3d',
  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://learnwiki.overleaf.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. notifyOnSystemMessageChanges:
  338. process.env.NOTIFY_ON_SYSTEM_MESSAGE_CHANGES === 'true',
  339. // start failing the health check if active handles exceeds this limit
  340. maxActiveHandles: process.env.MAX_ACTIVE_HANDLES
  341. ? parseInt(process.env.MAX_ACTIVE_HANDLES, 10)
  342. : undefined,
  343. // Security
  344. // --------
  345. security: {
  346. sessionSecret: process.env.SESSION_SECRET,
  347. sessionSecretUpcoming: process.env.SESSION_SECRET_UPCOMING,
  348. sessionSecretFallback: process.env.SESSION_SECRET_FALLBACK,
  349. bcryptRounds: parseInt(process.env.BCRYPT_ROUNDS, 10) || 12,
  350. }, // number of rounds used to hash user passwords (raised to power 2)
  351. adminUrl: process.env.ADMIN_URL,
  352. adminOnlyLogin: process.env.ADMIN_ONLY_LOGIN === 'true',
  353. adminPrivilegeAvailable: process.env.ADMIN_PRIVILEGE_AVAILABLE === 'true',
  354. adminRolesEnabled: false,
  355. blockCrossOriginRequests: process.env.BLOCK_CROSS_ORIGIN_REQUESTS === 'true',
  356. allowedOrigins: (process.env.ALLOWED_ORIGINS || siteUrl).split(','),
  357. httpAuthUsers,
  358. // Default features
  359. // ----------------
  360. //
  361. // You can select the features that are enabled by default for new
  362. // new users.
  363. defaultFeatures: (defaultFeatures = {
  364. collaborators: -1,
  365. dropbox: true,
  366. github: true,
  367. gitBridge: true,
  368. versioning: true,
  369. compileTimeout: 180,
  370. compileGroup: 'standard',
  371. references: true,
  372. trackChanges: true,
  373. }),
  374. // featuresEpoch: 'YYYY-MM-DD',
  375. features: {
  376. personal: defaultFeatures,
  377. },
  378. groupPlanModalOptions: {
  379. plan_codes: [],
  380. currencies: [],
  381. sizes: [],
  382. usages: [],
  383. },
  384. plans: [
  385. {
  386. planCode: 'personal',
  387. name: 'Personal',
  388. price_in_cents: 0,
  389. features: defaultFeatures,
  390. },
  391. ],
  392. disableChat: process.env.OVERLEAF_DISABLE_CHAT === 'true',
  393. disableLinkSharing: process.env.OVERLEAF_DISABLE_LINK_SHARING === 'true',
  394. enableSubscriptions: false,
  395. restrictedCountries: [],
  396. enableOnboardingEmails: process.env.ENABLE_ONBOARDING_EMAILS === 'true',
  397. enabledLinkedFileTypes: (process.env.ENABLED_LINKED_FILE_TYPES || '').split(
  398. ','
  399. ),
  400. // i18n
  401. // ------
  402. //
  403. i18n: {
  404. checkForHTMLInVars: process.env.I18N_CHECK_FOR_HTML_IN_VARS === 'true',
  405. escapeHTMLInVars: process.env.I18N_ESCAPE_HTML_IN_VARS === 'true',
  406. subdomainLang: {
  407. www: { lngCode: 'en', url: siteUrl },
  408. },
  409. defaultLng: 'en',
  410. },
  411. // Spelling languages
  412. // dic = available in client
  413. // server: false = not available on server
  414. // ------------------
  415. languages: [
  416. { code: 'en', name: 'English' },
  417. { code: 'en_US', dic: 'en_US', name: 'English (American)' },
  418. { code: 'en_GB', dic: 'en_GB', name: 'English (British)' },
  419. { code: 'en_CA', dic: 'en_CA', name: 'English (Canadian)' },
  420. {
  421. code: 'en_AU',
  422. dic: 'en_AU',
  423. name: 'English (Australian)',
  424. server: false,
  425. },
  426. {
  427. code: 'en_ZA',
  428. dic: 'en_ZA',
  429. name: 'English (South African)',
  430. server: false,
  431. },
  432. { code: 'af', dic: 'af_ZA', name: 'Afrikaans' },
  433. { code: 'an', dic: 'an_ES', name: 'Aragonese', server: false },
  434. { code: 'ar', dic: 'ar', name: 'Arabic' },
  435. { code: 'be_BY', dic: 'be_BY', name: 'Belarusian', server: false },
  436. { code: 'eu', dic: 'eu', name: 'Basque' },
  437. { code: 'bn_BD', dic: 'bn_BD', name: 'Bengali', server: false },
  438. { code: 'bs_BA', dic: 'bs_BA', name: 'Bosnian', server: false },
  439. { code: 'br', dic: 'br_FR', name: 'Breton' },
  440. { code: 'bg', dic: 'bg_BG', name: 'Bulgarian' },
  441. { code: 'ca', dic: 'ca', name: 'Catalan' },
  442. { code: 'hr', dic: 'hr_HR', name: 'Croatian' },
  443. { code: 'cs', dic: 'cs_CZ', name: 'Czech' },
  444. { code: 'da', dic: 'da_DK', name: 'Danish' },
  445. { code: 'nl', dic: 'nl', name: 'Dutch' },
  446. { code: 'dz', dic: 'dz', name: 'Dzongkha', server: false },
  447. { code: 'eo', dic: 'eo', name: 'Esperanto' },
  448. { code: 'et', dic: 'et_EE', name: 'Estonian' },
  449. { code: 'fo', dic: 'fo', name: 'Faroese' },
  450. { code: 'fr', dic: 'fr', name: 'French' },
  451. { code: 'gl', dic: 'gl_ES', name: 'Galician' },
  452. { code: 'de', dic: 'de_DE', name: 'German' },
  453. { code: 'de_AT', dic: 'de_AT', name: 'German (Austria)', server: false },
  454. {
  455. code: 'de_CH',
  456. dic: 'de_CH',
  457. name: 'German (Switzerland)',
  458. server: false,
  459. },
  460. { code: 'el', dic: 'el_GR', name: 'Greek' },
  461. { code: 'gug_PY', dic: 'gug_PY', name: 'Guarani', server: false },
  462. { code: 'gu_IN', dic: 'gu_IN', name: 'Gujarati', server: false },
  463. { code: 'he_IL', dic: 'he_IL', name: 'Hebrew', server: false },
  464. { code: 'hi_IN', dic: 'hi_IN', name: 'Hindi', server: false },
  465. { code: 'hu_HU', dic: 'hu_HU', name: 'Hungarian', server: false },
  466. { code: 'is_IS', dic: 'is_IS', name: 'Icelandic', server: false },
  467. { code: 'id', dic: 'id_ID', name: 'Indonesian' },
  468. { code: 'ga', dic: 'ga_IE', name: 'Irish' },
  469. { code: 'it', dic: 'it_IT', name: 'Italian' },
  470. { code: 'kk', dic: 'kk_KZ', name: 'Kazakh' },
  471. { code: 'ko', dic: 'ko', name: 'Korean', server: false },
  472. { code: 'ku', name: 'Kurdish' },
  473. { code: 'kmr', dic: 'kmr_Latn', name: 'Kurmanji', server: false },
  474. { code: 'lv', dic: 'lv_LV', name: 'Latvian' },
  475. { code: 'lt', dic: 'lt_LT', name: 'Lithuanian' },
  476. { code: 'lo_LA', dic: 'lo_LA', name: 'Laotian', server: false },
  477. { code: 'ml_IN', dic: 'ml_IN', name: 'Malayalam', server: false },
  478. { code: 'mn_MN', dic: 'mn_MN', name: 'Mongolian', server: false },
  479. { code: 'nr', name: 'Ndebele' },
  480. { code: 'ne_NP', dic: 'ne_NP', name: 'Nepali', server: false },
  481. { code: 'ns', name: 'Northern Sotho' },
  482. { code: 'no', name: 'Norwegian' },
  483. { code: 'nb_NO', dic: 'nb_NO', name: 'Norwegian (Bokmål)', server: false },
  484. { code: 'nn_NO', dic: 'nn_NO', name: 'Norwegian (Nynorsk)', server: false },
  485. { code: 'oc_FR', dic: 'oc_FR', name: 'Occitan', server: false },
  486. { code: 'fa', dic: 'fa_IR', name: 'Persian' },
  487. { code: 'pl', dic: 'pl_PL', name: 'Polish' },
  488. { code: 'pt_BR', dic: 'pt_BR', name: 'Portuguese (Brazilian)' },
  489. {
  490. code: 'pt_PT',
  491. dic: 'pt_PT',
  492. name: 'Portuguese (European)',
  493. },
  494. { code: 'pa', name: 'Punjabi' },
  495. { code: 'ro', dic: 'ro_RO', name: 'Romanian' },
  496. { code: 'ru', dic: 'ru_RU', name: 'Russian' },
  497. { code: 'gd_GB', dic: 'gd_GB', name: 'Scottish Gaelic', server: false },
  498. { code: 'sr_RS', dic: 'sr_RS', name: 'Serbian', server: false },
  499. { code: 'si_LK', dic: 'si_LK', name: 'Sinhala', server: false },
  500. { code: 'sk', dic: 'sk_SK', name: 'Slovak' },
  501. { code: 'sl', dic: 'sl_SI', name: 'Slovenian' },
  502. { code: 'st', name: 'Southern Sotho' },
  503. { code: 'es', dic: 'es_ES', name: 'Spanish' },
  504. { code: 'sw_TZ', dic: 'sw_TZ', name: 'Swahili', server: false },
  505. { code: 'sv', dic: 'sv_SE', name: 'Swedish' },
  506. { code: 'tl', dic: 'tl', name: 'Tagalog' },
  507. { code: 'te_IN', dic: 'te_IN', name: 'Telugu', server: false },
  508. { code: 'th_TH', dic: 'th_TH', name: 'Thai', server: false },
  509. { code: 'bo', dic: 'bo', name: 'Tibetan', server: false },
  510. { code: 'ts', name: 'Tsonga' },
  511. { code: 'tn', name: 'Tswana' },
  512. { code: 'tr_TR', dic: 'tr_TR', name: 'Turkish', server: false },
  513. { code: 'uk_UA', dic: 'uk_UA', name: 'Ukrainian', server: false },
  514. { code: 'hsb', name: 'Upper Sorbian' },
  515. { code: 'uz_UZ', dic: 'uz_UZ', name: 'Uzbek', server: false },
  516. { code: 'vi_VN', dic: 'vi_VN', name: 'Vietnamese', server: false },
  517. { code: 'cy', name: 'Welsh' },
  518. { code: 'xh', name: 'Xhosa' },
  519. ],
  520. translatedLanguages: {
  521. cn: '简体中文',
  522. cs: 'Čeština',
  523. da: 'Dansk',
  524. de: 'Deutsch',
  525. en: 'English',
  526. es: 'Español',
  527. fi: 'Suomi',
  528. fr: 'Français',
  529. it: 'Italiano',
  530. ja: '日本語',
  531. ko: '한국어',
  532. nl: 'Nederlands',
  533. no: 'Norsk',
  534. pl: 'Polski',
  535. pt: 'Português',
  536. ro: 'Română',
  537. ru: 'Русский',
  538. sv: 'Svenska',
  539. tr: 'Türkçe',
  540. uk: 'Українська',
  541. 'zh-CN': '简体中文',
  542. },
  543. maxDictionarySize: 1024 * 1024, // 1 MB
  544. // Password Settings
  545. // -----------
  546. // These restrict the passwords users can use when registering
  547. // opts are from http://antelle.github.io/passfield
  548. passwordStrengthOptions: {
  549. length: {
  550. min: 8,
  551. // Bcrypt does not support longer passwords than that.
  552. max: 72,
  553. },
  554. },
  555. elevateAccountSecurityAfterFailedLogin:
  556. parseInt(process.env.ELEVATED_ACCOUNT_SECURITY_AFTER_FAILED_LOGIN_MS, 10) ||
  557. 24 * 60 * 60 * 1000,
  558. deviceHistory: {
  559. cookieName: process.env.DEVICE_HISTORY_COOKIE_NAME || 'deviceHistory',
  560. entryExpiry:
  561. parseInt(process.env.DEVICE_HISTORY_ENTRY_EXPIRY_MS, 10) ||
  562. 90 * 24 * 60 * 60 * 1000,
  563. maxEntries: parseInt(process.env.DEVICE_HISTORY_MAX_ENTRIES, 10) || 10,
  564. secret: process.env.DEVICE_HISTORY_SECRET,
  565. },
  566. // Email support
  567. // -------------
  568. //
  569. // Overleaf uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
  570. // To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
  571. // email:
  572. // fromAddress: ""
  573. // replyTo: ""
  574. // lifecycle: false
  575. // # Example transport and parameter settings for Amazon SES
  576. // transport: "SES"
  577. // parameters:
  578. // AWSAccessKeyID: ""
  579. // AWSSecretKey: ""
  580. // For legacy reasons, we need to populate this object.
  581. sentry: {},
  582. // Production Settings
  583. // -------------------
  584. debugPugTemplates: process.env.DEBUG_PUG_TEMPLATES === 'true',
  585. precompilePugTemplatesAtBootTime: process.env
  586. .PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME
  587. ? process.env.PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME === 'true'
  588. : process.env.NODE_ENV === 'production',
  589. // Should javascript assets be served minified or not.
  590. useMinifiedJs: process.env.MINIFIED_JS === 'true' || false,
  591. // Should static assets be sent with a header to tell the browser to cache
  592. // them.
  593. cacheStaticAssets: false,
  594. // If you are running Overleaf over https, set this to true to send the
  595. // cookie with a secure flag (recommended).
  596. secureCookie: false,
  597. // 'SameSite' cookie setting. Can be set to 'lax', 'none' or 'strict'
  598. // 'lax' is recommended, as 'strict' will prevent people linking to projects
  599. // https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
  600. sameSiteCookie: 'lax',
  601. // If you are running Overleaf behind a proxy (like Apache, Nginx, etc)
  602. // then set this to true to allow it to correctly detect the forwarded IP
  603. // address and http/https protocol information.
  604. behindProxy: true,
  605. trustedProxyIps: process.env.TRUSTED_PROXY_IPS || 'loopback',
  606. // Delay before closing the http server upon receiving a SIGTERM process signal.
  607. gracefulShutdownDelayInMs:
  608. parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '5', 10) * seconds,
  609. maxReconnectGracefullyIntervalMs: parseInt(
  610. process.env.MAX_RECONNECT_GRACEFULLY_INTERVAL_MS ?? '30000',
  611. 10
  612. ),
  613. // Expose the hostname in the `X-Served-By` response header
  614. exposeHostname: process.env.EXPOSE_HOSTNAME === 'true',
  615. // Cookie max age (in milliseconds). Set to false for a browser session.
  616. cookieSessionLength: 5 * 24 * 60 * 60 * 1000, // 5 days
  617. // When true, only allow invites to be sent to email addresses that
  618. // already have user accounts
  619. restrictInvitesToExistingAccounts: false,
  620. // Should we allow access to any page without logging in? This includes
  621. // public projects, /learn, /templates, about pages, etc.
  622. allowPublicAccess: process.env.OVERLEAF_ALLOW_PUBLIC_ACCESS === 'true',
  623. // editor should be open by default
  624. editorIsOpen: process.env.EDITOR_OPEN !== 'false',
  625. // site should be open by default
  626. siteIsOpen: process.env.SITE_OPEN !== 'false',
  627. // status file for closing/opening the site at run-time, polled every 5s
  628. siteMaintenanceFile: process.env.SITE_MAINTENANCE_FILE,
  629. // Use a single compile directory for all users in a project
  630. // (otherwise each user has their own directory)
  631. // disablePerUserCompiles: true
  632. // Domain the client (pdfjs) should download the compiled pdf from
  633. pdfDownloadDomain: process.env.COMPILES_USER_CONTENT_DOMAIN, // "http://clsi-lb:3014"
  634. // By default turn on feature flag, can be overridden per request.
  635. enablePdfCaching: process.env.ENABLE_PDF_CACHING === 'true',
  636. // Maximum size of text documents in the real-time editing system.
  637. max_doc_length: 2 * 1024 * 1024, // 2mb
  638. primary_email_check_expiration: 1000 * 60 * 60 * 24 * 90, // 90 days
  639. userHardDeletionDelay:
  640. parseInt(process.env.OVERLEAF_USER_HARD_DELETION_DELAY, 10) ||
  641. 1000 * 60 * 60 * 24 * 90, // 90 days
  642. projectHardDeletionDelay:
  643. parseInt(process.env.OVERLEAF_PROJECT_HARD_DELETION_DELAY, 10) ||
  644. 1000 * 60 * 60 * 24 * 90, // 90 days
  645. // Maximum Delay before sending comment mention notifications
  646. notificationMaxDelay:
  647. parseInt(process.env.COMMENT_MENTION_DELAY_MINUTES) || 30 * 60 * 1000, // 30 minutes
  648. // Comment mention notifications will wait at least this long before being sent
  649. notificationMinDelay:
  650. parseInt(process.env.COMMENT_MENTION_DELAY_MINUTES) || 10 * 60 * 1000, // 10 minutes
  651. // Maximum JSON size in HTTP requests
  652. // We should be able to process twice the max doc length, to allow for
  653. // - the doc content
  654. // - text ranges spanning the whole doc
  655. //
  656. // There's also overhead required for the JSON encoding and the UTF-8
  657. // encoding, theoretically up to 6 times the max doc length (e.g. a document
  658. // entirely filled with "\u0011" characters). On the other hand, we don't want
  659. // to block the event loop with JSON parsing, so we try to find a practical
  660. // compromise.
  661. max_json_request_size:
  662. parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 12 * 1024 * 1024, // 12 MB
  663. // Internal configs
  664. // ----------------
  665. path: {
  666. // If we ever need to write something to disk (e.g. incoming requests
  667. // that need processing but may be too big for memory, then write
  668. // them to disk here).
  669. dumpFolder: Path.resolve(__dirname, '../data/dumpFolder'),
  670. uploadFolder: Path.resolve(__dirname, '../data/uploads'),
  671. },
  672. // Automatic Snapshots
  673. // -------------------
  674. automaticSnapshots: {
  675. // How long should we wait after the user last edited to
  676. // take a snapshot?
  677. waitTimeAfterLastEdit: 5 * minutes,
  678. // Even if edits are still taking place, this is maximum
  679. // time to wait before taking another snapshot.
  680. maxTimeBetweenSnapshots: 30 * minutes,
  681. },
  682. // Smoke test
  683. // ----------
  684. // Provide log in credentials and a project to be able to run
  685. // some basic smoke tests to check the core functionality.
  686. //
  687. smokeTest: {
  688. user: process.env.SMOKE_TEST_USER,
  689. userId: process.env.SMOKE_TEST_USER_ID,
  690. password: process.env.SMOKE_TEST_PASSWORD,
  691. projectId: process.env.SMOKE_TEST_PROJECT_ID,
  692. rateLimitSubject: process.env.SMOKE_TEST_RATE_LIMIT_SUBJECT || '127.0.0.1',
  693. stepTimeout: parseInt(process.env.SMOKE_TEST_STEP_TIMEOUT || '10000', 10),
  694. },
  695. appName: process.env.APP_NAME || 'Overleaf (Community Edition)',
  696. adminEmail: process.env.ADMIN_EMAIL || 'placeholder@example.com',
  697. adminDomains: process.env.ADMIN_DOMAINS
  698. ? JSON.parse(process.env.ADMIN_DOMAINS)
  699. : undefined,
  700. nav: {
  701. title: process.env.APP_NAME || 'Overleaf Community Edition',
  702. hide_powered_by: process.env.NAV_HIDE_POWERED_BY === 'true',
  703. left_footer: [],
  704. right_footer: [
  705. {
  706. text: '<a href="https://github.com/overleaf/overleaf">Fork on GitHub!</a>',
  707. },
  708. ],
  709. showSubscriptionLink: false,
  710. header_extras: [],
  711. },
  712. // Example:
  713. // header_extras: [{text: "Some Page", url: "http://example.com/some/page", class: "subdued"}]
  714. recaptcha: {
  715. endpoint:
  716. process.env.RECAPTCHA_ENDPOINT ||
  717. 'https://www.google.com/recaptcha/api/siteverify',
  718. trustedUsers: (process.env.CAPTCHA_TRUSTED_USERS || '')
  719. .split(',')
  720. .map(x => x.trim())
  721. .filter(x => x !== ''),
  722. trustedUsersRegex: process.env.CAPTCHA_TRUSTED_USERS_REGEX
  723. ? // Enforce matching of the entire input.
  724. new RegExp(`^${process.env.CAPTCHA_TRUSTED_USERS_REGEX}$`)
  725. : null,
  726. disabled: {
  727. invite: true,
  728. login: true,
  729. passwordReset: true,
  730. register: true,
  731. addEmail: true,
  732. },
  733. },
  734. customisation: {},
  735. redirects: {
  736. '/templates/index': '/templates/',
  737. },
  738. enablePugCache: process.env.ENABLE_PUG_CACHE === 'true',
  739. reloadModuleViewsOnEachRequest:
  740. process.env.ENABLE_PUG_CACHE !== 'true' &&
  741. process.env.NODE_ENV === 'development',
  742. rateLimit: {
  743. subnetRateLimiterDisabled:
  744. process.env.SUBNET_RATE_LIMITER_DISABLED === 'true',
  745. autoCompile: {
  746. everyone: process.env.RATE_LIMIT_AUTO_COMPILE_EVERYONE || 100,
  747. standard: process.env.RATE_LIMIT_AUTO_COMPILE_STANDARD || 25,
  748. },
  749. login: {
  750. ip: { points: 20, subnetPoints: 200, duration: 60 },
  751. email: { points: 10, duration: 120 },
  752. },
  753. },
  754. analytics: {
  755. enabled: false,
  756. },
  757. compileBodySizeLimitMb: process.env.COMPILE_BODY_SIZE_LIMIT_MB || 7,
  758. textExtensions: defaultTextExtensions.concat(
  759. parseTextExtensions(process.env.ADDITIONAL_TEXT_EXTENSIONS)
  760. ),
  761. // case-insensitive file names that is editable (doc) in the editor
  762. editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
  763. fileIgnorePattern:
  764. process.env.FILE_IGNORE_PATTERN ||
  765. '**/{{__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}}',
  766. validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
  767. emailConfirmationDisabled:
  768. process.env.EMAIL_CONFIRMATION_DISABLED === 'true' || false,
  769. emailAddressLimit: intFromEnv('EMAIL_ADDRESS_LIMIT', 10),
  770. enabledServices: (process.env.ENABLED_SERVICES || 'web,api')
  771. .split(',')
  772. .map(s => s.trim()),
  773. // module options
  774. // ----------
  775. modules: {
  776. sanitize: {
  777. options: {
  778. allowedTags: [
  779. 'h1',
  780. 'h2',
  781. 'h3',
  782. 'h4',
  783. 'h5',
  784. 'h6',
  785. 'blockquote',
  786. 'p',
  787. 'a',
  788. 'ul',
  789. 'ol',
  790. 'nl',
  791. 'li',
  792. 'b',
  793. 'i',
  794. 'strong',
  795. 'em',
  796. 'strike',
  797. 'code',
  798. 'hr',
  799. 'br',
  800. 'div',
  801. 'table',
  802. 'thead',
  803. 'col',
  804. 'caption',
  805. 'tbody',
  806. 'tr',
  807. 'th',
  808. 'td',
  809. 'tfoot',
  810. 'pre',
  811. 'iframe',
  812. 'img',
  813. 'figure',
  814. 'figcaption',
  815. 'span',
  816. 'source',
  817. 'track',
  818. 'video',
  819. 'del',
  820. ],
  821. allowedAttributes: {
  822. a: [
  823. 'href',
  824. 'name',
  825. 'target',
  826. 'class',
  827. 'event-tracking',
  828. 'event-tracking-ga',
  829. 'event-tracking-label',
  830. 'event-tracking-trigger',
  831. ],
  832. div: ['class', 'id', 'style'],
  833. h1: ['class', 'id'],
  834. h2: ['class', 'id'],
  835. h3: ['class', 'id'],
  836. h4: ['class', 'id'],
  837. h5: ['class', 'id'],
  838. h6: ['class', 'id'],
  839. p: ['class'],
  840. col: ['width'],
  841. figure: ['class', 'id', 'style'],
  842. figcaption: ['class', 'id', 'style'],
  843. i: ['aria-hidden', 'aria-label', 'class', 'id', 'translate'],
  844. iframe: [
  845. 'allowfullscreen',
  846. 'frameborder',
  847. 'height',
  848. 'src',
  849. 'style',
  850. 'width',
  851. ],
  852. img: ['alt', 'class', 'src', 'style'],
  853. source: ['src', 'type'],
  854. span: ['class', 'id', 'style'],
  855. strong: ['style'],
  856. table: ['border', 'class', 'id', 'style'],
  857. td: ['colspan', 'rowspan', 'headers', 'style'],
  858. th: [
  859. 'abbr',
  860. 'headers',
  861. 'colspan',
  862. 'rowspan',
  863. 'scope',
  864. 'sorted',
  865. 'style',
  866. ],
  867. tr: ['class'],
  868. track: ['src', 'kind', 'srcLang', 'label'],
  869. video: ['alt', 'class', 'controls', 'height', 'width'],
  870. },
  871. },
  872. },
  873. },
  874. overleafModuleImports: {
  875. // modules to import (an empty array for each set of modules)
  876. //
  877. // Restart webpack after making changes.
  878. //
  879. createFileModes: [],
  880. devToolbar: [],
  881. gitBridge: [],
  882. publishModal: [],
  883. tprFileViewInfo: [],
  884. tprFileViewRefreshError: [],
  885. tprFileViewRefreshButton: [],
  886. tprFileViewNotOriginalImporter: [],
  887. contactUsModal: [],
  888. sourceEditorExtensions: [],
  889. sourceEditorComponents: [],
  890. pdfLogEntryHeaderActionComponents: [],
  891. pdfLogEntryComponents: [],
  892. pdfLogEntriesComponents: [],
  893. pdfPreviewPromotions: [],
  894. diagnosticActions: [],
  895. sourceEditorCompletionSources: [],
  896. sourceEditorSymbolPalette: [],
  897. sourceEditorToolbarComponents: [],
  898. sourceEditorToolbarEndButtons: [],
  899. rootContextProviders: [],
  900. mainEditorLayoutModals: [],
  901. mainEditorLayoutPanels: [],
  902. langFeedbackLinkingWidgets: [],
  903. labsExperiments: [],
  904. integrationLinkingWidgets: [],
  905. referenceLinkingWidgets: [],
  906. importProjectFromGithubModalWrapper: [],
  907. importProjectFromGithubMenu: [],
  908. editorLeftMenuSync: [],
  909. editorLeftMenuManageTemplate: [],
  910. menubarExtraComponents: [],
  911. oauth2Server: [],
  912. managedGroupSubscriptionEnrollmentNotification: [],
  913. managedGroupEnrollmentInvite: [],
  914. ssoCertificateInfo: [],
  915. v1ImportDataScreen: [],
  916. snapshotUtils: [],
  917. visualEditorProviders: [],
  918. usGovBanner: [],
  919. rollingBuildsUpdatedAlert: [],
  920. offlineModeToolbarButtons: [],
  921. settingsEntries: [],
  922. autoCompleteExtensions: [],
  923. sectionTitleGenerators: [],
  924. toastGenerators: [
  925. Path.resolve(
  926. __dirname,
  927. '../frontend/js/features/pdf-preview/components/synctex-toasts'
  928. ),
  929. ],
  930. editorSidebarComponents: [
  931. Path.resolve(
  932. __dirname,
  933. '../modules/full-project-search/frontend/js/components/full-project-search.tsx'
  934. ),
  935. ],
  936. fileTreeToolbarComponents: [
  937. Path.resolve(
  938. __dirname,
  939. '../modules/full-project-search/frontend/js/components/full-project-search-button.tsx'
  940. ),
  941. ],
  942. fullProjectSearchPanel: [
  943. Path.resolve(
  944. __dirname,
  945. '../modules/full-project-search/frontend/js/components/full-project-search.tsx'
  946. ),
  947. ],
  948. integrationPanelComponents: [],
  949. referenceSearchSetting: [],
  950. errorLogsComponents: [],
  951. referenceIndices: [],
  952. railEntries: [],
  953. railPopovers: [],
  954. },
  955. moduleImportSequence: [
  956. 'history-v1',
  957. 'launchpad',
  958. 'server-ce-scripts',
  959. 'user-activate',
  960. ],
  961. viewIncludes: {},
  962. csp: {
  963. enabled: process.env.CSP_ENABLED === 'true',
  964. reportOnly: process.env.CSP_REPORT_ONLY === 'true',
  965. reportPercentage: parseFloat(process.env.CSP_REPORT_PERCENTAGE) || 0,
  966. reportUri: process.env.CSP_REPORT_URI,
  967. exclude: [],
  968. viewDirectives: {
  969. 'app/views/project/ide-react': [`img-src 'self' data: blob:`],
  970. },
  971. },
  972. unsupportedBrowsers: {
  973. ie: '<=11',
  974. safari: '<=14',
  975. firefox: '<=78',
  976. },
  977. // ID of the IEEE brand in the rails app
  978. ieeeBrandId: intFromEnv('IEEE_BRAND_ID', 15),
  979. managedUsers: {
  980. enabled: false,
  981. },
  982. }
  983. module.exports.mergeWith = function (overrides) {
  984. return merge(overrides, module.exports)
  985. }