@kortix/agent-tunnel 0.13.32 → 0.13.34
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/client-cli.js +14 -2
- package/package.json +1 -1
- package/src/client/tunnel-client.ts +14 -2
package/dist/client-cli.js
CHANGED
|
@@ -60,7 +60,15 @@ class TunnelClient {
|
|
|
60
60
|
},
|
|
61
61
|
body: JSON.stringify({ method, params })
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
let data;
|
|
64
|
+
try {
|
|
65
|
+
data = await res.json();
|
|
66
|
+
} catch {
|
|
67
|
+
if (!res.ok) {
|
|
68
|
+
throw new TunnelClientError(-1, `HTTP ${res.status} ${res.statusText}`, undefined, false);
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`Failed to parse response for ${method}: unexpected non-JSON body`);
|
|
71
|
+
}
|
|
64
72
|
if (!res.ok) {
|
|
65
73
|
if (res.status === 404)
|
|
66
74
|
this.cachedTunnelId = null;
|
|
@@ -87,7 +95,11 @@ class TunnelClient {
|
|
|
87
95
|
if (!res.ok) {
|
|
88
96
|
throw new TunnelClientError(-1, `Failed to list connections: HTTP ${res.status}`);
|
|
89
97
|
}
|
|
90
|
-
|
|
98
|
+
try {
|
|
99
|
+
return await res.json();
|
|
100
|
+
} catch {
|
|
101
|
+
throw new Error(`Failed to parse connections response: unexpected non-JSON body`);
|
|
102
|
+
}
|
|
91
103
|
}
|
|
92
104
|
async resolveTunnelId() {
|
|
93
105
|
if (this.explicitTunnelId)
|
package/package.json
CHANGED
|
@@ -67,7 +67,15 @@ export class TunnelClient {
|
|
|
67
67
|
body: JSON.stringify({ method, params }),
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
let data: Record<string, unknown>;
|
|
71
|
+
try {
|
|
72
|
+
data = (await res.json()) as Record<string, unknown>;
|
|
73
|
+
} catch {
|
|
74
|
+
if (!res.ok) {
|
|
75
|
+
throw new TunnelClientError(-1, `HTTP ${res.status} ${res.statusText}`, undefined, false);
|
|
76
|
+
}
|
|
77
|
+
throw new Error(`Failed to parse response for ${method}: unexpected non-JSON body`);
|
|
78
|
+
}
|
|
71
79
|
|
|
72
80
|
if (!res.ok) {
|
|
73
81
|
if (res.status === 404) this.cachedTunnelId = null;
|
|
@@ -105,7 +113,11 @@ export class TunnelClient {
|
|
|
105
113
|
throw new TunnelClientError(-1, `Failed to list connections: HTTP ${res.status}`);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
|
-
|
|
116
|
+
try {
|
|
117
|
+
return (await res.json()) as Array<Record<string, unknown>>;
|
|
118
|
+
} catch {
|
|
119
|
+
throw new Error(`Failed to parse connections response: unexpected non-JSON body`);
|
|
120
|
+
}
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
async resolveTunnelId(): Promise<string> {
|