@forvibe/cli 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1837,6 +1837,19 @@ function scanAppAssets(rootDir, techStack) {
1837
1837
 
1838
1838
  // src/api/forvibe-client.ts
1839
1839
  var DEFAULT_API_URL = "https://forvibe.app";
1840
+ async function fetchWithAuth(url, init, maxRedirects = 3) {
1841
+ let currentUrl = url;
1842
+ for (let i = 0; i <= maxRedirects; i++) {
1843
+ const response = await fetch(currentUrl, { ...init, redirect: "manual" });
1844
+ if (response.status < 300 || response.status >= 400) {
1845
+ return response;
1846
+ }
1847
+ const location = response.headers.get("location");
1848
+ if (!location) return response;
1849
+ currentUrl = new URL(location, currentUrl).toString();
1850
+ }
1851
+ throw new Error("Too many redirects");
1852
+ }
1840
1853
  var ForvibeClient = class {
1841
1854
  baseUrl;
1842
1855
  sessionToken = null;
@@ -1879,12 +1892,13 @@ var ForvibeClient = class {
1879
1892
  if (!this.sessionToken) {
1880
1893
  throw new Error("Not connected. Please validate OTC code first.");
1881
1894
  }
1882
- const response = await fetch(`${this.baseUrl}/api/agent/report`, {
1895
+ const headers = {
1896
+ "Content-Type": "application/json",
1897
+ Authorization: `Bearer ${this.sessionToken}`
1898
+ };
1899
+ const response = await fetchWithAuth(`${this.baseUrl}/api/agent/report`, {
1883
1900
  method: "POST",
1884
- headers: {
1885
- "Content-Type": "application/json",
1886
- Authorization: `Bearer ${this.sessionToken}`
1887
- },
1901
+ headers,
1888
1902
  body: JSON.stringify({ report })
1889
1903
  });
1890
1904
  if (!response.ok) {
@@ -1896,10 +1910,14 @@ var ForvibeClient = class {
1896
1910
  } catch {
1897
1911
  }
1898
1912
  if (response.status === 401) {
1899
- throw new Error("Session expired. Please generate a new connection code.");
1913
+ throw new Error(
1914
+ errorMessage || "Session expired. Please generate a new connection code."
1915
+ );
1900
1916
  }
1901
1917
  if (response.status === 409) {
1902
- throw new Error("Report has already been submitted for this session.");
1918
+ throw new Error(
1919
+ errorMessage || "Report has already been submitted for this session."
1920
+ );
1903
1921
  }
1904
1922
  if (response.status === 413) {
1905
1923
  throw new Error("Report too large. Try reducing the number of screenshots.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forvibe/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Forvibe CLI - AI-powered project analyzer for App Store automation",
5
5
  "type": "module",
6
6
  "bin": {