/**
 * Interface of the server (auto-generated code)
 */
import { z as zod } from "zod";

import {ZodJwtHeader, ZodJwtHeaderWrite } from "./jwt-header";
import {ZodJwtPayload, ZodJwtPayloadWrite } from "./jwt-payload";

export const ZodJwtToken = zod.object({
	header: ZodJwtHeader,
	payload: ZodJwtPayload,
	signature: zod.string(),

});

export type JwtToken = zod.infer<typeof ZodJwtToken>;

export function isJwtToken(data: any): data is JwtToken {
	try {
		ZodJwtToken.parse(data);
		return true;
	} catch (e: any) {
		console.log(`Fail to parse data type='ZodJwtToken' error=${e}`);
		return false;
	}
}
export const ZodJwtTokenWrite = zod.object({
	header: ZodJwtHeader.optional(),
	payload: ZodJwtPayload.optional(),
	signature: zod.string().optional(),

});

export type JwtTokenWrite = zod.infer<typeof ZodJwtTokenWrite>;

export function isJwtTokenWrite(data: any): data is JwtTokenWrite {
	try {
		ZodJwtTokenWrite.parse(data);
		return true;
	} catch (e: any) {
		console.log(`Fail to parse data type='ZodJwtTokenWrite' error=${e}`);
		return false;
	}
}
