@talkjs/core 1.8.1 → 1.8.3

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.
@@ -378,9 +378,13 @@ class C {
378
378
  }
379
379
  renewSession() {
380
380
  return __async(this, null, function* () {
381
- const e2 = yield this.authProvider.getToken().catch(() => {
382
- });
383
- if (!e2) return;
381
+ let e2;
382
+ try {
383
+ const t3 = this.authProvider.getCachedToken();
384
+ e2 = t3 || (yield this.authProvider.getToken());
385
+ } catch (e3) {
386
+ return;
387
+ }
384
388
  const t2 = yield this.connection.call({ method: "POST", path: ["session", "renew"], data: { token: e2 }, headers: {} });
385
389
  if (!t2.ok && "client" === t2.where) return;
386
390
  const s2 = t2.value;
@@ -399,7 +403,7 @@ class C {
399
403
  });
400
404
  }
401
405
  }
402
- class I {
406
+ class T {
403
407
  constructor(e2, t2, s2) {
404
408
  this.handlers = s2, this.stateMachine = new i("StopStartConnection", ["STOPPED", "WAITING_FOR_WS", "READY", "TERMINATED"], { unexpectedDisconnect: { from: ["READY"], to: "WAITING_FOR_WS", afterTransition: () => {
405
409
  this.inactivityTimer.stop(), this.handlers.onNotReady();
@@ -452,7 +456,7 @@ class I {
452
456
  logTrace(e2, t2, s2) {
453
457
  }
454
458
  }
455
- class T {
459
+ class I {
456
460
  constructor(e2, t2, s2) {
457
461
  this.handlers = s2, this.stateMachine = new i("QueuedConnection", ["NOT_READY", "PROCESSING_QUEUE", "READY", "TERMINATED"], { processQueue: { from: ["NOT_READY"], to: "PROCESSING_QUEUE", afterTransition: () => {
458
462
  this.sendQueuedCalls();
@@ -467,7 +471,7 @@ class T {
467
471
  e3 == null ? void 0 : e3.clientErr("SESSION_DESTROYED");
468
472
  }
469
473
  this.connection.destroy();
470
- } } }), this.subscribeQueue = {}, this.callQueue = [], this.connection = new I(e2, t2, { onUpstreamRestarting: () => {
474
+ } } }), this.subscribeQueue = {}, this.callQueue = [], this.connection = new T(e2, t2, { onUpstreamRestarting: () => {
471
475
  this.handlers.onUpstreamRestarting();
472
476
  }, onReady: () => {
473
477
  this.stateMachine.transition("processQueue");
@@ -669,7 +673,7 @@ class j extends O {
669
673
  }
670
674
  class $ {
671
675
  constructor(e2, t2, s2) {
672
- this.pendingBatch = null, this.connection = new T(e2, t2, s2);
676
+ this.pendingBatch = null, this.connection = new I(e2, t2, s2);
673
677
  }
674
678
  sync() {
675
679
  return __async(this, null, function* () {
@@ -1693,13 +1697,13 @@ function Ce(e2, t2, s2) {
1693
1697
  return n2.ok ? o(n2.value.data) : "server" === n2.where && 404 === n2.value.status || "server" === n2.where && 403 === n2.value.status && "NOT_A_PARTICIPANT" === n2.value.errorCode ? o(null) : n2;
1694
1698
  });
1695
1699
  }
1696
- class Ie extends Y {
1700
+ class Te extends Y {
1697
1701
  constructor(e2, t2, s2, n2, a2, r2) {
1698
1702
  super(e2, a2, r2), this.getParticipantDataStore = t2, this.conversationId = s2, this.realtimeClient = n2, this.handlers = r2, this.unsubscribeDebounceMs = 3e4, this.pendingLoadMore = void 0;
1699
1703
  }
1700
1704
  fetchInitial(e2) {
1701
1705
  return __async(this, null, function* () {
1702
- const t2 = yield Te({ realtimeClient: this.realtimeClient, conversationId: this.conversationId, count: 10 });
1706
+ const t2 = yield Ie({ realtimeClient: this.realtimeClient, conversationId: this.conversationId, count: 10 });
1703
1707
  return t2.ok ? null === t2.value.participants ? o({ lastChanged: e2, stores: null, inWindow: null, windowEnd: null }) : xe({ seq: e2, participants: t2.value.participants, cursor: t2.value.nextCursor, getParticipantDataStore: this.getParticipantDataStore }) : t2;
1704
1708
  });
1705
1709
  }
@@ -1742,7 +1746,7 @@ class Ie extends Y {
1742
1746
  }
1743
1747
  }
1744
1748
  if (null === s2.value.windowEnd) return t2.resolve(), void (this.pendingLoadMore = void 0);
1745
- const n2 = s2.value.windowEnd.cursor, a2 = yield Te({ count: e2, cursor: n2, conversationId: this.conversationId, realtimeClient: this.realtimeClient });
1749
+ const n2 = s2.value.windowEnd.cursor, a2 = yield Ie({ count: e2, cursor: n2, conversationId: this.conversationId, realtimeClient: this.realtimeClient });
1746
1750
  t2.resolve(), this.pendingLoadMore = void 0, yield this.handlers.onLoadedMore({ type: "virtual.participants.loadedmore", conversationId: this.conversationId, data: a2 });
1747
1751
  });
1748
1752
  }
@@ -1774,7 +1778,7 @@ class Ie extends Y {
1774
1778
  this.mutate(e2, (t3) => null === t3.value.stores ? t3 : (this.teardownNested(t3.value), o({ lastChanged: e2, stores: null, inWindow: null, windowEnd: null })));
1775
1779
  }
1776
1780
  }
1777
- function Te(_0) {
1781
+ function Ie(_0) {
1778
1782
  return __async(this, arguments, function* ({ cursor: e2, realtimeClient: t2, conversationId: s2, count: n2 }) {
1779
1783
  const a2 = { limit: n2, cursor: e2 }, r2 = yield t2.call({ method: "GET", path: ["me", "conversations", s2, "participants"], data: a2, flags: { bypassCache: true } });
1780
1784
  if (r2.ok) {
@@ -2231,7 +2235,7 @@ class Oe {
2231
2235
  if (e(t2, ["users", "*"])) return new ue(this.virtualSeq, t2[1], this.realtimeClient, this.emitMutex, { onTeardown: s2 });
2232
2236
  if (e(t2, ["me", "conversations", "*"])) return new be(this.virtualSeq, this.subscribeConvData(t2[2]), this.realtimeClient, this.emitMutex, { onTeardown: s2 });
2233
2237
  if (e(t2, ["me", "conversations", "*", "messages"])) return new fe(this.virtualSeq, t2[2], this.realtimeClient, this.emitMutex, { onTeardown: s2, onLoadedMore: (e2) => this.onVirtualPublish(e2) });
2234
- if (e(t2, ["me", "conversations", "*", "participants"])) return new Ie(this.virtualSeq, (e2) => this.subscribeParticipantData(t2[2], e2), t2[2], this.realtimeClient, this.emitMutex, { onTeardown: s2, onLoadedMore: (e2) => this.onVirtualPublish(e2) });
2238
+ if (e(t2, ["me", "conversations", "*", "participants"])) return new Te(this.virtualSeq, (e2) => this.subscribeParticipantData(t2[2], e2), t2[2], this.realtimeClient, this.emitMutex, { onTeardown: s2, onLoadedMore: (e2) => this.onVirtualPublish(e2) });
2235
2239
  if (e(t2, ["me", "conversations", "*", "participants", "*"])) return new Re(this.virtualSeq, this.subscribeParticipantData(t2[2], t2[4]), this.realtimeClient, this.emitMutex, { onTeardown: s2 });
2236
2240
  if (e(t2, ["me", "conversations", "*", "typing"])) return new ke(this.virtualSeq, t2[2], this.realtimeClient, this.emitMutex, { onTeardown: s2 });
2237
2241
  if (e(t2, ["me", "conversations"])) return new Ee(this.virtualSeq, (e2) => this.subscribeConvData(e2), this.realtimeClient, this.emitMutex, { onTeardown: s2, onLoadedMore: (e2) => this.onVirtualPublish(e2) });
@@ -2602,11 +2606,11 @@ var St = ht;
2602
2606
  function Ct(e2) {
2603
2607
  return 95 === e2 || St(e2);
2604
2608
  }
2605
- function It(e2) {
2609
+ function Tt(e2) {
2606
2610
  return ht(e2) || ((t2 = e2) < 91 ? t2 < 47 ? t2 >= 35 && t2 <= 43 || 45 == t2 : t2 < 61 ? 47 == t2 : 61 == t2 || 64 == t2 : t2 < 95 ? 91 == t2 || 93 == t2 : t2 < 123 ? 95 == t2 : t2 >= 123 && t2 <= 126 || 10003 == t2) || ut(e2);
2607
2611
  var t2;
2608
2612
  }
2609
- function Tt(e2) {
2613
+ function It(e2) {
2610
2614
  return 47 === e2 || 63 === e2 || 35 === e2;
2611
2615
  }
2612
2616
  function xt(e2) {
@@ -2810,7 +2814,7 @@ function Zt(e2, t2, s2) {
2810
2814
  47 === s2 ? t2.state = 3 : 46 === s2 ? e2.removeMachine(t2) : St(s2) ? (t2.state = 5, yt(s2) && e2.addMachine(Ls(n2, 0))) : e2.removeMachine(t2);
2811
2815
  }
2812
2816
  function Xt(e2, t2, s2) {
2813
- 47 === s2 ? t2.state = 4 : It(s2) ? (t2.state = 10, t2.acceptStateReached = true) : Us(e2, t2);
2817
+ 47 === s2 ? t2.state = 4 : Tt(s2) ? (t2.state = 10, t2.acceptStateReached = true) : Us(e2, t2);
2814
2818
  }
2815
2819
  function es(e2, t2, s2, n2) {
2816
2820
  47 === n2 ? (t2.state = 10, t2.acceptStateReached = true) : St(n2) ? (t2.state = 5, t2.acceptStateReached = true) : e2.removeMachine(t2);
@@ -2822,7 +2826,7 @@ function ss(e2, t2, s2) {
2822
2826
  St(s2) ? t2.state = 5 : e2.removeMachine(t2);
2823
2827
  }
2824
2828
  function ns(e2, t2, s2) {
2825
- 46 === s2 ? t2.state = 7 : 45 === s2 ? t2.state = 6 : 58 === s2 ? t2.state = 8 : Tt(s2) ? t2.state = 10 : Ct(s2) || Us(e2, t2);
2829
+ 46 === s2 ? t2.state = 7 : 45 === s2 ? t2.state = 6 : 58 === s2 ? t2.state = 8 : It(s2) ? t2.state = 10 : Ct(s2) || Us(e2, t2);
2826
2830
  }
2827
2831
  function as(e2, t2, s2, n2) {
2828
2832
  45 === n2 || (46 === n2 ? Us(e2, t2) : St(n2) ? t2.state = 5 : Us(e2, t2));
@@ -2831,7 +2835,7 @@ function rs(e2, t2, s2, n2) {
2831
2835
  46 === n2 ? Us(e2, t2) : St(n2) ? (t2.state = 5, t2.acceptStateReached = true) : Us(e2, t2);
2832
2836
  }
2833
2837
  function is(e2, t2, s2) {
2834
- 46 === s2 ? t2.state = 14 : 58 === s2 ? t2.state = 8 : ot(s2) || (Tt(s2) ? t2.state = 10 : ht(s2) ? e2.removeMachine(t2) : Us(e2, t2));
2838
+ 46 === s2 ? t2.state = 14 : 58 === s2 ? t2.state = 8 : ot(s2) || (It(s2) ? t2.state = 10 : ht(s2) ? e2.removeMachine(t2) : Us(e2, t2));
2835
2839
  }
2836
2840
  function os(e2, t2, s2) {
2837
2841
  ot(s2) ? (t2.octetsEncountered++, 4 === t2.octetsEncountered && (t2.acceptStateReached = true), t2.state = 13) : Us(e2, t2);
@@ -2840,10 +2844,10 @@ function cs(e2, t2, s2) {
2840
2844
  ot(s2) ? t2.state = 9 : Us(e2, t2);
2841
2845
  }
2842
2846
  function ls(e2, t2, s2) {
2843
- ot(s2) || (Tt(s2) ? t2.state = 10 : Us(e2, t2));
2847
+ ot(s2) || (It(s2) ? t2.state = 10 : Us(e2, t2));
2844
2848
  }
2845
2849
  function hs(e2, t2, s2) {
2846
- It(s2) || Us(e2, t2);
2850
+ Tt(s2) || Us(e2, t2);
2847
2851
  }
2848
2852
  function us(e2, t2, s2, n2) {
2849
2853
  "a" === s2.toLowerCase() ? t2.state = 16 : bs(e2, t2, n2);
@@ -2884,10 +2888,10 @@ function Ss(e2, t2, s2) {
2884
2888
  function Cs(e2, t2, s2) {
2885
2889
  46 === s2 || 45 === s2 ? Us(e2, t2) : St(s2) ? (t2.state = 25, t2.acceptStateReached = true) : Us(e2, t2);
2886
2890
  }
2887
- function Is(e2, t2, s2) {
2891
+ function Ts(e2, t2, s2) {
2888
2892
  jt(s2) ? (t2.state = 29, t2.acceptStateReached = true) : e2.removeMachine(t2);
2889
2893
  }
2890
- function Ts(e2, t2, s2) {
2894
+ function Is(e2, t2, s2) {
2891
2895
  jt(s2) || Us(e2, t2);
2892
2896
  }
2893
2897
  function xs(e2, t2, s2) {
@@ -3370,10 +3374,10 @@ var yn = (function() {
3370
3374
  Cs(s3, i2, a3);
3371
3375
  break;
3372
3376
  case 28:
3373
- Is(s3, i2, a3);
3377
+ Ts(s3, i2, a3);
3374
3378
  break;
3375
3379
  case 29:
3376
- Ts(s3, i2, a3);
3380
+ Is(s3, i2, a3);
3377
3381
  break;
3378
3382
  case 30:
3379
3383
  xs(s3, i2, a3);
@@ -3451,9 +3455,9 @@ function Sn(e2, t2 = e2) {
3451
3455
  }
3452
3456
  const Cn = We(/<!!mention:([^>\s]*?)\|(.*?)>/gm, ([e2, t2, s2]) => /* @__PURE__ */ (function(e3, t3) {
3453
3457
  return { type: "mention", id: e3, text: t3 };
3454
- })(decodeURIComponent(t2), s2)), In = We(/<!!customemoji:(.*?)>/gm, ([e2, t2]) => /* @__PURE__ */ (function(e3) {
3458
+ })(decodeURIComponent(t2), s2)), Tn = We(/<!!customemoji:(.*?)>/gm, ([e2, t2]) => /* @__PURE__ */ (function(e3) {
3455
3459
  return { type: "customemoji", text: e3 };
3456
- })(t2)), Tn = We(/<((?:https?|mailto):.*?)\|(.*?)>/gi, ([e2, t2, s2]) => /* @__PURE__ */ (function(e3, t3 = []) {
3460
+ })(t2)), In = We(/<((?:https?|mailto):.*?)\|(.*?)>/gi, ([e2, t2, s2]) => /* @__PURE__ */ (function(e3, t3 = []) {
3457
3461
  return { type: "link", url: e3, children: t3 };
3458
3462
  })(t2, [s2])), xn = We(/<actionlink:([^|]+)[|]([^>]*)>/gi, ([e2, t2, s2]) => {
3459
3463
  const { action: n2, params: a2 } = Mn(t2);
@@ -3474,17 +3478,21 @@ function Mn(e2) {
3474
3478
  const _n = We(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__ */ (function(e3 = []) {
3475
3479
  return { type: "bulletlist", children: e3 };
3476
3480
  })([e2.startsWith("\n") ? e2.slice(1) : e2])), An = We(/^\s*[-*+]\s+([^\n]+)(?:\n|$)/gm, ([e2, t2]) => ({ type: "bulletpoint", children: [t2] })), Nn = (e2) => {
3477
- const t2 = /(?:^|[^-:/\w])([(+]?[0-9](?:[-_+ ().]?[0-9]){5,11}[0-9])(?:[^-:/\w]|$)/g;
3478
- let s2 = 0;
3479
- const n2 = [];
3480
- for (const a2 of Z(e2, t2)) {
3481
- const t3 = a2[0], r2 = a2[1], i2 = t3.startsWith(r2) ? a2.index : a2.index + 1;
3482
- i2 - s2 > 0 && n2.push(e2.substring(s2, i2));
3483
- const o2 = Sn("tel:" + r2.replace(/[^0-9+]/g, ""), r2);
3484
- n2.push(o2), s2 = i2 + r2.length;
3485
- }
3486
- return s2 < e2.length && n2.push(e2.substring(s2)), n2;
3487
- }, Dn = (e2) => Tn(e2).flatMap((e3) => "string" == typeof e3 ? Rn(e3) : ["<", ...Rn(e3.url), ...Rn("|" + e3.children[0] + ">")]), Rn = (e2) => {
3481
+ const t2 = /(?:^|[^-:/\w])([(+]?[0-9](?:[-_+ ().]?[0-9]){5,11}[0-9])(?:[^-:/\w]|$)/g, s2 = /^(\d{4})-(\d{4})$/;
3482
+ let n2 = 0;
3483
+ const a2 = [];
3484
+ for (const r2 of Z(e2, t2)) {
3485
+ const t3 = r2[0], i2 = r2[1], o2 = i2.match(s2);
3486
+ if (o2) {
3487
+ if (Number(o2[1]) < Number(o2[2])) continue;
3488
+ }
3489
+ const c2 = t3.startsWith(i2) ? r2.index : r2.index + 1;
3490
+ c2 - n2 > 0 && a2.push(e2.substring(n2, c2));
3491
+ const l2 = Sn("tel:" + i2.replace(/[^0-9+]/g, ""), i2);
3492
+ a2.push(l2), n2 = c2 + i2.length;
3493
+ }
3494
+ return n2 < e2.length && a2.push(e2.substring(n2)), a2;
3495
+ }, Dn = (e2) => In(e2).flatMap((e3) => "string" == typeof e3 ? Rn(e3) : ["<", ...Rn(e3.url), ...Rn("|" + e3.children[0] + ">")]), Rn = (e2) => {
3488
3496
  const t2 = yn.parse(e2, { urls: true, email: true, phone: false, hashtag: false, mention: false }), s2 = [];
3489
3497
  let n2 = 0;
3490
3498
  for (const a2 of t2) {
@@ -3497,7 +3505,7 @@ const _n = We(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__
3497
3505
  function Pn(e2 = { except: [] }) {
3498
3506
  var _a2;
3499
3507
  const t2 = { multilineSteps: [], singlelineSteps: [] }, s2 = (_a2 = e2.except) != null ? _a2 : On.filter((t3) => !e2.only.includes(t3));
3500
- return s2.includes("BulletPoint") || t2.multilineSteps.push(_n, An), s2.includes("Mention") || t2.singlelineSteps.push(Cn), s2.includes("CustomEmoji") || t2.singlelineSteps.push(In), s2.includes("Codespan") || t2.multilineSteps.push(We(/```([^]+?)```/g, ([e3, t3]) => ({ type: "codespan", text: t3.replace(/<!!mention:.*?\|([^>]*)>/gim, "@$1").replace(/<!!customemoji:(.*?)>/gim, "$1") }))), s2.includes("FormattedLink") || t2.singlelineSteps.push(Tn), s2.includes("Actions") || (t2.singlelineSteps.push(xn), t2.singlelineSteps.push(En)), s2.includes("Wikitext") || t2.singlelineSteps.push(Fe), s2.includes("Autolink") || t2.singlelineSteps.push(Dn, Nn), t2;
3508
+ return s2.includes("BulletPoint") || t2.multilineSteps.push(_n, An), s2.includes("Mention") || t2.singlelineSteps.push(Cn), s2.includes("CustomEmoji") || t2.singlelineSteps.push(Tn), s2.includes("Codespan") || t2.multilineSteps.push(We(/```([^]+?)```/g, ([e3, t3]) => ({ type: "codespan", text: t3.replace(/<!!mention:.*?\|([^>]*)>/gim, "@$1").replace(/<!!customemoji:(.*?)>/gim, "$1") }))), s2.includes("FormattedLink") || t2.singlelineSteps.push(In), s2.includes("Actions") || (t2.singlelineSteps.push(xn), t2.singlelineSteps.push(En)), s2.includes("Wikitext") || t2.singlelineSteps.push(Fe), s2.includes("Autolink") || t2.singlelineSteps.push(Dn, Nn), t2;
3501
3509
  }
3502
3510
  const jn = (function(e2) {
3503
3511
  const t2 = RegExp(`[^${e2}]+${e2}?|${e2}`, "g");
@@ -3559,7 +3567,8 @@ function Fn(e2, t2) {
3559
3567
  }
3560
3568
  class Hn {
3561
3569
  constructor(e2, t2, s2, n2, a2) {
3562
- this._onSnapshot = t2, this._pageSize = s2, this._maxPageSize = n2, this._sort = a2, this._windowStatus = void 0, this._loadMoreDeferred = void 0, this._connectedDefer = r(), this._underlyingSubscription = e2(this.handleSnapshot.bind(this)), this._underlyingSubscription.connected.catch((e3) => this._connectedDefer.reject(e3));
3570
+ this._onSnapshot = t2, this._pageSize = s2, this._maxPageSize = n2, this._sort = a2, this._windowStatus = void 0, this._loadMoreDeferred = void 0, this._connectedDefer = r(), this._connectedDefer.promise.catch(() => {
3571
+ }), this._underlyingSubscription = e2(this.handleSnapshot.bind(this)), this._underlyingSubscription.connected.catch((e3) => this._connectedDefer.reject(e3));
3563
3572
  }
3564
3573
  updateWindowStatusAndGetState(e2, t2) {
3565
3574
  var _a2, _b2;
@@ -4058,7 +4067,7 @@ class la {
4058
4067
  function ha({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRetry: i2, authProvider: o2, errorTracker: c2, abortSignal: l2 }) {
4059
4068
  var _a2;
4060
4069
  (!r2 || r2 <= 0) && (r2 = 1);
4061
- const h2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2026-02-03T10:48:11.175Z" };
4070
+ const h2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2026-02-24T08:38:41.193Z" };
4062
4071
  s2 instanceof FormData || (h2["Content-Type"] = (_a2 = n2 == null ? void 0 : n2.contentType) != null ? _a2 : "application/json");
4063
4072
  return a(r2, () => __async(null, null, function* () {
4064
4073
  if (o2) {
@@ -4087,7 +4096,7 @@ class ua {
4087
4096
  __privateAdd(this, _e2);
4088
4097
  __privateAdd(this, _t2);
4089
4098
  var _a2, _b2, _c, _d;
4090
- this._timeCreated = Date.now(), __privateSet(this, _e2, (_b2 = (_a2 = globalThis.document) == null ? void 0 : _a2.referrer) != null ? _b2 : ""), __privateSet(this, _t2, ((_d = (_c = globalThis.location) == null ? void 0 : _c.href) != null ? _d : globalThis.HermesInternal) ? "React Native Hermes" : ""), this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2026-02-03T10:48:11.175Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: __privateGet(this, _t2), referrer: __privateGet(this, _e2), userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: __privateGet(this, _t2), stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2026-02-03T10:48:11.175Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
4099
+ this._timeCreated = Date.now(), __privateSet(this, _e2, (_b2 = (_a2 = globalThis.document) == null ? void 0 : _a2.referrer) != null ? _b2 : ""), __privateSet(this, _t2, ((_d = (_c = globalThis.location) == null ? void 0 : _c.href) != null ? _d : globalThis.HermesInternal) ? "React Native Hermes" : ""), this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2026-02-24T08:38:41.193Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: __privateGet(this, _t2), referrer: __privateGet(this, _e2), userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: __privateGet(this, _t2), stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2026-02-24T08:38:41.193Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
4091
4100
  }
4092
4101
  setData({ appId: e2, meId: t2, sessionId: s2 }) {
4093
4102
  this._trackJSData.customer.userId = e2, this._trackJSData.customer.sessionId = `${e2}/${t2}`, this._trackJSData.customer.correlationId = s2;
@@ -4165,6 +4174,9 @@ class ma {
4165
4174
  return this.pendingToken = e2, this.handlers.onNeedToken(), e2.promise;
4166
4175
  });
4167
4176
  }
4177
+ getCachedTokenResult() {
4178
+ return this.tokenResult ? this.tokenResult : void 0;
4179
+ }
4168
4180
  setTokenResult(e2) {
4169
4181
  this.pendingToken && (this.pendingToken.resolve(e2), this.pendingToken = null), this.tokenResult = e2, this.handlers.onChange(e2);
4170
4182
  }
@@ -4198,11 +4210,13 @@ class fa {
4198
4210
  }
4199
4211
  getToken() {
4200
4212
  return __async(this, null, function* () {
4201
- const e2 = yield this.inner.getTokenResult();
4202
- if (e2.ok) return e2.value;
4203
- throw e2.value;
4213
+ return va(yield this.inner.getTokenResult());
4204
4214
  });
4205
4215
  }
4216
+ getCachedToken() {
4217
+ const e2 = this.inner.getCachedTokenResult();
4218
+ if (void 0 !== e2) return va(e2);
4219
+ }
4206
4220
  checkCanSetAuth() {
4207
4221
  if (this._calledBokens) throw new Error("[TalkJS] Cannot switch to JWT authentication once connected to TalkJS servers. To use JWTs, call `setToken` or set `onNeedToken` before triggering any requests or mounting any components. We recommend setting up authentication in your app's entry point (App.jsx, main.js, or similar) so it runs first.");
4208
4222
  }
@@ -4331,14 +4345,18 @@ function ga(e2) {
4331
4345
  throw `Could not base64-decode and JSON-parse token section: ${e2}. Check that you base-64 encoded the section correctly.`;
4332
4346
  }
4333
4347
  }
4334
- const va = new class {
4348
+ function va(e2) {
4349
+ if (e2.ok) return e2.value;
4350
+ throw e2.value;
4351
+ }
4352
+ const ba = new class {
4335
4353
  constructor() {
4336
4354
  this.registry = {};
4337
4355
  }
4338
4356
  getOrCreate(e2) {
4339
4357
  const t2 = this.key(e2), s2 = this.registry[t2];
4340
4358
  if (s2) return s2;
4341
- const n2 = new wa(e2);
4359
+ const n2 = new ya(e2);
4342
4360
  return this.registry[t2] = n2, n2;
4343
4361
  }
4344
4362
  deregister(e2, t2) {
@@ -4349,11 +4367,11 @@ const va = new class {
4349
4367
  return `${e2}:${t2}`;
4350
4368
  }
4351
4369
  }();
4352
- function ba(e2) {
4370
+ function wa(e2) {
4353
4371
  if (!e2) throw new Error("[TalkJS] Must provide an options object to `getTalkSession`");
4354
- return e2.forceCreateNew ? new wa(e2) : va.getOrCreate(e2);
4372
+ return e2.forceCreateNew ? new ya(e2) : ba.getOrCreate(e2);
4355
4373
  }
4356
- class wa {
4374
+ class ya {
4357
4375
  constructor(e2) {
4358
4376
  this._onNeedToken = void 0, (function(e3) {
4359
4377
  function t3(e4, t4) {
@@ -4372,7 +4390,7 @@ class wa {
4372
4390
  }
4373
4391
  }));
4374
4392
  const o2 = Math.random().toString().split(".")[1];
4375
- this._realtimeClient = new ia(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.8.0", o2, e2.clientBuild), s2, this._authProvider), this.currentUser = this.user(s2), this._terminationReason = r(), this._terminationReason.promise.then((e3) => {
4393
+ this._realtimeClient = new ia(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.8.2", o2, e2.clientBuild), s2, this._authProvider), this.currentUser = this.user(s2), this._terminationReason = r(), this._terminationReason.promise.then((e3) => {
4376
4394
  console.error(`[TalkJS] ${e3}`);
4377
4395
  }), (function(e3, t3) {
4378
4396
  return __async(this, null, function* () {
@@ -4428,14 +4446,14 @@ class wa {
4428
4446
  }
4429
4447
  searchMessages(e2) {
4430
4448
  let t2;
4431
- return { setQuery: (s2) => t2 && t2.searchString === s2 ? t2.currentState : (t2 && t2.cancel(), s2 && "" !== s2 ? (t2 = new ka(e2, s2, `${this._apiUrls.restApiHttpUrl}/${this._appId}/me/messages/search`, (e3) => __async(this, null, function* () {
4449
+ return { setQuery: (s2) => t2 && t2.searchString === s2 ? t2.currentState : (t2 && t2.cancel(), s2 && "" !== s2 ? (t2 = new Sa(e2, s2, `${this._apiUrls.restApiHttpUrl}/${this._appId}/me/messages/search`, (e3) => __async(this, null, function* () {
4432
4450
  const [t3, s3] = yield Promise.all([this.conversation(e3.conversationId).get(), this._realtimeClient.hydrateMessageData(e3, e3.conversationId)]);
4433
4451
  return null === t3 ? c("Message belongs to nonexistent conversation") : s3.ok ? o({ conversation: t3, message: s3.value }) : s3;
4434
4452
  }), this._authProvider), t2.loadMore(3)) : (t2 = void 0, e2 == null ? void 0 : e2([], "loadedAll"), Promise.resolve({ results: [], loadedAll: true }))), loadMore: (e3) => t2 ? t2.loadMore(e3 != null ? e3 : 10) : Promise.resolve({ results: [], loadedAll: true }) };
4435
4453
  }
4436
4454
  searchConversations(e2) {
4437
4455
  let t2;
4438
- return { setQuery: (s2) => t2 && t2.searchString === s2 ? t2.currentState : (t2 && t2.cancel(), s2 && "" !== s2 ? (t2 = new ka(e2, s2, `${this._apiUrls.restApiHttpUrl}/${this._appId}/me/conversations/search`, (e3) => __async(this, null, function* () {
4456
+ return { setQuery: (s2) => t2 && t2.searchString === s2 ? t2.currentState : (t2 && t2.cancel(), s2 && "" !== s2 ? (t2 = new Sa(e2, s2, `${this._apiUrls.restApiHttpUrl}/${this._appId}/me/conversations/search`, (e3) => __async(this, null, function* () {
4439
4457
  const t3 = yield this._realtimeClient.hydrateConvData(e3);
4440
4458
  if (!t3.ok) return t3;
4441
4459
  const s3 = t3.value;
@@ -4443,28 +4461,28 @@ class wa {
4443
4461
  }), this._authProvider), t2.loadMore(3)) : (t2 = void 0, e2 == null ? void 0 : e2([], "loadedAll"), Promise.resolve({ results: [], loadedAll: true }))), loadMore: (e3) => t2 ? t2.loadMore(e3 != null ? e3 : 10) : Promise.resolve({ results: [], loadedAll: true }) };
4444
4462
  }
4445
4463
  terminate(e2) {
4446
- va.deregister(this._appId, this.currentUser.id), this._terminationReason.resolve(e2), this._realtimeClient.destroy();
4464
+ ba.deregister(this._appId, this.currentUser.id), this._terminationReason.resolve(e2), this._realtimeClient.destroy();
4447
4465
  }
4448
4466
  _isConnected() {
4449
4467
  return this._realtimeClient.isConnected();
4450
4468
  }
4451
4469
  uploadFile(e2, t2) {
4452
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, t2);
4470
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, t2);
4453
4471
  }
4454
4472
  uploadImage(e2, t2) {
4455
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "image" }, t2));
4473
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "image" }, t2));
4456
4474
  }
4457
4475
  uploadVideo(e2, t2) {
4458
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "video" }, t2));
4476
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "video" }, t2));
4459
4477
  }
4460
4478
  uploadAudio(e2, t2) {
4461
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "audio" }, t2));
4479
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "audio" }, t2));
4462
4480
  }
4463
4481
  uploadVoice(e2, t2) {
4464
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "voice" }, t2));
4482
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "voice" }, t2));
4465
4483
  }
4466
4484
  }
4467
- function ya(_0, _1, _2, _3, _4) {
4485
+ function ka(_0, _1, _2, _3, _4) {
4468
4486
  return __async(this, arguments, function* (e2, t2, s2, n2, { subtype: a2, filename: r2, width: i2, height: o2, duration: c2 }) {
4469
4487
  d("Upload file", yield s2.call({ method: "POST", path: ["files", "validate"], data: { filename: r2, filesize: n2.size } }));
4470
4488
  const l2 = new FormData();
@@ -4477,7 +4495,7 @@ function ya(_0, _1, _2, _3, _4) {
4477
4495
  }));
4478
4496
  });
4479
4497
  }
4480
- class ka {
4498
+ class Sa {
4481
4499
  constructor(e2, t2, s2, n2, a2) {
4482
4500
  this.onResults = e2, this.searchString = t2, this.baseUrl = s2, this.hydrateData = n2, this.authProvider = a2, this.error = void 0, this.lastCompletedQueryState = { results: [], loadedAll: false }, this.currentCursor = void 0, this.cancelQuery = () => {
4483
4501
  }, e2 == null ? void 0 : e2([], "searching");
@@ -4565,7 +4583,7 @@ class ka {
4565
4583
  }
4566
4584
  }
4567
4585
  export {
4568
- ba as getTalkSession,
4586
+ wa as getTalkSession,
4569
4587
  f as registerPolyfills
4570
4588
  };
4571
4589
  //# sourceMappingURL=talkSession.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talkjs/core",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "Lets you connect to your TalkJS chat as a user and read, subscribe to, and update your chat data.",
5
5
  "bugs": {
6
6
  "url": "https://talkjs.com/?chat"