2018-03-31 12:55:00 +02:00
|
|
|
const WebFinger = require('webfinger.js');
|
|
|
|
|
2018-04-01 16:33:48 +02:00
|
|
|
const webFinger = new WebFinger({ });
|
2018-03-31 12:55:00 +02:00
|
|
|
|
|
|
|
type ILink = {
|
2018-04-08 21:08:56 +02:00
|
|
|
href: string;
|
|
|
|
rel: string;
|
2018-04-01 14:24:25 +02:00
|
|
|
};
|
2018-03-31 12:55:00 +02:00
|
|
|
|
|
|
|
type IWebFinger = {
|
2018-04-08 21:08:56 +02:00
|
|
|
links: ILink[];
|
|
|
|
subject: string;
|
2018-04-01 14:24:25 +02:00
|
|
|
};
|
2018-03-31 12:55:00 +02:00
|
|
|
|
2018-06-18 02:54:53 +02:00
|
|
|
export default async function resolve(query: any): Promise<IWebFinger> {
|
|
|
|
return await new Promise((res, rej) => webFinger.lookup(query, (error: Error, result: any) => {
|
2018-04-02 11:36:47 +02:00
|
|
|
if (error) {
|
|
|
|
return rej(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
res(result.object);
|
|
|
|
})) as IWebFinger;
|
|
|
|
}
|