forked from shadowfacts/shadowfacts.net
Fix returning strings instead of JSON objects as actors on bad responses
This commit is contained in:
parent
10a90ea48f
commit
1ceaa15507
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue