-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customizable Error Filtering for js-rpc through User-Defined toError/fromError Functions #10
Comments
This could be have been in #3. |
A single replacer should be sufficient. What does the API look like? |
RIght, sensitive replacer was related stack value of PK. So I will refactor that out. API of? |
Give me an example of how it would be used here. |
JSON RPC reponse :
toError does not necessarily need a reviver as a parameter. |
|
The You'll need to maintain a sort of context to know if you are under the tree of Given that |
*Related: #10 Reviewed-by: @tegefaulkes [ci skip]
callers and handlers are now refactored * WIP - Newline now works, refers issue #1 node v20 fix feat: handlers implementations are now abstract arrow functions * Fixes #5 [ci skip] * resolves issue 5, makes RPC handlers abstract arrow function properties feat: rename to uppercase [ci skip] fix: handler export fix [ci skip] fix: tsconf from quic [ci skip] fix: dependencies (js quic), events and errors versions, changing to relative imports, jest dev dependency, js-quic tsconfig [ci skip] fix: tests imports, using @ [ci skip] chore: removed sysexits chore: fix default exports for callers and handlers Fixed index for handlers fix: remove @matrixai/id fix: remove @matrixai/id and ix chore : diagram [ci skip] chore : lintfix fix: errors now extend AbstractError [ci skip] fix: undoing fix #1 [ci skip] replacd errorCode with just code, references std error codes from rpc spec feat: events based createDestroy [ci skip] chore: img format fix [ci skip] chore: img in README.md [ci skip] feat: allows the user to pass in a generator function if the user wishes to specify a particular id [ci skip] fix: fixes #7 * Removes graceTimer and related jests chore: idGen name change. idGen parameter in creation and constructor. No longer optional. Only defaulted in one place. wip: added idgen to jests, was missing. [ci skip] wip: reimported ix, since a few tests rely on it. removed, matrixai/id wip: jests for #4 removed, matrixai/id wip: * Implements custom RPC Error codes. * Fixed jest for concurrent timeouts * All errors now have a cause * All errors now use custom error codes. wip: *Client uses ctx timer now wip: *Jests to test concurrency wip: *custom RPC based errors for RPC Client, now all errors have a cause and an error message WIP: * Refactor out sensitiveReplacer WIP: * Refactor out sensitiveReplacer WIP: * Update to latest async init and events * set default timeout to Infinity * jest to check server and client with infinite timeout * fixing jests which broke after changing default timeout to infinity WIP: f1x #4 WIP: f1x #11 f1x: parameterize toError, fromError and replacer wip: tofrom fix: parameterize toError, fromError and replacer fix: Makes concurrent jests non deterministic * Related #4 fix: parameterize replacer toError and fromError, change fromError to return JSONValue, stringify fromError usages * Related #10 fix: Converted global state for fromError to handle it internally. *Related: #10 Reviewed-by: @tegefaulkes [ci skip] chore: Jests for fromError and toError, and using a custom replacer. related: #10 [ci skip]
Errors can go both directions. Server to client and client to server. This means both On top of this, Furthermore |
Another issue is the idea of the default middleware. Is the default middleware necessary? If so, you cannot expect the user to supply middleware combined with the default if they are not aware of it. You must then instead take in additional middleware and compose with the default middleware. I'm not sure about this but @tegefaulkes can explain more later about this. |
Therefore the
|
Default middleware is a compromise. We need to map the stream from The alternative was to split up the user supplied middleware into stages. raw data stage and JSON message stage. To do this it will take a little bit of refactoring and prototyping with how the middleware is supplied and composed. |
Let's examine the relationship between JSON RPC errors and stream errors. On the transport layer we have stream error codes. This is why we have On the application layer, we have RPC errors. In this case an error is encoded as per the JSON RPC protocol. https://www.jsonrpc.org/specification#error_object Which might look something like this:
Therefore let's consider how Server SideThe idea here is that during the handling of a stream. The handler function may throw up an error. Let's consider just for unary handlers.
In this case the
This could be done by default to be:
The result is then combined with the rest of the JSON RPC message to eventually produce:
On the other side, when it receives this JSON RPC error message. The parser/middleware is supposed to understand it, and thus convert it back to the exception object, that being of
This is actually similar to the default we have in For the client, it now as per calling the networked handler, should throw up that exception object.
ClientFor the client the opposite order occurs. But it still requires For StreamsStreams needs to do the same thing. Stream handlers have to now deal with errors being thrown into the async iterator/generator and dealt with too. |
Some discussion with @tegefaulkes.
Regardless, when creating |
So for now, if the user wants to supply custom middleware, they have to combine it with the default middleware explicitly? Is this guaranteed by the types? |
Using the default middleware isn't enforced by types. But that mapping of |
Seems that errors sent through the forward path just wasn't supported and I think I know why. The JSONRPC spec doesn't really allow it. The Error message is a response type message. So it's not really allowed
I'm not sure it's a simple change to allow RPC errors on the forward path and even if we add it its not really a feature we need. |
whats filter sensitive for? The replacer can take in any key as a parameter, definable by the user |
@CMCDragonkai, client doesn't currently transmit any errors to server, so whats exactly the need for fromError in client and conversely toError in server? |
Moved to #18 |
# This is the 1st commit message: fix: RPCServer.start is now no longer a factory function fix: fixed RPC tests after async-init change # This is the commit message #2: chore: updated inline documentation according to async-init changes # This is the commit message #3: wip: fixing imports # This is the commit message #4: wip: RPCServer deconstruction # This is the commit message #5: fix: RPCServer start stop order # This is the commit message #6: fix: added back createDestroy back to RPCClient # This is the commit message #7: chore: lintfix # This is the commit message #8: wip: completely removed create destroy from rpcclient # This is the commit message #9: fix: RPCClient tests after async-init changes # This is the commit message #10: wip # This is the commit message #11: fix: idgen is optional in constructor # This is the commit message #12: fix: type import in ./types # This is the commit message #13: chore: test for RPCServer force stopping # This is the commit message #14: fix: proper implementation of fromError toError, clientOutputTransformStream no longer outputs error.data, but rather error directly # This is the commit message #15: fix: jest fix for ErrorRPCRemote # This is the commit message #16: wip toError fromError fix: proper implementation of fromError toError, clientOutputTransformStream no longer outputs error.data, but rather error directly fix: changed rpcClient toError implementation fix: changing ErrorRPCRemote constructor to be in-line with toError error creation constructor fix: jest fix for ErrorRPCRemote fix: fixing exports fix: RPC errors now correctly extend AbstractError fix: removed old events fix: cleaned up imports feat: client has toError as parameter fix: removed type from JSONError obj fix: startStop constructor correctly used fix: infinity is definitely not == 1 minute chore: rename variable
Description
Enable user-defined error serialization and deserialization through toError and fromError functions in js-rpc. Add optional replacer and reviver parameters to further customize the (de)serialization process, thereby enhancing security by allowing application-specific rules for sensitive data filtering.
Requirements
Tasks
Acceptance Criteria
The text was updated successfully, but these errors were encountered: