@deepfrog/pangents-widget 2.2.0 → 2.2.2

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.
@@ -16793,7 +16793,7 @@ class EnhancedErrorHandler {
16793
16793
  // 30 seconds
16794
16794
  constructor() {
16795
16795
  __publicField(this, "errorQueue", []);
16796
- __publicField(this, "isOnline", navigator.onLine);
16796
+ __publicField(this, "isOnline", typeof navigator !== "undefined" ? navigator.onLine : true);
16797
16797
  __publicField(this, "maxQueueSize", 50);
16798
16798
  // Reduced from 100
16799
16799
  __publicField(this, "retryAttempts", 2);
@@ -16809,6 +16809,7 @@ class EnhancedErrorHandler {
16809
16809
  }
16810
16810
  // Setup event listeners for online/offline status
16811
16811
  setupEventListeners() {
16812
+ if (typeof window === "undefined") return;
16812
16813
  window.addEventListener("online", () => {
16813
16814
  this.isOnline = true;
16814
16815
  this.flushErrorQueue();
@@ -16835,10 +16836,6 @@ class EnhancedErrorHandler {
16835
16836
  console.warn("[Enhanced Error Handler] No API key provided for validation");
16836
16837
  return false;
16837
16838
  }
16838
- if (!apiKey.startsWith("pangents_wk_") || apiKey.length < 20) {
16839
- console.warn("[Enhanced Error Handler] Invalid API key format");
16840
- return false;
16841
- }
16842
16839
  return true;
16843
16840
  }
16844
16841
  // Generate error fingerprint for duplicate detection
@@ -16875,8 +16872,8 @@ class EnhancedErrorHandler {
16875
16872
  action: (context == null ? void 0 : context.action) || "Unknown",
16876
16873
  userId: context == null ? void 0 : context.userId,
16877
16874
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16878
- userAgent: navigator.userAgent,
16879
- url: window.location.href,
16875
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "server",
16876
+ url: typeof window !== "undefined" ? window.location.href : "",
16880
16877
  apiKey: (context == null ? void 0 : context.apiKey) ? context.apiKey.substring(0, 20) + "..." : void 0
16881
16878
  };
16882
16879
  const severity = this.determineSeverity(apiError);
@@ -16909,8 +16906,8 @@ class EnhancedErrorHandler {
16909
16906
  action: (context == null ? void 0 : context.action) || "Runtime",
16910
16907
  userId: context == null ? void 0 : context.userId,
16911
16908
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16912
- userAgent: navigator.userAgent,
16913
- url: window.location.href
16909
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "server",
16910
+ url: typeof window !== "undefined" ? window.location.href : ""
16914
16911
  };
16915
16912
  const errorReport = {
16916
16913
  error: apiError,
@@ -16989,9 +16986,9 @@ class EnhancedErrorHandler {
16989
16986
  await api2.post("/errors/report", {
16990
16987
  errors: errorsToSend,
16991
16988
  clientInfo: {
16992
- userAgent: navigator.userAgent,
16989
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "server",
16993
16990
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16994
- url: window.location.href,
16991
+ url: typeof window !== "undefined" ? window.location.href : "",
16995
16992
  circuitBreakerState: this.circuitBreaker.getState(),
16996
16993
  remainingRateLimit: this.rateLimiter.getRemainingRequests()
16997
16994
  }
@@ -17026,15 +17023,17 @@ class EnhancedErrorHandler {
17026
17023
  // Show user notification based on error severity
17027
17024
  showUserNotification(error, severity) {
17028
17025
  const message = this.getUserFriendlyMessage(error);
17029
- window.dispatchEvent(new CustomEvent("error:notification", {
17030
- detail: {
17031
- message,
17032
- severity,
17033
- error,
17034
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
17035
- canRetry: this.canRetryError(error)
17036
- }
17037
- }));
17026
+ if (typeof window !== "undefined") {
17027
+ window.dispatchEvent(new CustomEvent("error:notification", {
17028
+ detail: {
17029
+ message,
17030
+ severity,
17031
+ error,
17032
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
17033
+ canRetry: this.canRetryError(error)
17034
+ }
17035
+ }));
17036
+ }
17038
17037
  }
17039
17038
  // Determine if error can be retried
17040
17039
  canRetryError(error) {
@@ -28283,14 +28282,14 @@ class ApiKeyValidator {
28283
28282
  if (!this.validateApiKeyFormat(sanitized)) {
28284
28283
  return {
28285
28284
  isValid: false,
28286
- error: "Invalid API key format. Expected format: pangents_wk_[alphanumeric characters]"
28285
+ error: "Invalid API key format."
28287
28286
  };
28288
28287
  }
28289
28288
  return { isValid: true };
28290
28289
  } catch (error) {
28291
28290
  return {
28292
28291
  isValid: false,
28293
- error: error instanceof Error ? error.message : "Invalid API key"
28292
+ error: error instanceof Error ? error.message : "Invalid API key format."
28294
28293
  };
28295
28294
  }
28296
28295
  }
@@ -29345,8 +29344,11 @@ function WidgetContent() {
29345
29344
  });
29346
29345
  }
29347
29346
  };
29347
+ const prevAuthRef = useRef({});
29348
29348
  useEffect(() => {
29349
- validateKey();
29349
+ const force = prevAuthRef.current.apiKey !== apiKey || prevAuthRef.current.tenantId !== tenantId;
29350
+ validateKey(force);
29351
+ prevAuthRef.current = { apiKey, tenantId };
29350
29352
  }, [apiKey, tenantId]);
29351
29353
  const handleRetry = () => {
29352
29354
  validateKey(true);
@@ -29833,4 +29835,4 @@ export {
29833
29835
  Chatbot as C,
29834
29836
  Widget as W
29835
29837
  };
29836
- //# sourceMappingURL=widget-embed-CtD27t5y.es.js.map
29838
+ //# sourceMappingURL=widget-embed-DzLM7DN8.es.js.map