Skip to content
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

[Session] Adding the Relay type #53

Merged
merged 10 commits into from
Oct 11, 2023
87 changes: 87 additions & 0 deletions proto/pocket/service/relay.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
syntax = "proto3";
package pocket.service;

option go_package = "pocket/x/service/types";


import "cosmos_proto/cosmos.proto";
import "pocket/service/service.proto";
import "pocket/application/application.proto";
import "pocket/supplier/supplier.proto";

// Relay is a protobuf containing both the RelayRequest, signed by the Application
// and the RelayResponse, signed by the Supplier. Together, the serialized tuple is
// what is inserted into the SMST leaves as values in the Claim/Proof lifecycle.
message Relay {
RelayRequest req = 1;
RelayResponse res = 2;
}

// RelayMeta is used to hold the metadata for a RelayRequest.
message RelayRequestMetadata {
session.SessionHeader session_header = 1; // The session header for the relay
map<string, string> headers = 2; // The headers of the request
bytes application_signature = 3; // The signature of the application of the request
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
}

// RelayResponse is used to hold the response from a RelayRequest.
message RelayRequest {
RelayRequestMetadata meta = 1;
// TODO: Add other relay types in the future such as the ones below:
oneof payload {
JSONRPCPayload json_rpc_payload = 2;
RESTPayload rest_payload = 3;
// WebSocketsPayload websockets_payload = 4;
// GRPCPayload grpc_payload = 5;
// GraphQLPayload graphql_payload = 6;
}
}

// RelayResponseMetadata is used to hold the metadata for a RelayResponse
message RelayResponseMetadata {
session.SessionHeader session_header = 1; // The session header for the relay
map<string, string> headers = 2; // The headers of the response
uint32 status_code = 3; // The status code of the response
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
string err = 4; // The error message of the response
bytes supplier_signature = 5; // The signature of the supplier on the response
}

// RelayResponse is used to hold the response to a RelayRequest.
message RelayResponse {
RelayResponseMetadata meta = 1;
// TODO: Add other relay types in the future such as the ones below:
oneof payload {
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
JSONRPCPayload json_rpc_payload = 2;
RESTPayload rest_payload = 3;
// WebSocketsPayload websockets_payload = 4;
// GRPCPayload grpc_payload = 5;
// GraphQLPayload graphql_payload = 6;
}
}

// JSONRPCPayload is used to hold the payload and request metadata for a JSON-RPC request.
// See the JSONRPC spec in the following link for more details: https://www.jsonrpc.org/specification#request_object
message JSONRPCPayload {
bytes id = 1; // JSONRPC version 2 expected a field named "id".
string jsonrpc = 2; // JSONRPC version 2 expects a field named "jsonrpc" with a value of "2.0".
string method = 3; // The method being invoked on the server.
map<string, string> parameters = 4; // The parameters field can be empty, an array or a structure
bytes data = 5;
}

// RESTRequestType is used to hold the type of REST request being made.
enum RESTRequestType {
REST_REQUEST_TYPE_UNKNOWN = 0; // Default value, used for uninitialized fields
REST_REQUEST_TYPE_GET = 1;
REST_REQUEST_TYPE_PUT = 2;
REST_REQUEST_TYPE_POST = 3;
REST_REQUEST_TYPE_DELETE = 4;
}

// RESTPayload is used to hold the payload and request metadata for a REST request.
message RESTPayload {
RESTRequestType request_type = 1;
string http_path = 2;
string contents = 3;
// TODO_INCOMPLETE: Add REST relay payload fields
}
Loading