callix-dialer-widget 1.3.9 → 1.3.11

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.
@@ -55402,12 +55402,43 @@ function formatDuration(seconds) {
55402
55402
  return `${mins}:${secs.toString().padStart(2, "0")}`;
55403
55403
  }
55404
55404
  const API_BASE_URL = typeof window !== "undefined" ? window.__CALLIX_API_BASE_URL__ || "https://callix-zeta.vercel.app" : "https://callix-zeta.vercel.app";
55405
+ function getSessionToken() {
55406
+ if (typeof window === "undefined") return null;
55407
+ const possibleKeys = [
55408
+ "callix_dialer_session_token",
55409
+ "callix_session_token",
55410
+ "sessionToken"
55411
+ ];
55412
+ for (const key of possibleKeys) {
55413
+ const value = localStorage.getItem(key);
55414
+ if (value) {
55415
+ try {
55416
+ const parsed = JSON.parse(value);
55417
+ return parsed.token || parsed.sessionToken || value;
55418
+ } catch {
55419
+ return value;
55420
+ }
55421
+ }
55422
+ }
55423
+ return null;
55424
+ }
55425
+ function getAuthHeaders() {
55426
+ const token = getSessionToken();
55427
+ const headers = {
55428
+ "Content-Type": "application/json"
55429
+ };
55430
+ if (token) {
55431
+ headers["x-session-token"] = token;
55432
+ }
55433
+ return headers;
55434
+ }
55405
55435
  async function getCampaignConfig(contactId) {
55406
55436
  const url = `${API_BASE_URL}/api/campaign-config/${contactId}`;
55407
55437
  const response = await fetch(url, {
55408
55438
  method: "GET",
55409
- credentials: "include"
55410
- // Usar 'include' para cross-origin
55439
+ headers: getAuthHeaders(),
55440
+ credentials: "omit"
55441
+ // API usa localStorage, não cookies
55411
55442
  });
55412
55443
  if (!response.ok) {
55413
55444
  const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
@@ -55420,7 +55451,8 @@ async function getCodeToNameMapping(campaignModelId) {
55420
55451
  const url = `${API_BASE_URL}/api/campaign-fields/${campaignModelId}`;
55421
55452
  const response = await fetch(url, {
55422
55453
  method: "GET",
55423
- credentials: "include"
55454
+ headers: getAuthHeaders(),
55455
+ credentials: "omit"
55424
55456
  });
55425
55457
  if (!response.ok) {
55426
55458
  const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
@@ -55433,7 +55465,8 @@ async function getContactValues(contactId) {
55433
55465
  const url = `${API_BASE_URL}/api/campaign-contact/${contactId}`;
55434
55466
  const response = await fetch(url, {
55435
55467
  method: "GET",
55436
- credentials: "include"
55468
+ headers: getAuthHeaders(),
55469
+ credentials: "omit"
55437
55470
  });
55438
55471
  if (!response.ok) {
55439
55472
  const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));