settings.defaults.js 33 KB

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