(rawToken: string)
| 204 | // Revokes an access token or refresh token by hashing it and deleting the DB record. |
| 205 | // Per RFC 7009, revocation always succeeds even if the token doesn't exist. |
| 206 | export async function revokeToken(rawToken: string): Promise<void> { |
| 207 | if (rawToken.startsWith(OAUTH_ACCESS_TOKEN_PREFIX)) { |
| 208 | const secret = rawToken.slice(OAUTH_ACCESS_TOKEN_PREFIX.length); |
| 209 | const hash = hashSecret(secret); |
| 210 | await __unsafePrisma.oAuthToken.deleteMany({ where: { hash } }); |
| 211 | } else if (rawToken.startsWith(OAUTH_REFRESH_TOKEN_PREFIX)) { |
| 212 | const secret = rawToken.slice(OAUTH_REFRESH_TOKEN_PREFIX.length); |
| 213 | const hash = hashSecret(secret); |
| 214 | await __unsafePrisma.oAuthRefreshToken.deleteMany({ where: { hash } }); |
| 215 | } |
| 216 | } |
no test coverage detected