import { z } from "zod/v4"; export const register = z.object({ type: z.literal("register"), username: z.string(), password: z.string() }); export type Register = z.infer; export const offer = z.object({ type: z.literal("offer"), id: z.uuid({ version: "v4" }), offer: z.object({ type: z.literal("offer"), sdp: z.string() }) }); export type Offer = z.infer; export const answer = z.object({ type: z.literal("answer"), id: z.uuid({ version: "v4" }), answer: z.object({ type: z.literal("answer"), sdp: z.string() }) }); export type Answer = z.infer; export const candidate = z.object({ type: z.literal("candidate"), id: z.uuid({ version: "v4" }), candidate: z.looseObject({ candidate: z.string() }) }); export type Candidate = z.infer; export const schemas = z.union([ register, offer, answer, candidate ]); export type Message = z.infer;