1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-23 19:19:05 +09:00
misskey/src/remote/webfinger.ts

24 lines
454 B
TypeScript
Raw Normal View History

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