@allscale/cli 1.0.2 → 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 +58 -5
- package/dist/commands/build-info.js +9 -9
- package/dist/commands/claim-link/claim.js +10 -10
- package/dist/commands/claim-link/create.js +30 -30
- package/dist/commands/claim-link/get.js +13 -13
- package/dist/commands/claim-link/list.js +11 -11
- package/dist/commands/claim-link/status.js +10 -10
- package/dist/commands/describe.js +8 -8
- package/dist/commands/device-login.js +24 -24
- package/dist/commands/invoice/get.js +10 -10
- package/dist/commands/invoice/list.js +8 -8
- package/dist/commands/invoice/pay.js +28 -28
- package/dist/commands/invoice/received.js +8 -8
- package/dist/commands/invoice/send.js +22 -22
- package/dist/commands/invoice/sent.js +4 -4
- package/dist/commands/invoice/update.js +11 -11
- package/dist/commands/logout.js +12 -12
- package/dist/commands/operations.js +7 -7
- package/dist/commands/otp-login.js +19 -19
- package/dist/commands/otp-send.js +7 -7
- package/dist/commands/payout/send.js +12 -12
- package/dist/commands/payout/status.js +12 -12
- package/dist/commands/scope.js +12 -12
- package/dist/commands/store/create.js +15 -15
- package/dist/commands/transaction/get.js +11 -11
- package/dist/commands/transaction/list.js +5 -5
- package/dist/commands/wallet/list.js +9 -9
- package/dist/commands/wallet/send.js +27 -27
- package/dist/commands/whoami.js +12 -12
- package/dist/index.js +9 -9
- package/dist/lib/help.js +10 -7
- package/oclif.manifest.json +5 -5
- package/package.json +1 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).some(n=>
|
|
3
|
-
`)}var h=L(require("fs")),Fe=L(require("path")),Jt=L(require("crypto"));var
|
|
4
|
-
`)}else Un.stderr.write(n)}var
|
|
5
|
-
`);return}re=n,N=t,oe=!0}var
|
|
1
|
+
"use strict";var Dr=Object.create;var xe=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Fr=Object.getPrototypeOf,Mr=Object.prototype.hasOwnProperty;var qr=(e,n)=>{for(var t in n)xe(e,t,{get:n[t],enumerable:!0})},Rt=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Br(n))!Mr.call(e,r)&&r!==t&&xe(e,r,{get:()=>n[r],enumerable:!(i=$r(n,r))||i.enumerable});return e};var L=(e,n,t)=>(t=e!=null?Dr(Fr(e)):{},Rt(n||!e||!e.__esModule?xe(t,"default",{value:e,enumerable:!0}):t,e)),Gr=e=>Rt(xe({},"__esModule",{value:!0}),e);var Zs={};qr(Zs,{default:()=>un,parseLineFlag:()=>Vs,parseLineFlags:()=>Rr,resolveInvoiceAmountAndLines:()=>Or});module.exports=Gr(Zs);var X=require("process");var R=require("@oclif/core");var xt="public",Pt="https://app.allscale.io";var Ut=["https://app.allscale.io"];var Sn="Override the API base URL (public builds accept only https://app.allscale.io)";var kn="Only https://app.allscale.io is allowed, and URL userinfo is forbidden.";function Dt(e){try{let n=new URL(e);return n.username.length>0||n.password.length>0?null:n.protocol==="https:"?n:null}catch{return null}}function $t(e){return Dt(e)!==null}function wn(e){let n=Dt(e);return n!==null&&Ut.includes(n.origin)}function he(){return"".trim()||void 0}function ee(){return"public"}function M(e){try{let{hostname:n}=new URL(e);return n==="127.0.0.1"||n==="localhost"||n==="[::1]"}catch{return!1}}function bn(e){try{return new URL(e).origin}catch{return null}}function ye(){{let e="[]".trim();if(e.length===0)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}return Tn()}function Tn(){let e=process.env.ALLSCALE_BUILD_PAIRS?.trim()??"";if(e.length>0)try{let i=JSON.parse(e);if(!Array.isArray(i))return[];let r=[];for(let o of i){if(typeof o!="object"||o===null)continue;let{base:a,key:s,keyId:c}=o;if(typeof a!="string"||a.trim().length===0||typeof s!="string"||s.trim().length===0)continue;let u=typeof c=="string"?c.trim():"";r.push({base:a.trim(),key:s,keyId:u.length>0?u:"cli-1"})}return r}catch{return[]}let n=process.env.ALLSCALE_SIGNING_KEY??"",t=process.env.ALLSCALE_BUILD_API_BASE?.trim()??"";if(n.trim().length>0&&t.length>0){let i=process.env.ALLSCALE_SIGNING_KEY_ID?.trim();return[{base:t,key:n,keyId:i&&i.length>0?i:"cli-1"}]}return[]}var Nn="device-login",Yr=/^[A-Za-z0-9._-]{1,64}$/;function Cn(e){return Yr.test(e)?e:"<profile>"}function q(e){return"allscale otp-login --profile "+(e===void 0?"<profile>":Cn(e))+" --email <you@example.com> --scopes <scope> --otp-stdin"}function Pe(){return"`allscale device-login` (or `allscale otp-login` \u2014 requires `--email` and `--scopes` \u2014 for headless automation)"}function Ft(e){let n=Cn(e);return`No tokens stored for profile '${e}'. Run \`allscale device-login --profile ${n}\` (recommended), or use \`${q(e)}\` for headless automation.`}function Mt(e){return`Unknown profile '${e}' \u2014 no such profile is saved on this machine. Check the spelling first; to deliberately create '${e}', run \`allscale ${Nn} --profile ${Cn(e)}\`.`}var Kr={"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 jr=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 In(e){return(typeof e=="string"?e:String(e??"")).replace(jr,"")}var Vr=64;function Ln(e,n=new Map,t=0){if(typeof e=="string")return In(e);if(e===null||typeof e!="object")return e;let i=n.get(e);if(i!==void 0)return i;if(t>=Vr)return e;if(Array.isArray(e)){let a=[];n.set(e,a);for(let s of e)a.push(Ln(s,n,t+1));return a}let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return e;let o={};n.set(e,o);for(let[a,s]of Object.entries(e))Object.defineProperty(o,a,{value:Ln(s,n,t+1),writable:!0,enumerable:!0,configurable:!0});return o}var l=class extends Error{code;details;constructor(n,t,i){super(In(t)),this.code=n,this.details=i&&Ln(i),this.name="AllscaleError"}get exitCode(){return Kr[this.code]}toJSON(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}};function qt(e){if(e instanceof l)return e;if(e instanceof Error){if(Jr(e)){let n=Xr(e),t={};return e.name&&e.name!=="Error"&&(t.name=e.name),Object.keys(n).length>0&&(t.oclif=n),new l("input.invalid",e.message,Object.keys(t).length>0?t:void 0)}return new l("internal",e.message,{name:e.name})}return new l("internal","Unknown error",{value:String(e)})}var Hr=new Set(["CLIError","CLIParseError","RequiredArgsError","RequiredFlagError","UnexpectedArgsError","FlagInvalidOptionError","ArgInvalidOptionError","InvalidArgsSpecError"]),Wr=[/^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 Jr(e){if(zr(e))return!0;let n=e.name??"";return Hr.has(n)?n==="CLIError"?En(e,"parse")||Bt(e.message):!0:Bt(e.message)}function zr(e){if(!En(e,"oclif"))return!1;let n=e.oclif;return typeof n=="object"&&n!==null&&n.exit===2&&En(e,"parse")}function Bt(e){return e?In(e).split(`
|
|
2
|
+
`).some(n=>Wr.some(t=>t.test(n.trim()))):!1}function En(e,n){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,n)}function Xr(e){let n=e,t={};for(let i of["code","exitCode","suggestions","ref"])n[i]!==void 0&&(t[i]=n[i]);return t}function Gt(e){process.stdout.write(`${JSON.stringify({data:e},null,2)}
|
|
3
|
+
`)}var h=L(require("fs")),Fe=L(require("path")),Jt=L(require("crypto"));var Zr="...<truncated>",Qr=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+/g,eo=/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,Pn=String.raw`(?:(?:Bearer|Basic)\s+)?(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s,;)}\]]+)`,vn=String.raw`(?:proxy[_-]?)?authorization`,no=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${vn}"|'${vn}'|${vn})\s*[:=]\s*)((?:Bearer|Basic)\s+)?(?!<redacted(?:-jwt)?>)${Pn}`,"gi"),to=/\b(https?:\/\/)[^\s/?#]+@/gi,io=String.raw`(?:[A-Za-z0-9]+[_-])*`,ro=String.raw`(?:[A-Za-z0-9]{1,32}[_-]){0,8}`,Kt=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)`,Yt=Kt(io),oo=Kt(ro),ao=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${Yt}"|'${Yt}'|${oo})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${Pn}`,"gi"),On=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)`,so=new RegExp(String.raw`(^|[^A-Za-z0-9])((?:"${On}"|'${On}'|${On})\s*[:=]\s*)(?!<redacted(?:-jwt)?>)${Pn}`,"g");function Ue(e){return e.replace(to,"$1<redacted>@").replace(Qr,"<redacted-jwt>").replace(no,"$1$2$3<redacted>").replace(ao,"$1$2<redacted>").replace(so,"$1$2<redacted>").replace(eo,"Bearer <redacted>")}var lo=/(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 De(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return lo.test(n)}function jt(e){let n="";for(let t of e){let i=t.codePointAt(0),r=i<=8||i>=11&&i<=12||i>=14&&i<=31||i>=127&&i<=159;n+=r?`\\u${i.toString(16).padStart(4,"0")}`:t}return n}function $e(e,n,t=Zr){if(n<=0)return"";if(Buffer.byteLength(e,"utf8")<=n)return e;let i=Buffer.byteLength(t,"utf8");if(i>=n){let s="",c=0;for(let u of t){let p=Buffer.byteLength(u,"utf8");if(c+p>n)break;s+=u,c+=p}return s}let r=n-i,o="",a=0;for(let s of e){let c=Buffer.byteLength(s,"utf8");if(a+c>r)break;o+=s,a+=c}return`${o}${t}`}function T(e,n=16384){return $e(jt(Ue(e)),n)}var Rn=100,co=8,uo=8*1024;function Be(){return{remaining:uo}}function xn(e,n){let t=Math.min(16384,n.remaining),i=$e(e,t);return n.remaining-=Buffer.byteLength(i,"utf8"),i}function ne(e,n,t=0,i={}){if(t>co)return xn("<truncated>",n);if(typeof e=="string"){let r=Ue(e);return xn(i.escapeControls?jt(r):r,n)}if(Array.isArray(e)){let r=e.slice(0,Rn),o=r.map(a=>ne(a,n,t+1,i));return e.length>r.length&&o.push(xn(`<${e.length-r.length} more items truncated>`,n)),o}if(e!==null&&typeof e=="object"){let r=Object.create(null),o=Object.entries(e);for(let[a,s]of o.slice(0,Rn))r[a]=ne(s,n,t+1,i);return o.length>Rn&&(r.output_truncated=!0),r}return e}var Un=require("process");var Dn=!1;function $n(e){Dn=e}function Ht(){return Dn}var Vt="1";function ie(e,n){if(Dn){let t={...e};delete t.version;let i=Be(),r={event:t.event,...t},o=ne(r,i,0,{escapeControls:!0}),a=JSON.stringify({version:Vt,...o});Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:Vt,event:o.event,output_truncated:!0})),Un.stderr.write(`${a}
|
|
4
|
+
`)}else Un.stderr.write(n)}var Wt="2",re=null,N=null,oe=!1,ge=!1;function po(){let e=process.env.ALLSCALE_OUTPUT_FILE_PATH;if(e)return e;let n=process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY;if(n){let t=new Date().toISOString().replace(/[:.]/g,"-"),i=Jt.randomBytes(4).toString("hex");return Fe.join(n,`allscale-output-${t}-${i}.ndjson`)}return null}var Bn=64*1024*1024,fo=null;function Fn(e={}){if(e.quiet&&(ge=!0),oe)return;let n=po();if(!n)return;re=null;let t=null;try{if((fo??process.platform)==="win32")throw new Error("owner-only sidecar ACLs cannot be enforced on Windows; sidecar output is disabled");let i=Fe.dirname(n);if(h.mkdirSync(i,{recursive:!0,mode:448}),!process.env.ALLSCALE_OUTPUT_FILE_PATH&&process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY){let c=h.statSync(i),u=c.mode&511;if(!c.isDirectory()||(u&63)!==0)throw new Error(`output directory must be owner-only (no group/other permissions); current mode is ${u.toString(8).padStart(3,"0")}`)}let r=h.constants.O_NOFOLLOW??0;t=h.openSync(n,h.constants.O_APPEND|h.constants.O_CREAT|h.constants.O_WRONLY|(h.constants.O_NONBLOCK??0)|r,384);let o=h.fstatSync(t),a=h.lstatSync(n);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 s=o.mode&511;if((s&63)!==0)throw new Error(`existing sidecar file must already be owner-only; current mode is ${s.toString(8).padStart(3,"0")}. Rotate or remove it before retrying`);h.fchmodSync(t,384)}catch(i){if(t!==null)try{h.closeSync(t)}catch{}ge||ie({event:"sidecar_disabled",reason:"open_failed",detail:T(`sidecar path '${n}' could not be opened safely (${i.message})`)},`${T(`[allscale] sidecar path '${n}' could not be opened safely (${i.message}); refusing to write. Sidecar disabled for this run.`)}
|
|
5
|
+
`);return}re=n,N=t,oe=!0}var mo=[/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 ho(e){let n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2");return mo.some(t=>t.test(n))}function zt(e){try{let n=new URL(e),t=n.username.length>0||n.password.length>0;t&&(n.username="",n.password="");let i=n.pathname;n.pathname=yo(n.pathname);let r=t;n.pathname!==i&&(r=!0);for(let[o]of n.searchParams)ho(o)&&(n.searchParams.set(o,"<redacted>"),r=!0);return r?n.toString():e}catch{return e}}function yo(e){return e.replace(/(\/(?:api\/)?(?:v1\/)?public\/claim-links\/)([^/:]+)(:claim)?(?=\/?$)/,"$1<redacted>$3").replace(/(\/(?:api\/)?public\/claim-links\/)([^/]+)(\/claim)(?=\/?$)/,"$1<redacted>$3")}function go(e){return(e.type==="request"||e.type==="bridge_browser_open")&&typeof e.url=="string"?{...e,url:zt(e.url)}:e}function _o(e){let n=new Date().toISOString(),t=e,{type:i,...r}=t,o=ne(r,Be()),a=JSON.stringify({version:Wt,timestamp:n,type:i,...o});return Buffer.byteLength(a,"utf8")+1>65536&&(a=JSON.stringify({version:Wt,timestamp:n,type:i,output_truncated:!0})),a}function k(e){if(!oe||!re||N===null)return;let n=go(e),t=_o(n);try{if(h.fstatSync(N).size+Buffer.byteLength(t,"utf8")+1>Bn){oe=!1;try{h.closeSync(N)}catch{}N=null,ge||ie({event:"sidecar_disabled",reason:"size_limit",...re===null?{}:{path:T(re)},max_bytes:Bn},`${T(`[allscale] sidecar exceeded ${Bn} bytes; disabling it for the rest of this run. Rotate or remove ${re}, or point ALLSCALE_OUTPUT_FILE_DIRECTORY at a directory so each run gets its own file.`)}
|
|
6
6
|
`);return}h.appendFileSync(N,`${t}
|
|
7
7
|
`)}catch(i){if(oe=!1,N!==null){try{h.closeSync(N)}catch{}N=null}try{ge||ie({event:"sidecar_disabled",reason:"write_failed",detail:T(i.message)},`${T(`[allscale] sidecar write failed (${i.message}); disabling sidecar for the rest of this run.`)}
|
|
8
|
-
`)}catch{}}}var $=
|
|
9
|
-
The CLI default is now ${
|
|
8
|
+
`)}catch{}}}var $=zt;function Xt(){return!!(process.env.ALLSCALE_OUTPUT_FILE_PATH||process.env.ALLSCALE_OUTPUT_FILE_DIRECTORY)}function _e(){if(ge=!1,oe=!1,N!==null){try{h.closeSync(N)}catch{}N=null}}function Zt(e=!1){let n=process.stdin.isTTY===!0&&process.stdout.isTTY===!0;return e||Xt()||!n}var Ae=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"]),Ao=new Set(Array.from(Ae).filter(e=>e.startsWith("-")&&!e.startsWith("--")&&e.length===2)),So=Array.from(Ae).filter(e=>e.startsWith("--")).sort((e,n)=>n.length-e.length),ko=new Set(["--otp-stdin","--password-stdin"]);function Mn(e){let n=[];for(let t=0;t<e.length;t+=1){let i=e[t];if(i.startsWith("-")){let o=i.indexOf("=");if(o!==-1){let a=i.slice(0,o);if(Ae.has(a)){n.push(`${a}=<redacted>`);continue}}}if(Ae.has(i)){n.push(i),t+1<e.length&&(Ae.has(e[t+1])||(n.push("<redacted>"),t+=1));continue}if(i.startsWith("-")&&!i.startsWith("--")&&i.length>2&&i[1]!=="="){let o=i.slice(0,2);if(Ao.has(o)){n.push(`${o}<redacted>`);continue}}let r=ko.has(i)?void 0:So.find(o=>i.length>o.length&&i.startsWith(o));if(r){n.push(`${r}<redacted>`);continue}n.push(i)}return n}function Qt(e){k({type:"error",code:e.code,message:T(e.message)}),k({type:"command-end",ok:!1,exitCode:e.exitCode}),_e()}var Se=he()??Pt,se={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 G(e){return $t(e)?new URL(e).origin:null}function O(e){try{let n=new URL(e);return`${n.protocol}//${n.host}`}catch{return"<unparseable URL>"}}function ei(){let e=process.env[se.TOKEN]?.trim();return e&&e.length>0?e:void 0}function qn(){let e=process.env[se.PROFILE]?.trim();return e&&e.length>0?e:void 0}function ke(){let e=process.env[se.API_BASE]?.trim();return e&&e.length>0?e:void 0}function ni(){let e=process.env[se.INSECURE_STORAGE]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function ti(){let e=process.env[se.NO_KEYCHAIN]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function ii(){let e=process.env[se.ALLOW_RAW]?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}function ri(e){let{resolvedApiBase:n,fromExplicitOverride:t,profileApiBase:i,profileApiBaseSource:r}=e;if(he()===void 0&&Se!==""&&"".length!==0&&!t&&r!=="explicit"&&i===""&&n==="")return`Notice: this profile is pinned to ${""} (staging) in ~/.allscale/config.toml.
|
|
9
|
+
The CLI default is now ${Se} (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 Y=L(require("fs")),
|
|
15
|
-
`)}};var Uo=/_(removed|cleared|count|total)$/i;function Do(e,n){return typeof n=="number"&&Uo.test(e)}var $o=new Set(ci);function Bo(e,n){return e==="token_symbol"&&typeof n=="string"&&$o.has(n)}var Fo=new Set(fi);function Mo(e,n){return e==="otp_reason"&&typeof n=="string"&&Fo.has(n)}var Ye=100;function Ke(e,n=0){if(n>8)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,Ye),i=t.map(r=>Ke(r,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null),i=Object.entries(e);for(let[r,o]of i.slice(0,Ye))t[r]=De(r)&&!Do(r,o)&&!Bo(r,o)&&!Mo(r,o)?"<redacted>":Ke(o,n+1);if(i.length>Ye){let r="<truncated>";for(;r in t;)r=`<${r}>`;t[r]=`${i.length-Ye} more keys`}return t}if(typeof e=="string"){let t=Go(e);return t!==void 0?T(JSON.stringify(Ke(t,n+1))):T(e)}return e}function Go(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function qo(e){let n=Ht()?void 0:2,t=Ke(e.toJSON()),i=JSON.stringify(t,null,n);return Buffer.byteLength(i,"utf8")+1<=65536?i:JSON.stringify({error:{code:e.code,message:T(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,n)}function Yo(e){if(e.requiresInput===!0)return!0;let n=r=>typeof r=="object"&&r!==null&&r.required===!0,t=e.flags??{},i=e.args??{};return Object.values(t).some(r=>n(r))||Object.values(i).some(r=>n(r))}var Ei=L(require("path"));var Wn=require("crypto"),d=L(require("fs")),S=L(require("path"));var Ve=1024*1024,Ko=5e3,Vo=20,Ho=3e4,jn=4096,jo=new Int32Array(new SharedArrayBuffer(4)),Te=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function He(e){return e instanceof Te}var E=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},Jo=null;function H(){return new l("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 je(){return(Jo??process.platform)!=="win32"}function ki(){if(!je())throw H()}function wi(e){try{return d.default.lstatSync(e),!1}catch(n){if(!_(n,"ENOENT"))throw n}try{let n=d.default.lstatSync(S.dirname(e));return!n.isSymbolicLink()&&n.isDirectory()}catch(n){if(_(n,"ENOENT"))return!0;throw n}}function _(e,n){return typeof e=="object"&&e!==null&&e.code===n}function be(e,n){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${n} is not owned by the current effective user`)}function Le(e,n){return e.dev===n.dev&&e.ino===n.ino}function Wo(e){Atomics.wait(jo,0,0,e)}function Ti(e){try{return process.kill(e,0),!0}catch(n){return!_(n,"ESRCH")}}function zo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mi(e,n){let t=S.dirname(e);n&&d.default.mkdirSync(t,{recursive:!0,mode:448});let i;try{i=d.default.lstatSync(t)}catch(o){if(!n&&_(o,"ENOENT"))return!1;throw o}if(i.isSymbolicLink()||!i.isDirectory())throw new Error("credential-store parent must be a real directory");if(process.platform==="win32")return!0;let r=null;try{r=d.default.openSync(t,d.default.constants.O_RDONLY|(d.default.constants.O_DIRECTORY??0)|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0));let o=d.default.fstatSync(r),a=d.default.lstatSync(t);if(!o.isDirectory()||a.isSymbolicLink()||!a.isDirectory()||!Le(o,a))throw new Error("credential-store parent changed while it was being inspected");be(o,"credential-store parent");let s=o;if((o.mode&63)!==0&&S.basename(t)===".allscale"&&(d.default.fchmodSync(r,448),s=d.default.fstatSync(r)),(s.mode&63)!==0)throw new Error("credential-store parent must not grant group or other permissions")}finally{r!==null&&d.default.closeSync(r)}return!0}function x(e,n,t,i={}){if(!t.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");let r;try{r=d.default.lstatSync(e)}catch(o){throw i.retryOnPathChange&&_(o,"ENOENT")?new E:o}if(!Le(t,r))throw i.retryOnPathChange?new E:new Error("credential-store target changed while it was being opened or is not a regular file");if(r.isSymbolicLink()||!r.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");if(!i.allowMultipleLinks&&(t.nlink!==1||r.nlink!==1))throw new Te;if(be(t,"credential-store file"),process.platform!=="win32"){d.default.fchmodSync(n,384);let o=d.default.fstatSync(n);if((o.mode&63)!==0)throw new Error("credential-store file could not be made owner-only");return o}return t}function Xo(e,n){if(n.size>Ve)throw new Error("credential-store file exceeds the maximum supported size");let t=Buffer.alloc(Ve+1),i=0;for(;i<t.length;){let r=d.default.readSync(e,t,i,t.length-i,null);if(r===0)break;i+=r}if(i>Ve)throw new Error("credential-store file exceeds the maximum supported size");return t.subarray(0,i).toString("utf8")}function hi(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(r){if(_(r,"ENOENT"))try{if(d.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(_(o,"ENOENT"))return null;throw o}throw r}let t=d.default.fstatSync(n),i=x(e,n,t);return Xo(n,i)}finally{n!==null&&d.default.closeSync(n)}}function yi(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(r){if(_(r,"ENOENT")&&wi(e))return;throw r}let t=d.default.fstatSync(n),i=x(e,n,t);j(e,i)}finally{n!==null&&d.default.closeSync(n)}Li(S.dirname(e))}function Zo(e){let n;try{n=d.default.lstatSync(e)}catch(t){if(_(t,"ENOENT"))return;throw t}if(n.isSymbolicLink()||!n.isFile())throw new Error("credential-store replacement target must be a regular file");if(n.nlink!==1)throw new Te;be(n,"credential-store replacement target")}function Qo(e,n){for(let t=0;t<8;t+=1){let i=(0,Wn.randomBytes)(12).toString("hex"),r=S.join(e,`.${n}.${process.pid}.${i}.tmp`);try{return{fd:d.default.openSync(r,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_WRONLY|(d.default.constants.O_NOFOLLOW??0),384),tempPath:r}}catch(o){if(_(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function bi(e,n){let t=0;for(;t<n.length;){let i=d.default.writeSync(e,n,t,n.length-t,null);if(!Number.isSafeInteger(i)||i<=0)throw new Error("credential-store temp file write made no progress");t+=i}}function Li(e){if(process.platform==="win32")return;let n=null;try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_DIRECTORY??0)|(d.default.constants.O_NOFOLLOW??0)),d.default.fsyncSync(n)}catch{}finally{if(n!==null)try{d.default.closeSync(n)}catch{}}}function ea(e,n){let t=Buffer.from(n,"utf8");if(t.length>Ve)throw new Error("credential-store file exceeds the maximum supported size");let i=S.dirname(e),r=S.basename(e),o=null,a=null,s=!1;try{let c=Qo(i,r);o=c.fd,a=c.tempPath;let u=d.default.fstatSync(o);if((x(a,o,u).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");bi(o,t),d.default.fsyncSync(o),x(a,o,d.default.fstatSync(o));let f=o;o=null,d.default.closeSync(f),Zo(e),d.default.renameSync(a,e),s=!0}finally{if(o!==null)try{d.default.closeSync(o)}catch{}if(!s&&a!==null)try{d.default.unlinkSync(a)}catch{}}Li(i)}function na(e){return S.join(S.dirname(e),`.${S.basename(e)}.lock`)}function ta(e){return S.join(S.dirname(e),`.${S.basename(e)}.lock-recovery`)}function ia(e,n){if(n.size>jn)return null;let t=Buffer.alloc(jn+1),i=0;for(;i<t.length;){let o=d.default.readSync(e,t,i,t.length-i,null);if(o===0)break;i+=o}if(i>jn)return null;let r;try{r=JSON.parse(t.subarray(0,i).toString("utf8"))}catch{return null}return typeof r!="object"||r===null||!Number.isSafeInteger(r.pid)||(r.pid??0)<=0||typeof r.nonce!="string"||!/^[a-f0-9]{24}$/.test(r.nonce??"")||typeof r.target!="string"?null:r}function j(e,n){let t=d.default.lstatSync(e);if(t.isSymbolicLink()||!t.isFile()||!Le(t,n))throw new Error("credential-store lock changed while it was being inspected");be(t,"credential-store lock"),d.default.unlinkSync(e)}function gi(e,n){let t=null;try{try{t=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(c){if(_(c,"ENOENT"))try{let u=d.default.lstatSync(e);throw u.isSymbolicLink()||!u.isFile()?new Error("credential-store lock must be a real regular file"):new E}catch(u){if(_(u,"ENOENT"))return{state:"absent"};throw u}throw c}let i=d.default.fstatSync(t),r=x(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=ia(t,r);return{state:(o?.target===n&&o?!Ti(o.pid):Date.now()-r.mtimeMs>=Ho)?"stale":"active",stats:r}}finally{t!==null&&d.default.closeSync(t)}}function ra(e,n){for(let t=0;t<8;t+=1){let i=(0,Wn.randomBytes)(12).toString("hex"),r=S.join(e,`.${n}.${process.pid}.${i}.lock-claim`),o={pid:process.pid,nonce:i,target:n},a=null;try{a=d.default.openSync(r,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_WRONLY|(d.default.constants.O_NOFOLLOW??0),384);let s=d.default.fstatSync(a),c=x(r,a,s,{allowMultipleLinks:!0});return bi(a,Buffer.from(JSON.stringify(o),"utf8")),d.default.fsyncSync(a),{claimPath:r,metadata:o,stats:c}}catch(s){if(_(s,"EEXIST"))continue;try{d.default.unlinkSync(r)}catch{}throw s}finally{a!==null&&d.default.closeSync(a)}}throw new Error("could not allocate a unique credential-store lock claim")}function oa(e,n){let t;try{t=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(i){throw _(i,"ENOENT")?new E:i}try{let i=d.default.fstatSync(t),r=x(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!Le(r,n))throw new E;return{fd:t,lockPath:e,stats:r}}catch(i){throw d.default.closeSync(t),i}}function _i(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(t){if(_(t,"ENOENT"))try{let i=d.default.lstatSync(e);throw i.isSymbolicLink()||!i.isFile()?new Error("credential-store recovery gate must be a real regular file"):new E}catch(i){if(_(i,"ENOENT"))return!1;throw i}throw t}return x(e,n,d.default.fstatSync(n),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{n!==null&&d.default.closeSync(n)}}function aa(e){let n;try{n=d.default.openSync(e,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_RDWR|(d.default.constants.O_NOFOLLOW??0),384)}catch(i){if(_(i,"EEXIST"))return null;throw i}let t=null;try{t=d.default.fstatSync(n);let i=x(e,n,t,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:n,lockPath:e,stats:i}}catch(i){if(t!==null)try{j(e,t)}catch{}throw d.default.closeSync(n),i}}function V(e,n){if(Date.now()>=e)throw n?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");Wo(Vo)}function Si(e){let n=S.dirname(e),t=S.basename(e),i=na(e),r=ta(e),o=ra(n,t),a=Date.now()+Ko,s=!1,c=!1,u=null,p;try{for(;u===null;)try{if(_i(r)){V(a,!0);continue}d.default.linkSync(o.claimPath,i),c=!0,u=oa(i,o.stats),s=!0}catch(f){if(c&&!s){try{j(i,o.stats)}catch{}c=!1}if(f instanceof E){V(a,!1);continue}if(!_(f,"EEXIST"))throw f;let y;try{y=gi(i,t)}catch(A){if(A instanceof E){V(a,!1);continue}throw A}if(y.state==="absent")continue;if(y.state==="stale"){let A;try{A=aa(r)}catch(b){if(b instanceof E){V(a,!1);continue}throw b}if(A!==null){try{let b;try{b=gi(i,t)}catch(U){if(U instanceof E){V(a,!1);continue}throw U}b.state==="stale"&&j(i,b.stats)}finally{Jn(A)}continue}}let m;try{m=_i(r)}catch(A){if(A instanceof E){V(a,!1);continue}throw A}V(a,m)}}catch(f){p=f}try{j(o.claimPath,o.stats)}catch(f){!_(f,"ENOENT")&&!s&&p===void 0&&(p=f)}if(p!==void 0)throw p;if(u===null)throw new Error("credential-store lock acquisition failed");return u}function Jn(e){try{j(e.lockPath,e.stats)}finally{d.default.closeSync(e.fd)}}function sa(e,n){let t=zo(n),i=new RegExp(`^\\.${t}\\.(\\d+)\\.[a-f0-9]{24}\\.tmp$`).exec(e)??new RegExp(`^\\.${t}\\.(\\d+)\\.[a-f0-9]{24}\\.lock-claim$`).exec(e);if(!i)return null;let r=Number(i[1]);return Number.isSafeInteger(r)&&r>0?r:null}function Ai(e){let n=S.dirname(e),t=S.basename(e);for(let i of d.default.readdirSync(n)){let r=sa(i,t);if(r===null||Ti(r))continue;let o=S.join(n,i),a=null;try{try{a=d.default.openSync(o,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(u){if(_(u,"ENOENT")||_(u,"ELOOP"))continue;throw u}let s=d.default.fstatSync(a),c=d.default.lstatSync(o);if(!s.isFile()||c.isSymbolicLink()||!c.isFile()||!Le(s,c))continue;try{be(s,"credential-store orphan")}catch{continue}j(o,s)}catch(s){if(!_(s,"ENOENT"))throw s}finally{a!==null&&d.default.closeSync(a)}}}function Ee(e,n,t){if(!je()){if(n.allowUnsupportedPlatformCleanup){if(n.createParent)throw H();if(!mi(e,!1))return t({read:()=>null,remove:()=>{},write:()=>{throw H()}});let a=Si(e);try{return Ai(e),t({read:()=>hi(e),remove:()=>yi(e),write:()=>{throw H()}})}finally{Jn(a)}}if(!n.createParent){let o=!1;try{o=wi(e)}catch{throw H()}if(o)return t({read:()=>null,remove:()=>{},write:()=>{throw H()}})}throw H()}if(!mi(e,n.createParent))return t({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let r=Si(e);try{return Ai(e),t({read:()=>hi(e),remove:()=>yi(e),write:o=>ea(e,o)})}finally{Jn(r)}}var zn="allscale-cli";function et(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ni(e){return et(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function W(e){return new l("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 Xn(){return new l("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 Je(){return new l("internal","The session credential store in the plaintext file could not be written safely. Any previous credential file was left unchanged.")}var J,Zn=!1;function la(){return ni()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function ca(e){if(typeof e!="object"||e===null||e.code!=="MODULE_NOT_FOUND")return!1;let n=e.message;return typeof n=="string"&&n.split(`
|
|
16
|
-
`,1)[0]==="Cannot find module 'keytar'"}function da(){if(J!==void 0)return J;if(la())return Zn=!1,J=null,J;try{J=require("keytar"),Zn=!1}catch(e){Zn=!ca(e),J=null}return J}function Ci(){let e=je()?"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 l("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 Qn(e){try{return await e()}catch{throw Ci()}}var nt=class{constructor(n){this.keytar=n}keytar;kind="keychain";async read(n){let t=await Qn(()=>this.keytar.getPassword(zn,n));if(t===null)return null;let i;try{i=JSON.parse(t)}catch{throw W("OS keychain")}if(!Ni(i))throw W("OS keychain");return i}async get(n){return this.read(n)}async set(n,t){await this.read(n),await Qn(()=>this.keytar.setPassword(zn,n,JSON.stringify(t)))}async delete(n){await this.read(n),await Qn(()=>this.keytar.deletePassword(zn,n))}},ua="credentials.json",tt=class{kind="insecure-file";filePath;constructor(n){this.filePath=n??Ei.join(Kn(),ua)}read(n){let t;try{t=n.read()}catch(r){throw He(r)?Xn():W("plaintext file")}if(t===null)return{profiles:{}};let i;try{i=JSON.parse(t)}catch{throw W("plaintext file")}if(!et(i)||!et(i.profiles))throw W("plaintext file");return i}write(n,t){try{n.write(JSON.stringify(t,null,2))}catch(i){throw He(i)?Xn():Je()}}profileTokens(n,t){let i=n.profiles[t];if(i!==void 0){if(!Ni(i))throw W("plaintext file");return i}}async get(n){try{return Ee(this.filePath,{createParent:!1},t=>this.profileTokens(this.read(t),n)??null)}catch(t){throw t instanceof l?t:W("plaintext file")}}async set(n,t){try{Ee(this.filePath,{createParent:!0},i=>{let r=this.read(i);this.profileTokens(r,n),r.profiles[n]=t,this.write(i,r)})}catch(i){throw i instanceof l?i:Je()}}async delete(n){try{Ee(this.filePath,{createParent:!1},t=>{let i=this.read(t);this.profileTokens(i,n)!==void 0&&(delete i.profiles[n],this.write(t,i))})}catch(t){throw t instanceof l?t:Je()}}async clearProfile(n){try{return Ee(this.filePath,{createParent:!1,allowUnsupportedPlatformCleanup:!0},t=>{let i=this.read(t);return this.profileTokens(i,n)===void 0?!1:(delete i.profiles[n],Object.keys(i.profiles).length===0?t.remove():this.write(t,i),!0)})}catch(t){throw t instanceof l?t:He(t)?Xn():Je()}}};function We(e){if(e.insecureStorage)return ki(),new tt(e.insecureFilePath);let n=da();if(n)return new nt(n);throw Ci()}var it=class{kind="insecure-file";async get(n){return null}async set(n,t){throw new l("internal","NoopTokenStore: refusing to persist tokens \u2014 caller used --token override path.")}async delete(n){}};function ze(){return new it}var Xe="allscale_access_token",rt="allscale_refresh_token";function Ii(e){return(typeof e.getSetCookie=="function"?e.getSetCookie():e.get("set-cookie")?[e.get("set-cookie")]:[]).map(t=>{let i=t.indexOf(";"),r=i===-1?t:t.slice(0,i),o=r.indexOf("=");return o===-1?null:{name:r.slice(0,o).trim(),value:r.slice(o+1).trim()}}).filter(t=>t!==null)}function ot(e){return e.map(n=>`${n.name}=${n.value}`).join("; ")}function at(e,n){return e.find(t=>t.name===n)?.value??null}var vi=L(require("crypto")),Oi=L(require("fs")),Ri=L(require("path"));var pa="key-id",fa="x-allscale-cli-version",st="cli-1",ma="aScaLe_cli_obf_v1",ha="WWoBD3QEZwECUTEuOD4dTgdWawQSKAQ8UlRaaw==";function ya(e,n){let t=Buffer.from(e,"base64"),i=Buffer.from(n,"utf8"),r=Buffer.alloc(t.length);for(let o=0;o<t.length;o++)r[o]=t[o]^i[o%i.length];return r.toString("utf8")}var ga=ya(ha,ma),xi=`Bearer ${ga}`;function Pi(e,n){let t=bn(e);if(t!==null)return n.find(i=>bn(i.base)===t)}function _a(e){if("f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2".trim().length>0)return"f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2";let n=ye();if(n.length>0){let i=Pi(e,n);if(i)return i.key;if(M(e)){let r=process.env.ALLSCALE_SIGNING_KEY;return r&&r.trim().length>0?r:M(n[0].base)?n[0].key:void 0}return}let t=process.env.ALLSCALE_SIGNING_KEY;return t&&t.trim().length>0?t:void 0}function Sa(e){{let i="cli-1".trim();if(i.length>0)return i}let n=ye();if(n.length>0){let i=e!==void 0?Pi(e,n):void 0;if(i)return i.keyId;if(e!==void 0&&M(e)){let r=process.env.ALLSCALE_SIGNING_KEY;if(r&&r.trim().length>0){let o=process.env.ALLSCALE_SIGNING_KEY_ID;return o!==void 0?o.trim():st}if(!M(n[0].base))return st}return n[0].keyId}let t=process.env.ALLSCALE_SIGNING_KEY_ID;return t!==void 0?t.trim():st}function Aa(){return"1.0.2"}function ka(){return new l("signing.key_unavailable","No request-signing key is available for this destination in this build. Published builds embed one at publish time; when running from source or an internal build, set ALLSCALE_SIGNING_KEY + ALLSCALE_BUILD_API_BASE (or ALLSCALE_BUILD_PAIRS for more than one environment) in the environment.")}function lt(e,n){let t=_a(n);if(!t)throw ka();let i=Sa(n),r=Math.floor(Date.now()/1e3).toString(),o=vi.createHash("sha256").update(`${t}${r}${e}`).digest("hex"),a={timestamp:r,"secret-key":o,[fa]:Aa()};return i.length>0&&(a[pa]=i),a}function Ui(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e)}function wa(e,n={}){let t;try{t=oi(Me())}catch{return}if(!(t.length===0||t.includes(e)))return new l("auth.unknown_profile",Ft(e)+(n.messageSuffix??""),{profile:e})}function Ne(e){if(e.profileExplicit){let n=wa(e.profile);if(n)return n}return new l("auth.no_token",Bt(e.profile))}var Ta=500,ba=8,Di=100;function ct(e,n=0){if(n>ba)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,Di),i=t.map(r=>ct(r,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null);for(let[i,r]of Object.entries(e).slice(0,Di))t[i]=De(i)?"<redacted>":ct(r,n+1);return t}return e}function La(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function $i(e,n=Ta){let t=La(e),i=t===void 0?Ue(e):JSON.stringify(ct(t));return $e(i,n)}var dt=256*1024,Ze=class extends l{constructor(n,t,i="backend-envelope"){let r=i==="successful-query",o=i==="successful-mutation";super(r?"transport.response_too_large":"backend.internal",r?`The API returned an HTTP-success response larger than the CLI's ${t}-byte safety limit, so it was not parsed. For list commands, request fewer rows by removing --all or using --input/--limit pagination, and reduce --select when possible; for other commands, contact support.`:o?`The API returned an HTTP-success response larger than the CLI's ${t}-byte safety limit, so its result was not parsed. The operation may already have completed; inspect authoritative state before retrying.`:`API response body exceeded the ${t}-byte safety limit and was not parsed.`,{status:n,max_body_bytes:t,...o?{outcome_ambiguous:!0}:{}}),this.name="ResponseBodyTooLargeError"}},Qe=class extends Error{status;timeoutMs;constructor(n,t){super(`API response body read exceeded its ${t}ms deadline.`),this.name="ResponseBodyReadTimeoutError",this.status=n,this.timeoutMs=t}};async function ut(e,n,t={}){if(!Number.isSafeInteger(n)||n<=0)throw new RangeError("maxBytes must be a positive safe integer");if(t.timeoutMs!==void 0&&(!Number.isSafeInteger(t.timeoutMs)||t.timeoutMs<=0))throw new RangeError("timeoutMs must be a positive safe integer");let i=e.headers.get("content-length"),r=i!==null&&/^\d+$/.test(i.trim())?Number(i):void 0;if(r!==void 0&&r>n)throw e.body?.cancel().catch(()=>{}),new Ze(e.status,n,t.oversizeKind);if(!e.body)return"";let o=e.body.getReader(),a=[],s=0,c,u=t.timeoutMs,p=u===void 0?void 0:new Promise((f,y)=>{c=setTimeout(()=>{y(new Qe(e.status,u))},u),c.unref?.()});try{for(;;){let f=o.read(),{done:y,value:m}=p?await Promise.race([f,p]):await f;if(y)break;if(s+=m.byteLength,s>n)throw o.cancel().catch(()=>{}),new Ze(e.status,n,t.oversizeKind);a.push(Buffer.from(m))}}catch(f){throw f instanceof Qe&&o.cancel(f).catch(()=>{}),f}finally{c!==void 0&&clearTimeout(c);try{o.releaseLock()}catch{}}return Buffer.concat(a,s).toString("utf8")}var Ea="X-AllScale-Api-Key",Na=3e4,Ca=32*1024*1024,Ia=4*1024*1024;function va(e,n){let t=new AbortController,i=!1,r=()=>{t.abort(e?.reason)};e?.aborted?r():e?.addEventListener("abort",r,{once:!0});let o=setTimeout(()=>{i=!0,t.abort()},n);return{signal:t.signal,timedOut:()=>i,dispose:()=>{clearTimeout(o),e?.removeEventListener("abort",r)}}}function Oa(e,n){return n?n.aborted?Promise.reject(Object.assign(new Error("The operation was aborted"),{name:"AbortError"})):new Promise((t,i)=>{let r=()=>{i(Object.assign(new Error("The operation was aborted"),{name:"AbortError"}))};n.addEventListener("abort",r,{once:!0}),e.then(t,i).finally(()=>{n.removeEventListener("abort",r)})}):e}function Ra(e,n){if(!(e<300||e>=400))throw new l("transport.network",`API returned HTTP ${e} (a redirect) for ${$(n||"the request")}. The CLI does NOT follow redirects on credential-bearing requests \u2014 a cross-origin hop could re-send credentials and the request body to the new host. Check that --api-base / ALLSCALE_API_BASE points at the API origin directly and that no proxy is rewriting it.`,{status:e})}async function qi(e){if(!(e.status<300||e.status>=400)){try{await e.body?.cancel()}catch{}Ra(e.status,e.url)}}var Bi="--dns-result-order=ipv4first";async function en(e,n){if(e.status!==403)return;let t=e.headers.get("content-type")?.toLowerCase()??"",i=e.headers.get("cf-ray")??"",r=e.headers.get("cf-mitigated")?.trim().toLowerCase()==="challenge",o=t.includes("text/html"),a=n?.slice(0,4096)??"",s=/^\s*(?:<!doctype\s+html|<html\b)/i.test(a),c=/cf-error-details|\/cdn-cgi\/(?:challenge-platform|styles\/cf\.errors)|sorry,\s*you have been blocked|attention required[^<]{0,160}cloudflare|cloudflare ray id|error\s*(?:code\s*)?1020/i.test(a);if(!((o||s)&&(r||n!==void 0&&c)))return;if(n===void 0)try{e.body?.cancel().catch(()=>{})}catch{}let p=/^[A-Za-z0-9-]{1,128}$/.test(i)?i:void 0;throw new l("transport.network",`Cloudflare blocked this request before it reached the AllScale API (HTTP 403). This can happen when the release edge accepts IPv4 but rejects IPv6. Retry with NODE_OPTIONS=${Bi} and report the Cloudflare Ray ID to support; the CLI will not automatically retry a possibly mutating request.`,{status:403,edge_provider:"cloudflare",...p?{cf_ray:p}:{},ipv4_workaround:`NODE_OPTIONS=${Bi}`})}var z=class{constructor(n){this.opts=n}opts;refreshInFlight=null;async requestWithMetadata(n){return this.requestInternal(n,{withMetadata:!0})}async request(n){return this.requestInternal(n,{withMetadata:!1})}async requestInternal(n,t){let i=n.timeoutMs??this.opts.requestTimeoutMs??Na;if(!Number.isFinite(i)||i<1)throw new l("input.invalid","HTTP request timeout must be a positive number of milliseconds.");K(this.opts.apiBase),qe(this.opts.apiBase);let r=this.opts.override?{access_token:this.opts.override.access_token,refresh_token:this.opts.override.refresh_token??""}:await this.opts.tokenStore.get(this.opts.profile),o=va(n.signal,i);try{return await this.requestWithinDeadline({...n,signal:o.signal},t,r)}catch(a){throw o.timedOut()?new l("transport.timeout",`Request to ${$(new URL(n.path,this.opts.apiBase).toString())} timed out after ${i}ms.`,{timeout_ms:i}):n.signal?.aborted&&!(a instanceof l)?new l("transport.network",`Request to ${$(new URL(n.path,this.opts.apiBase).toString())} was aborted by the caller.`):a}finally{o.dispose()}}async requestWithinDeadline(n,t,i){let r=new URL(n.path,this.opts.apiBase).toString();li(this.opts.apiBase,r);let o=i?.agent_key,a=n.auth??"auto",s=Yi(n.path),c=a==="required"?!0:a==="none"?!1:Ua(n.path);if((s||a==="required")&&!n._isRefresh&&!this.opts.override&&!i?.access_token&&!o)throw Ne({profile:this.opts.profile,profileExplicit:this.opts.profileExplicit});let u=Ui(n.body),p=!!o||!!i?.access_token;c&&p&&!this.opts.override&&Ge(this.opts.apiBase,i?.api_base);let f=this.buildHeaders({attachAuth:c&&p,bodyForSig:u,tokens:i,extra:n.headers}),y=Date.now();k({type:"request",method:n.method??"GET",url:r,...n._isRefresh?{refresh:!0}:{}});let m;try{m=await fetch(r,{method:n.method??"GET",headers:f,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(b){throw new l("transport.network",`Network error contacting ${$(r)}: ${b instanceof Error?b.message:String(b)}`)}if(k({type:"response",status:m.status,durationMs:Date.now()-y}),c&&!!i?.access_token&&!o&&m.status===401&&!n._isRefresh&&!this.opts.override){let b=await Oa(this.refreshSingleFlight(),n.signal),U=this.buildHeaders({attachAuth:c&&!!b.access_token,bodyForSig:u,tokens:b,extra:n.headers}),Z=Date.now();k({type:"request",method:n.method??"GET",url:r});let C;try{C=await fetch(r,{method:n.method??"GET",headers:U,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(I){throw new l("transport.network",`Network error contacting ${$(r)} on refresh-retry: ${I instanceof Error?I.message:String(I)}`)}return k({type:"response",status:C.status,durationMs:Date.now()-Z}),Fi(C,{withMetadata:t.withMetadata,authBearing:c,responseKind:Mi(n)})}return Fi(m,{withMetadata:t.withMetadata,authBearing:c&&p,agentKeyAuth:c&&!!o,responseKind:Mi(n)})}buildHeaders(n){let i={Accept:"application/json","Content-Type":"application/json",...lt(n.bodyForSig,this.opts.apiBase),...n.extra};if(n.attachAuth){i.Authorization=xi;let r=n.tokens;if(r?.agent_key)return i[Ea]=r.agent_key,i;let o=r?.access_token;o&&(i.Cookie=ot([{name:Xe,value:o}]))}return i}async refreshSingleFlight(){return this.refreshInFlight?this.refreshInFlight:(this.refreshInFlight=this.doRefresh().finally(()=>{this.refreshInFlight=null}),this.refreshInFlight)}async adoptConcurrentlyRotatedTokens(n){let t;try{t=await this.opts.tokenStore.get(this.opts.profile)}catch{return null}if(!t?.access_token||!t?.refresh_token||t.refresh_token===n.refresh_token)return null;if(Ge(this.opts.apiBase,t.api_base),t.agent_key)throw new l("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than use it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");return t}async doRefresh(){let n=await this.opts.tokenStore.get(this.opts.profile);if(!n?.access_token||!n?.refresh_token)throw new l("auth.token_expired",`No refresh token available; log in again \u2014 ${Pe()}.`);if(Ge(this.opts.apiBase,n.api_base),n.agent_key)throw new l("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than overwrite it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");let t=new URL("/api/public/auth/refresh_token",this.opts.apiBase).toString(),i=ot([{name:Xe,value:n.access_token},{name:rt,value:n.refresh_token}]),r=lt("",this.opts.apiBase);k({type:"request",method:"POST",url:t,refresh:!0});let o=new AbortController,a=!1,s=setTimeout(()=>{a=!0,o.abort()},1e4),c;try{c=await fetch(t,{method:"POST",headers:{Accept:"application/json",Cookie:i,...r},signal:o.signal,redirect:"manual"})}catch(m){throw k({type:"refresh",ok:!1}),new l("transport.network",a&&m instanceof Error&&m.name==="AbortError"?`Token refresh against ${$(t)} timed out after 10s with no response.`:`Network error during token refresh against ${$(t)}: ${m instanceof Error?m.message:String(m)}`)}finally{clearTimeout(s)}k({type:"response",status:c.status,durationMs:0});try{await qi(c)}catch(m){throw k({type:"refresh",ok:!1}),m}if(c.status!==200){let m=null;try{await en(c);let A=await Ma(c);await en(c,A),Vi(c.status,A),c.status===401&&(m=await this.adoptConcurrentlyRotatedTokens(n))}catch(A){throw k({type:"refresh",ok:!1}),A}if(m)return k({type:"refresh",ok:!0,adopted:!0}),m;throw k({type:"refresh",ok:!1}),new l("auth.token_expired",`Refresh token was rejected; re-authenticate \u2014 ${Pe()}.`,{status:c.status})}let u=Ii(c.headers),p=at(u,Xe),f=at(u,rt);if(!p||!f)throw k({type:"refresh",ok:!1}),new l("auth.token_expired","Refresh response did not include new access/refresh cookies.");let y={...n,access_token:p,refresh_token:f};return await this.opts.tokenStore.set(this.opts.profile,y),k({type:"refresh",ok:!0}),y}},xa=["/secure","/api/secure","/v1/secure","/api/v1/secure"];function Yi(e){let n=e.split(/[?#]/,1)[0];return xa.some(t=>n===t||n.startsWith(`${t}/`))}var Pa=[/^\/(api\/)?(v1\/)?public\/businesses\/payments?(\/|$)/,/^\/(api\/)?(v1\/)?public\/businesses\/transactions?(\/|$)/];function pt(e){let n=e.split(/[?#]/,1)[0];return Pa.some(t=>t.test(n))}function Ua(e){return Yi(e)||pt(e)}async function Fi(e,n={}){await qi(e);let t=e.status>=200&&e.status<300;t||await en(e);let i=n.responseKind??"mutation",o=await ut(e,t?i==="query"?Ca:Ia:dt,{oversizeKind:t?i==="query"?"successful-query":"successful-mutation":"backend-envelope"});t||await en(e,o);let a=null;if(o.length>0)try{a=JSON.parse(o)}catch{a={raw:o}}if(e.status>=200&&e.status<300){if(n.withMetadata){let c={};return e.headers.forEach((u,p)=>{c[p]=u}),{status:e.status,headers:c,body:a}}return a}let s=Ga(a)??`HTTP ${e.status}`;if(Vi(e.status,a),Ba(e.status,a,n),e.status===401){if(n.agentKeyAuth)throw new l("auth.token_expired","Agent key was rejected (expired or revoked). Re-run `allscale device-login` to mint a new scoped key.",{status:401,body:a});let c=n.authBearing?"auth.token_expired":"input.invalid";throw new l(c,s,{status:401,body:a})}throw e.status===403?new l("auth.permission_denied",s,{status:403,body:a}):e.status===404?new l("not_found",s,{status:404,body:a}):e.status===429?new l("rate_limited",s,{status:429,body:a}):e.status>=500?new l("backend.internal",s,{status:e.status,body:a}):new l("input.invalid",s,{status:e.status,body:a})}function Mi(e){if(e.responseKind)return e.responseKind;let n=(e.method??"GET").toUpperCase();return n==="GET"||n==="HEAD"?"query":"mutation"}var Da=2014,Gi=2004;function Ki(e,n){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!="object")return!1;let i=t.code;return i===n||i===String(n)}function $a(e){return Ki(e,Da)}function Ba(e,n,t){if(!(e>=200&&e<300)&&t.authBearing&&!(e===401&&t.agentKeyAuth)&&Ki(n,Gi))throw new l("auth.token_expired",`The API rejected this credential as invalid. Re-authenticate with ${Pe()} and retry. If that does not help, upgrade the CLI \u2014 the API may have rotated the client credential this build carries.`,{status:e,backend_code:Gi})}var Fa=1e4;async function Ma(e,n=Fa){if(e.status>=200&&e.status<300)return"";try{return await ut(e,dt,{timeoutMs:n})}catch{return""}}function Vi(e,n){if(!(e>=200&&e<300)&&$a(n))throw new l("auth.signature_rejected","The AllScale API rejected this CLI build's request signing key. Download the latest version \u2014 `npm install -g @allscale/cli@latest` \u2014 and retry: retiring an old signing key is how a release is made mandatory. If you are already on the latest version, this build's key row is missing or misprovisioned on the backend \u2014 contact AllScale support. Re-logging in will not help either way; the key ships inside the CLI build itself.",{status:e,body:typeof n=="string"?$i(n):n})}function Ga(e){if(!e||typeof e!="object")return;let n=e;if(typeof n.message=="string")return n.message;if(typeof n.detail=="string")return n.detail;if(Array.isArray(n.detail))return JSON.stringify(n.detail)}var qa=/^\/(api\/)?(v1\/)?public\//;function ft(e,n={}){let t=typeof n.pathHint=="string"?n.pathHint:"",i=t&&qa.test(t),r=t&&pt(t),o=i&&!r&&!n.forceAuth;if(e.token)return new z({apiBase:e.apiBase,tokenStore:ze(),profile:e.profile,profileExplicit:e.profileExplicit,override:{access_token:e.token}});if(o)return new z({apiBase:e.apiBase,tokenStore:ze(),profile:e.profile,profileExplicit:e.profileExplicit});try{return new z({apiBase:e.apiBase,tokenStore:We({insecureStorage:e.insecureStorage}),profile:e.profile,profileExplicit:e.profileExplicit})}catch(a){if(r)return new z({apiBase:e.apiBase,tokenStore:ze(),profile:e.profile,profileExplicit:e.profileExplicit});throw a}}var Hi=[{name:"create_claim_link",kind:"mutation",description:"Create a single App claim link. Returns the pending link, funding address, exact deposit total, and bearer claim URL. The link becomes available after the sender's deposit is confirmed. No claim-back.",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateClaimLinkInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"CreateClaimLinkResult",ofType:null}},deprecated:null},{name:"create_contact",kind:"mutation",description:"create a new contact",args:[{name:"create_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateContactInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"create_payment",kind:"mutation",description:"create a new payment",args:[{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreatePaymentInput",ofType:null}},defaultValue:null},{name:"wallet_ids",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"create_store",kind:"mutation",description:"create store",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateStoreInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"StoreCreateResult",ofType:null}},deprecated:null},{name:"update_payment",kind:"mutation",description:"update an existing payment status by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"UpdatePaymentInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"activities",kind:"query",description:"Get current user's activity list with multi-dimensional filters (type, status, contact, wallet, time range, amount range)",args:[{name:"filter_input",description:null,type:{kind:"INPUT_OBJECT",name:"ActivityFilterInput",ofType:null},defaultValue:"null"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"20"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItemPaginatedResponse",ofType:null}},deprecated:null},{name:"auto_payout_session_status",kind:"query",description:"Return the current merchant auto-payout status, expiry, total/used/remaining USD cap, per-transaction limit, and authorized chain/token pairs. Merchants without an active setup receive provisioned=false with null money/expiry fields and no pairs.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AutoPayoutSessionStatus",ofType:null}},deprecated:null},{name:"business",kind:"query",description:"get one business by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Business",ofType:null}},deprecated:null},{name:"business_contact_by_email",kind:"query",description:"Look up the contact card of the business whose login email is given. Used to fill the invoice header's From: block with the same name/email/phone the web editor shows.",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"BusinessContact",ofType:null}},deprecated:null},{name:"business_transaction_records",kind:"query",description:"get transaction records for business",args:[{name:"direction",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_type",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"business_wallets",kind:"query",description:"List the CALLER'S OWN non-custodial wallets (id, chain, address, coin balances). Takes no business id \u2014 the owner is derived from the authenticated identity, so there is no caller-supplied id to mismatch and no way to read another merchant's wallets. Returns [] when the account has no wallet yet.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"WalletEmbedded",ofType:null}}}},deprecated:null},{name:"claim_link",kind:"query",description:"Get one of the caller's own claim links by id (sender surface). A non-owned or unknown id returns CLAIM_LINK_NOT_AVAILABLE \u2014 no existence leak.",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},deprecated:null},{name:"contact",kind:"query",description:"get one contact by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contact_by_email",kind:"query",description:"get one contact by it's email",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contacts",kind:"query",description:"get multi contacts by owner business id",args:[{name:"owner_business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ContactPaginatedResponse",ofType:null}},deprecated:null},{name:"my_claim_links",kind:"query",description:"List the caller's claim links, newest first. Optional status and link_source filters narrow the results; query_input controls pagination, ordering, and the created_at time range.",args:[{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"link_source",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkPaginatedResponse",ofType:null}},deprecated:null},{name:"my_transactions",kind:"query",description:"get one user's successful transactions by query",args:[{name:"query_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"payment",kind:"query",description:"get one payment by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"payments",kind:"query",description:"All payments by business ID as sender or recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"recipient_payments",kind:"query",description:"Get multiple payments by business ID as recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"sender_payments",kind:"query",description:"Get multiple payments by business ID as sender",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"transaction",kind:"query",description:"get one transaction by id_str",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}},deprecated:null}],ji=[{name:"ActivityFilterInput",kind:"INPUT",description:null,inputFields:[{name:"transaction_types",description:"Filter by transaction types (OR): 1=PAYMENT, 2=REWARD, 3=WITHDRAWAL, 8=CHECKOUT_INTENT_EPHEMERAL, 9=CHECKOUT_INTENT, 10=ON_CHAIN_TX, 11=CHECKOUT_INTENT_EPHEMERAL_REFUND, 13=CHECKOUT_INTENT_EPHEMERAL_NET_INCOME, 14=CLAIM_LINK",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"transaction_statuses",description:"Filter by transaction statuses (OR): 0=NEW, 1=SUCCESS, 2=FAILED, 3=CONFIRMING",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"payment_statuses",description:"Filter by payment statuses (OR): -4=OVERDUE, -1=FAILED, 0=DRAFT, 1=SENT, 2=ACKNOWLEDGED, 3=PROCESSING, 10=PAID",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"withdraw_statuses",description:"Filter by withdraw statuses (OR): -4=CANCELED, -1=FAILED, 1=CREATED, 20=CONFIRMED",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"directions",description:"Filter by transaction direction (OR): 1=INFLOW, -1=OUTFLOW",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"contact_keyword",description:"Fuzzy search by contact name/email or store name. OR relationship with wallet_address.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"wallet_address",description:"Fuzzy search by counterparty wallet address (tx_from/tx_to). OR relationship with contact_keyword.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"start_time",description:"Filter transactions after this time, ISO8601 format (e.g. 2024-01-01T00:00:00.000Z)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"end_time",description:"Filter transactions before this time, ISO8601 format",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"min_amount",description:"Filter transactions with amount >= this value (Decimal string)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"max_amount",description:"Filter transactions with amount <= this value (Decimal string)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"is_claim_link",description:"When true, return only claim-link activity: a receiver's claim (an ON_CHAIN_TX tagged with claim_link_id) OR a sender's CLAIM_LINK row (single claim_link_id / batch claim_link_batch_id). Matched by claim-link linkage presence, NOT transaction_types \u2014 a receiver's claim shares transaction_type=ON_CHAIN_TX(10) with a plain deposit, so it cannot be selected by type alone (bug 6935616).",type:{kind:"SCALAR",name:"Boolean",ofType:null},defaultValue:"null"}]},{name:"ActivityItem",kind:"OBJECT",description:null,fields:[{name:"transaction_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"Transaction record ID"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Transaction amount in cryptocurrency"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Transaction amount in fiat cents"},{name:"transaction_time",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"When the transaction occurred on-chain"},{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Record creation time in UTC"},{name:"transaction_status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Status: 0=NEW, 1=SUCCESS, 2=FAILED, 3=CONFIRMING"},{name:"payment_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Linked payment ID for PAYMENT type transactions"},{name:"transaction_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Type: 1=PAYMENT, 2=REWARD, 3=SEND, 4=SERVICE_FEE, 9=CHECKOUT_INTENT, 10=ON_CHAIN_TX, 14=CLAIM_LINK"},{name:"direction",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Direction: 1=INFLOW (received), -1=OUTFLOW (sent)"},{name:"wallet_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"Counterparty wallet address (sender if INFLOW, recipient if OUTFLOW)"},{name:"tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"On-chain transaction hash"},{name:"tx_block_chain",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Blockchain network type"},{name:"tx_block_number",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Block number of the on-chain transaction"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"User-provided memo or notes"},{name:"payment_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Cryptocurrency type (e.g. USDT)"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Fiat currency type (e.g. USD, CNY)"},{name:"total_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Total fee = network_fee + service_fee"},{name:"network_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"On-chain gas/network fee"},{name:"service_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"AllScale platform service fee"},{name:"counterparty_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Counterparty's business ID if they are an AllScale user"},{name:"claim_link_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Linked claim link ID for CLAIM_LINK type transactions"}]},{name:"ActivityItemPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItem",ofType:null}}}},description:null}]},{name:"AuthorizedPolicyPair",kind:"OBJECT",description:null,fields:[{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Chain identified by its BlockChainType value (for example BASE = 5) \u2014 not the EIP-155 chain id."},{name:"token_symbol",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Stablecoin symbol: USDT or USDC"}]},{name:"AutoPayoutSessionStatus",kind:"OBJECT",description:null,fields:[{name:"provisioned",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"Whether auto-payout setup has been completed for this merchant."},{name:"active",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"True iff provisioned AND the session has not expired (the runtime auto-pay gate)"},{name:"session_expires_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"Session expiry (drives the countdown); null when not provisioned"},{name:"total_cap_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"Unified session total cap in USD (decimal string); null when not provisioned"},{name:"used_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"Cumulative USD spent (reserved + committed) this session (decimal string); populated only for an ACTIVE session, else null"},{name:"remaining_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"max(0, total_cap - used) in USD (decimal string); populated only for an ACTIVE session, else null"},{name:"per_transaction_limit",type:{kind:"SCALAR",name:"String",ofType:null},description:"Unified single-transaction limit (token-unit decimal string, stablecoin $ 1:1) recorded when auto-payout is enabled; null when not provisioned or when recorded entries have different limits. Retained after a session expires, so it still reports what was recorded."},{name:"authorized_pairs",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AuthorizedPolicyPair",ofType:null}}}},description:"The (chain, stable-coin) pairs the merchant authorized when enabling auto-payout; empty when auto-payout was never provisioned. Retained after a session expires, so it still reports what was authorized."},{name:"sponsor_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"Lowercased sponsor address used to validate authorized payouts. Populated whether or not auto-payout is provisioned, so it is readable while enabling; null when unavailable."}]},{name:"Business",kind:"OBJECT",description:null,fields:[{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"user name"},{name:"email",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"email of the user"},{name:"description",type:{kind:"SCALAR",name:"String",ofType:null},description:"description of the user"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the business"},{name:"address",type:{kind:"SCALAR",name:"String",ofType:null},description:"address field for business"},{name:"country",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"country code of business"},{name:"contact_name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"contact name of business"},{name:"contact_avatar",type:{kind:"SCALAR",name:"String",ofType:null},description:"contact avatar url of business"},{name:"contact_phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"contact phone of business"},{name:"avatar",type:{kind:"SCALAR",name:"String",ofType:null},description:"avatar url of business"},{name:"default_currency",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"default currency for business"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the business"},{name:"tax_number",type:{kind:"SCALAR",name:"String",ofType:null},description:"tax id of the business"},{name:"about",type:{kind:"SCALAR",name:"String",ofType:null},description:"about of the business, can be changed by business"},{name:"business_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"business type"},{name:"accepted_stable_coins",type:{kind:"SCALAR",name:"Int",ofType:null},description:"bitflag of accepted stablecoins for invoices (StableCoinFlag)"},{name:"employee_count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"total active employees in the business"}]},{name:"BusinessContact",kind:"OBJECT",description:null,fields:[{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Display name of the business's user account."},{name:"email",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Login email of the business's user account."},{name:"contact_name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Contact person the business presents on its invoices. Preferred over `name` when both are set."},{name:"contact_phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"Contact phone the business presents on its invoices. Null when the business has not set one."}]},{name:"ClaimLink",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim link id"},{name:"business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"sender business that owns the link"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"ClaimLinkStatus lifecycle state"},{name:"amount",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim amount, decimal string in token units"},{name:"token_symbol",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"stablecoin symbol, e.g. USDT / USDC"},{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"BlockChainType the link is locked to"},{name:"sender_display_name",type:{kind:"SCALAR",name:"String",ofType:null},description:"name shown to the receiver (person or Store name)"},{name:"sender_message",type:{kind:"SCALAR",name:"String",ofType:null},description:"optional message shown on the claim page"},{name:"receiver_email",type:{kind:"SCALAR",name:"String",ofType:null},description:"receiver email, if the sender supplied one"},{name:"reference_id",type:{kind:"SCALAR",name:"String",ofType:null},description:"Optional merchant-supplied reference identifier."},{name:"expected_deposit_total",type:{kind:"SCALAR",name:"String",ofType:null},description:"decimal string; the expected POOL balance (principal). The sender's gross outlay is the fee breakdown's total"},{name:"service_fee",type:{kind:"SCALAR",name:"String",ofType:null},description:"AllScale service fee fixed when the claim link is created; null when not applicable."},{name:"network_fee",type:{kind:"SCALAR",name:"String",ofType:null},description:"Network fee fixed when the claim link is created; null when not applicable."},{name:"funded_amount",type:{kind:"SCALAR",name:"String",ofType:null},description:"decimal string; the deposit actually received at the pool wallet"},{name:"funded_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the confirming sender deposit"},{name:"expiry_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC; the resolved claim-window deadline (funded_at + the chosen window, default 14d); None until link_sent"},{name:"claimed_via",type:{kind:"SCALAR",name:"String",ofType:null},description:"how it was claimed: masked receiver email or 0x address"},{name:"claim_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the successful claim"},{name:"refund_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the expiry refund back to the sender"},{name:"refunded_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC when the expiry refund proved on-chain"},{name:"cancel_requested_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC timestamp set when the sender requests cancellation while a claim is in progress. The request stays pending until the in-flight payout resolves: it is cleared if that payout completes (the cancellation is moot and the link is claimed), and retained if the payout did not go through and the link is cancelled and refunded. Null therefore means either no mid-claim cancellation was requested, or one that was resolved by a completed payout."},{name:"claim_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Bearer claim URL returned by create and single-link detail operations. The sender distributes this URL themselves; it is never emailed to the receiver. Null when unavailable, and always null on list operations \u2014 selecting it there returns the field as null rather than omitting it."}]},{name:"ClaimLinkFeeBreakdown",kind:"OBJECT",description:null,fields:[{name:"amount",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim amount the receiver gets, decimal string"},{name:"network_fee",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"gas reserve = gas_shares \xD7 per_transfer_gas, decimal string"},{name:"service_fee",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"AllScale service fee for the chain, decimal string"},{name:"total",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"amount + network_fee + service_fee \u2014 what the sender pays"},{name:"per_transfer_gas",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"one transfer's gas in token units (echoed for audit)"},{name:"gas_shares",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Number of per_transfer_gas shares reserved; currently 2 for a single claim link."}]},{name:"ClaimLinkPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}}}},description:null}]},{name:"CoinBalanceEmbedded",kind:"OBJECT",description:null,fields:[{name:"coin_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Stablecoin held, as the numeric StableCoin value (1 = USDT, 2 = USDC). `wallet list` decorates each balance with the derived `coin_name`."},{name:"balance",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Decimal",ofType:null}},description:"Balance of the coin"}]},{name:"Contact",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"id of the contact"},{name:"owner_business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"owner id of the contact"},{name:"contact_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"contact id if contact is allscale business"},{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"name of the contact"},{name:"binding_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"the way of binding an allscale business id to the contact, by email matching(1) or scan qrcode(2), etc."},{name:"email",type:{kind:"SCALAR",name:"String",ofType:null},description:"email of the contact"},{name:"evm_wallet_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"evm wallet address of the contact"},{name:"tax_number",type:{kind:"SCALAR",name:"String",ofType:null},description:"tax number of the contact"},{name:"address",type:{kind:"SCALAR",name:"String",ofType:null},description:"address of the contact"},{name:"phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"phone number of the contact"},{name:"last_payment_created_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"last payment date of the contact"},{name:"last_paid_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"last successful pay date"},{name:"description",type:{kind:"SCALAR",name:"String",ofType:null},description:"Free-form description of the contact."},{name:"is_favourite",type:{kind:"SCALAR",name:"Boolean",ofType:null},description:"is favourite or not"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the contact"}]},{name:"ContactPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}}}},description:null}]},{name:"CreateClaimLinkInput",kind:"INPUT",description:null,inputFields:[{name:"amount",description:"claim amount, decimal string in token units (e.g. '10.5')",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"token_symbol",description:"stablecoin symbol: 'USDT' or 'USDC'",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:"BlockChainType value the link is locked to (EVM only)",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"per_transfer_gas",description:"one ERC-20 transfer's gas in TOKEN units (decimal string); from the App's withdraw estimate",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"receiver_email",description:"optional receiver email \u2014 a SENDER-SIDE LABEL ONLY, recording who the link is meant for. AllScale does NOT email the receiver (no invite, no expiry reminder, no resend); the sender must distribute `claim_url` themselves.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_display_name",description:"name shown to the receiver (person or Store name)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_message",description:"optional message shown on the claim page (<= 200 chars)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"idempotency_key",description:"optional client retry-safety token; a retried create with the same key returns the existing link instead of a duplicate",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"claim_window_seconds",description:"Optional positive claim-window duration in seconds. Defaults to 14 days. The window starts when funding is confirmed; after it expires, unclaimed funds are returned to the sender.",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"CreateClaimLinkResult",kind:"OBJECT",description:null,fields:[{name:"claim_link",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},description:"the newly created link (pending_deposit)"},{name:"claim_token",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Bearer claim token returned only when the claim link is created and never available again. Capture and store it securely immediately; it preserves claim authority when claim_url is unavailable."},{name:"claim_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Bearer claim URL; null when no claim-page URL is configured."},{name:"pool_wallet_address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"ERC-4337 address the sender funds"},{name:"expected_deposit_total",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"the expected POOL balance (principal), decimal string; the sender's gross outlay is the fee breakdown's total"},{name:"fees",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkFeeBreakdown",ofType:null}},description:"the frozen fee breakdown"}]},{name:"CreateContactInput",kind:"INPUT",description:null,inputFields:[{name:"owner_business_id",description:"owner id of the contact",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"name",description:"name of the contact",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"email",description:"email of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"evm_wallet_address",description:"evm wallet address of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"address",description:"address of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"phone",description:"phone number of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"tax_number",description:"tax number of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"description",description:"Free-form description of the contact.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"binding_type",description:"binding type of the contact",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"CreatePaymentInput",kind:"INPUT",description:null,inputFields:[{name:"sender_contact_id",description:"contact id of the payer/sender",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"payment_type",description:"payment type of the payment",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"1"},{name:"accepted_stable_coins",description:"optional per-invoice bitflag (StableCoinFlag) overriding the recipient business's accepted_stable_coins setting",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"payment_extra_info",description:"payment extra info of the payment, JSON object string",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"currency",description:"currency of the payment, only if the payment_type is CURRENCY",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"amount_cents",description:"amount of the payment in cents",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"amount_coins",description:"amount of the payment in coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},defaultValue:"null"},{name:"html_template",description:"HTML template for the invoice",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"memo",description:"memo of the payment",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"tax_id",description:"optional taxpayer identification for the invoice",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"due_datetime",description:"datetime the payment is due",type:{kind:"SCALAR",name:"DateTime",ofType:null},defaultValue:"null"},{name:"wallets",description:"list of wallets address",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"PlainWalletEmbeddedInput",ofType:null}}}},defaultValue:null}]},{name:"CreateStoreInput",kind:"INPUT",description:null,inputFields:[{name:"name",description:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"logo_url",description:"logo url",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:null},{name:"business_id",description:"pay account business id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"type",description:"type of the store",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"1"},{name:"default_timeout_seconds",description:"default timeout seconds for checkout intents",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"3600"},{name:"swidge_enabled",description:"whether Swidge cross-chain checkout is enabled for this store",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"true"},{name:"claim_link_claim_notify_enabled",description:"Whether AllScale sends merchant claim-notification emails for this store; defaults to false.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"false"},{name:"description",description:"description",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"scopes",description:"permission scopes",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},defaultValue:'["*"]'},{name:"ip_allowlist",description:"allowed IPs/CIDRs",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},defaultValue:"[]"},{name:"is_sandbox",description:"Whether to create the store in sandbox mode.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"true"},{name:"rate_limit_per_minute",description:"Optional request-per-minute limit; defaults to 300, and 0 uses the platform default.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"300"},{name:"replay_window_seconds",description:"override replay window seconds",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_webhook",description:"transaction webhook url",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"claim_link_webhook_url",description:"Merchant webhook URL for claim-link terminal-state callbacks; distinct from transaction_webhook.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"redirect_url",description:"Redirect URL used after payment completes.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"fee_rate",description:"fee rate",type:{kind:"SCALAR",name:"Decimal",ofType:null},defaultValue:"null"},{name:"accepted_stable_coins",description:"bitflag of accepted stablecoins for checkout (StableCoinFlag); null inherits from business",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"Payment",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the payment"},{name:"recipient_business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"business id of the payee/recipient"},{name:"sender_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id of the payer/sender"},{name:"sender_contact_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"contact id of the payer/sender"},{name:"payment_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"payment type of the payment"},{name:"accepted_stable_coins",type:{kind:"SCALAR",name:"Int",ofType:null},description:"bitflag of stablecoins accepted for this payment (StableCoinFlag). None on payments created before the multi-coin rollout."},{name:"payment_extra_info",type:{kind:"SCALAR",name:"String",ofType:null},description:"payment extra info of the payment, JSON object string"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"currency of the payment, only if the payment_type is CURRENCY"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the payment"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"amount of the payment in cents"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"amount of the payment in coins"},{name:"invoice_url",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"invoice url of the payment"},{name:"invoice_visible_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"invoice visible id of the pdf"},{name:"tax_id",type:{kind:"SCALAR",name:"String",ofType:null},description:"optional taxpayer identification for the invoice"},{name:"error_message",type:{kind:"SCALAR",name:"String",ofType:null},description:"error message of the payment if status is failed"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"memo of the payment"},{name:"due_datetime",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"datetime the payment is due"},{name:"display_amount",type:{kind:"SCALAR",name:"String",ofType:null},description:"display amount of the payment"},{name:"encrypted_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Opaque payment identifier used in public payment links."}]},{name:"PaymentPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}}}},description:null}]},{name:"PlainWalletEmbeddedInput",kind:"INPUT",description:null,inputFields:[{name:"id_str",description:"Unique identifier for the wallet",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:"Blockchain type of the address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"address",description:"Blockchain address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}]},{name:"QueryInput",kind:"INPUT",description:null,inputFields:[{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"order_by",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"},{name:"raw_filter_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:'"{}"'},{name:"created_at_lte",description:null,type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"created_at_gte",description:null,type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"}]},{name:"Store",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"Unique store identifier."},{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"name"},{name:"type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"type of the store"},{name:"scopes",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},description:"permission scopes"},{name:"is_sandbox",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"Whether this store uses sandbox mode."},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the store"},{name:"transaction_webhook",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction webhook url"},{name:"claim_link_webhook_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Merchant webhook URL for claim-link terminal-state callbacks; distinct from transaction_webhook."},{name:"redirect_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Redirect URL used after payment completes."}]},{name:"StoreCreateResult",kind:"OBJECT",description:null,fields:[{name:"store",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Store",ofType:null}},description:"store"},{name:"api_secret",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Store API secret returned only when the store is created and never available again. Capture and store it securely immediately."}]},{name:"Transaction",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the transaction record"},{name:"owner_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"owner user type of the record"},{name:"owner_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id that owns this transaction record"},{name:"owner_employee_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"employee id that owns this transaction record"},{name:"transaction_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"type of the transaction"},{name:"direction",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"direction of the transaction"},{name:"reference_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"reference type of the related record"},{name:"payment_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"payment id when reference_type is PAYMENT"},{name:"counterparty_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id of the counterparty"},{name:"counterparty_employee_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"employee id of the counterparty"},{name:"counterparty_name",type:{kind:"SCALAR",name:"String",ofType:null},description:"name of the counterparty"},{name:"payment_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"payment type if this is a payment transaction"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"currency of the transaction"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"amount in cents"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"amount in coins"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the transaction"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"memo of the transaction"},{name:"transaction_time",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"actual transaction time"},{name:"tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"hash of the transaction"},{name:"tx_block_chain",type:{kind:"SCALAR",name:"Int",ofType:null},description:"block chain of the transaction"},{name:"tx_from",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction sender address"},{name:"tx_to",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction receiver address"},{name:"tx_block_number",type:{kind:"SCALAR",name:"Int",ofType:null},description:"block number of the transaction"},{name:"total_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Total fee (network_fee + service_fee)"},{name:"network_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Network/gas fee"},{name:"service_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Allscale service fee (0.03%)"}]},{name:"TransactionPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}}}},description:null}]},{name:"UpdatePaymentInput",kind:"INPUT",description:null,inputFields:[{name:"memo",description:"memo of the payment",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_business_id",description:"sender business id of the payer",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"due_datetime",description:"new payment deadline for an OVERDUE invoice. Only an overdue invoice may be extended, and only FORWARD. Extending past now also revives the invoice (back to SENT/ACKNOWLEDGED) so buyers can pay again.",type:{kind:"SCALAR",name:"DateTime",ofType:null},defaultValue:"null"}]},{name:"WalletEmbedded",kind:"OBJECT",description:null,fields:[{name:"id_str",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"wallet id"},{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Chain the wallet lives on, as the numeric BlockChainType value (NOT a name). `wallet list` decorates each wallet with the derived `chain_name` and `eip155_chain_id`."},{name:"address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"wallet address"},{name:"coin_balances",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"OBJECT",name:"CoinBalanceEmbedded",ofType:null}}},description:"wallet balance"}]}];var nn=new Set(["SCALAR","ENUM"]),Ya=new Set(["password","password_hash","totp_secret","credential","credentials","private_key","encryption_key"]),Ka=[/(^|_)password(_|$)/i,/(^|_)secret(_|$)/i,/(^|_)token(_|$)/i,/(^|_)api[_-]?key(_|$)/i,/(^|_)signing[_-]?key(_|$)/i,/(^|_)private[_-]?key(_|$)/i,/(^|_)credential(_|$)/i],Va=new Set(["CreateClaimLinkResult.claim_token","StoreCreateResult.api_secret"]),Ha=new Map([["StoreCreateResult.store",["id","name"]],["CreateClaimLinkResult.claim_link",["id","token_symbol","status"]]]),ja=new Set(["token_symbol"]),Ja=new Set;function mt(e,n){return Ja.has(`${e}.${n}`)}function ht(e){return ja.has(e.toLowerCase())?!1:Ya.has(e)?!0:Ka.some(n=>n.test(e))}function Wa(e,n){return Va.has(`${e}.${n}`)}function yt(e){return e.kind==="NON_NULL"&&e.ofType?`${yt(e.ofType)}!`:e.kind==="LIST"&&e.ofType?`[${yt(e.ofType)}]`:e.name??"Unknown"}function Ce(e){let n=e;for(;n&&n.ofType;)n=n.ofType;return!n||!n.name?null:{kind:n.kind,name:n.name}}function za(e,n){let t=n.find(a=>a.name===e);if(!t||t.kind==="SCALAR"||t.kind==="ENUM")return"";if(t.kind==="UNION")return"__typename";let i=t.fields??[];if(i.length===0)return"";let r=[],o=!1;for(let a of i){let s=Ce(a.type);if(!s)continue;if(nn.has(s.kind)){if(ht(a.name)&&!Wa(e,a.name)||mt(e,a.name))continue;r.push(a.name);continue}let c=Ha.get(`${e}.${a.name}`);if(c){let u=n.find(m=>m.name===s.name),p=new Set((u?.fields??[]).filter(m=>{let A=Ce(m.type);return A!==null&&nn.has(A.kind)&&!ht(m.name)}).map(m=>m.name)),f=c.filter(m=>!p.has(m));if(f.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${f.join(", ")}] that are not selectable scalars on ${s.name}; fix the entry or the public registry.`);let y=c.filter(m=>mt(s.name,m));if(y.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${y.join(", ")}] that DEFAULT_SELECTION_EXCLUSIONS keeps out of default selections on ${s.name}; drop the field from the nested entry, or remove the exclusion if it is no longer true.`);r.push(`${a.name} { ${c.join(" ")} }`);continue}if(!o&&a.name==="items"&&a.type.kind==="NON_NULL"&&a.type.ofType?.kind==="LIST"){let u=Xa(a.type)?.name;if(u){let p=Za(u,n);p&&r.push(`items { ${p} }`),o=!0}}}return r.length>0?r.join(" "):"__typename"}function Xa(e){return Ce(e)}function Za(e,n){let t=n.find(o=>o.name===e);if(!t||t.kind==="UNION")return"__typename";let i=t.fields??[],r=[];for(let o of i){let a=Ce(o.type);if(a&&nn.has(a.kind)){if(ht(o.name)||mt(e,o.name))continue;r.push(o.name)}}return r.length>0?r.join(" "):"__typename"}function Ji(e,n,t){let i=Qa(e.name),r=e.args.map(p=>{let f=yt(p.type);return p.defaultValue!==null&&p.defaultValue!==void 0?`$${p.name}: ${f} = ${p.defaultValue}`:`$${p.name}: ${f}`}).join(", "),o=e.args.map(p=>`${p.name}: $${p.name}`).join(", "),a=r.length>0?`${e.kind} ${i}(${r})`:`${e.kind} ${i}`,s=o.length>0?`${e.name}(${o})`:e.name,c=Ce(e.returnType),u;if(c&&nn.has(c.kind))u=s;else{let p=t&&t.trim().length>0?t.trim():c&&za(c.name,n)||"__typename";u=`${s} { ${p} }`}return`${a} { ${u} }`}function Wi(e,n){let i=e.args.filter(r=>r.type.kind==="NON_NULL"&&r.defaultValue===null).map(r=>r.name).filter(r=>!(r in n));return i.length===0?{ok:!0}:{ok:!1,missing:i}}function zi(e,n,t){return e.find(i=>i.kind===n&&i.name===t)??null}function Xi(e){if(!e||typeof e!="object")return!1;let n=e.errors;return Array.isArray(n)&&n.length>0}function Zi(e,n=3){let t=e.errors;return!Array.isArray(t)||t.length===0?"":t.slice(0,n).map(i=>typeof i=="object"&&i!==null&&typeof i.message=="string"?i.message:JSON.stringify(i)).join("; ")}function Qa(e){return e.replace(/[^_0-9A-Za-z]/g,"_")}var es=new Set;var ns=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","claim_link:read_only","claim_link:all","transaction:read_only","transaction:all","store:read_only","store:all","wallet:read_only","wallet:all"]),gt=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","transaction:read_only","wallet:read_only","wallet:all","claim_link:read_only","claim_link:all","store:read_only","store:all"]),_t=new Set(["payroll","admin:user","admin:org","admin:audit"]);function tn(e){let n=e.lastIndexOf(":");return n===-1?e:e.slice(0,n)}function rn(e,n){if(e===n)return!0;let t=":read_only";return n.endsWith(t)&&e===`${n.slice(0,-t.length)}:all`}var ts=new Set(["cli_op:all"]),is=new Set([...ts].map(tn));var Mc=new Set([...[...ns,...gt,...es].map(tn),..._t,...is]);var rs={payments:"invoice:read_only",payment:"invoice:read_only",sender_payments:"invoice:read_only",recipient_payments:"invoice:read_only",business_contact_by_email:"invoice:read_only",create_payment:"invoice:all",update_payment:"invoice:all",contact_by_email:"contact:read_only",contact:"contact:read_only",contacts:"contact:read_only",create_contact:"contact:all",transaction:"transaction:read_only",my_transactions:"transaction:read_only",business_transaction_records:"transaction:read_only",activities:"transaction:read_only",business_wallets:"wallet:read_only",business_invoice:"payroll:read_only",auto_payout_session_status:"store:read_only",create_store:"store:all",my_claim_links:"claim_link:read_only",claim_link:"claim_link:read_only",claim_link_fee_preview:"claim_link:read_only",claim_link_limits:"claim_link:read_only",create_claim_link:"claim_link:all",claim_link_funding_by_idempotency_key:"claim_link:all"},os={business:"the broad `business` query is default-denied for agent keys by design \u2014 no scope grants it, because allowing the entry point would expose every nested field of the Business type"},as=/API key scope not granted:\s*requires\s+(.+?),\s*key has\s+(.+?)\.?\s*$/i,ss=/is not available to API keys/i,Qi=/^[a-z_]+(?::[a-z_]+)*:[a-z_]+$/;function er(e){if(typeof e!="string")return;let n=as.exec(e);if(!n)return;let t=n[1].trim(),i=n[2].trim(),r=ss.test(t),o=!r&&Qi.test(t)?t:void 0,a;if(i.toLowerCase()==="none")a=[];else{let s=i.split(",").map(c=>c.trim()).filter(c=>Qi.test(c));a=s.length>0?s:void 0}if(!(o===void 0&&!r))return{required:o,granted:a,notAvailableToKeys:r}}function nr(e){let n=os[e];if(n!==void 0)return{ungrantableReason:n};let t=rs[e];if(t!==void 0)return{scope:t}}function tr(e){if(_t.has(tn(e)))return{kind:"ungrantable"};for(let n of gt)if(rn(n,e))return{kind:"approval_screen"};return{kind:"otp_login_only"}}var ls=new Set([8100]),cs=new Set([...ls,3e3,3200,3300,3400,3500,3600,4e3,4100,4200,4300,4400,4600,4700,4800,4900,4901,5e3,5200,5300,5400,5500,5600,6050,8300,8301,8302,8306]);function St(e,n){let t=rr(e),i={graphql_error_count:ds(e.errors),...t===void 0?{}:{backend_code:t}};if(t===2102)throw us(e,n,i);if(t===429)throw new l("rate_limited",`GraphQL ${n.kind} '${n.operationName}' was rate limited. Retry after a backoff.`,i);if(t===1002)throw new l("auth.permission_denied",`The signed-in account is not permitted to perform GraphQL ${n.kind} '${n.operationName}'. This is a role or ownership restriction, not a missing agent-key scope \u2014 re-authorizing will not grant it.`,i);if(t!==void 0&&cs.has(t))throw new l("not_found",`GraphQL ${n.kind} '${n.operationName}' could not find the requested resource.`,i);if(Xi(e))throw new l("input.invalid",`GraphQL ${n.kind} '${n.operationName}' returned errors: ${Zi(e)}`,i);if(t!==void 0)throw new l("input.invalid",`GraphQL ${n.kind} '${n.operationName}' failed with backend code ${t}.`,i)}function rr(e){let n=ir(e.code);if(n!==void 0)return n;if(Array.isArray(e.errors))for(let t of e.errors){if(!t||typeof t!="object")continue;let i=t.extensions;if(!i||typeof i!="object")continue;let r=ir(i.code);if(r!==void 0)return r}}function ir(e){if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return e;if(typeof e=="string"&&/^\d+$/.test(e)){let n=Number(e);if(Number.isSafeInteger(n)&&n>0)return n}}function ds(e){return Array.isArray(e)?e.length:e==null?0:1}function us(e,n,t){let i=`GraphQL ${n.kind} '${n.operationName}'`,r={...t,operation:n.operationName},o=er(ps(e,rr(e))),a=nr(n.operationName),s=o?.notAvailableToKeys===!0,c=o?.required??a?.scope,u=o?.granted,p=u===void 0?"":` This key holds ${u.length>0?u.join(", "):"no scopes"}.`;if(s||a?.ungrantableReason!==void 0){let f=a?.ungrantableReason!==void 0?`: ${a.ungrantableReason}`:"";return new l("auth.permission_denied",`${i} is not available to agent keys${f}. Re-authorizing will NOT help \u2014 no scope grants it.${p} Use a command that does not need it, or perform this action in the AllScale dashboard.`,{...r,missing_scopes:[],...u===void 0?{}:{granted_scopes:u},ungrantable:!0})}if(c!==void 0){let f=tr(c),y=f.kind==="ungrantable"?`\`${c}\` cannot be granted to any key (the backend clips this category to nothing), so re-authorizing will NOT help.`:f.kind==="approval_screen"?`Re-run \`allscale device-login\` and enable it on the approval screen, or \`${G()}\` with \`--scopes ${c}\`.`:`The browser approval screen does not offer \`${c}\`, so \`device-login\` cannot grant it \u2014 use \`${G()}\` with \`--scopes ${c}\`.`;return new l("auth.permission_denied",`The current agent key lacks \`${c}\`, required by ${i}.${p} ${y}`,{...r,missing_scopes:[c],...u===void 0?{}:{granted_scopes:u},...f.kind==="ungrantable"?{ungrantable:!0}:{}})}return new l("auth.permission_denied",`The current agent key does not have the scope required by ${i}.${p} Re-run \`allscale device-login\` (or \`${G()}\`) and grant the required scope.`,r)}function ps(e,n){let t=e.errors;if(typeof t=="string")return t;if(!Array.isArray(t))return"";let i=r=>{if(r===null||typeof r!="object")return;let o=r.message;return typeof o=="string"?o:void 0};if(n!==void 0)for(let r of t){if(r===null||typeof r!="object")continue;let o=r.extensions;if(!o||typeof o!="object")continue;let a=o.code;if(a===n||typeof a=="string"&&Number(a)===n){let c=i(r);if(c!==void 0)return c}}for(let r of t){let o=i(r);if(o!==void 0)return o}return""}async function v(e,n,t,i,r={}){let o=zi(Hi,n,t);if(!o)throw new l("input.invalid",`No ${n} named '${t}' in the schema. Run \`allscale operations --kind ${n}\` to list options.`);let a=Wi(o,i);if(!a.ok)throw new l("input.invalid",`Missing required variables for ${t}: ${a.missing.join(", ")}`,{required:a.missing});let s=Ji(o,ji,r.selection);return fs(e,{...r,kind:n,operationName:o.name,document:s,variables:i})}async function fs(e,n){n.showDoc&&process.stderr.write(`${n.document}
|
|
17
|
-
`);let t=ft(e),i=n.path??"/api/secure/graphql",r=await t.request({method:"POST",path:i,responseKind:n.kind,body:{query:n.document,...Object.keys(n.variables).length>0?{variables:n.variables}:{},operationName:n.operationName}});St(r,{kind:n.kind,operationName:n.operationName});let o=r.data?.[n.operationName];return o===void 0?null:o}async function P(e){if(e.token)return{kind:"override",accessToken:e.token};let t=await
|
|
18
|
-
`);return}if(t.toLowerCase()!==n.toLowerCase())throw new l("auth.permission_denied",`--business-id '${n}' is not the business you are signed in as. This command always acts as the authenticated business, so a different business id cannot be used. Omit the flag, or sign in as that business.`)}function
|
|
19
|
-
Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new l("backend.internal",`contact_by_email returned an unexpected shape for "${n}".`,{received:i});return r}async function
|
|
20
|
-
Note: --auto-create-contact will not work with the current agent key either \u2014 it was minted without the ${le} scope that create_contact requires. `+
|
|
21
|
-
`),o;let a=
|
|
13
|
+
To move to production, run: allscale device-login --api-base ${Se}
|
|
14
|
+
`}var Y=L(require("fs")),oi=L(require("os")),Gn=L(require("path")),Yn=L(require("@iarna/toml"));var bo=".allscale",Lo="config.toml";function Kn(){return Gn.join(oi.homedir(),bo)}function Eo(){return Gn.join(Kn(),Lo)}function Me(){let e=Eo();if(!Y.existsSync(e))return{};let n=Y.readFileSync(e,"utf-8");try{return Yn.parse(n)}catch(t){throw new l("internal",`Failed to parse ${e}: ${t.message}`)}}function ai(e){return Object.keys(e.profile??{}).sort()}function si(e,n){return e.profile?.[n]}function li(e,n,t){let i=n??t??e.default??"default";if(i.includes(":"))throw new l("input.invalid",`Invalid profile name '${i}': ':' is reserved as the keychain namespace separator \u2014 pick a name without ':'.`);return i}function K(e){if(!wn(e))throw new l("input.invalid",`Refusing to send credentials to API base ${O(e)}. `+kn)}function qe(e,n){K(e);let t=G(e),i=typeof n=="string"?G(n):null;if(t&&i===t)return;let r=typeof n=="string"?O(n):"<missing origin binding>";throw new l("input.invalid",`Refusing to send stored credentials: API base ${O(e)} does not match their bound origin ${r}. Re-login against the intended API base before retrying.`)}function ci(e,n){let t=G(e),i=G(n);if(!(t&&i===t))throw new l("input.invalid",`Refusing API request to ${O(n)} because it is outside the configured API origin ${O(e)}.`)}function Ge(e){let n=Co(e);if(n)throw new l("input.invalid",n.message)}function No(){let e=he();if(e===void 0)return;let n=ye();return n.length>0?{endpoints:n.map(t=>t.base),fromPairs:!0}:{endpoints:[e],fromPairs:!1}}function Co(e){let n=No();if(n===void 0||M(e))return;let{endpoints:t,fromPairs:i}=n,r=G(e),o=t.map(s=>G(s)).filter(s=>s!==null);if(r!==null&&o.includes(r))return;let a=t.map(s=>O(s)).join(", ");return{message:i?`Refusing to send to ${O(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 ${O(e)} \u2014 this build only signs for ${a}. Re-login against this build's environment, or use a build for that one.`}}var Io=require("@noble/hashes/sha3");var vo=new Set([1,2,3,5,6,7,8,9]);function jn(e){return vo.has(e)}var di=["USDT","USDC"];var ql=new Set([`0x${"0".repeat(40)}`,`0x${"0".repeat(36)}dead`]);var ui=new Map([[1,"USDT"],[2,"USDC"],[3,"BUSD"],[4,"DAI"],[5,"TUSD"],[6,"PAX"],[7,"GUSD"],[8,"USTC"],[9,"FRAX"],[10,"EURS"]]);function Vn(e){return ui.get(e)??`Coin ${e}`}function pi(){return[...ui.values()]}var Oo="unknown_otp_id",Ro="invalid_code",xo="expired_code";function Po(e){return`'${e.replace(/'/g,"'\\''")}'`}function fi(e){return`Run \`allscale otp-send --email ${Po(e)}\` first \u2014 that command does report a missing account \u2014 then retry with the otp_id it returns and a fresh code.`}var Uo=new Map([[Oo,(e,n)=>`${e}: this environment never issued the --otp-id you passed for '${n}', 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. ${fi(n)}`],[Ro,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.`],[xo,(e,n,t)=>t?`${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. ${fi(n)}`]]);var mi=[...Uo.keys()];var w=require("@oclif/core"),we=class e extends R.Command{static enableJsonFlag=!0;static legacyStagingNoticeShown=!1;static emitsOwnOutput=!1;static requiresEscapeHatch=!1;static requiresInput=!1;static isLocalOnly=!1;static baseFlags={profile:R.Flags.string({description:"Named profile from ~/.allscale/config.toml",helpGroup:"GLOBAL"}),token:R.Flags.string({description:"Override the access token for this invocation (precedence: --token > ALLSCALE_TOKEN > --profile)",helpGroup:"GLOBAL",hidden:ee()==="public"}),"api-base":R.Flags.string({description:Sn,helpGroup:"GLOBAL",hidden:ee()==="public"}),"insecure-storage":R.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{$n(this.jsonEnabled()),Fn(),k({type:"session-start",command:this.id??"",argv:Mn(this.argv)});let n=this.constructor;if(ee()==="public"){if(this.argv.some(o=>o==="--token"||o.startsWith("--token=")))throw new l("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 l("input.invalid","--api-base is not supported in this build; it always talks to its bound AllScale environment.");if(!n.isLocalOnly&&ke()!==void 0)throw new l("input.invalid","ALLSCALE_API_BASE is not supported in this build; unset it \u2014 this build always talks to its bound AllScale environment.")}let t=Zt(this.jsonEnabled()),i=this.argv.length===0&&!t&&Ko(n)?this.config.findCommand(this.id??""):void 0;if(i){_e();let o=await(0,R.loadHelpClass)(this.config),a=this.config.pjson.oclif?.helpOptions??this.config.pjson.helpOptions;await new o(this.config,a).showCommandHelp(i,this.config.topics);return}if(n.requiresEscapeHatch&&!ii())throw this.argv.length>0&&await this.parse(),new l("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 r=await this.runCommand();return k({type:"command-end",ok:!0}),_e(),n.emitsOwnOutput?void 0:(this.jsonEnabled()||Gt(r),{data:r})}catch(n){let t=qt(n);Qt({code:t.code,message:t.message,exitCode:t.exitCode}),this.emitError(t),process.exitCode=t.exitCode;return}finally{$n(!1)}}resolveSessionApiBaseChain(n){let t=Me(),i=n.profile??void 0,r=n["api-base"]??void 0,o=i!==void 0||qn()!==void 0,a=li(t,i,qn()),s=si(t,a),c=ee()==="public"&&ke()!==void 0,u=r??(c?void 0:ke()),p=u??s?.api_base??Se,f=ri({resolvedApiBase:p,fromExplicitOverride:u!==void 0,profileApiBase:s?.api_base,profileApiBaseSource:s?.api_base_source});return f&&!e.legacyStagingNoticeShown&&(e.legacyStagingNoticeShown=!0,ie({event:"legacy_staging_profile",api_base:p,profile:a},f)),{apiBase:p,explicitApiBase:u,envApiBaseIgnored:c,profileApiBase:s?.api_base,profile:a,profileExplicit:o}}resolveSessionApiBaseForPayoutDerivation(n){let{apiBase:t}=this.resolveSessionApiBaseChain(n);return this.constructor.isLocalOnly||K(t),t}resolveContext(n){if(ee()==="public"){if(n.token!==void 0)throw new l("input.invalid","--token is not supported in this build. Set the ALLSCALE_TOKEN environment variable instead (it does not leak into shell history or process listings).");if(n["api-base"]!==void 0)throw new l("input.invalid","--api-base is not supported in this build; it always talks to its bound AllScale environment.");if(!this.constructor.isLocalOnly&&ke()!==void 0)throw new l("input.invalid","ALLSCALE_API_BASE is not supported in this build; unset it \u2014 this build always talks to its bound AllScale environment.")}let t=n.token??void 0,i=!!n["insecure-storage"],{apiBase:r,explicitApiBase:o,envApiBaseIgnored:a,profile:s,profileApiBase:c,profileExplicit:u}=this.resolveSessionApiBaseChain(n);return this.constructor.isLocalOnly||(K(r),Ge(r)),{apiBase:r,profile:s,token:t??ei(),insecureStorage:i||ni(),apiBaseSource:o!==void 0?"explicit":c!==void 0?"profile":"default",profileExplicit:u,envApiBaseIgnored:a}}emitError(n){process.stderr.write(`${Yo(n)}
|
|
15
|
+
`)}};var Do=/_(removed|cleared|count|total)$/i;function $o(e,n){return typeof n=="number"&&Do.test(e)}var Bo=new Set(di);function Fo(e,n){return e==="token_symbol"&&typeof n=="string"&&Bo.has(n)}var Mo=new Set(mi);function qo(e,n){return e==="otp_reason"&&typeof n=="string"&&Mo.has(n)}var Ye=100;function Ke(e,n=0){if(n>8)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,Ye),i=t.map(r=>Ke(r,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null),i=Object.entries(e);for(let[r,o]of i.slice(0,Ye))t[r]=De(r)&&!$o(r,o)&&!Fo(r,o)&&!qo(r,o)?"<redacted>":Ke(o,n+1);if(i.length>Ye){let r="<truncated>";for(;r in t;)r=`<${r}>`;t[r]=`${i.length-Ye} more keys`}return t}if(typeof e=="string"){let t=Go(e);return t!==void 0?T(JSON.stringify(Ke(t,n+1))):T(e)}return e}function Go(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function Yo(e){let n=Ht()?void 0:2,t=Ke(e.toJSON()),i=JSON.stringify(t,null,n);return Buffer.byteLength(i,"utf8")+1<=65536?i:JSON.stringify({error:{code:e.code,message:T(e.message),details:{output_truncated:!0,max_output_bytes:65536}}},null,n)}function Ko(e){if(e.requiresInput===!0)return!0;let n=r=>typeof r=="object"&&r!==null&&r.required===!0,t=e.flags??{},i=e.args??{};return Object.values(t).some(r=>n(r))||Object.values(i).some(r=>n(r))}var Ni=L(require("path"));var Jn=require("crypto"),d=L(require("fs")),A=L(require("path"));var je=1024*1024,jo=5e3,Vo=20,Ho=3e4,Hn=4096,Wo=new Int32Array(new SharedArrayBuffer(4)),Te=class extends Error{constructor(){super("credential-store data file must not have hard links"),this.name="PrivateCredentialFileHardLinkError"}};function Ve(e){return e instanceof Te}var E=class extends Error{constructor(){super("credential-store lock changed during concurrent inspection")}},Jo=null;function V(){return new l("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 He(){return(Jo??process.platform)!=="win32"}function wi(){if(!He())throw V()}function Ti(e){try{return d.default.lstatSync(e),!1}catch(n){if(!_(n,"ENOENT"))throw n}try{let n=d.default.lstatSync(A.dirname(e));return!n.isSymbolicLink()&&n.isDirectory()}catch(n){if(_(n,"ENOENT"))return!0;throw n}}function _(e,n){return typeof e=="object"&&e!==null&&e.code===n}function be(e,n){if(typeof process.geteuid=="function"&&e.uid!==process.geteuid())throw new Error(`${n} is not owned by the current effective user`)}function Le(e,n){return e.dev===n.dev&&e.ino===n.ino}function zo(e){Atomics.wait(Wo,0,0,e)}function bi(e){try{return process.kill(e,0),!0}catch(n){return!_(n,"ESRCH")}}function Xo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hi(e,n){let t=A.dirname(e);n&&d.default.mkdirSync(t,{recursive:!0,mode:448});let i;try{i=d.default.lstatSync(t)}catch(o){if(!n&&_(o,"ENOENT"))return!1;throw o}if(i.isSymbolicLink()||!i.isDirectory())throw new Error("credential-store parent must be a real directory");if(process.platform==="win32")return!0;let r=null;try{r=d.default.openSync(t,d.default.constants.O_RDONLY|(d.default.constants.O_DIRECTORY??0)|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0));let o=d.default.fstatSync(r),a=d.default.lstatSync(t);if(!o.isDirectory()||a.isSymbolicLink()||!a.isDirectory()||!Le(o,a))throw new Error("credential-store parent changed while it was being inspected");be(o,"credential-store parent");let s=o;if((o.mode&63)!==0&&A.basename(t)===".allscale"&&(d.default.fchmodSync(r,448),s=d.default.fstatSync(r)),(s.mode&63)!==0)throw new Error("credential-store parent must not grant group or other permissions")}finally{r!==null&&d.default.closeSync(r)}return!0}function x(e,n,t,i={}){if(!t.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");let r;try{r=d.default.lstatSync(e)}catch(o){throw i.retryOnPathChange&&_(o,"ENOENT")?new E:o}if(!Le(t,r))throw i.retryOnPathChange?new E:new Error("credential-store target changed while it was being opened or is not a regular file");if(r.isSymbolicLink()||!r.isFile())throw new Error("credential-store target changed while it was being opened or is not a regular file");if(!i.allowMultipleLinks&&(t.nlink!==1||r.nlink!==1))throw new Te;if(be(t,"credential-store file"),process.platform!=="win32"){d.default.fchmodSync(n,384);let o=d.default.fstatSync(n);if((o.mode&63)!==0)throw new Error("credential-store file could not be made owner-only");return o}return t}function Zo(e,n){if(n.size>je)throw new Error("credential-store file exceeds the maximum supported size");let t=Buffer.alloc(je+1),i=0;for(;i<t.length;){let r=d.default.readSync(e,t,i,t.length-i,null);if(r===0)break;i+=r}if(i>je)throw new Error("credential-store file exceeds the maximum supported size");return t.subarray(0,i).toString("utf8")}function yi(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(r){if(_(r,"ENOENT"))try{if(d.default.lstatSync(e).isSymbolicLink())throw new Error("credential-store target must not be a symbolic link")}catch(o){if(_(o,"ENOENT"))return null;throw o}throw r}let t=d.default.fstatSync(n),i=x(e,n,t);return Zo(n,i)}finally{n!==null&&d.default.closeSync(n)}}function gi(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(r){if(_(r,"ENOENT")&&Ti(e))return;throw r}let t=d.default.fstatSync(n),i=x(e,n,t);H(e,i)}finally{n!==null&&d.default.closeSync(n)}Ei(A.dirname(e))}function Qo(e){let n;try{n=d.default.lstatSync(e)}catch(t){if(_(t,"ENOENT"))return;throw t}if(n.isSymbolicLink()||!n.isFile())throw new Error("credential-store replacement target must be a regular file");if(n.nlink!==1)throw new Te;be(n,"credential-store replacement target")}function ea(e,n){for(let t=0;t<8;t+=1){let i=(0,Jn.randomBytes)(12).toString("hex"),r=A.join(e,`.${n}.${process.pid}.${i}.tmp`);try{return{fd:d.default.openSync(r,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_WRONLY|(d.default.constants.O_NOFOLLOW??0),384),tempPath:r}}catch(o){if(_(o,"EEXIST"))continue;throw o}}throw new Error("could not allocate a unique credential-store temp file")}function Li(e,n){let t=0;for(;t<n.length;){let i=d.default.writeSync(e,n,t,n.length-t,null);if(!Number.isSafeInteger(i)||i<=0)throw new Error("credential-store temp file write made no progress");t+=i}}function Ei(e){if(process.platform==="win32")return;let n=null;try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_DIRECTORY??0)|(d.default.constants.O_NOFOLLOW??0)),d.default.fsyncSync(n)}catch{}finally{if(n!==null)try{d.default.closeSync(n)}catch{}}}function na(e,n){let t=Buffer.from(n,"utf8");if(t.length>je)throw new Error("credential-store file exceeds the maximum supported size");let i=A.dirname(e),r=A.basename(e),o=null,a=null,s=!1;try{let c=ea(i,r);o=c.fd,a=c.tempPath;let u=d.default.fstatSync(o);if((x(a,o,u).mode&63)!==0&&process.platform!=="win32")throw new Error("credential-store temp file is not owner-only");Li(o,t),d.default.fsyncSync(o),x(a,o,d.default.fstatSync(o));let f=o;o=null,d.default.closeSync(f),Qo(e),d.default.renameSync(a,e),s=!0}finally{if(o!==null)try{d.default.closeSync(o)}catch{}if(!s&&a!==null)try{d.default.unlinkSync(a)}catch{}}Ei(i)}function ta(e){return A.join(A.dirname(e),`.${A.basename(e)}.lock`)}function ia(e){return A.join(A.dirname(e),`.${A.basename(e)}.lock-recovery`)}function ra(e,n){if(n.size>Hn)return null;let t=Buffer.alloc(Hn+1),i=0;for(;i<t.length;){let o=d.default.readSync(e,t,i,t.length-i,null);if(o===0)break;i+=o}if(i>Hn)return null;let r;try{r=JSON.parse(t.subarray(0,i).toString("utf8"))}catch{return null}return typeof r!="object"||r===null||!Number.isSafeInteger(r.pid)||(r.pid??0)<=0||typeof r.nonce!="string"||!/^[a-f0-9]{24}$/.test(r.nonce??"")||typeof r.target!="string"?null:r}function H(e,n){let t=d.default.lstatSync(e);if(t.isSymbolicLink()||!t.isFile()||!Le(t,n))throw new Error("credential-store lock changed while it was being inspected");be(t,"credential-store lock"),d.default.unlinkSync(e)}function _i(e,n){let t=null;try{try{t=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(c){if(_(c,"ENOENT"))try{let u=d.default.lstatSync(e);throw u.isSymbolicLink()||!u.isFile()?new Error("credential-store lock must be a real regular file"):new E}catch(u){if(_(u,"ENOENT"))return{state:"absent"};throw u}throw c}let i=d.default.fstatSync(t),r=x(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0}),o=ra(t,r);return{state:(o?.target===n&&o?!bi(o.pid):Date.now()-r.mtimeMs>=Ho)?"stale":"active",stats:r}}finally{t!==null&&d.default.closeSync(t)}}function oa(e,n){for(let t=0;t<8;t+=1){let i=(0,Jn.randomBytes)(12).toString("hex"),r=A.join(e,`.${n}.${process.pid}.${i}.lock-claim`),o={pid:process.pid,nonce:i,target:n},a=null;try{a=d.default.openSync(r,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_WRONLY|(d.default.constants.O_NOFOLLOW??0),384);let s=d.default.fstatSync(a),c=x(r,a,s,{allowMultipleLinks:!0});return Li(a,Buffer.from(JSON.stringify(o),"utf8")),d.default.fsyncSync(a),{claimPath:r,metadata:o,stats:c}}catch(s){if(_(s,"EEXIST"))continue;try{d.default.unlinkSync(r)}catch{}throw s}finally{a!==null&&d.default.closeSync(a)}}throw new Error("could not allocate a unique credential-store lock claim")}function aa(e,n){let t;try{t=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(i){throw _(i,"ENOENT")?new E:i}try{let i=d.default.fstatSync(t),r=x(e,t,i,{allowMultipleLinks:!0,retryOnPathChange:!0});if(!Le(r,n))throw new E;return{fd:t,lockPath:e,stats:r}}catch(i){throw d.default.closeSync(t),i}}function Ai(e){let n=null;try{try{n=d.default.openSync(e,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(t){if(_(t,"ENOENT"))try{let i=d.default.lstatSync(e);throw i.isSymbolicLink()||!i.isFile()?new Error("credential-store recovery gate must be a real regular file"):new E}catch(i){if(_(i,"ENOENT"))return!1;throw i}throw t}return x(e,n,d.default.fstatSync(n),{allowMultipleLinks:!0,retryOnPathChange:!0}),!0}finally{n!==null&&d.default.closeSync(n)}}function sa(e){let n;try{n=d.default.openSync(e,d.default.constants.O_CREAT|d.default.constants.O_EXCL|d.default.constants.O_RDWR|(d.default.constants.O_NOFOLLOW??0),384)}catch(i){if(_(i,"EEXIST"))return null;throw i}let t=null;try{t=d.default.fstatSync(n);let i=x(e,n,t,{allowMultipleLinks:!0,retryOnPathChange:!0});return{fd:n,lockPath:e,stats:i}}catch(i){if(t!==null)try{H(e,t)}catch{}throw d.default.closeSync(n),i}}function j(e,n){if(Date.now()>=e)throw n?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");zo(Vo)}function Si(e){let n=A.dirname(e),t=A.basename(e),i=ta(e),r=ia(e),o=oa(n,t),a=Date.now()+jo,s=!1,c=!1,u=null,p;try{for(;u===null;)try{if(Ai(r)){j(a,!0);continue}d.default.linkSync(o.claimPath,i),c=!0,u=aa(i,o.stats),s=!0}catch(f){if(c&&!s){try{H(i,o.stats)}catch{}c=!1}if(f instanceof E){j(a,!1);continue}if(!_(f,"EEXIST"))throw f;let y;try{y=_i(i,t)}catch(S){if(S instanceof E){j(a,!1);continue}throw S}if(y.state==="absent")continue;if(y.state==="stale"){let S;try{S=sa(r)}catch(b){if(b instanceof E){j(a,!1);continue}throw b}if(S!==null){try{let b;try{b=_i(i,t)}catch(U){if(U instanceof E){j(a,!1);continue}throw U}b.state==="stale"&&H(i,b.stats)}finally{Wn(S)}continue}}let m;try{m=Ai(r)}catch(S){if(S instanceof E){j(a,!1);continue}throw S}j(a,m)}}catch(f){p=f}try{H(o.claimPath,o.stats)}catch(f){!_(f,"ENOENT")&&!s&&p===void 0&&(p=f)}if(p!==void 0)throw p;if(u===null)throw new Error("credential-store lock acquisition failed");return u}function Wn(e){try{H(e.lockPath,e.stats)}finally{d.default.closeSync(e.fd)}}function la(e,n){let t=Xo(n),i=new RegExp(`^\\.${t}\\.(\\d+)\\.[a-f0-9]{24}\\.tmp$`).exec(e)??new RegExp(`^\\.${t}\\.(\\d+)\\.[a-f0-9]{24}\\.lock-claim$`).exec(e);if(!i)return null;let r=Number(i[1]);return Number.isSafeInteger(r)&&r>0?r:null}function ki(e){let n=A.dirname(e),t=A.basename(e);for(let i of d.default.readdirSync(n)){let r=la(i,t);if(r===null||bi(r))continue;let o=A.join(n,i),a=null;try{try{a=d.default.openSync(o,d.default.constants.O_RDONLY|(d.default.constants.O_NOFOLLOW??0)|(d.default.constants.O_NONBLOCK??0))}catch(u){if(_(u,"ENOENT")||_(u,"ELOOP"))continue;throw u}let s=d.default.fstatSync(a),c=d.default.lstatSync(o);if(!s.isFile()||c.isSymbolicLink()||!c.isFile()||!Le(s,c))continue;try{be(s,"credential-store orphan")}catch{continue}H(o,s)}catch(s){if(!_(s,"ENOENT"))throw s}finally{a!==null&&d.default.closeSync(a)}}}function Ee(e,n,t){if(!He()){if(n.allowUnsupportedPlatformCleanup){if(n.createParent)throw V();if(!hi(e,!1))return t({read:()=>null,remove:()=>{},write:()=>{throw V()}});let a=Si(e);try{return ki(e),t({read:()=>yi(e),remove:()=>gi(e),write:()=>{throw V()}})}finally{Wn(a)}}if(!n.createParent){let o=!1;try{o=Ti(e)}catch{throw V()}if(o)return t({read:()=>null,remove:()=>{},write:()=>{throw V()}})}throw V()}if(!hi(e,n.createParent))return t({read:()=>null,remove:()=>{},write:()=>{throw new Error("credential-store parent does not exist")}});let r=Si(e);try{return ki(e),t({read:()=>yi(e),remove:()=>gi(e),write:o=>na(e,o)})}finally{Wn(r)}}var zn="allscale-cli";function et(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ci(e){return et(e)&&typeof e.access_token=="string"&&typeof e.refresh_token=="string"}function J(e){return new l("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 Xn(){return new l("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 We(){return new l("internal","The session credential store in the plaintext file could not be written safely. Any previous credential file was left unchanged.")}var W,Zn=!1;function ca(){return ti()?"ALLSCALE_NO_KEYCHAIN":process.env.KEYTAR_DISABLE==="1"?"KEYTAR_DISABLE":null}function da(e){if(typeof e!="object"||e===null||e.code!=="MODULE_NOT_FOUND")return!1;let n=e.message;return typeof n=="string"&&n.split(`
|
|
16
|
+
`,1)[0]==="Cannot find module 'keytar'"}function ua(){if(W!==void 0)return W;if(ca())return Zn=!1,W=null,W;try{W=require("keytar"),Zn=!1}catch(e){Zn=!da(e),W=null}return W}var pa="OS keychain could not be accessed on this system (keytar / libsecret may be unavailable, locked, or unusable).";function Ii(){let e=He()?"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 l("storage.unavailable",`${pa} `+e+" Never silently downgrade in production.")}async function Qn(e){try{return await e()}catch{throw Ii()}}var nt=class{constructor(n){this.keytar=n}keytar;kind="keychain";async read(n){let t=await Qn(()=>this.keytar.getPassword(zn,n));if(t===null)return null;let i;try{i=JSON.parse(t)}catch{throw J("OS keychain")}if(!Ci(i))throw J("OS keychain");return i}async get(n){return this.read(n)}async set(n,t){await this.read(n),await Qn(()=>this.keytar.setPassword(zn,n,JSON.stringify(t)))}async delete(n){await this.read(n),await Qn(()=>this.keytar.deletePassword(zn,n))}},fa="credentials.json",tt=class{kind="insecure-file";filePath;constructor(n){this.filePath=n??Ni.join(Kn(),fa)}read(n){let t;try{t=n.read()}catch(r){throw Ve(r)?Xn():J("plaintext file")}if(t===null)return{profiles:{}};let i;try{i=JSON.parse(t)}catch{throw J("plaintext file")}if(!et(i)||!et(i.profiles))throw J("plaintext file");return i}write(n,t){try{n.write(JSON.stringify(t,null,2))}catch(i){throw Ve(i)?Xn():We()}}profileTokens(n,t){let i=n.profiles[t];if(i!==void 0){if(!Ci(i))throw J("plaintext file");return i}}async get(n){try{return Ee(this.filePath,{createParent:!1},t=>this.profileTokens(this.read(t),n)??null)}catch(t){throw t instanceof l?t:J("plaintext file")}}async set(n,t){try{Ee(this.filePath,{createParent:!0},i=>{let r=this.read(i);this.profileTokens(r,n),r.profiles[n]=t,this.write(i,r)})}catch(i){throw i instanceof l?i:We()}}async delete(n){try{Ee(this.filePath,{createParent:!1},t=>{let i=this.read(t);this.profileTokens(i,n)!==void 0&&(delete i.profiles[n],this.write(t,i))})}catch(t){throw t instanceof l?t:We()}}async clearProfile(n){try{return Ee(this.filePath,{createParent:!1,allowUnsupportedPlatformCleanup:!0},t=>{let i=this.read(t);return this.profileTokens(i,n)===void 0?!1:(delete i.profiles[n],Object.keys(i.profiles).length===0?t.remove():this.write(t,i),!0)})}catch(t){throw t instanceof l?t:Ve(t)?Xn():We()}}};function Je(e){if(e.insecureStorage)return wi(),new tt(e.insecureFilePath);let n=ua();if(n)return new nt(n);throw Ii()}var it=class{kind="insecure-file";async get(n){return null}async set(n,t){throw new l("internal","NoopTokenStore: refusing to persist tokens \u2014 caller used --token override path.")}async delete(n){}};function ze(){return new it}var Xe="allscale_access_token",rt="allscale_refresh_token";function vi(e){return(typeof e.getSetCookie=="function"?e.getSetCookie():e.get("set-cookie")?[e.get("set-cookie")]:[]).map(t=>{let i=t.indexOf(";"),r=i===-1?t:t.slice(0,i),o=r.indexOf("=");return o===-1?null:{name:r.slice(0,o).trim(),value:r.slice(o+1).trim()}}).filter(t=>t!==null)}function ot(e){return e.map(n=>`${n.name}=${n.value}`).join("; ")}function at(e,n){return e.find(t=>t.name===n)?.value??null}var Oi=L(require("crypto")),Ri=L(require("fs")),xi=L(require("path"));var ma="key-id",ha="x-allscale-cli-version",st="cli-1",ya="aScaLe_cli_obf_v1",ga="WWoBD3QEZwECUTEuOD4dTgdWawQSKAQ8UlRaaw==";function _a(e,n){let t=Buffer.from(e,"base64"),i=Buffer.from(n,"utf8"),r=Buffer.alloc(t.length);for(let o=0;o<t.length;o++)r[o]=t[o]^i[o%i.length];return r.toString("utf8")}var Aa=_a(ga,ya),Pi=`Bearer ${Aa}`;function Ui(e,n){let t=bn(e);if(t!==null)return n.find(i=>bn(i.base)===t)}function Sa(e){if("f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2".trim().length>0)return"f17372513b233456b90621e793c1d0759bce34f8eec3415abc6c2f08270faef2";let n=ye();if(n.length>0){let i=Ui(e,n);if(i)return i.key;if(M(e)){let r=process.env.ALLSCALE_SIGNING_KEY;return r&&r.trim().length>0?r:M(n[0].base)?n[0].key:void 0}return}let t=process.env.ALLSCALE_SIGNING_KEY;return t&&t.trim().length>0?t:void 0}function ka(e){{let i="cli-1".trim();if(i.length>0)return i}let n=ye();if(n.length>0){let i=e!==void 0?Ui(e,n):void 0;if(i)return i.keyId;if(e!==void 0&&M(e)){let r=process.env.ALLSCALE_SIGNING_KEY;if(r&&r.trim().length>0){let o=process.env.ALLSCALE_SIGNING_KEY_ID;return o!==void 0?o.trim():st}if(!M(n[0].base))return st}return n[0].keyId}let t=process.env.ALLSCALE_SIGNING_KEY_ID;return t!==void 0?t.trim():st}function wa(){return"1.0.3"}function Ta(){return new l("signing.key_unavailable","No request-signing key is available for this destination in this build. Published builds embed one at publish time; when running from source or an internal build, set ALLSCALE_SIGNING_KEY + ALLSCALE_BUILD_API_BASE (or ALLSCALE_BUILD_PAIRS for more than one environment) in the environment.")}function lt(e,n){let t=Sa(n);if(!t)throw Ta();let i=ka(n),r=Math.floor(Date.now()/1e3).toString(),o=Oi.createHash("sha256").update(`${t}${r}${e}`).digest("hex"),a={timestamp:r,"secret-key":o,[ha]:wa()};return i.length>0&&(a[ma]=i),a}function Di(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e)}function ba(e,n={}){let t;try{t=ai(Me())}catch{return}if(!(t.length===0||t.includes(e)))return new l("auth.unknown_profile",Mt(e)+(n.messageSuffix??""),{profile:e})}function Ne(e){if(e.profileExplicit){let n=ba(e.profile);if(n)return n}return new l("auth.no_token",Ft(e.profile))}var La=500,Ea=8,$i=100;function ct(e,n=0){if(n>Ea)return"<truncated>";if(Array.isArray(e)){let t=e.slice(0,$i),i=t.map(r=>ct(r,n+1));return e.length>t.length&&i.push(`<${e.length-t.length} more items truncated>`),i}if(e!==null&&typeof e=="object"){let t=Object.create(null);for(let[i,r]of Object.entries(e).slice(0,$i))t[i]=De(i)?"<redacted>":ct(r,n+1);return t}return e}function Na(e){let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return;let t;try{t=JSON.parse(n)}catch{return}return t!==null&&typeof t=="object"?t:void 0}function Bi(e,n=La){let t=Na(e),i=t===void 0?Ue(e):JSON.stringify(ct(t));return $e(i,n)}var dt=256*1024,Ze=class extends l{constructor(n,t,i="backend-envelope"){let r=i==="successful-query",o=i==="successful-mutation";super(r?"transport.response_too_large":"backend.internal",r?`The API returned an HTTP-success response larger than the CLI's ${t}-byte safety limit, so it was not parsed. For list commands, request fewer rows by removing --all or using --input/--limit pagination, and reduce --select when possible; for other commands, contact support.`:o?`The API returned an HTTP-success response larger than the CLI's ${t}-byte safety limit, so its result was not parsed. The operation may already have completed; inspect authoritative state before retrying.`:`API response body exceeded the ${t}-byte safety limit and was not parsed.`,{status:n,max_body_bytes:t,...o?{outcome_ambiguous:!0}:{}}),this.name="ResponseBodyTooLargeError"}},Qe=class extends Error{status;timeoutMs;constructor(n,t){super(`API response body read exceeded its ${t}ms deadline.`),this.name="ResponseBodyReadTimeoutError",this.status=n,this.timeoutMs=t}};async function ut(e,n,t={}){if(!Number.isSafeInteger(n)||n<=0)throw new RangeError("maxBytes must be a positive safe integer");if(t.timeoutMs!==void 0&&(!Number.isSafeInteger(t.timeoutMs)||t.timeoutMs<=0))throw new RangeError("timeoutMs must be a positive safe integer");let i=e.headers.get("content-length"),r=i!==null&&/^\d+$/.test(i.trim())?Number(i):void 0;if(r!==void 0&&r>n)throw e.body?.cancel().catch(()=>{}),new Ze(e.status,n,t.oversizeKind);if(!e.body)return"";let o=e.body.getReader(),a=[],s=0,c,u=t.timeoutMs,p=u===void 0?void 0:new Promise((f,y)=>{c=setTimeout(()=>{y(new Qe(e.status,u))},u),c.unref?.()});try{for(;;){let f=o.read(),{done:y,value:m}=p?await Promise.race([f,p]):await f;if(y)break;if(s+=m.byteLength,s>n)throw o.cancel().catch(()=>{}),new Ze(e.status,n,t.oversizeKind);a.push(Buffer.from(m))}}catch(f){throw f instanceof Qe&&o.cancel(f).catch(()=>{}),f}finally{c!==void 0&&clearTimeout(c);try{o.releaseLock()}catch{}}return Buffer.concat(a,s).toString("utf8")}var Ca="X-AllScale-Api-Key",Ia=3e4,va=32*1024*1024,Oa=4*1024*1024;function Ra(e,n){let t=new AbortController,i=!1,r=()=>{t.abort(e?.reason)};e?.aborted?r():e?.addEventListener("abort",r,{once:!0});let o=setTimeout(()=>{i=!0,t.abort()},n);return{signal:t.signal,timedOut:()=>i,dispose:()=>{clearTimeout(o),e?.removeEventListener("abort",r)}}}function xa(e,n){return n?n.aborted?Promise.reject(Object.assign(new Error("The operation was aborted"),{name:"AbortError"})):new Promise((t,i)=>{let r=()=>{i(Object.assign(new Error("The operation was aborted"),{name:"AbortError"}))};n.addEventListener("abort",r,{once:!0}),e.then(t,i).finally(()=>{n.removeEventListener("abort",r)})}):e}function Pa(e,n){if(!(e<300||e>=400))throw new l("transport.network",`API returned HTTP ${e} (a redirect) for ${$(n||"the request")}. The CLI does NOT follow redirects on credential-bearing requests \u2014 a cross-origin hop could re-send credentials and the request body to the new host. Check that --api-base / ALLSCALE_API_BASE points at the API origin directly and that no proxy is rewriting it.`,{status:e})}async function Yi(e){if(!(e.status<300||e.status>=400)){try{await e.body?.cancel()}catch{}Pa(e.status,e.url)}}var Fi="--dns-result-order=ipv4first";async function en(e,n){if(e.status!==403)return;let t=e.headers.get("content-type")?.toLowerCase()??"",i=e.headers.get("cf-ray")??"",r=e.headers.get("cf-mitigated")?.trim().toLowerCase()==="challenge",o=t.includes("text/html"),a=n?.slice(0,4096)??"",s=/^\s*(?:<!doctype\s+html|<html\b)/i.test(a),c=/cf-error-details|\/cdn-cgi\/(?:challenge-platform|styles\/cf\.errors)|sorry,\s*you have been blocked|attention required[^<]{0,160}cloudflare|cloudflare ray id|error\s*(?:code\s*)?1020/i.test(a);if(!((o||s)&&(r||n!==void 0&&c)))return;if(n===void 0)try{e.body?.cancel().catch(()=>{})}catch{}let p=/^[A-Za-z0-9-]{1,128}$/.test(i)?i:void 0;throw new l("transport.network",`Cloudflare blocked this request before it reached the AllScale API (HTTP 403). This can happen when the release edge accepts IPv4 but rejects IPv6. Retry with NODE_OPTIONS=${Fi} and report the Cloudflare Ray ID to support; the CLI will not automatically retry a possibly mutating request.`,{status:403,edge_provider:"cloudflare",...p?{cf_ray:p}:{},ipv4_workaround:`NODE_OPTIONS=${Fi}`})}var z=class{constructor(n){this.opts=n}opts;refreshInFlight=null;async requestWithMetadata(n){return this.requestInternal(n,{withMetadata:!0})}async request(n){return this.requestInternal(n,{withMetadata:!1})}async requestInternal(n,t){let i=n.timeoutMs??this.opts.requestTimeoutMs??Ia;if(!Number.isFinite(i)||i<1)throw new l("input.invalid","HTTP request timeout must be a positive number of milliseconds.");K(this.opts.apiBase),Ge(this.opts.apiBase);let r=this.opts.override?{access_token:this.opts.override.access_token,refresh_token:this.opts.override.refresh_token??""}:await this.opts.tokenStore.get(this.opts.profile),o=Ra(n.signal,i);try{return await this.requestWithinDeadline({...n,signal:o.signal},t,r)}catch(a){throw o.timedOut()?new l("transport.timeout",`Request to ${$(new URL(n.path,this.opts.apiBase).toString())} timed out after ${i}ms.`,{timeout_ms:i}):n.signal?.aborted&&!(a instanceof l)?new l("transport.network",`Request to ${$(new URL(n.path,this.opts.apiBase).toString())} was aborted by the caller.`):a}finally{o.dispose()}}async requestWithinDeadline(n,t,i){let r=new URL(n.path,this.opts.apiBase).toString();ci(this.opts.apiBase,r);let o=i?.agent_key,a=n.auth??"auto",s=Ki(n.path),c=a==="required"?!0:a==="none"?!1:$a(n.path);if((s||a==="required")&&!n._isRefresh&&!this.opts.override&&!i?.access_token&&!o)throw Ne({profile:this.opts.profile,profileExplicit:this.opts.profileExplicit});let u=Di(n.body),p=!!o||!!i?.access_token;c&&p&&!this.opts.override&&qe(this.opts.apiBase,i?.api_base);let f=this.buildHeaders({attachAuth:c&&p,bodyForSig:u,tokens:i,extra:n.headers}),y=Date.now();k({type:"request",method:n.method??"GET",url:r,...n._isRefresh?{refresh:!0}:{}});let m;try{m=await fetch(r,{method:n.method??"GET",headers:f,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(b){throw new l("transport.network",`Network error contacting ${$(r)}: ${b instanceof Error?b.message:String(b)}`)}if(k({type:"response",status:m.status,durationMs:Date.now()-y}),c&&!!i?.access_token&&!o&&m.status===401&&!n._isRefresh&&!this.opts.override){let b=await xa(this.refreshSingleFlight(),n.signal),U=this.buildHeaders({attachAuth:c&&!!b.access_token,bodyForSig:u,tokens:b,extra:n.headers}),Z=Date.now();k({type:"request",method:n.method??"GET",url:r});let C;try{C=await fetch(r,{method:n.method??"GET",headers:U,body:n.body!==void 0?u:void 0,signal:n.signal,redirect:"manual"})}catch(I){throw new l("transport.network",`Network error contacting ${$(r)} on refresh-retry: ${I instanceof Error?I.message:String(I)}`)}return k({type:"response",status:C.status,durationMs:Date.now()-Z}),Mi(C,{withMetadata:t.withMetadata,authBearing:c,responseKind:qi(n)})}return Mi(m,{withMetadata:t.withMetadata,authBearing:c&&p,agentKeyAuth:c&&!!o,responseKind:qi(n)})}buildHeaders(n){let i={Accept:"application/json","Content-Type":"application/json",...lt(n.bodyForSig,this.opts.apiBase),...n.extra};if(n.attachAuth){i.Authorization=Pi;let r=n.tokens;if(r?.agent_key)return i[Ca]=r.agent_key,i;let o=r?.access_token;o&&(i.Cookie=ot([{name:Xe,value:o}]))}return i}async refreshSingleFlight(){return this.refreshInFlight?this.refreshInFlight:(this.refreshInFlight=this.doRefresh().finally(()=>{this.refreshInFlight=null}),this.refreshInFlight)}async adoptConcurrentlyRotatedTokens(n){let t;try{t=await this.opts.tokenStore.get(this.opts.profile)}catch{return null}if(!t?.access_token||!t?.refresh_token||t.refresh_token===n.refresh_token)return null;if(qe(this.opts.apiBase,t.api_base),t.agent_key)throw new l("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than use it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");return t}async doRefresh(){let n=await this.opts.tokenStore.get(this.opts.profile);if(!n?.access_token||!n?.refresh_token)throw new l("auth.token_expired",`No refresh token available; log in again \u2014 ${Pe()}.`);if(qe(this.opts.apiBase,n.api_base),n.agent_key)throw new l("auth.credential_changed","The stored credential for this profile changed to a scoped agent key while a session refresh was in flight; the refresh was abandoned rather than overwrite it. Re-run the command \u2014 it will use the agent key. No re-authentication is needed.");let t=new URL("/api/public/auth/refresh_token",this.opts.apiBase).toString(),i=ot([{name:Xe,value:n.access_token},{name:rt,value:n.refresh_token}]),r=lt("",this.opts.apiBase);k({type:"request",method:"POST",url:t,refresh:!0});let o=new AbortController,a=!1,s=setTimeout(()=>{a=!0,o.abort()},1e4),c;try{c=await fetch(t,{method:"POST",headers:{Accept:"application/json",Cookie:i,...r},signal:o.signal,redirect:"manual"})}catch(m){throw k({type:"refresh",ok:!1}),new l("transport.network",a&&m instanceof Error&&m.name==="AbortError"?`Token refresh against ${$(t)} timed out after 10s with no response.`:`Network error during token refresh against ${$(t)}: ${m instanceof Error?m.message:String(m)}`)}finally{clearTimeout(s)}k({type:"response",status:c.status,durationMs:0});try{await Yi(c)}catch(m){throw k({type:"refresh",ok:!1}),m}if(c.status!==200){let m=null;try{await en(c);let S=await Ga(c);await en(c,S),Vi(c.status,S),c.status===401&&(m=await this.adoptConcurrentlyRotatedTokens(n))}catch(S){throw k({type:"refresh",ok:!1}),S}if(m)return k({type:"refresh",ok:!0,adopted:!0}),m;throw k({type:"refresh",ok:!1}),new l("auth.token_expired",`Refresh token was rejected; re-authenticate \u2014 ${Pe()}.`,{status:c.status})}let u=vi(c.headers),p=at(u,Xe),f=at(u,rt);if(!p||!f)throw k({type:"refresh",ok:!1}),new l("auth.token_expired","Refresh response did not include new access/refresh cookies.");let y={...n,access_token:p,refresh_token:f};return await this.opts.tokenStore.set(this.opts.profile,y),k({type:"refresh",ok:!0}),y}},Ua=["/secure","/api/secure","/v1/secure","/api/v1/secure"];function Ki(e){let n=e.split(/[?#]/,1)[0];return Ua.some(t=>n===t||n.startsWith(`${t}/`))}var Da=[/^\/(api\/)?(v1\/)?public\/businesses\/payments?(\/|$)/,/^\/(api\/)?(v1\/)?public\/businesses\/transactions?(\/|$)/];function pt(e){let n=e.split(/[?#]/,1)[0];return Da.some(t=>t.test(n))}function $a(e){return Ki(e)||pt(e)}async function Mi(e,n={}){await Yi(e);let t=e.status>=200&&e.status<300;t||await en(e);let i=n.responseKind??"mutation",o=await ut(e,t?i==="query"?va:Oa:dt,{oversizeKind:t?i==="query"?"successful-query":"successful-mutation":"backend-envelope"});t||await en(e,o);let a=null;if(o.length>0)try{a=JSON.parse(o)}catch{a={raw:o}}if(e.status>=200&&e.status<300){if(n.withMetadata){let c={};return e.headers.forEach((u,p)=>{c[p]=u}),{status:e.status,headers:c,body:a}}return a}let s=Ya(a)??`HTTP ${e.status}`;if(Vi(e.status,a),Ma(e.status,a,n),e.status===401){if(n.agentKeyAuth)throw new l("auth.token_expired","Agent key was rejected (expired or revoked). Re-run `allscale device-login` to mint a new scoped key.",{status:401,body:a});let c=n.authBearing?"auth.token_expired":"input.invalid";throw new l(c,s,{status:401,body:a})}throw e.status===403?new l("auth.permission_denied",s,{status:403,body:a}):e.status===404?new l("not_found",s,{status:404,body:a}):e.status===429?new l("rate_limited",s,{status:429,body:a}):e.status>=500?new l("backend.internal",s,{status:e.status,body:a}):new l("input.invalid",s,{status:e.status,body:a})}function qi(e){if(e.responseKind)return e.responseKind;let n=(e.method??"GET").toUpperCase();return n==="GET"||n==="HEAD"?"query":"mutation"}var Ba=2014,Gi=2004;function ji(e,n){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!="object")return!1;let i=t.code;return i===n||i===String(n)}function Fa(e){return ji(e,Ba)}function Ma(e,n,t){if(!(e>=200&&e<300)&&t.authBearing&&!(e===401&&t.agentKeyAuth)&&ji(n,Gi))throw new l("auth.token_expired",`The API rejected this credential as invalid. Re-authenticate with ${Pe()} and retry. If that does not help, upgrade the CLI \u2014 the API may have rotated the client credential this build carries.`,{status:e,backend_code:Gi})}var qa=1e4;async function Ga(e,n=qa){if(e.status>=200&&e.status<300)return"";try{return await ut(e,dt,{timeoutMs:n})}catch{return""}}function Vi(e,n){if(!(e>=200&&e<300)&&Fa(n))throw new l("auth.signature_rejected","The AllScale API rejected this CLI build's request signing key. Download the latest version \u2014 `npm install -g @allscale/cli@latest` \u2014 and retry: retiring an old signing key is how a release is made mandatory. If you are already on the latest version, this build's key row is missing or misprovisioned on the backend \u2014 contact AllScale support. Re-logging in will not help either way; the key ships inside the CLI build itself.",{status:e,body:typeof n=="string"?Bi(n):n})}function Ya(e){if(!e||typeof e!="object")return;let n=e;if(typeof n.message=="string")return n.message;if(typeof n.detail=="string")return n.detail;if(Array.isArray(n.detail))return JSON.stringify(n.detail)}var Ka=/^\/(api\/)?(v1\/)?public\//;function ft(e,n={}){let t=typeof n.pathHint=="string"?n.pathHint:"",i=t&&Ka.test(t),r=t&&pt(t),o=i&&!r&&!n.forceAuth;if(e.token)return new z({apiBase:e.apiBase,tokenStore:ze(),profile:e.profile,profileExplicit:e.profileExplicit,override:{access_token:e.token}});if(o)return new z({apiBase:e.apiBase,tokenStore:ze(),profile:e.profile,profileExplicit:e.profileExplicit});try{return new z({apiBase:e.apiBase,tokenStore:Je({insecureStorage:e.insecureStorage}),profile:e.profile,profileExplicit:e.profileExplicit})}catch(a){if(r)return new z({apiBase:e.apiBase,tokenStore:ze(),profile:e.profile,profileExplicit:e.profileExplicit});throw a}}var Hi=[{name:"create_claim_link",kind:"mutation",description:"Create a single App claim link. Returns the pending link, funding address, exact deposit total, and bearer claim URL. The link becomes available after the sender's deposit is confirmed. No claim-back.",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateClaimLinkInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"CreateClaimLinkResult",ofType:null}},deprecated:null},{name:"create_contact",kind:"mutation",description:"create a new contact",args:[{name:"create_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateContactInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"create_payment",kind:"mutation",description:"create a new payment",args:[{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreatePaymentInput",ofType:null}},defaultValue:null},{name:"wallet_ids",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"create_store",kind:"mutation",description:"create store",args:[{name:"input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"CreateStoreInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"StoreCreateResult",ofType:null}},deprecated:null},{name:"update_payment",kind:"mutation",description:"update an existing payment status by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"payment",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"UpdatePaymentInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"activities",kind:"query",description:"Get current user's activity list with multi-dimensional filters (type, status, contact, wallet, time range, amount range)",args:[{name:"filter_input",description:null,type:{kind:"INPUT_OBJECT",name:"ActivityFilterInput",ofType:null},defaultValue:"null"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"20"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItemPaginatedResponse",ofType:null}},deprecated:null},{name:"auto_payout_session_status",kind:"query",description:"Return the current merchant auto-payout status, expiry, total/used/remaining USD cap, per-transaction limit, and authorized chain/token pairs. Merchants without an active setup receive provisioned=false with null money/expiry fields and no pairs.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AutoPayoutSessionStatus",ofType:null}},deprecated:null},{name:"business",kind:"query",description:"get one business by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Business",ofType:null}},deprecated:null},{name:"business_contact_by_email",kind:"query",description:"Look up the contact card of the business whose login email is given. Used to fill the invoice header's From: block with the same name/email/phone the web editor shows.",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"BusinessContact",ofType:null}},deprecated:null},{name:"business_transaction_records",kind:"query",description:"get transaction records for business",args:[{name:"direction",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_type",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"business_wallets",kind:"query",description:"List the CALLER'S OWN non-custodial wallets (id, chain, address, coin balances). Takes no business id \u2014 the owner is derived from the authenticated identity, so there is no caller-supplied id to mismatch and no way to read another merchant's wallets. Returns [] when the account has no wallet yet.",args:[],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"WalletEmbedded",ofType:null}}}},deprecated:null},{name:"claim_link",kind:"query",description:"Get one of the caller's own claim links by id (sender surface). A non-owned or unknown id returns CLAIM_LINK_NOT_AVAILABLE \u2014 no existence leak.",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},deprecated:null},{name:"contact",kind:"query",description:"get one contact by it's id",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contact_by_email",kind:"query",description:"get one contact by it's email",args:[{name:"email",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}},deprecated:null},{name:"contacts",kind:"query",description:"get multi contacts by owner business id",args:[{name:"owner_business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ContactPaginatedResponse",ofType:null}},deprecated:null},{name:"my_claim_links",kind:"query",description:"List the caller's claim links, newest first. Optional status and link_source filters narrow the results; query_input controls pagination, ordering, and the created_at time range.",args:[{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"},{name:"status",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"link_source",description:null,type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkPaginatedResponse",ofType:null}},deprecated:null},{name:"my_transactions",kind:"query",description:"get one user's successful transactions by query",args:[{name:"query_input",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"TransactionPaginatedResponse",ofType:null}},deprecated:null},{name:"payment",kind:"query",description:"get one payment by its ID",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}},deprecated:null},{name:"payments",kind:"query",description:"All payments by business ID as sender or recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"recipient_payments",kind:"query",description:"Get multiple payments by business ID as recipient",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"sender_payments",kind:"query",description:"Get multiple payments by business ID as sender",args:[{name:"business_id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"query_input",description:null,type:{kind:"INPUT_OBJECT",name:"QueryInput",ofType:null},defaultValue:"null"}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"PaymentPaginatedResponse",ofType:null}},deprecated:null},{name:"transaction",kind:"query",description:"get one transaction by id_str",args:[{name:"id_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}],returnType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}},deprecated:null}],Wi=[{name:"ActivityFilterInput",kind:"INPUT",description:null,inputFields:[{name:"transaction_types",description:"Filter by transaction types (OR): 1=PAYMENT, 2=REWARD, 3=WITHDRAWAL, 8=CHECKOUT_INTENT_EPHEMERAL, 9=CHECKOUT_INTENT, 10=ON_CHAIN_TX, 11=CHECKOUT_INTENT_EPHEMERAL_REFUND, 13=CHECKOUT_INTENT_EPHEMERAL_NET_INCOME, 14=CLAIM_LINK",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"transaction_statuses",description:"Filter by transaction statuses (OR): 0=NEW, 1=SUCCESS, 2=FAILED, 3=CONFIRMING",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"payment_statuses",description:"Filter by payment statuses (OR): -4=OVERDUE, -1=FAILED, 0=DRAFT, 1=SENT, 2=ACKNOWLEDGED, 3=PROCESSING, 10=PAID",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"withdraw_statuses",description:"Filter by withdraw statuses (OR): -4=CANCELED, -1=FAILED, 1=CREATED, 20=CONFIRMED",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"directions",description:"Filter by transaction direction (OR): 1=INFLOW, -1=OUTFLOW",type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}}},defaultValue:"null"},{name:"contact_keyword",description:"Fuzzy search by contact name/email or store name. OR relationship with wallet_address.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"wallet_address",description:"Fuzzy search by counterparty wallet address (tx_from/tx_to). OR relationship with contact_keyword.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"start_time",description:"Filter transactions after this time, ISO8601 format (e.g. 2024-01-01T00:00:00.000Z)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"end_time",description:"Filter transactions before this time, ISO8601 format",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"min_amount",description:"Filter transactions with amount >= this value (Decimal string)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"max_amount",description:"Filter transactions with amount <= this value (Decimal string)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"is_claim_link",description:"When true, return only claim-link activity: a receiver's claim (an ON_CHAIN_TX tagged with claim_link_id) OR a sender's CLAIM_LINK row (single claim_link_id / batch claim_link_batch_id). Matched by claim-link linkage presence, NOT transaction_types \u2014 a receiver's claim shares transaction_type=ON_CHAIN_TX(10) with a plain deposit, so it cannot be selected by type alone (bug 6935616).",type:{kind:"SCALAR",name:"Boolean",ofType:null},defaultValue:"null"}]},{name:"ActivityItem",kind:"OBJECT",description:null,fields:[{name:"transaction_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"Transaction record ID"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Transaction amount in cryptocurrency"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Transaction amount in fiat cents"},{name:"transaction_time",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"When the transaction occurred on-chain"},{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Record creation time in UTC"},{name:"transaction_status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Status: 0=NEW, 1=SUCCESS, 2=FAILED, 3=CONFIRMING"},{name:"payment_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Linked payment ID for PAYMENT type transactions"},{name:"transaction_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Type: 1=PAYMENT, 2=REWARD, 3=SEND, 4=SERVICE_FEE, 9=CHECKOUT_INTENT, 10=ON_CHAIN_TX, 14=CLAIM_LINK"},{name:"direction",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Direction: 1=INFLOW (received), -1=OUTFLOW (sent)"},{name:"wallet_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"Counterparty wallet address (sender if INFLOW, recipient if OUTFLOW)"},{name:"tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"On-chain transaction hash"},{name:"tx_block_chain",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Blockchain network type"},{name:"tx_block_number",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Block number of the on-chain transaction"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"User-provided memo or notes"},{name:"payment_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Cryptocurrency type (e.g. USDT)"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"Fiat currency type (e.g. USD, CNY)"},{name:"total_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Total fee = network_fee + service_fee"},{name:"network_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"On-chain gas/network fee"},{name:"service_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"AllScale platform service fee"},{name:"counterparty_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Counterparty's business ID if they are an AllScale user"},{name:"claim_link_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"Linked claim link ID for CLAIM_LINK type transactions"}]},{name:"ActivityItemPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ActivityItem",ofType:null}}}},description:null}]},{name:"AuthorizedPolicyPair",kind:"OBJECT",description:null,fields:[{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Chain identified by its BlockChainType value (for example BASE = 5) \u2014 not the EIP-155 chain id."},{name:"token_symbol",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Stablecoin symbol: USDT or USDC"}]},{name:"AutoPayoutSessionStatus",kind:"OBJECT",description:null,fields:[{name:"provisioned",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"Whether auto-payout setup has been completed for this merchant."},{name:"active",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"True iff provisioned AND the session has not expired (the runtime auto-pay gate)"},{name:"session_expires_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"Session expiry (drives the countdown); null when not provisioned"},{name:"total_cap_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"Unified session total cap in USD (decimal string); null when not provisioned"},{name:"used_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"Cumulative USD spent (reserved + committed) this session (decimal string); populated only for an ACTIVE session, else null"},{name:"remaining_usd",type:{kind:"SCALAR",name:"String",ofType:null},description:"max(0, total_cap - used) in USD (decimal string); populated only for an ACTIVE session, else null"},{name:"per_transaction_limit",type:{kind:"SCALAR",name:"String",ofType:null},description:"Unified single-transaction limit (token-unit decimal string, stablecoin $ 1:1) recorded when auto-payout is enabled; null when not provisioned or when recorded entries have different limits. Retained after a session expires, so it still reports what was recorded."},{name:"authorized_pairs",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"AuthorizedPolicyPair",ofType:null}}}},description:"The (chain, stable-coin) pairs the merchant authorized when enabling auto-payout; empty when auto-payout was never provisioned. Retained after a session expires, so it still reports what was authorized."},{name:"sponsor_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"Lowercased sponsor address used to validate authorized payouts. Populated whether or not auto-payout is provisioned, so it is readable while enabling; null when unavailable."}]},{name:"Business",kind:"OBJECT",description:null,fields:[{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"user name"},{name:"email",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"email of the user"},{name:"description",type:{kind:"SCALAR",name:"String",ofType:null},description:"description of the user"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the business"},{name:"address",type:{kind:"SCALAR",name:"String",ofType:null},description:"address field for business"},{name:"country",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"country code of business"},{name:"contact_name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"contact name of business"},{name:"contact_avatar",type:{kind:"SCALAR",name:"String",ofType:null},description:"contact avatar url of business"},{name:"contact_phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"contact phone of business"},{name:"avatar",type:{kind:"SCALAR",name:"String",ofType:null},description:"avatar url of business"},{name:"default_currency",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"default currency for business"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the business"},{name:"tax_number",type:{kind:"SCALAR",name:"String",ofType:null},description:"tax id of the business"},{name:"about",type:{kind:"SCALAR",name:"String",ofType:null},description:"about of the business, can be changed by business"},{name:"business_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"business type"},{name:"accepted_stable_coins",type:{kind:"SCALAR",name:"Int",ofType:null},description:"bitflag of accepted stablecoins for invoices (StableCoinFlag)"},{name:"employee_count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"total active employees in the business"}]},{name:"BusinessContact",kind:"OBJECT",description:null,fields:[{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Display name of the business's user account."},{name:"email",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Login email of the business's user account."},{name:"contact_name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Contact person the business presents on its invoices. Preferred over `name` when both are set."},{name:"contact_phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"Contact phone the business presents on its invoices. Null when the business has not set one."}]},{name:"ClaimLink",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim link id"},{name:"business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"sender business that owns the link"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"ClaimLinkStatus lifecycle state"},{name:"amount",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim amount, decimal string in token units"},{name:"token_symbol",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"stablecoin symbol, e.g. USDT / USDC"},{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"BlockChainType the link is locked to"},{name:"sender_display_name",type:{kind:"SCALAR",name:"String",ofType:null},description:"name shown to the receiver (person or Store name)"},{name:"sender_message",type:{kind:"SCALAR",name:"String",ofType:null},description:"optional message shown on the claim page"},{name:"receiver_email",type:{kind:"SCALAR",name:"String",ofType:null},description:"receiver email, if the sender supplied one"},{name:"reference_id",type:{kind:"SCALAR",name:"String",ofType:null},description:"Optional merchant-supplied reference identifier."},{name:"expected_deposit_total",type:{kind:"SCALAR",name:"String",ofType:null},description:"decimal string; the expected POOL balance (principal). The sender's gross outlay is the fee breakdown's total"},{name:"service_fee",type:{kind:"SCALAR",name:"String",ofType:null},description:"AllScale service fee fixed when the claim link is created; null when not applicable."},{name:"network_fee",type:{kind:"SCALAR",name:"String",ofType:null},description:"Network fee fixed when the claim link is created; null when not applicable."},{name:"funded_amount",type:{kind:"SCALAR",name:"String",ofType:null},description:"decimal string; the deposit actually received at the pool wallet"},{name:"funded_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the confirming sender deposit"},{name:"expiry_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC; the resolved claim-window deadline (funded_at + the chosen window, default 14d); None until link_sent"},{name:"claimed_via",type:{kind:"SCALAR",name:"String",ofType:null},description:"how it was claimed: masked receiver email or 0x address"},{name:"claim_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the successful claim"},{name:"refund_tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"on-chain tx hash of the expiry refund back to the sender"},{name:"refunded_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC when the expiry refund proved on-chain"},{name:"cancel_requested_at",type:{kind:"SCALAR",name:"String",ofType:null},description:"ISO-8601 UTC timestamp set when the sender requests cancellation while a claim is in progress. The request stays pending until the in-flight payout resolves: it is cleared if that payout completes (the cancellation is moot and the link is claimed), and retained if the payout did not go through and the link is cancelled and refunded. Null therefore means either no mid-claim cancellation was requested, or one that was resolved by a completed payout."},{name:"claim_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Bearer claim URL returned by create and single-link detail operations. The sender distributes this URL themselves; it is never emailed to the receiver. Null when unavailable, and always null on list operations \u2014 selecting it there returns the field as null rather than omitting it."}]},{name:"ClaimLinkFeeBreakdown",kind:"OBJECT",description:null,fields:[{name:"amount",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"claim amount the receiver gets, decimal string"},{name:"network_fee",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"gas reserve = gas_shares \xD7 per_transfer_gas, decimal string"},{name:"service_fee",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"AllScale service fee for the chain, decimal string"},{name:"total",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"amount + network_fee + service_fee \u2014 what the sender pays"},{name:"per_transfer_gas",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"one transfer's gas in token units (echoed for audit)"},{name:"gas_shares",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Number of per_transfer_gas shares reserved; currently 2 for a single claim link."}]},{name:"ClaimLinkPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}}}},description:null}]},{name:"CoinBalanceEmbedded",kind:"OBJECT",description:null,fields:[{name:"coin_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Stablecoin held, as the numeric StableCoin value (1 = USDT, 2 = USDC). `wallet list` decorates each balance with the derived `coin_name`."},{name:"balance",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Decimal",ofType:null}},description:"Balance of the coin"}]},{name:"Contact",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"id of the contact"},{name:"owner_business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"owner id of the contact"},{name:"contact_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"contact id if contact is allscale business"},{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"name of the contact"},{name:"binding_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"the way of binding an allscale business id to the contact, by email matching(1) or scan qrcode(2), etc."},{name:"email",type:{kind:"SCALAR",name:"String",ofType:null},description:"email of the contact"},{name:"evm_wallet_address",type:{kind:"SCALAR",name:"String",ofType:null},description:"evm wallet address of the contact"},{name:"tax_number",type:{kind:"SCALAR",name:"String",ofType:null},description:"tax number of the contact"},{name:"address",type:{kind:"SCALAR",name:"String",ofType:null},description:"address of the contact"},{name:"phone",type:{kind:"SCALAR",name:"String",ofType:null},description:"phone number of the contact"},{name:"last_payment_created_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"last payment date of the contact"},{name:"last_paid_at",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"last successful pay date"},{name:"description",type:{kind:"SCALAR",name:"String",ofType:null},description:"Free-form description of the contact."},{name:"is_favourite",type:{kind:"SCALAR",name:"Boolean",ofType:null},description:"is favourite or not"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the contact"}]},{name:"ContactPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Contact",ofType:null}}}},description:null}]},{name:"CreateClaimLinkInput",kind:"INPUT",description:null,inputFields:[{name:"amount",description:"claim amount, decimal string in token units (e.g. '10.5')",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"token_symbol",description:"stablecoin symbol: 'USDT' or 'USDC'",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:"BlockChainType value the link is locked to (EVM only)",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"per_transfer_gas",description:"one ERC-20 transfer's gas in TOKEN units (decimal string); from the App's withdraw estimate",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"receiver_email",description:"optional receiver email \u2014 a SENDER-SIDE LABEL ONLY, recording who the link is meant for. AllScale does NOT email the receiver (no invite, no expiry reminder, no resend); the sender must distribute `claim_url` themselves.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_display_name",description:"name shown to the receiver (person or Store name)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_message",description:"optional message shown on the claim page (<= 200 chars)",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"idempotency_key",description:"optional client retry-safety token; a retried create with the same key returns the existing link instead of a duplicate",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"claim_window_seconds",description:"Optional positive claim-window duration in seconds. Defaults to 14 days. The window starts when funding is confirmed; after it expires, unclaimed funds are returned to the sender.",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"CreateClaimLinkResult",kind:"OBJECT",description:null,fields:[{name:"claim_link",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLink",ofType:null}},description:"the newly created link (pending_deposit)"},{name:"claim_token",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Bearer claim token returned only when the claim link is created and never available again. Capture and store it securely immediately; it preserves claim authority when claim_url is unavailable."},{name:"claim_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Bearer claim URL; null when no claim-page URL is configured."},{name:"pool_wallet_address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"ERC-4337 address the sender funds"},{name:"expected_deposit_total",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"the expected POOL balance (principal), decimal string; the sender's gross outlay is the fee breakdown's total"},{name:"fees",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"ClaimLinkFeeBreakdown",ofType:null}},description:"the frozen fee breakdown"}]},{name:"CreateContactInput",kind:"INPUT",description:null,inputFields:[{name:"owner_business_id",description:"owner id of the contact",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"name",description:"name of the contact",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"email",description:"email of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"evm_wallet_address",description:"evm wallet address of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"address",description:"address of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"phone",description:"phone number of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"tax_number",description:"tax number of the contact",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"description",description:"Free-form description of the contact.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"binding_type",description:"binding type of the contact",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"CreatePaymentInput",kind:"INPUT",description:null,inputFields:[{name:"sender_contact_id",description:"contact id of the payer/sender",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"payment_type",description:"payment type of the payment",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"1"},{name:"accepted_stable_coins",description:"optional per-invoice bitflag (StableCoinFlag) overriding the recipient business's accepted_stable_coins setting",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"payment_extra_info",description:"payment extra info of the payment, JSON object string",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"currency",description:"currency of the payment, only if the payment_type is CURRENCY",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"amount_cents",description:"amount of the payment in cents",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"amount_coins",description:"amount of the payment in coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},defaultValue:"null"},{name:"html_template",description:"HTML template for the invoice",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"memo",description:"memo of the payment",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"tax_id",description:"optional taxpayer identification for the invoice",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"due_datetime",description:"datetime the payment is due",type:{kind:"SCALAR",name:"DateTime",ofType:null},defaultValue:"null"},{name:"wallets",description:"list of wallets address",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"INPUT_OBJECT",name:"PlainWalletEmbeddedInput",ofType:null}}}},defaultValue:null}]},{name:"CreateStoreInput",kind:"INPUT",description:null,inputFields:[{name:"name",description:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"logo_url",description:"logo url",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:null},{name:"business_id",description:"pay account business id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},defaultValue:null},{name:"type",description:"type of the store",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"1"},{name:"default_timeout_seconds",description:"default timeout seconds for checkout intents",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"3600"},{name:"swidge_enabled",description:"whether Swidge cross-chain checkout is enabled for this store",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"true"},{name:"claim_link_claim_notify_enabled",description:"Whether AllScale sends merchant claim-notification emails for this store; defaults to false.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"false"},{name:"description",description:"description",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"scopes",description:"permission scopes",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},defaultValue:'["*"]'},{name:"ip_allowlist",description:"allowed IPs/CIDRs",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},defaultValue:"[]"},{name:"is_sandbox",description:"Whether to create the store in sandbox mode.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},defaultValue:"true"},{name:"rate_limit_per_minute",description:"Optional request-per-minute limit; defaults to 300, and 0 uses the platform default.",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"300"},{name:"replay_window_seconds",description:"override replay window seconds",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"},{name:"transaction_webhook",description:"transaction webhook url",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"claim_link_webhook_url",description:"Merchant webhook URL for claim-link terminal-state callbacks; distinct from transaction_webhook.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"redirect_url",description:"Redirect URL used after payment completes.",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"fee_rate",description:"fee rate",type:{kind:"SCALAR",name:"Decimal",ofType:null},defaultValue:"null"},{name:"accepted_stable_coins",description:"bitflag of accepted stablecoins for checkout (StableCoinFlag); null inherits from business",type:{kind:"SCALAR",name:"Int",ofType:null},defaultValue:"null"}]},{name:"Payment",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the payment"},{name:"recipient_business_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"business id of the payee/recipient"},{name:"sender_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id of the payer/sender"},{name:"sender_contact_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"contact id of the payer/sender"},{name:"payment_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"payment type of the payment"},{name:"accepted_stable_coins",type:{kind:"SCALAR",name:"Int",ofType:null},description:"bitflag of stablecoins accepted for this payment (StableCoinFlag). None on payments created before the multi-coin rollout."},{name:"payment_extra_info",type:{kind:"SCALAR",name:"String",ofType:null},description:"payment extra info of the payment, JSON object string"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"currency of the payment, only if the payment_type is CURRENCY"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the payment"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"amount of the payment in cents"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"amount of the payment in coins"},{name:"invoice_url",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"invoice url of the payment"},{name:"invoice_visible_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"invoice visible id of the pdf"},{name:"tax_id",type:{kind:"SCALAR",name:"String",ofType:null},description:"optional taxpayer identification for the invoice"},{name:"error_message",type:{kind:"SCALAR",name:"String",ofType:null},description:"error message of the payment if status is failed"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"memo of the payment"},{name:"due_datetime",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"datetime the payment is due"},{name:"display_amount",type:{kind:"SCALAR",name:"String",ofType:null},description:"display amount of the payment"},{name:"encrypted_id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Opaque payment identifier used in public payment links."}]},{name:"PaymentPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Payment",ofType:null}}}},description:null}]},{name:"PlainWalletEmbeddedInput",kind:"INPUT",description:null,inputFields:[{name:"id_str",description:"Unique identifier for the wallet",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null},{name:"chain",description:"Blockchain type of the address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:null},{name:"address",description:"Blockchain address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:null}]},{name:"QueryInput",kind:"INPUT",description:null,inputFields:[{name:"limit",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"skip",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},defaultValue:"0"},{name:"order_by",description:null,type:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}},defaultValue:"null"},{name:"raw_filter_str",description:null,type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},defaultValue:'"{}"'},{name:"created_at_lte",description:null,type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"created_at_gte",description:null,type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"}]},{name:"Store",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"Unique store identifier."},{name:"name",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"name"},{name:"type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"type of the store"},{name:"scopes",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}}}},description:"permission scopes"},{name:"is_sandbox",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Boolean",ofType:null}},description:"Whether this store uses sandbox mode."},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the store"},{name:"transaction_webhook",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction webhook url"},{name:"claim_link_webhook_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Merchant webhook URL for claim-link terminal-state callbacks; distinct from transaction_webhook."},{name:"redirect_url",type:{kind:"SCALAR",name:"String",ofType:null},description:"Redirect URL used after payment completes."}]},{name:"StoreCreateResult",kind:"OBJECT",description:null,fields:[{name:"store",type:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Store",ofType:null}},description:"store"},{name:"api_secret",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"Store API secret returned only when the store is created and never available again. Capture and store it securely immediately."}]},{name:"Transaction",kind:"OBJECT",description:null,fields:[{name:"created_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"created timestamp, UTC timezone"},{name:"updated_at",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"updated timestamp, UTC timezone"},{name:"id",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null}},description:"db id of the transaction record"},{name:"owner_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"owner user type of the record"},{name:"owner_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id that owns this transaction record"},{name:"owner_employee_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"employee id that owns this transaction record"},{name:"transaction_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"type of the transaction"},{name:"direction",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"direction of the transaction"},{name:"reference_type",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"reference type of the related record"},{name:"payment_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"payment id when reference_type is PAYMENT"},{name:"counterparty_business_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"business id of the counterparty"},{name:"counterparty_employee_id",type:{kind:"SCALAR",name:"ObjectIdScalar",ofType:null},description:"employee id of the counterparty"},{name:"counterparty_name",type:{kind:"SCALAR",name:"String",ofType:null},description:"name of the counterparty"},{name:"payment_type",type:{kind:"SCALAR",name:"Int",ofType:null},description:"payment type if this is a payment transaction"},{name:"currency",type:{kind:"SCALAR",name:"Int",ofType:null},description:"currency of the transaction"},{name:"amount_cents",type:{kind:"SCALAR",name:"Int",ofType:null},description:"amount in cents"},{name:"amount_coins",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"amount in coins"},{name:"status",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"status of the transaction"},{name:"memo",type:{kind:"SCALAR",name:"String",ofType:null},description:"memo of the transaction"},{name:"transaction_time",type:{kind:"SCALAR",name:"DateTime",ofType:null},description:"actual transaction time"},{name:"tx_hash",type:{kind:"SCALAR",name:"String",ofType:null},description:"hash of the transaction"},{name:"tx_block_chain",type:{kind:"SCALAR",name:"Int",ofType:null},description:"block chain of the transaction"},{name:"tx_from",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction sender address"},{name:"tx_to",type:{kind:"SCALAR",name:"String",ofType:null},description:"transaction receiver address"},{name:"tx_block_number",type:{kind:"SCALAR",name:"Int",ofType:null},description:"block number of the transaction"},{name:"total_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Total fee (network_fee + service_fee)"},{name:"network_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Network/gas fee"},{name:"service_fee",type:{kind:"SCALAR",name:"Decimal",ofType:null},description:"Allscale service fee (0.03%)"}]},{name:"TransactionPaginatedResponse",kind:"OBJECT",description:null,fields:[{name:"count",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:null},{name:"items",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"NON_NULL",name:null,ofType:{kind:"OBJECT",name:"Transaction",ofType:null}}}},description:null}]},{name:"UpdatePaymentInput",kind:"INPUT",description:null,inputFields:[{name:"memo",description:"memo of the payment",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"sender_business_id",description:"sender business id of the payer",type:{kind:"SCALAR",name:"String",ofType:null},defaultValue:"null"},{name:"due_datetime",description:"new payment deadline for an OVERDUE invoice. Only an overdue invoice may be extended, and only FORWARD. Extending past now also revives the invoice (back to SENT/ACKNOWLEDGED) so buyers can pay again.",type:{kind:"SCALAR",name:"DateTime",ofType:null},defaultValue:"null"}]},{name:"WalletEmbedded",kind:"OBJECT",description:null,fields:[{name:"id_str",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"wallet id"},{name:"chain",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"Int",ofType:null}},description:"Chain the wallet lives on, as the numeric BlockChainType value (NOT a name). `wallet list` decorates each wallet with the derived `chain_name` and `eip155_chain_id`."},{name:"address",type:{kind:"NON_NULL",name:null,ofType:{kind:"SCALAR",name:"String",ofType:null}},description:"wallet address"},{name:"coin_balances",type:{kind:"NON_NULL",name:null,ofType:{kind:"LIST",name:null,ofType:{kind:"OBJECT",name:"CoinBalanceEmbedded",ofType:null}}},description:"wallet balance"}]}];var nn=new Set(["SCALAR","ENUM"]),ja=new Set(["password","password_hash","totp_secret","credential","credentials","private_key","encryption_key"]),Va=[/(^|_)password(_|$)/i,/(^|_)secret(_|$)/i,/(^|_)token(_|$)/i,/(^|_)api[_-]?key(_|$)/i,/(^|_)signing[_-]?key(_|$)/i,/(^|_)private[_-]?key(_|$)/i,/(^|_)credential(_|$)/i],Ha=new Set(["CreateClaimLinkResult.claim_token","StoreCreateResult.api_secret"]),Wa=new Map([["StoreCreateResult.store",["id","name"]],["CreateClaimLinkResult.claim_link",["id","token_symbol","status"]]]),Ja=new Set(["token_symbol"]),za=new Set;function mt(e,n){return za.has(`${e}.${n}`)}function ht(e){return Ja.has(e.toLowerCase())?!1:ja.has(e)?!0:Va.some(n=>n.test(e))}function Xa(e,n){return Ha.has(`${e}.${n}`)}function yt(e){return e.kind==="NON_NULL"&&e.ofType?`${yt(e.ofType)}!`:e.kind==="LIST"&&e.ofType?`[${yt(e.ofType)}]`:e.name??"Unknown"}function Ce(e){let n=e;for(;n&&n.ofType;)n=n.ofType;return!n||!n.name?null:{kind:n.kind,name:n.name}}function Za(e,n){let t=n.find(a=>a.name===e);if(!t||t.kind==="SCALAR"||t.kind==="ENUM")return"";if(t.kind==="UNION")return"__typename";let i=t.fields??[];if(i.length===0)return"";let r=[],o=!1;for(let a of i){let s=Ce(a.type);if(!s)continue;if(nn.has(s.kind)){if(ht(a.name)&&!Xa(e,a.name)||mt(e,a.name))continue;r.push(a.name);continue}let c=Wa.get(`${e}.${a.name}`);if(c){let u=n.find(m=>m.name===s.name),p=new Set((u?.fields??[]).filter(m=>{let S=Ce(m.type);return S!==null&&nn.has(S.kind)&&!ht(m.name)}).map(m=>m.name)),f=c.filter(m=>!p.has(m));if(f.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${f.join(", ")}] that are not selectable scalars on ${s.name}; fix the entry or the public registry.`);let y=c.filter(m=>mt(s.name,m));if(y.length>0)throw new Error(`EXPLICIT_NESTED_DEFAULT_FIELDS["${e}.${a.name}"] names field(s) [${y.join(", ")}] that DEFAULT_SELECTION_EXCLUSIONS keeps out of default selections on ${s.name}; drop the field from the nested entry, or remove the exclusion if it is no longer true.`);r.push(`${a.name} { ${c.join(" ")} }`);continue}if(!o&&a.name==="items"&&a.type.kind==="NON_NULL"&&a.type.ofType?.kind==="LIST"){let u=Qa(a.type)?.name;if(u){let p=es(u,n);p&&r.push(`items { ${p} }`),o=!0}}}return r.length>0?r.join(" "):"__typename"}function Qa(e){return Ce(e)}function es(e,n){let t=n.find(o=>o.name===e);if(!t||t.kind==="UNION")return"__typename";let i=t.fields??[],r=[];for(let o of i){let a=Ce(o.type);if(a&&nn.has(a.kind)){if(ht(o.name)||mt(e,o.name))continue;r.push(o.name)}}return r.length>0?r.join(" "):"__typename"}function Ji(e,n,t){let i=ns(e.name),r=e.args.map(p=>{let f=yt(p.type);return p.defaultValue!==null&&p.defaultValue!==void 0?`$${p.name}: ${f} = ${p.defaultValue}`:`$${p.name}: ${f}`}).join(", "),o=e.args.map(p=>`${p.name}: $${p.name}`).join(", "),a=r.length>0?`${e.kind} ${i}(${r})`:`${e.kind} ${i}`,s=o.length>0?`${e.name}(${o})`:e.name,c=Ce(e.returnType),u;if(c&&nn.has(c.kind))u=s;else{let p=t&&t.trim().length>0?t.trim():c&&Za(c.name,n)||"__typename";u=`${s} { ${p} }`}return`${a} { ${u} }`}function zi(e,n){let i=e.args.filter(r=>r.type.kind==="NON_NULL"&&r.defaultValue===null).map(r=>r.name).filter(r=>!(r in n));return i.length===0?{ok:!0}:{ok:!1,missing:i}}function Xi(e,n,t){return e.find(i=>i.kind===n&&i.name===t)??null}function Zi(e){if(!e||typeof e!="object")return!1;let n=e.errors;return Array.isArray(n)&&n.length>0}function Qi(e,n=3){let t=e.errors;return!Array.isArray(t)||t.length===0?"":t.slice(0,n).map(i=>typeof i=="object"&&i!==null&&typeof i.message=="string"?i.message:JSON.stringify(i)).join("; ")}function ns(e){return e.replace(/[^_0-9A-Za-z]/g,"_")}var ts=new Set;var is=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","claim_link:read_only","claim_link:all","transaction:read_only","transaction:all","store:read_only","store:all","wallet:read_only","wallet:all"]),gt=new Set(["invoice:read_only","invoice:all","contact:read_only","contact:all","transaction:read_only","wallet:read_only","wallet:all","claim_link:read_only","claim_link:all","store:read_only","store:all"]),_t=new Set(["payroll","admin:user","admin:org","admin:audit"]);function tn(e){let n=e.lastIndexOf(":");return n===-1?e:e.slice(0,n)}function rn(e,n){if(e===n)return!0;let t=":read_only";return n.endsWith(t)&&e===`${n.slice(0,-t.length)}:all`}var rs=new Set(["cli_op:all"]),os=new Set([...rs].map(tn));var Gc=new Set([...[...is,...gt,...ts].map(tn),..._t,...os]);var as={payments:"invoice:read_only",payment:"invoice:read_only",sender_payments:"invoice:read_only",recipient_payments:"invoice:read_only",business_contact_by_email:"invoice:read_only",create_payment:"invoice:all",update_payment:"invoice:all",contact_by_email:"contact:read_only",contact:"contact:read_only",contacts:"contact:read_only",create_contact:"contact:all",transaction:"transaction:read_only",my_transactions:"transaction:read_only",business_transaction_records:"transaction:read_only",activities:"transaction:read_only",business_wallets:"wallet:read_only",business_invoice:"payroll:read_only",auto_payout_session_status:"store:read_only",create_store:"store:all",my_claim_links:"claim_link:read_only",claim_link:"claim_link:read_only",claim_link_fee_preview:"claim_link:read_only",claim_link_limits:"claim_link:read_only",create_claim_link:"claim_link:all",claim_link_funding_by_idempotency_key:"claim_link:all"},ss={business:"the broad `business` query is default-denied for agent keys by design \u2014 no scope grants it, because allowing the entry point would expose every nested field of the Business type"},ls=/API key scope not granted:\s*requires\s+(.+?),\s*key has\s+(.+?)\.?\s*$/i,cs=/is not available to API keys/i,er=/^[a-z_]+(?::[a-z_]+)*:[a-z_]+$/;function nr(e){if(typeof e!="string")return;let n=ls.exec(e);if(!n)return;let t=n[1].trim(),i=n[2].trim(),r=cs.test(t),o=!r&&er.test(t)?t:void 0,a;if(i.toLowerCase()==="none")a=[];else{let s=i.split(",").map(c=>c.trim()).filter(c=>er.test(c));a=s.length>0?s:void 0}if(!(o===void 0&&!r))return{required:o,granted:a,notAvailableToKeys:r}}function tr(e){let n=ss[e];if(n!==void 0)return{ungrantableReason:n};let t=as[e];if(t!==void 0)return{scope:t}}function ir(e){if(_t.has(tn(e)))return{kind:"ungrantable"};for(let n of gt)if(rn(n,e))return{kind:"approval_screen"};return{kind:"otp_login_only"}}var At=8100,ds=new Set([At]),us=new Set([...ds,3e3,3200,3300,3400,3500,3600,4e3,4100,4200,4300,4400,4600,4700,4800,4900,4901,5e3,5200,5300,5400,5500,5600,6050,8300,8301,8302,8306]);function St(e,n){let t=or(e),i={graphql_error_count:ps(e.errors),...t===void 0?{}:{backend_code:t}};if(t===2102)throw fs(e,n,i);if(t===429)throw new l("rate_limited",`GraphQL ${n.kind} '${n.operationName}' was rate limited. Retry after a backoff.`,i);if(t===1002)throw new l("auth.permission_denied",`The signed-in account is not permitted to perform GraphQL ${n.kind} '${n.operationName}'. This is a role or ownership restriction, not a missing agent-key scope \u2014 re-authorizing will not grant it.`,i);if(t!==void 0&&us.has(t))throw new l("not_found",`GraphQL ${n.kind} '${n.operationName}' could not find the requested resource.`,i);if(Zi(e))throw new l("input.invalid",`GraphQL ${n.kind} '${n.operationName}' returned errors: ${Qi(e)}`,i);if(t!==void 0)throw new l("input.invalid",`GraphQL ${n.kind} '${n.operationName}' failed with backend code ${t}.`,i)}function or(e){let n=rr(e.code);if(n!==void 0)return n;if(Array.isArray(e.errors))for(let t of e.errors){if(!t||typeof t!="object")continue;let i=t.extensions;if(!i||typeof i!="object")continue;let r=rr(i.code);if(r!==void 0)return r}}function rr(e){if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return e;if(typeof e=="string"&&/^\d+$/.test(e)){let n=Number(e);if(Number.isSafeInteger(n)&&n>0)return n}}function ps(e){return Array.isArray(e)?e.length:e==null?0:1}function fs(e,n,t){let i=`GraphQL ${n.kind} '${n.operationName}'`,r={...t,operation:n.operationName},o=nr(ms(e,or(e))),a=tr(n.operationName),s=o?.notAvailableToKeys===!0,c=o?.required??a?.scope,u=o?.granted,p=u===void 0?"":` This key holds ${u.length>0?u.join(", "):"no scopes"}.`;if(s||a?.ungrantableReason!==void 0){let f=a?.ungrantableReason!==void 0?`: ${a.ungrantableReason}`:"";return new l("auth.permission_denied",`${i} is not available to agent keys${f}. Re-authorizing will NOT help \u2014 no scope grants it.${p} Use a command that does not need it, or perform this action in the AllScale dashboard.`,{...r,missing_scopes:[],...u===void 0?{}:{granted_scopes:u},ungrantable:!0})}if(c!==void 0){let f=ir(c),y=f.kind==="ungrantable"?`\`${c}\` cannot be granted to any key (the backend clips this category to nothing), so re-authorizing will NOT help.`:f.kind==="approval_screen"?`Re-run \`allscale device-login\` and enable it on the approval screen, or \`${q()}\` with \`--scopes ${c}\`.`:`The browser approval screen does not offer \`${c}\`, so \`device-login\` cannot grant it \u2014 use \`${q()}\` with \`--scopes ${c}\`.`;return new l("auth.permission_denied",`The current agent key lacks \`${c}\`, required by ${i}.${p} ${y}`,{...r,missing_scopes:[c],...u===void 0?{}:{granted_scopes:u},...f.kind==="ungrantable"?{ungrantable:!0}:{}})}return new l("auth.permission_denied",`The current agent key does not have the scope required by ${i}.${p} Re-run \`allscale device-login\` (or \`${q()}\`) and grant the required scope.`,r)}function ms(e,n){let t=e.errors;if(typeof t=="string")return t;if(!Array.isArray(t))return"";let i=r=>{if(r===null||typeof r!="object")return;let o=r.message;return typeof o=="string"?o:void 0};if(n!==void 0)for(let r of t){if(r===null||typeof r!="object")continue;let o=r.extensions;if(!o||typeof o!="object")continue;let a=o.code;if(a===n||typeof a=="string"&&Number(a)===n){let c=i(r);if(c!==void 0)return c}}for(let r of t){let o=i(r);if(o!==void 0)return o}return""}async function v(e,n,t,i,r={}){let o=Xi(Hi,n,t);if(!o)throw new l("input.invalid",`No ${n} named '${t}' in the schema. Run \`allscale operations --kind ${n}\` to list options.`);let a=zi(o,i);if(!a.ok)throw new l("input.invalid",`Missing required variables for ${t}: ${a.missing.join(", ")}`,{required:a.missing});let s=Ji(o,Wi,r.selection);return hs(e,{...r,kind:n,operationName:o.name,document:s,variables:i})}async function hs(e,n){n.showDoc&&process.stderr.write(`${n.document}
|
|
17
|
+
`);let t=ft(e),i=n.path??"/api/secure/graphql",r=await t.request({method:"POST",path:i,responseKind:n.kind,body:{query:n.document,...Object.keys(n.variables).length>0?{variables:n.variables}:{},operationName:n.operationName}});St(r,{kind:n.kind,operationName:n.operationName});let o=r.data?.[n.operationName];return o===void 0?null:o}async function P(e){if(e.token)return{kind:"override",accessToken:e.token};let t=await Je({insecureStorage:e.insecureStorage}).get(e.profile),i=t?.api_base;return t?.agent_key?{kind:"agent",storedApiBase:i,businessId:kt(t.business_id),userEmail:kt(t.user_email),scopes:ys(t.scopes)}:t?.access_token?{kind:"human",storedApiBase:i,accessToken:t.access_token,userEmail:kt(t.user_email)}:{kind:"none"}}function kt(e){return typeof e=="string"&&e.length>0?e:void 0}function ys(e){if(!Array.isArray(e))return;let n=e.filter(t=>typeof t=="string"&&t.length>0);return n.length>0?n:void 0}function wt(e){let n=e.split(".");if(n.length!==3)throw new l("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 t;try{let i=Buffer.from(n[1].replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8");t=JSON.parse(i)}catch{throw ar()}if(typeof t!="object"||t===null||Array.isArray(t))throw ar();return t}function ar(){return new l("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.")}async function on(e,n){if(typeof n=="string"&&n.length>0)return n;let t=await P(e);switch(t.kind){case"override":case"human":return As(t.accessToken);case"agent":if(t.businessId!==void 0)return t.businessId;throw new l("input.invalid","Agent-key sessions carry no JWT to derive the business id from \u2014 pass --business-id explicitly. (Re-run `allscale device-login` to store your business id automatically.)");case"none":throw Ne({profile:e.profile,profileExplicit:e.profileExplicit});default:return sr(t)}}async function gs(e){let n=i=>{let r=wt(i);return typeof r.user_id=="string"&&r.user_id.length>0?r.user_id:void 0},t=await P(e);switch(t.kind){case"override":case"human":return n(t.accessToken);case"agent":return t.businessId;case"none":throw Ne({profile:e.profile,profileExplicit:e.profileExplicit});default:return sr(t)}}function sr(e){throw new l("internal",`Unhandled credential kind: ${JSON.stringify(e.kind)}`)}var _s=/^[0-9a-f]{24}$/i;async function lr(e,n){if(typeof n!="string"||n.length===0)return;if(!_s.test(n))throw new l("input.invalid",`--business-id '${n}' is not a valid business id (expected 24 hexadecimal characters). Omit the flag to use the business you are signed in as.`);let t=await gs(e);if(t===void 0){process.stderr.write(`Note: could not verify that --business-id '${n}' is your own business \u2014 this session stores no business id (an agent-key login predating the backend returning it). The command acts as the business you are signed in as regardless. Re-run \`allscale device-login\` to store it and enable this check.
|
|
18
|
+
`);return}if(t.toLowerCase()!==n.toLowerCase())throw new l("auth.permission_denied",`--business-id '${n}' is not the business you are signed in as. This command always acts as the authenticated business, so a different business id cannot be used. Omit the flag, or sign in as that business.`)}function As(e){let n=wt(e),t=typeof n.user_id=="string"?n.user_id:void 0;if(!t)throw new l("input.invalid","Could not infer --business-id from the cached JWT (no user_id claim). Pass --business-id explicitly.");return t}function Tt(e,n){return{lacks:e.kind==="agent"&&e.scopes!==void 0&&!e.scopes.some(i=>rn(i,n)),grantedScopes:e.kind==="agent"?e.scopes:void 0}}async function cr(e,n){return Tt(await P(e),n).lacks}var an="id email name address phone",le="contact:all";function dr(e){return`Re-run \`allscale ${Nn} --profile ${e}\` and turn the Contacts write toggle ON, also turn Invoices Allow changes ON, plus Wallets read unless you pass --wallet-id. A bare approval starts every category OFF and the new key REPLACES the old one, so anything left unselected is gone. Or mint a key with explicit scopes via \`${q(e)}\` including ${le} and invoice:all, plus wallet:read_only unless you pass --wallet-id \u2014 note it requests only that list with no implicit scope defaults, and the backend clips grants to your account's role; include every scope this workflow needs. Alternatively create the contact in the web app first, or pass an existing contact via --to-contact-id.`}function Ss(e){return e.startsWith("transport.")||e.startsWith("auth.")||e.startsWith("backend.")||e==="internal"||e==="rate_limited"}async function ks(e,n,t={}){let i;try{i=await v(e,"query","contact_by_email",{email:n},{selection:an,showDoc:!1})}catch(o){if(o instanceof l&&Ss(o.code))throw o;let a=o instanceof Error?o.message:String(o),s=t.notFoundMessage??`No contact found for "${n}". Re-run with \`--auto-create-contact\` (optionally \`--contact-name "<name>"\`) to create one, or pass the contact_id directly via --to-contact-id.`;throw new l("input.invalid",`${s}
|
|
19
|
+
Backend error: ${a}`)}let r=i;if(!r||typeof r.id!="string")throw new l("backend.internal",`contact_by_email returned an unexpected shape for "${n}".`,{received:i});return r}async function ur(e,n,t){let i=n.trim().toLowerCase(),o=(await v(e,"query","contacts",{owner_business_id_str:t,query_input:{limit:500,skip:0}},{selection:`count items { ${an} }`,showDoc:!1}))?.items??[];for(let a of o)if(typeof a?.email=="string"&&a.email.toLowerCase()===i)return a;return null}function ws(e){return e instanceof Error?/A contact named .* already exists/i.test(e.message):!1}async function pr(e,n,t={}){try{return await ks(e,n)}catch(c){if(!(c instanceof l)||c.code!=="input.invalid")throw c;if(!t.autoCreateName||t.autoCreateName.length===0)throw await cr(e,le)?new l("input.invalid",`${c.message}
|
|
20
|
+
Note: --auto-create-contact will not work with the current agent key either \u2014 it was minted without the ${le} scope that create_contact requires. `+dr(e.profile)):c}let i=await on(e,t.businessIdFlag),r=t.stderr??process.stderr,o=await ur(e,n,i);if(o)return r.write(`Found existing contact "${o.name??n}" <${n}> (id=${o.id}) via list fallback \u2014 skipping auto-create.
|
|
21
|
+
`),o;let a=Tt(await P(e),le);if(a.lacks)throw new l("auth.permission_denied",`Cannot auto-create a contact for "${n}": creating contacts requires the ${le} scope, and this agent key was minted without it (granted scopes are checked by the backend on each request). `+dr(e.profile),{operation:"create_contact",missing_scopes:[le],...a.grantedScopes===void 0?{}:{granted_scopes:a.grantedScopes}});let s;try{s=await v(e,"mutation","create_contact",{create_input:{owner_business_id:i,name:t.autoCreateName,email:n}},{selection:an,showDoc:!1})}catch(c){if(ws(c)){let u=await ur(e,n,i);if(u)return r.write(`create_contact reported "${t.autoCreateName}" already exists; recovered existing contact <${n}> (id=${u.id}) via list fallback.
|
|
22
22
|
`),u;throw new l("input.invalid",`Cannot auto-create contact "${t.autoCreateName}" \u2014 a contact with that name already exists on your business, but its email is not "${n}". Pass --contact-name "<different-name>" or look up the existing contact's id_str and use --to-contact-id instead.`)}throw c}if(!s||typeof s.id!="string")throw new l("backend.internal",`create_contact returned an unexpected shape for "${n}".`,{received:s});return r.write(`Auto-created contact "${t.autoCreateName}" <${n}> (id=${s.id}) \u2014 proceeding with invoice send.
|
|
23
|
-
`),s}async function
|
|
23
|
+
`),s}async function fr(e,n){let t=await v(e,"query","contact",{id_str:n},{selection:an,showDoc:!1}),i=t;if(!i||typeof i.id!="string")throw new l("backend.internal",`contact(id_str:"${n}") returned an unexpected shape.`,{received:t});return i}var gr=L(require("handlebars"));var mr=`<!DOCTYPE html>
|
|
24
24
|
<html lang="en">
|
|
25
25
|
<head>
|
|
26
26
|
<meta charset="UTF-8"/>
|
|
@@ -162,12 +162,12 @@ Note: --auto-create-contact will not work with the current agent key either \u20
|
|
|
162
162
|
</div>
|
|
163
163
|
</body>
|
|
164
164
|
</html>
|
|
165
|
-
`;var ks=new Set(["integer","group","decimal","fraction","minusSign","plusSign"]);function ws(e="0",n="en-US",t="USD",i=2){let r=_r(e),o;try{o=mr(n,t,i)}catch{o=mr(n,"USD",i)}return`${o.formatToParts(r).filter(c=>ks.has(c.type)).map(c=>c.value).join("")} ${t}`}function mr(e,n,t){return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:Math.max(2,t),currencyDisplay:"code"})}function ln(e){let n=typeof e=="string"?e:String(e??"0"),t=/^(-?)(\d+)(?:\.(\d+))?$/.exec(n);if(!t)return null;let i=(t[3]??"").replace(/0+$/,"");return{negative:t[1]==="-",units:BigInt(`${t[2]}${i}`),scale:i.length}}function gr(e){let n=10n**BigInt(e.scale),t=e.units/n,i=e.scale===0?"":(e.units%n).toString().padStart(e.scale,"0").replace(/0+$/,"");return`${e.negative&&e.units!==0n?"-":""}${t}${i.length>0?`.${i}`:""}`}function _r(e){return gr(ln(e)??{negative:!1,units:0n,scale:0})}function hr(e){if(e===void 0)return;let n=ln(e);return n&&n.units!==0n?e:void 0}function Ts(e,n){let t=ln(e),i=ln(n);return!t||!i?"0":gr({negative:t.negative!==i.negative,units:t.units*i.units,scale:t.scale+i.scale})}function bs(e){if(e==null||e==="")return"";let n=Number(e);return Number.isFinite(n)?n.toLocaleString("en-US"):String(e)}var Ls=/(\.\d{3})\d+/,Es=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/;function Ns(e,n){if(!e)return"";let t=String(e).replace(Ls,"$1"),i=new Date(Es.test(t)?`${t.replace(" ","T")}Z`:t);return Number.isNaN(i.getTime())?"Invalid Date":new Intl.DateTimeFormat("en-US",{month:"short",day:"2-digit",year:"numeric",...n?{timeZone:n}:{}}).format(i)}var sn=null;function Cs(){if(sn)return sn;let e=yr.default.create();return e.registerHelper("multiply",Ts),e.registerHelper("or",(n,t)=>!!n||!!t),e.registerHelper("formatQuantity",bs),e.registerHelper("formatDate",n=>Ns(n)),sn=e.compile(fr),sn}function Sr(e){let n=Cs(),t=e.currencyLabel??"USD",i={...e.invoiceData,discountApplied:hr(e.invoiceData.discountApplied),tax:hr(e.invoiceData.tax)};return n({invoiceData:i,invoiceTotal:e.invoiceTotal??i.total??"0",baseUrl:e.baseUrl??""},{helpers:{formatMoneyWithCode:(r,...o)=>ws(_r(r),"en-US",t,e.amountScale??2)}})}function kr(e=new Date){let n=new Date(e.getTime());return n.setDate(n.getDate()+30),n}function wr(e=new Date){return kr(e).toISOString()}function Tr(e,n,t){return new Date(e,n,t).toISOString()}function br(e){let n=Number(e.slice(0,4)),t=Number(e.slice(5,7)),i=Number(e.slice(8,10));return Tr(n,t-1,i)}function Lr(e=new Date){let n=kr(e);return Tr(n.getFullYear(),n.getMonth(),n.getDate())}function Ar(e){let n=new Date(e.getTime());return n.setHours(0,0,0,0),n.getTime()}function Er(e,n=new Date){let t=new Date(e),i=Number.isNaN(t.getTime())?30:Math.max(1,Math.round((Ar(t)-Ar(n))/864e5));return`Thank you for your business! Payment is due within ${i} ${i===1?"day":"days"}.`}var Tt=/^(?:0|[1-9]\d*)(?:\.\d+)?$/,Is=/^0(?:\.0+)?$/,Ie=128;function ve(e,n,t={}){if(n.length>Ie)throw new l("input.invalid",`${e} is too long; decimal values may contain at most ${Ie} characters.`);let i=n.trim();if(!Tt.test(i))throw new l("input.invalid",`${e} must be a decimal string without sign or exponent; got '${n}'.`);if(!t.allowZero&&Is.test(i))throw new l("input.invalid",`${e} must be greater than zero; got '${n}'.`);return i}function Nr(e,n,t,i="for the selected token and chain"){if((n.split(".")[1]??"").replace(/0+$/,"").length>t)throw new l("input.invalid",`${e} supports at most ${t} effective decimal places ${i}; got '${n}'. The CLI will not round a funds amount.`);return n}var vs=/^(\d{4})-(\d{2})-(\d{2})$/,Os=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(\.\d{1,9})?)?$/,Rs=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,9})?)?([Zz]|([+-])(\d{2}):?(\d{2}))$/,xs=/[T ]\d{2}:\d{2}:\d{2}(\.\d{1,9})/;function bt(e,n,t){let i=Number(t.y),r=Number(t.m),o=Number(t.d),a=new Date(Date.UTC(i,r-1,o));if(a.getUTCFullYear()!==i||a.getUTCMonth()!==r-1||a.getUTCDate()!==o)throw cn(e,`${t.y}-${t.m}-${t.d} is not a real calendar date`,n);let s=(c,u,p)=>{if(u===void 0)return;if(Number(u)>p)throw cn(e,`${c} ${u} is out of range (0-${p})`,n)};s("hour",t.hh,23),s("minute",t.mm,59),s("second",t.ss,59),s("offset hours",t.offH,23),s("offset minutes",t.offM,59)}function cn(e,n,t){return new l("input.invalid",`${t} '${e}' is not a valid date/time: ${n}. Accepted: YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss (both read as UTC), YYYY-MM-DDTHH:mm:ssZ, or YYYY-MM-DDTHH:mm:ss+08:00.`)}function Cr(e,n="--due"){let t=e.trim();if(t.length===0)throw cn(e,"it is empty",n);let i=Rs.exec(t);if(i){bt(t,n,{y:i[1],m:i[2],d:i[3],hh:i[4],mm:i[5],ss:i[6],offH:i[9],offM:i[10]});let a=`${i[1]}-${i[2]}-${i[3]}T${i[4]}:${i[5]}`,s=i[6]===void 0?"":`:${i[6]}`,c=xs.exec(t)?.[1]??"",u=i[7].toUpperCase()==="Z"?"Z":`${i[8]}${i[9]}:${i[10]}`;return`${a}${s}${c}${u}`}let r=Os.exec(t);if(r){bt(t,n,{y:r[1],m:r[2],d:r[3],hh:r[4],mm:r[5],ss:r[6]});let[,a,s,c,u,p,f,y]=r;return`${a}-${s}-${c}T${u}:${p}:${f??"00"}${y??""}Z`}let o=vs.exec(t);if(o)return bt(t,n,{y:o[1],m:o[2],d:o[3],hh:"00",mm:"00"}),`${o[1]}-${o[2]}-${o[3]}T00:00:00Z`;throw cn(e,"it is not an ISO 8601 date or date-time",n)}function Ps(e){if(e==null)return null;let n=typeof e=="string"?Number(e):e;return Number.isFinite(n)?n===0?null:n===1?1:n===2?2:"unsupported":"unsupported"}function Ir(e){let n=Ps(e);return n===null||n==="unsupported"?null:1<<n-1}var Bd=String(Number.MAX_SAFE_INTEGER);var Us=Math.floor(Number.MAX_SAFE_INTEGER/100),Ds=BigInt(Us),$s=2147483647n,Bs=10,de=2,dn=0,Fs=6,Lt=new Set([1,2]),Ms=new Set([dn,...Lt]),un=class e extends we{static description="Send an invoice by email. Resolves the contact, selects receiving wallets, renders a minimal HTML invoice, and submits create_payment through the authenticated session. No browser ceremony \u2014 the payer signs when they pay, not when you issue. Returns a fixed summary (payment_id, contact, amount, wallet count) rather than a GraphQL selection, which is why there is no --select here; read the created invoice back with `invoice get \"$PAYMENT_ID\" --select 'id status amount_coins display_amount payment_type'`, using the payment_id returned by this command. The follow-up reflects the default USDT path; display_amount remains the denomination-aware value. Note the direction: an invoice you send lists YOU as the payee, so it appears under `invoice received`, not `invoice sent`.";static examples=["$ allscale invoice send --to-email client@example.com --amount 1.00",`$ allscale invoice send --to-email client@example.com --amount 250 --payment-type 2 --currency-label USDC --memo "January retainer" --due "$(node -p 'new Date(Date.now()+30*864e5).toISOString().slice(0,10)')"`,'$ allscale invoice send --to-contact-id 695da2cd3b9598f5edcdcb56 --amount 50 --line "Design|1|30.00" --line "Copy|1|20.00"','$ allscale invoice send --to-email client@example.com --amount 75 --line "Consulting retainer"','$ allscale invoice send --to-email client@example.com --amount 350 --line "Discovery (4h)|4|25.00" --line "Implementation (10h)|10|25.00"','$ allscale invoice send --to-email client@example.com --line "Discovery (4h)|4|25.00" --line "Implementation (10h)|10|25.00"',"$ allscale invoice send --to-email client@example.com --amount 100 --wallet-id 66ac1234567890abcdef0123","$ allscale invoice send --to-email newclient@example.com --amount 100 --auto-create-contact",'$ allscale invoice send --to-email billing@acme.com --amount 100 --auto-create-contact --contact-name "Acme Inc"'];static requiresInput=!0;static flags={"to-email":w.Flags.string({helpGroup:"REQUIRED (ONE OF)",description:"Email of the contact to invoice. Resolves via contact_by_email. If no contact exists for the email, add --auto-create-contact to create one before invoicing. Mutually exclusive with --to-contact-id.",exclusive:["to-contact-id"]}),"to-contact-id":w.Flags.string({helpGroup:"REQUIRED (ONE OF)",description:"Contact id directly (skip the email lookup). Mutually exclusive with --to-email.",exclusive:["to-email"]}),amount:w.Flags.string({helpGroup:"CONDITIONAL",description:'Exact decimal amount: USDT/USDC accept up to 6 effective decimal places (minimum 0.10), while fiat accepts up to 2. Redundant trailing zeroes are allowed and canonicalized; the CLI never rounds or truncates. Optional when every --line is the three-field "<description>|<quantity>|<amount>" form \u2014 in that case the CLI sums the lines to derive the invoice total. Required otherwise.'}),"auto-create-contact":w.Flags.boolean({description:"If --to-email doesn't resolve to an existing contact, auto-create the contact (using the email + your business as owner; name defaults to the full email address, override with --contact-name) and proceed with the invoice. Ignored when the contact already exists (safe to leave on in scripts). Requires --to-email; not valid with --to-contact-id.",default:!1,exclusive:["to-contact-id"]}),"contact-name":w.Flags.string({description:"Display name to use when --auto-create-contact creates a new contact. Optional \u2014 defaults to the full email address (unique enough to avoid a per-business name collision). Has no effect when the contact already exists or when --auto-create-contact is not set.",exclusive:["to-contact-id"]}),"currency-label":w.Flags.string({description:'Label shown after each amount in the rendered invoice (e.g. "250.00 USDT"). Display only \u2014 it changes no amount, no asset, and nothing the payer is charged. Which stablecoins the invoice ACCEPTS is decided by --payment-type when you pass it explicitly (=1 USDT, =2 USDC); omit that flag and the invoice accepts whatever your business is configured for. Defaults to the label matching --payment-type (USDT or USDC; USD for --payment-type=0 fiat \u2014 pass this flag explicitly for a non-USD --currency-int).'}),"currency-int":w.Flags.integer({description:"Fiat currency code, such as USD=1 or AED=2. Only sent when --payment-type=0 (fiat invoice); ignored for stablecoin payment types. Default: 1 (USD).",default:1}),"payment-type":w.Flags.integer({description:"What the invoice is denominated in AND which stablecoin it may be paid with: 0 = fiat (pair with --currency-int), 1 = USDT, 2 = USDC. Passing 1 or 2 EXPLICITLY pins the invoice to that coin \u2014 a payment arriving in the other stablecoin is rejected, and the payer's email names only this coin. Omit the flag and the invoice accepts whichever stablecoins your business is configured for (it is still denominated in USDT, the default). For 0 the amount is fiat but settlement is still in a stablecoin, so the payer may likewise use any coin your business accepts. Any other value is rejected locally (exit 2) \u2014 the backend would otherwise issue an invoice in an undocumented asset. Default: 1 (denomination only \u2014 omitting the flag pins nothing).",default:1}),memo:w.Flags.string({description:'Free-form invoice memo / description shown to the payer. When omitted, defaults to the same note the web invoice editor generates: "Thank you for your business! Payment is due within N days." with N derived from the due date (30 unless --due says otherwise).'}),due:w.Flags.string({description:`Invoice due date / datetime (ISO 8601), e.g. YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss, YYYY-MM-DDTHH:mm:ssZ, or YYYY-MM-DDTHH:mm:ss+08:00. A value without a UTC offset is read as UTC (so a date-only value means midnight UTC) \u2014 stated explicitly because interpreting it in the local timezone would make the same command mean different things on different machines. When omitted, defaults to 30 days from now, matching the web invoice editor. The rendered document shows the NORMALIZED date in the web's display format ("MMM DD, YYYY"), not the raw flag text. The examples compute the date with POSIX command substitution, which sh/bash/zsh and PowerShell expand but cmd.exe does not; on cmd.exe pass an explicit date instead.`}),"tax-id":w.Flags.string({description:"Optional taxpayer identification shown in the invoice footer."}),line:w.Flags.string({description:`Line item on the rendered invoice. Repeatable. Two forms: "<description>" (qty=1, amount=full --amount) or "<description>|<quantity>|<amount>" (all explicit; same exact decimal precision as --amount). Use the three-field form for more than one line: the single-field form gives EVERY line the full --amount, so two such lines sum to twice --amount and trigger the totals-mismatch warning. With three-field lines you may omit --amount entirely and the CLI sums them. Every line total (quantity x amount) must fit the selected denomination's precision, whether or not --amount is given; the CLI never rounds it.`,multiple:!0}),"wallet-id":w.Flags.string({description:"id of a wallet to receive payment, as listed by `wallet list`. Repeatable. When given, the backend resolves and validates the ids (no wallet read needed \u2014 works with an invoice-scope-only agent key). When omitted, the CLI fetches your wallets via the narrow `business_wallets` query, which requires the wallet:read_only scope on an agent key.",multiple:!0}),"business-id":w.Flags.string({char:"b",description:"Your own business id. Optional and redundant \u2014 the invoice is always issued as the business you are signed in as, and contacts and wallets always resolve against it. Supplying a different business id is rejected rather than silently ignored; omit the flag unless a script needs to assert which business it is acting as."}),"show-doc":w.Flags.boolean({description:"Print the generated GraphQL document to stderr.",default:!1}),...we.baseFlags};async runCommand(){let{flags:n,metadata:t}=await this.parse(e),i=n.amount,r=n.line??[],o=n["payment-type"];if(!Ms.has(o))throw new l("input.invalid",`--payment-type ${o} is not a supported invoice denomination. Accepted: 0 (CURRENCY/fiat, pair with --currency-int), 1 (USDT), 2 (USDC).`);let a=t.flags["payment-type"]?.setFromDefault!==!0,s=n["currency-label"]??(o===0?"USD":Hn(o)),c=new Date,u=n.due?.trim(),p=u===void 0||u.length===0?wr(c):Cr(u),f=u===void 0||u.length===0?Lr(c):br(p),y=n.memo??Er(f,c),{amount:m,amountSource:A,parsedLines:b,subtotal:U}=vr({paymentType:o,rawAmount:i,rawLines:r,currencyLabel:s}),Z=n["currency-int"];if(o===dn&&(!Number.isInteger(Z)||Z<1))throw new l("input.invalid",`--currency-int=${Z} is not a valid Currency enum value (the enum starts at USD=1). Pass --currency-int=1 for USD, or change --payment-type to a stablecoin (USDT=1, USDC=2, ...) where currency is unused.`);A==="derived-from-lines"?X.stderr.write(`Deriving --amount from --line totals: ${m.canonical} ${s}.
|
|
165
|
+
`;var Ts=new Set(["integer","group","decimal","fraction","minusSign","plusSign"]);function bs(e="0",n="en-US",t="USD",i=2){let r=Ar(e),o;try{o=hr(n,t,i)}catch{o=hr(n,"USD",i)}return`${o.formatToParts(r).filter(c=>Ts.has(c.type)).map(c=>c.value).join("")} ${t}`}function hr(e,n,t){return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:Math.max(2,t),currencyDisplay:"code"})}function ln(e){let n=typeof e=="string"?e:String(e??"0"),t=/^(-?)(\d+)(?:\.(\d+))?$/.exec(n);if(!t)return null;let i=(t[3]??"").replace(/0+$/,"");return{negative:t[1]==="-",units:BigInt(`${t[2]}${i}`),scale:i.length}}function _r(e){let n=10n**BigInt(e.scale),t=e.units/n,i=e.scale===0?"":(e.units%n).toString().padStart(e.scale,"0").replace(/0+$/,"");return`${e.negative&&e.units!==0n?"-":""}${t}${i.length>0?`.${i}`:""}`}function Ar(e){return _r(ln(e)??{negative:!1,units:0n,scale:0})}function yr(e){if(e===void 0)return;let n=ln(e);return n&&n.units!==0n?e:void 0}function Ls(e,n){let t=ln(e),i=ln(n);return!t||!i?"0":_r({negative:t.negative!==i.negative,units:t.units*i.units,scale:t.scale+i.scale})}function Es(e){if(e==null||e==="")return"";let n=Number(e);return Number.isFinite(n)?n.toLocaleString("en-US"):String(e)}var Ns=/(\.\d{3})\d+/,Cs=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/;function Is(e,n){if(!e)return"";let t=String(e).replace(Ns,"$1"),i=new Date(Cs.test(t)?`${t.replace(" ","T")}Z`:t);return Number.isNaN(i.getTime())?"Invalid Date":new Intl.DateTimeFormat("en-US",{month:"short",day:"2-digit",year:"numeric",...n?{timeZone:n}:{}}).format(i)}var sn=null;function vs(){if(sn)return sn;let e=gr.default.create();return e.registerHelper("multiply",Ls),e.registerHelper("or",(n,t)=>!!n||!!t),e.registerHelper("formatQuantity",Es),e.registerHelper("formatDate",n=>Is(n)),sn=e.compile(mr),sn}function Sr(e){let n=vs(),t=e.currencyLabel??"USD",i={...e.invoiceData,discountApplied:yr(e.invoiceData.discountApplied),tax:yr(e.invoiceData.tax)};return n({invoiceData:i,invoiceTotal:e.invoiceTotal??i.total??"0",baseUrl:e.baseUrl??""},{helpers:{formatMoneyWithCode:(r,...o)=>bs(Ar(r),"en-US",t,e.amountScale??2)}})}function wr(e=new Date){let n=new Date(e.getTime());return n.setDate(n.getDate()+30),n}function Tr(e=new Date){return wr(e).toISOString()}function br(e,n,t){return new Date(e,n,t).toISOString()}function Lr(e){let n=Number(e.slice(0,4)),t=Number(e.slice(5,7)),i=Number(e.slice(8,10));return br(n,t-1,i)}function Er(e=new Date){let n=wr(e);return br(n.getFullYear(),n.getMonth(),n.getDate())}function kr(e){let n=new Date(e.getTime());return n.setHours(0,0,0,0),n.getTime()}function Nr(e,n=new Date){let t=new Date(e),i=Number.isNaN(t.getTime())?30:Math.max(1,Math.round((kr(t)-kr(n))/864e5));return`Thank you for your business! Payment is due within ${i} ${i===1?"day":"days"}.`}var bt=/^(?:0|[1-9]\d*)(?:\.\d+)?$/,Os=/^0(?:\.0+)?$/,Ie=128;function ve(e,n,t={}){if(n.length>Ie)throw new l("input.invalid",`${e} is too long; decimal values may contain at most ${Ie} characters.`);let i=n.trim();if(!bt.test(i))throw new l("input.invalid",`${e} must be a decimal string without sign or exponent; got '${n}'.`);if(!t.allowZero&&Os.test(i))throw new l("input.invalid",`${e} must be greater than zero; got '${n}'.`);return i}function Cr(e,n,t,i="for the selected token and chain"){if((n.split(".")[1]??"").replace(/0+$/,"").length>t)throw new l("input.invalid",`${e} supports at most ${t} effective decimal places ${i}; got '${n}'. The CLI will not round a funds amount.`);return n}var Rs=/^(\d{4})-(\d{2})-(\d{2})$/,xs=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(\.\d{1,9})?)?$/,Ps=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,9})?)?([Zz]|([+-])(\d{2}):?(\d{2}))$/,Us=/[T ]\d{2}:\d{2}:\d{2}(\.\d{1,9})/;function Lt(e,n,t){let i=Number(t.y),r=Number(t.m),o=Number(t.d),a=new Date(Date.UTC(i,r-1,o));if(a.getUTCFullYear()!==i||a.getUTCMonth()!==r-1||a.getUTCDate()!==o)throw cn(e,`${t.y}-${t.m}-${t.d} is not a real calendar date`,n);let s=(c,u,p)=>{if(u===void 0)return;if(Number(u)>p)throw cn(e,`${c} ${u} is out of range (0-${p})`,n)};s("hour",t.hh,23),s("minute",t.mm,59),s("second",t.ss,59),s("offset hours",t.offH,23),s("offset minutes",t.offM,59)}function cn(e,n,t){return new l("input.invalid",`${t} '${e}' is not a valid date/time: ${n}. Accepted: YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss (both read as UTC), YYYY-MM-DDTHH:mm:ssZ, or YYYY-MM-DDTHH:mm:ss+08:00.`)}function Ir(e,n="--due"){let t=e.trim();if(t.length===0)throw cn(e,"it is empty",n);let i=Ps.exec(t);if(i){Lt(t,n,{y:i[1],m:i[2],d:i[3],hh:i[4],mm:i[5],ss:i[6],offH:i[9],offM:i[10]});let a=`${i[1]}-${i[2]}-${i[3]}T${i[4]}:${i[5]}`,s=i[6]===void 0?"":`:${i[6]}`,c=Us.exec(t)?.[1]??"",u=i[7].toUpperCase()==="Z"?"Z":`${i[8]}${i[9]}:${i[10]}`;return`${a}${s}${c}${u}`}let r=xs.exec(t);if(r){Lt(t,n,{y:r[1],m:r[2],d:r[3],hh:r[4],mm:r[5],ss:r[6]});let[,a,s,c,u,p,f,y]=r;return`${a}-${s}-${c}T${u}:${p}:${f??"00"}${y??""}Z`}let o=Rs.exec(t);if(o)return Lt(t,n,{y:o[1],m:o[2],d:o[3],hh:"00",mm:"00"}),`${o[1]}-${o[2]}-${o[3]}T00:00:00Z`;throw cn(e,"it is not an ISO 8601 date or date-time",n)}function Ds(e){if(e==null)return null;let n=typeof e=="string"?Number(e):e;return Number.isFinite(n)?n===0?null:n===1?1:n===2?2:"unsupported":"unsupported"}function vr(e){let n=Ds(e);return n===null||n==="unsupported"?null:1<<n-1}var qd=String(Number.MAX_SAFE_INTEGER);var $s=Math.floor(Number.MAX_SAFE_INTEGER/100),Bs=BigInt($s),Fs=2147483647n,Ms=10,de=2,dn=0,qs=6,Et=new Set([1,2]),Gs=new Set([dn,...Et]),un=class e extends we{static description="Send an invoice by email. Resolves the contact, selects receiving wallets, renders a minimal HTML invoice, and submits create_payment through the authenticated session. No browser ceremony \u2014 the payer signs when they pay, not when you issue. Returns a fixed summary (payment_id, contact, amount, wallet count) rather than a GraphQL selection, which is why there is no --select here; read the created invoice back with `invoice get \"$PAYMENT_ID\" --select 'id status amount_coins display_amount payment_type'`, using the payment_id returned by this command. The follow-up reflects the default USDT path; display_amount remains the denomination-aware value. Note the direction: an invoice you send lists YOU as the payee, so it appears under `invoice received`, not `invoice sent`.";static examples=["$ allscale invoice send --to-email client@example.com --amount 1.00",`$ allscale invoice send --to-email client@example.com --amount 250 --payment-type 2 --currency-label USDC --memo "January retainer" --due "$(node -p 'new Date(Date.now()+30*864e5).toISOString().slice(0,10)')"`,'$ allscale invoice send --to-contact-id 695da2cd3b9598f5edcdcb56 --amount 50 --line "Design|1|30.00" --line "Copy|1|20.00"','$ allscale invoice send --to-email client@example.com --amount 75 --line "Consulting retainer"','$ allscale invoice send --to-email client@example.com --amount 350 --line "Discovery (4h)|4|25.00" --line "Implementation (10h)|10|25.00"','$ allscale invoice send --to-email client@example.com --line "Discovery (4h)|4|25.00" --line "Implementation (10h)|10|25.00"',"$ allscale invoice send --to-email client@example.com --amount 100 --wallet-id 66ac1234567890abcdef0123","$ allscale invoice send --to-email newclient@example.com --amount 100 --auto-create-contact",'$ allscale invoice send --to-email billing@acme.com --amount 100 --auto-create-contact --contact-name "Acme Inc"'];static requiresInput=!0;static flags={"to-email":w.Flags.string({helpGroup:"REQUIRED (ONE OF)",description:"Email of the contact to invoice. Resolves via contact_by_email. If no contact exists for the email, add --auto-create-contact to create one before invoicing. Mutually exclusive with --to-contact-id.",exclusive:["to-contact-id"]}),"to-contact-id":w.Flags.string({helpGroup:"REQUIRED (ONE OF)",description:"Contact id directly (skip the email lookup). Mutually exclusive with --to-email.",exclusive:["to-email"]}),amount:w.Flags.string({helpGroup:"CONDITIONAL",description:'Exact decimal amount: USDT/USDC accept up to 6 effective decimal places (minimum 0.10), while fiat accepts up to 2. Redundant trailing zeroes are allowed and canonicalized; the CLI never rounds or truncates. Optional when every --line is the three-field "<description>|<quantity>|<amount>" form \u2014 in that case the CLI sums the lines to derive the invoice total. Required otherwise.'}),"auto-create-contact":w.Flags.boolean({description:"If --to-email doesn't resolve to an existing contact, auto-create the contact (using the email + your business as owner; name defaults to the full email address, override with --contact-name) and proceed with the invoice. Ignored when the contact already exists (safe to leave on in scripts). Under an agent key, the full send needs contact:all and invoice:all, plus wallet:read_only unless you pass --wallet-id. A bare device-login approval starts every category OFF and its new key replaces the old one, so select Contacts write and Invoices Allow changes plus Wallets read (unless using --wallet-id) in the same re-login. Requires --to-email; not valid with --to-contact-id.",default:!1,exclusive:["to-contact-id"]}),"contact-name":w.Flags.string({description:"Display name to use when --auto-create-contact creates a new contact. Optional \u2014 defaults to the full email address (unique enough to avoid a per-business name collision). Has no effect when the contact already exists or when --auto-create-contact is not set.",exclusive:["to-contact-id"]}),"currency-label":w.Flags.string({description:'Label shown after each amount in the rendered invoice (e.g. "250.00 USDT"). Display only \u2014 it changes no amount, no asset, and nothing the payer is charged. Which stablecoins the invoice ACCEPTS is decided by --payment-type when you pass it explicitly (=1 USDT, =2 USDC); omit that flag and the invoice accepts whatever your business is configured for. Defaults to the label matching --payment-type (USDT or USDC; USD for --payment-type=0 fiat \u2014 pass this flag explicitly for a non-USD --currency-int).'}),"currency-int":w.Flags.integer({description:"Fiat currency code, such as USD=1 or AED=2. Only sent when --payment-type=0 (fiat invoice); ignored for stablecoin payment types. Default: 1 (USD).",default:1}),"payment-type":w.Flags.integer({description:"What the invoice is denominated in AND which stablecoin it may be paid with: 0 = fiat (pair with --currency-int), 1 = USDT, 2 = USDC. Passing 1 or 2 EXPLICITLY pins the invoice to that coin \u2014 a payment arriving in the other stablecoin is rejected, and the payer's email names only this coin. Omit the flag and the invoice accepts whichever stablecoins your business is configured for (it is still denominated in USDT, the default). For 0 the amount is fiat but settlement is still in a stablecoin, so the payer may likewise use any coin your business accepts. Any other value is rejected locally (exit 2) \u2014 the backend would otherwise issue an invoice in an undocumented asset. Default: 1 (denomination only \u2014 omitting the flag pins nothing).",default:1}),memo:w.Flags.string({description:'Free-form invoice memo / description shown to the payer. When omitted, defaults to the same note the web invoice editor generates: "Thank you for your business! Payment is due within N days." with N derived from the due date (30 unless --due says otherwise).'}),due:w.Flags.string({description:`Invoice due date / datetime (ISO 8601), e.g. YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss, YYYY-MM-DDTHH:mm:ssZ, or YYYY-MM-DDTHH:mm:ss+08:00. A value without a UTC offset is read as UTC (so a date-only value means midnight UTC) \u2014 stated explicitly because interpreting it in the local timezone would make the same command mean different things on different machines. When omitted, defaults to 30 days from now, matching the web invoice editor. The rendered document shows the NORMALIZED date in the web's display format ("MMM DD, YYYY"), not the raw flag text. The examples compute the date with POSIX command substitution, which sh/bash/zsh and PowerShell expand but cmd.exe does not; on cmd.exe pass an explicit date instead.`}),"tax-id":w.Flags.string({description:"Optional taxpayer identification shown in the invoice footer."}),line:w.Flags.string({description:`Line item on the rendered invoice. Repeatable. Two forms: "<description>" (qty=1, amount=full --amount) or "<description>|<quantity>|<amount>" (all explicit; same exact decimal precision as --amount). Use the three-field form for more than one line: the single-field form gives EVERY line the full --amount, so two such lines sum to twice --amount and trigger the totals-mismatch warning. With three-field lines you may omit --amount entirely and the CLI sums them. Every line total (quantity x amount) must fit the selected denomination's precision, whether or not --amount is given; the CLI never rounds it.`,multiple:!0}),"wallet-id":w.Flags.string({description:"id of a wallet to receive payment, as listed by `wallet list`. Repeatable. When given, the backend resolves and validates the ids (no wallet read needed \u2014 works with an invoice-scope-only agent key). When omitted, the CLI fetches your wallets via the narrow `business_wallets` query, which requires the wallet:read_only scope on an agent key.",multiple:!0}),"business-id":w.Flags.string({char:"b",description:"Your own business id. Optional and redundant \u2014 the invoice is always issued as the business you are signed in as, and contacts and wallets always resolve against it. Supplying a different business id is rejected rather than silently ignored; omit the flag unless a script needs to assert which business it is acting as."}),"show-doc":w.Flags.boolean({description:"Print the generated GraphQL document to stderr.",default:!1}),...we.baseFlags};async runCommand(){let{flags:n,metadata:t}=await this.parse(e),i=n.amount,r=n.line??[],o=n["payment-type"];if(!Gs.has(o))throw new l("input.invalid",`--payment-type ${o} is not a supported invoice denomination. Accepted: 0 (CURRENCY/fiat, pair with --currency-int), 1 (USDT), 2 (USDC).`);let a=t.flags["payment-type"]?.setFromDefault!==!0,s=n["currency-label"]??(o===0?"USD":Vn(o)),c=new Date,u=n.due?.trim(),p=u===void 0||u.length===0?Tr(c):Ir(u),f=u===void 0||u.length===0?Er(c):Lr(p),y=n.memo??Nr(f,c),{amount:m,amountSource:S,parsedLines:b,subtotal:U}=Or({paymentType:o,rawAmount:i,rawLines:r,currencyLabel:s}),Z=n["currency-int"];if(o===dn&&(!Number.isInteger(Z)||Z<1))throw new l("input.invalid",`--currency-int=${Z} is not a valid Currency enum value (the enum starts at USD=1). Pass --currency-int=1 for USD, or change --payment-type to a stablecoin (USDT=1, USDC=2, ...) where currency is unused.`);S==="derived-from-lines"?X.stderr.write(`Deriving --amount from --line totals: ${m.canonical} ${s}.
|
|
166
166
|
`):U.atomicUnits!==m.atomicUnits&&X.stderr.write(`Warning: --line totals sum to ${U.canonical} ${s}, but --amount is ${m.canonical} ${s}. The recipient is charged --amount; the rendered invoice shows the line breakdown.
|
|
167
|
-
`);let C=this.resolveContext(n),I=n["wallet-id"]??[];if(I.some(g=>g.length===0||g.trim()!==g)||new Set(I).size!==I.length||I.length>64)throw new l("input.invalid","--wallet-id values must be non-empty, unique, unpadded wallet ids (maximum 64).");let
|
|
168
|
-
`),!pe&&gn.length===0)throw new l("input.invalid","No noncustodial wallets found on your business that the invoice flow accepts. Add a wallet on a supported chain (ETH/BASE/BNB/ARBITRUM/POLYGON/OPTIMISM/SOL/TRON) first, or pin wallets explicitly with --wallet-id.");let fe=await
|
|
169
|
-
`)}}}y.length>0&&(D.memo=y),D.due_datetime=p,n["tax-id"]&&(D.tax_id=n["tax-id"]);let
|
|
170
|
-
`),{payment_id:(await v(C,"mutation","create_payment",{payment:D,wallet_ids:
|
|
167
|
+
`);let C=this.resolveContext(n),I=n["wallet-id"]??[];if(I.some(g=>g.length===0||g.trim()!==g)||new Set(I).size!==I.length||I.length>64)throw new l("input.invalid","--wallet-id values must be non-empty, unique, unpadded wallet ids (maximum 64).");let Ct=n["to-email"],fn=n["to-contact-id"];if(!Ct&&!fn)throw new l("input.invalid","One of --to-email or --to-contact-id is required.");await lr(C,n["business-id"]);let ue,Q,mn,hn,yn;if(fn){let g=await fr(C,fn);ue=g.id,Q=g.email,mn=g.name,hn=g.address??void 0,yn=g.phone??void 0}else{let g=Ct,me=n["auto-create-contact"]?n["contact-name"]??g:void 0,B=await pr(C,g,{autoCreateName:me,businessIdFlag:n["business-id"]});ue=B.id,Q=B.email,mn=B.name,hn=B.address??void 0,yn=B.phone??void 0}let pe=I.length>0,It=pe?[]:await zs(C),gn=It.filter(g=>jn(g.chain)),_n=It.filter(g=>!jn(g.chain));if(!pe&&_n.length>0&&X.stderr.write(`Skipping ${_n.length} wallet(s) on chains the invoice flow doesn't accept (create_payment requires notification-supported chains): ${_n.map(g=>`chain=${g.chain}`).join(", ")}
|
|
168
|
+
`),!pe&&gn.length===0)throw new l("input.invalid","No noncustodial wallets found on your business that the invoice flow accepts. Add a wallet on a supported chain (ETH/BASE/BNB/ARBITRUM/POLYGON/OPTIMISM/SOL/TRON) first, or pin wallets explicitly with --wallet-id.");let fe=await Xs(C,n["business-id"]);fe.notice&&X.stderr.write(fe.notice);let An=[...b.items];An.length===0&&An.push({description:"Invoice",quantity:"1",amount:m.canonical});let Pr=Sr({invoiceData:{date:c.toISOString(),dueDate:f,from:{name:fe.name,email:fe.email,phone:fe.phone},to:{name:mn??Q,email:Q,address:hn,phone:yn},items:An,note:y,taxId:n["tax-id"],subtotal:U.canonical,total:m.canonical},invoiceTotal:m.canonical,amountScale:m.scale,currencyLabel:s,baseUrl:C.apiBase}),D={sender_contact_id:ue,payment_type:o,html_template:Pr,wallets:[]};o===dn?(D.currency=Z,D.amount_cents=Number(m.atomicUnits)):D.amount_coins=m.canonical;let vt=a?vr(o):null;if(vt!==null){D.accepted_stable_coins=vt;let g=n["currency-label"];if(g){let me=Vn(o).toUpperCase(),B=g.trim().toUpperCase(),Ot=pi().map(F=>F.toUpperCase()).filter(F=>F!==me&&new RegExp(`\\b${F}\\b`).test(B));if(Ot.length>0){let F=Ot.join(" / ");X.stderr.write(`Warning: --currency-label ${F} contradicts --payment-type ${o} (${me}). The invoice document will read ${JSON.stringify(T(g))}, but this invoice accepts ${me} only \u2014 a payer who follows the label and sends ${F} will have the payment rejected. Drop --currency-label to let it follow --payment-type.
|
|
169
|
+
`)}}}y.length>0&&(D.memo=y),D.due_datetime=p,n["tax-id"]&&(D.tax_id=n["tax-id"]);let Ur=pe?I:gn.map(g=>g.id_str);return X.stderr.write(`Issuing invoice for ${m.canonical} ${s} to ${Q} (contact ${ue})...
|
|
170
|
+
`),{payment_id:(await v(C,"mutation","create_payment",{payment:D,wallet_ids:Ur},{selection:"id amount_coins currency status created_at",showDoc:!!n["show-doc"]}))?.id,to_contact_id:ue,to_email:Q,amount:m.canonical,currency_label:s,wallets:pe?I.length:gn.length}}};function Or(e){let n=Et.has(e.paymentType)?qs:de,t=typeof e.rawAmount=="string"&&e.rawAmount.trim().length>0,i,r;if(t){let c=ve("--amount",e.rawAmount);i=pn(c,"--amount",n),r="flag"}else{if(e.rawLines.length===0)throw new l("input.invalid",'Need either --amount or one or more --line entries to know what to charge. Re-run with --amount=<decimal>, or pass --line items in the "<desc>|<qty>|<amount>" form so the total can be derived.');let c=e.rawLines.map((u,p)=>({raw:u,idx:p,isThreeField:u.includes("|")})).filter(u=>!u.isThreeField);if(c.length>0)throw new l("input.invalid",`Without --amount, every --line must be in the "<description>|<quantity>|<amount>" form so the total can be derived. Single-field entry at --line[${c[0].idx}] ("${c[0].raw}") doesn't supply an amount. Either re-run with --amount=<decimal>, or expand the single-field --line to the full three-field form.`);i=Nt(0n,n),r="derived-from-lines"}let o=Rr(e.rawLines,i.canonical,{amountScale:n}),a=e.rawLines.length===0?i:o.subtotal;r==="derived-from-lines"&&(i=a);let s=Js(i.scale,e.paymentType);if(i.atomicUnits>s){let c=r==="flag"?"--amount is":"--line totals are";throw new l("input.invalid",`${c} too large to render and charge without rounding; the maximum is '${Re(s,i.scale)}'.`)}if(Et.has(e.paymentType)&&i.atomicUnits<BigInt(Ms)*10n**BigInt(i.scale-de)){let c=e.paymentType===2?"USDC":"USDT";throw new l("input.invalid",`${c} invoice total must be at least 0.10; got ${i.canonical}.`)}if(r==="derived-from-lines"&&i.atomicUnits<=0n)throw new l("input.invalid",`--line totals sum to ${a.canonical} ${e.currencyLabel}; an invoice must charge more than zero. Check the per-line amounts and quantities, or pass --amount explicitly.`);return{amount:i,amountSource:r,parsedLines:o,subtotal:a}}var Ys=/^(?:\d+(?:\.\d*)?|\.\d+)$/,Ks=/^(?:0+(?:\.0*)?|\.0+)$/;function js(e,n){if(n.length>Ie)throw new l("input.invalid",`${e} is too long; decimal values may contain at most ${Ie} characters.`);let t=n.trim();if(!Ys.test(t))throw new l("input.invalid",`${e} must be a decimal string without sign or exponent; got '${n}'.`);if(Ks.test(t))throw new l("input.invalid",`${e} must be greater than zero; got '${n}'.`);let i=t.startsWith(".")?`0${t}`:t,[r,o]=i.split("."),a=r.replace(/^0+(?=\d)/,"");return o===void 0?a:`${a}.${o}`}function Rr(e,n,t={}){let i=t.amountScale??de,r=pn(ve("--amount",n,{allowZero:!0}),"--amount",i,{allowZero:!0}),o=e.map((a,s)=>xr(a,s,r));return{items:o.map(({item:a})=>a),subtotal:Ws(o,i)}}function Vs(e,n,t,i=de){let r=pn(ve("--amount",t,{allowZero:!0}),"--amount",i,{allowZero:!0});return xr(e,n,r).item}function xr(e,n,t){let i=e.split("|");if(i.length===1)return{item:{description:i[0].trim(),quantity:"1",amount:t.canonical},amount:t,quantityUnits:1n,quantityScale:0};if(i.length!==3)throw new l("input.invalid",`--line[${n}] must be "<description>" or "<description>|<quantity>|<amount>" (got "${e}").`);let[r,o,a]=i.map(y=>y.trim()),s=js(`--line[${n}] quantity`,o),c=Number(s);if(!Number.isFinite(c)||c<=0)throw new l("input.invalid",`--line[${n}] quantity must be a positive number; got "${o}".`);let u=ve(`--line[${n}] amount`,a,{allowZero:!0}),p=pn(u,`--line[${n}] amount`,t.scale,{allowZero:!0}),f=Hs(s);return{item:{description:r,quantity:Re(f.units,f.scale),amount:p.canonical},amount:p,quantityUnits:f.units,quantityScale:f.scale}}function Hs(e){let[n,t=""]=e.split("."),i=t.replace(/0+$/,"");return{units:BigInt(`${n}${i}`),scale:i.length}}function Ws(e,n){let t=0n;for(let[i,r]of e.entries()){let o=10n**BigInt(r.quantityScale),a=r.amount.atomicUnits*r.quantityUnits;if(a%o!==0n)throw new l("input.invalid",`--line[${i}] total has more than ${n} effective decimal places and cannot be represented exactly. Adjust its quantity or per-line amount; the CLI will not round a funds amount.`);t+=a/o}if(t>Oe(n))throw new l("input.invalid",`--line totals are too large to render and charge without rounding; the maximum is ${Re(Oe(n),n)}.`);return Nt(t,n)}function Oe(e){return Bs*10n**BigInt(e-de)}function Js(e,n){return n===dn?Fs:Oe(e)}function pn(e,n,t,i={}){if(!bt.test(e))throw new l("input.invalid",`${n} must be a decimal string without sign or exponent; got '${e}'.`);Cr(n,e,t,"for this invoice denomination");let[r,o=""]=e.split("."),a=o.replace(/0+$/,""),s=BigInt(r)*10n**BigInt(t)+BigInt(a.padEnd(t,"0")||"0");if(s>Oe(t))throw new l("input.invalid",`${n} is too large to render and charge without rounding; the maximum is '${Re(Oe(t),t)}'.`);if(!i.allowZero&&s<=0n)throw new l("input.invalid",`${n} must be greater than zero; got '${e}'.`);return Nt(s,t)}function Nt(e,n){return{canonical:Re(e,n,de),atomicUnits:e,scale:n}}function Re(e,n,t=0){if(n===0)return e.toString();let i=10n**BigInt(n),r=e/i,a=(e%i).toString().padStart(n,"0").replace(/0+$/,"").padEnd(Math.min(t,n),"0");return a.length>0?`${r}.${a}`:r.toString()}async function zs(e){return await v(e,"query","business_wallets",{},{selection:"id_str chain address",showDoc:!1})??[]}async function Xs(e,n){let t;try{t=await P(e)}catch{return{name:"",email:"",notice:`Invoice header's From: block is blank: your stored credentials could not be read to identify the issuer. The invoice itself is unaffected.
|
|
171
171
|
`}}let i=t.kind==="human"||t.kind==="agent"?t.userEmail:void 0;if(i===void 0)try{let r=await on(e,n),o=await v(e,"query","business",{id_str:r},{selection:"name email",showDoc:!1}),a=ce(o?.name),s=ce(o?.email);if(a!==void 0||s!==void 0)return{name:a??s??"",email:s??""}}catch{}if(i===void 0)return{name:"",email:"",notice:t.kind==="override"?`Invoice header's From: block is blank: the --token session's business lookup did not return a name or email. Use a stored login (device-login / otp-login) to fill it from your contact card. The invoice itself is unaffected.
|
|
172
172
|
`:"Invoice header's From: block is blank: this session predates the CLI recording your login email. Re-run `allscale device-login` (or otp-login) to record it. The invoice itself is unaffected.\n"};try{let r=await v(e,"query","business_contact_by_email",{email:i},{selection:"contact_name name email contact_phone",showDoc:!1});return{name:ce(r?.contact_name)??ce(r?.name)??i,email:ce(r?.email)??i,phone:ce(r?.contact_phone)}}catch{return{name:i,email:i,notice:t.kind==="agent"?`Invoice header shows your login email instead of your business contact card: the business_contact_by_email lookup was refused or failed. On an agent key this usually means the backend does not yet allow that lookup for agent keys. The invoice itself is unaffected.
|
|
173
173
|
`:`Invoice header shows your login email instead of your business contact card: the business_contact_by_email lookup failed. The invoice itself is unaffected.
|