import { ObjectId } from 'bson';
import { z } from 'zod';

export const TokenPrivilege = z.object({
  grantedBy: z.string(),
  privilege: z.string(),
});
export type TokenPrivilege = z.infer<typeof TokenPrivilege>;

export interface TokenPayload {
  userId: string;
  name: string;
  username: string;
  allowRefresh: boolean;
  lifeTime?: number;
  privileges: TokenPrivilege[];
}

export interface SignPayload {
  audience: string;
  userId: ObjectId;
  name: string;
  username: string;
  lifeTime?: number;
  privileges: { grantedBy: string; privilege: string }[];
  allowRefresh: boolean;
}
