prividium 0.14.1 → 0.15.1

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
@@ -574,6 +577,18 @@ Environment variables (optional):
574
577
 
575
578
  Precedence: CLI flags > environment variables > saved config file.
576
579
 
580
+ ### Local Development
581
+
582
+ When running the full Prividium stack locally (`pnpm dev`), use:
583
+
584
+ ```bash
585
+ npx prividium proxy \
586
+ --rpc-url http://localhost:8000 \
587
+ --user-panel-url http://localhost:3001
588
+ ```
589
+
590
+ Point Foundry, Hardhat, or your scripts at `http://127.0.0.1:24101/rpc` after sign-in.
591
+
577
592
  ### Config Commands
578
593
 
579
594
  ```bash
@@ -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
@@ -37,6 +37,15 @@ export class PopupAuth {
37
37
  console.warn(`Received message from unexpected origin: ${event.origin}`);
38
38
  return;
39
39
  }
40
+ // Stop polling for popup.closed now that a definitive response
41
+ // has arrived. Otherwise, the callback page self-closes (~100ms
42
+ // after posting) while setToken() is still awaiting token
43
+ // expiration, and the poll can reject with "Authentication was
44
+ // cancelled" even though the token gets stored successfully.
45
+ if (checkInterval) {
46
+ clearInterval(checkInterval);
47
+ checkInterval = null;
48
+ }
40
49
  // Handle error from callback
41
50
  if (event.data.error) {
42
51
  popup.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prividium",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "prividium": "bin/cli.js"