Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@synonymdev/slashtags-rpc
Advanced tools
helper module for creating RPCs using Slashtags nodes
helper module for creating RPCs using Slashtags nodes
npm install @synonymdev/slashtags-rpc
import Slashtag from '@synonymdev/slashtag';
import c from 'compact-encoding';
class Foo extends SlashtagsRPC {
get id() {
return 'foo';
}
get valueEncoding() {
return c.string;
}
get handshakeEncoding() {
return c.string;
}
handshake(socket) {
return this.id + '-handshake:for:' + socket.remotePublicKey.toString('hex');
}
onopen(handshake, socket) {
this.emit('handshake', handshake, socket.reomtePublicKey);
}
get methods() {
const self = this;
return [
{
name: 'echo',
handler: (req) => req,
},
];
}
async echo(key, message) {
const rpc = await this.rpc(key);
return rpc?.request('echo', message);
}
}
const alice = new Slashtag();
const aliceFoo = new Foo(alice);
id
String identifies your RPC protocol.
valueEncoding
Default compact encoding for all requests and responses.
handshakeEncoding
Default compact encoding for handshake message, sent first thing on opening the channel.
handshake(stream) => any
A callback function that should returns the handshake value. stream
is a SecretStream.
onopen(handshake, stream)
A callback on opening the rpc. handshake
is the value sent on opening the channel, stream
is a SecretStream.
methods
An array of methods objects that should be as following:
{
name: string,
options?: {
// Optional encoding for both the request and response
valueEncoding: Encoding,
// Optional encoding for requests
requestEncoding: Encoding,
// Optional encoding for responses
responseEncoding: Encoding
},
// Handler that takes the decoded request and returns a response value
handler: (req) => any
}
rpc(key)
Returns a ProtomuxRPC instance after connecting to a Slashtag by its key, id or url. If connection is already opened, the same RPC instance is returned.
Internally, it uses Slashtags.connect(key)
then sets up the RPC instance using setup(socket)
setup(socket)
Create a new ProtomuxRPC instance on any stream if doesn't already exist.
FAQs
helper module for creating RPCs using Slashtags nodes
We found that @synonymdev/slashtags-rpc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.