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

26 lines
537 B
TypeScript
Raw Normal View History

2018-03-31 19:55:00 +09:00
const WebFinger = require('webfinger.js');
2018-04-01 19:43:26 +09:00
const webFinger = new WebFinger({ tls_only: false });
2018-03-31 19:55:00 +09:00
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);
}));