import * as express from 'express'
-import { body } from 'express-validator/check'
+import { body } from 'express-validator'
import {
isSignatureCreatorValid, isSignatureTypeValid,
isSignatureValueValid
import { areValidationErrors } from '../utils'
const signatureValidator = [
- body('signature.type').custom(isSignatureTypeValid).withMessage('Should have a valid signature type'),
- body('signature.created').custom(isDateValid).withMessage('Should have a valid signature created date'),
- body('signature.creator').custom(isSignatureCreatorValid).withMessage('Should have a valid signature creator'),
- body('signature.signatureValue').custom(isSignatureValueValid).withMessage('Should have a valid signature value'),
+ body('signature.type')
+ .optional()
+ .custom(isSignatureTypeValid).withMessage('Should have a valid signature type'),
+ body('signature.created')
+ .optional()
+ .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'),
+ body('signature.signatureValue')
+ .optional()
+ .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