X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Frequests.ts;h=d67d460446e99a2aa22d6116f7928af90f5e05f8;hb=6599f096d5a26f2cc9624359d92cc501ec189586;hp=183f6df0daf2b9de488c7740799310bd8b3b97ee;hpb=709756b8e183f67ef9bf8f7bc149af4736260350;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 183f6df0d..d67d46044 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -8,6 +8,7 @@ import { CONFIG } from '../initializers' import { PodInstance } from '../models' +import { PodSignature } from '../../shared' import { sign } from './peertube-crypto' type MakeRetryRequestParams = { @@ -37,9 +38,18 @@ type MakeSecureRequestParams = { } function makeSecureRequest (params: MakeSecureRequestParams) { return new Promise<{ response: request.RequestResponse, body: any }>((res, rej) => { - const requestParams = { + const requestParams: { + url: string, + json: { + signature: PodSignature, + data: any + } + } = { url: REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path, - json: {} + json: { + signature: null, + data: null + } } if (params.method !== 'POST') { @@ -58,14 +68,14 @@ function makeSecureRequest (params: MakeSecureRequestParams) { } sign(dataToSign).then(signature => { - requestParams.json['signature'] = { + requestParams.json.signature = { host, // Which host we pretend to be signature } // If there are data informations if (params.data) { - requestParams.json['data'] = params.data + requestParams.json.data = params.data } request.post(requestParams, (err, response, body) => err ? rej(err) : res({ response, body }))