99 InvalidRequestError ,
1010 ServerError ,
1111 TooManyRequestsError ,
12- OAuthError
12+ OAuthError ,
1313} from "../errors.js" ;
1414
1515export type RevocationHandlerOptions = {
@@ -21,7 +21,10 @@ export type RevocationHandlerOptions = {
2121 rateLimit ?: Partial < RateLimitOptions > | false ;
2222} ;
2323
24- export function revocationHandler ( { provider, rateLimit : rateLimitConfig } : RevocationHandlerOptions ) : RequestHandler {
24+ export function revocationHandler ( {
25+ provider,
26+ rateLimit : rateLimitConfig ,
27+ } : RevocationHandlerOptions ) : RequestHandler {
2528 if ( ! provider . revokeToken ) {
2629 throw new Error ( "Auth provider does not support revoking tokens" ) ;
2730 }
@@ -37,21 +40,25 @@ export function revocationHandler({ provider, rateLimit: rateLimitConfig }: Revo
3740
3841 // Apply rate limiting unless explicitly disabled
3942 if ( rateLimitConfig !== false ) {
40- router . use ( rateLimit ( {
41- windowMs : 15 * 60 * 1000 , // 15 minutes
42- max : 50 , // 50 requests per windowMs
43- standardHeaders : true ,
44- legacyHeaders : false ,
45- message : new TooManyRequestsError ( 'You have exceeded the rate limit for token revocation requests' ) . toResponseObject ( ) ,
46- ...rateLimitConfig
47- } ) ) ;
43+ router . use (
44+ rateLimit ( {
45+ windowMs : 15 * 60 * 1000 , // 15 minutes
46+ max : 50 , // 50 requests per windowMs
47+ standardHeaders : true ,
48+ legacyHeaders : false ,
49+ message : new TooManyRequestsError (
50+ "You have exceeded the rate limit for token revocation requests"
51+ ) . toResponseObject ( ) ,
52+ ...rateLimitConfig ,
53+ } )
54+ ) ;
4855 }
4956
5057 // Authenticate and extract client details
5158 router . use ( authenticateClient ( { clientsStore : provider . clientsStore } ) ) ;
5259
5360 router . post ( "/" , async ( req , res ) => {
54- res . setHeader ( ' Cache-Control' , ' no-store' ) ;
61+ res . setHeader ( " Cache-Control" , " no-store" ) ;
5562
5663 try {
5764 const parseResult = OAuthTokenRevocationRequestSchema . safeParse ( req . body ) ;
@@ -62,7 +69,6 @@ export function revocationHandler({ provider, rateLimit: rateLimitConfig }: Revo
6269 const client = req . client ;
6370 if ( ! client ) {
6471 // This should never happen
65- console . error ( "Missing client information after authentication" ) ;
6672 throw new ServerError ( "Internal Server Error" ) ;
6773 }
6874
@@ -73,7 +79,6 @@ export function revocationHandler({ provider, rateLimit: rateLimitConfig }: Revo
7379 const status = error instanceof ServerError ? 500 : 400 ;
7480 res . status ( status ) . json ( error . toResponseObject ( ) ) ;
7581 } else {
76- console . error ( "Unexpected error revoking token:" , error ) ;
7782 const serverError = new ServerError ( "Internal Server Error" ) ;
7883 res . status ( 500 ) . json ( serverError . toResponseObject ( ) ) ;
7984 }
0 commit comments