
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
@memofs/json-rpc
Advanced tools
Dependency-free JSON-RPC 2.0 protocol primitives shared by MemoFS transports.
@memofs/json-rpcDependency-free JSON-RPC 2.0 protocol primitives shared by MemoFS transports.
Two MemoFS packages speak JSON-RPC over the wire. Before this package, both shipped near-identical copies of the same ~200 lines of spec types and helpers, and one was coupled to the other's error classes. That violates the workspace DRY/SSOT rule and the package-boundaries rule (no transport in core, no distribution→distribution import). Extracting the spec layer into a neutral, dependency-free package fixes both:
JsonRpcProtocolError) — consumers that own their own
error hierarchy catch it and re-throw in their own type.JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse,
JsonRpcErrorResponse, JsonRpcId.JSON_RPC_ERRORS (the five spec codes: parseError,
invalidRequest, methodNotFound, invalidParams, internalError).parseJsonRpcPayload, validateJsonRpcRequest
(throw JsonRpcProtocolError with the correct spec code on any violation).success(id, result), failure(id, code, message, data?).isNotification, isPlainObject.npm install @memofs/json-rpc
Requires Node.js >= 22.
import {
failure,
JSON_RPC_ERRORS,
JsonRpcProtocolError,
parseJsonRpcPayload,
success,
validateJsonRpcRequest,
} from "@memofs/json-rpc";
// 1. Parse the incoming wire payload (throws JsonRpcProtocolError on bad JSON).
const payload = parseJsonRpcPayload(await request.text());
// 2. Validate the request shape (throws with the right spec code).
const request = validateJsonRpcRequest(payload);
// 3. Dispatch + respond.
return success(request.id, await handle(request.method, request.params));
// On an unknown method:
return failure(
request.id,
JSON_RPC_ERRORS.methodNotFound,
`Method "${request.method}" is not available.`,
);
A package with its own error hierarchy re-throws in its own type — the protocol layer never imports a consumer's classes:
import { JsonRpcProtocolError, JSON_RPC_ERRORS } from "@memofs/json-rpc";
try {
validateJsonRpcRequest(payload);
} catch (err) {
if (err instanceof JsonRpcProtocolError) {
throw new YourValidationError(err.message, {
code: err.jsonRpcCode, // the spec code, already mapped
});
}
throw err;
}
See our central Contributing Guide and development scripts for details on formatting, linting, and testing within the monorepo.
MIT
FAQs
Dependency-free JSON-RPC 2.0 protocol primitives shared by MemoFS transports.
The npm package @memofs/json-rpc receives a total of 0 weekly downloads. As such, @memofs/json-rpc popularity was classified as not popular.
We found that @memofs/json-rpc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.