]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/constants.ts
Add latency setting support
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.ts
1 import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
2 import { randomBytes } from 'crypto'
3 import { invert } from 'lodash'
4 import { join } from 'path'
5 import { randomInt, root } from '@shared/core-utils'
6 import {
7 AbuseState,
8 JobType,
9 VideoImportState,
10 VideoPrivacy,
11 VideoRateType,
12 VideoResolution,
13 VideoState,
14 VideoTranscodingFPS
15 } from '../../shared/models'
16 import { ActivityPubActorType } from '../../shared/models/activitypub'
17 import { ActorImageType, FollowState } from '../../shared/models/actors'
18 import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
19 import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
20 import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
21 // Do not use barrels, remain constants as independent as possible
22 import { isTestInstance, parseDurationToMs, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
23 import { CONFIG, registerConfigChangedHandler } from './config'
24
25 // ---------------------------------------------------------------------------
26
27 const LAST_MIGRATION_VERSION = 690
28
29 // ---------------------------------------------------------------------------
30
31 const API_VERSION = 'v1'
32 const PEERTUBE_VERSION: string = require(join(root(), 'package.json')).version
33
34 const PAGINATION = {
35 GLOBAL: {
36 COUNT: {
37 DEFAULT: 15,
38 MAX: 100
39 }
40 },
41 OUTBOX: {
42 COUNT: {
43 MAX: 50
44 }
45 }
46 }
47
48 const WEBSERVER = {
49 URL: '',
50 HOST: '',
51 SCHEME: '',
52 WS: '',
53 HOSTNAME: '',
54 PORT: 0,
55 RTMP_URL: '',
56 RTMPS_URL: ''
57 }
58
59 // Sortable columns per schema
60 const SORTABLE_COLUMNS = {
61 USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt', 'lastLoginDate', 'role' ],
62 USER_SUBSCRIPTIONS: [ 'id', 'createdAt' ],
63 ACCOUNTS: [ 'createdAt' ],
64 JOBS: [ 'createdAt' ],
65 VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ],
66 VIDEO_IMPORTS: [ 'createdAt' ],
67
68 VIDEO_COMMENT_THREADS: [ 'createdAt', 'totalReplies' ],
69 VIDEO_COMMENTS: [ 'createdAt' ],
70
71 VIDEO_RATES: [ 'createdAt' ],
72 BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ],
73
74 INSTANCE_FOLLOWERS: [ 'createdAt', 'state', 'score' ],
75 INSTANCE_FOLLOWING: [ 'createdAt', 'redundancyAllowed', 'state' ],
76 ACCOUNT_FOLLOWERS: [ 'createdAt' ],
77 CHANNEL_FOLLOWERS: [ 'createdAt' ],
78
79 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'trending', 'hot', 'best' ],
80
81 // Don't forget to update peertube-search-index with the same values
82 VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'match' ],
83 VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ],
84 VIDEO_PLAYLISTS_SEARCH: [ 'match', 'displayName', 'createdAt' ],
85
86 ABUSES: [ 'id', 'createdAt', 'state' ],
87
88 ACCOUNTS_BLOCKLIST: [ 'createdAt' ],
89 SERVERS_BLOCKLIST: [ 'createdAt' ],
90
91 USER_NOTIFICATIONS: [ 'createdAt', 'read' ],
92
93 VIDEO_PLAYLISTS: [ 'name', 'displayName', 'createdAt', 'updatedAt' ],
94
95 PLUGINS: [ 'name', 'createdAt', 'updatedAt' ],
96
97 AVAILABLE_PLUGINS: [ 'npmName', 'popularity' ],
98
99 VIDEO_REDUNDANCIES: [ 'name' ]
100 }
101
102 const OAUTH_LIFETIME = {
103 ACCESS_TOKEN: 3600 * 24, // 1 day, for upload
104 REFRESH_TOKEN: 1209600 // 2 weeks
105 }
106
107 const ROUTE_CACHE_LIFETIME = {
108 FEEDS: '15 minutes',
109 ROBOTS: '2 hours',
110 SITEMAP: '1 day',
111 SECURITYTXT: '2 hours',
112 NODEINFO: '10 minutes',
113 DNT_POLICY: '1 week',
114 ACTIVITY_PUB: {
115 VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example
116 },
117 STATS: '4 hours'
118 }
119
120 // ---------------------------------------------------------------------------
121
122 // Number of points we add/remove after a successful/bad request
123 const ACTOR_FOLLOW_SCORE = {
124 PENALTY: -10,
125 BONUS: 10,
126 BASE: 1000,
127 MAX: 10000
128 }
129
130 const FOLLOW_STATES: { [ id: string ]: FollowState } = {
131 PENDING: 'pending',
132 ACCEPTED: 'accepted'
133 }
134
135 const REMOTE_SCHEME = {
136 HTTP: 'https',
137 WS: 'wss'
138 }
139
140 const JOB_ATTEMPTS: { [id in JobType]: number } = {
141 'activitypub-http-broadcast': 1,
142 'activitypub-http-unicast': 1,
143 'activitypub-http-fetcher': 2,
144 'activitypub-follow': 5,
145 'activitypub-cleaner': 1,
146 'video-file-import': 1,
147 'video-transcoding': 1,
148 'video-import': 1,
149 'email': 5,
150 'actor-keys': 3,
151 'videos-views-stats': 1,
152 'activitypub-refresher': 1,
153 'video-redundancy': 1,
154 'video-live-ending': 1,
155 'video-edition': 1,
156 'move-to-object-storage': 3
157 }
158 // Excluded keys are jobs that can be configured by admins
159 const JOB_CONCURRENCY: { [id in Exclude<JobType, 'video-transcoding' | 'video-import'>]: number } = {
160 'activitypub-http-broadcast': 1,
161 'activitypub-http-unicast': 10,
162 'activitypub-http-fetcher': 3,
163 'activitypub-cleaner': 1,
164 'activitypub-follow': 1,
165 'video-file-import': 1,
166 'email': 5,
167 'actor-keys': 1,
168 'videos-views-stats': 1,
169 'activitypub-refresher': 1,
170 'video-redundancy': 1,
171 'video-live-ending': 10,
172 'video-edition': 1,
173 'move-to-object-storage': 1
174 }
175 const JOB_TTL: { [id in JobType]: number } = {
176 'activitypub-http-broadcast': 60000 * 10, // 10 minutes
177 'activitypub-http-unicast': 60000 * 10, // 10 minutes
178 'activitypub-http-fetcher': 1000 * 3600 * 10, // 10 hours
179 'activitypub-follow': 60000 * 10, // 10 minutes
180 'activitypub-cleaner': 1000 * 3600, // 1 hour
181 'video-file-import': 1000 * 3600, // 1 hour
182 'video-transcoding': 1000 * 3600 * 48, // 2 days, transcoding could be long
183 'video-edition': 1000 * 3600 * 10, // 10 hours
184 'video-import': 1000 * 3600 * 2, // 2 hours
185 'email': 60000 * 10, // 10 minutes
186 'actor-keys': 60000 * 20, // 20 minutes
187 'videos-views-stats': undefined, // Unlimited
188 'activitypub-refresher': 60000 * 10, // 10 minutes
189 'video-redundancy': 1000 * 3600 * 3, // 3 hours
190 'video-live-ending': 1000 * 60 * 10, // 10 minutes
191 'move-to-object-storage': 1000 * 60 * 60 * 3 // 3 hours
192 }
193 const REPEAT_JOBS: { [ id in JobType ]?: EveryRepeatOptions | CronRepeatOptions } = {
194 'videos-views-stats': {
195 cron: randomInt(1, 20) + ' * * * *' // Between 1-20 minutes past the hour
196 },
197 'activitypub-cleaner': {
198 cron: '30 5 * * ' + randomInt(0, 7) // 1 time per week (random day) at 5:30 AM
199 }
200 }
201 const JOB_PRIORITY = {
202 TRANSCODING: 100
203 }
204
205 const BROADCAST_CONCURRENCY = 30 // How many requests in parallel we do in activitypub-http-broadcast job
206 const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...)
207
208 const AP_CLEANER = {
209 CONCURRENCY: 10, // How many requests in parallel we do in activitypub-cleaner job
210 UNAVAILABLE_TRESHOLD: 3, // How many attemps we do before removing an unavailable remote resource
211 PERIOD: parseDurationToMs('1 week') // /!\ Has to be sync with REPEAT_JOBS
212 }
213
214 const REQUEST_TIMEOUTS = {
215 DEFAULT: 7000, // 7 seconds
216 FILE: 30000, // 30 seconds
217 REDUNDANCY: JOB_TTL['video-redundancy']
218 }
219
220 const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days
221 const VIDEO_IMPORT_TIMEOUT = Math.floor(JOB_TTL['video-import'] * 0.9)
222
223 const SCHEDULER_INTERVALS_MS = {
224 ACTOR_FOLLOW_SCORES: 60000 * 60, // 1 hour
225 REMOVE_OLD_JOBS: 60000 * 60, // 1 hour
226 UPDATE_VIDEOS: 60000, // 1 minute
227 YOUTUBE_DL_UPDATE: 60000 * 60 * 24, // 1 day
228 VIDEO_VIEWS_BUFFER_UPDATE: CONFIG.VIEWS.VIDEOS.LOCAL_BUFFER_UPDATE_INTERVAL,
229 CHECK_PLUGINS: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL,
230 CHECK_PEERTUBE_VERSION: 60000 * 60 * 24, // 1 day
231 AUTO_FOLLOW_INDEX_INSTANCES: 60000 * 60 * 24, // 1 day
232 REMOVE_OLD_VIEWS: 60000 * 60 * 24, // 1 day
233 REMOVE_OLD_HISTORY: 60000 * 60 * 24, // 1 day
234 UPDATE_INBOX_STATS: 1000 * 60, // 1 minute
235 REMOVE_DANGLING_RESUMABLE_UPLOADS: 60000 * 60 // 1 hour
236 }
237
238 // ---------------------------------------------------------------------------
239
240 const CONSTRAINTS_FIELDS = {
241 USERS: {
242 NAME: { min: 1, max: 120 }, // Length
243 DESCRIPTION: { min: 3, max: 1000 }, // Length
244 USERNAME: { min: 1, max: 50 }, // Length
245 PASSWORD: { min: 6, max: 255 }, // Length
246 VIDEO_QUOTA: { min: -1 },
247 VIDEO_QUOTA_DAILY: { min: -1 },
248 VIDEO_LANGUAGES: { max: 500 }, // Array length
249 BLOCKED_REASON: { min: 3, max: 250 } // Length
250 },
251 ABUSES: {
252 REASON: { min: 2, max: 3000 }, // Length
253 MODERATION_COMMENT: { min: 2, max: 3000 } // Length
254 },
255 ABUSE_MESSAGES: {
256 MESSAGE: { min: 2, max: 3000 } // Length
257 },
258 VIDEO_BLACKLIST: {
259 REASON: { min: 2, max: 300 } // Length
260 },
261 VIDEO_CHANNELS: {
262 NAME: { min: 1, max: 120 }, // Length
263 DESCRIPTION: { min: 3, max: 1000 }, // Length
264 SUPPORT: { min: 3, max: 1000 }, // Length
265 URL: { min: 3, max: 2000 } // Length
266 },
267 VIDEO_CAPTIONS: {
268 CAPTION_FILE: {
269 EXTNAME: [ '.vtt', '.srt' ],
270 FILE_SIZE: {
271 max: 20 * 1024 * 1024 // 20MB
272 }
273 }
274 },
275 VIDEO_IMPORTS: {
276 URL: { min: 3, max: 2000 }, // Length
277 TORRENT_NAME: { min: 3, max: 255 }, // Length
278 TORRENT_FILE: {
279 EXTNAME: [ '.torrent' ],
280 FILE_SIZE: {
281 max: 1024 * 200 // 200 KB
282 }
283 }
284 },
285 VIDEOS_REDUNDANCY: {
286 URL: { min: 3, max: 2000 } // Length
287 },
288 VIDEO_RATES: {
289 URL: { min: 3, max: 2000 } // Length
290 },
291 VIDEOS: {
292 NAME: { min: 3, max: 120 }, // Length
293 LANGUAGE: { min: 1, max: 10 }, // Length
294 TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length
295 DESCRIPTION: { min: 3, max: 10000 }, // Length
296 SUPPORT: { min: 3, max: 1000 }, // Length
297 IMAGE: {
298 EXTNAME: [ '.png', '.jpg', '.jpeg', '.webp' ],
299 FILE_SIZE: {
300 max: 4 * 1024 * 1024 // 4MB
301 }
302 },
303 EXTNAME: [] as string[],
304 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2
305 DURATION: { min: 0 }, // Number
306 TAGS: { min: 0, max: 5 }, // Number of total tags
307 TAG: { min: 2, max: 30 }, // Length
308 VIEWS: { min: 0 },
309 LIKES: { min: 0 },
310 DISLIKES: { min: 0 },
311 FILE_SIZE: { min: -1 },
312 PARTIAL_UPLOAD_SIZE: { max: 50 * 1024 * 1024 * 1024 }, // 50GB
313 URL: { min: 3, max: 2000 } // Length
314 },
315 VIDEO_PLAYLISTS: {
316 NAME: { min: 1, max: 120 }, // Length
317 DESCRIPTION: { min: 3, max: 1000 }, // Length
318 URL: { min: 3, max: 2000 }, // Length
319 IMAGE: {
320 EXTNAME: [ '.jpg', '.jpeg' ],
321 FILE_SIZE: {
322 max: 4 * 1024 * 1024 // 4MB
323 }
324 }
325 },
326 ACTORS: {
327 PUBLIC_KEY: { min: 10, max: 5000 }, // Length
328 PRIVATE_KEY: { min: 10, max: 5000 }, // Length
329 URL: { min: 3, max: 2000 }, // Length
330 IMAGE: {
331 EXTNAME: [ '.png', '.jpeg', '.jpg', '.gif', '.webp' ],
332 FILE_SIZE: {
333 max: 4 * 1024 * 1024 // 4MB
334 }
335 }
336 },
337 VIDEO_EVENTS: {
338 COUNT: { min: 0 }
339 },
340 VIDEO_COMMENTS: {
341 TEXT: { min: 1, max: 10000 }, // Length
342 URL: { min: 3, max: 2000 } // Length
343 },
344 VIDEO_SHARE: {
345 URL: { min: 3, max: 2000 } // Length
346 },
347 CONTACT_FORM: {
348 FROM_NAME: { min: 1, max: 120 }, // Length
349 BODY: { min: 3, max: 5000 } // Length
350 },
351 PLUGINS: {
352 NAME: { min: 1, max: 214 }, // Length
353 DESCRIPTION: { min: 1, max: 20000 } // Length
354 },
355 COMMONS: {
356 URL: { min: 5, max: 2000 } // Length
357 },
358 VIDEO_EDITOR: {
359 TASKS: { min: 1, max: 10 }, // Number of tasks
360 CUT_TIME: { min: 0 } // Value
361 }
362 }
363
364 const VIEW_LIFETIME = {
365 VIEW: CONFIG.VIEWS.VIDEOS.IP_VIEW_EXPIRATION,
366 VIEWER: 60000 * 5 // 5 minutes
367 }
368
369 let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour
370
371 const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = {
372 MIN: 1,
373 STANDARD: [ 24, 25, 30 ],
374 HD_STANDARD: [ 50, 60 ],
375 AUDIO_MERGE: 25,
376 AVERAGE: 30,
377 MAX: 60,
378 KEEP_ORIGIN_FPS_RESOLUTION_MIN: 720 // We keep the original FPS on high resolutions (720 minimum)
379 }
380
381 const DEFAULT_AUDIO_RESOLUTION = VideoResolution.H_480P
382
383 const VIDEO_RATE_TYPES: { [ id: string ]: VideoRateType } = {
384 LIKE: 'like',
385 DISLIKE: 'dislike'
386 }
387
388 const FFMPEG_NICE: { [ id: string ]: number } = {
389 // parent process defaults to niceness = 0
390 // reminder: lower = higher priority, max value is 19, lowest is -20
391 LIVE: 5, // prioritize over VOD and THUMBNAIL
392 THUMBNAIL: 10,
393 VOD: 15
394 }
395
396 const VIDEO_CATEGORIES = {
397 1: 'Music',
398 2: 'Films',
399 3: 'Vehicles',
400 4: 'Art',
401 5: 'Sports',
402 6: 'Travels',
403 7: 'Gaming',
404 8: 'People',
405 9: 'Comedy',
406 10: 'Entertainment',
407 11: 'News & Politics',
408 12: 'How To',
409 13: 'Education',
410 14: 'Activism',
411 15: 'Science & Technology',
412 16: 'Animals',
413 17: 'Kids',
414 18: 'Food'
415 }
416
417 // See https://creativecommons.org/licenses/?lang=en
418 const VIDEO_LICENCES = {
419 1: 'Attribution',
420 2: 'Attribution - Share Alike',
421 3: 'Attribution - No Derivatives',
422 4: 'Attribution - Non Commercial',
423 5: 'Attribution - Non Commercial - Share Alike',
424 6: 'Attribution - Non Commercial - No Derivatives',
425 7: 'Public Domain Dedication'
426 }
427
428 const VIDEO_LANGUAGES: { [id: string]: string } = {}
429
430 const VIDEO_PRIVACIES: { [ id in VideoPrivacy ]: string } = {
431 [VideoPrivacy.PUBLIC]: 'Public',
432 [VideoPrivacy.UNLISTED]: 'Unlisted',
433 [VideoPrivacy.PRIVATE]: 'Private',
434 [VideoPrivacy.INTERNAL]: 'Internal'
435 }
436
437 const VIDEO_STATES: { [ id in VideoState ]: string } = {
438 [VideoState.PUBLISHED]: 'Published',
439 [VideoState.TO_TRANSCODE]: 'To transcode',
440 [VideoState.TO_IMPORT]: 'To import',
441 [VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream',
442 [VideoState.LIVE_ENDED]: 'Livestream ended',
443 [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage',
444 [VideoState.TRANSCODING_FAILED]: 'Transcoding failed',
445 [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED]: 'External storage move failed',
446 [VideoState.TO_EDIT]: 'To edit*'
447 }
448
449 const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = {
450 [VideoImportState.FAILED]: 'Failed',
451 [VideoImportState.PENDING]: 'Pending',
452 [VideoImportState.SUCCESS]: 'Success',
453 [VideoImportState.REJECTED]: 'Rejected',
454 [VideoImportState.CANCELLED]: 'Cancelled',
455 [VideoImportState.PROCESSING]: 'Processing'
456 }
457
458 const ABUSE_STATES: { [ id in AbuseState ]: string } = {
459 [AbuseState.PENDING]: 'Pending',
460 [AbuseState.REJECTED]: 'Rejected',
461 [AbuseState.ACCEPTED]: 'Accepted'
462 }
463
464 const VIDEO_PLAYLIST_PRIVACIES: { [ id in VideoPlaylistPrivacy ]: string } = {
465 [VideoPlaylistPrivacy.PUBLIC]: 'Public',
466 [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted',
467 [VideoPlaylistPrivacy.PRIVATE]: 'Private'
468 }
469
470 const VIDEO_PLAYLIST_TYPES: { [ id in VideoPlaylistType ]: string } = {
471 [VideoPlaylistType.REGULAR]: 'Regular',
472 [VideoPlaylistType.WATCH_LATER]: 'Watch later'
473 }
474
475 const MIMETYPES = {
476 AUDIO: {
477 MIMETYPE_EXT: {
478 'audio/mpeg': '.mp3',
479 'audio/mp3': '.mp3',
480 'application/ogg': '.ogg',
481 'audio/ogg': '.ogg',
482 'audio/x-ms-wma': '.wma',
483 'audio/wav': '.wav',
484 'audio/x-wav': '.wav',
485 'audio/x-flac': '.flac',
486 'audio/flac': '.flac',
487 'audio/aac': '.aac',
488 'audio/m4a': '.m4a',
489 'audio/mp4': '.m4a',
490 'audio/x-m4a': '.m4a',
491 'audio/ac3': '.ac3'
492 },
493 EXT_MIMETYPE: null as { [ id: string ]: string }
494 },
495 VIDEO: {
496 MIMETYPE_EXT: null as { [ id: string ]: string | string[] },
497 MIMETYPES_REGEX: null as string,
498 EXT_MIMETYPE: null as { [ id: string ]: string }
499 },
500 IMAGE: {
501 MIMETYPE_EXT: {
502 'image/png': '.png',
503 'image/gif': '.gif',
504 'image/webp': '.webp',
505 'image/jpg': '.jpg',
506 'image/jpeg': '.jpg'
507 },
508 EXT_MIMETYPE: null as { [ id: string ]: string }
509 },
510 VIDEO_CAPTIONS: {
511 MIMETYPE_EXT: {
512 'text/vtt': '.vtt',
513 'application/x-subrip': '.srt',
514 'text/plain': '.srt'
515 }
516 },
517 TORRENT: {
518 MIMETYPE_EXT: {
519 'application/x-bittorrent': '.torrent'
520 }
521 }
522 }
523 MIMETYPES.AUDIO.EXT_MIMETYPE = invert(MIMETYPES.AUDIO.MIMETYPE_EXT)
524 MIMETYPES.IMAGE.EXT_MIMETYPE = invert(MIMETYPES.IMAGE.MIMETYPE_EXT)
525
526 const BINARY_CONTENT_TYPES = new Set([
527 'binary/octet-stream',
528 'application/octet-stream',
529 'application/x-binary'
530 ])
531
532 // ---------------------------------------------------------------------------
533
534 const OVERVIEWS = {
535 VIDEOS: {
536 SAMPLE_THRESHOLD: 6,
537 SAMPLES_COUNT: 20
538 }
539 }
540
541 // ---------------------------------------------------------------------------
542
543 const SERVER_ACTOR_NAME = 'peertube'
544
545 const ACTIVITY_PUB = {
546 POTENTIAL_ACCEPT_HEADERS: [
547 'application/activity+json',
548 'application/ld+json',
549 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
550 ],
551 ACCEPT_HEADER: 'application/activity+json, application/ld+json',
552 PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
553 COLLECTION_ITEMS_PER_PAGE: 10,
554 FETCH_PAGE_LIMIT: 2000,
555 URL_MIME_TYPES: {
556 VIDEO: [] as string[],
557 TORRENT: [ 'application/x-bittorrent' ],
558 MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
559 },
560 MAX_RECURSION_COMMENTS: 100,
561 ACTOR_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2, // 2 days
562 VIDEO_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2, // 2 days
563 VIDEO_PLAYLIST_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2 // 2 days
564 }
565
566 const ACTIVITY_PUB_ACTOR_TYPES: { [ id: string ]: ActivityPubActorType } = {
567 GROUP: 'Group',
568 PERSON: 'Person',
569 APPLICATION: 'Application',
570 ORGANIZATION: 'Organization',
571 SERVICE: 'Service'
572 }
573
574 const HTTP_SIGNATURE = {
575 HEADER_NAME: 'signature',
576 ALGORITHM: 'rsa-sha256',
577 HEADERS_TO_SIGN: [ '(request-target)', 'host', 'date', 'digest' ],
578 REQUIRED_HEADERS: {
579 ALL: [ '(request-target)', 'host', 'date' ],
580 POST: [ '(request-target)', 'host', 'date', 'digest' ]
581 },
582 CLOCK_SKEW_SECONDS: 1800
583 }
584
585 // ---------------------------------------------------------------------------
586
587 let PRIVATE_RSA_KEY_SIZE = 2048
588
589 // Password encryption
590 const BCRYPT_SALT_SIZE = 10
591
592 const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes
593 const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days
594
595 const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes
596
597 const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = {
598 DO_NOT_LIST: 'do_not_list',
599 BLUR: 'blur',
600 DISPLAY: 'display'
601 }
602
603 // ---------------------------------------------------------------------------
604
605 // Express static paths (router)
606 const STATIC_PATHS = {
607 THUMBNAILS: '/static/thumbnails/',
608 WEBSEED: '/static/webseed/',
609 REDUNDANCY: '/static/redundancy/',
610 STREAMING_PLAYLISTS: {
611 HLS: '/static/streaming-playlists/hls'
612 }
613 }
614 const STATIC_DOWNLOAD_PATHS = {
615 TORRENTS: '/download/torrents/',
616 VIDEOS: '/download/videos/',
617 HLS_VIDEOS: '/download/streaming-playlists/hls/videos/'
618 }
619 const LAZY_STATIC_PATHS = {
620 BANNERS: '/lazy-static/banners/',
621 AVATARS: '/lazy-static/avatars/',
622 PREVIEWS: '/lazy-static/previews/',
623 VIDEO_CAPTIONS: '/lazy-static/video-captions/',
624 TORRENTS: '/lazy-static/torrents/'
625 }
626
627 // Cache control
628 const STATIC_MAX_AGE = {
629 SERVER: '2h',
630 LAZY_SERVER: '2d',
631 CLIENT: '30d'
632 }
633
634 // Videos thumbnail size
635 const THUMBNAILS_SIZE = {
636 width: 280,
637 height: 157,
638 minWidth: 150
639 }
640 const PREVIEWS_SIZE = {
641 width: 850,
642 height: 480,
643 minWidth: 400
644 }
645 const ACTOR_IMAGES_SIZE: { [key in ActorImageType]: { width: number, height: number }[]} = {
646 [ActorImageType.AVATAR]: [
647 {
648 width: 120,
649 height: 120
650 },
651 {
652 width: 48,
653 height: 48
654 }
655 ],
656 [ActorImageType.BANNER]: [
657 {
658 width: 1920,
659 height: 317 // 6/1 ratio
660 }
661 ]
662 }
663
664 const EMBED_SIZE = {
665 width: 560,
666 height: 315
667 }
668
669 // Sub folders of cache directory
670 const FILES_CACHE = {
671 PREVIEWS: {
672 DIRECTORY: join(CONFIG.STORAGE.CACHE_DIR, 'previews'),
673 MAX_AGE: 1000 * 3600 * 3 // 3 hours
674 },
675 VIDEO_CAPTIONS: {
676 DIRECTORY: join(CONFIG.STORAGE.CACHE_DIR, 'video-captions'),
677 MAX_AGE: 1000 * 3600 * 3 // 3 hours
678 },
679 TORRENTS: {
680 DIRECTORY: join(CONFIG.STORAGE.CACHE_DIR, 'torrents'),
681 MAX_AGE: 1000 * 3600 * 3 // 3 hours
682 }
683 }
684
685 const LRU_CACHE = {
686 USER_TOKENS: {
687 MAX_SIZE: 1000
688 },
689 ACTOR_IMAGE_STATIC: {
690 MAX_SIZE: 500
691 }
692 }
693
694 const RESUMABLE_UPLOAD_DIRECTORY = join(CONFIG.STORAGE.TMP_DIR, 'resumable-uploads')
695 const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls')
696 const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls')
697
698 const RESUMABLE_UPLOAD_SESSION_LIFETIME = SCHEDULER_INTERVALS_MS.REMOVE_DANGLING_RESUMABLE_UPLOADS
699
700 const VIDEO_LIVE = {
701 EXTENSION: '.ts',
702 CLEANUP_DELAY: 1000 * 60 * 5, // 5 minutes
703 SEGMENT_TIME_SECONDS: {
704 DEFAULT_LATENCY: 4, // 4 seconds
705 SMALL_LATENCY: 2 // 2 seconds
706 },
707 SEGMENTS_LIST_SIZE: 15, // 15 maximum segments in live playlist
708 REPLAY_DIRECTORY: 'replay',
709 EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION: 4,
710 MAX_SOCKET_WAITING_DATA: 1024 * 1000 * 100, // 100MB
711 RTMP: {
712 CHUNK_SIZE: 60000,
713 GOP_CACHE: true,
714 PING: 60,
715 PING_TIMEOUT: 30,
716 BASE_PATH: 'live'
717 }
718 }
719
720 const MEMOIZE_TTL = {
721 OVERVIEWS_SAMPLE: 1000 * 3600 * 4, // 4 hours
722 INFO_HASH_EXISTS: 1000 * 3600 * 12, // 12 hours
723 LIVE_ABLE_TO_UPLOAD: 1000 * 60, // 1 minute
724 LIVE_CHECK_SOCKET_HEALTH: 1000 * 60 // 1 minute
725 }
726
727 const MEMOIZE_LENGTH = {
728 INFO_HASH_EXISTS: 200
729 }
730
731 const QUEUE_CONCURRENCY = {
732 ACTOR_PROCESS_IMAGE: 3
733 }
734
735 const REDUNDANCY = {
736 VIDEOS: {
737 RANDOMIZED_FACTOR: 5
738 }
739 }
740
741 const ACCEPT_HEADERS = [ 'html', 'application/json' ].concat(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS)
742
743 const ASSETS_PATH = {
744 DEFAULT_AUDIO_BACKGROUND: join(root(), 'dist', 'server', 'assets', 'default-audio-background.jpg'),
745 DEFAULT_LIVE_BACKGROUND: join(root(), 'dist', 'server', 'assets', 'default-live-background.jpg')
746 }
747
748 // ---------------------------------------------------------------------------
749
750 const CUSTOM_HTML_TAG_COMMENTS = {
751 TITLE: '<!-- title tag -->',
752 DESCRIPTION: '<!-- description tag -->',
753 CUSTOM_CSS: '<!-- custom css tag -->',
754 META_TAGS: '<!-- meta tags -->',
755 SERVER_CONFIG: '<!-- server config -->'
756 }
757
758 // ---------------------------------------------------------------------------
759
760 const FEEDS = {
761 COUNT: 20
762 }
763
764 const MAX_LOGS_OUTPUT_CHARACTERS = 10 * 1000 * 1000
765 const LOG_FILENAME = 'peertube.log'
766 const AUDIT_LOG_FILENAME = 'peertube-audit.log'
767
768 // ---------------------------------------------------------------------------
769
770 const TRACKER_RATE_LIMITS = {
771 INTERVAL: 60000 * 5, // 5 minutes
772 ANNOUNCES_PER_IP_PER_INFOHASH: 15, // maximum announces per torrent in the interval
773 ANNOUNCES_PER_IP: 30, // maximum announces for all our torrents in the interval
774 BLOCK_IP_LIFETIME: 60000 * 3 // 3 minutes
775 }
776
777 const P2P_MEDIA_LOADER_PEER_VERSION = 2
778
779 // ---------------------------------------------------------------------------
780
781 const PLUGIN_GLOBAL_CSS_FILE_NAME = 'plugins-global.css'
782 const PLUGIN_GLOBAL_CSS_PATH = join(CONFIG.STORAGE.TMP_DIR, PLUGIN_GLOBAL_CSS_FILE_NAME)
783
784 let PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 1000 * 60 * 5 // 5 minutes
785
786 const DEFAULT_THEME_NAME = 'default'
787 const DEFAULT_USER_THEME_NAME = 'instance-default'
788
789 // ---------------------------------------------------------------------------
790
791 const SEARCH_INDEX = {
792 ROUTES: {
793 VIDEOS: '/api/v1/search/videos',
794 VIDEO_CHANNELS: '/api/v1/search/video-channels'
795 }
796 }
797
798 // ---------------------------------------------------------------------------
799
800 // Special constants for a test instance
801 if (isTestInstance() === true) {
802 PRIVATE_RSA_KEY_SIZE = 1024
803
804 ACTOR_FOLLOW_SCORE.BASE = 20
805
806 REMOTE_SCHEME.HTTP = 'http'
807 REMOTE_SCHEME.WS = 'ws'
808
809 STATIC_MAX_AGE.SERVER = '0'
810
811 ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2
812 ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
813 ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
814 ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
815
816 CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max = 100 * 1024 // 100KB
817 CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max = 400 * 1024 // 400KB
818
819 SCHEDULER_INTERVALS_MS.ACTOR_FOLLOW_SCORES = 1000
820 SCHEDULER_INTERVALS_MS.REMOVE_OLD_JOBS = 10000
821 SCHEDULER_INTERVALS_MS.REMOVE_OLD_HISTORY = 5000
822 SCHEDULER_INTERVALS_MS.REMOVE_OLD_VIEWS = 5000
823 SCHEDULER_INTERVALS_MS.UPDATE_VIDEOS = 5000
824 SCHEDULER_INTERVALS_MS.AUTO_FOLLOW_INDEX_INSTANCES = 5000
825 SCHEDULER_INTERVALS_MS.UPDATE_INBOX_STATS = 5000
826 SCHEDULER_INTERVALS_MS.CHECK_PEERTUBE_VERSION = 2000
827
828 REPEAT_JOBS['videos-views-stats'] = { every: 5000 }
829
830 REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 }
831 AP_CLEANER.PERIOD = 5000
832
833 REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
834
835 VIEW_LIFETIME.VIEWER = 1000 * 5 // 5 second
836 CONTACT_FORM_LIFETIME = 1000 // 1 second
837
838 JOB_ATTEMPTS['email'] = 1
839
840 FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000
841 MEMOIZE_TTL.OVERVIEWS_SAMPLE = 3000
842 MEMOIZE_TTL.LIVE_ABLE_TO_UPLOAD = 3000
843 OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD = 2
844
845 PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 5000
846
847 VIDEO_LIVE.CLEANUP_DELAY = 5000
848 VIDEO_LIVE.SEGMENT_TIME_SECONDS.DEFAULT_LATENCY = 2
849 VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY = 1
850 VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION = 1
851 }
852
853 updateWebserverUrls()
854 updateWebserverConfig()
855
856 registerConfigChangedHandler(() => {
857 updateWebserverUrls()
858 updateWebserverConfig()
859 })
860
861 // ---------------------------------------------------------------------------
862
863 const FILES_CONTENT_HASH = {
864 MANIFEST: generateContentHash(),
865 FAVICON: generateContentHash(),
866 LOGO: generateContentHash()
867 }
868
869 // ---------------------------------------------------------------------------
870
871 const VIDEO_FILTERS = {
872 WATERMARK: {
873 SIZE_RATIO: 1 / 10,
874 HORIZONTAL_MARGIN_RATIO: 1 / 20,
875 VERTICAL_MARGIN_RATIO: 1 / 20
876 }
877 }
878
879 // ---------------------------------------------------------------------------
880
881 export {
882 WEBSERVER,
883 API_VERSION,
884 VIDEO_LIVE,
885 PEERTUBE_VERSION,
886 LAZY_STATIC_PATHS,
887 SEARCH_INDEX,
888 RESUMABLE_UPLOAD_DIRECTORY,
889 RESUMABLE_UPLOAD_SESSION_LIFETIME,
890 HLS_REDUNDANCY_DIRECTORY,
891 P2P_MEDIA_LOADER_PEER_VERSION,
892 ACTOR_IMAGES_SIZE,
893 ACCEPT_HEADERS,
894 BCRYPT_SALT_SIZE,
895 TRACKER_RATE_LIMITS,
896 FILES_CACHE,
897 LOG_FILENAME,
898 CONSTRAINTS_FIELDS,
899 EMBED_SIZE,
900 REDUNDANCY,
901 JOB_CONCURRENCY,
902 JOB_ATTEMPTS,
903 AP_CLEANER,
904 LAST_MIGRATION_VERSION,
905 OAUTH_LIFETIME,
906 CUSTOM_HTML_TAG_COMMENTS,
907 BROADCAST_CONCURRENCY,
908 AUDIT_LOG_FILENAME,
909 PAGINATION,
910 ACTOR_FOLLOW_SCORE,
911 PREVIEWS_SIZE,
912 REMOTE_SCHEME,
913 FOLLOW_STATES,
914 DEFAULT_USER_THEME_NAME,
915 SERVER_ACTOR_NAME,
916 PLUGIN_GLOBAL_CSS_FILE_NAME,
917 PLUGIN_GLOBAL_CSS_PATH,
918 PRIVATE_RSA_KEY_SIZE,
919 VIDEO_FILTERS,
920 ROUTE_CACHE_LIFETIME,
921 SORTABLE_COLUMNS,
922 HLS_STREAMING_PLAYLIST_DIRECTORY,
923 FEEDS,
924 JOB_TTL,
925 DEFAULT_THEME_NAME,
926 NSFW_POLICY_TYPES,
927 STATIC_MAX_AGE,
928 STATIC_PATHS,
929 VIDEO_IMPORT_TIMEOUT,
930 VIDEO_PLAYLIST_TYPES,
931 MAX_LOGS_OUTPUT_CHARACTERS,
932 ACTIVITY_PUB,
933 ACTIVITY_PUB_ACTOR_TYPES,
934 THUMBNAILS_SIZE,
935 VIDEO_CATEGORIES,
936 MEMOIZE_LENGTH,
937 VIDEO_LANGUAGES,
938 VIDEO_PRIVACIES,
939 VIDEO_LICENCES,
940 VIDEO_STATES,
941 QUEUE_CONCURRENCY,
942 VIDEO_RATE_TYPES,
943 JOB_PRIORITY,
944 VIDEO_TRANSCODING_FPS,
945 FFMPEG_NICE,
946 ABUSE_STATES,
947 LRU_CACHE,
948 REQUEST_TIMEOUTS,
949 USER_PASSWORD_RESET_LIFETIME,
950 USER_PASSWORD_CREATE_LIFETIME,
951 MEMOIZE_TTL,
952 USER_EMAIL_VERIFY_LIFETIME,
953 OVERVIEWS,
954 SCHEDULER_INTERVALS_MS,
955 REPEAT_JOBS,
956 STATIC_DOWNLOAD_PATHS,
957 MIMETYPES,
958 CRAWL_REQUEST_CONCURRENCY,
959 DEFAULT_AUDIO_RESOLUTION,
960 BINARY_CONTENT_TYPES,
961 JOB_COMPLETED_LIFETIME,
962 HTTP_SIGNATURE,
963 VIDEO_IMPORT_STATES,
964 VIEW_LIFETIME,
965 CONTACT_FORM_LIFETIME,
966 VIDEO_PLAYLIST_PRIVACIES,
967 PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME,
968 ASSETS_PATH,
969 FILES_CONTENT_HASH,
970 loadLanguages,
971 buildLanguages,
972 generateContentHash
973 }
974
975 // ---------------------------------------------------------------------------
976
977 function buildVideoMimetypeExt () {
978 const data = {
979 // streamable formats that warrant cross-browser compatibility
980 'video/webm': '.webm',
981 // We'll add .ogg if additional extensions are enabled
982 // We could add .ogg here but since it could be an audio file,
983 // it would be confusing for users because PeerTube will refuse their file (based on the mimetype)
984 'video/ogg': [ '.ogv' ],
985 'video/mp4': '.mp4'
986 }
987
988 if (CONFIG.TRANSCODING.ENABLED) {
989 if (CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS) {
990 data['video/ogg'].push('.ogg')
991
992 Object.assign(data, {
993 'video/x-matroska': '.mkv',
994
995 // Developed by Apple
996 'video/quicktime': [ '.mov', '.qt', '.mqv' ], // often used as output format by editing software
997 'video/x-m4v': '.m4v',
998 'video/m4v': '.m4v',
999
1000 // Developed by the Adobe Flash Platform
1001 'video/x-flv': '.flv',
1002 'video/x-f4v': '.f4v', // replacement for flv
1003
1004 // Developed by Microsoft
1005 'video/x-ms-wmv': '.wmv',
1006 'video/x-msvideo': '.avi',
1007 'video/avi': '.avi',
1008
1009 // Developed by 3GPP
1010 // common video formats for cell phones
1011 'video/3gpp': [ '.3gp', '.3gpp' ],
1012 'video/3gpp2': [ '.3g2', '.3gpp2' ],
1013
1014 // Developed by FFmpeg/Mplayer
1015 'application/x-nut': '.nut',
1016
1017 // The standard video format used by many Sony and Panasonic HD camcorders.
1018 // It is also used for storing high definition video on Blu-ray discs.
1019 'video/mp2t': '.mts',
1020 'video/m2ts': '.m2ts',
1021
1022 // Old formats reliant on MPEG-1/MPEG-2
1023 'video/mpv': '.mpv',
1024 'video/mpeg2': '.m2v',
1025 'video/mpeg': [ '.m1v', '.mpg', '.mpe', '.mpeg', '.vob' ],
1026 'video/dvd': '.vob',
1027
1028 // Could be anything
1029 'application/octet-stream': null,
1030 'application/mxf': '.mxf' // often used as exchange format by editing software
1031 })
1032 }
1033
1034 if (CONFIG.TRANSCODING.ALLOW_AUDIO_FILES) {
1035 Object.assign(data, MIMETYPES.AUDIO.MIMETYPE_EXT)
1036 }
1037 }
1038
1039 return data
1040 }
1041
1042 function updateWebserverUrls () {
1043 WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT)
1044 WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP)
1045 WEBSERVER.WS = CONFIG.WEBSERVER.WS
1046
1047 WEBSERVER.SCHEME = CONFIG.WEBSERVER.SCHEME
1048 WEBSERVER.HOSTNAME = CONFIG.WEBSERVER.HOSTNAME
1049 WEBSERVER.PORT = CONFIG.WEBSERVER.PORT
1050
1051 WEBSERVER.RTMP_URL = 'rtmp://' + CONFIG.LIVE.RTMP.HOSTNAME + ':' + CONFIG.LIVE.RTMP.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
1052 WEBSERVER.RTMPS_URL = 'rtmps://' + CONFIG.LIVE.RTMPS.HOSTNAME + ':' + CONFIG.LIVE.RTMPS.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
1053 }
1054
1055 function updateWebserverConfig () {
1056 MIMETYPES.VIDEO.MIMETYPE_EXT = buildVideoMimetypeExt()
1057 MIMETYPES.VIDEO.MIMETYPES_REGEX = buildMimetypesRegex(MIMETYPES.VIDEO.MIMETYPE_EXT)
1058
1059 ACTIVITY_PUB.URL_MIME_TYPES.VIDEO = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT)
1060
1061 MIMETYPES.VIDEO.EXT_MIMETYPE = buildVideoExtMimetype(MIMETYPES.VIDEO.MIMETYPE_EXT)
1062
1063 CONSTRAINTS_FIELDS.VIDEOS.EXTNAME = Object.keys(MIMETYPES.VIDEO.EXT_MIMETYPE)
1064 }
1065
1066 function buildVideoExtMimetype (obj: { [ id: string ]: string | string[] }) {
1067 const result: { [id: string]: string } = {}
1068
1069 for (const mimetype of Object.keys(obj)) {
1070 const value = obj[mimetype]
1071 if (!value) continue
1072
1073 const extensions = Array.isArray(value) ? value : [ value ]
1074
1075 for (const extension of extensions) {
1076 result[extension] = mimetype
1077 }
1078 }
1079
1080 return result
1081 }
1082
1083 function buildMimetypesRegex (obj: { [id: string]: string | string[] }) {
1084 return Object.keys(obj)
1085 .map(m => `(${m})`)
1086 .join('|')
1087 }
1088
1089 function loadLanguages () {
1090 Object.assign(VIDEO_LANGUAGES, buildLanguages())
1091 }
1092
1093 function buildLanguages () {
1094 const iso639 = require('iso-639-3')
1095
1096 const languages: { [id: string]: string } = {}
1097
1098 const additionalLanguages = {
1099 sgn: true, // Sign languages (macro language)
1100 ase: true, // American sign language
1101 sdl: true, // Arabian sign language
1102 bfi: true, // British sign language
1103 bzs: true, // Brazilian sign language
1104 csl: true, // Chinese sign language
1105 cse: true, // Czech sign language
1106 dsl: true, // Danish sign language
1107 fsl: true, // French sign language
1108 gsg: true, // German sign language
1109 pks: true, // Pakistan sign language
1110 jsl: true, // Japanese sign language
1111 sfs: true, // South African sign language
1112 swl: true, // Swedish sign language
1113 rsl: true, // Russian sign language
1114
1115 kab: true, // Kabyle
1116
1117 lat: true, // Latin
1118
1119 epo: true, // Esperanto
1120 tlh: true, // Klingon
1121 jbo: true, // Lojban
1122 avk: true, // Kotava
1123
1124 zxx: true // No linguistic content (ISO-639-2)
1125 }
1126
1127 // Only add ISO639-1 languages and some sign languages (ISO639-3)
1128 iso639
1129 .filter(l => {
1130 return (l.iso6391 !== undefined && l.type === 'living') ||
1131 additionalLanguages[l.iso6393] === true
1132 })
1133 .forEach(l => { languages[l.iso6391 || l.iso6393] = l.name })
1134
1135 // Override Occitan label
1136 languages['oc'] = 'Occitan'
1137 languages['el'] = 'Greek'
1138
1139 // Chinese languages
1140 languages['zh-Hans'] = 'Simplified Chinese'
1141 languages['zh-Hant'] = 'Traditional Chinese'
1142
1143 return languages
1144 }
1145
1146 function generateContentHash () {
1147 return randomBytes(20).toString('hex')
1148 }