File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ import {
1010// Define the port to listen on 
1111const  PORT  =  3000 ; 
1212
13+ // Cache for verification keys to improve performance 
14+ let  verificationKeysCache  =  {  id : "" ,  keys : [ ]  } ; 
15+ 
1316// Define the handler function 
1417async  function  handler ( request ,  response )  { 
1518  console . log ( `Received [${ request . method }  ] to [${ request . url }  ]` ) ; 
@@ -36,15 +39,18 @@ async function handler(request, response) {
3639  const  keyID  =  String ( request . headers [ "github-public-key-identifier" ] ) ; 
3740
3841  try  { 
39-     const  {  isValidRequest,  payload }  =  await  verifyAndParseRequest ( 
42+     const  {  isValidRequest,  payload,  cache  }  =  await  verifyAndParseRequest ( 
4043      body , 
4144      signature , 
4245      keyID , 
4346      { 
4447        token : tokenForUser , 
48+         cache : verificationKeysCache ,  
4549      } , 
4650    ) ; 
4751
52+     verificationKeysCache  =  cache ; 
53+ 
4854    if  ( ! isValidRequest )  { 
4955      console . error ( "Request verification failed" ) ; 
5056      response . writeHead ( 401 ,  {  "Content-Type" : "text/plain"  } ) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments