@ton/mcp 0.1.15-alpha.2 → 0.1.15-alpha.4

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.cjs CHANGED
@@ -40166,6 +40166,15 @@ function Base64Normalize(data) {
40166
40166
  return data.replace(/\s+/g, "").replace(/-/g, "+").replace(/_/g, "/");
40167
40167
  }
40168
40168
  /**
40169
+ * Make base64url string
40170
+ * @param data Base64url or base64 string
40171
+ * @returns Normalized base64url string
40172
+ * example: a+/ => a-_=
40173
+ */
40174
+ function Base64NormalizeUrl(data) {
40175
+ return Base64Normalize(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
40176
+ }
40177
+ /**
40169
40178
  * Parse base64 string
40170
40179
  * @param data Base64 string
40171
40180
  * @returns utf-8 string
@@ -81587,37 +81596,37 @@ var import_blakejs = /* @__PURE__ */ __toESM(require_blakejs(), 1);
81587
81596
  function P() {
81588
81597
  return typeof process < "u" && !!process.env;
81589
81598
  }
81590
- function B(o) {
81591
- return process?.env?.[o];
81599
+ function B(i) {
81600
+ return process?.env?.[i];
81592
81601
  }
81593
- var O = P() && !B("TONBRIDGE_DEBUG"), s = (...o) => {
81594
- O || console.debug("[TON_CONNECT_BRIDGE_SDK]", ...o);
81595
- }, b = (...o) => {
81596
- console.error("[TON_CONNECT_BRIDGE_SDK]", ...o);
81602
+ var O = P() && !B("TONBRIDGE_DEBUG"), s = (...i) => {
81603
+ O || console.debug("[TON_CONNECT_BRIDGE_SDK]", ...i);
81604
+ }, b = (...i) => {
81605
+ console.error("[TON_CONNECT_BRIDGE_SDK]", ...i);
81597
81606
  };
81598
- var a = class o extends Error {
81607
+ var a = class i extends Error {
81599
81608
  static prefix = "[BRIDGE_SDK_ERROR]";
81600
81609
  constructor(e, t) {
81601
- super(e, t), this.message = `${o.prefix} ${e ? `
81602
- ` + e : ""}`, s(this.message), Object.setPrototypeOf(this, o.prototype);
81610
+ super(e, t), this.message = `${i.prefix} ${e ? `
81611
+ ` + e : ""}`, s(this.message), Object.setPrototypeOf(this, i.prototype);
81603
81612
  }
81604
81613
  };
81605
- function k(o) {
81606
- return o.slice(-1) === "/" ? o.slice(0, -1) : o;
81614
+ function k(i) {
81615
+ return i.slice(-1) === "/" ? i.slice(0, -1) : i;
81607
81616
  }
81608
- function E(o, e) {
81609
- return k(o) + "/" + e;
81617
+ function v(i, e) {
81618
+ return k(i) + "/" + e;
81610
81619
  }
81611
- function p(o) {
81620
+ function p(i) {
81612
81621
  let e = new AbortController();
81613
- return o?.aborted ? e.abort() : o?.addEventListener("abort", () => e.abort(), { once: true }), e;
81622
+ return i?.aborted ? e.abort() : i?.addEventListener("abort", () => e.abort(), { once: true }), e;
81614
81623
  }
81615
- function D(o, e) {
81624
+ function M(i, e) {
81616
81625
  let t = null, r = null, n = null;
81617
81626
  return {
81618
81627
  create: async (d, ...u) => {
81619
81628
  if (n?.abort(), n = p(d), n.signal.aborted) throw new a("Resource creation was aborted");
81620
- let m = o(n.signal, ...u);
81629
+ let m = i(n.signal, ...u);
81621
81630
  r = m;
81622
81631
  let g = await m;
81623
81632
  if (r !== m && g !== t) throw await e(g), new a("Resource creation was aborted by a new resource creation");
@@ -81638,9 +81647,9 @@ function D(o, e) {
81638
81647
  }
81639
81648
  };
81640
81649
  }
81641
- function M(o, e) {
81650
+ function D(i, e) {
81642
81651
  let t = e?.timeout, r = e?.signal, n = p(r);
81643
- return new Promise(async (i, c) => {
81652
+ return new Promise(async (o, c) => {
81644
81653
  if (r?.aborted) {
81645
81654
  c(new a("Timeout aborted before setTimeout"));
81646
81655
  return;
@@ -81650,8 +81659,8 @@ function M(o, e) {
81650
81659
  n.abort(), c(new a(`Timeout after ${t}ms`));
81651
81660
  }, t)), n.signal.addEventListener("abort", () => {
81652
81661
  l && (clearTimeout(l), l = void 0, c(new a("Timeout aborted after setTimeout")));
81653
- }, { once: true }), await o((...d) => {
81654
- clearTimeout(l), l = void 0, i(...d);
81662
+ }, { once: true }), await i((...d) => {
81663
+ clearTimeout(l), l = void 0, o(...d);
81655
81664
  }, (d) => {
81656
81665
  clearTimeout(l), l = void 0, c(d);
81657
81666
  }, {
@@ -81660,22 +81669,23 @@ function M(o, e) {
81660
81669
  });
81661
81670
  });
81662
81671
  }
81663
- var v = class o {
81664
- constructor(e, t, r, n, i, c, l) {
81672
+ var y = class i {
81673
+ constructor(e, t, r, n, o, c, l) {
81665
81674
  this.bridgeUrl = e;
81666
81675
  this.sessionIds = t;
81667
81676
  this.listener = r;
81668
81677
  this.errorsListener = n;
81669
- this.lastEventId = i;
81678
+ this.lastEventId = o;
81670
81679
  this.heartbeatFormat = c;
81671
81680
  this.enableQueueDoneEvent = l;
81672
81681
  }
81673
81682
  static ssePath = "events";
81674
81683
  static postPath = "message";
81684
+ static verifyPath = "verify";
81675
81685
  static defaultTtl = 300;
81676
- eventSource = D(async (e, t) => await U({
81686
+ eventSource = M(async (e, t) => await U({
81677
81687
  bridgeUrl: this.bridgeUrl,
81678
- ssePath: o.ssePath,
81688
+ ssePath: i.ssePath,
81679
81689
  sessionIds: this.sessionIds,
81680
81690
  errorHandler: this.errorsHandler.bind(this),
81681
81691
  messageHandler: this.messagesHandler.bind(this),
@@ -81697,7 +81707,7 @@ var v = class o {
81697
81707
  return this.eventSource.current()?.readyState === EventSource.CONNECTING;
81698
81708
  }
81699
81709
  static async open(e) {
81700
- let t = new o(e.bridgeUrl, e.sessionIds, e.listener, e.errorsListener, e.lastEventId, e.heartbeatFormat, e.enableQueueDoneEvent);
81710
+ let t = new i(e.bridgeUrl, e.sessionIds, e.listener, e.errorsListener, e.lastEventId, e.heartbeatFormat, e.enableQueueDoneEvent);
81701
81711
  try {
81702
81712
  return await t.registerSession(e.options), t;
81703
81713
  } catch (r) {
@@ -81707,14 +81717,25 @@ var v = class o {
81707
81717
  async registerSession(e) {
81708
81718
  await this.eventSource.create(e?.signal, e?.connectingDeadlineMS);
81709
81719
  }
81710
- static async sendRequest(e, t, r, n, i) {
81711
- let c = new URL(E(e, this.postPath));
81712
- c.searchParams.append("client_id", r), c.searchParams.append("to", n), c.searchParams.append("ttl", (i?.ttl ?? o.defaultTtl).toString()), i?.topic && c.searchParams.append("topic", i.topic), i?.traceId && c.searchParams.append("trace_id", i.traceId);
81713
- let l = Base64.encode(t), d = await this.post(c, l, i?.signal);
81714
- if (!d.ok) throw new a(`Bridge send failed, status ${d.status}`);
81720
+ static async verifyRequest(e, t, r) {
81721
+ let n = new URL(v(e, this.verifyPath));
81722
+ return { status: (await (await this.post(n, {
81723
+ client_id: t.clientId,
81724
+ url: t.url,
81725
+ type: t.type
81726
+ }, r?.signal)).json()).status };
81727
+ }
81728
+ static async sendRequest(e, t, r, n, o) {
81729
+ let c = new URL(v(e, this.postPath));
81730
+ c.searchParams.append("client_id", r), c.searchParams.append("to", n), c.searchParams.append("ttl", (o?.ttl ?? i.defaultTtl).toString()), o?.topic && c.searchParams.append("topic", o.topic), o?.traceId && c.searchParams.append("trace_id", o.traceId);
81731
+ let l = Base64.encode(t);
81732
+ await this.post(c, l, o?.signal);
81733
+ }
81734
+ async verify(e, t) {
81735
+ return i.verifyRequest(this.bridgeUrl, e, t);
81715
81736
  }
81716
81737
  async send(e, t, r, n) {
81717
- return o.sendRequest(this.bridgeUrl, e, t, r, n);
81738
+ return i.sendRequest(this.bridgeUrl, e, t, r, n);
81718
81739
  }
81719
81740
  async close() {
81720
81741
  await this.eventSource.dispose().catch((e) => {
@@ -81730,10 +81751,11 @@ var v = class o {
81730
81751
  static async post(e, t, r) {
81731
81752
  let n = await fetch(e, {
81732
81753
  method: "post",
81733
- body: t,
81734
- signal: r
81754
+ body: typeof t == "object" ? JSON.stringify(t) : t,
81755
+ signal: r,
81756
+ headers: typeof t == "object" ? { "Content-Type": "application/json" } : void 0
81735
81757
  });
81736
- if (!n.ok) throw new a(`Bridge send failed, status ${n.status}`);
81758
+ if (!n.ok) throw new a(`Bridge post failed, status ${n.status}`);
81737
81759
  return n;
81738
81760
  }
81739
81761
  async errorsHandler(e, t) {
@@ -81743,96 +81765,96 @@ var v = class o {
81743
81765
  this.listener(e);
81744
81766
  }
81745
81767
  };
81746
- async function U(o) {
81747
- let { lastEventId: e, heartbeatFormat: t, enableQueueDoneEvent: r } = o;
81748
- return await M(async (n, i, c) => {
81768
+ async function U(i) {
81769
+ let { lastEventId: e, heartbeatFormat: t, enableQueueDoneEvent: r } = i;
81770
+ return await D(async (n, o, c) => {
81749
81771
  let { signal: l } = c;
81750
81772
  if (s("[BridgeGateway] Connecting to bridge SSE..."), l?.aborted) {
81751
- i(new a("Bridge connection aborted before connection"));
81773
+ o(new a("Bridge connection aborted before connection"));
81752
81774
  return;
81753
81775
  }
81754
- let d = new URL(E(o.bridgeUrl, o.ssePath));
81755
- if (d.searchParams.append("client_id", o.sessionIds.join(",")), e && d.searchParams.append("last_event_id", e), t && d.searchParams.append("heartbeat", t), r && d.searchParams.append("enable_queue_done_event", "true"), l?.aborted) {
81756
- i(new a("Bridge connection aborted after building url"));
81776
+ let d = new URL(v(i.bridgeUrl, i.ssePath));
81777
+ if (d.searchParams.append("client_id", i.sessionIds.join(",")), e && d.searchParams.append("last_event_id", e), t && d.searchParams.append("heartbeat", t), r && d.searchParams.append("enable_queue_done_event", "true"), l?.aborted) {
81778
+ o(new a("Bridge connection aborted after building url"));
81757
81779
  return;
81758
81780
  }
81759
81781
  s("[BridgeGateway] Initializing EventSource instance...");
81760
81782
  let u = new EventSource(d.toString()), m = false;
81761
81783
  u.onerror = async (g) => {
81762
81784
  if (s("[BridgeGateway] EventSource error occurred:", JSON.stringify(g)), l?.aborted) {
81763
- u.close(), i(new a("Bridge connection aborted on error callback"));
81785
+ u.close(), o(new a("Bridge connection aborted on error callback"));
81764
81786
  return;
81765
81787
  }
81766
81788
  if (!m) {
81767
- u.close(), i(new a("Bridge error before connecting"));
81789
+ u.close(), o(new a("Bridge error before connecting"));
81768
81790
  return;
81769
81791
  }
81770
81792
  try {
81771
- u.close(), await o.errorHandler(u, g);
81772
- } catch (A) {
81773
- u.close(), i(A);
81793
+ u.close(), await i.errorHandler(u, g);
81794
+ } catch (I) {
81795
+ u.close(), o(I);
81774
81796
  }
81775
81797
  }, u.onopen = () => {
81776
81798
  if (l?.aborted) {
81777
- u.close(), i(new a("Bridge connection aborted on open"));
81799
+ u.close(), o(new a("Bridge connection aborted on open"));
81778
81800
  return;
81779
81801
  }
81780
81802
  m = true, s("[BridgeGateway] EventSource connection established."), n(u);
81781
81803
  }, u.onmessage = (g) => {
81782
81804
  if (l?.aborted) {
81783
- u.close(), i(new a("Bridge connection aborted on message"));
81805
+ u.close(), o(new a("Bridge connection aborted on message"));
81784
81806
  return;
81785
81807
  }
81786
- e = g.lastEventId, o.messageHandler(g);
81787
- }, o.signal?.addEventListener("abort", () => {
81788
- u.close(), i(new a("Bridge connection aborted"));
81808
+ e = g.lastEventId, i.messageHandler(g);
81809
+ }, i.signal?.addEventListener("abort", () => {
81810
+ u.close(), o(new a("Bridge connection aborted"));
81789
81811
  }, { once: true });
81790
81812
  }, {
81791
- timeout: o.connectingDeadlineMS,
81792
- signal: o.signal
81813
+ timeout: i.connectingDeadlineMS,
81814
+ signal: i.signal
81793
81815
  });
81794
81816
  }
81795
- async function y(o, e) {
81817
+ async function h(i, e) {
81796
81818
  if (e?.signal?.aborted) throw new a("Delay aborted before setTimeout");
81797
81819
  return new Promise((t, r) => {
81798
- let n = setTimeout(t, o);
81820
+ let n = setTimeout(t, i);
81799
81821
  e?.signal?.addEventListener("abort", () => {
81800
81822
  clearTimeout(n), r(new a("Delay aborted after setTimeout"));
81801
81823
  }, { once: true });
81802
81824
  });
81803
81825
  }
81804
- async function S(o, e) {
81826
+ async function f(i, e) {
81805
81827
  let { signal: t, attempts: r = 10, delayMs: n = 100 } = e ?? {};
81806
- if (typeof o != "function") throw new a(`Expected a function, got ${typeof o}`);
81807
- let i = 0, c;
81808
- for (; i < r;) {
81809
- if (s(`[callForSuccess] Attempt: ${i}`), t?.aborted) throw new a(`Aborted after attempts ${i}`);
81828
+ if (typeof i != "function") throw new a(`Expected a function, got ${typeof i}`);
81829
+ let o = 0, c;
81830
+ for (; o < r;) {
81831
+ if (s(`[callForSuccess] Attempt: ${o}`), t?.aborted) throw new a(`Aborted after attempts ${o}`);
81810
81832
  try {
81811
- return await o({ signal: t });
81833
+ return await i({ signal: t });
81812
81834
  } catch (l) {
81813
- s(`[callForSuccess], error after attempt ${i}, ${/* @__PURE__ */ new Date()}: ${JSON.stringify(l)}`, l), c = l, i++, i < r && (await y(n, { signal: t }), e?.exponential && (n = Math.min(n * 2, e.maxDelayMs ?? Number.MAX_SAFE_INTEGER)));
81835
+ s(`[callForSuccess], error after attempt ${o}, ${/* @__PURE__ */ new Date()}: ${JSON.stringify(l)}`, l), c = l, o++, o < r && (await h(n, { signal: t }), e?.exponential && (n = Math.min(n * 2, e.maxDelayMs ?? Number.MAX_SAFE_INTEGER)));
81814
81836
  }
81815
81837
  }
81816
81838
  throw c;
81817
81839
  }
81818
- function T(o) {
81819
- return [...new Set(o)];
81840
+ function x(i) {
81841
+ return [...new Set(i)];
81820
81842
  }
81821
- function x(o, e) {
81822
- let t = new Set(o), r = new Set(e);
81843
+ function T(i, e) {
81844
+ let t = new Set(i), r = new Set(e);
81823
81845
  if (t.size !== r.size) return false;
81824
81846
  for (let n of t) if (!r.has(n)) return false;
81825
81847
  return true;
81826
81848
  }
81827
- function G(o, e) {
81849
+ function G(i, e) {
81828
81850
  let t = import_blakejs.default.blake2bInit(import_nacl_fast.default.box.nonceLength);
81829
- return import_blakejs.default.blake2bUpdate(t, o), import_blakejs.default.blake2bUpdate(t, e), import_blakejs.default.blake2bFinal(t);
81851
+ return import_blakejs.default.blake2bUpdate(t, i), import_blakejs.default.blake2bUpdate(t, e), import_blakejs.default.blake2bFinal(t);
81830
81852
  }
81831
- function I(o, e, t) {
81832
- let r = o.subarray(0, import_nacl_fast.default.box.publicKeyLength), n = G(r, e), i = o.subarray(import_nacl_fast.default.box.publicKeyLength);
81833
- return import_nacl_fast.default.box.open(i, n, r, t);
81853
+ function R(i, e, t) {
81854
+ let r = i.subarray(0, import_nacl_fast.default.box.publicKeyLength), n = G(r, e), o = i.subarray(import_nacl_fast.default.box.publicKeyLength);
81855
+ return import_nacl_fast.default.box.open(o, n, r, t);
81834
81856
  }
81835
- var C = class o {
81857
+ var C = class i {
81836
81858
  constructor(e, t = null, r = null, n = void 0) {
81837
81859
  this.bridgeUrl = e;
81838
81860
  this.listener = t;
@@ -81855,7 +81877,7 @@ var C = class o {
81855
81877
  heartbeatTimer = null;
81856
81878
  connectionOptions = {};
81857
81879
  static async open(e) {
81858
- let t = new o(e.bridgeUrl, e.listener, e.errorListener, e.options?.heartbeatReconnectIntervalMs);
81880
+ let t = new i(e.bridgeUrl, e.listener, e.errorListener, e.options?.heartbeatReconnectIntervalMs);
81859
81881
  e.onConnecting && (t.onConnecting = e.onConnecting), e.onQueueDone && (t.onQueueDone = e.onQueueDone);
81860
81882
  try {
81861
81883
  return await t.restoreConnection(e.clients, e.options), t;
@@ -81878,8 +81900,8 @@ var C = class o {
81878
81900
  let { signal: r } = p(e);
81879
81901
  this.lastHeartbeatAt = Date.now();
81880
81902
  let n = (c) => {
81881
- this.heartbeatTimer = setTimeout(i, c);
81882
- }, i = async () => {
81903
+ this.heartbeatTimer = setTimeout(o, c);
81904
+ }, o = async () => {
81883
81905
  if (r.aborted) {
81884
81906
  this.stopHeartbeatWatcher();
81885
81907
  return;
@@ -81888,7 +81910,7 @@ var C = class o {
81888
81910
  n(this.heartbeatReconnectIntervalMs / 2);
81889
81911
  return;
81890
81912
  }
81891
- if (await y(this.missedHeartbeatDelay, { signal: r }), r.aborted) {
81913
+ if (await h(this.missedHeartbeatDelay, { signal: r }), r.aborted) {
81892
81914
  this.stopHeartbeatWatcher();
81893
81915
  return;
81894
81916
  }
@@ -81934,7 +81956,7 @@ var C = class o {
81934
81956
  this.startHeartbeatWatcher(t?.signal);
81935
81957
  }
81936
81958
  async updateClients(e, t) {
81937
- x(this.clients.map((i) => i.session.sessionId), e.map((i) => i.session.sessionId)) || (this.clients = e, await this.restoreConnection(e, {
81959
+ T(this.clients.map((o) => o.session.sessionId), e.map((o) => o.session.sessionId)) || (this.clients = e, await this.restoreConnection(e, {
81938
81960
  ...this.connectionOptions,
81939
81961
  signal: t?.signal
81940
81962
  }));
@@ -81950,7 +81972,7 @@ var C = class o {
81950
81972
  return;
81951
81973
  }
81952
81974
  let t = this.connectionOptions;
81953
- await S(({ signal: r }) => this.openGateway(this.clients.map((n) => n.session), {
81975
+ await f(({ signal: r }) => this.openGateway(this.clients.map((n) => n.session), {
81954
81976
  lastEventId: this.lastEventId,
81955
81977
  connectingDeadlineMS: t?.connectingDeadlineMs ?? this.defaultConnectingDeadlineMS,
81956
81978
  signal: r
@@ -81962,14 +81984,23 @@ var C = class o {
81962
81984
  maxDelayMs: t?.maxDelayMs ?? this.defaultMaxExponentialDelayMS
81963
81985
  });
81964
81986
  }
81987
+ async verify(e, t) {
81988
+ return f(async ({ signal: r }) => y.verifyRequest(this.bridgeUrl, e, { signal: r }), {
81989
+ attempts: t?.attempts ?? Number.MAX_SAFE_INTEGER,
81990
+ delayMs: t?.delayMs ?? this.defaultRetryDelayMs,
81991
+ signal: t?.signal,
81992
+ exponential: t?.exponential ?? true,
81993
+ maxDelayMs: t?.maxDelayMs ?? this.defaultMaxExponentialDelayMS
81994
+ });
81995
+ }
81965
81996
  async send(e, t, r, n) {
81966
81997
  if (n?.signal?.aborted) {
81967
81998
  s("[BridgeProvider] Send aborted before encryption.");
81968
81999
  return;
81969
82000
  }
81970
- let i = t.encrypt(JSON.stringify(e), hexToByteArray(r)), c = n?.topic ?? ("method" in e ? e.method : void 0);
81971
- await S(async ({ signal: l }) => {
81972
- await v.sendRequest(this.bridgeUrl, i, t.sessionId, r, {
82001
+ let o = t.encrypt(JSON.stringify(e), hexToByteArray(r)), c = n?.topic ?? ("method" in e ? e.method : void 0);
82002
+ await f(async ({ signal: l }) => {
82003
+ await y.sendRequest(this.bridgeUrl, o, t.sessionId, r, {
81973
82004
  traceId: n?.traceId,
81974
82005
  topic: c,
81975
82006
  signal: l,
@@ -82014,7 +82045,7 @@ var C = class o {
82014
82045
  }
82015
82046
  loadMaybeSource(e, t) {
82016
82047
  if (!t) return;
82017
- let r = I(Base64.decode(t).toUint8Array(), hexToByteArray(e.sessionId), hexToByteArray(e.stringifyKeypair().secretKey));
82048
+ let r = R(Base64.decode(t).toUint8Array(), hexToByteArray(e.sessionId), hexToByteArray(e.stringifyKeypair().secretKey));
82018
82049
  if (!r) throw new Error("Decrypt error ");
82019
82050
  let n = JSON.parse(new TextDecoder().decode(r));
82020
82051
  return {
@@ -82041,13 +82072,13 @@ var C = class o {
82041
82072
  this.errorListener?.(new a(`Failed to parse message: ${e.data}`));
82042
82073
  return;
82043
82074
  }
82044
- let r = this.getCryptoSession(t.from), n = JSON.parse(r.decrypt(Base64.decode(t.message).toUint8Array(), hexToByteArray(t.from))), i = this.loadMaybeSource(r, t.request_source);
82075
+ let r = this.getCryptoSession(t.from), n = JSON.parse(r.decrypt(Base64.decode(t.message).toUint8Array(), hexToByteArray(t.from))), o = this.loadMaybeSource(r, t.request_source);
82045
82076
  s("[BridgeProvider] Incoming message decrypted:", n), this.lastEventId = e.lastEventId, this.listener?.({
82046
82077
  lastEventId: e.lastEventId,
82047
82078
  traceId: t.trace_id,
82048
82079
  ...n,
82049
82080
  from: t.from,
82050
- requestSource: i,
82081
+ requestSource: o,
82051
82082
  connectSource: t.connect_source
82052
82083
  });
82053
82084
  }
@@ -82072,7 +82103,7 @@ var C = class o {
82072
82103
  s("[BridgeProvider] Open gateway aborted after close.");
82073
82104
  return;
82074
82105
  }
82075
- this.gateway = new v(this.bridgeUrl, T(e.map(({ sessionId: r }) => r)), this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this), this.lastEventId, "message", true), s("[BridgeProvider] BridgeGateway created. Connecting to bridge..."), this.onConnectingCallback?.(), await this.gateway.registerSession({
82106
+ this.gateway = new y(this.bridgeUrl, x(e.map(({ sessionId: r }) => r)), this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this), this.lastEventId, "message", true), s("[BridgeProvider] BridgeGateway created. Connecting to bridge..."), this.onConnectingCallback?.(), await this.gateway.registerSession({
82076
82107
  connectingDeadlineMS: t?.connectingDeadlineMS,
82077
82108
  signal: t?.signal
82078
82109
  }), s("[BridgeProvider] Connected to bridge successfully.");
@@ -108454,11 +108485,15 @@ async function resolveOperatorCredentials(privateKey, expectedPublicKey, deps) {
108454
108485
  }
108455
108486
  function buildAgenticCreateDeepLink(input) {
108456
108487
  const url = new URL("/create", AGENTIC_DASHBOARD_BASE_URL);
108457
- url.searchParams.set("operatorPublicKey", input.operatorPublicKey);
108458
- url.searchParams.set("callbackUrl", input.callbackUrl);
108459
- if (input.agentName?.trim()) url.searchParams.set("agentName", input.agentName.trim());
108460
- if (input.source?.trim()) url.searchParams.set("source", input.source.trim());
108461
- if (input.tonDeposit?.trim()) url.searchParams.set("tonDeposit", input.tonDeposit.trim());
108488
+ const payload = {
108489
+ originOperatorPublicKey: input.operatorPublicKey,
108490
+ callbackUrl: input.callbackUrl
108491
+ };
108492
+ if (input.agentName?.trim()) payload.agentName = input.agentName.trim();
108493
+ if (input.source?.trim()) payload.source = input.source.trim();
108494
+ if (input.tonDeposit?.trim()) payload.tonDeposit = input.tonDeposit.trim();
108495
+ const payloadBytes = new TextEncoder().encode(JSON.stringify(payload));
108496
+ url.searchParams.set("data", Base64NormalizeUrl(Uint8ArrayToBase64(payloadBytes)));
108462
108497
  return url.toString();
108463
108498
  }
108464
108499
  function buildAgenticDashboardLink(address) {