Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix build

Chocobozzzf304a1580b5c
diff --git a/client/src/app/shared/shared-video-miniature/video-filters.model.ts b/client/src/app/shared/shared-video-miniature/video-filters.model.ts
index 982880b0e7..8ad2fcd5d6 100644
--- a/client/src/app/shared/shared-video-miniature/video-filters.model.ts
+++ b/client/src/app/shared/shared-video-miniature/video-filters.model.ts
@@ -1,5 +1,6 @@
import { intoArray, toBoolean } from '@app/helpers'
-import { AttributesOnly, getAllPrivacies } from '@shared/core-utils'
+import { getAllPrivacies } from '@shared/core-utils'
+import { AttributesOnly } from '@shared/typescript-utils'
import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models'
type VideoFiltersKeys = {
diff --git a/client/tsconfig.json b/client/tsconfig.json
index d68b3058e6..41814d0362 100644
--- a/client/tsconfig.json
+++ b/client/tsconfig.json
@@ -35,6 +35,8 @@
"@shared/models": [ "../shared/models" ],
"@shared/core-utils": [ "../shared/core-utils" ],
"@shared/core-utils/*": [ "../shared/core-utils/*" ],
+ "@shared/typescript-utils": [ "../shared/typescript-utils" ],
+ "@shared/typescript-utils/*": [ "../shared/typescript-utils/*" ],
"@root-helpers/*": [ "src/root-helpers/*" ],
"fs": [ "src/shims/noop.ts" ],
"http": [ "src/shims/http.ts" ],
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts
index 66a353204a..b8f7c782ae 100644
--- a/server/helpers/peertube-crypto.ts
+++ b/server/helpers/peertube-crypto.ts
@@ -2,9 +2,9 @@ import { compare, genSalt, hash } from 'bcrypt'
import { createSign, createVerify } from 'crypto'
import { Request } from 'express'
import { cloneDeep } from 'lodash'
+import { sha256 } from '@shared/extra-utils'
import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants'
import { MActor } from '../types/models'
-import { sha256 } from '@shared/core-utils/common/crypto'
import { createPrivateKey, getPublicKey, promisify1, promisify2 } from './core-utils'
import { jsonld } from './custom-jsonld-signature'
import { logger } from './logger'
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index d6a3dae955..bd85eaa561 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -1,9 +1,9 @@
import { remove } from 'fs-extra'
import { Instance as ParseTorrent } from 'parse-torrent'
import { join } from 'path'
+import { sha256 } from '@shared/extra-utils'
import { ResultList } from '../../shared'
import { CONFIG } from '../initializers/config'
-import { sha256 } from '@shared/core-utils/common/crypto'
import { execPromise, execPromise2, randomBytesPromise } from './core-utils'
import { logger } from './logger'
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts
index 03663d73c4..68d532c489 100644
--- a/server/helpers/webtorrent.ts
+++ b/server/helpers/webtorrent.ts
@@ -13,9 +13,9 @@ import { VideoPathManager } from '@server/lib/video-path-manager'
import { MVideo } from '@server/types/models/video/video'
import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/video/video-file'
import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist'
+import { sha1 } from '@shared/extra-utils'
import { CONFIG } from '../initializers/config'
import { promisify2 } from './core-utils'
-import { sha1 } from '@shared/core-utils/common/crypto'
import { logger } from './logger'
import { generateVideoImportTmpPath } from './utils'
import { extractVideo } from './video'
diff --git a/server/lib/auth/oauth.ts b/server/lib/auth/oauth.ts
index dc0022852d..2bf7a63617 100644
--- a/server/lib/auth/oauth.ts
+++ b/server/lib/auth/oauth.ts
@@ -8,9 +8,9 @@ import {
UnauthorizedClientError,
UnsupportedGrantTypeError
} from 'oauth2-server'
-import { sha1 } from '@shared/core-utils/common/crypto'
import { randomBytesPromise } from '@server/helpers/core-utils'
import { MOAuthClient } from '@server/types/models'
+import { sha1 } from '@shared/extra-utils'
import { OAUTH_LIFETIME } from '../../initializers/constants'
import { BypassLogin, getClient, getRefreshToken, getUser, revokeToken, saveToken } from './oauth-model'
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index 91708839bb..e7e439bfe4 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -4,12 +4,12 @@ import { join } from 'path'
import validator from 'validator'
import { toCompleteUUID } from '@server/helpers/custom-validators/misc'
import { escapeHTML } from '@shared/core-utils/renderer'
+import { sha256 } from '@shared/extra-utils'
import { HTMLServerConfig } from '@shared/models'
import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n'
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos'
import { isTestInstance } from '../helpers/core-utils'
-import { sha256 } from '@shared/core-utils/common/crypto'
import { logger } from '../helpers/logger'
import { mdToPlainText } from '../helpers/markdown'
import { CONFIG } from '../initializers/config'
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index e4904be5f3..1574ff27ba 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -2,7 +2,7 @@ import { close, ensureDir, move, open, outputJSON, read, readFile, remove, stat,
import { flatten, uniq } from 'lodash'
import { basename, dirname, join } from 'path'
import { MStreamingPlaylistFilesVideo, MVideo, MVideoUUID } from '@server/types/models'
-import { sha256 } from '@shared/core-utils/common/crypto'
+import { sha256 } from '@shared/extra-utils'
import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamSize } from '../helpers/ffprobe-utils'
import { logger } from '../helpers/logger'
import { doRequest, doRequestAndSaveToFile } from '../helpers/requests'
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts
index 7b410f8eea..9957ffee3c 100644
--- a/server/models/video/video-streaming-playlist.ts
+++ b/server/models/video/video-streaming-playlist.ts
@@ -18,10 +18,10 @@ import {
import { getHLSPublicFileUrl } from '@server/lib/object-storage'
import { VideoFileModel } from '@server/models/video/video-file'
import { MStreamingPlaylist, MVideo } from '@server/types/models'
-import { AttributesOnly } from '@shared/typescript-utils'
+import { sha1 } from '@shared/extra-utils'
import { VideoStorage } from '@shared/models'
+import { AttributesOnly } from '@shared/typescript-utils'
import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
-import { sha1 } from '@shared/core-utils/common/crypto'
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
import { isArrayOf } from '../../helpers/custom-validators/misc'
import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'
diff --git a/server/tests/shared/streaming-playlists.ts b/server/tests/shared/streaming-playlists.ts
index 738dc90e13..7ca707f2ef 100644
--- a/server/tests/shared/streaming-playlists.ts
+++ b/server/tests/shared/streaming-playlists.ts
@@ -1,7 +1,7 @@
import { expect } from 'chai'
import { basename } from 'path'
import { removeFragmentedMP4Ext } from '@shared/core-utils'
-import { sha256 } from '@shared/core-utils/common/crypto'
+import { sha256 } from '@shared/extra-utils'
import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models'
import { PeerTubeServer } from '@shared/server-commands'
diff --git a/server/tests/shared/tracker.ts b/server/tests/shared/tracker.ts
index 699895d5f3..9c1f0246a3 100644
--- a/server/tests/shared/tracker.ts
+++ b/server/tests/shared/tracker.ts
@@ -1,5 +1,5 @@
import { expect } from 'chai'
-import { sha1 } from '@shared/core-utils'
+import { sha1 } from '@shared/extra-utils'
import { makeGetRequest } from '@shared/server-commands'
async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) {
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index 8314551f64..44c42bad6a 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -5,7 +5,7 @@ import { program } from 'commander'
import { accessSync, constants } from 'fs'
import { remove } from 'fs-extra'
import { join } from 'path'
-import { sha256 } from '@shared/core-utils/crypto'
+import { sha256, wait } from '@shared/core-utils'
import { doRequestAndSaveToFile } from '../helpers/requests'
import {
assignToken,
@@ -15,7 +15,6 @@ import {
getLogger,
getServerCredentials
} from './cli'
-import { wait } from '@shared/server-commands'
import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl'
import prompt = require('prompt')
diff --git a/shared/core-utils/common/index.ts b/shared/core-utils/common/index.ts
index f9ba10d5e0..720977ead6 100644
--- a/shared/core-utils/common/index.ts
+++ b/shared/core-utils/common/index.ts
@@ -1,5 +1,5 @@
export * from './array'
-export * from './crypto'
+export * from './random'
export * from './date'
export * from './env'
export * from './object'
diff --git a/shared/core-utils/common/random.ts b/shared/core-utils/common/random.ts
new file mode 100644
index 0000000000..705735d09f
--- /dev/null
+++ b/shared/core-utils/common/random.ts
@@ -0,0 +1,8 @@
+// high excluded
+function randomInt (low: number, high: number) {
+ return Math.floor(Math.random() * (high - low) + low)
+}
+
+export {
+ randomInt
+}
diff --git a/shared/core-utils/common/crypto.ts b/shared/extra-utils/crypto.ts
similarity index 100%
rename from shared/core-utils/common/crypto.ts
rename to shared/extra-utils/crypto.ts
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts
index 38303cf1fa..373d27cb49 100644
--- a/shared/extra-utils/index.ts
+++ b/shared/extra-utils/index.ts
@@ -1,2 +1,3 @@
+export * from './crypto'
export * from './ffprobe'
export * from './file'