summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAcid Chicken (硫酸鶏) <root@acid-chicken.com>2019-01-31 17:52:17 +0900
committerGitHub <noreply@github.com>2019-01-31 17:52:17 +0900
commit6439a6c63fb603c9137e5f7f7b65168db7d98cb0 (patch)
tree6d3719a57c0fcfa95a9c45244a218954854b82aa /src
parentUpdate gulp-yaml requirement from 2.0.2 to 2.0.3 (#4053) (diff)
downloadsharkey-6439a6c63fb603c9137e5f7f7b65168db7d98cb0.tar.gz
sharkey-6439a6c63fb603c9137e5f7f7b65168db7d98cb0.tar.bz2
sharkey-6439a6c63fb603c9137e5f7f7b65168db7d98cb0.zip
Create type definition for 'webfinger.js' (#4054)
Diffstat (limited to 'src')
-rw-r--r--src/@types/webfinger.js.d.ts65
-rw-r--r--src/remote/webfinger.ts4
2 files changed, 67 insertions, 2 deletions
diff --git a/src/@types/webfinger.js.d.ts b/src/@types/webfinger.js.d.ts
new file mode 100644
index 0000000000..9783a14cba
--- /dev/null
+++ b/src/@types/webfinger.js.d.ts
@@ -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;
+ }
+}
diff --git a/src/remote/webfinger.ts b/src/remote/webfinger.ts
index cba09379a1..1229dbaf98 100644
--- a/src/remote/webfinger.ts
+++ b/src/remote/webfinger.ts
@@ -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);
}