File tree Expand file tree Collapse file tree
src/infrastructure/verification Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ export function isTlsnVerifierAvailable(): boolean {
8383/** Default max attestation age: 5 minutes. */
8484const DEFAULT_MAX_AGE_SECONDS = 300 ;
8585
86+ /** Timeout for the TLSNotary verifier subprocess (seconds). */
87+ const VERIFIER_TIMEOUT_SECONDS = 60 ;
88+
8689function extractHostname ( url : string ) : string | null {
8790 try {
8891 return new URL ( url ) . hostname ;
@@ -284,7 +287,24 @@ async function runVerifierBinary(
284287 stdout : "pipe" ,
285288 stderr : "pipe" ,
286289 } ) ;
287- await proc . exited ;
290+
291+ const timeoutMs = VERIFIER_TIMEOUT_SECONDS * 1000 ;
292+ let timer : ReturnType < typeof setTimeout > ;
293+ const timedOut = await Promise . race ( [
294+ proc . exited . then ( ( ) => false ) ,
295+ new Promise < boolean > ( ( resolve ) => {
296+ timer = setTimeout ( ( ) => resolve ( true ) , timeoutMs ) ;
297+ } ) ,
298+ ] ) ;
299+ clearTimeout ( timer ! ) ;
300+
301+ if ( timedOut ) {
302+ proc . kill ( ) ;
303+ return {
304+ signatureValid : false ,
305+ error : `verifier timed out after ${ VERIFIER_TIMEOUT_SECONDS } s` ,
306+ } ;
307+ }
288308
289309 if ( proc . exitCode !== 0 ) {
290310 const stderr = await new Response ( proc . stderr ) . text ( ) ;
You can’t perform that action at this time.
0 commit comments