![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@emiw/redstone-protocol
Advanced tools
The protocol and parser the worker-client communication in redstone
import { encode, decode, createParser } from '@emiw/redstone-protocol';
// There are two sides to this module, the lower level encode/decode, and the higher level Parser class-ish.
// Encode/Decode
// Encoding
// IMPORTANT: `meta` must be JSON serializable, and data must be a buffer!
const encoded = encode({ state: 5, foo: 'bar' }, new Buffer('foo bar baz')); // encode(meta, data)
console.log(encoded); // "%7B%22state%22%3A5%2C%22foo%22%3A%22bar%22%7D:Zm9vIGJhciBiYXo=;"
// Decoding
const decoded = decode(encoded);
console.log(decoded); // "{ meta: { state: 5, foo: 'bar' }, data: <Buffer 66 6f 6f 20 62 61 72 20 62 61 7a> }"
console.log(decoded.data.toString('utf8'); // "foo bar baz"
// See below for more on the actual protocol.
// Parser
// The parser exists as a way to abstract away the process of storing chunks as the come in from a socket, extracting
// the packets, and parsing them.
const socket = getNetSocketSomehow();
const parser = createParser();
socket.on('data', parser.addChunk);
// WARNING: All of these events will be fired for every packet.
parser.on('packet', (packet) => {
// packet = { meta: ..., data: ... }
});
parser.on('meta', (meta) => {
// meta = ...
});
parser.on('data', (data) => {
// data = Buffer(...)
});
socket.write(encode({ foo: 'bar' }));
// There are a few abstractions for dealing with sockets. To use them, just pass in a socket to `createParser`:
const parser = createParser(socket); // This automatically does `socket.on('data', parser.addChunk)`
parser.write(meta, data); // same as parser.write(encode(meta, data));
The actual protocol has hastily implemented by @ariporad, and it could certainly be implemented better. But here's how it's implemented as of now:
There are three terms you need to know:
encodeURIComponent(JSON.stringify(meta))
).Packets are in the format: meta:data;
Here's an example packet (encode({ foo: 'bar' }, new Buffer('foo'))
)
%7B%22foo%22%3A%22bar%22%7D:Zm9v;
^^^^^^^^^^ Meta ^^^^^^^^^^^ ^^^^ <- Data
Here's a "null" packet:
:;
For ideas/discussion about improving the protocol, see the wiki page.
FAQs
The protocol and parser the worker-client communication in redstone
The npm package @emiw/redstone-protocol receives a total of 0 weekly downloads. As such, @emiw/redstone-protocol popularity was classified as not popular.
We found that @emiw/redstone-protocol demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.