prividium 0.1.8 → 0.1.9

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.
@@ -28,7 +28,7 @@ function checkHostAndPortWarnings(host, port, allowExternalAccess) {
28
28
  }
29
29
  async function startServer(opts) {
30
30
  const config = new ConfigFile(opts.configPath);
31
- const workflow = new CreationWorkflow(config);
31
+ const workflow = new CreationWorkflow(config, opts.host, opts.port);
32
32
  workflow.start();
33
33
  const configConfig = config.read();
34
34
  const env = envSchema.parse(process.env);
@@ -48,11 +48,11 @@ async function startServer(opts) {
48
48
  }
49
49
  });
50
50
  checkHostAndPortWarnings(opts.host, opts.port, opts.allowExternalAccess);
51
- const serverUrl = await app.listen({
51
+ await app.listen({
52
52
  port: opts.port,
53
53
  host: opts.host
54
54
  });
55
- await workflow.waitForAuthentication(serverUrl);
55
+ await workflow.waitForAuthentication(`http://${opts.host}:${opts.port}`);
56
56
  }
57
57
  export const addProxy = (cli) => {
58
58
  return cli.command('proxy', 'Starts authenticated rpc proxy server', (yargs) => yargs
@@ -12,9 +12,13 @@ _____________|__|__ _|__| __| _/|__|__ __ _____ ____ | | |__|
12
12
  export class CreationWorkflow {
13
13
  config;
14
14
  submitCallback;
15
- constructor(config) {
15
+ host;
16
+ port;
17
+ constructor(config, host, port) {
16
18
  this.config = config;
17
19
  this.submitCallback = undefined;
20
+ this.host = host;
21
+ this.port = port;
18
22
  }
19
23
  start() {
20
24
  console.log(color.blue(HEADER));
@@ -96,7 +100,7 @@ export class CreationWorkflow {
96
100
  this.submitCallback('Authentication successful!');
97
101
  await setTimeout(100);
98
102
  }
99
- log.info(`Your proxy rpc is ready! 🚀: \n\n${color.bold('http://127.0.0.1:24101/rpc')}\n`);
103
+ log.info(`Your proxy rpc is ready! 🚀: \n\n${color.bold(`http://${this.host}:${this.port}/rpc`)}\n`);
100
104
  log.info('Waiting for logs...');
101
105
  }
102
106
  onMessage(msg) {
@@ -16,6 +16,7 @@ const rpcCallSchema = z.object({ method: z.string() });
16
16
  const rpcReqSchema = z.union([rpcCallSchema, rpcCallSchema.array()]);
17
17
  export function buildServer(config) {
18
18
  const app = fastifyApp();
19
+ const validHosts = config.host === 'localhost' || config.host === '127.0.0.1' ? ['localhost', '127.0.0.1'] : [config.host];
19
20
  app.setValidatorCompiler(validatorCompiler);
20
21
  const state = randomStateString();
21
22
  let accessToken = '';
@@ -79,9 +80,9 @@ export function buildServer(config) {
79
80
  return;
80
81
  }
81
82
  const portStr = config.port !== 80 ? `:${config.port}` : '';
82
- const fullHost = `${config.host}${portStr}`;
83
- if (req.headers.host && req.headers.host !== fullHost) {
84
- log.error(`Expected host ${fullHost} but got ${req.headers.host}`);
83
+ const fullHosts = validHosts.map((host) => `${host}${portStr}`);
84
+ if (req.headers.host && !fullHosts.some((host) => req.headers.host === host)) {
85
+ log.error(`Expected host to by any of ${fullHosts.join(', ')} but got ${req.headers.host}`);
85
86
  reply.status(403).send("host doesn't match");
86
87
  return;
87
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prividium",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "bin": {
5
5
  "prividium": "./bin/cli.js"
6
6
  },
@@ -18,7 +18,7 @@
18
18
  "README.md"
19
19
  ],
20
20
  "scripts": {
21
- "build": "tsc -b && yarn copy-static-files",
21
+ "build": "tsc -b && pnpm copy-static-files",
22
22
  "copy-static-files": "cp -r cli/static dist/cli",
23
23
  "dev": "tsc -b --watch",
24
24
  "lint": "eslint . --ignore-path ../../.gitignore --max-warnings 0 --cache --cache-strategy content --cache-location ../../.eslint-cache/prividium-sdk",
@@ -34,7 +34,7 @@
34
34
  "@fastify/http-proxy": "^11.3.0",
35
35
  "@fastify/static": "^8.3.0",
36
36
  "appdirsjs": "^1.2.7",
37
- "fastify": "^5.0.0",
37
+ "fastify": "^5.7.1",
38
38
  "fastify-type-provider-zod": "^6.1.0",
39
39
  "kleur": "^4.1.5",
40
40
  "open": "^10.1.0",