mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-25 22:22:51 +09:00
Create type definition for 'webfinger.js' (#4054)
This commit is contained in:
parent
76fe1c21c3
commit
6439a6c63f
65
src/@types/webfinger.js.d.ts
vendored
Normal file
65
src/@types/webfinger.js.d.ts
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
declare module 'webfinger.js' {
|
||||
interface IWebFingerConstructorConfig {
|
||||
tls_only?: boolean;
|
||||
webfist_fallback?: boolean;
|
||||
uri_fallback?: boolean;
|
||||
request_timeout?: number;
|
||||
}
|
||||
|
||||
type JRDProperties = { [type: string]: string };
|
||||
|
||||
interface IJRDLink {
|
||||
rel: string;
|
||||
type?: string;
|
||||
href?: string;
|
||||
template?: string;
|
||||
titles?: { [lang: string]: string };
|
||||
properties?: JRDProperties;
|
||||
}
|
||||
|
||||
interface IJRD {
|
||||
subject?: string;
|
||||
expires?: Date;
|
||||
aliases?: string[];
|
||||
properties?: JRDProperties;
|
||||
links?: IJRDLink[];
|
||||
}
|
||||
|
||||
interface IIDXLinks {
|
||||
'avatar': IJRDLink[];
|
||||
'remotestorage': IJRDLink[];
|
||||
'blog': IJRDLink[];
|
||||
'vcard': IJRDLink[];
|
||||
'updates': IJRDLink[];
|
||||
'share': IJRDLink[];
|
||||
'profile': IJRDLink[];
|
||||
'webfist': IJRDLink[];
|
||||
'camlistore': IJRDLink[];
|
||||
[type: string]: IJRDLink[];
|
||||
}
|
||||
|
||||
interface IIDXProperties {
|
||||
'name': string;
|
||||
[type: string]: string;
|
||||
}
|
||||
|
||||
interface IIDX {
|
||||
links: IIDXLinks;
|
||||
properties: IIDXProperties;
|
||||
}
|
||||
|
||||
interface ILookupCallbackResult {
|
||||
object: IJRD;
|
||||
json: string;
|
||||
idx: IIDX;
|
||||
}
|
||||
|
||||
type LookupCallback = (err: Error | string, result?: ILookupCallbackResult) => void;
|
||||
|
||||
export class WebFinger {
|
||||
constructor(config?: IWebFingerConstructorConfig);
|
||||
|
||||
public lookup(address: string, cb: LookupCallback): NodeJS.Timeout;
|
||||
public lookupLink(address: string, rel: string, cb: IJRDLink): void;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
const WebFinger = require('webfinger.js');
|
||||
import { WebFinger } from 'webfinger.js';
|
||||
|
||||
const webFinger = new WebFinger({ });
|
||||
|
||||
@ -13,7 +13,7 @@ type IWebFinger = {
|
||||
};
|
||||
|
||||
export default async function resolve(query: any): Promise<IWebFinger> {
|
||||
return await new Promise((res, rej) => webFinger.lookup(query, (error: Error, result: any) => {
|
||||
return await new Promise((res, rej) => webFinger.lookup(query, (error: Error | string, result: any) => {
|
||||
if (error) {
|
||||
return rej(error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user