diff --git a/bun.lockb b/bun.lockb index c7094dc6..41e8c4ba 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index fb35c340..51477623 100644 --- a/package.json +++ b/package.json @@ -106,13 +106,13 @@ "@json2csv/plainjs": "^7.0.6", "@logtape/logtape": "npm:@jsr/logtape__logtape@0.4.2", "@lysand-org/client": "^0.2.5", - "@lysand-org/federation": "^2.1.9", + "@lysand-org/federation": "^2.1.10", "@oclif/core": "^4.0.14", "@sentry/bun": "^8.20.0", "@tufjs/canonical-json": "^2.0.0", "altcha-lib": "^0.5.1", "blurhash": "^2.0.5", - "bullmq": "^5.10.3", + "bullmq": "^5.10.4", "chalk": "^5.3.0", "cli-progress": "^3.12.0", "cli-table": "^0.3.11", diff --git a/packages/database-interface/instance.ts b/packages/database-interface/instance.ts index 1414f95a..100b9620 100644 --- a/packages/database-interface/instance.ts +++ b/packages/database-interface/instance.ts @@ -2,6 +2,7 @@ import { getLogger } from "@logtape/logtape"; import { EntityValidator, FederationRequester, + type ResponseError, type ValidationError, } from "@lysand-org/federation"; import type { ServerMetadata } from "@lysand-org/federation/types"; @@ -145,7 +146,9 @@ export class Instance extends BaseInterface { // @ts-expect-error Bun extension proxy: config.http.proxy.address, }, - ); + ).catch((e) => ({ + ...(e as ResponseError).response, + })); if (!(ok && raw.headers.get("content-type")?.includes("json"))) { // If the server doesn't have a Lysand well-known endpoint, it's not a Lysand instance @@ -202,7 +205,13 @@ export class Instance extends BaseInterface { }>(wellKnownUrl, { // @ts-expect-error Bun extension proxy: config.http.proxy.address, - }); + }).catch((e) => ({ + ...( + e as ResponseError<{ + links: { rel: string; href: string }[]; + }> + ).response, + })); if (!ok) { logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold( @@ -246,7 +255,19 @@ export class Instance extends BaseInterface { }>(metadataUrl.href, { // @ts-expect-error Bun extension proxy: config.http.proxy.address, - }); + }).catch((e) => ({ + ...( + e as ResponseError<{ + metadata: { + nodeName?: string; + title?: string; + nodeDescription?: string; + description?: string; + }; + software: { version: string }; + }> + ).response, + })); if (!ok2) { logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold( diff --git a/packages/database-interface/user.ts b/packages/database-interface/user.ts index f7d04b8d..c94fe972 100644 --- a/packages/database-interface/user.ts +++ b/packages/database-interface/user.ts @@ -340,19 +340,13 @@ export class User extends BaseInterface { uri: string, instance: Instance, ): Promise { - const { - raw: response, - data: json, - ok, - } = await FederationRequester.get>(uri, { + const { data: json } = await FederationRequester.get< + Partial + >(uri, { // @ts-expect-error Bun extension proxy: config.http.proxy.address, }); - if (!ok) { - throw new Error(`HTTP error! status: ${response.status}`); - } - const validator = new EntityValidator(); const data = await validator.User(json);