pinokiod 1.0.11 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,7 +34,6 @@
34
34
  "isomorphic-git": "^1.23.0",
35
35
  "jsonpath-plus": "^7.2.0",
36
36
  "key-store": "^1.2.0",
37
- "localtunnel": "^2.0.2",
38
37
  "lodash": "^4.17.21",
39
38
  "marked": "^5.0.1",
40
39
  "mime-types": "^2.1.35",
package/server/index.js CHANGED
@@ -20,7 +20,9 @@ const git = require('isomorphic-git')
20
20
  const http = require('isomorphic-git/http/node')
21
21
  const marked = require('marked')
22
22
  const multer = require('multer');
23
- const localtunnel = require('localtunnel');
23
+ //const localtunnel = require('localtunnel');
24
+ //const ngrok = require("@ngrok/ngrok");
25
+
24
26
  const ejs = require('ejs');
25
27
 
26
28
 
@@ -35,7 +37,7 @@ class Server {
35
37
  this.agent = config.agent
36
38
  this.port = config.port
37
39
  this.kernel = new Kernel(config.store)
38
- this.tunnels = {}
40
+ // this.tunnels = {}
39
41
  this.version = {
40
42
  pinokiod: packagejson.version,
41
43
  pinokio: config.version
@@ -95,23 +97,24 @@ class Server {
95
97
  for(let key in localMem) {
96
98
  let val = localMem[key]
97
99
  // check for localhost url
98
- let localhost = false
99
- let tunnel
100
- try {
101
- let url = new URL(val)
102
- if (localhosts.includes(url.hostname)) {
103
- localhost = true
104
- if (this.tunnels[val]) {
105
- tunnel = this.tunnels[val].url
106
- }
107
- }
108
- } catch (e) { }
100
+ // let localhost = false
101
+ // let tunnel
102
+ // try {
103
+ // let url = new URL(val)
104
+ // if (localhosts.includes(url.hostname)) {
105
+ // localhost = true
106
+ // if (this.tunnels[val]) {
107
+ // tunnel = this.tunnels[val].url()
108
+ // //tunnel = this.tunnels[val].url
109
+ // }
110
+ // }
111
+ // } catch (e) { }
109
112
  mem.push({
110
113
  type: "local",
111
114
  key,
112
115
  val,
113
- tunnel,
114
- localhost,
116
+ // tunnel,
117
+ // localhost,
115
118
  })
116
119
  }
117
120
  return mem
@@ -1752,41 +1755,57 @@ class Server {
1752
1755
  let mem = this.getMemory(filepath)
1753
1756
  res.json(mem)
1754
1757
  })
1755
- this.app.post("/pinokio/tunnel", async (req, res) => {
1756
- let port
1757
- let local_host
1758
- try {
1759
- let u = new URL(req.body.url)
1760
- port = u.port
1761
- local_host = u.hostname
1762
- console.log({ local_host, port })
1763
- if (req.body.action === "start") {
1764
- //const tunnel = await localtunnel({ local_host, port: parseInt(port) });
1765
- //const tunnel = await localtunnel({ local_host: "127.0.0.1", port: parseInt(port) });
1766
- const tunnel = await localtunnel({ port: parseInt(port) });
1767
- let url = req.body.url
1768
- this.tunnels[url] = tunnel
1769
- tunnel.on('error', (err) => {
1770
- console.log(err)
1771
- delete this.tunnels[url]
1772
- })
1773
- tunnel.on('close', () => {
1774
- // tunnels are closed
1775
- console.log("tunnel closed", { url, tunnel_url: tunnel.url })
1776
- delete this.tunnels[url]
1777
- });
1778
- res.json({ url: tunnel.url })
1779
- } else if (req.body.action === "stop") {
1780
- let url = req.body.url
1781
- console.log({ tunnels: this.tunnels, url })
1782
- this.tunnels[url].close()
1783
- res.json({ url })
1784
- }
1785
- } catch (e) {
1786
- console.log("ERROR", e)
1787
- res.json({ error: e.message })
1788
- }
1789
- })
1758
+ // this.app.post("/pinokio/tunnel", async (req, res) => {
1759
+ // let port
1760
+ // let local_host
1761
+ // try {
1762
+ // let u = new URL(req.body.url)
1763
+ // port = u.port
1764
+ // local_host = u.hostname
1765
+ // console.log({ local_host, port })
1766
+ // if (req.body.action === "start") {
1767
+ // // Output ngrok url to console
1768
+ //
1769
+ // let url = req.body.url
1770
+ // console.log("tunnel", req.body)
1771
+ // const tunnel = await ngrok.forward({ addr: port, authtoken: req.body.token });
1772
+ // console.log("created", tunnel)
1773
+ // console.log("url", tunnel.url())
1774
+ // this.tunnels[url] = tunnel
1775
+ // res.json({ url: tunnel.url() })
1776
+ //
1777
+ //
1778
+ // // localtunnel
1779
+ // //const tunnel = await localtunnel({ local_host, port: parseInt(port) });
1780
+ // //const tunnel = await localtunnel({ local_host: "127.0.0.1", port: parseInt(port) });
1781
+ //
1782
+ // //const tunnel = await localtunnel({ port: parseInt(port) });
1783
+ // //this.tunnels[url] = tunnel
1784
+ // //tunnel.on('error', (err) => {
1785
+ // // console.log(err)
1786
+ // // delete this.tunnels[url]
1787
+ // //})
1788
+ // //tunnel.on('close', () => {
1789
+ // // // tunnels are closed
1790
+ // // console.log("tunnel closed", { url, tunnel_url: tunnel.url })
1791
+ // // delete this.tunnels[url]
1792
+ // //});
1793
+ // //res.json({ url: tunnel.url })
1794
+ // } else if (req.body.action === "stop") {
1795
+ // let url = req.body.url
1796
+ // await this.tunnels[url].close()
1797
+ // delete this.tunnels[url]
1798
+ // res.json({ url })
1799
+ //// let url = req.body.url
1800
+ //// console.log({ tunnels: this.tunnels, url })
1801
+ //// this.tunnels[url].close()
1802
+ //// res.json({ url })
1803
+ // }
1804
+ // } catch (e) {
1805
+ // console.log("ERROR", e)
1806
+ // res.json({ error: e.message })
1807
+ // }
1808
+ // })
1790
1809
  this.app.post("/pinokio/tabs", async (req, res) => {
1791
1810
  this.tabs[req.body.name] = req.body.tabs
1792
1811
  res.json({ success: true })
@@ -666,6 +666,7 @@ body.dark .memory {
666
666
  }
667
667
  */
668
668
  .memory {
669
+ display: none;
669
670
  position: absolute;
670
671
  z-index: 10000;
671
672
  top: 10px;
@@ -636,40 +636,43 @@ document.addEventListener("DOMContentLoaded", async () => {
636
636
  })
637
637
  Reporter()
638
638
  */
639
- document.querySelector(".memory").addEventListener("click", async (e) => {
640
- let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
641
- let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
642
- if (target) {
643
- e.preventDefault()
644
- e.stopPropagation()
645
- let url = target.getAttribute("data-url")
646
- let response = await fetch("/pinokio/tunnel", {
647
- method: "POST",
648
- headers: {
649
- "Content-Type": "application/json"
650
- },
651
- body: JSON.stringify({ url, action: "start" })
652
- }).then((res) => {
653
- return res.json()
654
- })
655
- await reloadMemory()
656
- } else if (target2) {
657
- console.log("target2", target2)
658
- e.preventDefault()
659
- e.stopPropagation()
660
- let url = target2.getAttribute("data-url")
661
- let response = await fetch("/pinokio/tunnel", {
662
- method: "POST",
663
- headers: {
664
- "Content-Type": "application/json"
665
- },
666
- body: JSON.stringify({ url, action: "stop" })
667
- }).then((res) => {
668
- return res.json()
669
- })
670
- await reloadMemory()
671
- }
672
- })
639
+ // document.querySelector(".memory").addEventListener("click", async (e) => {
640
+ // let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
641
+ // let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
642
+ // if (target) {
643
+ // e.preventDefault()
644
+ // e.stopPropagation()
645
+ // let url = target.getAttribute("data-url")
646
+ // const token = prompt("Enter an Ngrok auth token to expose your machine to the public Internet https://ngrok.com/")
647
+ // if (token && token.length > 0) {
648
+ // let response = await fetch("/pinokio/tunnel", {
649
+ // method: "POST",
650
+ // headers: {
651
+ // "Content-Type": "application/json"
652
+ // },
653
+ // body: JSON.stringify({ url, action: "start", token })
654
+ // }).then((res) => {
655
+ // return res.json()
656
+ // })
657
+ // await reloadMemory()
658
+ // }
659
+ // } else if (target2) {
660
+ // console.log("target2", target2)
661
+ // e.preventDefault()
662
+ // e.stopPropagation()
663
+ // let url = target2.getAttribute("data-url")
664
+ // let response = await fetch("/pinokio/tunnel", {
665
+ // method: "POST",
666
+ // headers: {
667
+ // "Content-Type": "application/json"
668
+ // },
669
+ // body: JSON.stringify({ url, action: "stop" })
670
+ // }).then((res) => {
671
+ // return res.json()
672
+ // })
673
+ // await reloadMemory()
674
+ // }
675
+ // })
673
676
  document.querySelector("#lv").addEventListener("click", (e) => {
674
677
  let m = e.target.closest(".memory")
675
678
  m.classList.toggle("collapsed")
@@ -619,40 +619,46 @@ document.addEventListener("DOMContentLoaded", async () => {
619
619
  })
620
620
  Reporter()
621
621
  */
622
- document.querySelector(".memory").addEventListener("click", async (e) => {
623
- let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
624
- let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
625
- if (target) {
626
- e.preventDefault()
627
- e.stopPropagation()
628
- let url = target.getAttribute("data-url")
629
- let response = await fetch("/pinokio/tunnel", {
630
- method: "POST",
631
- headers: {
632
- "Content-Type": "application/json"
633
- },
634
- body: JSON.stringify({ url, action: "start" })
635
- }).then((res) => {
636
- return res.json()
637
- })
638
- await reloadMemory()
639
- } else if (target2) {
640
- console.log("target2", target2)
641
- e.preventDefault()
642
- e.stopPropagation()
643
- let url = target2.getAttribute("data-url")
644
- let response = await fetch("/pinokio/tunnel", {
645
- method: "POST",
646
- headers: {
647
- "Content-Type": "application/json"
648
- },
649
- body: JSON.stringify({ url, action: "stop" })
650
- }).then((res) => {
651
- return res.json()
652
- })
653
- await reloadMemory()
654
- }
655
- })
622
+
623
+
624
+
625
+ // document.querySelector(".memory").addEventListener("click", async (e) => {
626
+ // let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
627
+ // let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
628
+ // if (target) {
629
+ // e.preventDefault()
630
+ // e.stopPropagation()
631
+ // let url = target.getAttribute("data-url")
632
+ // const token = prompt("Enter an Ngrok auth token to expose your machine to the public Internet https://ngrok.com/")
633
+ // if (token && token.length > 0) {
634
+ // let response = await fetch("/pinokio/tunnel", {
635
+ // method: "POST",
636
+ // headers: {
637
+ // "Content-Type": "application/json"
638
+ // },
639
+ // body: JSON.stringify({ url, action: "start", token })
640
+ // }).then((res) => {
641
+ // return res.json()
642
+ // })
643
+ // await reloadMemory()
644
+ // }
645
+ // } else if (target2) {
646
+ // console.log("target2", target2)
647
+ // e.preventDefault()
648
+ // e.stopPropagation()
649
+ // let url = target2.getAttribute("data-url")
650
+ // let response = await fetch("/pinokio/tunnel", {
651
+ // method: "POST",
652
+ // headers: {
653
+ // "Content-Type": "application/json"
654
+ // },
655
+ // body: JSON.stringify({ url, action: "stop" })
656
+ // }).then((res) => {
657
+ // return res.json()
658
+ // })
659
+ // await reloadMemory()
660
+ // }
661
+ // })
656
662
  /*
657
663
  document.querySelector("#source").addEventListener("click", (e) => {
658
664
  refreshParent({