@everymatrix/nuts-inbox-widget 1.90.16 → 1.90.18
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/hydrate/index.js
CHANGED
|
@@ -4702,12 +4702,13 @@ class Encoder {
|
|
|
4702
4702
|
class Decoder extends Emitter {
|
|
4703
4703
|
/**
|
|
4704
4704
|
* Decoder constructor
|
|
4705
|
-
*
|
|
4706
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
4707
4705
|
*/
|
|
4708
|
-
constructor(
|
|
4706
|
+
constructor(opts) {
|
|
4709
4707
|
super();
|
|
4710
|
-
this.
|
|
4708
|
+
this.opts = Object.assign({
|
|
4709
|
+
reviver: undefined,
|
|
4710
|
+
maxAttachments: 10,
|
|
4711
|
+
}, typeof opts === "function" ? { reviver: opts } : opts);
|
|
4711
4712
|
}
|
|
4712
4713
|
/**
|
|
4713
4714
|
* Decodes an encoded packet string into packet JSON.
|
|
@@ -4778,7 +4779,14 @@ class Decoder extends Emitter {
|
|
|
4778
4779
|
if (buf != Number(buf) || str.charAt(i) !== "-") {
|
|
4779
4780
|
throw new Error("Illegal attachments");
|
|
4780
4781
|
}
|
|
4781
|
-
|
|
4782
|
+
const n = Number(buf);
|
|
4783
|
+
if (!isInteger(n) || n < 0) {
|
|
4784
|
+
throw new Error("Illegal attachments");
|
|
4785
|
+
}
|
|
4786
|
+
else if (n > this.opts.maxAttachments) {
|
|
4787
|
+
throw new Error("too many attachments");
|
|
4788
|
+
}
|
|
4789
|
+
p.attachments = n;
|
|
4782
4790
|
}
|
|
4783
4791
|
// look up namespace (if any)
|
|
4784
4792
|
if ("/" === str.charAt(i + 1)) {
|
|
@@ -4824,7 +4832,7 @@ class Decoder extends Emitter {
|
|
|
4824
4832
|
}
|
|
4825
4833
|
tryParse(str) {
|
|
4826
4834
|
try {
|
|
4827
|
-
return JSON.parse(str, this.reviver);
|
|
4835
|
+
return JSON.parse(str, this.opts.reviver);
|
|
4828
4836
|
}
|
|
4829
4837
|
catch (e) {
|
|
4830
4838
|
return false;
|
package/hydrate/index.mjs
CHANGED
|
@@ -4698,12 +4698,13 @@ class Encoder {
|
|
|
4698
4698
|
class Decoder extends Emitter {
|
|
4699
4699
|
/**
|
|
4700
4700
|
* Decoder constructor
|
|
4701
|
-
*
|
|
4702
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
4703
4701
|
*/
|
|
4704
|
-
constructor(
|
|
4702
|
+
constructor(opts) {
|
|
4705
4703
|
super();
|
|
4706
|
-
this.
|
|
4704
|
+
this.opts = Object.assign({
|
|
4705
|
+
reviver: undefined,
|
|
4706
|
+
maxAttachments: 10,
|
|
4707
|
+
}, typeof opts === "function" ? { reviver: opts } : opts);
|
|
4707
4708
|
}
|
|
4708
4709
|
/**
|
|
4709
4710
|
* Decodes an encoded packet string into packet JSON.
|
|
@@ -4774,7 +4775,14 @@ class Decoder extends Emitter {
|
|
|
4774
4775
|
if (buf != Number(buf) || str.charAt(i) !== "-") {
|
|
4775
4776
|
throw new Error("Illegal attachments");
|
|
4776
4777
|
}
|
|
4777
|
-
|
|
4778
|
+
const n = Number(buf);
|
|
4779
|
+
if (!isInteger(n) || n < 0) {
|
|
4780
|
+
throw new Error("Illegal attachments");
|
|
4781
|
+
}
|
|
4782
|
+
else if (n > this.opts.maxAttachments) {
|
|
4783
|
+
throw new Error("too many attachments");
|
|
4784
|
+
}
|
|
4785
|
+
p.attachments = n;
|
|
4778
4786
|
}
|
|
4779
4787
|
// look up namespace (if any)
|
|
4780
4788
|
if ("/" === str.charAt(i + 1)) {
|
|
@@ -4820,7 +4828,7 @@ class Decoder extends Emitter {
|
|
|
4820
4828
|
}
|
|
4821
4829
|
tryParse(str) {
|
|
4822
4830
|
try {
|
|
4823
|
-
return JSON.parse(str, this.reviver);
|
|
4831
|
+
return JSON.parse(str, this.opts.reviver);
|
|
4824
4832
|
}
|
|
4825
4833
|
catch (e) {
|
|
4826
4834
|
return false;
|