prividium 0.14.1 → 0.15.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
@@ -551,6 +551,8 @@ prividium proxy \
551
551
 
552
552
  What happens:
553
553
 
554
+ - Validates that `--user-panel-url` points to a Prividium™ User Panel before starting. Exits with an error if an Admin
555
+ Panel URL is detected; warns and continues if the URL cannot be reached or confirmed.
554
556
  - Prints a local URL to open in your browser for sign-in.
555
557
  - After successful sign-in, the proxy is available at `http://127.0.0.1:24101/rpc`.
556
558
  - All requests are forwarded to your `--rpc-url` with `Authorization: Bearer <token>`.
@@ -559,7 +561,8 @@ What happens:
559
561
  Flags:
560
562
 
561
563
  - `--rpc-url, -r` (string): Target Prividium™ RPC URL.
562
- - `--user-panel-url, -u` (string): URL used to log in to Prividium™.
564
+ - `--user-panel-url, -u` (string): URL of the Prividium™ User Panel used for sign-in. The command validates this URL on
565
+ startup and exits with an error if it detects an Admin Panel URL.
563
566
  - `--port, -p` (number, default `24101`): Local proxy port. This has to match with the port configured in the admin
564
567
  panel, which by default uses this same port.
565
568
  - `--host, -h` (string, default `127.0.0.1`): host binded to server. By default only connections comming from local
@@ -4,6 +4,41 @@ import { CreationWorkflow } from '../server/connection-workflow.js';
4
4
  import { buildServer } from '../server/server.js';
5
5
  import { gatherUrlConfig } from './utils/url-config.js';
6
6
  const DEFAULT_PORT = 24101;
7
+ async function verifyUserPanelUrl(url) {
8
+ try {
9
+ const response = await fetch(url, { signal: AbortSignal.timeout(5000) });
10
+ const html = await response.text();
11
+ const metaMatch = html.match(/<meta\s+name="prividium-component"\s+content="([^"]*)"\s*\/?>/i);
12
+ if (metaMatch?.[1]) {
13
+ const component = metaMatch[1].toLowerCase();
14
+ if (component === 'admin-panel') {
15
+ log.error(`The --user-panel-url appears to point to an Admin Panel, not a User Panel.\n` +
16
+ ` Provided URL: ${url}\n\n` +
17
+ `Please provide the User Panel URL instead (typically a different port).`);
18
+ process.exit(1);
19
+ }
20
+ if (component !== 'user-panel') {
21
+ log.warn(`Could not confirm that --user-panel-url points to a Prividium User Panel.\n` +
22
+ ` Provided URL: ${url}\n` +
23
+ ` Detected component: "${metaMatch[1]}"\n` +
24
+ `Proceeding anyway. If authentication hangs, verify this URL is correct.`);
25
+ }
26
+ return;
27
+ }
28
+ log.warn(`Could not confirm that --user-panel-url points to a Prividium User Panel.\n` +
29
+ ` Provided URL: ${url}\n` +
30
+ `Proceeding anyway. If authentication hangs, verify this URL is correct.`);
31
+ }
32
+ catch (error) {
33
+ if (error instanceof TypeError ||
34
+ (error instanceof DOMException && (error.name === 'TimeoutError' || error.name === 'AbortError'))) {
35
+ log.warn(`Could not reach --user-panel-url at ${url}.\n` +
36
+ `Proceeding anyway. If authentication hangs, verify this URL is correct.`);
37
+ return;
38
+ }
39
+ throw error;
40
+ }
41
+ }
7
42
  function checkHostAndPortWarnings(host, port, allowExternalAccess) {
8
43
  if (port !== DEFAULT_PORT) {
9
44
  log.warn(`Non standard port detected: ${port}. Redirect from prividium auth might not work.`);
@@ -31,6 +66,8 @@ async function startServer(opts) {
31
66
  rpcUrlLabel: 'prividium rpc',
32
67
  logProvidedUrls: true
33
68
  });
69
+ await verifyUserPanelUrl(userPanelUrl);
70
+ checkHostAndPortWarnings(opts.host, opts.port, opts.allowExternalAccess);
34
71
  const app = buildServer({
35
72
  prividiumRpcUrl,
36
73
  userPanelUrl,
@@ -49,7 +86,6 @@ async function startServer(opts) {
49
86
  workflow.onError(err);
50
87
  }
51
88
  });
52
- checkHostAndPortWarnings(opts.host, opts.port, opts.allowExternalAccess);
53
89
  await app.listen({
54
90
  port: opts.port,
55
91
  host: opts.host
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prividium",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "prividium": "bin/cli.js"