@allscale/cli 0.1.0
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 +482 -0
- package/bin/dev.js +11 -0
- package/bin/run-oclif.js +69 -0
- package/bin/run.js +6 -0
- package/dist/commands/build-info.js +16 -0
- package/dist/commands/claim-link/claim.js +17 -0
- package/dist/commands/claim-link/create.js +75 -0
- package/dist/commands/claim-link/get.js +18 -0
- package/dist/commands/claim-link/list.js +18 -0
- package/dist/commands/claim-link/preview.js +18 -0
- package/dist/commands/claim-link/status.js +17 -0
- package/dist/commands/describe.js +16 -0
- package/dist/commands/device-login.js +40 -0
- package/dist/commands/invoice/get.js +18 -0
- package/dist/commands/invoice/list.js +19 -0
- package/dist/commands/invoice/pay.js +66 -0
- package/dist/commands/invoice/received.js +19 -0
- package/dist/commands/invoice/send.js +167 -0
- package/dist/commands/invoice/sent.js +18 -0
- package/dist/commands/invoice/update.js +18 -0
- package/dist/commands/logout.js +17 -0
- package/dist/commands/operations.js +16 -0
- package/dist/commands/otp-login.js +23 -0
- package/dist/commands/otp-send.js +17 -0
- package/dist/commands/payout/send.js +23 -0
- package/dist/commands/payout/status.js +18 -0
- package/dist/commands/scope.js +22 -0
- package/dist/commands/store/create.js +28 -0
- package/dist/commands/transaction/get.js +18 -0
- package/dist/commands/transaction/list.js +18 -0
- package/dist/commands/wallet/list.js +18 -0
- package/dist/commands/wallet/send.js +63 -0
- package/dist/commands/whoami.js +18 -0
- package/dist/hooks/version-suffix.js +2 -0
- package/dist/index.js +17 -0
- package/dist/lib/help.js +3 -0
- package/oclif.manifest.json +3329 -0
- package/package.json +135 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";var On=Object.create;var ne=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var Pn=Object.getPrototypeOf,Nn=Object.prototype.hasOwnProperty;var vn=(e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})},dt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Rn(t))!Nn.call(e,i)&&i!==n&&ne(e,i,{get:()=>t[i],enumerable:!(r=Cn(t,i))||r.enumerable});return e};var E=(e,t,n)=>(n=e!=null?On(Pn(e)):{},dt(t||!e||!e.__esModule?ne(n,"default",{value:e,enumerable:!0}):n,e)),xn=e=>dt(ne({},"__esModule",{value:!0}),e);var yi={};vn(yi,{AllscaleCommand:()=>de,AllscaleError:()=>c,Args:()=>j.Args,Flags:()=>j.Flags,Transport:()=>me,decodeJwt:()=>cn,isExpired:()=>un,pickTokenStore:()=>Tn});module.exports=xn(yi);var I=require("@oclif/core");var ft="public",pt="https://app.allscale.io";var gt=["https://app.allscale.io"];var be="Override the API base URL (public builds accept only https://app.allscale.io)";var Le="Only https://app.allscale.io is allowed, and URL userinfo is forbidden.";function ht(e){try{let t=new URL(e);return t.username.length>0||t.password.length>0?null:t.protocol==="https:"?t:null}catch{return null}}function mt(e){return ht(e)!==null}function ke(e){let t=ht(e);return t!==null&>.includes(t.origin)}function W(){return"".trim()||void 0}function J(){return"public"}function P(e){try{let{hostname:t}=new URL(e);return t==="127.0.0.1"||t==="localhost"||t==="[::1]"}catch{return!1}}function Ie(e){try{return new URL(e).origin}catch{return null}}function z(){{let e="[]".trim();if(e.length===0)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}return Te()}function Te(){let e=process.env.ALLSCALE_BUILD_PAIRS?.trim()??"";if(e.length>0)try{let r=JSON.parse(e);if(!Array.isArray(r))return[];let i=[];for(let o of r){if(typeof o!="object"||o===null)continue;let{base:s,key:l,keyId:u}=o;if(typeof s!="string"||s.trim().length===0||typeof l!="string"||l.trim().length===0)continue;let d=typeof u=="string"?u.trim():"";i.push({base:s.trim(),key:l,keyId:d.length>0?d:"cli-1"})}return i}catch{return[]}let t=process.env.ALLSCALE_SIGNING_KEY??"",n=process.env.ALLSCALE_BUILD_API_BASE?.trim()??"";if(t.trim().length>0&&n.length>0){let r=process.env.ALLSCALE_SIGNING_KEY_ID?.trim();return[{base:n,key:t,keyId:r&&r.length>0?r:"cli-1"}]}return[]}var _t="`allscale device-login` (or `allscale otp-login` for headless automation)";var yt="drop `--headless` and use the browser-bridge flow with an agent-key session.",St="allscale device-login";var Dn="device-login";function Un(e){return"allscale otp-login --profile "+(e??"<profile>")+" --email <you@example.com> --scopes <scope> --otp-stdin"}function Re(){return _t}function At(e,t="default"){return t==="headless"?`No tokens stored for profile '${e}'. Headless signing needs the user token of a legacy JWT session, which agent keys do not carry \u2014 `+yt:`No tokens stored for profile '${e}'. Run \`allscale device-login --profile <profile>\` with the same profile (recommended), use \`${Un()}\` for headless automation`+"."}function wt(e,t){let n=t.length>0?`Saved profiles: ${t.join(", ")}.`:"No profiles are saved on this machine yet.";return`Unknown profile '${e}' \u2014 no such profile is saved on this machine. ${n} Check the spelling first; to deliberately create '${e}', run \`allscale ${Dn} --profile ${e}\`.`}var Fn={"input.invalid":2,"storage.unavailable":2,"transport.network":3,"transport.timeout":3,"transport.response_too_large":2,"auth.no_token":4,"auth.unknown_profile":2,"auth.token_expired":5,"auth.credential_changed":3,"auth.permission_denied":6,"auth.signature_rejected":11,"claim.not_claimable":12,"claim.expired":12,"claim.payout_ambiguous":9,"claim_link.funding_ambiguous":9,"claim_link.intent_conflict":2,"claim_link.browser_cancelled":12,"user.cancelled":12,"signing.key_unavailable":2,not_found:7,rate_limited:8,"backend.internal":9,"wallet.requires_browser_auth":6,"wallet.bridge_timeout":3,"wallet.bridge_invalid_response":9,"wallet.headless_not_supported":6,"wallet.headless_setup_required":6,"wallet.headless_config_missing":6,"wallet.headless_sign_failed":9,"raw.disabled":10,internal:1},$n=new RegExp(["\\u001b\\[[0-9;:<=>?]*[ -/]*[@-~]","\\u009b[0-9;:<=>?]*[ -/]*[@-~]","\\u001b\\][^\\u0007\\u001b\\u009c]*(?:\\u0007|\\u001b\\\\|\\u009c)","\\u009d[^\\u0007\\u001b\\u009c]*(?:\\u0007|\\u001b\\\\|\\u009c)","\\u001b[ -/]+[0-~]","\\u001b[0-Z\\x5c-~]","\\u001b\\[[0-9;:<=>?]*[ -/]*","\\u009b[0-9;:<=>?]*[ -/]*","[\\u0007\\u001b\\u0090\\u0098\\u009b\\u009c\\u009d\\u009e\\u009f]"].join("|"),"g");function Pe(e){return(typeof e=="string"?e:String(e??"")).replace($n,"")}var Mn=64;function Oe(e,t=new Map,n=0){if(typeof e=="string")return Pe(e);if(e===null||typeof e!="object")return e;let r=t.get(e);if(r!==void 0)return r;if(n>=Mn)return e;if(Array.isArray(e)){let s=[];t.set(e,s);for(let l of e)s.push(Oe(l,t,n+1));return s}let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&i!==null)return e;let o={};t.set(e,o);for(let[s,l]of Object.entries(e))Object.defineProperty(o,s,{value:Oe(l,t,n+1),writable:!0,enumerable:!0,configurable:!0});return o}var c=class extends Error{code;details;constructor(t,n,r){super(Pe(n)),this.code=t,this.details=r&&Oe(r),this.name="AllscaleError"}get exitCode(){return Fn[this.code]}toJSON(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}};function bt(e){if(e instanceof c)return e;if(e instanceof Error){if(Yn(e)){let t=qn(e),n={};return e.name&&e.name!=="Error"&&(n.name=e.name),Object.keys(t).length>0&&(n.oclif=t),new c("input.invalid",e.message,Object.keys(n).length>0?n:void 0)}return new c("internal",e.message,{name:e.name})}return new c("internal","Unknown error",{value:String(e)})}var Gn=new Set(["CLIError","CLIParseError","RequiredArgsError","RequiredFlagError","UnexpectedArgsError","FlagInvalidOptionError","ArgInvalidOptionError","InvalidArgsSpecError"]),Kn=[/^Missing \d+ required arg/i,/^Missing required flag/i,/^Unexpected argument/i,/^Nonexistent flag/i,/^Unexpected arguments?/i,/^Failed parsing/i,/^Parsing --[A-Za-z0-9][A-Za-z0-9-]*(?:\s|$)/i,/^Expected (?:--|-).*/i,/^Flag --[A-Za-z0-9][A-Za-z0-9-]* can only be specified once\.?$/i,/^Flag --[A-Za-z0-9][A-Za-z0-9-]* expects a value$/i,/^Flag --[A-Za-z0-9][A-Za-z0-9-]* expects one of these values: /i,/to be one of: /];function Yn(e){if(Hn(e))return!0;let t=e.name??"";return Gn.has(t)?t==="CLIError"?Ce(e,"parse")||Et(e.message):!0:Et(e.message)}function Hn(e){if(!Ce(e,"oclif"))return!1;let t=e.oclif;return typeof t=="object"&&t!==null&&t.exit===2&&Ce(e,"parse")}function Et(e){return e?Pe(e).split(`
|
|
2
|
+
`).some(t=>Kn.some(n=>n.test(t.trim()))):!1}function Ce(e,t){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,t)}function qn(e){let t=e,n={};for(let r of["code","exitCode","suggestions","ref"])t[r]!==void 0&&(n[r]=t[r]);return n}function Lt(e){process.stdout.write(`${JSON.stringify({data:e},null,2)}
|
|
3
|
+
`)}var p=E(require("fs")),ie=E(require("path")),Pt=E(require("crypto"));var jn="...<truncated>",Wn=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+/g,Jn=/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,Ue=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,Ne=String.raw`(?:proxy[_-]?)?authorization`,zn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Ne}"|'${Ne}'|${Ne})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${Ue}`,"gi"),Vn=/\b(https?:\/\/)[^\s/?#]+@/gi,ve=String.raw`(?:password|passwd|passphrase|otp(?:[_-]?code)?|signature|hmac|sig|session[_-]?id|mnemonic|seed|cookie|bearer|(?:[A-Za-z0-9]+[_-])*(?:token|secret)|(?:api|access|private|signing)[_-]?key|credential|claim[_-]?url)`,Xn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${ve}"|'${ve}'|${ve})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${Ue}`,"gi"),xe=String.raw`(?:[A-Za-z0-9]+(?:Token|Secret)|[Oo][Tt][Pp]Code|[Ss]essionId|(?:api|API|access|Access|private|Private|signing|Signing)Key|[Cc]laimUrl)`,Zn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${xe}"|'${xe}'|${xe})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${Ue}`,"g");function kt(e){return e.replace(Vn,"$1<redacted>@").replace(Wn,"<redacted-jwt>").replace(zn,"$1$2$3<redacted>").replace(Xn,"$1$2<redacted>").replace(Zn,"$1$2<redacted>").replace(Jn,"Bearer <redacted>")}function Tt(e){let t="";for(let n of e){let r=n.codePointAt(0),i=r<=8||r>=11&&r<=12||r>=14&&r<=31||r>=127&&r<=159;t+=i?`\\u${r.toString(16).padStart(4,"0")}`:n}return t}function It(e,t,n=jn){if(t<=0)return"";if(Buffer.byteLength(e,"utf8")<=t)return e;let r=Buffer.byteLength(n,"utf8");if(r>=t){let l="",u=0;for(let d of n){let f=Buffer.byteLength(d,"utf8");if(u+f>t)break;l+=d,u+=f}return l}let i=t-r,o="",s=0;for(let l of e){let u=Buffer.byteLength(l,"utf8");if(s+u>i)break;o+=l,s+=u}return`${o}${n}`}function b(e,t=16384){return It(Tt(kt(e)),t)}var Be=100,Qn=8,er=8*1024;function re(){return{remaining:er}}function De(e,t){let n=Math.min(16384,t.remaining),r=It(e,n);return t.remaining-=Buffer.byteLength(r,"utf8"),r}function U(e,t,n=0,r={}){if(n>Qn)return De("<truncated>",t);if(typeof e=="string"){let i=kt(e);return De(r.escapeControls?Tt(i):i,t)}if(Array.isArray(e)){let i=e.slice(0,Be),o=i.map(s=>U(s,t,n+1,r));return e.length>i.length&&o.push(De(`<${e.length-i.length} more items truncated>`,t)),o}if(e!==null&&typeof e=="object"){let i=Object.create(null),o=Object.entries(e);for(let[s,l]of o.slice(0,Be))i[s]=U(l,t,n+1,r);return o.length>Be&&(i.output_truncated=!0),i}return e}var Fe=require("process");var $e=!1;function Me(e){$e=e}function Ct(){return $e}var Ot="1";function $(e,t){if($e){let n={...e};delete n.version;let r=re(),i={event:n.event,...n},o=U(i,r,0,{escapeControls:!0}),s=JSON.stringify({version:Ot,...o});Buffer.byteLength(s,"utf8")+1>65536&&(s=JSON.stringify({version:Ot,event:o.event,output_truncated:!0})),Fe.stderr.write(`${s}
|
|
4
|
+
`)}else Fe.stderr.write(t)}var Rt="2",M=null,L=null,G=!1;function tr(){let e=process.env.ALLSCALE_OUTPUT_FILE_PATH;if(e)return e;let t=process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY;if(t){let n=new Date().toISOString().replace(/[:.]/g,"-"),r=Pt.randomBytes(4).toString("hex");return ie.join(t,`allscale-output-${n}-${r}.ndjson`)}return null}var Ge=64*1024*1024,nr=null;function Nt(){if(G)return;let e=tr();if(!e)return;M=null;let t=null;try{if((nr??process.platform)==="win32")throw new Error("owner-only sidecar ACLs cannot be enforced on Windows; sidecar output is disabled");let n=ie.dirname(e);if(p.mkdirSync(n,{recursive:!0,mode:448}),!process.env.ALLSCALE_OUTPUT_FILE_PATH&&process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY){let l=p.statSync(n),u=l.mode&511;if(!l.isDirectory()||(u&63)!==0)throw new Error(`output directory must be owner-only (no group/other permissions); current mode is ${u.toString(8).padStart(3,"0")}`)}let r=p.constants.O_NOFOLLOW??0;t=p.openSync(e,p.constants.O_APPEND|p.constants.O_CREAT|p.constants.O_WRONLY|(p.constants.O_NONBLOCK??0)|r,384);let i=p.fstatSync(t),o=p.lstatSync(e);if(!i.isFile()||o.isSymbolicLink()||o.dev!==i.dev||o.ino!==i.ino)throw new Error("target changed while it was being opened or is not a regular file");if(typeof process.geteuid=="function"&&i.uid!==process.geteuid())throw new Error("existing sidecar file is not owned by the current effective user");let s=i.mode&511;if((s&63)!==0)throw new Error(`existing sidecar file must already be owner-only; current mode is ${s.toString(8).padStart(3,"0")}. Rotate or remove it before retrying`);p.fchmodSync(t,384)}catch(n){if(t!==null)try{p.closeSync(t)}catch{}$({event:"sidecar_disabled",reason:"open_failed",detail:b(`sidecar path '${e}' could not be opened safely (${n.message})`)},`${b(`[allscale] sidecar path '${e}' could not be opened safely (${n.message}); refusing to write. Sidecar disabled for this run.`)}
|
|
5
|
+
`);return}M=e,L=t,G=!0}var rr=[/password/i,/secret/i,/token/i,/api[_-]?key/i,/signing[_-]?key/i,/private[_-]?key/i,/credential/i,/otp/i,/signature/i,/(?:^|[_-])sig(?:[_-]|$)/i,/hmac/i,/session[_-]?id/i,/nonce/i,/bearer/i,/authorization/i,/^code$/i,/^auth$/i,/^state$/i];function ir(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return rr.some(n=>n.test(t))}function vt(e){try{let t=new URL(e),n=t.username.length>0||t.password.length>0;n&&(t.username="",t.password="");let r=t.pathname;t.pathname=or(t.pathname);let i=n;t.pathname!==r&&(i=!0);for(let[o]of t.searchParams)ir(o)&&(t.searchParams.set(o,"<redacted>"),i=!0);return i?t.toString():e}catch{return e}}function or(e){return e.replace(/(\/(?:api\/)?(?:v1\/)?public\/claim-links\/)([^/:]+)(:claim)?(?=\/?$)/,"$1<redacted>$3").replace(/(\/(?:api\/)?public\/claim-links\/)([^/]+)(\/claim)(?=\/?$)/,"$1<redacted>$3")}function sr(e){return(e.type==="request"||e.type==="bridge_browser_open")&&typeof e.url=="string"?{...e,url:vt(e.url)}:e}function ar(e){let t=new Date().toISOString(),n=e,{type:r,...i}=n,o=U(i,re()),s=JSON.stringify({version:Rt,timestamp:t,type:r,...o});return Buffer.byteLength(s,"utf8")+1>65536&&(s=JSON.stringify({version:Rt,timestamp:t,type:r,output_truncated:!0})),s}function y(e){if(!G||!M||L===null)return;let t=sr(e),n=ar(t);try{if(p.fstatSync(L).size+Buffer.byteLength(n,"utf8")+1>Ge){G=!1;try{p.closeSync(L)}catch{}L=null,$({event:"sidecar_disabled",reason:"size_limit",...M===null?{}:{path:b(M)},max_bytes:Ge},`${b(`[allscale] sidecar exceeded ${Ge} bytes; disabling it for the rest of this run. Rotate or remove ${M}, or point ALLSCALE_OUTPUT_FILE_DIRECTORY at a directory so each run gets its own file.`)}
|
|
6
|
+
`);return}p.appendFileSync(L,`${n}
|
|
7
|
+
`)}catch(r){if(G=!1,L!==null){try{p.closeSync(L)}catch{}L=null}try{$({event:"sidecar_disabled",reason:"write_failed",detail:b(r.message)},`${b(`[allscale] sidecar write failed (${r.message}); disabling sidecar for the rest of this run.`)}
|
|
8
|
+
`)}catch{}}}var C=vt;function xt(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function oe(){if(G=!1,L!==null){try{p.closeSync(L)}catch{}L=null}}function Bt(e=!1){let t=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||xt()||!t}var V=W()??pt,Y={TOKEN:"ALLSCALE_TOKEN",PROFILE:"ALLSCALE_PROFILE",API_BASE:"ALLSCALE_API_BASE",PAYOUT_API_BASE:"ALLSCALE_PAYOUT_API_BASE",PRETTY:"ALLSCALE_PRETTY",LOG_LEVEL:"ALLSCALE_LOG_LEVEL",INSECURE_STORAGE:"ALLSCALE_INSECURE_STORAGE",NO_KEYCHAIN:"ALLSCALE_NO_KEYCHAIN",ALLOW_RAW:"ALLSCALE_ALLOW_RAW",OUTPUT_FILE_PATH:"ALLSCALE_OUTPUT_FILE_PATH",OUTPUT_FILE_DIRECTORY:"ALLSCALE_OUTPUT_FILE_DIRECTORY",STORE_API_KEY:"ALLSCALE_STORE_API_KEY",STORE_API_SECRET:"ALLSCALE_STORE_API_SECRET"};function R(e){return mt(e)?new URL(e).origin:null}function T(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return"<unparseable URL>"}}function Dt(){let e=process.env[Y.TOKEN]?.trim();return e&&e.length>0?e:void 0}function Ke(){let e=process.env[Y.PROFILE]?.trim();return e&&e.length>0?e:void 0}function se(){let e=process.env[Y.API_BASE]?.trim();return e&&e.length>0?e:void 0}function Ut(){let e=process.env[Y.INSECURE_STORAGE]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Ft(){let e=process.env[Y.NO_KEYCHAIN]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function $t(){let e=process.env[Y.ALLOW_RAW]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Mt(e){let{resolvedApiBase:t,fromExplicitOverride:n,profileApiBase:r,profileApiBaseSource:i}=e;if(W()===void 0&&V!==""&&"".length!==0&&!n&&i!=="explicit"&&r===""&&t==="")return`Notice: this profile is pinned to ${""} (staging) in ~/.allscale/config.toml.
|
|
9
|
+
The CLI default is now ${V} (production), but a saved profile wins over the default,
|
|
10
|
+
so this session still uses staging. That pin was written before the default changed, so it may just be
|
|
11
|
+
the old default rather than a deliberate choice.
|
|
12
|
+
To keep staging, re-run login with --api-base ${""} (recorded as deliberate, silences this).
|
|
13
|
+
To move to production, run: ${St} --api-base ${V}
|
|
14
|
+
`}var H=E(require("fs")),Gt=E(require("os")),Ye=E(require("path")),He=E(require("@iarna/toml"));var ur=".allscale",dr="config.toml";function qe(){return Ye.join(Gt.homedir(),ur)}function fr(){return Ye.join(qe(),dr)}function ae(){let e=fr();if(!H.existsSync(e))return{};let t=H.readFileSync(e,"utf-8");try{return He.parse(t)}catch(n){throw new c("internal",`Failed to parse ${e}: ${n.message}`)}}function Kt(e){return Object.keys(e.profile??{}).sort()}function Yt(e,t){return e.profile?.[t]}function Ht(e,t,n){let r=t??n??e.default??"default";if(r.includes(":"))throw new c("input.invalid",`Invalid profile name '${r}': ':' is reserved as the keychain namespace separator \u2014 pick a name without ':'.`);return r}function q(e){if(!ke(e))throw new c("input.invalid",`Refusing to send credentials to API base ${T(e)}. `+Le)}function je(e,t){q(e);let n=R(e),r=typeof t=="string"?R(t):null;if(n&&r===n)return;let i=typeof t=="string"?T(t):"<missing origin binding>";throw new c("input.invalid",`Refusing to send stored credentials: API base ${T(e)} does not match their bound origin ${i}. Re-login against the intended API base before retrying.`)}function qt(e,t){let n=R(e),r=R(t);if(!(n&&r===n))throw new c("input.invalid",`Refusing API request to ${T(t)} because it is outside the configured API origin ${T(e)}.`)}function le(e){let t=W();if(t===void 0||P(e))return;let n=R(e),r=z();if(r.length>0){let o=r.map(l=>R(l.base)).filter(l=>l!==null);if(n!==null&&o.includes(n))return;let s=r.map(l=>T(l.base)).join(", ");throw new c("input.invalid",`Refusing to send to ${T(e)} \u2014 this build only signs for: ${s}. Re-login against one of this build's environments, or use a build that includes the one you need.`)}let i=R(t);if(!(n!==null&&n===i))throw new c("input.invalid",`Refusing to send to ${T(e)} \u2014 this build only signs for ${T(t)}. Re-login against this build's environment, or use a build for that one.`)}var pr=require("@noble/hashes/sha3");var jt=["USDT","USDC"];var no=new Set([`0x${"0".repeat(40)}`,`0x${"0".repeat(36)}dead`]);var j=require("@oclif/core"),de=class e extends I.Command{static enableJsonFlag=!0;static legacyStagingNoticeShown=!1;static emitsOwnOutput=!1;static requiresEscapeHatch=!1;static requiresInput=!1;static isLocalOnly=!1;static baseFlags={profile:I.Flags.string({description:"Named profile from ~/.allscale/config.toml",helpGroup:"GLOBAL"}),token:I.Flags.string({description:"Override the access token for this invocation (precedence: --token > ALLSCALE_TOKEN > --profile)",helpGroup:"GLOBAL",hidden:J()==="public"}),"api-base":I.Flags.string({description:be,helpGroup:"GLOBAL",hidden:J()==="public"}),"insecure-storage":I.Flags.boolean({description:"Force POSIX plaintext token storage at ~/.allscale/credentials.json (mode 0600) instead of the OS keychain \u2014 for headless / CI / agent use. Unavailable on Windows because Node cannot verify owner-only ACL/link safety. Also via ALLSCALE_INSECURE_STORAGE=1.",default:!1,helpGroup:"GLOBAL"})};async run(){try{Me(this.jsonEnabled()),Nt(),y({type:"session-start",command:this.id??"",argv:hr(this.argv)});let t=this.constructor;if(J()==="public"){if(this.argv.some(o=>o==="--token"||o.startsWith("--token=")))throw new c("input.invalid","--token is not supported in this build. Set the ALLSCALE_TOKEN environment variable instead (it does not leak into shell history or process listings).");if(this.argv.some(o=>o==="--api-base"||o.startsWith("--api-base=")))throw new c("input.invalid","--api-base is not supported in this build; it always talks to its bound AllScale environment.");if(!t.isLocalOnly&&se()!==void 0)throw new c("input.invalid","ALLSCALE_API_BASE is not supported in this build; unset it \u2014 this build always talks to its bound AllScale environment.")}if(t.requiresEscapeHatch&&!$t())throw this.argv.length>0&&await this.parse(),new c("raw.disabled","This command is an opt-in escape hatch and is disabled by default. Set ALLSCALE_ALLOW_RAW=1 to enable raw GraphQL/REST passthroughs and schema introspection. The real access boundary is enforced server-side by the key's scope regardless.");let n=Bt(this.jsonEnabled()),r=this.argv.length===0&&!n&&br(t)?this.config.findCommand(this.id??""):void 0;if(r){oe();let o=await(0,I.loadHelpClass)(this.config),s=this.config.pjson.oclif?.helpOptions??this.config.pjson.helpOptions;await new o(this.config,s).showCommandHelp(r,this.config.topics);return}let i=await this.runCommand();return y({type:"command-end",ok:!0}),oe(),t.emitsOwnOutput?void 0:(this.jsonEnabled()||Lt(i),{data:i})}catch(t){let n=bt(t);y({type:"error",code:n.code,message:b(n.message)}),y({type:"command-end",ok:!1,exitCode:n.exitCode}),oe(),this.emitError(n),process.exitCode=n.exitCode;return}finally{Me(!1)}}resolveSessionApiBaseChain(t){let n=ae(),r=t.profile??void 0,i=t["api-base"]??void 0,o=r!==void 0||Ke()!==void 0,s=Ht(n,r,Ke()),l=Yt(n,s),u=i??se(),d=u??l?.api_base??V,f=Mt({resolvedApiBase:d,fromExplicitOverride:u!==void 0,profileApiBase:l?.api_base,profileApiBaseSource:l?.api_base_source});return f&&!e.legacyStagingNoticeShown&&(e.legacyStagingNoticeShown=!0,$({event:"legacy_staging_profile",api_base:d,profile:s},f)),{apiBase:d,explicitApiBase:u,profileApiBase:l?.api_base,profile:s,profileExplicit:o}}resolveSessionApiBaseForPayoutDerivation(t){let{apiBase:n}=this.resolveSessionApiBaseChain(t);return this.constructor.isLocalOnly||q(n),n}resolveContext(t){if(J()==="public"){if(t.token!==void 0)throw new c("input.invalid","--token is not supported in this build. Set the ALLSCALE_TOKEN environment variable instead (it does not leak into shell history or process listings).");if(t["api-base"]!==void 0)throw new c("input.invalid","--api-base is not supported in this build; it always talks to its bound AllScale environment.");if(!this.constructor.isLocalOnly&&se()!==void 0)throw new c("input.invalid","ALLSCALE_API_BASE is not supported in this build; unset it \u2014 this build always talks to its bound AllScale environment.")}let n=t.token??void 0,r=!!t["insecure-storage"],{apiBase:i,explicitApiBase:o,profile:s,profileApiBase:l,profileExplicit:u}=this.resolveSessionApiBaseChain(t);return this.constructor.isLocalOnly||(q(i),le(i)),{apiBase:i,profile:s,token:n??Dt(),insecureStorage:r||Ut(),apiBaseSource:o!==void 0?"explicit":l!==void 0?"profile":"default",profileExplicit:u}}emitError(t){process.stderr.write(`${wr(t)}
|
|
15
|
+
`)}},ue=new Set(["--password","-p","--token","-t","--otp","--otp-id","--api-base","--payout-api-base","--browser-base","--input","-i","--claim-token","--claim-url","--api-key","--api-secret"]),gr=new Set(Array.from(ue).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2));function hr(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r.startsWith("-")){let i=r.indexOf("=");if(i!==-1){let o=r.slice(0,i);if(ue.has(o)){t.push(`${o}=<redacted>`);continue}}}if(ue.has(r)){t.push(r),n+1<e.length&&(ue.has(e[n+1])||(t.push("<redacted>"),n+=1));continue}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>2&&r[1]!=="="){let i=r.slice(0,2);if(gr.has(i)){t.push(`${i}<redacted>`);continue}}t.push(r)}return t}var mr=/(token|secret|password|passwd|passphrase|cookie|authorization|bearer|credential|mnemonic|seed|api[_-]?key|apikey|private[_-]?key|privkey|otp|signature|hmac|(?:^|[_-])sig(?:[_-]|$)|session[_-]?id|^input$)/i;function _r(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return mr.test(t)}var yr=/_(removed|cleared|count|total)$/i;function Sr(e,t){return typeof t=="number"&&yr.test(e)}var Er=new Set(jt);function Ar(e,t){return e==="token_symbol"&&typeof t=="string"&&Er.has(t)}var ce=100;function We(e,t=0){if(t>8)return"<truncated>";if(Array.isArray(e)){let n=e.slice(0,ce),r=n.map(i=>We(i,t+1));return e.length>n.length&&r.push(`<${e.length-n.length} more items truncated>`),r}if(e!==null&&typeof e=="object"){let n=Object.create(null),r=Object.entries(e);for(let[i,o]of r.slice(0,ce))n[i]=_r(i)&&!Sr(i,o)&&!Ar(i,o)?"<redacted>":We(o,t+1);if(r.length>ce){let i="<truncated>";for(;i in n;)i=`<${i}>`;n[i]=`${r.length-ce} more keys`}return n}return typeof e=="string"?b(e):e}function wr(e){let t=Ct()?void 0:2,n=We(e.toJSON()),r=JSON.stringify(n,null,t);return Buffer.byteLength(r,"utf8")+1<=65536?r:JSON.stringify({error:{code:e.code,message:b(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,t)}function br(e){if(e.requiresInput===!0)return!0;let t=i=>typeof i=="object"&&i!==null&&i.required===!0,n=e.flags??{},r=e.args??{};return Object.values(n).some(i=>t(i))||Object.values(r).some(i=>t(i))}var fe="allscale_access_token",Je="allscale_refresh_token";function Wt(e){return(typeof e.getSetCookie=="function"?e.getSetCookie():e.get("set-cookie")?[e.get("set-cookie")]:[]).map(n=>{let r=n.indexOf(";"),i=r===-1?n:n.slice(0,r),o=i.indexOf("=");return o===-1?null:{name:i.slice(0,o).trim(),value:i.slice(o+1).trim()}}).filter(n=>n!==null)}function ze(e){return e.map(t=>`${t.name}=${t.value}`).join("; ")}function Ve(e,t){return e.find(n=>n.name===t)?.value??null}var Jt=E(require("crypto")),zt=E(require("fs")),Vt=E(require("path"));var Lr="key-id",kr="x-allscale-cli-version",Xe="cli-1",Tr="aScaLe_cli_obf_v1",Ir="WWoBD3QEZwECUTEuOD4dTgdWawQSKAQ8UlRaaw==";function Or(e,t){let n=Buffer.from(e,"base64"),r=Buffer.from(t,"utf8"),i=Buffer.alloc(n.length);for(let o=0;o<n.length;o++)i[o]=n[o]^r[o%r.length];return i.toString("utf8")}var Cr=Or(Ir,Tr),Xt=`Bearer ${Cr}`;function Zt(e,t){let n=Ie(e);if(n!==null)return t.find(r=>Ie(r.base)===n)}function Rr(e){if("f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2".trim().length>0)return"f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2";let t=z();if(t.length>0){let r=Zt(e,t);if(r)return r.key;if(P(e)){let i=process.env.ALLSCALE_SIGNING_KEY;return i&&i.trim().length>0?i:P(t[0].base)?t[0].key:void 0}return}let n=process.env.ALLSCALE_SIGNING_KEY;return n&&n.trim().length>0?n:void 0}function Pr(e){{let r="cli-1".trim();if(r.length>0)return r}let t=z();if(t.length>0){let r=e!==void 0?Zt(e,t):void 0;if(r)return r.keyId;if(e!==void 0&&P(e)){let i=process.env.ALLSCALE_SIGNING_KEY;if(i&&i.trim().length>0){let o=process.env.ALLSCALE_SIGNING_KEY_ID;return o!==void 0?o.trim():Xe}if(!P(t[0].base))return Xe}return t[0].keyId}let n=process.env.ALLSCALE_SIGNING_KEY_ID;return n!==void 0?n.trim():Xe}function Nr(){return"0.1.0"}function vr(){return new c("signing.key_unavailable","No request-signing key is available for this destination in this build. Published builds embed one at publish time; when running from source or an internal build, set ALLSCALE_SIGNING_KEY + ALLSCALE_BUILD_API_BASE (or ALLSCALE_BUILD_PAIRS for more than one environment) in the environment.")}function Ze(e,t){let n=Rr(t);if(!n)throw vr();let r=Pr(t),i=Math.floor(Date.now()/1e3).toString(),o=Jt.createHash("sha256").update(`${n}${i}${e}`).digest("hex"),s={timestamp:i,"secret-key":o,[kr]:Nr()};return r.length>0&&(s[Lr]=r),s}function Qt(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e)}function xr(e,t={}){let n;try{n=Kt(ae())}catch{return}if(!(n.length===0||n.includes(e)))return new c("auth.unknown_profile",wt(e,n)+(t.messageSuffix??""),{profile:e,known_profiles:n})}function en(e){if(e.profileExplicit){let t=xr(e.profile);if(t)return t}return new c("auth.no_token",At(e.profile,e.flow))}var Qe=256*1024,pe=class extends c{constructor(t,n,r="backend-envelope"){let i=r==="successful-query",o=r==="successful-mutation";super(i?"transport.response_too_large":"backend.internal",i?`The API returned an HTTP-success response larger than the CLI's ${n}-byte safety limit, so it was not parsed. For list commands, request fewer rows by removing --all or using --input/--limit pagination, and reduce --select when possible; for other commands, contact support.`:o?`The API returned an HTTP-success response larger than the CLI's ${n}-byte safety limit, so its result was not parsed. The operation may already have completed; inspect authoritative state before retrying.`:`API response body exceeded the ${n}-byte safety limit and was not parsed.`,{status:t,max_body_bytes:n,...o?{outcome_ambiguous:!0}:{}}),this.name="ResponseBodyTooLargeError"}},ge=class extends Error{status;timeoutMs;constructor(t,n){super(`API response body read exceeded its ${n}ms deadline.`),this.name="ResponseBodyReadTimeoutError",this.status=t,this.timeoutMs=n}};async function et(e,t,n={}){if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("maxBytes must be a positive safe integer");if(n.timeoutMs!==void 0&&(!Number.isSafeInteger(n.timeoutMs)||n.timeoutMs<=0))throw new RangeError("timeoutMs must be a positive safe integer");let r=e.headers.get("content-length"),i=r!==null&&/^\d+$/.test(r.trim())?Number(r):void 0;if(i!==void 0&&i>t)throw e.body?.cancel().catch(()=>{}),new pe(e.status,t,n.oversizeKind);if(!e.body)return"";let o=e.body.getReader(),s=[],l=0,u,d=n.timeoutMs,f=d===void 0?void 0:new Promise((g,w)=>{u=setTimeout(()=>{w(new ge(e.status,d))},d),u.unref?.()});try{for(;;){let g=o.read(),{done:w,value:_}=f?await Promise.race([g,f]):await g;if(w)break;if(l+=_.byteLength,l>t)throw o.cancel().catch(()=>{}),new pe(e.status,t,n.oversizeKind);s.push(Buffer.from(_))}}catch(g){throw g instanceof ge&&o.cancel(g).catch(()=>{}),g}finally{u!==void 0&&clearTimeout(u);try{o.releaseLock()}catch{}}return Buffer.concat(s,l).toString("utf8")}var Br="X-AllScale-Api-Key",Dr=3e4,Ur=32*1024*1024,Fr=4*1024*1024;function $r(e,t){let n=new AbortController,r=!1,i=()=>{n.abort(e?.reason)};e?.aborted?i():e?.addEventListener("abort",i,{once:!0});let o=setTimeout(()=>{r=!0,n.abort()},t);return{signal:n.signal,timedOut:()=>r,dispose:()=>{clearTimeout(o),e?.removeEventListener("abort",i)}}}function Mr(e,t){return t?t.aborted?Promise.reject(Object.assign(new Error("The operation was aborted"),{name:"AbortError"})):new Promise((n,r)=>{let i=()=>{r(Object.assign(new Error("The operation was aborted"),{name:"AbortError"}))};t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener("abort",i)})}):e}function Gr(e,t){if(!(e<300||e>=400))throw new c("transport.network",`API returned HTTP ${e} (a redirect) for ${C(t||"the request")}. The CLI does NOT follow redirects on credential-bearing requests \u2014 a cross-origin hop could re-send credentials and the request body to the new host. Check that --api-base / ALLSCALE_API_BASE points at the API origin directly and that no proxy is rewriting it.`,{status:e})}async function sn(e){if(!(e.status<300||e.status>=400)){try{await e.body?.cancel()}catch{}Gr(e.status,e.url)}}var tn="--dns-result-order=ipv4first";async function he(e,t){if(e.status!==403)return;let n=e.headers.get("content-type")?.toLowerCase()??"",r=e.headers.get("cf-ray")??"",i=e.headers.get("cf-mitigated")?.trim().toLowerCase()==="challenge",o=n.includes("text/html"),s=t?.slice(0,4096)??"",l=/^\s*(?:<!doctype\s+html|<html\b)/i.test(s),u=/cf-error-details|\/cdn-cgi\/(?:challenge-platform|styles\/cf\.errors)|sorry,\s*you have been blocked|attention required[^<]{0,160}cloudflare|cloudflare ray id|error\s*(?:code\s*)?1020/i.test(s);if(!((o||l)&&(i||t!==void 0&&u)))return;if(t===void 0)try{e.body?.cancel().catch(()=>{})}catch{}let f=/^[A-Za-z0-9-]{1,128}$/.test(r)?r:void 0;throw new c("transport.network",`Cloudflare blocked this request before it reached the AllScale API (HTTP 403). This can happen when the release edge accepts IPv4 but rejects IPv6. Retry with NODE_OPTIONS=${tn} and report the Cloudflare Ray ID to support; the CLI will not automatically retry a possibly mutating request.`,{status:403,edge_provider:"cloudflare",...f?{cf_ray:f}:{},ipv4_workaround:`NODE_OPTIONS=${tn}`})}var me=class{constructor(t){this.opts=t}opts;refreshInFlight=null;async requestWithMetadata(t){return this.requestInternal(t,{withMetadata:!0})}async request(t){return this.requestInternal(t,{withMetadata:!1})}async requestInternal(t,n){let r=t.timeoutMs??this.opts.requestTimeoutMs??Dr;if(!Number.isFinite(r)||r<1)throw new c("input.invalid","HTTP request timeout must be a positive number of milliseconds.");q(this.opts.apiBase),le(this.opts.apiBase);let i=this.opts.override?{access_token:this.opts.override.access_token,refresh_token:this.opts.override.refresh_token??""}:await this.opts.tokenStore.get(this.opts.profile),o=$r(t.signal,r);try{return await this.requestWithinDeadline({...t,signal:o.signal},n,i)}catch(s){throw o.timedOut()?new c("transport.timeout",`Request to ${C(new URL(t.path,this.opts.apiBase).toString())} timed out after ${r}ms.`,{timeout_ms:r}):t.signal?.aborted&&!(s instanceof c)?new c("transport.network",`Request to ${C(new URL(t.path,this.opts.apiBase).toString())} was aborted by the caller.`):s}finally{o.dispose()}}async requestWithinDeadline(t,n,r){let i=new URL(t.path,this.opts.apiBase).toString();qt(this.opts.apiBase,i);let o=r?.agent_key,s=t.auth??"auto",l=an(t.path),u=s==="required"?!0:s==="none"?!1:qr(t.path);if((l||s==="required")&&!t._isRefresh&&!this.opts.override&&!r?.access_token&&!o)throw en({profile:this.opts.profile,profileExplicit:this.opts.profileExplicit});let d=Qt(t.body),f=!!o||!!r?.access_token;u&&f&&!this.opts.override&&je(this.opts.apiBase,r?.api_base);let g=this.buildHeaders({attachAuth:u&&f,bodyForSig:d,tokens:r,extra:t.headers}),w=Date.now();y({type:"request",method:t.method??"GET",url:i,...t._isRefresh?{refresh:!0}:{}});let _;try{_=await fetch(i,{method:t.method??"GET",headers:g,body:t.body!==void 0?d:void 0,signal:t.signal,redirect:"manual"})}catch(S){throw new c("transport.network",`Network error contacting ${C(i)}: ${S instanceof Error?S.message:String(S)}`)}if(y({type:"response",status:_.status,durationMs:Date.now()-w}),u&&!!r?.access_token&&!o&&_.status===401&&!t._isRefresh&&!this.opts.override){let S=await Mr(this.refreshSingleFlight(),t.signal),te=this.buildHeaders({attachAuth:u&&!!S.access_token,bodyForSig:d,tokens:S,extra:t.headers}),In=Date.now();y({type:"request",method:t.method??"GET",url:i});let Ae;try{Ae=await fetch(i,{method:t.method??"GET",headers:te,body:t.body!==void 0?d:void 0,signal:t.signal,redirect:"manual"})}catch(we){throw new c("transport.network",`Network error contacting ${C(i)} on refresh-retry: ${we instanceof Error?we.message:String(we)}`)}return y({type:"response",status:Ae.status,durationMs:Date.now()-In}),nn(Ae,{withMetadata:n.withMetadata,authBearing:u,responseKind:rn(t)})}return nn(_,{withMetadata:n.withMetadata,authBearing:u&&f,agentKeyAuth:u&&!!o,responseKind:rn(t)})}buildHeaders(t){let r={Accept:"application/json","Content-Type":"application/json",...Ze(t.bodyForSig,this.opts.apiBase),...t.extra};if(t.attachAuth){r.Authorization=Xt;let i=t.tokens;if(i?.agent_key)return r[Br]=i.agent_key,r;let o=i?.access_token;o&&(r.Cookie=ze([{name:fe,value:o}]))}return r}async refreshSingleFlight(){return this.refreshInFlight?this.refreshInFlight:(this.refreshInFlight=this.doRefresh().finally(()=>{this.refreshInFlight=null}),this.refreshInFlight)}async doRefresh(){let t=await this.opts.tokenStore.get(this.opts.profile);if(!t?.access_token||!t?.refresh_token)throw new c("auth.token_expired",`No refresh token available; log in again \u2014 ${Re()}.`);if(je(this.opts.apiBase,t.api_base),t.agent_key)throw new c("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than overwrite it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");let n=new URL("/api/public/auth/refresh_token",this.opts.apiBase).toString(),r=ze([{name:fe,value:t.access_token},{name:Je,value:t.refresh_token}]),i=Ze("",this.opts.apiBase);y({type:"request",method:"POST",url:n,refresh:!0});let o=new AbortController,s=!1,l=setTimeout(()=>{s=!0,o.abort()},1e4),u;try{u=await fetch(n,{method:"POST",headers:{Accept:"application/json",Cookie:r,...i},signal:o.signal,redirect:"manual"})}catch(_){throw y({type:"refresh",ok:!1}),new c("transport.network",s&&_ instanceof Error&&_.name==="AbortError"?`Token refresh against ${C(n)} timed out after 10s with no response.`:`Network error during token refresh against ${C(n)}: ${_ instanceof Error?_.message:String(_)}`)}finally{clearTimeout(l)}y({type:"response",status:u.status,durationMs:0});try{await sn(u)}catch(_){throw y({type:"refresh",ok:!1}),_}if(u.status!==200){y({type:"refresh",ok:!1}),await he(u);let _=await Jr(u);throw await he(u,_),ln(u.status,_),new c("auth.token_expired",`Refresh token was rejected; re-authenticate \u2014 ${Re()}.`,{status:u.status})}let d=Wt(u.headers),f=Ve(d,fe),g=Ve(d,Je);if(!f||!g)throw y({type:"refresh",ok:!1}),new c("auth.token_expired","Refresh response did not include new access/refresh cookies.");let w={...t,access_token:f,refresh_token:g};return await this.opts.tokenStore.set(this.opts.profile,w),y({type:"refresh",ok:!0}),w}},Kr=["/secure","/api/secure","/v1/secure","/api/v1/secure"];function an(e){let t=e.split(/[?#]/,1)[0];return Kr.some(n=>t===n||t.startsWith(`${n}/`))}var Yr=[/^\/(api\/)?(v1\/)?public\/businesses\/payments?(\/|$)/,/^\/(api\/)?(v1\/)?public\/businesses\/transactions?(\/|$)/];function Hr(e){let t=e.split(/[?#]/,1)[0];return Yr.some(n=>n.test(t))}function qr(e){return an(e)||Hr(e)}async function nn(e,t={}){await sn(e);let n=e.status>=200&&e.status<300;n||await he(e);let r=t.responseKind??"mutation",o=await et(e,n?r==="query"?Ur:Fr:Qe,{oversizeKind:n?r==="query"?"successful-query":"successful-mutation":"backend-envelope"});n||await he(e,o);let s=null;if(o.length>0)try{s=JSON.parse(o)}catch{s={raw:o}}if(e.status>=200&&e.status<300){if(t.withMetadata){let u={};return e.headers.forEach((d,f)=>{u[f]=d}),{status:e.status,headers:u,body:s}}return s}let l=zr(s)??`HTTP ${e.status}`;if(ln(e.status,s),e.status===401){if(t.agentKeyAuth)throw new c("auth.token_expired","Agent key was rejected (expired or revoked). Re-run `allscale device-login` to mint a new scoped key.",{status:401,body:s});let u=t.authBearing?"auth.token_expired":"input.invalid";throw new c(u,l,{status:401,body:s})}throw e.status===403?new c("auth.permission_denied",l,{status:403,body:s}):e.status===404?new c("not_found",l,{status:404,body:s}):e.status===429?new c("rate_limited",l,{status:429,body:s}):e.status>=500?new c("backend.internal",l,{status:e.status,body:s}):new c("input.invalid",l,{status:e.status,body:s})}function rn(e){if(e.responseKind)return e.responseKind;let t=(e.method??"GET").toUpperCase();return t==="GET"||t==="HEAD"?"query":"mutation"}var on=2014;function jr(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!="object")return!1;let n=t.code;return n===on||n===String(on)}var Wr=1e4;async function Jr(e,t=Wr){if(e.status>=200&&e.status<300)return"";try{return await et(e,Qe,{timeoutMs:t})}catch{return""}}function ln(e,t){if(!(e>=200&&e<300)&&jr(t))throw new c("auth.signature_rejected","The AllScale API rejected this CLI build's request signing key. Download the latest version \u2014 `npm install -g @allscale/cli@latest` \u2014 and retry: retiring an old signing key is how a release is made mandatory. If you are already on the latest version, this build's key row is missing or misprovisioned on the backend \u2014 contact AllScale support. Re-logging in will not help either way; the key ships inside the CLI build itself.",{status:e,body:typeof t=="string"?t.slice(0,500):t})}function zr(e){if(!e||typeof e!="object")return;let t=e;if(typeof t.message=="string")return t.message;if(typeof t.detail=="string")return t.detail;if(Array.isArray(t.detail))return JSON.stringify(t.detail)}function cn(e){let t=e.split(".");if(t.length!==3)throw new c("auth.token_expired","Stored token is not a valid JWT.");try{let n=Buffer.from(t[1].replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8");return JSON.parse(n)}catch(n){throw new c("auth.token_expired",`Failed to decode JWT payload: ${n.message}`)}}function un(e,t=Math.floor(Date.now()/1e3)){return typeof e.exp=="number"&&e.exp<t}var bn=E(require("path"));var rt=require("crypto"),a=E(require("fs")),m=E(require("path"));var _e=1024*1024,Vr=5e3,Xr=20,Zr=3e4,tt=4096,Qr=new Int32Array(new SharedArrayBuffer(4)),X=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function ye(e){return e instanceof X}var A=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},ei=null;function v(){return new c("storage.unavailable","Owner-only plaintext credential ACLs cannot be enforced on Windows; --insecure-storage is disabled on this platform. Use Windows Credential Manager instead. `allscale logout` can still remove a legacy plaintext file when the requested profile is its only remaining profile.")}function Se(){return(ei??process.platform)!=="win32"}function yn(){if(!Se())throw v()}function Sn(e){try{return a.default.lstatSync(e),!1}catch(t){if(!h(t,"ENOENT"))throw t}try{let t=a.default.lstatSync(m.dirname(e));return!t.isSymbolicLink()&&t.isDirectory()}catch(t){if(h(t,"ENOENT"))return!0;throw t}}function h(e,t){return typeof e=="object"&&e!==null&&e.code===t}function Z(e,t){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${t} is not owned by the current effective user`)}function Q(e,t){return e.dev===t.dev&&e.ino===t.ino}function ti(e){Atomics.wait(Qr,0,0,e)}function En(e){try{return process.kill(e,0),!0}catch(t){return!h(t,"ESRCH")}}function ni(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dn(e,t){let n=m.dirname(e);t&&a.default.mkdirSync(n,{recursive:!0,mode:448});let r;try{r=a.default.lstatSync(n)}catch(o){if(!t&&h(o,"ENOENT"))return!1;throw o}if(r.isSymbolicLink()||!r.isDirectory())throw new Error("credential-store parent must be a real directory");if(process.platform==="win32")return!0;let i=null;try{i=a.default.openSync(n,a.default.constants.O_RDONLY|(a.default.constants.O_DIRECTORY??0)|(a.default.constants.O_NOFOLLOW??0)|(a.default.constants.O_NONBLOCK??0));let o=a.default.fstatSync(i),s=a.default.lstatSync(n);if(!o.isDirectory()||s.isSymbolicLink()||!s.isDirectory()||!Q(o,s))throw new Error("credential-store parent changed while it was being inspected");Z(o,"credential-store parent");let l=o;if((o.mode&63)!==0&&m.basename(n)===".allscale"&&(a.default.fchmodSync(i,448),l=a.default.fstatSync(i)),(l.mode&63)!==0)throw new Error("credential-store parent must not grant group or other permissions")}finally{i!==null&&a.default.closeSync(i)}return!0}function O(e,t,n,r={}){if(!n.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");let i;try{i=a.default.lstatSync(e)}catch(o){throw r.retryOnPathChange&&h(o,"ENOENT")?new A:o}if(!Q(n,i))throw r.retryOnPathChange?new A:new Error("credential-store target changed while it was being opened or is not a regular file");if(i.isSymbolicLink()||!i.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");if(!r.allowMultipleLinks&&(n.nlink!==1||i.nlink!==1))throw new X;if(Z(n,"credential-store file"),process.platform!=="win32"){a.default.fchmodSync(t,384);let o=a.default.fstatSync(t);if((o.mode&63)!==0)throw new Error("credential-store file could not be made owner-only");return o}return n}function ri(e,t){if(t.size>_e)throw new Error("credential-store file exceeds the maximum supported size");let n=Buffer.alloc(_e+1),r=0;for(;r<n.length;){let i=a.default.readSync(e,n,r,n.length-r,null);if(i===0)break;r+=i}if(r>_e)throw new Error("credential-store file exceeds the maximum supported size");return n.subarray(0,r).toString("utf8")}function fn(e){let t=null;try{try{t=a.default.openSync(e,a.default.constants.O_RDONLY|(a.default.constants.O_NOFOLLOW??0)|(a.default.constants.O_NONBLOCK??0))}catch(i){if(h(i,"ENOENT"))try{if(a.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(h(o,"ENOENT"))return null;throw o}throw i}let n=a.default.fstatSync(t),r=O(e,t,n);return ri(t,r)}finally{t!==null&&a.default.closeSync(t)}}function pn(e){let t=null;try{try{t=a.default.openSync(e,a.default.constants.O_RDONLY|(a.default.constants.O_NOFOLLOW??0)|(a.default.constants.O_NONBLOCK??0))}catch(i){if(h(i,"ENOENT")&&Sn(e))return;throw i}let n=a.default.fstatSync(t),r=O(e,t,n);x(e,r)}finally{t!==null&&a.default.closeSync(t)}wn(m.dirname(e))}function ii(e){let t;try{t=a.default.lstatSync(e)}catch(n){if(h(n,"ENOENT"))return;throw n}if(t.isSymbolicLink()||!t.isFile())throw new Error("credential-store replacement target must be a regular file");if(t.nlink!==1)throw new X;Z(t,"credential-store replacement target")}function oi(e,t){for(let n=0;n<8;n+=1){let r=(0,rt.randomBytes)(12).toString("hex"),i=m.join(e,`.${t}.${process.pid}.${r}.tmp`);try{return{fd:a.default.openSync(i,a.default.constants.O_CREAT|a.default.constants.O_EXCL|a.default.constants.O_WRONLY|(a.default.constants.O_NOFOLLOW??0),384),tempPath:i}}catch(o){if(h(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function An(e,t){let n=0;for(;n<t.length;){let r=a.default.writeSync(e,t,n,t.length-n,null);if(!Number.isSafeInteger(r)||r<=0)throw new Error("credential-store temp file write made no progress");n+=r}}function wn(e){if(process.platform==="win32")return;let t=null;try{t=a.default.openSync(e,a.default.constants.O_RDONLY|(a.default.constants.O_DIRECTORY??0)|(a.default.constants.O_NOFOLLOW??0)),a.default.fsyncSync(t)}catch{}finally{if(t!==null)try{a.default.closeSync(t)}catch{}}}function si(e,t){let n=Buffer.from(t,"utf8");if(n.length>_e)throw new Error("credential-store file exceeds the maximum supported size");let r=m.dirname(e),i=m.basename(e),o=null,s=null,l=!1;try{let u=oi(r,i);o=u.fd,s=u.tempPath;let d=a.default.fstatSync(o);if((O(s,o,d).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");An(o,n),a.default.fsyncSync(o),O(s,o,a.default.fstatSync(o));let g=o;o=null,a.default.closeSync(g),ii(e),a.default.renameSync(s,e),l=!0}finally{if(o!==null)try{a.default.closeSync(o)}catch{}if(!l&&s!==null)try{a.default.unlinkSync(s)}catch{}}wn(r)}function ai(e){return m.join(m.dirname(e),`.${m.basename(e)}.lock`)}function li(e){return m.join(m.dirname(e),`.${m.basename(e)}.lock-recovery`)}function ci(e,t){if(t.size>tt)return null;let n=Buffer.alloc(tt+1),r=0;for(;r<n.length;){let o=a.default.readSync(e,n,r,n.length-r,null);if(o===0)break;r+=o}if(r>tt)return null;let i;try{i=JSON.parse(n.subarray(0,r).toString("utf8"))}catch{return null}return typeof i!="object"||i===null||!Number.isSafeInteger(i.pid)||(i.pid??0)<=0||typeof i.nonce!="string"||!/^[a-f0-9]{24}$/.test(i.nonce??"")||typeof i.target!="string"?null:i}function x(e,t){let n=a.default.lstatSync(e);if(n.isSymbolicLink()||!n.isFile()||!Q(n,t))throw new Error("credential-store lock changed while it was being inspected");Z(n,"credential-store lock"),a.default.unlinkSync(e)}function gn(e,t){let n=null;try{try{n=a.default.openSync(e,a.default.constants.O_RDONLY|(a.default.constants.O_NOFOLLOW??0)|(a.default.constants.O_NONBLOCK??0))}catch(u){if(h(u,"ENOENT"))try{let d=a.default.lstatSync(e);throw d.isSymbolicLink()||!d.isFile()?new Error("credential-store lock must be a real regular file"):new A}catch(d){if(h(d,"ENOENT"))return{state:"absent"};throw d}throw u}let r=a.default.fstatSync(n),i=O(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=ci(n,i);return{state:(o?.target===t&&o?!En(o.pid):Date.now()-i.mtimeMs>=Zr)?"stale":"active",stats:i}}finally{n!==null&&a.default.closeSync(n)}}function ui(e,t){for(let n=0;n<8;n+=1){let r=(0,rt.randomBytes)(12).toString("hex"),i=m.join(e,`.${t}.${process.pid}.${r}.lock-claim`),o={pid:process.pid,nonce:r,target:t},s=null;try{s=a.default.openSync(i,a.default.constants.O_CREAT|a.default.constants.O_EXCL|a.default.constants.O_WRONLY|(a.default.constants.O_NOFOLLOW??0),384);let l=a.default.fstatSync(s),u=O(i,s,l,{allowMultipleLinks:!0});return An(s,Buffer.from(JSON.stringify(o),"utf8")),a.default.fsyncSync(s),{claimPath:i,metadata:o,stats:u}}catch(l){if(h(l,"EEXIST"))continue;try{a.default.unlinkSync(i)}catch{}throw l}finally{s!==null&&a.default.closeSync(s)}}throw new Error("could not allocate a unique credential-store lock claim")}function di(e,t){let n;try{n=a.default.openSync(e,a.default.constants.O_RDONLY|(a.default.constants.O_NOFOLLOW??0)|(a.default.constants.O_NONBLOCK??0))}catch(r){throw h(r,"ENOENT")?new A:r}try{let r=a.default.fstatSync(n),i=O(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!Q(i,t))throw new A;return{fd:n,lockPath:e,stats:i}}catch(r){throw a.default.closeSync(n),r}}function hn(e){let t=null;try{try{t=a.default.openSync(e,a.default.constants.O_RDONLY|(a.default.constants.O_NOFOLLOW??0)|(a.default.constants.O_NONBLOCK??0))}catch(n){if(h(n,"ENOENT"))try{let r=a.default.lstatSync(e);throw r.isSymbolicLink()||!r.isFile()?new Error("credential-store recovery gate must be a real regular file"):new A}catch(r){if(h(r,"ENOENT"))return!1;throw r}throw n}return O(e,t,a.default.fstatSync(t),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{t!==null&&a.default.closeSync(t)}}function fi(e){let t;try{t=a.default.openSync(e,a.default.constants.O_CREAT|a.default.constants.O_EXCL|a.default.constants.O_RDWR|(a.default.constants.O_NOFOLLOW??0),384)}catch(r){if(h(r,"EEXIST"))return null;throw r}let n=null;try{n=a.default.fstatSync(t);let r=O(e,t,n,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:t,lockPath:e,stats:r}}catch(r){if(n!==null)try{x(e,n)}catch{}throw a.default.closeSync(t),r}}function N(e,t){if(Date.now()>=e)throw t?new Error("credential-store recovery gate remained present past the bounded wait; a previous lock reclaimer may have crashed, so automatic recovery is intentionally disabled and manual inspection/removal is required"):new Error("credential-store lock remained busy past the bounded wait");ti(Xr)}function mn(e){let t=m.dirname(e),n=m.basename(e),r=ai(e),i=li(e),o=ui(t,n),s=Date.now()+Vr,l=!1,u=!1,d=null,f;try{for(;d===null;)try{if(hn(i)){N(s,!0);continue}a.default.linkSync(o.claimPath,r),u=!0,d=di(r,o.stats),l=!0}catch(g){if(u&&!l){try{x(r,o.stats)}catch{}u=!1}if(g instanceof A){N(s,!1);continue}if(!h(g,"EEXIST"))throw g;let w;try{w=gn(r,n)}catch(k){if(k instanceof A){N(s,!1);continue}throw k}if(w.state==="absent")continue;if(w.state==="stale"){let k;try{k=fi(i)}catch(S){if(S instanceof A){N(s,!1);continue}throw S}if(k!==null){try{let S;try{S=gn(r,n)}catch(te){if(te instanceof A){N(s,!1);continue}throw te}S.state==="stale"&&x(r,S.stats)}finally{nt(k)}continue}}let _;try{_=hn(i)}catch(k){if(k instanceof A){N(s,!1);continue}throw k}N(s,_)}}catch(g){f=g}try{x(o.claimPath,o.stats)}catch(g){!h(g,"ENOENT")&&!l&&f===void 0&&(f=g)}if(f!==void 0)throw f;if(d===null)throw new Error("credential-store lock acquisition failed");return d}function nt(e){try{x(e.lockPath,e.stats)}finally{a.default.closeSync(e.fd)}}function pi(e,t){let n=ni(t),r=new RegExp(`^\\.${n}\\.(\\d+)\\.[a-f0-9]{24}\\.tmp$`).exec(e)??new RegExp(`^\\.${n}\\.(\\d+)\\.[a-f0-9]{24}\\.lock-claim$`).exec(e);if(!r)return null;let i=Number(r[1]);return Number.isSafeInteger(i)&&i>0?i:null}function _n(e){let t=m.dirname(e),n=m.basename(e);for(let r of a.default.readdirSync(t)){let i=pi(r,n);if(i===null||En(i))continue;let o=m.join(t,r),s=null;try{try{s=a.default.openSync(o,a.default.constants.O_RDONLY|(a.default.constants.O_NOFOLLOW??0)|(a.default.constants.O_NONBLOCK??0))}catch(d){if(h(d,"ENOENT")||h(d,"ELOOP"))continue;throw d}let l=a.default.fstatSync(s),u=a.default.lstatSync(o);if(!l.isFile()||u.isSymbolicLink()||!u.isFile()||!Q(l,u))continue;try{Z(l,"credential-store orphan")}catch{continue}x(o,l)}catch(l){if(!h(l,"ENOENT"))throw l}finally{s!==null&&a.default.closeSync(s)}}}function ee(e,t,n){if(!Se()){if(t.allowUnsupportedPlatformCleanup){if(t.createParent)throw v();if(!dn(e,!1))return n({read:()=>null,remove:()=>{},write:()=>{throw v()}});let s=mn(e);try{return _n(e),n({read:()=>fn(e),remove:()=>pn(e),write:()=>{throw v()}})}finally{nt(s)}}if(!t.createParent){let o=!1;try{o=Sn(e)}catch{throw v()}if(o)return n({read:()=>null,remove:()=>{},write:()=>{throw v()}})}throw v()}if(!dn(e,t.createParent))return n({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let i=mn(e);try{return _n(e),n({read:()=>fn(e),remove:()=>pn(e),write:o=>si(e,o)})}finally{nt(i)}}var it="allscale-cli";function lt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ln(e){return lt(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function D(e){return new c("internal",`The session credential store in the ${e} exists but could not be read as valid credential data. Refusing to treat it as empty or overwrite it; session credentials may still remain on this machine.`)}function ot(){return new c("internal","The session credential store in the plaintext file has multiple hard links. Refusing to read, modify, or delete it because another directory entry may retain session credentials. Remove every extra hard link, then re-run the command. If you intentionally keep a deduplicated backup, revoke or rotate its credentials before treating logout as complete.")}function Ee(){return new c("internal","The session credential store in the plaintext file could not be written safely. Any previous credential file was left unchanged.")}var B,st=!1;function gi(){return Ft()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function hi(e){if(typeof e!="object"||e===null||e.code!=="MODULE_NOT_FOUND")return!1;let t=e.message;return typeof t=="string"&&t.split(`
|
|
16
|
+
`,1)[0]==="Cannot find module 'keytar'"}function mi(){if(B!==void 0)return B;if(gi())return st=!1,B=null,B;try{B=require("keytar"),st=!1}catch(e){st=!hi(e),B=null}return B}function kn(){let e=Se()?"Re-run with --insecure-storage (or set ALLSCALE_INSECURE_STORAGE=1) to use the owner-only plaintext credential file.":"Plaintext credential fallback is unavailable on Windows because owner-only ACLs cannot be verified; use Windows Credential Manager.";return new c("storage.unavailable","OS keychain could not be accessed on this system (keytar / libsecret may be unavailable, locked, or unusable). "+e+" Never silently downgrade in production.")}async function at(e){try{return await e()}catch{throw kn()}}var ct=class{constructor(t){this.keytar=t}keytar;kind="keychain";async read(t){let n=await at(()=>this.keytar.getPassword(it,t));if(n===null)return null;let r;try{r=JSON.parse(n)}catch{throw D("OS keychain")}if(!Ln(r))throw D("OS keychain");return r}async get(t){return this.read(t)}async set(t,n){await this.read(t),await at(()=>this.keytar.setPassword(it,t,JSON.stringify(n)))}async delete(t){await this.read(t),await at(()=>this.keytar.deletePassword(it,t))}},_i="credentials.json",ut=class{kind="insecure-file";filePath;constructor(t){this.filePath=t??bn.join(qe(),_i)}read(t){let n;try{n=t.read()}catch(i){throw ye(i)?ot():D("plaintext file")}if(n===null)return{profiles:{}};let r;try{r=JSON.parse(n)}catch{throw D("plaintext file")}if(!lt(r)||!lt(r.profiles))throw D("plaintext file");return r}write(t,n){try{t.write(JSON.stringify(n,null,2))}catch(r){throw ye(r)?ot():Ee()}}profileTokens(t,n){let r=t.profiles[n];if(r!==void 0){if(!Ln(r))throw D("plaintext file");return r}}async get(t){try{return ee(this.filePath,{createParent:!1},n=>this.profileTokens(this.read(n),t)??null)}catch(n){throw n instanceof c?n:D("plaintext file")}}async set(t,n){try{ee(this.filePath,{createParent:!0},r=>{let i=this.read(r);this.profileTokens(i,t),i.profiles[t]=n,this.write(r,i)})}catch(r){throw r instanceof c?r:Ee()}}async delete(t){try{ee(this.filePath,{createParent:!1},n=>{let r=this.read(n);this.profileTokens(r,t)!==void 0&&(delete r.profiles[t],this.write(n,r))})}catch(n){throw n instanceof c?n:Ee()}}async clearProfile(t){try{return ee(this.filePath,{createParent:!1,allowUnsupportedPlatformCleanup:!0},n=>{let r=this.read(n);return this.profileTokens(r,t)===void 0?!1:(delete r.profiles[t],Object.keys(r.profiles).length===0?n.remove():this.write(n,r),!0)})}catch(n){throw n instanceof c?n:ye(n)?ot():Ee()}}};function Tn(e){if(e.insecureStorage)return yn(),new ut(e.insecureFilePath);let t=mi();if(t)return new ct(t);throw kn()}0&&(module.exports={AllscaleCommand,AllscaleError,Args,Flags,Transport,decodeJwt,isExpired,pickTokenStore});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
package/dist/lib/help.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var w=Object.create;var c=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var N=(t,e)=>{for(var n in e)c(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of L(e))!C.call(t,o)&&o!==n&&c(t,o,{get:()=>e[o],enumerable:!(r=O(e,o))||r.enumerable});return t};var l=(t,e,n)=>(n=t!=null?w(I(t)):{},S(e||!t||!t.__esModule?c(n,"default",{value:t,enumerable:!0}):n,t)),$=t=>S(c({},"__esModule",{value:!0}),t);var U={};N(U,{default:()=>d});module.exports=$(U);var u=require("@oclif/core");var s=l(require("fs")),h=l(require("path")),k=l(require("crypto"));var m=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,f=String.raw`(?:proxy[_-]?)?authorization`,M=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${f}"|'${f}'|${f})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${m}`,"gi");var p=String.raw`(?:password|passwd|passphrase|otp(?:[_-]?code)?|signature|hmac|sig|session[_-]?id|mnemonic|seed|cookie|bearer|(?:[A-Za-z0-9]+[_-])*(?:token|secret)|(?:api|access|private|signing)[_-]?key|credential|claim[_-]?url)`,G=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${p}"|'${p}'|${p})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${m}`,"gi"),g=String.raw`(?:[A-Za-z0-9]+(?:Token|Secret)|[Oo][Tt][Pp]Code|[Ss]essionId|(?:api|API|access|Access|private|Private|signing|Signing)Key|[Cc]laimUrl)`,z=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${g}"|'${g}'|${g})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${m}`,"g");var j=8*1024;var P=require("process");var W=64*1024*1024;function T(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function y(t=!1){let e=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return t||T()||!e}function B(t){return t instanceof Error&&/^Command .+ not found\.$/.test(t.message)}var R=["REQUIRED","REQUIRED (ONE OF)","CONDITIONAL"],_=class extends u.CommandHelp{groupFlags(e){let{flagGroups:n,mainFlags:r}=super.groupFlags(e),o={},E=!1;for(let i of R){let a=n[i];a&&a.length>0&&(o[i]=a,E=!0)}let A=r;E&&r.length>0&&(o.OPTIONAL=r,A=[]);let b=new Set([...R,"OPTIONAL","GLOBAL"]);for(let[i,a]of Object.entries(n))b.has(i)||(o[i]=a);return n.GLOBAL&&(o.GLOBAL=n.GLOBAL),{flagGroups:o,mainFlags:A}}},d=class extends u.Help{CommandHelpClass=_;async showHelp(e){if(!e.some(r=>r==="--help"||r==="-h")&&y(this.jsonModeRequested())){this.emitInputInvalid(e.length===0?"No command given. Run `allscale --help` to list commands, or pass --help for usage.":`\`${e.join(" ")}\` is a topic, not a runnable command. Run it with \`--help\` to list its subcommands.`);return}try{return await super.showHelp(e)}catch(r){if(!B(r))throw r;this.emitInputInvalid(`Unknown command \`${e.filter(o=>!o.startsWith("-")).join(" ")}\`. Run \`allscale --help\` to list available commands.`);return}}emitInputInvalid(e){let n=this.jsonModeRequested()?void 0:2;process.stderr.write(`${JSON.stringify({error:{code:"input.invalid",message:e}},null,n)}
|
|
2
|
+
`),process.exitCode=2}jsonModeRequested(){let e=process.argv.slice(2),n=e.indexOf("--"),r=e.indexOf("--json");return r!==-1&&(n===-1||r<n)?!0:this.config.scopedEnvVar?.("CONTENT_TYPE")?.toLowerCase()==="json"}};
|
|
3
|
+
//# sourceMappingURL=help.js.map
|