From 9a27cdc27c900feaae5f6db4315c4ccdfc0c4493 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Nov 2017 15:20:42 +0100 Subject: Optimize signature verification --- server/middlewares/activitypub.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'server/middlewares/activitypub.ts') diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index 0ea522e5c..8e8a3961b 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts @@ -1,9 +1,10 @@ -import { NextFunction, Request, Response, RequestHandler } from 'express' +import { eachSeries } from 'async' +import { NextFunction, Request, RequestHandler, Response } from 'express' import { ActivityPubSignature } from '../../shared' import { isSignatureVerified, logger } from '../helpers' import { fetchRemoteAccountAndCreateServer } from '../helpers/activitypub' -import { database as db, ACTIVITY_PUB_ACCEPT_HEADER } from '../initializers' -import { each, eachSeries, waterfall } from 'async' +import { database as db } from '../initializers' +import { ACTIVITY_PUB } from '../initializers/constants' async function checkSignature (req: Request, res: Response, next: NextFunction) { const signatureObject: ActivityPubSignature = req.body.signature @@ -37,7 +38,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction) function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { return (req: Request, res: Response, next: NextFunction) => { - if (req.header('Accept') !== ACTIVITY_PUB_ACCEPT_HEADER) { + if (req.header('Accept') !== ACTIVITY_PUB.ACCEPT_HEADER) { return next() } -- cgit v1.2.3