@nora-link/client 1.0.0 → 1.0.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/.vscode/launch.json +1 -1
- package/README.md +20 -4
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3 -1
- package/dist/logger.d.ts +7 -6
- package/dist/logger.js +28 -12
- package/package.json +4 -2
- package/src/cli.ts +5 -2
- package/src/logger.ts +30 -15
package/.vscode/launch.json
CHANGED
package/README.md
CHANGED
|
@@ -4,16 +4,32 @@ This package helps you access your private servers inside your home network, sec
|
|
|
4
4
|
|
|
5
5
|
## Getting an API key
|
|
6
6
|
|
|
7
|
-
1. Go to [https://noralink.eu
|
|
8
|
-
2. Navigate from the dropdown (or follow [link](https://noralink.eu
|
|
7
|
+
1. Go to [https://noralink.eu/home](https://noralink.eu/home) and create an account
|
|
8
|
+
2. Navigate from the dropdown (or follow [link](https://noralink.eu/home/api-keys)) to the **Manage API keys** menu
|
|
9
9
|
3. Create a new key and copy it somewhere safe
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
## Creating a tunnel
|
|
13
13
|
|
|
14
|
-
The following command creates a tunnel under
|
|
14
|
+
The following command creates a tunnel under subdomain `app` to `internal-server.local:1234/sample-path`. Replace `[your-api-key]` with the API key you obtained before.
|
|
15
15
|
|
|
16
|
-
`npx @nora-link/client -f
|
|
16
|
+
`npx @nora-link/client -f "app|internal-server.local:1234/sample-path" -k [your-api-key]`
|
|
17
|
+
|
|
18
|
+
You can also specify a label to be displayed in the UI:
|
|
19
|
+
|
|
20
|
+
`npx @nora-link/client -f "app|This is my test app|internal-server.local:1234/sample-path" -k [your-api-key]`
|
|
21
|
+
|
|
22
|
+
Or you can create multiple tunnels to different apps:
|
|
23
|
+
|
|
24
|
+
`npx @nora-link/client -f "app|app1.local:1234" -f "test|app2.local:1234" -k [your-api-key]`
|
|
17
25
|
|
|
18
26
|
## Accessing the tunnel
|
|
19
27
|
|
|
28
|
+
You can acess the tunnel by navigating to [https://noralink.eu/home](https://noralink.eu/home) and clicking the card corresponding your tunnel, or by going directly to the subdomain associated to your tunnerl. Eg: [https://app.noralink.eu](https://app.noralink.eu).
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Available subdomains
|
|
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*.
|
|
34
|
+
|
|
35
|
+
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).
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
const commander_1 = require("commander");
|
|
@@ -10,6 +11,7 @@ commander_1.program
|
|
|
10
11
|
.usage('[OPTIONS]...')
|
|
11
12
|
.option('-d, --debug', 'output extra debugging', false)
|
|
12
13
|
.option('-n, --non-secure', 'don\'t use secure connection', false)
|
|
14
|
+
.option('-l, --log', `min log level to display (${logger_1.LOG_LEVEL.join(',')})`, new RegExp(`^${logger_1.LOG_LEVEL.join('|')}$`), 'info')
|
|
13
15
|
.requiredOption('-f, --forward <path|label|url...>', 'Forward path to local url')
|
|
14
16
|
.requiredOption('-k, --key <api-key>', 'Api Key')
|
|
15
17
|
.requiredOption('-h, --host <hostname>', 'Server host name', 'noralink.eu')
|
|
@@ -45,6 +47,6 @@ new client_1.Client({
|
|
|
45
47
|
secure: !options.nonSecure,
|
|
46
48
|
tunnels,
|
|
47
49
|
apiKey: options.key,
|
|
48
|
-
logger: logger_1.
|
|
50
|
+
logger: (0, logger_1.createConsoleLogger)(options.log),
|
|
49
51
|
}).handle$
|
|
50
52
|
.subscribe();
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export declare
|
|
1
|
+
export declare const LOG_LEVEL: readonly ["trace", "debug", "info", "warn", "error"];
|
|
2
|
+
type LogLevel = typeof LOG_LEVEL[number];
|
|
3
|
+
export type Logger = {
|
|
4
|
+
[P in LogLevel]: (msg: string, err?: any) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function createConsoleLogger(minLevel: LogLevel): Logger;
|
|
7
|
+
export {};
|
package/dist/logger.js
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
info
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
exports.LOG_LEVEL = void 0;
|
|
4
|
+
exports.createConsoleLogger = createConsoleLogger;
|
|
5
|
+
exports.LOG_LEVEL = [
|
|
6
|
+
'trace',
|
|
7
|
+
'debug',
|
|
8
|
+
'info',
|
|
9
|
+
'warn',
|
|
10
|
+
'error'
|
|
11
|
+
];
|
|
12
|
+
function createConsoleLogger(minLevel) {
|
|
13
|
+
const minLevelIndex = exports.LOG_LEVEL.indexOf(minLevel);
|
|
14
|
+
function log(kind, ...args) {
|
|
15
|
+
const level = exports.LOG_LEVEL.indexOf(kind);
|
|
16
|
+
if (level < minLevelIndex) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const now = new Date().toLocaleString();
|
|
20
|
+
const logArgs = [`[${now}][${kind}]${args[0]}`];
|
|
21
|
+
if (args[1])
|
|
22
|
+
logArgs.push(args[1]);
|
|
23
|
+
console.log(...logArgs);
|
|
24
|
+
}
|
|
25
|
+
return new Proxy({}, {
|
|
26
|
+
get: function (_, name) {
|
|
27
|
+
return log.bind(null, name);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
1
3
|
import { program } from 'commander';
|
|
2
4
|
import { Client, ClientConnectionOptions } from './client';
|
|
3
|
-
import {
|
|
5
|
+
import { createConsoleLogger, LOG_LEVEL } from './logger';
|
|
4
6
|
|
|
5
7
|
const { name, version } = require('../package.json');
|
|
6
8
|
|
|
@@ -10,6 +12,7 @@ program
|
|
|
10
12
|
.usage('[OPTIONS]...')
|
|
11
13
|
.option('-d, --debug', 'output extra debugging', false)
|
|
12
14
|
.option('-n, --non-secure', 'don\'t use secure connection', false)
|
|
15
|
+
.option('-l, --log', `min log level to display (${LOG_LEVEL.join(',')})`, new RegExp(`^${LOG_LEVEL.join('|')}$`), 'info')
|
|
13
16
|
.requiredOption('-f, --forward <path|label|url...>', 'Forward path to local url')
|
|
14
17
|
.requiredOption('-k, --key <api-key>', 'Api Key')
|
|
15
18
|
.requiredOption('-h, --host <hostname>', 'Server host name', 'noralink.eu')
|
|
@@ -49,7 +52,7 @@ new Client({
|
|
|
49
52
|
secure: !options.nonSecure,
|
|
50
53
|
tunnels,
|
|
51
54
|
apiKey: options.key,
|
|
52
|
-
logger:
|
|
55
|
+
logger: createConsoleLogger(options.log),
|
|
53
56
|
}).handle$
|
|
54
57
|
.subscribe();
|
|
55
58
|
|
package/src/logger.ts
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
export
|
|
2
|
-
trace
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const LOG_LEVEL = [
|
|
2
|
+
'trace',
|
|
3
|
+
'debug',
|
|
4
|
+
'info',
|
|
5
|
+
'warn',
|
|
6
|
+
'error'
|
|
7
|
+
] as const;
|
|
8
|
+
|
|
9
|
+
type LogLevel = typeof LOG_LEVEL[number];
|
|
10
|
+
|
|
11
|
+
export type Logger = {
|
|
12
|
+
[P in LogLevel]: (msg: string, err?: any) => void;
|
|
5
13
|
}
|
|
6
14
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
export function createConsoleLogger(minLevel: LogLevel): Logger {
|
|
16
|
+
const minLevelIndex = LOG_LEVEL.indexOf(minLevel);
|
|
17
|
+
function log(kind: keyof Logger, ...args: Parameters<Logger['info']>) {
|
|
18
|
+
const level = LOG_LEVEL.indexOf(kind);
|
|
19
|
+
if (level < minLevelIndex) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
11
22
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
const now = new Date().toLocaleString();
|
|
24
|
+
const logArgs = [`[${now}][${kind}]${args[0]}`];
|
|
25
|
+
if (args[1]) logArgs.push(args[1]);
|
|
26
|
+
console.log(...logArgs);
|
|
27
|
+
}
|
|
15
28
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
29
|
+
return new Proxy({}, {
|
|
30
|
+
get: function (_, name: LogLevel) {
|
|
31
|
+
return log.bind(null, name);
|
|
32
|
+
}
|
|
33
|
+
}) as Logger;
|
|
34
|
+
}
|