diff --git a/.protolint.yaml b/.protolint.yaml index 3aef447..5a92260 100644 --- a/.protolint.yaml +++ b/.protolint.yaml @@ -50,6 +50,8 @@ lint: - MESSAGES_HAVE_COMMENT - RPCS_HAVE_COMMENT - SERVICES_HAVE_COMMENT + # Allow for fields we have in libxmtp like "sent_at_ns" + - FIELD_NAMES_EXCLUDE_PREPOSITIONS # Linter rules option. rules_option: diff --git a/proto/device_sync/consent_backup.proto b/proto/device_sync/consent_backup.proto new file mode 100644 index 0000000..12bd636 --- /dev/null +++ b/proto/device_sync/consent_backup.proto @@ -0,0 +1,26 @@ +// Definitions for backups +syntax = "proto3"; +package xmtp.device_sync.consent_backup; + +// Proto representation of a consent record save +message ConsentSave { + ConsentTypeSave entity_type = 1; + ConsentStateSave state = 2; + string entity = 3; +} + +// Consent record type +enum ConsentTypeSave { + CONSENT_TYPE_SAVE_UNSPECIFIED = 0; + CONSENT_TYPE_SAVE_CONVERSATION_ID = 1; + CONSENT_TYPE_SAVE_INBOX_ID = 2; + CONSENT_TYPE_SAVE_ADDRESS = 3; +} + +// Consent record state +enum ConsentStateSave { + CONSENT_STATE_SAVE_UNSPECIFIED = 0; + CONSENT_STATE_SAVE_UNKNOWN = 1; + CONSENT_STATE_SAVE_ALLOWED = 2; + CONSENT_STATE_SAVE_DENIED = 3; +} diff --git a/proto/device_sync/device_sync.proto b/proto/device_sync/device_sync.proto new file mode 100644 index 0000000..95a513b --- /dev/null +++ b/proto/device_sync/device_sync.proto @@ -0,0 +1,33 @@ +// Definitions for backups +syntax = "proto3"; +package xmtp.device_sync; + +import "device_sync/consent_backup.proto"; +import "device_sync/group_backup.proto"; +import "device_sync/message_backup.proto"; + +// Union type representing everything that can be serialied and saved in a backup archive. +message BackupElement { + oneof element { + BackupMetadataSave metadata = 1; + xmtp.device_sync.group_backup.GroupSave group = 2; + xmtp.device_sync.message_backup.GroupMessageSave group_message = 3; + xmtp.device_sync.consent_backup.ConsentSave consent = 4; + } +} + +// Proto representation of backup metadata +// (Backup version is explicitly missing - it's stored as a header.) +message BackupMetadataSave { + repeated BackupElementSelection elements = 2; + int64 exported_at_ns = 3; + optional int64 start_ns = 4; + optional int64 end_ns = 5; +} + +// Elements selected for backup +enum BackupElementSelection { + BACKUP_ELEMENT_SELECTION_UNSPECIFIED = 0; + BACKUP_ELEMENT_SELECTION_MESSAGES = 1; + BACKUP_ELEMENT_SELECTION_CONSENT = 2; +} diff --git a/proto/device_sync/group_backup.proto b/proto/device_sync/group_backup.proto new file mode 100644 index 0000000..df52390 --- /dev/null +++ b/proto/device_sync/group_backup.proto @@ -0,0 +1,35 @@ +// Definitions for backups +syntax = "proto3"; +package xmtp.device_sync.group_backup; + +// Proto representation of a stored group +message GroupSave { + bytes id = 1; + int64 created_at_ns = 2; + GroupMembershipStateSave membership_state = 3; + int64 installations_last_checked = 4; + string added_by_inbox_id = 5; + optional int64 welcome_id = 6; + int64 rotated_at_ns = 7; + ConversationTypeSave conversation_type = 8; + optional string dm_id = 9; + optional int64 last_message_ns = 10; + optional int64 message_disappear_from_ns = 11; + optional int64 message_disappear_in_ns = 12; +} + +// Group membership state +enum GroupMembershipStateSave { + GROUP_MEMBERSHIP_STATE_SAVE_UNSPECIFIED = 0; + GROUP_MEMBERSHIP_STATE_SAVE_ALLOWED = 1; + GROUP_MEMBERSHIP_STATE_SAVE_REJECTED = 2; + GROUP_MEMBERSHIP_STATE_SAVE_PENDING = 3; +} + +// Conversation type +enum ConversationTypeSave { + CONVERSATION_TYPE_SAVE_UNSPECIFIED = 0; + CONVERSATION_TYPE_SAVE_GROUP = 1; + CONVERSATION_TYPE_SAVE_DM = 2; + CONVERSATION_TYPE_SAVE_SYNC = 3; +} diff --git a/proto/device_sync/message_backup.proto b/proto/device_sync/message_backup.proto new file mode 100644 index 0000000..9870cfe --- /dev/null +++ b/proto/device_sync/message_backup.proto @@ -0,0 +1,50 @@ +// Definitions for backups +syntax = "proto3"; +package xmtp.device_sync.message_backup; + +// Proto representation of a stored group message +message GroupMessageSave { + bytes id = 1; + bytes group_id = 2; + bytes decrypted_message_bytes = 3; + int64 sent_at_ns = 4; + GroupMessageKindSave kind = 5; + bytes sender_installation_id = 6; + string sender_inbox_id = 7; + DeliveryStatusSave delivery_status = 8; + ContentTypeSave content_type = 9; + int32 version_major = 10; + int32 version_minor = 11; + string authority_id = 12; + optional bytes reference_id = 13; +} + +// Group message kind +enum GroupMessageKindSave { + GROUP_MESSAGE_KIND_SAVE_UNSPECIFIED = 0; + GROUP_MESSAGE_KIND_SAVE_APPLICATION = 1; + GROUP_MESSAGE_KIND_SAVE_MEMBERSHIP_CHANGE = 2; +} + +// Group message delivery status +enum DeliveryStatusSave { + DELIVERY_STATUS_SAVE_UNSPECIFIED = 0; + DELIVERY_STATUS_SAVE_UNPUBLISHED = 1; + DELIVERY_STATUS_SAVE_PUBLISHED = 2; + DELIVERY_STATUS_SAVE_FAILED = 3; +} + +// Group message content type +enum ContentTypeSave { + CONTENT_TYPE_SAVE_UNSPECIFIED = 0; + CONTENT_TYPE_SAVE_UNKNOWN = 1; + CONTENT_TYPE_SAVE_TEXT = 2; + CONTENT_TYPE_SAVE_GROUP_MEMBERSHIP_CHANGE = 3; + CONTENT_TYPE_SAVE_GROUP_UPDATED = 4; + CONTENT_TYPE_SAVE_REACTION = 5; + CONTENT_TYPE_SAVE_READ_RECEIPT = 6; + CONTENT_TYPE_SAVE_REPLY = 7; + CONTENT_TYPE_SAVE_ATTACHMENT = 8; + CONTENT_TYPE_SAVE_REMOTE_ATTACHMENT = 9; + CONTENT_TYPE_SAVE_TRANSACTION_REFERENCE = 10; +}