just-bash 2.13.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +300 -314
- package/dist/bin/chunks/{chunk-3YMCKZTY.js → chunk-FBJJY4ZV.js} +1 -1
- package/dist/bin/chunks/chunk-LIYVQA3X.js +2 -0
- package/dist/bin/chunks/{chunk-N6KA6G3Q.js → chunk-TKTKRRAL.js} +1 -1
- package/dist/bin/chunks/curl-SRTMGOVV.js +26 -0
- package/dist/bin/chunks/{flag-coverage-IRM4GISL.js → flag-coverage-A4G6STMS.js} +1 -1
- package/dist/bin/chunks/{js-exec-YGYYZEEQ.js → js-exec-JORCTVUT.js} +1 -1
- package/dist/bin/chunks/js-exec-worker.js +1 -0
- package/dist/bin/{shell/chunks/python3-WO3WFGMS.js → chunks/python3-PF7AHNQM.js} +1 -1
- package/dist/bin/chunks/time-DDS6JJ23.js +2 -0
- package/dist/bin/chunks/worker.js +1 -0
- package/dist/bin/just-bash.js +178 -178
- package/dist/bin/shell/chunks/{chunk-3YMCKZTY.js → chunk-FBJJY4ZV.js} +1 -1
- package/dist/bin/shell/chunks/chunk-LIYVQA3X.js +2 -0
- package/dist/bin/shell/chunks/{chunk-N6KA6G3Q.js → chunk-TKTKRRAL.js} +1 -1
- package/dist/bin/shell/chunks/curl-SRTMGOVV.js +26 -0
- package/dist/bin/shell/chunks/{flag-coverage-IRM4GISL.js → flag-coverage-A4G6STMS.js} +1 -1
- package/dist/bin/shell/chunks/{js-exec-VYG74FQ3.js → js-exec-B6QNYHUL.js} +1 -1
- package/dist/bin/{chunks/python3-EIXZW3LO.js → shell/chunks/python3-J7DP4JBQ.js} +1 -1
- package/dist/bin/shell/chunks/time-DDS6JJ23.js +2 -0
- package/dist/bin/shell/shell.js +180 -180
- package/dist/bundle/browser.js +485 -485
- package/dist/bundle/chunks/chunk-CWQS3NFK.js +1 -0
- package/dist/bundle/chunks/{chunk-JCMONG3T.js → chunk-F5CMUULS.js} +1 -1
- package/dist/bundle/chunks/{chunk-MJWMXCEJ.js → chunk-H2WXJGD7.js} +1 -1
- package/dist/bundle/chunks/curl-COE4TZE6.js +25 -0
- package/dist/bundle/chunks/{flag-coverage-SPT2DN2I.js → flag-coverage-G2R7PMYU.js} +1 -1
- package/dist/bundle/chunks/{js-exec-R2LSP7M4.js → js-exec-YJSMH5AG.js} +1 -1
- package/dist/bundle/chunks/js-exec-worker.js +1 -0
- package/dist/bundle/chunks/{python3-DH2SBOI3.js → python3-6HF56IYI.js} +1 -1
- package/dist/bundle/chunks/{time-FABCOJJU.js → time-YG5BMRIQ.js} +1 -1
- package/dist/bundle/chunks/worker.js +1 -0
- package/dist/bundle/index.cjs +657 -657
- package/dist/bundle/index.js +118 -118
- package/dist/commands/curl/types.d.ts +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/network/allow-list.d.ts +5 -3
- package/dist/network/fetch.d.ts +1 -1
- package/dist/network/index.d.ts +1 -1
- package/dist/network/types.d.ts +32 -1
- package/package.json +2 -2
- package/dist/bin/chunks/chunk-QZNF3Y3J.js +0 -2
- package/dist/bin/chunks/curl-B64SIJOD.js +0 -26
- package/dist/bin/chunks/time-VSKBXRQH.js +0 -2
- package/dist/bin/shell/chunks/chunk-QZNF3Y3J.js +0 -2
- package/dist/bin/shell/chunks/curl-B64SIJOD.js +0 -26
- package/dist/bin/shell/chunks/time-VSKBXRQH.js +0 -2
- package/dist/bundle/chunks/chunk-RH6GWZAJ.js +0 -1
- package/dist/bundle/chunks/curl-FCIO57JJ.js +0 -25
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as g}from"./chunk-4OALHZXB.js";import{c as u}from"./chunk-
|
|
2
|
+
import{a as g}from"./chunk-4OALHZXB.js";import{c as u}from"./chunk-LIYVQA3X.js";import{a as h}from"./chunk-4PRVMER6.js";import{a as f}from"./chunk-SYG3IW7P.js";var v={name:"time",async execute(r,s){let a="%e %M",o=null,p=!1,c=!1,t=0;for(;t<r.length;){let e=r[t];if(e==="-f"||e==="--format"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-f'
|
|
3
3
|
`,exitCode:1};a=r[t],t++}else if(e==="-o"||e==="--output"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-o'
|
|
4
4
|
`,exitCode:1};o=r[t],t++}else if(e==="-a"||e==="--append")p=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
|
|
5
5
|
Elapsed (wall clock) time: %e seconds
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as F}from"./chunk-4OALHZXB.js";import{a as w,b as n}from"./chunk-
|
|
2
|
+
import{a as F}from"./chunk-4OALHZXB.js";import{a as w,b as n}from"./chunk-LIYVQA3X.js";import{a as T,b as g}from"./chunk-OOJCYVYF.js";import{a as m}from"./chunk-SYG3IW7P.js";var h={NOOP:0,READ_FILE:1,WRITE_FILE:2,STAT:3,READDIR:4,MKDIR:5,RM:6,EXISTS:7,APPEND_FILE:8,SYMLINK:9,READLINK:10,LSTAT:11,CHMOD:12,REALPATH:13,RENAME:14,COPY_FILE:15,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200,EXEC_COMMAND:300},a={PENDING:0,READY:1,SUCCESS:2,ERROR:3},u={NONE:0,NOT_FOUND:1,IS_DIRECTORY:2,NOT_DIRECTORY:3,EXISTS:4,PERMISSION_DENIED:5,INVALID_PATH:6,IO_ERROR:7,TIMEOUT:8,NETWORK_ERROR:9,NETWORK_NOT_CONFIGURED:10},s={OP_CODE:0,STATUS:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,PATH_BUFFER:32,DATA_BUFFER:4128},E={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:1048576,TOTAL:1052704},S={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},l={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};function _(){return new w(E.TOTAL)}var R=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return n.load(this.int32View,s.OP_CODE/4)}setOpCode(t){n.store(this.int32View,s.OP_CODE/4,t)}getStatus(){return n.load(this.int32View,s.STATUS/4)}setStatus(t){n.store(this.int32View,s.STATUS/4,t)}getPathLength(){return n.load(this.int32View,s.PATH_LENGTH/4)}setPathLength(t){n.store(this.int32View,s.PATH_LENGTH/4,t)}getDataLength(){return n.load(this.int32View,s.DATA_LENGTH/4)}setDataLength(t){n.store(this.int32View,s.DATA_LENGTH/4,t)}getResultLength(){return n.load(this.int32View,s.RESULT_LENGTH/4)}setResultLength(t){n.store(this.int32View,s.RESULT_LENGTH/4,t)}getErrorCode(){return n.load(this.int32View,s.ERROR_CODE/4)}setErrorCode(t){n.store(this.int32View,s.ERROR_CODE/4,t)}getFlags(){return n.load(this.int32View,s.FLAGS/4)}setFlags(t){n.store(this.int32View,s.FLAGS/4,t)}getMode(){return n.load(this.int32View,s.MODE/4)}setMode(t){n.store(this.int32View,s.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(s.PATH_BUFFER,s.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>E.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${E.PATH_BUFFER}`);this.uint8View.set(e,s.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(s.DATA_BUFFER,s.DATA_BUFFER+t)}setData(t){if(t.length>E.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${E.DATA_BUFFER}`);this.uint8View.set(t,s.DATA_BUFFER),this.setDataLength(t.length)}getDataAsString(){let t=this.getData();return new TextDecoder().decode(t)}setDataFromString(t){let e=new TextEncoder().encode(t);this.setData(e)}getResult(){let t=this.getResultLength();return this.uint8View.slice(s.DATA_BUFFER,s.DATA_BUFFER+t)}setResult(t){if(t.length>E.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${E.DATA_BUFFER}`);this.uint8View.set(t,s.DATA_BUFFER),this.setResultLength(t.length)}getResultAsString(){let t=this.getResult();return new TextDecoder().decode(t)}setResultFromString(t){let e=new TextEncoder().encode(t);this.setResult(e)}encodeStat(t){this.uint8View[s.DATA_BUFFER+l.IS_FILE]=t.isFile?1:0,this.uint8View[s.DATA_BUFFER+l.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[s.DATA_BUFFER+l.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(s.DATA_BUFFER+l.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(s.DATA_BUFFER+l.SIZE,e,!0),this.dataView.setFloat64(s.DATA_BUFFER+l.MTIME,t.mtime.getTime(),!0),this.setResultLength(l.TOTAL)}decodeStat(){return{isFile:this.uint8View[s.DATA_BUFFER+l.IS_FILE]===1,isDirectory:this.uint8View[s.DATA_BUFFER+l.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[s.DATA_BUFFER+l.IS_SYMLINK]===1,mode:this.dataView.getInt32(s.DATA_BUFFER+l.MODE,!0),size:this.dataView.getFloat64(s.DATA_BUFFER+l.SIZE,!0),mtime:new Date(this.dataView.getFloat64(s.DATA_BUFFER+l.MTIME,!0))}}waitForReady(t){return n.wait(this.int32View,s.STATUS/4,a.PENDING,t)}waitForReadyAsync(t){return n.waitAsync(this.int32View,s.STATUS/4,a.PENDING,t)}async waitUntilReady(t){let e=Date.now();for(;;){let r=this.getStatus();if(r===a.READY)return!0;let o=Date.now()-e;if(o>=t)return!1;let i=t-o,c=n.waitAsync(this.int32View,s.STATUS/4,r,i);if(c.async&&await c.value==="timed-out")return!1}}waitForResult(t){return n.wait(this.int32View,s.STATUS/4,a.READY,t)}notify(){return n.notify(this.int32View,s.STATUS/4)}reset(){this.setOpCode(h.NOOP),this.setStatus(a.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(u.NONE),this.setFlags(S.NONE),this.setMode(0)}};var A=class{fs;cwd;commandName;secureFetch;maxOutputSize;exec;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;startTime=0;timeoutMs=0;constructor(t,e,r,o,i=void 0,c=0,d=void 0){this.fs=e,this.cwd=r,this.commandName=o,this.secureFetch=i,this.maxOutputSize=c,this.exec=d,this.protocol=new R(t)}remainingMs(){return Math.max(0,this.timeoutMs-(Date.now()-this.startTime))}raceDeadline(t){let e=this.remainingMs();if(e<=0)return this.running=!1,this.output.exitCode=124,this.output.stderr+=`
|
|
3
3
|
${this.commandName}: execution timeout exceeded
|
|
4
4
|
`,Promise.reject(new Error("Operation timed out"));let r=t();return new Promise((o,i)=>{let c=T(()=>{this.running=!1,this.output.exitCode=124,this.output.stderr+=`
|
|
5
5
|
${this.commandName}: execution timeout exceeded
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{d}from"./chunk-LIYVQA3X.js";import{a as b}from"./chunk-4VDEBYW7.js";import{a as T,b as w,c as f}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";function c(s){let t=s.indexOf("=");if(t>=0){let a=s.slice(0,t),r=s.slice(t+1);return a?`${encodeURIComponent(a)}=${encodeURIComponent(r)}`:encodeURIComponent(r)}return encodeURIComponent(s)}function m(s){let t=s.indexOf("=");if(t<0)return null;let a=s.slice(0,t),r=s.slice(t+1),e,i,o=r.match(/;type=([^;]+)$/);o&&(i=o[1],r=r.slice(0,-o[0].length));let n=r.match(/;filename=([^;]+)/);return n&&(e=n[1],r=r.replace(n[0],"")),(r.startsWith("@")||r.startsWith("<"))&&(e=e??r.slice(1).split("/").pop()),{name:a,value:r,filename:e,contentType:i}}function v(s,t){let a=`----CurlFormBoundary${Date.now().toString(36)}`,r=[];for(let e of s){let i=e.value;if(i.startsWith("@")||i.startsWith("<")){let n=i.slice(1);i=t.get(n)??""}let o=`--${a}\r
|
|
3
|
+
`;e.filename?(o+=`Content-Disposition: form-data; name="${e.name}"; filename="${e.filename}"\r
|
|
4
|
+
`,e.contentType&&(o+=`Content-Type: ${e.contentType}\r
|
|
5
|
+
`)):o+=`Content-Disposition: form-data; name="${e.name}"\r
|
|
6
|
+
`,o+=`\r
|
|
7
|
+
${i}\r
|
|
8
|
+
`,r.push(o)}return r.push(`--${a}--\r
|
|
9
|
+
`),{body:r.join(""),boundary:a}}var F={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]};function O(s){let t={method:"GET",headers:new d,dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1},a=!1;for(let r=0;r<s.length;r++){let e=s[r];if(e==="-X"||e==="--request")t.method=s[++r]??"GET";else if(e.startsWith("-X"))t.method=e.slice(2);else if(e.startsWith("--request="))t.method=e.slice(10);else if(e==="-H"||e==="--header"){let i=s[++r];if(i){let o=i.indexOf(":");if(o>0){let n=i.slice(0,o).trim(),l=i.slice(o+1).trim();t.headers.append(n,l)}}}else if(e.startsWith("--header=")){let i=e.slice(9),o=i.indexOf(":");if(o>0){let n=i.slice(0,o).trim(),l=i.slice(o+1).trim();t.headers.append(n,l)}}else if(e==="-d"||e==="--data"||e==="--data-raw")t.data=s[++r]??"",a=!0;else if(e.startsWith("-d"))t.data=e.slice(2),a=!0;else if(e.startsWith("--data="))t.data=e.slice(7),a=!0;else if(e.startsWith("--data-raw="))t.data=e.slice(11),a=!0;else if(e==="--data-binary")t.data=s[++r]??"",t.dataBinary=!0,a=!0;else if(e.startsWith("--data-binary="))t.data=e.slice(14),t.dataBinary=!0,a=!0;else if(e==="--data-urlencode"){let i=s[++r]??"";t.data=(t.data?`${t.data}&`:"")+c(i),a=!0}else if(e.startsWith("--data-urlencode=")){let i=e.slice(17);t.data=(t.data?`${t.data}&`:"")+c(i),a=!0}else if(e==="-F"||e==="--form"){let i=s[++r]??"",o=m(i);o&&t.formFields.push(o),a=!0}else if(e.startsWith("--form=")){let i=e.slice(7),o=m(i);o&&t.formFields.push(o),a=!0}else if(e==="-u"||e==="--user")t.user=s[++r];else if(e.startsWith("-u"))t.user=e.slice(2);else if(e.startsWith("--user="))t.user=e.slice(7);else if(e==="-A"||e==="--user-agent")t.headers.set("User-Agent",s[++r]??"");else if(e.startsWith("-A"))t.headers.set("User-Agent",e.slice(2));else if(e.startsWith("--user-agent="))t.headers.set("User-Agent",e.slice(13));else if(e==="-e"||e==="--referer")t.headers.set("Referer",s[++r]??"");else if(e.startsWith("-e"))t.headers.set("Referer",e.slice(2));else if(e.startsWith("--referer="))t.headers.set("Referer",e.slice(10));else if(e==="-b"||e==="--cookie")t.headers.set("Cookie",s[++r]??"");else if(e.startsWith("-b"))t.headers.set("Cookie",e.slice(2));else if(e.startsWith("--cookie="))t.headers.set("Cookie",e.slice(9));else if(e==="-c"||e==="--cookie-jar")t.cookieJar=s[++r];else if(e.startsWith("--cookie-jar="))t.cookieJar=e.slice(13);else if(e==="-T"||e==="--upload-file")t.uploadFile=s[++r],t.method==="GET"&&(t.method="PUT");else if(e.startsWith("--upload-file="))t.uploadFile=e.slice(14),t.method==="GET"&&(t.method="PUT");else if(e==="-m"||e==="--max-time"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--max-time=")){let i=parseFloat(e.slice(11));!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e==="--connect-timeout"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--connect-timeout=")){let i=parseFloat(e.slice(18));!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e==="-o"||e==="--output")t.outputFile=s[++r];else if(e.startsWith("--output="))t.outputFile=e.slice(9);else if(e==="-O"||e==="--remote-name")t.useRemoteName=!0;else if(e==="-I"||e==="--head")t.headOnly=!0,t.method="HEAD";else if(e==="-i"||e==="--include")t.includeHeaders=!0;else if(e==="-s"||e==="--silent")t.silent=!0;else if(e==="-S"||e==="--show-error")t.showError=!0;else if(e==="-f"||e==="--fail")t.failSilently=!0;else if(e==="-L"||e==="--location")t.followRedirects=!0;else if(e==="--max-redirs")r++;else if(!e.startsWith("--max-redirs="))if(e==="-w"||e==="--write-out")t.writeOut=s[++r];else if(e.startsWith("--write-out="))t.writeOut=e.slice(12);else if(e==="-v"||e==="--verbose")t.verbose=!0;else{if(e.startsWith("--")&&e!=="--")return f("curl",e);if(e.startsWith("-")&&e!=="-")for(let i of e.slice(1))switch(i){case"s":t.silent=!0;break;case"S":t.showError=!0;break;case"f":t.failSilently=!0;break;case"L":t.followRedirects=!0;break;case"I":t.headOnly=!0,t.method="HEAD";break;case"i":t.includeHeaders=!0;break;case"O":t.useRemoteName=!0;break;case"v":t.verbose=!0;break;default:return f("curl",`-${i}`)}else e.startsWith("-")||(t.url=e)}}return a&&t.method==="GET"&&(t.method="POST"),t}function h(s){return Object.entries(s).map(([t,a])=>`${t}: ${a}`).join(`\r
|
|
10
|
+
`)}function W(s){try{return new URL(s).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function p(s,t){let a=s;return a=a.replace(/%\{http_code\}/g,String(t.status)),a=a.replace(/%\{content_type\}/g,t.headers["content-type"]||""),a=a.replace(/%\{url_effective\}/g,t.url),a=a.replace(/%\{size_download\}/g,String(t.bodyLength)),a=a.replace(/\\n/g,`
|
|
11
|
+
`),a}async function S(s,t){if(s.uploadFile){let a=t.fs.resolvePath(t.cwd,s.uploadFile);return{body:await t.fs.readFile(a)}}if(s.formFields.length>0){let a=new Map;for(let i of s.formFields)if(i.value.startsWith("@")||i.value.startsWith("<")){let o=t.fs.resolvePath(t.cwd,i.value.slice(1));try{let n=await t.fs.readFile(o);a.set(i.value.slice(1),n)}catch{a.set(i.value.slice(1),"")}}let{body:r,boundary:e}=v(s.formFields,a);return{body:r,contentType:`multipart/form-data; boundary=${e}`}}return s.data!==void 0?{body:s.data}:{}}function E(s,t){let a=new d(s.headers);if(s.user){let r=Buffer.from(s.user).toString("base64");a.set("Authorization",`Basic ${r}`)}return t&&!a.has("Content-Type")&&a.set("Content-Type",t),a}async function P(s,t,a){if(!s.cookieJar)return;let r=t["set-cookie"];if(!r)return;let e=a.fs.resolvePath(a.cwd,s.cookieJar);await a.fs.writeFile(e,r)}function H(s,t,a){let r="";if(s.verbose){r+=`> ${s.method} ${a}
|
|
12
|
+
`;for(let[e,i]of s.headers)r+=`> ${e}: ${i}
|
|
13
|
+
`;r+=`>
|
|
14
|
+
`,r+=`< HTTP/1.1 ${t.status} ${t.statusText}
|
|
15
|
+
`;for(let[e,i]of Object.entries(t.headers))r+=`< ${e}: ${i}
|
|
16
|
+
`;r+=`<
|
|
17
|
+
`}return s.includeHeaders&&!s.verbose&&(r+=`HTTP/1.1 ${t.status} ${t.statusText}\r
|
|
18
|
+
`,r+=h(t.headers),r+=`\r
|
|
19
|
+
\r
|
|
20
|
+
`),s.headOnly?s.includeHeaders||s.verbose||(r+=`HTTP/1.1 ${t.status} ${t.statusText}\r
|
|
21
|
+
`,r+=h(t.headers),r+=`\r
|
|
22
|
+
`):r+=t.body,s.writeOut&&(r+=p(s.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),r}var q={name:"curl",async execute(s,t){if(w(s))return T(F);let a=O(s);if("exitCode"in a)return a;let r=a;if(!r.url)return{stdout:"",stderr:`curl: no URL specified
|
|
23
|
+
`,exitCode:2};if(!t.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available
|
|
24
|
+
`,exitCode:1};let e=r.url;e.match(/^https?:\/\//)||(e=`https://${e}`);try{let{body:i,contentType:o}=await S(r,t),n=E(r,o),l=await t.fetch(e,{method:r.method,headers:n,body:i,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs});if(await P(r,l.headers,t),r.failSilently&&l.status>=400)return{stdout:"",stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${l.status}
|
|
25
|
+
`:"",exitCode:22};let u=H(r,l,e);if(r.outputFile||r.useRemoteName){let y=r.outputFile||W(e),$=t.fs.resolvePath(t.cwd,y);await t.fs.writeFile($,r.headOnly?"":l.body),r.verbose||(u=""),r.writeOut&&(u=p(r.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:u,stderr:"",exitCode:0}}catch(i){let o=b(i),n=1;return o.includes("Network access denied")?n=7:o.includes("HTTP method")&&o.includes("not allowed")?n=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?n=47:o.includes("aborted")&&(n=28),{stdout:"",stderr:!r.silent||r.showError?`curl: (${n}) ${o}
|
|
26
|
+
`:"",exitCode:n}}}};export{q as curlCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as yr}from"./chunk-WS6P4H4S.js";import{b as Ar}from"./chunk-LGF54XJQ.js";import{b as $r}from"./chunk-B3RU2PUI.js";import"./chunk-GZHFXDDO.js";import"./chunk-QSDVMMYI.js";import{c as Sr}from"./chunk-UPUMZYZE.js";import{b as wr}from"./chunk-XKPFI566.js";import{b as xr}from"./chunk-ORUYSLP4.js";import{b as vr}from"./chunk-IDGH4PGU.js";import{b as kr}from"./chunk-F3LGZXLQ.js";import{b as qr}from"./chunk-BYDV4VEF.js";import{b as Cr}from"./chunk-JLX6YWGA.js";import{b as br}from"./chunk-FLPVVSN5.js";import{d as Ir,e as Mr,f as jr}from"./chunk-54G6AE72.js";import{b as tr}from"./chunk-DOXYBGNA.js";import{b as lr}from"./chunk-
|
|
2
|
+
import{b as yr}from"./chunk-WS6P4H4S.js";import{b as Ar}from"./chunk-LGF54XJQ.js";import{b as $r}from"./chunk-B3RU2PUI.js";import"./chunk-GZHFXDDO.js";import"./chunk-QSDVMMYI.js";import{c as Sr}from"./chunk-UPUMZYZE.js";import{b as wr}from"./chunk-XKPFI566.js";import{b as xr}from"./chunk-ORUYSLP4.js";import{b as vr}from"./chunk-IDGH4PGU.js";import{b as kr}from"./chunk-F3LGZXLQ.js";import{b as qr}from"./chunk-BYDV4VEF.js";import{b as Cr}from"./chunk-JLX6YWGA.js";import{b as br}from"./chunk-FLPVVSN5.js";import{d as Ir,e as Mr,f as jr}from"./chunk-54G6AE72.js";import{b as tr}from"./chunk-DOXYBGNA.js";import{b as lr}from"./chunk-FBJJY4ZV.js";import{b as ur}from"./chunk-THALLNXT.js";import{b as pr}from"./chunk-EZS766DD.js";import{b as er}from"./chunk-3Y32LPNT.js";import{b as dr}from"./chunk-7BORMNPQ.js";import{b as cr}from"./chunk-N43DJTSI.js";import"./chunk-OBI37ZY4.js";import{b as hr}from"./chunk-N5OTVT4F.js";import{c as or,d as ar}from"./chunk-MAVV76T4.js";import{b as sr}from"./chunk-JTF74J6E.js";import{c as ir,d as gr}from"./chunk-GO6FXSC4.js";import{b as mr}from"./chunk-GR23MPTT.js";import"./chunk-ZO5PSLKR.js";import{b as Fr}from"./chunk-GOJZHH3L.js";import{b as zr}from"./chunk-P6GNZPVW.js";import{b as fr}from"./chunk-LOJMXC4F.js";import{b as nr}from"./chunk-AXWFPG37.js";import"./chunk-YTIURC67.js";import{b as R}from"./chunk-PQNTKMH3.js";import{b as U}from"./chunk-PPBQJBC2.js";import{b as V}from"./chunk-NSUMEERA.js";import{b as W}from"./chunk-XY5HGZW5.js";import{c as X,d as Y}from"./chunk-AAW7UMPO.js";import{c as Z,d as _}from"./chunk-3MBAUIBB.js";import{b as N}from"./chunk-RT7TRQVZ.js";import{b as rr}from"./chunk-CQG2HEAL.js";import{b as G}from"./chunk-RJSAGJQJ.js";import{b as H}from"./chunk-YEKSVVRC.js";import{b as J}from"./chunk-26NO42TF.js";import{b as K}from"./chunk-LGJM5YFT.js";import{b as L}from"./chunk-LMK6G2HH.js";import{b as O}from"./chunk-ZKC5HQYO.js";import{b as P}from"./chunk-ROJPSS6N.js";import{b as Q}from"./chunk-THNL3XFF.js";import{b as y}from"./chunk-CGE2EHYP.js";import{b as A}from"./chunk-ZA4HUKJ3.js";import{b as $}from"./chunk-WWZVR5NN.js";import{b as S}from"./chunk-JQBC3FXE.js";import{b as T}from"./chunk-SYL34GE7.js";import{b as B}from"./chunk-5G2VOPPJ.js";import{b as D}from"./chunk-SGA7Y45Z.js";import{b as E}from"./chunk-EUXCM6C4.js";import{b as w}from"./chunk-YLE2OYY6.js";import{b as x}from"./chunk-S7OHMN3F.js";import{b as v}from"./chunk-YWZOGBFE.js";import"./chunk-YMMJLYIX.js";import{d as k,e as q,f as C}from"./chunk-YFPDB4PH.js";import"./chunk-SXB55JOI.js";import{b}from"./chunk-HJEHIH4P.js";import"./chunk-V7ZOPVQS.js";import"./chunk-4OALHZXB.js";import"./chunk-G43H2WGH.js";import{b as I}from"./chunk-VVFGRIJZ.js";import{b as M}from"./chunk-SDLWFYVT.js";import{b as j}from"./chunk-FA2CHD73.js";import{b as t}from"./chunk-R2LDP472.js";import{b as l}from"./chunk-PS4LOXE5.js";import{b as u}from"./chunk-VNER2XXL.js";import{b as p}from"./chunk-YX7OOTPO.js";import{b as e}from"./chunk-7ADG3DNO.js";import{b as d}from"./chunk-TEFXEYX3.js";import{b as c}from"./chunk-ZSVBYEY4.js";import{b as h}from"./chunk-SXRVLCZ4.js";import"./chunk-FSZWFMB4.js";import"./chunk-LIYVQA3X.js";import"./chunk-OOJCYVYF.js";import"./chunk-4PRVMER6.js";import"./chunk-MO4RPBN2.js";import"./chunk-YU6OGPZR.js";import"./chunk-SE4C7FJY.js";import{b as i}from"./chunk-LJKIWB5F.js";import{b as g}from"./chunk-MRP4ZCD7.js";import"./chunk-5WFYIUU2.js";import{b as m}from"./chunk-ND23BJUM.js";import"./chunk-D5WP4CKS.js";import"./chunk-6KZRLMG3.js";import{b as F}from"./chunk-MXVNCVD6.js";import"./chunk-OBH7XN5N.js";import{b as z}from"./chunk-OQV5J23L.js";import"./chunk-SYG3IW7P.js";import{b as f}from"./chunk-EJQKHROT.js";import"./chunk-JBABAK44.js";import{b as n}from"./chunk-ITA43A73.js";import"./chunk-4VDEBYW7.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var Er=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,I,M,j,y,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,ir,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,Ir,Mr,jr,yr,Ar,$r,Sr];function Tr(){return Er}var Br=new Map;for(let r of Tr())Br.set(r.name,new Set(r.flags.map(o=>o.flag)));function Fa(r,o,Dr){let a=Br.get(o);if(!(!a||a.size===0))for(let s of Dr)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{Fa as emitFlagCoverage};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as F,b as M}from"./chunk-
|
|
2
|
+
import{a as F,b as M}from"./chunk-TKTKRRAL.js";import"./chunk-4OALHZXB.js";import"./chunk-MY5PY2PL.js";import"./chunk-LIYVQA3X.js";import{a as k,b as T}from"./chunk-OOJCYVYF.js";import{a as C}from"./chunk-4PRVMER6.js";import{b}from"./chunk-YU6OGPZR.js";import{a as p}from"./chunk-SYG3IW7P.js";import{b as j}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";import{AsyncLocalStorage as L}from"node:async_hooks";import{randomBytes as R}from"node:crypto";import{fileURLToPath as U}from"node:url";import{Worker as I}from"node:worker_threads";var J=1e4,D=6e4,W=new L,A=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
|
|
3
3
|
|
|
4
4
|
Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
|
|
5
5
|
|
|
@@ -1503,6 +1503,7 @@ var WorkerDefenseInDepth = class {
|
|
|
1503
1503
|
var _SharedArrayBuffer = globalThis.SharedArrayBuffer;
|
|
1504
1504
|
var _Atomics = globalThis.Atomics;
|
|
1505
1505
|
var _performanceNow = performance.now.bind(performance);
|
|
1506
|
+
var _Headers = globalThis.Headers;
|
|
1506
1507
|
|
|
1507
1508
|
// src/commands/worker-bridge/protocol.ts
|
|
1508
1509
|
var OpCode = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as M,b as D}from"./chunk-
|
|
2
|
+
import{a as M,b as D}from"./chunk-TKTKRRAL.js";import"./chunk-4OALHZXB.js";import"./chunk-MY5PY2PL.js";import"./chunk-LIYVQA3X.js";import{a as C,b as v}from"./chunk-OOJCYVYF.js";import{a as b}from"./chunk-4PRVMER6.js";import{c as h}from"./chunk-MO4RPBN2.js";import{b as k}from"./chunk-YU6OGPZR.js";import{a as c}from"./chunk-SYG3IW7P.js";import{a as T,b as P}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";import{randomBytes as F}from"node:crypto";import{fileURLToPath as W}from"node:url";import{Worker as $}from"node:worker_threads";var Q=1e4,R=6e4,U={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};function I(r){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(r.length===0)return e;let t=r.findIndex(o=>!o.startsWith("-")||o==="-"||o==="--");for(let o=0;o<(t===-1?r.length:t);o++){let s=r[o];if(s==="-c")return o+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
|
|
3
3
|
`,exitCode:2}:(e.code=r[o+1],e.scriptArgs=r.slice(o+2),e);if(s==="-m")return o+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
|
|
4
4
|
`,exitCode:2}:(e.module=r[o+1],e.scriptArgs=r.slice(o+2),e);if(s==="--version"||s==="-V")return e.showVersion=!0,e;if(s.startsWith("-")&&s!=="-")return{stdout:"",stderr:`python3: unrecognized option '${s}'
|
|
5
5
|
`,exitCode:2}}if(t!==-1){let o=r[t];o==="--"?t+1<r.length&&(e.scriptFile=r[t+1],e.scriptArgs=r.slice(t+2)):(e.scriptFile=o,e.scriptArgs=r.slice(t+1))}return e}var w=new WeakMap;function L(r){let e=w.get(r);return e||(e={executionQueue:[],isExecuting:!1},w.set(r,e)),e}function oe(){w=new WeakMap}var H=W(new URL("./worker.js",import.meta.url));function N(){return F(16).toString("hex")}function z(r,e){if(!r||typeof r!="object")return{success:!1,error:"Malformed worker response"};let t=r;return typeof t.protocolToken!="string"||t.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:t.type==="security-violation"?{success:!1,error:`Security violation: ${typeof t.violation?.type=="string"?t.violation.type:"unknown"}`}:typeof t.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:t.success?{success:!0}:{success:!1,error:typeof t.error=="string"&&t.error.length>0?t.error:"Worker execution failed"}}function a(r){if(r.isExecuting||r.executionQueue.length===0)return;for(;r.executionQueue.length>0&&r.executionQueue[0].canceled;)r.executionQueue.shift();if(r.executionQueue.length===0)return;let e=r.executionQueue.shift();if(!e)return;r.isExecuting=!0;let t;try{t=k.runTrusted(()=>new $(H,{workerData:e.input}))}catch(n){let i=n instanceof Error?n.message:String(n);e.resolve({success:!1,error:c(i)}),r.isExecuting=!1,a(r);return}e.workerRef&&(e.workerRef.current=t);let o=h(e.requireDefenseContext,"python3","worker message callback",n=>{e.resolve(z(n,e.input.protocolToken)),r.isExecuting=!1,t.terminate(),a(r)}),s=h(e.requireDefenseContext,"python3","worker error callback",n=>{e.resolve({success:!1,error:c(n.message)}),r.isExecuting=!1,a(r)}),p=h(e.requireDefenseContext,"python3","worker exit callback",()=>{r.isExecuting&&(e.resolve({success:!1,error:"Worker exited unexpectedly"}),r.isExecuting=!1,a(r))}),f=n=>{try{o(n)}catch(i){let m=i instanceof Error?i.message:String(i);e.resolve({success:!1,error:c(m)}),r.isExecuting=!1,t.terminate(),a(r)}},l=n=>{try{s(n)}catch(i){let m=i instanceof Error?i.message:String(i);e.resolve({success:!1,error:c(m)}),r.isExecuting=!1,a(r)}},y=()=>{try{p()}catch(n){let i=n instanceof Error?n.message:String(n);e.resolve({success:!1,error:c(i)}),r.isExecuting=!1,a(r)}};t.on("message",f),t.on("error",l),t.on("exit",y)}async function B(r,e,t,o=[]){let s=M(),p=new D(s,e.fs,e.cwd,"python3",e.fetch,e.limits?.maxOutputSize??0),f=e.limits?.maxPythonTimeoutMs??Q,l=e.fetch?Math.max(f,R):f,y=L(e.fs),n={protocolToken:N(),sharedBuffer:s,pythonCode:r,cwd:e.cwd,env:b(e.env),args:o,scriptPath:t,timeoutMs:l},i={current:null},m=new Promise(u=>{let E={input:n,resolve:()=>{},workerRef:i,requireDefenseContext:e.requireDefenseContext},_=h(e.requireDefenseContext,"python3","worker timeout callback",()=>{i.current?i.current.terminate():E.canceled=!0,u({success:!1,error:`Execution timeout: exceeded ${l}ms limit`})}),O=C(()=>{try{_()}catch(d){let A=d instanceof Error?d.message:String(d);u({success:!1,error:c(A)})}},l);E.resolve=d=>{v(O),u(d)},y.executionQueue.push(E),a(y)}),[g,x]=await Promise.all([p.run(l).catch(u=>({stdout:"",stderr:`python3: bridge error: ${c(u.message)}
|
|
@@ -1530,6 +1530,7 @@ function wrapWasmCallback(component, phase, callback) {
|
|
|
1530
1530
|
var _SharedArrayBuffer = globalThis.SharedArrayBuffer;
|
|
1531
1531
|
var _Atomics = globalThis.Atomics;
|
|
1532
1532
|
var _performanceNow = performance.now.bind(performance);
|
|
1533
|
+
var _Headers = globalThis.Headers;
|
|
1533
1534
|
|
|
1534
1535
|
// src/commands/worker-bridge/protocol.ts
|
|
1535
1536
|
var OpCode = {
|