mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-16 06:57:36 -07:00
26 lines
520 B
TypeScript
26 lines
520 B
TypeScript
|
const WebFinger = require('webfinger.js');
|
||
|
|
||
|
const webFinger = new WebFinger({});
|
||
|
|
||
|
type ILink = {
|
||
|
href: string;
|
||
|
rel: string;
|
||
|
}
|
||
|
|
||
|
type IWebFinger = {
|
||
|
links: Array<ILink>;
|
||
|
subject: string;
|
||
|
}
|
||
|
|
||
|
export default (query, verifier): Promise<IWebFinger> => new Promise((res, rej) => webFinger.lookup(query, (error, result) => {
|
||
|
if (error) {
|
||
|
return rej(error);
|
||
|
}
|
||
|
|
||
|
if (result.object.subject.toLowerCase().replace(/^acct:/, '') !== verifier) {
|
||
|
return rej('WebFinger verfification failed');
|
||
|
}
|
||
|
|
||
|
res(result.object);
|
||
|
}));
|