@everymatrix/nuts-inbox-widget 1.86.27 → 1.86.28

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.
@@ -800,7 +800,7 @@ class Transport extends Emitter {
800
800
  }
801
801
  _port() {
802
802
  if (this.opts.port &&
803
- ((this.opts.secure && Number(this.opts.port !== 443)) ||
803
+ ((this.opts.secure && Number(this.opts.port) !== 443) ||
804
804
  (!this.opts.secure && Number(this.opts.port) !== 80))) {
805
805
  return ":" + this.opts.port;
806
806
  }
@@ -2421,11 +2421,11 @@ function _reconstructPacket(data, buffers) {
2421
2421
  * These strings must not be used as event names, as they have a special meaning.
2422
2422
  */
2423
2423
  const RESERVED_EVENTS$1 = [
2424
- "connect",
2425
- "connect_error",
2426
- "disconnect",
2427
- "disconnecting",
2428
- "newListener",
2424
+ "connect", // used on the client side
2425
+ "connect_error", // used on the client side
2426
+ "disconnect", // used on both sides
2427
+ "disconnecting", // used on the server side
2428
+ "newListener", // used by the Node.js EventEmitter
2429
2429
  "removeListener", // used by the Node.js EventEmitter
2430
2430
  ];
2431
2431
  /**
@@ -2516,10 +2516,6 @@ class Encoder {
2516
2516
  return buffers; // write all the buffers
2517
2517
  }
2518
2518
  }
2519
- // see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
2520
- function isObject(value) {
2521
- return Object.prototype.toString.call(value) === "[object Object]";
2522
- }
2523
2519
  /**
2524
2520
  * A socket.io Decoder instance
2525
2521
  *
@@ -2725,13 +2721,55 @@ class BinaryReconstructor {
2725
2721
  this.buffers = [];
2726
2722
  }
2727
2723
  }
2724
+ function isNamespaceValid(nsp) {
2725
+ return typeof nsp === "string";
2726
+ }
2727
+ // see https://caniuse.com/mdn-javascript_builtins_number_isinteger
2728
+ const isInteger = Number.isInteger ||
2729
+ function (value) {
2730
+ return (typeof value === "number" &&
2731
+ isFinite(value) &&
2732
+ Math.floor(value) === value);
2733
+ };
2734
+ function isAckIdValid(id) {
2735
+ return id === undefined || isInteger(id);
2736
+ }
2737
+ // see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
2738
+ function isObject(value) {
2739
+ return Object.prototype.toString.call(value) === "[object Object]";
2740
+ }
2741
+ function isDataValid(type, payload) {
2742
+ switch (type) {
2743
+ case PacketType.CONNECT:
2744
+ return payload === undefined || isObject(payload);
2745
+ case PacketType.DISCONNECT:
2746
+ return payload === undefined;
2747
+ case PacketType.EVENT:
2748
+ return (Array.isArray(payload) &&
2749
+ (typeof payload[0] === "number" ||
2750
+ (typeof payload[0] === "string" &&
2751
+ RESERVED_EVENTS$1.indexOf(payload[0]) === -1)));
2752
+ case PacketType.ACK:
2753
+ return Array.isArray(payload);
2754
+ case PacketType.CONNECT_ERROR:
2755
+ return typeof payload === "string" || isObject(payload);
2756
+ default:
2757
+ return false;
2758
+ }
2759
+ }
2760
+ function isPacketValid(packet) {
2761
+ return (isNamespaceValid(packet.nsp) &&
2762
+ isAckIdValid(packet.id) &&
2763
+ isDataValid(packet.type, packet.data));
2764
+ }
2728
2765
 
2729
2766
  const parser = /*#__PURE__*/Object.freeze({
2730
2767
  __proto__: null,
2731
2768
  protocol: protocol,
2732
2769
  get PacketType () { return PacketType; },
2733
2770
  Encoder: Encoder,
2734
- Decoder: Decoder
2771
+ Decoder: Decoder,
2772
+ isPacketValid: isPacketValid
2735
2773
  });
2736
2774
 
2737
2775
  function on(obj, ev, fn) {
@@ -796,7 +796,7 @@ class Transport extends Emitter {
796
796
  }
797
797
  _port() {
798
798
  if (this.opts.port &&
799
- ((this.opts.secure && Number(this.opts.port !== 443)) ||
799
+ ((this.opts.secure && Number(this.opts.port) !== 443) ||
800
800
  (!this.opts.secure && Number(this.opts.port) !== 80))) {
801
801
  return ":" + this.opts.port;
802
802
  }
@@ -2417,11 +2417,11 @@ function _reconstructPacket(data, buffers) {
2417
2417
  * These strings must not be used as event names, as they have a special meaning.
2418
2418
  */
2419
2419
  const RESERVED_EVENTS$1 = [
2420
- "connect",
2421
- "connect_error",
2422
- "disconnect",
2423
- "disconnecting",
2424
- "newListener",
2420
+ "connect", // used on the client side
2421
+ "connect_error", // used on the client side
2422
+ "disconnect", // used on both sides
2423
+ "disconnecting", // used on the server side
2424
+ "newListener", // used by the Node.js EventEmitter
2425
2425
  "removeListener", // used by the Node.js EventEmitter
2426
2426
  ];
2427
2427
  /**
@@ -2512,10 +2512,6 @@ class Encoder {
2512
2512
  return buffers; // write all the buffers
2513
2513
  }
2514
2514
  }
2515
- // see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
2516
- function isObject(value) {
2517
- return Object.prototype.toString.call(value) === "[object Object]";
2518
- }
2519
2515
  /**
2520
2516
  * A socket.io Decoder instance
2521
2517
  *
@@ -2721,13 +2717,55 @@ class BinaryReconstructor {
2721
2717
  this.buffers = [];
2722
2718
  }
2723
2719
  }
2720
+ function isNamespaceValid(nsp) {
2721
+ return typeof nsp === "string";
2722
+ }
2723
+ // see https://caniuse.com/mdn-javascript_builtins_number_isinteger
2724
+ const isInteger = Number.isInteger ||
2725
+ function (value) {
2726
+ return (typeof value === "number" &&
2727
+ isFinite(value) &&
2728
+ Math.floor(value) === value);
2729
+ };
2730
+ function isAckIdValid(id) {
2731
+ return id === undefined || isInteger(id);
2732
+ }
2733
+ // see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
2734
+ function isObject(value) {
2735
+ return Object.prototype.toString.call(value) === "[object Object]";
2736
+ }
2737
+ function isDataValid(type, payload) {
2738
+ switch (type) {
2739
+ case PacketType.CONNECT:
2740
+ return payload === undefined || isObject(payload);
2741
+ case PacketType.DISCONNECT:
2742
+ return payload === undefined;
2743
+ case PacketType.EVENT:
2744
+ return (Array.isArray(payload) &&
2745
+ (typeof payload[0] === "number" ||
2746
+ (typeof payload[0] === "string" &&
2747
+ RESERVED_EVENTS$1.indexOf(payload[0]) === -1)));
2748
+ case PacketType.ACK:
2749
+ return Array.isArray(payload);
2750
+ case PacketType.CONNECT_ERROR:
2751
+ return typeof payload === "string" || isObject(payload);
2752
+ default:
2753
+ return false;
2754
+ }
2755
+ }
2756
+ function isPacketValid(packet) {
2757
+ return (isNamespaceValid(packet.nsp) &&
2758
+ isAckIdValid(packet.id) &&
2759
+ isDataValid(packet.type, packet.data));
2760
+ }
2724
2761
 
2725
2762
  const parser = /*#__PURE__*/Object.freeze({
2726
2763
  __proto__: null,
2727
2764
  protocol: protocol,
2728
2765
  get PacketType () { return PacketType; },
2729
2766
  Encoder: Encoder,
2730
- Decoder: Decoder
2767
+ Decoder: Decoder,
2768
+ isPacketValid: isPacketValid
2731
2769
  });
2732
2770
 
2733
2771
  function on(obj, ev, fn) {