@truebit/cli 1.120.0-beta.293 → 1.120.0-beta.294
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
|
@@ -501,7 +501,7 @@ ${r.data.payload.instrumentedTaskId}`);else throw"Malformed instrumentation serv
|
|
|
501
501
|
`+Nn.cyan("=".repeat(60))),console.log(Nn.cyan.bold(" Quota Status")),console.log(Nn.cyan("=".repeat(60))+`
|
|
502
502
|
`),console.log(Nn.white("Wallet Address: ")+Nn.yellow(t)),console.log(Nn.white("Subscription Tier: ")+Nn.green(s.userSubscription.toUpperCase())),s.maxSolutions!==void 0&&console.log(Nn.white("Max Solutions: ")+Nn.green(`${s.maxSolutions}`)),s.quotaMax===0)console.log(Nn.white("Monthly Quota: ")+Nn.green("UNLIMITED")),s.currentUsage!==void 0&&console.log(Nn.white("Current Usage: ")+Nn.yellow(`${s.currentUsage} executions`));else{if(console.log(Nn.white("Monthly Quota: ")+Nn.green(`${s.quotaMax} executions`)),s.currentUsage!==void 0&&(console.log(Nn.white("Current Usage: ")+Nn.yellow(`${s.currentUsage} executions`)),s.remaining!==void 0)){let d=s.remaining===0?Nn.red:s.remaining<s.quotaMax*.2?Nn.yellow:Nn.green;console.log(Nn.white("Remaining: ")+d(`${s.remaining} executions`))}console.log(Nn.white("Quota Resets On: ")+Nn.yellow(u))}console.log(`
|
|
503
503
|
`+Nn.cyan("=".repeat(60))+`
|
|
504
|
-
`)}catch(e){throw e instanceof Error?console.error(Nn.red("Error fetching quota status: ")+e.message):console.error(Nn.red("Error fetching quota status: ")+String(e)),e}}yAe();i0();async function RBt(e){try{console.log("Fetching execution status...");let r=await(await fd()).get(`api/execution/${e}`).catch(B0);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(t){console.error(`Couldn't fetch execution status for executionId ${e}: ${t}`)}}import MBt from"chalk";import{ethers as kpa}from"ethers";i0();import*as Lee from"crypto";import Ppa from"axios";import bAe from"chalk";function PBt(e){if(Ppa.isAxiosError(e)&&e.response?.data){let t=e.response.data;return console.log(bAe.red(t.message)),typeof t=="string"?t:t.message||JSON.stringify(t)}return e instanceof Error?e.message:String(e)}async function Cpa(e,t){try{let r=F0({namespace:t});return(await e.post("getkey",r)).data}catch(r){return PBt(r),console.error(bAe.red("Failed to retrieve encryption key from Hub-TEE-KMS. Please try again")),null}}function Mpa(e,t){try{let r=Buffer.from(t,"base64"),n=Lee.randomBytes(16),a=Lee.createCipheriv("aes-256-cbc",r,n),i=Buffer.concat([a.update(e,"utf8"),a.final()]);return r.fill(0),{encrypted_authString:i.toString("base64"),iv:n.toString("base64")}}catch{return null}}async function CBt(e,t,r){try{let n=await Cpa(e,r);if(!n)return null;let a=Mpa(t,n.plaintext_key);return a?{encrypted_authString:a.encrypted_authString,encrypted_data_key:n.encryption_key,iv:a.iv}:null}catch(n){return PBt(n),console.error(bAe.red("Failed to encrypt credentials. Please try again.")),null}}async function kBt(e,t,r,n,a,i,s){console.log("Deploying the API Authentication Credentials");try{if(!cBt(i))throw"Invalid private key provided";if(!kpa.isAddress(s))throw"Invalid address provided";if(mie(n,a),!y4(e))throw"Invalid taskId";let o=await TJe();console.log("Encrypting credentials...");let l=await CBt(o,a,t);if(!l)return;let u=F0({taskId:e,namespace:t,taskName:r,method:n,encrypted_authString:l.encrypted_authString,encrypted_data_key:l.encrypted_data_key,iv:l.iv});await o.post("credentials",u).catch(B0),console.log("The encrypted credentials were deployed "+MBt.green("Successfully"))}catch(o){let l=o instanceof Error?o.message:String(o);console.error(MBt.red(l));return}}import{inspect as w6a}from"util";import Ts from"ora";import{v4 as S6a}from"uuid";import{ethers as Xee}from"ethers";var NBt={name:"@truebit/cli",version:"1.120.0-beta.293",private:!1,description:"truebit-cli is a basic command line that allows interaction between users and truebit nextgen node.",author:{name:"Truebit Co.",url:"https://truebit.io/"},license:"https://truebit.io/terms/",repository:{type:"git",url:"https://github.com/TruebitProtocol"},homepage:"https://truebit.io/",main:"build/index.mjs",module:"build/index.mjs",types:"build/types/index.d.ts",type:"module",scripts:{prebuild:"rimraf build logs","prebuild:dev":"rimraf build logs","build:dev":"tsc && chmod +x build/index.mjs",build:"NODE_ENV=production node esbuild.config.mjs && chmod +x build/index.mjs",dev:"export NODE_ENV=development && npx nodemon",test:"vitest run --passWithNoTests tests/"},dependencies:{axios:"1.13.6",chalk:"5.6.2",colors:"1.4.0",commander:"14.0.3",ethers:"6.16.0",figlet:"1.11.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.1.0",esbuild:"0.27.4",typescript:"5.9.3",vitest:"4.1.0"},engines:{node:">=22.13.0"}};Us();i0();Fc();Us();import{createInterface as Fpa}from"node:readline/promises";import bm from"chalk";i0();import EA from"axios";import{ethers as b4}from"ethers";import{randomBytes as Dpa}from"crypto";import{v4 as $pa}from"uuid";Us();import{ethers as jee}from"ethers";async function DBt(e){Hy(e);let t=_n(ss(),Tt.AVAX),r=jee.keccak256(jee.toUtf8Bytes(e));return await t.authorization.registerAuthorization(r),r}async function vAe(e,t,r=Vr("address")){Hy(e);let n=_n(ss(),Tt.AVAX),a=await n.authorization.getEIP712Domain(),i=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"}]},l=jee.keccak256(jee.toUtf8Bytes(e)),u={user:r,apiKeyHash:l,nonce:Number(i),deadline:s};if(!n.utils)throw new Error("Private key is required for signing operations");let d=await n.utils.signMeta(a,o,u);return(await mBt(r,l,s,d,t)).status==201?l:null}Us();Fc();import{isTooManyTries as $Bt,retryAsync as LBt}from"ts-retry";var jBt="0x0000000000000000000000000000000000000000";async function BBt(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 Lpa(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 zy(e){return e==="Y"||e==="N"}function FBt(e){return!b4.isAddress(e)||e.length!==42||!e.startsWith("0x")}async function UBt(){let e=ss(),t=_n(e,Tt.AVAX),r=Vr("address"),n=await Bpa(),a=await jpa();Hy(a);let i=b4.keccak256(b4.toUtf8Bytes(a)),s=Math.floor(Date.now()/1e3)+3600,o=await t.taskRegistry.getEIP712Domain(),l=await t.authorization.getEIP712Domain(),u={RegisterTaskNamespaceMeta:[{name:"user",type:"address"},{name:"namespace",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},d={RegisterMeta:[{name:"user",type:"address"},{name:"apiKeyHash",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},c=BigInt(await t.taskRegistry.nonces(r)),h=await t.authorization.nonces(r),p={user:b4.getAddress(r),namespace:n,nonce:c,deadline:s},m={user:r,apiKeyHash:i,nonce:Number(h),deadline:s};if(!t.utils)throw new Error("Private key is required for signing operations");let b=await t.utils.signMeta(o,u,p),v=await t.utils.signMeta(l,d,m),_={user:r,namespace:n,apiKeyHash:i,namespaceSignature:b,apiKeySignature:v,namespaceDeadline:s,apiKeyDeadline:s};try{let w=await hBt(_);if(w.status!==201)throw new Error("Registration failed with unexpected status");if(!w.data.namespaceRegistration.success)throw new Error("Namespace registration failed");if(!w.data.apiKeyRegistration.success)throw new Error("API key registration failed");return{namespace:n,apiKey:a,hashedApiKey:i}}catch(w){let S=w.message;throw new Error(`Combined registration failed: ${S}`)}}async function Lpa(e){let t=await Bs();try{return(await t.get(`userexistence/${e}`)).data===!0}catch(r){if(EA.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 Bee(e,t){try{let r={message:"I am a Truebit User"};if(!t)throw Error("Secret.json does not exists");let n=t.privateKey,a=t.address,i=Xo.createSignedBody(r,n,a);return(await(await Bs()).get(`user/${e}`,{headers:{"truebit-auth":JSON.stringify(i)}})).data}catch(r){if(EA.isAxiosError(r)&&r.response?.status===401&&r.response?.data.message.includes("Entitlement Validation Error")||EA.isAxiosError(r)&&r.response?.status==404&&r.response?.data.message&&r.response?.data.message.includes("User not found"))return null;throw EA.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 VBt(e){try{return await(await Bs()).post("user/register",e)}catch(t){throw EA.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 jpa(){let e=ss(),t=_n(e,Tt.AVAX),r="";try{await LBt(async()=>{r=$pa();let n=b4.keccak256(b4.toUtf8Bytes(r));return await t.authorization.getPayerAddress(n)===jBt},{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw $Bt(n)?Error("Attempts to generate unique Api Key for the user exhausted."):n}return r}async function Bpa(){let e=ss(),t=_n(e,Tt.AVAX),r="";try{await LBt(async()=>(r=Dpa(4).toString("hex"),await t.taskRegistry.getNamespaceOwner(r)===jBt),{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw $Bt(n)?Error("Attempts to generate unique namespace for the user exhausted."):n}return r}function HBt(e){e.fullNameAnswer="",e.emailAddressAnswer="",e.companyNameAnswer="",e.jobPositionAnswer="",e.eulaAnswer="",e.confirmRegistration=""}Fc();a6();import Upa from"ora";import*as Fee from"os";async function zBt(e,t,r){let n=Fs(),a=n!==null,i=0,s,o=Fpa({input:process.stdin,output:process.stdout,terminal:!0});switch(a&&(FBt(n.address)?i=1:(s=await Bee(n.address,n),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(On.SETUP_STEP1_SCENARIO1_P2(s));break;case 3:{console.log(On.SETUP_STEP2_SCENARIO3_P1),console.log();let l={user_ip:e,date_time:Ia(),os_version:Fee.type+"_"+Fee.release,node_version:process.version,cli_version:t};await r.sendEventToMixpanel("user_registration_begin",l);let u={confirmRegistration:"",fullNameAnswer:"",emailAddressAnswer:"",companyNameAnswer:"",jobPositionAnswer:"",eulaAnswer:""};try{for(;u.confirmRegistration!="Y";){for(u.fullNameAnswer=(await o.question(bm.bold(" 1. Full Name: "))).trim();u.fullNameAnswer==="";)console.log("Your full name is required. Please provide your first and last name to proceed."),u.fullNameAnswer=(await o.question(bm.bold(" 1. Full Name: "))).trim();for(u.emailAddressAnswer=(await o.question(bm.bold(" 2. Email Address: "))).trim();!await BBt(u.emailAddressAnswer);)u.emailAddressAnswer=(await o.question(bm.bold(" 2. Email Address: "))).trim();for(u.companyNameAnswer=(await o.question(bm.bold(" 3. Company Name: "))).trim(),u.jobPositionAnswer=(await o.question(bm.bold(" 4. Job Position: "))).trim();!zy(u.eulaAnswer);)u.eulaAnswer=(await o.question(bm.bold(` 5. Accept EULA? [Y|N] (${On.EULA_TERMS_LINK}): `))).toUpperCase();if(u.eulaAnswer=="N"){console.log(On.EULA_REGISTRATION_NO_ACCEPTED);break}for(;!zy(u.confirmRegistration);)console.log(`
|
|
504
|
+
`)}catch(e){throw e instanceof Error?console.error(Nn.red("Error fetching quota status: ")+e.message):console.error(Nn.red("Error fetching quota status: ")+String(e)),e}}yAe();i0();async function RBt(e){try{console.log("Fetching execution status...");let r=await(await fd()).get(`api/execution/${e}`).catch(B0);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(t){console.error(`Couldn't fetch execution status for executionId ${e}: ${t}`)}}import MBt from"chalk";import{ethers as kpa}from"ethers";i0();import*as Lee from"crypto";import Ppa from"axios";import bAe from"chalk";function PBt(e){if(Ppa.isAxiosError(e)&&e.response?.data){let t=e.response.data;return console.log(bAe.red(t.message)),typeof t=="string"?t:t.message||JSON.stringify(t)}return e instanceof Error?e.message:String(e)}async function Cpa(e,t){try{let r=F0({namespace:t});return(await e.post("getkey",r)).data}catch(r){return PBt(r),console.error(bAe.red("Failed to retrieve encryption key from Hub-TEE-KMS. Please try again")),null}}function Mpa(e,t){try{let r=Buffer.from(t,"base64"),n=Lee.randomBytes(16),a=Lee.createCipheriv("aes-256-cbc",r,n),i=Buffer.concat([a.update(e,"utf8"),a.final()]);return r.fill(0),{encrypted_authString:i.toString("base64"),iv:n.toString("base64")}}catch{return null}}async function CBt(e,t,r){try{let n=await Cpa(e,r);if(!n)return null;let a=Mpa(t,n.plaintext_key);return a?{encrypted_authString:a.encrypted_authString,encrypted_data_key:n.encryption_key,iv:a.iv}:null}catch(n){return PBt(n),console.error(bAe.red("Failed to encrypt credentials. Please try again.")),null}}async function kBt(e,t,r,n,a,i,s){console.log("Deploying the API Authentication Credentials");try{if(!cBt(i))throw"Invalid private key provided";if(!kpa.isAddress(s))throw"Invalid address provided";if(mie(n,a),!y4(e))throw"Invalid taskId";let o=await TJe();console.log("Encrypting credentials...");let l=await CBt(o,a,t);if(!l)return;let u=F0({taskId:e,namespace:t,taskName:r,method:n,encrypted_authString:l.encrypted_authString,encrypted_data_key:l.encrypted_data_key,iv:l.iv});await o.post("credentials",u).catch(B0),console.log("The encrypted credentials were deployed "+MBt.green("Successfully"))}catch(o){let l=o instanceof Error?o.message:String(o);console.error(MBt.red(l));return}}import{inspect as w6a}from"util";import Ts from"ora";import{v4 as S6a}from"uuid";import{ethers as Xee}from"ethers";var NBt={name:"@truebit/cli",version:"1.120.0-beta.294",private:!1,description:"truebit-cli is a basic command line that allows interaction between users and truebit nextgen node.",author:{name:"Truebit Co.",url:"https://truebit.io/"},license:"https://truebit.io/terms/",repository:{type:"git",url:"https://github.com/TruebitProtocol"},homepage:"https://truebit.io/",main:"build/index.mjs",module:"build/index.mjs",types:"build/types/index.d.ts",type:"module",scripts:{prebuild:"rimraf build logs","prebuild:dev":"rimraf build logs","build:dev":"tsc && chmod +x build/index.mjs",build:"NODE_ENV=production node esbuild.config.mjs && chmod +x build/index.mjs",dev:"export NODE_ENV=development && npx nodemon",test:"vitest run --passWithNoTests tests/"},dependencies:{axios:"1.13.6",chalk:"5.6.2",colors:"1.4.0",commander:"14.0.3",ethers:"6.16.0",figlet:"1.11.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.1.0",esbuild:"0.27.4",typescript:"5.9.3",vitest:"4.1.0"},engines:{node:">=22.13.0"}};Us();i0();Fc();Us();import{createInterface as Fpa}from"node:readline/promises";import bm from"chalk";i0();import EA from"axios";import{ethers as b4}from"ethers";import{randomBytes as Dpa}from"crypto";import{v4 as $pa}from"uuid";Us();import{ethers as jee}from"ethers";async function DBt(e){Hy(e);let t=_n(ss(),Tt.AVAX),r=jee.keccak256(jee.toUtf8Bytes(e));return await t.authorization.registerAuthorization(r),r}async function vAe(e,t,r=Vr("address")){Hy(e);let n=_n(ss(),Tt.AVAX),a=await n.authorization.getEIP712Domain(),i=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"}]},l=jee.keccak256(jee.toUtf8Bytes(e)),u={user:r,apiKeyHash:l,nonce:Number(i),deadline:s};if(!n.utils)throw new Error("Private key is required for signing operations");let d=await n.utils.signMeta(a,o,u);return(await mBt(r,l,s,d,t)).status==201?l:null}Us();Fc();import{isTooManyTries as $Bt,retryAsync as LBt}from"ts-retry";var jBt="0x0000000000000000000000000000000000000000";async function BBt(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 Lpa(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 zy(e){return e==="Y"||e==="N"}function FBt(e){return!b4.isAddress(e)||e.length!==42||!e.startsWith("0x")}async function UBt(){let e=ss(),t=_n(e,Tt.AVAX),r=Vr("address"),n=await Bpa(),a=await jpa();Hy(a);let i=b4.keccak256(b4.toUtf8Bytes(a)),s=Math.floor(Date.now()/1e3)+3600,o=await t.taskRegistry.getEIP712Domain(),l=await t.authorization.getEIP712Domain(),u={RegisterTaskNamespaceMeta:[{name:"user",type:"address"},{name:"namespace",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},d={RegisterMeta:[{name:"user",type:"address"},{name:"apiKeyHash",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},c=BigInt(await t.taskRegistry.nonces(r)),h=await t.authorization.nonces(r),p={user:b4.getAddress(r),namespace:n,nonce:c,deadline:s},m={user:r,apiKeyHash:i,nonce:Number(h),deadline:s};if(!t.utils)throw new Error("Private key is required for signing operations");let b=await t.utils.signMeta(o,u,p),v=await t.utils.signMeta(l,d,m),_={user:r,namespace:n,apiKeyHash:i,namespaceSignature:b,apiKeySignature:v,namespaceDeadline:s,apiKeyDeadline:s};try{let w=await hBt(_);if(w.status!==201)throw new Error("Registration failed with unexpected status");if(!w.data.namespaceRegistration.success)throw new Error("Namespace registration failed");if(!w.data.apiKeyRegistration.success)throw new Error("API key registration failed");return{namespace:n,apiKey:a,hashedApiKey:i}}catch(w){let S=w.message;throw new Error(`Combined registration failed: ${S}`)}}async function Lpa(e){let t=await Bs();try{return(await t.get(`userexistence/${e}`)).data===!0}catch(r){if(EA.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 Bee(e,t){try{let r={message:"I am a Truebit User"};if(!t)throw Error("Secret.json does not exists");let n=t.privateKey,a=t.address,i=Xo.createSignedBody(r,n,a);return(await(await Bs()).get(`user/${e}`,{headers:{"truebit-auth":JSON.stringify(i)}})).data}catch(r){if(EA.isAxiosError(r)&&r.response?.status===401&&r.response?.data.message.includes("Entitlement Validation Error")||EA.isAxiosError(r)&&r.response?.status==404&&r.response?.data.message&&r.response?.data.message.includes("User not found"))return null;throw EA.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 VBt(e){try{return await(await Bs()).post("user/register",e)}catch(t){throw EA.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 jpa(){let e=ss(),t=_n(e,Tt.AVAX),r="";try{await LBt(async()=>{r=$pa();let n=b4.keccak256(b4.toUtf8Bytes(r));return await t.authorization.getPayerAddress(n)===jBt},{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw $Bt(n)?Error("Attempts to generate unique Api Key for the user exhausted."):n}return r}async function Bpa(){let e=ss(),t=_n(e,Tt.AVAX),r="";try{await LBt(async()=>(r=Dpa(4).toString("hex"),await t.taskRegistry.getNamespaceOwner(r)===jBt),{delay:500,maxTry:5,until:n=>n===!0})}catch(n){throw $Bt(n)?Error("Attempts to generate unique namespace for the user exhausted."):n}return r}function HBt(e){e.fullNameAnswer="",e.emailAddressAnswer="",e.companyNameAnswer="",e.jobPositionAnswer="",e.eulaAnswer="",e.confirmRegistration=""}Fc();a6();import Upa from"ora";import*as Fee from"os";async function zBt(e,t,r){let n=Fs(),a=n!==null,i=0,s,o=Fpa({input:process.stdin,output:process.stdout,terminal:!0});switch(a&&(FBt(n.address)?i=1:(s=await Bee(n.address,n),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(On.SETUP_STEP1_SCENARIO1_P2(s));break;case 3:{console.log(On.SETUP_STEP2_SCENARIO3_P1),console.log();let l={user_ip:e,date_time:Ia(),os_version:Fee.type+"_"+Fee.release,node_version:process.version,cli_version:t};await r.sendEventToMixpanel("user_registration_begin",l);let u={confirmRegistration:"",fullNameAnswer:"",emailAddressAnswer:"",companyNameAnswer:"",jobPositionAnswer:"",eulaAnswer:""};try{for(;u.confirmRegistration!="Y";){for(u.fullNameAnswer=(await o.question(bm.bold(" 1. Full Name: "))).trim();u.fullNameAnswer==="";)console.log("Your full name is required. Please provide your first and last name to proceed."),u.fullNameAnswer=(await o.question(bm.bold(" 1. Full Name: "))).trim();for(u.emailAddressAnswer=(await o.question(bm.bold(" 2. Email Address: "))).trim();!await BBt(u.emailAddressAnswer);)u.emailAddressAnswer=(await o.question(bm.bold(" 2. Email Address: "))).trim();for(u.companyNameAnswer=(await o.question(bm.bold(" 3. Company Name: "))).trim(),u.jobPositionAnswer=(await o.question(bm.bold(" 4. Job Position: "))).trim();!zy(u.eulaAnswer);)u.eulaAnswer=(await o.question(bm.bold(` 5. Accept EULA? [Y|N] (${On.EULA_TERMS_LINK}): `))).toUpperCase();if(u.eulaAnswer=="N"){console.log(On.EULA_REGISTRATION_NO_ACCEPTED);break}for(;!zy(u.confirmRegistration);)console.log(`
|
|
505
505
|
Is the information provided above correct?`),u.confirmRegistration=(await o.question(bm.bold("Press [Y] to confirm or [N] to edit: "))).toUpperCase();u.confirmRegistration=="N"&&(console.log(`
|
|
506
506
|
Please provide the following information:`),HBt(u))}}catch(h){if(h.name==="AbortError"||h.message.includes("Ctrl+C")){let p=h.message,m=l;m.error_details=p,m.date_time=Ia();let b={fullname:u.fullNameAnswer,email:u.emailAddressAnswer,company:u.companyNameAnswer,role:u.jobPositionAnswer};m.user_info=JSON.stringify(b),await r.sendEventToMixpanel("user_registration_failed",m),process.exit(0)}}if(u.eulaAnswer=="N")break;let d=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 c=Upa({text:bm.bold("... registering your account."),stream:process.stdout}).start();try{let{namespace:h,apiKey:p}=await UBt(),m={name:u.fullNameAnswer,email:u.emailAddressAnswer,walletAddress:n?.address,company:u.companyNameAnswer,jobDescription:u.jobPositionAnswer,EULA:Xo.createSignedBody({ip:await GP(),date:new Date().toISOString()},n.privateKey),defaultNamespace:h,defaultApiKey:p};await VBt(m),c.stop(),console.log(On.SETUP_STEP2_SCENARIO3_P2(u,n.address,h,p)),d.distinct_id=m.walletAddress,d.date_time=Ia(),d.fullname=m.name,d.email=m.email,d.company=m.company,d.role=m.jobDescription,d.namespace=m.defaultNamespace,d.api_key=p,d.wallet_address=m.walletAddress,await r.sendEventToMixpanel("user_registration_success",d),await r.registerUserMixpanel(d.wallet_address,Vpa(d))}catch(h){c.stop();let p=h.message,m=l;m.error_details=p,m.date_time=Ia();let b={fullname:u.fullNameAnswer,email:u.emailAddressAnswer,company:u.companyNameAnswer,role:u.jobPositionAnswer};m.user_info=JSON.stringify(b),await r.sendEventToMixpanel("user_registration_failed",m);let v=p?p.match(/CreateUserValidation - (.*?.*)/)?.[1]:null;if(v)throw Error(v);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(On.SETUP_STEP2_UNHANDLED_ERROR),process.exit(1)}finally{c.clear()}break}default:throw Error("An unexpected error occurred.")}o.close()}function Vpa(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 T6a}from"node:net";import Hpa from"chalk";Us();a6();import{createInterface as zpa}from"node:readline/promises";import*as Uee from"os";async function WBt(e,t,r){let n=Fs(),a=n!==null,i;switch(a?a&&!n.eula?i=2:i=3:i=1,i){case 1:case 2:{let s=zpa({input:process.stdin,output:process.stdout,terminal:!0}),o="",l={user_ip:e,date_time:Ia(),os_version:Uee.type+"_"+Uee.release,node_version:process.version,cli_version:t};for(console.log(On.EULA_INSTALLATION);!zy(o);)o=(await s.question(Hpa.bold(`
|
|
507
507
|
Have you read, and do you accept the Terms of Use? [Y|N]: `))).toUpperCase(),await r.sendEventToMixpanel("TOS_shown",l);if(o=="N")throw l.date_time=Ia(),await r.sendEventToMixpanel("TOS_rejected",l),On.EULA_INSTALLATION_NO_ACCEPTED;l.date_time=Ia(),await r.sendEventToMixpanel("TOS_accepted",l);let u=Math.round(new Date().getTime()).toString();if(i===1){let d={...Bue(),eula:u};OJe(d)}else i===2&&zE({eula:u});s.close()}break;default:break}}Us();a6();async function sf(e=!1){let t=Fs(),r=t!==null,n=null,a;switch(r?r&&(!t.privateKey||!t.address)?a=2:(n=await Bee(t.address,t),n?a=4:a=3):a=1,a){case 1:case 2:case 3:console.log(On.USER_NO_REGISTERED),process.exit(1);break;case 4:e&&console.log(`You are logged in as: ${n?.name} - ${n?.email}`);break}}import{createInterface as Wpa}from"node:readline/promises";a6();Us();import Gpa from"chalk";async function GBt(){console.log(Gpa.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.294",
|
|
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": "d698430ef670cd04f39c0e3d9e5d1157f6bae03b"
|
|
59
59
|
}
|