@brainfish-ai/web-tracker 0.0.24 → 0.0.25

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.
@@ -3456,6 +3456,28 @@ class TTLSet {
3456
3456
  return Array.from(this.items.keys());
3457
3457
  }
3458
3458
  }
3459
+ let latestIdentifyPayload = null;
3460
+ if (typeof window !== "undefined") {
3461
+ window.addEventListener("message", (event) => {
3462
+ const trustedOrigin = "https://agent.brainfi.sh";
3463
+ if (event.origin !== trustedOrigin) {
3464
+ return;
3465
+ }
3466
+ if (event.data?.type === "REQUEST_USER_IDENTITY") {
3467
+ if (latestIdentifyPayload && event.source) {
3468
+ const iframe = document.querySelector("#bf-iframe-container .trigger-iframe");
3469
+ if (!iframe || event.source !== iframe.contentWindow) {
3470
+ console.warn("BrainfishWidgetWarn: Rejected REQUEST_USER_IDENTITY from untrusted iframe source:", event.origin);
3471
+ return;
3472
+ }
3473
+ event.source.postMessage({
3474
+ type: "USER_IDENTIFY",
3475
+ payload: latestIdentifyPayload
3476
+ }, event.origin);
3477
+ }
3478
+ }
3479
+ });
3480
+ }
3459
3481
  var NudgeCTABlockActionType;
3460
3482
  (function(NudgeCTABlockActionType2) {
3461
3483
  NudgeCTABlockActionType2["OpenUrl"] = "openUrl";
@@ -3612,6 +3634,7 @@ const _TrackerSdk = class _TrackerSdk {
3612
3634
  if (payload.phone && !/^\+[1-9]\d{1,14}$/.test(payload.phone)) {
3613
3635
  console.warn("BrainfishWidgetWarn: phone should be in E.164 format (e.g., +14155552671). Providing the correct format ensures accurate user identification.");
3614
3636
  }
3637
+ latestIdentifyPayload = payload;
3615
3638
  const iframe = document.querySelector("#bf-iframe-container .trigger-iframe");
3616
3639
  if (iframe) {
3617
3640
  const sendMessage = () => {
@@ -38480,7 +38503,7 @@ function toCamelCase(str) {
38480
38503
  ($1) => $1.toUpperCase().replace("-", "").replace("_", "")
38481
38504
  );
38482
38505
  }
38483
- const VERSION = "0.0.24";
38506
+ const VERSION = "0.0.25";
38484
38507
  class Tracker extends TrackerSdk {
38485
38508
  constructor(options) {
38486
38509
  super({
Binary file