INNER CODE UNIT · JavaScript

scheduleTokenExpiry

Adamant-im/adamant-tradebot · api/ws/index.js:37

function scheduleTokenExpiry(socket) {
  const delay = socket.data.tokenExpiresAt - Date.now();

  if (!(delay > 0)) {
    webuiLog.info(`WS token expired user=${socket.data.user?.login || 'unknown'} id=${socket.id}; disconnecting.`);
    socket.disconnect(true);
    return;
  }

  // Delays above the timer limit re-check on wake-up instead of firing immediately
  socket.data.expiryTimer = setTimeout(() => scheduleTokenExpiry(socket), Math.min(delay, MAX_TIMER_DELAY_MS));
  socket.data.expiryTimer.unref?.();
}

/**
 * Registers JWT authentication and params subscription handlers on Socket.IO.
 *
 * Clients authenticate with a JWT signed by the private WebUI (`private_webui_secret_key`) —

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…