wative 1.0.44 → 1.1.0

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/bin/wative-ssh.sh CHANGED
@@ -11,7 +11,6 @@ awk -F "=" '/^\[keystore\]/ {flag=1} flag && /^allowed_keystores/ {print $2}' "$
11
11
  # Clear previous environment variables file
12
12
  > "$ENV_FILE"
13
13
 
14
-
15
14
  # Iterate through the keystores and prompt for passwords
16
15
  while IFS= read -r ALLOWED_KEYSTORE; do
17
16
  # Skip empty lines
@@ -20,7 +19,7 @@ while IFS= read -r ALLOWED_KEYSTORE; do
20
19
  ALLOWED_KEYSTORE=$(echo "$ALLOWED_KEYSTORE" | sed 's/-/_/g')
21
20
  # Prompt the user to input a password for the current keystore
22
21
  PASSWORD_INPUT=$(systemd-ask-password "Input the password for keystore [$ALLOWED_KEYSTORE]: ")
23
-
22
+
24
23
  # Save the environment variable to a temporary file
25
24
  echo "export \"$ALLOWED_KEYSTORE\"=\"$PASSWORD_INPUT\"" >> "$ENV_FILE"
26
25
 
@@ -38,4 +37,4 @@ rm -f "$ENV_FILE"
38
37
  # Execute wative-ssh with the loaded environment variables
39
38
  TARGET_FILE=$(realpath "$(dirname "$(realpath "$0")")/../lib/wative-ssh.umd.js")
40
39
 
