mcbe-ipc 3.4.0 → 3.4.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/dist/ipc.d.ts +1 -0
- package/dist/ipc.js +8 -2
- package/package.json +1 -1
package/dist/ipc.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare namespace PROTO {
|
|
|
51
51
|
to_uint8array(): Uint8Array;
|
|
52
52
|
}
|
|
53
53
|
namespace MIPS {
|
|
54
|
+
function is_valid(str: string): boolean;
|
|
54
55
|
function serialize(stream: PROTO.Buffer): Generator<void, string, void>;
|
|
55
56
|
function deserialize(str: string): Generator<void, PROTO.Buffer, void>;
|
|
56
57
|
}
|
package/dist/ipc.js
CHANGED
|
@@ -107,6 +107,10 @@ export var PROTO;
|
|
|
107
107
|
PROTO.Buffer = Buffer;
|
|
108
108
|
let MIPS;
|
|
109
109
|
(function (MIPS) {
|
|
110
|
+
function is_valid(str) {
|
|
111
|
+
return str.startsWith('(0x') && str.endsWith(')');
|
|
112
|
+
}
|
|
113
|
+
MIPS.is_valid = is_valid;
|
|
110
114
|
function* serialize(stream) {
|
|
111
115
|
const uint8array = stream.to_uint8array();
|
|
112
116
|
let str = '(0x';
|
|
@@ -120,7 +124,7 @@ export var PROTO;
|
|
|
120
124
|
}
|
|
121
125
|
MIPS.serialize = serialize;
|
|
122
126
|
function* deserialize(str) {
|
|
123
|
-
if (
|
|
127
|
+
if (is_valid(str)) {
|
|
124
128
|
const buffer = new Buffer();
|
|
125
129
|
const hex_str = str.slice(3, str.length - 1);
|
|
126
130
|
for (let i = 0; i < hex_str.length; i++) {
|
|
@@ -502,10 +506,12 @@ export var NET;
|
|
|
502
506
|
if (event.sourceType !== ScriptEventSource.Server)
|
|
503
507
|
return;
|
|
504
508
|
const [serialized_endpoint, serialized_header] = event.id.split(':');
|
|
509
|
+
if (!PROTO.MIPS.is_valid(serialized_endpoint))
|
|
510
|
+
return;
|
|
505
511
|
const endpoint_stream = yield* PROTO.MIPS.deserialize(serialized_endpoint);
|
|
506
512
|
const endpoint = yield* Endpoint.deserialize(endpoint_stream);
|
|
507
513
|
const listeners = LISTENERS.get(endpoint);
|
|
508
|
-
if (listeners !== undefined) {
|
|
514
|
+
if (listeners !== undefined && PROTO.MIPS.is_valid(serialized_header)) {
|
|
509
515
|
const header_stream = yield* PROTO.MIPS.deserialize(serialized_header);
|
|
510
516
|
const header = yield* Header.deserialize(header_stream);
|
|
511
517
|
const errors = [];
|
package/package.json
CHANGED