@allscale/cli 1.0.1 → 1.0.3
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 +92 -12
- package/dist/commands/build-info.js +12 -12
- package/dist/commands/claim-link/claim.js +10 -10
- package/dist/commands/claim-link/create.js +31 -31
- 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 +28 -27
- 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 +29 -29
- 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 +17 -17
- package/dist/commands/otp-send.js +11 -11
- package/dist/commands/payout/send.js +14 -14
- package/dist/commands/payout/status.js +12 -12
- package/dist/commands/scope.js +16 -16
- package/dist/commands/store/create.js +16 -16
- 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 +27 -27
- package/dist/commands/whoami.js +14 -12
- package/dist/hooks/version-suffix.js +1 -1
- package/dist/index.js +11 -11
- package/dist/lib/help.js +10 -7
- package/oclif.manifest.json +24 -11
- package/package.json +1 -1
package/dist/commands/scope.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).some(t=>
|
|
3
|
-
`)}var p=
|
|
4
|
-
`)}else
|
|
5
|
-
`);return}
|
|
6
|
-
`);return}p.appendFileSync(
|
|
7
|
-
`)}catch(r){if(U=!1,
|
|
8
|
-
`)}catch{}}}function _t(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function
|
|
9
|
-
The CLI default is now ${
|
|
1
|
+
"use strict";var Vt=Object.create;var Q=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var en=Object.getPrototypeOf,tn=Object.prototype.hasOwnProperty;var nn=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},Je=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Qt(t))!tn.call(e,i)&&i!==n&&Q(e,i,{get:()=>t[i],enumerable:!(r=Zt(t,i))||r.enumerable});return e};var b=(e,t,n)=>(n=e!=null?Vt(en(e)):{},Je(t||!e||!e.__esModule?Q(n,"default",{value:e,enumerable:!0}):n,e)),rn=e=>Je(Q({},"__esModule",{value:!0}),e);var xr={};nn(xr,{default:()=>de});module.exports=rn(xr);var E=require("@oclif/core");var Xe="public",Ve="https://app.allscale.io";var Ze=["https://app.allscale.io"];var fe="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 Qe(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 et(e){return Qe(e)!==null}function he(e){let t=Qe(e);return t!==null&&Ze.includes(t.origin)}function Y(){return"".trim()||void 0}function x(){return"public"}function tt(e){try{let{hostname:t}=new URL(e);return t==="127.0.0.1"||t==="localhost"||t==="[::1]"}catch{return!1}}function nt(){{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: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 on="device-login",sn=/^[A-Za-z0-9._-]{1,64}$/;function N(e){return sn.test(e)?e:"<profile>"}function ee(e){return"allscale otp-login --profile "+(e===void 0?"<profile>":N(e))+" --email <you@example.com> --scopes <scope> --otp-stdin"}function it(e){let t=N(e);return`No tokens stored for profile '${e}'. Run \`allscale device-login --profile ${t}\` (recommended), or use \`${ee(e)}\` for headless automation.`}function ot(e){return`Unknown profile '${e}' \u2014 no such profile is saved on this machine. Check the spelling first; to deliberately create '${e}', run \`allscale ${on} --profile ${N(e)}\`.`}var an={"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};var ln=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 Se(e){return(typeof e=="string"?e:String(e??"")).replace(ln,"")}var cn=64;function ye(e,t=new Map,n=0){if(typeof e=="string")return Se(e);if(e===null||typeof e!="object")return e;let r=t.get(e);if(r!==void 0)return r;if(n>=cn)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(Se(n)),this.code=t,this.details=r&&ye(r),this.name="AllscaleError"}get exitCode(){return an[this.code]}toJSON(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}};function st(e){if(e instanceof c)return e;if(e instanceof Error){if(pn(e)){let t=gn(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 un=new Set(["CLIError","CLIParseError","RequiredArgsError","RequiredFlagError","UnexpectedArgsError","FlagInvalidOptionError","ArgInvalidOptionError","InvalidArgsSpecError"]),dn=[/^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 pn(e){if(fn(e))return!0;let t=e.name??"";return un.has(t)?t==="CLIError"?_e(e,"parse")||rt(e.message):!0:rt(e.message)}function fn(e){if(!_e(e,"oclif"))return!1;let t=e.oclif;return typeof t=="object"&&t!==null&&t.exit===2&&_e(e,"parse")}function rt(e){return e?Se(e).split(`
|
|
2
|
+
`).some(t=>dn.some(n=>n.test(t.trim()))):!1}function _e(e,t){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,t)}function gn(e){let t=e,n={};for(let r of["code","exitCode","suggestions","ref"])t[r]!==void 0&&(n[r]=t[r]);return n}function at(e){process.stdout.write(`${JSON.stringify({data:e},null,2)}
|
|
3
|
+
`)}var p=b(require("fs")),ne=b(require("path")),yt=b(require("crypto"));var hn="...<truncated>",mn=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+/g,yn=/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,Le=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,be=String.raw`(?:proxy[_-]?)?authorization`,_n=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${be}"|'${be}'|${be})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${Le}`,"gi"),Sn=/\b(https?:\/\/)[^\s/?#]+@/gi,bn=String.raw`(?:[A-Za-z0-9]+[_-])*`,An=String.raw`(?:[A-Za-z0-9]{1,32}[_-]){0,8}`,ct=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)`,lt=ct(bn),En=ct(An),wn=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${lt}"|'${lt}'|${En})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${Le}`,"gi"),Ae=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)`,Ln=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Ae}"|'${Ae}'|${Ae})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${Le}`,"g");function ut(e){return e.replace(Sn,"$1<redacted>@").replace(mn,"<redacted-jwt>").replace(_n,"$1$2$3<redacted>").replace(wn,"$1$2<redacted>").replace(Ln,"$1$2<redacted>").replace(yn,"Bearer <redacted>")}var kn=/(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 dt(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return kn.test(t)}function pt(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 ft(e,t,n=hn){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 h=Buffer.byteLength(d,"utf8");if(u+h>t)break;l+=d,u+=h}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 ft(pt(ut(e)),t)}var Ee=100,On=8,Tn=8*1024;function te(){return{remaining:Tn}}function we(e,t){let n=Math.min(16384,t.remaining),r=ft(e,n);return t.remaining-=Buffer.byteLength(r,"utf8"),r}function R(e,t,n=0,r={}){if(n>On)return we("<truncated>",t);if(typeof e=="string"){let i=ut(e);return we(r.escapeControls?pt(i):i,t)}if(Array.isArray(e)){let i=e.slice(0,Ee),o=i.map(a=>R(a,t,n+1,r));return e.length>i.length&&o.push(we(`<${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]=R(l,t,n+1,r);return o.length>Ee&&(i.output_truncated=!0),i}return e}var ke=require("process");var Oe=!1;function Te(e){Oe=e}function ht(){return Oe}var gt="1";function B(e,t){if(Oe){let n={...e};delete n.version;let r=te(),i={event:n.event,...n},o=R(i,r,0,{escapeControls:!0}),a=JSON.stringify({version:gt,...o});Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:gt,event:o.event,output_truncated:!0})),ke.stderr.write(`${a}
|
|
4
|
+
`)}else ke.stderr.write(t)}var mt="2",D=null,S=null,U=!1,K=!1;function In(){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=yt.randomBytes(4).toString("hex");return ne.join(t,`allscale-output-${n}-${r}.ndjson`)}return null}var Ie=64*1024*1024,vn=null;function ve(e={}){if(e.quiet&&(K=!0),U)return;let t=In();if(!t)return;D=null;let n=null;try{if((vn??process.platform)==="win32")throw new Error("owner-only sidecar ACLs cannot be enforced on Windows; sidecar output is disabled");let r=ne.dirname(t);if(p.mkdirSync(r,{recursive:!0,mode:448}),!process.env.ALLSCALE_OUTPUT_FILE_PATH&&process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY){let u=p.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=p.constants.O_NOFOLLOW??0;n=p.openSync(t,p.constants.O_APPEND|p.constants.O_CREAT|p.constants.O_WRONLY|(p.constants.O_NONBLOCK??0)|i,384);let o=p.fstatSync(n),a=p.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`);p.fchmodSync(n,384)}catch(r){if(n!==null)try{p.closeSync(n)}catch{}K||B({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}D=t,S=n,U=!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 xn(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return Cn.some(n=>n.test(t))}function Nn(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=Rn(t.pathname);let i=n;t.pathname!==r&&(i=!0);for(let[o]of t.searchParams)xn(o)&&(t.searchParams.set(o,"<redacted>"),i=!0);return i?t.toString():e}catch{return e}}function Rn(e){return e.replace(/(\/(?:api\/)?(?:v1\/)?public\/claim-links\/)([^/:]+)(:claim)?(?=\/?$)/,"$1<redacted>$3").replace(/(\/(?:api\/)?public\/claim-links\/)([^/]+)(\/claim)(?=\/?$)/,"$1<redacted>$3")}function Pn(e){return(e.type==="request"||e.type==="bridge_browser_open")&&typeof e.url=="string"?{...e,url:Nn(e.url)}:e}function Bn(e){let t=new Date().toISOString(),n=e,{type:r,...i}=n,o=R(i,te()),a=JSON.stringify({version:mt,timestamp:t,type:r,...o});return Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:mt,timestamp:t,type:r,output_truncated:!0})),a}function $(e){if(!U||!D||S===null)return;let t=Pn(e),n=Bn(t);try{if(p.fstatSync(S).size+Buffer.byteLength(n,"utf8")+1>Ie){U=!1;try{p.closeSync(S)}catch{}S=null,K||B({event:"sidecar_disabled",reason:"size_limit",...D===null?{}:{path:y(D)},max_bytes:Ie},`${y(`[allscale] sidecar exceeded ${Ie} bytes; disabling it for the rest of this run. Rotate or remove ${D}, or point ALLSCALE_OUTPUT_FILE_DIRECTORY at a directory so each run gets its own file.`)}
|
|
6
|
+
`);return}p.appendFileSync(S,`${n}
|
|
7
|
+
`)}catch(r){if(U=!1,S!==null){try{p.closeSync(S)}catch{}S=null}try{K||B({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 _t(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function j(){if(K=!1,U=!1,S!==null){try{p.closeSync(S)}catch{}S=null}}function St(e=!1){let t=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||_t()||!t}var H=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"]),Dn=new Set(Array.from(H).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2)),Un=Array.from(H).filter(e=>e.startsWith("--")).sort((e,t)=>t.length-e.length),$n=new Set(["--otp-stdin","--password-stdin"]);function Ce(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(H.has(a)){t.push(`${a}=<redacted>`);continue}}}if(H.has(r)){t.push(r),n+1<e.length&&(H.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(Dn.has(o)){t.push(`${o}<redacted>`);continue}}let i=$n.has(r)?void 0:Un.find(o=>r.length>o.length&&r.startsWith(o));if(i){t.push(`${i}<redacted>`);continue}t.push(r)}return t}function bt(e){$({type:"error",code:e.code,message:y(e.message)}),$({type:"command-end",ok:!1,exitCode:e.exitCode}),j()}var W=Y()??Ve,M={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 xe(e){return et(e)?new URL(e).origin:null}function q(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return"<unparseable URL>"}}function re(){let e=process.env[M.TOKEN]?.trim();return e&&e.length>0?e:void 0}function Ne(){let e=process.env[M.PROFILE]?.trim();return e&&e.length>0?e:void 0}function z(){let e=process.env[M.API_BASE]?.trim();return e&&e.length>0?e:void 0}function At(){let e=process.env[M.INSECURE_STORAGE]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Et(){let e=process.env[M.NO_KEYCHAIN]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function wt(){let e=process.env[M.ALLOW_RAW]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function Lt(e){let{resolvedApiBase:t,fromExplicitOverride:n,profileApiBase:r,profileApiBaseSource:i}=e;if(Y()===void 0&&W!==""&&"".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 ${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
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 ${
|
|
14
|
-
`}var L=
|
|
15
|
-
`)}};var Kn=/_(removed|cleared|count|total)$/i;function jn(e,t){return typeof t=="number"&&Kn.test(e)}var Hn=new Set(vt);function Wn(e,t){return e==="token_symbol"&&typeof t=="string"&&Hn.has(t)}var se=100;function ae(e,t=0){if(t>8)return"<truncated>";if(Array.isArray(e)){let n=e.slice(0,se),r=n.map(i=>ae(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,se))n[i]=dt(i)&&!jn(i,o)&&!Wn(i,o)?"<redacted>":ae(o,t+1);if(r.length>se){let i="<truncated>";for(;i in n;)i=`<${i}>`;n[i]=`${r.length-se} more keys`}return n}if(typeof e=="string"){let n=zn(e);return n!==void 0?h(JSON.stringify(ae(n,t+1))):h(e)}return e}function zn(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 qn(e){let t=ht()?void 0:2,n=ae(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 Jn(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 Xn(e,t={}){let n;try{n=Tt(oe())}catch{return}if(!(n.length===0||n.includes(e)))return new c("auth.unknown_profile",ot(e)+(t.messageSuffix??""),{profile:e})}function Rt(e){if(e.profileExplicit){let t=Xn(e.profile);if(t)return t}return new c("auth.no_token",it(e.profile))}var Ht=A(require("path"));var Fe=require("crypto"),s=A(require("fs")),g=A(require("path"));var le=1024*1024,Zn=5e3,Vn=20,Qn=3e4,De=4096,er=new Int32Array(new SharedArrayBuffer(4)),q=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function ce(e){return e instanceof q}var y=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},tr=null;function T(){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 ue(){return(tr??process.platform)!=="win32"}function Mt(){if(!ue())throw T()}function Gt(e){try{return s.default.lstatSync(e),!1}catch(t){if(!f(t,"ENOENT"))throw t}try{let t=s.default.lstatSync(g.dirname(e));return!t.isSymbolicLink()&&t.isDirectory()}catch(t){if(f(t,"ENOENT"))return!0;throw t}}function f(e,t){return typeof e=="object"&&e!==null&&e.code===t}function J(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 nr(e){Atomics.wait(er,0,0,e)}function Yt(e){try{return process.kill(e,0),!0}catch(t){return!f(t,"ESRCH")}}function rr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nt(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&&f(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");J(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&&f(o,"ENOENT")?new y:o}if(!X(n,i))throw r.retryOnPathChange?new y: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(J(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 ir(e,t){if(t.size>le)throw new Error("credential-store file exceeds the maximum supported size");let n=Buffer.alloc(le+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>le)throw new Error("credential-store file exceeds the maximum supported size");return n.subarray(0,r).toString("utf8")}function xt(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(f(i,"ENOENT"))try{if(s.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(f(o,"ENOENT"))return null;throw o}throw i}let n=s.default.fstatSync(t),r=b(e,t,n);return ir(t,r)}finally{t!==null&&s.default.closeSync(t)}}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(i){if(f(i,"ENOENT")&&Gt(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)}jt(g.dirname(e))}function or(e){let t;try{t=s.default.lstatSync(e)}catch(n){if(f(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;J(t,"credential-store replacement target")}function sr(e,t){for(let n=0;n<8;n+=1){let r=(0,Fe.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(f(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function Kt(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 jt(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 ar(e,t){let n=Buffer.from(t,"utf8");if(n.length>le)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=sr(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");Kt(o,n),s.default.fsyncSync(o),b(a,o,s.default.fstatSync(o));let S=o;o=null,s.default.closeSync(S),or(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{}}jt(r)}function lr(e){return g.join(g.dirname(e),`.${g.basename(e)}.lock`)}function cr(e){return g.join(g.dirname(e),`.${g.basename(e)}.lock-recovery`)}function ur(e,t){if(t.size>De)return null;let n=Buffer.alloc(De+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>De)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");J(n,"credential-store lock"),s.default.unlinkSync(e)}function Ut(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(f(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 y}catch(d){if(f(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=ur(n,i);return{state:(o?.target===t&&o?!Yt(o.pid):Date.now()-i.mtimeMs>=Qn)?"stale":"active",stats:i}}finally{n!==null&&s.default.closeSync(n)}}function dr(e,t){for(let n=0;n<8;n+=1){let r=(0,Fe.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 Kt(a,Buffer.from(JSON.stringify(o),"utf8")),s.default.fsyncSync(a),{claimPath:i,metadata:o,stats:u}}catch(l){if(f(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 pr(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 f(r,"ENOENT")?new y:r}try{let r=s.default.fstatSync(n),i=b(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!X(i,t))throw new y;return{fd:n,lockPath:e,stats:i}}catch(r){throw s.default.closeSync(n),r}}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(n){if(f(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 y}catch(r){if(f(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 fr(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(f(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 k(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");nr(Vn)}function $t(e){let t=g.dirname(e),n=g.basename(e),r=lr(e),i=cr(e),o=dr(t,n),a=Date.now()+Zn,l=!1,u=!1,d=null,m;try{for(;d===null;)try{if(Dt(i)){k(a,!0);continue}s.default.linkSync(o.claimPath,r),u=!0,d=pr(r,o.stats),l=!0}catch(S){if(u&&!l){try{O(r,o.stats)}catch{}u=!1}if(S instanceof y){k(a,!1);continue}if(!f(S,"EEXIST"))throw S;let fe;try{fe=Ut(r,n)}catch(E){if(E instanceof y){k(a,!1);continue}throw E}if(fe.state==="absent")continue;if(fe.state==="stale"){let E;try{E=fr(i)}catch(v){if(v instanceof y){k(a,!1);continue}throw v}if(E!==null){try{let v;try{v=Ut(r,n)}catch(qe){if(qe instanceof y){k(a,!1);continue}throw qe}v.state==="stale"&&O(r,v.stats)}finally{$e(E)}continue}}let ze;try{ze=Dt(i)}catch(E){if(E instanceof y){k(a,!1);continue}throw E}k(a,ze)}}catch(S){m=S}try{O(o.claimPath,o.stats)}catch(S){!f(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 $e(e){try{O(e.lockPath,e.stats)}finally{s.default.closeSync(e.fd)}}function gr(e,t){let n=rr(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 Ft(e){let t=g.dirname(e),n=g.basename(e);for(let r of s.default.readdirSync(t)){let i=gr(r,n);if(i===null||Yt(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(f(d,"ENOENT")||f(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{J(l,"credential-store orphan")}catch{continue}O(o,l)}catch(l){if(!f(l,"ENOENT"))throw l}finally{a!==null&&s.default.closeSync(a)}}}function Z(e,t,n){if(!ue()){if(t.allowUnsupportedPlatformCleanup){if(t.createParent)throw T();if(!Nt(e,!1))return n({read:()=>null,remove:()=>{},write:()=>{throw T()}});let a=$t(e);try{return Ft(e),n({read:()=>xt(e),remove:()=>Bt(e),write:()=>{throw T()}})}finally{$e(a)}}if(!t.createParent){let o=!1;try{o=Gt(e)}catch{throw T()}if(o)return n({read:()=>null,remove:()=>{},write:()=>{throw T()}})}throw T()}if(!Nt(e,t.createParent))return n({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let i=$t(e);try{return Ft(e),n({read:()=>xt(e),remove:()=>Bt(e),write:o=>ar(e,o)})}finally{$e(i)}}var Me="allscale-cli";function je(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wt(e){return je(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 Ge(){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 de(){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,Ye=!1;function hr(){return wt()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function mr(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
|
-
`);let i=await
|
|
13
|
+
To move to production, run: allscale device-login --api-base ${W}
|
|
14
|
+
`}var L=b(require("fs")),kt=b(require("os")),Re=b(require("path")),Pe=b(require("@iarna/toml"));var Gn=".allscale",Yn="config.toml";function Be(){return Re.join(kt.homedir(),Gn)}function Kn(){return Re.join(Be(),Yn)}function ie(){let e=Kn();if(!L.existsSync(e))return{};let t=L.readFileSync(e,"utf-8");try{return Pe.parse(t)}catch(n){throw new c("internal",`Failed to parse ${e}: ${n.message}`)}}function Ot(e){return Object.keys(e.profile??{}).sort()}function Tt(e,t){return e.profile?.[t]}function It(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 De(e){if(!he(e))throw new c("input.invalid",`Refusing to send credentials to API base ${q(e)}. `+ge)}function vt(e){let t=Hn(e);if(t)throw new c("input.invalid",t.message)}function jn(){let e=Y();if(e===void 0)return;let t=nt();return t.length>0?{endpoints:t.map(n=>n.base),fromPairs:!0}:{endpoints:[e],fromPairs:!1}}function Hn(e){let t=jn();if(t===void 0||tt(e))return;let{endpoints:n,fromPairs:r}=t,i=xe(e),o=n.map(l=>xe(l)).filter(l=>l!==null);if(i!==null&&o.includes(i))return;let a=n.map(l=>q(l)).join(", ");return{message:r?`Refusing to send to ${q(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 ${q(e)} \u2014 this build only signs for ${a}. Re-login against this build's environment, or use a build for that one.`}}var Wn=require("@noble/hashes/sha3");var Ct=["USDT","USDC"];var _i=new Set([`0x${"0".repeat(40)}`,`0x${"0".repeat(36)}dead`]);var qn="unknown_otp_id",zn="invalid_code",Jn="expired_code";function Xn(e){return`'${e.replace(/'/g,"'\\''")}'`}function xt(e){return`Run \`allscale otp-send --email ${Xn(e)}\` first \u2014 that command does report a missing account \u2014 then retry with the otp_id it returns and a fresh code.`}var Vn=new Map([[qn,(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. ${xt(t)}`],[zn,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.`],[Jn,(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. ${xt(t)}`]]);var Nt=[...Vn.keys()];var Rt=require("@oclif/core"),G=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:x()==="public"}),"api-base":E.Flags.string({description:fe,helpGroup:"GLOBAL",hidden:x()==="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{Te(this.jsonEnabled()),ve(),$({type:"session-start",command:this.id??"",argv:Ce(this.argv)});let t=this.constructor;if(x()==="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&&z()!==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=St(this.jsonEnabled()),r=this.argv.length===0&&!n&&sr(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&&!wt())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 $({type:"command-end",ok:!0}),j(),t.emitsOwnOutput?void 0:(this.jsonEnabled()||at(i),{data:i})}catch(t){let n=st(t);bt({code:n.code,message:n.message,exitCode:n.exitCode}),this.emitError(n),process.exitCode=n.exitCode;return}finally{Te(!1)}}resolveSessionApiBaseChain(t){let n=ie(),r=t.profile??void 0,i=t["api-base"]??void 0,o=r!==void 0||Ne()!==void 0,a=It(n,r,Ne()),l=Tt(n,a),u=x()==="public"&&z()!==void 0,d=i??(u?void 0:z()),h=d??l?.api_base??W,m=Lt({resolvedApiBase:h,fromExplicitOverride:d!==void 0,profileApiBase:l?.api_base,profileApiBaseSource:l?.api_base_source});return m&&!e.legacyStagingNoticeShown&&(e.legacyStagingNoticeShown=!0,B({event:"legacy_staging_profile",api_base:h,profile:a},m)),{apiBase:h,explicitApiBase:d,envApiBaseIgnored:u,profileApiBase:l?.api_base,profile:a,profileExplicit:o}}resolveSessionApiBaseForPayoutDerivation(t){let{apiBase:n}=this.resolveSessionApiBaseChain(t);return this.constructor.isLocalOnly||De(n),n}resolveContext(t){if(x()==="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&&z()!==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:u,profileExplicit:d}=this.resolveSessionApiBaseChain(t);return this.constructor.isLocalOnly||(De(i),vt(i)),{apiBase:i,profile:l,token:n??re(),insecureStorage:r||At(),apiBaseSource:o!==void 0?"explicit":u!==void 0?"profile":"default",profileExplicit:d,envApiBaseIgnored:a}}emitError(t){process.stderr.write(`${or(t)}
|
|
15
|
+
`)}};var Zn=/_(removed|cleared|count|total)$/i;function Qn(e,t){return typeof t=="number"&&Zn.test(e)}var er=new Set(Ct);function tr(e,t){return e==="token_symbol"&&typeof t=="string"&&er.has(t)}var nr=new Set(Nt);function rr(e,t){return e==="otp_reason"&&typeof t=="string"&&nr.has(t)}var oe=100;function se(e,t=0){if(t>8)return"<truncated>";if(Array.isArray(e)){let n=e.slice(0,oe),r=n.map(i=>se(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,oe))n[i]=dt(i)&&!Qn(i,o)&&!tr(i,o)&&!rr(i,o)?"<redacted>":se(o,t+1);if(r.length>oe){let i="<truncated>";for(;i in n;)i=`<${i}>`;n[i]=`${r.length-oe} more keys`}return n}if(typeof e=="string"){let n=ir(e);return n!==void 0?y(JSON.stringify(se(n,t+1))):y(e)}return e}function ir(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 or(e){let t=ht()?void 0:2,n=se(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 sr(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 ar(e,t={}){let n;try{n=Ot(ie())}catch{return}if(!(n.length===0||n.includes(e)))return new c("auth.unknown_profile",ot(e)+(t.messageSuffix??""),{profile:e})}function Pt(e){if(e.profileExplicit){let t=ar(e.profile);if(t)return t}return new c("auth.no_token",it(e.profile))}var qt=b(require("path"));var Fe=require("crypto"),s=b(require("fs")),g=b(require("path"));var ae=1024*1024,lr=5e3,cr=20,ur=3e4,Ue=4096,dr=new Int32Array(new SharedArrayBuffer(4)),J=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function le(e){return e instanceof J}var _=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},pr=null;function O(){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 ce(){return(pr??process.platform)!=="win32"}function Yt(){if(!ce())throw O()}function Kt(e){try{return s.default.lstatSync(e),!1}catch(t){if(!f(t,"ENOENT"))throw t}try{let t=s.default.lstatSync(g.dirname(e));return!t.isSymbolicLink()&&t.isDirectory()}catch(t){if(f(t,"ENOENT"))return!0;throw t}}function f(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 fr(e){Atomics.wait(dr,0,0,e)}function jt(e){try{return process.kill(e,0),!0}catch(t){return!f(t,"ESRCH")}}function gr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bt(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&&f(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 w(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&&f(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 J;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 hr(e,t){if(t.size>ae)throw new Error("credential-store file exceeds the maximum supported size");let n=Buffer.alloc(ae+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>ae)throw new Error("credential-store file exceeds the maximum supported size");return n.subarray(0,r).toString("utf8")}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(f(i,"ENOENT"))try{if(s.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(f(o,"ENOENT"))return null;throw o}throw i}let n=s.default.fstatSync(t),r=w(e,t,n);return hr(t,r)}finally{t!==null&&s.default.closeSync(t)}}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(f(i,"ENOENT")&&Kt(e))return;throw i}let n=s.default.fstatSync(t),r=w(e,t,n);T(e,r)}finally{t!==null&&s.default.closeSync(t)}Wt(g.dirname(e))}function mr(e){let t;try{t=s.default.lstatSync(e)}catch(n){if(f(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 J;X(t,"credential-store replacement target")}function yr(e,t){for(let n=0;n<8;n+=1){let r=(0,Fe.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(f(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function Ht(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 Wt(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>ae)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=yr(r,i);o=u.fd,a=u.tempPath;let d=s.default.fstatSync(o);if((w(a,o,d).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");Ht(o,n),s.default.fsyncSync(o),w(a,o,s.default.fstatSync(o));let m=o;o=null,s.default.closeSync(m),mr(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{}}Wt(r)}function Sr(e){return g.join(g.dirname(e),`.${g.basename(e)}.lock`)}function br(e){return g.join(g.dirname(e),`.${g.basename(e)}.lock-recovery`)}function Ar(e,t){if(t.size>Ue)return null;let n=Buffer.alloc(Ue+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>Ue)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 T(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 $t(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(f(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(f(d,"ENOENT"))return{state:"absent"};throw d}throw u}let r=s.default.fstatSync(n),i=w(e,n,r,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=Ar(n,i);return{state:(o?.target===t&&o?!jt(o.pid):Date.now()-i.mtimeMs>=ur)?"stale":"active",stats:i}}finally{n!==null&&s.default.closeSync(n)}}function Er(e,t){for(let n=0;n<8;n+=1){let r=(0,Fe.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=w(i,a,l,{allowMultipleLinks:!0});return Ht(a,Buffer.from(JSON.stringify(o),"utf8")),s.default.fsyncSync(a),{claimPath:i,metadata:o,stats:u}}catch(l){if(f(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 wr(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 f(r,"ENOENT")?new _:r}try{let r=s.default.fstatSync(n),i=w(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 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(n){if(f(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(f(r,"ENOENT"))return!1;throw r}throw n}return w(e,t,s.default.fstatSync(t),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{t!==null&&s.default.closeSync(t)}}function Lr(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(f(r,"EEXIST"))return null;throw r}let n=null;try{n=s.default.fstatSync(t);let r=w(e,t,n,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:t,lockPath:e,stats:r}}catch(r){if(n!==null)try{T(e,n)}catch{}throw s.default.closeSync(t),r}}function k(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");fr(cr)}function Mt(e){let t=g.dirname(e),n=g.basename(e),r=Sr(e),i=br(e),o=Er(t,n),a=Date.now()+lr,l=!1,u=!1,d=null,h;try{for(;d===null;)try{if(Ft(i)){k(a,!0);continue}s.default.linkSync(o.claimPath,r),u=!0,d=wr(r,o.stats),l=!0}catch(m){if(u&&!l){try{T(r,o.stats)}catch{}u=!1}if(m instanceof _){k(a,!1);continue}if(!f(m,"EEXIST"))throw m;let pe;try{pe=$t(r,n)}catch(A){if(A instanceof _){k(a,!1);continue}throw A}if(pe.state==="absent")continue;if(pe.state==="stale"){let A;try{A=Lr(i)}catch(C){if(C instanceof _){k(a,!1);continue}throw C}if(A!==null){try{let C;try{C=$t(r,n)}catch(ze){if(ze instanceof _){k(a,!1);continue}throw ze}C.state==="stale"&&T(r,C.stats)}finally{$e(A)}continue}}let qe;try{qe=Ft(i)}catch(A){if(A instanceof _){k(a,!1);continue}throw A}k(a,qe)}}catch(m){h=m}try{T(o.claimPath,o.stats)}catch(m){!f(m,"ENOENT")&&!l&&h===void 0&&(h=m)}if(h!==void 0)throw h;if(d===null)throw new Error("credential-store lock acquisition failed");return d}function $e(e){try{T(e.lockPath,e.stats)}finally{s.default.closeSync(e.fd)}}function kr(e,t){let n=gr(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=g.dirname(e),n=g.basename(e);for(let r of s.default.readdirSync(t)){let i=kr(r,n);if(i===null||jt(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(f(d,"ENOENT")||f(d,"ELOOP"))continue;throw d}let l=s.default.fstatSync(a),u=s.default.lstatSync(o);if(!l.isFile()||u.isSymbolicLink()||!u.isFile()||!V(l,u))continue;try{X(l,"credential-store orphan")}catch{continue}T(o,l)}catch(l){if(!f(l,"ENOENT"))throw l}finally{a!==null&&s.default.closeSync(a)}}}function Z(e,t,n){if(!ce()){if(t.allowUnsupportedPlatformCleanup){if(t.createParent)throw O();if(!Bt(e,!1))return n({read:()=>null,remove:()=>{},write:()=>{throw O()}});let a=Mt(e);try{return Gt(e),n({read:()=>Dt(e),remove:()=>Ut(e),write:()=>{throw O()}})}finally{$e(a)}}if(!t.createParent){let o=!1;try{o=Kt(e)}catch{throw O()}if(o)return n({read:()=>null,remove:()=>{},write:()=>{throw O()}})}throw O()}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:()=>Dt(e),remove:()=>Ut(e),write:o=>_r(e,o)})}finally{$e(i)}}var Me="allscale-cli";function je(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zt(e){return je(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 Ge(){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 ue(){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,Ye=!1;function Or(){return Et()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function Tr(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 Ir(){if(I!==void 0)return I;if(Or())return Ye=!1,I=null,I;try{I=require("keytar"),Ye=!1}catch(e){Ye=!Tr(e),I=null}return I}var vr="OS keychain could not be accessed on this system (keytar / libsecret may be unavailable, locked, or unusable).";function Jt(){let e=ce()?"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",`${vr} `+e+" Never silently downgrade in production.")}async function Ke(e){try{return await e()}catch{throw Jt()}}var He=class{constructor(t){this.keytar=t}keytar;kind="keychain";async read(t){let n=await Ke(()=>this.keytar.getPassword(Me,t));if(n===null)return null;let r;try{r=JSON.parse(n)}catch{throw v("OS keychain")}if(!zt(r))throw v("OS keychain");return r}async get(t){return this.read(t)}async set(t,n){await this.read(t),await Ke(()=>this.keytar.setPassword(Me,t,JSON.stringify(n)))}async delete(t){await this.read(t),await Ke(()=>this.keytar.deletePassword(Me,t))}},Cr="credentials.json",We=class{kind="insecure-file";filePath;constructor(t){this.filePath=t??qt.join(Be(),Cr)}read(t){let n;try{n=t.read()}catch(i){throw le(i)?Ge():v("plaintext file")}if(n===null)return{profiles:{}};let r;try{r=JSON.parse(n)}catch{throw v("plaintext file")}if(!je(r)||!je(r.profiles))throw v("plaintext file");return r}write(t,n){try{t.write(JSON.stringify(n,null,2))}catch(r){throw le(r)?Ge():ue()}}profileTokens(t,n){let r=t.profiles[n];if(r!==void 0){if(!zt(r))throw v("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:v("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:ue()}}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:ue()}}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:le(n)?Ge():ue()}}};function Xt(e){if(e.insecureStorage)return Yt(),new We(e.insecureFilePath);let t=Ir();if(t)return new He(t);throw Jt()}var de=class e extends G{static description="Show the capabilities granted to the current CLI session (chosen on the browser approval screen at `device-login`, or via --scopes on `otp-login`). Scopes are checked by the backend on each request. Scope controls reduce access but do not prevent credential compromise, misuse within a granted scope, configuration errors, or unauthorized actions by an otherwise authenticated caller. Read from the cached token bundle; no network call.";static examples=["$ allscale scope","$ allscale scope --profile prod"];static isLocalOnly=!0;static flags={...G.baseFlags,token:{...G.baseFlags.token,description:"Not supported by this command. `scope` reads scopes recorded with a stored profile, so an arbitrary token has no authoritative scope source and is rejected locally. Use --profile to select the stored credential whose scopes should be shown."}};async runCommand(){let{flags:t}=await this.parse(e);if(t.token!==void 0)throw new c("input.invalid","--token is not supported by `allscale scope`: scopes are recorded metadata on a stored profile and cannot be derived from an arbitrary token. Use --profile <name> to select the credential whose recorded scopes should be shown.");let n=this.resolveContext(t);re()!==void 0&&process.stderr.write(`Note: ALLSCALE_TOKEN is set but ignored by \`scope\` \u2014 scopes are recorded metadata on a stored profile. Showing scopes recorded for profile '${n.profile}'.
|
|
17
|
+
`);let i=await Xt({insecureStorage:n.insecureStorage}).get(n.profile);if(!i)throw Pt({profile:n.profile,profileExplicit:n.profileExplicit});let o=i.scopes??[],a=!!i.agent_key,l=a&&typeof i.agent_key_expires_at=="number"?new Date(i.agent_key_expires_at*1e3).toISOString():void 0;return a?process.stderr.write(`Scopes for profile '${n.profile}': ${o.length>0?o.join(", "):"(none recorded)"}
|
|
18
18
|
(agent-key session \u2014 scopes are checked by the backend on each request; scope controls reduce access but do not prevent credential compromise, misuse within a granted scope, configuration errors, or unauthorized actions by an otherwise authenticated caller)
|
|
19
|
-
${l?`Key expires at ${l}`:"Key has no recorded expiry"}; agent keys don't refresh \u2014 re-run \`allscale device-login --profile ${
|
|
19
|
+
${l?`Key expires at ${l}`:"Key has no recorded expiry"}; agent keys don't refresh \u2014 re-run \`allscale device-login --profile ${N(n.profile)}\` (or \`${ee(n.profile)}\`) when it expires or is revoked.
|
|
20
20
|
`):process.stderr.write(`Profile '${n.profile}' holds a legacy full-permission session (no agent key).
|
|
21
|
-
Scopes apply to agent keys: run \`allscale device-login --profile ${
|
|
21
|
+
Scopes apply to agent keys: run \`allscale device-login --profile ${N(n.profile)}\` or \`${ee(n.profile)}\` to mint a scoped agent key (granted scopes are checked by the backend on each request).
|
|
22
22
|
`),{profile:n.profile,scopes:o,scoped:o.length>0,enforced:a,...l?{agent_key_expires_at:l}:{}}}};
|
|
23
23
|
//# sourceMappingURL=scope.js.map
|