diff --git a/httpd-client/lib/session.ts b/httpd-client/lib/session.ts index dbec35d28..93a1eedb2 100644 --- a/httpd-client/lib/session.ts +++ b/httpd-client/lib/session.ts @@ -1,11 +1,19 @@ import type { Fetcher, RequestOptions } from "./fetcher.js"; import type { SuccessResponse } from "./shared.js"; -import type { ZodSchema } from "zod"; +import type { ZodSchema, z } from "zod"; import { number, object, string } from "zod"; import { successResponseSchema } from "./shared.js"; +export const sessionPayloadSchema = object({ + sessionId: string(), + signature: string(), + publicKey: string(), +}); + +export type SessionPayload = z.infer; + interface Session { sessionId: string; status: string; @@ -40,6 +48,17 @@ export class Client { ); } + public async create(options?: RequestOptions): Promise { + return this.#fetcher.fetchOk( + { + method: "POST", + path: "sessions", + options, + }, + sessionSchema, + ); + } + public async update( id: string, body: {