@voxli/cli 0.3.0 → 0.3.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/dist/cli.js CHANGED
@@ -1,12 +1,15 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
2
3
  import { Command } from "commander";
3
4
  import { authCommand } from "./commands/auth.js";
4
5
  import { listenCommand } from "./commands/listen.js";
6
+ const require = createRequire(import.meta.url);
7
+ const { version } = require("../package.json");
5
8
  const program = new Command();
6
9
  program
7
10
  .name("voxli")
8
11
  .description("CLI agent for running Voxli test scenarios locally")
9
- .version("0.1.0");
12
+ .version(version);
10
13
  program
11
14
  .command("auth")
12
15
  .description("Authenticate with your Voxli API key")
@@ -18,7 +18,7 @@ async function promptForKey() {
18
18
  rl.close();
19
19
  }
20
20
  }
21
- async function validateAndSave(key) {
21
+ async function validateAndSave(key, userId) {
22
22
  console.log("Validating...");
23
23
  try {
24
24
  const hostname = getStableHostname();
@@ -36,14 +36,14 @@ async function validateAndSave(key) {
36
36
  // Network error or other — warn but still save
37
37
  console.warn("Warning: could not validate key (network error). Saving anyway.");
38
38
  }
39
- await writeConfig({ apiKey: key });
39
+ await writeConfig({ apiKey: key, userId });
40
40
  console.log("API key saved to ~/.voxli/config.json");
41
41
  }
42
42
  export async function authCommand(opts) {
43
43
  if (!opts.manual) {
44
44
  try {
45
- const key = await browserAuth();
46
- await validateAndSave(key);
45
+ const result = await browserAuth();
46
+ await validateAndSave(result.apiKey, result.userId);
47
47
  return;
48
48
  }
49
49
  catch (err) {
@@ -1 +1,5 @@
1
- export declare function browserAuth(): Promise<string>;
1
+ export interface BrowserAuthResult {
2
+ apiKey: string;
3
+ userId?: string;
4
+ }
5
+ export declare function browserAuth(): Promise<BrowserAuthResult>;
@@ -57,6 +57,7 @@ export async function browserAuth() {
57
57
  }
58
58
  const returnedKey = url.searchParams.get("key");
59
59
  const returnedState = url.searchParams.get("state");
60
+ const returnedUserId = url.searchParams.get("user_id");
60
61
  if (returnedState !== state) {
61
62
  res.writeHead(403, { "Content-Type": "text/html" });
62
63
  res.end(ERROR_HTML);
@@ -70,7 +71,7 @@ export async function browserAuth() {
70
71
  res.writeHead(200, { "Content-Type": "text/html" });
71
72
  res.end(SUCCESS_HTML);
72
73
  cleanup();
73
- resolve(returnedKey);
74
+ resolve({ apiKey: returnedKey, userId: returnedUserId || undefined });
74
75
  });
75
76
  const timeout = setTimeout(() => {
76
77
  cleanup();
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export interface VoxliConfig {
2
2
  apiKey: string;
3
+ userId?: string;
3
4
  }
4
5
  export interface RegisterPayload {
5
6
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxli/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "CLI agent for running Voxli test scenarios locally",
5
5
  "type": "module",
6
6
  "bin": {