@proveanything/smartlinks 1.3.38 → 1.3.40

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.
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.3.38 | Generated: 2026-02-18T19:45:24.113Z
3
+ Version: 1.3.40 | Generated: 2026-02-18T20:09:53.593Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -468,18 +468,25 @@ export class IframeResponder {
468
468
  const path = proxyData.path.startsWith('/') ? proxyData.path.slice(1) : proxyData.path;
469
469
  // Check for cached data matches on GET requests
470
470
  if (proxyData.method === 'GET') {
471
+ console.log('[IframeResponder:Parent] 🔍 Checking cache for:', path);
471
472
  const cachedResponse = this.getCachedResponse(path);
472
473
  if (cachedResponse !== null) {
474
+ console.log('[IframeResponder:Parent] ✅ Returning cached response');
473
475
  response.data = cachedResponse;
474
476
  this.sendResponse(event, response);
475
477
  return;
476
478
  }
479
+ console.log('[IframeResponder:Parent] ❌ No cache hit, will fetch from API');
477
480
  }
478
481
  // Forward to actual API using SDK's configured baseURL
479
482
  const baseUrl = getBaseURL();
483
+ console.log('[IframeResponder:Parent] 🌍 Base URL from SDK:', baseUrl);
480
484
  if (!baseUrl) {
481
- throw new Error('SDK not initialized - call initializeApi() first');
485
+ const error = 'SDK not initialized - call initializeApi() first';
486
+ console.error('[IframeResponder:Parent] ❌', error);
487
+ throw new Error(error);
482
488
  }
489
+ const fullUrl = `${baseUrl}/${path}`;
483
490
  const fetchOptions = {
484
491
  method: proxyData.method,
485
492
  headers: proxyData.headers,
@@ -488,39 +495,70 @@ export class IframeResponder {
488
495
  fetchOptions.body = JSON.stringify(proxyData.body);
489
496
  fetchOptions.headers = Object.assign(Object.assign({}, fetchOptions.headers), { 'Content-Type': 'application/json' });
490
497
  }
491
- const fetchResponse = await fetch(`${baseUrl}/${path}`, fetchOptions);
492
- response.data = await fetchResponse.json();
498
+ console.log('[IframeResponder:Parent] 🚀 Fetching:', fullUrl, {
499
+ method: proxyData.method,
500
+ headerCount: Object.keys(fetchOptions.headers || {}).length
501
+ });
502
+ const fetchResponse = await fetch(fullUrl, fetchOptions);
503
+ console.log('[IframeResponder:Parent] 📥 Fetch response:', {
504
+ status: fetchResponse.status,
505
+ ok: fetchResponse.ok,
506
+ statusText: fetchResponse.statusText
507
+ });
508
+ const responseData = await fetchResponse.json();
509
+ console.log('[IframeResponder:Parent] 📦 Response data received, keys:', Object.keys(responseData || {}));
510
+ response.data = responseData;
493
511
  }
494
512
  catch (err) {
513
+ console.error('[IframeResponder:Parent] ❌ Proxy request error:', {
514
+ id: proxyData.id,
515
+ error: err.message,
516
+ stack: err.stack
517
+ });
495
518
  response.error = (err === null || err === void 0 ? void 0 : err.message) || 'Unknown error';
496
519
  (_c = (_b = this.options).onError) === null || _c === void 0 ? void 0 : _c.call(_b, err);
497
520
  }
521
+ console.log('[IframeResponder:Parent] 📤 Sending response back to iframe:', {
522
+ id: response.id,
523
+ hasData: !!response.data,
524
+ hasError: !!response.error
525
+ });
498
526
  this.sendResponse(event, response);
499
527
  }
500
528
  getCachedResponse(path) {
501
- // Collection request
502
- if (path.includes('/collection/') && this.cache.collection) {
503
- const match = path.match(/collection\/([^/]+)/);
504
- if (match && match[1] === this.options.collectionId) {
529
+ // App data endpoints should NOT be cached - they need fresh data from API
530
+ // These are the new separated app config endpoints
531
+ if (path.includes('/app/') && (path.includes('/data') || path.match(/\/app\/[^/]+$/))) {
532
+ console.log('[IframeResponder:Parent] 🚫 Not caching app data endpoint:', path);
533
+ return null;
534
+ }
535
+ // Collection request - ONLY match direct collection endpoint, not app config endpoints
536
+ if (this.cache.collection) {
537
+ const collectionMatch = path.match(/^public\/collection\/([^/]+)$/);
538
+ if (collectionMatch && collectionMatch[1] === this.options.collectionId) {
539
+ console.log('[IframeResponder:Parent] 📦 Cache hit: collection');
505
540
  return JSON.parse(JSON.stringify(this.cache.collection));
506
541
  }
507
542
  }
508
- // Product request
509
- if (path.includes('/product/') && this.cache.product && this.options.productId) {
510
- const match = path.match(/product\/([^/]+)/);
511
- if (match && match[1] === this.options.productId) {
543
+ // Product request - ONLY match direct product endpoint, not app config endpoints
544
+ if (this.cache.product && this.options.productId) {
545
+ const productMatch = path.match(/^public\/collection\/[^/]+\/product\/([^/]+)$/);
546
+ if (productMatch && productMatch[1] === this.options.productId) {
547
+ console.log('[IframeResponder:Parent] 📦 Cache hit: product');
512
548
  return JSON.parse(JSON.stringify(this.cache.product));
513
549
  }
514
550
  }
515
551
  // Proof request
516
- if (path.includes('/proof/') && this.cache.proof && this.options.proofId) {
517
- const match = path.match(/proof\/([^/]+)/);
518
- if (match && match[1] === this.options.proofId) {
552
+ if (this.cache.proof && this.options.proofId) {
553
+ const proofMatch = path.match(/^public\/proof\/([^/]+)$/);
554
+ if (proofMatch && proofMatch[1] === this.options.proofId) {
555
+ console.log('[IframeResponder:Parent] 📦 Cache hit: proof');
519
556
  return JSON.parse(JSON.stringify(this.cache.proof));
520
557
  }
521
558
  }
522
559
  // Account request
523
560
  if (path.includes('/account') && this.cache.user) {
561
+ console.log('[IframeResponder:Parent] 📦 Cache hit: account');
524
562
  return JSON.parse(JSON.stringify(Object.assign(Object.assign({}, this.cache.user.accountData), { uid: this.cache.user.uid, email: this.cache.user.email, displayName: this.cache.user.displayName })));
525
563
  }
526
564
  return null;
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.3.38 | Generated: 2026-02-18T19:45:24.113Z
3
+ Version: 1.3.40 | Generated: 2026-02-18T20:09:53.593Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.3.38",
3
+ "version": "1.3.40",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",