@ujet/websdk-headless 5.2.1 → 5.5.1

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.
package/dist/index.mjs CHANGED
@@ -726,7 +726,7 @@ const cq = new TextDecoder(), lq = (r) => {
726
726
  }, dq = (r) => r.length === 0, fq = (...r) => r.every(dq), _A = (r) => {
727
727
  const e = sq.sanitize(r, aq);
728
728
  return e.includes(oq) ? (console.warn("Suspicious content detected and removed."), "") : e;
729
- }, zme = "prod", bA = "5.2.1", tE = "https://main.api.ujet.co", Jn = {
729
+ }, zme = "prod", bA = "5.5.1", tE = "https://main.api.ujet.co", Jn = {
730
730
  companyId: "",
731
731
  tenant: "",
732
732
  trackerId: "",
@@ -1103,14 +1103,14 @@ class Cq {
1103
1103
  var c;
1104
1104
  let t = e.host;
1105
1105
  t || (e.tenant ? t = tE.replace("main.api", e.tenant) : t = tE);
1106
- const n = e.lang || "en", i = !!((c = e.cobrowse) != null && c.enabled), a = (e.bridge || "https://websdk.ujet.co/v3/bridge.html") + "?5.2.1", l = /^https:/.test(a) ? new URL(a).origin : "*", u = ["twilio_chat", "nexmo_chat"];
1106
+ const n = e.lang || "en", i = !!((c = e.cobrowse) != null && c.enabled), a = (e.bridge || "https://websdk.ujet.co/v3/bridge.html") + "?5.5.1", l = /^https:/.test(a) ? new URL(a).origin : "*", u = ["twilio_chat", "nexmo_chat"];
1107
1107
  i && u.push("cobrowse"), this.config = {
1108
1108
  host: t,
1109
1109
  lang: n,
1110
1110
  cobrowse: i,
1111
1111
  companyId: e.companyId,
1112
1112
  location: location.href,
1113
- version: e.version || "5.2.1",
1113
+ version: e.version || "5.5.1",
1114
1114
  bridge: a,
1115
1115
  bridgeOrigin: l,
1116
1116
  modules: u
@@ -2841,9 +2841,9 @@ class O6 {
2841
2841
  Re(this, "request");
2842
2842
  Re(this, "lastDapRequestId", null);
2843
2843
  // Server-issued direct-access key id, stashed from the getMenus response header
2844
- // and echoed back on the next createChat. Internal round-trip state (mirrors
2845
- // lastDapRequestId) so callers never supply it. Sticky: persists across chats
2846
- // until the next getMenus overwrites it.
2844
+ // and echoed back on the next createChat. Internal round-trip state so callers
2845
+ // never supply it. Sticky: persists across chats until the next getMenus
2846
+ // overwrites it (unlike lastDapRequestId, which is single-use).
2847
2847
  Re(this, "lastDirectAccessKeyId", null);
2848
2848
  // Monotonic token: cancelDapPolling() bumps it; a poll bails once the live
2849
2849
  // value no longer matches the value captured when its getMenus() started.
@@ -2900,26 +2900,23 @@ class O6 {
2900
2900
  async getFeatureFlags() {
2901
2901
  return (await this.get("feature_flags")).data;
2902
2902
  }
2903
- async getMenus(e, t) {
2904
- const n = this.dapPollGeneration;
2905
- let i = await this.get("menus", { type: "web_menu", lang: e, direct_access_key: t });
2906
- this.stashDapRequestId(i);
2907
- const s = this.isChatDapPending(i.data) ? i.data : null;
2908
- s && (i = await this.pollChatDap(e, Number(s.max_timeout) || 0, n));
2909
- const a = i.headers["ujet-direct-access"], l = !!a && a !== "false";
2910
- s && !l && (this.lastDapRequestId = null);
2911
- const u = {
2903
+ async getMenus(e, t, n) {
2904
+ const i = this.dapPollGeneration, s = { type: "web_menu", lang: e, direct_access_key: t };
2905
+ n != null && n.initialMessage && (s.initial_message = n.initialMessage), n != null && n.signedCustomData && (s.custom_data_signed = n.signedCustomData), n != null && n.customData && (s.custom_data_unsigned = n.customData);
2906
+ let a = await this.post("menus", s);
2907
+ this.stashDapRequestId(a), this.isChatDapPending(a.data) && (a = await this.pollChatDap(e, Number(a.data.max_timeout) || 0, i));
2908
+ const l = a.headers["ujet-direct-access"], c = {
2912
2909
  key: !!t,
2913
- user: l,
2910
+ user: !!l && l !== "false",
2914
2911
  key_id: null
2915
- }, c = i.headers["ujet-direct-access-key-id"];
2916
- if (c) {
2917
- const v = Number(c);
2918
- Number.isFinite(v) && (u.key_id = v);
2912
+ }, d = a.headers["ujet-direct-access-key-id"];
2913
+ if (d) {
2914
+ const y = Number(d);
2915
+ Number.isFinite(y) && (c.key_id = y);
2919
2916
  }
2920
- this.lastDirectAccessKeyId = u.key_id;
2921
- let d = [];
2922
- return Array.isArray(i.data) ? d = i.data : Hm.warn("unexpected /menus response shape; rendering an empty menu list"), { menus: kA(d), direct: u };
2917
+ this.lastDirectAccessKeyId = c.key_id;
2918
+ let h = [];
2919
+ return Array.isArray(a.data) ? h = a.data : Hm.warn("unexpected /menus response shape; rendering an empty menu list"), { menus: kA(h), direct: c };
2923
2920
  }
2924
2921
  stashDapRequestId(e) {
2925
2922
  const t = e.headers["ujet-dap-request-id"];
@@ -2947,7 +2944,7 @@ class O6 {
2947
2944
  const u = await this.get("menus", { type: "web_menu", lang: e, dap_request_id: i });
2948
2945
  if (!this.isChatDapPending(u.data)) return u;
2949
2946
  }
2950
- return await this.get("menus", { type: "web_menu", lang: e });
2947
+ return await this.fetchRootMenus(e);
2951
2948
  }
2952
2949
  async getAfterHourMessage(e) {
2953
2950
  return (await this.get(`audible_messages/${e}`)).data["after_hours.message"].text;
@@ -3739,8 +3736,8 @@ let Yme = class {
3739
3736
  async getProhibitedFileTypes() {
3740
3737
  return await this.methods.listFileTypes();
3741
3738
  }
3742
- async getMenus(e, t) {
3743
- return await this.methods.getMenus(t || this.lang, e);
3739
+ async getMenus(e, t, n) {
3740
+ return await this.methods.getMenus(t || this.lang, e, n);
3744
3741
  }
3745
3742
  cancelMenuPolling() {
3746
3743
  this.methods.cancelDapPolling();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ujet/websdk-headless",
3
- "version": "5.2.1",
3
+ "version": "5.5.1",
4
4
  "types": "dist/index.d.ts",
5
5
  "files": [
6
6
  "dist/index.mjs",