Fix returning strings instead of JSON objects as actors on bad responses

This commit is contained in:
Shadowfacts 2019-09-18 08:39:17 -04:00
parent 10a90ea48f
commit 1ceaa15507
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 1 additions and 6 deletions

View File

@ -57,8 +57,6 @@ export async function getCachedActor(url: string): Promise<ActorObject | null> {
}
async function cacheActor(actorObject: ActorObject) {
if (!actorObject.publicKey) return;
function getIconUrl(icon: string | object): string {
return icon instanceof String ? icon : (icon as any).url;
}
@ -88,7 +86,7 @@ async function fetchActor(url?: string): Promise<ActorObject | null> {
json: true
}, (err, res) => {
if (err) reject(err);
else resolve(res.body ? res.body as ActorObject : null);
else resolve(res.body && res.body instanceof Object ? res.body as ActorObject : null);
});
});
}

View File

@ -25,9 +25,6 @@ export = async (req: Request, res: Response, next: NextFunction) => {
console.log(`Could not retrieve actor ${req.body.actor} to validate HTTP signature for`, req.body);
res.status(401).end("Could not retrieve actor to validate HTTP signature");
}
} else if (!actor.publicKey) {
console.log(`Could not validate HTTP signature, actor missing public key: ${actor}`);
res.status(401).end("Actor missing public key.")
} else if (!validate(req, actor.publicKey.publicKeyPem)) {
console.log(`Could not validate HTTP signature for ${req.body.actor}`);
res.status(401).end("Could not validate HTTP signature");