@weldsuite/helpdesk-widget-sdk 1.0.13 → 1.0.15

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/dist/index.js CHANGED
@@ -1027,11 +1027,7 @@ class SecurityManager {
1027
1027
  * Validate message origin
1028
1028
  */
1029
1029
  isOriginAllowed(origin) {
1030
- // If no allowed origins specified, only allow same origin
1031
- if (this.config.allowedOrigins?.length === 0) {
1032
- return origin === window.location.origin;
1033
- }
1034
- // Check if origin is in allowed list
1030
+ // Check if origin is in allowed list (includes same-origin and programmatically added origins)
1035
1031
  if (this.allowedOrigins.has(origin)) {
1036
1032
  return true;
1037
1033
  }
@@ -1289,6 +1285,15 @@ class MessageBroker {
1289
1285
  this.logger = logger.child('[MessageBroker]');
1290
1286
  this.iframeManager = iframeManager;
1291
1287
  this.security = new SecurityManager(config.security, this.logger);
1288
+ // Automatically trust messages from the widget's base URL
1289
+ // The iframes load from api.baseUrl, so we must accept their postMessages
1290
+ try {
1291
+ const widgetOrigin = new URL(config.api.baseUrl).origin;
1292
+ this.security.addAllowedOrigin(widgetOrigin);
1293
+ }
1294
+ catch {
1295
+ // Invalid URL, will rely on configured allowedOrigins
1296
+ }
1292
1297
  this.rateLimiter = new RateLimiter(100, 60000); // 100 messages per minute
1293
1298
  // Bind handlers once for proper cleanup
1294
1299
  this.boundHandleMessage = this.handleMessage.bind(this);
@@ -2394,7 +2399,7 @@ class StateCoordinator {
2394
2399
  }
2395
2400
  }
2396
2401
 
2397
- var version = "1.0.13";
2402
+ var version = "1.0.15";
2398
2403
  var packageJson = {
2399
2404
  version: version};
2400
2405