41
- "$(which node)" "$TARGET_FILE"
40
+ /usr/local/bin/node "$TARGET_FILE"
package/lib/wative.esm.js CHANGED
@@ -1 +1 @@
1
- import*as e from"path";import{Command as t}from"commander";import{execSync as r}from"child_process";import*as i from"fs";import*as o from"ini";import"figlet";import"inquirer";import"web3";import"@solana/web3.js";import"@solana/spl-token";import"@metaplex-foundation/js";import"bignumber.js";function n(e,t,r,i){return new(r||(r=Promise))((function(o,n){function s(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function s(e,t){var r,i,o,n,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;n&&(n=0,a[0]&&(s=0)),s;)try{if(r=1,i&&(o=2&a[0]?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],i=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError,require("chalk"),require("chalk"),require("chalk"),process.env.HOME||process.env.USERPROFILE;require("bn.js").BN,require("ethereumjs-util").stripHexPrefix,require("bignumber.js").BigNumber,require("chalk"),require("wative-core").WativeCore,require("chalk"),require("dotenv").config(),require("cli-progress"),require("wative-core").WativeCore;var a=function(t){return n(void 0,void 0,void 0,(function(){var a,c,l,u,d,v,p;return s(this,(function(h){switch(h.label){case 0:return a="/etc/wative",i.existsSync(a)||i.mkdirSync(a),[4,n(void 0,void 0,void 0,(function(){var t,o,n,a,c;return s(this,(function(s){return t="/etc/wative",o=e.join(t,"id_rsa_server.pub"),n=e.join(t,"id_rsa_server"),i.existsSync(o)&&i.existsSync(n)||(console.log("Generating SSH key pair..."),r("ssh-keygen -t rsa -f ".concat(n," -N 'wative_server'"),{stdio:"inherit"})),a=e.join(t,"id_rsa_detake.pub"),c=e.join(t,"id_rsa_detake"),i.existsSync(a)&&i.existsSync(c)||(console.log("Generating SSH key pair..."),r("ssh-keygen -t rsa -f ".concat(c," -N 'wative_detake'"),{stdio:"inherit"})),[2]}))}))];case 1:return h.sent(),c=e.join(a,"config.ini"),i.existsSync(c)||(f=t,m=e.resolve(f,"network.json"),l=JSON.parse(i.readFileSync(m,"utf8")),u=l.accounts,d=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].trim().toLocaleLowerCase().replace(/\s+/g,"-").trim().replace(/\-+/g,"-").trim());return t}(u),v={keystore:{path:t,allowed_keystores:d},ssh:{listen:"127.0.0.1",port:5678}},p=o.stringify(v),i.writeFileSync(c,p)),[2,o.parse(i.readFileSync(c,"utf-8"))]}var f,m}))}))},c=require("os"),l=new t,u=require("../package.json"),d=function(){try{return r("systemctl --version",{stdio:"ignore"}),!0}catch(e){return!1}};l.version(u.version).description("Wative CLI Tool"),l.command("version").description("Show the version of wative").action((function(){console.log("Wative CLI Tool v".concat(u.version))}));l.command("ssh").option("start","Start SSH service").option("stop","Stop SSH service").option("service add","Add SSH service").option("service remove","Remove SSH service").action((function(t,i){return n(void 0,void 0,void 0,(function(){return s(this,(function(o){switch(o.label){case 0:return"start"!==t?[3,2]:[4,n(void 0,void 0,void 0,(function(){var t,i;return s(this,(function(o){switch(o.label){case 0:return t=c.homedir(),i=e.join(t,".wative"),[4,a(i)];case 1:o.sent(),console.log("Starting SSH service...");try{r("wative-ssh",{stdio:"inherit"})}catch(e){}return console.log("SSH service started."),[2]}}))}))];case 1:return o.sent(),[2];case 2:return"stop"===t?(function(){try{r("ps aux | grep wative-ssh | grep -v grep | awk '{print $2}' | sudo xargs kill",{stdio:"inherit"})}catch(e){}console.log("SSH service stopped.")}(),[2]):"service"===t&&"add"===i?(n(void 0,void 0,void 0,(function(){var t,i;return s(this,(function(o){switch(o.label){case 0:return d()?(t=c.homedir(),i=e.join(t,".wative"),[4,a(i)]):(console.log("Systemd is not available."),[2]);case 1:o.sent(),console.log("Adding SSH service...");try{r("sudo echo '".concat("\n [Unit]\n Description=Wative SSH Server\n After=network.target\n\n [Service]\n ExecStart=/usr/local/bin/wative-ssh\n User=root\n Group=root\n StandardOutput=append:/var/log/wative-ssh.log\n StandardError=append:/var/log/wative-ssh.err\n\n [Install]\n WantedBy=multi-user.target\n ","' > ").concat("/etc/systemd/system/wative.service"),{stdio:"inherit"}),r("sudo systemctl daemon-reload",{stdio:"inherit"}),r("sudo systemctl enable wative",{stdio:"inherit"}),r("sudo systemctl start wative",{stdio:"inherit"})}catch(e){console.log(e)}return console.log("SSH service added."),[2]}}))})),[2]):"service"===t&&"remove"===i?(function(){if(d()){console.log("Removing SSH service...");try{r("sudo systemctl stop wative",{stdio:"inherit"})}catch(e){}try{r("sudo systemctl disable wative",{stdio:"inherit"})}catch(e){}try{r("sudo rm -rf /etc/systemd/system/wative.service",{stdio:"inherit"})}catch(e){}try{r("sudo systemctl daemon-reload",{stdio:"inherit"})}catch(e){}console.log("SSH service removed.")}else console.log("Systemd is not available.")}(),[2]):[2]}}))}))})),l.command("cmd").description("Start wallet-cli shell").action((function(){return n(void 0,void 0,void 0,(function(){return s(this,(function(e){try{r("wallet-cli",{stdio:"inherit"})}catch(e){}return[2]}))}))})),l.parse(process.argv);
1
+ import*as e from"path";import{Command as t}from"commander";import{execSync as r}from"child_process";import*as i from"fs";import*as o from"ini";import"figlet";import"inquirer";import"web3";import"@solana/web3.js";import"@solana/spl-token";import"@metaplex-foundation/js";import"bignumber.js";function n(e,t,r,i){return new(r||(r=Promise))((function(o,n){function s(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function s(e,t){var r,i,o,n,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;n&&(n=0,a[0]&&(s=0)),s;)try{if(r=1,i&&(o=2&a[0]?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],i=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError,require("chalk"),require("chalk"),require("chalk"),process.env.HOME||process.env.USERPROFILE;require("bn.js").BN,require("ethereumjs-util").stripHexPrefix,require("bignumber.js").BigNumber,require("chalk"),require("wative-core").WativeCore,require("chalk"),require("dotenv").config(),require("cli-progress"),require("wative-core").WativeCore;var a=function(t){return n(void 0,void 0,void 0,(function(){var a,c,l,u,d,v,p;return s(this,(function(h){switch(h.label){case 0:return a="/etc/wative",i.existsSync(a)||i.mkdirSync(a),[4,n(void 0,void 0,void 0,(function(){var t,o,n,a,c;return s(this,(function(s){return t="/etc/wative",o=e.join(t,"id_rsa_server.pub"),n=e.join(t,"id_rsa_server"),i.existsSync(o)&&i.existsSync(n)||(console.log("Generating SSH key pair..."),r("ssh-keygen -t rsa -f ".concat(n," -N 'wative_server'"),{stdio:"inherit"})),a=e.join(t,"id_rsa_detake.pub"),c=e.join(t,"id_rsa_detake"),i.existsSync(a)&&i.existsSync(c)||(console.log("Generating SSH key pair..."),r("ssh-keygen -t rsa -f ".concat(c," -N 'wative_detake'"),{stdio:"inherit"})),[2]}))}))];case 1:return h.sent(),c=e.join(a,"config.ini"),i.existsSync(c)||(f=t,m=e.resolve(f,"network.json"),l=JSON.parse(i.readFileSync(m,"utf8")),u=l.accounts,d=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].trim().toLocaleLowerCase().replace(/\s+/g,"-").trim().replace(/\-+/g,"-").trim());return t}(u),v={keystore:{path:t,allowed_keystores:d},ssh:{listen:"127.0.0.1",port:5678}},p=o.stringify(v),i.writeFileSync(c,p)),[2,o.parse(i.readFileSync(c,"utf-8"))]}var f,m}))}))},c=require("os"),l=new t,u=require("../package.json"),d=function(){try{return r("systemctl --version",{stdio:"ignore"}),!0}catch(e){return!1}};l.version(u.version).description("Wative CLI Tool"),l.command("version").description("Show the version of wative").action((function(){console.log("Wative CLI Tool v".concat(u.version))}));l.command("ssh").option("start","Start SSH service").option("stop","Stop SSH service").option("service add","Add SSH service").option("service remove","Remove SSH service").action((function(t,i){return n(void 0,void 0,void 0,(function(){return s(this,(function(o){switch(o.label){case 0:return"start"!==t?[3,2]:[4,n(void 0,void 0,void 0,(function(){var t,i;return s(this,(function(o){switch(o.label){case 0:return t=c.homedir(),i=e.join(t,".wative"),[4,a(i)];case 1:o.sent(),console.log("Starting SSH service...");try{r("wative-ssh",{stdio:"inherit"})}catch(e){}return console.log("SSH service started."),[2]}}))}))];case 1:return o.sent(),[2];case 2:return"stop"===t?(function(){try{r("ps aux | grep wative-ssh | grep -v grep | awk '{print $2}' | sudo xargs kill",{stdio:"inherit"})}catch(e){}console.log("SSH service stopped.")}(),[2]):"service"===t&&"add"===i?(n(void 0,void 0,void 0,(function(){var t,i;return s(this,(function(o){switch(o.label){case 0:return d()?(t=c.homedir(),i=e.join(t,".wative"),[4,a(i)]):(console.log("Systemd is not available."),[2]);case 1:o.sent(),console.log("Adding SSH service...");try{r("sudo echo '".concat("\n[Unit]\nDescription=Wative SSH Server\nAfter=network.target\n\n[Service]\nExecStart=/usr/local/bin/wative-ssh\nUser=root\nGroup=root\nStandardOutput=append:/var/log/wative-ssh.log\nStandardError=append:/var/log/wative-ssh.err\n\n[Install]\nWantedBy=multi-user.target\n ","' > ").concat("/etc/systemd/system/wative.service"),{stdio:"inherit"}),r("sudo systemctl daemon-reload",{stdio:"inherit"}),r("sudo systemctl enable wative",{stdio:"inherit"}),r("sudo systemctl start wative",{stdio:"inherit"})}catch(e){console.log(e)}return console.log("SSH service added."),[2]}}))})),[2]):"service"===t&&"remove"===i?(function(){if(d()){console.log("Removing SSH service...");try{r("sudo systemctl stop wative",{stdio:"inherit"})}catch(e){}try{r("sudo systemctl disable wative",{stdio:"inherit"})}catch(e){}try{r("sudo rm -rf /etc/systemd/system/wative.service",{stdio:"inherit"})}catch(e){}try{r("sudo systemctl daemon-reload",{stdio:"inherit"})}catch(e){}console.log("SSH service removed.")}else console.log("Systemd is not available.")}(),[2]):[2]}}))}))})),l.command("cmd").description("Start wallet-cli shell").action((function(){return n(void 0,void 0,void 0,(function(){return s(this,(function(e){try{r("wallet-cli",{stdio:"inherit"})}catch(e){}return[2]}))}))})),l.parse(process.argv);
package/lib/wative.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("path"),require("commander"),require("child_process"),require("fs"),require("ini"),require("figlet"),require("inquirer"),require("web3"),require("@solana/web3.js"),require("@solana/spl-token"),require("@metaplex-foundation/js"),require("bignumber.js")):"function"==typeof define&&define.amd?define(["path","commander","child_process","fs","ini","figlet","inquirer","web3","@solana/web3.js","@solana/spl-token","@metaplex-foundation/js","bignumber.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).path,e.commander,e.child_process,e.fs,e.ini)}(this,(function(e,t,r,n,i){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=o(e),c=o(n),a=o(i);function u(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))}function l(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,n=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){s.label=c[1];break}if(6===c[0]&&s.label<i[1]){s.label=i[1],i=c;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(c);break}i[2]&&s.ops.pop(),s.trys.pop();continue}c=t.call(e,s)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}"function"==typeof SuppressedError&&SuppressedError,require("chalk"),require("chalk"),require("chalk"),process.env.HOME||process.env.USERPROFILE;require("bn.js").BN,require("ethereumjs-util").stripHexPrefix,require("bignumber.js").BigNumber,require("chalk"),require("wative-core").WativeCore,require("chalk"),require("dotenv").config(),require("cli-progress"),require("wative-core").WativeCore;var d=function(e){return u(void 0,void 0,void 0,(function(){var t,n,i,o,d,v,f;return l(this,(function(p){switch(p.label){case 0:return t="/etc/wative",c.existsSync(t)||c.mkdirSync(t),[4,u(void 0,void 0,void 0,(function(){var e,t,n,i,o;return l(this,(function(a){return e="/etc/wative",t=s.join(e,"id_rsa_server.pub"),n=s.join(e,"id_rsa_server"),c.existsSync(t)&&c.existsSync(n)||(console.log("Generating SSH key pair..."),r.execSync("ssh-keygen -t rsa -f ".concat(n," -N 'wative_server'"),{stdio:"inherit"})),i=s.join(e,"id_rsa_detake.pub"),o=s.join(e,"id_rsa_detake"),c.existsSync(i)&&c.existsSync(o)||(console.log("Generating SSH key pair..."),r.execSync("ssh-keygen -t rsa -f ".concat(o," -N 'wative_detake'"),{stdio:"inherit"})),[2]}))}))];case 1:return p.sent(),n=s.join(t,"config.ini"),c.existsSync(n)||(h=e,y=s.resolve(h,"network.json"),i=JSON.parse(c.readFileSync(y,"utf8")),o=i.accounts,d=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].trim().toLocaleLowerCase().replace(/\s+/g,"-").trim().replace(/\-+/g,"-").trim());return t}(o),v={keystore:{path:e,allowed_keystores:d},ssh:{listen:"127.0.0.1",port:5678}},f=a.stringify(v),c.writeFileSync(n,f)),[2,a.parse(c.readFileSync(n,"utf-8"))]}var h,y}))}))},v=require("os"),f=new t.Command,p=require("../package.json"),h=function(){try{return r.execSync("systemctl --version",{stdio:"ignore"}),!0}catch(e){return!1}};f.version(p.version).description("Wative CLI Tool"),f.command("version").description("Show the version of wative").action((function(){console.log("Wative CLI Tool v".concat(p.version))}));f.command("ssh").option("start","Start SSH service").option("stop","Stop SSH service").option("service add","Add SSH service").option("service remove","Remove SSH service").action((function(e,t){return u(void 0,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return"start"!==e?[3,2]:[4,u(void 0,void 0,void 0,(function(){var e,t;return l(this,(function(n){switch(n.label){case 0:return e=v.homedir(),t=s.join(e,".wative"),[4,d(t)];case 1:n.sent(),console.log("Starting SSH service...");try{r.execSync("wative-ssh",{stdio:"inherit"})}catch(e){}return console.log("SSH service started."),[2]}}))}))];case 1:return n.sent(),[2];case 2:return"stop"===e?(function(){try{r.execSync("ps aux | grep wative-ssh | grep -v grep | awk '{print $2}' | sudo xargs kill",{stdio:"inherit"})}catch(e){}console.log("SSH service stopped.")}(),[2]):"service"===e&&"add"===t?(u(void 0,void 0,void 0,(function(){var e,t;return l(this,(function(n){switch(n.label){case 0:return h()?(e=v.homedir(),t=s.join(e,".wative"),[4,d(t)]):(console.log("Systemd is not available."),[2]);case 1:n.sent(),console.log("Adding SSH service...");try{r.execSync("sudo echo '".concat("\n [Unit]\n Description=Wative SSH Server\n After=network.target\n\n [Service]\n ExecStart=/usr/local/bin/wative-ssh\n User=root\n Group=root\n StandardOutput=append:/var/log/wative-ssh.log\n StandardError=append:/var/log/wative-ssh.err\n\n [Install]\n WantedBy=multi-user.target\n ","' > ").concat("/etc/systemd/system/wative.service"),{stdio:"inherit"}),r.execSync("sudo systemctl daemon-reload",{stdio:"inherit"}),r.execSync("sudo systemctl enable wative",{stdio:"inherit"}),r.execSync("sudo systemctl start wative",{stdio:"inherit"})}catch(e){console.log(e)}return console.log("SSH service added."),[2]}}))})),[2]):"service"===e&&"remove"===t?(function(){if(h()){console.log("Removing SSH service...");try{r.execSync("sudo systemctl stop wative",{stdio:"inherit"})}catch(e){}try{r.execSync("sudo systemctl disable wative",{stdio:"inherit"})}catch(e){}try{r.execSync("sudo rm -rf /etc/systemd/system/wative.service",{stdio:"inherit"})}catch(e){}try{r.execSync("sudo systemctl daemon-reload",{stdio:"inherit"})}catch(e){}console.log("SSH service removed.")}else console.log("Systemd is not available.")}(),[2]):[2]}}))}))})),f.command("cmd").description("Start wallet-cli shell").action((function(){return u(void 0,void 0,void 0,(function(){return l(this,(function(e){try{r.execSync("wallet-cli",{stdio:"inherit"})}catch(e){}return[2]}))}))})),f.parse(process.argv)}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("path"),require("commander"),require("child_process"),require("fs"),require("ini"),require("figlet"),require("inquirer"),require("web3"),require("@solana/web3.js"),require("@solana/spl-token"),require("@metaplex-foundation/js"),require("bignumber.js")):"function"==typeof define&&define.amd?define(["path","commander","child_process","fs","ini","figlet","inquirer","web3","@solana/web3.js","@solana/spl-token","@metaplex-foundation/js","bignumber.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).path,e.commander,e.child_process,e.fs,e.ini)}(this,(function(e,t,r,n,i){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=o(e),c=o(n),a=o(i);function u(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))}function l(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&c[0]?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,n=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){s.label=c[1];break}if(6===c[0]&&s.label<i[1]){s.label=i[1],i=c;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(c);break}i[2]&&s.ops.pop(),s.trys.pop();continue}c=t.call(e,s)}catch(e){c=[6,e],n=0}finally{r=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}"function"==typeof SuppressedError&&SuppressedError,require("chalk"),require("chalk"),require("chalk"),process.env.HOME||process.env.USERPROFILE;require("bn.js").BN,require("ethereumjs-util").stripHexPrefix,require("bignumber.js").BigNumber,require("chalk"),require("wative-core").WativeCore,require("chalk"),require("dotenv").config(),require("cli-progress"),require("wative-core").WativeCore;var d=function(e){return u(void 0,void 0,void 0,(function(){var t,n,i,o,d,v,f;return l(this,(function(p){switch(p.label){case 0:return t="/etc/wative",c.existsSync(t)||c.mkdirSync(t),[4,u(void 0,void 0,void 0,(function(){var e,t,n,i,o;return l(this,(function(a){return e="/etc/wative",t=s.join(e,"id_rsa_server.pub"),n=s.join(e,"id_rsa_server"),c.existsSync(t)&&c.existsSync(n)||(console.log("Generating SSH key pair..."),r.execSync("ssh-keygen -t rsa -f ".concat(n," -N 'wative_server'"),{stdio:"inherit"})),i=s.join(e,"id_rsa_detake.pub"),o=s.join(e,"id_rsa_detake"),c.existsSync(i)&&c.existsSync(o)||(console.log("Generating SSH key pair..."),r.execSync("ssh-keygen -t rsa -f ".concat(o," -N 'wative_detake'"),{stdio:"inherit"})),[2]}))}))];case 1:return p.sent(),n=s.join(t,"config.ini"),c.existsSync(n)||(h=e,y=s.resolve(h,"network.json"),i=JSON.parse(c.readFileSync(y,"utf8")),o=i.accounts,d=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].trim().toLocaleLowerCase().replace(/\s+/g,"-").trim().replace(/\-+/g,"-").trim());return t}(o),v={keystore:{path:e,allowed_keystores:d},ssh:{listen:"127.0.0.1",port:5678}},f=a.stringify(v),c.writeFileSync(n,f)),[2,a.parse(c.readFileSync(n,"utf-8"))]}var h,y}))}))},v=require("os"),f=new t.Command,p=require("../package.json"),h=function(){try{return r.execSync("systemctl --version",{stdio:"ignore"}),!0}catch(e){return!1}};f.version(p.version).description("Wative CLI Tool"),f.command("version").description("Show the version of wative").action((function(){console.log("Wative CLI Tool v".concat(p.version))}));f.command("ssh").option("start","Start SSH service").option("stop","Stop SSH service").option("service add","Add SSH service").option("service remove","Remove SSH service").action((function(e,t){return u(void 0,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return"start"!==e?[3,2]:[4,u(void 0,void 0,void 0,(function(){var e,t;return l(this,(function(n){switch(n.label){case 0:return e=v.homedir(),t=s.join(e,".wative"),[4,d(t)];case 1:n.sent(),console.log("Starting SSH service...");try{r.execSync("wative-ssh",{stdio:"inherit"})}catch(e){}return console.log("SSH service started."),[2]}}))}))];case 1:return n.sent(),[2];case 2:return"stop"===e?(function(){try{r.execSync("ps aux | grep wative-ssh | grep -v grep | awk '{print $2}' | sudo xargs kill",{stdio:"inherit"})}catch(e){}console.log("SSH service stopped.")}(),[2]):"service"===e&&"add"===t?(u(void 0,void 0,void 0,(function(){var e,t;return l(this,(function(n){switch(n.label){case 0:return h()?(e=v.homedir(),t=s.join(e,".wative"),[4,d(t)]):(console.log("Systemd is not available."),[2]);case 1:n.sent(),console.log("Adding SSH service...");try{r.execSync("sudo echo '".concat("\n[Unit]\nDescription=Wative SSH Server\nAfter=network.target\n\n[Service]\nExecStart=/usr/local/bin/wative-ssh\nUser=root\nGroup=root\nStandardOutput=append:/var/log/wative-ssh.log\nStandardError=append:/var/log/wative-ssh.err\n\n[Install]\nWantedBy=multi-user.target\n ","' > ").concat("/etc/systemd/system/wative.service"),{stdio:"inherit"}),r.execSync("sudo systemctl daemon-reload",{stdio:"inherit"}),r.execSync("sudo systemctl enable wative",{stdio:"inherit"}),r.execSync("sudo systemctl start wative",{stdio:"inherit"})}catch(e){console.log(e)}return console.log("SSH service added."),[2]}}))})),[2]):"service"===e&&"remove"===t?(function(){if(h()){console.log("Removing SSH service...");try{r.execSync("sudo systemctl stop wative",{stdio:"inherit"})}catch(e){}try{r.execSync("sudo systemctl disable wative",{stdio:"inherit"})}catch(e){}try{r.execSync("sudo rm -rf /etc/systemd/system/wative.service",{stdio:"inherit"})}catch(e){}try{r.execSync("sudo systemctl daemon-reload",{stdio:"inherit"})}catch(e){}console.log("SSH service removed.")}else console.log("Systemd is not available.")}(),[2]):[2]}}))}))})),f.command("cmd").description("Start wallet-cli shell").action((function(){return u(void 0,void 0,void 0,(function(){return l(this,(function(e){try{r.execSync("wallet-cli",{stdio:"inherit"})}catch(e){}return[2]}))}))})),f.parse(process.argv)}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wative",
3
- "version": "1.0.44",
3
+ "version": "1.1.0",
4
4
  "description": "An agile keystore management toolkit",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/src/wative.ts CHANGED
@@ -60,19 +60,19 @@ const addSSHService = async () => {
60
60
 
61
61
  const serviceFilePath = '/etc/systemd/system/wative.service';
62
62
  const serviceContent = `
63
- [Unit]
64
- Description=Wative SSH Server
65
- After=network.target
66
-
67
- [Service]
68
- ExecStart=/usr/local/bin/wative-ssh
69
- User=root
70
- Group=root
71
- StandardOutput=append:/var/log/wative-ssh.log
72
- StandardError=append:/var/log/wative-ssh.err
73
-
74
- [Install]
75
- WantedBy=multi-user.target
63
+ [Unit]
64
+ Description=Wative SSH Server
65
+ After=network.target
66
+
67
+ [Service]
68
+ ExecStart=/usr/local/bin/wative-ssh
69
+ User=root
70
+ Group=root
71
+ StandardOutput=append:/var/log/wative-ssh.log
72
+ StandardError=append:/var/log/wative-ssh.err
73
+
74
+ [Install]
75
+ WantedBy=multi-user.target
76
76
  `;
77
77
 
78
78
  console.log('Adding SSH service...');