@proveanything/smartlinks 1.3.41 → 1.3.42

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.41 | Generated: 2026-02-18T20:14:53.508Z
3
+ Version: 1.3.42 | Generated: 2026-02-19T07:40:37.858Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -1530,6 +1530,7 @@ interface AppConfig {
1530
1530
  proof: boolean; // use at the proof level
1531
1531
  widget: boolean; // has a widget component available
1532
1532
  }
1533
+ directComponent: boolean; // Whether the app provides a direct React component for embedding (instead of using an iframe)
1533
1534
  [key: string]: any
1534
1535
  }
1535
1536
  ```
package/dist/http.js CHANGED
@@ -173,13 +173,6 @@ export function initializeApi(options) {
173
173
  apiKey = options.apiKey;
174
174
  bearerToken = options.bearerToken;
175
175
  proxyMode = !!options.proxyMode;
176
- console.log('[SmartLinks] initializeApi called', {
177
- baseURL,
178
- proxyMode,
179
- hasApiKey: !!apiKey,
180
- hasBearerToken: !!bearerToken,
181
- isIframe: typeof window !== 'undefined' && window.parent !== window
182
- });
183
176
  // Auto-enable ngrok skip header if domain contains .ngrok.io and user did not explicitly set the flag.
184
177
  // Infer ngrok usage from common domains (.ngrok.io or .ngrok-free.dev)
185
178
  const inferredNgrok = /(\.ngrok\.io|\.ngrok-free\.dev)(\b|\/)/i.test(baseURL);
@@ -233,33 +226,19 @@ function ensureProxyListener() {
233
226
  return;
234
227
  window.addEventListener("message", (event) => {
235
228
  const msg = event.data;
236
- // Log all messages to help debug
237
- if (msg && msg._smartlinksProxyResponse) {
238
- console.log('[SmartLinks:Child] 📨 Received proxy response from parent', {
239
- id: msg.id,
240
- hasError: !!msg.error,
241
- hasData: !!msg.data,
242
- origin: event.origin
243
- });
244
- }
245
229
  if (!msg || !msg._smartlinksProxyResponse || !msg.id)
246
230
  return;
247
231
  logDebug('[smartlinks] proxy:response', { id: msg.id, ok: !msg.error, keys: Object.keys(msg) });
248
232
  const pending = proxyPending[msg.id];
249
233
  if (pending) {
250
234
  if (msg.error) {
251
- console.error('[SmartLinks:Child] ❌ Proxy request failed', { id: msg.id, error: msg.error });
252
235
  pending.reject(new Error(msg.error));
253
236
  }
254
237
  else {
255
- console.log('[SmartLinks:Child] ✅ Proxy request succeeded', { id: msg.id });
256
238
  pending.resolve(msg.data);
257
239
  }
258
240
  delete proxyPending[msg.id];
259
241
  }
260
- else {
261
- console.warn('[SmartLinks:Child] ⚠️ Received response for unknown request', { id: msg.id });
262
- }
263
242
  });
264
243
  window._smartlinksProxyListener = true;
265
244
  }
@@ -287,25 +266,10 @@ async function proxyRequest(method, path, body, headers, options) {
287
266
  headers,
288
267
  options,
289
268
  };
290
- console.log('[SmartLinks:Child] 🚀 Sending proxy request to parent', {
291
- id,
292
- method,
293
- path,
294
- hasBody: !!body,
295
- bodyType: body ? body.constructor.name : 'none',
296
- headerCount: headers ? Object.keys(headers).length : 0
297
- });
298
269
  logDebug('[smartlinks] proxy:postMessage', { id, method, path, headers: headers ? redactHeaders(headers) : undefined, hasBody: !!body });
299
270
  return new Promise((resolve, reject) => {
300
271
  proxyPending[id] = { resolve, reject };
301
- try {
302
- window.parent.postMessage(msg, "*");
303
- console.log('[SmartLinks:Child] ✅ postMessage sent successfully', { id });
304
- }
305
- catch (error) {
306
- console.error('[SmartLinks:Child] ❌ postMessage failed', { id, error });
307
- throw error;
308
- }
272
+ window.parent.postMessage(msg, "*");
309
273
  // Optionally: add a timeout here to reject if no response
310
274
  });
311
275
  }
@@ -240,65 +240,34 @@ export class IframeResponder {
240
240
  // Message Handling
241
241
  // ===========================================================================
242
242
  async handleMessage(event) {
243
- var _a, _b;
244
- // Log all received messages for debugging
245
- const data = event.data;
246
- if (data && typeof data === 'object') {
247
- console.log('[IframeResponder:Parent] 📨 Received message from iframe', {
248
- type: data.type || (data._smartlinksProxyRequest ? 'proxy-request' : 'unknown'),
249
- hasId: !!data.id,
250
- isProxyRequest: !!data._smartlinksProxyRequest,
251
- isCustomProxyRequest: !!data._smartlinksCustomProxyRequest,
252
- isStandardMessage: !!data._smartlinksIframeMessage,
253
- isRouteChange: data.type === 'smartlinks-route-change',
254
- origin: event.origin,
255
- source: event.source === ((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) ? 'our-iframe' : 'other'
256
- });
257
- }
258
243
  // Validate source is our iframe
259
244
  if (!this.iframe || event.source !== this.iframe.contentWindow) {
260
- console.log('[IframeResponder:Parent] ⚠️ Ignoring message - not from our iframe', {
261
- hasIframe: !!this.iframe,
262
- isCorrectSource: event.source === ((_b = this.iframe) === null || _b === void 0 ? void 0 : _b.contentWindow)
263
- });
264
245
  return;
265
246
  }
247
+ const data = event.data;
266
248
  if (!data || typeof data !== 'object') {
267
- console.log('[IframeResponder:Parent] ⚠️ Ignoring message - invalid data');
268
249
  return;
269
250
  }
270
251
  // Route changes (deep linking)
271
252
  if (data.type === 'smartlinks-route-change') {
272
- console.log('[IframeResponder:Parent] 🔀 Handling route change');
273
253
  this.handleRouteChange(data);
274
254
  return;
275
255
  }
276
256
  // Standardized iframe messages
277
257
  if (data._smartlinksIframeMessage) {
278
- console.log('[IframeResponder:Parent] 📋 Handling standard message');
279
258
  await this.handleStandardMessage(data, event);
280
259
  return;
281
260
  }
282
261
  // File upload proxy
283
262
  if (data._smartlinksProxyUpload) {
284
- console.log('[IframeResponder:Parent] 📤 Handling upload proxy');
285
263
  await this.handleUpload(data, event);
286
264
  return;
287
265
  }
288
266
  // API proxy requests
289
267
  if (data._smartlinksProxyRequest || data._smartlinksCustomProxyRequest) {
290
- console.log('[IframeResponder:Parent] 🌐 Handling API proxy request', {
291
- id: data.id,
292
- method: data.method,
293
- path: data.path,
294
- isCustom: !!data._smartlinksCustomProxyRequest
295
- });
296
268
  await this.handleProxyRequest(data, event);
297
269
  return;
298
270
  }
299
- console.log('[IframeResponder:Parent] ⚠️ Unhandled message type', {
300
- keys: Object.keys(data)
301
- });
302
271
  }
303
272
  // ===========================================================================
304
273
  // Route Changes (Deep Linking)
@@ -404,17 +373,12 @@ export class IframeResponder {
404
373
  // ===========================================================================
405
374
  async handleProxyRequest(data, event) {
406
375
  var _a, _b, _c;
407
- console.log('[IframeResponder:Parent] 🔧 handleProxyRequest called', {
408
- id: data.id,
409
- hasCustomFlag: '_smartlinksCustomProxyRequest' in data
410
- });
411
376
  const response = {
412
377
  _smartlinksProxyResponse: true,
413
378
  id: data.id,
414
379
  };
415
380
  // Handle custom proxy requests (redirects, etc.)
416
381
  if ('_smartlinksCustomProxyRequest' in data && data._smartlinksCustomProxyRequest) {
417
- console.log('[IframeResponder:Parent] 🔄 Handling custom proxy request', { request: data.request });
418
382
  if (data.request === 'REDIRECT') {
419
383
  const url = (_a = data.params) === null || _a === void 0 ? void 0 : _a.url;
420
384
  if (url) {
@@ -426,32 +390,21 @@ export class IframeResponder {
426
390
  }
427
391
  }
428
392
  const proxyData = data;
429
- console.log('[IframeResponder:Parent] 🌐 Processing API proxy request', {
430
- id: proxyData.id,
431
- method: proxyData.method,
432
- path: proxyData.path
433
- });
434
393
  try {
435
394
  const path = proxyData.path.startsWith('/') ? proxyData.path.slice(1) : proxyData.path;
436
395
  // Check for cached data matches on GET requests
437
396
  if (proxyData.method === 'GET') {
438
- console.log('[IframeResponder:Parent] 🔍 Checking cache for:', path);
439
397
  const cachedResponse = this.getCachedResponse(path);
440
398
  if (cachedResponse !== null) {
441
- console.log('[IframeResponder:Parent] ✅ Returning cached response');
442
399
  response.data = cachedResponse;
443
400
  this.sendResponse(event, response);
444
401
  return;
445
402
  }
446
- console.log('[IframeResponder:Parent] ❌ No cache hit, will fetch from API');
447
403
  }
448
404
  // Forward to actual API using SDK's configured baseURL
449
405
  const baseUrl = getBaseURL();
450
- console.log('[IframeResponder:Parent] 🌍 Base URL from SDK:', baseUrl);
451
406
  if (!baseUrl) {
452
- const error = 'SDK not initialized - call initializeApi() first';
453
- console.error('[IframeResponder:Parent] ❌', error);
454
- throw new Error(error);
407
+ throw new Error('SDK not initialized - call initializeApi() first');
455
408
  }
456
409
  const fullUrl = `${baseUrl}/${path}`;
457
410
  const fetchOptions = {
@@ -462,48 +415,27 @@ export class IframeResponder {
462
415
  fetchOptions.body = JSON.stringify(proxyData.body);
463
416
  fetchOptions.headers = Object.assign(Object.assign({}, fetchOptions.headers), { 'Content-Type': 'application/json' });
464
417
  }
465
- console.log('[IframeResponder:Parent] 🚀 Fetching:', fullUrl, {
466
- method: proxyData.method,
467
- headerCount: Object.keys(fetchOptions.headers || {}).length
468
- });
469
418
  const fetchResponse = await fetch(fullUrl, fetchOptions);
470
- console.log('[IframeResponder:Parent] 📥 Fetch response:', {
471
- status: fetchResponse.status,
472
- ok: fetchResponse.ok,
473
- statusText: fetchResponse.statusText
474
- });
475
419
  const responseData = await fetchResponse.json();
476
- console.log('[IframeResponder:Parent] 📦 Response data received, keys:', Object.keys(responseData || {}));
477
420
  response.data = responseData;
478
421
  }
479
422
  catch (err) {
480
- console.error('[IframeResponder:Parent] Proxy request error:', {
481
- id: proxyData.id,
482
- error: err.message,
483
- stack: err.stack
484
- });
423
+ console.error('[IframeResponder] Proxy request error:', err);
485
424
  response.error = (err === null || err === void 0 ? void 0 : err.message) || 'Unknown error';
486
425
  (_c = (_b = this.options).onError) === null || _c === void 0 ? void 0 : _c.call(_b, err);
487
426
  }
488
- console.log('[IframeResponder:Parent] 📤 Sending response back to iframe:', {
489
- id: response.id,
490
- hasData: !!response.data,
491
- hasError: !!response.error
492
- });
493
427
  this.sendResponse(event, response);
494
428
  }
495
429
  getCachedResponse(path) {
496
430
  // App data endpoints should NOT be cached - they need fresh data from API
497
431
  // These are the new separated app config endpoints
498
432
  if (path.includes('/app/') && (path.includes('/data') || path.match(/\/app\/[^/]+$/))) {
499
- console.log('[IframeResponder:Parent] 🚫 Not caching app data endpoint:', path);
500
433
  return null;
501
434
  }
502
435
  // Collection request - ONLY match direct collection endpoint, not app config endpoints
503
436
  if (this.cache.collection) {
504
437
  const collectionMatch = path.match(/^public\/collection\/([^/]+)$/);
505
438
  if (collectionMatch && collectionMatch[1] === this.options.collectionId) {
506
- console.log('[IframeResponder:Parent] 📦 Cache hit: collection');
507
439
  return JSON.parse(JSON.stringify(this.cache.collection));
508
440
  }
509
441
  }
@@ -511,7 +443,6 @@ export class IframeResponder {
511
443
  if (this.cache.product && this.options.productId) {
512
444
  const productMatch = path.match(/^public\/collection\/[^/]+\/product\/([^/]+)$/);
513
445
  if (productMatch && productMatch[1] === this.options.productId) {
514
- console.log('[IframeResponder:Parent] 📦 Cache hit: product');
515
446
  return JSON.parse(JSON.stringify(this.cache.product));
516
447
  }
517
448
  }
@@ -519,13 +450,11 @@ export class IframeResponder {
519
450
  if (this.cache.proof && this.options.proofId) {
520
451
  const proofMatch = path.match(/^public\/proof\/([^/]+)$/);
521
452
  if (proofMatch && proofMatch[1] === this.options.proofId) {
522
- console.log('[IframeResponder:Parent] 📦 Cache hit: proof');
523
453
  return JSON.parse(JSON.stringify(this.cache.proof));
524
454
  }
525
455
  }
526
456
  // Account request
527
457
  if (path.includes('/account') && this.cache.user) {
528
- console.log('[IframeResponder:Parent] 📦 Cache hit: account');
529
458
  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 })));
530
459
  }
531
460
  return null;
@@ -104,6 +104,7 @@ export interface AppConfig {
104
104
  proof: boolean;
105
105
  widget: boolean;
106
106
  };
107
+ directComponent: boolean;
107
108
  [key: string]: any;
108
109
  }
109
110
  /**
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.3.41 | Generated: 2026-02-18T20:14:53.508Z
3
+ Version: 1.3.42 | Generated: 2026-02-19T07:40:37.858Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -1530,6 +1530,7 @@ interface AppConfig {
1530
1530
  proof: boolean; // use at the proof level
1531
1531
  widget: boolean; // has a widget component available
1532
1532
  }
1533
+ directComponent: boolean; // Whether the app provides a direct React component for embedding (instead of using an iframe)
1533
1534
  [key: string]: any
1534
1535
  }
1535
1536
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.3.41",
3
+ "version": "1.3.42",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",