@nora-link/client 1.0.14 → 1.0.16
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 +23 -1
- package/dist/cli.js +5 -2
- package/dist/client.d.ts +2 -1
- package/dist/client.js +21 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @nora-link/client
|
|
2
2
|
|
|
3
|
-
This package helps you access your private servers inside your home network, securely, from the internet, without the hassle of setting up
|
|
3
|
+
This package helps you access your private http/ws servers inside your home network, securely, from the internet, **without the hassle of setting up**.
|
|
4
4
|
|
|
5
5
|
## Getting an API key
|
|
6
6
|
|
|
@@ -34,6 +34,28 @@ Currently only a subset of subdomains are available to use with your own tunnels
|
|
|
34
34
|
|
|
35
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).
|
|
36
36
|
|
|
37
|
+
## Security
|
|
38
|
+
|
|
39
|
+
- #### End-to-End TLS Encryption
|
|
40
|
+
All traffic from the client machine to the user’s browser is encrypted using TLS, ensuring data security during transmission.
|
|
41
|
+
- #### Certificate Management by Google Cloud
|
|
42
|
+
Certificates for the service are handled by Google Cloud, providing robust and trusted certificate management.
|
|
43
|
+
- #### Secure WebSocket Tunneling
|
|
44
|
+
Traffic is tunneled via a secure WebSocket connection, and is only accessible to the authenticated user.
|
|
45
|
+
- #### Authentication with External Providers
|
|
46
|
+
Users can create accounts using Google and GitHub identity providers or via email/password. This flexibility enhances the user experience while providing secure authentication methods.
|
|
47
|
+
- #### Email Verification for Email/Password Signups
|
|
48
|
+
Email/password accounts require email verification, adding an extra layer of security. MFA is not yet supported for email/password.
|
|
49
|
+
- #### Scoped Access with API Key
|
|
50
|
+
The client uses an API key, generated from the browser, which is only shown once and hashed after creation. The key is scoped to the user, ensuring access is limited to tunnels created only by that user. API keys are never stored in plaintext; only their hash is kept, minimizing the risk of exposure.
|
|
51
|
+
- #### HttpOnly Secure Cookie for Session Management
|
|
52
|
+
Browser authentication is maintained via a secure, HttpOnly cookie with a 12-hour expiration, reducing the risk of session hijacking.
|
|
53
|
+
- #### Open Source, Lightweight Client
|
|
54
|
+
The client source code is open source, providing transparency, and is lightweight, reducing the attack surface and complexity.
|
|
55
|
+
- #### Host-Specific Access Control
|
|
56
|
+
The server can only access pre-defined local hosts specified in the config, ensuring that no unauthorized access to other local services is possible.
|
|
57
|
+
|
|
58
|
+
|
|
37
59
|
## Pricing
|
|
38
60
|
|
|
39
61
|
This service is currently free to use, but as our cloud costs grow, we plan to charge for use to cover the costs. This
|
package/dist/cli.js
CHANGED
|
@@ -47,12 +47,15 @@ if (!tunnels.length) {
|
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
+
const logger = (0, logger_1.createConsoleLogger)(options.log);
|
|
50
51
|
new client_1.Client({
|
|
51
52
|
agent: `${name}@${version}`,
|
|
52
53
|
hostname: options.host,
|
|
53
54
|
secure: !options.nonSecure,
|
|
54
55
|
tunnels,
|
|
55
56
|
apiKey: options.key,
|
|
56
|
-
logger
|
|
57
|
-
}).handle$.subscribe(
|
|
57
|
+
logger,
|
|
58
|
+
}).handle$.subscribe(status => {
|
|
59
|
+
logger.info(`[nora-link] ${status}`);
|
|
60
|
+
});
|
|
58
61
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -16,10 +16,11 @@ export interface ClientConnectionOptions {
|
|
|
16
16
|
}
|
|
17
17
|
export declare class Client {
|
|
18
18
|
private options;
|
|
19
|
+
private retryCount;
|
|
19
20
|
constructor(options: ClientConnectionOptions);
|
|
20
21
|
private server$;
|
|
21
22
|
private data$;
|
|
22
|
-
readonly handle$: Observable<'connected' | 'connecting'>;
|
|
23
|
+
readonly handle$: Observable<'connected' | 'connecting' | 'disconnected'>;
|
|
23
24
|
private send;
|
|
24
25
|
private getStreamData;
|
|
25
26
|
private httpRequest;
|
package/dist/client.js
CHANGED
|
@@ -12,10 +12,10 @@ const const_1 = require("./const");
|
|
|
12
12
|
class Client {
|
|
13
13
|
constructor(options) {
|
|
14
14
|
this.options = options;
|
|
15
|
+
this.retryCount = 1;
|
|
15
16
|
this.server$ = new rxjs_1.Observable(observer => {
|
|
16
17
|
const subdomains = this.options.tunnels.map(v => `${v.subdomain}|${v.label}`);
|
|
17
18
|
const qs = (0, node_querystring_1.stringify)({ s: subdomains });
|
|
18
|
-
this.options.logger?.info(`[nora-link] connecting`);
|
|
19
19
|
const protocol = (this.options.secure ?? true) ? 'wss' : 'ws';
|
|
20
20
|
const headers = {
|
|
21
21
|
authorization: `Bearer ${this.options.apiKey}`,
|
|
@@ -29,7 +29,6 @@ class Client {
|
|
|
29
29
|
followRedirects: true,
|
|
30
30
|
});
|
|
31
31
|
ws.on('open', () => {
|
|
32
|
-
this.options.logger?.info(`[nora-link] connected`);
|
|
33
32
|
observer.next(ws);
|
|
34
33
|
});
|
|
35
34
|
ws.on('error', (err) => {
|
|
@@ -42,12 +41,19 @@ class Client {
|
|
|
42
41
|
const handler = (msg) => {
|
|
43
42
|
Buffer.isBuffer(msg) && observer.next(msg);
|
|
44
43
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
ws.once('close', (code, reason) => {
|
|
44
|
+
const errorHandler = (err) => observer.error(err);
|
|
45
|
+
const closeHandler = (code, reason) => {
|
|
48
46
|
observer.error(new Error(`${code} - ${reason.toString()}`));
|
|
49
|
-
}
|
|
50
|
-
|
|
47
|
+
};
|
|
48
|
+
ws.on('message', handler);
|
|
49
|
+
ws.once('error', errorHandler);
|
|
50
|
+
ws.once('close', closeHandler);
|
|
51
|
+
return () => {
|
|
52
|
+
ws.off('message', handler);
|
|
53
|
+
ws.off('error', errorHandler);
|
|
54
|
+
ws.off('close', closeHandler);
|
|
55
|
+
ws.close();
|
|
56
|
+
};
|
|
51
57
|
})), (0, rxjs_1.map)(v => {
|
|
52
58
|
if (v.length >= 5) {
|
|
53
59
|
const id = v.readUint32BE();
|
|
@@ -61,19 +67,21 @@ class Client {
|
|
|
61
67
|
}
|
|
62
68
|
return null;
|
|
63
69
|
}), (0, rxjs_1.filter)(v => !!v), (0, rxjs_1.share)());
|
|
64
|
-
this.handle$ = (0, rxjs_1.merge)(this.server$.pipe((0, rxjs_1.
|
|
70
|
+
this.handle$ = (0, rxjs_1.merge)(this.server$.pipe((0, rxjs_1.tap)(() => {
|
|
71
|
+
this.retryCount = 1;
|
|
72
|
+
}), (0, rxjs_1.map)(_ => 'connected')), this.data$.pipe((0, rxjs_1.mergeMap)(({ id, msg, type }) => type === 'http' || type === 'ws'
|
|
65
73
|
? this.httpRequest({
|
|
66
74
|
type,
|
|
67
75
|
options: JSON.parse(msg.toString()),
|
|
68
76
|
data$: this.getStreamData(id),
|
|
69
77
|
send: (type, msg) => this.send(id, type, msg),
|
|
70
78
|
})
|
|
71
|
-
: rxjs_1.EMPTY))).pipe((0, rxjs_1.startWith)('connecting'), (0, rxjs_1.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.options.logger?.error(`[nora-link] connection error: ${err}`);
|
|
79
|
+
: rxjs_1.EMPTY))).pipe((0, rxjs_1.startWith)('connecting'), (0, rxjs_1.catchError)(err => (0, rxjs_1.concat)((0, rxjs_1.of)('disconnected'), (0, rxjs_1.throwError)(() => err))), (0, rxjs_1.retry)({
|
|
80
|
+
delay: (err) => {
|
|
81
|
+
const delaySeconds = Math.round(Math.min(600, Math.pow(1.8, this.retryCount - 1)));
|
|
82
|
+
this.options.logger?.error(`[nora-link] connection error ${this.retryCount}: ${err}`);
|
|
76
83
|
this.options.logger?.info(`[nora-link] retrying in ${delaySeconds} sec`);
|
|
84
|
+
this.retryCount++;
|
|
77
85
|
return (0, rxjs_1.timer)(delaySeconds * 1000);
|
|
78
86
|
},
|
|
79
87
|
}), (0, rxjs_1.share)());
|