mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
Add a create method to the session.Client
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
@@ -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<typeof sessionPayloadSchema>;
|
||||
|
||||
interface Session {
|
||||
sessionId: string;
|
||||
status: string;
|
||||
@@ -40,6 +48,17 @@ export class Client {
|
||||
);
|
||||
}
|
||||
|
||||
public async create(options?: RequestOptions): Promise<Session> {
|
||||
return this.#fetcher.fetchOk(
|
||||
{
|
||||
method: "POST",
|
||||
path: "sessions",
|
||||
options,
|
||||
},
|
||||
sessionSchema,
|
||||
);
|
||||
}
|
||||
|
||||
public async update(
|
||||
id: string,
|
||||
body: {
|
||||
|
||||
Reference in New Issue
Block a user