@@ -96,24 +96,24 @@ test('installer files are written without UTF-8 BOM', () => {
9696 assert . notDeepEqual ( [ ...firstBytes ( shPath , 3 ) ] , [ 0xef , 0xbb , 0xbf ] ) ;
9797} ) ;
9898
99- test ( 'Vercel static-path headers match the dynamic endpoint contract' , ( ) => {
99+ test ( 'Vercel routes explicit installer paths through the secured API contract' , ( ) => {
100100 const config = JSON . parse ( read ( vercelPath ) ) ;
101- const stableRef = '23721bb0e7b561a7deb356656a7e2e3a879bc086 ' ;
101+ const stableRef = '9fefa8fd8162024649aed2132b2770240fba2bc9 ' ;
102102 assert . equal ( config . env . CONTEXA_STABLE_INSTALLER_REF , stableRef ) ;
103+ assert . equal ( config . redirects , undefined ,
104+ 'direct redirects bypass the API response security headers' ) ;
105+ assert . ok ( config . rewrites . some ( entry =>
106+ entry . source === '/(.*)' && entry . destination === '/api' ) ) ;
103107 for ( const route of [ '/install.ps1' , '/install.sh' ] ) {
104- const redirect = config . redirects . find ( candidate => candidate . source === route ) ;
105- assert . ok ( redirect , `missing stable-channel redirect for ${ route } ` ) ;
106- assert . equal ( redirect . destination , `https://raw.githubusercontent.com/contexa-security/install-ctxa/${ stableRef } ${ route } ` ) ;
107- assert . equal ( redirect . permanent , false ) ;
108108 const entry = config . headers . find ( candidate => candidate . source === route ) ;
109109 assert . ok ( entry , `missing Vercel header contract for ${ route } ` ) ;
110- const headers = Object . fromEntries ( entry . headers . map ( header => [ header . key . toLowerCase ( ) , header . value ] ) ) ;
110+ const headers = Object . fromEntries (
111+ entry . headers . map ( header => [ header . key . toLowerCase ( ) , header . value ] ) ) ;
111112 assert . equal ( headers [ 'content-type' ] , 'text/plain; charset=utf-8' ) ;
112113 assert . equal ( headers [ 'cache-control' ] , 'no-store' ) ;
113114 assert . equal ( headers [ 'x-content-type-options' ] , 'nosniff' ) ;
114115 }
115116} ) ;
116-
117117test ( 'api prioritizes explicit paths and exposes immutable version URLs' , ( ) => {
118118 function invoke ( url , ua = '' ) {
119119 const headers = { } ;
@@ -143,17 +143,21 @@ test('api prioritizes explicit paths and exposes immutable version URLs', () =>
143143 const immutable = invoke ( '/v9.9.9-installer-test/install.ps1' ) ;
144144 assert . equal ( immutable . statusCode , 302 ) ;
145145 assert . equal ( immutable . headers . location , 'https://raw.githubusercontent.com/contexa-security/install-ctxa/v9.9.9-installer-test/install.ps1' ) ;
146+ assert . equal ( immutable . headers [ 'content-type' ] , 'text/plain; charset=utf-8' ) ;
146147 assert . equal ( immutable . headers [ 'cache-control' ] , 'public, max-age=31536000, immutable' ) ;
148+ assert . equal ( immutable . headers [ 'x-content-type-options' ] , 'nosniff' ) ;
147149 const caseSensitiveTag = invoke ( '/v9.9.9-Installer-Test/install.sh' ) ;
148150 assert . equal ( caseSensitiveTag . headers . location , 'https://raw.githubusercontent.com/contexa-security/install-ctxa/v9.9.9-Installer-Test/install.sh' ) ;
149151
150152 const originalStableRef = process . env . CONTEXA_STABLE_INSTALLER_REF ;
151153 try {
152- process . env . CONTEXA_STABLE_INSTALLER_REF = '23721bb0e7b561a7deb356656a7e2e3a879bc086 ' ;
154+ process . env . CONTEXA_STABLE_INSTALLER_REF = '9fefa8fd8162024649aed2132b2770240fba2bc9 ' ;
153155 const stable = invoke ( '/' , 'WindowsPowerShell/5.1' ) ;
154156 assert . equal ( stable . statusCode , 302 ) ;
155- assert . equal ( stable . headers . location , 'https://raw.githubusercontent.com/contexa-security/install-ctxa/23721bb0e7b561a7deb356656a7e2e3a879bc086/install.ps1' ) ;
157+ assert . equal ( stable . headers . location , 'https://raw.githubusercontent.com/contexa-security/install-ctxa/9fefa8fd8162024649aed2132b2770240fba2bc9/install.ps1' ) ;
158+ assert . equal ( stable . headers [ 'content-type' ] , 'text/plain; charset=utf-8' ) ;
156159 assert . equal ( stable . headers [ 'cache-control' ] , 'no-store' ) ;
160+ assert . equal ( stable . headers [ 'x-content-type-options' ] , 'nosniff' ) ;
157161 } finally {
158162 if ( originalStableRef === undefined ) delete process . env . CONTEXA_STABLE_INSTALLER_REF ;
159163 else process . env . CONTEXA_STABLE_INSTALLER_REF = originalStableRef ;
0 commit comments