@truebit/cli 1.120.0-beta.259 → 1.120.0-beta.260

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
@@ -514,7 +514,7 @@ ${r.data.payload.instrumentedTaskId}`);else throw"Malformed instrumentation serv
514
514
  `),console.log(Fi.white("Wallet Address: ")+Fi.yellow(e)),console.log(Fi.white("Subscription Tier: ")+Fi.green(s.userSubscription.toUpperCase())),s.maxSolutions!==void 0&&console.log(Fi.white("Max Solutions: ")+Fi.green(`${s.maxSolutions}`)),s.quotaMax===0)console.log(Fi.white("Monthly Quota: ")+Fi.green("UNLIMITED")),s.currentUsage!==void 0&&console.log(Fi.white("Current Usage: ")+Fi.yellow(`${s.currentUsage} executions`));else{if(console.log(Fi.white("Monthly Quota: ")+Fi.green(`${s.quotaMax} executions`)),s.currentUsage!==void 0&&(console.log(Fi.white("Current Usage: ")+Fi.yellow(`${s.currentUsage} executions`)),s.remaining!==void 0)){let c=s.remaining===0?Fi.red:s.remaining<s.quotaMax*.2?Fi.yellow:Fi.green;console.log(Fi.white("Remaining: ")+c(`${s.remaining} executions`))}console.log(Fi.white("Quota Resets On: ")+Fi.yellow(f))}console.log(`
515
515
  `+Fi.cyan("=".repeat(60))+`
516
516
  `)}catch(t){throw t instanceof Error?console.error(Fi.red("Error fetching quota status: ")+t.message):console.error(Fi.red("Error fetching quota status: ")+String(t)),t}}HKe();El();async function n_r(t){try{console.log("Fetching execution status...");let r=await(await Fh()).get(`api/execution/${t}`).catch(Ac);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}`)}}var i_r=cr(yV(),1),Tk=class{tokens=[];authInputs;parse(e,r){let n=this.parseKeyValuePairs(r);if(e.length==0){this.authInputs=n;return}let i=Object.keys(n);if(e.every(a=>i.includes(a))){let a={};for(let s of e)a[s]=n[s];this.authInputs=a}else throw new Error(`Invalid authString: ${e} are required`)}parseKeyValuePairs(e){try{let r=e.split(","),n={};for(let i of r){let[a,s]=i.split(":");n[a.trim()]=s.trim()}return n}catch{throw new Error("Invalid auth string")}}},Mpe=class extends Tk{tokens=["accessKey","secretKey"];constructor(e){super(),this.parse(this.tokens,e)}authHeaders(e){return i_r.default.sign(e,{accessKeyId:this.authInputs.accessKey,secretAccessKey:this.authInputs.secretKey}).headers||{}}},Ppe=class extends Tk{tokens=["username","password"];constructor(e){super(),this.parse(this.tokens,e)}authHeaders(e){return{Authorization:`Basic ${btoa(`${this.authInputs.username}:${this.authInputs.password}`)}`}}},Rpe=class extends Tk{tokens=[];constructor(e){super(),this.parse([],e)}authHeaders(e){return{...this.authInputs}}};var B1;(function(t){t.AWS_SIGNATURE="aws-signature",t.BASIC_AUTH="basic-auth",t.CUSTOM_HEADER="custom-header"})(B1||(B1={}));var zKe=(t,e)=>{switch(t){case B1.AWS_SIGNATURE:return new Mpe(e);case B1.BASIC_AUTH:return new Ppe(e);case B1.CUSTOM_HEADER:return new Rpe(e);default:throw new Error(`Invalid authentication method specified. Should be one of <${Object.values(B1)}>`)}};import e0a from"chalk";import{ethers as t0a}from"ethers";El();import*as qpe from"crypto";async function Xua(t){try{return(await t.get("/getkey")).data}catch(e){throw new Error(`Failed to get encryption key: ${e}`)}}function Qua(t,e){try{let r=Buffer.from(e,"base64"),n=qpe.randomBytes(16),i=qpe.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(r){throw r instanceof Error?new Error(`Failed to encrypt credentials: ${r.message}`):new Error(`Failed to encrypt credentials: ${r}`)}}async function a_r(t,e){let r=await Xua(t),n=Qua(e,r.plaintext_key);return{encrypted_authString:n.encrypted_authString,encrypted_data_key:r.encrypted_key,iv:n.iv}}async function s_r(t,e,r,n,i,a,s){console.log("Deploying the API Authentication Credentials");try{if(!Lvr(a))throw"Invalid private key provided";if(!t0a.isAddress(s))throw"Invalid address provided";if(zKe(n,i),!lT(t))throw"Invalid taskId";let o=await LCt();console.log("Encrypting credentials...");let u=await a_r(o,i);await o.post("credentials",{taskId:t,namespace:e,taskName:r,method:n,encrypted_authString:u.encrypted_authString,encrypted_data_key:u.encrypted_data_key,iv:u.iv}).catch(Ac),console.log("The encrypted credentials were deployed "+e0a.green("Successfully"))}catch(o){throw console.log(o),`There was an Error deploying credentials:
517
- Couldn't push api credentials to remote server: ${o}`}}import{inspect as Hfa}from"util";import Yu from"ora";import{v4 as zfa}from"uuid";import{ethers as Kpe}from"ethers";var o_r={name:"@truebit/cli",version:"1.120.0-beta.259",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.3",chalk:"5.6.2",colors:"1.4.0",commander:"14.0.2",ethers:"6.16.0",figlet:"1.10.0","form-data":"4.0.5","openapi-enforcer":"1.23.0",ora:"9.1.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.2",typescript:"5.9.3",vitest:"4.0.18"},engines:{node:">=22.13.0"}};gf();El();u6();gf();import{createInterface as u0a}from"node:readline/promises";import A2 from"chalk";El();import Ok from"axios";import{ethers as WKe}from"ethers";import{randomBytes as n0a}from"crypto";import{v4 as i0a}from"uuid";gf();import{ethers as Npe}from"ethers";async function u_r(t){xk(t);let e=Ri(w0(),zt.AVAX),r=Npe.keccak256(Npe.toUtf8Bytes(t));return await e.authorization.registerAuthorization(r),r}async function Dpe(t,e,r=Yn("address")){xk(t);let n=Ri(w0(),zt.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=Npe.keccak256(Npe.toUtf8Bytes(t)),f={user:r,apiKeyHash:u,nonce:Number(a),deadline:s},c=await n.utils.signMeta(i,o,f);return(await Uvr(r,u,s,c,e)).status==201?u:null}u6();import{isTooManyTries as f_r,retryAsync as l_r}from"ts-retry";var c_r="0x0000000000000000000000000000000000000000";async function d_r(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 a0a(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 n8(t){return t==="Y"||t==="N"}function p_r(t){return!WKe.isAddress(t)||t.length!==42||!t.startsWith("0x")}async function h_r(){let t=await s0a();try{if(!await Dpe(t,!0))throw Error("The API key could not been registered.")}catch(e){let r=e.message;if(r)throw Error(`There was an error registering the API key -> ${r}`)}return t}async function m_r(){let t=await o0a();try{if(!await Ope(t,!0))throw Error("The namespace could not been registered.")}catch(e){let r=e.message,n=r?r.match(/execution reverted: "(.*?)" /)?.[1]:null;if(n)throw Error(`There was an error registering the namespace -> ${n}`);if(r)throw Error(`There was an error registering the namespace -> ${r}`)}return t}async function a0a(t){let e=await bf();try{return(await e.get(`userexistence/${t}`)).data===!0}catch(r){if(Ok.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 kpe(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=Zf.createSignedBody(r,n,i);return(await(await bf()).get(`user/${t}`,{headers:{"truebit-auth":JSON.stringify(a)}})).data}catch(r){if(Ok.isAxiosError(r)&&r.response?.status===401&&r.response?.data.message.includes("Entitlement Validation Error")||Ok.isAxiosError(r)&&r.response?.status==404&&r.response?.data.message&&r.response?.data.message.includes("User not found"))return null;throw Ok.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 y_r(t){try{return await(await bf()).post("user/register",t)}catch(e){throw Ok.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 s0a(){let t=w0(),e=Ri(t,zt.AVAX),r="";try{await l_r(async()=>{r=i0a();let n=WKe.keccak256(WKe.toUtf8Bytes(r));return await e.authorization.getPayerAddress(n)===c_r},{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw f_r(n)?Error("Attempts to generate unique Api Key for the user exhausted."):n}return r}async function o0a(){let t=w0(),e=Ri(t,zt.AVAX),r="";try{await l_r(async()=>(r=n0a(4).toString("hex"),await e.taskRegistry.getNamespaceOwner(r)===c_r),{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw f_r(n)?Error("Attempts to generate unique namespace for the user exhausted."):n}return r}function b_r(t){t.fullNameAnswer="",t.emailAddressAnswer="",t.companyNameAnswer="",t.jobPositionAnswer="",t.eulaAnswer="",t.confirmRegistration=""}u6();ng();import f0a from"ora";import*as $pe from"os";async function g_r(t,e,r){let n=E0(),i=n!==null,a=0,s,o=u0a({input:process.stdin,output:process.stdout,terminal:!0});switch(i&&(p_r(n.address)?a=1:(s=await kpe(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(Pi.SETUP_STEP1_SCENARIO1_P2(s));break;case 3:{console.log(Pi.SETUP_STEP2_SCENARIO3_P1),console.log();let u={user_ip:t,date_time:us(),os_version:$pe.type+"_"+$pe.release,node_version:process.version,cli_version:e};await r.sendEventToMixpanel("user_registration_begin",u);let f={confirmRegistration:"",fullNameAnswer:"",emailAddressAnswer:"",companyNameAnswer:"",jobPositionAnswer:"",eulaAnswer:""};try{for(;f.confirmRegistration!="Y";){for(f.fullNameAnswer=(await o.question(A2.bold(" 1. Full Name: "))).trim();f.fullNameAnswer==="";)console.log("Your full name is required. Please provide your first and last name to proceed."),f.fullNameAnswer=(await o.question(A2.bold(" 1. Full Name: "))).trim();for(f.emailAddressAnswer=(await o.question(A2.bold(" 2. Email Address: "))).trim();!await d_r(f.emailAddressAnswer);)f.emailAddressAnswer=(await o.question(A2.bold(" 2. Email Address: "))).trim();for(f.companyNameAnswer=(await o.question(A2.bold(" 3. Company Name: "))).trim(),f.jobPositionAnswer=(await o.question(A2.bold(" 4. Job Position: "))).trim();!n8(f.eulaAnswer);)f.eulaAnswer=(await o.question(A2.bold(` 5. Accept EULA? [Y|N] (${Pi.EULA_TERMS_LINK}): `))).toUpperCase();if(f.eulaAnswer=="N"){console.log(Pi.EULA_REGISTRATION_NO_ACCEPTED);break}for(;!n8(f.confirmRegistration);)console.log(`
517
+ Couldn't push api credentials to remote server: ${o}`}}import{inspect as Hfa}from"util";import Yu from"ora";import{v4 as zfa}from"uuid";import{ethers as Kpe}from"ethers";var o_r={name:"@truebit/cli",version:"1.120.0-beta.260",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.3",chalk:"5.6.2",colors:"1.4.0",commander:"14.0.2",ethers:"6.16.0",figlet:"1.10.0","form-data":"4.0.5","openapi-enforcer":"1.23.0",ora:"9.1.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.2",typescript:"5.9.3",vitest:"4.0.18"},engines:{node:">=22.13.0"}};gf();El();u6();gf();import{createInterface as u0a}from"node:readline/promises";import A2 from"chalk";El();import Ok from"axios";import{ethers as WKe}from"ethers";import{randomBytes as n0a}from"crypto";import{v4 as i0a}from"uuid";gf();import{ethers as Npe}from"ethers";async function u_r(t){xk(t);let e=Ri(w0(),zt.AVAX),r=Npe.keccak256(Npe.toUtf8Bytes(t));return await e.authorization.registerAuthorization(r),r}async function Dpe(t,e,r=Yn("address")){xk(t);let n=Ri(w0(),zt.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=Npe.keccak256(Npe.toUtf8Bytes(t)),f={user:r,apiKeyHash:u,nonce:Number(a),deadline:s},c=await n.utils.signMeta(i,o,f);return(await Uvr(r,u,s,c,e)).status==201?u:null}u6();import{isTooManyTries as f_r,retryAsync as l_r}from"ts-retry";var c_r="0x0000000000000000000000000000000000000000";async function d_r(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 a0a(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 n8(t){return t==="Y"||t==="N"}function p_r(t){return!WKe.isAddress(t)||t.length!==42||!t.startsWith("0x")}async function h_r(){let t=await s0a();try{if(!await Dpe(t,!0))throw Error("The API key could not been registered.")}catch(e){let r=e.message;if(r)throw Error(`There was an error registering the API key -> ${r}`)}return t}async function m_r(){let t=await o0a();try{if(!await Ope(t,!0))throw Error("The namespace could not been registered.")}catch(e){let r=e.message,n=r?r.match(/execution reverted: "(.*?)" /)?.[1]:null;if(n)throw Error(`There was an error registering the namespace -> ${n}`);if(r)throw Error(`There was an error registering the namespace -> ${r}`)}return t}async function a0a(t){let e=await bf();try{return(await e.get(`userexistence/${t}`)).data===!0}catch(r){if(Ok.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 kpe(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=Zf.createSignedBody(r,n,i);return(await(await bf()).get(`user/${t}`,{headers:{"truebit-auth":JSON.stringify(a)}})).data}catch(r){if(Ok.isAxiosError(r)&&r.response?.status===401&&r.response?.data.message.includes("Entitlement Validation Error")||Ok.isAxiosError(r)&&r.response?.status==404&&r.response?.data.message&&r.response?.data.message.includes("User not found"))return null;throw Ok.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 y_r(t){try{return await(await bf()).post("user/register",t)}catch(e){throw Ok.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 s0a(){let t=w0(),e=Ri(t,zt.AVAX),r="";try{await l_r(async()=>{r=i0a();let n=WKe.keccak256(WKe.toUtf8Bytes(r));return await e.authorization.getPayerAddress(n)===c_r},{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw f_r(n)?Error("Attempts to generate unique Api Key for the user exhausted."):n}return r}async function o0a(){let t=w0(),e=Ri(t,zt.AVAX),r="";try{await l_r(async()=>(r=n0a(4).toString("hex"),await e.taskRegistry.getNamespaceOwner(r)===c_r),{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw f_r(n)?Error("Attempts to generate unique namespace for the user exhausted."):n}return r}function b_r(t){t.fullNameAnswer="",t.emailAddressAnswer="",t.companyNameAnswer="",t.jobPositionAnswer="",t.eulaAnswer="",t.confirmRegistration=""}u6();ng();import f0a from"ora";import*as $pe from"os";async function g_r(t,e,r){let n=E0(),i=n!==null,a=0,s,o=u0a({input:process.stdin,output:process.stdout,terminal:!0});switch(i&&(p_r(n.address)?a=1:(s=await kpe(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(Pi.SETUP_STEP1_SCENARIO1_P2(s));break;case 3:{console.log(Pi.SETUP_STEP2_SCENARIO3_P1),console.log();let u={user_ip:t,date_time:us(),os_version:$pe.type+"_"+$pe.release,node_version:process.version,cli_version:e};await r.sendEventToMixpanel("user_registration_begin",u);let f={confirmRegistration:"",fullNameAnswer:"",emailAddressAnswer:"",companyNameAnswer:"",jobPositionAnswer:"",eulaAnswer:""};try{for(;f.confirmRegistration!="Y";){for(f.fullNameAnswer=(await o.question(A2.bold(" 1. Full Name: "))).trim();f.fullNameAnswer==="";)console.log("Your full name is required. Please provide your first and last name to proceed."),f.fullNameAnswer=(await o.question(A2.bold(" 1. Full Name: "))).trim();for(f.emailAddressAnswer=(await o.question(A2.bold(" 2. Email Address: "))).trim();!await d_r(f.emailAddressAnswer);)f.emailAddressAnswer=(await o.question(A2.bold(" 2. Email Address: "))).trim();for(f.companyNameAnswer=(await o.question(A2.bold(" 3. Company Name: "))).trim(),f.jobPositionAnswer=(await o.question(A2.bold(" 4. Job Position: "))).trim();!n8(f.eulaAnswer);)f.eulaAnswer=(await o.question(A2.bold(` 5. Accept EULA? [Y|N] (${Pi.EULA_TERMS_LINK}): `))).toUpperCase();if(f.eulaAnswer=="N"){console.log(Pi.EULA_REGISTRATION_NO_ACCEPTED);break}for(;!n8(f.confirmRegistration);)console.log(`
518
518
  Is the information provided above correct?`),f.confirmRegistration=(await o.question(A2.bold("Press [Y] to confirm or [N] to edit: "))).toUpperCase();f.confirmRegistration=="N"&&(console.log(`
519
519
  Please provide the following information:`),b_r(f))}}catch(h){if(h.name==="AbortError"||h.message.includes("Ctrl+C")){let p=h.message,m=u;m.error_details=p,m.date_time=us();let y={fullname:f.fullNameAnswer,email:f.emailAddressAnswer,company:f.companyNameAnswer,role:f.jobPositionAnswer};m.user_info=JSON.stringify(y),await r.sendEventToMixpanel("user_registration_failed",m),process.exit(0)}}if(f.eulaAnswer=="N")break;let c=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=f0a({text:A2.bold("... registering your account."),stream:process.stdout}).start();try{let h=await m_r(),p=await h_r(),m={name:f.fullNameAnswer,email:f.emailAddressAnswer,walletAddress:n?.address,company:f.companyNameAnswer,jobDescription:f.jobPositionAnswer,EULA:Zf.createSignedBody({ip:await zG(),date:new Date().toISOString()},n.privateKey),defaultNamespace:h,defaultApiKey:p};await y_r(m),d.stop(),console.log(Pi.SETUP_STEP2_SCENARIO3_P2(f,n.address,h,p)),c.distinct_id=m.walletAddress,c.date_time=us(),c.fullname=m.name,c.email=m.email,c.company=m.company,c.role=m.jobDescription,c.namespace=m.defaultNamespace,c.api_key=p,c.wallet_address=m.walletAddress,await r.sendEventToMixpanel("user_registration_success",c),await r.registerUserMixpanel(c.wallet_address,l0a(c))}catch(h){d.stop();let p=h.message,m=u;m.error_details=p,m.date_time=us();let y={fullname:f.fullNameAnswer,email:f.emailAddressAnswer,company:f.companyNameAnswer,role:f.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(Pi.SETUP_STEP2_UNHANDLED_ERROR),process.exit(1)}finally{d.clear()}break}default:throw Error("An unexpected error occurred.")}o.close()}function l0a(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 Wfa}from"node:net";import c0a from"chalk";gf();ng();import{createInterface as d0a}from"node:readline/promises";import*as Bpe from"os";async function v_r(t,e,r){let n=E0(),i=n!==null,a=0;switch(i?i&&!n.eula?a=2:a=3:a=1,a){case 1:case 2:{let s=d0a({input:process.stdin,output:process.stdout,terminal:!0}),o="",u={user_ip:t,date_time:us(),os_version:Bpe.type+"_"+Bpe.release,node_version:process.version,cli_version:e};for(console.log(Pi.EULA_INSTALLATION);!n8(o);)o=(await s.question(c0a.bold(`
520
520
  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=us(),await r.sendEventToMixpanel("TOS_rejected",u),Pi.EULA_INSTALLATION_NO_ACCEPTED;u.date_time=us(),await r.sendEventToMixpanel("TOS_accepted",u);let f=Math.round(new Date().getTime()).toString();if(a===1){let c={...MTe(),eula:f};HCt(c)}else a===2&&fq({eula:f});s.close()}break;default:break}}gf();ng();async function Vc(t=!1){let e=E0(),r=e!==null,n=null,i=0;switch(r?r&&(!e.privateKey||!e.address)?i=2:(n=await kpe(e.address,e),n?i=4:i=3):i=1,i){case 1:case 2:case 3:console.log(Pi.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 p0a}from"node:readline/promises";ng();gf();import h0a from"chalk";async function __r(){console.log(h0a.bold(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truebit/cli",
3
- "version": "1.120.0-beta.259",
3
+ "version": "1.120.0-beta.260",
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": "54a84390e92cb10603ad7772c06bb524ea0b6c9b"
58
+ "gitHead": "7be7df08be95b6848e5e99b12e8fb1737061d5fe"
59
59
  }