@allscale/cli 0.1.0 → 1.0.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 +113 -41
- package/bin/dev.js +11 -1
- package/bin/run-oclif.js +216 -27
- package/bin/run.js +19 -1
- package/dist/commands/build-info.js +13 -13
- package/dist/commands/claim-link/claim.js +14 -14
- package/dist/commands/claim-link/create.js +40 -37
- package/dist/commands/claim-link/get.js +26 -15
- package/dist/commands/claim-link/list.js +15 -15
- package/dist/commands/claim-link/status.js +13 -13
- package/dist/commands/describe.js +13 -13
- package/dist/commands/device-login.js +23 -24
- package/dist/commands/invoice/get.js +15 -15
- package/dist/commands/invoice/list.js +16 -16
- package/dist/commands/invoice/pay.js +40 -41
- package/dist/commands/invoice/received.js +16 -16
- package/dist/commands/invoice/send.js +42 -34
- package/dist/commands/invoice/sent.js +15 -15
- package/dist/commands/invoice/update.js +17 -15
- package/dist/commands/logout.js +14 -14
- package/dist/commands/operations.js +13 -13
- package/dist/commands/otp-login.js +21 -20
- package/dist/commands/otp-send.js +13 -13
- package/dist/commands/payout/send.js +14 -14
- package/dist/commands/payout/status.js +15 -15
- package/dist/commands/scope.js +17 -16
- package/dist/commands/store/create.js +17 -17
- package/dist/commands/transaction/get.js +15 -15
- package/dist/commands/transaction/list.js +15 -15
- package/dist/commands/wallet/list.js +15 -15
- package/dist/commands/wallet/send.js +40 -43
- package/dist/commands/whoami.js +14 -14
- package/dist/hooks/version-suffix.js +1 -1
- package/dist/index.js +14 -14
- package/dist/lib/help.js +7 -2
- package/dist/lib/output/audit-lifecycle.js +7 -0
- package/oclif.manifest.json +123 -292
- package/package.json +4 -6
- package/dist/commands/claim-link/preview.js +0 -18
package/dist/commands/logout.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).some(t=>
|
|
3
|
-
`)}var f=
|
|
4
|
-
`)}else
|
|
5
|
-
`);return}
|
|
6
|
-
`);return}f.appendFileSync(
|
|
7
|
-
`)}catch(r){if(
|
|
8
|
-
`)}catch{}}}function
|
|
9
|
-
The CLI default is now ${
|
|
1
|
+
"use strict";var ln=Object.create;var oe=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty;var pn=(e,t)=>{for(var n in t)oe(e,n,{get:t[n],enumerable:!0})},Ve=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of un(t))!fn.call(e,i)&&i!==n&&oe(e,i,{get:()=>t[i],enumerable:!(r=cn(t,i))||r.enumerable});return e};var E=(e,t,n)=>(n=e!=null?ln(dn(e)):{},Ve(t||!e||!e.__esModule?oe(n,"default",{value:e,enumerable:!0}):n,e)),gn=e=>Ve(oe({},"__esModule",{value:!0}),e);var Ur={};pn(Ur,{default:()=>_e});module.exports=gn(Ur);var L=require("@oclif/core");var Qe="public",et="https://app.allscale.io";var tt=["https://app.allscale.io"];var Ae="Override the API base URL (public builds accept only https://app.allscale.io)";var Ee="Only https://app.allscale.io is allowed, and URL userinfo is forbidden.";function nt(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 rt(e){return nt(e)!==null}function we(e){let t=nt(e);return t!==null&&tt.includes(t.origin)}function z(){return"".trim()||void 0}function J(){return"public"}function it(e){try{let{hostname:t}=new URL(e);return t==="127.0.0.1"||t==="localhost"||t==="[::1]"}catch{return!1}}function ot(){{let e="[]".trim();if(e.length===0)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}return be()}function be(){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:a,key:l,keyId:u}=o;if(typeof a!="string"||a.trim().length===0||typeof l!="string"||l.trim().length===0)continue;let d=typeof u=="string"?u.trim():"";i.push({base:a.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 hn="device-login",mn=/^[A-Za-z0-9._-]{1,64}$/;function yn(e){return mn.test(e)?e:"<profile>"}function at(e){return`Unknown profile '${e}' \u2014 no such profile is saved on this machine. Check the spelling first; to deliberately create '${e}', run \`allscale ${hn} --profile ${yn(e)}\`.`}var Sn={"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_op_expired":3,"wallet.bridge_invalid_response":9,"wallet.transaction_reverted":12,"wallet.transaction_status_unknown":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 Te(e){return(typeof e=="string"?e:String(e??"")).replace(_n,"")}var An=64;function Le(e,t=new Map,n=0){if(typeof e=="string")return Te(e);if(e===null||typeof e!="object")return e;let r=t.get(e);if(r!==void 0)return r;if(n>=An)return e;if(Array.isArray(e)){let a=[];t.set(e,a);for(let l of e)a.push(Le(l,t,n+1));return a}let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&i!==null)return e;let o={};t.set(e,o);for(let[a,l]of Object.entries(e))Object.defineProperty(o,a,{value:Le(l,t,n+1),writable:!0,enumerable:!0,configurable:!0});return o}var c=class extends Error{code;details;constructor(t,n,r){super(Te(n)),this.code=t,this.details=r&&Le(r),this.name="AllscaleError"}get exitCode(){return Sn[this.code]}toJSON(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}};function lt(e){if(e instanceof c)return e;if(e instanceof Error){if(bn(e)){let t=kn(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 En=new Set(["CLIError","CLIParseError","RequiredArgsError","RequiredFlagError","UnexpectedArgsError","FlagInvalidOptionError","ArgInvalidOptionError","InvalidArgsSpecError"]),wn=[/^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 bn(e){if(Ln(e))return!0;let t=e.name??"";return En.has(t)?t==="CLIError"?ke(e,"parse")||st(e.message):!0:st(e.message)}function Ln(e){if(!ke(e,"oclif"))return!1;let t=e.oclif;return typeof t=="object"&&t!==null&&t.exit===2&&ke(e,"parse")}function st(e){return e?Te(e).split(`
|
|
2
|
+
`).some(t=>wn.some(n=>n.test(t.trim()))):!1}function ke(e,t){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,t)}function kn(e){let t=e,n={};for(let r of["code","exitCode","suggestions","ref"])t[r]!==void 0&&(n[r]=t[r]);return n}function ct(e){process.stdout.write(`${JSON.stringify({data:e},null,2)}
|
|
3
|
+
`)}var f=E(require("fs")),ae=E(require("path")),_t=E(require("crypto"));var Tn="...<truncated>",On=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+/g,Cn=/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,Pe=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,Oe=String.raw`(?:proxy[_-]?)?authorization`,In=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Oe}"|'${Oe}'|${Oe})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${Pe}`,"gi"),vn=/\b(https?:\/\/)[^\s/?#]+@/gi,Pn=String.raw`(?:[A-Za-z0-9]+[_-])*`,Rn=String.raw`(?:[A-Za-z0-9]{1,32}[_-]){0,8}`,dt=e=>String.raw`(?:password|passwd|passphrase|otp(?:[_-]?code)?|signature|hmac|sig|session[_-]?id|mnemonic|seed|cookie|bearer|${e}(?:token|secret)|(?:api|access|private|signing)[_-]?key|credential|claim[_-]?url)`,ut=dt(Pn),Nn=dt(Rn),xn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${ut}"|'${ut}'|${Nn})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${Pe}`,"gi"),Ce=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)`,Bn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Ce}"|'${Ce}'|${Ce})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${Pe}`,"g");function ft(e){return e.replace(vn,"$1<redacted>@").replace(On,"<redacted-jwt>").replace(In,"$1$2$3<redacted>").replace(xn,"$1$2<redacted>").replace(Bn,"$1$2<redacted>").replace(Cn,"Bearer <redacted>")}var Un=/(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 pt(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Un.test(t)}function gt(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 ht(e,t,n=Tn){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 m=Buffer.byteLength(d,"utf8");if(u+m>t)break;l+=d,u+=m}return l}let i=t-r,o="",a=0;for(let l of e){let u=Buffer.byteLength(l,"utf8");if(a+u>i)break;o+=l,a+=u}return`${o}${n}`}function y(e,t=16384){return ht(gt(ft(e)),t)}var Ie=100,Dn=8,Fn=8*1024;function se(){return{remaining:Fn}}function ve(e,t){let n=Math.min(16384,t.remaining),r=ht(e,n);return t.remaining-=Buffer.byteLength(r,"utf8"),r}function U(e,t,n=0,r={}){if(n>Dn)return ve("<truncated>",t);if(typeof e=="string"){let i=ft(e);return ve(r.escapeControls?gt(i):i,t)}if(Array.isArray(e)){let i=e.slice(0,Ie),o=i.map(a=>U(a,t,n+1,r));return e.length>i.length&&o.push(ve(`<${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[a,l]of o.slice(0,Ie))i[a]=U(l,t,n+1,r);return o.length>Ie&&(i.output_truncated=!0),i}return e}var Re=require("process");var Ne=!1;function xe(e){Ne=e}function yt(){return Ne}var mt="1";function F(e,t){if(Ne){let n={...e};delete n.version;let r=se(),i={event:n.event,...n},o=U(i,r,0,{escapeControls:!0}),a=JSON.stringify({version:mt,...o});Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:mt,event:o.event,output_truncated:!0})),Re.stderr.write(`${a}
|
|
4
|
+
`)}else Re.stderr.write(t)}var St="2",$=null,A=null,M=!1,q=!1;function $n(){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=_t.randomBytes(4).toString("hex");return ae.join(t,`allscale-output-${n}-${r}.ndjson`)}return null}var Be=64*1024*1024,Mn=null;function Ue(e={}){if(e.quiet&&(q=!0),M)return;let t=$n();if(!t)return;$=null;let n=null;try{if((Mn??process.platform)==="win32")throw new Error("owner-only sidecar ACLs cannot be enforced on Windows; sidecar output is disabled");let r=ae.dirname(t);if(f.mkdirSync(r,{recursive:!0,mode:448}),!process.env.ALLSCALE_OUTPUT_FILE_PATH&&process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY){let u=f.statSync(r),d=u.mode&511;if(!u.isDirectory()||(d&63)!==0)throw new Error(`output directory must be owner-only (no group/other permissions); current mode is ${d.toString(8).padStart(3,"0")}`)}let i=f.constants.O_NOFOLLOW??0;n=f.openSync(t,f.constants.O_APPEND|f.constants.O_CREAT|f.constants.O_WRONLY|(f.constants.O_NONBLOCK??0)|i,384);let o=f.fstatSync(n),a=f.lstatSync(t);if(!o.isFile()||a.isSymbolicLink()||a.dev!==o.dev||a.ino!==o.ino)throw new Error("target changed while it was being opened or is not a regular file");if(typeof process.geteuid=="function"&&o.uid!==process.geteuid())throw new Error("existing sidecar file is not owned by the current effective user");let l=o.mode&511;if((l&63)!==0)throw new Error(`existing sidecar file must already be owner-only; current mode is ${l.toString(8).padStart(3,"0")}. Rotate or remove it before retrying`);f.fchmodSync(n,384)}catch(r){if(n!==null)try{f.closeSync(n)}catch{}q||F({event:"sidecar_disabled",reason:"open_failed",detail:y(`sidecar path '${t}' could not be opened safely (${r.message})`)},`${y(`[allscale] sidecar path '${t}' could not be opened safely (${r.message}); refusing to write. Sidecar disabled for this run.`)}
|
|
5
|
+
`);return}$=t,A=n,M=!0}var Gn=[/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 Yn(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Gn.some(n=>n.test(t))}function Kn(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=jn(t.pathname);let i=n;t.pathname!==r&&(i=!0);for(let[o]of t.searchParams)Yn(o)&&(t.searchParams.set(o,"<redacted>"),i=!0);return i?t.toString():e}catch{return e}}function jn(e){return e.replace(/(\/(?:api\/)?(?:v1\/)?public\/claim-links\/)([^/:]+)(:claim)?(?=\/?$)/,"$1<redacted>$3").replace(/(\/(?:api\/)?public\/claim-links\/)([^/]+)(\/claim)(?=\/?$)/,"$1<redacted>$3")}function Hn(e){return(e.type==="request"||e.type==="bridge_browser_open")&&typeof e.url=="string"?{...e,url:Kn(e.url)}:e}function Wn(e){let t=new Date().toISOString(),n=e,{type:r,...i}=n,o=U(i,se()),a=JSON.stringify({version:St,timestamp:t,type:r,...o});return Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:St,timestamp:t,type:r,output_truncated:!0})),a}function G(e){if(!M||!$||A===null)return;let t=Hn(e),n=Wn(t);try{if(f.fstatSync(A).size+Buffer.byteLength(n,"utf8")+1>Be){M=!1;try{f.closeSync(A)}catch{}A=null,q||F({event:"sidecar_disabled",reason:"size_limit",...$===null?{}:{path:y($)},max_bytes:Be},`${y(`[allscale] sidecar exceeded ${Be} bytes; disabling it for the rest of this run. Rotate or remove ${$}, or point ALLSCALE_OUTPUT_FILE_DIRECTORY at a directory so each run gets its own file.`)}
|
|
6
|
+
`);return}f.appendFileSync(A,`${n}
|
|
7
|
+
`)}catch(r){if(M=!1,A!==null){try{f.closeSync(A)}catch{}A=null}try{q||F({event:"sidecar_disabled",reason:"write_failed",detail:y(r.message)},`${y(`[allscale] sidecar write failed (${r.message}); disabling sidecar for the rest of this run.`)}
|
|
8
|
+
`)}catch{}}}function At(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function X(){if(q=!1,M=!1,A!==null){try{f.closeSync(A)}catch{}A=null}}function Et(e=!1){let t=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||At()||!t}var Z=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"]),zn=new Set(Array.from(Z).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2)),Jn=Array.from(Z).filter(e=>e.startsWith("--")).sort((e,t)=>t.length-e.length),qn=new Set(["--otp-stdin","--password-stdin"]);function De(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r.startsWith("-")){let o=r.indexOf("=");if(o!==-1){let a=r.slice(0,o);if(Z.has(a)){t.push(`${a}=<redacted>`);continue}}}if(Z.has(r)){t.push(r),n+1<e.length&&(Z.has(e[n+1])||(t.push("<redacted>"),n+=1));continue}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>2&&r[1]!=="="){let o=r.slice(0,2);if(zn.has(o)){t.push(`${o}<redacted>`);continue}}let i=qn.has(r)?void 0:Jn.find(o=>r.length>o.length&&r.startsWith(o));if(i){t.push(`${i}<redacted>`);continue}t.push(r)}return t}function wt(e){G({type:"error",code:e.code,message:y(e.message)}),G({type:"command-end",ok:!1,exitCode:e.exitCode}),X()}var V=z()??et,K={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 le(e){return rt(e)?new URL(e).origin:null}function j(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return"<unparseable URL>"}}function bt(){let e=process.env[K.TOKEN]?.trim();return e&&e.length>0?e:void 0}function Fe(){let e=process.env[K.PROFILE]?.trim();return e&&e.length>0?e:void 0}function ce(){let e=process.env[K.API_BASE]?.trim();return e&&e.length>0?e:void 0}function Lt(){let e=process.env[K.INSECURE_STORAGE]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function kt(){let e=process.env[K.NO_KEYCHAIN]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Tt(){let e=process.env[K.ALLOW_RAW]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Ot(e){let{resolvedApiBase:t,fromExplicitOverride:n,profileApiBase:r,profileApiBaseSource:i}=e;if(z()===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
10
|
so this session still uses staging. That pin was written before the default changed, so it may just be
|
|
11
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:
|
|
14
|
-
`}var
|
|
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"]),Kn=new Set(Array.from(ue).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2));function Hn(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(Kn.has(i)){t.push(`${i}<redacted>`);continue}}t.push(r)}return t}var jn=/(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 Wn(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return jn.test(t)}var Jn=/_(removed|cleared|count|total)$/i;function zn(e,t){return typeof t=="number"&&Jn.test(e)}var qn=new Set(Ct);function Vn(e,t){return e==="token_symbol"&&typeof t=="string"&&qn.has(t)}var ce=100;function $e(e,t=0){if(t>8)return"<truncated>";if(Array.isArray(e)){let n=e.slice(0,ce),r=n.map(i=>$e(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]=Wn(i)&&!zn(i,o)&&!Vn(i,o)?"<redacted>":$e(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"?_(e):e}function Xn(e){let t=pt()?void 0:2,n=$e(e.toJSON()),r=JSON.stringify(n,null,t);return Buffer.byteLength(r,"utf8")+1<=65536?r:JSON.stringify({error:{code:e.code,message:_(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,t)}function Zn(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 Yt=w(require("path"));var Ye=require("crypto"),s=w(require("fs")),h=w(require("path"));var de=1024*1024,Qn=5e3,er=20,tr=3e4,Me=4096,nr=new Int32Array(new SharedArrayBuffer(4)),Z=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function O(e){return e instanceof Z}var S=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},rr=null;function H(){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 j(){return(rr??process.platform)!=="win32"}function Ft(e){try{return s.default.lstatSync(e),!1}catch(t){if(!g(t,"ENOENT"))throw t}try{let t=s.default.lstatSync(h.dirname(e));return!t.isSymbolicLink()&&t.isDirectory()}catch(t){if(g(t,"ENOENT"))return!0;throw t}}function g(e,t){return typeof e=="object"&&e!==null&&e.code===t}function Q(e,t){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${t} is not owned by the current effective user`)}function ee(e,t){return e.dev===t.dev&&e.ino===t.ino}function ir(e){Atomics.wait(nr,0,0,e)}function $t(e){try{return process.kill(e,0),!0}catch(t){return!g(t,"ESRCH")}}function or(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vt(e,t){let n=h.dirname(e);t&&s.default.mkdirSync(n,{recursive:!0,mode:448});let r;try{r=s.default.lstatSync(n)}catch(o){if(!t&&g(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=s.default.openSync(n,s.default.constants.O_RDONLY|(s.default.constants.O_DIRECTORY??0)|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0));let o=s.default.fstatSync(i),a=s.default.lstatSync(n);if(!o.isDirectory()||a.isSymbolicLink()||!a.isDirectory()||!ee(o,a))throw new Error("credential-store parent changed while it was being inspected");Q(o,"credential-store parent");let l=o;if((o.mode&63)!==0&&h.basename(n)===".allscale"&&(s.default.fchmodSync(i,448),l=s.default.fstatSync(i)),(l.mode&63)!==0)throw new Error("credential-store parent must not grant group or other permissions")}finally{i!==null&&s.default.closeSync(i)}return!0}function k(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=s.default.lstatSync(e)}catch(o){throw r.retryOnPathChange&&g(o,"ENOENT")?new S:o}if(!ee(n,i))throw r.retryOnPathChange?new S: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 Z;if(Q(n,"credential-store file"),process.platform!=="win32"){s.default.fchmodSync(t,384);let o=s.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 sr(e,t){if(t.size>de)throw new Error("credential-store file exceeds the maximum supported size");let n=Buffer.alloc(de+1),r=0;for(;r<n.length;){let i=s.default.readSync(e,n,r,n.length-r,null);if(i===0)break;r+=i}if(r>de)throw new Error("credential-store file exceeds the maximum supported size");return n.subarray(0,r).toString("utf8")}function Rt(e){let t=null;try{try{t=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(i){if(g(i,"ENOENT"))try{if(s.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(g(o,"ENOENT"))return null;throw o}throw i}let n=s.default.fstatSync(t),r=k(e,t,n);return sr(t,r)}finally{t!==null&&s.default.closeSync(t)}}function Nt(e){let t=null;try{try{t=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(i){if(g(i,"ENOENT")&&Ft(e))return;throw i}let n=s.default.fstatSync(t),r=k(e,t,n);C(e,r)}finally{t!==null&&s.default.closeSync(t)}Gt(h.dirname(e))}function ar(e){let t;try{t=s.default.lstatSync(e)}catch(n){if(g(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 Z;Q(t,"credential-store replacement target")}function lr(e,t){for(let n=0;n<8;n+=1){let r=(0,Ye.randomBytes)(12).toString("hex"),i=h.join(e,`.${t}.${process.pid}.${r}.tmp`);try{return{fd:s.default.openSync(i,s.default.constants.O_CREAT|s.default.constants.O_EXCL|s.default.constants.O_WRONLY|(s.default.constants.O_NOFOLLOW??0),384),tempPath:i}}catch(o){if(g(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function Mt(e,t){let n=0;for(;n<t.length;){let r=s.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 Gt(e){if(process.platform==="win32")return;let t=null;try{t=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_DIRECTORY??0)|(s.default.constants.O_NOFOLLOW??0)),s.default.fsyncSync(t)}catch{}finally{if(t!==null)try{s.default.closeSync(t)}catch{}}}function cr(e,t){let n=Buffer.from(t,"utf8");if(n.length>de)throw new Error("credential-store file exceeds the maximum supported size");let r=h.dirname(e),i=h.basename(e),o=null,a=null,l=!1;try{let u=lr(r,i);o=u.fd,a=u.tempPath;let d=s.default.fstatSync(o);if((k(a,o,d).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");Mt(o,n),s.default.fsyncSync(o),k(a,o,s.default.fstatSync(o));let p=o;o=null,s.default.closeSync(p),ar(e),s.default.renameSync(a,e),l=!0}finally{if(o!==null)try{s.default.closeSync(o)}catch{}if(!l&&a!==null)try{s.default.unlinkSync(a)}catch{}}Gt(r)}function ur(e){return h.join(h.dirname(e),`.${h.basename(e)}.lock`)}function dr(e){return h.join(h.dirname(e),`.${h.basename(e)}.lock-recovery`)}function fr(e,t){if(t.size>Me)return null;let n=Buffer.alloc(Me+1),r=0;for(;r<n.length;){let o=s.default.readSync(e,n,r,n.length-r,null);if(o===0)break;r+=o}if(r>Me)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 C(e,t){let n=s.default.lstatSync(e);if(n.isSymbolicLink()||!n.isFile()||!ee(n,t))throw new Error("credential-store lock changed while it was being inspected");Q(n,"credential-store lock"),s.default.unlinkSync(e)}function xt(e,t){let n=null;try{try{n=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(u){if(g(u,"ENOENT"))try{let d=s.default.lstatSync(e);throw d.isSymbolicLink()||!d.isFile()?new Error("credential-store lock must be a real regular file"):new S}catch(d){if(g(d,"ENOENT"))return{state:"absent"};throw d}throw u}let r=s.default.fstatSync(n),i=k(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=fr(n,i);return{state:(o?.target===t&&o?!$t(o.pid):Date.now()-i.mtimeMs>=tr)?"stale":"active",stats:i}}finally{n!==null&&s.default.closeSync(n)}}function pr(e,t){for(let n=0;n<8;n+=1){let r=(0,Ye.randomBytes)(12).toString("hex"),i=h.join(e,`.${t}.${process.pid}.${r}.lock-claim`),o={pid:process.pid,nonce:r,target:t},a=null;try{a=s.default.openSync(i,s.default.constants.O_CREAT|s.default.constants.O_EXCL|s.default.constants.O_WRONLY|(s.default.constants.O_NOFOLLOW??0),384);let l=s.default.fstatSync(a),u=k(i,a,l,{allowMultipleLinks:!0});return Mt(a,Buffer.from(JSON.stringify(o),"utf8")),s.default.fsyncSync(a),{claimPath:i,metadata:o,stats:u}}catch(l){if(g(l,"EEXIST"))continue;try{s.default.unlinkSync(i)}catch{}throw l}finally{a!==null&&s.default.closeSync(a)}}throw new Error("could not allocate a unique credential-store lock claim")}function gr(e,t){let n;try{n=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(r){throw g(r,"ENOENT")?new S:r}try{let r=s.default.fstatSync(n),i=k(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!ee(i,t))throw new S;return{fd:n,lockPath:e,stats:i}}catch(r){throw s.default.closeSync(n),r}}function Bt(e){let t=null;try{try{t=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(n){if(g(n,"ENOENT"))try{let r=s.default.lstatSync(e);throw r.isSymbolicLink()||!r.isFile()?new Error("credential-store recovery gate must be a real regular file"):new S}catch(r){if(g(r,"ENOENT"))return!1;throw r}throw n}return k(e,t,s.default.fstatSync(t),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{t!==null&&s.default.closeSync(t)}}function hr(e){let t;try{t=s.default.openSync(e,s.default.constants.O_CREAT|s.default.constants.O_EXCL|s.default.constants.O_RDWR|(s.default.constants.O_NOFOLLOW??0),384)}catch(r){if(g(r,"EEXIST"))return null;throw r}let n=null;try{n=s.default.fstatSync(t);let r=k(e,t,n,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:t,lockPath:e,stats:r}}catch(r){if(n!==null)try{C(e,n)}catch{}throw s.default.closeSync(t),r}}function I(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");ir(er)}function Ut(e){let t=h.dirname(e),n=h.basename(e),r=ur(e),i=dr(e),o=pr(t,n),a=Date.now()+Qn,l=!1,u=!1,d=null,m;try{for(;d===null;)try{if(Bt(i)){I(a,!0);continue}s.default.linkSync(o.claimPath,r),u=!0,d=gr(r,o.stats),l=!0}catch(p){if(u&&!l){try{C(r,o.stats)}catch{}u=!1}if(p instanceof S){I(a,!1);continue}if(!g(p,"EEXIST"))throw p;let y;try{y=xt(r,n)}catch(b){if(b instanceof S){I(a,!1);continue}throw b}if(y.state==="absent")continue;if(y.state==="stale"){let b;try{b=hr(i)}catch(x){if(x instanceof S){I(a,!1);continue}throw x}if(b!==null){try{let x;try{x=xt(r,n)}catch(qe){if(qe instanceof S){I(a,!1);continue}throw qe}x.state==="stale"&&C(r,x.stats)}finally{Ge(b)}continue}}let ze;try{ze=Bt(i)}catch(b){if(b instanceof S){I(a,!1);continue}throw b}I(a,ze)}}catch(p){m=p}try{C(o.claimPath,o.stats)}catch(p){!g(p,"ENOENT")&&!l&&m===void 0&&(m=p)}if(m!==void 0)throw m;if(d===null)throw new Error("credential-store lock acquisition failed");return d}function Ge(e){try{C(e.lockPath,e.stats)}finally{s.default.closeSync(e.fd)}}function mr(e,t){let n=or(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 Dt(e){let t=h.dirname(e),n=h.basename(e);for(let r of s.default.readdirSync(t)){let i=mr(r,n);if(i===null||$t(i))continue;let o=h.join(t,r),a=null;try{try{a=s.default.openSync(o,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(d){if(g(d,"ENOENT")||g(d,"ELOOP"))continue;throw d}let l=s.default.fstatSync(a),u=s.default.lstatSync(o);if(!l.isFile()||u.isSymbolicLink()||!u.isFile()||!ee(l,u))continue;try{Q(l,"credential-store orphan")}catch{continue}C(o,l)}catch(l){if(!g(l,"ENOENT"))throw l}finally{a!==null&&s.default.closeSync(a)}}}function A(e,t,n){if(!j()){if(t.allowUnsupportedPlatformCleanup){if(t.createParent)throw H();if(!vt(e,!1))return n({read:()=>null,remove:()=>{},write:()=>{throw H()}});let a=Ut(e);try{return Dt(e),n({read:()=>Rt(e),remove:()=>Nt(e),write:()=>{throw H()}})}finally{Ge(a)}}if(!t.createParent){let o=!1;try{o=Ft(e)}catch{throw H()}if(o)return n({read:()=>null,remove:()=>{},write:()=>{throw H()}})}throw H()}if(!vt(e,t.createParent))return n({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let i=Ut(e);try{return Dt(e),n({read:()=>Rt(e),remove:()=>Nt(e),write:o=>cr(e,o)})}finally{Ge(i)}}var R="allscale-cli";function He(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kt(e){return He(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function v(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 Ke(){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 fe(){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 P,pe=!1;function Ht(){return wt()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function Sr(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
|
|
12
|
+
To keep staging, re-run \`allscale device-login\` with --api-base ${""} (recorded as deliberate, silences this).
|
|
13
|
+
To move to production, run: allscale device-login --api-base ${V}
|
|
14
|
+
`}var C=E(require("fs")),Ct=E(require("os")),$e=E(require("path")),Me=E(require("@iarna/toml"));var Vn=".allscale",Qn="config.toml";function Q(){return $e.join(Ct.homedir(),Vn)}function er(){return $e.join(Q(),Qn)}function ue(){let e=er();if(!C.existsSync(e))return{};let t=C.readFileSync(e,"utf-8");try{return Me.parse(t)}catch(n){throw new c("internal",`Failed to parse ${e}: ${n.message}`)}}function It(e){return Object.keys(e.profile??{}).sort()}function vt(e,t){return e.profile?.[t]}function Pt(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 Ge(e){if(!we(e))throw new c("input.invalid",`Refusing to send credentials to API base ${j(e)}. `+Ee)}function Rt(e){let t=z();if(t===void 0||it(e))return;let n=le(e),r=ot();if(r.length>0){let o=r.map(l=>le(l.base)).filter(l=>l!==null);if(n!==null&&o.includes(n))return;let a=r.map(l=>j(l.base)).join(", ");throw new c("input.invalid",`Refusing to send to ${j(e)} \u2014 this build only signs for: ${a}. Re-login against one of this build's environments, or use a build that includes the one you need.`)}let i=le(t);if(!(n!==null&&n===i))throw new c("input.invalid",`Refusing to send to ${j(e)} \u2014 this build only signs for ${j(t)}. Re-login against this build's environment, or use a build for that one.`)}var tr=require("@noble/hashes/sha3");var Nt=["USDT","USDC"];var bi=new Set([`0x${"0".repeat(40)}`,`0x${"0".repeat(36)}dead`]);var xt=require("@oclif/core"),ee=class e extends L.Command{static enableJsonFlag=!0;static legacyStagingNoticeShown=!1;static emitsOwnOutput=!1;static requiresEscapeHatch=!1;static requiresInput=!1;static isLocalOnly=!1;static baseFlags={profile:L.Flags.string({description:"Named profile from ~/.allscale/config.toml",helpGroup:"GLOBAL"}),token:L.Flags.string({description:"Override the access token for this invocation (precedence: --token > ALLSCALE_TOKEN > --profile)",helpGroup:"GLOBAL",hidden:J()==="public"}),"api-base":L.Flags.string({description:Ae,helpGroup:"GLOBAL",hidden:J()==="public"}),"insecure-storage":L.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{xe(this.jsonEnabled()),Ue(),G({type:"session-start",command:this.id??"",argv:De(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&&ce()!==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=Et(this.jsonEnabled()),r=this.argv.length===0&&!n&&lr(t)?this.config.findCommand(this.id??""):void 0;if(r){X();let o=await(0,L.loadHelpClass)(this.config),a=this.config.pjson.oclif?.helpOptions??this.config.pjson.helpOptions;await new o(this.config,a).showCommandHelp(r,this.config.topics);return}if(t.requiresEscapeHatch&&!Tt())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. Access remains governed by the key's granted scopes, which the backend checks on each request.");let i=await this.runCommand();return G({type:"command-end",ok:!0}),X(),t.emitsOwnOutput?void 0:(this.jsonEnabled()||ct(i),{data:i})}catch(t){let n=lt(t);wt({code:n.code,message:n.message,exitCode:n.exitCode}),this.emitError(n),process.exitCode=n.exitCode;return}finally{xe(!1)}}resolveSessionApiBaseChain(t){let n=ue(),r=t.profile??void 0,i=t["api-base"]??void 0,o=r!==void 0||Fe()!==void 0,a=Pt(n,r,Fe()),l=vt(n,a),u=i??ce(),d=u??l?.api_base??V,m=Ot({resolvedApiBase:d,fromExplicitOverride:u!==void 0,profileApiBase:l?.api_base,profileApiBaseSource:l?.api_base_source});return m&&!e.legacyStagingNoticeShown&&(e.legacyStagingNoticeShown=!0,F({event:"legacy_staging_profile",api_base:d,profile:a},m)),{apiBase:d,explicitApiBase:u,profileApiBase:l?.api_base,profile:a,profileExplicit:o}}resolveSessionApiBaseForPayoutDerivation(t){let{apiBase:n}=this.resolveSessionApiBaseChain(t);return this.constructor.isLocalOnly||Ge(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&&ce()!==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:a,profileApiBase:l,profileExplicit:u}=this.resolveSessionApiBaseChain(t);return this.constructor.isLocalOnly||(Ge(i),Rt(i)),{apiBase:i,profile:a,token:n??bt(),insecureStorage:r||Lt(),apiBaseSource:o!==void 0?"explicit":l!==void 0?"profile":"default",profileExplicit:u}}emitError(t){process.stderr.write(`${ar(t)}
|
|
15
|
+
`)}};var nr=/_(removed|cleared|count|total)$/i;function rr(e,t){return typeof t=="number"&&nr.test(e)}var ir=new Set(Nt);function or(e,t){return e==="token_symbol"&&typeof t=="string"&&ir.has(t)}var de=100;function fe(e,t=0){if(t>8)return"<truncated>";if(Array.isArray(e)){let n=e.slice(0,de),r=n.map(i=>fe(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,de))n[i]=pt(i)&&!rr(i,o)&&!or(i,o)?"<redacted>":fe(o,t+1);if(r.length>de){let i="<truncated>";for(;i in n;)i=`<${i}>`;n[i]=`${r.length-de} more keys`}return n}if(typeof e=="string"){let n=sr(e);return n!==void 0?y(JSON.stringify(fe(n,t+1))):y(e)}return e}function sr(e){let t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return;let n;try{n=JSON.parse(t)}catch{return}return n!==null&&typeof n=="object"?n:void 0}function ar(e){let t=yt()?void 0:2,n=fe(e.toJSON()),r=JSON.stringify(n,null,t);return Buffer.byteLength(r,"utf8")+1<=65536?r:JSON.stringify({error:{code:e.code,message:y(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,t)}function lr(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 Wt=E(require("path"));var je=require("crypto"),s=E(require("fs")),h=E(require("path"));var pe=1024*1024,cr=5e3,ur=20,dr=3e4,Ye=4096,fr=new Int32Array(new SharedArrayBuffer(4)),te=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function T(e){return e instanceof te}var _=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},pr=null;function H(){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 W(){return(pr??process.platform)!=="win32"}function Yt(e){try{return s.default.lstatSync(e),!1}catch(t){if(!g(t,"ENOENT"))throw t}try{let t=s.default.lstatSync(h.dirname(e));return!t.isSymbolicLink()&&t.isDirectory()}catch(t){if(g(t,"ENOENT"))return!0;throw t}}function g(e,t){return typeof e=="object"&&e!==null&&e.code===t}function ne(e,t){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${t} is not owned by the current effective user`)}function re(e,t){return e.dev===t.dev&&e.ino===t.ino}function gr(e){Atomics.wait(fr,0,0,e)}function Kt(e){try{return process.kill(e,0),!0}catch(t){return!g(t,"ESRCH")}}function hr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bt(e,t){let n=h.dirname(e);t&&s.default.mkdirSync(n,{recursive:!0,mode:448});let r;try{r=s.default.lstatSync(n)}catch(o){if(!t&&g(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=s.default.openSync(n,s.default.constants.O_RDONLY|(s.default.constants.O_DIRECTORY??0)|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0));let o=s.default.fstatSync(i),a=s.default.lstatSync(n);if(!o.isDirectory()||a.isSymbolicLink()||!a.isDirectory()||!re(o,a))throw new Error("credential-store parent changed while it was being inspected");ne(o,"credential-store parent");let l=o;if((o.mode&63)!==0&&h.basename(n)===".allscale"&&(s.default.fchmodSync(i,448),l=s.default.fstatSync(i)),(l.mode&63)!==0)throw new Error("credential-store parent must not grant group or other permissions")}finally{i!==null&&s.default.closeSync(i)}return!0}function k(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=s.default.lstatSync(e)}catch(o){throw r.retryOnPathChange&&g(o,"ENOENT")?new _:o}if(!re(n,i))throw r.retryOnPathChange?new _: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 te;if(ne(n,"credential-store file"),process.platform!=="win32"){s.default.fchmodSync(t,384);let o=s.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 mr(e,t){if(t.size>pe)throw new Error("credential-store file exceeds the maximum supported size");let n=Buffer.alloc(pe+1),r=0;for(;r<n.length;){let i=s.default.readSync(e,n,r,n.length-r,null);if(i===0)break;r+=i}if(r>pe)throw new Error("credential-store file exceeds the maximum supported size");return n.subarray(0,r).toString("utf8")}function Ut(e){let t=null;try{try{t=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(i){if(g(i,"ENOENT"))try{if(s.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(g(o,"ENOENT"))return null;throw o}throw i}let n=s.default.fstatSync(t),r=k(e,t,n);return mr(t,r)}finally{t!==null&&s.default.closeSync(t)}}function Dt(e){let t=null;try{try{t=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(i){if(g(i,"ENOENT")&&Yt(e))return;throw i}let n=s.default.fstatSync(t),r=k(e,t,n);v(e,r)}finally{t!==null&&s.default.closeSync(t)}Ht(h.dirname(e))}function yr(e){let t;try{t=s.default.lstatSync(e)}catch(n){if(g(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 te;ne(t,"credential-store replacement target")}function Sr(e,t){for(let n=0;n<8;n+=1){let r=(0,je.randomBytes)(12).toString("hex"),i=h.join(e,`.${t}.${process.pid}.${r}.tmp`);try{return{fd:s.default.openSync(i,s.default.constants.O_CREAT|s.default.constants.O_EXCL|s.default.constants.O_WRONLY|(s.default.constants.O_NOFOLLOW??0),384),tempPath:i}}catch(o){if(g(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function jt(e,t){let n=0;for(;n<t.length;){let r=s.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 Ht(e){if(process.platform==="win32")return;let t=null;try{t=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_DIRECTORY??0)|(s.default.constants.O_NOFOLLOW??0)),s.default.fsyncSync(t)}catch{}finally{if(t!==null)try{s.default.closeSync(t)}catch{}}}function _r(e,t){let n=Buffer.from(t,"utf8");if(n.length>pe)throw new Error("credential-store file exceeds the maximum supported size");let r=h.dirname(e),i=h.basename(e),o=null,a=null,l=!1;try{let u=Sr(r,i);o=u.fd,a=u.tempPath;let d=s.default.fstatSync(o);if((k(a,o,d).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");jt(o,n),s.default.fsyncSync(o),k(a,o,s.default.fstatSync(o));let p=o;o=null,s.default.closeSync(p),yr(e),s.default.renameSync(a,e),l=!0}finally{if(o!==null)try{s.default.closeSync(o)}catch{}if(!l&&a!==null)try{s.default.unlinkSync(a)}catch{}}Ht(r)}function Ar(e){return h.join(h.dirname(e),`.${h.basename(e)}.lock`)}function Er(e){return h.join(h.dirname(e),`.${h.basename(e)}.lock-recovery`)}function wr(e,t){if(t.size>Ye)return null;let n=Buffer.alloc(Ye+1),r=0;for(;r<n.length;){let o=s.default.readSync(e,n,r,n.length-r,null);if(o===0)break;r+=o}if(r>Ye)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 v(e,t){let n=s.default.lstatSync(e);if(n.isSymbolicLink()||!n.isFile()||!re(n,t))throw new Error("credential-store lock changed while it was being inspected");ne(n,"credential-store lock"),s.default.unlinkSync(e)}function Ft(e,t){let n=null;try{try{n=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(u){if(g(u,"ENOENT"))try{let d=s.default.lstatSync(e);throw d.isSymbolicLink()||!d.isFile()?new Error("credential-store lock must be a real regular file"):new _}catch(d){if(g(d,"ENOENT"))return{state:"absent"};throw d}throw u}let r=s.default.fstatSync(n),i=k(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=wr(n,i);return{state:(o?.target===t&&o?!Kt(o.pid):Date.now()-i.mtimeMs>=dr)?"stale":"active",stats:i}}finally{n!==null&&s.default.closeSync(n)}}function br(e,t){for(let n=0;n<8;n+=1){let r=(0,je.randomBytes)(12).toString("hex"),i=h.join(e,`.${t}.${process.pid}.${r}.lock-claim`),o={pid:process.pid,nonce:r,target:t},a=null;try{a=s.default.openSync(i,s.default.constants.O_CREAT|s.default.constants.O_EXCL|s.default.constants.O_WRONLY|(s.default.constants.O_NOFOLLOW??0),384);let l=s.default.fstatSync(a),u=k(i,a,l,{allowMultipleLinks:!0});return jt(a,Buffer.from(JSON.stringify(o),"utf8")),s.default.fsyncSync(a),{claimPath:i,metadata:o,stats:u}}catch(l){if(g(l,"EEXIST"))continue;try{s.default.unlinkSync(i)}catch{}throw l}finally{a!==null&&s.default.closeSync(a)}}throw new Error("could not allocate a unique credential-store lock claim")}function Lr(e,t){let n;try{n=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(r){throw g(r,"ENOENT")?new _:r}try{let r=s.default.fstatSync(n),i=k(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!re(i,t))throw new _;return{fd:n,lockPath:e,stats:i}}catch(r){throw s.default.closeSync(n),r}}function $t(e){let t=null;try{try{t=s.default.openSync(e,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(n){if(g(n,"ENOENT"))try{let r=s.default.lstatSync(e);throw r.isSymbolicLink()||!r.isFile()?new Error("credential-store recovery gate must be a real regular file"):new _}catch(r){if(g(r,"ENOENT"))return!1;throw r}throw n}return k(e,t,s.default.fstatSync(t),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{t!==null&&s.default.closeSync(t)}}function kr(e){let t;try{t=s.default.openSync(e,s.default.constants.O_CREAT|s.default.constants.O_EXCL|s.default.constants.O_RDWR|(s.default.constants.O_NOFOLLOW??0),384)}catch(r){if(g(r,"EEXIST"))return null;throw r}let n=null;try{n=s.default.fstatSync(t);let r=k(e,t,n,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:t,lockPath:e,stats:r}}catch(r){if(n!==null)try{v(e,n)}catch{}throw s.default.closeSync(t),r}}function I(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");gr(ur)}function Mt(e){let t=h.dirname(e),n=h.basename(e),r=Ar(e),i=Er(e),o=br(t,n),a=Date.now()+cr,l=!1,u=!1,d=null,m;try{for(;d===null;)try{if($t(i)){I(a,!0);continue}s.default.linkSync(o.claimPath,r),u=!0,d=Lr(r,o.stats),l=!0}catch(p){if(u&&!l){try{v(r,o.stats)}catch{}u=!1}if(p instanceof _){I(a,!1);continue}if(!g(p,"EEXIST"))throw p;let S;try{S=Ft(r,n)}catch(b){if(b instanceof _){I(a,!1);continue}throw b}if(S.state==="absent")continue;if(S.state==="stale"){let b;try{b=kr(i)}catch(B){if(B instanceof _){I(a,!1);continue}throw B}if(b!==null){try{let B;try{B=Ft(r,n)}catch(Ze){if(Ze instanceof _){I(a,!1);continue}throw Ze}B.state==="stale"&&v(r,B.stats)}finally{Ke(b)}continue}}let Xe;try{Xe=$t(i)}catch(b){if(b instanceof _){I(a,!1);continue}throw b}I(a,Xe)}}catch(p){m=p}try{v(o.claimPath,o.stats)}catch(p){!g(p,"ENOENT")&&!l&&m===void 0&&(m=p)}if(m!==void 0)throw m;if(d===null)throw new Error("credential-store lock acquisition failed");return d}function Ke(e){try{v(e.lockPath,e.stats)}finally{s.default.closeSync(e.fd)}}function Tr(e,t){let n=hr(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 Gt(e){let t=h.dirname(e),n=h.basename(e);for(let r of s.default.readdirSync(t)){let i=Tr(r,n);if(i===null||Kt(i))continue;let o=h.join(t,r),a=null;try{try{a=s.default.openSync(o,s.default.constants.O_RDONLY|(s.default.constants.O_NOFOLLOW??0)|(s.default.constants.O_NONBLOCK??0))}catch(d){if(g(d,"ENOENT")||g(d,"ELOOP"))continue;throw d}let l=s.default.fstatSync(a),u=s.default.lstatSync(o);if(!l.isFile()||u.isSymbolicLink()||!u.isFile()||!re(l,u))continue;try{ne(l,"credential-store orphan")}catch{continue}v(o,l)}catch(l){if(!g(l,"ENOENT"))throw l}finally{a!==null&&s.default.closeSync(a)}}}function w(e,t,n){if(!W()){if(t.allowUnsupportedPlatformCleanup){if(t.createParent)throw H();if(!Bt(e,!1))return n({read:()=>null,remove:()=>{},write:()=>{throw H()}});let a=Mt(e);try{return Gt(e),n({read:()=>Ut(e),remove:()=>Dt(e),write:()=>{throw H()}})}finally{Ke(a)}}if(!t.createParent){let o=!1;try{o=Yt(e)}catch{throw H()}if(o)return n({read:()=>null,remove:()=>{},write:()=>{throw H()}})}throw H()}if(!Bt(e,t.createParent))return n({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let i=Mt(e);try{return Gt(e),n({read:()=>Ut(e),remove:()=>Dt(e),write:o=>_r(e,o)})}finally{Ke(i)}}var N="allscale-cli";function We(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zt(e){return We(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function R(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 He(){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 ge(){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 P,he=!1;function Jt(){return kt()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function Cr(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 qt(){if(P!==void 0)return P;if(Jt())return he=!1,P=null,P;try{P=require("keytar"),he=!1}catch(e){he=!Cr(e),P=null}return P}function Xt(){let e=Jt();return e||(he?"the installed keytar/native keychain backend failed to load":null)}function Zt(){let e=W()?"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 x(e){try{return await e()}catch{throw Zt()}}function Vt(){return qt()}var ze=class{constructor(t){this.keytar=t}keytar;kind="keychain";async read(t){let n=await x(()=>this.keytar.getPassword(N,t));if(n===null)return null;let r;try{r=JSON.parse(n)}catch{throw R("OS keychain")}if(!zt(r))throw R("OS keychain");return r}async get(t){return this.read(t)}async set(t,n){await this.read(t),await x(()=>this.keytar.setPassword(N,t,JSON.stringify(n)))}async delete(t){await this.read(t),await x(()=>this.keytar.deletePassword(N,t))}},Ir="credentials.json",me=class{kind="insecure-file";filePath;constructor(t){this.filePath=t??Wt.join(Q(),Ir)}read(t){let n;try{n=t.read()}catch(i){throw T(i)?He():R("plaintext file")}if(n===null)return{profiles:{}};let r;try{r=JSON.parse(n)}catch{throw R("plaintext file")}if(!We(r)||!We(r.profiles))throw R("plaintext file");return r}write(t,n){try{t.write(JSON.stringify(n,null,2))}catch(r){throw T(r)?He():ge()}}profileTokens(t,n){let r=t.profiles[n];if(r!==void 0){if(!zt(r))throw R("plaintext file");return r}}async get(t){try{return w(this.filePath,{createParent:!1},n=>this.profileTokens(this.read(n),t)??null)}catch(n){throw n instanceof c?n:R("plaintext file")}}async set(t,n){try{w(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:ge()}}async delete(t){try{w(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:ge()}}async clearProfile(t){try{return w(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:T(n)?He():ge()}}};function Qt(e={}){let t=[new me(e.insecureFilePath)];if(e.includeKeychain!==!1){let n=qt();n&&t.push(new ze(n))}return t}function en(e,t){if(!(e instanceof me))throw new c("internal","Refusing plaintext cleanup through a non-file token store.");return e.clearProfile(t)}var tn=E(require("path"));function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vr(e){return ie(e)&&typeof e.api_key=="string"&&typeof e.api_secret=="string"}function nn(e){return ie(e)&&ie(e.stores)&&Object.values(e.stores).every(vr)}function O(e){return new c("internal",`The store-HMAC credential store in the ${e} exists but could not be read as valid credential data. Refusing to treat it as empty or overwrite it; store credentials may still remain on this machine.`)}function Je(){return new c("internal","The store-HMAC credential store in the plaintext file has multiple hard links. Refusing to read, modify, or delete it because another directory entry may retain store 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 ye(){return new c("internal","The store-HMAC credential store in the plaintext file could not be written safely. Any previous credential file was left unchanged.")}var Pr="store-credentials:",qe=class{constructor(t){this.keytar=t}keytar;kind="keychain";account(t){return`${Pr}${t}`}async read(t){let n=await x(()=>this.keytar.getPassword(N,this.account(t)));if(n===null)return{stores:{}};let r;try{r=JSON.parse(n)}catch{throw O("OS keychain")}if(!nn(r))throw O("OS keychain");return r}async write(t,n){if(Object.keys(n.stores).length===0){await x(()=>this.keytar.deletePassword(N,this.account(t)));return}await x(()=>this.keytar.setPassword(N,this.account(t),JSON.stringify(n)))}async get(t,n){return(await this.read(t)).stores[n]??null}async set(t,n,r){let i=await this.read(t);i.stores[n]=r,await this.write(t,i)}async delete(t,n){let r=await this.read(t);delete r.stores[n],await this.write(t,r)}async list(t){return(await this.read(t)).stores}},Rr="store-credentials.json",Se=class{kind="insecure-file";filePath;constructor(t){this.filePath=t??tn.join(Q(),Rr)}read(t){let n;try{n=t.read()}catch(i){throw T(i)?Je():O("plaintext file")}if(n===null)return{profiles:{}};let r;try{r=JSON.parse(n)}catch{throw O("plaintext file")}if(!ie(r)||!ie(r.profiles))throw O("plaintext file");return r}profileBundle(t,n){let r=t.profiles[n];if(r!==void 0){if(!nn(r))throw O("plaintext file");return r}}write(t,n){try{t.write(JSON.stringify(n,null,2))}catch(r){throw T(r)?Je():ye()}}async get(t,n){try{return w(this.filePath,{createParent:!1},r=>{let i=this.read(r);return this.profileBundle(i,t)?.stores[n]??null})}catch(r){throw r instanceof c?r:O("plaintext file")}}async set(t,n,r){try{w(this.filePath,{createParent:!0},i=>{let o=this.read(i),a=this.profileBundle(o,t)??{stores:{}};a.stores[n]=r,o.profiles[t]=a,this.write(i,o)})}catch(i){throw i instanceof c?i:ye()}}async delete(t,n){try{w(this.filePath,{createParent:!1},r=>{let i=this.read(r),o=this.profileBundle(i,t);!o||o.stores[n]===void 0||(delete o.stores[n],Object.keys(o.stores).length===0&&delete i.profiles[t],this.write(r,i))})}catch(r){throw r instanceof c?r:ye()}}async list(t){try{return w(this.filePath,{createParent:!1},n=>{let r=this.read(n);return this.profileBundle(r,t)?.stores??{}})}catch(n){throw n instanceof c?n:O("plaintext file")}}async clearProfile(t){try{return w(this.filePath,{createParent:!1,allowUnsupportedPlatformCleanup:!0},n=>{let r=this.read(n),i=this.profileBundle(r,t);if(!i)return 0;let o=Object.keys(i.stores).length;return delete r.profiles[t],Object.keys(r.profiles).length===0?n.remove():this.write(n,r),o})}catch(n){throw n instanceof c?n:T(n)?Je():ye()}}};function rn(e={}){let t=[new Se(e.insecureFilePath)];if(e.includeKeychain!==!1){let n=Vt();n&&t.push(new qe(n))}return t}function on(e,t){if(!(e instanceof Se))throw new c("internal","Refusing plaintext cleanup through a non-file store-credential backend.");return e.clearProfile(t)}function sn(e,t={}){let n;try{n=It(ue())}catch{return}if(!(n.length===0||n.includes(e)))return new c("auth.unknown_profile",at(e)+(t.messageSuffix??""),{profile:e})}var _e=class e extends ee{static description="Clear cached credentials (session token + store keys) for a profile. By default, clears BOTH the OS keychain and plaintext file store. With --insecure-storage or ALLSCALE_INSECURE_STORAGE=1, clears only plaintext files and never probes the keychain; omit/unset that opt-in when a full-machine sweep is wanted. If the keychain is suppressed or unavailable, a bare logout fails closed after attempting the plaintext-file cleanup.";static isLocalOnly=!0;static examples=["$ allscale logout","$ allscale logout --profile staging"];static flags={...ee.baseFlags};async runCommand(){let{flags:t}=await this.parse(e),n=this.resolveContext(t),r=!n.insecureStorage,i=Qt({includeKeychain:r}),o=rn({includeKeychain:r}),a=!1,l=0,u=[];for(let p of i){let S=await xr(p,n.profile);a||=S.removed,S.error&&u.push(S.error)}for(let p of o){let S=await Br(p,n.profile);l+=S.removed,S.error&&u.push(S.error)}let d=Xt(),m=i.some(p=>p.kind==="keychain")&&o.some(p=>p.kind==="keychain");if(!n.insecureStorage&&!m){let p=d??"the native keychain backend is unavailable or failed to load",S=Nr(p);u.push(`Could not inspect or clear the OS keychain because ${p}. Plaintext-file cleanup was still attempted, but session or store credentials may STILL remain on this machine. ${S}, repair any file-store errors above, and re-run bare 'allscale logout'.`)}if(u.length>0)throw new c("internal",u.join(" "),{profile:n.profile,removed:a,store_credentials_removed:l});if(!a&&l===0&&n.profileExplicit){let p=sn(n.profile,{messageSuffix:" Nothing was removed."});if(p)throw p}return{profile:n.profile,removal_status:a||l>0?"removed":n.insecureStorage?"skipped":"nothing_to_remove",removed:a,store_credentials_removed:l}}};function Nr(e){return e==="ALLSCALE_NO_KEYCHAIN"||e==="KEYTAR_DISABLE"?"Re-enable keychain access":"Install or repair keychain support"}async function xr(e,t){try{return!W()&&e.kind==="insecure-file"?{removed:await en(e,t)}:await e.get(t)?(await e.delete(t),{removed:!0}):{removed:!1}}catch(n){return{removed:!1,error:`Could not clear the session token for profile '${t}': ${an(n)} The session credential may STILL remain on this machine; repair the credential store and re-run 'allscale logout'.`}}}async function Br(e,t){let n=0;try{if(!W()&&e.kind==="insecure-file")return{removed:await on(e,t)};let r=Object.keys(await e.list(t));for(let i of r)await e.delete(t,i),n+=1;return{removed:n}}catch(r){return{removed:n,error:`Could not fully clear store credentials for profile '${t}': ${an(r)}. ${n} removed; any remaining store api_secret is STILL on this machine and can still authorize 'payout send'. Re-run 'allscale logout' once the credential store is reachable.`}}}function an(e){return e instanceof Error?e.message:String(e)}
|
|
17
17
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).some(n=>
|
|
3
|
-
`)}var l=y(require("fs")),
|
|
4
|
-
`)}else
|
|
5
|
-
`);return}
|
|
6
|
-
`);return}l.appendFileSync(
|
|
7
|
-
`)}catch(i){if(
|
|
8
|
-
`)}catch{}}}function
|
|
9
|
-
The CLI default is now ${
|
|
1
|
+
"use strict";var ze=Object.create;var P=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Qe=(e,n)=>{for(var t in n)P(e,t,{get:n[t],enumerable:!0})},me=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of He(n))!Xe.call(e,a)&&a!==t&&P(e,a,{get:()=>n[a],enumerable:!(i=We(n,a))||i.enumerable});return e};var y=(e,n,t)=>(t=e!=null?ze(Ze(e)):{},me(n||!e||!e.__esModule?P(t,"default",{value:e,enumerable:!0}):t,e)),en=e=>me(P({},"__esModule",{value:!0}),e);var zn={};Qe(zn,{default:()=>M});module.exports=en(zn);var f=require("@oclif/core");var fe="public",ye="https://app.allscale.io";var Ae=["https://app.allscale.io"];var J="Override the API base URL (public builds accept only https://app.allscale.io)";var Y="Only https://app.allscale.io is allowed, and URL userinfo is forbidden.";function _e(e){try{let n=new URL(e);return n.username.length>0||n.password.length>0?null:n.protocol==="https:"?n:null}catch{return null}}function Le(e){return _e(e)!==null}function q(e){let n=_e(e);return n!==null&&Ae.includes(n.origin)}function b(){return"".trim()||void 0}function E(){return"public"}function ge(e){try{let{hostname:n}=new URL(e);return n==="127.0.0.1"||n==="localhost"||n==="[::1]"}catch{return!1}}function Te(){{let e="[]".trim();if(e.length===0)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}return j()}function j(){let e=process.env.ALLSCALE_BUILD_PAIRS?.trim()??"";if(e.length>0)try{let i=JSON.parse(e);if(!Array.isArray(i))return[];let a=[];for(let r of i){if(typeof r!="object"||r===null)continue;let{base:o,key:s,keyId:u}=r;if(typeof o!="string"||o.trim().length===0||typeof s!="string"||s.trim().length===0)continue;let p=typeof u=="string"?u.trim():"";a.push({base:o.trim(),key:s,keyId:p.length>0?p:"cli-1"})}return a}catch{return[]}let n=process.env.ALLSCALE_SIGNING_KEY??"",t=process.env.ALLSCALE_BUILD_API_BASE?.trim()??"";if(n.trim().length>0&&t.length>0){let i=process.env.ALLSCALE_SIGNING_KEY_ID?.trim();return[{base:t,key:n,keyId:i&&i.length>0?i:"cli-1"}]}return[]}var nn={"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_op_expired":3,"wallet.bridge_invalid_response":9,"wallet.transaction_reverted":12,"wallet.transaction_status_unknown":9,"raw.disabled":10,internal:1},tn=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 W(e){return(typeof e=="string"?e:String(e??"")).replace(tn,"")}var an=64;function K(e,n=new Map,t=0){if(typeof e=="string")return W(e);if(e===null||typeof e!="object")return e;let i=n.get(e);if(i!==void 0)return i;if(t>=an)return e;if(Array.isArray(e)){let o=[];n.set(e,o);for(let s of e)o.push(K(s,n,t+1));return o}let a=Object.getPrototypeOf(e);if(a!==Object.prototype&&a!==null)return e;let r={};n.set(e,r);for(let[o,s]of Object.entries(e))Object.defineProperty(r,o,{value:K(s,n,t+1),writable:!0,enumerable:!0,configurable:!0});return r}var d=class extends Error{code;details;constructor(n,t,i){super(W(t)),this.code=n,this.details=i&&K(i),this.name="AllscaleError"}get exitCode(){return nn[this.code]}toJSON(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}};function he(e){if(e instanceof d)return e;if(e instanceof Error){if(sn(e)){let n=dn(e),t={};return e.name&&e.name!=="Error"&&(t.name=e.name),Object.keys(n).length>0&&(t.oclif=n),new d("input.invalid",e.message,Object.keys(t).length>0?t:void 0)}return new d("internal",e.message,{name:e.name})}return new d("internal","Unknown error",{value:String(e)})}var rn=new Set(["CLIError","CLIParseError","RequiredArgsError","RequiredFlagError","UnexpectedArgsError","FlagInvalidOptionError","ArgInvalidOptionError","InvalidArgsSpecError"]),on=[/^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 sn(e){if(ln(e))return!0;let n=e.name??"";return rn.has(n)?n==="CLIError"?z(e,"parse")||Se(e.message):!0:Se(e.message)}function ln(e){if(!z(e,"oclif"))return!1;let n=e.oclif;return typeof n=="object"&&n!==null&&n.exit===2&&z(e,"parse")}function Se(e){return e?W(e).split(`
|
|
2
|
+
`).some(n=>on.some(t=>t.test(n.trim()))):!1}function z(e,n){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,n)}function dn(e){let n=e,t={};for(let i of["code","exitCode","suggestions","ref"])n[i]!==void 0&&(t[i]=n[i]);return t}function ke(e){process.stdout.write(`${JSON.stringify({data:e},null,2)}
|
|
3
|
+
`)}var l=y(require("fs")),D=y(require("path")),Be=y(require("crypto"));var un="...<truncated>",pn=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+/g,cn=/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,ee=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,H=String.raw`(?:proxy[_-]?)?authorization`,mn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${H}"|'${H}'|${H})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${ee}`,"gi"),fn=/\b(https?:\/\/)[^\s/?#]+@/gi,yn=String.raw`(?:[A-Za-z0-9]+[_-])*`,An=String.raw`(?:[A-Za-z0-9]{1,32}[_-]){0,8}`,Ce=e=>String.raw`(?:password|passwd|passphrase|otp(?:[_-]?code)?|signature|hmac|sig|session[_-]?id|mnemonic|seed|cookie|bearer|${e}(?:token|secret)|(?:api|access|private|signing)[_-]?key|credential|claim[_-]?url)`,Ne=Ce(yn),_n=Ce(An),Ln=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Ne}"|'${Ne}'|${_n})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${ee}`,"gi"),Z=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)`,gn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Z}"|'${Z}'|${Z})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${ee}`,"g");function be(e){return e.replace(fn,"$1<redacted>@").replace(pn,"<redacted-jwt>").replace(mn,"$1$2$3<redacted>").replace(Ln,"$1$2<redacted>").replace(gn,"$1$2<redacted>").replace(cn,"Bearer <redacted>")}var Tn=/(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 Ee(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Tn.test(n)}function Oe(e){let n="";for(let t of e){let i=t.codePointAt(0),a=i<=8||i>=11&&i<=12||i>=14&&i<=31||i>=127&&i<=159;n+=a?`\\u${i.toString(16).padStart(4,"0")}`:t}return n}function Re(e,n,t=un){if(n<=0)return"";if(Buffer.byteLength(e,"utf8")<=n)return e;let i=Buffer.byteLength(t,"utf8");if(i>=n){let s="",u=0;for(let p of t){let _=Buffer.byteLength(p,"utf8");if(u+_>n)break;s+=p,u+=_}return s}let a=n-i,r="",o=0;for(let s of e){let u=Buffer.byteLength(s,"utf8");if(o+u>a)break;r+=s,o+=u}return`${r}${t}`}function c(e,n=16384){return Re(Oe(be(e)),n)}var X=100,Sn=8,hn=8*1024;function x(){return{remaining:hn}}function Q(e,n){let t=Math.min(16384,n.remaining),i=Re(e,t);return n.remaining-=Buffer.byteLength(i,"utf8"),i}function L(e,n,t=0,i={}){if(t>Sn)return Q("<truncated>",n);if(typeof e=="string"){let a=be(e);return Q(i.escapeControls?Oe(a):a,n)}if(Array.isArray(e)){let a=e.slice(0,X),r=a.map(o=>L(o,n,t+1,i));return e.length>a.length&&r.push(Q(`<${e.length-a.length} more items truncated>`,n)),r}if(e!==null&&typeof e=="object"){let a=Object.create(null),r=Object.entries(e);for(let[o,s]of r.slice(0,X))a[o]=L(s,n,t+1,i);return r.length>X&&(a.output_truncated=!0),a}return e}var ne=require("process");var te=!1;function ie(e){te=e}function we(){return te}var Ie="1";function T(e,n){if(te){let t={...e};delete t.version;let i=x(),a={event:t.event,...t},r=L(a,i,0,{escapeControls:!0}),o=JSON.stringify({version:Ie,...r});Buffer.byteLength(o,"utf8")+1>65536&&(o=JSON.stringify({version:Ie,event:r.event,output_truncated:!0})),ne.stderr.write(`${o}
|
|
4
|
+
`)}else ne.stderr.write(n)}var Ue="2",S=null,m=null,h=!1,O=!1;function kn(){let e=process.env.ALLSCALE_OUTPUT_FILE_PATH;if(e)return e;let n=process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY;if(n){let t=new Date().toISOString().replace(/[:.]/g,"-"),i=Be.randomBytes(4).toString("hex");return D.join(n,`allscale-output-${t}-${i}.ndjson`)}return null}var ae=64*1024*1024,Nn=null;function re(e={}){if(e.quiet&&(O=!0),h)return;let n=kn();if(!n)return;S=null;let t=null;try{if((Nn??process.platform)==="win32")throw new Error("owner-only sidecar ACLs cannot be enforced on Windows; sidecar output is disabled");let i=D.dirname(n);if(l.mkdirSync(i,{recursive:!0,mode:448}),!process.env.ALLSCALE_OUTPUT_FILE_PATH&&process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY){let u=l.statSync(i),p=u.mode&511;if(!u.isDirectory()||(p&63)!==0)throw new Error(`output directory must be owner-only (no group/other permissions); current mode is ${p.toString(8).padStart(3,"0")}`)}let a=l.constants.O_NOFOLLOW??0;t=l.openSync(n,l.constants.O_APPEND|l.constants.O_CREAT|l.constants.O_WRONLY|(l.constants.O_NONBLOCK??0)|a,384);let r=l.fstatSync(t),o=l.lstatSync(n);if(!r.isFile()||o.isSymbolicLink()||o.dev!==r.dev||o.ino!==r.ino)throw new Error("target changed while it was being opened or is not a regular file");if(typeof process.geteuid=="function"&&r.uid!==process.geteuid())throw new Error("existing sidecar file is not owned by the current effective user");let s=r.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`);l.fchmodSync(t,384)}catch(i){if(t!==null)try{l.closeSync(t)}catch{}O||T({event:"sidecar_disabled",reason:"open_failed",detail:c(`sidecar path '${n}' could not be opened safely (${i.message})`)},`${c(`[allscale] sidecar path '${n}' could not be opened safely (${i.message}); refusing to write. Sidecar disabled for this run.`)}
|
|
5
|
+
`);return}S=n,m=t,h=!0}var Cn=[/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 bn(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Cn.some(t=>t.test(n))}function En(e){try{let n=new URL(e),t=n.username.length>0||n.password.length>0;t&&(n.username="",n.password="");let i=n.pathname;n.pathname=On(n.pathname);let a=t;n.pathname!==i&&(a=!0);for(let[r]of n.searchParams)bn(r)&&(n.searchParams.set(r,"<redacted>"),a=!0);return a?n.toString():e}catch{return e}}function On(e){return e.replace(/(\/(?:api\/)?(?:v1\/)?public\/claim-links\/)([^/:]+)(:claim)?(?=\/?$)/,"$1<redacted>$3").replace(/(\/(?:api\/)?public\/claim-links\/)([^/]+)(\/claim)(?=\/?$)/,"$1<redacted>$3")}function Rn(e){return(e.type==="request"||e.type==="bridge_browser_open")&&typeof e.url=="string"?{...e,url:En(e.url)}:e}function In(e){let n=new Date().toISOString(),t=e,{type:i,...a}=t,r=L(a,x()),o=JSON.stringify({version:Ue,timestamp:n,type:i,...r});return Buffer.byteLength(o,"utf8")+1>65536&&(o=JSON.stringify({version:Ue,timestamp:n,type:i,output_truncated:!0})),o}function k(e){if(!h||!S||m===null)return;let n=Rn(e),t=In(n);try{if(l.fstatSync(m).size+Buffer.byteLength(t,"utf8")+1>ae){h=!1;try{l.closeSync(m)}catch{}m=null,O||T({event:"sidecar_disabled",reason:"size_limit",...S===null?{}:{path:c(S)},max_bytes:ae},`${c(`[allscale] sidecar exceeded ${ae} bytes; disabling it for the rest of this run. Rotate or remove ${S}, or point ALLSCALE_OUTPUT_FILE_DIRECTORY at a directory so each run gets its own file.`)}
|
|
6
|
+
`);return}l.appendFileSync(m,`${t}
|
|
7
|
+
`)}catch(i){if(h=!1,m!==null){try{l.closeSync(m)}catch{}m=null}try{O||T({event:"sidecar_disabled",reason:"write_failed",detail:c(i.message)},`${c(`[allscale] sidecar write failed (${i.message}); disabling sidecar for the rest of this run.`)}
|
|
8
|
+
`)}catch{}}}function ve(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function R(){if(O=!1,h=!1,m!==null){try{l.closeSync(m)}catch{}m=null}}function Pe(e=!1){let n=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||ve()||!n}var I=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"]),wn=new Set(Array.from(I).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2)),Un=Array.from(I).filter(e=>e.startsWith("--")).sort((e,n)=>n.length-e.length),Bn=new Set(["--otp-stdin","--password-stdin"]);function oe(e){let n=[];for(let t=0;t<e.length;t+=1){let i=e[t];if(i.startsWith("-")){let r=i.indexOf("=");if(r!==-1){let o=i.slice(0,r);if(I.has(o)){n.push(`${o}=<redacted>`);continue}}}if(I.has(i)){n.push(i),t+1<e.length&&(I.has(e[t+1])||(n.push("<redacted>"),t+=1));continue}if(i.startsWith("-")&&!i.startsWith("--")&&i.length>2&&i[1]!=="="){let r=i.slice(0,2);if(wn.has(r)){n.push(`${r}<redacted>`);continue}}let a=Bn.has(i)?void 0:Un.find(r=>i.length>r.length&&i.startsWith(r));if(a){n.push(`${a}<redacted>`);continue}n.push(i)}return n}function xe(e){k({type:"error",code:e.code,message:c(e.message)}),k({type:"command-end",ok:!1,exitCode:e.exitCode}),R()}var w=b()??ye,U={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 F(e){return Le(e)?new URL(e).origin:null}function C(e){try{let n=new URL(e);return`${n.protocol}//${n.host}`}catch{return"<unparseable URL>"}}function De(){let e=process.env[U.TOKEN]?.trim();return e&&e.length>0?e:void 0}function se(){let e=process.env[U.PROFILE]?.trim();return e&&e.length>0?e:void 0}function $(){let e=process.env[U.API_BASE]?.trim();return e&&e.length>0?e:void 0}function Fe(){let e=process.env[U.INSECURE_STORAGE]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function $e(){let e=process.env[U.ALLOW_RAW]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Ve(e){let{resolvedApiBase:n,fromExplicitOverride:t,profileApiBase:i,profileApiBaseSource:a}=e;if(b()===void 0&&w!==""&&"".length!==0&&!t&&a!=="explicit"&&i===""&&n==="")return`Notice: this profile is pinned to ${""} (staging) in ~/.allscale/config.toml.
|
|
9
|
+
The CLI default is now ${w} (production), but a saved profile wins over the default,
|
|
10
10
|
so this session still uses staging. That pin was written before the default changed, so it may just be
|
|
11
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:
|
|
14
|
-
`}var
|
|
15
|
-
`)}},$=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"]),Rn=new Set(Array.from($).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2));function wn(e){let n=[];for(let t=0;t<e.length;t+=1){let i=e[t];if(i.startsWith("-")){let a=i.indexOf("=");if(a!==-1){let o=i.slice(0,a);if($.has(o)){n.push(`${o}=<redacted>`);continue}}}if($.has(i)){n.push(i),t+1<e.length&&($.has(e[t+1])||(n.push("<redacted>"),t+=1));continue}if(i.startsWith("-")&&!i.startsWith("--")&&i.length>2&&i[1]!=="="){let a=i.slice(0,2);if(Rn.has(a)){n.push(`${a}<redacted>`);continue}}n.push(i)}return n}var Un=/(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 Bn(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Un.test(n)}var Pn=/_(removed|cleared|count|total)$/i;function vn(e,n){return typeof n=="number"&&Pn.test(e)}var xn=new Set(Me);function Dn(e,n){return e==="token_symbol"&&typeof n=="string"&&xn.has(n)}var F=100;function le(e,n=0){if(n>8)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,F),i=t.map(a=>le(a,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null),i=Object.entries(e);for(let[a,o]of i.slice(0,F))t[a]=Bn(a)&&!vn(a,o)&&!Dn(a,o)?"<redacted>":le(o,n+1);if(i.length>F){let a="<truncated>";for(;a in t;)a=`<${a}>`;t[a]=`${i.length-F} more keys`}return t}return typeof e=="string"?c(e):e}function Fn(e){let n=Ee()?void 0:2,t=le(e.toJSON()),i=JSON.stringify(t,null,n);return Buffer.byteLength(i,"utf8")+1<=65536?i:JSON.stringify({error:{code:e.code,message:c(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,n)}function $n(e){if(e.requiresInput===!0)return!0;let n=a=>typeof a=="object"&&a!==null&&a.required===!0,t=e.flags??{},i=e.args??{};return Object.values(t).some(a=>n(a))||Object.values(i).some(a=>n(a))}var Je=[{name:"create_claim_link",kind:"mutation",description:"Create a single App claim link. Returns the pending link, funding address, exact deposit total, and bearer claim URL. The link becomes available after the sender's deposit is confirmed. No claim-back.",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateClaimLinkInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"CreateClaimLinkResult",ofType:null}},deprecated:null},{name:"create_contact",kind:"mutation",description:"create a new contact",args:[{name:"create_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateContactInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"create_payment",kind:"mutation",description:"create a new payment",args:[{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreatePaymentInput",ofType:null}},defaultValue:null},{name:"wallet_ids",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"create_store",kind:"mutation",description:"create store",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateStoreInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"StoreCreateResult",ofType:null}},deprecated:null},{name:"update_payment",kind:"mutation",description:"update an existing payment status by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"UpdatePaymentInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"activities",kind:"query",description:"Get current user's activity list with multi-dimensional filters (type, status, contact, wallet, time range, amount range)",args:[{name:"filter_input",description:null,type:{kind:"INPUT_OBJECT",name:"ActivityFilterInput",ofType:null},defaultValue:"null"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"20"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItemPaginatedResponse",ofType:null}},deprecated:null},{name:"auto_payout_session_status",kind:"query",description:"Return the current merchant auto-payout status, expiry, total/used/remaining USD cap, per-transaction limit, and authorized chain/token pairs. Merchants without an active setup receive provisioned=false with null money/expiry fields and no pairs.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AutoPayoutSessionStatus",ofType:null}},deprecated:null},{name:"business",kind:"query",description:"get one business by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Business",ofType:null}},deprecated:null},{name:"business_transaction_records",kind:"query",description:"get transaction records for business",args:[{name:"direction",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_type",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"business_wallets",kind:"query",description:"List the CALLER'S OWN non-custodial wallets (id, chain, address, coin balances). Takes no business id \u2014 the owner is derived from the authenticated identity, so there is no caller-supplied id to mismatch and no way to read another merchant's wallets. Returns [] when the account has no wallet yet.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"WalletEmbedded",ofType:null}}}},deprecated:null},{name:"claim_link",kind:"query",description:"Get one of the caller's own claim links by id (sender surface). A non-owned or unknown id returns CLAIM_LINK_NOT_AVAILABLE \u2014 no existence leak.",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},deprecated:null},{name:"claim_link_fee_preview",kind:"query",description:"Preview the Amount / Network fee / Service fee / Total breakdown without creating a link. Asset and precision validation matches create, but create-time amount and rate limits are enforced only when the link is created, so a successful preview does not guarantee create will succeed. per_transfer_gas is the withdrawal gas estimate in token units.",args:[{name:"amount",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"token_symbol",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"per_transfer_gas",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkFeeBreakdown",ofType:null}},deprecated:null},{name:"contact",kind:"query",description:"get one contact by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contact_by_email",kind:"query",description:"get one contact by it's email",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contacts",kind:"query",description:"get multi contacts by owner business id",args:[{name:"owner_business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ContactPaginatedResponse",ofType:null}},deprecated:null},{name:"my_claim_links",kind:"query",description:"List the caller's claim links, newest first. Optional status and link_source filters narrow the results; query_input controls pagination, ordering, and the created_at time range.",args:[{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"link_source",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkPaginatedResponse",ofType:null}},deprecated:null},{name:"my_transactions",kind:"query",description:"get one user's successful transactions by query",args:[{name:"query_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"payment",kind:"query",description:"get one payment by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"payments",kind:"query",description:"All payments by business ID as sender or recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"recipient_payments",kind:"query",description:"Get multiple payments by business ID as recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"sender_payments",kind:"query",description:"Get multiple payments by business ID as sender",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"transaction",kind:"query",description:"get one transaction by id_str",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}},deprecated:null}];var de={source:"public-cli-contract",synced_at:"2026-08-03T03:01:54.000Z"};var V=class e extends R{static requiresEscapeHatch=!0;static isLocalOnly=!0;static description="List every operation exposed by the schema (queries and mutations). Disabled by default (exit 10); set ALLSCALE_ALLOW_RAW=1 to enable.";static examples=["$ allscale operations","$ allscale operations --kind mutation","$ allscale operations --grep invoice"];static flags={kind:w.Flags.string({char:"k",description:"Filter by operation kind",options:["query","mutation"]}),grep:w.Flags.string({char:"g",description:"Filter by substring match against name + description (case-insensitive)"}),...R.baseFlags};async runCommand(){let{flags:n}=await this.parse(e),t=n.kind,i=n.grep?.toLowerCase(),a=Je.filter(r=>!(t&&r.kind!==t||i&&!`${r.name} ${r.description??""}`.toLowerCase().includes(i))),o={query:0,mutation:0};for(let r of a)o[r.kind]=(o[r.kind]??0)+1;return{total:a.length,by_kind:o,schema_source:de.source,schema_synced_at:de.synced_at,operations:a.map(r=>({name:r.name,kind:r.kind,description:r.description,arg_names:r.args.map(s=>s.name),return_type:ue(r.returnType)}))}}};function ue(e){return e.kind==="NON_NULL"&&e.ofType?`${ue(e.ofType)}!`:e.kind==="LIST"&&e.ofType?`[${ue(e.ofType)}]`:e.name??"Unknown"}
|
|
12
|
+
To keep staging, re-run \`allscale device-login\` with --api-base ${""} (recorded as deliberate, silences this).
|
|
13
|
+
To move to production, run: allscale device-login --api-base ${w}
|
|
14
|
+
`}var A=y(require("fs")),Ge=y(require("os")),le=y(require("path")),de=y(require("@iarna/toml"));var xn=".allscale",Dn="config.toml";function Fn(){return le.join(Ge.homedir(),xn)}function $n(){return le.join(Fn(),Dn)}function Me(){let e=$n();if(!A.existsSync(e))return{};let n=A.readFileSync(e,"utf-8");try{return de.parse(n)}catch(t){throw new d("internal",`Failed to parse ${e}: ${t.message}`)}}function Je(e,n){return e.profile?.[n]}function Ye(e,n,t){let i=n??t??e.default??"default";if(i.includes(":"))throw new d("input.invalid",`Invalid profile name '${i}': ':' is reserved as the keychain namespace separator \u2014 pick a name without ':'.`);return i}function ue(e){if(!q(e))throw new d("input.invalid",`Refusing to send credentials to API base ${C(e)}. `+Y)}function qe(e){let n=b();if(n===void 0||ge(e))return;let t=F(e),i=Te();if(i.length>0){let r=i.map(s=>F(s.base)).filter(s=>s!==null);if(t!==null&&r.includes(t))return;let o=i.map(s=>C(s.base)).join(", ");throw new d("input.invalid",`Refusing to send to ${C(e)} \u2014 this build only signs for: ${o}. Re-login against one of this build's environments, or use a build that includes the one you need.`)}let a=F(n);if(!(t!==null&&t===a))throw new d("input.invalid",`Refusing to send to ${C(e)} \u2014 this build only signs for ${C(n)}. Re-login against this build's environment, or use a build for that one.`)}var Vn=require("@noble/hashes/sha3");var je=["USDT","USDC"];var Pt=new Set([`0x${"0".repeat(40)}`,`0x${"0".repeat(36)}dead`]);var v=require("@oclif/core"),B=class e extends f.Command{static enableJsonFlag=!0;static legacyStagingNoticeShown=!1;static emitsOwnOutput=!1;static requiresEscapeHatch=!1;static requiresInput=!1;static isLocalOnly=!1;static baseFlags={profile:f.Flags.string({description:"Named profile from ~/.allscale/config.toml",helpGroup:"GLOBAL"}),token:f.Flags.string({description:"Override the access token for this invocation (precedence: --token > ALLSCALE_TOKEN > --profile)",helpGroup:"GLOBAL",hidden:E()==="public"}),"api-base":f.Flags.string({description:J,helpGroup:"GLOBAL",hidden:E()==="public"}),"insecure-storage":f.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{ie(this.jsonEnabled()),re(),k({type:"session-start",command:this.id??"",argv:oe(this.argv)});let n=this.constructor;if(E()==="public"){if(this.argv.some(r=>r==="--token"||r.startsWith("--token=")))throw new d("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(r=>r==="--api-base"||r.startsWith("--api-base=")))throw new d("input.invalid","--api-base is not supported in this build; it always talks to its bound AllScale environment.");if(!n.isLocalOnly&&$()!==void 0)throw new d("input.invalid","ALLSCALE_API_BASE is not supported in this build; unset it \u2014 this build always talks to its bound AllScale environment.")}let t=Pe(this.jsonEnabled()),i=this.argv.length===0&&!t&&Kn(n)?this.config.findCommand(this.id??""):void 0;if(i){R();let r=await(0,f.loadHelpClass)(this.config),o=this.config.pjson.oclif?.helpOptions??this.config.pjson.helpOptions;await new r(this.config,o).showCommandHelp(i,this.config.topics);return}if(n.requiresEscapeHatch&&!$e())throw this.argv.length>0&&await this.parse(),new d("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. Access remains governed by the key's granted scopes, which the backend checks on each request.");let a=await this.runCommand();return k({type:"command-end",ok:!0}),R(),n.emitsOwnOutput?void 0:(this.jsonEnabled()||ke(a),{data:a})}catch(n){let t=he(n);xe({code:t.code,message:t.message,exitCode:t.exitCode}),this.emitError(t),process.exitCode=t.exitCode;return}finally{ie(!1)}}resolveSessionApiBaseChain(n){let t=Me(),i=n.profile??void 0,a=n["api-base"]??void 0,r=i!==void 0||se()!==void 0,o=Ye(t,i,se()),s=Je(t,o),u=a??$(),p=u??s?.api_base??w,_=Ve({resolvedApiBase:p,fromExplicitOverride:u!==void 0,profileApiBase:s?.api_base,profileApiBaseSource:s?.api_base_source});return _&&!e.legacyStagingNoticeShown&&(e.legacyStagingNoticeShown=!0,T({event:"legacy_staging_profile",api_base:p,profile:o},_)),{apiBase:p,explicitApiBase:u,profileApiBase:s?.api_base,profile:o,profileExplicit:r}}resolveSessionApiBaseForPayoutDerivation(n){let{apiBase:t}=this.resolveSessionApiBaseChain(n);return this.constructor.isLocalOnly||ue(t),t}resolveContext(n){if(E()==="public"){if(n.token!==void 0)throw new d("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(n["api-base"]!==void 0)throw new d("input.invalid","--api-base is not supported in this build; it always talks to its bound AllScale environment.");if(!this.constructor.isLocalOnly&&$()!==void 0)throw new d("input.invalid","ALLSCALE_API_BASE is not supported in this build; unset it \u2014 this build always talks to its bound AllScale environment.")}let t=n.token??void 0,i=!!n["insecure-storage"],{apiBase:a,explicitApiBase:r,profile:o,profileApiBase:s,profileExplicit:u}=this.resolveSessionApiBaseChain(n);return this.constructor.isLocalOnly||(ue(a),qe(a)),{apiBase:a,profile:o,token:t??De(),insecureStorage:i||Fe(),apiBaseSource:r!==void 0?"explicit":s!==void 0?"profile":"default",profileExplicit:u}}emitError(n){process.stderr.write(`${jn(n)}
|
|
15
|
+
`)}};var Gn=/_(removed|cleared|count|total)$/i;function Mn(e,n){return typeof n=="number"&&Gn.test(e)}var Jn=new Set(je);function Yn(e,n){return e==="token_symbol"&&typeof n=="string"&&Jn.has(n)}var V=100;function G(e,n=0){if(n>8)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,V),i=t.map(a=>G(a,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null),i=Object.entries(e);for(let[a,r]of i.slice(0,V))t[a]=Ee(a)&&!Mn(a,r)&&!Yn(a,r)?"<redacted>":G(r,n+1);if(i.length>V){let a="<truncated>";for(;a in t;)a=`<${a}>`;t[a]=`${i.length-V} more keys`}return t}if(typeof e=="string"){let t=qn(e);return t!==void 0?c(JSON.stringify(G(t,n+1))):c(e)}return e}function qn(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function jn(e){let n=we()?void 0:2,t=G(e.toJSON()),i=JSON.stringify(t,null,n);return Buffer.byteLength(i,"utf8")+1<=65536?i:JSON.stringify({error:{code:e.code,message:c(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,n)}function Kn(e){if(e.requiresInput===!0)return!0;let n=a=>typeof a=="object"&&a!==null&&a.required===!0,t=e.flags??{},i=e.args??{};return Object.values(t).some(a=>n(a))||Object.values(i).some(a=>n(a))}var Ke=[{name:"create_claim_link",kind:"mutation",description:"Create a single App claim link. Returns the pending link, funding address, exact deposit total, and bearer claim URL. The link becomes available after the sender's deposit is confirmed. No claim-back.",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateClaimLinkInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"CreateClaimLinkResult",ofType:null}},deprecated:null},{name:"create_contact",kind:"mutation",description:"create a new contact",args:[{name:"create_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateContactInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"create_payment",kind:"mutation",description:"create a new payment",args:[{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreatePaymentInput",ofType:null}},defaultValue:null},{name:"wallet_ids",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"create_store",kind:"mutation",description:"create store",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateStoreInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"StoreCreateResult",ofType:null}},deprecated:null},{name:"update_payment",kind:"mutation",description:"update an existing payment status by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"UpdatePaymentInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"activities",kind:"query",description:"Get current user's activity list with multi-dimensional filters (type, status, contact, wallet, time range, amount range)",args:[{name:"filter_input",description:null,type:{kind:"INPUT_OBJECT",name:"ActivityFilterInput",ofType:null},defaultValue:"null"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"20"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItemPaginatedResponse",ofType:null}},deprecated:null},{name:"auto_payout_session_status",kind:"query",description:"Return the current merchant auto-payout status, expiry, total/used/remaining USD cap, per-transaction limit, and authorized chain/token pairs. Merchants without an active setup receive provisioned=false with null money/expiry fields and no pairs.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AutoPayoutSessionStatus",ofType:null}},deprecated:null},{name:"business",kind:"query",description:"get one business by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Business",ofType:null}},deprecated:null},{name:"business_contact_by_email",kind:"query",description:"Look up the contact card of the business whose login email is given. Used to fill the invoice header's From: block with the same name/email/phone the web editor shows.",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"BusinessContact",ofType:null}},deprecated:null},{name:"business_transaction_records",kind:"query",description:"get transaction records for business",args:[{name:"direction",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_type",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"business_wallets",kind:"query",description:"List the CALLER'S OWN non-custodial wallets (id, chain, address, coin balances). Takes no business id \u2014 the owner is derived from the authenticated identity, so there is no caller-supplied id to mismatch and no way to read another merchant's wallets. Returns [] when the account has no wallet yet.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"WalletEmbedded",ofType:null}}}},deprecated:null},{name:"claim_link",kind:"query",description:"Get one of the caller's own claim links by id (sender surface). A non-owned or unknown id returns CLAIM_LINK_NOT_AVAILABLE \u2014 no existence leak.",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},deprecated:null},{name:"contact",kind:"query",description:"get one contact by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contact_by_email",kind:"query",description:"get one contact by it's email",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contacts",kind:"query",description:"get multi contacts by owner business id",args:[{name:"owner_business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ContactPaginatedResponse",ofType:null}},deprecated:null},{name:"my_claim_links",kind:"query",description:"List the caller's claim links, newest first. Optional status and link_source filters narrow the results; query_input controls pagination, ordering, and the created_at time range.",args:[{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"link_source",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkPaginatedResponse",ofType:null}},deprecated:null},{name:"my_transactions",kind:"query",description:"get one user's successful transactions by query",args:[{name:"query_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"payment",kind:"query",description:"get one payment by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"payments",kind:"query",description:"All payments by business ID as sender or recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"recipient_payments",kind:"query",description:"Get multiple payments by business ID as recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"sender_payments",kind:"query",description:"Get multiple payments by business ID as sender",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"transaction",kind:"query",description:"get one transaction by id_str",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}},deprecated:null}];var pe={source:"public-cli-contract",synced_at:"2026-08-03T03:01:54.000Z"};var M=class e extends B{static requiresEscapeHatch=!0;static isLocalOnly=!0;static description="List every operation exposed by the schema (queries and mutations). Disabled by default (exit 10); set ALLSCALE_ALLOW_RAW=1 to enable.";static examples=["$ allscale operations","$ allscale operations --kind mutation","$ allscale operations --grep invoice"];static flags={kind:v.Flags.string({char:"k",description:"Filter by operation kind",options:["query","mutation"]}),grep:v.Flags.string({char:"g",description:"Filter by substring match against name + description (case-insensitive)"}),...B.baseFlags};async runCommand(){let{flags:n}=await this.parse(e),t=n.kind,i=n.grep?.toLowerCase(),a=Ke.filter(o=>!(t&&o.kind!==t||i&&!`${o.name} ${o.description??""}`.toLowerCase().includes(i))),r={query:0,mutation:0};for(let o of a)r[o.kind]=(r[o.kind]??0)+1;return{total:a.length,by_kind:r,schema_source:pe.source,schema_synced_at:pe.synced_at,operations:a.map(o=>({name:o.name,kind:o.kind,description:o.description,arg_names:o.args.map(s=>s.name),return_type:ce(o.returnType)}))}}};function ce(e){return e.kind==="NON_NULL"&&e.ofType?`${ce(e.ofType)}!`:e.kind==="LIST"&&e.ofType?`[${ce(e.ofType)}]`:e.name??"Unknown"}
|
|
16
16
|
//# sourceMappingURL=operations.js.map
|