shogowada / json-rpc-2.0

Let your client and server talk over function calls under JSON-RPC 2.0 spec. Strongly typed. No external dependencies.

Home Page:https://www.npmjs.com/package/json-rpc-2.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

models.ts isJSONRPCResponse logic hole intentional?

okaihc opened this issue · comments

The following logic allows a variety of badly formatted JSON string to be reported back as valid JSON-RPC response.

export const isJSONRPCResponse = (payload: any): payload is JSONRPCResponse => {
return !isJSONRPCRequest(payload);
};

Also even if I patched it up to confirm that payload is neither Response nor Request, receiveAndSend() does not reject. Not sure if this was intentional but it seems it would be good to be able to use a .catch with receiveAndSend() when payload is neither Response nor Request?

You are right. Both issue are fixed with json-rpc-2.0@0.2.10.

Thanks

Works beautifully! Thanks!
BTW this is the only javascript/typescript library I can find that does JSON-RPC 2.0 bi-directionally over a single WebSocket connection AND completely separates the transport from the RPC protocol. It allows me to do things like use more than one protocol on the same WebSocket connection and still have access to the raw WebSocket for whatever funny reason I have...thanks for posting this project.