@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.
@@ -1025,11 +1025,7 @@ class SecurityManager {
1025
1025
  * Validate message origin
1026
1026
  */
1027
1027
  isOriginAllowed(origin) {
1028
- // If no allowed origins specified, only allow same origin
1029
- if (this.config.allowedOrigins?.length === 0) {
1030
- return origin === window.location.origin;
1031
- }
1032
- // Check if origin is in allowed list
1028
+ // Check if origin is in allowed list (includes same-origin and programmatically added origins)
1033
1029
  if (this.allowedOrigins.has(origin)) {
1034
1030
  return true;
1035
1031
  }
@@ -1248,6 +1244,15 @@ class MessageBroker {
1248
1244
  this.logger = logger.child('[MessageBroker]');
1249
1245
  this.iframeManager = iframeManager;
1250
1246
  this.security = new SecurityManager(config.security, this.logger);
1247
+ // Automatically trust messages from the widget's base URL
1248
+ // The iframes load from api.baseUrl, so we must accept their postMessages
1249
+ try {
1250
+ const widgetOrigin = new URL(config.api.baseUrl).origin;
1251
+ this.security.addAllowedOrigin(widgetOrigin);
1252
+ }
1253
+ catch {
1254
+ // Invalid URL, will rely on configured allowedOrigins
1255
+ }
1251
1256
  this.rateLimiter = new RateLimiter(100, 60000); // 100 messages per minute
1252
1257
  // Bind handlers once for proper cleanup
1253
1258
  this.boundHandleMessage = this.handleMessage.bind(this);
@@ -2183,7 +2188,7 @@ class StateCoordinator {
2183
2188
  }
2184
2189
  }
2185
2190
 
2186
- var version = "1.0.13";
2191
+ var version = "1.0.15";
2187
2192
  var packageJson = {
2188
2193
  version: version};
2189
2194