decentralised sync engine

feat: temporary testing route for handshake

serenity a4d055b3 ae576761

Changed files
+32
src
routes
testing
+2
src/routes/index.ts
···
import type { Route, WsRoute } from "@/lib/types/routes";
import { didWebDocRoute } from "@/routes/dot-well-known/did-dot-json/route";
import { indexRoute } from "@/routes/route";
export const routes: Record<string, Route | WsRoute> = {
"/": indexRoute,
"/.well-known/did.json": didWebDocRoute,
};
···
import type { Route, WsRoute } from "@/lib/types/routes";
import { didWebDocRoute } from "@/routes/dot-well-known/did-dot-json/route";
import { indexRoute } from "@/routes/route";
+
import { testingRoute } from "@/routes/testing/route";
export const routes: Record<string, Route | WsRoute> = {
"/": indexRoute,
"/.well-known/did.json": didWebDocRoute,
+
"/testing": testingRoute,
};
+30
src/routes/testing/route.ts
···
···
+
import type { Route } from "@/lib/types/routes";
+
import { initiateHandshakeTo } from "@/lib/utils/handshake";
+
import {
+
newErrorResponse,
+
newSuccessResponse,
+
} from "@/lib/utils/http/responses";
+
+
export const testingRoute: Route = {
+
method: "GET",
+
handler: async () => {
+
const sessionInfo = await initiateHandshakeTo({
+
did: "did:web:localhost%3A7337",
+
channels: [
+
{
+
authority: "did:plc:knucpdtudgdpyoeydicvhzel",
+
collection: "systems.gmstn.development.channel",
+
rKey: "3m3tpcwneq22e",
+
},
+
],
+
});
+
if (!sessionInfo.ok)
+
return newErrorResponse(400, {
+
message: "something went wrong with the handshake.",
+
details: sessionInfo.error,
+
});
+
return newSuccessResponse({
+
sessionInfo: sessionInfo.data,
+
});
+
},
+
};