@everymatrix/nuts-inbox-widget 1.94.69 → 1.94.70
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
|
@@ -4567,7 +4567,7 @@ function deconstructPacket(packet) {
|
|
|
4567
4567
|
pack.attachments = buffers.length; // number of binary 'attachments'
|
|
4568
4568
|
return { packet: pack, buffers: buffers };
|
|
4569
4569
|
}
|
|
4570
|
-
function _deconstructPacket(data, buffers) {
|
|
4570
|
+
function _deconstructPacket(data, buffers, toJSON) {
|
|
4571
4571
|
if (!data)
|
|
4572
4572
|
return data;
|
|
4573
4573
|
if (isBinary(data)) {
|
|
@@ -4583,6 +4583,9 @@ function _deconstructPacket(data, buffers) {
|
|
|
4583
4583
|
return newData;
|
|
4584
4584
|
}
|
|
4585
4585
|
else if (typeof data === "object" && !(data instanceof Date)) {
|
|
4586
|
+
if (data.toJSON && typeof data.toJSON === "function" && !toJSON) {
|
|
4587
|
+
return _deconstructPacket(data.toJSON(), buffers, true);
|
|
4588
|
+
}
|
|
4586
4589
|
const newData = {};
|
|
4587
4590
|
for (const key in data) {
|
|
4588
4591
|
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
@@ -4767,10 +4770,6 @@ class Decoder extends Emitter {
|
|
|
4767
4770
|
packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
|
|
4768
4771
|
// binary packet's json
|
|
4769
4772
|
this.reconstructor = new BinaryReconstructor(packet);
|
|
4770
|
-
// no attachments, labeled binary but no binary data to follow
|
|
4771
|
-
if (packet.attachments === 0) {
|
|
4772
|
-
super.emitReserved("decoded", packet);
|
|
4773
|
-
}
|
|
4774
4773
|
}
|
|
4775
4774
|
else {
|
|
4776
4775
|
// non-binary full packet
|
|
@@ -4820,7 +4819,7 @@ class Decoder extends Emitter {
|
|
|
4820
4819
|
throw new Error("Illegal attachments");
|
|
4821
4820
|
}
|
|
4822
4821
|
const n = Number(buf);
|
|
4823
|
-
if (!isInteger(n) || n <
|
|
4822
|
+
if (!isInteger(n) || n < 1) {
|
|
4824
4823
|
throw new Error("Illegal attachments");
|
|
4825
4824
|
}
|
|
4826
4825
|
else if (n > this.opts.maxAttachments) {
|
package/hydrate/index.mjs
CHANGED
|
@@ -4563,7 +4563,7 @@ function deconstructPacket(packet) {
|
|
|
4563
4563
|
pack.attachments = buffers.length; // number of binary 'attachments'
|
|
4564
4564
|
return { packet: pack, buffers: buffers };
|
|
4565
4565
|
}
|
|
4566
|
-
function _deconstructPacket(data, buffers) {
|
|
4566
|
+
function _deconstructPacket(data, buffers, toJSON) {
|
|
4567
4567
|
if (!data)
|
|
4568
4568
|
return data;
|
|
4569
4569
|
if (isBinary(data)) {
|
|
@@ -4579,6 +4579,9 @@ function _deconstructPacket(data, buffers) {
|
|
|
4579
4579
|
return newData;
|
|
4580
4580
|
}
|
|
4581
4581
|
else if (typeof data === "object" && !(data instanceof Date)) {
|
|
4582
|
+
if (data.toJSON && typeof data.toJSON === "function" && !toJSON) {
|
|
4583
|
+
return _deconstructPacket(data.toJSON(), buffers, true);
|
|
4584
|
+
}
|
|
4582
4585
|
const newData = {};
|
|
4583
4586
|
for (const key in data) {
|
|
4584
4587
|
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
@@ -4763,10 +4766,6 @@ class Decoder extends Emitter {
|
|
|
4763
4766
|
packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
|
|
4764
4767
|
// binary packet's json
|
|
4765
4768
|
this.reconstructor = new BinaryReconstructor(packet);
|
|
4766
|
-
// no attachments, labeled binary but no binary data to follow
|
|
4767
|
-
if (packet.attachments === 0) {
|
|
4768
|
-
super.emitReserved("decoded", packet);
|
|
4769
|
-
}
|
|
4770
4769
|
}
|
|
4771
4770
|
else {
|
|
4772
4771
|
// non-binary full packet
|
|
@@ -4816,7 +4815,7 @@ class Decoder extends Emitter {
|
|
|
4816
4815
|
throw new Error("Illegal attachments");
|
|
4817
4816
|
}
|
|
4818
4817
|
const n = Number(buf);
|
|
4819
|
-
if (!isInteger(n) || n <
|
|
4818
|
+
if (!isInteger(n) || n < 1) {
|
|
4820
4819
|
throw new Error("Illegal attachments");
|
|
4821
4820
|
}
|
|
4822
4821
|
else if (n > this.opts.maxAttachments) {
|