wenay-common2 1.0.53 → 1.0.56

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.
@@ -12,6 +12,7 @@ const DEFAULT_LIMITS = {
12
12
  maxStringLen: 1_000_000,
13
13
  maxCallbacks: 100,
14
14
  maxPathLen: 16,
15
+ maxBinaryLen: 8_000_000,
15
16
  };
16
17
  const resolveLimits = (opts) => opts ? { ...DEFAULT_LIMITS, ...opts } : DEFAULT_LIMITS;
17
18
  exports.resolveLimits = resolveLimits;
@@ -32,6 +32,13 @@ const SERIALIZERS = [
32
32
  (v) => v instanceof RegExp ? [REGEXP_MARKER, { source: v.source, flags: v.flags }] : null,
33
33
  (v) => typeof v === "bigint" ? [BIGINT_MARKER, v.toString()] : null,
34
34
  ];
35
+ function binaryByteLength(v) {
36
+ if (ArrayBuffer.isView(v))
37
+ return v.byteLength;
38
+ if (v instanceof ArrayBuffer)
39
+ return v.byteLength;
40
+ return null;
41
+ }
35
42
  function walk(val, onLeaf, lim, depth = 0) {
36
43
  if (lim) {
37
44
  if (depth > lim.maxDepth)
@@ -41,6 +48,12 @@ function walk(val, onLeaf, lim, depth = 0) {
41
48
  }
42
49
  if (val == null || typeof val !== "object")
43
50
  return onLeaf(val);
51
+ const bin = binaryByteLength(val);
52
+ if (bin != null) {
53
+ if (lim && bin > lim.maxBinaryLen)
54
+ throw new rpc_limits_1.PayloadLimitError("binary too long");
55
+ return val;
56
+ }
44
57
  if (val instanceof Date || val instanceof Map || val instanceof Set || val instanceof RegExp)
45
58
  return onLeaf(val);
46
59
  const ks0 = Object.keys(val);
package/lib/index.d.ts CHANGED
@@ -33,3 +33,4 @@ export * as Params from "./Exchange/CParams";
33
33
  export * as Time from "./Common/Time";
34
34
  export * as Color from "./Common/Color";
35
35
  export * as ObserveAll2 from "./Common/ObserveAll2";
36
+ export * as Replay from "./Common/events/replay-index";
package/lib/index.js CHANGED
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ObserveAll2 = exports.Color = exports.Time = exports.Params = exports.Bars = exports.Math = exports.ListenNext = void 0;
39
+ exports.Replay = exports.ObserveAll2 = exports.Color = exports.Time = exports.Params = exports.Bars = exports.Math = exports.ListenNext = void 0;
40
40
  __exportStar(require("./Common/node_console"), exports);
41
41
  __exportStar(require("./Common/core/Decorator"), exports);
42
42
  __exportStar(require("./Common/core/BaseTypes"), exports);
@@ -72,3 +72,4 @@ exports.Params = __importStar(require("./Exchange/CParams"));
72
72
  exports.Time = __importStar(require("./Common/Time"));
73
73
  exports.Color = __importStar(require("./Common/Color"));
74
74
  exports.ObserveAll2 = __importStar(require("./Common/ObserveAll2"));
75
+ exports.Replay = __importStar(require("./Common/events/replay-index"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wenay-common2",
3
- "version": "1.0.53",
3
+ "version": "1.0.56",
4
4
  "description": "Common library",
5
5
  "strict": true,
6
6
  "main": "lib/index.js",
@@ -25,6 +25,7 @@
25
25
  ".": "./lib/index.js",
26
26
  "./observe-all2": "./lib/Common/ObserveAll2/index.js",
27
27
  "./listen2": "./lib/Common/events/Listen2.js",
28
+ "./replay": "./lib/Common/events/replay-index.js",
28
29
  "./lib/client": "./lib/client.js",
29
30
  "./lib/server": "./lib/server.js",
30
31
  "./client": "./lib/client.js",