From 91f4ec3747e814b941051b665645aae2433e6c1c Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 3 Apr 2022 16:30:22 +0900 Subject: [PATCH] fix types --- packages/backend/src/misc/captcha.ts | 3 ++- .../src/remote/activitypub/misc/ld-signature.ts | 3 ++- .../src/server/api/endpoints/notes/translate.ts | 3 ++- .../backend/src/services/fetch-instance-metadata.ts | 11 ++++++----- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/misc/captcha.ts b/packages/backend/src/misc/captcha.ts index 293cbdcd37..9a87a4a3c8 100644 --- a/packages/backend/src/misc/captcha.ts +++ b/packages/backend/src/misc/captcha.ts @@ -42,7 +42,8 @@ async function getCaptchaResponse(url: string, secret: string, response: string) headers: { 'User-Agent': config.userAgent, }, - timeout: 10 * 1000, + // TODO + //timeout: 10 * 1000, agent: getAgentByUrl, }).catch(e => { throw `${e.message || e}`; diff --git a/packages/backend/src/remote/activitypub/misc/ld-signature.ts b/packages/backend/src/remote/activitypub/misc/ld-signature.ts index 5132c6ef96..362a543ece 100644 --- a/packages/backend/src/remote/activitypub/misc/ld-signature.ts +++ b/packages/backend/src/remote/activitypub/misc/ld-signature.ts @@ -113,7 +113,8 @@ export class LdSignature { headers: { Accept: 'application/ld+json, application/json', }, - timeout: this.loderTimeout, + // TODO + //timeout: this.loderTimeout, agent: u => u.protocol === 'http:' ? httpAgent : httpsAgent, }).then(res => { if (!res.ok) { diff --git a/packages/backend/src/server/api/endpoints/notes/translate.ts b/packages/backend/src/server/api/endpoints/notes/translate.ts index 068df6940b..c602981b30 100644 --- a/packages/backend/src/server/api/endpoints/notes/translate.ts +++ b/packages/backend/src/server/api/endpoints/notes/translate.ts @@ -75,7 +75,8 @@ export default define(meta, paramDef, async (ps, user) => { Accept: 'application/json, */*', }, body: params, - timeout: 10000, + // TODO + //timeout: 10000, agent: getAgentByUrl, }); diff --git a/packages/backend/src/services/fetch-instance-metadata.ts b/packages/backend/src/services/fetch-instance-metadata.ts index 2b6f82a910..d5294c5fe8 100644 --- a/packages/backend/src/services/fetch-instance-metadata.ts +++ b/packages/backend/src/services/fetch-instance-metadata.ts @@ -97,7 +97,7 @@ async function fetchNodeinfo(instance: Instance): Promise { } else { throw e.statusCode || e.message; } - }); + }) as Record; if (wellknown.links == null || !Array.isArray(wellknown.links)) { throw 'No wellknown links'; @@ -121,7 +121,7 @@ async function fetchNodeinfo(instance: Instance): Promise { logger.succ(`Successfuly fetched nodeinfo of ${instance.host}`); - return info; + return info as NodeInfo; } catch (e) { logger.error(`Failed to fetch nodeinfo of ${instance.host}: ${e}`); @@ -142,12 +142,12 @@ async function fetchDom(instance: Instance): Promise { return doc; } -async function fetchManifest(instance: Instance): Promise | null> { +async function fetchManifest(instance: Instance): Promise | null> { const url = 'https://' + instance.host; const manifestUrl = url + '/manifest.json'; - const manifest = await getJson(manifestUrl); + const manifest = await getJson(manifestUrl) as Record; return manifest; } @@ -167,7 +167,8 @@ async function fetchFaviconUrl(instance: Instance, doc: DOMWindow['document'] | const faviconUrl = url + '/favicon.ico'; const favicon = await fetch(faviconUrl, { - timeout: 10000, + // TODO + //timeout: 10000, agent: getAgentByUrl, });