import { buildContract } from '@jig-software/trest-core';
import { z } from 'zod';

export const GetInfoResult = z.object({
  acceptedHosts: z.array(z.string()),
  clientId: z.string(),
  publicKey: z.string(),
  acceptRegistration: z.boolean(),
});
export type getInfoResult = z.infer<typeof GetInfoResult>;

export const infoContract = buildContract((c) =>
  c
    .parse((p) =>
      p.error.text(500).error.text(400).error.text(401).error.text(403),
    )
    .endpoints({
      getInfo: (e) =>
        e.method('GET').parse((p) => p.success.object(200, GetInfoResult)),
    }),
);
