@unboundcx/sdk 1.2.5 → 1.2.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.
package/base.js CHANGED
@@ -203,14 +203,41 @@ export class BaseSDK {
203
203
  return this._httpRequest(endpoint, method, params);
204
204
  }
205
205
 
206
+ _isMultipartBody(body) {
207
+ // Check if body is FormData or multipart content
208
+ if (!body) return false;
209
+
210
+ // Browser FormData
211
+ if (typeof FormData !== 'undefined' && body instanceof FormData) {
212
+ return true;
213
+ }
214
+
215
+ // Node.js Buffer (our manual multipart construction)
216
+ if (typeof Buffer !== 'undefined' && Buffer.isBuffer(body)) {
217
+ return true;
218
+ }
219
+
220
+ // Uint8Array (fallback multipart construction)
221
+ if (body instanceof Uint8Array) {
222
+ return true;
223
+ }
224
+
225
+ // String-based multipart (check for multipart boundaries)
226
+ if (typeof body === 'string' && body.includes('Content-Disposition: form-data')) {
227
+ return true;
228
+ }
229
+
230
+ return false;
231
+ }
232
+
206
233
  async _httpRequest(endpoint, method, params = {}) {
207
234
  const { body, query, headers = {} } = params;
208
235
 
209
236
  const options = {
210
237
  method,
211
238
  headers: {
212
- // Only set Content-Type if not already provided (check both cases)
213
- ...(headers?.['Content-Type'] || headers?.['content-type']
239
+ // Smart content-type detection based on actual body content
240
+ ...(this._isMultipartBody(body) || headers?.['Content-Type'] || headers?.['content-type']
214
241
  ? {}
215
242
  : { 'Content-Type': 'application/json' }),
216
243
  ...headers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "1.2.5",
3
+ "version": "1.2.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",
@@ -163,7 +163,7 @@ export class StorageService {
163
163
 
164
164
  return {
165
165
  formData,
166
- headers: { 'content-type': '' } // Explicitly set empty content-type to prevent JSON default
166
+ headers: {} // Let browser handle content-type automatically
167
167
  };
168
168
  }
169
169