Skip to content

feat: add cookie health check and safe cookie rotation workflow - #2

Open
lumishoang wants to merge 2 commits into
leninug:mainfrom
lumishoang:feat/cookie-rotation-health
Open

feat: add cookie health check and safe cookie rotation workflow#2
lumishoang wants to merge 2 commits into
leninug:mainfrom
lumishoang:feat/cookie-rotation-health

Conversation

@lumishoang

Copy link
Copy Markdown

Summary

This PR adds a safer, operator-friendly cookie rotation flow for Twitter auth stability.

Added

  • npm run cookie:check (src/cookie-check.mjs)
    • Validates cookie file structure and performs a lightweight auth health-check.
  • npm run cookie:replace -- <path> (src/replace-cookies.mjs)
    • Validates incoming cookie file (auth_token, ct0)
    • Backs up current data/cookies.json to data/backups/
    • Health-checks new cookie file before atomic swap
    • Leaves current cookie untouched on failure
  • src/lib/cookie-health.mjs
    • Shared validation + health-check + error classification logic

Runtime hardening

  • Startup preflight in src/index.mjs now checks cookie health first.
  • Bot exits early with clear Telegram alert when cookie/auth is invalid.

Docs

  • Added guides/05-cookie-rotation.md
  • README now includes cookie check/replace commands

Why

Current flow detects session-expiry after failures. This PR adds proactive and safe rotation with lower operational risk.

Backward compatibility

  • Existing npm start and setup flow remain intact.
  • New commands are additive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant