@nora-link/client 2.0.1 → 2.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/README.md CHANGED
@@ -30,7 +30,27 @@ You can acess the tunnel by navigating to [https://noralink.eu/home](https://nor
30
30
 
31
31
  ## Available subdomains
32
32
 
33
- Currently only a subset of subdomains are available to use with your own tunnels, from the following: *admin, api, app, control, dashboard, home, my, nodered, smarthome, test*.
33
+ Currently only a subset of subdomains are available to use with your own tunnels, from the following:
34
+ - `ev`
35
+ - `evse`
36
+ - `mower`
37
+ - `zigbee-garage`
38
+ - `cnc`
39
+ - `nodered-living`
40
+ - `zigbee-home`
41
+ - `zigbee`
42
+ - `nas`
43
+ - `music`
44
+ - `test`
45
+ - `smarthome`
46
+ - `nodered`
47
+ - `my`
48
+ - `home`
49
+ - `control`
50
+ - `api`
51
+ - `admin`
52
+ - `app`
53
+ - `dashboard`
34
54
 
35
55
  If you want a new subdomain, add a request here: [Request a new subdomain thread](https://github.com/andrei-tatar/nora-link-client/issues/1).
36
56
 
@@ -60,4 +80,4 @@ If you want a new subdomain, add a request here: [Request a new subdomain thread
60
80
 
61
81
  This service is currently free to use, but as our cloud costs grow, we plan to charge for use to cover the costs. This
62
82
  means that while basic features will remain free, full access and advanced features will require a subscription. We
63
- appreciate your understanding and support as we continue to improve our service.
83
+ appreciate your understanding and support as we continue to improve our service.
package/dist/cli.js CHANGED
@@ -5,6 +5,7 @@ const commander_1 = require("commander");
5
5
  const client_1 = require("./client");
6
6
  const logger_1 = require("./logger");
7
7
  const { name, version } = require("../package.json");
8
+ const TRUST_HTTPS_CERT_PREFIX = "trust!";
8
9
  commander_1.program
9
10
  .name(name)
10
11
  .version(version, "-v, --version")
@@ -25,6 +26,7 @@ commander_1.program
25
26
  .addHelpText("afterAll", 'To tunnel a local port to the subdomain `test`, you can use `-f "test|localhost:3000"`')
26
27
  .addHelpText("afterAll", 'To tunnel an ip to the subdomain `test`, you can use `-f "test|192.168.1.130"`')
27
28
  .addHelpText("afterAll", 'To tunnel a local hostname to the subdomain `test` with label `My App`, you can use `-f "test|My App|local-host.local"`')
29
+ .addHelpText("afterAll", 'To tunnel an https url with a self-signed/invalid certificate, prefix the url with `trust!`, e.g. `-f "test|trust!https://localhost:3000"`')
28
30
  .parse();
29
31
  const options = commander_1.program.opts();
30
32
  let tunnels = [];
@@ -35,12 +37,17 @@ if (Array.isArray(options.forward)) {
35
37
  const [subdomain, labelOrUrl, urlPart] = v.split("|");
36
38
  const label = urlPart ? labelOrUrl : subdomain;
37
39
  let url = urlPart ?? labelOrUrl;
40
+ let rejectUnauthorized;
41
+ if (url.startsWith(`${TRUST_HTTPS_CERT_PREFIX}https://`)) {
42
+ rejectUnauthorized = false;
43
+ url = url.replace(TRUST_HTTPS_CERT_PREFIX, "");
44
+ }
38
45
  const urlHasProtocol = /^https?:\/\//.test(url);
39
46
  if (!urlHasProtocol) {
40
47
  //if missing protocol, assume http
41
48
  url = `http://${url}`;
42
49
  }
43
- return { subdomain, url, label };
50
+ return { subdomain, url, label, rejectUnauthorized };
44
51
  });
45
52
  }
46
53
  if (!tunnels.length) {
package/dist/client.d.ts CHANGED
@@ -5,6 +5,7 @@ export interface TunnelOptions {
5
5
  url: string;
6
6
  label: string;
7
7
  removeHostHeader?: boolean;
8
+ rejectUnauthorized?: boolean;
8
9
  }
9
10
  export interface ClientConnectionOptions {
10
11
  agent?: string;
package/dist/client.js CHANGED
@@ -7,6 +7,7 @@ exports.Client = void 0;
7
7
  const rxjs_1 = require("rxjs");
8
8
  const ws_1 = __importDefault(require("ws"));
9
9
  const node_http_1 = require("node:http");
10
+ const node_https_1 = require("node:https");
10
11
  const node_querystring_1 = require("node:querystring");
11
12
  const const_1 = require("./const");
12
13
  const firebase_1 = require("./firebase");
@@ -156,16 +157,18 @@ class Client {
156
157
  if (!tunnel) {
157
158
  throw new Error(`subdomain ${subdomain} not registered`);
158
159
  }
160
+ const { protocol, hostname, port, pathname } = new URL(tunnel.url);
159
161
  if (tunnel.removeHostHeader ?? true) {
160
162
  delete headers["host"];
161
163
  }
162
- const { hostname, port, pathname } = new URL(tunnel.url);
163
- const req = (0, node_http_1.request)({
164
+ const isHttps = protocol === "https:";
165
+ const req = (isHttps ? node_https_1.request : node_http_1.request)({
164
166
  host: hostname,
165
167
  port: port,
166
168
  path: pathname === "/" ? url : `${pathname}${url}`,
167
169
  method,
168
170
  headers,
171
+ ...(isHttps ? { rejectUnauthorized: tunnel.rejectUnauthorized } : {}),
169
172
  });
170
173
  req.on("error", (err) => reqObserver.error(err));
171
174
  if (type === "ws") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nora-link/client",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "noralink.eu client",
5
5
  "bin": {
6
6
  "noralink": "dist/cli.js"