Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
protomux-rpc
Advanced tools
Simple RPC over Protomux channels.
npm install protomux-rpc
On the server side:
const ProtomuxRPC = require('protomux-rpc')
const rpc = new ProtomuxRPC(stream)
rpc.respond('echo', (req) => req)
On the client side:
const ProtomuxRPC = require('protomux-rpc')
const rpc = new ProtomuxRPC(stream)
await rpc.request('echo', Buffer.from('hello world')))
// <Buffer 'hello world'>
const rpc = new ProtomuxRPC(stream[, options])
Construct a new RPC channel from a framed stream.
Options include:
{
// Optional binary ID to identify this RPC channel
id: buffer,
// Optional protocol name
protocol: 'protomux-rpc',
// Optional default value encoding
valueEncoding: encoding,
// Optional handshake
handshake: buffer,
// Optional encoding for the handshake
handshakeEncoding: encoding
}
const rpc = new ProtomuxRPC(mux[, options])
Construct a new RPC channel from an existing muxer.
Options are the same as new ProtomuxRPC(stream)
.
rpc.closed
Whether or not the RPC channel is closed.
rpc.opened
Whether or not the RPC channel is opened.
rpc.mux
The muxer used by the channel.
rpc.stream
The stream used by the channel.
rpc.respond(method[, options], handler)
Register a handler for an RPC method. The handler is passed the request value and must either return the response value or throw an error.
Only a single handler may be active for any given method; any previous handler is overwritten when registering a new one.
Options include:
{
// Optional encoding for both requests and responses, defaults to raw
valueEncoding: encoding,
requestEncoding: encoding, // Optional encoding for requests
responseEncoding: encoding // Optional encoding for responses
}
rpc.unrespond(method)
Remove a handler for an RPC method.
const response = await rpc.request(method, value[, options])
Perform an RPC request, returning a promise that will resolve with the value returned by the request handler or reject with an error.
Options are the same as rpc.respond()
with the addition of:
{
timeout: -1 // Optional request timeout in milliseconds
}
rpc.event(method, value[, options])
Perform an RPC request but don't wait for a response.
Options are the same as rpc.respond()
.
rpc.cork()
Cork the underlying channel. See channel.cork()
for more information.
rpc.uncork()
Uncork the underlying channel. See channel.uncork()
for more information.
await rpc.fullyOpened()
Resolves when the rpc is fully setup, or rejects if the setup failed.
await rpc.end()
Gracefully end the RPC channel, waiting for all inflights requests and response handlers before closing.
rpc.destroy([err])
Forcefully close the RPC channel, rejecting any inflight requests.
rpc.on('open', [handshake])
Emitted when the remote side adds the RPC protocol.
rpc.on('close')
Emitted when the RPC channel closes, i.e. when the remote side closes or rejects the RPC protocol or we closed it.
rpc.on('destroy')
Emitted when the RPC channel is destroyed, i.e. after close
when all pending promises has resolved.
All types are specified as their corresponding compact-encoding codec.
request
(0
)uint
The ID of the requeststring
The method to callraw
The request valueA request ID of 0
indicates an event call and must not be responded to.
response
(1
)bitfield(1)
Flags
error
uint
The ID of the requesterror
is set) string
The error messageerror
is not set) raw
The response valueApache-2.0
FAQs
RPC over Protomux channels
The npm package protomux-rpc receives a total of 698 weekly downloads. As such, protomux-rpc popularity was classified as not popular.
We found that protomux-rpc demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.