@ours.network/tg-connector 1.0.1-nightly.6 → 1.0.1-nightly.8
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 +356 -305
- package/package.json +4 -4
package/dist/connector.js
CHANGED
|
@@ -4100,21 +4100,21 @@ var require_data_url = __commonJS({
|
|
|
4100
4100
|
function percentDecode(input) {
|
|
4101
4101
|
const length = input.length;
|
|
4102
4102
|
const output = new Uint8Array(length);
|
|
4103
|
-
let
|
|
4103
|
+
let j = 0;
|
|
4104
4104
|
let i = 0;
|
|
4105
4105
|
while (i < length) {
|
|
4106
4106
|
const byte = input[i];
|
|
4107
4107
|
if (byte !== 37) {
|
|
4108
|
-
output[
|
|
4108
|
+
output[j++] = byte;
|
|
4109
4109
|
} else if (byte === 37 && !(isHexCharByte(input[i + 1]) && isHexCharByte(input[i + 2]))) {
|
|
4110
|
-
output[
|
|
4110
|
+
output[j++] = 37;
|
|
4111
4111
|
} else {
|
|
4112
|
-
output[
|
|
4112
|
+
output[j++] = hexByteToNumber(input[i + 1]) << 4 | hexByteToNumber(input[i + 2]);
|
|
4113
4113
|
i += 2;
|
|
4114
4114
|
}
|
|
4115
4115
|
++i;
|
|
4116
4116
|
}
|
|
4117
|
-
return length ===
|
|
4117
|
+
return length === j ? output : output.subarray(0, j);
|
|
4118
4118
|
}
|
|
4119
4119
|
function parseMIMEType(input) {
|
|
4120
4120
|
input = removeHTTPWhitespace(input, true, true);
|
|
@@ -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(
|
|
4449
|
-
if (!FunctionPrototypeSymbolHasInstance(I,
|
|
4448
|
+
webidl.brandCheck = function(V2, I) {
|
|
4449
|
+
if (!FunctionPrototypeSymbolHasInstance(I, V2)) {
|
|
4450
4450
|
const err = new TypeError("Illegal invocation");
|
|
4451
4451
|
err.code = "ERR_INVALID_THIS";
|
|
4452
4452
|
throw err;
|
|
@@ -4454,8 +4454,8 @@ var require_webidl = __commonJS({
|
|
|
4454
4454
|
};
|
|
4455
4455
|
webidl.brandCheckMultiple = function(List) {
|
|
4456
4456
|
const prototypes = List.map((c) => webidl.util.MakeTypeAssertion(c));
|
|
4457
|
-
return (
|
|
4458
|
-
if (prototypes.every((typeCheck) => !typeCheck(
|
|
4457
|
+
return (V2) => {
|
|
4458
|
+
if (prototypes.every((typeCheck) => !typeCheck(V2))) {
|
|
4459
4459
|
const err = new TypeError("Illegal invocation");
|
|
4460
4460
|
err.code = "ERR_INVALID_THIS";
|
|
4461
4461
|
throw err;
|
|
@@ -4477,10 +4477,10 @@ var require_webidl = __commonJS({
|
|
|
4477
4477
|
});
|
|
4478
4478
|
};
|
|
4479
4479
|
webidl.util.MakeTypeAssertion = function(I) {
|
|
4480
|
-
return (
|
|
4480
|
+
return (O3) => FunctionPrototypeSymbolHasInstance(I, O3);
|
|
4481
4481
|
};
|
|
4482
|
-
webidl.util.Type = function(
|
|
4483
|
-
switch (typeof
|
|
4482
|
+
webidl.util.Type = function(V2) {
|
|
4483
|
+
switch (typeof V2) {
|
|
4484
4484
|
case "undefined":
|
|
4485
4485
|
return UNDEFINED;
|
|
4486
4486
|
case "boolean":
|
|
@@ -4495,7 +4495,7 @@ var require_webidl = __commonJS({
|
|
|
4495
4495
|
return BIGINT;
|
|
4496
4496
|
case "function":
|
|
4497
4497
|
case "object": {
|
|
4498
|
-
if (
|
|
4498
|
+
if (V2 === null) {
|
|
4499
4499
|
return NULL;
|
|
4500
4500
|
}
|
|
4501
4501
|
return OBJECT;
|
|
@@ -4534,7 +4534,7 @@ var require_webidl = __commonJS({
|
|
|
4534
4534
|
};
|
|
4535
4535
|
webidl.util.markAsUncloneable = runtimeFeatures.has("markAsUncloneable") ? __require("node:worker_threads").markAsUncloneable : () => {
|
|
4536
4536
|
};
|
|
4537
|
-
webidl.util.ConvertToInt = function(
|
|
4537
|
+
webidl.util.ConvertToInt = function(V2, bitLength, signedness, flags) {
|
|
4538
4538
|
let upperBound;
|
|
4539
4539
|
let lowerBound;
|
|
4540
4540
|
if (bitLength === 64) {
|
|
@@ -4551,7 +4551,7 @@ 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 x2 = Number(
|
|
4554
|
+
let x2 = Number(V2);
|
|
4555
4555
|
if (x2 === 0) {
|
|
4556
4556
|
x2 = 0;
|
|
4557
4557
|
}
|
|
@@ -4559,7 +4559,7 @@ var require_webidl = __commonJS({
|
|
|
4559
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
|
-
message: `Could not convert ${webidl.util.Stringify(
|
|
4562
|
+
message: `Could not convert ${webidl.util.Stringify(V2)} to an integer.`
|
|
4563
4563
|
});
|
|
4564
4564
|
}
|
|
4565
4565
|
x2 = webidl.util.IntegerPart(x2);
|
|
@@ -4597,45 +4597,45 @@ var require_webidl = __commonJS({
|
|
|
4597
4597
|
}
|
|
4598
4598
|
return r;
|
|
4599
4599
|
};
|
|
4600
|
-
webidl.util.Stringify = function(
|
|
4601
|
-
const type = webidl.util.Type(
|
|
4600
|
+
webidl.util.Stringify = function(V2) {
|
|
4601
|
+
const type = webidl.util.Type(V2);
|
|
4602
4602
|
switch (type) {
|
|
4603
4603
|
case SYMBOL:
|
|
4604
|
-
return `Symbol(${
|
|
4604
|
+
return `Symbol(${V2.description})`;
|
|
4605
4605
|
case OBJECT:
|
|
4606
|
-
return inspect(
|
|
4606
|
+
return inspect(V2);
|
|
4607
4607
|
case STRING:
|
|
4608
|
-
return `"${
|
|
4608
|
+
return `"${V2}"`;
|
|
4609
4609
|
case BIGINT:
|
|
4610
|
-
return `${
|
|
4610
|
+
return `${V2}n`;
|
|
4611
4611
|
default:
|
|
4612
|
-
return `${
|
|
4612
|
+
return `${V2}`;
|
|
4613
4613
|
}
|
|
4614
4614
|
};
|
|
4615
|
-
webidl.util.IsResizableArrayBuffer = function(
|
|
4616
|
-
if (types.isArrayBuffer(
|
|
4617
|
-
return
|
|
4615
|
+
webidl.util.IsResizableArrayBuffer = function(V2) {
|
|
4616
|
+
if (types.isArrayBuffer(V2)) {
|
|
4617
|
+
return V2.resizable;
|
|
4618
4618
|
}
|
|
4619
|
-
if (types.isSharedArrayBuffer(
|
|
4620
|
-
return
|
|
4619
|
+
if (types.isSharedArrayBuffer(V2)) {
|
|
4620
|
+
return V2.growable;
|
|
4621
4621
|
}
|
|
4622
4622
|
throw webidl.errors.exception({
|
|
4623
4623
|
header: "IsResizableArrayBuffer",
|
|
4624
|
-
message: `"${webidl.util.Stringify(
|
|
4624
|
+
message: `"${webidl.util.Stringify(V2)}" is not an array buffer.`
|
|
4625
4625
|
});
|
|
4626
4626
|
};
|
|
4627
4627
|
webidl.util.HasFlag = function(flags, attributes) {
|
|
4628
4628
|
return typeof flags === "number" && (flags & attributes) === attributes;
|
|
4629
4629
|
};
|
|
4630
4630
|
webidl.sequenceConverter = function(converter) {
|
|
4631
|
-
return (
|
|
4632
|
-
if (webidl.util.Type(
|
|
4631
|
+
return (V2, prefix, argument, Iterable) => {
|
|
4632
|
+
if (webidl.util.Type(V2) !== OBJECT) {
|
|
4633
4633
|
throw webidl.errors.exception({
|
|
4634
4634
|
header: prefix,
|
|
4635
|
-
message: `${argument} (${webidl.util.Stringify(
|
|
4635
|
+
message: `${argument} (${webidl.util.Stringify(V2)}) is not iterable.`
|
|
4636
4636
|
});
|
|
4637
4637
|
}
|
|
4638
|
-
const method = typeof Iterable === "function" ? Iterable() :
|
|
4638
|
+
const method = typeof Iterable === "function" ? Iterable() : V2?.[Symbol.iterator]?.();
|
|
4639
4639
|
const seq = [];
|
|
4640
4640
|
let index = 0;
|
|
4641
4641
|
if (method === void 0 || typeof method.next !== "function") {
|
|
@@ -4655,30 +4655,30 @@ var require_webidl = __commonJS({
|
|
|
4655
4655
|
};
|
|
4656
4656
|
};
|
|
4657
4657
|
webidl.recordConverter = function(keyConverter, valueConverter) {
|
|
4658
|
-
return (
|
|
4659
|
-
if (webidl.util.Type(
|
|
4658
|
+
return (O3, prefix, argument) => {
|
|
4659
|
+
if (webidl.util.Type(O3) !== OBJECT) {
|
|
4660
4660
|
throw webidl.errors.exception({
|
|
4661
4661
|
header: prefix,
|
|
4662
|
-
message: `${argument} ("${webidl.util.TypeValueToString(
|
|
4662
|
+
message: `${argument} ("${webidl.util.TypeValueToString(O3)}") is not an Object.`
|
|
4663
4663
|
});
|
|
4664
4664
|
}
|
|
4665
4665
|
const result = {};
|
|
4666
|
-
if (!types.isProxy(
|
|
4667
|
-
const keys2 = [...Object.getOwnPropertyNames(
|
|
4666
|
+
if (!types.isProxy(O3)) {
|
|
4667
|
+
const keys2 = [...Object.getOwnPropertyNames(O3), ...Object.getOwnPropertySymbols(O3)];
|
|
4668
4668
|
for (const key of keys2) {
|
|
4669
4669
|
const keyName = webidl.util.Stringify(key);
|
|
4670
4670
|
const typedKey = keyConverter(key, prefix, `Key ${keyName} in ${argument}`);
|
|
4671
|
-
const typedValue = valueConverter(
|
|
4671
|
+
const typedValue = valueConverter(O3[key], prefix, `${argument}[${keyName}]`);
|
|
4672
4672
|
result[typedKey] = typedValue;
|
|
4673
4673
|
}
|
|
4674
4674
|
return result;
|
|
4675
4675
|
}
|
|
4676
|
-
const keys = Reflect.ownKeys(
|
|
4676
|
+
const keys = Reflect.ownKeys(O3);
|
|
4677
4677
|
for (const key of keys) {
|
|
4678
|
-
const desc = Reflect.getOwnPropertyDescriptor(
|
|
4678
|
+
const desc = Reflect.getOwnPropertyDescriptor(O3, key);
|
|
4679
4679
|
if (desc?.enumerable) {
|
|
4680
4680
|
const typedKey = keyConverter(key, prefix, argument);
|
|
4681
|
-
const typedValue = valueConverter(
|
|
4681
|
+
const typedValue = valueConverter(O3[key], prefix, argument);
|
|
4682
4682
|
result[typedKey] = typedValue;
|
|
4683
4683
|
}
|
|
4684
4684
|
}
|
|
@@ -4686,14 +4686,14 @@ var require_webidl = __commonJS({
|
|
|
4686
4686
|
};
|
|
4687
4687
|
};
|
|
4688
4688
|
webidl.interfaceConverter = function(TypeCheck, name) {
|
|
4689
|
-
return (
|
|
4690
|
-
if (!TypeCheck(
|
|
4689
|
+
return (V2, prefix, argument) => {
|
|
4690
|
+
if (!TypeCheck(V2)) {
|
|
4691
4691
|
throw webidl.errors.exception({
|
|
4692
4692
|
header: prefix,
|
|
4693
|
-
message: `Expected ${argument} ("${webidl.util.Stringify(
|
|
4693
|
+
message: `Expected ${argument} ("${webidl.util.Stringify(V2)}") to be an instance of ${name}.`
|
|
4694
4694
|
});
|
|
4695
4695
|
}
|
|
4696
|
-
return
|
|
4696
|
+
return V2;
|
|
4697
4697
|
};
|
|
4698
4698
|
};
|
|
4699
4699
|
webidl.dictionaryConverter = function(converters) {
|
|
@@ -4736,11 +4736,11 @@ var require_webidl = __commonJS({
|
|
|
4736
4736
|
};
|
|
4737
4737
|
};
|
|
4738
4738
|
webidl.nullableConverter = function(converter) {
|
|
4739
|
-
return (
|
|
4740
|
-
if (
|
|
4741
|
-
return
|
|
4739
|
+
return (V2, prefix, argument) => {
|
|
4740
|
+
if (V2 === null) {
|
|
4741
|
+
return V2;
|
|
4742
4742
|
}
|
|
4743
|
-
return converter(
|
|
4743
|
+
return converter(V2, prefix, argument);
|
|
4744
4744
|
};
|
|
4745
4745
|
};
|
|
4746
4746
|
webidl.is.USVString = function(value) {
|
|
@@ -4753,8 +4753,8 @@ var require_webidl = __commonJS({
|
|
|
4753
4753
|
webidl.is.URL = webidl.util.MakeTypeAssertion(URL);
|
|
4754
4754
|
webidl.is.AbortSignal = webidl.util.MakeTypeAssertion(AbortSignal);
|
|
4755
4755
|
webidl.is.MessagePort = webidl.util.MakeTypeAssertion(MessagePort);
|
|
4756
|
-
webidl.is.BufferSource = function(
|
|
4757
|
-
return types.isArrayBuffer(
|
|
4756
|
+
webidl.is.BufferSource = function(V2) {
|
|
4757
|
+
return types.isArrayBuffer(V2) || ArrayBuffer.isView(V2) && types.isArrayBuffer(V2.buffer);
|
|
4758
4758
|
};
|
|
4759
4759
|
webidl.util.getCopyOfBytesHeldByBufferSource = function(bufferSource) {
|
|
4760
4760
|
const jsBufferSource = bufferSource;
|
|
@@ -4777,26 +4777,26 @@ var require_webidl = __commonJS({
|
|
|
4777
4777
|
bytes.set(view);
|
|
4778
4778
|
return bytes;
|
|
4779
4779
|
};
|
|
4780
|
-
webidl.converters.DOMString = function(
|
|
4781
|
-
if (
|
|
4780
|
+
webidl.converters.DOMString = function(V2, prefix, argument, flags) {
|
|
4781
|
+
if (V2 === null && webidl.util.HasFlag(flags, webidl.attributes.LegacyNullToEmptyString)) {
|
|
4782
4782
|
return "";
|
|
4783
4783
|
}
|
|
4784
|
-
if (typeof
|
|
4784
|
+
if (typeof V2 === "symbol") {
|
|
4785
4785
|
throw webidl.errors.exception({
|
|
4786
4786
|
header: prefix,
|
|
4787
4787
|
message: `${argument} is a symbol, which cannot be converted to a DOMString.`
|
|
4788
4788
|
});
|
|
4789
4789
|
}
|
|
4790
|
-
return String(
|
|
4790
|
+
return String(V2);
|
|
4791
4791
|
};
|
|
4792
|
-
webidl.converters.ByteString = function(
|
|
4793
|
-
if (typeof
|
|
4792
|
+
webidl.converters.ByteString = function(V2, prefix, argument) {
|
|
4793
|
+
if (typeof V2 === "symbol") {
|
|
4794
4794
|
throw webidl.errors.exception({
|
|
4795
4795
|
header: prefix,
|
|
4796
4796
|
message: `${argument} is a symbol, which cannot be converted to a ByteString.`
|
|
4797
4797
|
});
|
|
4798
4798
|
}
|
|
4799
|
-
const x2 = String(
|
|
4799
|
+
const x2 = String(V2);
|
|
4800
4800
|
for (let index = 0; index < x2.length; index++) {
|
|
4801
4801
|
if (x2.charCodeAt(index) > 255) {
|
|
4802
4802
|
throw new TypeError(
|
|
@@ -4812,136 +4812,136 @@ var require_webidl = __commonJS({
|
|
|
4812
4812
|
}
|
|
4813
4813
|
return `${value}`.toWellFormed();
|
|
4814
4814
|
};
|
|
4815
|
-
webidl.converters.boolean = function(
|
|
4816
|
-
const x2 = Boolean(
|
|
4815
|
+
webidl.converters.boolean = function(V2) {
|
|
4816
|
+
const x2 = Boolean(V2);
|
|
4817
4817
|
return x2;
|
|
4818
4818
|
};
|
|
4819
|
-
webidl.converters.any = function(
|
|
4820
|
-
return
|
|
4819
|
+
webidl.converters.any = function(V2) {
|
|
4820
|
+
return V2;
|
|
4821
4821
|
};
|
|
4822
|
-
webidl.converters["long long"] = function(
|
|
4823
|
-
const x2 = webidl.util.ConvertToInt(
|
|
4822
|
+
webidl.converters["long long"] = function(V2, prefix, argument) {
|
|
4823
|
+
const x2 = webidl.util.ConvertToInt(V2, 64, "signed", 0, prefix, argument);
|
|
4824
4824
|
return x2;
|
|
4825
4825
|
};
|
|
4826
|
-
webidl.converters["unsigned long long"] = function(
|
|
4827
|
-
const x2 = webidl.util.ConvertToInt(
|
|
4826
|
+
webidl.converters["unsigned long long"] = function(V2, prefix, argument) {
|
|
4827
|
+
const x2 = webidl.util.ConvertToInt(V2, 64, "unsigned", 0, prefix, argument);
|
|
4828
4828
|
return x2;
|
|
4829
4829
|
};
|
|
4830
|
-
webidl.converters["unsigned long"] = function(
|
|
4831
|
-
const x2 = webidl.util.ConvertToInt(
|
|
4830
|
+
webidl.converters["unsigned long"] = function(V2, prefix, argument) {
|
|
4831
|
+
const x2 = webidl.util.ConvertToInt(V2, 32, "unsigned", 0, prefix, argument);
|
|
4832
4832
|
return x2;
|
|
4833
4833
|
};
|
|
4834
|
-
webidl.converters["unsigned short"] = function(
|
|
4835
|
-
const x2 = webidl.util.ConvertToInt(
|
|
4834
|
+
webidl.converters["unsigned short"] = function(V2, prefix, argument, flags) {
|
|
4835
|
+
const x2 = webidl.util.ConvertToInt(V2, 16, "unsigned", flags, prefix, argument);
|
|
4836
4836
|
return x2;
|
|
4837
4837
|
};
|
|
4838
|
-
webidl.converters.ArrayBuffer = function(
|
|
4839
|
-
if (webidl.util.Type(
|
|
4838
|
+
webidl.converters.ArrayBuffer = function(V2, prefix, argument, flags) {
|
|
4839
|
+
if (webidl.util.Type(V2) !== OBJECT || !types.isArrayBuffer(V2)) {
|
|
4840
4840
|
throw webidl.errors.conversionFailed({
|
|
4841
4841
|
prefix,
|
|
4842
|
-
argument: `${argument} ("${webidl.util.Stringify(
|
|
4842
|
+
argument: `${argument} ("${webidl.util.Stringify(V2)}")`,
|
|
4843
4843
|
types: ["ArrayBuffer"]
|
|
4844
4844
|
});
|
|
4845
4845
|
}
|
|
4846
|
-
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(
|
|
4846
|
+
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(V2)) {
|
|
4847
4847
|
throw webidl.errors.exception({
|
|
4848
4848
|
header: prefix,
|
|
4849
4849
|
message: `${argument} cannot be a resizable ArrayBuffer.`
|
|
4850
4850
|
});
|
|
4851
4851
|
}
|
|
4852
|
-
return
|
|
4852
|
+
return V2;
|
|
4853
4853
|
};
|
|
4854
|
-
webidl.converters.SharedArrayBuffer = function(
|
|
4855
|
-
if (webidl.util.Type(
|
|
4854
|
+
webidl.converters.SharedArrayBuffer = function(V2, prefix, argument, flags) {
|
|
4855
|
+
if (webidl.util.Type(V2) !== OBJECT || !types.isSharedArrayBuffer(V2)) {
|
|
4856
4856
|
throw webidl.errors.conversionFailed({
|
|
4857
4857
|
prefix,
|
|
4858
|
-
argument: `${argument} ("${webidl.util.Stringify(
|
|
4858
|
+
argument: `${argument} ("${webidl.util.Stringify(V2)}")`,
|
|
4859
4859
|
types: ["SharedArrayBuffer"]
|
|
4860
4860
|
});
|
|
4861
4861
|
}
|
|
4862
|
-
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(
|
|
4862
|
+
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(V2)) {
|
|
4863
4863
|
throw webidl.errors.exception({
|
|
4864
4864
|
header: prefix,
|
|
4865
4865
|
message: `${argument} cannot be a resizable SharedArrayBuffer.`
|
|
4866
4866
|
});
|
|
4867
4867
|
}
|
|
4868
|
-
return
|
|
4868
|
+
return V2;
|
|
4869
4869
|
};
|
|
4870
|
-
webidl.converters.TypedArray = function(
|
|
4871
|
-
if (webidl.util.Type(
|
|
4870
|
+
webidl.converters.TypedArray = function(V2, T2, prefix, argument, flags) {
|
|
4871
|
+
if (webidl.util.Type(V2) !== OBJECT || !types.isTypedArray(V2) || V2.constructor.name !== T2.name) {
|
|
4872
4872
|
throw webidl.errors.conversionFailed({
|
|
4873
4873
|
prefix,
|
|
4874
|
-
argument: `${argument} ("${webidl.util.Stringify(
|
|
4874
|
+
argument: `${argument} ("${webidl.util.Stringify(V2)}")`,
|
|
4875
4875
|
types: [T2.name]
|
|
4876
4876
|
});
|
|
4877
4877
|
}
|
|
4878
|
-
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowShared) && types.isSharedArrayBuffer(
|
|
4878
|
+
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowShared) && types.isSharedArrayBuffer(V2.buffer)) {
|
|
4879
4879
|
throw webidl.errors.exception({
|
|
4880
4880
|
header: prefix,
|
|
4881
4881
|
message: `${argument} cannot be a view on a shared array buffer.`
|
|
4882
4882
|
});
|
|
4883
4883
|
}
|
|
4884
|
-
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(
|
|
4884
|
+
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(V2.buffer)) {
|
|
4885
4885
|
throw webidl.errors.exception({
|
|
4886
4886
|
header: prefix,
|
|
4887
4887
|
message: `${argument} cannot be a view on a resizable array buffer.`
|
|
4888
4888
|
});
|
|
4889
4889
|
}
|
|
4890
|
-
return
|
|
4890
|
+
return V2;
|
|
4891
4891
|
};
|
|
4892
|
-
webidl.converters.DataView = function(
|
|
4893
|
-
if (webidl.util.Type(
|
|
4892
|
+
webidl.converters.DataView = function(V2, prefix, argument, flags) {
|
|
4893
|
+
if (webidl.util.Type(V2) !== OBJECT || !types.isDataView(V2)) {
|
|
4894
4894
|
throw webidl.errors.conversionFailed({
|
|
4895
4895
|
prefix,
|
|
4896
|
-
argument: `${argument} ("${webidl.util.Stringify(
|
|
4896
|
+
argument: `${argument} ("${webidl.util.Stringify(V2)}")`,
|
|
4897
4897
|
types: ["DataView"]
|
|
4898
4898
|
});
|
|
4899
4899
|
}
|
|
4900
|
-
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowShared) && types.isSharedArrayBuffer(
|
|
4900
|
+
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowShared) && types.isSharedArrayBuffer(V2.buffer)) {
|
|
4901
4901
|
throw webidl.errors.exception({
|
|
4902
4902
|
header: prefix,
|
|
4903
4903
|
message: `${argument} cannot be a view on a shared array buffer.`
|
|
4904
4904
|
});
|
|
4905
4905
|
}
|
|
4906
|
-
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(
|
|
4906
|
+
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(V2.buffer)) {
|
|
4907
4907
|
throw webidl.errors.exception({
|
|
4908
4908
|
header: prefix,
|
|
4909
4909
|
message: `${argument} cannot be a view on a resizable array buffer.`
|
|
4910
4910
|
});
|
|
4911
4911
|
}
|
|
4912
|
-
return
|
|
4912
|
+
return V2;
|
|
4913
4913
|
};
|
|
4914
|
-
webidl.converters.ArrayBufferView = function(
|
|
4915
|
-
if (webidl.util.Type(
|
|
4914
|
+
webidl.converters.ArrayBufferView = function(V2, prefix, argument, flags) {
|
|
4915
|
+
if (webidl.util.Type(V2) !== OBJECT || !types.isArrayBufferView(V2)) {
|
|
4916
4916
|
throw webidl.errors.conversionFailed({
|
|
4917
4917
|
prefix,
|
|
4918
|
-
argument: `${argument} ("${webidl.util.Stringify(
|
|
4918
|
+
argument: `${argument} ("${webidl.util.Stringify(V2)}")`,
|
|
4919
4919
|
types: ["ArrayBufferView"]
|
|
4920
4920
|
});
|
|
4921
4921
|
}
|
|
4922
|
-
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowShared) && types.isSharedArrayBuffer(
|
|
4922
|
+
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowShared) && types.isSharedArrayBuffer(V2.buffer)) {
|
|
4923
4923
|
throw webidl.errors.exception({
|
|
4924
4924
|
header: prefix,
|
|
4925
4925
|
message: `${argument} cannot be a view on a shared array buffer.`
|
|
4926
4926
|
});
|
|
4927
4927
|
}
|
|
4928
|
-
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(
|
|
4928
|
+
if (!webidl.util.HasFlag(flags, webidl.attributes.AllowResizable) && webidl.util.IsResizableArrayBuffer(V2.buffer)) {
|
|
4929
4929
|
throw webidl.errors.exception({
|
|
4930
4930
|
header: prefix,
|
|
4931
4931
|
message: `${argument} cannot be a view on a resizable array buffer.`
|
|
4932
4932
|
});
|
|
4933
4933
|
}
|
|
4934
|
-
return
|
|
4934
|
+
return V2;
|
|
4935
4935
|
};
|
|
4936
|
-
webidl.converters.BufferSource = function(
|
|
4937
|
-
if (types.isArrayBuffer(
|
|
4938
|
-
return webidl.converters.ArrayBuffer(
|
|
4936
|
+
webidl.converters.BufferSource = function(V2, prefix, argument, flags) {
|
|
4937
|
+
if (types.isArrayBuffer(V2)) {
|
|
4938
|
+
return webidl.converters.ArrayBuffer(V2, prefix, argument, flags);
|
|
4939
4939
|
}
|
|
4940
|
-
if (types.isArrayBufferView(
|
|
4940
|
+
if (types.isArrayBufferView(V2)) {
|
|
4941
4941
|
flags &= ~webidl.attributes.AllowShared;
|
|
4942
|
-
return webidl.converters.ArrayBufferView(
|
|
4942
|
+
return webidl.converters.ArrayBufferView(V2, prefix, argument, flags);
|
|
4943
4943
|
}
|
|
4944
|
-
if (types.isSharedArrayBuffer(
|
|
4944
|
+
if (types.isSharedArrayBuffer(V2)) {
|
|
4945
4945
|
throw webidl.errors.exception({
|
|
4946
4946
|
header: prefix,
|
|
4947
4947
|
message: `${argument} cannot be a SharedArrayBuffer.`
|
|
@@ -4949,24 +4949,24 @@ var require_webidl = __commonJS({
|
|
|
4949
4949
|
}
|
|
4950
4950
|
throw webidl.errors.conversionFailed({
|
|
4951
4951
|
prefix,
|
|
4952
|
-
argument: `${argument} ("${webidl.util.Stringify(
|
|
4952
|
+
argument: `${argument} ("${webidl.util.Stringify(V2)}")`,
|
|
4953
4953
|
types: ["ArrayBuffer", "ArrayBufferView"]
|
|
4954
4954
|
});
|
|
4955
4955
|
};
|
|
4956
|
-
webidl.converters.AllowSharedBufferSource = function(
|
|
4957
|
-
if (types.isArrayBuffer(
|
|
4958
|
-
return webidl.converters.ArrayBuffer(
|
|
4956
|
+
webidl.converters.AllowSharedBufferSource = function(V2, prefix, argument, flags) {
|
|
4957
|
+
if (types.isArrayBuffer(V2)) {
|
|
4958
|
+
return webidl.converters.ArrayBuffer(V2, prefix, argument, flags);
|
|
4959
4959
|
}
|
|
4960
|
-
if (types.isSharedArrayBuffer(
|
|
4961
|
-
return webidl.converters.SharedArrayBuffer(
|
|
4960
|
+
if (types.isSharedArrayBuffer(V2)) {
|
|
4961
|
+
return webidl.converters.SharedArrayBuffer(V2, prefix, argument, flags);
|
|
4962
4962
|
}
|
|
4963
|
-
if (types.isArrayBufferView(
|
|
4963
|
+
if (types.isArrayBufferView(V2)) {
|
|
4964
4964
|
flags |= webidl.attributes.AllowShared;
|
|
4965
|
-
return webidl.converters.ArrayBufferView(
|
|
4965
|
+
return webidl.converters.ArrayBufferView(V2, prefix, argument, flags);
|
|
4966
4966
|
}
|
|
4967
4967
|
throw webidl.errors.conversionFailed({
|
|
4968
4968
|
prefix,
|
|
4969
|
-
argument: `${argument} ("${webidl.util.Stringify(
|
|
4969
|
+
argument: `${argument} ("${webidl.util.Stringify(V2)}")`,
|
|
4970
4970
|
types: ["ArrayBuffer", "SharedArrayBuffer", "ArrayBufferView"]
|
|
4971
4971
|
});
|
|
4972
4972
|
};
|
|
@@ -4985,12 +4985,12 @@ var require_webidl = __commonJS({
|
|
|
4985
4985
|
webidl.is.AbortSignal,
|
|
4986
4986
|
"AbortSignal"
|
|
4987
4987
|
);
|
|
4988
|
-
webidl.converters.EventHandlerNonNull = function(
|
|
4989
|
-
if (webidl.util.Type(
|
|
4988
|
+
webidl.converters.EventHandlerNonNull = function(V2) {
|
|
4989
|
+
if (webidl.util.Type(V2) !== OBJECT) {
|
|
4990
4990
|
return null;
|
|
4991
4991
|
}
|
|
4992
|
-
if (typeof
|
|
4993
|
-
return
|
|
4992
|
+
if (typeof V2 === "function") {
|
|
4993
|
+
return V2;
|
|
4994
4994
|
}
|
|
4995
4995
|
return () => {
|
|
4996
4996
|
};
|
|
@@ -5324,11 +5324,11 @@ var require_util2 = __commonJS({
|
|
|
5324
5324
|
}
|
|
5325
5325
|
function tryUpgradeRequestToAPotentiallyTrustworthyURL(request) {
|
|
5326
5326
|
}
|
|
5327
|
-
function sameOrigin(
|
|
5328
|
-
if (
|
|
5327
|
+
function sameOrigin(A2, B2) {
|
|
5328
|
+
if (A2.origin === B2.origin && A2.origin === "null") {
|
|
5329
5329
|
return true;
|
|
5330
5330
|
}
|
|
5331
|
-
if (
|
|
5331
|
+
if (A2.protocol === B2.protocol && A2.hostname === B2.hostname && A2.port === B2.port) {
|
|
5332
5332
|
return true;
|
|
5333
5333
|
}
|
|
5334
5334
|
return false;
|
|
@@ -12850,8 +12850,8 @@ var require_mock_utils = __commonJS({
|
|
|
12850
12850
|
const value = data[key];
|
|
12851
12851
|
const name = Buffer.from(`${key}`);
|
|
12852
12852
|
if (Array.isArray(value)) {
|
|
12853
|
-
for (let
|
|
12854
|
-
result.push(name, Buffer.from(`${value[
|
|
12853
|
+
for (let j = 0; j < value.length; ++j) {
|
|
12854
|
+
result.push(name, Buffer.from(`${value[j]}`));
|
|
12855
12855
|
}
|
|
12856
12856
|
} else {
|
|
12857
12857
|
result.push(name, Buffer.from(`${value}`));
|
|
@@ -15686,10 +15686,10 @@ var require_cache = __commonJS({
|
|
|
15686
15686
|
foundEndingQuote = true;
|
|
15687
15687
|
} else {
|
|
15688
15688
|
const fieldListParts = [value.substring(1)];
|
|
15689
|
-
for (let
|
|
15690
|
-
const nextPart = trimOWS(directives[
|
|
15689
|
+
for (let j = i + 1; j < directives.length; j++) {
|
|
15690
|
+
const nextPart = trimOWS(directives[j].value);
|
|
15691
15691
|
const closingQuote2 = findUnescapedQuote(nextPart, 0);
|
|
15692
|
-
lastQuotedPart =
|
|
15692
|
+
lastQuotedPart = j;
|
|
15693
15693
|
if (closingQuote2 !== -1) {
|
|
15694
15694
|
fieldListParts.push(nextPart.substring(0, closingQuote2));
|
|
15695
15695
|
foundEndingQuote = true;
|
|
@@ -15706,9 +15706,9 @@ var require_cache = __commonJS({
|
|
|
15706
15706
|
i = lastQuotedPart;
|
|
15707
15707
|
const headers = fieldList.split(",");
|
|
15708
15708
|
let validFieldNames = true;
|
|
15709
|
-
for (let
|
|
15710
|
-
headers[
|
|
15711
|
-
if (!isValidHTTPToken(headers[
|
|
15709
|
+
for (let j = 0; j < headers.length; j++) {
|
|
15710
|
+
headers[j] = trimOWS(headers[j]);
|
|
15711
|
+
if (!isValidHTTPToken(headers[j])) {
|
|
15712
15712
|
validFieldNames = false;
|
|
15713
15713
|
}
|
|
15714
15714
|
}
|
|
@@ -15768,8 +15768,8 @@ var require_cache = __commonJS({
|
|
|
15768
15768
|
const output = [];
|
|
15769
15769
|
for (let i = 0; i < values.length; i++) {
|
|
15770
15770
|
const parts = values[i].split(",");
|
|
15771
|
-
for (let
|
|
15772
|
-
output.push(parts[
|
|
15771
|
+
for (let j = 0; j < parts.length; j++) {
|
|
15772
|
+
output.push(parts[j]);
|
|
15773
15773
|
}
|
|
15774
15774
|
}
|
|
15775
15775
|
return output;
|
|
@@ -16423,8 +16423,8 @@ var require_cache_handler = __commonJS({
|
|
|
16423
16423
|
const values = Array.isArray(connectionHeader) ? connectionHeader : [connectionHeader];
|
|
16424
16424
|
for (let i = 0; i < values.length; i++) {
|
|
16425
16425
|
const tokens = values[i].split(",");
|
|
16426
|
-
for (let
|
|
16427
|
-
headersToRemove.push(trimOWS(tokens[
|
|
16426
|
+
for (let j = 0; j < tokens.length; j++) {
|
|
16427
|
+
headersToRemove.push(trimOWS(tokens[j]).toLowerCase());
|
|
16428
16428
|
}
|
|
16429
16429
|
}
|
|
16430
16430
|
}
|
|
@@ -17242,8 +17242,8 @@ var require_cache2 = __commonJS({
|
|
|
17242
17242
|
continue;
|
|
17243
17243
|
}
|
|
17244
17244
|
const directives = value.split(",");
|
|
17245
|
-
for (let
|
|
17246
|
-
if (trimOWS(directives[
|
|
17245
|
+
for (let j = 0; j < directives.length; j++) {
|
|
17246
|
+
if (trimOWS(directives[j]).toLowerCase() === "no-cache") {
|
|
17247
17247
|
return true;
|
|
17248
17248
|
}
|
|
17249
17249
|
}
|
|
@@ -18756,10 +18756,10 @@ var require_headers = __commonJS({
|
|
|
18756
18756
|
}
|
|
18757
18757
|
function headerValueNormalize(potentialValue) {
|
|
18758
18758
|
let i = 0;
|
|
18759
|
-
let
|
|
18760
|
-
while (
|
|
18761
|
-
while (
|
|
18762
|
-
return i === 0 &&
|
|
18759
|
+
let j = potentialValue.length;
|
|
18760
|
+
while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(j - 1))) --j;
|
|
18761
|
+
while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(i))) ++i;
|
|
18762
|
+
return i === 0 && j === potentialValue.length ? potentialValue : potentialValue.substring(i, j);
|
|
18763
18763
|
}
|
|
18764
18764
|
function fill(headers, object2) {
|
|
18765
18765
|
if (Array.isArray(object2)) {
|
|
@@ -18823,8 +18823,8 @@ var require_headers = __commonJS({
|
|
|
18823
18823
|
for (let i = 0; i < names.length; ++i) {
|
|
18824
18824
|
const { 0: name, 1: value } = names[i];
|
|
18825
18825
|
if (name === "set-cookie") {
|
|
18826
|
-
for (let
|
|
18827
|
-
headers.push([name, cookies[
|
|
18826
|
+
for (let j = 0; j < cookies.length; ++j) {
|
|
18827
|
+
headers.push([name, cookies[j]]);
|
|
18828
18828
|
}
|
|
18829
18829
|
} else {
|
|
18830
18830
|
headers.push([name, value]);
|
|
@@ -18966,7 +18966,7 @@ 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 i = 1,
|
|
18969
|
+
for (let i = 1, j = 0, right = 0, left = 0, pivot = 0, x2, value; i < size; ++i) {
|
|
18970
18970
|
value = iterator.next().value;
|
|
18971
18971
|
x2 = array[i] = [value[0], value[1].value];
|
|
18972
18972
|
assert(x2[1] !== null);
|
|
@@ -18981,9 +18981,9 @@ var require_headers = __commonJS({
|
|
|
18981
18981
|
}
|
|
18982
18982
|
}
|
|
18983
18983
|
if (i !== pivot) {
|
|
18984
|
-
|
|
18985
|
-
while (
|
|
18986
|
-
array[
|
|
18984
|
+
j = i;
|
|
18985
|
+
while (j > left) {
|
|
18986
|
+
array[j] = array[--j];
|
|
18987
18987
|
}
|
|
18988
18988
|
array[left] = x2;
|
|
18989
18989
|
}
|
|
@@ -19164,19 +19164,19 @@ var require_headers = __commonJS({
|
|
|
19164
19164
|
enumerable: false
|
|
19165
19165
|
}
|
|
19166
19166
|
});
|
|
19167
|
-
webidl.converters.HeadersInit = function(
|
|
19168
|
-
if (webidl.util.Type(
|
|
19169
|
-
const iterator = Reflect.get(
|
|
19170
|
-
if (!util.types.isProxy(
|
|
19167
|
+
webidl.converters.HeadersInit = function(V2, prefix, argument) {
|
|
19168
|
+
if (webidl.util.Type(V2) === webidl.util.Types.OBJECT) {
|
|
19169
|
+
const iterator = Reflect.get(V2, Symbol.iterator);
|
|
19170
|
+
if (!util.types.isProxy(V2) && iterator === Headers.prototype.entries) {
|
|
19171
19171
|
try {
|
|
19172
|
-
return getHeadersList(
|
|
19172
|
+
return getHeadersList(V2).entriesList;
|
|
19173
19173
|
} catch {
|
|
19174
19174
|
}
|
|
19175
19175
|
}
|
|
19176
19176
|
if (typeof iterator === "function") {
|
|
19177
|
-
return webidl.converters["sequence<sequence<ByteString>>"](
|
|
19177
|
+
return webidl.converters["sequence<sequence<ByteString>>"](V2, prefix, argument, iterator.bind(V2));
|
|
19178
19178
|
}
|
|
19179
|
-
return webidl.converters["record<ByteString, ByteString>"](
|
|
19179
|
+
return webidl.converters["record<ByteString, ByteString>"](V2, prefix, argument);
|
|
19180
19180
|
}
|
|
19181
19181
|
throw webidl.errors.conversionFailed({
|
|
19182
19182
|
prefix: "Headers constructor",
|
|
@@ -19562,32 +19562,32 @@ var require_response = __commonJS({
|
|
|
19562
19562
|
}
|
|
19563
19563
|
return response;
|
|
19564
19564
|
}
|
|
19565
|
-
webidl.converters.XMLHttpRequestBodyInit = function(
|
|
19566
|
-
if (typeof
|
|
19567
|
-
return webidl.converters.USVString(
|
|
19565
|
+
webidl.converters.XMLHttpRequestBodyInit = function(V2, prefix, name) {
|
|
19566
|
+
if (typeof V2 === "string") {
|
|
19567
|
+
return webidl.converters.USVString(V2, prefix, name);
|
|
19568
19568
|
}
|
|
19569
|
-
if (webidl.is.Blob(
|
|
19570
|
-
return
|
|
19569
|
+
if (webidl.is.Blob(V2)) {
|
|
19570
|
+
return V2;
|
|
19571
19571
|
}
|
|
19572
|
-
if (webidl.is.BufferSource(
|
|
19573
|
-
return
|
|
19572
|
+
if (webidl.is.BufferSource(V2)) {
|
|
19573
|
+
return V2;
|
|
19574
19574
|
}
|
|
19575
|
-
if (webidl.is.FormData(
|
|
19576
|
-
return
|
|
19575
|
+
if (webidl.is.FormData(V2)) {
|
|
19576
|
+
return V2;
|
|
19577
19577
|
}
|
|
19578
|
-
if (webidl.is.URLSearchParams(
|
|
19579
|
-
return
|
|
19578
|
+
if (webidl.is.URLSearchParams(V2)) {
|
|
19579
|
+
return V2;
|
|
19580
19580
|
}
|
|
19581
|
-
return webidl.converters.DOMString(
|
|
19581
|
+
return webidl.converters.DOMString(V2, prefix, name);
|
|
19582
19582
|
};
|
|
19583
|
-
webidl.converters.BodyInit = function(
|
|
19584
|
-
if (webidl.is.ReadableStream(
|
|
19585
|
-
return
|
|
19583
|
+
webidl.converters.BodyInit = function(V2, prefix, argument) {
|
|
19584
|
+
if (webidl.is.ReadableStream(V2)) {
|
|
19585
|
+
return V2;
|
|
19586
19586
|
}
|
|
19587
|
-
if (
|
|
19588
|
-
return
|
|
19587
|
+
if (V2?.[Symbol.asyncIterator]) {
|
|
19588
|
+
return V2;
|
|
19589
19589
|
}
|
|
19590
|
-
return webidl.converters.XMLHttpRequestBodyInit(
|
|
19590
|
+
return webidl.converters.XMLHttpRequestBodyInit(V2, prefix, argument);
|
|
19591
19591
|
};
|
|
19592
19592
|
webidl.converters.ResponseInit = webidl.dictionaryConverter([
|
|
19593
19593
|
{
|
|
@@ -20268,14 +20268,14 @@ var require_request2 = __commonJS({
|
|
|
20268
20268
|
}
|
|
20269
20269
|
});
|
|
20270
20270
|
webidl.is.Request = webidl.util.MakeTypeAssertion(Request);
|
|
20271
|
-
webidl.converters.RequestInfo = function(
|
|
20272
|
-
if (typeof
|
|
20273
|
-
return webidl.converters.USVString(
|
|
20271
|
+
webidl.converters.RequestInfo = function(V2) {
|
|
20272
|
+
if (typeof V2 === "string") {
|
|
20273
|
+
return webidl.converters.USVString(V2);
|
|
20274
20274
|
}
|
|
20275
|
-
if (webidl.is.Request(
|
|
20276
|
-
return
|
|
20275
|
+
if (webidl.is.Request(V2)) {
|
|
20276
|
+
return V2;
|
|
20277
20277
|
}
|
|
20278
|
-
return webidl.converters.USVString(
|
|
20278
|
+
return webidl.converters.USVString(V2);
|
|
20279
20279
|
};
|
|
20280
20280
|
webidl.converters.RequestInit = webidl.dictionaryConverter([
|
|
20281
20281
|
{
|
|
@@ -21666,8 +21666,8 @@ var require_util3 = __commonJS({
|
|
|
21666
21666
|
var assert = __require("node:assert");
|
|
21667
21667
|
var { URLSerializer } = require_data_url();
|
|
21668
21668
|
var { isValidHeaderName } = require_util2();
|
|
21669
|
-
function urlEquals(
|
|
21670
|
-
const serializedA = URLSerializer(
|
|
21669
|
+
function urlEquals(A2, B2, excludeFragment = false) {
|
|
21670
|
+
const serializedA = URLSerializer(A2, excludeFragment);
|
|
21671
21671
|
const serializedB = URLSerializer(B2, excludeFragment);
|
|
21672
21672
|
return serializedA === serializedB;
|
|
21673
21673
|
}
|
|
@@ -24574,11 +24574,11 @@ var require_websocket = __commonJS({
|
|
|
24574
24574
|
webidl.converters["sequence<DOMString>"] = webidl.sequenceConverter(
|
|
24575
24575
|
webidl.converters.DOMString
|
|
24576
24576
|
);
|
|
24577
|
-
webidl.converters["DOMString or sequence<DOMString>"] = function(
|
|
24578
|
-
if (webidl.util.Type(
|
|
24579
|
-
return webidl.converters["sequence<DOMString>"](
|
|
24577
|
+
webidl.converters["DOMString or sequence<DOMString>"] = function(V2, prefix, argument) {
|
|
24578
|
+
if (webidl.util.Type(V2) === webidl.util.Types.OBJECT && Symbol.iterator in V2) {
|
|
24579
|
+
return webidl.converters["sequence<DOMString>"](V2);
|
|
24580
24580
|
}
|
|
24581
|
-
return webidl.converters.DOMString(
|
|
24581
|
+
return webidl.converters.DOMString(V2, prefix, argument);
|
|
24582
24582
|
};
|
|
24583
24583
|
webidl.converters.WebSocketInit = webidl.dictionaryConverter([
|
|
24584
24584
|
{
|
|
@@ -24596,22 +24596,22 @@ var require_websocket = __commonJS({
|
|
|
24596
24596
|
converter: webidl.nullableConverter(webidl.converters.HeadersInit)
|
|
24597
24597
|
}
|
|
24598
24598
|
]);
|
|
24599
|
-
webidl.converters["DOMString or sequence<DOMString> or WebSocketInit"] = function(
|
|
24600
|
-
if (webidl.util.Type(
|
|
24601
|
-
return webidl.converters.WebSocketInit(
|
|
24599
|
+
webidl.converters["DOMString or sequence<DOMString> or WebSocketInit"] = function(V2) {
|
|
24600
|
+
if (webidl.util.Type(V2) === webidl.util.Types.OBJECT && !(Symbol.iterator in V2)) {
|
|
24601
|
+
return webidl.converters.WebSocketInit(V2);
|
|
24602
24602
|
}
|
|
24603
|
-
return { protocols: webidl.converters["DOMString or sequence<DOMString>"](
|
|
24603
|
+
return { protocols: webidl.converters["DOMString or sequence<DOMString>"](V2) };
|
|
24604
24604
|
};
|
|
24605
|
-
webidl.converters.WebSocketSendData = function(
|
|
24606
|
-
if (webidl.util.Type(
|
|
24607
|
-
if (webidl.is.Blob(
|
|
24608
|
-
return
|
|
24605
|
+
webidl.converters.WebSocketSendData = function(V2) {
|
|
24606
|
+
if (webidl.util.Type(V2) === webidl.util.Types.OBJECT) {
|
|
24607
|
+
if (webidl.is.Blob(V2)) {
|
|
24608
|
+
return V2;
|
|
24609
24609
|
}
|
|
24610
|
-
if (webidl.is.BufferSource(
|
|
24611
|
-
return
|
|
24610
|
+
if (webidl.is.BufferSource(V2)) {
|
|
24611
|
+
return V2;
|
|
24612
24612
|
}
|
|
24613
24613
|
}
|
|
24614
|
-
return webidl.converters.USVString(
|
|
24614
|
+
return webidl.converters.USVString(V2);
|
|
24615
24615
|
};
|
|
24616
24616
|
module.exports = {
|
|
24617
24617
|
WebSocket,
|
|
@@ -24993,7 +24993,7 @@ var require_websocketstream = __commonJS({
|
|
|
24993
24993
|
webidl.converters.WebSocketCloseInfo = webidl.dictionaryConverter([
|
|
24994
24994
|
{
|
|
24995
24995
|
key: "closeCode",
|
|
24996
|
-
converter: (
|
|
24996
|
+
converter: (V2) => webidl.converters["unsigned short"](V2, webidl.attributes.EnforceRange)
|
|
24997
24997
|
},
|
|
24998
24998
|
{
|
|
24999
24999
|
key: "reason",
|
|
@@ -25001,11 +25001,11 @@ var require_websocketstream = __commonJS({
|
|
|
25001
25001
|
defaultValue: () => ""
|
|
25002
25002
|
}
|
|
25003
25003
|
]);
|
|
25004
|
-
webidl.converters.WebSocketStreamWrite = function(
|
|
25005
|
-
if (typeof
|
|
25006
|
-
return webidl.converters.USVString(
|
|
25004
|
+
webidl.converters.WebSocketStreamWrite = function(V2) {
|
|
25005
|
+
if (typeof V2 === "string") {
|
|
25006
|
+
return webidl.converters.USVString(V2);
|
|
25007
25007
|
}
|
|
25008
|
-
return webidl.converters.BufferSource(
|
|
25008
|
+
return webidl.converters.BufferSource(V2);
|
|
25009
25009
|
};
|
|
25010
25010
|
module.exports = { WebSocketStream };
|
|
25011
25011
|
}
|
|
@@ -26149,11 +26149,11 @@ function m(t, o = 65536, s = false) {
|
|
|
26149
26149
|
if (s) {
|
|
26150
26150
|
e.fsyncSync(r);
|
|
26151
26151
|
for (let a = p(t); ; a = p(a)) {
|
|
26152
|
-
let
|
|
26152
|
+
let S = e.openSync(a, e.constants.O_RDONLY | e.constants.O_DIRECTORY | e.constants.O_NOFOLLOW);
|
|
26153
26153
|
try {
|
|
26154
|
-
e.fsyncSync(
|
|
26154
|
+
e.fsyncSync(S);
|
|
26155
26155
|
} finally {
|
|
26156
|
-
e.closeSync(
|
|
26156
|
+
e.closeSync(S);
|
|
26157
26157
|
}
|
|
26158
26158
|
if (a === p(a)) break;
|
|
26159
26159
|
}
|
|
@@ -26208,11 +26208,13 @@ var k = 100 * 1024 * 1024;
|
|
|
26208
26208
|
var $ = { brokerUrl: "wss://broker1.ours.network", port: 3050, stateDir: b(v(), ".ours"), gcIntervalMs: 36e5, historyMaxBytes: k, apiVisibility: "owner", apiAuthMode: "legacy" };
|
|
26209
26209
|
var K = "daemon-token";
|
|
26210
26210
|
|
|
26211
|
-
// node_modules/@ours.network/sdk/dist/chunk-
|
|
26212
|
-
import {
|
|
26213
|
-
import {
|
|
26214
|
-
import {
|
|
26215
|
-
import {
|
|
26211
|
+
// node_modules/@ours.network/sdk/dist/chunk-H6U3YRJE.js
|
|
26212
|
+
import { homedir as me } from "node:os";
|
|
26213
|
+
import { isAbsolute as ye, join as ge, resolve as ne } from "node:path";
|
|
26214
|
+
import { randomBytes as V } from "node:crypto";
|
|
26215
|
+
import { readFileSync as Ee } from "node:fs";
|
|
26216
|
+
import { homedir as ve } from "node:os";
|
|
26217
|
+
import { join as M, resolve as P } from "node:path";
|
|
26216
26218
|
var d = class extends Error {
|
|
26217
26219
|
constructor(n, r, i) {
|
|
26218
26220
|
super(r);
|
|
@@ -26221,8 +26223,8 @@ var d = class extends Error {
|
|
|
26221
26223
|
this.name = "OursError";
|
|
26222
26224
|
}
|
|
26223
26225
|
};
|
|
26224
|
-
var
|
|
26225
|
-
function
|
|
26226
|
+
var U = () => new d("INVALID_OBSERVATION", "Terminal observation must match this external owner instance and contain valid process evidence.");
|
|
26227
|
+
function y(e2) {
|
|
26226
26228
|
if (typeof e2 != "string" || /[\s\\#]/.test(e2) || !/^https?:\/\//i.test(e2)) throw new Error("Daemon endpoint must be an HTTP or HTTPS URL without credentials or fragment");
|
|
26227
26229
|
let t;
|
|
26228
26230
|
try {
|
|
@@ -26242,7 +26244,7 @@ function u2(e2, t) {
|
|
|
26242
26244
|
}
|
|
26243
26245
|
return n.href;
|
|
26244
26246
|
}
|
|
26245
|
-
function
|
|
26247
|
+
function R2(e2) {
|
|
26246
26248
|
try {
|
|
26247
26249
|
let t = new URL(e2);
|
|
26248
26250
|
return t.origin + t.pathname;
|
|
@@ -26250,7 +26252,7 @@ function A2(e2) {
|
|
|
26250
26252
|
return "<invalid daemon endpoint>";
|
|
26251
26253
|
}
|
|
26252
26254
|
}
|
|
26253
|
-
async function
|
|
26255
|
+
async function F(e2) {
|
|
26254
26256
|
let t = e2.body?.getReader();
|
|
26255
26257
|
if (!t) throw new Error("Missing daemon response");
|
|
26256
26258
|
let n = [], r = 0;
|
|
@@ -26267,38 +26269,38 @@ async function L2(e2) {
|
|
|
26267
26269
|
});
|
|
26268
26270
|
}
|
|
26269
26271
|
}
|
|
26270
|
-
function
|
|
26272
|
+
function N(e2, t) {
|
|
26271
26273
|
let n = (o) => o !== null && typeof o == "object" && !Array.isArray(o), r = (o, s) => Object.keys(o).length === s.length && Object.keys(o).every((a) => s.includes(a)), i = (o) => typeof o == "string" && o.trim().length > 0 && o.length <= 1024;
|
|
26272
|
-
if (!n(e2) || !r(e2, ["ownerInstanceId", "reason", "observedAt", "process"]) || !t || e2.ownerInstanceId !== t || e2.reason !== "process-exit" && e2.reason !== "session-end" || !Number.isSafeInteger(e2.observedAt) || Number(e2.observedAt) < 0 || !n(e2.process) || !r(e2.process, ["pid", "bootId", "startId", "domain"]) || !Number.isSafeInteger(e2.process.pid) || Number(e2.process.pid) < 1 || !i(e2.process.bootId) || !i(e2.process.startId) || !i(e2.process.domain)) throw
|
|
26274
|
+
if (!n(e2) || !r(e2, ["ownerInstanceId", "reason", "observedAt", "process"]) || !t || e2.ownerInstanceId !== t || e2.reason !== "process-exit" && e2.reason !== "session-end" || !Number.isSafeInteger(e2.observedAt) || Number(e2.observedAt) < 0 || !n(e2.process) || !r(e2.process, ["pid", "bootId", "startId", "domain"]) || !Number.isSafeInteger(e2.process.pid) || Number(e2.process.pid) < 1 || !i(e2.process.bootId) || !i(e2.process.startId) || !i(e2.process.domain)) throw U();
|
|
26273
26275
|
}
|
|
26274
|
-
var
|
|
26275
|
-
var
|
|
26276
|
-
function
|
|
26277
|
-
if (!
|
|
26276
|
+
var w2 = (e2) => typeof e2 == "string" && e2.length > 0;
|
|
26277
|
+
var $2 = (e2) => ({ event: "sync_required", reason: "legacy_or_malformed_event", source_event: e2 });
|
|
26278
|
+
function te(e2) {
|
|
26279
|
+
if (!w2(e2.event)) return $2("unknown");
|
|
26278
26280
|
if (e2.event === "contact_removed") {
|
|
26279
26281
|
let t = /^[0-9A-F]{64}$/;
|
|
26280
|
-
return typeof e2.cid != "string" || !t.test(e2.cid) || typeof e2.identity_cid != "string" || !t.test(e2.identity_cid) || e2.by !== "local" && e2.by !== "peer" ?
|
|
26282
|
+
return typeof e2.cid != "string" || !t.test(e2.cid) || typeof e2.identity_cid != "string" || !t.test(e2.identity_cid) || e2.by !== "local" && e2.by !== "peer" ? $2("contact_removed") : { event: "contact_removed", identity_cid: e2.identity_cid, cid: e2.cid, by: e2.by };
|
|
26281
26283
|
}
|
|
26282
|
-
if (e2.event === "message_received") return !
|
|
26284
|
+
if (e2.event === "message_received") return !w2(e2.sender_id) || !w2(e2.sender_name) || !w2(e2.msg_id) || !w2(e2.wire_id) || !w2(e2.date) ? $2("message_received") : { event: "message_received", sender_id: e2.sender_id, sender_name: e2.sender_name, from: w2(e2.from) ? e2.from : e2.sender_name, msg_id: e2.msg_id, wire_id: e2.wire_id, date: e2.date };
|
|
26283
26285
|
if (e2.event === "receipt_received") {
|
|
26284
26286
|
let t = e2.kind, n = e2.wire_ids;
|
|
26285
|
-
return !
|
|
26287
|
+
return !w2(e2.sender_id) || t !== "delivered" && t !== "read" || !Array.isArray(n) || n.length === 0 || !n.every(w2) ? $2("receipt_received") : { event: "receipt_received", sender_id: e2.sender_id, kind: t, wire_ids: [...n], date: w2(e2.date) ? e2.date : (/* @__PURE__ */ new Date()).toISOString() };
|
|
26286
26288
|
}
|
|
26287
26289
|
return e2;
|
|
26288
26290
|
}
|
|
26289
|
-
var
|
|
26291
|
+
var fe = { event: () => {
|
|
26290
26292
|
}, notification: () => {
|
|
26291
26293
|
} };
|
|
26292
|
-
var
|
|
26293
|
-
function
|
|
26294
|
+
var xt = { ...fe };
|
|
26295
|
+
function q(e2, t = /* @__PURE__ */ new Set()) {
|
|
26294
26296
|
if (e2 === null || typeof e2 == "string" || typeof e2 == "boolean") return true;
|
|
26295
26297
|
if (typeof e2 == "number") return Number.isFinite(e2);
|
|
26296
26298
|
if (typeof e2 != "object" || t.has(e2)) return false;
|
|
26297
26299
|
t.add(e2);
|
|
26298
|
-
let n = Array.isArray(e2) ? e2.every((r) =>
|
|
26300
|
+
let n = Array.isArray(e2) ? e2.every((r) => q(r, t)) : Object.getPrototypeOf(e2) === Object.prototype && Object.values(e2).every((r) => q(r, t));
|
|
26299
26301
|
return t.delete(e2), n;
|
|
26300
26302
|
}
|
|
26301
|
-
var
|
|
26303
|
+
var x = class {
|
|
26302
26304
|
base;
|
|
26303
26305
|
leaseToken;
|
|
26304
26306
|
sessionMode;
|
|
@@ -26314,7 +26316,7 @@ var R2 = class {
|
|
|
26314
26316
|
if (t.credentialPath !== void 0 && t.apiToken !== void 0) throw new Error("Credential path cannot be combined with an explicit API token");
|
|
26315
26317
|
if ("serverCertificate" in t && t.serverCertificate !== void 0) throw new Error("Custom serverCertificate is not supported; HTTPS uses Node certificate trust, including NODE_EXTRA_CA_CERTS");
|
|
26316
26318
|
if (new URL(t.url).protocol !== "http:" && new URL(t.url).protocol !== "https:") throw new Error("Client requires an HTTP or HTTPS daemon endpoint");
|
|
26317
|
-
if (this.base =
|
|
26319
|
+
if (this.base = y(t.url), this.sessionMode = t.sessionMode ?? "local", this.sessionMode !== "local" && this.sessionMode !== "external") throw new Error("Invalid sessionMode");
|
|
26318
26320
|
if (this.sessionMode === "external" && !t.leaseToken) throw new Error("External ownership requires a stable caller-supplied leaseToken");
|
|
26319
26321
|
this.leaseToken = t.leaseToken, this.clientPid = t.clientPid ?? process.pid, this.explicitApiToken = t.apiToken, this.credentialPath = t.credentialPath;
|
|
26320
26322
|
let n = t.fetch ?? globalThis.fetch;
|
|
@@ -26332,7 +26334,7 @@ var R2 = class {
|
|
|
26332
26334
|
async post(t, n, r = false) {
|
|
26333
26335
|
let i = await this.fetchImpl(u2(this.base, `/api/v1/${t}`), { redirect: "error", method: "POST", headers: this.headers({ "content-type": "application/json" }), body: JSON.stringify(n ?? {}), ...r ? { signal: AbortSignal.timeout(5e3) } : {} }), o;
|
|
26334
26336
|
try {
|
|
26335
|
-
r ? o = await
|
|
26337
|
+
r ? o = await F(i) : o = await i.json();
|
|
26336
26338
|
} catch {
|
|
26337
26339
|
throw new Error(`${t}: the daemon returned a non-JSON response (HTTP ${i.status})`);
|
|
26338
26340
|
}
|
|
@@ -26389,8 +26391,8 @@ var R2 = class {
|
|
|
26389
26391
|
async releaseLease(t = {}) {
|
|
26390
26392
|
let n = t?.observation;
|
|
26391
26393
|
if (n !== void 0) {
|
|
26392
|
-
if (this.sessionMode !== "external") throw
|
|
26393
|
-
|
|
26394
|
+
if (this.sessionMode !== "external") throw U();
|
|
26395
|
+
N(n, this.leaseToken);
|
|
26394
26396
|
}
|
|
26395
26397
|
let r = await this.post("releaseLease", t, n !== void 0);
|
|
26396
26398
|
if (n !== void 0) {
|
|
@@ -26487,9 +26489,9 @@ var R2 = class {
|
|
|
26487
26489
|
if (!c || typeof c != "object" || Array.isArray(c) || Object.keys(c).length !== 2 || typeof c.command != "string" || !("arguments" in c)) throw new Error("invalid command payload");
|
|
26488
26490
|
let l = c, m2 = l.command, f = this.commandHandlers.get(m2);
|
|
26489
26491
|
if (!f) throw new Error("handler not registered");
|
|
26490
|
-
let
|
|
26491
|
-
if (!
|
|
26492
|
-
a = { ok: true, result:
|
|
26492
|
+
let g2 = Object.freeze({ sender_cid: s.from.id, sender_name: s.from.name, request_wire_id: s.wire_id }), E = await f(l.arguments, g2);
|
|
26493
|
+
if (!q(E)) throw new Error("handler returned a non-JSON value");
|
|
26494
|
+
a = { ok: true, result: E };
|
|
26493
26495
|
} catch {
|
|
26494
26496
|
}
|
|
26495
26497
|
await this.post("sendCommandResult", { contact: s.from.id, reply_to_wire_id: s.wire_id, outcome: a });
|
|
@@ -26565,7 +26567,7 @@ var R2 = class {
|
|
|
26565
26567
|
}
|
|
26566
26568
|
if ("error" in s) throw new Error(`watchNotifications(${t}): ${s.error}`);
|
|
26567
26569
|
r = s.cursor;
|
|
26568
|
-
for (let a of s.events) yield
|
|
26570
|
+
for (let a of s.events) yield te(a && typeof a == "object" ? a : {});
|
|
26569
26571
|
}
|
|
26570
26572
|
}
|
|
26571
26573
|
async fetchFile(t) {
|
|
@@ -26611,6 +26613,51 @@ var R2 = class {
|
|
|
26611
26613
|
return await i.json();
|
|
26612
26614
|
}
|
|
26613
26615
|
};
|
|
26616
|
+
var O2 = class extends Error {
|
|
26617
|
+
constructor(t) {
|
|
26618
|
+
super(`Invalid gateway client profile: ${t}. Configure ~/.ours-client/profile.json with ours-install client; no local service fallback is permitted.`), this.name = "ClientProfileError";
|
|
26619
|
+
}
|
|
26620
|
+
};
|
|
26621
|
+
function he(e2 = process.env) {
|
|
26622
|
+
if (e2.OURS_CONFIG !== void 0) {
|
|
26623
|
+
if (!e2.OURS_CONFIG.trim()) throw new O2("OURS_CONFIG must name a client profile");
|
|
26624
|
+
return ne(e2.OURS_CONFIG);
|
|
26625
|
+
}
|
|
26626
|
+
return ge(e2.HOME || me(), ".ours-client", "profile.json");
|
|
26627
|
+
}
|
|
26628
|
+
function we(e2) {
|
|
26629
|
+
let t = (o) => {
|
|
26630
|
+
throw new O2(o);
|
|
26631
|
+
};
|
|
26632
|
+
if (!e2 || typeof e2 != "object" || Array.isArray(e2)) return t("expected a JSON object");
|
|
26633
|
+
let n = e2;
|
|
26634
|
+
if (["port", "stateDir", "apiToken", "apiVisibility"].some((o) => Object.hasOwn(n, o))) return t("daemon-local configuration cannot select a client server");
|
|
26635
|
+
if (typeof n.serverUrl != "string" || !n.serverUrl || /[\s\\?#]/.test(n.serverUrl)) return t("serverUrl must be an HTTP or HTTPS gateway base URL without credentials, query or fragment");
|
|
26636
|
+
let r;
|
|
26637
|
+
try {
|
|
26638
|
+
r = y(n.serverUrl);
|
|
26639
|
+
} catch {
|
|
26640
|
+
return t("serverUrl must be a safe HTTP or HTTPS gateway base URL");
|
|
26641
|
+
}
|
|
26642
|
+
let i = r + "/daemon";
|
|
26643
|
+
if (n.endpoint !== void 0) try {
|
|
26644
|
+
if (typeof n.endpoint != "string" || y(n.endpoint) !== i) return t("endpoint must equal serverUrl/daemon; remove stale endpoint overrides");
|
|
26645
|
+
} catch {
|
|
26646
|
+
return t("endpoint must equal serverUrl/daemon");
|
|
26647
|
+
}
|
|
26648
|
+
return typeof n.expectedInstanceId != "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(n.expectedInstanceId) ? t("expectedInstanceId must be a lowercase UUID") : typeof n.credentialPath != "string" || !ye(n.credentialPath) || ne(n.credentialPath) !== n.credentialPath ? t("credentialPath must be an absolute normalized path") : Object.freeze({ serverUrl: r, endpoint: i, expectedInstanceId: n.expectedInstanceId, credentialPath: n.credentialPath });
|
|
26649
|
+
}
|
|
26650
|
+
function re(e2 = process.env) {
|
|
26651
|
+
let t = he(e2), n;
|
|
26652
|
+
try {
|
|
26653
|
+
n = JSON.parse(m(t).toString("utf8"));
|
|
26654
|
+
} catch {
|
|
26655
|
+
throw new O2("selected profile is missing, invalid JSON or unsafe; require a 0700 directory and a 0600 regular file");
|
|
26656
|
+
}
|
|
26657
|
+
let r = we(n);
|
|
26658
|
+
if (["OURS_PORT", "OURS_STATE_DIR", "OURS_API_TOKEN", "OURS_DAEMON_ID", "OURS_DAEMON_URL", "OURS_DAEMON_CREDENTIAL_PATH"].some((o) => e2[o]?.trim())) throw new O2("remove legacy OURS_PORT/STATE_DIR/API_TOKEN/DAEMON_ID/DAEMON_URL/DAEMON_CREDENTIAL_PATH environment selectors");
|
|
26659
|
+
return Object.freeze({ ...r, configPath: t });
|
|
26660
|
+
}
|
|
26614
26661
|
var p2 = class extends Error {
|
|
26615
26662
|
constructor(n, r) {
|
|
26616
26663
|
super(r);
|
|
@@ -26618,64 +26665,64 @@ var p2 = class extends Error {
|
|
|
26618
26665
|
this.name = "DaemonSelectionError";
|
|
26619
26666
|
}
|
|
26620
26667
|
};
|
|
26621
|
-
var
|
|
26668
|
+
var B = class extends p2 {
|
|
26622
26669
|
constructor(n, r, i = {}) {
|
|
26623
|
-
super("DAEMON_UNAVAILABLE", `no ours daemon is running at ${
|
|
26670
|
+
super("DAEMON_UNAVAILABLE", `no ours daemon is running at ${R2(n)} for state directory ${JSON.stringify(r)}. Install the daemon with \`npm install --global @ours.network/daemon\`, 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.`);
|
|
26624
26671
|
this.endpoint = n;
|
|
26625
26672
|
this.stateDir = r;
|
|
26626
26673
|
this.name = "DaemonUnavailableError", i.cause !== void 0 && (this.cause = i.cause);
|
|
26627
26674
|
}
|
|
26628
26675
|
};
|
|
26629
|
-
var
|
|
26630
|
-
var
|
|
26631
|
-
var
|
|
26632
|
-
var
|
|
26633
|
-
function
|
|
26676
|
+
var oe = $.port;
|
|
26677
|
+
var J = K;
|
|
26678
|
+
var _e = ".ours";
|
|
26679
|
+
var Ie = ["explicit", "environment", "config-file"];
|
|
26680
|
+
function Oe(e2 = {}) {
|
|
26634
26681
|
let t = e2.env ?? process.env;
|
|
26635
26682
|
if (t.OURS_TLS_CERT !== void 0 || t.OURS_TLS_KEY !== void 0) throw new p2("INCOHERENT_SELECTION", "Daemon TLS is not supported in V1; remove OURS_TLS_CERT/OURS_TLS_KEY and explicitly configure HTTP");
|
|
26636
26683
|
if (e2.endpoint !== void 0 && new URL(e2.endpoint).protocol !== "http:" && new URL(e2.endpoint).protocol !== "https:") throw new p2("INCOHERENT_SELECTION", "Client requires an HTTP or HTTPS daemon endpoint");
|
|
26637
|
-
let n = e2.readTextFile ?? ((
|
|
26684
|
+
let n = e2.readTextFile ?? ((E) => Ee(E, "utf8")), r = e2.homeDir ?? ve(), i = k2(t, "OURS_INSTANCE");
|
|
26638
26685
|
if (i !== void 0) throw new p2("INCOHERENT_SELECTION", `OURS_INSTANCE=${JSON.stringify(i)} 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.`);
|
|
26639
26686
|
if (e2.stateDir !== void 0 && e2.expectStateDir !== void 0) {
|
|
26640
|
-
let
|
|
26641
|
-
if (
|
|
26687
|
+
let E = P(e2.stateDir), T2 = P(e2.expectStateDir);
|
|
26688
|
+
if (E !== T2) throw new p2("INCOHERENT_SELECTION", `stateDir ${JSON.stringify(E)} and expectStateDir ${JSON.stringify(T2)} 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.`);
|
|
26642
26689
|
}
|
|
26643
|
-
let o =
|
|
26644
|
-
|
|
26645
|
-
let
|
|
26646
|
-
return { baseUrl: m2, port: a, stateDir: l, expectStateDir: e2.expectStateDir !== void 0 ?
|
|
26690
|
+
let o = Re(e2.configPath, k2(t, "OURS_CONFIG")), s = o ? Se(o.value, n) : {}, a = ie(e2.port, Ae(k2(t, "OURS_PORT")), s.port, oe), c = ie(e2.stateDir ?? e2.expectStateDir, k2(t, "OURS_STATE_DIR"), s.stateDir, M(r, _e)), l = { value: P(c.value), source: c.source }, m2 = e2.endpoint !== void 0 ? { value: y(e2.endpoint), source: "explicit" } : { value: `http://127.0.0.1:${a.value}`, source: a.source }, f = k2(t, "OURS_API_TOKEN");
|
|
26691
|
+
Te({ endpointSelected: e2.endpoint !== void 0 || a.source !== "default", endpointSource: m2.source, stateDirIntentional: Ie.includes(l.source), stateDirSource: l.source, hasExplicitToken: e2.token !== void 0 && e2.token !== "", hasEnvToken: f !== void 0, requireExplicitSelection: e2.requireExplicitSelection === true, portSource: a.source });
|
|
26692
|
+
let g2 = be(e2.token, f, s, l, e2.readTextFile);
|
|
26693
|
+
return { baseUrl: m2, port: a, stateDir: l, expectStateDir: e2.expectStateDir !== void 0 ? P(e2.expectStateDir) : l.value, ...g2 ? { token: g2 } : {}, ...o ? { configPath: o } : {} };
|
|
26647
26694
|
}
|
|
26648
|
-
function
|
|
26695
|
+
function en(e2) {
|
|
26649
26696
|
return { baseUrl: e2.baseUrl.value, baseUrlSource: e2.baseUrl.source, port: e2.port.value, portSource: e2.port.source, stateDir: e2.stateDir.value, stateDirSource: e2.stateDir.source, expectStateDir: e2.expectStateDir, tokenSource: e2.token?.source ?? "none", configPath: e2.configPath?.value ?? null };
|
|
26650
26697
|
}
|
|
26651
|
-
function
|
|
26698
|
+
function Te(e2) {
|
|
26652
26699
|
if (e2.requireExplicitSelection) {
|
|
26653
|
-
if (e2.endpointSource === "default" && e2.portSource === "default") throw
|
|
26654
|
-
if (!e2.stateDirIntentional) throw
|
|
26700
|
+
if (e2.endpointSource === "default" && e2.portSource === "default") throw D(`requireExplicitSelection is set, but no daemon was selected. Pass endpoint/port, set OURS_PORT, or point OURS_CONFIG at a config file. Refusing the built-in default 127.0.0.1:${oe}.`);
|
|
26701
|
+
if (!e2.stateDirIntentional) throw D("requireExplicitSelection is set, but the state directory is the built-in default. Every auth-affecting field must be chosen deliberately: pass stateDir or expectStateDir, set OURS_STATE_DIR, or name a config file. Refusing before reading any token or opening any socket.");
|
|
26655
26702
|
}
|
|
26656
|
-
if (e2.endpointSelected && !e2.stateDirIntentional) throw
|
|
26657
|
-
if (e2.hasEnvToken && !e2.stateDirIntentional) throw
|
|
26658
|
-
if (e2.hasExplicitToken && !e2.stateDirIntentional) throw
|
|
26703
|
+
if (e2.endpointSelected && !e2.stateDirIntentional) throw D(`the endpoint was selected (source: ${e2.endpointSource}) but the state directory is the built-in default. A daemon's API token belongs to one state directory, so reading the default token and sending it to a separately chosen endpoint would disclose a credential to it. Select the state directory too: stateDir, expectStateDir, OURS_STATE_DIR, or one config file. An explicit token alone is not enough \u2014 without an expected state directory there is nothing to assert the endpoint against before the token is sent.`);
|
|
26704
|
+
if (e2.hasEnvToken && !e2.stateDirIntentional) throw D("OURS_API_TOKEN is set, but the state directory is the built-in default. An environment token is process-wide and authenticates to every daemon it is offered to, so it requires an explicitly expected state directory: pass stateDir or expectStateDir, or set OURS_STATE_DIR.");
|
|
26705
|
+
if (e2.hasExplicitToken && !e2.stateDirIntentional) throw D("an explicit token was given, but the state directory is the built-in default, so there would be nothing to assert the daemon against before the token is sent. Pass expectStateDir (or stateDir) naming the state directory that token belongs to.");
|
|
26659
26706
|
}
|
|
26660
|
-
function
|
|
26707
|
+
function D(e2) {
|
|
26661
26708
|
return new p2("INCOHERENT_SELECTION", e2);
|
|
26662
26709
|
}
|
|
26663
|
-
function
|
|
26710
|
+
function be(e2, t, n, r, i) {
|
|
26664
26711
|
if (e2 !== void 0 && e2 !== "") return { value: e2, source: "explicit" };
|
|
26665
26712
|
if (t !== void 0) return { value: t, source: "environment" };
|
|
26666
26713
|
let o = n.apiToken?.trim();
|
|
26667
26714
|
if (o) return { value: o, source: "config-file" };
|
|
26668
26715
|
if (i === void 0) {
|
|
26669
|
-
let s = T(
|
|
26716
|
+
let s = T(M(r.value, J), false);
|
|
26670
26717
|
return s ? { value: s.token, source: "token-file" } : void 0;
|
|
26671
26718
|
}
|
|
26672
26719
|
try {
|
|
26673
|
-
let s = i(
|
|
26720
|
+
let s = i(M(r.value, J)).trim();
|
|
26674
26721
|
if (s) return { value: s, source: "token-file" };
|
|
26675
26722
|
} catch {
|
|
26676
26723
|
}
|
|
26677
26724
|
}
|
|
26678
|
-
function
|
|
26725
|
+
function Se(e2, t) {
|
|
26679
26726
|
let n;
|
|
26680
26727
|
try {
|
|
26681
26728
|
n = t(e2);
|
|
@@ -26711,41 +26758,45 @@ function we(e2, t) {
|
|
|
26711
26758
|
}
|
|
26712
26759
|
return o;
|
|
26713
26760
|
}
|
|
26714
|
-
function
|
|
26761
|
+
function k2(e2, t) {
|
|
26715
26762
|
let n = e2[t];
|
|
26716
26763
|
if (n === void 0) return;
|
|
26717
26764
|
let r = n.trim();
|
|
26718
26765
|
return r === "" ? void 0 : r;
|
|
26719
26766
|
}
|
|
26720
|
-
function
|
|
26767
|
+
function Ae(e2) {
|
|
26721
26768
|
if (e2 === void 0) return;
|
|
26722
26769
|
let t = Number.parseInt(e2, 10);
|
|
26723
26770
|
if (!Number.isInteger(t) || t < 1 || t > 65535) throw new p2("INCOHERENT_SELECTION", `OURS_PORT=${JSON.stringify(e2)} is not a TCP port between 1 and 65535.`);
|
|
26724
26771
|
return t;
|
|
26725
26772
|
}
|
|
26726
|
-
function
|
|
26773
|
+
function ie(e2, t, n, r) {
|
|
26727
26774
|
return e2 !== void 0 ? { value: e2, source: "explicit" } : t !== void 0 ? { value: t, source: "environment" } : n !== void 0 ? { value: n, source: "config-file" } : { value: r, source: "default" };
|
|
26728
26775
|
}
|
|
26729
|
-
function
|
|
26776
|
+
function Re(e2, t) {
|
|
26730
26777
|
if (e2 !== void 0) return { value: e2, source: "explicit" };
|
|
26731
26778
|
if (t !== void 0) return { value: t, source: "environment" };
|
|
26732
26779
|
}
|
|
26733
|
-
async function
|
|
26780
|
+
async function Ne(e2, t = {}) {
|
|
26734
26781
|
let n = t.fetch ?? globalThis.fetch, r = new AbortController(), i = setTimeout(() => r.abort(), t.timeoutMs ?? 5e3), o;
|
|
26735
26782
|
try {
|
|
26736
26783
|
let a = await n(u2(e2.baseUrl.value, "/state-dir"), { signal: r.signal, redirect: "error" });
|
|
26737
|
-
if (!a.ok) throw new p2("INCOHERENT_SELECTION", `${
|
|
26784
|
+
if (!a.ok) throw new p2("INCOHERENT_SELECTION", `${R2(u2(e2.baseUrl.value, "/state-dir"))} answered HTTP ${a.status}, so the daemon at that address could not be identified. Refusing to send a credential to it.`);
|
|
26738
26785
|
o = await a.json();
|
|
26739
26786
|
} catch (a) {
|
|
26740
|
-
throw a instanceof p2 ? a : new
|
|
26787
|
+
throw a instanceof p2 ? a : new B(e2.baseUrl.value, e2.expectStateDir, { cause: a });
|
|
26741
26788
|
} finally {
|
|
26742
26789
|
clearTimeout(i);
|
|
26743
26790
|
}
|
|
26744
|
-
let s = typeof o.stateDir == "string" ?
|
|
26745
|
-
if (s === null) throw new p2("INCOHERENT_SELECTION", `${
|
|
26746
|
-
if (s !== e2.expectStateDir) throw new p2("INCOHERENT_SELECTION", `the daemon at ${
|
|
26791
|
+
let s = typeof o.stateDir == "string" ? P(o.stateDir) : null;
|
|
26792
|
+
if (s === null) throw new p2("INCOHERENT_SELECTION", `${R2(u2(e2.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.`);
|
|
26793
|
+
if (s !== e2.expectStateDir) throw new p2("INCOHERENT_SELECTION", `the daemon at ${R2(e2.baseUrl.value)} owns state directory ${JSON.stringify(s)}, but this selection expects ${JSON.stringify(e2.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.`);
|
|
26747
26794
|
}
|
|
26748
|
-
async function
|
|
26795
|
+
async function G(e2 = {}) {
|
|
26796
|
+
if (e2.endpoint === void 0 && e2.port === void 0 && e2.stateDir === void 0 && e2.expectStateDir === void 0) {
|
|
26797
|
+
let g2 = re({ ...e2.env ?? process.env, ...e2.configPath === void 0 ? {} : { OURS_CONFIG: e2.configPath } });
|
|
26798
|
+
return G({ ...e2, endpoint: g2.endpoint, expectedInstanceId: g2.expectedInstanceId, credentialPath: g2.credentialPath, sessionMode: "external", leaseToken: e2.leaseToken ?? V(32).toString("hex"), env: {} });
|
|
26799
|
+
}
|
|
26749
26800
|
if ("serverCertificate" in e2 && e2.serverCertificate !== void 0) throw new Error("Custom serverCertificate is not supported; HTTPS uses Node certificate trust, including NODE_EXTRA_CA_CERTS");
|
|
26750
26801
|
let t = e2.env ?? process.env;
|
|
26751
26802
|
if (t.OURS_TLS_CERT !== void 0 || t.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");
|
|
@@ -26757,29 +26808,29 @@ async function ne(e2 = {}) {
|
|
|
26757
26808
|
}
|
|
26758
26809
|
if (l !== void 0 && (a === void 0 || m2.token !== void 0)) throw new Error("Credential path requires explicit daemon identity and cannot be combined with a token");
|
|
26759
26810
|
if (a !== void 0) {
|
|
26760
|
-
let { endpoint:
|
|
26761
|
-
if (!
|
|
26811
|
+
let { endpoint: g2, token: E } = m2;
|
|
26812
|
+
if (!g2) throw new Error("Instance selection requires an explicit endpoint");
|
|
26762
26813
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(a)) throw new Error("Expected daemon instance must be a lowercase UUID");
|
|
26763
26814
|
if (o !== void 0) throw new Error("Instance selection cannot use an injected fetch");
|
|
26764
|
-
let
|
|
26815
|
+
let T2 = y(g2);
|
|
26765
26816
|
if (c !== void 0 && !Array.isArray(c)) throw new Error("Instance selection requires a nonempty capability list");
|
|
26766
26817
|
let _2 = [...c ?? ["external-sessions-v1"]];
|
|
26767
|
-
if (!_2.length || _2.some((
|
|
26818
|
+
if (!_2.length || _2.some((b2) => typeof b2 != "string" || !b2.trim())) throw new Error("Instance selection requires a nonempty capability list");
|
|
26768
26819
|
if (i === "external") _2.includes("external-sessions-v1") || _2.push("external-sessions-v1");
|
|
26769
26820
|
else if (_2.includes("external-sessions-v1")) throw new Error("External capabilities require explicit sessionMode: external; refusing local-mode fallback");
|
|
26770
26821
|
{
|
|
26771
|
-
let
|
|
26772
|
-
if (!
|
|
26773
|
-
let
|
|
26774
|
-
if (!Array.isArray(
|
|
26822
|
+
let b2 = await globalThis.fetch(u2(T2, "/selection"), { signal: s ? AbortSignal.any([s, AbortSignal.timeout(5e3)]) : AbortSignal.timeout(5e3), redirect: "error" }), I = await F(b2);
|
|
26823
|
+
if (!b2.ok || !I || Object.keys(I).length !== 3 || Object.keys(I).some((S) => !["schema", "instanceId", "capabilities"].includes(S)) || I.schema !== 1 || I.instanceId !== a) throw new Error("Daemon instance selection metadata is absent, incompatible or mismatched");
|
|
26824
|
+
let j = I.capabilities;
|
|
26825
|
+
if (!Array.isArray(j) || j.some((S) => typeof S != "string") || _2.some((S) => !j.includes(S))) throw new Error("Daemon does not support the required capabilities; refusing local-mode fallback");
|
|
26775
26826
|
}
|
|
26776
|
-
let
|
|
26777
|
-
if (typeof
|
|
26778
|
-
return new
|
|
26827
|
+
let H = l === void 0 ? E : O(l);
|
|
26828
|
+
if (typeof H != "string" || !H.trim()) throw new Error("Instance selection requires an explicit API token after daemon verification");
|
|
26829
|
+
return new x({ url: T2, sessionMode: i, requestSignal: s, ...l === void 0 ? { apiToken: H } : { credentialPath: l }, leaseToken: n ?? V(32).toString("hex"), clientPid: r });
|
|
26779
26830
|
}
|
|
26780
26831
|
if (c !== void 0) throw new Error("Capability selection requires an expected daemon instance");
|
|
26781
|
-
let f =
|
|
26782
|
-
return await
|
|
26832
|
+
let f = Oe(m2);
|
|
26833
|
+
return await Ne(f, { fetch: o }), new x({ url: f.baseUrl.value, leaseToken: n ?? V(32).toString("hex"), clientPid: r, ...f.token?.source === "token-file" && m2.readTextFile === void 0 ? { credentialPath: M(f.expectStateDir, J) } : { apiToken: f.token?.value }, fetch: o, requestSignal: s });
|
|
26783
26834
|
}
|
|
26784
26835
|
|
|
26785
26836
|
// src/telegram.ts
|
|
@@ -26877,16 +26928,16 @@ function renderRange(text2, ents, start, end) {
|
|
|
26877
26928
|
i = eStart;
|
|
26878
26929
|
}
|
|
26879
26930
|
const kids = [];
|
|
26880
|
-
let
|
|
26881
|
-
while (
|
|
26882
|
-
kids.push(ents[
|
|
26883
|
-
|
|
26931
|
+
let j = k3 + 1;
|
|
26932
|
+
while (j < ents.length && ents[j].start < eEnd) {
|
|
26933
|
+
kids.push(ents[j]);
|
|
26934
|
+
j += 1;
|
|
26884
26935
|
}
|
|
26885
26936
|
const raw = text2.slice(eStart, eEnd);
|
|
26886
26937
|
const verbatim = e2.type === "code" || e2.type === "pre";
|
|
26887
26938
|
out += wrapEntity(e2, verbatim ? raw : renderRange(text2, kids, eStart, eEnd), raw);
|
|
26888
26939
|
i = eEnd;
|
|
26889
|
-
k3 =
|
|
26940
|
+
k3 = j;
|
|
26890
26941
|
}
|
|
26891
26942
|
if (i < end) out += text2.slice(i, end);
|
|
26892
26943
|
return out;
|
|
@@ -26994,16 +27045,16 @@ function parseInline(src) {
|
|
|
26994
27045
|
function parseLink(src, i) {
|
|
26995
27046
|
let depth = 0;
|
|
26996
27047
|
let close = -1;
|
|
26997
|
-
for (let
|
|
26998
|
-
if (src[
|
|
26999
|
-
|
|
27048
|
+
for (let j = i; j < src.length; j += 1) {
|
|
27049
|
+
if (src[j] === "\\") {
|
|
27050
|
+
j += 1;
|
|
27000
27051
|
continue;
|
|
27001
27052
|
}
|
|
27002
|
-
if (src[
|
|
27003
|
-
else if (src[
|
|
27053
|
+
if (src[j] === "[") depth += 1;
|
|
27054
|
+
else if (src[j] === "]") {
|
|
27004
27055
|
depth -= 1;
|
|
27005
27056
|
if (depth === 0) {
|
|
27006
|
-
close =
|
|
27057
|
+
close = j;
|
|
27007
27058
|
break;
|
|
27008
27059
|
}
|
|
27009
27060
|
}
|
|
@@ -27030,29 +27081,29 @@ function parseBlocks(src) {
|
|
|
27030
27081
|
const fence = /^```(.*)$/.exec(line);
|
|
27031
27082
|
if (fence) {
|
|
27032
27083
|
const body = [];
|
|
27033
|
-
let
|
|
27084
|
+
let j = i + 1;
|
|
27034
27085
|
let closed = false;
|
|
27035
|
-
for (;
|
|
27036
|
-
if (/^```\s*$/.test(lines[
|
|
27086
|
+
for (; j < lines.length; j += 1) {
|
|
27087
|
+
if (/^```\s*$/.test(lines[j])) {
|
|
27037
27088
|
closed = true;
|
|
27038
27089
|
break;
|
|
27039
27090
|
}
|
|
27040
|
-
body.push(lines[
|
|
27091
|
+
body.push(lines[j]);
|
|
27041
27092
|
}
|
|
27042
27093
|
if (closed) {
|
|
27043
27094
|
flushPlain();
|
|
27044
27095
|
out.push({ t: "pre", text: body.join("\n"), lang: fence[1].trim() });
|
|
27045
|
-
i =
|
|
27096
|
+
i = j;
|
|
27046
27097
|
continue;
|
|
27047
27098
|
}
|
|
27048
27099
|
}
|
|
27049
27100
|
if (/^>\s?/.test(line)) {
|
|
27050
27101
|
const body = [];
|
|
27051
|
-
let
|
|
27052
|
-
for (;
|
|
27102
|
+
let j = i;
|
|
27103
|
+
for (; j < lines.length && /^>\s?/.test(lines[j]); j += 1) body.push(lines[j].replace(/^>\s?/, ""));
|
|
27053
27104
|
flushPlain();
|
|
27054
27105
|
out.push({ t: "quote", kids: parseInline(body.join("\n")) });
|
|
27055
|
-
i =
|
|
27106
|
+
i = j - 1;
|
|
27056
27107
|
continue;
|
|
27057
27108
|
}
|
|
27058
27109
|
plain.push(line);
|
|
@@ -28215,11 +28266,11 @@ function daemonSelectionOptions() {
|
|
|
28215
28266
|
}
|
|
28216
28267
|
async function attachToDaemon() {
|
|
28217
28268
|
const options = daemonSelectionOptions();
|
|
28218
|
-
const legacy = options.expectedInstanceId ? null :
|
|
28219
|
-
const client = await
|
|
28269
|
+
const legacy = options.expectedInstanceId ? null : Oe(options);
|
|
28270
|
+
const client = await G({ ...options, leaseToken: randomBytes(24).toString("hex") });
|
|
28220
28271
|
try {
|
|
28221
28272
|
daemonIdentityNames = new Set((await client.identities()).map((row) => row.name));
|
|
28222
|
-
log(`attached to daemon ${JSON.stringify(legacy ?
|
|
28273
|
+
log(`attached to daemon ${JSON.stringify(legacy ? en(legacy) : {
|
|
28223
28274
|
endpoint: CONFIG.daemonUrl,
|
|
28224
28275
|
instanceId: CONFIG.daemonInstanceId
|
|
28225
28276
|
})}`);
|
|
@@ -28230,7 +28281,7 @@ async function attachToDaemon() {
|
|
|
28230
28281
|
}
|
|
28231
28282
|
async function clientFor(cfg) {
|
|
28232
28283
|
if (!daemon) throw new Error("not attached to a daemon yet");
|
|
28233
|
-
return
|
|
28284
|
+
return G({ ...daemonSelectionOptions(), leaseToken: cfg.leaseToken });
|
|
28234
28285
|
}
|
|
28235
28286
|
var connections = /* @__PURE__ */ new Map();
|
|
28236
28287
|
var bots = /* @__PURE__ */ new Map();
|