1import{a as U,b as q,u as D,r as o,j as e,L as B}from"./index-j7I9Tmll.js";import{P as h,d as O}from"./core-g119P-9l.js";/* empty css */function G(){const x=U().pathname.replace(/^\/|\/$/g,""),a=q[x],i=x==="url-to-base64";D({title:`${a.title} | Kernel Tools`,description:a.description,keywords:a.keywords,structuredData:{"@context":"https://schema.org","@type":"SoftwareApplication",name:a.title,description:a.description,applicationCategory:"DeveloperApplication",operatingSystem:"Any",url:`https://kerneltools.dev/${x}`}});const[y,f]=o.useState(""),[g,v]=o.useState("GET"),[T,R]=o.useState("*/*"),[r,k]=o.useState(null),[s,p]=o.useState({busy:!1,error:"",result:null}),b=o.useRef(null),d=o.useRef(0),w=o.useRef([]),S=()=>{var t;d.current++,(t=b.current)==null||t.abort(),b.current=null,w.current.forEach(n=>URL.revokeObjectURL(n)),w.current=[]},l=()=>{S(),p({busy:!1,error:"",result:null})};o.useEffect(()=>{const t=new AbortController;return fetch("/api/base64-request",{cache:"no-store",signal:t.signal}).then(async n=>{if(!n.ok)throw new Error;const c=await n.json();t.signal.aborted||k(c)}).catch(()=>{t.signal.aborted||k({enabled:!1,allowedHosts:[],error:"The remote-request service is unavailable."})}),()=>{t.abort(),S()}},[]);const N=async t=>{if(t.preventDefault(),l(),!(r!=null&&r.enabled))return;const n=d.current,c=new AbortController;b.current=c,p({busy:!0,error:"",result:null});const A=setTimeout(()=>c.abort(),2e4);try{const m=await fetch("/api/base64-request",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",signal:c.signal,body:JSON.stringify({url:y,method:i?"GET":g,headers:{Accept:T}})}),u=await m.json();if(n!==d.current)return;if(!m.ok)throw new Error(u.error||"Request failed.");const j=O(u.base64),E=URL.createObjectURL(new Blob([j],{type:"application/octet-stream"})),C=URL.createObjectURL(new Blob([u.base64],{type:"text/plain;charset=utf-8"}));w.current.push(E,C);const L=i?u.base64:new TextDecoder().decode(j.subarray(0,h*4));p({busy:!1,error:"",result:{...u,download:E,encodedDownload:C,preview:L.slice(0,h),truncated:L.length>h||!i&&j.length>h*4}})}catch(m){n===d.current&&p({busy:!1,error:c.signal.aborted?"Request timed out. Try again.":m.message,result:null})}finally{clearTimeout(A),n===d.current&&(b.current=null)}};return e.jsxs("div",{className:"base64-page",children:[e.jsx(B,{className:"base64-back",to:"/base64-tools",children:"â All Base64 tools"}),e.jsxs("header",{className:"base64-heading",children:[e.jsx("span",{className:"base64-eyebrow",children:"REMOTE RESOURCE TOOLS"}),e.jsx("h1",{children:a.title}),e.jsx("p",{children:a.description})]}),e.jsxs("section",{className:"base64-info",children:[e.jsx("h2",{children:"A request leaves your browser"}),e.jsx("p",{children:"When you press Send request, the URL and Accept header go to the Kernel Tools server, which contacts the selected host. Do not include secrets in the URL. This tool supports read-only GET and HEAD requests with no credentials or request bodies."}),e.jsx("p",{children:"Responses are limited to 2 MiB and 15 seconds. Redirects are refused. Response content is shown as inert text; binary downloads preserve the received bytes."})]}),e.jsxs("form",{className:"base64-workspace",onSubmit:N,children:[e.jsx("p",{role:"status",children:r?r.enabled?`Allowed destinations: ${r.allowedHosts.join(", ")}`:r.error||"Remote requests are disabled until the operator configures trusted destinations.":"Checking available destinationsâ¦"}),e.jsx("label",{htmlFor:"base64-network-url",children:"Public HTTPS URL"}),e.jsx("input",{id:"base64-network-url",type:"url",required:!0,maxLength:2048,value:y,onChange:t=>{l(),f(t.target.value)},placeholder:"https://allowed-host.example/resource",autoComplete:"off"}),!i&&e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"base64-network-method",children:"Method"}),e.jsxs("select",{id:"base64-network-method",value:g,onChange:t=>{l(),v(t.target.value)},children:[e.jsx("option",{children:"GET"}),e.jsx("option",{children:"HEAD"})]})]}),e.jsx("label",{htmlFor:"base64-network-accept",children:"Accept header"}),e.jsx("input",{id:"base64-network-accept",maxLength:4096,value:T,onChange:t=>{l(),R(t.target.value)},autoComplete:"off"}),e.jsxs("div",{className:"base64-actions",children:[e.jsx("button",{className:"btn btn-primary",type:"submit",disabled:!(r!=null&&r.enabled)||s.busy,children:"Send request"}),s.busy&&e.jsx("button",{className:"btn btn-ghost",type:"button",onClick:l,children:"Cancel"}),e.jsx("button",{className:"btn btn-ghost",type:"button",onClick:()=>{l(),f(""),R("*/*"),v("GET")},children:"Clear"})]}),s.busy&&e.jsx("p",{role:"status",children:"Waiting for the remote responseâ¦"}),s.error&&e.jsx("p",{role:"alert",className:"base64-error",children:s.error}),s.result&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{role:"status",children:["HTTP ",s.result.status," ",s.result.statusText," · ",s.result.bytes.toLocaleStr
1ing()," bytes · ",s.result.contentType]}),e.jsx("label",{htmlFor:"base64-network-output",children:i?"Base64 preview":"Response preview (UTF-8; binary bytes may appear as replacement characters)"}),e.jsx("textarea",{id:"base64-network-output",readOnly:!0,value:s.result.preview,spellCheck:"false"}),s.result.truncated&&e.jsxs("p",{children:["The preview is limited to ",h.toLocaleString()," characters. Downloads contain the complete result."]}),e.jsxs("div",{className:"base64-actions",children:[e.jsx("a",{className:"btn btn-primary",href:s.result.encodedDownload,download:"response.base64.txt",children:"Download Base64"}),e.jsx("a",{className:"btn btn-ghost",href:s.result.download,download:"response.bin",children:"Download response bytes"})]})]})]}),e.jsxs("section",{className:"base64-info",children:[e.jsx("h2",{children:"How to use this tool"}),e.jsxs("ol",{children:[e.jsx("li",{children:"Enter a resource on one of the allowed HTTPS hosts."}),e.jsx("li",{children:"Choose a read-only method and press Send request."}),e.jsx("li",{children:"Inspect the status and preview, then download the bytes or Base64."})]}),e.jsx("h2",{children:"Why are some URLs unavailable?"}),e.jsx("p",{children:"The service only contacts operator-vetted hosts. It cannot access private networks, authenticate to remote accounts, or follow redirects. Base64 encoding does not encrypt the response."})]})]})}export{G as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.