]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/requests.ts
Fix bad translation in confirm dialog
[github/Chocobozzz/PeerTube.git] / server / helpers / requests.ts
index 183f6df0daf2b9de488c7740799310bd8b3b97ee..d67d460446e99a2aa22d6116f7928af90f5e05f8 100644 (file)
@@ -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 }))