Release v0.7.0 - Automatic pairing and validated MA audio playback
Validate and generate manual release / package (push) Waiting to run
Validate and generate manual release / package (push) Waiting to run
This commit is contained in:
1 parent
83d168f5a1
commit
1ed30567fb
48 files changed
+2717
-742
No files matched your search
@@ -0,0 +1,39 @@
|
||||
// Authorized read-only real-origin browser check. Private inputs/results stay .local.
|
||||
import {readFile,writeFile,chmod} from 'node:fs/promises';
|
||||
const {chromium,firefox}=await import(process.env.AM_PLAYWRIGHT_MODULE??'playwright');
|
||||
import {loadMAToken} from '../gateway/private-config.mjs';
|
||||
const config=JSON.parse(await readFile('.local/live-environment.json','utf8')),token=await loadMAToken('.local');
|
||||
const report={at:new Date().toISOString(),scope:'actual origins, read-only API authentication; Ubuntu browsers, not Mac',browsers:[]};
|
||||
for(const [name,type]of (process.env.AM_PRIVATE_ROUTE==='1'?[['chromium',chromium]]:[['firefox',firefox],['chromium',chromium]])){
|
||||
const browser=await type.launch({headless:true,...(name==='chromium'?{args:['--no-sandbox',...(process.env.AM_PRIVATE_ROUTE==='1'?['--host-resolver-rules=MAP '+new URL(config.ma).hostname+' '+config.proxy_ip]:[])]}: {})});
|
||||
try{
|
||||
for(const origin of ['foundry','ma']){
|
||||
const page=await browser.newPage();const entry={browser:name,version:browser.version(),origin,maRoute:process.env.AM_PRIVATE_ROUTE==='1'&&name==='chromium'?'sandbox DNS override to private proxy; TLS validation unchanged':'normal resolver'};
|
||||
try{
|
||||
const response=await page.goto(config[origin],{waitUntil:'domcontentloaded',timeout:20000});const headers=await response.allHeaders();
|
||||
entry.httpStatus=response.status();entry.csp=headers['content-security-policy']??null;
|
||||
entry.result=await page.evaluate(async({base,token})=>{
|
||||
const meta=[...document.querySelectorAll('meta[http-equiv]')].filter(e=>e.httpEquiv.toLowerCase()==='content-security-policy').map(e=>e.content);
|
||||
const blocked=[];const policy=e=>blocked.push({directive:e.effectiveDirective,disposition:e.disposition});document.addEventListener('securitypolicyviolation',policy);
|
||||
const result=await new Promise(resolve=>{
|
||||
const url=new URL('/ws',base);url.protocol='wss:';let opened=false,settled=false,socket;
|
||||
const finish=result=>{if(settled)return;settled=true;clearTimeout(timer);if(socket){socket.onmessage=socket.onerror=socket.onclose=null;socket.close();}resolve(result);};
|
||||
const timer=setTimeout(()=>finish({stage:opened?'auth-timeout':'upgrade-timeout'}),10000);
|
||||
try{socket=new WebSocket(url);socket.onopen=()=>{opened=true;socket.send(JSON.stringify({message_id:'am-preflight-auth',command:'auth',args:{token}}));};
|
||||
socket.onmessage=e=>{let msg;try{msg=JSON.parse(e.data);}catch{return;}
|
||||
if(msg.message_id==='am-preflight-auth'){
|
||||
if(msg.result?.authenticated!==true){finish({stage:'auth-rejected'});return;}
|
||||
socket.send(JSON.stringify({message_id:'am-preflight-providers',command:'providers',args:{provider_type:'music'}}));
|
||||
}
|
||||
if(msg.message_id==='am-preflight-providers')finish({stage:'authenticated',providerCount:Array.isArray(msg.result)?msg.result.length:null,commandError:msg.error_code??null});
|
||||
};socket.onerror=()=>setTimeout(()=>finish({stage:opened?'socket-error':'upgrade-error'}),100);socket.onclose=e=>finish({stage:opened?'closed-after-open':'closed-before-open',code:e.code});
|
||||
}catch{setTimeout(()=>finish({stage:'constructor-error'}),100);}
|
||||
});document.removeEventListener('securitypolicyviolation',policy);return {...result,metaCSP:meta,blocked,secureContext:isSecureContext};
|
||||
},{base:config.ma,token});
|
||||
}catch{entry.result={stage:'navigation-failed'};}
|
||||
report.browsers.push(entry);await page.close();
|
||||
}
|
||||
}finally{await browser.close();}
|
||||
}
|
||||
await writeFile(process.env.AM_PRIVATE_ROUTE==='1'?'.local/live-browser-private-preflight.json':'.local/live-browser-preflight.json',JSON.stringify(report,null,2)+'\n',{mode:0o600});await chmod('.local/live-browser-preflight.json',0o600);
|
||||
console.log(JSON.stringify(report,null,2));
|
||||
Reference in new issue
Block a user