remove `/proto copy`
This commit is contained in:
parent
9e61001af7
commit
0744f7615e
|
@ -1,48 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message ApplicationMetadataMessage {
|
||||
// Signature of the payload field
|
||||
bytes signature = 1;
|
||||
// This is the encoded protobuf of the application level message, i.e ChatMessage
|
||||
bytes payload = 2;
|
||||
|
||||
// The type of protobuf message sent
|
||||
Type type = 3;
|
||||
|
||||
enum Type {
|
||||
TYPE_UNKNOWN_UNSPECIFIED = 0;
|
||||
TYPE_CHAT_MESSAGE = 1;
|
||||
TYPE_CONTACT_UPDATE = 2;
|
||||
TYPE_MEMBERSHIP_UPDATE_MESSAGE = 3;
|
||||
TYPE_PAIR_INSTALLATION = 4;
|
||||
TYPE_SYNC_INSTALLATION = 5;
|
||||
TYPE_REQUEST_ADDRESS_FOR_TRANSACTION = 6;
|
||||
TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION = 7;
|
||||
TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION = 8;
|
||||
TYPE_REQUEST_TRANSACTION = 9;
|
||||
TYPE_SEND_TRANSACTION = 10;
|
||||
TYPE_DECLINE_REQUEST_TRANSACTION = 11;
|
||||
TYPE_SYNC_INSTALLATION_CONTACT = 12;
|
||||
TYPE_SYNC_INSTALLATION_ACCOUNT = 13;
|
||||
TYPE_SYNC_INSTALLATION_PUBLIC_CHAT = 14;
|
||||
TYPE_CONTACT_CODE_ADVERTISEMENT = 15;
|
||||
TYPE_PUSH_NOTIFICATION_REGISTRATION = 16;
|
||||
TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE = 17;
|
||||
TYPE_PUSH_NOTIFICATION_QUERY = 18;
|
||||
TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE = 19;
|
||||
TYPE_PUSH_NOTIFICATION_REQUEST = 20;
|
||||
TYPE_PUSH_NOTIFICATION_RESPONSE = 21;
|
||||
TYPE_EMOJI_REACTION = 22;
|
||||
TYPE_GROUP_CHAT_INVITATION = 23;
|
||||
TYPE_CHAT_IDENTITY = 24;
|
||||
TYPE_COMMUNITY_DESCRIPTION = 25;
|
||||
TYPE_COMMUNITY_INVITATION = 26;
|
||||
TYPE_COMMUNITY_REQUEST_TO_JOIN = 27;
|
||||
TYPE_PIN_MESSAGE = 28;
|
||||
TYPE_EDIT_MESSAGE = 29;
|
||||
TYPE_STATUS_UPDATE = 30;
|
||||
TYPE_DELETE_MESSAGE = 31;
|
||||
TYPE_SYNC_INSTALLATION_COMMUNITY = 32;
|
||||
TYPE_ANONYMOUS_METRIC_BATCH = 33;
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
enumeration,
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
bytes,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface ApplicationMetadataMessage {
|
||||
signature: Uint8Array
|
||||
payload: Uint8Array
|
||||
type: ApplicationMetadataMessage.Type
|
||||
}
|
||||
|
||||
export namespace ApplicationMetadataMessage {
|
||||
export enum Type {
|
||||
TYPE_UNKNOWN_UNSPECIFIED = 'TYPE_UNKNOWN_UNSPECIFIED',
|
||||
TYPE_CHAT_MESSAGE = 'TYPE_CHAT_MESSAGE',
|
||||
TYPE_CONTACT_UPDATE = 'TYPE_CONTACT_UPDATE',
|
||||
TYPE_MEMBERSHIP_UPDATE_MESSAGE = 'TYPE_MEMBERSHIP_UPDATE_MESSAGE',
|
||||
TYPE_PAIR_INSTALLATION = 'TYPE_PAIR_INSTALLATION',
|
||||
TYPE_SYNC_INSTALLATION = 'TYPE_SYNC_INSTALLATION',
|
||||
TYPE_REQUEST_ADDRESS_FOR_TRANSACTION = 'TYPE_REQUEST_ADDRESS_FOR_TRANSACTION',
|
||||
TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION = 'TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION',
|
||||
TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION = 'TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION',
|
||||
TYPE_REQUEST_TRANSACTION = 'TYPE_REQUEST_TRANSACTION',
|
||||
TYPE_SEND_TRANSACTION = 'TYPE_SEND_TRANSACTION',
|
||||
TYPE_DECLINE_REQUEST_TRANSACTION = 'TYPE_DECLINE_REQUEST_TRANSACTION',
|
||||
TYPE_SYNC_INSTALLATION_CONTACT = 'TYPE_SYNC_INSTALLATION_CONTACT',
|
||||
TYPE_SYNC_INSTALLATION_ACCOUNT = 'TYPE_SYNC_INSTALLATION_ACCOUNT',
|
||||
TYPE_SYNC_INSTALLATION_PUBLIC_CHAT = 'TYPE_SYNC_INSTALLATION_PUBLIC_CHAT',
|
||||
TYPE_CONTACT_CODE_ADVERTISEMENT = 'TYPE_CONTACT_CODE_ADVERTISEMENT',
|
||||
TYPE_PUSH_NOTIFICATION_REGISTRATION = 'TYPE_PUSH_NOTIFICATION_REGISTRATION',
|
||||
TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE = 'TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE',
|
||||
TYPE_PUSH_NOTIFICATION_QUERY = 'TYPE_PUSH_NOTIFICATION_QUERY',
|
||||
TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE = 'TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE',
|
||||
TYPE_PUSH_NOTIFICATION_REQUEST = 'TYPE_PUSH_NOTIFICATION_REQUEST',
|
||||
TYPE_PUSH_NOTIFICATION_RESPONSE = 'TYPE_PUSH_NOTIFICATION_RESPONSE',
|
||||
TYPE_EMOJI_REACTION = 'TYPE_EMOJI_REACTION',
|
||||
TYPE_GROUP_CHAT_INVITATION = 'TYPE_GROUP_CHAT_INVITATION',
|
||||
TYPE_CHAT_IDENTITY = 'TYPE_CHAT_IDENTITY',
|
||||
TYPE_COMMUNITY_DESCRIPTION = 'TYPE_COMMUNITY_DESCRIPTION',
|
||||
TYPE_COMMUNITY_INVITATION = 'TYPE_COMMUNITY_INVITATION',
|
||||
TYPE_COMMUNITY_REQUEST_TO_JOIN = 'TYPE_COMMUNITY_REQUEST_TO_JOIN',
|
||||
TYPE_PIN_MESSAGE = 'TYPE_PIN_MESSAGE',
|
||||
TYPE_EDIT_MESSAGE = 'TYPE_EDIT_MESSAGE',
|
||||
TYPE_STATUS_UPDATE = 'TYPE_STATUS_UPDATE',
|
||||
TYPE_DELETE_MESSAGE = 'TYPE_DELETE_MESSAGE',
|
||||
TYPE_SYNC_INSTALLATION_COMMUNITY = 'TYPE_SYNC_INSTALLATION_COMMUNITY',
|
||||
TYPE_ANONYMOUS_METRIC_BATCH = 'TYPE_ANONYMOUS_METRIC_BATCH',
|
||||
}
|
||||
|
||||
enum __TypeValues {
|
||||
TYPE_UNKNOWN_UNSPECIFIED = 0,
|
||||
TYPE_CHAT_MESSAGE = 1,
|
||||
TYPE_CONTACT_UPDATE = 2,
|
||||
TYPE_MEMBERSHIP_UPDATE_MESSAGE = 3,
|
||||
TYPE_PAIR_INSTALLATION = 4,
|
||||
TYPE_SYNC_INSTALLATION = 5,
|
||||
TYPE_REQUEST_ADDRESS_FOR_TRANSACTION = 6,
|
||||
TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION = 7,
|
||||
TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION = 8,
|
||||
TYPE_REQUEST_TRANSACTION = 9,
|
||||
TYPE_SEND_TRANSACTION = 10,
|
||||
TYPE_DECLINE_REQUEST_TRANSACTION = 11,
|
||||
TYPE_SYNC_INSTALLATION_CONTACT = 12,
|
||||
TYPE_SYNC_INSTALLATION_ACCOUNT = 13,
|
||||
TYPE_SYNC_INSTALLATION_PUBLIC_CHAT = 14,
|
||||
TYPE_CONTACT_CODE_ADVERTISEMENT = 15,
|
||||
TYPE_PUSH_NOTIFICATION_REGISTRATION = 16,
|
||||
TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE = 17,
|
||||
TYPE_PUSH_NOTIFICATION_QUERY = 18,
|
||||
TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE = 19,
|
||||
TYPE_PUSH_NOTIFICATION_REQUEST = 20,
|
||||
TYPE_PUSH_NOTIFICATION_RESPONSE = 21,
|
||||
TYPE_EMOJI_REACTION = 22,
|
||||
TYPE_GROUP_CHAT_INVITATION = 23,
|
||||
TYPE_CHAT_IDENTITY = 24,
|
||||
TYPE_COMMUNITY_DESCRIPTION = 25,
|
||||
TYPE_COMMUNITY_INVITATION = 26,
|
||||
TYPE_COMMUNITY_REQUEST_TO_JOIN = 27,
|
||||
TYPE_PIN_MESSAGE = 28,
|
||||
TYPE_EDIT_MESSAGE = 29,
|
||||
TYPE_STATUS_UPDATE = 30,
|
||||
TYPE_DELETE_MESSAGE = 31,
|
||||
TYPE_SYNC_INSTALLATION_COMMUNITY = 32,
|
||||
TYPE_ANONYMOUS_METRIC_BATCH = 33,
|
||||
}
|
||||
|
||||
export namespace Type {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Type>(__TypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<ApplicationMetadataMessage> => {
|
||||
return message<ApplicationMetadataMessage>({
|
||||
1: { name: 'signature', codec: bytes },
|
||||
2: { name: 'payload', codec: bytes },
|
||||
3: { name: 'type', codec: ApplicationMetadataMessage.Type.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: ApplicationMetadataMessage): Uint8Array => {
|
||||
return encodeMessage(obj, ApplicationMetadataMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): ApplicationMetadataMessage => {
|
||||
return decodeMessage(buf, ApplicationMetadataMessage.codec())
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import "enums.proto";
|
||||
|
||||
// ChatIdentity represents the user defined identity associated with their public chat key
|
||||
message ChatIdentity {
|
||||
// Lamport timestamp of the message
|
||||
uint64 clock = 1;
|
||||
|
||||
// ens_name is the valid ENS name associated with the chat key
|
||||
string ens_name = 2;
|
||||
|
||||
// images is a string indexed mapping of images associated with an identity
|
||||
map<string, IdentityImage> images = 3;
|
||||
|
||||
// display name is the user set identity
|
||||
string display_name = 4;
|
||||
|
||||
// description is the user set description, valid only for organisations
|
||||
string description = 5;
|
||||
|
||||
string color = 6;
|
||||
|
||||
string emoji = 7;
|
||||
}
|
||||
|
||||
// ProfileImage represents data associated with a user's profile image
|
||||
message IdentityImage {
|
||||
|
||||
// payload is a context based payload for the profile image data,
|
||||
// context is determined by the `source_type`
|
||||
bytes payload = 1;
|
||||
|
||||
// source_type signals the image payload source
|
||||
SourceType source_type = 2;
|
||||
|
||||
// image_type signals the image type and method of parsing the payload
|
||||
ImageType image_type = 3;
|
||||
|
||||
// encryption_keys is a list of encrypted keys that can be used to decrypted an encrypted payload
|
||||
repeated bytes encryption_keys = 4;
|
||||
|
||||
// encrypted signals the encryption state of the payload, default is false.
|
||||
bool encrypted = 5;
|
||||
|
||||
// SourceType are the predefined types of image source allowed
|
||||
enum SourceType {
|
||||
UNKNOWN_SOURCE_TYPE = 0;
|
||||
|
||||
// RAW_PAYLOAD image byte data
|
||||
RAW_PAYLOAD = 1;
|
||||
|
||||
// ENS_AVATAR uses the ENS record's resolver get-text-data.avatar data
|
||||
// The `payload` field will be ignored if ENS_AVATAR is selected
|
||||
// The application will read and parse the ENS avatar data as image payload data, URLs will be ignored
|
||||
// The parent `ChatMessageIdentity` must have a valid `ens_name` set
|
||||
ENS_AVATAR = 2;
|
||||
}
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
uint64,
|
||||
string,
|
||||
enumeration,
|
||||
bytes,
|
||||
bool,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface ChatIdentity {
|
||||
clock: bigint
|
||||
ensName: string
|
||||
images: IdentityImage
|
||||
displayName: string
|
||||
description: string
|
||||
color: string
|
||||
emoji: string
|
||||
}
|
||||
|
||||
export namespace ChatIdentity {
|
||||
export const codec = (): Codec<ChatIdentity> => {
|
||||
return message<ChatIdentity>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'ensName', codec: string },
|
||||
3: { name: 'images', codec: IdentityImage.codec() },
|
||||
4: { name: 'displayName', codec: string },
|
||||
5: { name: 'description', codec: string },
|
||||
6: { name: 'color', codec: string },
|
||||
7: { name: 'emoji', codec: string },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: ChatIdentity): Uint8Array => {
|
||||
return encodeMessage(obj, ChatIdentity.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): ChatIdentity => {
|
||||
return decodeMessage(buf, ChatIdentity.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface IdentityImage {
|
||||
payload: Uint8Array
|
||||
sourceType: IdentityImage.SourceType
|
||||
imageType: ImageType
|
||||
encryptionKeys: Uint8Array[]
|
||||
encrypted: boolean
|
||||
}
|
||||
|
||||
export namespace IdentityImage {
|
||||
export enum SourceType {
|
||||
UNKNOWN_SOURCE_TYPE = 'UNKNOWN_SOURCE_TYPE',
|
||||
RAW_PAYLOAD = 'RAW_PAYLOAD',
|
||||
ENS_AVATAR = 'ENS_AVATAR',
|
||||
}
|
||||
|
||||
enum __SourceTypeValues {
|
||||
UNKNOWN_SOURCE_TYPE = 0,
|
||||
RAW_PAYLOAD = 1,
|
||||
ENS_AVATAR = 2,
|
||||
}
|
||||
|
||||
export namespace SourceType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof SourceType>(__SourceTypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<IdentityImage> => {
|
||||
return message<IdentityImage>({
|
||||
1: { name: 'payload', codec: bytes },
|
||||
2: { name: 'sourceType', codec: IdentityImage.SourceType.codec() },
|
||||
3: { name: 'imageType', codec: ImageType.codec() },
|
||||
4: { name: 'encryptionKeys', codec: bytes, repeats: true },
|
||||
5: { name: 'encrypted', codec: bool },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: IdentityImage): Uint8Array => {
|
||||
return encodeMessage(obj, IdentityImage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): IdentityImage => {
|
||||
return decodeMessage(buf, IdentityImage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export enum MessageType {
|
||||
UNKNOWN_MESSAGE_TYPE = 'UNKNOWN_MESSAGE_TYPE',
|
||||
ONE_TO_ONE = 'ONE_TO_ONE',
|
||||
PUBLIC_GROUP = 'PUBLIC_GROUP',
|
||||
PRIVATE_GROUP = 'PRIVATE_GROUP',
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 'SYSTEM_MESSAGE_PRIVATE_GROUP',
|
||||
COMMUNITY_CHAT = 'COMMUNITY_CHAT',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __MessageTypeValues {
|
||||
UNKNOWN_MESSAGE_TYPE = 0,
|
||||
ONE_TO_ONE = 1,
|
||||
PUBLIC_GROUP = 2,
|
||||
PRIVATE_GROUP = 3,
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4,
|
||||
COMMUNITY_CHAT = 5,
|
||||
SYSTEM_MESSAGE_GAP = 6,
|
||||
}
|
||||
|
||||
export namespace MessageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof MessageType>(__MessageTypeValues)
|
||||
}
|
||||
}
|
||||
export enum ImageType {
|
||||
UNKNOWN_IMAGE_TYPE = 'UNKNOWN_IMAGE_TYPE',
|
||||
PNG = 'PNG',
|
||||
JPEG = 'JPEG',
|
||||
WEBP = 'WEBP',
|
||||
GIF = 'GIF',
|
||||
}
|
||||
|
||||
enum __ImageTypeValues {
|
||||
UNKNOWN_IMAGE_TYPE = 0,
|
||||
PNG = 1,
|
||||
JPEG = 2,
|
||||
WEBP = 3,
|
||||
GIF = 4,
|
||||
}
|
||||
|
||||
export namespace ImageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ImageType>(__ImageTypeValues)
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import "enums.proto";
|
||||
|
||||
message StickerMessage {
|
||||
string hash = 1;
|
||||
int32 pack = 2;
|
||||
}
|
||||
|
||||
message ImageMessage {
|
||||
bytes payload = 1;
|
||||
ImageType type = 2;
|
||||
}
|
||||
|
||||
message AudioMessage {
|
||||
bytes payload = 1;
|
||||
AudioType type = 2;
|
||||
uint64 duration_ms = 3;
|
||||
enum AudioType {
|
||||
UNKNOWN_AUDIO_TYPE = 0;
|
||||
AAC = 1;
|
||||
AMR = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message EditMessage {
|
||||
uint64 clock = 1;
|
||||
// Text of the message
|
||||
string text = 2;
|
||||
|
||||
string chat_id = 3;
|
||||
string message_id = 4;
|
||||
|
||||
// Grant for community edit messages
|
||||
bytes grant = 5;
|
||||
|
||||
// The type of message (public/one-to-one/private-group-chat)
|
||||
MessageType message_type = 6;
|
||||
}
|
||||
|
||||
message DeleteMessage {
|
||||
uint64 clock = 1;
|
||||
|
||||
string chat_id = 2;
|
||||
string message_id = 3;
|
||||
|
||||
// Grant for community delete messages
|
||||
bytes grant = 4;
|
||||
|
||||
// The type of message (public/one-to-one/private-group-chat)
|
||||
MessageType message_type = 5;
|
||||
}
|
||||
|
||||
|
||||
message ChatMessage {
|
||||
// Lamport timestamp of the chat message
|
||||
uint64 clock = 1;
|
||||
// Unix timestamps in milliseconds, currently not used as we use whisper as more reliable, but here
|
||||
// so that we don't rely on it
|
||||
uint64 timestamp = 2;
|
||||
// Text of the message
|
||||
string text = 3;
|
||||
// Id of the message that we are replying to
|
||||
string response_to = 4;
|
||||
// Ens name of the sender
|
||||
string ens_name = 5;
|
||||
// Chat id, this field is symmetric for public-chats and private group chats,
|
||||
// but asymmetric in case of one-to-ones, as the sender will use the chat-id
|
||||
// of the received, while the receiver will use the chat-id of the sender.
|
||||
// Probably should be the concatenation of sender-pk & receiver-pk in alphabetical order
|
||||
string chat_id = 6;
|
||||
|
||||
// The type of message (public/one-to-one/private-group-chat)
|
||||
MessageType message_type = 7;
|
||||
// The type of the content of the message
|
||||
ContentType content_type = 8;
|
||||
|
||||
oneof payload {
|
||||
StickerMessage sticker = 9;
|
||||
ImageMessage image = 10;
|
||||
AudioMessage audio = 11;
|
||||
bytes community = 12;
|
||||
}
|
||||
|
||||
// Grant for community chat messages
|
||||
bytes grant = 13;
|
||||
|
||||
// Message author's display name, introduced in version 1
|
||||
string display_name = 14;
|
||||
|
||||
enum ContentType {
|
||||
UNKNOWN_CONTENT_TYPE = 0;
|
||||
TEXT_PLAIN = 1;
|
||||
STICKER = 2;
|
||||
STATUS = 3;
|
||||
EMOJI = 4;
|
||||
TRANSACTION_COMMAND = 5;
|
||||
// Only local
|
||||
SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 6;
|
||||
IMAGE = 7;
|
||||
AUDIO = 8;
|
||||
COMMUNITY = 9;
|
||||
// Only local
|
||||
SYSTEM_MESSAGE_GAP = 10;
|
||||
}
|
||||
}
|
|
@ -1,285 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
string,
|
||||
int32,
|
||||
bytes,
|
||||
enumeration,
|
||||
uint64,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface StickerMessage {
|
||||
hash: string
|
||||
pack: number
|
||||
}
|
||||
|
||||
export namespace StickerMessage {
|
||||
export const codec = (): Codec<StickerMessage> => {
|
||||
return message<StickerMessage>({
|
||||
1: { name: 'hash', codec: string },
|
||||
2: { name: 'pack', codec: int32 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: StickerMessage): Uint8Array => {
|
||||
return encodeMessage(obj, StickerMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): StickerMessage => {
|
||||
return decodeMessage(buf, StickerMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface ImageMessage {
|
||||
payload: Uint8Array
|
||||
type: ImageType
|
||||
}
|
||||
|
||||
export namespace ImageMessage {
|
||||
export const codec = (): Codec<ImageMessage> => {
|
||||
return message<ImageMessage>({
|
||||
1: { name: 'payload', codec: bytes },
|
||||
2: { name: 'type', codec: ImageType.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: ImageMessage): Uint8Array => {
|
||||
return encodeMessage(obj, ImageMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): ImageMessage => {
|
||||
return decodeMessage(buf, ImageMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface AudioMessage {
|
||||
payload: Uint8Array
|
||||
type: AudioMessage.AudioType
|
||||
durationMs: bigint
|
||||
}
|
||||
|
||||
export namespace AudioMessage {
|
||||
export enum AudioType {
|
||||
UNKNOWN_AUDIO_TYPE = 'UNKNOWN_AUDIO_TYPE',
|
||||
AAC = 'AAC',
|
||||
AMR = 'AMR',
|
||||
}
|
||||
|
||||
enum __AudioTypeValues {
|
||||
UNKNOWN_AUDIO_TYPE = 0,
|
||||
AAC = 1,
|
||||
AMR = 2,
|
||||
}
|
||||
|
||||
export namespace AudioType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof AudioType>(__AudioTypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<AudioMessage> => {
|
||||
return message<AudioMessage>({
|
||||
1: { name: 'payload', codec: bytes },
|
||||
2: { name: 'type', codec: AudioMessage.AudioType.codec() },
|
||||
3: { name: 'durationMs', codec: uint64 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: AudioMessage): Uint8Array => {
|
||||
return encodeMessage(obj, AudioMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): AudioMessage => {
|
||||
return decodeMessage(buf, AudioMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface EditMessage {
|
||||
clock: bigint
|
||||
text: string
|
||||
chatId: string
|
||||
messageId: string
|
||||
grant: Uint8Array
|
||||
messageType: MessageType
|
||||
}
|
||||
|
||||
export namespace EditMessage {
|
||||
export const codec = (): Codec<EditMessage> => {
|
||||
return message<EditMessage>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'text', codec: string },
|
||||
3: { name: 'chatId', codec: string },
|
||||
4: { name: 'messageId', codec: string },
|
||||
5: { name: 'grant', codec: bytes },
|
||||
6: { name: 'messageType', codec: MessageType.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: EditMessage): Uint8Array => {
|
||||
return encodeMessage(obj, EditMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): EditMessage => {
|
||||
return decodeMessage(buf, EditMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface DeleteMessage {
|
||||
clock: bigint
|
||||
chatId: string
|
||||
messageId: string
|
||||
grant: Uint8Array
|
||||
messageType: MessageType
|
||||
}
|
||||
|
||||
export namespace DeleteMessage {
|
||||
export const codec = (): Codec<DeleteMessage> => {
|
||||
return message<DeleteMessage>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'chatId', codec: string },
|
||||
3: { name: 'messageId', codec: string },
|
||||
4: { name: 'grant', codec: bytes },
|
||||
5: { name: 'messageType', codec: MessageType.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: DeleteMessage): Uint8Array => {
|
||||
return encodeMessage(obj, DeleteMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): DeleteMessage => {
|
||||
return decodeMessage(buf, DeleteMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
clock: bigint
|
||||
timestamp: bigint
|
||||
text: string
|
||||
responseTo: string
|
||||
ensName: string
|
||||
chatId: string
|
||||
messageType: MessageType
|
||||
contentType: ChatMessage.ContentType
|
||||
sticker: StickerMessage
|
||||
image: ImageMessage
|
||||
audio: AudioMessage
|
||||
community: Uint8Array
|
||||
grant: Uint8Array
|
||||
displayName: string
|
||||
}
|
||||
|
||||
export namespace ChatMessage {
|
||||
export enum ContentType {
|
||||
UNKNOWN_CONTENT_TYPE = 'UNKNOWN_CONTENT_TYPE',
|
||||
TEXT_PLAIN = 'TEXT_PLAIN',
|
||||
STICKER = 'STICKER',
|
||||
STATUS = 'STATUS',
|
||||
EMOJI = 'EMOJI',
|
||||
TRANSACTION_COMMAND = 'TRANSACTION_COMMAND',
|
||||
SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 'SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP',
|
||||
IMAGE = 'IMAGE',
|
||||
AUDIO = 'AUDIO',
|
||||
COMMUNITY = 'COMMUNITY',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __ContentTypeValues {
|
||||
UNKNOWN_CONTENT_TYPE = 0,
|
||||
TEXT_PLAIN = 1,
|
||||
STICKER = 2,
|
||||
STATUS = 3,
|
||||
EMOJI = 4,
|
||||
TRANSACTION_COMMAND = 5,
|
||||
SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 6,
|
||||
IMAGE = 7,
|
||||
AUDIO = 8,
|
||||
COMMUNITY = 9,
|
||||
SYSTEM_MESSAGE_GAP = 10,
|
||||
}
|
||||
|
||||
export namespace ContentType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ContentType>(__ContentTypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<ChatMessage> => {
|
||||
return message<ChatMessage>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'timestamp', codec: uint64 },
|
||||
3: { name: 'text', codec: string },
|
||||
4: { name: 'responseTo', codec: string },
|
||||
5: { name: 'ensName', codec: string },
|
||||
6: { name: 'chatId', codec: string },
|
||||
7: { name: 'messageType', codec: MessageType.codec() },
|
||||
8: { name: 'contentType', codec: ChatMessage.ContentType.codec() },
|
||||
9: { name: 'sticker', codec: StickerMessage.codec() },
|
||||
10: { name: 'image', codec: ImageMessage.codec() },
|
||||
11: { name: 'audio', codec: AudioMessage.codec() },
|
||||
12: { name: 'community', codec: bytes },
|
||||
13: { name: 'grant', codec: bytes },
|
||||
14: { name: 'displayName', codec: string },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: ChatMessage): Uint8Array => {
|
||||
return encodeMessage(obj, ChatMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): ChatMessage => {
|
||||
return decodeMessage(buf, ChatMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export enum MessageType {
|
||||
UNKNOWN_MESSAGE_TYPE = 'UNKNOWN_MESSAGE_TYPE',
|
||||
ONE_TO_ONE = 'ONE_TO_ONE',
|
||||
PUBLIC_GROUP = 'PUBLIC_GROUP',
|
||||
PRIVATE_GROUP = 'PRIVATE_GROUP',
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 'SYSTEM_MESSAGE_PRIVATE_GROUP',
|
||||
COMMUNITY_CHAT = 'COMMUNITY_CHAT',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __MessageTypeValues {
|
||||
UNKNOWN_MESSAGE_TYPE = 0,
|
||||
ONE_TO_ONE = 1,
|
||||
PUBLIC_GROUP = 2,
|
||||
PRIVATE_GROUP = 3,
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4,
|
||||
COMMUNITY_CHAT = 5,
|
||||
SYSTEM_MESSAGE_GAP = 6,
|
||||
}
|
||||
|
||||
export namespace MessageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof MessageType>(__MessageTypeValues)
|
||||
}
|
||||
}
|
||||
export enum ImageType {
|
||||
UNKNOWN_IMAGE_TYPE = 'UNKNOWN_IMAGE_TYPE',
|
||||
PNG = 'PNG',
|
||||
JPEG = 'JPEG',
|
||||
WEBP = 'WEBP',
|
||||
GIF = 'GIF',
|
||||
}
|
||||
|
||||
enum __ImageTypeValues {
|
||||
UNKNOWN_IMAGE_TYPE = 0,
|
||||
PNG = 1,
|
||||
JPEG = 2,
|
||||
WEBP = 3,
|
||||
GIF = 4,
|
||||
}
|
||||
|
||||
export namespace ImageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ImageType>(__ImageTypeValues)
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import "chat-identity.proto";
|
||||
|
||||
message Grant {
|
||||
bytes community_id = 1;
|
||||
bytes member_id = 2;
|
||||
string chat_id = 3;
|
||||
uint64 clock = 4;
|
||||
}
|
||||
|
||||
message CommunityMember {
|
||||
enum Roles {
|
||||
UNKNOWN_ROLE = 0;
|
||||
ROLE_ALL = 1;
|
||||
ROLE_MANAGE_USERS = 2;
|
||||
}
|
||||
repeated Roles roles = 1;
|
||||
}
|
||||
|
||||
message CommunityPermissions {
|
||||
enum Access {
|
||||
UNKNOWN_ACCESS = 0;
|
||||
NO_MEMBERSHIP = 1;
|
||||
INVITATION_ONLY = 2;
|
||||
ON_REQUEST = 3;
|
||||
}
|
||||
|
||||
bool ens_only = 1;
|
||||
// https://gitlab.matrix.org/matrix-org/olm/blob/master/docs/megolm.md is a candidate for the algorithm to be used in case we want to have private communityal chats, lighter than pairwise encryption using the DR, less secure, but more efficient for large number of participants
|
||||
bool private = 2;
|
||||
Access access = 3;
|
||||
}
|
||||
|
||||
message CommunityDescription {
|
||||
uint64 clock = 1;
|
||||
map<string,CommunityMember> members = 2;
|
||||
CommunityPermissions permissions = 3;
|
||||
ChatIdentity identity = 5;
|
||||
map<string,CommunityChat> chats = 6;
|
||||
repeated string ban_list = 7;
|
||||
map<string,CommunityCategory> categories = 8;
|
||||
uint64 archive_magnetlink_clock = 9;
|
||||
CommunityAdminSettings admin_settings = 10;
|
||||
}
|
||||
|
||||
message CommunityAdminSettings {
|
||||
bool pin_message_all_members_enabled = 1;
|
||||
}
|
||||
|
||||
message CommunityChat {
|
||||
map<string,CommunityMember> members = 1;
|
||||
CommunityPermissions permissions = 2;
|
||||
ChatIdentity identity = 3;
|
||||
string category_id = 4;
|
||||
int32 position = 5;
|
||||
}
|
||||
|
||||
message CommunityCategory {
|
||||
string category_id = 1;
|
||||
string name = 2;
|
||||
int32 position = 3;
|
||||
}
|
||||
|
||||
message CommunityInvitation {
|
||||
bytes community_description = 1;
|
||||
bytes grant = 2;
|
||||
string chat_id = 3;
|
||||
bytes public_key = 4;
|
||||
}
|
||||
|
||||
message CommunityRequestToJoin {
|
||||
uint64 clock = 1;
|
||||
string ens_name = 2;
|
||||
string chat_id = 3;
|
||||
bytes community_id = 4;
|
||||
}
|
||||
|
||||
message CommunityRequestToJoinResponse {
|
||||
uint64 clock = 1;
|
||||
CommunityDescription community = 2;
|
||||
bool accepted = 3;
|
||||
bytes grant = 4;
|
||||
}
|
||||
|
||||
message CommunityMessageArchiveMagnetlink {
|
||||
uint64 clock = 1;
|
||||
string magnet_uri = 2;
|
||||
}
|
||||
|
||||
message WakuMessage {
|
||||
bytes sig = 1;
|
||||
uint64 timestamp = 2;
|
||||
bytes topic = 3;
|
||||
bytes payload = 4;
|
||||
bytes padding = 5;
|
||||
bytes hash = 6;
|
||||
}
|
||||
|
||||
message WakuMessageArchiveMetadata {
|
||||
uint32 version = 1;
|
||||
uint64 from = 2;
|
||||
uint64 to = 3;
|
||||
repeated bytes contentTopic = 4;
|
||||
}
|
||||
|
||||
message WakuMessageArchive {
|
||||
uint32 version = 1;
|
||||
WakuMessageArchiveMetadata metadata = 2;
|
||||
repeated WakuMessage messages = 3;
|
||||
}
|
||||
|
||||
message WakuMessageArchiveIndexMetadata {
|
||||
uint32 version = 1;
|
||||
WakuMessageArchiveMetadata metadata = 2;
|
||||
uint64 offset = 3;
|
||||
uint64 size = 4;
|
||||
uint64 padding = 5;
|
||||
}
|
||||
|
||||
message WakuMessageArchiveIndex {
|
||||
map<string, WakuMessageArchiveIndexMetadata> archives = 1;
|
||||
}
|
|
@ -1,589 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
bytes,
|
||||
string,
|
||||
uint64,
|
||||
enumeration,
|
||||
bool,
|
||||
int32,
|
||||
uint32,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface Grant {
|
||||
communityId: Uint8Array
|
||||
memberId: Uint8Array
|
||||
chatId: string
|
||||
clock: bigint
|
||||
}
|
||||
|
||||
export namespace Grant {
|
||||
export const codec = (): Codec<Grant> => {
|
||||
return message<Grant>({
|
||||
1: { name: 'communityId', codec: bytes },
|
||||
2: { name: 'memberId', codec: bytes },
|
||||
3: { name: 'chatId', codec: string },
|
||||
4: { name: 'clock', codec: uint64 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: Grant): Uint8Array => {
|
||||
return encodeMessage(obj, Grant.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): Grant => {
|
||||
return decodeMessage(buf, Grant.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityMember {
|
||||
roles: CommunityMember.Roles[]
|
||||
}
|
||||
|
||||
export namespace CommunityMember {
|
||||
export enum Roles {
|
||||
UNKNOWN_ROLE = 'UNKNOWN_ROLE',
|
||||
ROLE_ALL = 'ROLE_ALL',
|
||||
ROLE_MANAGE_USERS = 'ROLE_MANAGE_USERS',
|
||||
}
|
||||
|
||||
enum __RolesValues {
|
||||
UNKNOWN_ROLE = 0,
|
||||
ROLE_ALL = 1,
|
||||
ROLE_MANAGE_USERS = 2,
|
||||
}
|
||||
|
||||
export namespace Roles {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Roles>(__RolesValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<CommunityMember> => {
|
||||
return message<CommunityMember>({
|
||||
1: { name: 'roles', codec: CommunityMember.Roles.codec(), repeats: true },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityMember): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityMember.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityMember => {
|
||||
return decodeMessage(buf, CommunityMember.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityPermissions {
|
||||
ensOnly: boolean
|
||||
private: boolean
|
||||
access: CommunityPermissions.Access
|
||||
}
|
||||
|
||||
export namespace CommunityPermissions {
|
||||
export enum Access {
|
||||
UNKNOWN_ACCESS = 'UNKNOWN_ACCESS',
|
||||
NO_MEMBERSHIP = 'NO_MEMBERSHIP',
|
||||
INVITATION_ONLY = 'INVITATION_ONLY',
|
||||
ON_REQUEST = 'ON_REQUEST',
|
||||
}
|
||||
|
||||
enum __AccessValues {
|
||||
UNKNOWN_ACCESS = 0,
|
||||
NO_MEMBERSHIP = 1,
|
||||
INVITATION_ONLY = 2,
|
||||
ON_REQUEST = 3,
|
||||
}
|
||||
|
||||
export namespace Access {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Access>(__AccessValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<CommunityPermissions> => {
|
||||
return message<CommunityPermissions>({
|
||||
1: { name: 'ensOnly', codec: bool },
|
||||
2: { name: 'private', codec: bool },
|
||||
3: { name: 'access', codec: CommunityPermissions.Access.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityPermissions): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityPermissions.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityPermissions => {
|
||||
return decodeMessage(buf, CommunityPermissions.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityDescription {
|
||||
clock: bigint
|
||||
members: CommunityMember
|
||||
permissions: CommunityPermissions
|
||||
identity: ChatIdentity
|
||||
chats: CommunityChat
|
||||
banList: string[]
|
||||
categories: CommunityCategory
|
||||
archiveMagnetlinkClock: bigint
|
||||
adminSettings: CommunityAdminSettings
|
||||
}
|
||||
|
||||
export namespace CommunityDescription {
|
||||
export const codec = (): Codec<CommunityDescription> => {
|
||||
return message<CommunityDescription>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'members', codec: CommunityMember.codec() },
|
||||
3: { name: 'permissions', codec: CommunityPermissions.codec() },
|
||||
5: { name: 'identity', codec: ChatIdentity.codec() },
|
||||
6: { name: 'chats', codec: CommunityChat.codec() },
|
||||
7: { name: 'banList', codec: string, repeats: true },
|
||||
8: { name: 'categories', codec: CommunityCategory.codec() },
|
||||
9: { name: 'archiveMagnetlinkClock', codec: uint64 },
|
||||
10: { name: 'adminSettings', codec: CommunityAdminSettings.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityDescription): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityDescription.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityDescription => {
|
||||
return decodeMessage(buf, CommunityDescription.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityAdminSettings {
|
||||
pinMessageAllMembersEnabled: boolean
|
||||
}
|
||||
|
||||
export namespace CommunityAdminSettings {
|
||||
export const codec = (): Codec<CommunityAdminSettings> => {
|
||||
return message<CommunityAdminSettings>({
|
||||
1: { name: 'pinMessageAllMembersEnabled', codec: bool },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityAdminSettings): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityAdminSettings.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityAdminSettings => {
|
||||
return decodeMessage(buf, CommunityAdminSettings.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityChat {
|
||||
members: CommunityMember
|
||||
permissions: CommunityPermissions
|
||||
identity: ChatIdentity
|
||||
categoryId: string
|
||||
position: number
|
||||
}
|
||||
|
||||
export namespace CommunityChat {
|
||||
export const codec = (): Codec<CommunityChat> => {
|
||||
return message<CommunityChat>({
|
||||
1: { name: 'members', codec: CommunityMember.codec() },
|
||||
2: { name: 'permissions', codec: CommunityPermissions.codec() },
|
||||
3: { name: 'identity', codec: ChatIdentity.codec() },
|
||||
4: { name: 'categoryId', codec: string },
|
||||
5: { name: 'position', codec: int32 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityChat): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityChat.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityChat => {
|
||||
return decodeMessage(buf, CommunityChat.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityCategory {
|
||||
categoryId: string
|
||||
name: string
|
||||
position: number
|
||||
}
|
||||
|
||||
export namespace CommunityCategory {
|
||||
export const codec = (): Codec<CommunityCategory> => {
|
||||
return message<CommunityCategory>({
|
||||
1: { name: 'categoryId', codec: string },
|
||||
2: { name: 'name', codec: string },
|
||||
3: { name: 'position', codec: int32 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityCategory): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityCategory.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityCategory => {
|
||||
return decodeMessage(buf, CommunityCategory.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityInvitation {
|
||||
communityDescription: Uint8Array
|
||||
grant: Uint8Array
|
||||
chatId: string
|
||||
publicKey: Uint8Array
|
||||
}
|
||||
|
||||
export namespace CommunityInvitation {
|
||||
export const codec = (): Codec<CommunityInvitation> => {
|
||||
return message<CommunityInvitation>({
|
||||
1: { name: 'communityDescription', codec: bytes },
|
||||
2: { name: 'grant', codec: bytes },
|
||||
3: { name: 'chatId', codec: string },
|
||||
4: { name: 'publicKey', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityInvitation): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityInvitation.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityInvitation => {
|
||||
return decodeMessage(buf, CommunityInvitation.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityRequestToJoin {
|
||||
clock: bigint
|
||||
ensName: string
|
||||
chatId: string
|
||||
communityId: Uint8Array
|
||||
}
|
||||
|
||||
export namespace CommunityRequestToJoin {
|
||||
export const codec = (): Codec<CommunityRequestToJoin> => {
|
||||
return message<CommunityRequestToJoin>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'ensName', codec: string },
|
||||
3: { name: 'chatId', codec: string },
|
||||
4: { name: 'communityId', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityRequestToJoin): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityRequestToJoin.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityRequestToJoin => {
|
||||
return decodeMessage(buf, CommunityRequestToJoin.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityRequestToJoinResponse {
|
||||
clock: bigint
|
||||
community: CommunityDescription
|
||||
accepted: boolean
|
||||
grant: Uint8Array
|
||||
}
|
||||
|
||||
export namespace CommunityRequestToJoinResponse {
|
||||
export const codec = (): Codec<CommunityRequestToJoinResponse> => {
|
||||
return message<CommunityRequestToJoinResponse>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'community', codec: CommunityDescription.codec() },
|
||||
3: { name: 'accepted', codec: bool },
|
||||
4: { name: 'grant', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: CommunityRequestToJoinResponse): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityRequestToJoinResponse.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): CommunityRequestToJoinResponse => {
|
||||
return decodeMessage(buf, CommunityRequestToJoinResponse.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityMessageArchiveMagnetlink {
|
||||
clock: bigint
|
||||
magnetUri: string
|
||||
}
|
||||
|
||||
export namespace CommunityMessageArchiveMagnetlink {
|
||||
export const codec = (): Codec<CommunityMessageArchiveMagnetlink> => {
|
||||
return message<CommunityMessageArchiveMagnetlink>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'magnetUri', codec: string },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (
|
||||
obj: CommunityMessageArchiveMagnetlink
|
||||
): Uint8Array => {
|
||||
return encodeMessage(obj, CommunityMessageArchiveMagnetlink.codec())
|
||||
}
|
||||
|
||||
export const decode = (
|
||||
buf: Uint8Array
|
||||
): CommunityMessageArchiveMagnetlink => {
|
||||
return decodeMessage(buf, CommunityMessageArchiveMagnetlink.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
sig: Uint8Array
|
||||
timestamp: bigint
|
||||
topic: Uint8Array
|
||||
payload: Uint8Array
|
||||
padding: Uint8Array
|
||||
hash: Uint8Array
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
export const codec = (): Codec<WakuMessage> => {
|
||||
return message<WakuMessage>({
|
||||
1: { name: 'sig', codec: bytes },
|
||||
2: { name: 'timestamp', codec: uint64 },
|
||||
3: { name: 'topic', codec: bytes },
|
||||
4: { name: 'payload', codec: bytes },
|
||||
5: { name: 'padding', codec: bytes },
|
||||
6: { name: 'hash', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: WakuMessage): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessage => {
|
||||
return decodeMessage(buf, WakuMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface WakuMessageArchiveMetadata {
|
||||
version: number
|
||||
from: bigint
|
||||
to: bigint
|
||||
contentTopic: Uint8Array[]
|
||||
}
|
||||
|
||||
export namespace WakuMessageArchiveMetadata {
|
||||
export const codec = (): Codec<WakuMessageArchiveMetadata> => {
|
||||
return message<WakuMessageArchiveMetadata>({
|
||||
1: { name: 'version', codec: uint32 },
|
||||
2: { name: 'from', codec: uint64 },
|
||||
3: { name: 'to', codec: uint64 },
|
||||
4: { name: 'contentTopic', codec: bytes, repeats: true },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: WakuMessageArchiveMetadata): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessageArchiveMetadata.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessageArchiveMetadata => {
|
||||
return decodeMessage(buf, WakuMessageArchiveMetadata.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface WakuMessageArchive {
|
||||
version: number
|
||||
metadata: WakuMessageArchiveMetadata
|
||||
messages: WakuMessage[]
|
||||
}
|
||||
|
||||
export namespace WakuMessageArchive {
|
||||
export const codec = (): Codec<WakuMessageArchive> => {
|
||||
return message<WakuMessageArchive>({
|
||||
1: { name: 'version', codec: uint32 },
|
||||
2: { name: 'metadata', codec: WakuMessageArchiveMetadata.codec() },
|
||||
3: { name: 'messages', codec: WakuMessage.codec(), repeats: true },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: WakuMessageArchive): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessageArchive.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessageArchive => {
|
||||
return decodeMessage(buf, WakuMessageArchive.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface WakuMessageArchiveIndexMetadata {
|
||||
version: number
|
||||
metadata: WakuMessageArchiveMetadata
|
||||
offset: bigint
|
||||
size: bigint
|
||||
padding: bigint
|
||||
}
|
||||
|
||||
export namespace WakuMessageArchiveIndexMetadata {
|
||||
export const codec = (): Codec<WakuMessageArchiveIndexMetadata> => {
|
||||
return message<WakuMessageArchiveIndexMetadata>({
|
||||
1: { name: 'version', codec: uint32 },
|
||||
2: { name: 'metadata', codec: WakuMessageArchiveMetadata.codec() },
|
||||
3: { name: 'offset', codec: uint64 },
|
||||
4: { name: 'size', codec: uint64 },
|
||||
5: { name: 'padding', codec: uint64 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: WakuMessageArchiveIndexMetadata): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessageArchiveIndexMetadata.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessageArchiveIndexMetadata => {
|
||||
return decodeMessage(buf, WakuMessageArchiveIndexMetadata.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface WakuMessageArchiveIndex {
|
||||
archives: WakuMessageArchiveIndexMetadata
|
||||
}
|
||||
|
||||
export namespace WakuMessageArchiveIndex {
|
||||
export const codec = (): Codec<WakuMessageArchiveIndex> => {
|
||||
return message<WakuMessageArchiveIndex>({
|
||||
1: { name: 'archives', codec: WakuMessageArchiveIndexMetadata.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: WakuMessageArchiveIndex): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessageArchiveIndex.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessageArchiveIndex => {
|
||||
return decodeMessage(buf, WakuMessageArchiveIndex.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface ChatIdentity {
|
||||
clock: bigint
|
||||
ensName: string
|
||||
images: IdentityImage
|
||||
displayName: string
|
||||
description: string
|
||||
color: string
|
||||
emoji: string
|
||||
}
|
||||
|
||||
export namespace ChatIdentity {
|
||||
export const codec = (): Codec<ChatIdentity> => {
|
||||
return message<ChatIdentity>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'ensName', codec: string },
|
||||
3: { name: 'images', codec: IdentityImage.codec() },
|
||||
4: { name: 'displayName', codec: string },
|
||||
5: { name: 'description', codec: string },
|
||||
6: { name: 'color', codec: string },
|
||||
7: { name: 'emoji', codec: string },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: ChatIdentity): Uint8Array => {
|
||||
return encodeMessage(obj, ChatIdentity.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): ChatIdentity => {
|
||||
return decodeMessage(buf, ChatIdentity.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface IdentityImage {
|
||||
payload: Uint8Array
|
||||
sourceType: IdentityImage.SourceType
|
||||
imageType: ImageType
|
||||
encryptionKeys: Uint8Array[]
|
||||
encrypted: boolean
|
||||
}
|
||||
|
||||
export namespace IdentityImage {
|
||||
export enum SourceType {
|
||||
UNKNOWN_SOURCE_TYPE = 'UNKNOWN_SOURCE_TYPE',
|
||||
RAW_PAYLOAD = 'RAW_PAYLOAD',
|
||||
ENS_AVATAR = 'ENS_AVATAR',
|
||||
}
|
||||
|
||||
enum __SourceTypeValues {
|
||||
UNKNOWN_SOURCE_TYPE = 0,
|
||||
RAW_PAYLOAD = 1,
|
||||
ENS_AVATAR = 2,
|
||||
}
|
||||
|
||||
export namespace SourceType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof SourceType>(__SourceTypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<IdentityImage> => {
|
||||
return message<IdentityImage>({
|
||||
1: { name: 'payload', codec: bytes },
|
||||
2: { name: 'sourceType', codec: IdentityImage.SourceType.codec() },
|
||||
3: { name: 'imageType', codec: ImageType.codec() },
|
||||
4: { name: 'encryptionKeys', codec: bytes, repeats: true },
|
||||
5: { name: 'encrypted', codec: bool },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: IdentityImage): Uint8Array => {
|
||||
return encodeMessage(obj, IdentityImage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): IdentityImage => {
|
||||
return decodeMessage(buf, IdentityImage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export enum MessageType {
|
||||
UNKNOWN_MESSAGE_TYPE = 'UNKNOWN_MESSAGE_TYPE',
|
||||
ONE_TO_ONE = 'ONE_TO_ONE',
|
||||
PUBLIC_GROUP = 'PUBLIC_GROUP',
|
||||
PRIVATE_GROUP = 'PRIVATE_GROUP',
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 'SYSTEM_MESSAGE_PRIVATE_GROUP',
|
||||
COMMUNITY_CHAT = 'COMMUNITY_CHAT',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __MessageTypeValues {
|
||||
UNKNOWN_MESSAGE_TYPE = 0,
|
||||
ONE_TO_ONE = 1,
|
||||
PUBLIC_GROUP = 2,
|
||||
PRIVATE_GROUP = 3,
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4,
|
||||
COMMUNITY_CHAT = 5,
|
||||
SYSTEM_MESSAGE_GAP = 6,
|
||||
}
|
||||
|
||||
export namespace MessageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof MessageType>(__MessageTypeValues)
|
||||
}
|
||||
}
|
||||
export enum ImageType {
|
||||
UNKNOWN_IMAGE_TYPE = 'UNKNOWN_IMAGE_TYPE',
|
||||
PNG = 'PNG',
|
||||
JPEG = 'JPEG',
|
||||
WEBP = 'WEBP',
|
||||
GIF = 'GIF',
|
||||
}
|
||||
|
||||
enum __ImageTypeValues {
|
||||
UNKNOWN_IMAGE_TYPE = 0,
|
||||
PNG = 1,
|
||||
JPEG = 2,
|
||||
WEBP = 3,
|
||||
GIF = 4,
|
||||
}
|
||||
|
||||
export namespace ImageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ImageType>(__ImageTypeValues)
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import "enums.proto";
|
||||
|
||||
message EmojiReaction {
|
||||
// clock Lamport timestamp of the chat message
|
||||
uint64 clock = 1;
|
||||
|
||||
// chat_id the ID of the chat the message belongs to, for query efficiency the chat_id is stored in the db even though the
|
||||
// target message also stores the chat_id
|
||||
string chat_id = 2;
|
||||
|
||||
// message_id the ID of the target message that the user wishes to react to
|
||||
string message_id = 3;
|
||||
|
||||
// message_type is (somewhat confusingly) the ID of the type of chat the message belongs to
|
||||
MessageType message_type = 4;
|
||||
|
||||
// type the ID of the emoji the user wishes to react with
|
||||
Type type = 5;
|
||||
|
||||
enum Type {
|
||||
UNKNOWN_EMOJI_REACTION_TYPE = 0;
|
||||
LOVE = 1;
|
||||
THUMBS_UP = 2;
|
||||
THUMBS_DOWN = 3;
|
||||
LAUGH = 4;
|
||||
SAD = 5;
|
||||
ANGRY = 6;
|
||||
}
|
||||
|
||||
// whether this is a rectraction of a previously sent emoji
|
||||
bool retracted = 6;
|
||||
|
||||
// Grant for organisation chat messages
|
||||
bytes grant = 7;
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
enumeration,
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
uint64,
|
||||
string,
|
||||
bool,
|
||||
bytes,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface EmojiReaction {
|
||||
clock: bigint
|
||||
chatId: string
|
||||
messageId: string
|
||||
messageType: MessageType
|
||||
type: EmojiReaction.Type
|
||||
retracted: boolean
|
||||
grant: Uint8Array
|
||||
}
|
||||
|
||||
export namespace EmojiReaction {
|
||||
export enum Type {
|
||||
UNKNOWN_EMOJI_REACTION_TYPE = 'UNKNOWN_EMOJI_REACTION_TYPE',
|
||||
LOVE = 'LOVE',
|
||||
THUMBS_UP = 'THUMBS_UP',
|
||||
THUMBS_DOWN = 'THUMBS_DOWN',
|
||||
LAUGH = 'LAUGH',
|
||||
SAD = 'SAD',
|
||||
ANGRY = 'ANGRY',
|
||||
}
|
||||
|
||||
enum __TypeValues {
|
||||
UNKNOWN_EMOJI_REACTION_TYPE = 0,
|
||||
LOVE = 1,
|
||||
THUMBS_UP = 2,
|
||||
THUMBS_DOWN = 3,
|
||||
LAUGH = 4,
|
||||
SAD = 5,
|
||||
ANGRY = 6,
|
||||
}
|
||||
|
||||
export namespace Type {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Type>(__TypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<EmojiReaction> => {
|
||||
return message<EmojiReaction>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'chatId', codec: string },
|
||||
3: { name: 'messageId', codec: string },
|
||||
4: { name: 'messageType', codec: MessageType.codec() },
|
||||
5: { name: 'type', codec: EmojiReaction.Type.codec() },
|
||||
6: { name: 'retracted', codec: bool },
|
||||
7: { name: 'grant', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: EmojiReaction): Uint8Array => {
|
||||
return encodeMessage(obj, EmojiReaction.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): EmojiReaction => {
|
||||
return decodeMessage(buf, EmojiReaction.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export enum MessageType {
|
||||
UNKNOWN_MESSAGE_TYPE = 'UNKNOWN_MESSAGE_TYPE',
|
||||
ONE_TO_ONE = 'ONE_TO_ONE',
|
||||
PUBLIC_GROUP = 'PUBLIC_GROUP',
|
||||
PRIVATE_GROUP = 'PRIVATE_GROUP',
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 'SYSTEM_MESSAGE_PRIVATE_GROUP',
|
||||
COMMUNITY_CHAT = 'COMMUNITY_CHAT',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __MessageTypeValues {
|
||||
UNKNOWN_MESSAGE_TYPE = 0,
|
||||
ONE_TO_ONE = 1,
|
||||
PUBLIC_GROUP = 2,
|
||||
PRIVATE_GROUP = 3,
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4,
|
||||
COMMUNITY_CHAT = 5,
|
||||
SYSTEM_MESSAGE_GAP = 6,
|
||||
}
|
||||
|
||||
export namespace MessageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof MessageType>(__MessageTypeValues)
|
||||
}
|
||||
}
|
||||
export enum ImageType {
|
||||
UNKNOWN_IMAGE_TYPE = 'UNKNOWN_IMAGE_TYPE',
|
||||
PNG = 'PNG',
|
||||
JPEG = 'JPEG',
|
||||
WEBP = 'WEBP',
|
||||
GIF = 'GIF',
|
||||
}
|
||||
|
||||
enum __ImageTypeValues {
|
||||
UNKNOWN_IMAGE_TYPE = 0,
|
||||
PNG = 1,
|
||||
JPEG = 2,
|
||||
WEBP = 3,
|
||||
GIF = 4,
|
||||
}
|
||||
|
||||
export namespace ImageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ImageType>(__ImageTypeValues)
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
enum MessageType {
|
||||
UNKNOWN_MESSAGE_TYPE = 0;
|
||||
ONE_TO_ONE = 1;
|
||||
PUBLIC_GROUP = 2;
|
||||
PRIVATE_GROUP = 3;
|
||||
// Only local
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4;
|
||||
COMMUNITY_CHAT = 5;
|
||||
// Only local
|
||||
SYSTEM_MESSAGE_GAP = 6;
|
||||
}
|
||||
|
||||
enum ImageType {
|
||||
UNKNOWN_IMAGE_TYPE = 0;
|
||||
|
||||
// Raster image files is payload data that can be read as a raster image
|
||||
PNG = 1;
|
||||
JPEG = 2;
|
||||
WEBP = 3;
|
||||
GIF = 4;
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import { enumeration } from 'protons-runtime'
|
||||
|
||||
export enum MessageType {
|
||||
UNKNOWN_MESSAGE_TYPE = 'UNKNOWN_MESSAGE_TYPE',
|
||||
ONE_TO_ONE = 'ONE_TO_ONE',
|
||||
PUBLIC_GROUP = 'PUBLIC_GROUP',
|
||||
PRIVATE_GROUP = 'PRIVATE_GROUP',
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 'SYSTEM_MESSAGE_PRIVATE_GROUP',
|
||||
COMMUNITY_CHAT = 'COMMUNITY_CHAT',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __MessageTypeValues {
|
||||
UNKNOWN_MESSAGE_TYPE = 0,
|
||||
ONE_TO_ONE = 1,
|
||||
PUBLIC_GROUP = 2,
|
||||
PRIVATE_GROUP = 3,
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4,
|
||||
COMMUNITY_CHAT = 5,
|
||||
SYSTEM_MESSAGE_GAP = 6,
|
||||
}
|
||||
|
||||
export namespace MessageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof MessageType>(__MessageTypeValues)
|
||||
}
|
||||
}
|
||||
export enum ImageType {
|
||||
UNKNOWN_IMAGE_TYPE = 'UNKNOWN_IMAGE_TYPE',
|
||||
PNG = 'PNG',
|
||||
JPEG = 'JPEG',
|
||||
WEBP = 'WEBP',
|
||||
GIF = 'GIF',
|
||||
}
|
||||
|
||||
enum __ImageTypeValues {
|
||||
UNKNOWN_IMAGE_TYPE = 0,
|
||||
PNG = 1,
|
||||
JPEG = 2,
|
||||
WEBP = 3,
|
||||
GIF = 4,
|
||||
}
|
||||
|
||||
export namespace ImageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ImageType>(__ImageTypeValues)
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import "chat-message.proto";
|
||||
import "emoji-reaction.proto";
|
||||
|
||||
message MembershipUpdateEvent {
|
||||
// Lamport timestamp of the event
|
||||
uint64 clock = 1;
|
||||
// List of public keys of objects of the action
|
||||
repeated string members = 2;
|
||||
// Name of the chat for the CHAT_CREATED/NAME_CHANGED event types
|
||||
string name = 3;
|
||||
// The type of the event
|
||||
EventType type = 4;
|
||||
|
||||
enum EventType {
|
||||
UNKNOWN = 0;
|
||||
CHAT_CREATED = 1;
|
||||
NAME_CHANGED = 2;
|
||||
MEMBERS_ADDED = 3;
|
||||
MEMBER_JOINED = 4;
|
||||
MEMBER_REMOVED = 5;
|
||||
ADMINS_ADDED = 6;
|
||||
ADMIN_REMOVED = 7;
|
||||
}
|
||||
}
|
||||
|
||||
// MembershipUpdateMessage is a message used to propagate information
|
||||
// about group membership changes.
|
||||
// For more information, see https://github.com/status-im/specs/blob/master/status-group-chats-spec.md.
|
||||
message MembershipUpdateMessage {
|
||||
// The chat id of the private group chat
|
||||
string chat_id = 1;
|
||||
// A list of events for this group chat, first x bytes are the signature, then is a
|
||||
// protobuf encoded MembershipUpdateEvent
|
||||
repeated bytes events = 2;
|
||||
|
||||
// An optional chat message
|
||||
oneof chat_entity {
|
||||
ChatMessage message = 3;
|
||||
EmojiReaction emoji_reaction = 4;
|
||||
}
|
||||
}
|
|
@ -1,423 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
enumeration,
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
uint64,
|
||||
string,
|
||||
bytes,
|
||||
int32,
|
||||
bool,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface MembershipUpdateEvent {
|
||||
clock: bigint
|
||||
members: string[]
|
||||
name: string
|
||||
type: MembershipUpdateEvent.EventType
|
||||
}
|
||||
|
||||
export namespace MembershipUpdateEvent {
|
||||
export enum EventType {
|
||||
UNKNOWN = 'UNKNOWN',
|
||||
CHAT_CREATED = 'CHAT_CREATED',
|
||||
NAME_CHANGED = 'NAME_CHANGED',
|
||||
MEMBERS_ADDED = 'MEMBERS_ADDED',
|
||||
MEMBER_JOINED = 'MEMBER_JOINED',
|
||||
MEMBER_REMOVED = 'MEMBER_REMOVED',
|
||||
ADMINS_ADDED = 'ADMINS_ADDED',
|
||||
ADMIN_REMOVED = 'ADMIN_REMOVED',
|
||||
}
|
||||
|
||||
enum __EventTypeValues {
|
||||
UNKNOWN = 0,
|
||||
CHAT_CREATED = 1,
|
||||
NAME_CHANGED = 2,
|
||||
MEMBERS_ADDED = 3,
|
||||
MEMBER_JOINED = 4,
|
||||
MEMBER_REMOVED = 5,
|
||||
ADMINS_ADDED = 6,
|
||||
ADMIN_REMOVED = 7,
|
||||
}
|
||||
|
||||
export namespace EventType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof EventType>(__EventTypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<MembershipUpdateEvent> => {
|
||||
return message<MembershipUpdateEvent>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'members', codec: string, repeats: true },
|
||||
3: { name: 'name', codec: string },
|
||||
4: { name: 'type', codec: MembershipUpdateEvent.EventType.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: MembershipUpdateEvent): Uint8Array => {
|
||||
return encodeMessage(obj, MembershipUpdateEvent.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): MembershipUpdateEvent => {
|
||||
return decodeMessage(buf, MembershipUpdateEvent.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface MembershipUpdateMessage {
|
||||
chatId: string
|
||||
events: Uint8Array[]
|
||||
message: ChatMessage
|
||||
emojiReaction: EmojiReaction
|
||||
}
|
||||
|
||||
export namespace MembershipUpdateMessage {
|
||||
export const codec = (): Codec<MembershipUpdateMessage> => {
|
||||
return message<MembershipUpdateMessage>({
|
||||
1: { name: 'chatId', codec: string },
|
||||
2: { name: 'events', codec: bytes, repeats: true },
|
||||
3: { name: 'message', codec: ChatMessage.codec() },
|
||||
4: { name: 'emojiReaction', codec: EmojiReaction.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: MembershipUpdateMessage): Uint8Array => {
|
||||
return encodeMessage(obj, MembershipUpdateMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): MembershipUpdateMessage => {
|
||||
return decodeMessage(buf, MembershipUpdateMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface StickerMessage {
|
||||
hash: string
|
||||
pack: number
|
||||
}
|
||||
|
||||
export namespace StickerMessage {
|
||||
export const codec = (): Codec<StickerMessage> => {
|
||||
return message<StickerMessage>({
|
||||
1: { name: 'hash', codec: string },
|
||||
2: { name: 'pack', codec: int32 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: StickerMessage): Uint8Array => {
|
||||
return encodeMessage(obj, StickerMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): StickerMessage => {
|
||||
return decodeMessage(buf, StickerMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface ImageMessage {
|
||||
payload: Uint8Array
|
||||
type: ImageType
|
||||
}
|
||||
|
||||
export namespace ImageMessage {
|
||||
export const codec = (): Codec<ImageMessage> => {
|
||||
return message<ImageMessage>({
|
||||
1: { name: 'payload', codec: bytes },
|
||||
2: { name: 'type', codec: ImageType.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: ImageMessage): Uint8Array => {
|
||||
return encodeMessage(obj, ImageMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): ImageMessage => {
|
||||
return decodeMessage(buf, ImageMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface AudioMessage {
|
||||
payload: Uint8Array
|
||||
type: AudioMessage.AudioType
|
||||
durationMs: bigint
|
||||
}
|
||||
|
||||
export namespace AudioMessage {
|
||||
export enum AudioType {
|
||||
UNKNOWN_AUDIO_TYPE = 'UNKNOWN_AUDIO_TYPE',
|
||||
AAC = 'AAC',
|
||||
AMR = 'AMR',
|
||||
}
|
||||
|
||||
enum __AudioTypeValues {
|
||||
UNKNOWN_AUDIO_TYPE = 0,
|
||||
AAC = 1,
|
||||
AMR = 2,
|
||||
}
|
||||
|
||||
export namespace AudioType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof AudioType>(__AudioTypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<AudioMessage> => {
|
||||
return message<AudioMessage>({
|
||||
1: { name: 'payload', codec: bytes },
|
||||
2: { name: 'type', codec: AudioMessage.AudioType.codec() },
|
||||
3: { name: 'durationMs', codec: uint64 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: AudioMessage): Uint8Array => {
|
||||
return encodeMessage(obj, AudioMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): AudioMessage => {
|
||||
return decodeMessage(buf, AudioMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface EditMessage {
|
||||
clock: bigint
|
||||
text: string
|
||||
chatId: string
|
||||
messageId: string
|
||||
grant: Uint8Array
|
||||
messageType: MessageType
|
||||
}
|
||||
|
||||
export namespace EditMessage {
|
||||
export const codec = (): Codec<EditMessage> => {
|
||||
return message<EditMessage>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'text', codec: string },
|
||||
3: { name: 'chatId', codec: string },
|
||||
4: { name: 'messageId', codec: string },
|
||||
5: { name: 'grant', codec: bytes },
|
||||
6: { name: 'messageType', codec: MessageType.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: EditMessage): Uint8Array => {
|
||||
return encodeMessage(obj, EditMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): EditMessage => {
|
||||
return decodeMessage(buf, EditMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface DeleteMessage {
|
||||
clock: bigint
|
||||
chatId: string
|
||||
messageId: string
|
||||
grant: Uint8Array
|
||||
messageType: MessageType
|
||||
}
|
||||
|
||||
export namespace DeleteMessage {
|
||||
export const codec = (): Codec<DeleteMessage> => {
|
||||
return message<DeleteMessage>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'chatId', codec: string },
|
||||
3: { name: 'messageId', codec: string },
|
||||
4: { name: 'grant', codec: bytes },
|
||||
5: { name: 'messageType', codec: MessageType.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: DeleteMessage): Uint8Array => {
|
||||
return encodeMessage(obj, DeleteMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): DeleteMessage => {
|
||||
return decodeMessage(buf, DeleteMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
clock: bigint
|
||||
timestamp: bigint
|
||||
text: string
|
||||
responseTo: string
|
||||
ensName: string
|
||||
chatId: string
|
||||
messageType: MessageType
|
||||
contentType: ChatMessage.ContentType
|
||||
sticker: StickerMessage
|
||||
image: ImageMessage
|
||||
audio: AudioMessage
|
||||
community: Uint8Array
|
||||
grant: Uint8Array
|
||||
displayName: string
|
||||
}
|
||||
|
||||
export namespace ChatMessage {
|
||||
export enum ContentType {
|
||||
UNKNOWN_CONTENT_TYPE = 'UNKNOWN_CONTENT_TYPE',
|
||||
TEXT_PLAIN = 'TEXT_PLAIN',
|
||||
STICKER = 'STICKER',
|
||||
STATUS = 'STATUS',
|
||||
EMOJI = 'EMOJI',
|
||||
TRANSACTION_COMMAND = 'TRANSACTION_COMMAND',
|
||||
SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 'SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP',
|
||||
IMAGE = 'IMAGE',
|
||||
AUDIO = 'AUDIO',
|
||||
COMMUNITY = 'COMMUNITY',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __ContentTypeValues {
|
||||
UNKNOWN_CONTENT_TYPE = 0,
|
||||
TEXT_PLAIN = 1,
|
||||
STICKER = 2,
|
||||
STATUS = 3,
|
||||
EMOJI = 4,
|
||||
TRANSACTION_COMMAND = 5,
|
||||
SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 6,
|
||||
IMAGE = 7,
|
||||
AUDIO = 8,
|
||||
COMMUNITY = 9,
|
||||
SYSTEM_MESSAGE_GAP = 10,
|
||||
}
|
||||
|
||||
export namespace ContentType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ContentType>(__ContentTypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<ChatMessage> => {
|
||||
return message<ChatMessage>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'timestamp', codec: uint64 },
|
||||
3: { name: 'text', codec: string },
|
||||
4: { name: 'responseTo', codec: string },
|
||||
5: { name: 'ensName', codec: string },
|
||||
6: { name: 'chatId', codec: string },
|
||||
7: { name: 'messageType', codec: MessageType.codec() },
|
||||
8: { name: 'contentType', codec: ChatMessage.ContentType.codec() },
|
||||
9: { name: 'sticker', codec: StickerMessage.codec() },
|
||||
10: { name: 'image', codec: ImageMessage.codec() },
|
||||
11: { name: 'audio', codec: AudioMessage.codec() },
|
||||
12: { name: 'community', codec: bytes },
|
||||
13: { name: 'grant', codec: bytes },
|
||||
14: { name: 'displayName', codec: string },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: ChatMessage): Uint8Array => {
|
||||
return encodeMessage(obj, ChatMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): ChatMessage => {
|
||||
return decodeMessage(buf, ChatMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export enum MessageType {
|
||||
UNKNOWN_MESSAGE_TYPE = 'UNKNOWN_MESSAGE_TYPE',
|
||||
ONE_TO_ONE = 'ONE_TO_ONE',
|
||||
PUBLIC_GROUP = 'PUBLIC_GROUP',
|
||||
PRIVATE_GROUP = 'PRIVATE_GROUP',
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 'SYSTEM_MESSAGE_PRIVATE_GROUP',
|
||||
COMMUNITY_CHAT = 'COMMUNITY_CHAT',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __MessageTypeValues {
|
||||
UNKNOWN_MESSAGE_TYPE = 0,
|
||||
ONE_TO_ONE = 1,
|
||||
PUBLIC_GROUP = 2,
|
||||
PRIVATE_GROUP = 3,
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4,
|
||||
COMMUNITY_CHAT = 5,
|
||||
SYSTEM_MESSAGE_GAP = 6,
|
||||
}
|
||||
|
||||
export namespace MessageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof MessageType>(__MessageTypeValues)
|
||||
}
|
||||
}
|
||||
export enum ImageType {
|
||||
UNKNOWN_IMAGE_TYPE = 'UNKNOWN_IMAGE_TYPE',
|
||||
PNG = 'PNG',
|
||||
JPEG = 'JPEG',
|
||||
WEBP = 'WEBP',
|
||||
GIF = 'GIF',
|
||||
}
|
||||
|
||||
enum __ImageTypeValues {
|
||||
UNKNOWN_IMAGE_TYPE = 0,
|
||||
PNG = 1,
|
||||
JPEG = 2,
|
||||
WEBP = 3,
|
||||
GIF = 4,
|
||||
}
|
||||
|
||||
export namespace ImageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ImageType>(__ImageTypeValues)
|
||||
}
|
||||
}
|
||||
export interface EmojiReaction {
|
||||
clock: bigint
|
||||
chatId: string
|
||||
messageId: string
|
||||
messageType: MessageType
|
||||
type: EmojiReaction.Type
|
||||
retracted: boolean
|
||||
grant: Uint8Array
|
||||
}
|
||||
|
||||
export namespace EmojiReaction {
|
||||
export enum Type {
|
||||
UNKNOWN_EMOJI_REACTION_TYPE = 'UNKNOWN_EMOJI_REACTION_TYPE',
|
||||
LOVE = 'LOVE',
|
||||
THUMBS_UP = 'THUMBS_UP',
|
||||
THUMBS_DOWN = 'THUMBS_DOWN',
|
||||
LAUGH = 'LAUGH',
|
||||
SAD = 'SAD',
|
||||
ANGRY = 'ANGRY',
|
||||
}
|
||||
|
||||
enum __TypeValues {
|
||||
UNKNOWN_EMOJI_REACTION_TYPE = 0,
|
||||
LOVE = 1,
|
||||
THUMBS_UP = 2,
|
||||
THUMBS_DOWN = 3,
|
||||
LAUGH = 4,
|
||||
SAD = 5,
|
||||
ANGRY = 6,
|
||||
}
|
||||
|
||||
export namespace Type {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Type>(__TypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<EmojiReaction> => {
|
||||
return message<EmojiReaction>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'chatId', codec: string },
|
||||
3: { name: 'messageId', codec: string },
|
||||
4: { name: 'messageType', codec: MessageType.codec() },
|
||||
5: { name: 'type', codec: EmojiReaction.Type.codec() },
|
||||
6: { name: 'retracted', codec: bool },
|
||||
7: { name: 'grant', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: EmojiReaction): Uint8Array => {
|
||||
return encodeMessage(obj, EmojiReaction.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): EmojiReaction => {
|
||||
return decodeMessage(buf, EmojiReaction.codec())
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import "enums.proto";
|
||||
|
||||
message PinMessage {
|
||||
uint64 clock = 1;
|
||||
string message_id = 2;
|
||||
string chat_id = 3;
|
||||
bool pinned = 4;
|
||||
// The type of message (public/one-to-one/private-group-chat)
|
||||
MessageType message_type = 5;
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
uint64,
|
||||
string,
|
||||
bool,
|
||||
enumeration,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface PinMessage {
|
||||
clock: bigint
|
||||
messageId: string
|
||||
chatId: string
|
||||
pinned: boolean
|
||||
messageType: MessageType
|
||||
}
|
||||
|
||||
export namespace PinMessage {
|
||||
export const codec = (): Codec<PinMessage> => {
|
||||
return message<PinMessage>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'messageId', codec: string },
|
||||
3: { name: 'chatId', codec: string },
|
||||
4: { name: 'pinned', codec: bool },
|
||||
5: { name: 'messageType', codec: MessageType.codec() },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: PinMessage): Uint8Array => {
|
||||
return encodeMessage(obj, PinMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): PinMessage => {
|
||||
return decodeMessage(buf, PinMessage.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export enum MessageType {
|
||||
UNKNOWN_MESSAGE_TYPE = 'UNKNOWN_MESSAGE_TYPE',
|
||||
ONE_TO_ONE = 'ONE_TO_ONE',
|
||||
PUBLIC_GROUP = 'PUBLIC_GROUP',
|
||||
PRIVATE_GROUP = 'PRIVATE_GROUP',
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 'SYSTEM_MESSAGE_PRIVATE_GROUP',
|
||||
COMMUNITY_CHAT = 'COMMUNITY_CHAT',
|
||||
SYSTEM_MESSAGE_GAP = 'SYSTEM_MESSAGE_GAP',
|
||||
}
|
||||
|
||||
enum __MessageTypeValues {
|
||||
UNKNOWN_MESSAGE_TYPE = 0,
|
||||
ONE_TO_ONE = 1,
|
||||
PUBLIC_GROUP = 2,
|
||||
PRIVATE_GROUP = 3,
|
||||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4,
|
||||
COMMUNITY_CHAT = 5,
|
||||
SYSTEM_MESSAGE_GAP = 6,
|
||||
}
|
||||
|
||||
export namespace MessageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof MessageType>(__MessageTypeValues)
|
||||
}
|
||||
}
|
||||
export enum ImageType {
|
||||
UNKNOWN_IMAGE_TYPE = 'UNKNOWN_IMAGE_TYPE',
|
||||
PNG = 'PNG',
|
||||
JPEG = 'JPEG',
|
||||
WEBP = 'WEBP',
|
||||
GIF = 'GIF',
|
||||
}
|
||||
|
||||
enum __ImageTypeValues {
|
||||
UNKNOWN_IMAGE_TYPE = 0,
|
||||
PNG = 1,
|
||||
JPEG = 2,
|
||||
WEBP = 3,
|
||||
GIF = 4,
|
||||
}
|
||||
|
||||
export namespace ImageType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof ImageType>(__ImageTypeValues)
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message SignedPreKey {
|
||||
bytes signed_pre_key = 1;
|
||||
uint32 version = 2;
|
||||
uint32 protocol_version = 3;
|
||||
}
|
||||
|
||||
// X3DH prekey bundle
|
||||
message Bundle {
|
||||
// Identity key
|
||||
bytes identity = 1;
|
||||
// Installation id
|
||||
map<string,SignedPreKey> signed_pre_keys = 2;
|
||||
// Prekey signature
|
||||
bytes signature = 4;
|
||||
|
||||
// When the bundle was created locally
|
||||
int64 timestamp = 5;
|
||||
}
|
||||
|
||||
message BundleContainer {
|
||||
reserved 3;
|
||||
// X3DH prekey bundle
|
||||
Bundle bundle = 1;
|
||||
// Private signed prekey
|
||||
bytes private_signed_pre_key = 2;
|
||||
}
|
||||
|
||||
message DRHeader {
|
||||
// Current ratchet public key
|
||||
bytes key = 1;
|
||||
// Number of the message in the sending chain
|
||||
uint32 n = 2;
|
||||
// Length of the previous sending chain
|
||||
uint32 pn = 3;
|
||||
// Bundle ID
|
||||
bytes id = 4;
|
||||
}
|
||||
|
||||
message DHHeader {
|
||||
// Compressed ephemeral public key
|
||||
bytes key = 1;
|
||||
}
|
||||
|
||||
message X3DHHeader {
|
||||
reserved 3;
|
||||
// Ephemeral key used
|
||||
bytes key = 1;
|
||||
// Used bundle's signed prekey
|
||||
bytes id = 4;
|
||||
}
|
||||
|
||||
// Hash Ratchet Header
|
||||
message HRHeader {
|
||||
// community key ID
|
||||
uint32 key_id = 1;
|
||||
// Community message number for this key_id
|
||||
uint32 seq_no = 2;
|
||||
// Community ID
|
||||
string group_id = 3;
|
||||
}
|
||||
|
||||
// Direct message value
|
||||
message EncryptedMessageProtocol {
|
||||
X3DHHeader X3DH_header = 1;
|
||||
DRHeader DR_header = 2;
|
||||
DHHeader DH_header = 101;
|
||||
HRHeader HR_header = 102;
|
||||
// Encrypted payload
|
||||
bytes payload = 3;
|
||||
}
|
||||
|
||||
// Top-level protocol message
|
||||
message ProtocolMessage {
|
||||
// The device id of the sender
|
||||
string installation_id = 2;
|
||||
|
||||
// List of bundles
|
||||
repeated Bundle bundles = 3;
|
||||
|
||||
// One to one message, encrypted, indexed by installation_id
|
||||
// TODO map here is redundant in case of community messages
|
||||
map<string,EncryptedMessageProtocol> encrypted_message = 101;
|
||||
|
||||
// Public chats, not encrypted
|
||||
bytes public_message = 102;
|
||||
}
|
|
@ -1,234 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
bytes,
|
||||
uint32,
|
||||
int64,
|
||||
string,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface SignedPreKey {
|
||||
signedPreKey: Uint8Array
|
||||
version: number
|
||||
protocolVersion: number
|
||||
}
|
||||
|
||||
export namespace SignedPreKey {
|
||||
export const codec = (): Codec<SignedPreKey> => {
|
||||
return message<SignedPreKey>({
|
||||
1: { name: 'signedPreKey', codec: bytes },
|
||||
2: { name: 'version', codec: uint32 },
|
||||
3: { name: 'protocolVersion', codec: uint32 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: SignedPreKey): Uint8Array => {
|
||||
return encodeMessage(obj, SignedPreKey.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): SignedPreKey => {
|
||||
return decodeMessage(buf, SignedPreKey.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface Bundle {
|
||||
identity: Uint8Array
|
||||
signedPreKeys: SignedPreKey
|
||||
signature: Uint8Array
|
||||
timestamp: bigint
|
||||
}
|
||||
|
||||
export namespace Bundle {
|
||||
export const codec = (): Codec<Bundle> => {
|
||||
return message<Bundle>({
|
||||
1: { name: 'identity', codec: bytes },
|
||||
2: { name: 'signedPreKeys', codec: SignedPreKey.codec() },
|
||||
4: { name: 'signature', codec: bytes },
|
||||
5: { name: 'timestamp', codec: int64 },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: Bundle): Uint8Array => {
|
||||
return encodeMessage(obj, Bundle.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): Bundle => {
|
||||
return decodeMessage(buf, Bundle.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface BundleContainer {
|
||||
bundle: Bundle
|
||||
privateSignedPreKey: Uint8Array
|
||||
}
|
||||
|
||||
export namespace BundleContainer {
|
||||
export const codec = (): Codec<BundleContainer> => {
|
||||
return message<BundleContainer>({
|
||||
1: { name: 'bundle', codec: Bundle.codec() },
|
||||
2: { name: 'privateSignedPreKey', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: BundleContainer): Uint8Array => {
|
||||
return encodeMessage(obj, BundleContainer.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): BundleContainer => {
|
||||
return decodeMessage(buf, BundleContainer.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface DRHeader {
|
||||
key: Uint8Array
|
||||
n: number
|
||||
pn: number
|
||||
id: Uint8Array
|
||||
}
|
||||
|
||||
export namespace DRHeader {
|
||||
export const codec = (): Codec<DRHeader> => {
|
||||
return message<DRHeader>({
|
||||
1: { name: 'key', codec: bytes },
|
||||
2: { name: 'n', codec: uint32 },
|
||||
3: { name: 'pn', codec: uint32 },
|
||||
4: { name: 'id', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: DRHeader): Uint8Array => {
|
||||
return encodeMessage(obj, DRHeader.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): DRHeader => {
|
||||
return decodeMessage(buf, DRHeader.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface DHHeader {
|
||||
key: Uint8Array
|
||||
}
|
||||
|
||||
export namespace DHHeader {
|
||||
export const codec = (): Codec<DHHeader> => {
|
||||
return message<DHHeader>({
|
||||
1: { name: 'key', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: DHHeader): Uint8Array => {
|
||||
return encodeMessage(obj, DHHeader.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): DHHeader => {
|
||||
return decodeMessage(buf, DHHeader.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface X3DHHeader {
|
||||
key: Uint8Array
|
||||
id: Uint8Array
|
||||
}
|
||||
|
||||
export namespace X3DHHeader {
|
||||
export const codec = (): Codec<X3DHHeader> => {
|
||||
return message<X3DHHeader>({
|
||||
1: { name: 'key', codec: bytes },
|
||||
4: { name: 'id', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: X3DHHeader): Uint8Array => {
|
||||
return encodeMessage(obj, X3DHHeader.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): X3DHHeader => {
|
||||
return decodeMessage(buf, X3DHHeader.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface HRHeader {
|
||||
keyId: number
|
||||
seqNo: number
|
||||
groupId: string
|
||||
}
|
||||
|
||||
export namespace HRHeader {
|
||||
export const codec = (): Codec<HRHeader> => {
|
||||
return message<HRHeader>({
|
||||
1: { name: 'keyId', codec: uint32 },
|
||||
2: { name: 'seqNo', codec: uint32 },
|
||||
3: { name: 'groupId', codec: string },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: HRHeader): Uint8Array => {
|
||||
return encodeMessage(obj, HRHeader.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): HRHeader => {
|
||||
return decodeMessage(buf, HRHeader.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface EncryptedMessageProtocol {
|
||||
X3DHHeader: X3DHHeader
|
||||
DRHeader: DRHeader
|
||||
DHHeader: DHHeader
|
||||
HRHeader: HRHeader
|
||||
payload: Uint8Array
|
||||
}
|
||||
|
||||
export namespace EncryptedMessageProtocol {
|
||||
export const codec = (): Codec<EncryptedMessageProtocol> => {
|
||||
return message<EncryptedMessageProtocol>({
|
||||
1: { name: 'X3DHHeader', codec: X3DHHeader.codec() },
|
||||
2: { name: 'DRHeader', codec: DRHeader.codec() },
|
||||
101: { name: 'DHHeader', codec: DHHeader.codec() },
|
||||
102: { name: 'HRHeader', codec: HRHeader.codec() },
|
||||
3: { name: 'payload', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: EncryptedMessageProtocol): Uint8Array => {
|
||||
return encodeMessage(obj, EncryptedMessageProtocol.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): EncryptedMessageProtocol => {
|
||||
return decodeMessage(buf, EncryptedMessageProtocol.codec())
|
||||
}
|
||||
}
|
||||
|
||||
export interface ProtocolMessage {
|
||||
installationId: string
|
||||
bundles: Bundle[]
|
||||
encryptedMessage: EncryptedMessageProtocol
|
||||
publicMessage: Uint8Array
|
||||
}
|
||||
|
||||
export namespace ProtocolMessage {
|
||||
export const codec = (): Codec<ProtocolMessage> => {
|
||||
return message<ProtocolMessage>({
|
||||
2: { name: 'installationId', codec: string },
|
||||
3: { name: 'bundles', codec: Bundle.codec(), repeats: true },
|
||||
101: {
|
||||
name: 'encryptedMessage',
|
||||
codec: EncryptedMessageProtocol.codec(),
|
||||
},
|
||||
102: { name: 'publicMessage', codec: bytes },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: ProtocolMessage): Uint8Array => {
|
||||
return encodeMessage(obj, ProtocolMessage.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): ProtocolMessage => {
|
||||
return decodeMessage(buf, ProtocolMessage.codec())
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
/* Specs:
|
||||
:AUTOMATIC
|
||||
To Send - "AUTOMATIC" status ping every 5 minutes
|
||||
Display - Online for up to 5 minutes from the last clock, after that Offline
|
||||
:ALWAYS_ONLINE
|
||||
To Send - "ALWAYS_ONLINE" status ping every 5 minutes
|
||||
Display - Online for up to 2 weeks from the last clock, after that Offline
|
||||
:INACTIVE
|
||||
To Send - A single "INACTIVE" status ping
|
||||
Display - Offline forever
|
||||
Note: Only send pings if the user interacted with the app in the last x minutes. */
|
||||
message StatusUpdate {
|
||||
|
||||
uint64 clock = 1;
|
||||
|
||||
StatusType status_type = 2;
|
||||
|
||||
string custom_text = 3;
|
||||
|
||||
enum StatusType {
|
||||
UNKNOWN_STATUS_TYPE = 0;
|
||||
AUTOMATIC = 1;
|
||||
DO_NOT_DISTURB = 2;
|
||||
ALWAYS_ONLINE = 3;
|
||||
INACTIVE = 4;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
enumeration,
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
uint64,
|
||||
string,
|
||||
} from 'protons-runtime'
|
||||
import type { Codec } from 'protons-runtime'
|
||||
|
||||
export interface StatusUpdate {
|
||||
clock: bigint
|
||||
statusType: StatusUpdate.StatusType
|
||||
customText: string
|
||||
}
|
||||
|
||||
export namespace StatusUpdate {
|
||||
export enum StatusType {
|
||||
UNKNOWN_STATUS_TYPE = 'UNKNOWN_STATUS_TYPE',
|
||||
AUTOMATIC = 'AUTOMATIC',
|
||||
DO_NOT_DISTURB = 'DO_NOT_DISTURB',
|
||||
ALWAYS_ONLINE = 'ALWAYS_ONLINE',
|
||||
INACTIVE = 'INACTIVE',
|
||||
}
|
||||
|
||||
enum __StatusTypeValues {
|
||||
UNKNOWN_STATUS_TYPE = 0,
|
||||
AUTOMATIC = 1,
|
||||
DO_NOT_DISTURB = 2,
|
||||
ALWAYS_ONLINE = 3,
|
||||
INACTIVE = 4,
|
||||
}
|
||||
|
||||
export namespace StatusType {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof StatusType>(__StatusTypeValues)
|
||||
}
|
||||
}
|
||||
|
||||
export const codec = (): Codec<StatusUpdate> => {
|
||||
return message<StatusUpdate>({
|
||||
1: { name: 'clock', codec: uint64 },
|
||||
2: { name: 'statusType', codec: StatusUpdate.StatusType.codec() },
|
||||
3: { name: 'customText', codec: string },
|
||||
})
|
||||
}
|
||||
|
||||
export const encode = (obj: StatusUpdate): Uint8Array => {
|
||||
return encodeMessage(obj, StatusUpdate.codec())
|
||||
}
|
||||
|
||||
export const decode = (buf: Uint8Array): StatusUpdate => {
|
||||
return decodeMessage(buf, StatusUpdate.codec())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue