#!/usr/bin/env node /** * JesusOS original Android / Termux thermal admission probe v1. * Local, read-only snapshot: no network, no child processes, no wallet, * no credentials, no miner activation, no writes and no background polling. * A sensor value alone NEVER authorizes a continuous-mining command. */ import fs from 'node:fs'; import path from 'node:path'; const cap=160; function read(file){ try { const s=fs.lstatSync(file); if(!s.isFile()&&!s.isSymbolicLink())return null; const v=fs.readFileSync(file,'utf8').trim(); return v.length<=cap?v:null; }catch{return null;} } function dirs(root){ try{return fs.readdirSync(root,{withFileTypes:true}) .filter(e=>e.isDirectory()||e.isSymbolicLink()).map(e=>path.join(root,e.name)).slice(0,32);} catch{return [];} } function temperature(raw){ const n=Number(raw); if(raw===null||!Number.isFinite(n))return null; const c=Math.abs(n)>1000?n/1000:Math.abs(n)>125?n/10:n; return c>=-20&&c<=130?Math.round(c*10)/10:null; } const batteries=dirs('/sys/class/power_supply').flatMap(d=>{ const type=read(path.join(d,'type')); if(type?.toLowerCase()!=='battery')return []; const capacity=Number(read(path.join(d,'capacity'))); const charge=read(path.join(d,'status')); return [{batteryPercent:Number.isInteger(capacity)&&capacity>=0&&capacity<=100?capacity:null, batteryTemperatureC:temperature(read(path.join(d,'temp'))), charging:charge==='Charging'||charge==='Full'?true:charge==='Discharging'||charge==='Not charging'?false:null}]; }); const thermal=dirs('/sys/class/thermal').flatMap(d=>{ const label=read(path.join(d,'type')); if(!label||!/^(cpu|soc|ap)[-_a-z0-9]*$/i.test(label))return []; const temp=temperature(read(path.join(d,'temp'))); return temp===null?[]:[{sensorType:'candidate-cpu-or-soc',temperatureC:temp}]; }); const b=batteries.length===1?batteries[0]:null; const cpu=thermal.length===1?thermal[0].temperatureC:null; const blockers=[]; if(!b)blockers.push('one-readable-battery-not-confirmed'); if(!b||b.batteryTemperatureC===null)blockers.push('battery-thermal-unavailable'); if(cpu===null)blockers.push('trusted-device-thermal-unavailable'); if(!b||b.batteryPercent===null)blockers.push('battery-percent-unavailable'); else if(b.batteryPercent<20)blockers.push('battery-below-20-percent'); if(!b||b.charging===null)blockers.push('charging-state-unavailable'); if(b?.charging===false&&b.batteryPercent!==null&&b.batteryPercent<50)blockers.push('battery-conservation'); if(b?.batteryTemperatureC!==null&&b?.batteryTemperatureC!==undefined&&b.batteryTemperatureC>=42)blockers.push('battery-too-hot'); if(cpu!==null&&cpu>=65)blockers.push('candidate-device-too-hot'); if(thermal.length!==1)blockers.push('cpu-sensor-identity-ambiguous'); const output={ schema:'jesusos.bitcoin.termux.thermal-preflight.v1', mode:'read-only-local', source:'unattested-android-sysfs', observedAt:new Date().toISOString(), batteryPercent:b?.batteryPercent??null, batteryTemperatureC:b?.batteryTemperatureC??null, charging:b?.charging??null, candidateCpuOrSocTemperatureC:cpu, candidateCpuOrSocSensorCount:thermal.length, hardwareMeasurementsComplete:blockers.length===0, continuousMiningPermitted:false, activeWorkerVerified:false,ownerConsentVerified:false, authenticatedDeviceVerified:false,sourcePinnedWorkerVerified:false, physicalSensorIdentityIndependentlyVerified:false, bitcoinPayoutVerified:false, blockers:blockers.concat('independent-owner-consent-and-worker-stop-controls-not-verified') }; console.log(JSON.stringify(output,null,2));