playsocketjs 4.1.0 → 4.1.1
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
|
@@ -436,12 +436,14 @@ export default class CRDTManager {
|
|
|
436
436
|
* @returns {*} - Sanitized value
|
|
437
437
|
*/
|
|
438
438
|
#sanitizeValue(value) {
|
|
439
|
+
if (value === undefined) return null; // Normalize undefined to null to avoid divergence in transport
|
|
440
|
+
|
|
439
441
|
// Check total serialized size
|
|
440
442
|
const jsonString = JSON.stringify(value);
|
|
441
443
|
if (jsonString?.length > 50000) throw new Error("Value too large!"); // 50KB limit
|
|
442
444
|
|
|
443
445
|
if (typeof value === "string") return (value.includes("<") || value.includes(">")) ? value.replace(/[<>]/g, "") : value;
|
|
444
|
-
if (Array.isArray(value)) return
|
|
446
|
+
if (Array.isArray(value)) return Array.from(value, item => this.#sanitizeValue(item));
|
|
445
447
|
if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, this.#sanitizeValue(v)]));
|
|
446
448
|
return value;
|
|
447
449
|
}
|