Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@toruslabs/openlogin-jrpc
Advanced tools
OpenLogin is a plug & play authentication suite that combines the simplicity of passwordless authentication with the security of non-custodial public key infrastructure (PKI).
@toruslabs/openlogin-jrpc is a JavaScript library that provides JSON-RPC (Remote Procedure Call) functionalities for interacting with the OpenLogin authentication system. It allows developers to create and manage JSON-RPC connections, handle requests and responses, and integrate with the OpenLogin system for secure authentication and communication.
Creating a JSON-RPC connection
This feature allows you to create a JSON-RPC connection using the provided middleware and engine. The code sample demonstrates how to set up a JSON-RPC engine and create a stream for sending and receiving JSON-RPC messages.
const { createStreamMiddleware } = require('@toruslabs/openlogin-jrpc');
const { createEngineStream } = require('@toruslabs/openlogin-jrpc');
const { JsonRpcEngine } = require('@toruslabs/openlogin-jrpc');
const engine = new JsonRpcEngine();
const { middleware, stream } = createStreamMiddleware();
engine.push(middleware);
const rpcStream = createEngineStream({ engine });
// Now you can use rpcStream to send and receive JSON-RPC messages
Handling JSON-RPC requests
This feature allows you to handle JSON-RPC requests by defining middleware functions. The code sample shows how to create a middleware that responds to a specific JSON-RPC method ('example_method') with a predefined result.
const { JsonRpcEngine } = require('@toruslabs/openlogin-jrpc');
const engine = new JsonRpcEngine();
engine.push((req, res, next, end) => {
if (req.method === 'example_method') {
res.result = 'example_result';
end();
} else {
next();
}
});
// Now the engine can handle JSON-RPC requests with the method 'example_method'
Sending JSON-RPC requests
This feature allows you to send JSON-RPC requests and handle the responses. The code sample demonstrates how to create a JSON-RPC request and send it through the rpcStream, then handle the response.
const { createEngineStream, JsonRpcEngine } = require('@toruslabs/openlogin-jrpc');
const { createStreamMiddleware } = require('@toruslabs/openlogin-jrpc');
const engine = new JsonRpcEngine();
const { middleware, stream } = createStreamMiddleware();
engine.push(middleware);
const rpcStream = createEngineStream({ engine });
const request = { jsonrpc: '2.0', id: 1, method: 'example_method', params: [] };
rpcStream.write(request, (err, response) => {
if (err) {
console.error(err);
} else {
console.log(response.result); // 'example_result'
}
});
json-rpc-engine is a library for creating and managing JSON-RPC engines. It provides similar functionalities for handling JSON-RPC requests and responses, but it does not specifically integrate with the OpenLogin system. It is more general-purpose and can be used in various JSON-RPC scenarios.
jayson is a full-featured JSON-RPC 2.0/1.0 client and server for Node.js. It provides comprehensive tools for creating JSON-RPC servers and clients, handling requests and responses, and supporting both HTTP and WebSocket transports. Unlike @toruslabs/openlogin-jrpc, it is not specifically designed for OpenLogin integration.
jsonrpc-lite is a lightweight JSON-RPC 2.0 library for Node.js and the browser. It focuses on simplicity and ease of use, providing basic functionalities for creating and parsing JSON-RPC messages. It does not offer the same level of integration with authentication systems like OpenLogin as @toruslabs/openlogin-jrpc does.
OpenLogin is a plug & play authentication suite that combines the simplicity of passwordless authentication with the security of non-custodial public key infrastructure (PKI).
OpenLogin JRPC contains rpc method implementations that are used on openlogin for managing authentication flows for the user.
Head over to docs to get started.
FAQs
OpenLogin is a plug & play authentication suite that combines the simplicity of passwordless authentication with the security of non-custodial public key infrastructure (PKI).
The npm package @toruslabs/openlogin-jrpc receives a total of 93,705 weekly downloads. As such, @toruslabs/openlogin-jrpc popularity was classified as popular.
We found that @toruslabs/openlogin-jrpc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.