From 334c429bfa3c0e2cb59e6e54c4a8a727d70d7aa4 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Mon, 26 Aug 2024 19:34:21 +0200 Subject: [PATCH] fix(federation): :bug: Correctly validate outbound Collections --- bun.lockb | Bin 281116 -> 281116 bytes package.json | 2 +- server/api/users/:uuid/outbox/index.ts | 11 +++-------- types/api.ts | 4 +++- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/bun.lockb b/bun.lockb index 36d6e366966378c78aeb1ae66c19a9e6dd2eb5c8..db943cf3b4c327d9ce24b63b08d8d8fe487bb819 100755 GIT binary patch delta 166 zcmV;X09pT>lo6bi5s)q*!(W#>MNMvy#p?bGWfEA6F5Y3tWVu}(#6 z4KV-!0003p?48#qZ)=laD;Tr5YgO$)U&L(T=uNTFETo~yH~Zy`VZZyv_%z|AB1`U5 zU|=);L=RII$=K*;!(BZ1s90EP+wQ%6bDV(|0qTu;-A@B8hfP@lhfP@mw@q0CBoP5I Uw{mI&Q%#qW&jTU1=C=bjk_?hdwEzGB delta 166 zcmV;X09pT>lo6bi5s)q*OohF+Fw3XhKaF$Z5Hag*owKwdtMecHk`-8|@0}fgu}(#6 z4KM%z000_ELMwZutu~WjD;Tr5YgO$)&@1OLE=rmGT9kR=%X3$jb-VHggz;^G^(kBX zXkqWzur;LiXtw923A*QWlw;a8FDmcPtzj`52h*vkNw7jShfP@lhfP@mw@q0CBoP5H Uw{mI&Q%#o=%mX2}=C=bjl0#5SVgLXD diff --git a/package.json b/package.json index 7dd56137..c858261f 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "@oclif/core": "^4.0.19", "@sentry/bun": "^8.26.0", "@tufjs/canonical-json": "^2.0.0", - "@versia/federation": "^0.1.0-rc.0", + "@versia/federation": "^0.1.0-rc.1", "altcha-lib": "^0.5.1", "blurhash": "^2.0.5", "bullmq": "^5.12.10", diff --git a/server/api/users/:uuid/outbox/index.ts b/server/api/users/:uuid/outbox/index.ts index 22c40c20..1dbba9bb 100644 --- a/server/api/users/:uuid/outbox/index.ts +++ b/server/api/users/:uuid/outbox/index.ts @@ -1,6 +1,6 @@ import { apiRoute, applyConfig, handleZodError } from "@/api"; import { zValidator } from "@hono/zod-validator"; -import type { Entity } from "@versia/federation/types"; +import type { Collection } from "@versia/federation/types"; import { and, count, eq, inArray } from "drizzle-orm"; import { z } from "zod"; import { db } from "~/drizzle/db"; @@ -108,14 +108,9 @@ export default apiRoute((app) => ).toString() : null, items: notes.map((note) => note.toVersia()), - }; + } satisfies Collection; - const { headers } = await author.sign( - // @ts-expect-error To fix when I add collections to versia-api - json as Entity, - context.req.url, - "GET", - ); + const { headers } = await author.sign(json, context.req.url, "GET"); return context.json(json, 200, headers.toJSON()); }, diff --git a/types/api.ts b/types/api.ts index 75e023c3..6e644cea 100644 --- a/types/api.ts +++ b/types/api.ts @@ -1,6 +1,7 @@ import type { Hono } from "@hono/hono"; import type { RouterRoute } from "@hono/hono/types"; import type { + Collection, Delete, Follow, FollowAccept, @@ -61,4 +62,5 @@ export type KnownEntity = | FollowReject | Unfollow | Delete - | LikeExtension; + | LikeExtension + | Collection;