chore(federation): Add sender public key to federation debugging

This commit is contained in:
Jesse Wierzbinski 2024-05-23 19:04:05 -10:00
parent f5605e6814
commit fc98c95892
No known key found for this signature in database
3 changed files with 18 additions and 3 deletions

View file

@ -4,8 +4,6 @@
"jest.rootPath": ".",
"conventionalCommits.scopes": [
"database",
"frontend",
"build",
"api",
"cli",
"federation",

View file

@ -5,6 +5,7 @@ import {
} from "@lysand-org/federation";
import { config } from "config-manager";
import type { User } from "~packages/database-interface/user";
import { LogLevel, LogManager } from "~packages/log-manager";
export const localObjectURI = (id: string) =>
new URL(`/objects/${id}`, config.http.base_url).toString();
@ -48,6 +49,13 @@ export const objectToInboxRequest = async (
if (config.debug.federation) {
// Debug request
await debugRequest(signed);
// Log public key
new LogManager(Bun.stdout).log(
LogLevel.DEBUG,
"Inbox.Signature",
`Sender public key: ${author.getUser().publicKey}`,
);
}
return signed;

View file

@ -22,7 +22,7 @@ import { db } from "~drizzle/db";
import { Notifications, Relationships } from "~drizzle/schema";
import { config } from "~packages/config-manager";
import { User } from "~packages/database-interface/user";
import { LogLevel } from "~packages/log-manager";
import { LogLevel, LogManager } from "~packages/log-manager";
export const meta = applyConfig({
allowedMethods: ["POST"],
@ -143,6 +143,15 @@ export default (app: Hono) =>
return errorResponse("Could not resolve keyId", 400);
}
if (config.debug.federation) {
// Log public key
new LogManager(Bun.stdout).log(
LogLevel.DEBUG,
"Inbox.Signature",
`Sender public key: ${sender.getUser().publicKey}`,
);
}
const validator = await SignatureValidator.fromStringKey(
sender.getUser().publicKey,
);