]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/activitypub/signature.ts
Move middleware utils in middlewares
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / activitypub / signature.ts
index be14e92eac3bbd921785e4edb55625093310031b..f2f7d58487882f84a287581c8ccf39342e1332c7 100644 (file)
@@ -1,12 +1,13 @@
 import * as express from 'express'
-import { body } from 'express-validator/check'
+import { body } from 'express-validator'
 import {
-  isSignatureCreatorValid, isSignatureTypeValid,
+  isSignatureCreatorValid,
+  isSignatureTypeValid,
   isSignatureValueValid
 } from '../../../helpers/custom-validators/activitypub/signature'
 import { isDateValid } from '../../../helpers/custom-validators/misc'
 import { logger } from '../../../helpers/logger'
-import { areValidationErrors } from '../utils'
+import { areValidationErrors } from '../shared'
 
 const signatureValidator = [
   body('signature.type')
@@ -14,7 +15,7 @@ const signatureValidator = [
     .custom(isSignatureTypeValid).withMessage('Should have a valid signature type'),
   body('signature.created')
     .optional()
-    .custom(isDateValid).withMessage('Should have a valid signature created date'),
+    .custom(isDateValid).withMessage('Should have a signature created date that conforms to ISO 8601'),
   body('signature.creator')
     .optional()
     .custom(isSignatureCreatorValid).withMessage('Should have a valid signature creator'),
@@ -23,7 +24,7 @@ const signatureValidator = [
     .custom(isSignatureValueValid).withMessage('Should have a valid signature value'),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking activitypub signature parameter', { parameters: { signature: req.body.signature } })
+    logger.debug('Checking Linked Data Signature parameter', { parameters: { signature: req.body.signature } })
 
     if (areValidationErrors(req, res)) return