# FIXME: Remove this. I think we can nuke this entire class because we don't # need it anymore. # KiriJSONRPC # # This just wraps JSONRPC and adds a little more sanity-checking, like # preventing the JSONRPC's own methods from being called by an RPC. extends JSONRPC class_name KiriJSONRPC func process_action_safer(action: Variant, recurse: bool = false) -> Variant: if action is String: action = JSON.parse_string(action) # Do some basic type sanity checking. var invalid_request : bool = false if not (action is Dictionary): invalid_request = true elif not ("method" in action): invalid_request = true elif not (action["method"] is String): invalid_request = true if invalid_request: return make_response_error( JSONRPC.INVALID_REQUEST, "Invalid request") # Exclude JSONRPC's own built-in methods. Why the heck are these allowed # here? var method_name = action["method"] var id = action["id"] var bad_message_names = [ "make_notification", "make_request", "make_response", "make_response_error", "process_action", "process_string", "set_scope" ] if method_name in bad_message_names: return make_response_error( JSONRPC.METHOD_NOT_FOUND, "Method not found: " + method_name, id) return process_action(action, recurse)