Skip to content

Commit

Permalink
Merge pull request #102 from xmtp/consistent-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas authored Oct 13, 2023
2 parents 12189ac + 5274efb commit 5d123fb
Show file tree
Hide file tree
Showing 21 changed files with 506 additions and 505 deletions.
2 changes: 1 addition & 1 deletion .protolint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ lint:
# INDENT rule option.
indent:
# Available styles are 4(4-spaces), 2(2-spaces) or tab.
style: 4
style: 2
# Specifies if it should stop considering and inserting new lines at the appropriate positions
# when the inner elements are on the same line. Default is false.
not_insert_newline: true
Expand Down
18 changes: 10 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"protoc": {
"compile_on_save": false,
"options": [
"--proto_path=build/tmp/vendor",
]
},
// protolint complains if lines are longer than length 80, display a ruler
"editor.rulers": [80]
"protoc": {
"compile_on_save": false,
"options": ["--proto_path=build/tmp/vendor"]
},
"[proto3]": {
"editor.defaultFormatter": "bufbuild.vscode-buf",
"editor.formatOnSave": true
},
// protolint complains if lines are longer than length 80, display a ruler
"editor.rulers": [80]
}
232 changes: 116 additions & 116 deletions proto/keystore_api/v1/keystore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,223 +14,223 @@ option java_package = "org.xmtp.proto.keystore.api.v1";

// Application-specific error codes for the Keystore API.
enum ErrorCode {
ERROR_CODE_UNSPECIFIED = 0;
ERROR_CODE_INVALID_INPUT = 1;
ERROR_CODE_NO_MATCHING_PREKEY = 2;
ERROR_CODE_UNSPECIFIED = 0;
ERROR_CODE_INVALID_INPUT = 1;
ERROR_CODE_NO_MATCHING_PREKEY = 2;
}

// Wrapper class for errors from the Keystore API
message KeystoreError {
string message = 1;
ErrorCode code = 2;
string message = 1;
ErrorCode code = 2;
}

// Decrypt a batch of messages using X3DH key agreement
message DecryptV1Request {
// A single decryption request
message Request {
xmtp.message_contents.Ciphertext payload = 1;
xmtp.message_contents.PublicKeyBundle peer_keys = 2;
bytes header_bytes = 3;
bool is_sender = 4;
}
// A single decryption request
message Request {
xmtp.message_contents.Ciphertext payload = 1;
xmtp.message_contents.PublicKeyBundle peer_keys = 2;
bytes header_bytes = 3;
bool is_sender = 4;
}

repeated Request requests = 1;
repeated Request requests = 1;
}

