@truebit/cli 1.120.0-beta.204 → 1.120.0-beta.206
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
|
@@ -224,7 +224,7 @@ API Task response`)}
|
|
|
224
224
|
`,r+=T0.green(JSON.stringify(_,null,2)),console.log(`API Task executed with status - ${T0.green("OK")} `),console.log(r)}else throw console.info(`Axios call - ${T0.red("ERROR")} `),console.log(r),new Error(`Invalid message input ${w}`)};import{Wallet as Ake}from"ethers";function BK(e){return/^[a-f0-9]{64}$/gi.test(e)}function qK(e){try{new Ake(e)}catch{return!1}return!0}var gc=e=>{let t=e.split("_");return!!BK(t[t.length-1])};function Dp(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 Ske}from"ethers";import hw from"axios";async function FK(e,t,n,a,r,i){let s={user:e,namespace:t,nonce:BigInt(n),deadline:a,signatureMeta:r};try{let o=await pf(),l={...s};return l.nonce=String(s.nonce),await o.post("user/relayer/namespace",l,{params:{fromSetup:i}})}catch(o){throw hw.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 UK(e,t,n,a,r){let i={user:e,apiKeyHash:t,deadline:n,signatureMeta:a};try{return await(await pf()).post("user/relayer/auth",i,{params:{fromSetup:r}})}catch(s){throw hw.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 jK(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 l=await pf(),d={...o};return d.nonce=String(o.nonce),await l.post("user/relayer/task",d)}catch(l){throw hw.isAxiosError(l)?l.response?new Error(`The server responding with an error - ${l.response.status+" - "+l.response.statusText+" - "+l.response.data.message}.`):l.request?new Error(`The server is not responding - ${l.message}.`):new Error(`There was an error in the communication with the server - ${l.message}.`):typeof l=="string"?new Error(`There was an error in the communication with the server -> ${l}`):new Error("There was an error in the communication with the server.")}}async function Cb(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 '${ls()}/.truebit/secret.json'`;return n?r=await i.taskRegistry.registerTaskNamespace(e):r=await Tke(s,e,i,t),r}async function Tke(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:Ske.getAddress(e),namespace:t,nonce:s,deadline:Math.floor(Date.now()/1e3)+3600},l=await n.utils.signMeta(r,i,o);return Date.now()/1e3>=o.deadline&&(o.deadline=Math.floor(Date.now()/1e3)+7200,l=await n.utils.signMeta(r,i,o)),(await FK(e,t,o.nonce,o.deadline,l,a)).status==201}async function HK(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},l=await r.utils.signMeta(i,s,o);return Date.now()/1e3>=o.deadline&&(o.deadline=Math.floor(Date.now()/1e3)+7200,l=await r.utils.signMeta(i,s,o)),(await jK(e,t,n,a,o.nonce,o.deadline,l)).status==201}async function zK(e){return await(await Rr()).post("api/filesystem/push",cs({taskId:e})).catch(Nr)}async function VK(e,t){let n=At("blockchainEnv");return await dn(n).taskRegistry.getLatestVersion(e,t)}async function GK(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 '${ls()}/.truebit/secret.json'`);s=await HK(o,t,n,e,i)}}catch(o){let l=o.message,d=l.match(/execution reverted: "(.*?)" /)?.[1];throw d?new Error(`Trying to register a task -> ${d}`):new Error(`Trying to register a task -> ${l}`)}return s}async function WK(e,t,n,a,r){if(!gc(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 zK(n),await GK({taskId:n,meta:a||"",active:!0},e,t,r),i=await VK(e,t)}catch(s){if(s instanceof Error)throw s;if(typeof s=="string")throw new Error(s)}return i}async function KK(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 Pb from"fs";import*as ZK from"path";var XK=async(e,t,n)=>{if(console.log("Executing the function Task"),!gc(t))throw"Invalid task id";let a={status:"",result:""},r=await Rr(),i=await r.post("api/execution/",cs({taskId:t,input:n})).catch(Nr),s=i.data.executionId;return console.log(`Execution Id: ${s}`),i.data.payload?(YK(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 l=setInterval(async()=>{try{let d=await r.get(`api/execution/${s}`);d.data&&d.data.status!="running"&&(YK(e,d.data),clearInterval(l),a.status=d.data.status,a.result=d.data.output?.result?d.data.output?.result:"",o())}catch(d){console.error(`Error polling execution status: ${d}`),clearInterval(l),a.status="failed",a.result=`Polling error: ${d}`,o()}},1e3);setTimeout(()=>{clearInterval(l),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 YK(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=Pb.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),Pb.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 JK(e){try{let n=await(await Rr()).post("api/instrumentation",cs({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:
|
|
225
225
|
${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 QK from"readline";import{ethers as Eke}from"ethers";async function eY(){let e=Ga(),t=e!==null,n=QK.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:cb(),console.log(Jt.SETUP_STEP1_SCENARIO1_P1);break;case 2:{cb();let i=Eke.Wallet.createRandom(),s=i.privateKey,o=i.address;_p({privateKey:s,address:o}),console.log(`
|
|
226
226
|
Setting up your new wallet...`),console.log(Jt.SETUP_STEP1_SCENARIO2(o));break}case 3:cb(),console.log(Jt.SETUP_STEP1_SCENARIO3),process.exit(1);break;default:console.log("An unexpected error occurred.");break}n.close()}async function tY(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 nY=pt(Jx(),1),Lp=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")}}},kb=class extends Lp{tokens=["accessKey","secretKey"];constructor(t){super(),this.parse(this.tokens,t)}authHeaders(t){return nY.default.sign(t,{accessKeyId:this.authInputs.accessKey,secretAccessKey:this.authInputs.secretKey}).headers||{}}},Ob=class extends Lp{tokens=["username","password"];constructor(t){super(),this.parse(this.tokens,t)}authHeaders(t){return{Authorization:`Basic ${btoa(`${this.authInputs.username}:${this.authInputs.password}`)}`}}},$b=class extends Lp{tokens=[];constructor(t){super(),this.parse([],t)}authHeaders(t){return{...this.authInputs}}};var E0;(function(e){e.AWS_SIGNATURE="aws-signature",e.BASIC_AUTH="basic-auth",e.CUSTOM_HEADER="custom-header"})(E0||(E0={}));var mw=(e,t)=>{switch(e){case E0.AWS_SIGNATURE:return new kb(t);case E0.BASIC_AUTH:return new Ob(t);case E0.CUSTOM_HEADER:return new $b(t);default:throw new Error(`Invalid authentication method specified. Should be one of <${Object.values(E0)}>`)}};import Mke from"chalk";import{ethers as Cke}from"ethers";async function aY(e,t,n,a,r,i,s){console.log("Deploying the API Authentication Credentials");try{if(!qK(i))throw"Invalid private key provided";if(!Cke.isAddress(s))throw"Invalid address provided";if(mw(a,r),!gc(e))throw"Invalid taskId";await(await Rr()).post("api/api-credentials",cs({taskId:e,namespace:t,taskName:n,authString:r,method:a})).catch(Nr),console.log("The credentials were deployed "+Mke.green("Successfully"))}catch(o){throw`There was an Error deploying credentials:
|
|
227
|
-
Couldn't push api credentials to remote server: ${o}`}}import{inspect as WOe}from"util";import ua from"ora";import{v4 as KOe}from"uuid";import{ethers as Wb}from"ethers";var rY={name:"@truebit/cli",version:"1.120.0-beta.
|
|
227
|
+
Couldn't push api credentials to remote server: ${o}`}}import{inspect as WOe}from"util";import ua from"ora";import{v4 as KOe}from"uuid";import{ethers as Wb}from"ethers";var rY={name:"@truebit/cli",version:"1.120.0-beta.206",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.12.1",chalk:"5.6.2",colors:"1.4.0",commander:"14.0.1",ethers:"6.15.0",figlet:"1.9.1","openapi-enforcer":"1.23.0",ora:"8.2.0","public-ip":"7.0.1","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":"3.2.4",esbuild:"^0.25.9",typescript:"5.9.2",vitest:"3.2.4"},engines:{node:">=22.13.0"}};import{createInterface as Dke}from"node:readline/promises";import ko from"chalk";import Bp from"axios";import{ethers as bw}from"ethers";import{randomBytes as kke}from"crypto";import{v4 as Oke}from"uuid";import{ethers as Rb}from"ethers";async function iY(e,t=At("blockchainEnv")){Dp(e);let n=dn(t),a=Rb.keccak256(Rb.toUtf8Bytes(e));return await n.authorization.registerAuthorization(a),a}async function Nb(e,t,n=At("blockchainEnv"),a=At("address")){Dp(e);let r=dn(n),i=await r.authorization.getEIP712Domain(),s=await r.authorization.nonces(a),o=Math.floor(Date.now()/1e3)+3600,l={RegisterMeta:[{name:"user",type:"address"},{name:"apiKeyHash",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},d=Rb.keccak256(Rb.toUtf8Bytes(e)),p={user:a,apiKeyHash:d,nonce:Number(s),deadline:o},b=await r.utils.signMeta(i,l,p);return(await UK(a,d,o,b,t)).status==201?d:null}import{isTooManyTries as sY,retryAsync as oY}from"ts-retry";var fY="0x0000000000000000000000000000000000000000";async function dY(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 $ke(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 yd(e){return e==="Y"||e==="N"}function lY(e){return!bw.isAddress(e)||e.length!==42||!e.startsWith("0x")}async function cY(){let e=await Rke();try{if(!await Nb(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 uY(){let e=await Nke();try{if(!await Cb(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 $ke(e){let t=await pf();try{return(await t.get(`userexistence/${e}`)).data===!0}catch(n){if(Bp.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 Db(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=ds.createSignedBody(n,a,r);return(await(await pf()).get(`user/${e}`,{headers:{"truebit-auth":JSON.stringify(i)}})).data}catch(n){if(Bp.isAxiosError(n)&&n.response?.status===401&&n.response?.data.message.includes("Entitlement Validation Error")||Bp.isAxiosError(n)&&n.response?.status==404&&n.response?.data.message&&n.response?.data.message.includes("User not found"))return null;throw Bp.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 pY(e){try{return await(await pf()).post("user/register",e)}catch(t){throw Bp.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 Rke(){let e=At("blockchainEnv"),t=dn(e),n="";try{await oY(async()=>{n=Oke();let a=bw.keccak256(bw.toUtf8Bytes(n));return await t.authorization.getPayerAddress(a)===fY},{delay:500,maxTry:5,until:a=>a===!0})}catch(a){throw sY(a)?Error("Attempts to generate unique Api Key for the user exhausted."):a}return n}async function Nke(){let e=At("blockchainEnv"),t=dn(e),n="";try{await oY(async()=>(n=kke(4).toString("hex"),await t.taskRegistry.getNamespaceOwner(n)===fY),{delay:500,maxTry:5,until:a=>a===!0})}catch(a){throw sY(a)?Error("Attempts to generate unique namespace for the user exhausted."):a}return n}function hY(e){e.fullNameAnswer="",e.emailAddressAnswer="",e.companyNameAnswer="",e.jobPositionAnswer="",e.eulaAnswer="",e.confirmRegistration=""}import Lke from"ora";import*as Lb from"os";async function mY(e,t,n){let a=Ga(),r=a!==null,i=0,s,o=Dke({input:process.stdin,output:process.stdout,terminal:!0});switch(r&&(lY(a.address)?i=1:(s=await Db(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 l={user_ip:e,date_time:Mn(),os_version:Lb.type+"_"+Lb.release,node_version:process.version,cli_version:t};await n.sendEventToMixpanel("user_registration_begin",l);let d={confirmRegistration:"",fullNameAnswer:"",emailAddressAnswer:"",companyNameAnswer:"",jobPositionAnswer:"",eulaAnswer:""};try{for(;d.confirmRegistration!="Y";){for(d.fullNameAnswer=(await o.question(ko.bold(" 1. Full Name: "))).trim();d.fullNameAnswer==="";)console.log("Your full name is required. Please provide your first and last name to proceed."),d.fullNameAnswer=(await o.question(ko.bold(" 1. Full Name: "))).trim();for(d.emailAddressAnswer=(await o.question(ko.bold(" 2. Email Address: "))).trim();!await dY(d.emailAddressAnswer);)d.emailAddressAnswer=(await o.question(ko.bold(" 2. Email Address: "))).trim();for(d.companyNameAnswer=(await o.question(ko.bold(" 3. Company Name: "))).trim(),d.jobPositionAnswer=(await o.question(ko.bold(" 4. Job Position: "))).trim();!yd(d.eulaAnswer);)d.eulaAnswer=(await o.question(ko.bold(` 5. Accept EULA? [Y|N] (${Jt.EULA_TERMS_LINK}): `))).toUpperCase();if(d.eulaAnswer=="N"){console.log(Jt.EULA_REGISTRATION_NO_ACCEPTED);break}for(;!yd(d.confirmRegistration);)console.log(`
|
|
228
228
|
Is the information provided above correct?`),d.confirmRegistration=(await o.question(ko.bold("Press [Y] to confirm or [N] to edit: "))).toUpperCase();d.confirmRegistration=="N"&&(console.log(`
|
|
229
229
|
Please provide the following information:`),hY(d))}}catch(w){if(w.name==="AbortError"||w.message.includes("Ctrl+C")){let A=w.message,_=l;_.error_details=A,_.date_time=Mn();let k={fullname:d.fullNameAnswer,email:d.emailAddressAnswer,company:d.companyNameAnswer,role:d.jobPositionAnswer};_.user_info=JSON.stringify(k),await n.sendEventToMixpanel("user_registration_failed",_),process.exit(0)}}if(d.eulaAnswer=="N")break;let p=l;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=Lke({text:ko.bold("... registering your account."),stream:process.stdout}).start();try{let w=await uY(),A=await cY(),_={name:d.fullNameAnswer,email:d.emailAddressAnswer,walletAddress:a?.address,company:d.companyNameAnswer,jobDescription:d.jobPositionAnswer,EULA:ds.createSignedBody({ip:await gb(),date:new Date().toISOString()},a.privateKey),defaultNamespace:w,defaultApiKey:A};await pY(_),b.stop(),console.log(Jt.SETUP_STEP2_SCENARIO3_P2(d,a.address,w,A)),p.distinct_id=_.walletAddress,p.date_time=Mn(),p.fullname=_.name,p.email=_.email,p.company=_.company,p.role=_.jobDescription,p.namespace=_.defaultNamespace,p.api_key=A,p.wallet_address=_.walletAddress,await n.sendEventToMixpanel("user_registration_success",p),await n.registerUserMixpanel(p.wallet_address,Bke(p))}catch(w){b.stop();let A=w.message,_=l;_.error_details=A,_.date_time=Mn();let k={fullname:d.fullNameAnswer,email:d.emailAddressAnswer,company:d.companyNameAnswer,role:d.jobPositionAnswer};_.user_info=JSON.stringify(k),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 Bke(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 YOe}from"node:net";import qke from"chalk";import{createInterface as Fke}from"node:readline/promises";import*as Bb from"os";async function bY(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=Fke({input:process.stdin,output:process.stdout,terminal:!0}),o="",l={user_ip:e,date_time:Mn(),os_version:Bb.type+"_"+Bb.release,node_version:process.version,cli_version:t};for(console.log(Jt.EULA_INSTALLATION);!yd(o);)o=(await s.question(qke.bold(`
|
|
230
230
|
Have you read, and do you accept the Terms of Use? [Y|N]: `))).toUpperCase(),await n.sendEventToMixpanel("TOS_shown",l);if(o=="N")throw l.date_time=Mn(),await n.sendEventToMixpanel("TOS_rejected",l),Jt.EULA_INSTALLATION_NO_ACCEPTED;l.date_time=Mn(),await n.sendEventToMixpanel("TOS_accepted",l);let d=Math.round(new Date().getTime()).toString();if(i===1){let p={...oc(),eula:d};jW(p)}else i===2&&_p({eula:d});s.close()}break;case 3:default:break}}async function I0(e=!1){let t=Ga(),n=t!==null,a=null,r=0;switch(n?n&&(!t.privateKey||!t.address)?r=2:(a=await Db(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 Uke}from"node:readline/promises";import jke from"chalk";async function yY(){console.log(jke.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.206",
|
|
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": "8d7b9dedef2b9ea2f0efbc5abfa6d28328612255"
|
|
58
58
|
}
|