diff options
Diffstat (limited to 'server/helpers/core-utils.ts')
-rw-r--r-- | server/helpers/core-utils.ts | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index 884206aad..25eb6454a 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts | |||
@@ -13,6 +13,7 @@ import * as pem from 'pem' | |||
13 | import * as rimraf from 'rimraf' | 13 | import * as rimraf from 'rimraf' |
14 | import { URL } from 'url' | 14 | import { URL } from 'url' |
15 | import { truncate } from 'lodash' | 15 | import { truncate } from 'lodash' |
16 | import * as crypto from 'crypto' | ||
16 | 17 | ||
17 | function sanitizeUrl (url: string) { | 18 | function sanitizeUrl (url: string) { |
18 | const urlObject = new URL(url) | 19 | const urlObject = new URL(url) |
@@ -95,6 +96,10 @@ function peertubeTruncate (str: string, maxLength: number) { | |||
95 | return truncate(str, options) | 96 | return truncate(str, options) |
96 | } | 97 | } |
97 | 98 | ||
99 | function sha256 (str: string) { | ||
100 | return crypto.createHash('sha256').update(str).digest('hex') | ||
101 | } | ||
102 | |||
98 | function promisify0<A> (func: (cb: (err: any, result: A) => void) => void): () => Promise<A> { | 103 | function promisify0<A> (func: (cb: (err: any, result: A) => void) => void): () => Promise<A> { |
99 | return function promisified (): Promise<A> { | 104 | return function promisified (): Promise<A> { |
100 | return new Promise<A>((resolve: (arg: A) => void, reject: (err: any) => void) => { | 105 | return new Promise<A>((resolve: (arg: A) => void, reject: (err: any) => void) => { |
@@ -165,6 +170,7 @@ export { | |||
165 | sanitizeHost, | 170 | sanitizeHost, |
166 | buildPath, | 171 | buildPath, |
167 | peertubeTruncate, | 172 | peertubeTruncate, |
173 | sha256, | ||
168 | 174 | ||
169 | promisify0, | 175 | promisify0, |
170 | promisify1, | 176 | promisify1, |