2025-06-15 04:38:20 +02:00
|
|
|
import { config } from "@versia-server/config";
|
2025-06-15 23:50:34 +02:00
|
|
|
import { apiRoute } from "@versia-server/kit/api";
|
2025-03-29 03:30:06 +01:00
|
|
|
import { describeRoute } from "hono-openapi";
|
|
|
|
|
import { resolver } from "hono-openapi/zod";
|
|
|
|
|
import { z } from "zod";
|
2023-10-16 19:39:41 +02:00
|
|
|
|
2025-03-29 03:30:06 +01:00
|
|
|
export default apiRoute((app) =>
|
|
|
|
|
app.get(
|
|
|
|
|
"/.well-known/host-meta",
|
|
|
|
|
describeRoute({
|
|
|
|
|
summary: "Well-known host-meta",
|
|
|
|
|
tags: ["Federation"],
|
|
|
|
|
responses: {
|
|
|
|
|
200: {
|
|
|
|
|
description: "Host-meta",
|
|
|
|
|
content: {
|
|
|
|
|
"application/xrd+xml": {
|
|
|
|
|
schema: resolver(z.any()),
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-09-16 15:29:09 +02:00
|
|
|
},
|
|
|
|
|
},
|
2025-03-29 03:30:06 +01:00
|
|
|
}),
|
|
|
|
|
(context) => {
|
|
|
|
|
context.header("Content-Type", "application/xrd+xml");
|
|
|
|
|
context.status(200);
|
2024-09-16 15:29:09 +02:00
|
|
|
|
2025-03-29 03:30:06 +01:00
|
|
|
return context.body(
|
|
|
|
|
`<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" template="${new URL(
|
|
|
|
|
"/.well-known/webfinger",
|
|
|
|
|
config.http.base_url,
|
|
|
|
|
).toString()}?resource={uri}"/></XRD>`,
|
|
|
|
|
200,
|
|
|
|
|
// biome-ignore lint/suspicious/noExplicitAny: Hono doesn't type this response so this has a TS error, it's joever
|
|
|
|
|
) as any;
|
|
|
|
|
},
|
|
|
|
|
),
|
2024-08-19 20:06:38 +02:00
|
|
|
);
|