type WebgameAuthInfo = {
  uid: string;
  platform: string;
  time: string;
  gkey?: string;
  skey?: string;
  is_adult?: string;
  exts?: string;
};

const TTL_MS = 5 * 60 * 1000;
const cache = new Map<string, { value: WebgameAuthInfo; expireAt: number }>();

export function setWebgameAuthInfo(sign: string, info: WebgameAuthInfo) {
  if (!sign) return;
  cache.set(sign, { value: info, expireAt: Date.now() + TTL_MS });
}

export function getWebgameAuthInfo(sign: string): WebgameAuthInfo | null {
  if (!sign) return null;
  const entry = cache.get(sign);
  if (!entry) return null;
  if (Date.now() > entry.expireAt) {
    cache.delete(sign);
    return null;
  }
  return entry.value;
}

