callix-dialer-widget 1.3.13 → 1.3.14

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.
@@ -52831,11 +52831,44 @@ if (!globalTwind.__twindInitialized) {
52831
52831
  setup(config);
52832
52832
  globalTwind.__twindInitialized = true;
52833
52833
  }
52834
+ const API_BASE_URL$1 = typeof window !== "undefined" ? window.__CALLIX_API_BASE_URL__ || (window.location.origin.includes("localhost") ? window.location.origin : "https://callix-zeta.vercel.app") : "";
52835
+ function getSessionToken$1() {
52836
+ if (typeof window === "undefined") return null;
52837
+ const possibleKeys = [
52838
+ "callix_dialer_session_token",
52839
+ "callix_session_token",
52840
+ "sessionToken"
52841
+ ];
52842
+ for (const key of possibleKeys) {
52843
+ const value = localStorage.getItem(key);
52844
+ if (value) {
52845
+ try {
52846
+ const parsed = JSON.parse(value);
52847
+ return parsed.token || parsed.sessionToken || value;
52848
+ } catch {
52849
+ return value;
52850
+ }
52851
+ }
52852
+ }
52853
+ return null;
52854
+ }
52855
+ function getAuthHeaders$1() {
52856
+ const token = getSessionToken$1();
52857
+ const headers = {
52858
+ "Content-Type": "application/json"
52859
+ };
52860
+ if (token) {
52861
+ headers["x-session-token"] = token;
52862
+ }
52863
+ return headers;
52864
+ }
52834
52865
  async function getCampaignConfig$1(contactId) {
52835
- const url = `/api/campaign-config/${contactId}`;
52866
+ const url = `${API_BASE_URL$1}/api/campaign-config/${contactId}`;
52836
52867
  const response = await fetch(url, {
52837
52868
  method: "GET",
52838
- credentials: "same-origin"
52869
+ headers: getAuthHeaders$1(),
52870
+ credentials: "omit"
52871
+ // API usa localStorage, não cookies
52839
52872
  });
52840
52873
  if (!response.ok) {
52841
52874
  const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
@@ -52845,10 +52878,11 @@ async function getCampaignConfig$1(contactId) {
52845
52878
  return json;
52846
52879
  }
52847
52880
  async function getCodeToNameMapping$1(campaignModelId) {
52848
- const url = `/api/campaign-fields/${campaignModelId}`;
52881
+ const url = `${API_BASE_URL$1}/api/campaign-fields/${campaignModelId}`;
52849
52882
  const response = await fetch(url, {
52850
52883
  method: "GET",
52851
- credentials: "same-origin"
52884
+ headers: getAuthHeaders$1(),
52885
+ credentials: "omit"
52852
52886
  });
52853
52887
  if (!response.ok) {
52854
52888
  const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
@@ -52858,10 +52892,11 @@ async function getCodeToNameMapping$1(campaignModelId) {
52858
52892
  return json;
52859
52893
  }
52860
52894
  async function getContactValues$1(contactId) {
52861
- const url = `/api/campaign-contact/${contactId}`;
52895
+ const url = `${API_BASE_URL$1}/api/campaign-contact/${contactId}`;
52862
52896
  const response = await fetch(url, {
52863
52897
  method: "GET",
52864
- credentials: "same-origin"
52898
+ headers: getAuthHeaders$1(),
52899
+ credentials: "omit"
52865
52900
  });
52866
52901
  if (!response.ok) {
52867
52902
  const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));