Refresh Token Service
Refresh tokens, explained simply:
Think of a refresh token as a long-lived “session receipt” stored in an HttpOnly cookie.
Every time you use it, we swap it for a brand new one (so an old one can’t be reused).
If an old token shows up again, we assume it was stolen and shut down the whole session family.
This in-memory implementation is perfect for dev/single-node. Use Redis/DB for production.
Key ideas:
Each refresh token belongs to a family (one login session) and is bound to a DPoP key thumbprint (jkt).
Rotate-on-use and reuse detection keep sessions safe.
Functions
Revoke a session family by presenting one of its token ids. Handy for logout when we read the cookie value.
Revoke every refresh token in a session family. Use this when we detect reuse or other anomalies.
Use-then-rotate flow for refresh tokens.