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