diff --git a/server/api/objects/:id/index.ts b/server/api/objects/:id/index.ts index 3a31ce16..d41c2f7c 100644 --- a/server/api/objects/:id/index.ts +++ b/server/api/objects/:id/index.ts @@ -2,6 +2,7 @@ import { applyConfig, handleZodError } from "@/api"; import { errorResponse, response } from "@/response"; import type { Hono } from "@hono/hono"; import { zValidator } from "@hono/zod-validator"; +import { getLogger } from "@logtape/logtape"; import { SignatureConstructor } from "@lysand-org/federation"; import type { Entity } from "@lysand-org/federation/types"; import { and, eq, inArray, sql } from "drizzle-orm"; @@ -99,13 +100,23 @@ export default (app: Hono) => const author = foundAuthor ?? User.getServerActor(); - const { headers } = await ( + const { headers, signedString } = await ( await SignatureConstructor.fromStringKey( author.data.privateKey ?? "", author.getUri(), ) ).sign("POST", reqUrl, objectString); + if (config.debug.federation) { + const logger = getLogger("federation"); + + // Log public key + logger.debug`Sender public key: ${author.data.publicKey}`; + + // Log signed string + logger.debug`Signed string:\n${signedString}`; + } + return response(objectString, 200, { "Content-Type": "application/json", ...headers.toJSON(), diff --git a/server/api/users/:uuid/index.ts b/server/api/users/:uuid/index.ts index dd2d6d63..412f34e6 100644 --- a/server/api/users/:uuid/index.ts +++ b/server/api/users/:uuid/index.ts @@ -2,6 +2,7 @@ import { applyConfig, handleZodError } from "@/api"; import { errorResponse, redirect, response } from "@/response"; import type { Hono } from "@hono/hono"; import { zValidator } from "@hono/zod-validator"; +import { getLogger } from "@logtape/logtape"; import { SignatureConstructor } from "@lysand-org/federation"; import { z } from "zod"; import { config } from "~/packages/config-manager"; @@ -83,13 +84,23 @@ export default (app: Hono) => reqUrl.protocol = "https:"; } - const { headers } = await ( + const { headers, signedString } = await ( await SignatureConstructor.fromStringKey( user.data.privateKey ?? "", user.getUri(), ) ).sign("POST", reqUrl, userString); + if (config.debug.federation) { + const logger = getLogger("federation"); + + // Log public key + logger.debug`Sender public key: ${user.data.publicKey}`; + + // Log signed string + logger.debug`Signed string:\n${signedString}`; + } + return response(userString, 200, { "Content-Type": "application/json", ...headers.toJSON(),