Token Issuance
Issuing audience-bound Bearer access tokens and atomically rotating refresh tokens via POST /oauth/token.
Opaque Hashed Storage in taicket_mcp
Taicket issues high-entropy opaque bearer tokens rather than self-contained JWTs. Plaintext tokens are returned once in the HTTP response and discarded from memory immediately. Only the SHA-256 hex digest (tokenHash), a short prefix (tokenPrefix), and the trailing four characters (tokenLast4) are stored in McpAccessToken and McpRefreshToken inside the dedicated taicket_mcp database.
Opaque database-backed tokens guarantee instant revocation with zero clock-skew or JWT revocation-list lag, and prevent server IDs, scopes, or Discord identifiers from leaking inside base64-decoded token headers.
Atomic Refresh Token Rotation & Replay Detection
Refresh tokens rotate on every use via an atomic MongoDB compare-and-swap update: findOneAndUpdate({ tokenHash, revokedAt: null, rotatedAt: null }, { $set: { rotatedAt: now, replacedByHash } }). Only one concurrent refresh call can succeed for a given token hash.
POST /oauth/token HTTP/1.1
Host: mcp.taicket.xyz
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&refresh_token=tmcp_rt_3d7c9e2a1b4f5082e6a9c0d1f2e3b4a5&client_id=dcr_9f4b2a1c8e7d6053a1b2c3d4&resource=https%3A%2F%2Fmcp.taicket.xyz%2FmcpIf the atomic update returns null and the submitted refresh token hash exists with rotatedAt != null, Taicket classifies the request as refresh token replay and immediately revokes the entire familyId across McpOAuthGrant, McpAccessToken, and McpRefreshToken. Both the attacker and the legitimate client are forced to re-authenticate through Discord consent.
{
"error": "invalid_grant",
"error_description": "Refresh token reuse detected. The authorization grant has been revoked."
}