@ours.network/tg-connector 1.0.1-nightly.1 → 1.0.1-nightly.2
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/connector.js +101 -101
- package/package.json +3 -3
package/dist/connector.js
CHANGED
|
@@ -6,11 +6,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __require = /* @__PURE__ */ ((
|
|
9
|
+
var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
|
|
10
10
|
get: (a4, b3) => (typeof require !== "undefined" ? require : a4)[b3]
|
|
11
|
-
}) :
|
|
11
|
+
}) : x2)(function(x2) {
|
|
12
12
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
-
throw Error('Dynamic require of "' +
|
|
13
|
+
throw Error('Dynamic require of "' + x2 + '" is not supported');
|
|
14
14
|
});
|
|
15
15
|
var __commonJS = (cb, mod) => function __require2() {
|
|
16
16
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -1035,7 +1035,7 @@ var require_util = __commonJS({
|
|
|
1035
1035
|
var { InvalidArgumentError, ConnectTimeoutError } = require_errors();
|
|
1036
1036
|
var { headerNameLowerCasedRecord } = require_constants();
|
|
1037
1037
|
var { tree } = require_tree();
|
|
1038
|
-
var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((
|
|
1038
|
+
var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v3) => Number(v3));
|
|
1039
1039
|
var BodyAsyncIterable = class {
|
|
1040
1040
|
constructor(body) {
|
|
1041
1041
|
this[kBody] = body;
|
|
@@ -1248,7 +1248,7 @@ var require_util = __commonJS({
|
|
|
1248
1248
|
let val = obj[key];
|
|
1249
1249
|
if (val !== void 0) {
|
|
1250
1250
|
if (!Object.hasOwn(obj, key)) {
|
|
1251
|
-
const headersValue = typeof headers[i2 + 1] === "string" ? headers[i2 + 1] : Array.isArray(headers[i2 + 1]) ? headers[i2 + 1].map((
|
|
1251
|
+
const headersValue = typeof headers[i2 + 1] === "string" ? headers[i2 + 1] : Array.isArray(headers[i2 + 1]) ? headers[i2 + 1].map((x2) => x2.toString("latin1")) : headers[i2 + 1].toString("latin1");
|
|
1252
1252
|
if (key === "__proto__") {
|
|
1253
1253
|
Object.defineProperty(obj, key, {
|
|
1254
1254
|
value: headersValue,
|
|
@@ -1267,7 +1267,7 @@ var require_util = __commonJS({
|
|
|
1267
1267
|
val.push(headers[i2 + 1].toString("latin1"));
|
|
1268
1268
|
}
|
|
1269
1269
|
} else {
|
|
1270
|
-
const headersValue = typeof headers[i2 + 1] === "string" ? headers[i2 + 1] : Array.isArray(headers[i2 + 1]) ? headers[i2 + 1].map((
|
|
1270
|
+
const headersValue = typeof headers[i2 + 1] === "string" ? headers[i2 + 1] : Array.isArray(headers[i2 + 1]) ? headers[i2 + 1].map((x2) => x2.toString("latin1")) : headers[i2 + 1].toString("latin1");
|
|
1271
1271
|
obj[key] = headersValue;
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
@@ -1292,7 +1292,7 @@ var require_util = __commonJS({
|
|
|
1292
1292
|
if (!Array.isArray(headers)) {
|
|
1293
1293
|
throw new TypeError("expected headers to be an array");
|
|
1294
1294
|
}
|
|
1295
|
-
return headers.map((
|
|
1295
|
+
return headers.map((x2) => Buffer.from(x2));
|
|
1296
1296
|
}
|
|
1297
1297
|
function isBuffer(buffer) {
|
|
1298
1298
|
return buffer instanceof Uint8Array || Buffer.isBuffer(buffer);
|
|
@@ -4445,8 +4445,8 @@ var require_webidl = __commonJS({
|
|
|
4445
4445
|
message: `"${context.value}" is an invalid ${context.type}.`
|
|
4446
4446
|
});
|
|
4447
4447
|
};
|
|
4448
|
-
webidl.brandCheck = function(V3,
|
|
4449
|
-
if (!FunctionPrototypeSymbolHasInstance(
|
|
4448
|
+
webidl.brandCheck = function(V3, I4) {
|
|
4449
|
+
if (!FunctionPrototypeSymbolHasInstance(I4, V3)) {
|
|
4450
4450
|
const err = new TypeError("Illegal invocation");
|
|
4451
4451
|
err.code = "ERR_INVALID_THIS";
|
|
4452
4452
|
throw err;
|
|
@@ -4476,8 +4476,8 @@ var require_webidl = __commonJS({
|
|
|
4476
4476
|
message: "Illegal constructor"
|
|
4477
4477
|
});
|
|
4478
4478
|
};
|
|
4479
|
-
webidl.util.MakeTypeAssertion = function(
|
|
4480
|
-
return (O3) => FunctionPrototypeSymbolHasInstance(
|
|
4479
|
+
webidl.util.MakeTypeAssertion = function(I4) {
|
|
4480
|
+
return (O3) => FunctionPrototypeSymbolHasInstance(I4, O3);
|
|
4481
4481
|
};
|
|
4482
4482
|
webidl.util.Type = function(V3) {
|
|
4483
4483
|
switch (typeof V3) {
|
|
@@ -4551,44 +4551,44 @@ var require_webidl = __commonJS({
|
|
|
4551
4551
|
lowerBound = -Math.pow(2, bitLength - 1);
|
|
4552
4552
|
upperBound = Math.pow(2, bitLength - 1) - 1;
|
|
4553
4553
|
}
|
|
4554
|
-
let
|
|
4555
|
-
if (
|
|
4556
|
-
|
|
4554
|
+
let x2 = Number(V3);
|
|
4555
|
+
if (x2 === 0) {
|
|
4556
|
+
x2 = 0;
|
|
4557
4557
|
}
|
|
4558
4558
|
if (webidl.util.HasFlag(flags, webidl.attributes.EnforceRange)) {
|
|
4559
|
-
if (Number.isNaN(
|
|
4559
|
+
if (Number.isNaN(x2) || x2 === Number.POSITIVE_INFINITY || x2 === Number.NEGATIVE_INFINITY) {
|
|
4560
4560
|
throw webidl.errors.exception({
|
|
4561
4561
|
header: "Integer conversion",
|
|
4562
4562
|
message: `Could not convert ${webidl.util.Stringify(V3)} to an integer.`
|
|
4563
4563
|
});
|
|
4564
4564
|
}
|
|
4565
|
-
|
|
4566
|
-
if (
|
|
4565
|
+
x2 = webidl.util.IntegerPart(x2);
|
|
4566
|
+
if (x2 < lowerBound || x2 > upperBound) {
|
|
4567
4567
|
throw webidl.errors.exception({
|
|
4568
4568
|
header: "Integer conversion",
|
|
4569
|
-
message: `Value must be between ${lowerBound}-${upperBound}, got ${
|
|
4569
|
+
message: `Value must be between ${lowerBound}-${upperBound}, got ${x2}.`
|
|
4570
4570
|
});
|
|
4571
4571
|
}
|
|
4572
|
-
return
|
|
4572
|
+
return x2;
|
|
4573
4573
|
}
|
|
4574
|
-
if (!Number.isNaN(
|
|
4575
|
-
|
|
4576
|
-
if (Math.floor(
|
|
4577
|
-
|
|
4574
|
+
if (!Number.isNaN(x2) && webidl.util.HasFlag(flags, webidl.attributes.Clamp)) {
|
|
4575
|
+
x2 = Math.min(Math.max(x2, lowerBound), upperBound);
|
|
4576
|
+
if (Math.floor(x2) % 2 === 0) {
|
|
4577
|
+
x2 = Math.floor(x2);
|
|
4578
4578
|
} else {
|
|
4579
|
-
|
|
4579
|
+
x2 = Math.ceil(x2);
|
|
4580
4580
|
}
|
|
4581
|
-
return
|
|
4581
|
+
return x2;
|
|
4582
4582
|
}
|
|
4583
|
-
if (Number.isNaN(
|
|
4583
|
+
if (Number.isNaN(x2) || x2 === 0 && Object.is(0, x2) || x2 === Number.POSITIVE_INFINITY || x2 === Number.NEGATIVE_INFINITY) {
|
|
4584
4584
|
return 0;
|
|
4585
4585
|
}
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
if (signedness === "signed" &&
|
|
4589
|
-
return
|
|
4586
|
+
x2 = webidl.util.IntegerPart(x2);
|
|
4587
|
+
x2 = x2 % Math.pow(2, bitLength);
|
|
4588
|
+
if (signedness === "signed" && x2 >= Math.pow(2, bitLength - 1)) {
|
|
4589
|
+
return x2 - Math.pow(2, bitLength);
|
|
4590
4590
|
}
|
|
4591
|
-
return
|
|
4591
|
+
return x2;
|
|
4592
4592
|
};
|
|
4593
4593
|
webidl.util.IntegerPart = function(n3) {
|
|
4594
4594
|
const r2 = Math.floor(Math.abs(n3));
|
|
@@ -4796,15 +4796,15 @@ var require_webidl = __commonJS({
|
|
|
4796
4796
|
message: `${argument} is a symbol, which cannot be converted to a ByteString.`
|
|
4797
4797
|
});
|
|
4798
4798
|
}
|
|
4799
|
-
const
|
|
4800
|
-
for (let index = 0; index <
|
|
4801
|
-
if (
|
|
4799
|
+
const x2 = String(V3);
|
|
4800
|
+
for (let index = 0; index < x2.length; index++) {
|
|
4801
|
+
if (x2.charCodeAt(index) > 255) {
|
|
4802
4802
|
throw new TypeError(
|
|
4803
|
-
`Cannot convert argument to a ByteString because the character at index ${index} has a value of ${
|
|
4803
|
+
`Cannot convert argument to a ByteString because the character at index ${index} has a value of ${x2.charCodeAt(index)} which is greater than 255.`
|
|
4804
4804
|
);
|
|
4805
4805
|
}
|
|
4806
4806
|
}
|
|
4807
|
-
return
|
|
4807
|
+
return x2;
|
|
4808
4808
|
};
|
|
4809
4809
|
webidl.converters.USVString = function(value) {
|
|
4810
4810
|
if (typeof value === "string") {
|
|
@@ -4813,27 +4813,27 @@ var require_webidl = __commonJS({
|
|
|
4813
4813
|
return `${value}`.toWellFormed();
|
|
4814
4814
|
};
|
|
4815
4815
|
webidl.converters.boolean = function(V3) {
|
|
4816
|
-
const
|
|
4817
|
-
return
|
|
4816
|
+
const x2 = Boolean(V3);
|
|
4817
|
+
return x2;
|
|
4818
4818
|
};
|
|
4819
4819
|
webidl.converters.any = function(V3) {
|
|
4820
4820
|
return V3;
|
|
4821
4821
|
};
|
|
4822
4822
|
webidl.converters["long long"] = function(V3, prefix, argument) {
|
|
4823
|
-
const
|
|
4824
|
-
return
|
|
4823
|
+
const x2 = webidl.util.ConvertToInt(V3, 64, "signed", 0, prefix, argument);
|
|
4824
|
+
return x2;
|
|
4825
4825
|
};
|
|
4826
4826
|
webidl.converters["unsigned long long"] = function(V3, prefix, argument) {
|
|
4827
|
-
const
|
|
4828
|
-
return
|
|
4827
|
+
const x2 = webidl.util.ConvertToInt(V3, 64, "unsigned", 0, prefix, argument);
|
|
4828
|
+
return x2;
|
|
4829
4829
|
};
|
|
4830
4830
|
webidl.converters["unsigned long"] = function(V3, prefix, argument) {
|
|
4831
|
-
const
|
|
4832
|
-
return
|
|
4831
|
+
const x2 = webidl.util.ConvertToInt(V3, 32, "unsigned", 0, prefix, argument);
|
|
4832
|
+
return x2;
|
|
4833
4833
|
};
|
|
4834
4834
|
webidl.converters["unsigned short"] = function(V3, prefix, argument, flags) {
|
|
4835
|
-
const
|
|
4836
|
-
return
|
|
4835
|
+
const x2 = webidl.util.ConvertToInt(V3, 16, "unsigned", flags, prefix, argument);
|
|
4836
|
+
return x2;
|
|
4837
4837
|
};
|
|
4838
4838
|
webidl.converters.ArrayBuffer = function(V3, prefix, argument, flags) {
|
|
4839
4839
|
if (webidl.util.Type(V3) !== OBJECT || !types.isArrayBuffer(V3)) {
|
|
@@ -12736,8 +12736,8 @@ var require_mock_utils = __commonJS({
|
|
|
12736
12736
|
}
|
|
12737
12737
|
if (value.includes(",")) {
|
|
12738
12738
|
const values = value.split(",");
|
|
12739
|
-
for (const
|
|
12740
|
-
normalizedQp.append(key,
|
|
12739
|
+
for (const v3 of values) {
|
|
12740
|
+
normalizedQp.append(key, v3);
|
|
12741
12741
|
}
|
|
12742
12742
|
continue;
|
|
12743
12743
|
}
|
|
@@ -15545,11 +15545,11 @@ var require_cache = __commonJS({
|
|
|
15545
15545
|
} else if (typeof opts.headers === "object") {
|
|
15546
15546
|
headers = {};
|
|
15547
15547
|
if (hasSafeIterator(opts.headers)) {
|
|
15548
|
-
for (const
|
|
15549
|
-
if (!Array.isArray(
|
|
15548
|
+
for (const x2 of opts.headers) {
|
|
15549
|
+
if (!Array.isArray(x2)) {
|
|
15550
15550
|
throw new Error("opts.headers is not a valid header map");
|
|
15551
15551
|
}
|
|
15552
|
-
const [key, val] =
|
|
15552
|
+
const [key, val] = x2;
|
|
15553
15553
|
if (typeof key !== "string" || typeof val !== "string") {
|
|
15554
15554
|
throw new Error("opts.headers is not a valid header map");
|
|
15555
15555
|
}
|
|
@@ -18966,15 +18966,15 @@ var require_headers = __commonJS({
|
|
|
18966
18966
|
const firstValue = iterator.next().value;
|
|
18967
18967
|
array[0] = [firstValue[0], firstValue[1].value];
|
|
18968
18968
|
assert(firstValue[1].value !== null);
|
|
18969
|
-
for (let i2 = 1, j2 = 0, right = 0, left = 0, pivot = 0,
|
|
18969
|
+
for (let i2 = 1, j2 = 0, right = 0, left = 0, pivot = 0, x2, value; i2 < size; ++i2) {
|
|
18970
18970
|
value = iterator.next().value;
|
|
18971
|
-
|
|
18972
|
-
assert(
|
|
18971
|
+
x2 = array[i2] = [value[0], value[1].value];
|
|
18972
|
+
assert(x2[1] !== null);
|
|
18973
18973
|
left = 0;
|
|
18974
18974
|
right = i2;
|
|
18975
18975
|
while (left < right) {
|
|
18976
18976
|
pivot = left + (right - left >> 1);
|
|
18977
|
-
if (array[pivot][0] <=
|
|
18977
|
+
if (array[pivot][0] <= x2[0]) {
|
|
18978
18978
|
left = pivot + 1;
|
|
18979
18979
|
} else {
|
|
18980
18980
|
right = pivot;
|
|
@@ -18985,7 +18985,7 @@ var require_headers = __commonJS({
|
|
|
18985
18985
|
while (j2 > left) {
|
|
18986
18986
|
array[j2] = array[--j2];
|
|
18987
18987
|
}
|
|
18988
|
-
array[left] =
|
|
18988
|
+
array[left] = x2;
|
|
18989
18989
|
}
|
|
18990
18990
|
}
|
|
18991
18991
|
if (!iterator.next().done) {
|
|
@@ -26059,15 +26059,15 @@ function readFileConfig() {
|
|
|
26059
26059
|
return out;
|
|
26060
26060
|
}
|
|
26061
26061
|
function envInt(name) {
|
|
26062
|
-
const
|
|
26063
|
-
if (
|
|
26064
|
-
const n3 = parseInt(
|
|
26062
|
+
const v3 = process.env[name];
|
|
26063
|
+
if (v3 === void 0) return void 0;
|
|
26064
|
+
const n3 = parseInt(v3, 10);
|
|
26065
26065
|
return Number.isNaN(n3) ? void 0 : n3;
|
|
26066
26066
|
}
|
|
26067
26067
|
function envBool(name) {
|
|
26068
|
-
const
|
|
26069
|
-
if (
|
|
26070
|
-
return
|
|
26068
|
+
const v3 = process.env[name];
|
|
26069
|
+
if (v3 === void 0) return void 0;
|
|
26070
|
+
return v3 === "1" || v3.toLowerCase() === "true";
|
|
26071
26071
|
}
|
|
26072
26072
|
function loadConfig() {
|
|
26073
26073
|
const file = readFileConfig();
|
|
@@ -26107,10 +26107,10 @@ import { createRequire as createRequire13 } from "node:module";
|
|
|
26107
26107
|
import { createRequire } from "node:module";
|
|
26108
26108
|
var require2 = createRequire(import.meta.url);
|
|
26109
26109
|
|
|
26110
|
-
// node_modules/@ours.network/sdk/dist/chunk-
|
|
26110
|
+
// node_modules/@ours.network/sdk/dist/chunk-D4OQPCKS.js
|
|
26111
26111
|
import { createRequire as createRequire10 } from "node:module";
|
|
26112
26112
|
|
|
26113
|
-
// node_modules/@ours.network/sdk/dist/chunk-
|
|
26113
|
+
// node_modules/@ours.network/sdk/dist/chunk-S2XNVXIH.js
|
|
26114
26114
|
import { createRequire as createRequire7 } from "node:module";
|
|
26115
26115
|
|
|
26116
26116
|
// node_modules/@ours.network/sdk/dist/chunk-IWDJ2GWC.js
|
|
@@ -26225,11 +26225,11 @@ function O(e, i2 = 65536, o2 = false) {
|
|
|
26225
26225
|
if (o2) {
|
|
26226
26226
|
n.fsyncSync(r2);
|
|
26227
26227
|
for (let c2 = u(e); ; c2 = u(c2)) {
|
|
26228
|
-
let
|
|
26228
|
+
let E4 = n.openSync(c2, n.constants.O_RDONLY | n.constants.O_DIRECTORY | n.constants.O_NOFOLLOW);
|
|
26229
26229
|
try {
|
|
26230
|
-
n.fsyncSync(
|
|
26230
|
+
n.fsyncSync(E4);
|
|
26231
26231
|
} finally {
|
|
26232
|
-
n.closeSync(
|
|
26232
|
+
n.closeSync(E4);
|
|
26233
26233
|
}
|
|
26234
26234
|
if (c2 === u(c2)) break;
|
|
26235
26235
|
}
|
|
@@ -26281,7 +26281,7 @@ function w(e) {
|
|
|
26281
26281
|
return i2.trimEnd();
|
|
26282
26282
|
}
|
|
26283
26283
|
|
|
26284
|
-
// node_modules/@ours.network/sdk/dist/chunk-
|
|
26284
|
+
// node_modules/@ours.network/sdk/dist/chunk-S2XNVXIH.js
|
|
26285
26285
|
var require8 = createRequire7(import.meta.url);
|
|
26286
26286
|
function l(d5, e = /* @__PURE__ */ new Set()) {
|
|
26287
26287
|
if (d5 === null || typeof d5 == "string" || typeof d5 == "boolean") return true;
|
|
@@ -26305,8 +26305,8 @@ var P = class {
|
|
|
26305
26305
|
commandHandlers = /* @__PURE__ */ new Map();
|
|
26306
26306
|
constructor(e) {
|
|
26307
26307
|
if (e.credentialPath !== void 0 && e.apiToken !== void 0) throw new Error("Credential path cannot be combined with an explicit API token");
|
|
26308
|
-
if ("serverCertificate" in e && e.serverCertificate !== void 0) throw new Error("
|
|
26309
|
-
if (new URL(e.url).protocol !== "http:") throw new Error("
|
|
26308
|
+
if ("serverCertificate" in e && e.serverCertificate !== void 0) throw new Error("Custom serverCertificate is not supported; HTTPS uses Node certificate trust, including NODE_EXTRA_CA_CERTS");
|
|
26309
|
+
if (new URL(e.url).protocol !== "http:" && new URL(e.url).protocol !== "https:") throw new Error("Client requires an HTTP or HTTPS daemon endpoint");
|
|
26310
26310
|
if (this.base = e.url.replace(/\/+$/, ""), this.sessionMode = e.sessionMode ?? "local", this.sessionMode !== "local" && this.sessionMode !== "external") throw new Error("Invalid sessionMode");
|
|
26311
26311
|
if (this.sessionMode === "external" && !e.leaseToken) throw new Error("External ownership requires a stable caller-supplied leaseToken");
|
|
26312
26312
|
this.leaseToken = e.leaseToken, this.clientPid = e.clientPid ?? process.pid, this.explicitApiToken = e.apiToken, this.credentialPath = e.credentialPath, this.fetchImpl = e.fetch ?? globalThis.fetch;
|
|
@@ -26475,7 +26475,7 @@ var P = class {
|
|
|
26475
26475
|
if (!a4 || typeof a4 != "object" || Array.isArray(a4) || Object.keys(a4).length !== 2 || typeof a4.command != "string" || !("arguments" in a4)) throw new Error("invalid command payload");
|
|
26476
26476
|
let p3 = a4, m3 = p3.command, c2 = this.commandHandlers.get(m3);
|
|
26477
26477
|
if (!c2) throw new Error("handler not registered");
|
|
26478
|
-
let
|
|
26478
|
+
let I4 = Object.freeze({ sender_cid: n3.from.id, sender_name: n3.from.name, request_wire_id: n3.wire_id }), y4 = await c2(p3.arguments, I4);
|
|
26479
26479
|
if (!l(y4)) throw new Error("handler returned a non-JSON value");
|
|
26480
26480
|
s5 = { ok: true, result: y4 };
|
|
26481
26481
|
} catch {
|
|
@@ -26615,11 +26615,11 @@ var _ = 100 * 1024 * 1024;
|
|
|
26615
26615
|
var s3 = { brokerUrl: "wss://broker1.ours.network", port: 3050, stateDir: a2(y(), ".ours"), gcIntervalMs: 36e5, historyMaxBytes: _, apiVisibility: "owner", apiAuthMode: "legacy" };
|
|
26616
26616
|
var I = "daemon-token";
|
|
26617
26617
|
|
|
26618
|
-
// node_modules/@ours.network/sdk/dist/chunk-
|
|
26618
|
+
// node_modules/@ours.network/sdk/dist/chunk-D4OQPCKS.js
|
|
26619
26619
|
import { randomBytes as A } from "node:crypto";
|
|
26620
26620
|
import { readFileSync as P2 } from "node:fs";
|
|
26621
|
-
import { homedir as
|
|
26622
|
-
import { join as D, resolve as
|
|
26621
|
+
import { homedir as F } from "node:os";
|
|
26622
|
+
import { join as D, resolve as E } from "node:path";
|
|
26623
26623
|
var require11 = createRequire10(import.meta.url);
|
|
26624
26624
|
var d3 = class extends Error {
|
|
26625
26625
|
constructor(o2, r2) {
|
|
@@ -26628,7 +26628,7 @@ var d3 = class extends Error {
|
|
|
26628
26628
|
this.name = "DaemonSelectionError";
|
|
26629
26629
|
}
|
|
26630
26630
|
};
|
|
26631
|
-
var
|
|
26631
|
+
var v = class extends d3 {
|
|
26632
26632
|
constructor(o2, r2, a4 = {}) {
|
|
26633
26633
|
super("DAEMON_UNAVAILABLE", `no ours daemon is running at ${o2} for state directory ${JSON.stringify(r2)}. Install the operator CLI with \`npm install --global @ours.network/cli\`, then start the shared daemon with \`ours daemon start\` or install/start its per-user service through \`ours daemon install-service\`. SDK applications attach to the shared daemon and do not start an embedded daemon.`);
|
|
26634
26634
|
this.endpoint = o2;
|
|
@@ -26637,23 +26637,23 @@ var N = class extends d3 {
|
|
|
26637
26637
|
}
|
|
26638
26638
|
};
|
|
26639
26639
|
var L = s3.port;
|
|
26640
|
-
var
|
|
26641
|
-
var
|
|
26640
|
+
var I2 = I;
|
|
26641
|
+
var V = ".ours";
|
|
26642
26642
|
var $ = ["explicit", "environment", "config-file"];
|
|
26643
26643
|
function q(e = {}) {
|
|
26644
26644
|
let t3 = e.env ?? process.env;
|
|
26645
26645
|
if (t3.OURS_TLS_CERT !== void 0 || t3.OURS_TLS_KEY !== void 0) throw new d3("INCOHERENT_SELECTION", "Daemon TLS is not supported in V1; remove OURS_TLS_CERT/OURS_TLS_KEY and explicitly configure HTTP");
|
|
26646
|
-
if (e.endpoint !== void 0 && new URL(e.endpoint).protocol !== "http:") throw new d3("INCOHERENT_SELECTION", "
|
|
26647
|
-
let o2 = e.readTextFile ?? ((u3) => P2(u3, "utf8")), r2 = e.homeDir ??
|
|
26646
|
+
if (e.endpoint !== void 0 && new URL(e.endpoint).protocol !== "http:" && new URL(e.endpoint).protocol !== "https:") throw new d3("INCOHERENT_SELECTION", "Client requires an HTTP or HTTPS daemon endpoint");
|
|
26647
|
+
let o2 = e.readTextFile ?? ((u3) => P2(u3, "utf8")), r2 = e.homeDir ?? F(), a4 = T2(t3, "OURS_INSTANCE");
|
|
26648
26648
|
if (a4 !== void 0) throw new d3("INCOHERENT_SELECTION", `OURS_INSTANCE=${JSON.stringify(a4)} is set, but named daemon instances are not implemented. Select the daemon with an explicit endpoint/port option or with OURS_PORT, and unset OURS_INSTANCE.`);
|
|
26649
26649
|
if (e.stateDir !== void 0 && e.expectStateDir !== void 0) {
|
|
26650
|
-
let u3 =
|
|
26650
|
+
let u3 = E(e.stateDir), p3 = E(e.expectStateDir);
|
|
26651
26651
|
if (u3 !== p3) throw new d3("INCOHERENT_SELECTION", `stateDir ${JSON.stringify(u3)} and expectStateDir ${JSON.stringify(p3)} name different directories. The state directory decides which token is read; the expected one decides which daemon that token may be sent to. Reconcile them, or pass only one.`);
|
|
26652
26652
|
}
|
|
26653
|
-
let s5 = j(e.configPath, T2(t3, "OURS_CONFIG")), n3 = s5 ? G(s5.value, o2) : {}, i2 = U(e.port, M(T2(t3, "OURS_PORT")), n3.port, L), c2 = U(e.stateDir ?? e.expectStateDir, T2(t3, "OURS_STATE_DIR"), n3.stateDir, D(r2,
|
|
26653
|
+
let s5 = j(e.configPath, T2(t3, "OURS_CONFIG")), n3 = s5 ? G(s5.value, o2) : {}, i2 = U(e.port, M(T2(t3, "OURS_PORT")), n3.port, L), c2 = U(e.stateDir ?? e.expectStateDir, T2(t3, "OURS_STATE_DIR"), n3.stateDir, D(r2, V)), l3 = { value: E(c2.value), source: c2.source }, f2 = e.endpoint !== void 0 ? { value: K(e.endpoint), source: "explicit" } : { value: `http://127.0.0.1:${i2.value}`, source: i2.source }, h3 = T2(t3, "OURS_API_TOKEN");
|
|
26654
26654
|
J({ endpointSelected: e.endpoint !== void 0 || i2.source !== "default", endpointSource: f2.source, stateDirIntentional: $.includes(l3.source), stateDirSource: l3.source, hasExplicitToken: e.token !== void 0 && e.token !== "", hasEnvToken: h3 !== void 0, requireExplicitSelection: e.requireExplicitSelection === true, portSource: i2.source });
|
|
26655
|
-
let
|
|
26656
|
-
return { baseUrl: f2, port: i2, stateDir: l3, expectStateDir: e.expectStateDir !== void 0 ?
|
|
26655
|
+
let w3 = H(e.token, h3, n3, l3, e.readTextFile);
|
|
26656
|
+
return { baseUrl: f2, port: i2, stateDir: l3, expectStateDir: e.expectStateDir !== void 0 ? E(e.expectStateDir) : l3.value, ...w3 ? { token: w3 } : {}, ...s5 ? { configPath: s5 } : {} };
|
|
26657
26657
|
}
|
|
26658
26658
|
function ne(e) {
|
|
26659
26659
|
return { baseUrl: e.baseUrl.value, baseUrlSource: e.baseUrl.source, port: e.port.value, portSource: e.port.source, stateDir: e.stateDir.value, stateDirSource: e.stateDir.source, expectStateDir: e.expectStateDir, tokenSource: e.token?.source ?? "none", configPath: e.configPath?.value ?? null };
|
|
@@ -26676,11 +26676,11 @@ function H(e, t3, o2, r2, a4) {
|
|
|
26676
26676
|
let s5 = o2.apiToken?.trim();
|
|
26677
26677
|
if (s5) return { value: s5, source: "config-file" };
|
|
26678
26678
|
if (a4 === void 0) {
|
|
26679
|
-
let n3 = h(D(r2.value,
|
|
26679
|
+
let n3 = h(D(r2.value, I2), false);
|
|
26680
26680
|
return n3 ? { value: n3.token, source: "token-file" } : void 0;
|
|
26681
26681
|
}
|
|
26682
26682
|
try {
|
|
26683
|
-
let n3 = a4(D(r2.value,
|
|
26683
|
+
let n3 = a4(D(r2.value, I2)).trim();
|
|
26684
26684
|
if (n3) return { value: n3, source: "token-file" };
|
|
26685
26685
|
} catch {
|
|
26686
26686
|
}
|
|
@@ -26750,16 +26750,16 @@ async function B(e, t3 = {}) {
|
|
|
26750
26750
|
if (!i2.ok) throw new d3("INCOHERENT_SELECTION", `${e.baseUrl.value}/state-dir answered HTTP ${i2.status}, so the daemon at that address could not be identified. Refusing to send a credential to it.`);
|
|
26751
26751
|
s5 = await i2.json();
|
|
26752
26752
|
} catch (i2) {
|
|
26753
|
-
throw i2 instanceof d3 ? i2 : new
|
|
26753
|
+
throw i2 instanceof d3 ? i2 : new v(e.baseUrl.value, e.expectStateDir, { cause: i2 });
|
|
26754
26754
|
} finally {
|
|
26755
26755
|
clearTimeout(a4);
|
|
26756
26756
|
}
|
|
26757
|
-
let n3 = typeof s5.stateDir == "string" ?
|
|
26757
|
+
let n3 = typeof s5.stateDir == "string" ? E(s5.stateDir) : null;
|
|
26758
26758
|
if (n3 === null) throw new d3("INCOHERENT_SELECTION", `${e.baseUrl.value}/state-dir did not report a state directory, so this is not an ours daemon or not one this client understands. Refusing to send a credential to it.`);
|
|
26759
26759
|
if (n3 !== e.expectStateDir) throw new d3("INCOHERENT_SELECTION", `the daemon at ${e.baseUrl.value} owns state directory ${JSON.stringify(n3)}, but this selection expects ${JSON.stringify(e.expectStateDir)}. The token belongs to the expected directory, so it is NOT being sent. Point the endpoint and the state directory at the same daemon.`);
|
|
26760
26760
|
}
|
|
26761
26761
|
async function re(e = {}) {
|
|
26762
|
-
if ("serverCertificate" in e && e.serverCertificate !== void 0) throw new Error("
|
|
26762
|
+
if ("serverCertificate" in e && e.serverCertificate !== void 0) throw new Error("Custom serverCertificate is not supported; HTTPS uses Node certificate trust, including NODE_EXTRA_CA_CERTS");
|
|
26763
26763
|
let t3 = e.env ?? process.env;
|
|
26764
26764
|
if (t3.OURS_TLS_CERT !== void 0 || t3.OURS_TLS_KEY !== void 0) throw new Error("Daemon TLS is not supported in V1; remove OURS_TLS_CERT/OURS_TLS_KEY and explicitly configure HTTP");
|
|
26765
26765
|
let { leaseToken: o2, clientPid: r2, sessionMode: a4 = "local", fetch: s5, expectedInstanceId: n3, requiredCapabilities: i2, credentialPath: c2, ...l3 } = e;
|
|
@@ -26770,12 +26770,12 @@ async function re(e = {}) {
|
|
|
26770
26770
|
}
|
|
26771
26771
|
if (c2 !== void 0 && (n3 === void 0 || l3.token !== void 0)) throw new Error("Credential path requires explicit daemon identity and cannot be combined with a token");
|
|
26772
26772
|
if (n3 !== void 0) {
|
|
26773
|
-
let { endpoint: h3, token:
|
|
26773
|
+
let { endpoint: h3, token: w3 } = l3;
|
|
26774
26774
|
if (!h3) throw new Error("Instance selection requires an explicit endpoint");
|
|
26775
26775
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(n3)) throw new Error("Expected daemon instance must be a lowercase UUID");
|
|
26776
26776
|
if (s5 !== void 0) throw new Error("Instance selection cannot use an injected fetch");
|
|
26777
26777
|
let u3 = new URL(h3);
|
|
26778
|
-
if (u3.protocol !== "http:" || u3.username || u3.password || u3.pathname !== "/" || u3.search || u3.hash) throw new Error("
|
|
26778
|
+
if (u3.protocol !== "http:" && u3.protocol !== "https:" || u3.username || u3.password || u3.pathname !== "/" || u3.search || u3.hash) throw new Error("Instance selection requires an HTTP or HTTPS origin endpoint");
|
|
26779
26779
|
if (i2 !== void 0 && !Array.isArray(i2)) throw new Error("Instance selection requires a nonempty capability list");
|
|
26780
26780
|
let p3 = [...i2 ?? ["external-sessions-v1"]];
|
|
26781
26781
|
if (!p3.length || p3.some((g3) => typeof g3 != "string" || !g3.trim())) throw new Error("Instance selection requires a nonempty capability list");
|
|
@@ -26787,13 +26787,13 @@ async function re(e = {}) {
|
|
|
26787
26787
|
let b3 = m3.capabilities;
|
|
26788
26788
|
if (!Array.isArray(b3) || b3.some((S3) => typeof S3 != "string") || p3.some((S3) => !b3.includes(S3))) throw new Error("Daemon does not support the required capabilities; refusing local-mode fallback");
|
|
26789
26789
|
}
|
|
26790
|
-
let O3 = c2 === void 0 ?
|
|
26790
|
+
let O3 = c2 === void 0 ? w3 : w(c2);
|
|
26791
26791
|
if (typeof O3 != "string" || !O3.trim()) throw new Error("Instance selection requires an explicit API token after daemon verification");
|
|
26792
26792
|
return new P({ url: h3, sessionMode: a4, ...c2 === void 0 ? { apiToken: O3 } : { credentialPath: c2 }, leaseToken: o2 ?? A(32).toString("hex"), clientPid: r2 });
|
|
26793
26793
|
}
|
|
26794
26794
|
if (i2 !== void 0) throw new Error("Capability selection requires an expected daemon instance");
|
|
26795
26795
|
let f2 = q(l3);
|
|
26796
|
-
return await B(f2, { fetch: s5 }), new P({ url: f2.baseUrl.value, leaseToken: o2 ?? A(32).toString("hex"), clientPid: r2, ...f2.token?.source === "token-file" && l3.readTextFile === void 0 ? { credentialPath: D(f2.expectStateDir,
|
|
26796
|
+
return await B(f2, { fetch: s5 }), new P({ url: f2.baseUrl.value, leaseToken: o2 ?? A(32).toString("hex"), clientPid: r2, ...f2.token?.source === "token-file" && l3.readTextFile === void 0 ? { credentialPath: D(f2.expectStateDir, I2) } : { apiToken: f2.token?.value }, fetch: s5 });
|
|
26797
26797
|
}
|
|
26798
26798
|
|
|
26799
26799
|
// node_modules/@ours.network/sdk/dist/chunk-Y3VPZJTG.js
|
|
@@ -27962,9 +27962,9 @@ function pruneRows(messages, nowMs, retentionDays = RETENTION_DAYS, maxRows = MA
|
|
|
27962
27962
|
}
|
|
27963
27963
|
return removed;
|
|
27964
27964
|
}
|
|
27965
|
-
function validRow(
|
|
27966
|
-
if (!
|
|
27967
|
-
const r2 =
|
|
27965
|
+
function validRow(v3) {
|
|
27966
|
+
if (!v3 || typeof v3 !== "object") return null;
|
|
27967
|
+
const r2 = v3;
|
|
27968
27968
|
if (typeof r2.chatId !== "string" || !r2.chatId) return null;
|
|
27969
27969
|
if (typeof r2.messageId !== "number" || !Number.isSafeInteger(r2.messageId) || r2.messageId <= 0) return null;
|
|
27970
27970
|
const dir = r2.direction === "outbound" ? "outbound" : "inbound";
|
|
@@ -27990,16 +27990,16 @@ function parseMapFile(raw, nowMs) {
|
|
|
27990
27990
|
if (!parsed || typeof parsed !== "object") return out;
|
|
27991
27991
|
const p3 = parsed;
|
|
27992
27992
|
if (p3.messages && typeof p3.messages === "object") {
|
|
27993
|
-
for (const [wireId,
|
|
27993
|
+
for (const [wireId, v3] of Object.entries(p3.messages)) {
|
|
27994
27994
|
if (!wireId) continue;
|
|
27995
|
-
const row = validRow(
|
|
27995
|
+
const row = validRow(v3);
|
|
27996
27996
|
if (row) out.messages[wireId] = row;
|
|
27997
27997
|
}
|
|
27998
27998
|
}
|
|
27999
27999
|
const now = new Date(nowMs).toISOString();
|
|
28000
28000
|
if (p3.settings && typeof p3.settings === "object") {
|
|
28001
|
-
for (const [cid,
|
|
28002
|
-
if (cid) out.settings[cid] = normalizeSettings(
|
|
28001
|
+
for (const [cid, v3] of Object.entries(p3.settings)) {
|
|
28002
|
+
if (cid) out.settings[cid] = normalizeSettings(v3, now);
|
|
28003
28003
|
}
|
|
28004
28004
|
}
|
|
28005
28005
|
pruneRows(out.messages, nowMs);
|
|
@@ -28358,7 +28358,7 @@ function registerRoute(conn) {
|
|
|
28358
28358
|
return null;
|
|
28359
28359
|
}
|
|
28360
28360
|
function unregisterRoute(conn) {
|
|
28361
|
-
for (const [k2,
|
|
28361
|
+
for (const [k2, v3] of conn.bot.exact) if (v3 === conn) conn.bot.exact.delete(k2);
|
|
28362
28362
|
if (conn.bot.catchAll === conn) conn.bot.catchAll = null;
|
|
28363
28363
|
}
|
|
28364
28364
|
function routeSlotConflict(bot, chatId, threadId) {
|
|
@@ -28414,7 +28414,7 @@ function watchRoute(conn) {
|
|
|
28414
28414
|
} else if (event === "receipt_received") {
|
|
28415
28415
|
const senderCid = typeof ev.sender_id === "string" ? ev.sender_id : "";
|
|
28416
28416
|
const kind = ev.kind === "delivered" || ev.kind === "read" ? ev.kind : null;
|
|
28417
|
-
const wireIds = Array.isArray(ev.wire_ids) ? ev.wire_ids.filter((
|
|
28417
|
+
const wireIds = Array.isArray(ev.wire_ids) ? ev.wire_ids.filter((v3) => typeof v3 === "string" && v3.length > 0) : [];
|
|
28418
28418
|
if (senderCid && kind && wireIds.length) {
|
|
28419
28419
|
await applyReceiptReactions(conn, senderCid, kind, wireIds);
|
|
28420
28420
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/tg-connector",
|
|
3
|
-
"version": "1.0.1-nightly.
|
|
3
|
+
"version": "1.0.1-nightly.2",
|
|
4
4
|
"description": "Bridge Telegram bots to ours.network agents \u2014 attaches to an already-running ours daemon and bridges one Telegram chat/topic to one agent per route. Run `ours-tg-connector add_new_connection`.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "FSL-1.1-Apache-2.0",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"test:v1-lifecycle": "node tests/v1-lifecycle.integration.mjs cli"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ours.network/sdk": "3.8.1-nightly.
|
|
40
|
+
"@ours.network/sdk": "3.8.1-nightly.4",
|
|
41
41
|
"undici": "^7.28.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@ours.network/cli": "2.8.1-nightly.
|
|
44
|
+
"@ours.network/cli": "2.8.1-nightly.2",
|
|
45
45
|
"@types/node": "^20.14.0",
|
|
46
46
|
"esbuild": "^0.24.2",
|
|
47
47
|
"tsx": "^4.19.0",
|