30 lines
642 B
TypeScript
30 lines
642 B
TypeScript
/**
|
|
* Interface of the server (auto-generated code)
|
|
*/
|
|
import { z as zod } from "zod";
|
|
|
|
import {ZodLong} from "./long";
|
|
|
|
export const ZodJwtPayload = zod.object({
|
|
sub: zod.string(),
|
|
application: zod.string(),
|
|
iss: zod.string(),
|
|
right: zod.record(zod.string(), zod.record(zod.string(), ZodLong)),
|
|
login: zod.string(),
|
|
exp: ZodLong,
|
|
iat: ZodLong,
|
|
|
|
});
|
|
|
|
export type JwtPayload = zod.infer<typeof ZodJwtPayload>;
|
|
|
|
export function isJwtPayload(data: any): data is JwtPayload {
|
|
try {
|
|
ZodJwtPayload.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodJwtPayload' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|