playsocketjs 4.3.0 → 4.3.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/README.md +1 -1
- package/package.json +1 -1
- package/src/universal/crdtManager.js +4 -4
package/README.md
CHANGED
|
@@ -293,7 +293,7 @@ const server = new PlaySocketServer({
|
|
|
293
293
|
const forwarded = info.req.headers["x-forwarded-for"];
|
|
294
294
|
const ip = forwarded ? forwarded.split(",")[0].trim() : info.req.socket.remoteAddress;
|
|
295
295
|
if (isRateLimited(ip)) {
|
|
296
|
-
return callback(false, 429, "Too
|
|
296
|
+
return callback(false, 429, "Too Many Requests");
|
|
297
297
|
}
|
|
298
298
|
callback(true);
|
|
299
299
|
}
|
package/package.json
CHANGED
|
@@ -114,7 +114,7 @@ export default class CRDTManager {
|
|
|
114
114
|
if (this.#debug) console.log(CONSOLE_PREFIX + "Importing update:", update); // Debug
|
|
115
115
|
|
|
116
116
|
// Check key limit to safeguard against too many keys
|
|
117
|
-
if (this.#keyOperations.size >= 100 && !this.#keyOperations.has(key)) throw new Error("Key limit exceeded
|
|
117
|
+
if (this.#keyOperations.size >= 100 && !this.#keyOperations.has(key)) throw new Error("Key limit exceeded");
|
|
118
118
|
|
|
119
119
|
// Get COPY of current ops (or empty array if none yet)
|
|
120
120
|
const currentOps = [...(this.#keyOperations.get(key) || [])];
|
|
@@ -157,7 +157,7 @@ export default class CRDTManager {
|
|
|
157
157
|
|
|
158
158
|
const currentOps = this.#keyOperations.get(key);
|
|
159
159
|
if (!currentOps?.some(op => op.uuid === opUuid)) return; // Operation not found
|
|
160
|
-
if (this.#debug) console.log(CONSOLE_PREFIX + `Removing operation ${opUuid} for key ${key} as part of property update reversion
|
|
160
|
+
if (this.#debug) console.log(CONSOLE_PREFIX + `Removing operation ${opUuid} for key ${key} as part of property update reversion`);
|
|
161
161
|
|
|
162
162
|
// The own vector clock entry isn't decremented because later ops may already embed the incremented counter
|
|
163
163
|
// and reusing a counter value would corrupt operation ordering (while a gap is harmless)
|
|
@@ -188,7 +188,7 @@ export default class CRDTManager {
|
|
|
188
188
|
secondValue = this.#sanitizeValue(secondValue);
|
|
189
189
|
|
|
190
190
|
// Debug log
|
|
191
|
-
if (this.#debug) console.log(CONSOLE_PREFIX + `Updating property with key ${key}, type ${type}, value ${value} and secondValue ${secondValue}
|
|
191
|
+
if (this.#debug) console.log(CONSOLE_PREFIX + `Updating property with key ${key}, type ${type}, value ${value} and secondValue ${secondValue}`);
|
|
192
192
|
|
|
193
193
|
// Increment vector clock
|
|
194
194
|
const counter = this.#vectorClock.get(this.#replicaId) || 0;
|
|
@@ -440,7 +440,7 @@ export default class CRDTManager {
|
|
|
440
440
|
|
|
441
441
|
// Check total serialized size
|
|
442
442
|
const jsonString = JSON.stringify(value);
|
|
443
|
-
if (jsonString?.length > 50000) throw new Error("Value too large
|
|
443
|
+
if (jsonString?.length > 50000) throw new Error("Value too large"); // 50KB limit
|
|
444
444
|
|
|
445
445
|
if (typeof value === "string") return (value.includes("<") || value.includes(">")) ? value.replace(/[<>]/g, "") : value;
|
|
446
446
|
if (Array.isArray(value)) return Array.from(value, item => this.#sanitizeValue(item));
|