@@ -33,6 +33,15 @@ function sha256(buf) {
3333 return crypto . createHash ( "sha256" ) . update ( buf ) . digest ( "hex" ) ;
3434}
3535
36+ function parseChecksumLine ( line ) {
37+ const match = line . trim ( ) . match ( / ^ ( [ a - f A - F 0 - 9 ] { 64 } ) \s + [ * ] ? ( .+ ) $ / ) ;
38+ if ( ! match ) return null ;
39+ return {
40+ hash : match [ 1 ] . toLowerCase ( ) ,
41+ file : match [ 2 ] . trim ( ) ,
42+ } ;
43+ }
44+
3645async function main ( ) {
3746 if ( process . platform !== "win32" ) {
3847 console . error ( "codex-browser-bridge only supports Windows (requires named pipes)." ) ;
@@ -63,17 +72,19 @@ async function main() {
6372 const checksums = await requestBuffer ( checksumsURL ) . catch ( ( err ) => {
6473 throw new Error ( `could not download checksums for ${ tag } : ${ err . message } ` ) ;
6574 } ) ;
66- const line = checksums . toString ( "utf8" ) . split ( / \r ? \n / ) . find ( ( l ) => l . endsWith ( ` ${ asset } ` ) ) ;
67- if ( ! line ) throw new Error ( `checksum not found for ${ asset } in ${ checksumsURL } ` ) ;
68- const expected = line . split ( / \s + / ) [ 0 ] . toLowerCase ( ) ;
75+ const checksum = checksums . toString ( "utf8" )
76+ . split ( / \r ? \n / )
77+ . map ( parseChecksumLine )
78+ . find ( ( entry ) => entry && entry . file === asset ) ;
79+ if ( ! checksum ) throw new Error ( `checksum not found for ${ asset } in ${ checksumsURL } ` ) ;
6980
7081 // Download binary
7182 console . log ( `Downloading codex-browser-bridge ${ tag } (${ arch } )...` ) ;
7283 const binary = await requestBuffer ( `${ base } /${ asset } ` ) ;
7384
7485 // Verify checksum
7586 const actual = sha256 ( binary ) ;
76- if ( actual !== expected ) throw new Error ( `checksum mismatch: expected ${ expected } , got ${ actual } ` ) ;
87+ if ( actual !== checksum . hash ) throw new Error ( `checksum mismatch: expected ${ checksum . hash } , got ${ actual } ` ) ;
7788
7889 // Install
7990 fs . mkdirSync ( binDir , { recursive : true } ) ;
0 commit comments