]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/activitypub/signature.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / activitypub / signature.ts
1 import { body } from 'express-validator/check'
2 import * as express from 'express'
3
4 import {
5 logger,
6 isDateValid,
7 isSignatureTypeValid,
8 isSignatureCreatorValid,
9 isSignatureValueValid
10 } from '../../../helpers'
11 import { checkErrors } from '../utils'
12
13 const signatureValidator = [
14 body('signature.type').custom(isSignatureTypeValid).withMessage('Should have a valid signature type'),
15 body('signature.created').custom(isDateValid).withMessage('Should have a valid signature created date'),
16 body('signature.creator').custom(isSignatureCreatorValid).withMessage('Should have a valid signature creator'),
17 body('signature.signatureValue').custom(isSignatureValueValid).withMessage('Should have a valid signature value'),
18
19 (req: express.Request, res: express.Response, next: express.NextFunction) => {
20 logger.debug('Checking activitypub signature parameter', { parameters: { signature: req.body.signature } })
21
22 checkErrors(req, res, next)
23 }
24 ]
25
26 // ---------------------------------------------------------------------------
27
28 export {
29 signatureValidator
30 }