pinokiod 1.3.38 → 1.3.39

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.
@@ -1,5 +1,7 @@
1
+ const { yellow, green, blue } = require('kleur');
2
+ const QRCode = require('qrcode');
1
3
  class C {
2
- async start (req, ondata, kernel) {
4
+ async tunnel (req, ondata, kernel) {
3
5
  /*
4
6
  {
5
7
  "method": "cloundflare.tunnel",
@@ -10,6 +12,47 @@ class C {
10
12
 
11
13
  => cloudflared tunnel --url http://localhost:8080
12
14
  */
15
+ const message = `cloudflared tunnel --url ${req.params.uri}`
16
+ let params = {
17
+ id: message,
18
+ message
19
+ }
20
+ if (req.client) {
21
+ params.rows = req.client.rows
22
+ params.cols = req.client.cols
23
+ }
24
+ let options = {}
25
+ if (req.cwd) options.cwd = req.cwd
26
+ if (req.parent && req.parent.path) options.group = req.parent.path
27
+ console.log("shells before", kernel.shell.shells)
28
+ let pattern = /(https:.+?trycloudflare\.com)/
29
+ let cloudflare_url = await new Promise((resolve, reject) => {
30
+ kernel.shell.start(params, options, (e) => {
31
+ ondata(e)
32
+ let test = pattern.exec(e.cleaned)
33
+ if (test && test.length > 0) {
34
+ resolve(test[1])
35
+ }
36
+ })
37
+ })
38
+ console.log("cloudflare_url", cloudflare_url)
39
+
40
+ ondata({ raw: yellow("\r\n## Scan the QR code to open in any device\r\n\r\n") })
41
+ ondata({ raw: blue(`${cloudflare_url}\r\n\r\n`) })
42
+
43
+ await new Promise((resolve, reject) => {
44
+ QRCode.toString(cloudflare_url, {
45
+ type: "terminal"
46
+ }, function(err, data) {
47
+ ondata({ raw: green(data).replaceAll("\n", "\r\n") })
48
+ ondata({ raw: "\r\n" })
49
+ setTimeout(() => {
50
+ resolve()
51
+ }, 2000)
52
+ });
53
+ })
54
+
55
+ return { uri: cloudflare_url }
13
56
  }
14
57
  async stop (req, ondata, kernel) {
15
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.3.38",
3
+ "version": "1.3.39",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -37,6 +37,7 @@
37
37
  "jsdom": "^24.0.0",
38
38
  "jsonpath-plus": "^7.2.0",
39
39
  "key-store": "^1.2.0",
40
+ "kleur": "^4.1.5",
40
41
  "lodash": "^4.17.21",
41
42
  "lproxy": "^0.0.9",
42
43
  "marked": "^5.0.1",