@forvibe/cli 1.0.2 → 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.
- package/dist/index.js +19 -5
- 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
|
|
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) {
|