Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@open-rpc/client-js
Advanced tools
Changelog
Readme
A browser-compatible JSON-RPC client with multiple transports:
import { RequestManager, HTTPTransport, Client } from "@open-rpc/client-js";
const transport = new HTTPTransport("http://localhost:8545");
const client = new Client(new RequestManager([transport]));
const result = await client.request({method: "addition", params: [2, 2]});
// => { jsonrpc: '2.0', id: 1, result: 4 }
import { EventEmitter } from "events";
import { RequestManager, EventEmitterTransport, Client } from "@open-rpc/client-js";
const chan1 = "chan1";
const chan2 = "chan2";
const emitter = new EventEmitter();
const transport = new EventEmitterTransport(emitter, chan1, chan2);
const requestManager = new RequestManager([transport]);
const client = new Client(requestManager);
// event emitter server code
emitter.on(chan1, (jsonrpcRequest) => {
const res = {
jsonrpc: "2.0",
result: "potato",
id: jsonrpcRequest.id,
};
emitter.emit(chan2, JSON.stringify(res));
});
const main = async () => {
const result = await client.request({method: "addition", params: [2, 2]});
console.log(result);
};
main().then(() => {
console.log("DONE");
});
import { RequestManager, Client, HTTPTransport } from "@open-rpc/client-js";
const transport = new HTTPTransport("http://localhost:3333");
const requestManager = new RequestManager([transport]);
const client = new Client(requestManager);
const main = async () => {
const result = await client.request({method: "addition", params: [2, 2]});
console.log(result);
};
main().then(() => {
console.log("DONE");
});
import { RequestManager, Client, WebSocketTransport } from "@open-rpc/client-js";
const transport = new WebSocketTransport("ws://localhost:3333");
const requestManager = new RequestManager([transport]);
const client = new Client(requestManager);
const main = async () => {
const result = await client.request({method: "addition", params: [2, 2]});
console.log(result);
};
main().then(() => {
console.log("DONE");
client.close();
});
How to contribute, build and release are outlined in CONTRIBUTING.md, BUILDING.md and RELEASING.md respectively. Commits in this repository follow the CONVENTIONAL_COMMITS.md specification.
FAQs
A browser-compatible JSON-RPC client with multiple transports.
The npm package @open-rpc/client-js receives a total of 31,764 weekly downloads. As such, @open-rpc/client-js popularity was classified as popular.
We found that @open-rpc/client-js 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.