@hytopia.com/server-protocol 1.4.30 → 1.4.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/server-protocol",
3
- "version": "1.4.30",
3
+ "version": "1.4.32",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -2,6 +2,7 @@ import Ajv from '../shared/Ajv';
2
2
  import type { JSONSchemaType, ValidateFunction } from 'ajv';
3
3
 
4
4
  const FRAME_HEADER_SIZE = 4;
5
+ const MAX_FRAME_BUFFER_SIZE = 32 * 1024 * 1024; // 32MB max buffer size
5
6
 
6
7
  /*
7
8
  * Packet types are numerically ordered relative to their use.
@@ -112,7 +113,16 @@ export function createPacketBufferUnframer(): (chunk: Uint8Array) => Uint8Array[
112
113
 
113
114
  // Grow buffer if needed
114
115
  if (used + chunk.length > buffer.length) {
115
- const grown = new Uint8Array(Math.max(buffer.length * 2, used + chunk.length));
116
+ const requiredSize = Math.max(buffer.length * 2, used + chunk.length);
117
+
118
+ // Enforce max buffer size cap
119
+ if (requiredSize > MAX_FRAME_BUFFER_SIZE) {
120
+ console.error(`Unframer packet buffer exceeded maximum size of ${MAX_FRAME_BUFFER_SIZE} bytes, discarding packet...`);
121
+ used = 0; // Reset buffer state to discard oversized packet and continue processing future packets
122
+ return [];
123
+ }
124
+
125
+ const grown = new Uint8Array(requiredSize);
116
126
  grown.set(buffer.subarray(0, used));
117
127
  buffer = grown;
118
128
  }
package/schemas/Entity.ts CHANGED
@@ -27,8 +27,9 @@ export type EntitySchema = {
27
27
  pn?: string; // parent node name
28
28
  r?: QuaternionSchema; // rotation
29
29
  rm?: boolean; // removed/remove
30
- s?: number; // model scale
30
+ s?: number; // model scale - Deprecated as of 0.11.10, use sv
31
31
  sn?: string[]; // model nodes to show by partial case insensitive match of gltf node names
32
+ sv?: VectorSchema; // model scale vector for each axis
32
33
  t?: RgbColorSchema; // tint color
33
34
  }
34
35
 
@@ -55,6 +56,7 @@ export const entitySchema: JSONSchemaType<EntitySchema> = {
55
56
  rm: { type: 'boolean', nullable: true },
56
57
  s: { type: 'number', nullable: true },
57
58
  sn: { type: 'array', items: { type: 'string' }, nullable: true },
59
+ sv: { ...vectorSchema, nullable: true },
58
60
  t: { ...rgbColorSchema, nullable: true },
59
61
  },
60
62
  required: [ 'i' ],