Implement remote status retrieval
This commit is contained in:
parent
7da60a0147
commit
68a9aac957
46 changed files with 468 additions and 198 deletions
25
src/common/remote/webfinger.ts
Normal file
25
src/common/remote/webfinger.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const WebFinger = require('webfinger.js');
|
||||
|
||||
const webFinger = new WebFinger({});
|
||||
|
||||
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);
|
||||
}));
|
||||
Loading…
Add table
Add a link
Reference in a new issue