@dubeyvishal/orbital-cli 1.3.9 → 1.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubeyvishal/orbital-cli",
3
- "version": "1.3.9",
3
+ "version": "1.4.9",
4
4
  "description": "A fullstack CLI-based AI platform with chat mode, multi-tool agents, and agentic AI workflows. Includes GitHub login with device authorization, secure authentication, and modular client–server architecture for building intelligent automation tools.",
5
5
  "author": "Vishal Dubey",
6
6
  "license": "MIT",
@@ -23,17 +23,27 @@ const URL = API_BASE;
23
23
  * Request a device authorization code from the server via direct fetch.
24
24
  * Replaces: authClient.device.code()
25
25
  */
26
+ const safeJson = async (res) => {
27
+ const text = await res.text();
28
+ if (!text) return null;
29
+ try {
30
+ return JSON.parse(text);
31
+ } catch {
32
+ return null;
33
+ }
34
+ };
35
+
26
36
  const requestDeviceCode = async (serverUrl, clientId, scope) => {
27
- const res = await fetch(`${serverUrl}/api/auth/device/authorize`, {
37
+ const res = await fetch(`${serverUrl}/api/auth/device/code`, {
28
38
  method: "POST",
29
39
  headers: { "Content-Type": "application/json" },
30
40
  body: JSON.stringify({ client_id: clientId, scope }),
31
41
  });
32
42
 
33
- const body = await res.json();
43
+ const body = await safeJson(res);
34
44
 
35
45
  if (!res.ok) {
36
- return { data: null, error: body };
46
+ return { data: null, error: body || { message: `HTTP ${res.status}` } };
37
47
  }
38
48
  return { data: body, error: null };
39
49
  };
@@ -56,10 +66,10 @@ const requestDeviceToken = async (serverUrl, deviceCode, clientId) => {
56
66
  }),
57
67
  });
58
68
 
59
- const body = await res.json();
69
+ const body = await safeJson(res);
60
70
 
61
71
  if (!res.ok) {
62
- return { data: null, error: body };
72
+ return { data: null, error: body || { message: `HTTP ${res.status}` } };
63
73
  }
64
74
  return { data: body, error: null };
65
75
  };