@pensar/apex 0.0.97 → 0.0.99

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/build/auth.js CHANGED
@@ -8,7 +8,7 @@ import fs from "fs/promises";
8
8
  // package.json
9
9
  var package_default = {
10
10
  name: "@pensar/apex",
11
- version: "0.0.97",
11
+ version: "0.0.99",
12
12
  description: "AI-powered penetration testing CLI tool with terminal UI",
13
13
  module: "src/tui/index.tsx",
14
14
  main: "build/index.js",
@@ -183,7 +183,7 @@ var config = {
183
183
  var PENSAR_API_BASE_URL = "https://api.pensar.dev";
184
184
  var PENSAR_CONSOLE_BASE_URL = "https://console.pensar.dev";
185
185
  function getPensarApiUrl() {
186
- return PENSAR_API_BASE_URL;
186
+ return process.env.PENSAR_API_URL || PENSAR_API_BASE_URL;
187
187
  }
188
188
  function getPensarConsoleUrl() {
189
189
  return process.env.PENSAR_CONSOLE_URL || PENSAR_CONSOLE_BASE_URL;
@@ -198,7 +198,7 @@ var config2 = {
198
198
  // src/core/api/constants.ts
199
199
  var PENSAR_API_BASE_URL2 = "https://api.pensar.dev";
200
200
  function getPensarApiUrl2() {
201
- return PENSAR_API_BASE_URL2;
201
+ return process.env.PENSAR_API_URL || PENSAR_API_BASE_URL2;
202
202
  }
203
203
  // src/core/auth/device-flow.ts
204
204
  function sleep(ms) {
@@ -323,7 +323,10 @@ async function fetchWorkspaces(apiUrl, accessToken) {
323
323
  throw new Error(`Failed to fetch workspaces (${response.status})`);
324
324
  }
325
325
  const data = await response.json();
326
- return data.workspaces;
326
+ return {
327
+ workspaces: data.workspaces,
328
+ consoleUrl: data.consoleUrl
329
+ };
327
330
  }
328
331
  async function pollForWorkspaceCreation(apiUrl, accessToken, signal) {
329
332
  const POLL_INTERVAL = 3000;
@@ -498,14 +501,15 @@ Authenticated successfully. Fetching workspaces...`);
498
501
  }
499
502
  }
500
503
  async function handleWorkspaces(apiUrl, accessToken) {
501
- let workspaces = await fetchWorkspaces(apiUrl, accessToken);
504
+ const wsResult = await fetchWorkspaces(apiUrl, accessToken);
505
+ let workspaces = wsResult.workspaces;
506
+ const consoleUrl = wsResult.consoleUrl ?? getPensarConsoleUrl();
502
507
  if (workspaces.length === 0) {
503
- const consoleUrl = getPensarConsoleUrl();
504
508
  console.log(`
505
509
  No workspaces found. Opening browser to create one...`);
506
- console.log(`If the browser didn't open, visit: ${consoleUrl}/credits
510
+ console.log(`If the browser didn't open, visit: ${consoleUrl}/create-workspace?redirect=/credits
507
511
  `);
508
- openUrl(`${consoleUrl}/credits`);
512
+ openUrl(`${consoleUrl}/create-workspace?redirect=/credits`);
509
513
  console.log("Waiting for workspace creation...");
510
514
  workspaces = await pollForWorkspaceCreation(apiUrl, accessToken);
511
515
  }
package/build/index.js CHANGED
@@ -31977,7 +31977,7 @@ var package_default2;
31977
31977
  var init_package = __esm(() => {
31978
31978
  package_default2 = {
31979
31979
  name: "@pensar/apex",
31980
- version: "0.0.97",
31980
+ version: "0.0.99",
31981
31981
  description: "AI-powered penetration testing CLI tool with terminal UI",
31982
31982
  module: "src/tui/index.tsx",
31983
31983
  main: "build/index.js",
@@ -88173,7 +88173,7 @@ var init_pensar2 = __esm(() => {
88173
88173
 
88174
88174
  // src/core/api/constants.ts
88175
88175
  function getPensarApiUrl() {
88176
- return PENSAR_API_BASE_URL;
88176
+ return process.env.PENSAR_API_URL || PENSAR_API_BASE_URL;
88177
88177
  }
88178
88178
  function getPensarGatewayUrl() {
88179
88179
  return process.env.PENSAR_GATEWAY_URL || PENSAR_GATEWAY_BASE_URL;
@@ -88404,7 +88404,10 @@ async function fetchWorkspaces(apiUrl, accessToken) {
88404
88404
  throw new Error(`Failed to fetch workspaces (${response.status})`);
88405
88405
  }
88406
88406
  const data = await response.json();
88407
- return data.workspaces;
88407
+ return {
88408
+ workspaces: data.workspaces,
88409
+ consoleUrl: data.consoleUrl
88410
+ };
88408
88411
  }
88409
88412
  async function pollForWorkspaceCreation(apiUrl, accessToken, signal) {
88410
88413
  const POLL_INTERVAL = 3000;
@@ -278734,6 +278737,7 @@ function AuthFlow({ onClose }) {
278734
278737
  }
278735
278738
  } catch {}
278736
278739
  };
278740
+ const consoleUrlRef = import_react48.useRef(getPensarConsoleUrl());
278737
278741
  const startFlow = async () => {
278738
278742
  setStep("requesting");
278739
278743
  setError(null);
@@ -278742,6 +278746,15 @@ function AuthFlow({ onClose }) {
278742
278746
  abortRef.current = ac;
278743
278747
  const apiUrl = getPensarApiUrl();
278744
278748
  try {
278749
+ try {
278750
+ const configResponse = await fetch(`${apiUrl}/api/cli/config`);
278751
+ if (configResponse.ok) {
278752
+ const cliConfig = await configResponse.json();
278753
+ if (cliConfig.consoleUrl) {
278754
+ consoleUrlRef.current = cliConfig.consoleUrl;
278755
+ }
278756
+ }
278757
+ } catch {}
278745
278758
  const info = await startDeviceFlow(apiUrl);
278746
278759
  if (ac.signal.aborted)
278747
278760
  return;
@@ -278827,12 +278840,16 @@ function AuthFlow({ onClose }) {
278827
278840
  };
278828
278841
  const handleFetchWorkspaces = async (apiUrl, accessToken, ac) => {
278829
278842
  try {
278830
- const ws = await fetchWorkspaces(apiUrl, accessToken);
278843
+ const wsResult = await fetchWorkspaces(apiUrl, accessToken);
278831
278844
  if (ac.signal.aborted)
278832
278845
  return;
278846
+ if (wsResult.consoleUrl) {
278847
+ consoleUrlRef.current = wsResult.consoleUrl;
278848
+ }
278849
+ const ws = wsResult.workspaces;
278833
278850
  if (ws.length === 0) {
278834
- const consoleUrl = getPensarConsoleUrl();
278835
- openUrl(`${consoleUrl}/credits`);
278851
+ const consoleUrl = consoleUrlRef.current;
278852
+ openUrl(`${consoleUrl}/create-workspace?redirect=/credits`);
278836
278853
  setStep("creating-workspace");
278837
278854
  handleWorkspaceCreationPoll(apiUrl, accessToken, ac);
278838
278855
  return;
@@ -278906,7 +278923,7 @@ function AuthFlow({ onClose }) {
278906
278923
  setStep("start");
278907
278924
  };
278908
278925
  const hasLowBalance = balance !== null && balance < 1;
278909
- const effectiveBillingUrl = billingUrl || (selectedWorkspace?.slug ? `${getPensarConsoleUrl()}/${selectedWorkspace.slug}/settings/billing` : connectedWorkspace?.slug ? `${getPensarConsoleUrl()}/${connectedWorkspace.slug}/settings/billing` : `${getPensarConsoleUrl()}/credits`);
278926
+ const effectiveBillingUrl = billingUrl || (selectedWorkspace?.slug ? `${consoleUrlRef.current}/${selectedWorkspace.slug}/settings/billing` : connectedWorkspace?.slug ? `${consoleUrlRef.current}/${connectedWorkspace.slug}/settings/billing` : `${consoleUrlRef.current}/credits`);
278910
278927
  const openBillingPage = () => {
278911
278928
  openUrl(effectiveBillingUrl);
278912
278929
  goHome();
@@ -279154,7 +279171,7 @@ function AuthFlow({ onClose }) {
279154
279171
  marginTop: 1,
279155
279172
  children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
279156
279173
  fg: colors2.text,
279157
- children: "Create a workspace and add credits in your browser."
279174
+ children: "Create a workspace in your browser to get started."
279158
279175
  }, undefined, false, undefined, this)
279159
279176
  }, undefined, false, undefined, this),
279160
279177
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
@@ -279172,8 +279189,8 @@ function AuthFlow({ onClose }) {
279172
279189
  "If the browser didn't open, visit:",
279173
279190
  `
279174
279191
  `,
279175
- getPensarConsoleUrl(),
279176
- "/credits"
279192
+ consoleUrlRef.current,
279193
+ "/create-workspace"
279177
279194
  ]
279178
279195
  }, undefined, true, undefined, this)
279179
279196
  }, undefined, false, undefined, this),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pensar/apex",
3
- "version": "0.0.97",
3
+ "version": "0.0.99",
4
4
  "description": "AI-powered penetration testing CLI tool with terminal UI",
5
5
  "module": "src/tui/index.tsx",
6
6
  "main": "build/index.js",