Sharkey/src/remote/webfinger.ts

24 lines
429 B
TypeScript
Raw Normal View History

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