// Response type for both V1 and V2 decryption requests
message DecryptResponse {
// A single decryption response
message Response {
// Wrapper object for success response
message Success {
bytes decrypted = 1;
}

oneof response {
Success result = 1;
KeystoreError error = 2;
}
// A single decryption response
message Response {
// Wrapper object for success response
message Success {
bytes decrypted = 1;
}

oneof response {
Success result = 1;
KeystoreError error = 2;
}
}

repeated Response responses = 1;
repeated Response responses = 1;
}

// Decrypt a batch of messages using the appropriate topic keys
message DecryptV2Request {
// A single decryption request
message Request {
xmtp.message_contents.Ciphertext payload = 1;
bytes header_bytes = 2;
string content_topic = 3;
}
// A single decryption request
message Request {
xmtp.message_contents.Ciphertext payload = 1;
bytes header_bytes = 2;
string content_topic = 3;
}

repeated Request requests = 1;
repeated Request requests = 1;
}

// Encrypt a batch of messages using X3DH key agreement
message EncryptV1Request {
// A single encryption request
message Request {
xmtp.message_contents.PublicKeyBundle recipient = 1;
bytes payload = 2;
bytes header_bytes = 3;
}
// A single encryption request
message Request {
xmtp.message_contents.PublicKeyBundle recipient = 1;
bytes payload = 2;
bytes header_bytes = 3;
}

repeated Request requests = 1;
repeated Request requests = 1;
}

// Response type for both V1 and V2 encryption requests
message EncryptResponse {
// A single encryption response
message Response {
// Wrapper object for success response
message Success {
xmtp.message_contents.Ciphertext encrypted = 1;
}

oneof response {
Success result = 1;
KeystoreError error = 2;
}
// A single encryption response
message Response {
// Wrapper object for success response
message Success {
xmtp.message_contents.Ciphertext encrypted = 1;
}

oneof response {
Success result = 1;
KeystoreError error = 2;
}
}

repeated Response responses = 1;
repeated Response responses = 1;
}

// Encrypt a batch of messages using the appropriate topic keys
message EncryptV2Request {
// A single encryption request
message Request {
bytes payload = 1;
bytes header_bytes = 2;
string content_topic = 3;
}
// A single encryption request
message Request {
bytes payload = 1;
bytes header_bytes = 2;
string content_topic = 3;
}

repeated Request requests = 1;
repeated Request requests = 1;
}

// Request to create an invite payload, and store the topic keys in the Keystore
message CreateInviteRequest {
xmtp.message_contents.InvitationV1.Context context = 1;
xmtp.message_contents.SignedPublicKeyBundle recipient = 2;
uint64 created_ns = 3;
xmtp.message_contents.InvitationV1.Context context = 1;
xmtp.message_contents.SignedPublicKeyBundle recipient = 2;
uint64 created_ns = 3;
}

// Request to create an invite payload from an existing topic, and store the
// topic keys in the Keystore
message CreateInviteFromTopicRequest {
xmtp.message_contents.SignedPublicKeyBundle recipient = 1;
string content_topic = 2;
uint64 created_ns = 3;
xmtp.message_contents.SignedPublicKeyBundle recipient = 1;
string content_topic = 2;
uint64 created_ns = 3;
}

// Request to create an invite payload, and store the topic keys in the Keystore
message CreateInvitesRequest {
xmtp.message_contents.InvitationV1.Context context = 1;
repeated xmtp.message_contents.SignedPublicKeyBundle recipients = 2;
uint64 created_ns = 3;
xmtp.message_contents.InvitationV1.Context context = 1;
repeated xmtp.message_contents.SignedPublicKeyBundle recipients = 2;
uint64 created_ns = 3;
}

// Response to a CreateInviteRequest
message CreateInviteResponse {
xmtp.message_contents.ConversationReference conversation = 1;
bytes payload = 2;
xmtp.message_contents.ConversationReference conversation = 1;
bytes payload = 2;
}

// Response to a CreateInvitesRequest
message CreateInvitesResponse {
repeated CreateInviteResponse responses = 1;
repeated CreateInviteResponse responses = 1;
}

// Request to save a batch of invite messages to the Keystore
message SaveInvitesRequest {
// Mirrors xmtp.envelope schema
message Request {
string content_topic = 1;
uint64 timestamp_ns = 2;
bytes payload = 3;
}
// Mirrors xmtp.envelope schema
message Request {
string content_topic = 1;
uint64 timestamp_ns = 2;
bytes payload = 3;
}

repeated Request requests = 1;
repeated Request requests = 1;
}

// Response to a SaveInvitesRequest
message SaveInvitesResponse {
// A single response
message Response {
// Wrapper object for success response
message Success {
xmtp.message_contents.ConversationReference conversation = 1;
}

oneof response {
Success result = 1;
KeystoreError error = 2;
}
// A single response
message Response {
// Wrapper object for success response
message Success {
xmtp.message_contents.ConversationReference conversation = 1;
}

repeated Response responses = 1;
oneof response {
Success result = 1;
KeystoreError error = 2;
}
}

repeated Response responses = 1;
}

// CreateAuthTokenRequest is used to create an auth token for the XMTP API
message CreateAuthTokenRequest {
optional uint64 timestamp_ns = 1;
optional uint64 timestamp_ns = 1;
}

// Response for GetV2Conversations
message GetV2ConversationsResponse {
repeated xmtp.message_contents.ConversationReference conversations = 1;
repeated xmtp.message_contents.ConversationReference conversations = 1;
}

// Used to check if the Keystore implementation has been setup for the given
// wallet address Only used for MM Snap Keystore currently
message GetKeystoreStatusRequest {
string wallet_address = 1;
string wallet_address = 1;
}

// Response to GetKeystoreStatusRequest
message GetKeystoreStatusResponse {
// Status of the Keystore for the specified wallet address
enum KeystoreStatus {
KEYSTORE_STATUS_UNSPECIFIED = 0;
KEYSTORE_STATUS_UNINITIALIZED = 1;
KEYSTORE_STATUS_INITIALIZED = 2;
}
// Status of the Keystore for the specified wallet address
enum KeystoreStatus {
KEYSTORE_STATUS_UNSPECIFIED = 0;
KEYSTORE_STATUS_UNINITIALIZED = 1;
KEYSTORE_STATUS_INITIALIZED = 2;
}

KeystoreStatus status = 1;
KeystoreStatus status = 1;
}

// Used to initialize the Keystore with a private key bundle retrieved from the
// client
message InitKeystoreRequest {
oneof bundle {
xmtp.message_contents.PrivateKeyBundleV1 v1 = 1;
}
oneof bundle {
xmtp.message_contents.PrivateKeyBundleV1 v1 = 1;
}
}

// Response to the request to initialize the Keystore
message InitKeystoreResponse {
KeystoreError error = 1;
KeystoreError error = 1;
}

// SignDigestRequest is used to sign a digest with either the identity key
// or a prekey
message SignDigestRequest {
bytes digest = 1;
oneof signer {
bool identity_key = 2;
uint32 prekey_index = 3;
}
bytes digest = 1;
oneof signer {
bool identity_key = 2;
uint32 prekey_index = 3;
}
}

// A mapping of topics to their decrypted invitations
message TopicMap {
// TopicData wraps the invitation and the timestamp it was created
message TopicData {
uint64 created_ns = 1;
string peer_address = 2;
xmtp.message_contents.InvitationV1 invitation = 3;
}
map<string, TopicData> topics = 1;
}
// TopicData wraps the invitation and the timestamp it was created
message TopicData {
uint64 created_ns = 1;
string peer_address = 2;
xmtp.message_contents.InvitationV1 invitation = 3;
}
map<string, TopicData> topics = 1;
}
Loading

0 comments on commit 5d123fb

Please sign in to comment.