@truebit/cli 1.120.0-beta.277 → 1.120.0-beta.278

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.
Files changed (2) hide show
  1. package/build/index.mjs +1 -1
  2. package/package.json +2 -2
package/build/index.mjs CHANGED
@@ -513,7 +513,7 @@ ${r.data.payload.instrumentedTaskId}`);else throw"Malformed instrumentation serv
513
513
  `+na.cyan("=".repeat(60))),console.log(na.cyan.bold(" Quota Status")),console.log(na.cyan("=".repeat(60))+`
514
514
  `),console.log(na.white("Wallet Address: ")+na.yellow(e)),console.log(na.white("Subscription Tier: ")+na.green(s.userSubscription.toUpperCase())),s.maxSolutions!==void 0&&console.log(na.white("Max Solutions: ")+na.green(`${s.maxSolutions}`)),s.quotaMax===0)console.log(na.white("Monthly Quota: ")+na.green("UNLIMITED")),s.currentUsage!==void 0&&console.log(na.white("Current Usage: ")+na.yellow(`${s.currentUsage} executions`));else{if(console.log(na.white("Monthly Quota: ")+na.green(`${s.quotaMax} executions`)),s.currentUsage!==void 0&&(console.log(na.white("Current Usage: ")+na.yellow(`${s.currentUsage} executions`)),s.remaining!==void 0)){let f=s.remaining===0?na.red:s.remaining<s.quotaMax*.2?na.yellow:na.green;console.log(na.white("Remaining: ")+f(`${s.remaining} executions`))}console.log(na.white("Quota Resets On: ")+na.yellow(l))}console.log(`
515
515
  `+na.cyan("=".repeat(60))+`
516
- `)}catch(t){throw t instanceof Error?console.error(na.red("Error fetching quota status: ")+t.message):console.error(na.red("Error fetching quota status: ")+String(t)),t}}Ktt();Zf();async function hTr(t){try{console.log("Fetching execution status...");let r=await(await wm()).get(`api/execution/${t}`).catch(nd);if(r.data.message)throw r.data.message;console.log("Task execution status: ",r.data.status),r.data.output&&console.log("Task execution output: ",r.data.output)}catch(e){console.error(`Couldn't fetch execution status for executionId ${t}: ${e}`)}}import bTr from"chalk";import{ethers as z8a}from"ethers";Zf();import*as mye from"crypto";import U8a from"axios";import Ytt from"chalk";function mTr(t){if(U8a.isAxiosError(t)&&t.response?.data){let e=t.response.data;return console.log(Ytt.red(e.message)),typeof e=="string"?e:e.message||JSON.stringify(e)}return t instanceof Error?t.message:String(t)}async function V8a(t,e){try{let r=id({namespace:e});return(await t.post("getkey",r)).data}catch(r){return mTr(r),console.error(Ytt.red("Failed to retrieve encryption key from Hub-TEE-KMS. Please try again")),null}}function H8a(t,e){try{let r=Buffer.from(e,"base64"),n=mye.randomBytes(16),i=mye.createCipheriv("aes-256-cbc",r,n),a=Buffer.concat([i.update(t,"utf8"),i.final()]);return r.fill(0),{encrypted_authString:a.toString("base64"),iv:n.toString("base64")}}catch{return null}}async function yTr(t,e,r){try{let n=await V8a(t,r);if(!n)return null;let i=H8a(e,n.plaintext_key);return i?{encrypted_authString:i.encrypted_authString,encrypted_data_key:n.encryption_key,iv:i.iv}:null}catch(n){return mTr(n),console.error(Ytt.red("Failed to encrypt credentials. Please try again.")),null}}async function gTr(t,e,r,n,i,a,s){console.log("Deploying the API Authentication Credentials");try{if(!Jxr(a))throw"Invalid private key provided";if(!z8a.isAddress(s))throw"Invalid address provided";if(H5e(n,i),!bC(t))throw"Invalid taskId";let o=await pkt();console.log("Encrypting credentials...");let u=await yTr(o,i,e);if(!u)return;let l=id({taskId:t,namespace:e,taskName:r,method:n,encrypted_authString:u.encrypted_authString,encrypted_data_key:u.encrypted_data_key,iv:u.iv});await o.post("credentials",l).catch(nd),console.log("The encrypted credentials were deployed "+bTr.green("Successfully"))}catch(o){let u=o instanceof Error?o.message:String(o);console.error(bTr.red(u));return}}import{inspect as N7a}from"util";import wl from"ora";import{v4 as D7a}from"uuid";import{ethers as Iye}from"ethers";var vTr={name:"@truebit/cli",version:"1.120.0-beta.277",private:!1,description:"truebit-cli is a basic command line that allows interaction between users and truebit nextgen node.",author:{name:"Truebit Co.",url:"https://truebit.io/"},license:"https://truebit.io/terms/",repository:{type:"git",url:"https://github.com/TruebitProtocol"},homepage:"https://truebit.io/",main:"build/index.mjs",module:"build/index.mjs",types:"build/types/index.d.ts",type:"module",scripts:{prebuild:"rimraf build logs","prebuild:dev":"rimraf build logs","build:dev":"tsc && chmod +x build/index.mjs",build:"NODE_ENV=production node esbuild.config.mjs && chmod +x build/index.mjs",dev:"export NODE_ENV=development && npx nodemon",test:"vitest run --passWithNoTests tests/"},dependencies:{axios:"1.13.6",chalk:"5.6.2",colors:"1.4.0",commander:"14.0.3",ethers:"6.16.0",figlet:"1.10.0","form-data":"4.0.5","openapi-enforcer":"1.23.0",ora:"9.3.0","public-ip":"8.0.0","ts-retry":"6.0.0",uuid:"13.0.0"},bin:{truebit:"build/index.mjs"},files:["build"],devDependencies:{"@types/figlet":"1.7.0","@vitest/coverage-v8":"4.0.18",esbuild:"0.27.3",typescript:"5.9.3",vitest:"4.0.18"},engines:{node:">=22.13.0"}};Ql();Zf();X6();Ql();import{createInterface as X8a}from"node:readline/promises";import gb from"chalk";Zf();import ZB from"axios";import{ethers as gC}from"ethers";import{randomBytes as G8a}from"crypto";import{v4 as K8a}from"uuid";Ql();import{ethers as yye}from"ethers";async function _Tr(t){X8(t);let e=$i(al(),Xt.AVAX),r=yye.keccak256(yye.toUtf8Bytes(t));return await e.authorization.registerAuthorization(r),r}async function Jtt(t,e,r=Zn("address")){X8(t);let n=$i(al(),Xt.AVAX),i=await n.authorization.getEIP712Domain(),a=await n.authorization.nonces(r),s=Math.floor(Date.now()/1e3)+3600,o={RegisterMeta:[{name:"user",type:"address"},{name:"apiKeyHash",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},u=yye.keccak256(yye.toUtf8Bytes(t)),l={user:r,apiKeyHash:u,nonce:Number(a),deadline:s};if(!n.utils)throw new Error("Private key is required for signing operations");let f=await n.utils.signMeta(i,o,l);return(await Xxr(r,u,s,f,e)).status==201?u:null}Ql();X6();import{isTooManyTries as ETr,retryAsync as STr}from"ts-retry";var wTr="0x0000000000000000000000000000000000000000";async function ATr(t){let e=!0;return t===""?(e=!1,console.log("An email address is required. Please provide your email address to proceed.")):new RegExp(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/).test(t)?await Y8a(t)&&(e=!1,console.log("The provided email address is already in use. Please enter a different email address.")):(e=!1,console.log("The email address provided is not valid. Please try again.")),e}function Q8(t){return t==="Y"||t==="N"}function xTr(t){return!gC.isAddress(t)||t.length!==42||!t.startsWith("0x")}async function TTr(){let t=al(),e=$i(t,Xt.AVAX),r=Zn("address"),n=await Z8a(),i=await J8a();X8(i);let a=gC.keccak256(gC.toUtf8Bytes(i)),s=Math.floor(Date.now()/1e3)+3600,o=await e.taskRegistry.getEIP712Domain(),u=await e.authorization.getEIP712Domain(),l={RegisterTaskNamespaceMeta:[{name:"user",type:"address"},{name:"namespace",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},f={RegisterMeta:[{name:"user",type:"address"},{name:"apiKeyHash",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},d=BigInt(await e.taskRegistry.nonces(r)),h=await e.authorization.nonces(r),p={user:gC.getAddress(r),namespace:n,nonce:d,deadline:s},m={user:r,apiKeyHash:a,nonce:Number(h),deadline:s};if(!e.utils)throw new Error("Private key is required for signing operations");let y=await e.utils.signMeta(o,l,p),b=await e.utils.signMeta(u,f,m),v={user:r,namespace:n,apiKeyHash:a,namespaceSignature:y,apiKeySignature:b,namespaceDeadline:s,apiKeyDeadline:s};try{let E=await Qxr(v);if(E.status!==201)throw new Error("Registration failed with unexpected status");if(!E.data.namespaceRegistration.success)throw new Error("Namespace registration failed");if(!E.data.apiKeyRegistration.success)throw new Error("API key registration failed");return{namespace:n,apiKey:i,hashedApiKey:a}}catch(E){let w=E.message;throw new Error(`Combined registration failed: ${w}`)}}async function Y8a(t){let e=await Zl();try{return(await e.get(`userexistence/${t}`)).data===!0}catch(r){if(ZB.isAxiosError(r)&&r.response?.status===404&&typeof r.response?.data?.message=="string"&&r.response.data.message.includes("User not found"))return!1;throw r}}async function bye(t,e){try{let r={message:"I am a Truebit User"};if(!e)throw Error("Secret.json does not exists");let n=e.privateKey,i=e.address,a=Of.createSignedBody(r,n,i);return(await(await Zl()).get(`user/${t}`,{headers:{"truebit-auth":JSON.stringify(a)}})).data}catch(r){if(ZB.isAxiosError(r)&&r.response?.status===401&&r.response?.data.message.includes("Entitlement Validation Error")||ZB.isAxiosError(r)&&r.response?.status==404&&r.response?.data.message&&r.response?.data.message.includes("User not found"))return null;throw ZB.isAxiosError(r)?r.response?Error(`The server responding with an error -> ${r.response.data.message||r.response.status+" - "+r.response.statusText}`):r.request?Error(`The server is not responding -> ${r.message}`):Error(`There was an error in the communication with the server -> ${r.message}`):Error(typeof r=="string"?`There was an error in the communication with the server -> ${r}`:"There was an error in the communication with the server.")}}async function OTr(t){try{return await(await Zl()).post("user/register",t)}catch(e){throw ZB.isAxiosError(e)?e.response?Error(`The server responding with an error -> ${e.response.data.message||e.response.status+" - "+e.response.statusText}`):e.request?Error(`The server is not responding -> ${e.message}`):Error(`There was an error in the communication with the server -> ${e.message}`):Error(typeof e=="string"?`There was an error in the communication with the server -> ${e}`:"There was an error in the communication with the server.")}}async function J8a(){let t=al(),e=$i(t,Xt.AVAX),r="";try{await STr(async()=>{r=K8a();let n=gC.keccak256(gC.toUtf8Bytes(r));return await e.authorization.getPayerAddress(n)===wTr},{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw ETr(n)?Error("Attempts to generate unique Api Key for the user exhausted."):n}return r}async function Z8a(){let t=al(),e=$i(t,Xt.AVAX),r="";try{await STr(async()=>(r=G8a(4).toString("hex"),await e.taskRegistry.getNamespaceOwner(r)===wTr),{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw ETr(n)?Error("Attempts to generate unique namespace for the user exhausted."):n}return r}function CTr(t){t.fullNameAnswer="",t.emailAddressAnswer="",t.companyNameAnswer="",t.jobPositionAnswer="",t.eulaAnswer="",t.confirmRegistration=""}X6();Zg();import Q8a from"ora";import*as gye from"os";async function ITr(t,e,r){let n=Xl(),i=n!==null,a=0,s,o=X8a({input:process.stdin,output:process.stdout,terminal:!0});switch(i&&(xTr(n.address)?a=1:(s=await bye(n.address,n),s?a=2:a=3)),a){case 1:console.log("The wallet set in the configuration must be a valid ethereum address. (ENS not supported yet)");break;case 2:console.log(Zi.SETUP_STEP1_SCENARIO1_P2(s));break;case 3:{console.log(Zi.SETUP_STEP2_SCENARIO3_P1),console.log();let u={user_ip:t,date_time:qs(),os_version:gye.type+"_"+gye.release,node_version:process.version,cli_version:e};await r.sendEventToMixpanel("user_registration_begin",u);let l={confirmRegistration:"",fullNameAnswer:"",emailAddressAnswer:"",companyNameAnswer:"",jobPositionAnswer:"",eulaAnswer:""};try{for(;l.confirmRegistration!="Y";){for(l.fullNameAnswer=(await o.question(gb.bold(" 1. Full Name: "))).trim();l.fullNameAnswer==="";)console.log("Your full name is required. Please provide your first and last name to proceed."),l.fullNameAnswer=(await o.question(gb.bold(" 1. Full Name: "))).trim();for(l.emailAddressAnswer=(await o.question(gb.bold(" 2. Email Address: "))).trim();!await ATr(l.emailAddressAnswer);)l.emailAddressAnswer=(await o.question(gb.bold(" 2. Email Address: "))).trim();for(l.companyNameAnswer=(await o.question(gb.bold(" 3. Company Name: "))).trim(),l.jobPositionAnswer=(await o.question(gb.bold(" 4. Job Position: "))).trim();!Q8(l.eulaAnswer);)l.eulaAnswer=(await o.question(gb.bold(` 5. Accept EULA? [Y|N] (${Zi.EULA_TERMS_LINK}): `))).toUpperCase();if(l.eulaAnswer=="N"){console.log(Zi.EULA_REGISTRATION_NO_ACCEPTED);break}for(;!Q8(l.confirmRegistration);)console.log(`
516
+ `)}catch(t){throw t instanceof Error?console.error(na.red("Error fetching quota status: ")+t.message):console.error(na.red("Error fetching quota status: ")+String(t)),t}}Ktt();Zf();async function hTr(t){try{console.log("Fetching execution status...");let r=await(await wm()).get(`api/execution/${t}`).catch(nd);if(r.data.message)throw r.data.message;console.log("Task execution status: ",r.data.status),r.data.output&&console.log("Task execution output: ",r.data.output)}catch(e){console.error(`Couldn't fetch execution status for executionId ${t}: ${e}`)}}import bTr from"chalk";import{ethers as z8a}from"ethers";Zf();import*as mye from"crypto";import U8a from"axios";import Ytt from"chalk";function mTr(t){if(U8a.isAxiosError(t)&&t.response?.data){let e=t.response.data;return console.log(Ytt.red(e.message)),typeof e=="string"?e:e.message||JSON.stringify(e)}return t instanceof Error?t.message:String(t)}async function V8a(t,e){try{let r=id({namespace:e});return(await t.post("getkey",r)).data}catch(r){return mTr(r),console.error(Ytt.red("Failed to retrieve encryption key from Hub-TEE-KMS. Please try again")),null}}function H8a(t,e){try{let r=Buffer.from(e,"base64"),n=mye.randomBytes(16),i=mye.createCipheriv("aes-256-cbc",r,n),a=Buffer.concat([i.update(t,"utf8"),i.final()]);return r.fill(0),{encrypted_authString:a.toString("base64"),iv:n.toString("base64")}}catch{return null}}async function yTr(t,e,r){try{let n=await V8a(t,r);if(!n)return null;let i=H8a(e,n.plaintext_key);return i?{encrypted_authString:i.encrypted_authString,encrypted_data_key:n.encryption_key,iv:i.iv}:null}catch(n){return mTr(n),console.error(Ytt.red("Failed to encrypt credentials. Please try again.")),null}}async function gTr(t,e,r,n,i,a,s){console.log("Deploying the API Authentication Credentials");try{if(!Jxr(a))throw"Invalid private key provided";if(!z8a.isAddress(s))throw"Invalid address provided";if(H5e(n,i),!bC(t))throw"Invalid taskId";let o=await pkt();console.log("Encrypting credentials...");let u=await yTr(o,i,e);if(!u)return;let l=id({taskId:t,namespace:e,taskName:r,method:n,encrypted_authString:u.encrypted_authString,encrypted_data_key:u.encrypted_data_key,iv:u.iv});await o.post("credentials",l).catch(nd),console.log("The encrypted credentials were deployed "+bTr.green("Successfully"))}catch(o){let u=o instanceof Error?o.message:String(o);console.error(bTr.red(u));return}}import{inspect as N7a}from"util";import wl from"ora";import{v4 as D7a}from"uuid";import{ethers as Iye}from"ethers";var vTr={name:"@truebit/cli",version:"1.120.0-beta.278",private:!1,description:"truebit-cli is a basic command line that allows interaction between users and truebit nextgen node.",author:{name:"Truebit Co.",url:"https://truebit.io/"},license:"https://truebit.io/terms/",repository:{type:"git",url:"https://github.com/TruebitProtocol"},homepage:"https://truebit.io/",main:"build/index.mjs",module:"build/index.mjs",types:"build/types/index.d.ts",type:"module",scripts:{prebuild:"rimraf build logs","prebuild:dev":"rimraf build logs","build:dev":"tsc && chmod +x build/index.mjs",build:"NODE_ENV=production node esbuild.config.mjs && chmod +x build/index.mjs",dev:"export NODE_ENV=development && npx nodemon",test:"vitest run --passWithNoTests tests/"},dependencies:{axios:"1.13.6",chalk:"5.6.2",colors:"1.4.0",commander:"14.0.3",ethers:"6.16.0",figlet:"1.10.0","form-data":"4.0.5","openapi-enforcer":"1.23.0",ora:"9.3.0","public-ip":"8.0.0","ts-retry":"6.0.0",uuid:"13.0.0"},bin:{truebit:"build/index.mjs"},files:["build"],devDependencies:{"@types/figlet":"1.7.0","@vitest/coverage-v8":"4.0.18",esbuild:"0.27.3",typescript:"5.9.3",vitest:"4.0.18"},engines:{node:">=22.13.0"}};Ql();Zf();X6();Ql();import{createInterface as X8a}from"node:readline/promises";import gb from"chalk";Zf();import ZB from"axios";import{ethers as gC}from"ethers";import{randomBytes as G8a}from"crypto";import{v4 as K8a}from"uuid";Ql();import{ethers as yye}from"ethers";async function _Tr(t){X8(t);let e=$i(al(),Xt.AVAX),r=yye.keccak256(yye.toUtf8Bytes(t));return await e.authorization.registerAuthorization(r),r}async function Jtt(t,e,r=Zn("address")){X8(t);let n=$i(al(),Xt.AVAX),i=await n.authorization.getEIP712Domain(),a=await n.authorization.nonces(r),s=Math.floor(Date.now()/1e3)+3600,o={RegisterMeta:[{name:"user",type:"address"},{name:"apiKeyHash",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},u=yye.keccak256(yye.toUtf8Bytes(t)),l={user:r,apiKeyHash:u,nonce:Number(a),deadline:s};if(!n.utils)throw new Error("Private key is required for signing operations");let f=await n.utils.signMeta(i,o,l);return(await Xxr(r,u,s,f,e)).status==201?u:null}Ql();X6();import{isTooManyTries as ETr,retryAsync as STr}from"ts-retry";var wTr="0x0000000000000000000000000000000000000000";async function ATr(t){let e=!0;return t===""?(e=!1,console.log("An email address is required. Please provide your email address to proceed.")):new RegExp(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/).test(t)?await Y8a(t)&&(e=!1,console.log("The provided email address is already in use. Please enter a different email address.")):(e=!1,console.log("The email address provided is not valid. Please try again.")),e}function Q8(t){return t==="Y"||t==="N"}function xTr(t){return!gC.isAddress(t)||t.length!==42||!t.startsWith("0x")}async function TTr(){let t=al(),e=$i(t,Xt.AVAX),r=Zn("address"),n=await Z8a(),i=await J8a();X8(i);let a=gC.keccak256(gC.toUtf8Bytes(i)),s=Math.floor(Date.now()/1e3)+3600,o=await e.taskRegistry.getEIP712Domain(),u=await e.authorization.getEIP712Domain(),l={RegisterTaskNamespaceMeta:[{name:"user",type:"address"},{name:"namespace",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},f={RegisterMeta:[{name:"user",type:"address"},{name:"apiKeyHash",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},d=BigInt(await e.taskRegistry.nonces(r)),h=await e.authorization.nonces(r),p={user:gC.getAddress(r),namespace:n,nonce:d,deadline:s},m={user:r,apiKeyHash:a,nonce:Number(h),deadline:s};if(!e.utils)throw new Error("Private key is required for signing operations");let y=await e.utils.signMeta(o,l,p),b=await e.utils.signMeta(u,f,m),v={user:r,namespace:n,apiKeyHash:a,namespaceSignature:y,apiKeySignature:b,namespaceDeadline:s,apiKeyDeadline:s};try{let E=await Qxr(v);if(E.status!==201)throw new Error("Registration failed with unexpected status");if(!E.data.namespaceRegistration.success)throw new Error("Namespace registration failed");if(!E.data.apiKeyRegistration.success)throw new Error("API key registration failed");return{namespace:n,apiKey:i,hashedApiKey:a}}catch(E){let w=E.message;throw new Error(`Combined registration failed: ${w}`)}}async function Y8a(t){let e=await Zl();try{return(await e.get(`userexistence/${t}`)).data===!0}catch(r){if(ZB.isAxiosError(r)&&r.response?.status===404&&typeof r.response?.data?.message=="string"&&r.response.data.message.includes("User not found"))return!1;throw r}}async function bye(t,e){try{let r={message:"I am a Truebit User"};if(!e)throw Error("Secret.json does not exists");let n=e.privateKey,i=e.address,a=Of.createSignedBody(r,n,i);return(await(await Zl()).get(`user/${t}`,{headers:{"truebit-auth":JSON.stringify(a)}})).data}catch(r){if(ZB.isAxiosError(r)&&r.response?.status===401&&r.response?.data.message.includes("Entitlement Validation Error")||ZB.isAxiosError(r)&&r.response?.status==404&&r.response?.data.message&&r.response?.data.message.includes("User not found"))return null;throw ZB.isAxiosError(r)?r.response?Error(`The server responding with an error -> ${r.response.data.message||r.response.status+" - "+r.response.statusText}`):r.request?Error(`The server is not responding -> ${r.message}`):Error(`There was an error in the communication with the server -> ${r.message}`):Error(typeof r=="string"?`There was an error in the communication with the server -> ${r}`:"There was an error in the communication with the server.")}}async function OTr(t){try{return await(await Zl()).post("user/register",t)}catch(e){throw ZB.isAxiosError(e)?e.response?Error(`The server responding with an error -> ${e.response.data.message||e.response.status+" - "+e.response.statusText}`):e.request?Error(`The server is not responding -> ${e.message}`):Error(`There was an error in the communication with the server -> ${e.message}`):Error(typeof e=="string"?`There was an error in the communication with the server -> ${e}`:"There was an error in the communication with the server.")}}async function J8a(){let t=al(),e=$i(t,Xt.AVAX),r="";try{await STr(async()=>{r=K8a();let n=gC.keccak256(gC.toUtf8Bytes(r));return await e.authorization.getPayerAddress(n)===wTr},{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw ETr(n)?Error("Attempts to generate unique Api Key for the user exhausted."):n}return r}async function Z8a(){let t=al(),e=$i(t,Xt.AVAX),r="";try{await STr(async()=>(r=G8a(4).toString("hex"),await e.taskRegistry.getNamespaceOwner(r)===wTr),{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw ETr(n)?Error("Attempts to generate unique namespace for the user exhausted."):n}return r}function CTr(t){t.fullNameAnswer="",t.emailAddressAnswer="",t.companyNameAnswer="",t.jobPositionAnswer="",t.eulaAnswer="",t.confirmRegistration=""}X6();Zg();import Q8a from"ora";import*as gye from"os";async function ITr(t,e,r){let n=Xl(),i=n!==null,a=0,s,o=X8a({input:process.stdin,output:process.stdout,terminal:!0});switch(i&&(xTr(n.address)?a=1:(s=await bye(n.address,n),s?a=2:a=3)),a){case 1:console.log("The wallet set in the configuration must be a valid ethereum address. (ENS not supported yet)");break;case 2:console.log(Zi.SETUP_STEP1_SCENARIO1_P2(s));break;case 3:{console.log(Zi.SETUP_STEP2_SCENARIO3_P1),console.log();let u={user_ip:t,date_time:qs(),os_version:gye.type+"_"+gye.release,node_version:process.version,cli_version:e};await r.sendEventToMixpanel("user_registration_begin",u);let l={confirmRegistration:"",fullNameAnswer:"",emailAddressAnswer:"",companyNameAnswer:"",jobPositionAnswer:"",eulaAnswer:""};try{for(;l.confirmRegistration!="Y";){for(l.fullNameAnswer=(await o.question(gb.bold(" 1. Full Name: "))).trim();l.fullNameAnswer==="";)console.log("Your full name is required. Please provide your first and last name to proceed."),l.fullNameAnswer=(await o.question(gb.bold(" 1. Full Name: "))).trim();for(l.emailAddressAnswer=(await o.question(gb.bold(" 2. Email Address: "))).trim();!await ATr(l.emailAddressAnswer);)l.emailAddressAnswer=(await o.question(gb.bold(" 2. Email Address: "))).trim();for(l.companyNameAnswer=(await o.question(gb.bold(" 3. Company Name: "))).trim(),l.jobPositionAnswer=(await o.question(gb.bold(" 4. Job Position: "))).trim();!Q8(l.eulaAnswer);)l.eulaAnswer=(await o.question(gb.bold(` 5. Accept EULA? [Y|N] (${Zi.EULA_TERMS_LINK}): `))).toUpperCase();if(l.eulaAnswer=="N"){console.log(Zi.EULA_REGISTRATION_NO_ACCEPTED);break}for(;!Q8(l.confirmRegistration);)console.log(`
517
517
  Is the information provided above correct?`),l.confirmRegistration=(await o.question(gb.bold("Press [Y] to confirm or [N] to edit: "))).toUpperCase();l.confirmRegistration=="N"&&(console.log(`
518
518
  Please provide the following information:`),CTr(l))}}catch(h){if(h.name==="AbortError"||h.message.includes("Ctrl+C")){let p=h.message,m=u;m.error_details=p,m.date_time=qs();let y={fullname:l.fullNameAnswer,email:l.emailAddressAnswer,company:l.companyNameAnswer,role:l.jobPositionAnswer};m.user_info=JSON.stringify(y),await r.sendEventToMixpanel("user_registration_failed",m),process.exit(0)}}if(l.eulaAnswer=="N")break;let f=u;console.log(),console.log("By completing registration, you'll be automatically subscribed to our newsletter."),console.log("To opt-out, please follow the steps described in our documentation portal."),console.log();let d=Q8a({text:gb.bold("... registering your account."),stream:process.stdout}).start();try{let{namespace:h,apiKey:p}=await TTr(),m={name:l.fullNameAnswer,email:l.emailAddressAnswer,walletAddress:n?.address,company:l.companyNameAnswer,jobDescription:l.jobPositionAnswer,EULA:Of.createSignedBody({ip:await xJ(),date:new Date().toISOString()},n.privateKey),defaultNamespace:h,defaultApiKey:p};await OTr(m),d.stop(),console.log(Zi.SETUP_STEP2_SCENARIO3_P2(l,n.address,h,p)),f.distinct_id=m.walletAddress,f.date_time=qs(),f.fullname=m.name,f.email=m.email,f.company=m.company,f.role=m.jobDescription,f.namespace=m.defaultNamespace,f.api_key=p,f.wallet_address=m.walletAddress,await r.sendEventToMixpanel("user_registration_success",f),await r.registerUserMixpanel(f.wallet_address,e4a(f))}catch(h){d.stop();let p=h.message,m=u;m.error_details=p,m.date_time=qs();let y={fullname:l.fullNameAnswer,email:l.emailAddressAnswer,company:l.companyNameAnswer,role:l.jobPositionAnswer};m.user_info=JSON.stringify(y),await r.sendEventToMixpanel("user_registration_failed",m);let b=p?p.match(/CreateUserValidation - (.*?.*)/)?.[1]:null;if(b)throw Error(b);if(p.includes("Sender doesn't have enough funds to send tx"))throw Error("We are currently experiencing technical difficulties. Please try again later.");console.error(Zi.SETUP_STEP2_UNHANDLED_ERROR),process.exit(1)}finally{d.clear()}break}default:throw Error("An unexpected error occurred.")}o.close()}function e4a(t){return{apiKey:t.api_key,name:t.fullname,email:t.email,ip:t.user_ip,company:t.company,role:t.role,namespace:t.namespace,walletAddress:t.wallet_address}}import{setDefaultAutoSelectFamily as k7a}from"node:net";import t4a from"chalk";Ql();Zg();import{createInterface as r4a}from"node:readline/promises";import*as vye from"os";async function MTr(t,e,r){let n=Xl(),i=n!==null,a;switch(i?i&&!n.eula?a=2:a=3:a=1,a){case 1:case 2:{let s=r4a({input:process.stdin,output:process.stdout,terminal:!0}),o="",u={user_ip:t,date_time:qs(),os_version:vye.type+"_"+vye.release,node_version:process.version,cli_version:e};for(console.log(Zi.EULA_INSTALLATION);!Q8(o);)o=(await s.question(t4a.bold(`
519
519
  Have you read, and do you accept the Terms of Use? [Y|N]: `))).toUpperCase(),await r.sendEventToMixpanel("TOS_shown",u);if(o=="N")throw u.date_time=qs(),await r.sendEventToMixpanel("TOS_rejected",u),Zi.EULA_INSTALLATION_NO_ACCEPTED;u.date_time=qs(),await r.sendEventToMixpanel("TOS_accepted",u);let l=Math.round(new Date().getTime()).toString();if(a===1){let f={...mPe(),eula:l};bkt(f)}else a===2&&vD({eula:l});s.close()}break;default:break}}Ql();Zg();async function Sd(t=!1){let e=Xl(),r=e!==null,n=null,i;switch(r?r&&(!e.privateKey||!e.address)?i=2:(n=await bye(e.address,e),n?i=4:i=3):i=1,i){case 1:case 2:case 3:console.log(Zi.USER_NO_REGISTERED),process.exit(1);break;case 4:t&&console.log(`You are logged in as: ${n?.name} - ${n?.email}`);break}}import{createInterface as n4a}from"node:readline/promises";Zg();Ql();import i4a from"chalk";async function PTr(){console.log(i4a.bold(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truebit/cli",
3
- "version": "1.120.0-beta.277",
3
+ "version": "1.120.0-beta.278",
4
4
  "private": false,
5
5
  "description": "truebit-cli is a basic command line that allows interaction between users and truebit nextgen node.",
6
6
  "author": {
@@ -55,5 +55,5 @@
55
55
  "engines": {
56
56
  "node": ">=22.13.0"
57
57
  },
58
- "gitHead": "daa90d44916ffa67c646ca9f66d04615d766434e"
58
+ "gitHead": "cbf86d33da0869c345c0f690b8ef577c66f7c586"
59
59
  }