wative 1.1.1 → 1.1.2

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/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,log:{size:10485760,backups:3}}},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 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("Starting SSH service...");try{r("wative-ssh --daemon",{stdio:"inherit"})}catch(e){}return console.log("SSH service started."),[2]}}))}))];case 1:return o.sent(),[2];case 2:return"stop"===t?(function(){if(d()){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.")}else console.log("Systemd is not available.")}(),[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/wative-ssh.log\nStandardError=append:/var/log/wative/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){}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,v,d,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,v=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),d={keystore:{path:t,allowed_keystores:v},ssh:{listen:"127.0.0.1",port:5678,log:{size:10485760,backups:3}}},p=o.stringify(d),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"),v=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,o){return n(void 0,void 0,void 0,(function(){return s(this,(function(l){switch(l.label){case 0:return"start"!==t?[3,2]:[4,n(void 0,void 0,void 0,(function(){var t,o,n;return s(this,(function(s){switch(s.label){case 0:return v()?(t="/var/log/wative",i.existsSync(t)||i.mkdirSync(t),o=c.homedir(),n=e.join(o,".wative"),[4,a(n)]):(console.log("Systemd is not available."),[2]);case 1:s.sent(),console.log("Starting SSH service...");try{r("wative-ssh --daemon",{stdio:"inherit"})}catch(e){}return console.log("SSH service started."),[2]}}))}))];case 1:return l.sent(),[2];case 2:return"stop"===t?(function(){if(v()){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.")}else console.log("Systemd is not available.")}(),[2]):"service"===t&&"add"===o?(n(void 0,void 0,void 0,(function(){var t,o,n;return s(this,(function(s){switch(s.label){case 0:return v()?(t="/var/log/wative",i.existsSync(t)||i.mkdirSync(t),o=c.homedir(),n=e.join(o,".wative"),[4,a(n)]):(console.log("Systemd is not available."),[2]);case 1:s.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/wative-ssh.log\nStandardError=append:/var/log/wative/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){}return console.log("SSH service added."),[2]}}))})),[2]):"service"===t&&"remove"===o?(function(){if(v()){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,log:{size:10485760,backups:3}}},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 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("Starting SSH service...");try{r.execSync("wative-ssh --daemon",{stdio:"inherit"})}catch(e){}return console.log("SSH service started."),[2]}}))}))];case 1:return n.sent(),[2];case 2:return"stop"===e?(function(){if(h()){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.")}else console.log("Systemd is not available.")}(),[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/wative-ssh.log\nStandardError=append:/var/log/wative/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){}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)||(y=e,h=s.resolve(y,"network.json"),i=JSON.parse(c.readFileSync(h,"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,log:{size:10485760,backups:3}}},f=a.stringify(v),c.writeFileSync(n,f)),[2,a.parse(c.readFileSync(n,"utf-8"))]}var y,h}))}))},v=require("os"),f=new t.Command,p=require("../package.json"),y=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,n;return l(this,(function(i){switch(i.label){case 0:return y()?(e="/var/log/wative",c.existsSync(e)||c.mkdirSync(e),t=v.homedir(),n=s.join(t,".wative"),[4,d(n)]):(console.log("Systemd is not available."),[2]);case 1:i.sent(),console.log("Starting SSH service...");try{r.execSync("wative-ssh --daemon",{stdio:"inherit"})}catch(e){}return console.log("SSH service started."),[2]}}))}))];case 1:return n.sent(),[2];case 2:return"stop"===e?(function(){if(y()){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.")}else console.log("Systemd is not available.")}(),[2]):"service"===e&&"add"===t?(u(void 0,void 0,void 0,(function(){var e,t,n;return l(this,(function(i){switch(i.label){case 0:return y()?(e="/var/log/wative",c.existsSync(e)||c.mkdirSync(e),t=v.homedir(),n=s.join(t,".wative"),[4,d(n)]):(console.log("Systemd is not available."),[2]);case 1:i.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/wative-ssh.log\nStandardError=append:/var/log/wative/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){}return console.log("SSH service added."),[2]}}))})),[2]):"service"===e&&"remove"===t?(function(){if(y()){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.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "An agile keystore management toolkit",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/src/wative.ts CHANGED
@@ -2,6 +2,7 @@ import * as path from 'path';
2
2
  import { Command } from 'commander';
3
3
  import { execSync } from 'child_process';
4
4
  import { getAndGenerateConfig } from './ssh/utils';
5
+ import * as fs from 'fs';
5
6
 
6
7
  const os = require('os');
7
8
  const program = new Command();
@@ -34,6 +35,11 @@ const startSSHService = async () => {
34
35
  return;
35
36
  }
36
37
 
38
+ let logDir = '/var/log/wative';
39
+ if (!fs.existsSync(logDir)) {
40
+ fs.mkdirSync(logDir);
41
+ }
42
+
37
43
  const userHomeDirectory = os.homedir();
38
44
  const keystorePath = path.join(userHomeDirectory, '.wative');
39
45
  await getAndGenerateConfig(keystorePath);
@@ -64,6 +70,11 @@ const addSSHService = async () => {
64
70
  return;
65
71
  }
66
72
 
73
+ let logDir = '/var/log/wative';
74
+ if (!fs.existsSync(logDir)) {
75
+ fs.mkdirSync(logDir);
76
+ }
77
+
67
78
  const userHomeDirectory = os.homedir();
68
79
  const keystorePath = path.join(userHomeDirectory, '.wative');
69
80
  await getAndGenerateConfig(keystorePath);