@unboundcx/sdk 2.8.5 → 2.8.6

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/index.js +57 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -153,6 +153,63 @@ class UnboundSDK extends BaseSDK {
153
153
  'buildMasterAuth is only available with the internal SDK extension. Please use: sdk.use(InternalExtension)',
154
154
  );
155
155
  }
156
+
157
+ /**
158
+ * Check SDK configuration and API connectivity
159
+ * Calls the /health endpoint to verify SDK setup
160
+ *
161
+ * @returns {Promise<Object>} Health check result with:
162
+ * - healthy: boolean - If API is reachable
163
+ * - hasAuthorization: boolean - If auth credentials were received by API
164
+ * - authType: string|null - Type of auth detected by API ('bearer', 'cookie', or 'bearer+cookie')
165
+ * - namespace: string - Current namespace
166
+ * - environment: string - 'node' or 'browser'
167
+ * - transport: string - Transport method used ('HTTP', 'WebSocket', etc.)
168
+ */
169
+ async status() {
170
+ try {
171
+ const response = await this._fetch('/health', 'GET', {
172
+ returnRawResponse: true,
173
+ });
174
+
175
+ // Parse response
176
+ let healthData;
177
+ try {
178
+ if (typeof response.json === 'function') {
179
+ healthData = await response.json();
180
+ } else if (response.body) {
181
+ healthData = typeof response.body === 'string'
182
+ ? JSON.parse(response.body)
183
+ : response.body;
184
+ } else {
185
+ healthData = {};
186
+ }
187
+ } catch (e) {
188
+ healthData = {};
189
+ }
190
+
191
+ return {
192
+ healthy: response.ok || response.status === 200,
193
+ hasAuthorization: healthData.hasAuthorization || false,
194
+ authType: healthData.authType || null,
195
+ namespace: this.namespace,
196
+ environment: this.environment,
197
+ transport: healthData.transport || 'unknown',
198
+ timestamp: healthData.timestamp,
199
+ statusCode: response.status,
200
+ };
201
+ } catch (error) {
202
+ return {
203
+ healthy: false,
204
+ hasAuthorization: false,
205
+ authType: null,
206
+ namespace: this.namespace,
207
+ environment: this.environment,
208
+ error: error.message,
209
+ statusCode: error.status || null,
210
+ };
211
+ }
212
+ }
156
213
  }
157
214
 
158
215
  // Export both the class and a factory function for convenience
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "2.8.5",
3
+ "version": "2.8.6",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",