@proveanything/smartlinks 1.3.39 → 1.3.41

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.39 | Generated: 2026-02-18T19:54:44.075Z
3
+ Version: 1.3.41 | Generated: 2026-02-18T20:14:53.508Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -33,7 +33,6 @@ import { getBaseURL } from './http';
33
33
  */
34
34
  export class IframeResponder {
35
35
  constructor(options) {
36
- var _a;
37
36
  this.iframe = null;
38
37
  this.uploads = new Map();
39
38
  this.isInitialLoad = true;
@@ -41,17 +40,6 @@ export class IframeResponder {
41
40
  this.resizeHandler = null;
42
41
  this.appUrl = null;
43
42
  this.resolveReady = null;
44
- console.log('[IframeResponder:Parent] 🏗️ Constructor called', {
45
- collectionId: options.collectionId,
46
- appId: options.appId,
47
- productId: options.productId,
48
- hasCache: !!options.cache,
49
- hasCachedApps: !!((_a = options.cache) === null || _a === void 0 ? void 0 : _a.apps),
50
- });
51
- console.log('[IframeResponder:Parent] SDK version check:', {
52
- hasCache: typeof cache !== 'undefined',
53
- hasCacheGetOrFetch: typeof (cache === null || cache === void 0 ? void 0 : cache.getOrFetch) === 'function',
54
- });
55
43
  this.options = options;
56
44
  this.cache = options.cache || {};
57
45
  // Create ready promise
@@ -62,7 +50,6 @@ export class IframeResponder {
62
50
  this.resolveAppUrl()
63
51
  .then(() => {
64
52
  var _a;
65
- console.log('[IframeResponder] App URL resolved successfully:', this.appUrl);
66
53
  (_a = this.resolveReady) === null || _a === void 0 ? void 0 : _a.call(this);
67
54
  })
68
55
  .catch((err) => {
@@ -78,20 +65,16 @@ export class IframeResponder {
78
65
  * Returns the src URL to set on the iframe.
79
66
  */
80
67
  async attach(iframe) {
81
- console.log('[IframeResponder:Parent] 🔗 attach() called, waiting for ready...');
82
68
  await this.ready;
83
- console.log('[IframeResponder:Parent] ✅ Ready resolved, appUrl:', this.appUrl);
84
69
  this.iframe = iframe;
85
70
  // Set up message listener
86
71
  this.messageHandler = this.handleMessage.bind(this);
87
72
  window.addEventListener('message', this.messageHandler);
88
- console.log('[IframeResponder:Parent] 👂 Message listener attached to window');
89
73
  // Set up resize listener for viewport-based calculations
90
74
  this.resizeHandler = this.calculateViewportHeight.bind(this);
91
75
  window.addEventListener('resize', this.resizeHandler);
92
76
  window.addEventListener('orientationchange', this.resizeHandler);
93
77
  const src = this.buildIframeSrc();
94
- console.log('[IframeResponder:Parent] 🎯 Built iframe src:', src);
95
78
  return src;
96
79
  }
97
80
  /**
@@ -121,42 +104,30 @@ export class IframeResponder {
121
104
  // ===========================================================================
122
105
  async resolveAppUrl() {
123
106
  var _a, _b;
124
- console.log('[IframeResponder] resolveAppUrl started');
125
107
  // Use explicit override if provided
126
108
  if (this.options.appUrl) {
127
109
  this.appUrl = this.options.appUrl;
128
- console.log('[IframeResponder] Using override URL:', this.appUrl);
129
110
  return;
130
111
  }
131
112
  // Check pre-populated cache
132
113
  const cachedApps = this.cache.apps;
133
114
  if (cachedApps) {
134
- console.log('[IframeResponder] Found cached apps:', cachedApps.length);
135
115
  const app = cachedApps.find(a => a.id === this.options.appId);
136
116
  if (app) {
137
117
  this.appUrl = this.getVersionUrl(app);
138
- console.log('[IframeResponder] Using cached app URL:', this.appUrl);
139
118
  return;
140
119
  }
141
- console.log('[IframeResponder] App not found in cache, fetching from API');
142
- }
143
- else {
144
- console.log('[IframeResponder] No cached apps, fetching from API');
145
120
  }
146
121
  // Fetch from API with caching
147
122
  try {
148
- console.log('[IframeResponder] Calling cache.getOrFetch for apps');
149
123
  const appsConfig = await cache.getOrFetch(`apps:${this.options.collectionId}`, () => collection.getAppsConfig(this.options.collectionId), { ttl: 5 * 60 * 1000, storage: 'session' });
150
- console.log('[IframeResponder] Got appsConfig from API:', appsConfig);
151
124
  const apps = appsConfig.apps;
152
- console.log('[IframeResponder] Extracted apps array:', apps === null || apps === void 0 ? void 0 : apps.length, apps);
153
125
  const app = apps.find(a => a.id === this.options.appId);
154
126
  if (!app) {
155
127
  console.error('[IframeResponder] App not found:', this.options.appId, 'Available:', apps.map(a => a.id));
156
128
  throw new Error(`App "${this.options.appId}" not found in collection "${this.options.collectionId}"`);
157
129
  }
158
130
  this.appUrl = this.getVersionUrl(app);
159
- console.log('[IframeResponder] Resolved app URL:', this.appUrl);
160
131
  }
161
132
  catch (err) {
162
133
  console.error('[IframeResponder] resolveAppUrl error:', err);
@@ -176,9 +147,7 @@ export class IframeResponder {
176
147
  // ===========================================================================
177
148
  buildIframeSrc() {
178
149
  var _a, _b;
179
- console.log('[IframeResponder] buildIframeSrc called, appUrl:', this.appUrl);
180
150
  if (!this.appUrl) {
181
- console.error('[IframeResponder] Cannot build src - appUrl is null!');
182
151
  throw new Error('App URL not resolved');
183
152
  }
184
153
  const params = new URLSearchParams();
@@ -222,7 +191,6 @@ export class IframeResponder {
222
191
  let finalUrl = this.appUrl;
223
192
  // Check if this URL uses hash routing (has a # in it)
224
193
  const hasHash = finalUrl.includes('#');
225
- console.log('[IframeResponder] URL has hash routing:', hasHash);
226
194
  if (hasHash) {
227
195
  // Hash-routed app - build params into the hash portion
228
196
  const [baseWithHash, existingQuery = ''] = finalUrl.split('?');
@@ -251,7 +219,6 @@ export class IframeResponder {
251
219
  params.forEach((value, key) => url.searchParams.set(key, value));
252
220
  finalUrl = url.toString();
253
221
  }
254
- console.log('[IframeResponder] Final iframe URL:', finalUrl);
255
222
  return finalUrl;
256
223
  }
257
224
  // ===========================================================================
@@ -526,29 +493,39 @@ export class IframeResponder {
526
493
  this.sendResponse(event, response);
527
494
  }
528
495
  getCachedResponse(path) {
529
- // Collection request
530
- if (path.includes('/collection/') && this.cache.collection) {
531
- const match = path.match(/collection\/([^/]+)/);
532
- if (match && match[1] === this.options.collectionId) {
496
+ // App data endpoints should NOT be cached - they need fresh data from API
497
+ // These are the new separated app config endpoints
498
+ if (path.includes('/app/') && (path.includes('/data') || path.match(/\/app\/[^/]+$/))) {
499
+ console.log('[IframeResponder:Parent] 🚫 Not caching app data endpoint:', path);
500
+ return null;
501
+ }
502
+ // Collection request - ONLY match direct collection endpoint, not app config endpoints
503
+ if (this.cache.collection) {
504
+ const collectionMatch = path.match(/^public\/collection\/([^/]+)$/);
505
+ if (collectionMatch && collectionMatch[1] === this.options.collectionId) {
506
+ console.log('[IframeResponder:Parent] 📦 Cache hit: collection');
533
507
  return JSON.parse(JSON.stringify(this.cache.collection));
534
508
  }
535
509
  }
536
- // Product request
537
- if (path.includes('/product/') && this.cache.product && this.options.productId) {
538
- const match = path.match(/product\/([^/]+)/);
539
- if (match && match[1] === this.options.productId) {
510
+ // Product request - ONLY match direct product endpoint, not app config endpoints
511
+ if (this.cache.product && this.options.productId) {
512
+ const productMatch = path.match(/^public\/collection\/[^/]+\/product\/([^/]+)$/);
513
+ if (productMatch && productMatch[1] === this.options.productId) {
514
+ console.log('[IframeResponder:Parent] 📦 Cache hit: product');
540
515
  return JSON.parse(JSON.stringify(this.cache.product));
541
516
  }
542
517
  }
543
518
  // Proof request
544
- if (path.includes('/proof/') && this.cache.proof && this.options.proofId) {
545
- const match = path.match(/proof\/([^/]+)/);
546
- if (match && match[1] === this.options.proofId) {
519
+ if (this.cache.proof && this.options.proofId) {
520
+ const proofMatch = path.match(/^public\/proof\/([^/]+)$/);
521
+ if (proofMatch && proofMatch[1] === this.options.proofId) {
522
+ console.log('[IframeResponder:Parent] 📦 Cache hit: proof');
547
523
  return JSON.parse(JSON.stringify(this.cache.proof));
548
524
  }
549
525
  }
550
526
  // Account request
551
527
  if (path.includes('/account') && this.cache.user) {
528
+ console.log('[IframeResponder:Parent] 📦 Cache hit: account');
552
529
  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 })));
553
530
  }
554
531
  return null;
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.3.39 | Generated: 2026-02-18T19:54:44.075Z
3
+ Version: 1.3.41 | Generated: 2026-02-18T20:14:53.508Z
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.39",
3
+ "version": "1.3.41",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",