/**
 * Dev-Helper: generates a local JWT signed with MAILFORGE_JWT_SECRET, using
 * the same `signJwt` path the production code uses. Avoids encoding pitfalls
 * (TextEncoder vs hex-decoded Buffer).
 *
 *   npm run dev-jwt
 *   open "http://localhost:3000/?token=$(npm run -s dev-jwt)"
 */

import { signJwt } from '@/core/auth/jwt';

async function main(): Promise<void> {
  const token = await signJwt(
    {
      userId: 'dev-user',
      workspaceIds: ['demo'],
      permissions: ['email:send'],
      displayName: 'Dev User',
    },
    7200,
  );
  process.stdout.write(token);
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
