diff options
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r-- | server/initializers/constants.ts | 68 |
1 files changed, 58 insertions, 10 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 7039ab457..66eb31230 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { RepeatOptions } from 'bullmq' | 1 | import { RepeatOptions } from 'bullmq' |
2 | import { randomBytes } from 'crypto' | 2 | import { Encoding, randomBytes } from 'crypto' |
3 | import { invert } from 'lodash' | 3 | import { invert } from 'lodash' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { randomInt, root } from '@shared/core-utils' | 5 | import { randomInt, root } from '@shared/core-utils' |
@@ -25,7 +25,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' | |||
25 | 25 | ||
26 | // --------------------------------------------------------------------------- | 26 | // --------------------------------------------------------------------------- |
27 | 27 | ||
28 | const LAST_MIGRATION_VERSION = 740 | 28 | const LAST_MIGRATION_VERSION = 745 |
29 | 29 | ||
30 | // --------------------------------------------------------------------------- | 30 | // --------------------------------------------------------------------------- |
31 | 31 | ||
@@ -116,7 +116,8 @@ const ROUTE_CACHE_LIFETIME = { | |||
116 | ACTIVITY_PUB: { | 116 | ACTIVITY_PUB: { |
117 | VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example | 117 | VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example |
118 | }, | 118 | }, |
119 | STATS: '4 hours' | 119 | STATS: '4 hours', |
120 | WELL_KNOWN: '1 day' | ||
120 | } | 121 | } |
121 | 122 | ||
122 | // --------------------------------------------------------------------------- | 123 | // --------------------------------------------------------------------------- |
@@ -636,9 +637,18 @@ let PRIVATE_RSA_KEY_SIZE = 2048 | |||
636 | // Password encryption | 637 | // Password encryption |
637 | const BCRYPT_SALT_SIZE = 10 | 638 | const BCRYPT_SALT_SIZE = 10 |
638 | 639 | ||
640 | const ENCRYPTION = { | ||
641 | ALGORITHM: 'aes-256-cbc', | ||
642 | IV: 16, | ||
643 | SALT: 'peertube', | ||
644 | ENCODING: 'hex' as Encoding | ||
645 | } | ||
646 | |||
639 | const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes | 647 | const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes |
640 | const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days | 648 | const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days |
641 | 649 | ||
650 | const TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME = 60000 * 10 // 10 minutes | ||
651 | |||
642 | const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes | 652 | const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes |
643 | 653 | ||
644 | const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = { | 654 | const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = { |
@@ -652,10 +662,15 @@ const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = { | |||
652 | // Express static paths (router) | 662 | // Express static paths (router) |
653 | const STATIC_PATHS = { | 663 | const STATIC_PATHS = { |
654 | THUMBNAILS: '/static/thumbnails/', | 664 | THUMBNAILS: '/static/thumbnails/', |
665 | |||
655 | WEBSEED: '/static/webseed/', | 666 | WEBSEED: '/static/webseed/', |
667 | PRIVATE_WEBSEED: '/static/webseed/private/', | ||
668 | |||
656 | REDUNDANCY: '/static/redundancy/', | 669 | REDUNDANCY: '/static/redundancy/', |
670 | |||
657 | STREAMING_PLAYLISTS: { | 671 | STREAMING_PLAYLISTS: { |
658 | HLS: '/static/streaming-playlists/hls' | 672 | HLS: '/static/streaming-playlists/hls', |
673 | PRIVATE_HLS: '/static/streaming-playlists/hls/private/' | ||
659 | } | 674 | } |
660 | } | 675 | } |
661 | const STATIC_DOWNLOAD_PATHS = { | 676 | const STATIC_DOWNLOAD_PATHS = { |
@@ -670,6 +685,13 @@ const LAZY_STATIC_PATHS = { | |||
670 | VIDEO_CAPTIONS: '/lazy-static/video-captions/', | 685 | VIDEO_CAPTIONS: '/lazy-static/video-captions/', |
671 | TORRENTS: '/lazy-static/torrents/' | 686 | TORRENTS: '/lazy-static/torrents/' |
672 | } | 687 | } |
688 | const OBJECT_STORAGE_PROXY_PATHS = { | ||
689 | PRIVATE_WEBSEED: '/object-storage-proxy/webseed/private/', | ||
690 | |||
691 | STREAMING_PLAYLISTS: { | ||
692 | PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/' | ||
693 | } | ||
694 | } | ||
673 | 695 | ||
674 | // Cache control | 696 | // Cache control |
675 | const STATIC_MAX_AGE = { | 697 | const STATIC_MAX_AGE = { |
@@ -735,12 +757,32 @@ const LRU_CACHE = { | |||
735 | }, | 757 | }, |
736 | ACTOR_IMAGE_STATIC: { | 758 | ACTOR_IMAGE_STATIC: { |
737 | MAX_SIZE: 500 | 759 | MAX_SIZE: 500 |
760 | }, | ||
761 | STATIC_VIDEO_FILES_RIGHTS_CHECK: { | ||
762 | MAX_SIZE: 5000, | ||
763 | TTL: parseDurationToMs('10 seconds') | ||
764 | }, | ||
765 | VIDEO_TOKENS: { | ||
766 | MAX_SIZE: 100_000, | ||
767 | TTL: parseDurationToMs('8 hours') | ||
738 | } | 768 | } |
739 | } | 769 | } |
740 | 770 | ||
741 | const RESUMABLE_UPLOAD_DIRECTORY = join(CONFIG.STORAGE.TMP_DIR, 'resumable-uploads') | 771 | const DIRECTORIES = { |
742 | const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls') | 772 | RESUMABLE_UPLOAD: join(CONFIG.STORAGE.TMP_DIR, 'resumable-uploads'), |
743 | const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') | 773 | |
774 | HLS_STREAMING_PLAYLIST: { | ||
775 | PUBLIC: join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls'), | ||
776 | PRIVATE: join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls', 'private') | ||
777 | }, | ||
778 | |||
779 | VIDEOS: { | ||
780 | PUBLIC: CONFIG.STORAGE.VIDEOS_DIR, | ||
781 | PRIVATE: join(CONFIG.STORAGE.VIDEOS_DIR, 'private') | ||
782 | }, | ||
783 | |||
784 | HLS_REDUNDANCY: join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') | ||
785 | } | ||
744 | 786 | ||
745 | const RESUMABLE_UPLOAD_SESSION_LIFETIME = SCHEDULER_INTERVALS_MS.REMOVE_DANGLING_RESUMABLE_UPLOADS | 787 | const RESUMABLE_UPLOAD_SESSION_LIFETIME = SCHEDULER_INTERVALS_MS.REMOVE_DANGLING_RESUMABLE_UPLOADS |
746 | 788 | ||
@@ -804,6 +846,10 @@ const REDUNDANCY = { | |||
804 | } | 846 | } |
805 | 847 | ||
806 | const ACCEPT_HEADERS = [ 'html', 'application/json' ].concat(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS) | 848 | const ACCEPT_HEADERS = [ 'html', 'application/json' ].concat(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS) |
849 | const OTP = { | ||
850 | HEADER_NAME: 'x-peertube-otp', | ||
851 | HEADER_REQUIRED_VALUE: 'required; app' | ||
852 | } | ||
807 | 853 | ||
808 | const ASSETS_PATH = { | 854 | const ASSETS_PATH = { |
809 | DEFAULT_AUDIO_BACKGROUND: join(root(), 'dist', 'server', 'assets', 'default-audio-background.jpg'), | 855 | DEFAULT_AUDIO_BACKGROUND: join(root(), 'dist', 'server', 'assets', 'default-audio-background.jpg'), |
@@ -952,13 +998,14 @@ const VIDEO_FILTERS = { | |||
952 | export { | 998 | export { |
953 | WEBSERVER, | 999 | WEBSERVER, |
954 | API_VERSION, | 1000 | API_VERSION, |
1001 | ENCRYPTION, | ||
955 | VIDEO_LIVE, | 1002 | VIDEO_LIVE, |
956 | PEERTUBE_VERSION, | 1003 | PEERTUBE_VERSION, |
957 | LAZY_STATIC_PATHS, | 1004 | LAZY_STATIC_PATHS, |
1005 | OBJECT_STORAGE_PROXY_PATHS, | ||
958 | SEARCH_INDEX, | 1006 | SEARCH_INDEX, |
959 | RESUMABLE_UPLOAD_DIRECTORY, | 1007 | DIRECTORIES, |
960 | RESUMABLE_UPLOAD_SESSION_LIFETIME, | 1008 | RESUMABLE_UPLOAD_SESSION_LIFETIME, |
961 | HLS_REDUNDANCY_DIRECTORY, | ||
962 | P2P_MEDIA_LOADER_PEER_VERSION, | 1009 | P2P_MEDIA_LOADER_PEER_VERSION, |
963 | ACTOR_IMAGES_SIZE, | 1010 | ACTOR_IMAGES_SIZE, |
964 | ACCEPT_HEADERS, | 1011 | ACCEPT_HEADERS, |
@@ -985,13 +1032,13 @@ export { | |||
985 | FOLLOW_STATES, | 1032 | FOLLOW_STATES, |
986 | DEFAULT_USER_THEME_NAME, | 1033 | DEFAULT_USER_THEME_NAME, |
987 | SERVER_ACTOR_NAME, | 1034 | SERVER_ACTOR_NAME, |
1035 | TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME, | ||
988 | PLUGIN_GLOBAL_CSS_FILE_NAME, | 1036 | PLUGIN_GLOBAL_CSS_FILE_NAME, |
989 | PLUGIN_GLOBAL_CSS_PATH, | 1037 | PLUGIN_GLOBAL_CSS_PATH, |
990 | PRIVATE_RSA_KEY_SIZE, | 1038 | PRIVATE_RSA_KEY_SIZE, |
991 | VIDEO_FILTERS, | 1039 | VIDEO_FILTERS, |
992 | ROUTE_CACHE_LIFETIME, | 1040 | ROUTE_CACHE_LIFETIME, |
993 | SORTABLE_COLUMNS, | 1041 | SORTABLE_COLUMNS, |
994 | HLS_STREAMING_PLAYLIST_DIRECTORY, | ||
995 | JOB_TTL, | 1042 | JOB_TTL, |
996 | DEFAULT_THEME_NAME, | 1043 | DEFAULT_THEME_NAME, |
997 | NSFW_POLICY_TYPES, | 1044 | NSFW_POLICY_TYPES, |
@@ -1040,6 +1087,7 @@ export { | |||
1040 | PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME, | 1087 | PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME, |
1041 | ASSETS_PATH, | 1088 | ASSETS_PATH, |
1042 | FILES_CONTENT_HASH, | 1089 | FILES_CONTENT_HASH, |
1090 | OTP, | ||
1043 | loadLanguages, | 1091 | loadLanguages, |
1044 | buildLanguages, | 1092 | buildLanguages, |
1045 | generateContentHash | 1093 | generateContentHash |