// @blocklet/sdk/lib/middlewares shim
export function csrf() {
  return (_req: any, _res: any, next: any) => next();
}

export function auth(options?: { roles?: string[] }) {
  return (req: any, res: any, next: any) => {
    if (!options?.roles) return next();
    if (!req.user?.did) return res.status(401).json({ error: 'Login required' });
    if (!options.roles.includes(req.user.role)) {
      return res.status(403).json({ error: 'Insufficient permissions' });
    }
    next();
  };
}
