bytex-sdk 1.7.3 → 1.7.4

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 +17 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -363,11 +363,27 @@ export class BytexCloud {
363
363
  let url = `${this.workerUrl}?action=view&key=${this.apiKey}&file=${encodeURIComponent(streamName)}`;
364
364
  if (password) url += `&password=${encodeURIComponent(password)}`;
365
365
 
366
- const res = await fetch(url);
366
+ const { data: { session } } = await this.supabase.auth.getSession();
367
+ const res = await fetch(url, {
368
+ headers: {
369
+ 'Authorization': `Bearer ${session?.access_token || ''}`
370
+ }
371
+ });
367
372
  if (!res.ok) throw new Error(`Download failed: ${res.status}`);
368
373
  return await res.blob();
369
374
  }
370
375
 
376
+ /**
377
+ * Helper to download JSON data directly from cloud.
378
+ * @param {string} name
379
+ * @returns {object}
380
+ */
381
+ async downloadData(name) {
382
+ const blob = await this.download(name);
383
+ const text = await blob.text();
384
+ return JSON.parse(text);
385
+ }
386
+
371
387
  /**
372
388
  * Get the streaming URL for a media file (video/audio).
373
389
  * Supports precision seeking with range requests.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bytex-sdk",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {