@allscale/cli 1.0.1 → 1.0.2
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 +38 -11
- package/dist/commands/build-info.js +12 -12
- package/dist/commands/claim-link/claim.js +10 -10
- package/dist/commands/claim-link/create.js +27 -27
- package/dist/commands/claim-link/get.js +13 -13
- package/dist/commands/claim-link/list.js +12 -12
- package/dist/commands/claim-link/status.js +11 -11
- package/dist/commands/describe.js +11 -11
- package/dist/commands/device-login.js +26 -25
- package/dist/commands/invoice/get.js +12 -12
- package/dist/commands/invoice/list.js +12 -12
- package/dist/commands/invoice/pay.js +41 -37
- package/dist/commands/invoice/received.js +12 -12
- package/dist/commands/invoice/send.js +27 -27
- package/dist/commands/invoice/sent.js +11 -11
- package/dist/commands/invoice/update.js +13 -13
- package/dist/commands/logout.js +19 -13
- package/dist/commands/operations.js +11 -11
- package/dist/commands/otp-login.js +18 -18
- package/dist/commands/otp-send.js +11 -11
- package/dist/commands/payout/send.js +13 -13
- package/dist/commands/payout/status.js +12 -12
- package/dist/commands/scope.js +17 -17
- package/dist/commands/store/create.js +13 -13
- package/dist/commands/transaction/get.js +12 -12
- package/dist/commands/transaction/list.js +12 -12
- package/dist/commands/wallet/list.js +12 -12
- package/dist/commands/wallet/send.js +25 -25
- package/dist/commands/whoami.js +14 -12
- package/dist/hooks/version-suffix.js +1 -1
- package/dist/index.js +11 -11
- package/oclif.manifest.json +23 -10
- package/package.json +1 -1
package/dist/commands/whoami.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).some(t=>
|
|
3
|
-
`)}var f=A(require("fs")),
|
|
4
|
-
`)}else
|
|
5
|
-
`);return}
|
|
6
|
-
`);return}f.appendFileSync(
|
|
7
|
-
`)}catch(r){if(
|
|
8
|
-
`)}catch{}}}function
|
|
1
|
+
"use strict";var an=Object.create;var Q=Object.defineProperty;var ln=Object.getOwnPropertyDescriptor;var cn=Object.getOwnPropertyNames;var un=Object.getPrototypeOf,dn=Object.prototype.hasOwnProperty;var fn=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},Qe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of cn(t))!dn.call(e,i)&&i!==n&&Q(e,i,{get:()=>t[i],enumerable:!(r=ln(t,i))||r.enumerable});return e};var A=(e,t,n)=>(n=e!=null?an(un(e)):{},Qe(t||!e||!e.__esModule?Q(n,"default",{value:e,enumerable:!0}):n,e)),pn=e=>Qe(Q({},"__esModule",{value:!0}),e);var Fr={};fn(Fr,{default:()=>de});module.exports=pn(Fr);var E=require("@oclif/core");var et="public",tt="https://app.allscale.io";var nt=["https://app.allscale.io"];var pe="Override the API base URL (public builds accept only https://app.allscale.io)";var ge="Only https://app.allscale.io is allowed, and URL userinfo is forbidden.";function rt(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 it(e){return rt(e)!==null}function he(e){let t=rt(e);return t!==null&&nt.includes(t.origin)}function G(){return"".trim()||void 0}function R(){return"public"}function ot(e){try{let{hostname:t}=new URL(e);return t==="127.0.0.1"||t==="localhost"||t==="[::1]"}catch{return!1}}function st(){{let e="[]".trim();if(e.length===0)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}return me()}function me(){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:d}=o;if(typeof a!="string"||a.trim().length===0||typeof l!="string"||l.trim().length===0)continue;let u=typeof d=="string"?d.trim():"";i.push({base:a.trim(),key:l,keyId:u.length>0?u:"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 gn="device-login",hn=/^[A-Za-z0-9._-]{1,64}$/;function Y(e){return hn.test(e)?e:"<profile>"}function be(e){return"allscale otp-login --profile "+(e===void 0?"<profile>":Y(e))+" --email <you@example.com> --scopes <scope> --otp-stdin"}function lt(e){let t=Y(e);return`No tokens stored for profile '${e}'. Run \`allscale device-login --profile ${t}\` (recommended), or use \`${be(e)}\` for headless automation.`}function ct(e){return`Unknown profile '${e}' \u2014 no such profile is saved on this machine. Check the spelling first; to deliberately create '${e}', run \`allscale ${gn} --profile ${Y(e)}\`.`}var mn={"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_invalid":5,"auth.token_expired":5,"auth.device_pairing_timeout":3,"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},yn=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 Ae(e){return(typeof e=="string"?e:String(e??"")).replace(yn,"")}var _n=64;function ye(e,t=new Map,n=0){if(typeof e=="string")return Ae(e);if(e===null||typeof e!="object")return e;let r=t.get(e);if(r!==void 0)return r;if(n>=_n)return e;if(Array.isArray(e)){let a=[];t.set(e,a);for(let l of e)a.push(ye(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:ye(l,t,n+1),writable:!0,enumerable:!0,configurable:!0});return o}var c=class extends Error{code;details;constructor(t,n,r){super(Ae(n)),this.code=t,this.details=r&&ye(r),this.name="AllscaleError"}get exitCode(){return mn[this.code]}toJSON(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}};function ut(e){if(e instanceof c)return e;if(e instanceof Error){if(Sn(e)){let t=En(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 bn=new Set(["CLIError","CLIParseError","RequiredArgsError","RequiredFlagError","UnexpectedArgsError","FlagInvalidOptionError","ArgInvalidOptionError","InvalidArgsSpecError"]),An=[/^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(wn(e))return!0;let t=e.name??"";return bn.has(t)?t==="CLIError"?_e(e,"parse")||at(e.message):!0:at(e.message)}function wn(e){if(!_e(e,"oclif"))return!1;let t=e.oclif;return typeof t=="object"&&t!==null&&t.exit===2&&_e(e,"parse")}function at(e){return e?Ae(e).split(`
|
|
2
|
+
`).some(t=>An.some(n=>n.test(t.trim()))):!1}function _e(e,t){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,t)}function En(e){let t=e,n={};for(let r of["code","exitCode","suggestions","ref"])t[r]!==void 0&&(n[r]=t[r]);return n}function dt(e){process.stdout.write(`${JSON.stringify({data:e},null,2)}
|
|
3
|
+
`)}var f=A(require("fs")),te=A(require("path")),St=A(require("crypto"));var Ln="...<truncated>",kn=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+/g,On=/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,ke=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,Se=String.raw`(?:proxy[_-]?)?authorization`,Tn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Se}"|'${Se}'|${Se})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${ke}`,"gi"),In=/\b(https?:\/\/)[^\s/?#]+@/gi,vn=String.raw`(?:[A-Za-z0-9]+[_-])*`,Cn=String.raw`(?:[A-Za-z0-9]{1,32}[_-]){0,8}`,pt=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)`,ft=pt(vn),xn=pt(Cn),Nn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${ft}"|'${ft}'|${xn})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${ke}`,"gi"),we=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)`,Rn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${we}"|'${we}'|${we})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${ke}`,"g");function gt(e){return e.replace(In,"$1<redacted>@").replace(kn,"<redacted-jwt>").replace(Tn,"$1$2$3<redacted>").replace(Nn,"$1$2<redacted>").replace(Rn,"$1$2<redacted>").replace(On,"Bearer <redacted>")}var Pn=/(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 ht(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Pn.test(t)}function mt(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 yt(e,t,n=Ln){if(t<=0)return"";if(Buffer.byteLength(e,"utf8")<=t)return e;let r=Buffer.byteLength(n,"utf8");if(r>=t){let l="",d=0;for(let u of n){let h=Buffer.byteLength(u,"utf8");if(d+h>t)break;l+=u,d+=h}return l}let i=t-r,o="",a=0;for(let l of e){let d=Buffer.byteLength(l,"utf8");if(a+d>i)break;o+=l,a+=d}return`${o}${n}`}function y(e,t=16384){return yt(mt(gt(e)),t)}var Ee=100,Bn=8,Dn=8*1024;function ee(){return{remaining:Dn}}function Le(e,t){let n=Math.min(16384,t.remaining),r=yt(e,n);return t.remaining-=Buffer.byteLength(r,"utf8"),r}function P(e,t,n=0,r={}){if(n>Bn)return Le("<truncated>",t);if(typeof e=="string"){let i=gt(e);return Le(r.escapeControls?mt(i):i,t)}if(Array.isArray(e)){let i=e.slice(0,Ee),o=i.map(a=>P(a,t,n+1,r));return e.length>i.length&&o.push(Le(`<${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,Ee))i[a]=P(l,t,n+1,r);return o.length>Ee&&(i.output_truncated=!0),i}return e}var Oe=require("process");var Te=!1;function Ie(e){Te=e}function bt(){return Te}var _t="1";function D(e,t){if(Te){let n={...e};delete n.version;let r=ee(),i={event:n.event,...n},o=P(i,r,0,{escapeControls:!0}),a=JSON.stringify({version:_t,...o});Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:_t,event:o.event,output_truncated:!0})),Oe.stderr.write(`${a}
|
|
4
|
+
`)}else Oe.stderr.write(t)}var At="2",U=null,b=null,$=!1,K=!1;function Un(){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=St.randomBytes(4).toString("hex");return te.join(t,`allscale-output-${n}-${r}.ndjson`)}return null}var ve=64*1024*1024,$n=null;function Ce(e={}){if(e.quiet&&(K=!0),$)return;let t=Un();if(!t)return;U=null;let n=null;try{if(($n??process.platform)==="win32")throw new Error("owner-only sidecar ACLs cannot be enforced on Windows; sidecar output is disabled");let r=te.dirname(t);if(f.mkdirSync(r,{recursive:!0,mode:448}),!process.env.ALLSCALE_OUTPUT_FILE_PATH&&process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY){let d=f.statSync(r),u=d.mode&511;if(!d.isDirectory()||(u&63)!==0)throw new Error(`output directory must be owner-only (no group/other permissions); current mode is ${u.toString(8).padStart(3,"0")}`)}let 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{}K||D({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}U=t,b=n,$=!0}var Fn=[/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 Mn(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Fn.some(n=>n.test(t))}function Gn(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=Yn(t.pathname);let i=n;t.pathname!==r&&(i=!0);for(let[o]of t.searchParams)Mn(o)&&(t.searchParams.set(o,"<redacted>"),i=!0);return i?t.toString():e}catch{return e}}function Yn(e){return e.replace(/(\/(?:api\/)?(?:v1\/)?public\/claim-links\/)([^/:]+)(:claim)?(?=\/?$)/,"$1<redacted>$3").replace(/(\/(?:api\/)?public\/claim-links\/)([^/]+)(\/claim)(?=\/?$)/,"$1<redacted>$3")}function Kn(e){return(e.type==="request"||e.type==="bridge_browser_open")&&typeof e.url=="string"?{...e,url:Gn(e.url)}:e}function jn(e){let t=new Date().toISOString(),n=e,{type:r,...i}=n,o=P(i,ee()),a=JSON.stringify({version:At,timestamp:t,type:r,...o});return Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:At,timestamp:t,type:r,output_truncated:!0})),a}function F(e){if(!$||!U||b===null)return;let t=Kn(e),n=jn(t);try{if(f.fstatSync(b).size+Buffer.byteLength(n,"utf8")+1>ve){$=!1;try{f.closeSync(b)}catch{}b=null,K||D({event:"sidecar_disabled",reason:"size_limit",...U===null?{}:{path:y(U)},max_bytes:ve},`${y(`[allscale] sidecar exceeded ${ve} bytes; disabling it for the rest of this run. Rotate or remove ${U}, or point ALLSCALE_OUTPUT_FILE_DIRECTORY at a directory so each run gets its own file.`)}
|
|
6
|
+
`);return}f.appendFileSync(b,`${n}
|
|
7
|
+
`)}catch(r){if($=!1,b!==null){try{f.closeSync(b)}catch{}b=null}try{K||D({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 wt(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function j(){if(K=!1,$=!1,b!==null){try{f.closeSync(b)}catch{}b=null}}function Et(e=!1){let t=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||wt()||!t}var W=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(W).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2)),Hn=Array.from(W).filter(e=>e.startsWith("--")).sort((e,t)=>t.length-e.length),Jn=new Set(["--otp-stdin","--password-stdin"]);function xe(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(W.has(a)){t.push(`${a}=<redacted>`);continue}}}if(W.has(r)){t.push(r),n+1<e.length&&(W.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(Wn.has(o)){t.push(`${o}<redacted>`);continue}}let i=Jn.has(r)?void 0:Hn.find(o=>r.length>o.length&&r.startsWith(o));if(i){t.push(`${i}<redacted>`);continue}t.push(r)}return t}function Lt(e){F({type:"error",code:e.code,message:y(e.message)}),F({type:"command-end",ok:!1,exitCode:e.exitCode}),j()}var H=G()??tt,w={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 Ne(e){return it(e)?new URL(e).origin:null}function k(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return"<unparseable URL>"}}function Re(e){try{let t=new URL(e);return t.protocol!=="http:"&&t.protocol!=="https:"?`${t.protocol}//${t.host}`:t.username.length===0&&t.password.length===0&&t.search.length===0&&t.hash.length===0?e:(t.username="",t.password="",t.search="",t.hash="",`${t.origin}${t.pathname}`)}catch{return"<unparseable URL>"}}function kt(){let e=process.env[w.TOKEN]?.trim();return e&&e.length>0?e:void 0}function Pe(){let e=process.env[w.PROFILE]?.trim();return e&&e.length>0?e:void 0}function J(){let e=process.env[w.API_BASE]?.trim();return e&&e.length>0?e:void 0}function Ot(){let e=process.env[w.INSECURE_STORAGE]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Tt(){let e=process.env[w.NO_KEYCHAIN]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function It(){let e=process.env[w.ALLOW_RAW]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function vt(e){let{resolvedApiBase:t,fromExplicitOverride:n,profileApiBase:r,profileApiBaseSource:i}=e;if(G()===void 0&&H!==""&&"".length!==0&&!n&&i!=="explicit"&&r===""&&t==="")return`Notice: this profile is pinned to ${""} (staging) in ~/.allscale/config.toml.
|
|
9
9
|
The CLI default is now ${H} (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
12
|
To keep staging, re-run \`allscale device-login\` with --api-base ${""} (recorded as deliberate, silences this).
|
|
13
13
|
To move to production, run: allscale device-login --api-base ${H}
|
|
14
|
-
`}var
|
|
15
|
-
`)}};var qn=/_(removed|cleared|count|total)$/i;function Xn(e,t){return typeof t=="number"&&qn.test(e)}var Zn=new Set(xt);function Vn(e,t){return e==="token_symbol"&&typeof t=="string"&&Zn.has(t)}var ie=100;function oe(e,t=0){if(t>8)return"<truncated>";if(Array.isArray(e)){let n=e.slice(0,ie),r=n.map(i=>oe(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,ie))n[i]=pt(i)&&!Xn(i,o)&&!Vn(i,o)?"<redacted>":oe(o,t+1);if(r.length>ie){let i="<truncated>";for(;i in n;)i=`<${i}>`;n[i]=`${r.length-ie} more keys`}return n}if(typeof e=="string"){let n=Qn(e);return n!==void 0?h(JSON.stringify(oe(n,t+1))):h(e)}return e}function Qn(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 er(e){let t=_t()?void 0:2,n=oe(e.toJSON()),r=JSON.stringify(n,null,t);return Buffer.byteLength(r,"utf8")+1<=65536?r:JSON.stringify({error:{code:e.code,message:h(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,t)}function tr(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))}function nr(e,t={}){let n;try{n=Ct(re())}catch{return}if(!(n.length===0||n.includes(e)))return new c("auth.unknown_profile",at(e)+(t.messageSuffix??""),{profile:e})}function Bt(e){if(e.profileExplicit){let t=nr(e.profile);if(t)return t}return new c("auth.no_token",st(e.profile))}function Fe(e){let t=e.split(".");if(t.length!==3)throw new c("auth.token_expired","This token is not a JWT session. Agent API keys are not JWTs \u2014 this path needs a human session token.");try{let n=Buffer.from(t[1].replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8");return JSON.parse(n)}catch(n){throw new c("auth.token_expired",`Failed to decode JWT payload: ${n.message}`)}}function Ut(e,t=Math.floor(Date.now()/1e3)){return typeof e.exp=="number"&&e.exp<t}var qt=A(require("path"));var Ge=require("crypto"),s=A(require("fs")),g=A(require("path"));var se=1024*1024,rr=5e3,ir=20,or=3e4,$e=4096,sr=new Int32Array(new SharedArrayBuffer(4)),z=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function ae(e){return e instanceof z}var _=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},ar=null;function k(){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 le(){return(ar??process.platform)!=="win32"}function jt(){if(!le())throw k()}function Wt(e){try{return s.default.lstatSync(e),!1}catch(t){if(!p(t,"ENOENT"))throw t}try{let t=s.default.lstatSync(g.dirname(e));return!t.isSymbolicLink()&&t.isDirectory()}catch(t){if(p(t,"ENOENT"))return!0;throw t}}function p(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 X(e,t){return e.dev===t.dev&&e.ino===t.ino}function lr(e){Atomics.wait(sr,0,0,e)}function Ht(e){try{return process.kill(e,0),!0}catch(t){return!p(t,"ESRCH")}}function cr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dt(e,t){let n=g.dirname(e);t&&s.default.mkdirSync(n,{recursive:!0,mode:448});let r;try{r=s.default.lstatSync(n)}catch(o){if(!t&&p(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()||!X(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&&g.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 b(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&&p(o,"ENOENT")?new _:o}if(!X(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 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 ur(e,t){if(t.size>se)throw new Error("credential-store file exceeds the maximum supported size");let n=Buffer.alloc(se+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>se)throw new Error("credential-store file exceeds the maximum supported size");return n.subarray(0,r).toString("utf8")}function Ft(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(p(i,"ENOENT"))try{if(s.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(p(o,"ENOENT"))return null;throw o}throw i}let n=s.default.fstatSync(t),r=b(e,t,n);return ur(t,r)}finally{t!==null&&s.default.closeSync(t)}}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(i){if(p(i,"ENOENT")&&Wt(e))return;throw i}let n=s.default.fstatSync(t),r=b(e,t,n);O(e,r)}finally{t!==null&&s.default.closeSync(t)}zt(g.dirname(e))}function dr(e){let t;try{t=s.default.lstatSync(e)}catch(n){if(p(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 fr(e,t){for(let n=0;n<8;n+=1){let r=(0,Ge.randomBytes)(12).toString("hex"),i=g.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(p(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 zt(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 pr(e,t){let n=Buffer.from(t,"utf8");if(n.length>se)throw new Error("credential-store file exceeds the maximum supported size");let r=g.dirname(e),i=g.basename(e),o=null,a=null,l=!1;try{let u=fr(r,i);o=u.fd,a=u.tempPath;let d=s.default.fstatSync(o);if((b(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),b(a,o,s.default.fstatSync(o));let S=o;o=null,s.default.closeSync(S),dr(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{}}zt(r)}function gr(e){return g.join(g.dirname(e),`.${g.basename(e)}.lock`)}function hr(e){return g.join(g.dirname(e),`.${g.basename(e)}.lock-recovery`)}function mr(e,t){if(t.size>$e)return null;let n=Buffer.alloc($e+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>$e)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 O(e,t){let n=s.default.lstatSync(e);if(n.isSymbolicLink()||!n.isFile()||!X(n,t))throw new Error("credential-store lock changed while it was being inspected");q(n,"credential-store lock"),s.default.unlinkSync(e)}function Mt(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(p(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(p(d,"ENOENT"))return{state:"absent"};throw d}throw u}let r=s.default.fstatSync(n),i=b(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=mr(n,i);return{state:(o?.target===t&&o?!Ht(o.pid):Date.now()-i.mtimeMs>=or)?"stale":"active",stats:i}}finally{n!==null&&s.default.closeSync(n)}}function _r(e,t){for(let n=0;n<8;n+=1){let r=(0,Ge.randomBytes)(12).toString("hex"),i=g.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=b(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(p(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 yr(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 p(r,"ENOENT")?new _:r}try{let r=s.default.fstatSync(n),i=b(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!X(i,t))throw new _;return{fd:n,lockPath:e,stats:i}}catch(r){throw s.default.closeSync(n),r}}function Gt(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(p(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(p(r,"ENOENT"))return!1;throw r}throw n}return b(e,t,s.default.fstatSync(t),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{t!==null&&s.default.closeSync(t)}}function Sr(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(p(r,"EEXIST"))return null;throw r}let n=null;try{n=s.default.fstatSync(t);let r=b(e,t,n,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:t,lockPath:e,stats:r}}catch(r){if(n!==null)try{O(e,n)}catch{}throw s.default.closeSync(t),r}}function T(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");lr(ir)}function Yt(e){let t=g.dirname(e),n=g.basename(e),r=gr(e),i=hr(e),o=_r(t,n),a=Date.now()+rr,l=!1,u=!1,d=null,m;try{for(;d===null;)try{if(Gt(i)){T(a,!0);continue}s.default.linkSync(o.claimPath,r),u=!0,d=yr(r,o.stats),l=!0}catch(S){if(u&&!l){try{O(r,o.stats)}catch{}u=!1}if(S instanceof _){T(a,!1);continue}if(!p(S,"EEXIST"))throw S;let fe;try{fe=Mt(r,n)}catch(E){if(E instanceof _){T(a,!1);continue}throw E}if(fe.state==="absent")continue;if(fe.state==="stale"){let E;try{E=Sr(i)}catch(P){if(P instanceof _){T(a,!1);continue}throw P}if(E!==null){try{let P;try{P=Mt(r,n)}catch(Xe){if(Xe instanceof _){T(a,!1);continue}throw Xe}P.state==="stale"&&O(r,P.stats)}finally{Me(E)}continue}}let qe;try{qe=Gt(i)}catch(E){if(E instanceof _){T(a,!1);continue}throw E}T(a,qe)}}catch(S){m=S}try{O(o.claimPath,o.stats)}catch(S){!p(S,"ENOENT")&&!l&&m===void 0&&(m=S)}if(m!==void 0)throw m;if(d===null)throw new Error("credential-store lock acquisition failed");return d}function Me(e){try{O(e.lockPath,e.stats)}finally{s.default.closeSync(e.fd)}}function Ar(e,t){let n=cr(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 Kt(e){let t=g.dirname(e),n=g.basename(e);for(let r of s.default.readdirSync(t)){let i=Ar(r,n);if(i===null||Ht(i))continue;let o=g.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(p(d,"ENOENT")||p(d,"ELOOP"))continue;throw d}let l=s.default.fstatSync(a),u=s.default.lstatSync(o);if(!l.isFile()||u.isSymbolicLink()||!u.isFile()||!X(l,u))continue;try{q(l,"credential-store orphan")}catch{continue}O(o,l)}catch(l){if(!p(l,"ENOENT"))throw l}finally{a!==null&&s.default.closeSync(a)}}}function Z(e,t,n){if(!le()){if(t.allowUnsupportedPlatformCleanup){if(t.createParent)throw k();if(!Dt(e,!1))return n({read:()=>null,remove:()=>{},write:()=>{throw k()}});let a=Yt(e);try{return Kt(e),n({read:()=>Ft(e),remove:()=>$t(e),write:()=>{throw k()}})}finally{Me(a)}}if(!t.createParent){let o=!1;try{o=Wt(e)}catch{throw k()}if(o)return n({read:()=>null,remove:()=>{},write:()=>{throw k()}})}throw k()}if(!Dt(e,t.createParent))return n({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let i=Yt(e);try{return Kt(e),n({read:()=>Ft(e),remove:()=>$t(e),write:o=>pr(e,o)})}finally{Me(i)}}var Ye="allscale-cli";function He(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xt(e){return He(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function C(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 ce(){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 I,je=!1;function Er(){return Tt()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function wr(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
|
|
17
|
-
`)
|
|
14
|
+
`}var O=A(require("fs")),Ct=A(require("os")),Be=A(require("path")),De=A(require("@iarna/toml"));var Xn=".allscale",Vn="config.toml";function Ue(){return Be.join(Ct.homedir(),Xn)}function Zn(){return Be.join(Ue(),Vn)}function ne(){let e=Zn();if(!O.existsSync(e))return{};let t=O.readFileSync(e,"utf-8");try{return De.parse(t)}catch(n){throw new c("internal",`Failed to parse ${e}: ${n.message}`)}}function xt(e){return Object.keys(e.profile??{}).sort()}function Nt(e,t){return e.profile?.[t]}function Rt(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 re(e){if(!he(e))throw new c("input.invalid",`Refusing to send credentials to API base ${k(e)}. `+ge)}function $e(e){let t=Qn(e);if(t)throw new c("input.invalid",t.message)}function Fe(){let e=G();if(e===void 0)return;let t=st();return t.length>0?{endpoints:t.map(n=>n.base),fromPairs:!0}:{endpoints:[e],fromPairs:!1}}function Qn(e){let t=Fe();if(t===void 0||ot(e))return;let{endpoints:n,fromPairs:r}=t,i=Ne(e),o=n.map(l=>Ne(l)).filter(l=>l!==null);if(i!==null&&o.includes(i))return;let a=n.map(l=>k(l)).join(", ");return{message:r?`Refusing to send to ${k(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.`:`Refusing to send to ${k(e)} \u2014 this build only signs for ${a}. Re-login against this build's environment, or use a build for that one.`}}function Pt(e){for(let[t,n]of[["untrusted",re],["unsigned",$e]])try{n(e)}catch(r){if(r instanceof c)return{kind:t,message:r.message};throw r}}var er=require("@noble/hashes/sha3");var Bt=["USDT","USDC"];var Oi=new Set([`0x${"0".repeat(40)}`,`0x${"0".repeat(36)}dead`]);var tr="unknown_otp_id",nr="invalid_code",rr="expired_code";function ir(e){return`'${e.replace(/'/g,"'\\''")}'`}function Dt(e){return`Run \`allscale otp-send --email ${ir(e)}\` first \u2014 that command does report a missing account \u2014 then retry with the otp_id it returns and a fresh code.`}var or=new Map([[tr,(e,t)=>`${e}: this environment never issued the --otp-id you passed for '${t}', so the verification code was never the problem. The backend decides this by comparing the otp_id against that address alone, so it says nothing about whether the account exists. ${Dt(t)}`],[nr,e=>`${e}: the --otp-id is one this environment issued and a live code stands behind it \u2014 the verification code you passed is what does not match. Check for a typo \u2014 the backend invalidates the code after a few wrong answers, so if you are unsure, request a fresh code instead of guessing.`],[rr,(e,t,n)=>n?`${e}: this run's send request was accepted moments ago, but this attempt could not claim a live code for the --otp-id. Delivery is asynchronous and the code is stored only after the email goes out, so it may still be in flight \u2014 or the send may have failed outright, in which case no code is coming. The code you submitted may also have expired, been used, run out of attempts, or been replaced by a newer send. Check the inbox, including spam, and retry with whatever code arrived. If nothing arrives, confirm the address and wait at least three minutes before requesting one fresh code \u2014 sends are rate-limited per address, and retrying in a tight loop spends that budget even when the send is rejected.`:`${e}: this attempt could not claim a live code for the --otp-id. The code you submitted may have expired, been used, run out of attempts, been replaced by a later send, or never have been requested for this address; the backend does not distinguish those. If a newer code was delivered after the one you entered, use that one. ${Dt(t)}`]]);var Ut=[...or.keys()];var $t=require("@oclif/core"),z=class e extends E.Command{static enableJsonFlag=!0;static legacyStagingNoticeShown=!1;static emitsOwnOutput=!1;static requiresEscapeHatch=!1;static requiresInput=!1;static isLocalOnly=!1;static baseFlags={profile:E.Flags.string({description:"Named profile from ~/.allscale/config.toml",helpGroup:"GLOBAL"}),token:E.Flags.string({description:"Override the access token for this invocation (precedence: --token > ALLSCALE_TOKEN > --profile)",helpGroup:"GLOBAL",hidden:R()==="public"}),"api-base":E.Flags.string({description:pe,helpGroup:"GLOBAL",hidden:R()==="public"}),"insecure-storage":E.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()),Ce(),F({type:"session-start",command:this.id??"",argv:xe(this.argv)});let t=this.constructor;if(R()==="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&&J()!==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&&gr(t)?this.config.findCommand(this.id??""):void 0;if(r){j();let o=await(0,E.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&&!It())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 F({type:"command-end",ok:!0}),j(),t.emitsOwnOutput?void 0:(this.jsonEnabled()||dt(i),{data:i})}catch(t){let n=ut(t);Lt({code:n.code,message:n.message,exitCode:n.exitCode}),this.emitError(n),process.exitCode=n.exitCode;return}finally{Ie(!1)}}resolveSessionApiBaseChain(t){let n=ne(),r=t.profile??void 0,i=t["api-base"]??void 0,o=r!==void 0||Pe()!==void 0,a=Rt(n,r,Pe()),l=Nt(n,a),d=R()==="public"&&J()!==void 0,u=i??(d?void 0:J()),h=u??l?.api_base??H,m=vt({resolvedApiBase:h,fromExplicitOverride:u!==void 0,profileApiBase:l?.api_base,profileApiBaseSource:l?.api_base_source});return m&&!e.legacyStagingNoticeShown&&(e.legacyStagingNoticeShown=!0,D({event:"legacy_staging_profile",api_base:h,profile:a},m)),{apiBase:h,explicitApiBase:u,envApiBaseIgnored:d,profileApiBase:l?.api_base,profile:a,profileExplicit:o}}resolveSessionApiBaseForPayoutDerivation(t){let{apiBase:n}=this.resolveSessionApiBaseChain(t);return this.constructor.isLocalOnly||re(n),n}resolveContext(t){if(R()==="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&&J()!==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,envApiBaseIgnored:a,profile:l,profileApiBase:d,profileExplicit:u}=this.resolveSessionApiBaseChain(t);return this.constructor.isLocalOnly||(re(i),$e(i)),{apiBase:i,profile:l,token:n??kt(),insecureStorage:r||Ot(),apiBaseSource:o!==void 0?"explicit":d!==void 0?"profile":"default",profileExplicit:u,envApiBaseIgnored:a}}emitError(t){process.stderr.write(`${pr(t)}
|
|
15
|
+
`)}};var sr=/_(removed|cleared|count|total)$/i;function ar(e,t){return typeof t=="number"&&sr.test(e)}var lr=new Set(Bt);function cr(e,t){return e==="token_symbol"&&typeof t=="string"&&lr.has(t)}var ur=new Set(Ut);function dr(e,t){return e==="otp_reason"&&typeof t=="string"&&ur.has(t)}var ie=100;function oe(e,t=0){if(t>8)return"<truncated>";if(Array.isArray(e)){let n=e.slice(0,ie),r=n.map(i=>oe(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,ie))n[i]=ht(i)&&!ar(i,o)&&!cr(i,o)&&!dr(i,o)?"<redacted>":oe(o,t+1);if(r.length>ie){let i="<truncated>";for(;i in n;)i=`<${i}>`;n[i]=`${r.length-ie} more keys`}return n}if(typeof e=="string"){let n=fr(e);return n!==void 0?y(JSON.stringify(oe(n,t+1))):y(e)}return e}function fr(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 pr(e){let t=bt()?void 0:2,n=oe(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 gr(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))}function hr(e,t={}){let n;try{n=xt(ne())}catch{return}if(!(n.length===0||n.includes(e)))return new c("auth.unknown_profile",ct(e)+(t.messageSuffix??""),{profile:e})}function Ft(e){if(e.profileExplicit){let t=hr(e.profile);if(t)return t}return new c("auth.no_token",lt(e.profile))}function Me(e){let t=e.split(".");if(t.length!==3)throw new c("auth.token_invalid","This token is not a JWT session. Agent API keys are not JWTs \u2014 this path needs a human session token.");let n;try{let r=Buffer.from(t[1].replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8");n=JSON.parse(r)}catch{throw Mt()}if(typeof n!="object"||n===null||Array.isArray(n))throw Mt();return n}function Mt(){return new c("auth.token_invalid","The provided token is not a valid JWT credential \u2014 its payload could not be decoded. Check the --token / ALLSCALE_TOKEN value, or re-authenticate to obtain a fresh session.")}function Gt(e,t=Math.floor(Date.now()/1e3)){return typeof e.exp=="number"&&e.exp<t}var en=A(require("path"));var Ke=require("crypto"),s=A(require("fs")),g=A(require("path"));var se=1024*1024,mr=5e3,yr=20,_r=3e4,Ge=4096,br=new Int32Array(new SharedArrayBuffer(4)),q=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function ae(e){return e instanceof q}var _=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},Ar=null;function I(){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 le(){return(Ar??process.platform)!=="win32"}function qt(){if(!le())throw I()}function Xt(e){try{return s.default.lstatSync(e),!1}catch(t){if(!p(t,"ENOENT"))throw t}try{let t=s.default.lstatSync(g.dirname(e));return!t.isSymbolicLink()&&t.isDirectory()}catch(t){if(p(t,"ENOENT"))return!0;throw t}}function p(e,t){return typeof e=="object"&&e!==null&&e.code===t}function X(e,t){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${t} is not owned by the current effective user`)}function V(e,t){return e.dev===t.dev&&e.ino===t.ino}function Sr(e){Atomics.wait(br,0,0,e)}function Vt(e){try{return process.kill(e,0),!0}catch(t){return!p(t,"ESRCH")}}function wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yt(e,t){let n=g.dirname(e);t&&s.default.mkdirSync(n,{recursive:!0,mode:448});let r;try{r=s.default.lstatSync(n)}catch(o){if(!t&&p(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()||!V(o,a))throw new Error("credential-store parent changed while it was being inspected");X(o,"credential-store parent");let l=o;if((o.mode&63)!==0&&g.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 L(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&&p(o,"ENOENT")?new _:o}if(!V(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 q;if(X(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 Er(e,t){if(t.size>se)throw new Error("credential-store file exceeds the maximum supported size");let n=Buffer.alloc(se+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>se)throw new Error("credential-store file exceeds the maximum supported size");return n.subarray(0,r).toString("utf8")}function Kt(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(p(i,"ENOENT"))try{if(s.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(p(o,"ENOENT"))return null;throw o}throw i}let n=s.default.fstatSync(t),r=L(e,t,n);return Er(t,r)}finally{t!==null&&s.default.closeSync(t)}}function jt(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(p(i,"ENOENT")&&Xt(e))return;throw i}let n=s.default.fstatSync(t),r=L(e,t,n);v(e,r)}finally{t!==null&&s.default.closeSync(t)}Qt(g.dirname(e))}function Lr(e){let t;try{t=s.default.lstatSync(e)}catch(n){if(p(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 q;X(t,"credential-store replacement target")}function kr(e,t){for(let n=0;n<8;n+=1){let r=(0,Ke.randomBytes)(12).toString("hex"),i=g.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(p(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function Zt(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 Qt(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 Or(e,t){let n=Buffer.from(t,"utf8");if(n.length>se)throw new Error("credential-store file exceeds the maximum supported size");let r=g.dirname(e),i=g.basename(e),o=null,a=null,l=!1;try{let d=kr(r,i);o=d.fd,a=d.tempPath;let u=s.default.fstatSync(o);if((L(a,o,u).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");Zt(o,n),s.default.fsyncSync(o),L(a,o,s.default.fstatSync(o));let m=o;o=null,s.default.closeSync(m),Lr(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{}}Qt(r)}function Tr(e){return g.join(g.dirname(e),`.${g.basename(e)}.lock`)}function Ir(e){return g.join(g.dirname(e),`.${g.basename(e)}.lock-recovery`)}function vr(e,t){if(t.size>Ge)return null;let n=Buffer.alloc(Ge+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>Ge)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()||!V(n,t))throw new Error("credential-store lock changed while it was being inspected");X(n,"credential-store lock"),s.default.unlinkSync(e)}function Wt(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(d){if(p(d,"ENOENT"))try{let u=s.default.lstatSync(e);throw u.isSymbolicLink()||!u.isFile()?new Error("credential-store lock must be a real regular file"):new _}catch(u){if(p(u,"ENOENT"))return{state:"absent"};throw u}throw d}let r=s.default.fstatSync(n),i=L(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=vr(n,i);return{state:(o?.target===t&&o?!Vt(o.pid):Date.now()-i.mtimeMs>=_r)?"stale":"active",stats:i}}finally{n!==null&&s.default.closeSync(n)}}function Cr(e,t){for(let n=0;n<8;n+=1){let r=(0,Ke.randomBytes)(12).toString("hex"),i=g.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),d=L(i,a,l,{allowMultipleLinks:!0});return Zt(a,Buffer.from(JSON.stringify(o),"utf8")),s.default.fsyncSync(a),{claimPath:i,metadata:o,stats:d}}catch(l){if(p(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 xr(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 p(r,"ENOENT")?new _:r}try{let r=s.default.fstatSync(n),i=L(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!V(i,t))throw new _;return{fd:n,lockPath:e,stats:i}}catch(r){throw s.default.closeSync(n),r}}function Ht(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(p(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(p(r,"ENOENT"))return!1;throw r}throw n}return L(e,t,s.default.fstatSync(t),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{t!==null&&s.default.closeSync(t)}}function Nr(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(p(r,"EEXIST"))return null;throw r}let n=null;try{n=s.default.fstatSync(t);let r=L(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 T(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");Sr(yr)}function Jt(e){let t=g.dirname(e),n=g.basename(e),r=Tr(e),i=Ir(e),o=Cr(t,n),a=Date.now()+mr,l=!1,d=!1,u=null,h;try{for(;u===null;)try{if(Ht(i)){T(a,!0);continue}s.default.linkSync(o.claimPath,r),d=!0,u=xr(r,o.stats),l=!0}catch(m){if(d&&!l){try{v(r,o.stats)}catch{}d=!1}if(m instanceof _){T(a,!1);continue}if(!p(m,"EEXIST"))throw m;let fe;try{fe=Wt(r,n)}catch(S){if(S instanceof _){T(a,!1);continue}throw S}if(fe.state==="absent")continue;if(fe.state==="stale"){let S;try{S=Nr(i)}catch(N){if(N instanceof _){T(a,!1);continue}throw N}if(S!==null){try{let N;try{N=Wt(r,n)}catch(Ze){if(Ze instanceof _){T(a,!1);continue}throw Ze}N.state==="stale"&&v(r,N.stats)}finally{Ye(S)}continue}}let Ve;try{Ve=Ht(i)}catch(S){if(S instanceof _){T(a,!1);continue}throw S}T(a,Ve)}}catch(m){h=m}try{v(o.claimPath,o.stats)}catch(m){!p(m,"ENOENT")&&!l&&h===void 0&&(h=m)}if(h!==void 0)throw h;if(u===null)throw new Error("credential-store lock acquisition failed");return u}function Ye(e){try{v(e.lockPath,e.stats)}finally{s.default.closeSync(e.fd)}}function Rr(e,t){let n=wr(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 zt(e){let t=g.dirname(e),n=g.basename(e);for(let r of s.default.readdirSync(t)){let i=Rr(r,n);if(i===null||Vt(i))continue;let o=g.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(u){if(p(u,"ENOENT")||p(u,"ELOOP"))continue;throw u}let l=s.default.fstatSync(a),d=s.default.lstatSync(o);if(!l.isFile()||d.isSymbolicLink()||!d.isFile()||!V(l,d))continue;try{X(l,"credential-store orphan")}catch{continue}v(o,l)}catch(l){if(!p(l,"ENOENT"))throw l}finally{a!==null&&s.default.closeSync(a)}}}function Z(e,t,n){if(!le()){if(t.allowUnsupportedPlatformCleanup){if(t.createParent)throw I();if(!Yt(e,!1))return n({read:()=>null,remove:()=>{},write:()=>{throw I()}});let a=Jt(e);try{return zt(e),n({read:()=>Kt(e),remove:()=>jt(e),write:()=>{throw I()}})}finally{Ye(a)}}if(!t.createParent){let o=!1;try{o=Xt(e)}catch{throw I()}if(o)return n({read:()=>null,remove:()=>{},write:()=>{throw I()}})}throw I()}if(!Yt(e,t.createParent))return n({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let i=Jt(e);try{return zt(e),n({read:()=>Kt(e),remove:()=>jt(e),write:o=>Or(e,o)})}finally{Ye(i)}}var je="allscale-cli";function ze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function tn(e){return ze(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function x(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 We(){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 ce(){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 C,He=!1;function Pr(){return Tt()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function Br(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 Dr(){if(C!==void 0)return C;if(Pr())return He=!1,C=null,C;try{C=require("keytar"),He=!1}catch(e){He=!Br(e),C=null}return C}function nn(){let e=le()?"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 Je(e){try{return await e()}catch{throw nn()}}var qe=class{constructor(t){this.keytar=t}keytar;kind="keychain";async read(t){let n=await Je(()=>this.keytar.getPassword(je,t));if(n===null)return null;let r;try{r=JSON.parse(n)}catch{throw x("OS keychain")}if(!tn(r))throw x("OS keychain");return r}async get(t){return this.read(t)}async set(t,n){await this.read(t),await Je(()=>this.keytar.setPassword(je,t,JSON.stringify(n)))}async delete(t){await this.read(t),await Je(()=>this.keytar.deletePassword(je,t))}},Ur="credentials.json",Xe=class{kind="insecure-file";filePath;constructor(t){this.filePath=t??en.join(Ue(),Ur)}read(t){let n;try{n=t.read()}catch(i){throw ae(i)?We():x("plaintext file")}if(n===null)return{profiles:{}};let r;try{r=JSON.parse(n)}catch{throw x("plaintext file")}if(!ze(r)||!ze(r.profiles))throw x("plaintext file");return r}write(t,n){try{t.write(JSON.stringify(n,null,2))}catch(r){throw ae(r)?We():ce()}}profileTokens(t,n){let r=t.profiles[n];if(r!==void 0){if(!tn(r))throw x("plaintext file");return r}}async get(t){try{return Z(this.filePath,{createParent:!1},n=>this.profileTokens(this.read(n),t)??null)}catch(n){throw n instanceof c?n:x("plaintext file")}}async set(t,n){try{Z(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:ce()}}async delete(t){try{Z(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:ce()}}async clearProfile(t){try{return Z(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:ae(n)?We():ce()}}};function rn(e){if(e.insecureStorage)return qt(),new Xe(e.insecureFilePath);let t=Dr();if(t)return new qe(t);throw nn()}function ue(e){if(typeof e!="string")return;let t=e.trim();if(t.length===0||t.length>254||/\s/.test(t))return;let n=t.indexOf("@");if(!(n<=0)&&t.indexOf("@",n+1)===-1&&n!==t.length-1)return t.toLowerCase()}function on(e){if(typeof e!="string")return;let t=e.trim();return t.length===0?void 0:t}function $r(e){let t=[e.email,e.email_lower,e.user_name];for(let n of t){let r=ue(n);if(r!==void 0)return r}}var de=class e extends z{static description="Show the current authenticated identity from the stored credential (agent-key sessions report business_id / scopes / expiry; legacy password sessions decode the cached JWT). No network call. The reported `api_base` is the endpoint this session resolves to \u2014 its saved profile pin, else this build's own environment. A published build ignores ALLSCALE_API_BASE, and says so on stderr rather than echoing it as the session endpoint; an internal build honours the variable, so it is echoed there. Either way, a resolved endpoint that networked commands would refuse \u2014 an untrusted origin, or a real AllScale environment outside this build's signing binding, whether it came from the variable or from the profile's saved pin \u2014 is disclosed on stderr. This command stays usable offline and never fails closed.";static examples=["$ allscale whoami","$ allscale whoami --profile prod"];static isLocalOnly=!0;static flags={...z.baseFlags};async runCommand(){let{flags:t}=await this.parse(e),n=this.resolveContext(t);n.envApiBaseIgnored&&process.stderr.write(`Note: ${w.API_BASE} is set but ignored by this build \u2014 a published build always uses its own AllScale environment. Reporting the endpoint this session resolves to.
|
|
17
|
+
`);let r=Pt(n.apiBase);if(r){let a=n.apiBaseSource==="profile"?`profile '${n.profile}' records an api_base this build cannot use`:n.apiBaseSource==="explicit"?"the api_base given for this run is one this build cannot use":"this build's default api_base is one it cannot use",l=r.kind==="unsigned",d=l?" To reach it, use a build that signs for it \u2014 this one cannot, whatever the profile says."+(n.apiBaseSource==="profile"?" To use this build instead, remove this profile's api_base line from ~/.allscale/config.toml, or pick a --profile pinned to one of the above.":n.apiBaseSource==="explicit"?" To use this build instead, drop the override.":""):n.apiBaseSource==="profile"?` To fix: ${n.envApiBaseIgnored?`unset ${w.API_BASE} (networked commands refuse it, so it blocks the login below too), then `:""}remove this profile's api_base line from ~/.allscale/config.toml, or log in under a different --profile. Until that is done, any \`device-login\` / \`otp-login\` suggested for this profile will be refused the same way.`:n.apiBaseSource==="explicit"?" Drop the override to fall back to this profile's saved pin, or this build's default when it has none.":"",u=l?Fe():void 0,h=u?` This build only signs for${u.fromPairs?":":""} ${u.endpoints.map(m=>k(m)).join(", ")}.`:"";process.stderr.write(`Note: ${a} (${k(n.apiBase)}) \u2014 networked commands will refuse it.${h}${d}
|
|
18
|
+
`)}if(n.token)return sn(n.profile,n.apiBase,n.token,"override");let i=rn({insecureStorage:n.insecureStorage}),o=await i.get(n.profile);if(!o)throw Ft({profile:n.profile,profileExplicit:n.profileExplicit});if(o.agent_key){let a=Math.floor(Date.now()/1e3),l=o.agent_key_expires_at;return o.business_id||process.stderr.write(`No business id stored for profile '${n.profile}' \u2014 this agent-key session predates the backend returning it. Re-run \`allscale device-login --profile ${Y(n.profile)}\` (or \`${be(n.profile)}\`) to store it (and to auto-fill --business-id on invoice/store/etc.).
|
|
19
|
+
`),{profile:n.profile,api_base:Re(n.apiBase),credential:"agent_key",business_id:o.business_id,user_email:ue(o.user_email),user_type:o.user_type,scopes:o.scopes??[],expires_at:typeof l=="number"?new Date(l*1e3).toISOString():void 0,expired:typeof l=="number"?l<a:!1,storage:i.kind}}return sn(n.profile,n.apiBase,o.access_token,i.kind,o.user_email)}};function sn(e,t,n,r,i){let o=Me(n);return{profile:e,api_base:Re(t),credential:"cookie",user_id:on(o.user_id),user_email:ue(i)??$r(o),expires_at:typeof o.exp=="number"?new Date(o.exp*1e3).toISOString():void 0,expired:Gt(o),storage:r}}
|
|
18
20
|
//# sourceMappingURL=whoami.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var i in e)u(n,i,{get:e[i],enumerable:!0})},b=(n,e,i,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of h(e))!I.call(n,r)&&r!==i&&u(n,r,{get:()=>e[r],enumerable:!(t=E(e,r))||t.enumerable});return n};var m=n=>b(u({},"__esModule",{value:!0}),n);var T={};S(T,{default:()=>B});module.exports=m(T);var p="public",_="https://app.allscale.io";function a(){return"".trim()||void 0}function g(){return"public"}function L(){{let n="[]".trim();if(n.length===0)return[];try{let e=JSON.parse(n);return Array.isArray(e)?e:[]}catch{return[]}}return c()}function c(){let n=process.env.ALLSCALE_BUILD_PAIRS?.trim()??"";if(n.length>0)try{let t=JSON.parse(n);if(!Array.isArray(t))return[];let r=[];for(let o of t){if(typeof o!="object"||o===null)continue;let{base:s,key:l,keyId:A}=o;if(typeof s!="string"||s.trim().length===0||typeof l!="string"||l.trim().length===0)continue;let d=typeof A=="string"?A.trim():"";r.push({base:s.trim(),key:l,keyId:d.length>0?d:"cli-1"})}return r}catch{return[]}let e=process.env.ALLSCALE_SIGNING_KEY??"",i=process.env.ALLSCALE_BUILD_API_BASE?.trim()??"";if(e.trim().length>0&&i.length>0){let t=process.env.ALLSCALE_SIGNING_KEY_ID?.trim();return[{base:i,key:e,keyId:t&&t.length>0?t:"cli-1"}]}return[]}var X=a()??_;function f(n){try{let e=new URL(n);return`${e.protocol}//${e.host}`}catch{return"<unparseable URL>"}}var y=async function(n){try{let e=n.config.pjson.oclif?.additionalVersionFlags;if(!new Set(["--version",...Array.isArray(e)?e.filter(s=>typeof s=="string"):[]]).has(n.id))return;let t=a();if(t===void 0)return;let r=L().length,o=r>1?` (bound, ${r} endpoints)`:" (bound)";this.log(`build: ${g()} \xB7 api-base ${f(t)}${o}`)}catch{}},B=y;
|
|
2
2
|
//# sourceMappingURL=version-suffix.js.map
|