@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/cli.js +127 -92
- package/dist/index.cjs +127 -92
- package/dist/index.js +127 -92
- package/dist/serverless.cjs +127 -92
- package/dist/serverless.js +127 -92
- package/dist/utils/agentic.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -39771,6 +39771,15 @@ function Base64Normalize(data) {
|
|
|
39771
39771
|
return data.replace(/\s+/g, "").replace(/-/g, "+").replace(/_/g, "/");
|
|
39772
39772
|
}
|
|
39773
39773
|
/**
|
|
39774
|
+
* Make base64url string
|
|
39775
|
+
* @param data Base64url or base64 string
|
|
39776
|
+
* @returns Normalized base64url string
|
|
39777
|
+
* example: a+/ => a-_=
|
|
39778
|
+
*/
|
|
39779
|
+
function Base64NormalizeUrl(data) {
|
|
39780
|
+
return Base64Normalize(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
39781
|
+
}
|
|
39782
|
+
/**
|
|
39774
39783
|
* Parse base64 string
|
|
39775
39784
|
* @param data Base64 string
|
|
39776
39785
|
* @returns utf-8 string
|
|
@@ -81192,37 +81201,37 @@ var import_blakejs = /* @__PURE__ */ __toESM(require_blakejs(), 1);
|
|
|
81192
81201
|
function P() {
|
|
81193
81202
|
return typeof process < "u" && !!process.env;
|
|
81194
81203
|
}
|
|
81195
|
-
function B(
|
|
81196
|
-
return process?.env?.[
|
|
81204
|
+
function B(i) {
|
|
81205
|
+
return process?.env?.[i];
|
|
81197
81206
|
}
|
|
81198
|
-
var O = P() && !B("TONBRIDGE_DEBUG"), s = (...
|
|
81199
|
-
O || console.debug("[TON_CONNECT_BRIDGE_SDK]", ...
|
|
81200
|
-
}, b = (...
|
|
81201
|
-
console.error("[TON_CONNECT_BRIDGE_SDK]", ...
|
|
81207
|
+
var O = P() && !B("TONBRIDGE_DEBUG"), s = (...i) => {
|
|
81208
|
+
O || console.debug("[TON_CONNECT_BRIDGE_SDK]", ...i);
|
|
81209
|
+
}, b = (...i) => {
|
|
81210
|
+
console.error("[TON_CONNECT_BRIDGE_SDK]", ...i);
|
|
81202
81211
|
};
|
|
81203
|
-
var a = class
|
|
81212
|
+
var a = class i extends Error {
|
|
81204
81213
|
static prefix = "[BRIDGE_SDK_ERROR]";
|
|
81205
81214
|
constructor(e, t) {
|
|
81206
|
-
super(e, t), this.message = `${
|
|
81207
|
-
` + e : ""}`, s(this.message), Object.setPrototypeOf(this,
|
|
81215
|
+
super(e, t), this.message = `${i.prefix} ${e ? `
|
|
81216
|
+
` + e : ""}`, s(this.message), Object.setPrototypeOf(this, i.prototype);
|
|
81208
81217
|
}
|
|
81209
81218
|
};
|
|
81210
|
-
function k(
|
|
81211
|
-
return
|
|
81219
|
+
function k(i) {
|
|
81220
|
+
return i.slice(-1) === "/" ? i.slice(0, -1) : i;
|
|
81212
81221
|
}
|
|
81213
|
-
function
|
|
81214
|
-
return k(
|
|
81222
|
+
function v(i, e) {
|
|
81223
|
+
return k(i) + "/" + e;
|
|
81215
81224
|
}
|
|
81216
|
-
function p(
|
|
81225
|
+
function p(i) {
|
|
81217
81226
|
let e = new AbortController();
|
|
81218
|
-
return
|
|
81227
|
+
return i?.aborted ? e.abort() : i?.addEventListener("abort", () => e.abort(), { once: true }), e;
|
|
81219
81228
|
}
|
|
81220
|
-
function
|
|
81229
|
+
function M(i, e) {
|
|
81221
81230
|
let t = null, r = null, n = null;
|
|
81222
81231
|
return {
|
|
81223
81232
|
create: async (d, ...u) => {
|
|
81224
81233
|
if (n?.abort(), n = p(d), n.signal.aborted) throw new a("Resource creation was aborted");
|
|
81225
|
-
let m =
|
|
81234
|
+
let m = i(n.signal, ...u);
|
|
81226
81235
|
r = m;
|
|
81227
81236
|
let g = await m;
|
|
81228
81237
|
if (r !== m && g !== t) throw await e(g), new a("Resource creation was aborted by a new resource creation");
|
|
@@ -81243,9 +81252,9 @@ function D(o, e) {
|
|
|
81243
81252
|
}
|
|
81244
81253
|
};
|
|
81245
81254
|
}
|
|
81246
|
-
function
|
|
81255
|
+
function D(i, e) {
|
|
81247
81256
|
let t = e?.timeout, r = e?.signal, n = p(r);
|
|
81248
|
-
return new Promise(async (
|
|
81257
|
+
return new Promise(async (o, c) => {
|
|
81249
81258
|
if (r?.aborted) {
|
|
81250
81259
|
c(new a("Timeout aborted before setTimeout"));
|
|
81251
81260
|
return;
|
|
@@ -81255,8 +81264,8 @@ function M(o, e) {
|
|
|
81255
81264
|
n.abort(), c(new a(`Timeout after ${t}ms`));
|
|
81256
81265
|
}, t)), n.signal.addEventListener("abort", () => {
|
|
81257
81266
|
l && (clearTimeout(l), l = void 0, c(new a("Timeout aborted after setTimeout")));
|
|
81258
|
-
}, { once: true }), await
|
|
81259
|
-
clearTimeout(l), l = void 0,
|
|
81267
|
+
}, { once: true }), await i((...d) => {
|
|
81268
|
+
clearTimeout(l), l = void 0, o(...d);
|
|
81260
81269
|
}, (d) => {
|
|
81261
81270
|
clearTimeout(l), l = void 0, c(d);
|
|
81262
81271
|
}, {
|
|
@@ -81265,22 +81274,23 @@ function M(o, e) {
|
|
|
81265
81274
|
});
|
|
81266
81275
|
});
|
|
81267
81276
|
}
|
|
81268
|
-
var
|
|
81269
|
-
constructor(e, t, r, n,
|
|
81277
|
+
var y = class i {
|
|
81278
|
+
constructor(e, t, r, n, o, c, l) {
|
|
81270
81279
|
this.bridgeUrl = e;
|
|
81271
81280
|
this.sessionIds = t;
|
|
81272
81281
|
this.listener = r;
|
|
81273
81282
|
this.errorsListener = n;
|
|
81274
|
-
this.lastEventId =
|
|
81283
|
+
this.lastEventId = o;
|
|
81275
81284
|
this.heartbeatFormat = c;
|
|
81276
81285
|
this.enableQueueDoneEvent = l;
|
|
81277
81286
|
}
|
|
81278
81287
|
static ssePath = "events";
|
|
81279
81288
|
static postPath = "message";
|
|
81289
|
+
static verifyPath = "verify";
|
|
81280
81290
|
static defaultTtl = 300;
|
|
81281
|
-
eventSource =
|
|
81291
|
+
eventSource = M(async (e, t) => await U({
|
|
81282
81292
|
bridgeUrl: this.bridgeUrl,
|
|
81283
|
-
ssePath:
|
|
81293
|
+
ssePath: i.ssePath,
|
|
81284
81294
|
sessionIds: this.sessionIds,
|
|
81285
81295
|
errorHandler: this.errorsHandler.bind(this),
|
|
81286
81296
|
messageHandler: this.messagesHandler.bind(this),
|
|
@@ -81302,7 +81312,7 @@ var v = class o {
|
|
|
81302
81312
|
return this.eventSource.current()?.readyState === EventSource.CONNECTING;
|
|
81303
81313
|
}
|
|
81304
81314
|
static async open(e) {
|
|
81305
|
-
let t = new
|
|
81315
|
+
let t = new i(e.bridgeUrl, e.sessionIds, e.listener, e.errorsListener, e.lastEventId, e.heartbeatFormat, e.enableQueueDoneEvent);
|
|
81306
81316
|
try {
|
|
81307
81317
|
return await t.registerSession(e.options), t;
|
|
81308
81318
|
} catch (r) {
|
|
@@ -81312,14 +81322,25 @@ var v = class o {
|
|
|
81312
81322
|
async registerSession(e) {
|
|
81313
81323
|
await this.eventSource.create(e?.signal, e?.connectingDeadlineMS);
|
|
81314
81324
|
}
|
|
81315
|
-
static async
|
|
81316
|
-
let
|
|
81317
|
-
|
|
81318
|
-
|
|
81319
|
-
|
|
81325
|
+
static async verifyRequest(e, t, r) {
|
|
81326
|
+
let n = new URL(v(e, this.verifyPath));
|
|
81327
|
+
return { status: (await (await this.post(n, {
|
|
81328
|
+
client_id: t.clientId,
|
|
81329
|
+
url: t.url,
|
|
81330
|
+
type: t.type
|
|
81331
|
+
}, r?.signal)).json()).status };
|
|
81332
|
+
}
|
|
81333
|
+
static async sendRequest(e, t, r, n, o) {
|
|
81334
|
+
let c = new URL(v(e, this.postPath));
|
|
81335
|
+
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);
|
|
81336
|
+
let l = Base64.encode(t);
|
|
81337
|
+
await this.post(c, l, o?.signal);
|
|
81338
|
+
}
|
|
81339
|
+
async verify(e, t) {
|
|
81340
|
+
return i.verifyRequest(this.bridgeUrl, e, t);
|
|
81320
81341
|
}
|
|
81321
81342
|
async send(e, t, r, n) {
|
|
81322
|
-
return
|
|
81343
|
+
return i.sendRequest(this.bridgeUrl, e, t, r, n);
|
|
81323
81344
|
}
|
|
81324
81345
|
async close() {
|
|
81325
81346
|
await this.eventSource.dispose().catch((e) => {
|
|
@@ -81335,10 +81356,11 @@ var v = class o {
|
|
|
81335
81356
|
static async post(e, t, r) {
|
|
81336
81357
|
let n = await fetch(e, {
|
|
81337
81358
|
method: "post",
|
|
81338
|
-
body: t,
|
|
81339
|
-
signal: r
|
|
81359
|
+
body: typeof t == "object" ? JSON.stringify(t) : t,
|
|
81360
|
+
signal: r,
|
|
81361
|
+
headers: typeof t == "object" ? { "Content-Type": "application/json" } : void 0
|
|
81340
81362
|
});
|
|
81341
|
-
if (!n.ok) throw new a(`Bridge
|
|
81363
|
+
if (!n.ok) throw new a(`Bridge post failed, status ${n.status}`);
|
|
81342
81364
|
return n;
|
|
81343
81365
|
}
|
|
81344
81366
|
async errorsHandler(e, t) {
|
|
@@ -81348,96 +81370,96 @@ var v = class o {
|
|
|
81348
81370
|
this.listener(e);
|
|
81349
81371
|
}
|
|
81350
81372
|
};
|
|
81351
|
-
async function U(
|
|
81352
|
-
let { lastEventId: e, heartbeatFormat: t, enableQueueDoneEvent: r } =
|
|
81353
|
-
return await
|
|
81373
|
+
async function U(i) {
|
|
81374
|
+
let { lastEventId: e, heartbeatFormat: t, enableQueueDoneEvent: r } = i;
|
|
81375
|
+
return await D(async (n, o, c) => {
|
|
81354
81376
|
let { signal: l } = c;
|
|
81355
81377
|
if (s("[BridgeGateway] Connecting to bridge SSE..."), l?.aborted) {
|
|
81356
|
-
|
|
81378
|
+
o(new a("Bridge connection aborted before connection"));
|
|
81357
81379
|
return;
|
|
81358
81380
|
}
|
|
81359
|
-
let d = new URL(
|
|
81360
|
-
if (d.searchParams.append("client_id",
|
|
81361
|
-
|
|
81381
|
+
let d = new URL(v(i.bridgeUrl, i.ssePath));
|
|
81382
|
+
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) {
|
|
81383
|
+
o(new a("Bridge connection aborted after building url"));
|
|
81362
81384
|
return;
|
|
81363
81385
|
}
|
|
81364
81386
|
s("[BridgeGateway] Initializing EventSource instance...");
|
|
81365
81387
|
let u = new EventSource(d.toString()), m = false;
|
|
81366
81388
|
u.onerror = async (g) => {
|
|
81367
81389
|
if (s("[BridgeGateway] EventSource error occurred:", JSON.stringify(g)), l?.aborted) {
|
|
81368
|
-
u.close(),
|
|
81390
|
+
u.close(), o(new a("Bridge connection aborted on error callback"));
|
|
81369
81391
|
return;
|
|
81370
81392
|
}
|
|
81371
81393
|
if (!m) {
|
|
81372
|
-
u.close(),
|
|
81394
|
+
u.close(), o(new a("Bridge error before connecting"));
|
|
81373
81395
|
return;
|
|
81374
81396
|
}
|
|
81375
81397
|
try {
|
|
81376
|
-
u.close(), await
|
|
81377
|
-
} catch (
|
|
81378
|
-
u.close(),
|
|
81398
|
+
u.close(), await i.errorHandler(u, g);
|
|
81399
|
+
} catch (I) {
|
|
81400
|
+
u.close(), o(I);
|
|
81379
81401
|
}
|
|
81380
81402
|
}, u.onopen = () => {
|
|
81381
81403
|
if (l?.aborted) {
|
|
81382
|
-
u.close(),
|
|
81404
|
+
u.close(), o(new a("Bridge connection aborted on open"));
|
|
81383
81405
|
return;
|
|
81384
81406
|
}
|
|
81385
81407
|
m = true, s("[BridgeGateway] EventSource connection established."), n(u);
|
|
81386
81408
|
}, u.onmessage = (g) => {
|
|
81387
81409
|
if (l?.aborted) {
|
|
81388
|
-
u.close(),
|
|
81410
|
+
u.close(), o(new a("Bridge connection aborted on message"));
|
|
81389
81411
|
return;
|
|
81390
81412
|
}
|
|
81391
|
-
e = g.lastEventId,
|
|
81392
|
-
},
|
|
81393
|
-
u.close(),
|
|
81413
|
+
e = g.lastEventId, i.messageHandler(g);
|
|
81414
|
+
}, i.signal?.addEventListener("abort", () => {
|
|
81415
|
+
u.close(), o(new a("Bridge connection aborted"));
|
|
81394
81416
|
}, { once: true });
|
|
81395
81417
|
}, {
|
|
81396
|
-
timeout:
|
|
81397
|
-
signal:
|
|
81418
|
+
timeout: i.connectingDeadlineMS,
|
|
81419
|
+
signal: i.signal
|
|
81398
81420
|
});
|
|
81399
81421
|
}
|
|
81400
|
-
async function
|
|
81422
|
+
async function h(i, e) {
|
|
81401
81423
|
if (e?.signal?.aborted) throw new a("Delay aborted before setTimeout");
|
|
81402
81424
|
return new Promise((t, r) => {
|
|
81403
|
-
let n = setTimeout(t,
|
|
81425
|
+
let n = setTimeout(t, i);
|
|
81404
81426
|
e?.signal?.addEventListener("abort", () => {
|
|
81405
81427
|
clearTimeout(n), r(new a("Delay aborted after setTimeout"));
|
|
81406
81428
|
}, { once: true });
|
|
81407
81429
|
});
|
|
81408
81430
|
}
|
|
81409
|
-
async function
|
|
81431
|
+
async function f(i, e) {
|
|
81410
81432
|
let { signal: t, attempts: r = 10, delayMs: n = 100 } = e ?? {};
|
|
81411
|
-
if (typeof
|
|
81412
|
-
let
|
|
81413
|
-
for (;
|
|
81414
|
-
if (s(`[callForSuccess] Attempt: ${
|
|
81433
|
+
if (typeof i != "function") throw new a(`Expected a function, got ${typeof i}`);
|
|
81434
|
+
let o = 0, c;
|
|
81435
|
+
for (; o < r;) {
|
|
81436
|
+
if (s(`[callForSuccess] Attempt: ${o}`), t?.aborted) throw new a(`Aborted after attempts ${o}`);
|
|
81415
81437
|
try {
|
|
81416
|
-
return await
|
|
81438
|
+
return await i({ signal: t });
|
|
81417
81439
|
} catch (l) {
|
|
81418
|
-
s(`[callForSuccess], error after attempt ${
|
|
81440
|
+
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)));
|
|
81419
81441
|
}
|
|
81420
81442
|
}
|
|
81421
81443
|
throw c;
|
|
81422
81444
|
}
|
|
81423
|
-
function
|
|
81424
|
-
return [...new Set(
|
|
81445
|
+
function x(i) {
|
|
81446
|
+
return [...new Set(i)];
|
|
81425
81447
|
}
|
|
81426
|
-
function
|
|
81427
|
-
let t = new Set(
|
|
81448
|
+
function T(i, e) {
|
|
81449
|
+
let t = new Set(i), r = new Set(e);
|
|
81428
81450
|
if (t.size !== r.size) return false;
|
|
81429
81451
|
for (let n of t) if (!r.has(n)) return false;
|
|
81430
81452
|
return true;
|
|
81431
81453
|
}
|
|
81432
|
-
function G(
|
|
81454
|
+
function G(i, e) {
|
|
81433
81455
|
let t = import_blakejs.default.blake2bInit(import_nacl_fast.default.box.nonceLength);
|
|
81434
|
-
return import_blakejs.default.blake2bUpdate(t,
|
|
81456
|
+
return import_blakejs.default.blake2bUpdate(t, i), import_blakejs.default.blake2bUpdate(t, e), import_blakejs.default.blake2bFinal(t);
|
|
81435
81457
|
}
|
|
81436
|
-
function
|
|
81437
|
-
let r =
|
|
81438
|
-
return import_nacl_fast.default.box.open(
|
|
81458
|
+
function R(i, e, t) {
|
|
81459
|
+
let r = i.subarray(0, import_nacl_fast.default.box.publicKeyLength), n = G(r, e), o = i.subarray(import_nacl_fast.default.box.publicKeyLength);
|
|
81460
|
+
return import_nacl_fast.default.box.open(o, n, r, t);
|
|
81439
81461
|
}
|
|
81440
|
-
var C = class
|
|
81462
|
+
var C = class i {
|
|
81441
81463
|
constructor(e, t = null, r = null, n = void 0) {
|
|
81442
81464
|
this.bridgeUrl = e;
|
|
81443
81465
|
this.listener = t;
|
|
@@ -81460,7 +81482,7 @@ var C = class o {
|
|
|
81460
81482
|
heartbeatTimer = null;
|
|
81461
81483
|
connectionOptions = {};
|
|
81462
81484
|
static async open(e) {
|
|
81463
|
-
let t = new
|
|
81485
|
+
let t = new i(e.bridgeUrl, e.listener, e.errorListener, e.options?.heartbeatReconnectIntervalMs);
|
|
81464
81486
|
e.onConnecting && (t.onConnecting = e.onConnecting), e.onQueueDone && (t.onQueueDone = e.onQueueDone);
|
|
81465
81487
|
try {
|
|
81466
81488
|
return await t.restoreConnection(e.clients, e.options), t;
|
|
@@ -81483,8 +81505,8 @@ var C = class o {
|
|
|
81483
81505
|
let { signal: r } = p(e);
|
|
81484
81506
|
this.lastHeartbeatAt = Date.now();
|
|
81485
81507
|
let n = (c) => {
|
|
81486
|
-
this.heartbeatTimer = setTimeout(
|
|
81487
|
-
},
|
|
81508
|
+
this.heartbeatTimer = setTimeout(o, c);
|
|
81509
|
+
}, o = async () => {
|
|
81488
81510
|
if (r.aborted) {
|
|
81489
81511
|
this.stopHeartbeatWatcher();
|
|
81490
81512
|
return;
|
|
@@ -81493,7 +81515,7 @@ var C = class o {
|
|
|
81493
81515
|
n(this.heartbeatReconnectIntervalMs / 2);
|
|
81494
81516
|
return;
|
|
81495
81517
|
}
|
|
81496
|
-
if (await
|
|
81518
|
+
if (await h(this.missedHeartbeatDelay, { signal: r }), r.aborted) {
|
|
81497
81519
|
this.stopHeartbeatWatcher();
|
|
81498
81520
|
return;
|
|
81499
81521
|
}
|
|
@@ -81539,7 +81561,7 @@ var C = class o {
|
|
|
81539
81561
|
this.startHeartbeatWatcher(t?.signal);
|
|
81540
81562
|
}
|
|
81541
81563
|
async updateClients(e, t) {
|
|
81542
|
-
|
|
81564
|
+
T(this.clients.map((o) => o.session.sessionId), e.map((o) => o.session.sessionId)) || (this.clients = e, await this.restoreConnection(e, {
|
|
81543
81565
|
...this.connectionOptions,
|
|
81544
81566
|
signal: t?.signal
|
|
81545
81567
|
}));
|
|
@@ -81555,7 +81577,7 @@ var C = class o {
|
|
|
81555
81577
|
return;
|
|
81556
81578
|
}
|
|
81557
81579
|
let t = this.connectionOptions;
|
|
81558
|
-
await
|
|
81580
|
+
await f(({ signal: r }) => this.openGateway(this.clients.map((n) => n.session), {
|
|
81559
81581
|
lastEventId: this.lastEventId,
|
|
81560
81582
|
connectingDeadlineMS: t?.connectingDeadlineMs ?? this.defaultConnectingDeadlineMS,
|
|
81561
81583
|
signal: r
|
|
@@ -81567,14 +81589,23 @@ var C = class o {
|
|
|
81567
81589
|
maxDelayMs: t?.maxDelayMs ?? this.defaultMaxExponentialDelayMS
|
|
81568
81590
|
});
|
|
81569
81591
|
}
|
|
81592
|
+
async verify(e, t) {
|
|
81593
|
+
return f(async ({ signal: r }) => y.verifyRequest(this.bridgeUrl, e, { signal: r }), {
|
|
81594
|
+
attempts: t?.attempts ?? Number.MAX_SAFE_INTEGER,
|
|
81595
|
+
delayMs: t?.delayMs ?? this.defaultRetryDelayMs,
|
|
81596
|
+
signal: t?.signal,
|
|
81597
|
+
exponential: t?.exponential ?? true,
|
|
81598
|
+
maxDelayMs: t?.maxDelayMs ?? this.defaultMaxExponentialDelayMS
|
|
81599
|
+
});
|
|
81600
|
+
}
|
|
81570
81601
|
async send(e, t, r, n) {
|
|
81571
81602
|
if (n?.signal?.aborted) {
|
|
81572
81603
|
s("[BridgeProvider] Send aborted before encryption.");
|
|
81573
81604
|
return;
|
|
81574
81605
|
}
|
|
81575
|
-
let
|
|
81576
|
-
await
|
|
81577
|
-
await
|
|
81606
|
+
let o = t.encrypt(JSON.stringify(e), hexToByteArray(r)), c = n?.topic ?? ("method" in e ? e.method : void 0);
|
|
81607
|
+
await f(async ({ signal: l }) => {
|
|
81608
|
+
await y.sendRequest(this.bridgeUrl, o, t.sessionId, r, {
|
|
81578
81609
|
traceId: n?.traceId,
|
|
81579
81610
|
topic: c,
|
|
81580
81611
|
signal: l,
|
|
@@ -81619,7 +81650,7 @@ var C = class o {
|
|
|
81619
81650
|
}
|
|
81620
81651
|
loadMaybeSource(e, t) {
|
|
81621
81652
|
if (!t) return;
|
|
81622
|
-
let r =
|
|
81653
|
+
let r = R(Base64.decode(t).toUint8Array(), hexToByteArray(e.sessionId), hexToByteArray(e.stringifyKeypair().secretKey));
|
|
81623
81654
|
if (!r) throw new Error("Decrypt error ");
|
|
81624
81655
|
let n = JSON.parse(new TextDecoder().decode(r));
|
|
81625
81656
|
return {
|
|
@@ -81646,13 +81677,13 @@ var C = class o {
|
|
|
81646
81677
|
this.errorListener?.(new a(`Failed to parse message: ${e.data}`));
|
|
81647
81678
|
return;
|
|
81648
81679
|
}
|
|
81649
|
-
let r = this.getCryptoSession(t.from), n = JSON.parse(r.decrypt(Base64.decode(t.message).toUint8Array(), hexToByteArray(t.from))),
|
|
81680
|
+
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);
|
|
81650
81681
|
s("[BridgeProvider] Incoming message decrypted:", n), this.lastEventId = e.lastEventId, this.listener?.({
|
|
81651
81682
|
lastEventId: e.lastEventId,
|
|
81652
81683
|
traceId: t.trace_id,
|
|
81653
81684
|
...n,
|
|
81654
81685
|
from: t.from,
|
|
81655
|
-
requestSource:
|
|
81686
|
+
requestSource: o,
|
|
81656
81687
|
connectSource: t.connect_source
|
|
81657
81688
|
});
|
|
81658
81689
|
}
|
|
@@ -81677,7 +81708,7 @@ var C = class o {
|
|
|
81677
81708
|
s("[BridgeProvider] Open gateway aborted after close.");
|
|
81678
81709
|
return;
|
|
81679
81710
|
}
|
|
81680
|
-
this.gateway = new
|
|
81711
|
+
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({
|
|
81681
81712
|
connectingDeadlineMS: t?.connectingDeadlineMS,
|
|
81682
81713
|
signal: t?.signal
|
|
81683
81714
|
}), s("[BridgeProvider] Connected to bridge successfully.");
|
|
@@ -109239,11 +109270,15 @@ async function resolveOperatorCredentials(privateKey, expectedPublicKey, deps) {
|
|
|
109239
109270
|
}
|
|
109240
109271
|
function buildAgenticCreateDeepLink(input) {
|
|
109241
109272
|
const url = new URL("/create", AGENTIC_DASHBOARD_BASE_URL);
|
|
109242
|
-
|
|
109243
|
-
|
|
109244
|
-
|
|
109245
|
-
|
|
109246
|
-
if (input.
|
|
109273
|
+
const payload = {
|
|
109274
|
+
originOperatorPublicKey: input.operatorPublicKey,
|
|
109275
|
+
callbackUrl: input.callbackUrl
|
|
109276
|
+
};
|
|
109277
|
+
if (input.agentName?.trim()) payload.agentName = input.agentName.trim();
|
|
109278
|
+
if (input.source?.trim()) payload.source = input.source.trim();
|
|
109279
|
+
if (input.tonDeposit?.trim()) payload.tonDeposit = input.tonDeposit.trim();
|
|
109280
|
+
const payloadBytes = new TextEncoder().encode(JSON.stringify(payload));
|
|
109281
|
+
url.searchParams.set("data", Base64NormalizeUrl(Uint8ArrayToBase64(payloadBytes)));
|
|
109247
109282
|
return url.toString();
|
|
109248
109283
|
}
|
|
109249
109284
|
function buildAgenticDashboardLink(address) {
|