diff --git a/bun.lockb b/bun.lockb index dcf00f4a..845289c4 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 50519171..a431a752 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "@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.8", + "@lysand-org/federation": "^2.1.9-test2", "@oclif/core": "^4.0.14", "@sentry/bun": "^8.19.0", "@tufjs/canonical-json": "^2.0.0", diff --git a/packages/database-interface/instance.ts b/packages/database-interface/instance.ts index 6c9b4393..9effa534 100644 --- a/packages/database-interface/instance.ts +++ b/packages/database-interface/instance.ts @@ -1,5 +1,9 @@ import { getLogger } from "@logtape/logtape"; -import { EntityValidator, type ValidationError } from "@lysand-org/federation"; +import { + EntityValidator, + FederationRequester, + type ValidationError, +} from "@lysand-org/federation"; import type { ServerMetadata } from "@lysand-org/federation/types"; import chalk from "chalk"; import { config } from "config-manager"; @@ -135,9 +139,13 @@ export class Instance extends BaseInterface { const logger = getLogger("federation"); try { - const response = await fetch(wellKnownUrl, { - proxy: config.http.proxy.address, - }); + const { raw: response } = await FederationRequester.get( + wellKnownUrl, + { + // @ts-expect-error Bun extension + proxy: config.http.proxy.address, + }, + ); if ( !( @@ -190,9 +198,13 @@ export class Instance extends BaseInterface { const logger = getLogger("federation"); try { - const response = await fetch(wellKnownUrl, { - proxy: config.http.proxy.address, - }); + const { raw: response } = await FederationRequester.get( + wellKnownUrl, + { + // @ts-expect-error Bun extension + proxy: config.http.proxy.address, + }, + ); if (!response.ok) { logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold( @@ -223,9 +235,13 @@ export class Instance extends BaseInterface { return null; } - const metadataResponse = await fetch(metadataUrl.href, { - proxy: config.http.proxy.address, - }); + const { raw: metadataResponse } = await FederationRequester.get( + metadataUrl.href, + { + // @ts-expect-error Bun extension + proxy: config.http.proxy.address, + }, + ); if (!metadataResponse.ok) { logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold( diff --git a/packages/database-interface/note.ts b/packages/database-interface/note.ts index 2df23cc8..8ea0593a 100644 --- a/packages/database-interface/note.ts +++ b/packages/database-interface/note.ts @@ -6,7 +6,7 @@ import type { Attachment as ApiAttachment, Status as ApiStatus, } from "@lysand-org/client/types"; -import { EntityValidator } from "@lysand-org/federation"; +import { EntityValidator, FederationRequester } from "@lysand-org/federation"; import type { ContentFormat, Note as LysandNote, @@ -591,11 +591,8 @@ export class Note extends BaseInterface { throw new Error(`Invalid URI to parse ${uri}`); } - const response = await fetch(uri, { - method: "GET", - headers: { - Accept: "application/json", - }, + const { raw: response } = await FederationRequester.get(uri, { + // @ts-expect-error Bun extension proxy: config.http.proxy.address, }); diff --git a/packages/database-interface/user.ts b/packages/database-interface/user.ts index edf007fd..ad5d5104 100644 --- a/packages/database-interface/user.ts +++ b/packages/database-interface/user.ts @@ -6,10 +6,7 @@ import type { Account as ApiAccount, Mention as ApiMention, } from "@lysand-org/client/types"; -import { - EntityValidator, - type FederationRequester, -} from "@lysand-org/federation"; +import { EntityValidator, FederationRequester } from "@lysand-org/federation"; import type { Entity, User as LysandUser } from "@lysand-org/federation/types"; import { type InferInsertModel, @@ -343,9 +340,8 @@ export class User extends BaseInterface { uri: string, instance: Instance, ): Promise { - const response = await fetch(uri, { - method: "GET", - headers: { Accept: "application/json" }, + const { raw: response } = await FederationRequester.get(uri, { + // @ts-expect-error Bun extension proxy: config.http.proxy.address, });