Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

472 B
Raw Blame
import jwt from 'jsonwebtoken';

export function getValidOpenIdReuseUserId(
  openidUserId: string | undefined,
  secret: string | undefined = process.env.JWT_REFRESH_SECRET,
): string | null {
  if (!openidUserId || !secret) {
    return null;
  }

  try {
    const payload = jwt.verify(openidUserId, secret);
    return typeof payload === 'object' && payload != null && typeof payload.id === 'string'
      ? payload.id
      : null;
  } catch {
    return null;
  }
}