@truebit/cli 1.120.0-beta.188 → 1.120.0-beta.189
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/build/index.mjs +1 -1
- package/package.json +2 -2
package/build/index.mjs
CHANGED
|
@@ -225,7 +225,7 @@ API Task response`)}
|
|
|
225
225
|
`,r+=w0.green(JSON.stringify(_,null,2)),console.log(`API Task executed with status - ${w0.green("OK")} `),console.log(r)}else throw console.info(`Axios call - ${w0.red("ERROR")} `),console.log(r),new Error(`Invalid message input ${w}`)};import{Wallet as ZPe}from"ethers";function kK(e){return/^[a-f0-9]{64}$/gi.test(e)}function $K(e){try{new ZPe(e)}catch{return!1}return!0}var lc=e=>{let t=e.split("_");return!!kK(t[t.length-1])};function up(e){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(e))throw new Error("Invalid API key format")}import{ethers as XPe}from"ethers";import Qx from"axios";async function RK(e,t,n,a,r,i){let s={user:e,namespace:t,nonce:BigInt(n),deadline:a,signatureMeta:r};try{let o=await cf(),c={...s};return c.nonce=String(s.nonce),await o.post("user/relayer/namespace",c,{params:{fromSetup:i}})}catch(o){throw Qx.isAxiosError(o)?o.response?new Error(`The server responding with an error - ${o.response.status+" - "+o.response.statusText+" - "+o.response.data.message}.`):o.request?new Error(`The server is not responding - ${o.message}.`):new Error(`There was an error in the communication with the server - ${o.message}.`):typeof o=="string"?new Error(`There was an error in the communication with the server -> ${o}`):new Error("There was an error in the communication with the server.")}}async function NK(e,t,n,a,r){let i={user:e,apiKeyHash:t,deadline:n,signatureMeta:a};try{return await(await cf()).post("user/relayer/auth",i,{params:{fromSetup:r}})}catch(s){throw Qx.isAxiosError(s)?s.response?new Error(`The server responding with an error - ${s.response.status+" - "+s.response.statusText+" - "+s.response.data.message}.`):s.request?new Error(`The server is not responding - ${s.message}.`):new Error(`There was an error in the communication with the server - ${s.message}.`):typeof s=="string"?new Error(`There was an error in the communication with the server -> ${s}`):new Error("There was an error in the communication with the server.")}}async function DK(e,t,n,a,r,i,s){let o={user:e,namespace:t,taskName:n,task:a,nonce:BigInt(r),deadline:i,signatureMeta:s};try{let c=await cf(),l={...o};return l.nonce=String(o.nonce),await c.post("user/relayer/task",l)}catch(c){throw Qx.isAxiosError(c)?c.response?new Error(`The server responding with an error - ${c.response.status+" - "+c.response.statusText+" - "+c.response.data.message}.`):c.request?new Error(`The server is not responding - ${c.message}.`):new Error(`There was an error in the communication with the server - ${c.message}.`):typeof c=="string"?new Error(`There was an error in the communication with the server -> ${c}`):new Error("There was an error in the communication with the server.")}}async function ib(e,t,n=null,a=At("blockchainEnv")){Ta(e,"Namespace");let r,i=dn(a),s=At("address");if(!s)throw`Please provide an address property in '${os()}/.truebit/secret.json'`;return n?r=await i.taskRegistry.registerTaskNamespace(e):r=await JPe(s,e,i,t),r}async function JPe(e,t,n,a){let r=await n.taskRegistry.getEIP712Domain(),i={RegisterTaskNamespaceMeta:[{name:"user",type:"address"},{name:"namespace",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},s=BigInt(await n.taskRegistry.nonces(e)),o={user:XPe.getAddress(e),namespace:t,nonce:s,deadline:Math.floor(Date.now()/1e3)+3600},c=await n.utils.signMeta(r,i,o);return Date.now()/1e3>=o.deadline&&(o.deadline=Math.floor(Date.now()/1e3)+7200,c=await n.utils.signMeta(r,i,o)),(await RK(e,t,o.nonce,o.deadline,c,a)).status==201}async function LK(e,t,n,a,r){let i=await r.taskRegistry.getEIP712Domain(),s={Task:[{name:"taskId",type:"string"},{name:"meta",type:"string"},{name:"active",type:"bool"}],RegisterTaskMeta:[{name:"user",type:"address"},{name:"namespace",type:"string"},{name:"taskName",type:"string"},{name:"task",type:"Task"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},o={user:e,namespace:t,taskName:n,task:{taskId:a.taskId,meta:a.meta,active:a.active},nonce:BigInt(await r.taskRegistry.nonces(e)),deadline:Math.floor(Date.now()/1e3)+3600},c=await r.utils.signMeta(i,s,o);return Date.now()/1e3>=o.deadline&&(o.deadline=Math.floor(Date.now()/1e3)+7200,c=await r.utils.signMeta(i,s,o)),(await DK(e,t,n,a,o.nonce,o.deadline,c)).status==201}async function BK(e){return await(await Rr()).post("api/filesystem/push",fs({taskId:e})).catch(Nr)}async function qK(e,t){let n=At("blockchainEnv");return await dn(n).taskRegistry.getLatestVersion(e,t)}async function FK(e,t,n,a=null){let r=At("blockchainEnv"),i=dn(r),s=!1;try{if(a)s=await i.taskRegistry.registerTask(t,n,e);else{let o=At("address");if(!o)throw Error(`Please provide an address property in '${os()}/.truebit/secret.json'`);s=await LK(o,t,n,e,i)}}catch(o){let c=o.message,l=c.match(/execution reverted: "(.*?)" /)?.[1];throw l?new Error(`Trying to register a task -> ${l}`):new Error(`Trying to register a task -> ${c}`)}return s}async function UK(e,t,n,a,r){if(!lc(n))throw new Error("Invalid taskId");if(a)try{a=JSON.stringify(a)}catch{throw new Error("Meta information cannot be serialized as JSON")}let i=null;try{await BK(n),await FK({taskId:n,meta:a||"",active:!0},e,t,r),i=await qK(e,t)}catch(s){if(s instanceof Error)throw s;if(typeof s=="string")throw new Error(s)}return i}async function HK(e,t,n){let a=At("blockchainEnv"),r=dn(a),i=await r.taskRegistry.getLatestVersion(e,t);return await r.taskRegistry.setTaskLabel(e,t,i,n)}import*as sb from"fs";import*as zK from"path";var VK=async(e,t,n)=>{if(console.log("Executing the function Task"),!lc(t))throw"Invalid task id";let a={status:"",result:""},r=await Rr(),i=await r.post("api/execution/",fs({taskId:t,input:n})).catch(Nr),s=i.data.executionId;return console.log(`Execution Id: ${s}`),i.data.payload?(jK(e,i.data.payload),a.status=i.data.payload.status,a.result=i.data.payload.output?.result?i.data.payload.output?.result:""):await new Promise(o=>{let c=setInterval(async()=>{try{let l=await r.get(`api/execution/${s}`);l.data&&l.data.status!="running"&&(jK(e,l.data),clearInterval(c),a.status=l.data.status,a.result=l.data.output?.result?l.data.output?.result:"",o())}catch(l){console.error(`Error polling execution status: ${l}`),clearInterval(c),a.status="failed",a.result=`Polling error: ${l}`,o()}},1e3);setTimeout(()=>{clearInterval(c),a.status="timeout",a.result="Task execution timed out after 30 seconds",console.error("Task execution timed out after 30 seconds"),o()},3e4)}),a};function jK(e,t){if(console.log(`Task executed with status: ${t.status}`),t.output)if(console.log(`Task executed with result: ${t.output.result}`),t.output.metering){console.log("Task resource usage:");let n=t.output.metering,a=(i,s)=>{if(s==0)return"N/A";let o=i/s;return o<1?"Short":Number(o.toFixed(0))},r={Gas:{Unit:"Steps",Limits:n.limits.gas,Peak:"N/A","Last status":n.last.steps,Capacity:a(n.limits.gas,n.last.steps)},"Nested calls":{Unit:"Calls",Limits:n.limits.call,Peak:n.peak.call,"Last status":n.last.call,Capacity:a(n.limits.call,n.peak.call)},"Frame memory":{Unit:"Bytes",Limits:n.limits.frame,Peak:n.peak.frame,"Last status":n.last.frame,Capacity:a(n.limits.frame,n.peak.frame)},"System memory":{Unit:"64 Kb pages",Limits:n.limits.memory,Peak:n.peak.memory,"Last status":"\u{1D6AB} "+n.last.memoryGrowDelta,Capacity:a(n.limits.memory,n.peak.memory)}};if(console.table(r),e.updateConfig){let i=zK.join(process.cwd(),"config.json");try{let s=sb.readFileSync(i),o=JSON.parse(s.toString());o.run.limits.gas=String(n.last.steps),o.run.limits.call=String(n.peak.call),o.run.limits.frame=String(n.peak.frame),o.run.limits.memory=String(n.limits.memory),sb.writeFileSync(i,JSON.stringify(o)),console.log("Task limits updated with last/peak values (--update-config)")}catch(s){console.log(`Error updating config file at '${i}': '${s}', (--update-config)`)}}}else console.log("No task resource usage reported.")}async function GK(e){try{let n=await(await Rr()).post("api/instrumentation",fs({taskId:`${e}`})).catch(Nr);if(n.data.error?.status===!0)if(n.data.error.message)console.log(`Instrumentation failed: ${n.data.error?.message}`);else throw"Malformed instrumentation service error message";else if(n.data.payload&&n.data.payload.instrumentedTaskId)console.log("Your function task is ready."),console.log(`Use the following TaskId for execution or deployment:
|
|
226
226
|
${n.data.payload.instrumentedTaskId}`);else throw"Malformed instrumentation service success message";return n.data.payload.instrumentedTaskId}catch(t){throw console.error(t),t}}import*as WK from"readline";import{ethers as QPe}from"ethers";async function KK(){let e=Ga(),t=e!==null,n=WK.createInterface({input:process.stdin,output:process.stdout}),a=i=>new Promise(s=>n.question(i,s)),r=0;if(t&&e.privateKey&&e.address)r=1;else if(t)switch(console.log(Jt.SETUP_STEP1),(await a("Press [Y] to proceed or [N] to skip: ")).trim().toUpperCase()){case"Y":r=2;break;case"N":r=3;break;default:console.log("Invalid input. Please enter Y or N."),n.close();return}switch(r){case 1:Hm(),console.log(Jt.SETUP_STEP1_SCENARIO1_P1);break;case 2:{Hm();let i=QPe.Wallet.createRandom(),s=i.privateKey,o=i.address;Z6({privateKey:s,address:o}),console.log(`
|
|
227
227
|
Setting up your new wallet...`),console.log(Jt.SETUP_STEP1_SCENARIO2(o));break}case 3:Hm(),console.log(Jt.SETUP_STEP1_SCENARIO3),process.exit(1);break;default:console.log("An unexpected error occurred.");break}n.close()}async function YK(e){try{console.log("Fetching execution status...");let n=await(await Rr()).get(`api/execution/${e}`).catch(Nr);if(n.data.message)throw n.data.message;console.log("Task execution status: ",n.data.status),n.data.output&&console.log("Task execution output: ",n.data.output)}catch(t){console.error(`Couldn't fetch execution status for executionId ${e}: ${t}`)}}var ZK=dt(Dx(),1),pp=class{tokens=[];authInputs;parse(t,n){let a=this.parseKeyValuePairs(n);if(t.length==0){this.authInputs=a;return}let r=Object.keys(a);if(t.every(i=>r.includes(i))){let i={};for(let s of t)i[s]=a[s];this.authInputs=i}else throw new Error(`Invalid authString: ${t} are required`)}parseKeyValuePairs(t){try{let n=t.split(","),a={};for(let r of n){let[i,s]=r.split(":");a[i.trim()]=s.trim()}return a}catch{throw new Error("Invalid auth string")}}},ob=class extends pp{tokens=["accessKey","secretKey"];constructor(t){super(),this.parse(this.tokens,t)}authHeaders(t){return ZK.default.sign(t,{accessKeyId:this.authInputs.accessKey,secretAccessKey:this.authInputs.secretKey}).headers||{}}},fb=class extends pp{tokens=["username","password"];constructor(t){super(),this.parse(this.tokens,t)}authHeaders(t){return{Authorization:`Basic ${btoa(`${this.authInputs.username}:${this.authInputs.password}`)}`}}},db=class extends pp{tokens=[];constructor(t){super(),this.parse([],t)}authHeaders(t){return{...this.authInputs}}};var A0;(function(e){e.AWS_SIGNATURE="aws-signature",e.BASIC_AUTH="basic-auth",e.CUSTOM_HEADER="custom-header"})(A0||(A0={}));var ew=(e,t)=>{switch(e){case A0.AWS_SIGNATURE:return new ob(t);case A0.BASIC_AUTH:return new fb(t);case A0.CUSTOM_HEADER:return new db(t);default:throw new Error(`Invalid authentication method specified. Should be one of <${Object.values(A0)}>`)}};import tOe from"chalk";import{ethers as nOe}from"ethers";async function XK(e,t,n,a,r,i,s){console.log("Deploying the API Authentication Credentials");try{if(!$K(i))throw"Invalid private key provided";if(!nOe.isAddress(s))throw"Invalid address provided";if(ew(a,r),!lc(e))throw"Invalid taskId";await(await Rr()).post("api/api-credentials",fs({taskId:e,namespace:t,taskName:n,authString:r,method:a})).catch(Nr),console.log("The credentials were deployed "+tOe.green("Successfully"))}catch(o){throw`There was an Error deploying credentials:
|
|
228
|
-
Couldn't push api credentials to remote server: ${o}`}}import{inspect as _ke}from"util";import ua from"ora";import{v4 as xke}from"uuid";import{ethers as Ab}from"ethers";var JK={name:"@truebit/cli",version:"1.120.0-beta.
|
|
228
|
+
Couldn't push api credentials to remote server: ${o}`}}import{inspect as _ke}from"util";import ua from"ora";import{v4 as xke}from"uuid";import{ethers as Ab}from"ethers";var JK={name:"@truebit/cli",version:"1.120.0-beta.189",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","prebuild:dev":"rimraf build","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.11.0",chalk:"5.5.0",colors:"1.4.0",commander:"14.0.0",ethers:"6.15.0",figlet:"1.8.2","openapi-enforcer":"1.23.0",ora:"8.2.0","public-ip":"7.0.1","ts-retry":"6.0.0",uuid:"11.1.0"},bin:{truebit:"build/index.mjs"},files:["build"],devDependencies:{"@types/figlet":"1.7.0","@vitest/coverage-v8":"3.2.4",esbuild:"^0.25.8",typescript:"5.9.2",vitest:"3.2.4"},engines:{node:">=22.13.0"}};import{createInterface as dOe}from"node:readline/promises";import Mo from"chalk";import hp from"axios";import{ethers as tw}from"ethers";import{randomBytes as rOe}from"crypto";import{v4 as iOe}from"uuid";import{ethers as lb}from"ethers";async function QK(e,t=At("blockchainEnv")){up(e);let n=dn(t),a=lb.keccak256(lb.toUtf8Bytes(e));return await n.authorization.registerAuthorization(a),a}async function cb(e,t,n=At("blockchainEnv"),a=At("address")){up(e);let r=dn(n),i=await r.authorization.getEIP712Domain(),s=await r.authorization.nonces(a),o=Math.floor(Date.now()/1e3)+3600,c={RegisterMeta:[{name:"user",type:"address"},{name:"apiKeyHash",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},l=lb.keccak256(lb.toUtf8Bytes(e)),m={user:a,apiKeyHash:l,nonce:Number(s),deadline:o},b=await r.utils.signMeta(i,c,m);return(await NK(a,l,o,b,t)).status==201?l:null}import{isTooManyTries as eY,retryAsync as tY}from"ts-retry";var nY="0x0000000000000000000000000000000000000000";async function aY(e){let t=!0;return e===""?(t=!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(e)?await sOe(e)&&(t=!1,console.log("The provided email address is already in use. Please enter a different email address.")):(t=!1,console.log("The email address provided is not valid. Please try again.")),t}function md(e){return e==="Y"||e==="N"}function rY(e){return!tw.isAddress(e)||e.length!==42||!e.startsWith("0x")}async function iY(){let e=await oOe();try{if(!await cb(e,!0))throw Error("The API key could not been registered.")}catch(t){let n=t.message;if(n)throw Error(`There was an error registering the API key -> ${n}`)}return e}async function sY(){let e=await fOe();try{if(!await ib(e,!0))throw Error("The namespace could not been registered.")}catch(t){let n=t.message,a=n?n.match(/execution reverted: "(.*?)" /)?.[1]:null;if(a)throw Error(`There was an error registering the namespace -> ${a}`);if(n)throw Error(`There was an error registering the namespace -> ${n}`)}return e}async function sOe(e){let t=await cf();try{return(await t.get(`userexistence/${e}`)).data===!0}catch(n){if(hp.isAxiosError(n)&&n.response?.status===404&&typeof n.response?.data?.message=="string"&&n.response.data.message.includes("User not found"))return!1;throw n}}async function ub(e,t){try{let n={message:"I am a Truebit User"};if(!t)throw Error("Secret.json does not exists");let a=t.privateKey,r=t.address,i=ss.createSignedBody(n,a,r);return(await(await cf()).get(`user/${e}`,{headers:{"truebit-auth":JSON.stringify(i)}})).data}catch(n){if(hp.isAxiosError(n)&&n.response?.status===401&&n.response?.data.message.includes("Entitlement Validation Error")||hp.isAxiosError(n)&&n.response?.status==404&&n.response?.data.message&&n.response?.data.message.includes("User not found"))return null;throw hp.isAxiosError(n)?n.response?Error(`The server responding with an error -> ${n.response.data.message||n.response.status+" - "+n.response.statusText}`):n.request?Error(`The server is not responding -> ${n.message}`):Error(`There was an error in the communication with the server -> ${n.message}`):Error(typeof n=="string"?`There was an error in the communication with the server -> ${n}`:"There was an error in the communication with the server.")}}async function oY(e){try{return await(await cf()).post("user/register",e)}catch(t){throw hp.isAxiosError(t)?t.response?Error(`The server responding with an error -> ${t.response.data.message||t.response.status+" - "+t.response.statusText}`):t.request?Error(`The server is not responding -> ${t.message}`):Error(`There was an error in the communication with the server -> ${t.message}`):Error(typeof t=="string"?`There was an error in the communication with the server -> ${t}`:"There was an error in the communication with the server.")}}async function oOe(){let e=At("blockchainEnv"),t=dn(e),n="";try{await tY(async()=>{n=iOe();let a=tw.keccak256(tw.toUtf8Bytes(n));return await t.authorization.getPayerAddress(a)===nY},{delay:500,maxTry:5,until:a=>a===!0})}catch(a){throw eY(a)?Error("Attempts to generate unique Api Key for the user exhausted."):a}return n}async function fOe(){let e=At("blockchainEnv"),t=dn(e),n="";try{await tY(async()=>(n=rOe(4).toString("hex"),await t.taskRegistry.getNamespaceOwner(n)===nY),{delay:500,maxTry:5,until:a=>a===!0})}catch(a){throw eY(a)?Error("Attempts to generate unique namespace for the user exhausted."):a}return n}function fY(e){e.fullNameAnswer="",e.emailAddressAnswer="",e.companyNameAnswer="",e.jobPositionAnswer="",e.eulaAnswer="",e.confirmRegistration=""}import lOe from"ora";import*as pb from"os";async function dY(e,t,n){let a=Ga(),r=a!==null,i=0,s,o=dOe({input:process.stdin,output:process.stdout,terminal:!0});switch(r&&(rY(a.address)?i=1:(s=await ub(a.address,a),s?i=2:i=3)),i){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(Jt.SETUP_STEP1_SCENARIO1_P2(s));break;case 3:{console.log(Jt.SETUP_STEP2_SCENARIO3_P1),console.log();let c={user_ip:e,date_time:Mn(),os_version:pb.type+"_"+pb.release,node_version:process.version,cli_version:t};await n.sendEventToMixpanel("user_registration_begin",c);let l={confirmRegistration:"",fullNameAnswer:"",emailAddressAnswer:"",companyNameAnswer:"",jobPositionAnswer:"",eulaAnswer:""};try{for(;l.confirmRegistration!="Y";){for(l.fullNameAnswer=(await o.question(Mo.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(Mo.bold(" 1. Full Name: "))).trim();for(l.emailAddressAnswer=(await o.question(Mo.bold(" 2. Email Address: "))).trim();!await aY(l.emailAddressAnswer);)l.emailAddressAnswer=(await o.question(Mo.bold(" 2. Email Address: "))).trim();for(l.companyNameAnswer=(await o.question(Mo.bold(" 3. Company Name: "))).trim(),l.jobPositionAnswer=(await o.question(Mo.bold(" 4. Job Position: "))).trim();!md(l.eulaAnswer);)l.eulaAnswer=(await o.question(Mo.bold(` 5. Accept EULA? [Y|N] (${Jt.EULA_TERMS_LINK}): `))).toUpperCase();if(l.eulaAnswer=="N"){console.log(Jt.EULA_REGISTRATION_NO_ACCEPTED);break}for(;!md(l.confirmRegistration);)console.log(`
|
|
229
229
|
Is the information provided above correct?`),l.confirmRegistration=(await o.question(Mo.bold("Press [Y] to confirm or [N] to edit: "))).toUpperCase();l.confirmRegistration=="N"&&(console.log(`
|
|
230
230
|
Please provide the following information:`),fY(l))}}catch(w){if(w.name==="AbortError"||w.message.includes("Ctrl+C")){let A=w.message,_=c;_.error_details=A,_.date_time=Mn();let O={fullname:l.fullNameAnswer,email:l.emailAddressAnswer,company:l.companyNameAnswer,role:l.jobPositionAnswer};_.user_info=JSON.stringify(O),await n.sendEventToMixpanel("user_registration_failed",_),process.exit(0)}}if(l.eulaAnswer=="N")break;let m=c;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 b=lOe({text:Mo.bold("... registering your account."),stream:process.stdout}).start();try{let w=await sY(),A=await iY(),_={name:l.fullNameAnswer,email:l.emailAddressAnswer,walletAddress:a?.address,company:l.companyNameAnswer,jobDescription:l.jobPositionAnswer,EULA:ss.createSignedBody({ip:await Ym(),date:new Date().toISOString()},a.privateKey),defaultNamespace:w,defaultApiKey:A};await oY(_),b.stop(),console.log(Jt.SETUP_STEP2_SCENARIO3_P2(l,a.address,w,A)),m.distinct_id=_.walletAddress,m.date_time=Mn(),m.fullname=_.name,m.email=_.email,m.company=_.company,m.role=_.jobDescription,m.namespace=_.defaultNamespace,m.api_key=A,m.wallet_address=_.walletAddress,await n.sendEventToMixpanel("user_registration_success",m),await n.registerUserMixpanel(m.wallet_address,cOe(m))}catch(w){b.stop();let A=w.message,_=c;_.error_details=A,_.date_time=Mn();let O={fullname:l.fullNameAnswer,email:l.emailAddressAnswer,company:l.companyNameAnswer,role:l.jobPositionAnswer};_.user_info=JSON.stringify(O),await n.sendEventToMixpanel("user_registration_failed",_);let D=A?A.match(/CreateUserValidation - (.*?.*)/)?.[1]:null;if(D)throw Error(D);if(A.includes("Sender doesn't have enough funds to send tx"))throw Error("We are currently experiencing technical difficulties. Please try again later.");console.error(Jt.SETUP_STEP2_UNHANDLED_ERROR),process.exit(1)}finally{b.clear()}break}default:throw Error("An unexpected error occurred.")}o.close()}function cOe(e){return{apiKey:e.api_key,name:e.fullname,email:e.email,ip:e.user_ip,company:e.company,role:e.role,namespace:e.namespace,walletAddress:e.wallet_address}}import{setDefaultAutoSelectFamily as wke}from"node:net";import uOe from"chalk";import{createInterface as pOe}from"node:readline/promises";import*as hb from"os";async function lY(e,t,n){let a=Ga(),r=a!==null,i=0;switch(r?r&&!a.eula?i=2:i=3:i=1,i){case 1:case 2:{let s=pOe({input:process.stdin,output:process.stdout,terminal:!0}),o="",c={user_ip:e,date_time:Mn(),os_version:hb.type+"_"+hb.release,node_version:process.version,cli_version:t};for(console.log(Jt.EULA_INSTALLATION);!md(o);)o=(await s.question(uOe.bold(`
|
|
231
231
|
Have you read, and do you accept the Terms of Use? [Y|N]: `))).toUpperCase(),await n.sendEventToMixpanel("TOS_shown",c);if(o=="N")throw c.date_time=Mn(),await n.sendEventToMixpanel("TOS_rejected",c),Jt.EULA_INSTALLATION_NO_ACCEPTED;c.date_time=Mn(),await n.sendEventToMixpanel("TOS_accepted",c);let l=Math.round(new Date().getTime()).toString();if(i===1){let m={...Jl(),eula:l};DW(m)}else i===2&&Z6({eula:l});s.close()}break;case 3:default:break}}async function S0(e=!1){let t=Ga(),n=t!==null,a=null,r=0;switch(n?n&&(!t.privateKey||!t.address)?r=2:(a=await ub(t.address,t),a?r=4:r=3):r=1,r){case 1:case 2:case 3:console.log(Jt.USER_NO_REGISTERED),process.exit(1);break;case 4:e&&console.log(`You are logged in as: ${a?.name} - ${a?.email}`);break}}import{createInterface as hOe}from"node:readline/promises";import mOe from"chalk";async function cY(){console.log(mOe.bold(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truebit/cli",
|
|
3
|
-
"version": "1.120.0-beta.
|
|
3
|
+
"version": "1.120.0-beta.189",
|
|
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": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=22.13.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "98c6b1557bd8ede04918a53de48c63b544aff8de"
|
|
58
58
|
}
|