@truebit/cli 1.120.0-beta.272 → 1.120.0-beta.273
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
|
@@ -513,7 +513,7 @@ ${r.data.payload.instrumentedTaskId}`);else throw"Malformed instrumentation serv
|
|
|
513
513
|
`+Bi.cyan("=".repeat(60))),console.log(Bi.cyan.bold(" Quota Status")),console.log(Bi.cyan("=".repeat(60))+`
|
|
514
514
|
`),console.log(Bi.white("Wallet Address: ")+Bi.yellow(e)),console.log(Bi.white("Subscription Tier: ")+Bi.green(s.userSubscription.toUpperCase())),s.maxSolutions!==void 0&&console.log(Bi.white("Max Solutions: ")+Bi.green(`${s.maxSolutions}`)),s.quotaMax===0)console.log(Bi.white("Monthly Quota: ")+Bi.green("UNLIMITED")),s.currentUsage!==void 0&&console.log(Bi.white("Current Usage: ")+Bi.yellow(`${s.currentUsage} executions`));else{if(console.log(Bi.white("Monthly Quota: ")+Bi.green(`${s.quotaMax} executions`)),s.currentUsage!==void 0&&(console.log(Bi.white("Current Usage: ")+Bi.yellow(`${s.currentUsage} executions`)),s.remaining!==void 0)){let c=s.remaining===0?Bi.red:s.remaining<s.quotaMax*.2?Bi.yellow:Bi.green;console.log(Bi.white("Remaining: ")+c(`${s.remaining} executions`))}console.log(Bi.white("Quota Resets On: ")+Bi.yellow(f))}console.log(`
|
|
515
515
|
`+Bi.cyan("=".repeat(60))+`
|
|
516
|
-
`)}catch(t){throw t instanceof Error?console.error(Bi.red("Error fetching quota status: ")+t.message):console.error(Bi.red("Error fetching quota status: ")+String(t)),t}}zKe();vl();async function E_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}`)}}import A_r from"chalk";import{ethers as v0a}from"ethers";vl();import*as kpe from"crypto";import y0a from"axios";import WKe from"chalk";function S_r(t){if(y0a.isAxiosError(t)&&t.response?.data){let e=t.response.data;return console.log(WKe.red(e.message)),typeof e=="string"?e:e.message||JSON.stringify(e)}return t instanceof Error?t.message:String(t)}async function b0a(t,e){try{let r=xc({namespace:e});return(await t.post("getkey",r)).data}catch(r){return S_r(r),console.error(WKe.red("Failed to retrieve encryption key from Hub-TEE-KMS. Please try again")),null}}function g0a(t,e){try{let r=Buffer.from(e,"base64"),n=kpe.randomBytes(16),i=kpe.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 w_r(t,e,r){try{let n=await b0a(t,r);if(!n)return null;let i=g0a(e,n.plaintext_key);return i?{encrypted_authString:i.encrypted_authString,encrypted_data_key:n.encryption_key,iv:i.iv}:null}catch(n){return S_r(n),console.error(WKe.red("Failed to encrypt credentials. Please try again.")),null}}async function x_r(t,e,r,n,i,a,s){console.log("Deploying the API Authentication Credentials");try{if(!n_r(a))throw"Invalid private key provided";if(!v0a.isAddress(s))throw"Invalid address provided";if(cye(n,i),!sT(t))throw"Invalid taskId";let o=await tIt();console.log("Encrypting credentials...");let u=await w_r(o,i,e);if(!u)return;let f=xc({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",f).catch(Ac),console.log("The encrypted credentials were deployed "+A_r.green("Successfully"))}catch(o){let u=o instanceof Error?o.message:String(o);console.error(A_r.red(u));return}}import{inspect as ula}from"util";import Ku from"ora";import{v4 as fla}from"uuid";import{ethers as Jpe}from"ethers";var T_r={name:"@truebit/cli",version:"1.120.0-beta.272",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.5",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"}};w0();vl();u6();w0();import{createInterface as T0a}from"node:readline/promises";import A2 from"chalk";vl();import wk from"axios";import{ethers as oT}from"ethers";import{randomBytes as E0a}from"crypto";import{v4 as S0a}from"uuid";w0();import{ethers as $pe}from"ethers";async function O_r(t){J_(t);let e=gi(Mu(),zt.AVAX),r=$pe.keccak256($pe.toUtf8Bytes(t));return await e.authorization.registerAuthorization(r),r}async function GKe(t,e,r=Dn("address")){J_(t);let n=gi(Mu(),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=$pe.keccak256($pe.toUtf8Bytes(t)),f={user:r,apiKeyHash:u,nonce:Number(a),deadline:s};if(!n.utils)throw new Error("Private key is required for signing operations");let c=await n.utils.signMeta(i,o,f);return(await a_r(r,u,s,c,e)).status==201?u:null}w0();u6();import{isTooManyTries as C_r,retryAsync as I_r}from"ts-retry";var M_r="0x0000000000000000000000000000000000000000";async function P_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 w0a(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 Z_(t){return t==="Y"||t==="N"}function R_r(t){return!oT.isAddress(t)||t.length!==42||!t.startsWith("0x")}async function q_r(){let t=Mu(),e=gi(t,zt.AVAX),r=Dn("address"),n=await x0a(),i=await A0a();J_(i);let a=oT.keccak256(oT.toUtf8Bytes(i)),s=Math.floor(Date.now()/1e3)+3600,o=await e.taskRegistry.getEIP712Domain(),u=await e.authorization.getEIP712Domain(),f={RegisterTaskNamespaceMeta:[{name:"user",type:"address"},{name:"namespace",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},c={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:oT.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,f,p),b=await e.utils.signMeta(u,c,m),_={user:r,namespace:n,apiKeyHash:a,namespaceSignature:y,apiKeySignature:b,namespaceDeadline:s,apiKeyDeadline:s};try{let E=await s_r(_);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 A=E.message;throw new Error(`Combined registration failed: ${A}`)}}async function w0a(t){let e=await E0();try{return(await e.get(`userexistence/${t}`)).data===!0}catch(r){if(wk.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 Bpe(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=Yf.createSignedBody(r,n,i);return(await(await E0()).get(`user/${t}`,{headers:{"truebit-auth":JSON.stringify(a)}})).data}catch(r){if(wk.isAxiosError(r)&&r.response?.status===401&&r.response?.data.message.includes("Entitlement Validation Error")||wk.isAxiosError(r)&&r.response?.status==404&&r.response?.data.message&&r.response?.data.message.includes("User not found"))return null;throw wk.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 N_r(t){try{return await(await E0()).post("user/register",t)}catch(e){throw wk.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 A0a(){let t=Mu(),e=gi(t,zt.AVAX),r="";try{await I_r(async()=>{r=S0a();let n=oT.keccak256(oT.toUtf8Bytes(r));return await e.authorization.getPayerAddress(n)===M_r},{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw C_r(n)?Error("Attempts to generate unique Api Key for the user exhausted."):n}return r}async function x0a(){let t=Mu(),e=gi(t,zt.AVAX),r="";try{await I_r(async()=>(r=E0a(4).toString("hex"),await e.taskRegistry.getNamespaceOwner(r)===M_r),{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw C_r(n)?Error("Attempts to generate unique namespace for the user exhausted."):n}return r}function D_r(t){t.fullNameAnswer="",t.emailAddressAnswer="",t.companyNameAnswer="",t.jobPositionAnswer="",t.eulaAnswer="",t.confirmRegistration=""}u6();ng();import O0a from"ora";import*as Fpe from"os";async function k_r(t,e,r){let n=S0(),i=n!==null,a=0,s,o=T0a({input:process.stdin,output:process.stdout,terminal:!0});switch(i&&(R_r(n.address)?a=1:(s=await Bpe(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:Fpe.type+"_"+Fpe.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 P_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();!Z_(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(;!Z_(f.confirmRegistration);)console.log(`
|
|
516
|
+
`)}catch(t){throw t instanceof Error?console.error(Bi.red("Error fetching quota status: ")+t.message):console.error(Bi.red("Error fetching quota status: ")+String(t)),t}}zKe();vl();async function E_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}`)}}import A_r from"chalk";import{ethers as v0a}from"ethers";vl();import*as kpe from"crypto";import y0a from"axios";import WKe from"chalk";function S_r(t){if(y0a.isAxiosError(t)&&t.response?.data){let e=t.response.data;return console.log(WKe.red(e.message)),typeof e=="string"?e:e.message||JSON.stringify(e)}return t instanceof Error?t.message:String(t)}async function b0a(t,e){try{let r=xc({namespace:e});return(await t.post("getkey",r)).data}catch(r){return S_r(r),console.error(WKe.red("Failed to retrieve encryption key from Hub-TEE-KMS. Please try again")),null}}function g0a(t,e){try{let r=Buffer.from(e,"base64"),n=kpe.randomBytes(16),i=kpe.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 w_r(t,e,r){try{let n=await b0a(t,r);if(!n)return null;let i=g0a(e,n.plaintext_key);return i?{encrypted_authString:i.encrypted_authString,encrypted_data_key:n.encryption_key,iv:i.iv}:null}catch(n){return S_r(n),console.error(WKe.red("Failed to encrypt credentials. Please try again.")),null}}async function x_r(t,e,r,n,i,a,s){console.log("Deploying the API Authentication Credentials");try{if(!n_r(a))throw"Invalid private key provided";if(!v0a.isAddress(s))throw"Invalid address provided";if(cye(n,i),!sT(t))throw"Invalid taskId";let o=await tIt();console.log("Encrypting credentials...");let u=await w_r(o,i,e);if(!u)return;let f=xc({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",f).catch(Ac),console.log("The encrypted credentials were deployed "+A_r.green("Successfully"))}catch(o){let u=o instanceof Error?o.message:String(o);console.error(A_r.red(u));return}}import{inspect as ula}from"util";import Ku from"ora";import{v4 as fla}from"uuid";import{ethers as Jpe}from"ethers";var T_r={name:"@truebit/cli",version:"1.120.0-beta.273",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.5",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"}};w0();vl();u6();w0();import{createInterface as T0a}from"node:readline/promises";import A2 from"chalk";vl();import wk from"axios";import{ethers as oT}from"ethers";import{randomBytes as E0a}from"crypto";import{v4 as S0a}from"uuid";w0();import{ethers as $pe}from"ethers";async function O_r(t){J_(t);let e=gi(Mu(),zt.AVAX),r=$pe.keccak256($pe.toUtf8Bytes(t));return await e.authorization.registerAuthorization(r),r}async function GKe(t,e,r=Dn("address")){J_(t);let n=gi(Mu(),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=$pe.keccak256($pe.toUtf8Bytes(t)),f={user:r,apiKeyHash:u,nonce:Number(a),deadline:s};if(!n.utils)throw new Error("Private key is required for signing operations");let c=await n.utils.signMeta(i,o,f);return(await a_r(r,u,s,c,e)).status==201?u:null}w0();u6();import{isTooManyTries as C_r,retryAsync as I_r}from"ts-retry";var M_r="0x0000000000000000000000000000000000000000";async function P_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 w0a(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 Z_(t){return t==="Y"||t==="N"}function R_r(t){return!oT.isAddress(t)||t.length!==42||!t.startsWith("0x")}async function q_r(){let t=Mu(),e=gi(t,zt.AVAX),r=Dn("address"),n=await x0a(),i=await A0a();J_(i);let a=oT.keccak256(oT.toUtf8Bytes(i)),s=Math.floor(Date.now()/1e3)+3600,o=await e.taskRegistry.getEIP712Domain(),u=await e.authorization.getEIP712Domain(),f={RegisterTaskNamespaceMeta:[{name:"user",type:"address"},{name:"namespace",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},c={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:oT.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,f,p),b=await e.utils.signMeta(u,c,m),_={user:r,namespace:n,apiKeyHash:a,namespaceSignature:y,apiKeySignature:b,namespaceDeadline:s,apiKeyDeadline:s};try{let E=await s_r(_);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 A=E.message;throw new Error(`Combined registration failed: ${A}`)}}async function w0a(t){let e=await E0();try{return(await e.get(`userexistence/${t}`)).data===!0}catch(r){if(wk.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 Bpe(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=Yf.createSignedBody(r,n,i);return(await(await E0()).get(`user/${t}`,{headers:{"truebit-auth":JSON.stringify(a)}})).data}catch(r){if(wk.isAxiosError(r)&&r.response?.status===401&&r.response?.data.message.includes("Entitlement Validation Error")||wk.isAxiosError(r)&&r.response?.status==404&&r.response?.data.message&&r.response?.data.message.includes("User not found"))return null;throw wk.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 N_r(t){try{return await(await E0()).post("user/register",t)}catch(e){throw wk.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 A0a(){let t=Mu(),e=gi(t,zt.AVAX),r="";try{await I_r(async()=>{r=S0a();let n=oT.keccak256(oT.toUtf8Bytes(r));return await e.authorization.getPayerAddress(n)===M_r},{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw C_r(n)?Error("Attempts to generate unique Api Key for the user exhausted."):n}return r}async function x0a(){let t=Mu(),e=gi(t,zt.AVAX),r="";try{await I_r(async()=>(r=E0a(4).toString("hex"),await e.taskRegistry.getNamespaceOwner(r)===M_r),{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw C_r(n)?Error("Attempts to generate unique namespace for the user exhausted."):n}return r}function D_r(t){t.fullNameAnswer="",t.emailAddressAnswer="",t.companyNameAnswer="",t.jobPositionAnswer="",t.eulaAnswer="",t.confirmRegistration=""}u6();ng();import O0a from"ora";import*as Fpe from"os";async function k_r(t,e,r){let n=S0(),i=n!==null,a=0,s,o=T0a({input:process.stdin,output:process.stdout,terminal:!0});switch(i&&(R_r(n.address)?a=1:(s=await Bpe(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:Fpe.type+"_"+Fpe.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 P_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();!Z_(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(;!Z_(f.confirmRegistration);)console.log(`
|
|
517
517
|
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(`
|
|
518
518
|
Please provide the following information:`),D_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=O0a({text:A2.bold("... registering your account."),stream:process.stdout}).start();try{let{namespace:h,apiKey:p}=await q_r(),m={name:f.fullNameAnswer,email:f.emailAddressAnswer,walletAddress:n?.address,company:f.companyNameAnswer,jobDescription:f.jobPositionAnswer,EULA:Yf.createSignedBody({ip:await ZG(),date:new Date().toISOString()},n.privateKey),defaultNamespace:h,defaultApiKey:p};await N_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,C0a(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 C0a(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 lla}from"node:net";import I0a from"chalk";w0();ng();import{createInterface as M0a}from"node:readline/promises";import*as Lpe from"os";async function $_r(t,e,r){let n=S0(),i=n!==null,a=0;switch(i?i&&!n.eula?a=2:a=3:a=1,a){case 1:case 2:{let s=M0a({input:process.stdin,output:process.stdout,terminal:!0}),o="",u={user_ip:t,date_time:us(),os_version:Lpe.type+"_"+Lpe.release,node_version:process.version,cli_version:e};for(console.log(Pi.EULA_INSTALLATION);!Z_(o);)o=(await s.question(I0a.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=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={...PTe(),eula:f};aIt(c)}else a===2&&oq({eula:f});s.close()}break;default:break}}w0();ng();async function Hc(t=!1){let e=S0(),r=e!==null,n=null,i=0;switch(r?r&&(!e.privateKey||!e.address)?i=2:(n=await Bpe(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();w0();import R0a from"chalk";async function B_r(){console.log(R0a.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.273",
|
|
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": "
|
|
58
|
+
"gitHead": "012bf8b066d61733dca4969059aaaa17208c5885"
|
|
59
59
|
}
|