diff --git a/packages/status-js/buf.gen.yaml b/packages/status-js/buf.gen.yaml index 40edf963..f1095e97 100644 --- a/packages/status-js/buf.gen.yaml +++ b/packages/status-js/buf.gen.yaml @@ -1,6 +1,6 @@ -version: v1beta1 - +version: v1 plugins: - - name: ts_proto - out: ./src/proto - opt: grpc_js,esModuleInterop=true + - name: es + path: ./node_modules/.bin/protoc-gen-es + opt: target=ts + out: ./src/protos diff --git a/packages/status-js/package.json b/packages/status-js/package.json index 948f8a6e..a1679d4a 100644 --- a/packages/status-js/package.json +++ b/packages/status-js/package.json @@ -27,18 +27,19 @@ "typegen": "tsc --noEmit false --emitDeclarationOnly || true", "lint": "eslint src", "format": "prettier --write src", - "protos": "protons protos/*.proto", + "protos:list": "buf ls-files src/protos", + "protos:lint": "buf lint src/protos", + "protos": "buf generate src/protos", "clean": "rm -rf dist node_modules .turbo" }, "dependencies": { + "@bufbuild/protobuf": "^1.0.0", "ethereum-cryptography": "^1.0.3", "js-waku": "^0.30.0", - "long": "^5.2.0", - "protobufjs": "^6.11.3", - "protons-runtime": "^1.0.4" + "long": "^5.2.0" }, "devDependencies": { - "protons": "^3.0.4" + "@bufbuild/protoc-gen-es": "^1.0.0" }, "files": [ "dist/", diff --git a/packages/status-js/proto/status/v1/communities.proto b/packages/status-js/proto/status/v1/communities.proto deleted file mode 100644 index 48badc95..00000000 --- a/packages/status-js/proto/status/v1/communities.proto +++ /dev/null @@ -1,80 +0,0 @@ -syntax = "proto3"; - -package communities.v1; - -import "communities/v1/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 members = 2; - CommunityPermissions permissions = 3; - ChatIdentity identity = 5; - map chats = 6; - repeated string ban_list = 7; - map categories = 8; -} - -message CommunityChat { - map 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; -} diff --git a/packages/status-js/proto/status/v1/protocol_message.proto b/packages/status-js/proto/status/v1/protocol_message.proto deleted file mode 100644 index 8e4be557..00000000 --- a/packages/status-js/proto/status/v1/protocol_message.proto +++ /dev/null @@ -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 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 encrypted_message = 101; - - // Public chats, not encrypted - bytes public_message = 102; -} diff --git a/packages/status-js/src/client/chat.ts b/packages/status-js/src/client/chat.ts index 324b85d1..9e78d02a 100644 --- a/packages/status-js/src/client/chat.ts +++ b/packages/status-js/src/client/chat.ts @@ -2,28 +2,33 @@ import { PageDirection } from 'js-waku' import { SymDecoder } from 'js-waku/lib/waku_message/version_1' import { containsOnlyEmoji } from '../helpers/contains-only-emoji' +import { ApplicationMetadataMessage_Type } from '../protos/application-metadata-message_pb' import { - AudioMessage, ChatMessage as ChatMessageProto, + ChatMessage_ContentType, DeleteMessage, EditMessage, - ImageType, -} from '../protos/chat-message' -import { EmojiReaction } from '../protos/emoji-reaction' +} from '../protos/chat-message_pb' +import { EmojiReaction, EmojiReaction_Type } from '../protos/emoji-reaction_pb' +import { MessageType } from '../protos/enums_pb' import { generateKeyFromPassword } from '../utils/generate-key-from-password' import { getNextClock } from '../utils/get-next-clock' import { idToContentTopic } from '../utils/id-to-content-topic' import { getReactions } from './community/get-reactions' -import type { CommunityChat } from '../proto/communities/v1/communities' -import type { ImageMessage } from '../protos/chat-message' -import type { MessageType } from '../protos/enums' +import type { ImageMessage } from '../protos/chat-message_pb' +import type { CommunityChat as CommunityChatProto } from '../protos/communities_pb' import type { Client } from './client' import type { Community } from './community/community' import type { Reactions } from './community/get-reactions' import type { Member } from './member' +import type { PlainMessage } from '@bufbuild/protobuf' -export type ChatMessage = ChatMessageProto & { +export { ChatMessage_ContentType as ChatMessageContentType } from '../protos/chat-message_pb' + +export type CommunityChat = PlainMessage + +export type ChatMessage = PlainMessage & { messageId: string pinned: boolean reactions: Reactions @@ -453,11 +458,11 @@ export class Chat { } const type = containsOnlyEmoji(text) - ? ChatMessageProto.ContentType.EMOJI - : ChatMessageProto.ContentType.TEXT_PLAIN + ? ChatMessage_ContentType.EMOJI + : ChatMessage_ContentType.TEXT_PLAIN // TODO: protos does not support optional fields :-( - const payload = ChatMessageProto.encode({ + const payload = new ChatMessageProto({ clock: this.setClock(this.#clock), timestamp: BigInt(Date.now()), text, @@ -465,24 +470,13 @@ export class Chat { ensName: '', chatId: this.id, contentType: type, - messageType: 'COMMUNITY_CHAT' as MessageType, - sticker: { hash: '', pack: 0 }, - image: { - type: ImageType.JPEG, - payload: new Uint8Array([]), - }, - audio: { - type: AudioMessage.AudioType.AAC, - payload: new Uint8Array([]), - durationMs: BigInt(0), - }, - community: new Uint8Array([]), + messageType: MessageType.COMMUNITY_CHAT, grant: new Uint8Array([]), displayName: '', - }) + }).toBinary() await this.client.sendWakuMessage( - 'TYPE_CHAT_MESSAGE', + ApplicationMetadataMessage_Type.CHAT_MESSAGE, payload, this.contentTopic, this.symmetricKey @@ -490,32 +484,28 @@ export class Chat { } public sendImageMessage = async (image: ImageMessage) => { - const payload = ChatMessageProto.encode({ + const payload = new ChatMessageProto({ clock: this.setClock(this.#clock), timestamp: BigInt(Date.now()), text: '', responseTo: '', ensName: '', chatId: this.id, - messageType: 'COMMUNITY_CHAT' as MessageType, - contentType: ChatMessageProto.ContentType.TEXT_PLAIN, - sticker: { hash: '', pack: 0 }, - image: { - type: image.type, - payload: image.payload, + messageType: MessageType.COMMUNITY_CHAT, + contentType: ChatMessage_ContentType.IMAGE, + payload: { + case: 'image', + value: { + type: image.type, + payload: image.payload, + }, }, - audio: { - type: AudioMessage.AudioType.AAC, - payload: new Uint8Array([]), - durationMs: BigInt(0), - }, - community: new Uint8Array([]), grant: new Uint8Array([]), displayName: '', - }) + }).toBinary() await this.client.sendWakuMessage( - 'TYPE_CHAT_MESSAGE', + ApplicationMetadataMessage_Type.CHAT_MESSAGE, payload, this.contentTopic, this.symmetricKey @@ -541,17 +531,17 @@ export class Chat { throw new Error('Text message cannot be empty') } - const payload = EditMessage.encode({ + const payload = new EditMessage({ clock: this.setClock(this.#clock), text, messageId, chatId: this.id, grant: new Uint8Array([]), - messageType: 'COMMUNITY_CHAT' as MessageType, - }) + messageType: MessageType.COMMUNITY_CHAT, + }).toBinary() await this.client.sendWakuMessage( - 'TYPE_EDIT_MESSAGE', + ApplicationMetadataMessage_Type.EDIT_MESSAGE, payload, this.contentTopic, this.symmetricKey @@ -575,16 +565,16 @@ export class Chat { throw new Error('Text message can only be deleted by its author') } - const payload = DeleteMessage.encode({ + const payload = new DeleteMessage({ clock: this.setClock(this.#clock), messageId, chatId: this.id, grant: new Uint8Array([]), - messageType: 'COMMUNITY_CHAT' as MessageType, - }) + messageType: MessageType.COMMUNITY_CHAT, + }).toBinary() await this.client.sendWakuMessage( - 'TYPE_DELETE_MESSAGE', + ApplicationMetadataMessage_Type.DELETE_MESSAGE, payload, this.contentTopic, this.symmetricKey @@ -609,18 +599,18 @@ export class Chat { `0x${this.client.account.publicKey}` ) - const payload = EmojiReaction.encode({ + const payload = new EmojiReaction({ clock: this.setClock(this.#clock), chatId: this.id, - messageType: 'COMMUNITY_CHAT' as MessageType, + messageType: MessageType.COMMUNITY_CHAT, messageId, - type: reaction as EmojiReaction.Type, + type: EmojiReaction_Type[reaction], retracted, grant: new Uint8Array([]), - }) + }).toBinary() await this.client.sendWakuMessage( - 'TYPE_EMOJI_REACTION', + ApplicationMetadataMessage_Type.EMOJI_REACTION, payload, this.contentTopic, this.symmetricKey diff --git a/packages/status-js/src/client/client.ts b/packages/status-js/src/client/client.ts index bdb8afa2..394af6d5 100644 --- a/packages/status-js/src/client/client.ts +++ b/packages/status-js/src/client/client.ts @@ -10,13 +10,14 @@ import { waitForRemotePeer } from 'js-waku/lib/wait_for_remote_peer' import { SymEncoder } from 'js-waku/lib/waku_message/version_1' import { peers } from '../consts/peers' -import { ApplicationMetadataMessage } from '../protos/application-metadata-message' +import { ApplicationMetadataMessage } from '../protos/application-metadata-message_pb' import { Account } from './account' import { ActivityCenter } from './activityCenter' import { Community } from './community/community' import { handleWakuMessage } from './community/handle-waku-message' import { LocalStorage } from './storage' +import type { ApplicationMetadataMessage_Type } from '../protos/application-metadata-message_pb' import type { Storage } from './storage' import type { WakuLight } from 'js-waku/lib/interfaces' import type { MessageV1 as WakuMessage } from 'js-waku/lib/waku_message/version_1' @@ -238,7 +239,7 @@ class Client { } public sendWakuMessage = async ( - type: keyof typeof ApplicationMetadataMessage.Type, + type: ApplicationMetadataMessage_Type, payload: Uint8Array, contentTopic: string, symKey: Uint8Array @@ -253,11 +254,11 @@ class Client { const signature = await this.#account.sign(payload) - const message = ApplicationMetadataMessage.encode({ - type: type as ApplicationMetadataMessage.Type, + const message = new ApplicationMetadataMessage({ + type: type, signature, payload, - }) + }).toBinary() await this.waku.lightPush.push( new SymEncoder( diff --git a/packages/status-js/src/client/community/community.ts b/packages/status-js/src/client/community/community.ts index 38abd52a..cb31c41d 100644 --- a/packages/status-js/src/client/community/community.ts +++ b/packages/status-js/src/client/community/community.ts @@ -3,8 +3,9 @@ import { SymDecoder } from 'js-waku/lib/waku_message/version_1' import { getDifferenceByKeys } from '../../helpers/get-difference-by-keys' import { getObjectsDifference } from '../../helpers/get-objects-difference' -import { CommunityRequestToJoin } from '../../protos/communities' -import { MessageType } from '../../protos/enums' +import { ApplicationMetadataMessage_Type } from '../../protos/application-metadata-message_pb' +import { CommunityRequestToJoin } from '../../protos/communities_pb' +import { MessageType } from '../../protos/enums_pb' import { compressPublicKey } from '../../utils/compress-public-key' import { generateKeyFromPassword } from '../../utils/generate-key-from-password' import { getNextClock } from '../../utils/get-next-clock' @@ -12,11 +13,12 @@ import { idToContentTopic } from '../../utils/id-to-content-topic' import { Chat } from '../chat' import { Member } from '../member' -import type { - CommunityChat, - CommunityDescription, -} from '../../proto/communities/v1/communities' +import type { CommunityDescription as CommunityDescriptionProto } from '../../protos/communities_pb' +import type { CommunityChat } from '../chat' import type { Client } from '../client' +import type { PlainMessage } from '@bufbuild/protobuf' + +type CommunityDescription = PlainMessage export class Community { private client: Client @@ -239,15 +241,15 @@ export class Community { } public requestToJoin = async (chatId = '') => { - const payload = CommunityRequestToJoin.encode({ + const payload = new CommunityRequestToJoin({ clock: this.setClock(this.#clock), chatId, communityId: hexToBytes(this.id), ensName: '', - }) + }).toBinary() await this.client.sendWakuMessage( - 'TYPE_COMMUNITY_REQUEST_TO_JOIN', + ApplicationMetadataMessage_Type.COMMUNITY_REQUEST_TO_JOIN, payload, this.contentTopic, this.symmetricKey diff --git a/packages/status-js/src/client/community/get-reactions.ts b/packages/status-js/src/client/community/get-reactions.ts index e6b689fa..adcfeff4 100644 --- a/packages/status-js/src/client/community/get-reactions.ts +++ b/packages/status-js/src/client/community/get-reactions.ts @@ -1,6 +1,11 @@ -import type { EmojiReaction } from '../../protos/emoji-reaction' +import { EmojiReaction_Type } from '../../protos/emoji-reaction_pb' -type Reaction = Exclude<`${EmojiReaction.Type}`, 'UNKNOWN_EMOJI_REACTION_TYPE'> +import type { EmojiReaction } from '../../protos/emoji-reaction_pb' + +export type Reaction = Exclude< + keyof typeof EmojiReaction_Type, + 'UNKNOWN_EMOJI_REACTION_TYPE' +> export type Reactions = { [key in Reaction]: Set @@ -13,15 +18,17 @@ export function getReactions( ): Reactions { const { type, retracted } = reaction - if (type === 'UNKNOWN_EMOJI_REACTION_TYPE') { + if (type === EmojiReaction_Type.UNKNOWN_EMOJI_REACTION_TYPE) { return reactions } + const reactionName = EmojiReaction_Type[type] as Reaction + if (retracted) { - reactions[type].delete(publicKey) + reactions[reactionName].delete(publicKey) } else { // Set handles that potentially multiple same reactions count as one - reactions[type].add(publicKey) + reactions[reactionName].add(publicKey) } return reactions diff --git a/packages/status-js/src/client/community/handle-waku-message.ts b/packages/status-js/src/client/community/handle-waku-message.ts index 6be1cd89..912ef399 100644 --- a/packages/status-js/src/client/community/handle-waku-message.ts +++ b/packages/status-js/src/client/community/handle-waku-message.ts @@ -1,16 +1,19 @@ import { bytesToHex } from 'ethereum-cryptography/utils' -import { CommunityDescription } from '../../proto/communities/v1/communities' -import { ApplicationMetadataMessage } from '../../protos/application-metadata-message' +import { + ApplicationMetadataMessage, + ApplicationMetadataMessage_Type, +} from '../../protos/application-metadata-message_pb' import { ChatMessage, DeleteMessage, EditMessage, - MessageType, -} from '../../protos/chat-message' -import { EmojiReaction } from '../../protos/emoji-reaction' -import { PinMessage } from '../../protos/pin-message' -import { ProtocolMessage } from '../../protos/protocol-message' +} from '../../protos/chat-message_pb' +import { CommunityDescription } from '../../protos/communities_pb' +import { EmojiReaction } from '../../protos/emoji-reaction_pb' +import { MessageType } from '../../protos/enums_pb' +import { PinMessage } from '../../protos/pin-message_pb' +import { ProtocolMessage } from '../../protos/protocol-message_pb' import { isClockValid } from '../../utils/is-clock-valid' import { payloadToId } from '../../utils/payload-to-id' import { recoverPublicKey } from '../../utils/recover-public-key' @@ -46,7 +49,7 @@ export function handleWakuMessage( let messageToDecode = wakuMessage.payload let decodedProtocol try { - decodedProtocol = ProtocolMessage.decode(messageToDecode) + decodedProtocol = ProtocolMessage.fromBinary(messageToDecode) if (decodedProtocol) { messageToDecode = decodedProtocol.publicMessage } @@ -54,7 +57,7 @@ export function handleWakuMessage( // eslint-disable-next-line no-empty } - const decodedMetadata = ApplicationMetadataMessage.decode(messageToDecode) + const decodedMetadata = ApplicationMetadataMessage.fromBinary(messageToDecode) if (!decodedMetadata.payload) { return } @@ -82,9 +85,9 @@ export function handleWakuMessage( try { // decode, map and handle (events) switch (decodedMetadata.type) { - case ApplicationMetadataMessage.Type.TYPE_COMMUNITY_DESCRIPTION: { + case ApplicationMetadataMessage_Type.COMMUNITY_DESCRIPTION: { // decode - const decodedPayload = CommunityDescription.decode(messageToDecode) + const decodedPayload = CommunityDescription.fromBinary(messageToDecode) // validate if (!isClockValid(BigInt(decodedPayload.clock), messageTimestamp)) { @@ -104,9 +107,9 @@ export function handleWakuMessage( break } - case ApplicationMetadataMessage.Type.TYPE_CHAT_MESSAGE: { + case ApplicationMetadataMessage_Type.CHAT_MESSAGE: { // decode - const decodedPayload = ChatMessage.decode(messageToDecode) + const decodedPayload = ChatMessage.fromBinary(messageToDecode) if (!isClockValid(BigInt(decodedPayload.clock), messageTimestamp)) { return @@ -149,8 +152,8 @@ export function handleWakuMessage( break } - case ApplicationMetadataMessage.Type.TYPE_EDIT_MESSAGE: { - const decodedPayload = EditMessage.decode(messageToDecode) + case ApplicationMetadataMessage_Type.EDIT_MESSAGE: { + const decodedPayload = EditMessage.fromBinary(messageToDecode) if (!isClockValid(BigInt(decodedPayload.clock), messageTimestamp)) { return @@ -189,8 +192,8 @@ export function handleWakuMessage( break } - case ApplicationMetadataMessage.Type.TYPE_DELETE_MESSAGE: { - const decodedPayload = DeleteMessage.decode(messageToDecode) + case ApplicationMetadataMessage_Type.DELETE_MESSAGE: { + const decodedPayload = DeleteMessage.fromBinary(messageToDecode) if (!isClockValid(BigInt(decodedPayload.clock), messageTimestamp)) { return @@ -228,8 +231,8 @@ export function handleWakuMessage( break } - case ApplicationMetadataMessage.Type.TYPE_PIN_MESSAGE: { - const decodedPayload = PinMessage.decode(messageToDecode) + case ApplicationMetadataMessage_Type.PIN_MESSAGE: { + const decodedPayload = PinMessage.fromBinary(messageToDecode) if (!isClockValid(BigInt(decodedPayload.clock), messageTimestamp)) { return @@ -267,8 +270,8 @@ export function handleWakuMessage( break } - case ApplicationMetadataMessage.Type.TYPE_EMOJI_REACTION: { - const decodedPayload = EmojiReaction.decode(messageToDecode) + case ApplicationMetadataMessage_Type.EMOJI_REACTION: { + const decodedPayload = EmojiReaction.fromBinary(messageToDecode) if (!isClockValid(BigInt(decodedPayload.clock), messageTimestamp)) { return diff --git a/packages/status-js/src/client/community/map-chat-message.ts b/packages/status-js/src/client/community/map-chat-message.ts index d0139cac..312fda0a 100644 --- a/packages/status-js/src/client/community/map-chat-message.ts +++ b/packages/status-js/src/client/community/map-chat-message.ts @@ -1,4 +1,4 @@ -import type { ChatMessage as ChatMessageProto } from '../../protos/chat-message' +import type { ChatMessage as ChatMessageProto } from '../../protos/chat-message_pb' import type { Chat, ChatMessage } from '../chat' import type { Community } from './community' diff --git a/packages/status-js/src/index.ts b/packages/status-js/src/index.ts index 410740b5..0d9d15e8 100644 --- a/packages/status-js/src/index.ts +++ b/packages/status-js/src/index.ts @@ -5,8 +5,9 @@ export type { Notification, } from './client/activityCenter' export type { ChatMessage as Message } from './client/chat' +export { ChatMessageContentType as MessageContentType } from './client/chat' export type { Client, ClientOptions } from './client/client' export { createClient } from './client/client' export type { Community } from './client/community/community' -export type { Reactions } from './client/community/get-reactions' +export type { Reaction, Reactions } from './client/community/get-reactions' export type { Member } from './client/member' diff --git a/packages/status-js/src/proto/communities/v1/chat_identity.ts b/packages/status-js/src/proto/communities/v1/chat_identity.ts deleted file mode 100644 index 4aa2ed0a..00000000 --- a/packages/status-js/src/proto/communities/v1/chat_identity.ts +++ /dev/null @@ -1,526 +0,0 @@ -/* eslint-disable */ -import Long from 'long' -import _m0 from 'protobufjs/minimal' -import { ImageType, imageTypeFromJSON, imageTypeToJSON } from './enums' - -export const protobufPackage = 'communities.v1' - -/** ChatIdentity represents the user defined identity associated with their public chat key */ -export interface ChatIdentity { - /** Lamport timestamp of the message */ - clock: number - /** ens_name is the valid ENS name associated with the chat key */ - ensName: string - /** images is a string indexed mapping of images associated with an identity */ - images: { [key: string]: IdentityImage } - /** display name is the user set identity, valid only for organisations */ - displayName: string - /** description is the user set description, valid only for organisations */ - description: string - color: string - emoji: string -} - -export interface ChatIdentity_ImagesEntry { - key: string - value: IdentityImage | undefined -} - -/** ProfileImage represents data associated with a user's profile image */ -export interface IdentityImage { - /** - * payload is a context based payload for the profile image data, - * context is determined by the `source_type` - */ - payload: Uint8Array - /** source_type signals the image payload source */ - sourceType: IdentityImage_SourceType - /** image_type signals the image type and method of parsing the payload */ - imageType: ImageType -} - -/** SourceType are the predefined types of image source allowed */ -export enum IdentityImage_SourceType { - UNKNOWN_SOURCE_TYPE = 0, - /** RAW_PAYLOAD - RAW_PAYLOAD image byte data */ - RAW_PAYLOAD = 1, - /** - * ENS_AVATAR - 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, - UNRECOGNIZED = -1, -} - -export function identityImage_SourceTypeFromJSON( - object: any -): IdentityImage_SourceType { - switch (object) { - case 0: - case 'UNKNOWN_SOURCE_TYPE': - return IdentityImage_SourceType.UNKNOWN_SOURCE_TYPE - case 1: - case 'RAW_PAYLOAD': - return IdentityImage_SourceType.RAW_PAYLOAD - case 2: - case 'ENS_AVATAR': - return IdentityImage_SourceType.ENS_AVATAR - case -1: - case 'UNRECOGNIZED': - default: - return IdentityImage_SourceType.UNRECOGNIZED - } -} - -export function identityImage_SourceTypeToJSON( - object: IdentityImage_SourceType -): string { - switch (object) { - case IdentityImage_SourceType.UNKNOWN_SOURCE_TYPE: - return 'UNKNOWN_SOURCE_TYPE' - case IdentityImage_SourceType.RAW_PAYLOAD: - return 'RAW_PAYLOAD' - case IdentityImage_SourceType.ENS_AVATAR: - return 'ENS_AVATAR' - default: - return 'UNKNOWN' - } -} - -const baseChatIdentity: object = { - clock: 0, - ensName: '', - displayName: '', - description: '', - color: '', - emoji: '', -} - -export const ChatIdentity = { - encode( - message: ChatIdentity, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - if (message.ensName !== '') { - writer.uint32(18).string(message.ensName) - } - Object.entries(message.images).forEach(([key, value]) => { - ChatIdentity_ImagesEntry.encode( - { key: key as any, value }, - writer.uint32(26).fork() - ).ldelim() - }) - if (message.displayName !== '') { - writer.uint32(34).string(message.displayName) - } - if (message.description !== '') { - writer.uint32(42).string(message.description) - } - if (message.color !== '') { - writer.uint32(50).string(message.color) - } - if (message.emoji !== '') { - writer.uint32(58).string(message.emoji) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): ChatIdentity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseChatIdentity } as ChatIdentity - message.images = {} - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - message.ensName = reader.string() - break - case 3: - const entry3 = ChatIdentity_ImagesEntry.decode( - reader, - reader.uint32() - ) - if (entry3.value !== undefined) { - message.images[entry3.key] = entry3.value - } - break - case 4: - message.displayName = reader.string() - break - case 5: - message.description = reader.string() - break - case 6: - message.color = reader.string() - break - case 7: - message.emoji = reader.string() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): ChatIdentity { - const message = { ...baseChatIdentity } as ChatIdentity - message.images = {} - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.ensName !== undefined && object.ensName !== null) { - message.ensName = String(object.ensName) - } else { - message.ensName = '' - } - if (object.images !== undefined && object.images !== null) { - Object.entries(object.images).forEach(([key, value]) => { - message.images[key] = IdentityImage.fromJSON(value) - }) - } - if (object.displayName !== undefined && object.displayName !== null) { - message.displayName = String(object.displayName) - } else { - message.displayName = '' - } - if (object.description !== undefined && object.description !== null) { - message.description = String(object.description) - } else { - message.description = '' - } - if (object.color !== undefined && object.color !== null) { - message.color = String(object.color) - } else { - message.color = '' - } - if (object.emoji !== undefined && object.emoji !== null) { - message.emoji = String(object.emoji) - } else { - message.emoji = '' - } - return message - }, - - toJSON(message: ChatIdentity): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - message.ensName !== undefined && (obj.ensName = message.ensName) - obj.images = {} - if (message.images) { - Object.entries(message.images).forEach(([k, v]) => { - obj.images[k] = IdentityImage.toJSON(v) - }) - } - message.displayName !== undefined && (obj.displayName = message.displayName) - message.description !== undefined && (obj.description = message.description) - message.color !== undefined && (obj.color = message.color) - message.emoji !== undefined && (obj.emoji = message.emoji) - return obj - }, - - fromPartial(object: DeepPartial): ChatIdentity { - const message = { ...baseChatIdentity } as ChatIdentity - message.images = {} - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.ensName !== undefined && object.ensName !== null) { - message.ensName = object.ensName - } else { - message.ensName = '' - } - if (object.images !== undefined && object.images !== null) { - Object.entries(object.images).forEach(([key, value]) => { - if (value !== undefined) { - message.images[key] = IdentityImage.fromPartial(value) - } - }) - } - if (object.displayName !== undefined && object.displayName !== null) { - message.displayName = object.displayName - } else { - message.displayName = '' - } - if (object.description !== undefined && object.description !== null) { - message.description = object.description - } else { - message.description = '' - } - if (object.color !== undefined && object.color !== null) { - message.color = object.color - } else { - message.color = '' - } - if (object.emoji !== undefined && object.emoji !== null) { - message.emoji = object.emoji - } else { - message.emoji = '' - } - return message - }, -} - -const baseChatIdentity_ImagesEntry: object = { key: '' } - -export const ChatIdentity_ImagesEntry = { - encode( - message: ChatIdentity_ImagesEntry, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key !== '') { - writer.uint32(10).string(message.key) - } - if (message.value !== undefined) { - IdentityImage.encode(message.value, writer.uint32(18).fork()).ldelim() - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): ChatIdentity_ImagesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { - ...baseChatIdentity_ImagesEntry, - } as ChatIdentity_ImagesEntry - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.string() - break - case 2: - message.value = IdentityImage.decode(reader, reader.uint32()) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): ChatIdentity_ImagesEntry { - const message = { - ...baseChatIdentity_ImagesEntry, - } as ChatIdentity_ImagesEntry - if (object.key !== undefined && object.key !== null) { - message.key = String(object.key) - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = IdentityImage.fromJSON(object.value) - } else { - message.value = undefined - } - return message - }, - - toJSON(message: ChatIdentity_ImagesEntry): unknown { - const obj: any = {} - message.key !== undefined && (obj.key = message.key) - message.value !== undefined && - (obj.value = message.value - ? IdentityImage.toJSON(message.value) - : undefined) - return obj - }, - - fromPartial( - object: DeepPartial - ): ChatIdentity_ImagesEntry { - const message = { - ...baseChatIdentity_ImagesEntry, - } as ChatIdentity_ImagesEntry - if (object.key !== undefined && object.key !== null) { - message.key = object.key - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = IdentityImage.fromPartial(object.value) - } else { - message.value = undefined - } - return message - }, -} - -const baseIdentityImage: object = { sourceType: 0, imageType: 0 } - -export const IdentityImage = { - encode( - message: IdentityImage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.payload.length !== 0) { - writer.uint32(10).bytes(message.payload) - } - if (message.sourceType !== 0) { - writer.uint32(16).int32(message.sourceType) - } - if (message.imageType !== 0) { - writer.uint32(24).int32(message.imageType) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): IdentityImage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseIdentityImage } as IdentityImage - message.payload = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.payload = reader.bytes() - break - case 2: - message.sourceType = reader.int32() as any - break - case 3: - message.imageType = reader.int32() as any - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): IdentityImage { - const message = { ...baseIdentityImage } as IdentityImage - message.payload = new Uint8Array() - if (object.payload !== undefined && object.payload !== null) { - message.payload = bytesFromBase64(object.payload) - } - if (object.sourceType !== undefined && object.sourceType !== null) { - message.sourceType = identityImage_SourceTypeFromJSON(object.sourceType) - } else { - message.sourceType = 0 - } - if (object.imageType !== undefined && object.imageType !== null) { - message.imageType = imageTypeFromJSON(object.imageType) - } else { - message.imageType = 0 - } - return message - }, - - toJSON(message: IdentityImage): unknown { - const obj: any = {} - message.payload !== undefined && - (obj.payload = base64FromBytes( - message.payload !== undefined ? message.payload : new Uint8Array() - )) - message.sourceType !== undefined && - (obj.sourceType = identityImage_SourceTypeToJSON(message.sourceType)) - message.imageType !== undefined && - (obj.imageType = imageTypeToJSON(message.imageType)) - return obj - }, - - fromPartial(object: DeepPartial): IdentityImage { - const message = { ...baseIdentityImage } as IdentityImage - if (object.payload !== undefined && object.payload !== null) { - message.payload = object.payload - } else { - message.payload = new Uint8Array() - } - if (object.sourceType !== undefined && object.sourceType !== null) { - message.sourceType = object.sourceType - } else { - message.sourceType = 0 - } - if (object.imageType !== undefined && object.imageType !== null) { - message.imageType = object.imageType - } else { - message.imageType = 0 - } - return message - }, -} - -declare var self: any | undefined -declare var window: any | undefined -declare var global: any | undefined -var globalThis: any = (() => { - if (typeof globalThis !== 'undefined') return globalThis - if (typeof self !== 'undefined') return self - if (typeof window !== 'undefined') return window - if (typeof global !== 'undefined') return global - throw 'Unable to locate global object' -})() - -const atob: (b64: string) => string = - globalThis.atob || - (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')) -function bytesFromBase64(b64: string): Uint8Array { - const bin = atob(b64) - const arr = new Uint8Array(bin.length) - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i) - } - return arr -} - -const btoa: (bin: string) => string = - globalThis.btoa || - (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')) -function base64FromBytes(arr: Uint8Array): string { - const bin: string[] = [] - for (const byte of arr) { - bin.push(String.fromCharCode(byte)) - } - return btoa(bin.join('')) -} - -type Builtin = - | Date - | Function - | Uint8Array - | string - | number - | boolean - | undefined -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial - -function longToNumber(long: Long): number { - if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER') - } - return long.toNumber() -} - -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any - _m0.configure() -} diff --git a/packages/status-js/src/proto/communities/v1/chat_message.ts b/packages/status-js/src/proto/communities/v1/chat_message.ts deleted file mode 100644 index 5015180a..00000000 --- a/packages/status-js/src/proto/communities/v1/chat_message.ts +++ /dev/null @@ -1,1105 +0,0 @@ -/* eslint-disable */ -import Long from 'long' -import _m0 from 'protobufjs/minimal' -import { - ImageType, - MessageType, - imageTypeFromJSON, - imageTypeToJSON, - messageTypeFromJSON, - messageTypeToJSON, -} from './enums' - -export const protobufPackage = 'communities.v1' - -export interface StickerMessage { - hash: string - pack: number -} - -export interface ImageMessage { - payload: Uint8Array - type: ImageType -} - -export interface AudioMessage { - payload: Uint8Array - type: AudioMessage_AudioType - durationMs: number -} - -export enum AudioMessage_AudioType { - AUDIO_TYPE_UNKNOWN_UNSPECIFIED = 0, - AUDIO_TYPE_AAC = 1, - AUDIO_TYPE_AMR = 2, - UNRECOGNIZED = -1, -} - -export function audioMessage_AudioTypeFromJSON( - object: any -): AudioMessage_AudioType { - switch (object) { - case 0: - case 'AUDIO_TYPE_UNKNOWN_UNSPECIFIED': - return AudioMessage_AudioType.AUDIO_TYPE_UNKNOWN_UNSPECIFIED - case 1: - case 'AUDIO_TYPE_AAC': - return AudioMessage_AudioType.AUDIO_TYPE_AAC - case 2: - case 'AUDIO_TYPE_AMR': - return AudioMessage_AudioType.AUDIO_TYPE_AMR - case -1: - case 'UNRECOGNIZED': - default: - return AudioMessage_AudioType.UNRECOGNIZED - } -} - -export function audioMessage_AudioTypeToJSON( - object: AudioMessage_AudioType -): string { - switch (object) { - case AudioMessage_AudioType.AUDIO_TYPE_UNKNOWN_UNSPECIFIED: - return 'AUDIO_TYPE_UNKNOWN_UNSPECIFIED' - case AudioMessage_AudioType.AUDIO_TYPE_AAC: - return 'AUDIO_TYPE_AAC' - case AudioMessage_AudioType.AUDIO_TYPE_AMR: - return 'AUDIO_TYPE_AMR' - default: - return 'UNKNOWN' - } -} - -export interface EditMessage { - clock: number - /** Text of the message */ - text: string - chatId: string - messageId: string - /** Grant for community edit messages */ - grant: Uint8Array - /** The type of message (public/one-to-one/private-group-chat) */ - messageType: MessageType -} - -export interface DeleteMessage { - clock: number - chatId: string - messageId: string - /** Grant for community delete messages */ - grant: Uint8Array - /** The type of message (public/one-to-one/private-group-chat) */ - messageType: MessageType -} - -export interface ChatMessage { - /** Lamport timestamp of the chat message */ - clock: number - /** - * Unix timestamps in milliseconds, currently not used as we use whisper as more reliable, but here - * so that we don't rely on it - */ - timestamp: number - /** Text of the message */ - text: string - /** Id of the message that we are replying to */ - responseTo: string - /** Ens name of the sender */ - ensName: string - /** - * 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 - */ - chatId: string - /** The type of message (public/one-to-one/private-group-chat) */ - messageType: MessageType - /** The type of the content of the message */ - contentType: ChatMessage_ContentType - sticker: StickerMessage | undefined - image: ImageMessage | undefined - audio: AudioMessage | undefined - community: Uint8Array | undefined - /** Grant for community chat messages */ - grant?: Uint8Array | undefined -} - -export enum ChatMessage_ContentType { - CONTENT_TYPE_UNKNOWN_UNSPECIFIED = 0, - CONTENT_TYPE_TEXT_PLAIN = 1, - CONTENT_TYPE_STICKER = 2, - CONTENT_TYPE_STATUS = 3, - CONTENT_TYPE_EMOJI = 4, - CONTENT_TYPE_TRANSACTION_COMMAND = 5, - /** CONTENT_TYPE_SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP - Only local */ - CONTENT_TYPE_SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 6, - CONTENT_TYPE_IMAGE = 7, - CONTENT_TYPE_AUDIO = 8, - CONTENT_TYPE_COMMUNITY = 9, - /** CONTENT_TYPE_SYSTEM_MESSAGE_GAP - Only local */ - CONTENT_TYPE_SYSTEM_MESSAGE_GAP = 10, - UNRECOGNIZED = -1, -} - -export function chatMessage_ContentTypeFromJSON( - object: any -): ChatMessage_ContentType { - switch (object) { - case 0: - case 'CONTENT_TYPE_UNKNOWN_UNSPECIFIED': - return ChatMessage_ContentType.CONTENT_TYPE_UNKNOWN_UNSPECIFIED - case 1: - case 'CONTENT_TYPE_TEXT_PLAIN': - return ChatMessage_ContentType.CONTENT_TYPE_TEXT_PLAIN - case 2: - case 'CONTENT_TYPE_STICKER': - return ChatMessage_ContentType.CONTENT_TYPE_STICKER - case 3: - case 'CONTENT_TYPE_STATUS': - return ChatMessage_ContentType.CONTENT_TYPE_STATUS - case 4: - case 'CONTENT_TYPE_EMOJI': - return ChatMessage_ContentType.CONTENT_TYPE_EMOJI - case 5: - case 'CONTENT_TYPE_TRANSACTION_COMMAND': - return ChatMessage_ContentType.CONTENT_TYPE_TRANSACTION_COMMAND - case 6: - case 'CONTENT_TYPE_SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP': - return ChatMessage_ContentType.CONTENT_TYPE_SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP - case 7: - case 'CONTENT_TYPE_IMAGE': - return ChatMessage_ContentType.CONTENT_TYPE_IMAGE - case 8: - case 'CONTENT_TYPE_AUDIO': - return ChatMessage_ContentType.CONTENT_TYPE_AUDIO - case 9: - case 'CONTENT_TYPE_COMMUNITY': - return ChatMessage_ContentType.CONTENT_TYPE_COMMUNITY - case 10: - case 'CONTENT_TYPE_SYSTEM_MESSAGE_GAP': - return ChatMessage_ContentType.CONTENT_TYPE_SYSTEM_MESSAGE_GAP - case -1: - case 'UNRECOGNIZED': - default: - return ChatMessage_ContentType.UNRECOGNIZED - } -} - -export function chatMessage_ContentTypeToJSON( - object: ChatMessage_ContentType -): string { - switch (object) { - case ChatMessage_ContentType.CONTENT_TYPE_UNKNOWN_UNSPECIFIED: - return 'CONTENT_TYPE_UNKNOWN_UNSPECIFIED' - case ChatMessage_ContentType.CONTENT_TYPE_TEXT_PLAIN: - return 'CONTENT_TYPE_TEXT_PLAIN' - case ChatMessage_ContentType.CONTENT_TYPE_STICKER: - return 'CONTENT_TYPE_STICKER' - case ChatMessage_ContentType.CONTENT_TYPE_STATUS: - return 'CONTENT_TYPE_STATUS' - case ChatMessage_ContentType.CONTENT_TYPE_EMOJI: - return 'CONTENT_TYPE_EMOJI' - case ChatMessage_ContentType.CONTENT_TYPE_TRANSACTION_COMMAND: - return 'CONTENT_TYPE_TRANSACTION_COMMAND' - case ChatMessage_ContentType.CONTENT_TYPE_SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP: - return 'CONTENT_TYPE_SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP' - case ChatMessage_ContentType.CONTENT_TYPE_IMAGE: - return 'CONTENT_TYPE_IMAGE' - case ChatMessage_ContentType.CONTENT_TYPE_AUDIO: - return 'CONTENT_TYPE_AUDIO' - case ChatMessage_ContentType.CONTENT_TYPE_COMMUNITY: - return 'CONTENT_TYPE_COMMUNITY' - case ChatMessage_ContentType.CONTENT_TYPE_SYSTEM_MESSAGE_GAP: - return 'CONTENT_TYPE_SYSTEM_MESSAGE_GAP' - default: - return 'UNKNOWN' - } -} - -const baseStickerMessage: object = { hash: '', pack: 0 } - -export const StickerMessage = { - encode( - message: StickerMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.hash !== '') { - writer.uint32(10).string(message.hash) - } - if (message.pack !== 0) { - writer.uint32(16).int32(message.pack) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): StickerMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseStickerMessage } as StickerMessage - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.hash = reader.string() - break - case 2: - message.pack = reader.int32() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): StickerMessage { - const message = { ...baseStickerMessage } as StickerMessage - if (object.hash !== undefined && object.hash !== null) { - message.hash = String(object.hash) - } else { - message.hash = '' - } - if (object.pack !== undefined && object.pack !== null) { - message.pack = Number(object.pack) - } else { - message.pack = 0 - } - return message - }, - - toJSON(message: StickerMessage): unknown { - const obj: any = {} - message.hash !== undefined && (obj.hash = message.hash) - message.pack !== undefined && (obj.pack = message.pack) - return obj - }, - - fromPartial(object: DeepPartial): StickerMessage { - const message = { ...baseStickerMessage } as StickerMessage - if (object.hash !== undefined && object.hash !== null) { - message.hash = object.hash - } else { - message.hash = '' - } - if (object.pack !== undefined && object.pack !== null) { - message.pack = object.pack - } else { - message.pack = 0 - } - return message - }, -} - -const baseImageMessage: object = { type: 0 } - -export const ImageMessage = { - encode( - message: ImageMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.payload.length !== 0) { - writer.uint32(10).bytes(message.payload) - } - if (message.type !== 0) { - writer.uint32(16).int32(message.type) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): ImageMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseImageMessage } as ImageMessage - message.payload = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.payload = reader.bytes() - break - case 2: - message.type = reader.int32() as any - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): ImageMessage { - const message = { ...baseImageMessage } as ImageMessage - message.payload = new Uint8Array() - if (object.payload !== undefined && object.payload !== null) { - message.payload = bytesFromBase64(object.payload) - } - if (object.type !== undefined && object.type !== null) { - message.type = imageTypeFromJSON(object.type) - } else { - message.type = 0 - } - return message - }, - - toJSON(message: ImageMessage): unknown { - const obj: any = {} - message.payload !== undefined && - (obj.payload = base64FromBytes( - message.payload !== undefined ? message.payload : new Uint8Array() - )) - message.type !== undefined && (obj.type = imageTypeToJSON(message.type)) - return obj - }, - - fromPartial(object: DeepPartial): ImageMessage { - const message = { ...baseImageMessage } as ImageMessage - if (object.payload !== undefined && object.payload !== null) { - message.payload = object.payload - } else { - message.payload = new Uint8Array() - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type - } else { - message.type = 0 - } - return message - }, -} - -const baseAudioMessage: object = { type: 0, durationMs: 0 } - -export const AudioMessage = { - encode( - message: AudioMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.payload.length !== 0) { - writer.uint32(10).bytes(message.payload) - } - if (message.type !== 0) { - writer.uint32(16).int32(message.type) - } - if (message.durationMs !== 0) { - writer.uint32(24).uint64(message.durationMs) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): AudioMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseAudioMessage } as AudioMessage - message.payload = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.payload = reader.bytes() - break - case 2: - message.type = reader.int32() as any - break - case 3: - message.durationMs = longToNumber(reader.uint64() as Long) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): AudioMessage { - const message = { ...baseAudioMessage } as AudioMessage - message.payload = new Uint8Array() - if (object.payload !== undefined && object.payload !== null) { - message.payload = bytesFromBase64(object.payload) - } - if (object.type !== undefined && object.type !== null) { - message.type = audioMessage_AudioTypeFromJSON(object.type) - } else { - message.type = 0 - } - if (object.durationMs !== undefined && object.durationMs !== null) { - message.durationMs = Number(object.durationMs) - } else { - message.durationMs = 0 - } - return message - }, - - toJSON(message: AudioMessage): unknown { - const obj: any = {} - message.payload !== undefined && - (obj.payload = base64FromBytes( - message.payload !== undefined ? message.payload : new Uint8Array() - )) - message.type !== undefined && - (obj.type = audioMessage_AudioTypeToJSON(message.type)) - message.durationMs !== undefined && (obj.durationMs = message.durationMs) - return obj - }, - - fromPartial(object: DeepPartial): AudioMessage { - const message = { ...baseAudioMessage } as AudioMessage - if (object.payload !== undefined && object.payload !== null) { - message.payload = object.payload - } else { - message.payload = new Uint8Array() - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type - } else { - message.type = 0 - } - if (object.durationMs !== undefined && object.durationMs !== null) { - message.durationMs = object.durationMs - } else { - message.durationMs = 0 - } - return message - }, -} - -const baseEditMessage: object = { - clock: 0, - text: '', - chatId: '', - messageId: '', - messageType: 0, -} - -export const EditMessage = { - encode( - message: EditMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - if (message.text !== '') { - writer.uint32(18).string(message.text) - } - if (message.chatId !== '') { - writer.uint32(26).string(message.chatId) - } - if (message.messageId !== '') { - writer.uint32(34).string(message.messageId) - } - if (message.grant.length !== 0) { - writer.uint32(42).bytes(message.grant) - } - if (message.messageType !== 0) { - writer.uint32(48).int32(message.messageType) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): EditMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseEditMessage } as EditMessage - message.grant = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - message.text = reader.string() - break - case 3: - message.chatId = reader.string() - break - case 4: - message.messageId = reader.string() - break - case 5: - message.grant = reader.bytes() - break - case 6: - message.messageType = reader.int32() as any - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): EditMessage { - const message = { ...baseEditMessage } as EditMessage - message.grant = new Uint8Array() - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.text !== undefined && object.text !== null) { - message.text = String(object.text) - } else { - message.text = '' - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = String(object.chatId) - } else { - message.chatId = '' - } - if (object.messageId !== undefined && object.messageId !== null) { - message.messageId = String(object.messageId) - } else { - message.messageId = '' - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = bytesFromBase64(object.grant) - } - if (object.messageType !== undefined && object.messageType !== null) { - message.messageType = messageTypeFromJSON(object.messageType) - } else { - message.messageType = 0 - } - return message - }, - - toJSON(message: EditMessage): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - message.text !== undefined && (obj.text = message.text) - message.chatId !== undefined && (obj.chatId = message.chatId) - message.messageId !== undefined && (obj.messageId = message.messageId) - message.grant !== undefined && - (obj.grant = base64FromBytes( - message.grant !== undefined ? message.grant : new Uint8Array() - )) - message.messageType !== undefined && - (obj.messageType = messageTypeToJSON(message.messageType)) - return obj - }, - - fromPartial(object: DeepPartial): EditMessage { - const message = { ...baseEditMessage } as EditMessage - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.text !== undefined && object.text !== null) { - message.text = object.text - } else { - message.text = '' - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = object.chatId - } else { - message.chatId = '' - } - if (object.messageId !== undefined && object.messageId !== null) { - message.messageId = object.messageId - } else { - message.messageId = '' - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = object.grant - } else { - message.grant = new Uint8Array() - } - if (object.messageType !== undefined && object.messageType !== null) { - message.messageType = object.messageType - } else { - message.messageType = 0 - } - return message - }, -} - -const baseDeleteMessage: object = { - clock: 0, - chatId: '', - messageId: '', - messageType: 0, -} - -export const DeleteMessage = { - encode( - message: DeleteMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - if (message.chatId !== '') { - writer.uint32(18).string(message.chatId) - } - if (message.messageId !== '') { - writer.uint32(26).string(message.messageId) - } - if (message.grant.length !== 0) { - writer.uint32(34).bytes(message.grant) - } - if (message.messageType !== 0) { - writer.uint32(40).int32(message.messageType) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): DeleteMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseDeleteMessage } as DeleteMessage - message.grant = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - message.chatId = reader.string() - break - case 3: - message.messageId = reader.string() - break - case 4: - message.grant = reader.bytes() - break - case 5: - message.messageType = reader.int32() as any - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): DeleteMessage { - const message = { ...baseDeleteMessage } as DeleteMessage - message.grant = new Uint8Array() - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = String(object.chatId) - } else { - message.chatId = '' - } - if (object.messageId !== undefined && object.messageId !== null) { - message.messageId = String(object.messageId) - } else { - message.messageId = '' - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = bytesFromBase64(object.grant) - } - if (object.messageType !== undefined && object.messageType !== null) { - message.messageType = messageTypeFromJSON(object.messageType) - } else { - message.messageType = 0 - } - return message - }, - - toJSON(message: DeleteMessage): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - message.chatId !== undefined && (obj.chatId = message.chatId) - message.messageId !== undefined && (obj.messageId = message.messageId) - message.grant !== undefined && - (obj.grant = base64FromBytes( - message.grant !== undefined ? message.grant : new Uint8Array() - )) - message.messageType !== undefined && - (obj.messageType = messageTypeToJSON(message.messageType)) - return obj - }, - - fromPartial(object: DeepPartial): DeleteMessage { - const message = { ...baseDeleteMessage } as DeleteMessage - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = object.chatId - } else { - message.chatId = '' - } - if (object.messageId !== undefined && object.messageId !== null) { - message.messageId = object.messageId - } else { - message.messageId = '' - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = object.grant - } else { - message.grant = new Uint8Array() - } - if (object.messageType !== undefined && object.messageType !== null) { - message.messageType = object.messageType - } else { - message.messageType = 0 - } - return message - }, -} - -const baseChatMessage: object = { - clock: 0, - timestamp: 0, - text: '', - responseTo: '', - ensName: '', - chatId: '', - messageType: 0, - contentType: 0, -} - -export const ChatMessage = { - encode( - message: ChatMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - if (message.timestamp !== 0) { - writer.uint32(16).uint64(message.timestamp) - } - if (message.text !== '') { - writer.uint32(26).string(message.text) - } - if (message.responseTo !== '') { - writer.uint32(34).string(message.responseTo) - } - if (message.ensName !== '') { - writer.uint32(42).string(message.ensName) - } - if (message.chatId !== '') { - writer.uint32(50).string(message.chatId) - } - if (message.messageType !== 0) { - writer.uint32(56).int32(message.messageType) - } - if (message.contentType !== 0) { - writer.uint32(64).int32(message.contentType) - } - if (message.sticker !== undefined) { - StickerMessage.encode(message.sticker, writer.uint32(74).fork()).ldelim() - } - if (message.image !== undefined) { - ImageMessage.encode(message.image, writer.uint32(82).fork()).ldelim() - } - if (message.audio !== undefined) { - AudioMessage.encode(message.audio, writer.uint32(90).fork()).ldelim() - } - if (message.community !== undefined) { - writer.uint32(98).bytes(message.community) - } - if (message.grant !== undefined) { - writer.uint32(106).bytes(message.grant) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): ChatMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseChatMessage } as ChatMessage - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - message.timestamp = longToNumber(reader.uint64() as Long) - break - case 3: - message.text = reader.string() - break - case 4: - message.responseTo = reader.string() - break - case 5: - message.ensName = reader.string() - break - case 6: - message.chatId = reader.string() - break - case 7: - message.messageType = reader.int32() as any - break - case 8: - message.contentType = reader.int32() as any - break - case 9: - message.sticker = StickerMessage.decode(reader, reader.uint32()) - break - case 10: - message.image = ImageMessage.decode(reader, reader.uint32()) - break - case 11: - message.audio = AudioMessage.decode(reader, reader.uint32()) - break - case 12: - message.community = reader.bytes() - break - case 13: - message.grant = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): ChatMessage { - const message = { ...baseChatMessage } as ChatMessage - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.timestamp !== undefined && object.timestamp !== null) { - message.timestamp = Number(object.timestamp) - } else { - message.timestamp = 0 - } - if (object.text !== undefined && object.text !== null) { - message.text = String(object.text) - } else { - message.text = '' - } - if (object.responseTo !== undefined && object.responseTo !== null) { - message.responseTo = String(object.responseTo) - } else { - message.responseTo = '' - } - if (object.ensName !== undefined && object.ensName !== null) { - message.ensName = String(object.ensName) - } else { - message.ensName = '' - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = String(object.chatId) - } else { - message.chatId = '' - } - if (object.messageType !== undefined && object.messageType !== null) { - message.messageType = messageTypeFromJSON(object.messageType) - } else { - message.messageType = 0 - } - if (object.contentType !== undefined && object.contentType !== null) { - message.contentType = chatMessage_ContentTypeFromJSON(object.contentType) - } else { - message.contentType = 0 - } - if (object.sticker !== undefined && object.sticker !== null) { - message.sticker = StickerMessage.fromJSON(object.sticker) - } else { - message.sticker = undefined - } - if (object.image !== undefined && object.image !== null) { - message.image = ImageMessage.fromJSON(object.image) - } else { - message.image = undefined - } - if (object.audio !== undefined && object.audio !== null) { - message.audio = AudioMessage.fromJSON(object.audio) - } else { - message.audio = undefined - } - if (object.community !== undefined && object.community !== null) { - message.community = bytesFromBase64(object.community) - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = bytesFromBase64(object.grant) - } - return message - }, - - toJSON(message: ChatMessage): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - message.timestamp !== undefined && (obj.timestamp = message.timestamp) - message.text !== undefined && (obj.text = message.text) - message.responseTo !== undefined && (obj.responseTo = message.responseTo) - message.ensName !== undefined && (obj.ensName = message.ensName) - message.chatId !== undefined && (obj.chatId = message.chatId) - message.messageType !== undefined && - (obj.messageType = messageTypeToJSON(message.messageType)) - message.contentType !== undefined && - (obj.contentType = chatMessage_ContentTypeToJSON(message.contentType)) - message.sticker !== undefined && - (obj.sticker = message.sticker - ? StickerMessage.toJSON(message.sticker) - : undefined) - message.image !== undefined && - (obj.image = message.image - ? ImageMessage.toJSON(message.image) - : undefined) - message.audio !== undefined && - (obj.audio = message.audio - ? AudioMessage.toJSON(message.audio) - : undefined) - message.community !== undefined && - (obj.community = - message.community !== undefined - ? base64FromBytes(message.community) - : undefined) - message.grant !== undefined && - (obj.grant = - message.grant !== undefined - ? base64FromBytes(message.grant) - : undefined) - return obj - }, - - fromPartial(object: DeepPartial): ChatMessage { - const message = { ...baseChatMessage } as ChatMessage - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.timestamp !== undefined && object.timestamp !== null) { - message.timestamp = object.timestamp - } else { - message.timestamp = 0 - } - if (object.text !== undefined && object.text !== null) { - message.text = object.text - } else { - message.text = '' - } - if (object.responseTo !== undefined && object.responseTo !== null) { - message.responseTo = object.responseTo - } else { - message.responseTo = '' - } - if (object.ensName !== undefined && object.ensName !== null) { - message.ensName = object.ensName - } else { - message.ensName = '' - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = object.chatId - } else { - message.chatId = '' - } - if (object.messageType !== undefined && object.messageType !== null) { - message.messageType = object.messageType - } else { - message.messageType = 0 - } - if (object.contentType !== undefined && object.contentType !== null) { - message.contentType = object.contentType - } else { - message.contentType = 0 - } - if (object.sticker !== undefined && object.sticker !== null) { - message.sticker = StickerMessage.fromPartial(object.sticker) - } else { - message.sticker = undefined - } - if (object.image !== undefined && object.image !== null) { - message.image = ImageMessage.fromPartial(object.image) - } else { - message.image = undefined - } - if (object.audio !== undefined && object.audio !== null) { - message.audio = AudioMessage.fromPartial(object.audio) - } else { - message.audio = undefined - } - if (object.community !== undefined && object.community !== null) { - message.community = object.community - } else { - message.community = undefined - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = object.grant - } else { - message.grant = undefined - } - return message - }, -} - -declare var self: any | undefined -declare var window: any | undefined -declare var global: any | undefined -var globalThis: any = (() => { - if (typeof globalThis !== 'undefined') return globalThis - if (typeof self !== 'undefined') return self - if (typeof window !== 'undefined') return window - if (typeof global !== 'undefined') return global - throw 'Unable to locate global object' -})() - -const atob: (b64: string) => string = - globalThis.atob || - (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')) -function bytesFromBase64(b64: string): Uint8Array { - const bin = atob(b64) - const arr = new Uint8Array(bin.length) - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i) - } - return arr -} - -const btoa: (bin: string) => string = - globalThis.btoa || - (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')) -function base64FromBytes(arr: Uint8Array): string { - const bin: string[] = [] - for (const byte of arr) { - bin.push(String.fromCharCode(byte)) - } - return btoa(bin.join('')) -} - -type Builtin = - | Date - | Function - | Uint8Array - | string - | number - | boolean - | undefined -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial - -function longToNumber(long: Long): number { - if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER') - } - return long.toNumber() -} - -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any - _m0.configure() -} diff --git a/packages/status-js/src/proto/communities/v1/communities.ts b/packages/status-js/src/proto/communities/v1/communities.ts deleted file mode 100644 index 6f29c9ad..00000000 --- a/packages/status-js/src/proto/communities/v1/communities.ts +++ /dev/null @@ -1,1762 +0,0 @@ -/* eslint-disable */ -import Long from 'long' -import _m0 from 'protobufjs/minimal' -import { ChatIdentity } from './chat_identity' - -export const protobufPackage = 'communities.v1' - -export interface Grant { - communityId: Uint8Array - memberId: Uint8Array - chatId: string - clock: number -} - -export interface CommunityMember { - roles: CommunityMember_Roles[] -} - -export enum CommunityMember_Roles { - UNKNOWN_ROLE = 0, - ROLE_ALL = 1, - ROLE_MANAGE_USERS = 2, - UNRECOGNIZED = -1, -} - -export function communityMember_RolesFromJSON( - object: any -): CommunityMember_Roles { - switch (object) { - case 0: - case 'UNKNOWN_ROLE': - return CommunityMember_Roles.UNKNOWN_ROLE - case 1: - case 'ROLE_ALL': - return CommunityMember_Roles.ROLE_ALL - case 2: - case 'ROLE_MANAGE_USERS': - return CommunityMember_Roles.ROLE_MANAGE_USERS - case -1: - case 'UNRECOGNIZED': - default: - return CommunityMember_Roles.UNRECOGNIZED - } -} - -export function communityMember_RolesToJSON( - object: CommunityMember_Roles -): string { - switch (object) { - case CommunityMember_Roles.UNKNOWN_ROLE: - return 'UNKNOWN_ROLE' - case CommunityMember_Roles.ROLE_ALL: - return 'ROLE_ALL' - case CommunityMember_Roles.ROLE_MANAGE_USERS: - return 'ROLE_MANAGE_USERS' - default: - return 'UNKNOWN' - } -} - -export interface CommunityPermissions { - ensOnly: boolean - /** 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 */ - private: boolean - access: CommunityPermissions_Access -} - -export enum CommunityPermissions_Access { - UNKNOWN_ACCESS = 0, - NO_MEMBERSHIP = 1, - INVITATION_ONLY = 2, - ON_REQUEST = 3, - UNRECOGNIZED = -1, -} - -export function communityPermissions_AccessFromJSON( - object: any -): CommunityPermissions_Access { - switch (object) { - case 0: - case 'UNKNOWN_ACCESS': - return CommunityPermissions_Access.UNKNOWN_ACCESS - case 1: - case 'NO_MEMBERSHIP': - return CommunityPermissions_Access.NO_MEMBERSHIP - case 2: - case 'INVITATION_ONLY': - return CommunityPermissions_Access.INVITATION_ONLY - case 3: - case 'ON_REQUEST': - return CommunityPermissions_Access.ON_REQUEST - case -1: - case 'UNRECOGNIZED': - default: - return CommunityPermissions_Access.UNRECOGNIZED - } -} - -export function communityPermissions_AccessToJSON( - object: CommunityPermissions_Access -): string { - switch (object) { - case CommunityPermissions_Access.UNKNOWN_ACCESS: - return 'UNKNOWN_ACCESS' - case CommunityPermissions_Access.NO_MEMBERSHIP: - return 'NO_MEMBERSHIP' - case CommunityPermissions_Access.INVITATION_ONLY: - return 'INVITATION_ONLY' - case CommunityPermissions_Access.ON_REQUEST: - return 'ON_REQUEST' - default: - return 'UNKNOWN' - } -} - -export interface CommunityDescription { - // fixme?: bigint - clock: number - members: { [key: string]: CommunityMember } - permissions: CommunityPermissions | undefined - identity: ChatIdentity | undefined - chats: { [key: string]: CommunityChat } - banList: string[] - categories: { [key: string]: CommunityCategory } -} - -export interface CommunityDescription_MembersEntry { - key: string - value: CommunityMember | undefined -} - -export interface CommunityDescription_ChatsEntry { - key: string - value: CommunityChat | undefined -} - -export interface CommunityDescription_CategoriesEntry { - key: string - value: CommunityCategory | undefined -} - -export interface CommunityChat { - members: { [key: string]: CommunityMember } - permissions: CommunityPermissions | undefined - identity: ChatIdentity | undefined - categoryId: string - position: number -} - -export interface CommunityChat_MembersEntry { - key: string - value: CommunityMember | undefined -} - -export interface CommunityCategory { - categoryId: string - name: string - position: number -} - -export interface CommunityInvitation { - communityDescription: Uint8Array - grant: Uint8Array - chatId: string - publicKey: Uint8Array -} - -export interface CommunityRequestToJoin { - clock: number - ensName: string - chatId: string - communityId: Uint8Array -} - -export interface CommunityRequestToJoinResponse { - clock: number - community: CommunityDescription | undefined - accepted: boolean - grant: Uint8Array -} - -const baseGrant: object = { chatId: '', clock: 0 } - -export const Grant = { - encode(message: Grant, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.communityId.length !== 0) { - writer.uint32(10).bytes(message.communityId) - } - if (message.memberId.length !== 0) { - writer.uint32(18).bytes(message.memberId) - } - if (message.chatId !== '') { - writer.uint32(26).string(message.chatId) - } - if (message.clock !== 0) { - writer.uint32(32).uint64(message.clock) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): Grant { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseGrant } as Grant - message.communityId = new Uint8Array() - message.memberId = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.communityId = reader.bytes() - break - case 2: - message.memberId = reader.bytes() - break - case 3: - message.chatId = reader.string() - break - case 4: - message.clock = longToNumber(reader.uint64() as Long) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): Grant { - const message = { ...baseGrant } as Grant - message.communityId = new Uint8Array() - message.memberId = new Uint8Array() - if (object.communityId !== undefined && object.communityId !== null) { - message.communityId = bytesFromBase64(object.communityId) - } - if (object.memberId !== undefined && object.memberId !== null) { - message.memberId = bytesFromBase64(object.memberId) - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = String(object.chatId) - } else { - message.chatId = '' - } - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - return message - }, - - toJSON(message: Grant): unknown { - const obj: any = {} - message.communityId !== undefined && - (obj.communityId = base64FromBytes( - message.communityId !== undefined - ? message.communityId - : new Uint8Array() - )) - message.memberId !== undefined && - (obj.memberId = base64FromBytes( - message.memberId !== undefined ? message.memberId : new Uint8Array() - )) - message.chatId !== undefined && (obj.chatId = message.chatId) - message.clock !== undefined && (obj.clock = message.clock) - return obj - }, - - fromPartial(object: DeepPartial): Grant { - const message = { ...baseGrant } as Grant - if (object.communityId !== undefined && object.communityId !== null) { - message.communityId = object.communityId - } else { - message.communityId = new Uint8Array() - } - if (object.memberId !== undefined && object.memberId !== null) { - message.memberId = object.memberId - } else { - message.memberId = new Uint8Array() - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = object.chatId - } else { - message.chatId = '' - } - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - return message - }, -} - -const baseCommunityMember: object = { roles: 0 } - -export const CommunityMember = { - encode( - message: CommunityMember, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - writer.uint32(10).fork() - for (const v of message.roles) { - writer.int32(v) - } - writer.ldelim() - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): CommunityMember { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseCommunityMember } as CommunityMember - message.roles = [] - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - if ((tag & 7) === 2) { - const end2 = reader.uint32() + reader.pos - while (reader.pos < end2) { - message.roles.push(reader.int32() as any) - } - } else { - message.roles.push(reader.int32() as any) - } - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityMember { - const message = { ...baseCommunityMember } as CommunityMember - message.roles = [] - if (object.roles !== undefined && object.roles !== null) { - for (const e of object.roles) { - message.roles.push(communityMember_RolesFromJSON(e)) - } - } - return message - }, - - toJSON(message: CommunityMember): unknown { - const obj: any = {} - if (message.roles) { - obj.roles = message.roles.map(e => communityMember_RolesToJSON(e)) - } else { - obj.roles = [] - } - return obj - }, - - fromPartial(object: DeepPartial): CommunityMember { - const message = { ...baseCommunityMember } as CommunityMember - message.roles = [] - if (object.roles !== undefined && object.roles !== null) { - for (const e of object.roles) { - message.roles.push(e) - } - } - return message - }, -} - -const baseCommunityPermissions: object = { - ensOnly: false, - private: false, - access: 0, -} - -export const CommunityPermissions = { - encode( - message: CommunityPermissions, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.ensOnly === true) { - writer.uint32(8).bool(message.ensOnly) - } - if (message.private === true) { - writer.uint32(16).bool(message.private) - } - if (message.access !== 0) { - writer.uint32(24).int32(message.access) - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): CommunityPermissions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseCommunityPermissions } as CommunityPermissions - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.ensOnly = reader.bool() - break - case 2: - message.private = reader.bool() - break - case 3: - message.access = reader.int32() as any - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityPermissions { - const message = { ...baseCommunityPermissions } as CommunityPermissions - if (object.ensOnly !== undefined && object.ensOnly !== null) { - message.ensOnly = Boolean(object.ensOnly) - } else { - message.ensOnly = false - } - if (object.private !== undefined && object.private !== null) { - message.private = Boolean(object.private) - } else { - message.private = false - } - if (object.access !== undefined && object.access !== null) { - message.access = communityPermissions_AccessFromJSON(object.access) - } else { - message.access = 0 - } - return message - }, - - toJSON(message: CommunityPermissions): unknown { - const obj: any = {} - message.ensOnly !== undefined && (obj.ensOnly = message.ensOnly) - message.private !== undefined && (obj.private = message.private) - message.access !== undefined && - (obj.access = communityPermissions_AccessToJSON(message.access)) - return obj - }, - - fromPartial(object: DeepPartial): CommunityPermissions { - const message = { ...baseCommunityPermissions } as CommunityPermissions - if (object.ensOnly !== undefined && object.ensOnly !== null) { - message.ensOnly = object.ensOnly - } else { - message.ensOnly = false - } - if (object.private !== undefined && object.private !== null) { - message.private = object.private - } else { - message.private = false - } - if (object.access !== undefined && object.access !== null) { - message.access = object.access - } else { - message.access = 0 - } - return message - }, -} - -const baseCommunityDescription: object = { clock: 0, banList: '' } - -export const CommunityDescription = { - encode( - message: CommunityDescription, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - Object.entries(message.members).forEach(([key, value]) => { - CommunityDescription_MembersEntry.encode( - { key: key as any, value }, - writer.uint32(18).fork() - ).ldelim() - }) - if (message.permissions !== undefined) { - CommunityPermissions.encode( - message.permissions, - writer.uint32(26).fork() - ).ldelim() - } - if (message.identity !== undefined) { - ChatIdentity.encode(message.identity, writer.uint32(42).fork()).ldelim() - } - Object.entries(message.chats).forEach(([key, value]) => { - CommunityDescription_ChatsEntry.encode( - { key: key as any, value }, - writer.uint32(50).fork() - ).ldelim() - }) - for (const v of message.banList) { - writer.uint32(58).string(v!) - } - Object.entries(message.categories).forEach(([key, value]) => { - CommunityDescription_CategoriesEntry.encode( - { key: key as any, value }, - writer.uint32(66).fork() - ).ldelim() - }) - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): CommunityDescription { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseCommunityDescription } as CommunityDescription - message.members = {} - message.chats = {} - message.banList = [] - message.categories = {} - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - const entry2 = CommunityDescription_MembersEntry.decode( - reader, - reader.uint32() - ) - if (entry2.value !== undefined) { - message.members[entry2.key] = entry2.value - } - break - case 3: - message.permissions = CommunityPermissions.decode( - reader, - reader.uint32() - ) - break - case 5: - message.identity = ChatIdentity.decode(reader, reader.uint32()) - break - case 6: - const entry6 = CommunityDescription_ChatsEntry.decode( - reader, - reader.uint32() - ) - if (entry6.value !== undefined) { - message.chats[entry6.key] = entry6.value - } - break - case 7: - message.banList.push(reader.string()) - break - case 8: - const entry8 = CommunityDescription_CategoriesEntry.decode( - reader, - reader.uint32() - ) - if (entry8.value !== undefined) { - message.categories[entry8.key] = entry8.value - } - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityDescription { - const message = { ...baseCommunityDescription } as CommunityDescription - message.members = {} - message.chats = {} - message.banList = [] - message.categories = {} - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.members !== undefined && object.members !== null) { - Object.entries(object.members).forEach(([key, value]) => { - message.members[key] = CommunityMember.fromJSON(value) - }) - } - if (object.permissions !== undefined && object.permissions !== null) { - message.permissions = CommunityPermissions.fromJSON(object.permissions) - } else { - message.permissions = undefined - } - if (object.identity !== undefined && object.identity !== null) { - message.identity = ChatIdentity.fromJSON(object.identity) - } else { - message.identity = undefined - } - if (object.chats !== undefined && object.chats !== null) { - Object.entries(object.chats).forEach(([key, value]) => { - message.chats[key] = CommunityChat.fromJSON(value) - }) - } - if (object.banList !== undefined && object.banList !== null) { - for (const e of object.banList) { - message.banList.push(String(e)) - } - } - if (object.categories !== undefined && object.categories !== null) { - Object.entries(object.categories).forEach(([key, value]) => { - message.categories[key] = CommunityCategory.fromJSON(value) - }) - } - return message - }, - - toJSON(message: CommunityDescription): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - obj.members = {} - if (message.members) { - Object.entries(message.members).forEach(([k, v]) => { - obj.members[k] = CommunityMember.toJSON(v) - }) - } - message.permissions !== undefined && - (obj.permissions = message.permissions - ? CommunityPermissions.toJSON(message.permissions) - : undefined) - message.identity !== undefined && - (obj.identity = message.identity - ? ChatIdentity.toJSON(message.identity) - : undefined) - obj.chats = {} - if (message.chats) { - Object.entries(message.chats).forEach(([k, v]) => { - obj.chats[k] = CommunityChat.toJSON(v) - }) - } - if (message.banList) { - obj.banList = message.banList.map(e => e) - } else { - obj.banList = [] - } - obj.categories = {} - if (message.categories) { - Object.entries(message.categories).forEach(([k, v]) => { - obj.categories[k] = CommunityCategory.toJSON(v) - }) - } - return obj - }, - - fromPartial(object: DeepPartial): CommunityDescription { - const message = { ...baseCommunityDescription } as CommunityDescription - message.members = {} - message.chats = {} - message.banList = [] - message.categories = {} - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.members !== undefined && object.members !== null) { - Object.entries(object.members).forEach(([key, value]) => { - if (value !== undefined) { - message.members[key] = CommunityMember.fromPartial(value) - } - }) - } - if (object.permissions !== undefined && object.permissions !== null) { - message.permissions = CommunityPermissions.fromPartial(object.permissions) - } else { - message.permissions = undefined - } - if (object.identity !== undefined && object.identity !== null) { - message.identity = ChatIdentity.fromPartial(object.identity) - } else { - message.identity = undefined - } - if (object.chats !== undefined && object.chats !== null) { - Object.entries(object.chats).forEach(([key, value]) => { - if (value !== undefined) { - message.chats[key] = CommunityChat.fromPartial(value) - } - }) - } - if (object.banList !== undefined && object.banList !== null) { - for (const e of object.banList) { - message.banList.push(e) - } - } - if (object.categories !== undefined && object.categories !== null) { - Object.entries(object.categories).forEach(([key, value]) => { - if (value !== undefined) { - message.categories[key] = CommunityCategory.fromPartial(value) - } - }) - } - return message - }, -} - -const baseCommunityDescription_MembersEntry: object = { key: '' } - -export const CommunityDescription_MembersEntry = { - encode( - message: CommunityDescription_MembersEntry, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key !== '') { - writer.uint32(10).string(message.key) - } - if (message.value !== undefined) { - CommunityMember.encode(message.value, writer.uint32(18).fork()).ldelim() - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): CommunityDescription_MembersEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { - ...baseCommunityDescription_MembersEntry, - } as CommunityDescription_MembersEntry - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.string() - break - case 2: - message.value = CommunityMember.decode(reader, reader.uint32()) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityDescription_MembersEntry { - const message = { - ...baseCommunityDescription_MembersEntry, - } as CommunityDescription_MembersEntry - if (object.key !== undefined && object.key !== null) { - message.key = String(object.key) - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = CommunityMember.fromJSON(object.value) - } else { - message.value = undefined - } - return message - }, - - toJSON(message: CommunityDescription_MembersEntry): unknown { - const obj: any = {} - message.key !== undefined && (obj.key = message.key) - message.value !== undefined && - (obj.value = message.value - ? CommunityMember.toJSON(message.value) - : undefined) - return obj - }, - - fromPartial( - object: DeepPartial - ): CommunityDescription_MembersEntry { - const message = { - ...baseCommunityDescription_MembersEntry, - } as CommunityDescription_MembersEntry - if (object.key !== undefined && object.key !== null) { - message.key = object.key - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = CommunityMember.fromPartial(object.value) - } else { - message.value = undefined - } - return message - }, -} - -const baseCommunityDescription_ChatsEntry: object = { key: '' } - -export const CommunityDescription_ChatsEntry = { - encode( - message: CommunityDescription_ChatsEntry, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key !== '') { - writer.uint32(10).string(message.key) - } - if (message.value !== undefined) { - CommunityChat.encode(message.value, writer.uint32(18).fork()).ldelim() - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): CommunityDescription_ChatsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { - ...baseCommunityDescription_ChatsEntry, - } as CommunityDescription_ChatsEntry - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.string() - break - case 2: - message.value = CommunityChat.decode(reader, reader.uint32()) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityDescription_ChatsEntry { - const message = { - ...baseCommunityDescription_ChatsEntry, - } as CommunityDescription_ChatsEntry - if (object.key !== undefined && object.key !== null) { - message.key = String(object.key) - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = CommunityChat.fromJSON(object.value) - } else { - message.value = undefined - } - return message - }, - - toJSON(message: CommunityDescription_ChatsEntry): unknown { - const obj: any = {} - message.key !== undefined && (obj.key = message.key) - message.value !== undefined && - (obj.value = message.value - ? CommunityChat.toJSON(message.value) - : undefined) - return obj - }, - - fromPartial( - object: DeepPartial - ): CommunityDescription_ChatsEntry { - const message = { - ...baseCommunityDescription_ChatsEntry, - } as CommunityDescription_ChatsEntry - if (object.key !== undefined && object.key !== null) { - message.key = object.key - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = CommunityChat.fromPartial(object.value) - } else { - message.value = undefined - } - return message - }, -} - -const baseCommunityDescription_CategoriesEntry: object = { key: '' } - -export const CommunityDescription_CategoriesEntry = { - encode( - message: CommunityDescription_CategoriesEntry, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key !== '') { - writer.uint32(10).string(message.key) - } - if (message.value !== undefined) { - CommunityCategory.encode(message.value, writer.uint32(18).fork()).ldelim() - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): CommunityDescription_CategoriesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { - ...baseCommunityDescription_CategoriesEntry, - } as CommunityDescription_CategoriesEntry - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.string() - break - case 2: - message.value = CommunityCategory.decode(reader, reader.uint32()) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityDescription_CategoriesEntry { - const message = { - ...baseCommunityDescription_CategoriesEntry, - } as CommunityDescription_CategoriesEntry - if (object.key !== undefined && object.key !== null) { - message.key = String(object.key) - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = CommunityCategory.fromJSON(object.value) - } else { - message.value = undefined - } - return message - }, - - toJSON(message: CommunityDescription_CategoriesEntry): unknown { - const obj: any = {} - message.key !== undefined && (obj.key = message.key) - message.value !== undefined && - (obj.value = message.value - ? CommunityCategory.toJSON(message.value) - : undefined) - return obj - }, - - fromPartial( - object: DeepPartial - ): CommunityDescription_CategoriesEntry { - const message = { - ...baseCommunityDescription_CategoriesEntry, - } as CommunityDescription_CategoriesEntry - if (object.key !== undefined && object.key !== null) { - message.key = object.key - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = CommunityCategory.fromPartial(object.value) - } else { - message.value = undefined - } - return message - }, -} - -const baseCommunityChat: object = { categoryId: '', position: 0 } - -export const CommunityChat = { - encode( - message: CommunityChat, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - Object.entries(message.members).forEach(([key, value]) => { - CommunityChat_MembersEntry.encode( - { key: key as any, value }, - writer.uint32(10).fork() - ).ldelim() - }) - if (message.permissions !== undefined) { - CommunityPermissions.encode( - message.permissions, - writer.uint32(18).fork() - ).ldelim() - } - if (message.identity !== undefined) { - ChatIdentity.encode(message.identity, writer.uint32(26).fork()).ldelim() - } - if (message.categoryId !== '') { - writer.uint32(34).string(message.categoryId) - } - if (message.position !== 0) { - writer.uint32(40).int32(message.position) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): CommunityChat { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseCommunityChat } as CommunityChat - message.members = {} - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - const entry1 = CommunityChat_MembersEntry.decode( - reader, - reader.uint32() - ) - if (entry1.value !== undefined) { - message.members[entry1.key] = entry1.value - } - break - case 2: - message.permissions = CommunityPermissions.decode( - reader, - reader.uint32() - ) - break - case 3: - message.identity = ChatIdentity.decode(reader, reader.uint32()) - break - case 4: - message.categoryId = reader.string() - break - case 5: - message.position = reader.int32() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityChat { - const message = { ...baseCommunityChat } as CommunityChat - message.members = {} - if (object.members !== undefined && object.members !== null) { - Object.entries(object.members).forEach(([key, value]) => { - message.members[key] = CommunityMember.fromJSON(value) - }) - } - if (object.permissions !== undefined && object.permissions !== null) { - message.permissions = CommunityPermissions.fromJSON(object.permissions) - } else { - message.permissions = undefined - } - if (object.identity !== undefined && object.identity !== null) { - message.identity = ChatIdentity.fromJSON(object.identity) - } else { - message.identity = undefined - } - if (object.categoryId !== undefined && object.categoryId !== null) { - message.categoryId = String(object.categoryId) - } else { - message.categoryId = '' - } - if (object.position !== undefined && object.position !== null) { - message.position = Number(object.position) - } else { - message.position = 0 - } - return message - }, - - toJSON(message: CommunityChat): unknown { - const obj: any = {} - obj.members = {} - if (message.members) { - Object.entries(message.members).forEach(([k, v]) => { - obj.members[k] = CommunityMember.toJSON(v) - }) - } - message.permissions !== undefined && - (obj.permissions = message.permissions - ? CommunityPermissions.toJSON(message.permissions) - : undefined) - message.identity !== undefined && - (obj.identity = message.identity - ? ChatIdentity.toJSON(message.identity) - : undefined) - message.categoryId !== undefined && (obj.categoryId = message.categoryId) - message.position !== undefined && (obj.position = message.position) - return obj - }, - - fromPartial(object: DeepPartial): CommunityChat { - const message = { ...baseCommunityChat } as CommunityChat - message.members = {} - if (object.members !== undefined && object.members !== null) { - Object.entries(object.members).forEach(([key, value]) => { - if (value !== undefined) { - message.members[key] = CommunityMember.fromPartial(value) - } - }) - } - if (object.permissions !== undefined && object.permissions !== null) { - message.permissions = CommunityPermissions.fromPartial(object.permissions) - } else { - message.permissions = undefined - } - if (object.identity !== undefined && object.identity !== null) { - message.identity = ChatIdentity.fromPartial(object.identity) - } else { - message.identity = undefined - } - if (object.categoryId !== undefined && object.categoryId !== null) { - message.categoryId = object.categoryId - } else { - message.categoryId = '' - } - if (object.position !== undefined && object.position !== null) { - message.position = object.position - } else { - message.position = 0 - } - return message - }, -} - -const baseCommunityChat_MembersEntry: object = { key: '' } - -export const CommunityChat_MembersEntry = { - encode( - message: CommunityChat_MembersEntry, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key !== '') { - writer.uint32(10).string(message.key) - } - if (message.value !== undefined) { - CommunityMember.encode(message.value, writer.uint32(18).fork()).ldelim() - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): CommunityChat_MembersEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { - ...baseCommunityChat_MembersEntry, - } as CommunityChat_MembersEntry - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.string() - break - case 2: - message.value = CommunityMember.decode(reader, reader.uint32()) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityChat_MembersEntry { - const message = { - ...baseCommunityChat_MembersEntry, - } as CommunityChat_MembersEntry - if (object.key !== undefined && object.key !== null) { - message.key = String(object.key) - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = CommunityMember.fromJSON(object.value) - } else { - message.value = undefined - } - return message - }, - - toJSON(message: CommunityChat_MembersEntry): unknown { - const obj: any = {} - message.key !== undefined && (obj.key = message.key) - message.value !== undefined && - (obj.value = message.value - ? CommunityMember.toJSON(message.value) - : undefined) - return obj - }, - - fromPartial( - object: DeepPartial - ): CommunityChat_MembersEntry { - const message = { - ...baseCommunityChat_MembersEntry, - } as CommunityChat_MembersEntry - if (object.key !== undefined && object.key !== null) { - message.key = object.key - } else { - message.key = '' - } - if (object.value !== undefined && object.value !== null) { - message.value = CommunityMember.fromPartial(object.value) - } else { - message.value = undefined - } - return message - }, -} - -const baseCommunityCategory: object = { categoryId: '', name: '', position: 0 } - -export const CommunityCategory = { - encode( - message: CommunityCategory, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.categoryId !== '') { - writer.uint32(10).string(message.categoryId) - } - if (message.name !== '') { - writer.uint32(18).string(message.name) - } - if (message.position !== 0) { - writer.uint32(24).int32(message.position) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): CommunityCategory { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseCommunityCategory } as CommunityCategory - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.categoryId = reader.string() - break - case 2: - message.name = reader.string() - break - case 3: - message.position = reader.int32() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityCategory { - const message = { ...baseCommunityCategory } as CommunityCategory - if (object.categoryId !== undefined && object.categoryId !== null) { - message.categoryId = String(object.categoryId) - } else { - message.categoryId = '' - } - if (object.name !== undefined && object.name !== null) { - message.name = String(object.name) - } else { - message.name = '' - } - if (object.position !== undefined && object.position !== null) { - message.position = Number(object.position) - } else { - message.position = 0 - } - return message - }, - - toJSON(message: CommunityCategory): unknown { - const obj: any = {} - message.categoryId !== undefined && (obj.categoryId = message.categoryId) - message.name !== undefined && (obj.name = message.name) - message.position !== undefined && (obj.position = message.position) - return obj - }, - - fromPartial(object: DeepPartial): CommunityCategory { - const message = { ...baseCommunityCategory } as CommunityCategory - if (object.categoryId !== undefined && object.categoryId !== null) { - message.categoryId = object.categoryId - } else { - message.categoryId = '' - } - if (object.name !== undefined && object.name !== null) { - message.name = object.name - } else { - message.name = '' - } - if (object.position !== undefined && object.position !== null) { - message.position = object.position - } else { - message.position = 0 - } - return message - }, -} - -const baseCommunityInvitation: object = { chatId: '' } - -export const CommunityInvitation = { - encode( - message: CommunityInvitation, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.communityDescription.length !== 0) { - writer.uint32(10).bytes(message.communityDescription) - } - if (message.grant.length !== 0) { - writer.uint32(18).bytes(message.grant) - } - if (message.chatId !== '') { - writer.uint32(26).string(message.chatId) - } - if (message.publicKey.length !== 0) { - writer.uint32(34).bytes(message.publicKey) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): CommunityInvitation { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseCommunityInvitation } as CommunityInvitation - message.communityDescription = new Uint8Array() - message.grant = new Uint8Array() - message.publicKey = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.communityDescription = reader.bytes() - break - case 2: - message.grant = reader.bytes() - break - case 3: - message.chatId = reader.string() - break - case 4: - message.publicKey = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityInvitation { - const message = { ...baseCommunityInvitation } as CommunityInvitation - message.communityDescription = new Uint8Array() - message.grant = new Uint8Array() - message.publicKey = new Uint8Array() - if ( - object.communityDescription !== undefined && - object.communityDescription !== null - ) { - message.communityDescription = bytesFromBase64( - object.communityDescription - ) - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = bytesFromBase64(object.grant) - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = String(object.chatId) - } else { - message.chatId = '' - } - if (object.publicKey !== undefined && object.publicKey !== null) { - message.publicKey = bytesFromBase64(object.publicKey) - } - return message - }, - - toJSON(message: CommunityInvitation): unknown { - const obj: any = {} - message.communityDescription !== undefined && - (obj.communityDescription = base64FromBytes( - message.communityDescription !== undefined - ? message.communityDescription - : new Uint8Array() - )) - message.grant !== undefined && - (obj.grant = base64FromBytes( - message.grant !== undefined ? message.grant : new Uint8Array() - )) - message.chatId !== undefined && (obj.chatId = message.chatId) - message.publicKey !== undefined && - (obj.publicKey = base64FromBytes( - message.publicKey !== undefined ? message.publicKey : new Uint8Array() - )) - return obj - }, - - fromPartial(object: DeepPartial): CommunityInvitation { - const message = { ...baseCommunityInvitation } as CommunityInvitation - if ( - object.communityDescription !== undefined && - object.communityDescription !== null - ) { - message.communityDescription = object.communityDescription - } else { - message.communityDescription = new Uint8Array() - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = object.grant - } else { - message.grant = new Uint8Array() - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = object.chatId - } else { - message.chatId = '' - } - if (object.publicKey !== undefined && object.publicKey !== null) { - message.publicKey = object.publicKey - } else { - message.publicKey = new Uint8Array() - } - return message - }, -} - -const baseCommunityRequestToJoin: object = { - clock: 0, - ensName: '', - chatId: '', -} - -export const CommunityRequestToJoin = { - encode( - message: CommunityRequestToJoin, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - if (message.ensName !== '') { - writer.uint32(18).string(message.ensName) - } - if (message.chatId !== '') { - writer.uint32(26).string(message.chatId) - } - if (message.communityId.length !== 0) { - writer.uint32(34).bytes(message.communityId) - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): CommunityRequestToJoin { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseCommunityRequestToJoin } as CommunityRequestToJoin - message.communityId = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - message.ensName = reader.string() - break - case 3: - message.chatId = reader.string() - break - case 4: - message.communityId = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityRequestToJoin { - const message = { ...baseCommunityRequestToJoin } as CommunityRequestToJoin - message.communityId = new Uint8Array() - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.ensName !== undefined && object.ensName !== null) { - message.ensName = String(object.ensName) - } else { - message.ensName = '' - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = String(object.chatId) - } else { - message.chatId = '' - } - if (object.communityId !== undefined && object.communityId !== null) { - message.communityId = bytesFromBase64(object.communityId) - } - return message - }, - - toJSON(message: CommunityRequestToJoin): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - message.ensName !== undefined && (obj.ensName = message.ensName) - message.chatId !== undefined && (obj.chatId = message.chatId) - message.communityId !== undefined && - (obj.communityId = base64FromBytes( - message.communityId !== undefined - ? message.communityId - : new Uint8Array() - )) - return obj - }, - - fromPartial( - object: DeepPartial - ): CommunityRequestToJoin { - const message = { ...baseCommunityRequestToJoin } as CommunityRequestToJoin - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.ensName !== undefined && object.ensName !== null) { - message.ensName = object.ensName - } else { - message.ensName = '' - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = object.chatId - } else { - message.chatId = '' - } - if (object.communityId !== undefined && object.communityId !== null) { - message.communityId = object.communityId - } else { - message.communityId = new Uint8Array() - } - return message - }, -} - -const baseCommunityRequestToJoinResponse: object = { - clock: 0, - accepted: false, -} - -export const CommunityRequestToJoinResponse = { - encode( - message: CommunityRequestToJoinResponse, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - if (message.community !== undefined) { - CommunityDescription.encode( - message.community, - writer.uint32(18).fork() - ).ldelim() - } - if (message.accepted === true) { - writer.uint32(24).bool(message.accepted) - } - if (message.grant.length !== 0) { - writer.uint32(34).bytes(message.grant) - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): CommunityRequestToJoinResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { - ...baseCommunityRequestToJoinResponse, - } as CommunityRequestToJoinResponse - message.grant = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - message.community = CommunityDescription.decode( - reader, - reader.uint32() - ) - break - case 3: - message.accepted = reader.bool() - break - case 4: - message.grant = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): CommunityRequestToJoinResponse { - const message = { - ...baseCommunityRequestToJoinResponse, - } as CommunityRequestToJoinResponse - message.grant = new Uint8Array() - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.community !== undefined && object.community !== null) { - message.community = CommunityDescription.fromJSON(object.community) - } else { - message.community = undefined - } - if (object.accepted !== undefined && object.accepted !== null) { - message.accepted = Boolean(object.accepted) - } else { - message.accepted = false - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = bytesFromBase64(object.grant) - } - return message - }, - - toJSON(message: CommunityRequestToJoinResponse): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - message.community !== undefined && - (obj.community = message.community - ? CommunityDescription.toJSON(message.community) - : undefined) - message.accepted !== undefined && (obj.accepted = message.accepted) - message.grant !== undefined && - (obj.grant = base64FromBytes( - message.grant !== undefined ? message.grant : new Uint8Array() - )) - return obj - }, - - fromPartial( - object: DeepPartial - ): CommunityRequestToJoinResponse { - const message = { - ...baseCommunityRequestToJoinResponse, - } as CommunityRequestToJoinResponse - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.community !== undefined && object.community !== null) { - message.community = CommunityDescription.fromPartial(object.community) - } else { - message.community = undefined - } - if (object.accepted !== undefined && object.accepted !== null) { - message.accepted = object.accepted - } else { - message.accepted = false - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = object.grant - } else { - message.grant = new Uint8Array() - } - return message - }, -} - -declare var self: any | undefined -declare var window: any | undefined -declare var global: any | undefined -var globalThis: any = (() => { - if (typeof globalThis !== 'undefined') return globalThis - if (typeof self !== 'undefined') return self - if (typeof window !== 'undefined') return window - if (typeof global !== 'undefined') return global - throw 'Unable to locate global object' -})() - -const atob: (b64: string) => string = - globalThis.atob || - (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')) -function bytesFromBase64(b64: string): Uint8Array { - const bin = atob(b64) - const arr = new Uint8Array(bin.length) - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i) - } - return arr -} - -const btoa: (bin: string) => string = - globalThis.btoa || - (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')) -function base64FromBytes(arr: Uint8Array): string { - const bin: string[] = [] - for (const byte of arr) { - bin.push(String.fromCharCode(byte)) - } - return btoa(bin.join('')) -} - -type Builtin = - | Date - | Function - | Uint8Array - | string - | number - | boolean - | undefined -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial - -function longToNumber(long: Long): number { - if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER') - } - return long.toNumber() -} - -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any - _m0.configure() -} diff --git a/packages/status-js/src/proto/communities/v1/emoji_reaction.ts b/packages/status-js/src/proto/communities/v1/emoji_reaction.ts deleted file mode 100644 index c9014abe..00000000 --- a/packages/status-js/src/proto/communities/v1/emoji_reaction.ts +++ /dev/null @@ -1,324 +0,0 @@ -/* eslint-disable */ -import Long from 'long' -import _m0 from 'protobufjs/minimal' -import { MessageType, messageTypeFromJSON, messageTypeToJSON } from './enums' - -export const protobufPackage = 'communities.v1' - -export interface EmojiReaction { - /** clock Lamport timestamp of the chat message */ - clock: number - /** - * 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 - */ - chatId: string - /** message_id the ID of the target message that the user wishes to react to */ - messageId: string - /** message_type is (somewhat confusingly) the ID of the type of chat the message belongs to */ - messageType: MessageType - /** type the ID of the emoji the user wishes to react with */ - type: EmojiReaction_Type - /** whether this is a rectraction of a previously sent emoji */ - retracted: boolean - /** Grant for organisation chat messages */ - grant: Uint8Array -} - -export enum EmojiReaction_Type { - UNKNOWN_EMOJI_REACTION_TYPE = 0, - LOVE = 1, - THUMBS_UP = 2, - THUMBS_DOWN = 3, - LAUGH = 4, - SAD = 5, - ANGRY = 6, - UNRECOGNIZED = -1, -} - -export function emojiReaction_TypeFromJSON(object: any): EmojiReaction_Type { - switch (object) { - case 0: - case 'UNKNOWN_EMOJI_REACTION_TYPE': - return EmojiReaction_Type.UNKNOWN_EMOJI_REACTION_TYPE - case 1: - case 'LOVE': - return EmojiReaction_Type.LOVE - case 2: - case 'THUMBS_UP': - return EmojiReaction_Type.THUMBS_UP - case 3: - case 'THUMBS_DOWN': - return EmojiReaction_Type.THUMBS_DOWN - case 4: - case 'LAUGH': - return EmojiReaction_Type.LAUGH - case 5: - case 'SAD': - return EmojiReaction_Type.SAD - case 6: - case 'ANGRY': - return EmojiReaction_Type.ANGRY - case -1: - case 'UNRECOGNIZED': - default: - return EmojiReaction_Type.UNRECOGNIZED - } -} - -export function emojiReaction_TypeToJSON(object: EmojiReaction_Type): string { - switch (object) { - case EmojiReaction_Type.UNKNOWN_EMOJI_REACTION_TYPE: - return 'UNKNOWN_EMOJI_REACTION_TYPE' - case EmojiReaction_Type.LOVE: - return 'LOVE' - case EmojiReaction_Type.THUMBS_UP: - return 'THUMBS_UP' - case EmojiReaction_Type.THUMBS_DOWN: - return 'THUMBS_DOWN' - case EmojiReaction_Type.LAUGH: - return 'LAUGH' - case EmojiReaction_Type.SAD: - return 'SAD' - case EmojiReaction_Type.ANGRY: - return 'ANGRY' - default: - return 'UNKNOWN' - } -} - -const baseEmojiReaction: object = { - clock: 0, - chatId: '', - messageId: '', - messageType: 0, - type: 0, - retracted: false, -} - -export const EmojiReaction = { - encode( - message: EmojiReaction, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - if (message.chatId !== '') { - writer.uint32(18).string(message.chatId) - } - if (message.messageId !== '') { - writer.uint32(26).string(message.messageId) - } - if (message.messageType !== 0) { - writer.uint32(32).int32(message.messageType) - } - if (message.type !== 0) { - writer.uint32(40).int32(message.type) - } - if (message.retracted === true) { - writer.uint32(48).bool(message.retracted) - } - if (message.grant.length !== 0) { - writer.uint32(58).bytes(message.grant) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): EmojiReaction { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseEmojiReaction } as EmojiReaction - message.grant = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - message.chatId = reader.string() - break - case 3: - message.messageId = reader.string() - break - case 4: - message.messageType = reader.int32() as any - break - case 5: - message.type = reader.int32() as any - break - case 6: - message.retracted = reader.bool() - break - case 7: - message.grant = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): EmojiReaction { - const message = { ...baseEmojiReaction } as EmojiReaction - message.grant = new Uint8Array() - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = String(object.chatId) - } else { - message.chatId = '' - } - if (object.messageId !== undefined && object.messageId !== null) { - message.messageId = String(object.messageId) - } else { - message.messageId = '' - } - if (object.messageType !== undefined && object.messageType !== null) { - message.messageType = messageTypeFromJSON(object.messageType) - } else { - message.messageType = 0 - } - if (object.type !== undefined && object.type !== null) { - message.type = emojiReaction_TypeFromJSON(object.type) - } else { - message.type = 0 - } - if (object.retracted !== undefined && object.retracted !== null) { - message.retracted = Boolean(object.retracted) - } else { - message.retracted = false - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = bytesFromBase64(object.grant) - } - return message - }, - - toJSON(message: EmojiReaction): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - message.chatId !== undefined && (obj.chatId = message.chatId) - message.messageId !== undefined && (obj.messageId = message.messageId) - message.messageType !== undefined && - (obj.messageType = messageTypeToJSON(message.messageType)) - message.type !== undefined && - (obj.type = emojiReaction_TypeToJSON(message.type)) - message.retracted !== undefined && (obj.retracted = message.retracted) - message.grant !== undefined && - (obj.grant = base64FromBytes( - message.grant !== undefined ? message.grant : new Uint8Array() - )) - return obj - }, - - fromPartial(object: DeepPartial): EmojiReaction { - const message = { ...baseEmojiReaction } as EmojiReaction - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = object.chatId - } else { - message.chatId = '' - } - if (object.messageId !== undefined && object.messageId !== null) { - message.messageId = object.messageId - } else { - message.messageId = '' - } - if (object.messageType !== undefined && object.messageType !== null) { - message.messageType = object.messageType - } else { - message.messageType = 0 - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type - } else { - message.type = 0 - } - if (object.retracted !== undefined && object.retracted !== null) { - message.retracted = object.retracted - } else { - message.retracted = false - } - if (object.grant !== undefined && object.grant !== null) { - message.grant = object.grant - } else { - message.grant = new Uint8Array() - } - return message - }, -} - -declare var self: any | undefined -declare var window: any | undefined -declare var global: any | undefined -var globalThis: any = (() => { - if (typeof globalThis !== 'undefined') return globalThis - if (typeof self !== 'undefined') return self - if (typeof window !== 'undefined') return window - if (typeof global !== 'undefined') return global - throw 'Unable to locate global object' -})() - -const atob: (b64: string) => string = - globalThis.atob || - (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')) -function bytesFromBase64(b64: string): Uint8Array { - const bin = atob(b64) - const arr = new Uint8Array(bin.length) - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i) - } - return arr -} - -const btoa: (bin: string) => string = - globalThis.btoa || - (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')) -function base64FromBytes(arr: Uint8Array): string { - const bin: string[] = [] - for (const byte of arr) { - bin.push(String.fromCharCode(byte)) - } - return btoa(bin.join('')) -} - -type Builtin = - | Date - | Function - | Uint8Array - | string - | number - | boolean - | undefined -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial - -function longToNumber(long: Long): number { - if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER') - } - return long.toNumber() -} - -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any - _m0.configure() -} diff --git a/packages/status-js/src/proto/communities/v1/enums.ts b/packages/status-js/src/proto/communities/v1/enums.ts deleted file mode 100644 index 229cb9c9..00000000 --- a/packages/status-js/src/proto/communities/v1/enums.ts +++ /dev/null @@ -1,125 +0,0 @@ -/* eslint-disable */ -import Long from 'long' -import _m0 from 'protobufjs/minimal' - -export const protobufPackage = 'communities.v1' - -export enum MessageType { - MESSAGE_TYPE_UNKNOWN_UNSPECIFIED = 0, - MESSAGE_TYPE_ONE_TO_ONE = 1, - MESSAGE_TYPE_MESSAGE_TYPE_PUBLIC_GROUP = 2, - MESSAGE_TYPE_PRIVATE_GROUP = 3, - /** MESSAGE_TYPE_SYSTEM_MESSAGE_PRIVATE_GROUP - Only local */ - MESSAGE_TYPE_SYSTEM_MESSAGE_PRIVATE_GROUP = 4, - MESSAGE_TYPE_COMMUNITY_CHAT = 5, - /** MESSAGE_TYPE_SYSTEM_MESSAGE_GAP - Only local */ - MESSAGE_TYPE_SYSTEM_MESSAGE_GAP = 6, - UNRECOGNIZED = -1, -} - -export function messageTypeFromJSON(object: any): MessageType { - switch (object) { - case 0: - case 'MESSAGE_TYPE_UNKNOWN_UNSPECIFIED': - return MessageType.MESSAGE_TYPE_UNKNOWN_UNSPECIFIED - case 1: - case 'MESSAGE_TYPE_ONE_TO_ONE': - return MessageType.MESSAGE_TYPE_ONE_TO_ONE - case 2: - case 'MESSAGE_TYPE_MESSAGE_TYPE_PUBLIC_GROUP': - return MessageType.MESSAGE_TYPE_MESSAGE_TYPE_PUBLIC_GROUP - case 3: - case 'MESSAGE_TYPE_PRIVATE_GROUP': - return MessageType.MESSAGE_TYPE_PRIVATE_GROUP - case 4: - case 'MESSAGE_TYPE_SYSTEM_MESSAGE_PRIVATE_GROUP': - return MessageType.MESSAGE_TYPE_SYSTEM_MESSAGE_PRIVATE_GROUP - case 5: - case 'MESSAGE_TYPE_COMMUNITY_CHAT': - return MessageType.MESSAGE_TYPE_COMMUNITY_CHAT - case 6: - case 'MESSAGE_TYPE_SYSTEM_MESSAGE_GAP': - return MessageType.MESSAGE_TYPE_SYSTEM_MESSAGE_GAP - case -1: - case 'UNRECOGNIZED': - default: - return MessageType.UNRECOGNIZED - } -} - -export function messageTypeToJSON(object: MessageType): string { - switch (object) { - case MessageType.MESSAGE_TYPE_UNKNOWN_UNSPECIFIED: - return 'MESSAGE_TYPE_UNKNOWN_UNSPECIFIED' - case MessageType.MESSAGE_TYPE_ONE_TO_ONE: - return 'MESSAGE_TYPE_ONE_TO_ONE' - case MessageType.MESSAGE_TYPE_MESSAGE_TYPE_PUBLIC_GROUP: - return 'MESSAGE_TYPE_MESSAGE_TYPE_PUBLIC_GROUP' - case MessageType.MESSAGE_TYPE_PRIVATE_GROUP: - return 'MESSAGE_TYPE_PRIVATE_GROUP' - case MessageType.MESSAGE_TYPE_SYSTEM_MESSAGE_PRIVATE_GROUP: - return 'MESSAGE_TYPE_SYSTEM_MESSAGE_PRIVATE_GROUP' - case MessageType.MESSAGE_TYPE_COMMUNITY_CHAT: - return 'MESSAGE_TYPE_COMMUNITY_CHAT' - case MessageType.MESSAGE_TYPE_SYSTEM_MESSAGE_GAP: - return 'MESSAGE_TYPE_SYSTEM_MESSAGE_GAP' - default: - return 'UNKNOWN' - } -} - -export enum ImageType { - IMAGE_TYPE_UNKNOWN_UNSPECIFIED = 0, - /** IMAGE_TYPE_PNG - Raster image files is payload data that can be read as a raster image */ - IMAGE_TYPE_PNG = 1, - IMAGE_TYPE_JPEG = 2, - IMAGE_TYPE_WEBP = 3, - IMAGE_TYPE_GIF = 4, - UNRECOGNIZED = -1, -} - -export function imageTypeFromJSON(object: any): ImageType { - switch (object) { - case 0: - case 'IMAGE_TYPE_UNKNOWN_UNSPECIFIED': - return ImageType.IMAGE_TYPE_UNKNOWN_UNSPECIFIED - case 1: - case 'IMAGE_TYPE_PNG': - return ImageType.IMAGE_TYPE_PNG - case 2: - case 'IMAGE_TYPE_JPEG': - return ImageType.IMAGE_TYPE_JPEG - case 3: - case 'IMAGE_TYPE_WEBP': - return ImageType.IMAGE_TYPE_WEBP - case 4: - case 'IMAGE_TYPE_GIF': - return ImageType.IMAGE_TYPE_GIF - case -1: - case 'UNRECOGNIZED': - default: - return ImageType.UNRECOGNIZED - } -} - -export function imageTypeToJSON(object: ImageType): string { - switch (object) { - case ImageType.IMAGE_TYPE_UNKNOWN_UNSPECIFIED: - return 'IMAGE_TYPE_UNKNOWN_UNSPECIFIED' - case ImageType.IMAGE_TYPE_PNG: - return 'IMAGE_TYPE_PNG' - case ImageType.IMAGE_TYPE_JPEG: - return 'IMAGE_TYPE_JPEG' - case ImageType.IMAGE_TYPE_WEBP: - return 'IMAGE_TYPE_WEBP' - case ImageType.IMAGE_TYPE_GIF: - return 'IMAGE_TYPE_GIF' - default: - return 'UNKNOWN' - } -} - -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any - _m0.configure() -} diff --git a/packages/status-js/src/proto/communities/v1/membership_update_message.ts b/packages/status-js/src/proto/communities/v1/membership_update_message.ts deleted file mode 100644 index 3480f1e4..00000000 --- a/packages/status-js/src/proto/communities/v1/membership_update_message.ts +++ /dev/null @@ -1,436 +0,0 @@ -/* eslint-disable */ -import Long from 'long' -import _m0 from 'protobufjs/minimal' -import { ChatMessage } from './chat_message' -import { EmojiReaction } from './emoji_reaction' - -export const protobufPackage = 'communities.v1' - -export interface MembershipUpdateEvent { - /** Lamport timestamp of the event */ - clock: number - /** List of public keys of objects of the action */ - members: string[] - /** Name of the chat for the CHAT_CREATED/NAME_CHANGED event types */ - name: string - /** The type of the event */ - type: MembershipUpdateEvent_EventType -} - -export enum MembershipUpdateEvent_EventType { - UNKNOWN = 0, - CHAT_CREATED = 1, - NAME_CHANGED = 2, - MEMBERS_ADDED = 3, - MEMBER_JOINED = 4, - MEMBER_REMOVED = 5, - ADMINS_ADDED = 6, - ADMIN_REMOVED = 7, - UNRECOGNIZED = -1, -} - -export function membershipUpdateEvent_EventTypeFromJSON( - object: any -): MembershipUpdateEvent_EventType { - switch (object) { - case 0: - case 'UNKNOWN': - return MembershipUpdateEvent_EventType.UNKNOWN - case 1: - case 'CHAT_CREATED': - return MembershipUpdateEvent_EventType.CHAT_CREATED - case 2: - case 'NAME_CHANGED': - return MembershipUpdateEvent_EventType.NAME_CHANGED - case 3: - case 'MEMBERS_ADDED': - return MembershipUpdateEvent_EventType.MEMBERS_ADDED - case 4: - case 'MEMBER_JOINED': - return MembershipUpdateEvent_EventType.MEMBER_JOINED - case 5: - case 'MEMBER_REMOVED': - return MembershipUpdateEvent_EventType.MEMBER_REMOVED - case 6: - case 'ADMINS_ADDED': - return MembershipUpdateEvent_EventType.ADMINS_ADDED - case 7: - case 'ADMIN_REMOVED': - return MembershipUpdateEvent_EventType.ADMIN_REMOVED - case -1: - case 'UNRECOGNIZED': - default: - return MembershipUpdateEvent_EventType.UNRECOGNIZED - } -} - -export function membershipUpdateEvent_EventTypeToJSON( - object: MembershipUpdateEvent_EventType -): string { - switch (object) { - case MembershipUpdateEvent_EventType.UNKNOWN: - return 'UNKNOWN' - case MembershipUpdateEvent_EventType.CHAT_CREATED: - return 'CHAT_CREATED' - case MembershipUpdateEvent_EventType.NAME_CHANGED: - return 'NAME_CHANGED' - case MembershipUpdateEvent_EventType.MEMBERS_ADDED: - return 'MEMBERS_ADDED' - case MembershipUpdateEvent_EventType.MEMBER_JOINED: - return 'MEMBER_JOINED' - case MembershipUpdateEvent_EventType.MEMBER_REMOVED: - return 'MEMBER_REMOVED' - case MembershipUpdateEvent_EventType.ADMINS_ADDED: - return 'ADMINS_ADDED' - case MembershipUpdateEvent_EventType.ADMIN_REMOVED: - return 'ADMIN_REMOVED' - default: - return 'UNKNOWN' - } -} - -/** - * 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. - */ -export interface MembershipUpdateMessage { - /** The chat id of the private group chat */ - chatId: string - /** - * A list of events for this group chat, first x bytes are the signature, then is a - * protobuf encoded MembershipUpdateEvent - */ - events: Uint8Array[] - message: ChatMessage | undefined - emojiReaction: EmojiReaction | undefined -} - -const baseMembershipUpdateEvent: object = { - clock: 0, - members: '', - name: '', - type: 0, -} - -export const MembershipUpdateEvent = { - encode( - message: MembershipUpdateEvent, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.clock !== 0) { - writer.uint32(8).uint64(message.clock) - } - for (const v of message.members) { - writer.uint32(18).string(v!) - } - if (message.name !== '') { - writer.uint32(26).string(message.name) - } - if (message.type !== 0) { - writer.uint32(32).int32(message.type) - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): MembershipUpdateEvent { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { ...baseMembershipUpdateEvent } as MembershipUpdateEvent - message.members = [] - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.clock = longToNumber(reader.uint64() as Long) - break - case 2: - message.members.push(reader.string()) - break - case 3: - message.name = reader.string() - break - case 4: - message.type = reader.int32() as any - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): MembershipUpdateEvent { - const message = { ...baseMembershipUpdateEvent } as MembershipUpdateEvent - message.members = [] - if (object.clock !== undefined && object.clock !== null) { - message.clock = Number(object.clock) - } else { - message.clock = 0 - } - if (object.members !== undefined && object.members !== null) { - for (const e of object.members) { - message.members.push(String(e)) - } - } - if (object.name !== undefined && object.name !== null) { - message.name = String(object.name) - } else { - message.name = '' - } - if (object.type !== undefined && object.type !== null) { - message.type = membershipUpdateEvent_EventTypeFromJSON(object.type) - } else { - message.type = 0 - } - return message - }, - - toJSON(message: MembershipUpdateEvent): unknown { - const obj: any = {} - message.clock !== undefined && (obj.clock = message.clock) - if (message.members) { - obj.members = message.members.map(e => e) - } else { - obj.members = [] - } - message.name !== undefined && (obj.name = message.name) - message.type !== undefined && - (obj.type = membershipUpdateEvent_EventTypeToJSON(message.type)) - return obj - }, - - fromPartial( - object: DeepPartial - ): MembershipUpdateEvent { - const message = { ...baseMembershipUpdateEvent } as MembershipUpdateEvent - message.members = [] - if (object.clock !== undefined && object.clock !== null) { - message.clock = object.clock - } else { - message.clock = 0 - } - if (object.members !== undefined && object.members !== null) { - for (const e of object.members) { - message.members.push(e) - } - } - if (object.name !== undefined && object.name !== null) { - message.name = object.name - } else { - message.name = '' - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type - } else { - message.type = 0 - } - return message - }, -} - -const baseMembershipUpdateMessage: object = { chatId: '' } - -export const MembershipUpdateMessage = { - encode( - message: MembershipUpdateMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.chatId !== '') { - writer.uint32(10).string(message.chatId) - } - for (const v of message.events) { - writer.uint32(18).bytes(v!) - } - if (message.message !== undefined) { - ChatMessage.encode(message.message, writer.uint32(26).fork()).ldelim() - } - if (message.emojiReaction !== undefined) { - EmojiReaction.encode( - message.emojiReaction, - writer.uint32(34).fork() - ).ldelim() - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): MembershipUpdateMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { - ...baseMembershipUpdateMessage, - } as MembershipUpdateMessage - message.events = [] - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.chatId = reader.string() - break - case 2: - message.events.push(reader.bytes()) - break - case 3: - message.message = ChatMessage.decode(reader, reader.uint32()) - break - case 4: - message.emojiReaction = EmojiReaction.decode(reader, reader.uint32()) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): MembershipUpdateMessage { - const message = { - ...baseMembershipUpdateMessage, - } as MembershipUpdateMessage - message.events = [] - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = String(object.chatId) - } else { - message.chatId = '' - } - if (object.events !== undefined && object.events !== null) { - for (const e of object.events) { - message.events.push(bytesFromBase64(e)) - } - } - if (object.message !== undefined && object.message !== null) { - message.message = ChatMessage.fromJSON(object.message) - } else { - message.message = undefined - } - if (object.emojiReaction !== undefined && object.emojiReaction !== null) { - message.emojiReaction = EmojiReaction.fromJSON(object.emojiReaction) - } else { - message.emojiReaction = undefined - } - return message - }, - - toJSON(message: MembershipUpdateMessage): unknown { - const obj: any = {} - message.chatId !== undefined && (obj.chatId = message.chatId) - if (message.events) { - obj.events = message.events.map(e => - base64FromBytes(e !== undefined ? e : new Uint8Array()) - ) - } else { - obj.events = [] - } - message.message !== undefined && - (obj.message = message.message - ? ChatMessage.toJSON(message.message) - : undefined) - message.emojiReaction !== undefined && - (obj.emojiReaction = message.emojiReaction - ? EmojiReaction.toJSON(message.emojiReaction) - : undefined) - return obj - }, - - fromPartial( - object: DeepPartial - ): MembershipUpdateMessage { - const message = { - ...baseMembershipUpdateMessage, - } as MembershipUpdateMessage - message.events = [] - if (object.chatId !== undefined && object.chatId !== null) { - message.chatId = object.chatId - } else { - message.chatId = '' - } - if (object.events !== undefined && object.events !== null) { - for (const e of object.events) { - message.events.push(e) - } - } - if (object.message !== undefined && object.message !== null) { - message.message = ChatMessage.fromPartial(object.message) - } else { - message.message = undefined - } - if (object.emojiReaction !== undefined && object.emojiReaction !== null) { - message.emojiReaction = EmojiReaction.fromPartial(object.emojiReaction) - } else { - message.emojiReaction = undefined - } - return message - }, -} - -declare var self: any | undefined -declare var window: any | undefined -declare var global: any | undefined -var globalThis: any = (() => { - if (typeof globalThis !== 'undefined') return globalThis - if (typeof self !== 'undefined') return self - if (typeof window !== 'undefined') return window - if (typeof global !== 'undefined') return global - throw 'Unable to locate global object' -})() - -const atob: (b64: string) => string = - globalThis.atob || - (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')) -function bytesFromBase64(b64: string): Uint8Array { - const bin = atob(b64) - const arr = new Uint8Array(bin.length) - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i) - } - return arr -} - -const btoa: (bin: string) => string = - globalThis.btoa || - (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')) -function base64FromBytes(arr: Uint8Array): string { - const bin: string[] = [] - for (const byte of arr) { - bin.push(String.fromCharCode(byte)) - } - return btoa(bin.join('')) -} - -type Builtin = - | Date - | Function - | Uint8Array - | string - | number - | boolean - | undefined -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial - -function longToNumber(long: Long): number { - if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER') - } - return long.toNumber() -} - -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any - _m0.configure() -} diff --git a/packages/status-js/src/proto/status/v1/application_metadata_message.ts b/packages/status-js/src/proto/status/v1/application_metadata_message.ts deleted file mode 100644 index 15bfb831..00000000 --- a/packages/status-js/src/proto/status/v1/application_metadata_message.ts +++ /dev/null @@ -1,409 +0,0 @@ -/* eslint-disable */ -import Long from 'long' -import _m0 from 'protobufjs/minimal' - -export const protobufPackage = 'status.v1' - -export interface ApplicationMetadataMessage { - /** Signature of the payload field */ - signature: Uint8Array - /** This is the encoded protobuf of the application level message, i.e ChatMessage */ - payload: Uint8Array - /** The type of protobuf message sent */ - type: ApplicationMetadataMessage_Type -} - -export enum ApplicationMetadataMessage_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, - UNRECOGNIZED = -1, -} - -export function applicationMetadataMessage_TypeFromJSON( - object: any -): ApplicationMetadataMessage_Type { - switch (object) { - case 0: - case 'TYPE_UNKNOWN_UNSPECIFIED': - return ApplicationMetadataMessage_Type.TYPE_UNKNOWN_UNSPECIFIED - case 1: - case 'TYPE_CHAT_MESSAGE': - return ApplicationMetadataMessage_Type.TYPE_CHAT_MESSAGE - case 2: - case 'TYPE_CONTACT_UPDATE': - return ApplicationMetadataMessage_Type.TYPE_CONTACT_UPDATE - case 3: - case 'TYPE_MEMBERSHIP_UPDATE_MESSAGE': - return ApplicationMetadataMessage_Type.TYPE_MEMBERSHIP_UPDATE_MESSAGE - case 4: - case 'TYPE_PAIR_INSTALLATION': - return ApplicationMetadataMessage_Type.TYPE_PAIR_INSTALLATION - case 5: - case 'TYPE_SYNC_INSTALLATION': - return ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION - case 6: - case 'TYPE_REQUEST_ADDRESS_FOR_TRANSACTION': - return ApplicationMetadataMessage_Type.TYPE_REQUEST_ADDRESS_FOR_TRANSACTION - case 7: - case 'TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION': - return ApplicationMetadataMessage_Type.TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION - case 8: - case 'TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION': - return ApplicationMetadataMessage_Type.TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION - case 9: - case 'TYPE_REQUEST_TRANSACTION': - return ApplicationMetadataMessage_Type.TYPE_REQUEST_TRANSACTION - case 10: - case 'TYPE_SEND_TRANSACTION': - return ApplicationMetadataMessage_Type.TYPE_SEND_TRANSACTION - case 11: - case 'TYPE_DECLINE_REQUEST_TRANSACTION': - return ApplicationMetadataMessage_Type.TYPE_DECLINE_REQUEST_TRANSACTION - case 12: - case 'TYPE_SYNC_INSTALLATION_CONTACT': - return ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION_CONTACT - case 13: - case 'TYPE_SYNC_INSTALLATION_ACCOUNT': - return ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION_ACCOUNT - case 14: - case 'TYPE_SYNC_INSTALLATION_PUBLIC_CHAT': - return ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION_PUBLIC_CHAT - case 15: - case 'TYPE_CONTACT_CODE_ADVERTISEMENT': - return ApplicationMetadataMessage_Type.TYPE_CONTACT_CODE_ADVERTISEMENT - case 16: - case 'TYPE_PUSH_NOTIFICATION_REGISTRATION': - return ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_REGISTRATION - case 17: - case 'TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE': - return ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE - case 18: - case 'TYPE_PUSH_NOTIFICATION_QUERY': - return ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_QUERY - case 19: - case 'TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE': - return ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE - case 20: - case 'TYPE_PUSH_NOTIFICATION_REQUEST': - return ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_REQUEST - case 21: - case 'TYPE_PUSH_NOTIFICATION_RESPONSE': - return ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_RESPONSE - case 22: - case 'TYPE_EMOJI_REACTION': - return ApplicationMetadataMessage_Type.TYPE_EMOJI_REACTION - case 23: - case 'TYPE_GROUP_CHAT_INVITATION': - return ApplicationMetadataMessage_Type.TYPE_GROUP_CHAT_INVITATION - case 24: - case 'TYPE_CHAT_IDENTITY': - return ApplicationMetadataMessage_Type.TYPE_CHAT_IDENTITY - case 25: - case 'TYPE_COMMUNITY_DESCRIPTION': - return ApplicationMetadataMessage_Type.TYPE_COMMUNITY_DESCRIPTION - case 26: - case 'TYPE_COMMUNITY_INVITATION': - return ApplicationMetadataMessage_Type.TYPE_COMMUNITY_INVITATION - case 27: - case 'TYPE_COMMUNITY_REQUEST_TO_JOIN': - return ApplicationMetadataMessage_Type.TYPE_COMMUNITY_REQUEST_TO_JOIN - case 28: - case 'TYPE_PIN_MESSAGE': - return ApplicationMetadataMessage_Type.TYPE_PIN_MESSAGE - case 29: - case 'TYPE_EDIT_MESSAGE': - return ApplicationMetadataMessage_Type.TYPE_EDIT_MESSAGE - case 30: - case 'TYPE_STATUS_UPDATE': - return ApplicationMetadataMessage_Type.TYPE_STATUS_UPDATE - case 31: - case 'TYPE_DELETE_MESSAGE': - return ApplicationMetadataMessage_Type.TYPE_DELETE_MESSAGE - case 32: - case 'TYPE_SYNC_INSTALLATION_COMMUNITY': - return ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION_COMMUNITY - case 33: - case 'TYPE_ANONYMOUS_METRIC_BATCH': - return ApplicationMetadataMessage_Type.TYPE_ANONYMOUS_METRIC_BATCH - case -1: - case 'UNRECOGNIZED': - default: - return ApplicationMetadataMessage_Type.UNRECOGNIZED - } -} - -export function applicationMetadataMessage_TypeToJSON( - object: ApplicationMetadataMessage_Type -): string { - switch (object) { - case ApplicationMetadataMessage_Type.TYPE_UNKNOWN_UNSPECIFIED: - return 'TYPE_UNKNOWN_UNSPECIFIED' - case ApplicationMetadataMessage_Type.TYPE_CHAT_MESSAGE: - return 'TYPE_CHAT_MESSAGE' - case ApplicationMetadataMessage_Type.TYPE_CONTACT_UPDATE: - return 'TYPE_CONTACT_UPDATE' - case ApplicationMetadataMessage_Type.TYPE_MEMBERSHIP_UPDATE_MESSAGE: - return 'TYPE_MEMBERSHIP_UPDATE_MESSAGE' - case ApplicationMetadataMessage_Type.TYPE_PAIR_INSTALLATION: - return 'TYPE_PAIR_INSTALLATION' - case ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION: - return 'TYPE_SYNC_INSTALLATION' - case ApplicationMetadataMessage_Type.TYPE_REQUEST_ADDRESS_FOR_TRANSACTION: - return 'TYPE_REQUEST_ADDRESS_FOR_TRANSACTION' - case ApplicationMetadataMessage_Type.TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION: - return 'TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION' - case ApplicationMetadataMessage_Type.TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION: - return 'TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION' - case ApplicationMetadataMessage_Type.TYPE_REQUEST_TRANSACTION: - return 'TYPE_REQUEST_TRANSACTION' - case ApplicationMetadataMessage_Type.TYPE_SEND_TRANSACTION: - return 'TYPE_SEND_TRANSACTION' - case ApplicationMetadataMessage_Type.TYPE_DECLINE_REQUEST_TRANSACTION: - return 'TYPE_DECLINE_REQUEST_TRANSACTION' - case ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION_CONTACT: - return 'TYPE_SYNC_INSTALLATION_CONTACT' - case ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION_ACCOUNT: - return 'TYPE_SYNC_INSTALLATION_ACCOUNT' - case ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION_PUBLIC_CHAT: - return 'TYPE_SYNC_INSTALLATION_PUBLIC_CHAT' - case ApplicationMetadataMessage_Type.TYPE_CONTACT_CODE_ADVERTISEMENT: - return 'TYPE_CONTACT_CODE_ADVERTISEMENT' - case ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_REGISTRATION: - return 'TYPE_PUSH_NOTIFICATION_REGISTRATION' - case ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE: - return 'TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE' - case ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_QUERY: - return 'TYPE_PUSH_NOTIFICATION_QUERY' - case ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE: - return 'TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE' - case ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_REQUEST: - return 'TYPE_PUSH_NOTIFICATION_REQUEST' - case ApplicationMetadataMessage_Type.TYPE_PUSH_NOTIFICATION_RESPONSE: - return 'TYPE_PUSH_NOTIFICATION_RESPONSE' - case ApplicationMetadataMessage_Type.TYPE_EMOJI_REACTION: - return 'TYPE_EMOJI_REACTION' - case ApplicationMetadataMessage_Type.TYPE_GROUP_CHAT_INVITATION: - return 'TYPE_GROUP_CHAT_INVITATION' - case ApplicationMetadataMessage_Type.TYPE_CHAT_IDENTITY: - return 'TYPE_CHAT_IDENTITY' - case ApplicationMetadataMessage_Type.TYPE_COMMUNITY_DESCRIPTION: - return 'TYPE_COMMUNITY_DESCRIPTION' - case ApplicationMetadataMessage_Type.TYPE_COMMUNITY_INVITATION: - return 'TYPE_COMMUNITY_INVITATION' - case ApplicationMetadataMessage_Type.TYPE_COMMUNITY_REQUEST_TO_JOIN: - return 'TYPE_COMMUNITY_REQUEST_TO_JOIN' - case ApplicationMetadataMessage_Type.TYPE_PIN_MESSAGE: - return 'TYPE_PIN_MESSAGE' - case ApplicationMetadataMessage_Type.TYPE_EDIT_MESSAGE: - return 'TYPE_EDIT_MESSAGE' - case ApplicationMetadataMessage_Type.TYPE_STATUS_UPDATE: - return 'TYPE_STATUS_UPDATE' - case ApplicationMetadataMessage_Type.TYPE_DELETE_MESSAGE: - return 'TYPE_DELETE_MESSAGE' - case ApplicationMetadataMessage_Type.TYPE_SYNC_INSTALLATION_COMMUNITY: - return 'TYPE_SYNC_INSTALLATION_COMMUNITY' - case ApplicationMetadataMessage_Type.TYPE_ANONYMOUS_METRIC_BATCH: - return 'TYPE_ANONYMOUS_METRIC_BATCH' - default: - return 'UNKNOWN' - } -} - -const baseApplicationMetadataMessage: object = { type: 0 } - -export const ApplicationMetadataMessage = { - encode( - message: ApplicationMetadataMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.signature.length !== 0) { - writer.uint32(10).bytes(message.signature) - } - if (message.payload.length !== 0) { - writer.uint32(18).bytes(message.payload) - } - if (message.type !== 0) { - writer.uint32(24).int32(message.type) - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): ApplicationMetadataMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = { - ...baseApplicationMetadataMessage, - } as ApplicationMetadataMessage - message.signature = new Uint8Array() - message.payload = new Uint8Array() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.signature = reader.bytes() - break - case 2: - message.payload = reader.bytes() - break - case 3: - message.type = reader.int32() as any - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): ApplicationMetadataMessage { - const message = { - ...baseApplicationMetadataMessage, - } as ApplicationMetadataMessage - message.signature = new Uint8Array() - message.payload = new Uint8Array() - if (object.signature !== undefined && object.signature !== null) { - message.signature = bytesFromBase64(object.signature) - } - if (object.payload !== undefined && object.payload !== null) { - message.payload = bytesFromBase64(object.payload) - } - if (object.type !== undefined && object.type !== null) { - message.type = applicationMetadataMessage_TypeFromJSON(object.type) - } else { - message.type = 0 - } - return message - }, - - toJSON(message: ApplicationMetadataMessage): unknown { - const obj: any = {} - message.signature !== undefined && - (obj.signature = base64FromBytes( - message.signature !== undefined ? message.signature : new Uint8Array() - )) - message.payload !== undefined && - (obj.payload = base64FromBytes( - message.payload !== undefined ? message.payload : new Uint8Array() - )) - message.type !== undefined && - (obj.type = applicationMetadataMessage_TypeToJSON(message.type)) - return obj - }, - - fromPartial( - object: DeepPartial - ): ApplicationMetadataMessage { - const message = { - ...baseApplicationMetadataMessage, - } as ApplicationMetadataMessage - if (object.signature !== undefined && object.signature !== null) { - message.signature = object.signature - } else { - message.signature = new Uint8Array() - } - if (object.payload !== undefined && object.payload !== null) { - message.payload = object.payload - } else { - message.payload = new Uint8Array() - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type - } else { - message.type = 0 - } - return message - }, -} - -declare var self: any | undefined -declare var window: any | undefined -declare var global: any | undefined -var globalThis: any = (() => { - if (typeof globalThis !== 'undefined') return globalThis - if (typeof self !== 'undefined') return self - if (typeof window !== 'undefined') return window - if (typeof global !== 'undefined') return global - throw 'Unable to locate global object' -})() - -const atob: (b64: string) => string = - globalThis.atob || - (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')) -function bytesFromBase64(b64: string): Uint8Array { - const bin = atob(b64) - const arr = new Uint8Array(bin.length) - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i) - } - return arr -} - -const btoa: (bin: string) => string = - globalThis.btoa || - (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')) -function base64FromBytes(arr: Uint8Array): string { - const bin: string[] = [] - for (const byte of arr) { - bin.push(String.fromCharCode(byte)) - } - return btoa(bin.join('')) -} - -type Builtin = - | Date - | Function - | Uint8Array - | string - | number - | boolean - | undefined -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial - -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any - _m0.configure() -} diff --git a/packages/status-js/src/proto/status/v1/protocol_message.ts b/packages/status-js/src/proto/status/v1/protocol_message.ts deleted file mode 100644 index a6d0c905..00000000 --- a/packages/status-js/src/proto/status/v1/protocol_message.ts +++ /dev/null @@ -1,1160 +0,0 @@ -/* eslint-disable */ -import Long from 'long' -import * as _m0 from 'protobufjs/minimal' - -export const protobufPackage = '' - -export interface SignedPreKey { - signedPreKey: Uint8Array - version: number - protocolVersion: number -} - -/** X3DH prekey bundle */ -export interface Bundle { - /** Identity key */ - identity: Uint8Array - /** Installation id */ - signedPreKeys: { [key: string]: SignedPreKey } - /** Prekey signature */ - signature: Uint8Array - /** When the bundle was created locally */ - timestamp: number -} - -export interface Bundle_SignedPreKeysEntry { - key: string - value: SignedPreKey | undefined -} - -export interface BundleContainer { - /** X3DH prekey bundle */ - bundle: Bundle | undefined - /** Private signed prekey */ - privateSignedPreKey: Uint8Array -} - -export interface DRHeader { - /** Current ratchet public key */ - key: Uint8Array - /** Number of the message in the sending chain */ - n: number - /** Length of the previous sending chain */ - pn: number - /** Bundle ID */ - id: Uint8Array -} - -export interface DHHeader { - /** Compressed ephemeral public key */ - key: Uint8Array -} - -export interface X3DHHeader { - /** Ephemeral key used */ - key: Uint8Array - /** Used bundle's signed prekey */ - id: Uint8Array -} - -/** Hash Ratchet Header */ -export interface HRHeader { - /** community key ID */ - keyId: number - /** Community message number for this key_id */ - seqNo: number - /** Community ID */ - groupId: string -} - -/** Direct message value */ -export interface EncryptedMessageProtocol { - x3dhHeader: X3DHHeader | undefined - drHeader: DRHeader | undefined - dhHeader: DHHeader | undefined - hrHeader: HRHeader | undefined - /** Encrypted payload */ - payload: Uint8Array -} - -/** Top-level protocol message */ -export interface ProtocolMessage { - /** The device id of the sender */ - installationId: string - /** List of bundles */ - bundles: Bundle[] - /** - * One to one message, encrypted, indexed by installation_id - * TODO map here is redundant in case of community messages - */ - encryptedMessage: { [key: string]: EncryptedMessageProtocol } - /** Public chats, not encrypted */ - publicMessage: Uint8Array -} - -export interface ProtocolMessage_EncryptedMessageEntry { - key: string - value: EncryptedMessageProtocol | undefined -} - -function createBaseSignedPreKey(): SignedPreKey { - return { signedPreKey: new Uint8Array(), version: 0, protocolVersion: 0 } -} - -export const SignedPreKey = { - encode( - message: SignedPreKey, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.signedPreKey.length !== 0) { - writer.uint32(10).bytes(message.signedPreKey) - } - if (message.version !== 0) { - writer.uint32(16).uint32(message.version) - } - if (message.protocolVersion !== 0) { - writer.uint32(24).uint32(message.protocolVersion) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SignedPreKey { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseSignedPreKey() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.signedPreKey = reader.bytes() - break - case 2: - message.version = reader.uint32() - break - case 3: - message.protocolVersion = reader.uint32() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): SignedPreKey { - return { - signedPreKey: isSet(object.signedPreKey) - ? bytesFromBase64(object.signedPreKey) - : new Uint8Array(), - version: isSet(object.version) ? Number(object.version) : 0, - protocolVersion: isSet(object.protocolVersion) - ? Number(object.protocolVersion) - : 0, - } - }, - - toJSON(message: SignedPreKey): unknown { - const obj: any = {} - message.signedPreKey !== undefined && - (obj.signedPreKey = base64FromBytes( - message.signedPreKey !== undefined - ? message.signedPreKey - : new Uint8Array() - )) - message.version !== undefined && (obj.version = Math.round(message.version)) - message.protocolVersion !== undefined && - (obj.protocolVersion = Math.round(message.protocolVersion)) - return obj - }, - - fromPartial, I>>( - object: I - ): SignedPreKey { - const message = createBaseSignedPreKey() - message.signedPreKey = object.signedPreKey ?? new Uint8Array() - message.version = object.version ?? 0 - message.protocolVersion = object.protocolVersion ?? 0 - return message - }, -} - -function createBaseBundle(): Bundle { - return { - identity: new Uint8Array(), - signedPreKeys: {}, - signature: new Uint8Array(), - timestamp: 0, - } -} - -export const Bundle = { - encode( - message: Bundle, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.identity.length !== 0) { - writer.uint32(10).bytes(message.identity) - } - Object.entries(message.signedPreKeys).forEach(([key, value]) => { - Bundle_SignedPreKeysEntry.encode( - { key: key as any, value }, - writer.uint32(18).fork() - ).ldelim() - }) - if (message.signature.length !== 0) { - writer.uint32(34).bytes(message.signature) - } - if (message.timestamp !== 0) { - writer.uint32(40).int64(message.timestamp) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): Bundle { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseBundle() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.identity = reader.bytes() - break - case 2: - const entry2 = Bundle_SignedPreKeysEntry.decode( - reader, - reader.uint32() - ) - if (entry2.value !== undefined) { - message.signedPreKeys[entry2.key] = entry2.value - } - break - case 4: - message.signature = reader.bytes() - break - case 5: - message.timestamp = longToNumber(reader.int64() as Long) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): Bundle { - return { - identity: isSet(object.identity) - ? bytesFromBase64(object.identity) - : new Uint8Array(), - signedPreKeys: isObject(object.signedPreKeys) - ? Object.entries(object.signedPreKeys).reduce<{ - [key: string]: SignedPreKey - }>((acc, [key, value]) => { - acc[key] = SignedPreKey.fromJSON(value) - return acc - }, {}) - : {}, - signature: isSet(object.signature) - ? bytesFromBase64(object.signature) - : new Uint8Array(), - timestamp: isSet(object.timestamp) ? Number(object.timestamp) : 0, - } - }, - - toJSON(message: Bundle): unknown { - const obj: any = {} - message.identity !== undefined && - (obj.identity = base64FromBytes( - message.identity !== undefined ? message.identity : new Uint8Array() - )) - obj.signedPreKeys = {} - if (message.signedPreKeys) { - Object.entries(message.signedPreKeys).forEach(([k, v]) => { - obj.signedPreKeys[k] = SignedPreKey.toJSON(v) - }) - } - message.signature !== undefined && - (obj.signature = base64FromBytes( - message.signature !== undefined ? message.signature : new Uint8Array() - )) - message.timestamp !== undefined && - (obj.timestamp = Math.round(message.timestamp)) - return obj - }, - - fromPartial, I>>(object: I): Bundle { - const message = createBaseBundle() - message.identity = object.identity ?? new Uint8Array() - message.signedPreKeys = Object.entries(object.signedPreKeys ?? {}).reduce<{ - [key: string]: SignedPreKey - }>((acc, [key, value]) => { - if (value !== undefined) { - acc[key] = SignedPreKey.fromPartial(value) - } - return acc - }, {}) - message.signature = object.signature ?? new Uint8Array() - message.timestamp = object.timestamp ?? 0 - return message - }, -} - -function createBaseBundle_SignedPreKeysEntry(): Bundle_SignedPreKeysEntry { - return { key: '', value: undefined } -} - -export const Bundle_SignedPreKeysEntry = { - encode( - message: Bundle_SignedPreKeysEntry, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key !== '') { - writer.uint32(10).string(message.key) - } - if (message.value !== undefined) { - SignedPreKey.encode(message.value, writer.uint32(18).fork()).ldelim() - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): Bundle_SignedPreKeysEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseBundle_SignedPreKeysEntry() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.string() - break - case 2: - message.value = SignedPreKey.decode(reader, reader.uint32()) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): Bundle_SignedPreKeysEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) - ? SignedPreKey.fromJSON(object.value) - : undefined, - } - }, - - toJSON(message: Bundle_SignedPreKeysEntry): unknown { - const obj: any = {} - message.key !== undefined && (obj.key = message.key) - message.value !== undefined && - (obj.value = message.value - ? SignedPreKey.toJSON(message.value) - : undefined) - return obj - }, - - fromPartial, I>>( - object: I - ): Bundle_SignedPreKeysEntry { - const message = createBaseBundle_SignedPreKeysEntry() - message.key = object.key ?? '' - message.value = - object.value !== undefined && object.value !== null - ? SignedPreKey.fromPartial(object.value) - : undefined - return message - }, -} - -function createBaseBundleContainer(): BundleContainer { - return { bundle: undefined, privateSignedPreKey: new Uint8Array() } -} - -export const BundleContainer = { - encode( - message: BundleContainer, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.bundle !== undefined) { - Bundle.encode(message.bundle, writer.uint32(10).fork()).ldelim() - } - if (message.privateSignedPreKey.length !== 0) { - writer.uint32(18).bytes(message.privateSignedPreKey) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): BundleContainer { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseBundleContainer() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.bundle = Bundle.decode(reader, reader.uint32()) - break - case 2: - message.privateSignedPreKey = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): BundleContainer { - return { - bundle: isSet(object.bundle) ? Bundle.fromJSON(object.bundle) : undefined, - privateSignedPreKey: isSet(object.privateSignedPreKey) - ? bytesFromBase64(object.privateSignedPreKey) - : new Uint8Array(), - } - }, - - toJSON(message: BundleContainer): unknown { - const obj: any = {} - message.bundle !== undefined && - (obj.bundle = message.bundle ? Bundle.toJSON(message.bundle) : undefined) - message.privateSignedPreKey !== undefined && - (obj.privateSignedPreKey = base64FromBytes( - message.privateSignedPreKey !== undefined - ? message.privateSignedPreKey - : new Uint8Array() - )) - return obj - }, - - fromPartial, I>>( - object: I - ): BundleContainer { - const message = createBaseBundleContainer() - message.bundle = - object.bundle !== undefined && object.bundle !== null - ? Bundle.fromPartial(object.bundle) - : undefined - message.privateSignedPreKey = object.privateSignedPreKey ?? new Uint8Array() - return message - }, -} - -function createBaseDRHeader(): DRHeader { - return { key: new Uint8Array(), n: 0, pn: 0, id: new Uint8Array() } -} - -export const DRHeader = { - encode( - message: DRHeader, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key.length !== 0) { - writer.uint32(10).bytes(message.key) - } - if (message.n !== 0) { - writer.uint32(16).uint32(message.n) - } - if (message.pn !== 0) { - writer.uint32(24).uint32(message.pn) - } - if (message.id.length !== 0) { - writer.uint32(34).bytes(message.id) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): DRHeader { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseDRHeader() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.bytes() - break - case 2: - message.n = reader.uint32() - break - case 3: - message.pn = reader.uint32() - break - case 4: - message.id = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): DRHeader { - return { - key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), - n: isSet(object.n) ? Number(object.n) : 0, - pn: isSet(object.pn) ? Number(object.pn) : 0, - id: isSet(object.id) ? bytesFromBase64(object.id) : new Uint8Array(), - } - }, - - toJSON(message: DRHeader): unknown { - const obj: any = {} - message.key !== undefined && - (obj.key = base64FromBytes( - message.key !== undefined ? message.key : new Uint8Array() - )) - message.n !== undefined && (obj.n = Math.round(message.n)) - message.pn !== undefined && (obj.pn = Math.round(message.pn)) - message.id !== undefined && - (obj.id = base64FromBytes( - message.id !== undefined ? message.id : new Uint8Array() - )) - return obj - }, - - fromPartial, I>>(object: I): DRHeader { - const message = createBaseDRHeader() - message.key = object.key ?? new Uint8Array() - message.n = object.n ?? 0 - message.pn = object.pn ?? 0 - message.id = object.id ?? new Uint8Array() - return message - }, -} - -function createBaseDHHeader(): DHHeader { - return { key: new Uint8Array() } -} - -export const DHHeader = { - encode( - message: DHHeader, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key.length !== 0) { - writer.uint32(10).bytes(message.key) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): DHHeader { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseDHHeader() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): DHHeader { - return { - key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), - } - }, - - toJSON(message: DHHeader): unknown { - const obj: any = {} - message.key !== undefined && - (obj.key = base64FromBytes( - message.key !== undefined ? message.key : new Uint8Array() - )) - return obj - }, - - fromPartial, I>>(object: I): DHHeader { - const message = createBaseDHHeader() - message.key = object.key ?? new Uint8Array() - return message - }, -} - -function createBaseX3DHHeader(): X3DHHeader { - return { key: new Uint8Array(), id: new Uint8Array() } -} - -export const X3DHHeader = { - encode( - message: X3DHHeader, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key.length !== 0) { - writer.uint32(10).bytes(message.key) - } - if (message.id.length !== 0) { - writer.uint32(34).bytes(message.id) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): X3DHHeader { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseX3DHHeader() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.bytes() - break - case 4: - message.id = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): X3DHHeader { - return { - key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), - id: isSet(object.id) ? bytesFromBase64(object.id) : new Uint8Array(), - } - }, - - toJSON(message: X3DHHeader): unknown { - const obj: any = {} - message.key !== undefined && - (obj.key = base64FromBytes( - message.key !== undefined ? message.key : new Uint8Array() - )) - message.id !== undefined && - (obj.id = base64FromBytes( - message.id !== undefined ? message.id : new Uint8Array() - )) - return obj - }, - - fromPartial, I>>( - object: I - ): X3DHHeader { - const message = createBaseX3DHHeader() - message.key = object.key ?? new Uint8Array() - message.id = object.id ?? new Uint8Array() - return message - }, -} - -function createBaseHRHeader(): HRHeader { - return { keyId: 0, seqNo: 0, groupId: '' } -} - -export const HRHeader = { - encode( - message: HRHeader, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.keyId !== 0) { - writer.uint32(8).uint32(message.keyId) - } - if (message.seqNo !== 0) { - writer.uint32(16).uint32(message.seqNo) - } - if (message.groupId !== '') { - writer.uint32(26).string(message.groupId) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): HRHeader { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseHRHeader() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.keyId = reader.uint32() - break - case 2: - message.seqNo = reader.uint32() - break - case 3: - message.groupId = reader.string() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): HRHeader { - return { - keyId: isSet(object.keyId) ? Number(object.keyId) : 0, - seqNo: isSet(object.seqNo) ? Number(object.seqNo) : 0, - groupId: isSet(object.groupId) ? String(object.groupId) : '', - } - }, - - toJSON(message: HRHeader): unknown { - const obj: any = {} - message.keyId !== undefined && (obj.keyId = Math.round(message.keyId)) - message.seqNo !== undefined && (obj.seqNo = Math.round(message.seqNo)) - message.groupId !== undefined && (obj.groupId = message.groupId) - return obj - }, - - fromPartial, I>>(object: I): HRHeader { - const message = createBaseHRHeader() - message.keyId = object.keyId ?? 0 - message.seqNo = object.seqNo ?? 0 - message.groupId = object.groupId ?? '' - return message - }, -} - -function createBaseEncryptedMessageProtocol(): EncryptedMessageProtocol { - return { - x3dhHeader: undefined, - drHeader: undefined, - dhHeader: undefined, - hrHeader: undefined, - payload: new Uint8Array(), - } -} - -export const EncryptedMessageProtocol = { - encode( - message: EncryptedMessageProtocol, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.x3dhHeader !== undefined) { - X3DHHeader.encode(message.x3dhHeader, writer.uint32(10).fork()).ldelim() - } - if (message.drHeader !== undefined) { - DRHeader.encode(message.drHeader, writer.uint32(18).fork()).ldelim() - } - if (message.dhHeader !== undefined) { - DHHeader.encode(message.dhHeader, writer.uint32(810).fork()).ldelim() - } - if (message.hrHeader !== undefined) { - HRHeader.encode(message.hrHeader, writer.uint32(818).fork()).ldelim() - } - if (message.payload.length !== 0) { - writer.uint32(26).bytes(message.payload) - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): EncryptedMessageProtocol { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseEncryptedMessageProtocol() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.x3dhHeader = X3DHHeader.decode(reader, reader.uint32()) - break - case 2: - message.drHeader = DRHeader.decode(reader, reader.uint32()) - break - case 101: - message.dhHeader = DHHeader.decode(reader, reader.uint32()) - break - case 102: - message.hrHeader = HRHeader.decode(reader, reader.uint32()) - break - case 3: - message.payload = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): EncryptedMessageProtocol { - return { - x3dhHeader: isSet(object.x3dhHeader) - ? X3DHHeader.fromJSON(object.x3dhHeader) - : undefined, - drHeader: isSet(object.drHeader) - ? DRHeader.fromJSON(object.drHeader) - : undefined, - dhHeader: isSet(object.dhHeader) - ? DHHeader.fromJSON(object.dhHeader) - : undefined, - hrHeader: isSet(object.hrHeader) - ? HRHeader.fromJSON(object.hrHeader) - : undefined, - payload: isSet(object.payload) - ? bytesFromBase64(object.payload) - : new Uint8Array(), - } - }, - - toJSON(message: EncryptedMessageProtocol): unknown { - const obj: any = {} - message.x3dhHeader !== undefined && - (obj.x3dhHeader = message.x3dhHeader - ? X3DHHeader.toJSON(message.x3dhHeader) - : undefined) - message.drHeader !== undefined && - (obj.drHeader = message.drHeader - ? DRHeader.toJSON(message.drHeader) - : undefined) - message.dhHeader !== undefined && - (obj.dhHeader = message.dhHeader - ? DHHeader.toJSON(message.dhHeader) - : undefined) - message.hrHeader !== undefined && - (obj.hrHeader = message.hrHeader - ? HRHeader.toJSON(message.hrHeader) - : undefined) - message.payload !== undefined && - (obj.payload = base64FromBytes( - message.payload !== undefined ? message.payload : new Uint8Array() - )) - return obj - }, - - fromPartial, I>>( - object: I - ): EncryptedMessageProtocol { - const message = createBaseEncryptedMessageProtocol() - message.x3dhHeader = - object.x3dhHeader !== undefined && object.x3dhHeader !== null - ? X3DHHeader.fromPartial(object.x3dhHeader) - : undefined - message.drHeader = - object.drHeader !== undefined && object.drHeader !== null - ? DRHeader.fromPartial(object.drHeader) - : undefined - message.dhHeader = - object.dhHeader !== undefined && object.dhHeader !== null - ? DHHeader.fromPartial(object.dhHeader) - : undefined - message.hrHeader = - object.hrHeader !== undefined && object.hrHeader !== null - ? HRHeader.fromPartial(object.hrHeader) - : undefined - message.payload = object.payload ?? new Uint8Array() - return message - }, -} - -function createBaseProtocolMessage(): ProtocolMessage { - return { - installationId: '', - bundles: [], - encryptedMessage: {}, - publicMessage: new Uint8Array(), - } -} - -export const ProtocolMessage = { - encode( - message: ProtocolMessage, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.installationId !== '') { - writer.uint32(18).string(message.installationId) - } - for (const v of message.bundles) { - Bundle.encode(v!, writer.uint32(26).fork()).ldelim() - } - Object.entries(message.encryptedMessage).forEach(([key, value]) => { - ProtocolMessage_EncryptedMessageEntry.encode( - { key: key as any, value }, - writer.uint32(810).fork() - ).ldelim() - }) - if (message.publicMessage.length !== 0) { - writer.uint32(818).bytes(message.publicMessage) - } - return writer - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): ProtocolMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseProtocolMessage() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 2: - message.installationId = reader.string() - break - case 3: - message.bundles.push(Bundle.decode(reader, reader.uint32())) - break - case 101: - const entry101 = ProtocolMessage_EncryptedMessageEntry.decode( - reader, - reader.uint32() - ) - if (entry101.value !== undefined) { - message.encryptedMessage[entry101.key] = entry101.value - } - break - case 102: - message.publicMessage = reader.bytes() - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): ProtocolMessage { - return { - installationId: isSet(object.installationId) - ? String(object.installationId) - : '', - bundles: Array.isArray(object?.bundles) - ? object.bundles.map((e: any) => Bundle.fromJSON(e)) - : [], - encryptedMessage: isObject(object.encryptedMessage) - ? Object.entries(object.encryptedMessage).reduce<{ - [key: string]: EncryptedMessageProtocol - }>((acc, [key, value]) => { - acc[key] = EncryptedMessageProtocol.fromJSON(value) - return acc - }, {}) - : {}, - publicMessage: isSet(object.publicMessage) - ? bytesFromBase64(object.publicMessage) - : new Uint8Array(), - } - }, - - toJSON(message: ProtocolMessage): unknown { - const obj: any = {} - message.installationId !== undefined && - (obj.installationId = message.installationId) - if (message.bundles) { - obj.bundles = message.bundles.map(e => (e ? Bundle.toJSON(e) : undefined)) - } else { - obj.bundles = [] - } - obj.encryptedMessage = {} - if (message.encryptedMessage) { - Object.entries(message.encryptedMessage).forEach(([k, v]) => { - obj.encryptedMessage[k] = EncryptedMessageProtocol.toJSON(v) - }) - } - message.publicMessage !== undefined && - (obj.publicMessage = base64FromBytes( - message.publicMessage !== undefined - ? message.publicMessage - : new Uint8Array() - )) - return obj - }, - - fromPartial, I>>( - object: I - ): ProtocolMessage { - const message = createBaseProtocolMessage() - message.installationId = object.installationId ?? '' - message.bundles = object.bundles?.map(e => Bundle.fromPartial(e)) || [] - message.encryptedMessage = Object.entries( - object.encryptedMessage ?? {} - ).reduce<{ [key: string]: EncryptedMessageProtocol }>( - (acc, [key, value]) => { - if (value !== undefined) { - acc[key] = EncryptedMessageProtocol.fromPartial(value) - } - return acc - }, - {} - ) - message.publicMessage = object.publicMessage ?? new Uint8Array() - return message - }, -} - -function createBaseProtocolMessage_EncryptedMessageEntry(): ProtocolMessage_EncryptedMessageEntry { - return { key: '', value: undefined } -} - -export const ProtocolMessage_EncryptedMessageEntry = { - encode( - message: ProtocolMessage_EncryptedMessageEntry, - writer: _m0.Writer = _m0.Writer.create() - ): _m0.Writer { - if (message.key !== '') { - writer.uint32(10).string(message.key) - } - if (message.value !== undefined) { - EncryptedMessageProtocol.encode( - message.value, - writer.uint32(18).fork() - ).ldelim() - } - return writer - }, - - decode( - input: _m0.Reader | Uint8Array, - length?: number - ): ProtocolMessage_EncryptedMessageEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input) - let end = length === undefined ? reader.len : reader.pos + length - const message = createBaseProtocolMessage_EncryptedMessageEntry() - while (reader.pos < end) { - const tag = reader.uint32() - switch (tag >>> 3) { - case 1: - message.key = reader.string() - break - case 2: - message.value = EncryptedMessageProtocol.decode( - reader, - reader.uint32() - ) - break - default: - reader.skipType(tag & 7) - break - } - } - return message - }, - - fromJSON(object: any): ProtocolMessage_EncryptedMessageEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) - ? EncryptedMessageProtocol.fromJSON(object.value) - : undefined, - } - }, - - toJSON(message: ProtocolMessage_EncryptedMessageEntry): unknown { - const obj: any = {} - message.key !== undefined && (obj.key = message.key) - message.value !== undefined && - (obj.value = message.value - ? EncryptedMessageProtocol.toJSON(message.value) - : undefined) - return obj - }, - - fromPartial< - I extends Exact, I> - >(object: I): ProtocolMessage_EncryptedMessageEntry { - const message = createBaseProtocolMessage_EncryptedMessageEntry() - message.key = object.key ?? '' - message.value = - object.value !== undefined && object.value !== null - ? EncryptedMessageProtocol.fromPartial(object.value) - : undefined - return message - }, -} - -declare var self: any | undefined -declare var window: any | undefined -declare var global: any | undefined -var globalThis: any = (() => { - if (typeof globalThis !== 'undefined') return globalThis - if (typeof self !== 'undefined') return self - if (typeof window !== 'undefined') return window - if (typeof global !== 'undefined') return global - throw 'Unable to locate global object' -})() - -const atob: (b64: string) => string = - globalThis.atob || - (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')) -function bytesFromBase64(b64: string): Uint8Array { - const bin = atob(b64) - const arr = new Uint8Array(bin.length) - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i) - } - return arr -} - -const btoa: (bin: string) => string = - globalThis.btoa || - (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')) -function base64FromBytes(arr: Uint8Array): string { - const bin: string[] = [] - arr.forEach(byte => { - bin.push(String.fromCharCode(byte)) - }) - return btoa(bin.join('')) -} - -type Builtin = - | Date - | Function - | Uint8Array - | string - | number - | boolean - | undefined - -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial - -type KeysOfUnion = T extends T ? keyof T : never -export type Exact = P extends Builtin - ? P - : P & { [K in keyof P]: Exact } & Record< - Exclude>, - never - > - -function longToNumber(long: Long): number { - if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER') - } - return long.toNumber() -} - -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any - _m0.configure() -} - -function isObject(value: any): boolean { - return typeof value === 'object' && value !== null -} - -function isSet(value: any): boolean { - return value !== null && value !== undefined -} diff --git a/packages/status-js/src/protos/application-metadata-message.ts b/packages/status-js/src/protos/application-metadata-message.ts deleted file mode 100644 index 1ae6df36..00000000 --- a/packages/status-js/src/protos/application-metadata-message.ts +++ /dev/null @@ -1,109 +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(__TypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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()) - } -} diff --git a/packages/status-js/src/protos/application-metadata-message_pb.ts b/packages/status-js/src/protos/application-metadata-message_pb.ts new file mode 100644 index 00000000..f3f0c485 --- /dev/null +++ b/packages/status-js/src/protos/application-metadata-message_pb.ts @@ -0,0 +1,275 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file application-metadata-message.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message ApplicationMetadataMessage + */ +export class ApplicationMetadataMessage extends Message { + /** + * Signature of the payload field + * + * @generated from field: bytes signature = 1; + */ + signature = new Uint8Array(0); + + /** + * This is the encoded protobuf of the application level message, i.e ChatMessage + * + * @generated from field: bytes payload = 2; + */ + payload = new Uint8Array(0); + + /** + * The type of protobuf message sent + * + * @generated from field: ApplicationMetadataMessage.Type type = 3; + */ + type = ApplicationMetadataMessage_Type.UNKNOWN_UNSPECIFIED; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "ApplicationMetadataMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "signature", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 3, name: "type", kind: "enum", T: proto3.getEnumType(ApplicationMetadataMessage_Type) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ApplicationMetadataMessage { + return new ApplicationMetadataMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ApplicationMetadataMessage { + return new ApplicationMetadataMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ApplicationMetadataMessage { + return new ApplicationMetadataMessage().fromJsonString(jsonString, options); + } + + static equals(a: ApplicationMetadataMessage | PlainMessage | undefined, b: ApplicationMetadataMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(ApplicationMetadataMessage, a, b); + } +} + +/** + * @generated from enum ApplicationMetadataMessage.Type + */ +export enum ApplicationMetadataMessage_Type { + /** + * @generated from enum value: TYPE_UNKNOWN_UNSPECIFIED = 0; + */ + UNKNOWN_UNSPECIFIED = 0, + + /** + * @generated from enum value: TYPE_CHAT_MESSAGE = 1; + */ + CHAT_MESSAGE = 1, + + /** + * @generated from enum value: TYPE_CONTACT_UPDATE = 2; + */ + CONTACT_UPDATE = 2, + + /** + * @generated from enum value: TYPE_MEMBERSHIP_UPDATE_MESSAGE = 3; + */ + MEMBERSHIP_UPDATE_MESSAGE = 3, + + /** + * @generated from enum value: TYPE_PAIR_INSTALLATION = 4; + */ + PAIR_INSTALLATION = 4, + + /** + * @generated from enum value: TYPE_SYNC_INSTALLATION = 5; + */ + SYNC_INSTALLATION = 5, + + /** + * @generated from enum value: TYPE_REQUEST_ADDRESS_FOR_TRANSACTION = 6; + */ + REQUEST_ADDRESS_FOR_TRANSACTION = 6, + + /** + * @generated from enum value: TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION = 7; + */ + ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION = 7, + + /** + * @generated from enum value: TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION = 8; + */ + DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION = 8, + + /** + * @generated from enum value: TYPE_REQUEST_TRANSACTION = 9; + */ + REQUEST_TRANSACTION = 9, + + /** + * @generated from enum value: TYPE_SEND_TRANSACTION = 10; + */ + SEND_TRANSACTION = 10, + + /** + * @generated from enum value: TYPE_DECLINE_REQUEST_TRANSACTION = 11; + */ + DECLINE_REQUEST_TRANSACTION = 11, + + /** + * @generated from enum value: TYPE_SYNC_INSTALLATION_CONTACT = 12; + */ + SYNC_INSTALLATION_CONTACT = 12, + + /** + * @generated from enum value: TYPE_SYNC_INSTALLATION_ACCOUNT = 13; + */ + SYNC_INSTALLATION_ACCOUNT = 13, + + /** + * @generated from enum value: TYPE_SYNC_INSTALLATION_PUBLIC_CHAT = 14; + */ + SYNC_INSTALLATION_PUBLIC_CHAT = 14, + + /** + * @generated from enum value: TYPE_CONTACT_CODE_ADVERTISEMENT = 15; + */ + CONTACT_CODE_ADVERTISEMENT = 15, + + /** + * @generated from enum value: TYPE_PUSH_NOTIFICATION_REGISTRATION = 16; + */ + PUSH_NOTIFICATION_REGISTRATION = 16, + + /** + * @generated from enum value: TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE = 17; + */ + PUSH_NOTIFICATION_REGISTRATION_RESPONSE = 17, + + /** + * @generated from enum value: TYPE_PUSH_NOTIFICATION_QUERY = 18; + */ + PUSH_NOTIFICATION_QUERY = 18, + + /** + * @generated from enum value: TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE = 19; + */ + PUSH_NOTIFICATION_QUERY_RESPONSE = 19, + + /** + * @generated from enum value: TYPE_PUSH_NOTIFICATION_REQUEST = 20; + */ + PUSH_NOTIFICATION_REQUEST = 20, + + /** + * @generated from enum value: TYPE_PUSH_NOTIFICATION_RESPONSE = 21; + */ + PUSH_NOTIFICATION_RESPONSE = 21, + + /** + * @generated from enum value: TYPE_EMOJI_REACTION = 22; + */ + EMOJI_REACTION = 22, + + /** + * @generated from enum value: TYPE_GROUP_CHAT_INVITATION = 23; + */ + GROUP_CHAT_INVITATION = 23, + + /** + * @generated from enum value: TYPE_CHAT_IDENTITY = 24; + */ + CHAT_IDENTITY = 24, + + /** + * @generated from enum value: TYPE_COMMUNITY_DESCRIPTION = 25; + */ + COMMUNITY_DESCRIPTION = 25, + + /** + * @generated from enum value: TYPE_COMMUNITY_INVITATION = 26; + */ + COMMUNITY_INVITATION = 26, + + /** + * @generated from enum value: TYPE_COMMUNITY_REQUEST_TO_JOIN = 27; + */ + COMMUNITY_REQUEST_TO_JOIN = 27, + + /** + * @generated from enum value: TYPE_PIN_MESSAGE = 28; + */ + PIN_MESSAGE = 28, + + /** + * @generated from enum value: TYPE_EDIT_MESSAGE = 29; + */ + EDIT_MESSAGE = 29, + + /** + * @generated from enum value: TYPE_STATUS_UPDATE = 30; + */ + STATUS_UPDATE = 30, + + /** + * @generated from enum value: TYPE_DELETE_MESSAGE = 31; + */ + DELETE_MESSAGE = 31, + + /** + * @generated from enum value: TYPE_SYNC_INSTALLATION_COMMUNITY = 32; + */ + SYNC_INSTALLATION_COMMUNITY = 32, + + /** + * @generated from enum value: TYPE_ANONYMOUS_METRIC_BATCH = 33; + */ + ANONYMOUS_METRIC_BATCH = 33, +} +// Retrieve enum metadata with: proto3.getEnumType(ApplicationMetadataMessage_Type) +proto3.util.setEnumType(ApplicationMetadataMessage_Type, "ApplicationMetadataMessage.Type", [ + { no: 0, name: "TYPE_UNKNOWN_UNSPECIFIED" }, + { no: 1, name: "TYPE_CHAT_MESSAGE" }, + { no: 2, name: "TYPE_CONTACT_UPDATE" }, + { no: 3, name: "TYPE_MEMBERSHIP_UPDATE_MESSAGE" }, + { no: 4, name: "TYPE_PAIR_INSTALLATION" }, + { no: 5, name: "TYPE_SYNC_INSTALLATION" }, + { no: 6, name: "TYPE_REQUEST_ADDRESS_FOR_TRANSACTION" }, + { no: 7, name: "TYPE_ACCEPT_REQUEST_ADDRESS_FOR_TRANSACTION" }, + { no: 8, name: "TYPE_DECLINE_REQUEST_ADDRESS_FOR_TRANSACTION" }, + { no: 9, name: "TYPE_REQUEST_TRANSACTION" }, + { no: 10, name: "TYPE_SEND_TRANSACTION" }, + { no: 11, name: "TYPE_DECLINE_REQUEST_TRANSACTION" }, + { no: 12, name: "TYPE_SYNC_INSTALLATION_CONTACT" }, + { no: 13, name: "TYPE_SYNC_INSTALLATION_ACCOUNT" }, + { no: 14, name: "TYPE_SYNC_INSTALLATION_PUBLIC_CHAT" }, + { no: 15, name: "TYPE_CONTACT_CODE_ADVERTISEMENT" }, + { no: 16, name: "TYPE_PUSH_NOTIFICATION_REGISTRATION" }, + { no: 17, name: "TYPE_PUSH_NOTIFICATION_REGISTRATION_RESPONSE" }, + { no: 18, name: "TYPE_PUSH_NOTIFICATION_QUERY" }, + { no: 19, name: "TYPE_PUSH_NOTIFICATION_QUERY_RESPONSE" }, + { no: 20, name: "TYPE_PUSH_NOTIFICATION_REQUEST" }, + { no: 21, name: "TYPE_PUSH_NOTIFICATION_RESPONSE" }, + { no: 22, name: "TYPE_EMOJI_REACTION" }, + { no: 23, name: "TYPE_GROUP_CHAT_INVITATION" }, + { no: 24, name: "TYPE_CHAT_IDENTITY" }, + { no: 25, name: "TYPE_COMMUNITY_DESCRIPTION" }, + { no: 26, name: "TYPE_COMMUNITY_INVITATION" }, + { no: 27, name: "TYPE_COMMUNITY_REQUEST_TO_JOIN" }, + { no: 28, name: "TYPE_PIN_MESSAGE" }, + { no: 29, name: "TYPE_EDIT_MESSAGE" }, + { no: 30, name: "TYPE_STATUS_UPDATE" }, + { no: 31, name: "TYPE_DELETE_MESSAGE" }, + { no: 32, name: "TYPE_SYNC_INSTALLATION_COMMUNITY" }, + { no: 33, name: "TYPE_ANONYMOUS_METRIC_BATCH" }, +]); + diff --git a/packages/status-js/buf.yaml b/packages/status-js/src/protos/buf.yaml similarity index 53% rename from packages/status-js/buf.yaml rename to packages/status-js/src/protos/buf.yaml index c6a09b81..a258831a 100644 --- a/packages/status-js/buf.yaml +++ b/packages/status-js/src/protos/buf.yaml @@ -1,9 +1,10 @@ -version: v1beta1 - -build: - roots: - - ./proto +version: v1 +breaking: + use: + - FILE lint: + use: + - DEFAULT except: - ENUM_ZERO_VALUE_SUFFIX - ENUM_VALUE_PREFIX diff --git a/packages/status-js/src/protos/chat-identity.proto b/packages/status-js/src/protos/chat-identity.proto index 0d600990..91135c38 100644 --- a/packages/status-js/src/protos/chat-identity.proto +++ b/packages/status-js/src/protos/chat-identity.proto @@ -16,12 +16,19 @@ message ChatIdentity { // display name is the user set identity string display_name = 4; - // description is the user set description, valid only for organisations + // description is the user set description string description = 5; string color = 6; string emoji = 7; + + repeated SocialLink social_links = 8; + + // first known message timestamp in seconds (valid only for community chats for now) + // 0 - unknown + // 1 - no messages + uint32 first_message_timestamp = 9; } // ProfileImage represents data associated with a user's profile image @@ -57,3 +64,9 @@ message IdentityImage { ENS_AVATAR = 2; } } + +// SocialLinks represents social link assosiated with given chat identity (personal/community) +message SocialLink { + string text = 1; + string url = 2; +} diff --git a/packages/status-js/src/protos/chat-identity.ts b/packages/status-js/src/protos/chat-identity.ts deleted file mode 100644 index 4560a9fb..00000000 --- a/packages/status-js/src/protos/chat-identity.ts +++ /dev/null @@ -1,130 +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 => { - return message({ - 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(__SourceTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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(__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(__ImageTypeValues) - } -} diff --git a/packages/status-js/src/protos/chat-identity_pb.ts b/packages/status-js/src/protos/chat-identity_pb.ts new file mode 100644 index 00000000..f1279d65 --- /dev/null +++ b/packages/status-js/src/protos/chat-identity_pb.ts @@ -0,0 +1,264 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file chat-identity.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; +import { ImageType } from "./enums_pb.js"; + +/** + * ChatIdentity represents the user defined identity associated with their public chat key + * + * @generated from message ChatIdentity + */ +export class ChatIdentity extends Message { + /** + * Lamport timestamp of the message + * + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * ens_name is the valid ENS name associated with the chat key + * + * @generated from field: string ens_name = 2; + */ + ensName = ""; + + /** + * images is a string indexed mapping of images associated with an identity + * + * @generated from field: map images = 3; + */ + images: { [key: string]: IdentityImage } = {}; + + /** + * display name is the user set identity + * + * @generated from field: string display_name = 4; + */ + displayName = ""; + + /** + * description is the user set description + * + * @generated from field: string description = 5; + */ + description = ""; + + /** + * @generated from field: string color = 6; + */ + color = ""; + + /** + * @generated from field: string emoji = 7; + */ + emoji = ""; + + /** + * @generated from field: repeated SocialLink social_links = 8; + */ + socialLinks: SocialLink[] = []; + + /** + * first known message timestamp in seconds (valid only for community chats for now) + * 0 - unknown + * 1 - no messages + * + * @generated from field: uint32 first_message_timestamp = 9; + */ + firstMessageTimestamp = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "ChatIdentity"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "ens_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "images", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: IdentityImage} }, + { no: 4, name: "display_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 5, name: "description", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "color", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 7, name: "emoji", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 8, name: "social_links", kind: "message", T: SocialLink, repeated: true }, + { no: 9, name: "first_message_timestamp", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ChatIdentity { + return new ChatIdentity().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ChatIdentity { + return new ChatIdentity().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ChatIdentity { + return new ChatIdentity().fromJsonString(jsonString, options); + } + + static equals(a: ChatIdentity | PlainMessage | undefined, b: ChatIdentity | PlainMessage | undefined): boolean { + return proto3.util.equals(ChatIdentity, a, b); + } +} + +/** + * ProfileImage represents data associated with a user's profile image + * + * @generated from message IdentityImage + */ +export class IdentityImage extends Message { + /** + * payload is a context based payload for the profile image data, + * context is determined by the `source_type` + * + * @generated from field: bytes payload = 1; + */ + payload = new Uint8Array(0); + + /** + * source_type signals the image payload source + * + * @generated from field: IdentityImage.SourceType source_type = 2; + */ + sourceType = IdentityImage_SourceType.UNKNOWN_SOURCE_TYPE; + + /** + * image_type signals the image type and method of parsing the payload + * + * @generated from field: ImageType image_type = 3; + */ + imageType = ImageType.UNKNOWN_IMAGE_TYPE; + + /** + * encryption_keys is a list of encrypted keys that can be used to decrypted an encrypted payload + * + * @generated from field: repeated bytes encryption_keys = 4; + */ + encryptionKeys: Uint8Array[] = []; + + /** + * encrypted signals the encryption state of the payload, default is false. + * + * @generated from field: bool encrypted = 5; + */ + encrypted = false; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "IdentityImage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "source_type", kind: "enum", T: proto3.getEnumType(IdentityImage_SourceType) }, + { no: 3, name: "image_type", kind: "enum", T: proto3.getEnumType(ImageType) }, + { no: 4, name: "encryption_keys", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true }, + { no: 5, name: "encrypted", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): IdentityImage { + return new IdentityImage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): IdentityImage { + return new IdentityImage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): IdentityImage { + return new IdentityImage().fromJsonString(jsonString, options); + } + + static equals(a: IdentityImage | PlainMessage | undefined, b: IdentityImage | PlainMessage | undefined): boolean { + return proto3.util.equals(IdentityImage, a, b); + } +} + +/** + * SourceType are the predefined types of image source allowed + * + * @generated from enum IdentityImage.SourceType + */ +export enum IdentityImage_SourceType { + /** + * @generated from enum value: UNKNOWN_SOURCE_TYPE = 0; + */ + UNKNOWN_SOURCE_TYPE = 0, + + /** + * RAW_PAYLOAD image byte data + * + * @generated from enum value: RAW_PAYLOAD = 1; + */ + 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 + * + * @generated from enum value: ENS_AVATAR = 2; + */ + ENS_AVATAR = 2, +} +// Retrieve enum metadata with: proto3.getEnumType(IdentityImage_SourceType) +proto3.util.setEnumType(IdentityImage_SourceType, "IdentityImage.SourceType", [ + { no: 0, name: "UNKNOWN_SOURCE_TYPE" }, + { no: 1, name: "RAW_PAYLOAD" }, + { no: 2, name: "ENS_AVATAR" }, +]); + +/** + * SocialLinks represents social link assosiated with given chat identity (personal/community) + * + * @generated from message SocialLink + */ +export class SocialLink extends Message { + /** + * @generated from field: string text = 1; + */ + text = ""; + + /** + * @generated from field: string url = 2; + */ + url = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "SocialLink"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "text", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "url", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): SocialLink { + return new SocialLink().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): SocialLink { + return new SocialLink().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): SocialLink { + return new SocialLink().fromJsonString(jsonString, options); + } + + static equals(a: SocialLink | PlainMessage | undefined, b: SocialLink | PlainMessage | undefined): boolean { + return proto3.util.equals(SocialLink, a, b); + } +} + diff --git a/packages/status-js/src/protos/chat-message.ts b/packages/status-js/src/protos/chat-message.ts deleted file mode 100644 index 45147a62..00000000 --- a/packages/status-js/src/protos/chat-message.ts +++ /dev/null @@ -1,276 +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 => { - return message({ - 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 => { - return message({ - 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(__AudioTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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(__ContentTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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(__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(__ImageTypeValues) - } -} diff --git a/packages/status-js/src/protos/chat-message_pb.ts b/packages/status-js/src/protos/chat-message_pb.ts new file mode 100644 index 00000000..91fcabd6 --- /dev/null +++ b/packages/status-js/src/protos/chat-message_pb.ts @@ -0,0 +1,534 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file chat-message.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; +import { ImageType, MessageType } from "./enums_pb.js"; + +/** + * @generated from message StickerMessage + */ +export class StickerMessage extends Message { + /** + * @generated from field: string hash = 1; + */ + hash = ""; + + /** + * @generated from field: int32 pack = 2; + */ + pack = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "StickerMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "hash", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "pack", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): StickerMessage { + return new StickerMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): StickerMessage { + return new StickerMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): StickerMessage { + return new StickerMessage().fromJsonString(jsonString, options); + } + + static equals(a: StickerMessage | PlainMessage | undefined, b: StickerMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(StickerMessage, a, b); + } +} + +/** + * @generated from message ImageMessage + */ +export class ImageMessage extends Message { + /** + * @generated from field: bytes payload = 1; + */ + payload = new Uint8Array(0); + + /** + * @generated from field: ImageType type = 2; + */ + type = ImageType.UNKNOWN_IMAGE_TYPE; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "ImageMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "type", kind: "enum", T: proto3.getEnumType(ImageType) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ImageMessage { + return new ImageMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ImageMessage { + return new ImageMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ImageMessage { + return new ImageMessage().fromJsonString(jsonString, options); + } + + static equals(a: ImageMessage | PlainMessage | undefined, b: ImageMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(ImageMessage, a, b); + } +} + +/** + * @generated from message AudioMessage + */ +export class AudioMessage extends Message { + /** + * @generated from field: bytes payload = 1; + */ + payload = new Uint8Array(0); + + /** + * @generated from field: AudioMessage.AudioType type = 2; + */ + type = AudioMessage_AudioType.UNKNOWN_AUDIO_TYPE; + + /** + * @generated from field: uint64 duration_ms = 3; + */ + durationMs = protoInt64.zero; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "AudioMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "type", kind: "enum", T: proto3.getEnumType(AudioMessage_AudioType) }, + { no: 3, name: "duration_ms", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): AudioMessage { + return new AudioMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): AudioMessage { + return new AudioMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): AudioMessage { + return new AudioMessage().fromJsonString(jsonString, options); + } + + static equals(a: AudioMessage | PlainMessage | undefined, b: AudioMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(AudioMessage, a, b); + } +} + +/** + * @generated from enum AudioMessage.AudioType + */ +export enum AudioMessage_AudioType { + /** + * @generated from enum value: UNKNOWN_AUDIO_TYPE = 0; + */ + UNKNOWN_AUDIO_TYPE = 0, + + /** + * @generated from enum value: AAC = 1; + */ + AAC = 1, + + /** + * @generated from enum value: AMR = 2; + */ + AMR = 2, +} +// Retrieve enum metadata with: proto3.getEnumType(AudioMessage_AudioType) +proto3.util.setEnumType(AudioMessage_AudioType, "AudioMessage.AudioType", [ + { no: 0, name: "UNKNOWN_AUDIO_TYPE" }, + { no: 1, name: "AAC" }, + { no: 2, name: "AMR" }, +]); + +/** + * @generated from message EditMessage + */ +export class EditMessage extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * Text of the message + * + * @generated from field: string text = 2; + */ + text = ""; + + /** + * @generated from field: string chat_id = 3; + */ + chatId = ""; + + /** + * @generated from field: string message_id = 4; + */ + messageId = ""; + + /** + * Grant for community edit messages + * + * @generated from field: bytes grant = 5; + */ + grant = new Uint8Array(0); + + /** + * The type of message (public/one-to-one/private-group-chat) + * + * @generated from field: MessageType message_type = 6; + */ + messageType = MessageType.UNKNOWN_MESSAGE_TYPE; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "EditMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "text", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "message_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 5, name: "grant", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 6, name: "message_type", kind: "enum", T: proto3.getEnumType(MessageType) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): EditMessage { + return new EditMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): EditMessage { + return new EditMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): EditMessage { + return new EditMessage().fromJsonString(jsonString, options); + } + + static equals(a: EditMessage | PlainMessage | undefined, b: EditMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(EditMessage, a, b); + } +} + +/** + * @generated from message DeleteMessage + */ +export class DeleteMessage extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: string chat_id = 2; + */ + chatId = ""; + + /** + * @generated from field: string message_id = 3; + */ + messageId = ""; + + /** + * Grant for community delete messages + * + * @generated from field: bytes grant = 4; + */ + grant = new Uint8Array(0); + + /** + * The type of message (public/one-to-one/private-group-chat) + * + * @generated from field: MessageType message_type = 5; + */ + messageType = MessageType.UNKNOWN_MESSAGE_TYPE; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "DeleteMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "message_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "grant", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 5, name: "message_type", kind: "enum", T: proto3.getEnumType(MessageType) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DeleteMessage { + return new DeleteMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DeleteMessage { + return new DeleteMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DeleteMessage { + return new DeleteMessage().fromJsonString(jsonString, options); + } + + static equals(a: DeleteMessage | PlainMessage | undefined, b: DeleteMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(DeleteMessage, a, b); + } +} + +/** + * @generated from message ChatMessage + */ +export class ChatMessage extends Message { + /** + * Lamport timestamp of the chat message + * + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * Unix timestamps in milliseconds, currently not used as we use whisper as more reliable, but here + * so that we don't rely on it + * + * @generated from field: uint64 timestamp = 2; + */ + timestamp = protoInt64.zero; + + /** + * Text of the message + * + * @generated from field: string text = 3; + */ + text = ""; + + /** + * Id of the message that we are replying to + * + * @generated from field: string response_to = 4; + */ + responseTo = ""; + + /** + * Ens name of the sender + * + * @generated from field: string ens_name = 5; + */ + ensName = ""; + + /** + * 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 + * + * @generated from field: string chat_id = 6; + */ + chatId = ""; + + /** + * The type of message (public/one-to-one/private-group-chat) + * + * @generated from field: MessageType message_type = 7; + */ + messageType = MessageType.UNKNOWN_MESSAGE_TYPE; + + /** + * The type of the content of the message + * + * @generated from field: ChatMessage.ContentType content_type = 8; + */ + contentType = ChatMessage_ContentType.UNKNOWN_CONTENT_TYPE; + + /** + * @generated from oneof ChatMessage.payload + */ + payload: { + /** + * @generated from field: StickerMessage sticker = 9; + */ + value: StickerMessage; + case: "sticker"; + } | { + /** + * @generated from field: ImageMessage image = 10; + */ + value: ImageMessage; + case: "image"; + } | { + /** + * @generated from field: AudioMessage audio = 11; + */ + value: AudioMessage; + case: "audio"; + } | { + /** + * @generated from field: bytes community = 12; + */ + value: Uint8Array; + case: "community"; + } | { case: undefined; value?: undefined } = { case: undefined }; + + /** + * Grant for community chat messages + * + * @generated from field: bytes grant = 13; + */ + grant = new Uint8Array(0); + + /** + * Message author's display name, introduced in version 1 + * + * @generated from field: string display_name = 14; + */ + displayName = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "ChatMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "timestamp", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 3, name: "text", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "response_to", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 5, name: "ens_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 7, name: "message_type", kind: "enum", T: proto3.getEnumType(MessageType) }, + { no: 8, name: "content_type", kind: "enum", T: proto3.getEnumType(ChatMessage_ContentType) }, + { no: 9, name: "sticker", kind: "message", T: StickerMessage, oneof: "payload" }, + { no: 10, name: "image", kind: "message", T: ImageMessage, oneof: "payload" }, + { no: 11, name: "audio", kind: "message", T: AudioMessage, oneof: "payload" }, + { no: 12, name: "community", kind: "scalar", T: 12 /* ScalarType.BYTES */, oneof: "payload" }, + { no: 13, name: "grant", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 14, name: "display_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ChatMessage { + return new ChatMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ChatMessage { + return new ChatMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ChatMessage { + return new ChatMessage().fromJsonString(jsonString, options); + } + + static equals(a: ChatMessage | PlainMessage | undefined, b: ChatMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(ChatMessage, a, b); + } +} + +/** + * @generated from enum ChatMessage.ContentType + */ +export enum ChatMessage_ContentType { + /** + * @generated from enum value: UNKNOWN_CONTENT_TYPE = 0; + */ + UNKNOWN_CONTENT_TYPE = 0, + + /** + * @generated from enum value: TEXT_PLAIN = 1; + */ + TEXT_PLAIN = 1, + + /** + * @generated from enum value: STICKER = 2; + */ + STICKER = 2, + + /** + * @generated from enum value: STATUS = 3; + */ + STATUS = 3, + + /** + * @generated from enum value: EMOJI = 4; + */ + EMOJI = 4, + + /** + * @generated from enum value: TRANSACTION_COMMAND = 5; + */ + TRANSACTION_COMMAND = 5, + + /** + * Only local + * + * @generated from enum value: SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 6; + */ + SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 6, + + /** + * @generated from enum value: IMAGE = 7; + */ + IMAGE = 7, + + /** + * @generated from enum value: AUDIO = 8; + */ + AUDIO = 8, + + /** + * @generated from enum value: COMMUNITY = 9; + */ + COMMUNITY = 9, + + /** + * Only local + * + * @generated from enum value: SYSTEM_MESSAGE_GAP = 10; + */ + SYSTEM_MESSAGE_GAP = 10, +} +// Retrieve enum metadata with: proto3.getEnumType(ChatMessage_ContentType) +proto3.util.setEnumType(ChatMessage_ContentType, "ChatMessage.ContentType", [ + { no: 0, name: "UNKNOWN_CONTENT_TYPE" }, + { no: 1, name: "TEXT_PLAIN" }, + { no: 2, name: "STICKER" }, + { no: 3, name: "STATUS" }, + { no: 4, name: "EMOJI" }, + { no: 5, name: "TRANSACTION_COMMAND" }, + { no: 6, name: "SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP" }, + { no: 7, name: "IMAGE" }, + { no: 8, name: "AUDIO" }, + { no: 9, name: "COMMUNITY" }, + { no: 10, name: "SYSTEM_MESSAGE_GAP" }, +]); + diff --git a/packages/status-js/src/protos/communities-old.proto b/packages/status-js/src/protos/communities-old.proto deleted file mode 100644 index 67f2028f..00000000 --- a/packages/status-js/src/protos/communities-old.proto +++ /dev/null @@ -1,78 +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 members = 2; - CommunityPermissions permissions = 3; - ChatIdentity identity = 5; - map chats = 6; - repeated string ban_list = 7; - map categories = 8; -} - -message CommunityChat { - map 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; -} diff --git a/packages/status-js/src/protos/communities-old.ts b/packages/status-js/src/protos/communities-old.ts deleted file mode 100644 index c6876e86..00000000 --- a/packages/status-js/src/protos/communities-old.ts +++ /dev/null @@ -1,400 +0,0 @@ -/* eslint-disable import/export */ -/* eslint-disable @typescript-eslint/no-namespace */ - -import { encodeMessage, decodeMessage, message, bytes, string, uint64, enumeration, bool, int32 } 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 => { - return message({ - 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(__RolesValues) - } - } - - export const codec = (): Codec => { - return message({ - 1: { name: 'roles', codec: CommunityMember.Roles.codec() } - }) - } - - 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(__AccessValues) - } - } - - export const codec = (): Codec => { - return message({ - 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 -} - -export namespace CommunityDescription { - export const codec = (): Codec => { - return message({ - 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() } - }) - } - - export const encode = (obj: CommunityDescription): Uint8Array => { - return encodeMessage(obj, CommunityDescription.codec()) - } - - export const decode = (buf: Uint8Array): CommunityDescription => { - return decodeMessage(buf, CommunityDescription.codec()) - } -} - -export interface CommunityChat { - members: CommunityMember - permissions: CommunityPermissions - identity: ChatIdentity - categoryId: string - position: number -} - -export namespace CommunityChat { - export const codec = (): Codec => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 ChatIdentity { - clock: bigint - ensName: string - images: IdentityImage - displayName: string - description: string - color: string - emoji: string -} - -export namespace ChatIdentity { - export const codec = (): Codec => { - return message({ - 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(__SourceTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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(__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(__ImageTypeValues) - } -} diff --git a/packages/status-js/src/protos/communities.proto b/packages/status-js/src/protos/communities.proto index a9ec84b6..4d8412ec 100644 --- a/packages/status-js/src/protos/communities.proto +++ b/packages/status-js/src/protos/communities.proto @@ -14,6 +14,7 @@ message CommunityMember { UNKNOWN_ROLE = 0; ROLE_ALL = 1; ROLE_MANAGE_USERS = 2; + ROLE_MODERATE_CONTENT = 3; } repeated Roles roles = 1; } @@ -42,6 +43,10 @@ message CommunityDescription { map categories = 8; uint64 archive_magnetlink_clock = 9; CommunityAdminSettings admin_settings = 10; + string intro_message = 11; + string outro_message = 12; + bool encrypted = 13; + repeated string tags = 14; } message CommunityAdminSettings { @@ -74,6 +79,15 @@ message CommunityRequestToJoin { string ens_name = 2; string chat_id = 3; bytes community_id = 4; + string display_name = 5; +} + +message CommunityCancelRequestToJoin { + uint64 clock = 1; + string ens_name = 2; + string chat_id = 3; + bytes community_id = 4; + string display_name = 5; } message CommunityRequestToJoinResponse { @@ -81,6 +95,13 @@ message CommunityRequestToJoinResponse { CommunityDescription community = 2; bool accepted = 3; bytes grant = 4; + bytes community_id = 5; + string magnet_uri = 6; +} + +message CommunityRequestToLeave { + uint64 clock = 1; + bytes community_id = 2; } message CommunityMessageArchiveMagnetlink { @@ -95,6 +116,7 @@ message WakuMessage { bytes payload = 4; bytes padding = 5; bytes hash = 6; + string thirdPartyId = 7; } message WakuMessageArchiveMetadata { diff --git a/packages/status-js/src/protos/communities.ts b/packages/status-js/src/protos/communities.ts deleted file mode 100644 index 3eb498ba..00000000 --- a/packages/status-js/src/protos/communities.ts +++ /dev/null @@ -1,574 +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 => { - return message({ - 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(__RolesValues) - } - } - - export const codec = (): Codec => { - return message({ - 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(__AccessValues) - } - } - - export const codec = (): Codec => { - return message({ - 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: Record - permissions: CommunityPermissions - identity: ChatIdentity - chats: Record - banList: string[] - categories: Record - archiveMagnetlinkClock: bigint - adminSettings: CommunityAdminSettings -} - -export namespace CommunityDescription { - export const codec = (): Codec => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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(__SourceTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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(__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(__ImageTypeValues) - } -} diff --git a/packages/status-js/src/protos/communities_pb.ts b/packages/status-js/src/protos/communities_pb.ts new file mode 100644 index 00000000..2236d70a --- /dev/null +++ b/packages/status-js/src/protos/communities_pb.ts @@ -0,0 +1,1077 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file communities.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; +import { ChatIdentity } from "./chat-identity_pb.js"; + +/** + * @generated from message Grant + */ +export class Grant extends Message { + /** + * @generated from field: bytes community_id = 1; + */ + communityId = new Uint8Array(0); + + /** + * @generated from field: bytes member_id = 2; + */ + memberId = new Uint8Array(0); + + /** + * @generated from field: string chat_id = 3; + */ + chatId = ""; + + /** + * @generated from field: uint64 clock = 4; + */ + clock = protoInt64.zero; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "Grant"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "community_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "member_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 3, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Grant { + return new Grant().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Grant { + return new Grant().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Grant { + return new Grant().fromJsonString(jsonString, options); + } + + static equals(a: Grant | PlainMessage | undefined, b: Grant | PlainMessage | undefined): boolean { + return proto3.util.equals(Grant, a, b); + } +} + +/** + * @generated from message CommunityMember + */ +export class CommunityMember extends Message { + /** + * @generated from field: repeated CommunityMember.Roles roles = 1; + */ + roles: CommunityMember_Roles[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityMember"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "roles", kind: "enum", T: proto3.getEnumType(CommunityMember_Roles), repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityMember { + return new CommunityMember().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityMember { + return new CommunityMember().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityMember { + return new CommunityMember().fromJsonString(jsonString, options); + } + + static equals(a: CommunityMember | PlainMessage | undefined, b: CommunityMember | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityMember, a, b); + } +} + +/** + * @generated from enum CommunityMember.Roles + */ +export enum CommunityMember_Roles { + /** + * @generated from enum value: UNKNOWN_ROLE = 0; + */ + UNKNOWN_ROLE = 0, + + /** + * @generated from enum value: ROLE_ALL = 1; + */ + ROLE_ALL = 1, + + /** + * @generated from enum value: ROLE_MANAGE_USERS = 2; + */ + ROLE_MANAGE_USERS = 2, + + /** + * @generated from enum value: ROLE_MODERATE_CONTENT = 3; + */ + ROLE_MODERATE_CONTENT = 3, +} +// Retrieve enum metadata with: proto3.getEnumType(CommunityMember_Roles) +proto3.util.setEnumType(CommunityMember_Roles, "CommunityMember.Roles", [ + { no: 0, name: "UNKNOWN_ROLE" }, + { no: 1, name: "ROLE_ALL" }, + { no: 2, name: "ROLE_MANAGE_USERS" }, + { no: 3, name: "ROLE_MODERATE_CONTENT" }, +]); + +/** + * @generated from message CommunityPermissions + */ +export class CommunityPermissions extends Message { + /** + * @generated from field: bool ens_only = 1; + */ + ensOnly = false; + + /** + * 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 + * + * @generated from field: bool private = 2; + */ + private = false; + + /** + * @generated from field: CommunityPermissions.Access access = 3; + */ + access = CommunityPermissions_Access.UNKNOWN_ACCESS; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityPermissions"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "ens_only", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 2, name: "private", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 3, name: "access", kind: "enum", T: proto3.getEnumType(CommunityPermissions_Access) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityPermissions { + return new CommunityPermissions().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityPermissions { + return new CommunityPermissions().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityPermissions { + return new CommunityPermissions().fromJsonString(jsonString, options); + } + + static equals(a: CommunityPermissions | PlainMessage | undefined, b: CommunityPermissions | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityPermissions, a, b); + } +} + +/** + * @generated from enum CommunityPermissions.Access + */ +export enum CommunityPermissions_Access { + /** + * @generated from enum value: UNKNOWN_ACCESS = 0; + */ + UNKNOWN_ACCESS = 0, + + /** + * @generated from enum value: NO_MEMBERSHIP = 1; + */ + NO_MEMBERSHIP = 1, + + /** + * @generated from enum value: INVITATION_ONLY = 2; + */ + INVITATION_ONLY = 2, + + /** + * @generated from enum value: ON_REQUEST = 3; + */ + ON_REQUEST = 3, +} +// Retrieve enum metadata with: proto3.getEnumType(CommunityPermissions_Access) +proto3.util.setEnumType(CommunityPermissions_Access, "CommunityPermissions.Access", [ + { no: 0, name: "UNKNOWN_ACCESS" }, + { no: 1, name: "NO_MEMBERSHIP" }, + { no: 2, name: "INVITATION_ONLY" }, + { no: 3, name: "ON_REQUEST" }, +]); + +/** + * @generated from message CommunityDescription + */ +export class CommunityDescription extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: map members = 2; + */ + members: { [key: string]: CommunityMember } = {}; + + /** + * @generated from field: CommunityPermissions permissions = 3; + */ + permissions?: CommunityPermissions; + + /** + * @generated from field: ChatIdentity identity = 5; + */ + identity?: ChatIdentity; + + /** + * @generated from field: map chats = 6; + */ + chats: { [key: string]: CommunityChat } = {}; + + /** + * @generated from field: repeated string ban_list = 7; + */ + banList: string[] = []; + + /** + * @generated from field: map categories = 8; + */ + categories: { [key: string]: CommunityCategory } = {}; + + /** + * @generated from field: uint64 archive_magnetlink_clock = 9; + */ + archiveMagnetlinkClock = protoInt64.zero; + + /** + * @generated from field: CommunityAdminSettings admin_settings = 10; + */ + adminSettings?: CommunityAdminSettings; + + /** + * @generated from field: string intro_message = 11; + */ + introMessage = ""; + + /** + * @generated from field: string outro_message = 12; + */ + outroMessage = ""; + + /** + * @generated from field: bool encrypted = 13; + */ + encrypted = false; + + /** + * @generated from field: repeated string tags = 14; + */ + tags: string[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityDescription"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "members", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: CommunityMember} }, + { no: 3, name: "permissions", kind: "message", T: CommunityPermissions }, + { no: 5, name: "identity", kind: "message", T: ChatIdentity }, + { no: 6, name: "chats", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: CommunityChat} }, + { no: 7, name: "ban_list", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + { no: 8, name: "categories", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: CommunityCategory} }, + { no: 9, name: "archive_magnetlink_clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 10, name: "admin_settings", kind: "message", T: CommunityAdminSettings }, + { no: 11, name: "intro_message", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 12, name: "outro_message", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 13, name: "encrypted", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 14, name: "tags", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityDescription { + return new CommunityDescription().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityDescription { + return new CommunityDescription().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityDescription { + return new CommunityDescription().fromJsonString(jsonString, options); + } + + static equals(a: CommunityDescription | PlainMessage | undefined, b: CommunityDescription | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityDescription, a, b); + } +} + +/** + * @generated from message CommunityAdminSettings + */ +export class CommunityAdminSettings extends Message { + /** + * @generated from field: bool pin_message_all_members_enabled = 1; + */ + pinMessageAllMembersEnabled = false; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityAdminSettings"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "pin_message_all_members_enabled", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityAdminSettings { + return new CommunityAdminSettings().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityAdminSettings { + return new CommunityAdminSettings().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityAdminSettings { + return new CommunityAdminSettings().fromJsonString(jsonString, options); + } + + static equals(a: CommunityAdminSettings | PlainMessage | undefined, b: CommunityAdminSettings | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityAdminSettings, a, b); + } +} + +/** + * @generated from message CommunityChat + */ +export class CommunityChat extends Message { + /** + * @generated from field: map members = 1; + */ + members: { [key: string]: CommunityMember } = {}; + + /** + * @generated from field: CommunityPermissions permissions = 2; + */ + permissions?: CommunityPermissions; + + /** + * @generated from field: ChatIdentity identity = 3; + */ + identity?: ChatIdentity; + + /** + * @generated from field: string category_id = 4; + */ + categoryId = ""; + + /** + * @generated from field: int32 position = 5; + */ + position = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityChat"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "members", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: CommunityMember} }, + { no: 2, name: "permissions", kind: "message", T: CommunityPermissions }, + { no: 3, name: "identity", kind: "message", T: ChatIdentity }, + { no: 4, name: "category_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 5, name: "position", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityChat { + return new CommunityChat().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityChat { + return new CommunityChat().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityChat { + return new CommunityChat().fromJsonString(jsonString, options); + } + + static equals(a: CommunityChat | PlainMessage | undefined, b: CommunityChat | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityChat, a, b); + } +} + +/** + * @generated from message CommunityCategory + */ +export class CommunityCategory extends Message { + /** + * @generated from field: string category_id = 1; + */ + categoryId = ""; + + /** + * @generated from field: string name = 2; + */ + name = ""; + + /** + * @generated from field: int32 position = 3; + */ + position = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityCategory"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "category_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "position", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityCategory { + return new CommunityCategory().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityCategory { + return new CommunityCategory().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityCategory { + return new CommunityCategory().fromJsonString(jsonString, options); + } + + static equals(a: CommunityCategory | PlainMessage | undefined, b: CommunityCategory | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityCategory, a, b); + } +} + +/** + * @generated from message CommunityInvitation + */ +export class CommunityInvitation extends Message { + /** + * @generated from field: bytes community_description = 1; + */ + communityDescription = new Uint8Array(0); + + /** + * @generated from field: bytes grant = 2; + */ + grant = new Uint8Array(0); + + /** + * @generated from field: string chat_id = 3; + */ + chatId = ""; + + /** + * @generated from field: bytes public_key = 4; + */ + publicKey = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityInvitation"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "community_description", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "grant", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 3, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "public_key", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityInvitation { + return new CommunityInvitation().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityInvitation { + return new CommunityInvitation().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityInvitation { + return new CommunityInvitation().fromJsonString(jsonString, options); + } + + static equals(a: CommunityInvitation | PlainMessage | undefined, b: CommunityInvitation | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityInvitation, a, b); + } +} + +/** + * @generated from message CommunityRequestToJoin + */ +export class CommunityRequestToJoin extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: string ens_name = 2; + */ + ensName = ""; + + /** + * @generated from field: string chat_id = 3; + */ + chatId = ""; + + /** + * @generated from field: bytes community_id = 4; + */ + communityId = new Uint8Array(0); + + /** + * @generated from field: string display_name = 5; + */ + displayName = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityRequestToJoin"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "ens_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "community_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 5, name: "display_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityRequestToJoin { + return new CommunityRequestToJoin().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityRequestToJoin { + return new CommunityRequestToJoin().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityRequestToJoin { + return new CommunityRequestToJoin().fromJsonString(jsonString, options); + } + + static equals(a: CommunityRequestToJoin | PlainMessage | undefined, b: CommunityRequestToJoin | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityRequestToJoin, a, b); + } +} + +/** + * @generated from message CommunityCancelRequestToJoin + */ +export class CommunityCancelRequestToJoin extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: string ens_name = 2; + */ + ensName = ""; + + /** + * @generated from field: string chat_id = 3; + */ + chatId = ""; + + /** + * @generated from field: bytes community_id = 4; + */ + communityId = new Uint8Array(0); + + /** + * @generated from field: string display_name = 5; + */ + displayName = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityCancelRequestToJoin"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "ens_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "community_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 5, name: "display_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityCancelRequestToJoin { + return new CommunityCancelRequestToJoin().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityCancelRequestToJoin { + return new CommunityCancelRequestToJoin().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityCancelRequestToJoin { + return new CommunityCancelRequestToJoin().fromJsonString(jsonString, options); + } + + static equals(a: CommunityCancelRequestToJoin | PlainMessage | undefined, b: CommunityCancelRequestToJoin | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityCancelRequestToJoin, a, b); + } +} + +/** + * @generated from message CommunityRequestToJoinResponse + */ +export class CommunityRequestToJoinResponse extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: CommunityDescription community = 2; + */ + community?: CommunityDescription; + + /** + * @generated from field: bool accepted = 3; + */ + accepted = false; + + /** + * @generated from field: bytes grant = 4; + */ + grant = new Uint8Array(0); + + /** + * @generated from field: bytes community_id = 5; + */ + communityId = new Uint8Array(0); + + /** + * @generated from field: string magnet_uri = 6; + */ + magnetUri = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityRequestToJoinResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "community", kind: "message", T: CommunityDescription }, + { no: 3, name: "accepted", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 4, name: "grant", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 5, name: "community_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 6, name: "magnet_uri", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityRequestToJoinResponse { + return new CommunityRequestToJoinResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityRequestToJoinResponse { + return new CommunityRequestToJoinResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityRequestToJoinResponse { + return new CommunityRequestToJoinResponse().fromJsonString(jsonString, options); + } + + static equals(a: CommunityRequestToJoinResponse | PlainMessage | undefined, b: CommunityRequestToJoinResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityRequestToJoinResponse, a, b); + } +} + +/** + * @generated from message CommunityRequestToLeave + */ +export class CommunityRequestToLeave extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: bytes community_id = 2; + */ + communityId = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityRequestToLeave"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "community_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityRequestToLeave { + return new CommunityRequestToLeave().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityRequestToLeave { + return new CommunityRequestToLeave().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityRequestToLeave { + return new CommunityRequestToLeave().fromJsonString(jsonString, options); + } + + static equals(a: CommunityRequestToLeave | PlainMessage | undefined, b: CommunityRequestToLeave | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityRequestToLeave, a, b); + } +} + +/** + * @generated from message CommunityMessageArchiveMagnetlink + */ +export class CommunityMessageArchiveMagnetlink extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: string magnet_uri = 2; + */ + magnetUri = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "CommunityMessageArchiveMagnetlink"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "magnet_uri", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CommunityMessageArchiveMagnetlink { + return new CommunityMessageArchiveMagnetlink().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CommunityMessageArchiveMagnetlink { + return new CommunityMessageArchiveMagnetlink().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CommunityMessageArchiveMagnetlink { + return new CommunityMessageArchiveMagnetlink().fromJsonString(jsonString, options); + } + + static equals(a: CommunityMessageArchiveMagnetlink | PlainMessage | undefined, b: CommunityMessageArchiveMagnetlink | PlainMessage | undefined): boolean { + return proto3.util.equals(CommunityMessageArchiveMagnetlink, a, b); + } +} + +/** + * @generated from message WakuMessage + */ +export class WakuMessage extends Message { + /** + * @generated from field: bytes sig = 1; + */ + sig = new Uint8Array(0); + + /** + * @generated from field: uint64 timestamp = 2; + */ + timestamp = protoInt64.zero; + + /** + * @generated from field: bytes topic = 3; + */ + topic = new Uint8Array(0); + + /** + * @generated from field: bytes payload = 4; + */ + payload = new Uint8Array(0); + + /** + * @generated from field: bytes padding = 5; + */ + padding = new Uint8Array(0); + + /** + * @generated from field: bytes hash = 6; + */ + hash = new Uint8Array(0); + + /** + * @generated from field: string thirdPartyId = 7; + */ + thirdPartyId = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "WakuMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "timestamp", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 3, name: "topic", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 4, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 5, name: "padding", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 6, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 7, name: "thirdPartyId", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WakuMessage { + return new WakuMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WakuMessage { + return new WakuMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WakuMessage { + return new WakuMessage().fromJsonString(jsonString, options); + } + + static equals(a: WakuMessage | PlainMessage | undefined, b: WakuMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(WakuMessage, a, b); + } +} + +/** + * @generated from message WakuMessageArchiveMetadata + */ +export class WakuMessageArchiveMetadata extends Message { + /** + * @generated from field: uint32 version = 1; + */ + version = 0; + + /** + * @generated from field: uint64 from = 2; + */ + from = protoInt64.zero; + + /** + * @generated from field: uint64 to = 3; + */ + to = protoInt64.zero; + + /** + * @generated from field: repeated bytes contentTopic = 4; + */ + contentTopic: Uint8Array[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "WakuMessageArchiveMetadata"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "version", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 2, name: "from", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 3, name: "to", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 4, name: "contentTopic", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WakuMessageArchiveMetadata { + return new WakuMessageArchiveMetadata().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WakuMessageArchiveMetadata { + return new WakuMessageArchiveMetadata().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WakuMessageArchiveMetadata { + return new WakuMessageArchiveMetadata().fromJsonString(jsonString, options); + } + + static equals(a: WakuMessageArchiveMetadata | PlainMessage | undefined, b: WakuMessageArchiveMetadata | PlainMessage | undefined): boolean { + return proto3.util.equals(WakuMessageArchiveMetadata, a, b); + } +} + +/** + * @generated from message WakuMessageArchive + */ +export class WakuMessageArchive extends Message { + /** + * @generated from field: uint32 version = 1; + */ + version = 0; + + /** + * @generated from field: WakuMessageArchiveMetadata metadata = 2; + */ + metadata?: WakuMessageArchiveMetadata; + + /** + * @generated from field: repeated WakuMessage messages = 3; + */ + messages: WakuMessage[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "WakuMessageArchive"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "version", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 2, name: "metadata", kind: "message", T: WakuMessageArchiveMetadata }, + { no: 3, name: "messages", kind: "message", T: WakuMessage, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WakuMessageArchive { + return new WakuMessageArchive().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WakuMessageArchive { + return new WakuMessageArchive().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WakuMessageArchive { + return new WakuMessageArchive().fromJsonString(jsonString, options); + } + + static equals(a: WakuMessageArchive | PlainMessage | undefined, b: WakuMessageArchive | PlainMessage | undefined): boolean { + return proto3.util.equals(WakuMessageArchive, a, b); + } +} + +/** + * @generated from message WakuMessageArchiveIndexMetadata + */ +export class WakuMessageArchiveIndexMetadata extends Message { + /** + * @generated from field: uint32 version = 1; + */ + version = 0; + + /** + * @generated from field: WakuMessageArchiveMetadata metadata = 2; + */ + metadata?: WakuMessageArchiveMetadata; + + /** + * @generated from field: uint64 offset = 3; + */ + offset = protoInt64.zero; + + /** + * @generated from field: uint64 size = 4; + */ + size = protoInt64.zero; + + /** + * @generated from field: uint64 padding = 5; + */ + padding = protoInt64.zero; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "WakuMessageArchiveIndexMetadata"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "version", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 2, name: "metadata", kind: "message", T: WakuMessageArchiveMetadata }, + { no: 3, name: "offset", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 4, name: "size", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 5, name: "padding", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WakuMessageArchiveIndexMetadata { + return new WakuMessageArchiveIndexMetadata().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WakuMessageArchiveIndexMetadata { + return new WakuMessageArchiveIndexMetadata().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WakuMessageArchiveIndexMetadata { + return new WakuMessageArchiveIndexMetadata().fromJsonString(jsonString, options); + } + + static equals(a: WakuMessageArchiveIndexMetadata | PlainMessage | undefined, b: WakuMessageArchiveIndexMetadata | PlainMessage | undefined): boolean { + return proto3.util.equals(WakuMessageArchiveIndexMetadata, a, b); + } +} + +/** + * @generated from message WakuMessageArchiveIndex + */ +export class WakuMessageArchiveIndex extends Message { + /** + * @generated from field: map archives = 1; + */ + archives: { [key: string]: WakuMessageArchiveIndexMetadata } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "WakuMessageArchiveIndex"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "archives", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: WakuMessageArchiveIndexMetadata} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WakuMessageArchiveIndex { + return new WakuMessageArchiveIndex().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WakuMessageArchiveIndex { + return new WakuMessageArchiveIndex().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WakuMessageArchiveIndex { + return new WakuMessageArchiveIndex().fromJsonString(jsonString, options); + } + + static equals(a: WakuMessageArchiveIndex | PlainMessage | undefined, b: WakuMessageArchiveIndex | PlainMessage | undefined): boolean { + return proto3.util.equals(WakuMessageArchiveIndex, a, b); + } +} + diff --git a/packages/status-js/src/protos/emoji-reaction.ts b/packages/status-js/src/protos/emoji-reaction.ts deleted file mode 100644 index 635c39fe..00000000 --- a/packages/status-js/src/protos/emoji-reaction.ts +++ /dev/null @@ -1,110 +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(__TypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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(__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(__ImageTypeValues) - } -} diff --git a/packages/status-js/src/protos/emoji-reaction_pb.ts b/packages/status-js/src/protos/emoji-reaction_pb.ts new file mode 100644 index 00000000..55a4d333 --- /dev/null +++ b/packages/status-js/src/protos/emoji-reaction_pb.ts @@ -0,0 +1,147 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file emoji-reaction.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; +import { MessageType } from "./enums_pb.js"; + +/** + * @generated from message EmojiReaction + */ +export class EmojiReaction extends Message { + /** + * clock Lamport timestamp of the chat message + * + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * 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 + * + * @generated from field: string chat_id = 2; + */ + chatId = ""; + + /** + * message_id the ID of the target message that the user wishes to react to + * + * @generated from field: string message_id = 3; + */ + messageId = ""; + + /** + * message_type is (somewhat confusingly) the ID of the type of chat the message belongs to + * + * @generated from field: MessageType message_type = 4; + */ + messageType = MessageType.UNKNOWN_MESSAGE_TYPE; + + /** + * type the ID of the emoji the user wishes to react with + * + * @generated from field: EmojiReaction.Type type = 5; + */ + type = EmojiReaction_Type.UNKNOWN_EMOJI_REACTION_TYPE; + + /** + * whether this is a rectraction of a previously sent emoji + * + * @generated from field: bool retracted = 6; + */ + retracted = false; + + /** + * Grant for organisation chat messages + * + * @generated from field: bytes grant = 7; + */ + grant = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "EmojiReaction"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "message_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "message_type", kind: "enum", T: proto3.getEnumType(MessageType) }, + { no: 5, name: "type", kind: "enum", T: proto3.getEnumType(EmojiReaction_Type) }, + { no: 6, name: "retracted", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 7, name: "grant", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): EmojiReaction { + return new EmojiReaction().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): EmojiReaction { + return new EmojiReaction().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): EmojiReaction { + return new EmojiReaction().fromJsonString(jsonString, options); + } + + static equals(a: EmojiReaction | PlainMessage | undefined, b: EmojiReaction | PlainMessage | undefined): boolean { + return proto3.util.equals(EmojiReaction, a, b); + } +} + +/** + * @generated from enum EmojiReaction.Type + */ +export enum EmojiReaction_Type { + /** + * @generated from enum value: UNKNOWN_EMOJI_REACTION_TYPE = 0; + */ + UNKNOWN_EMOJI_REACTION_TYPE = 0, + + /** + * @generated from enum value: LOVE = 1; + */ + LOVE = 1, + + /** + * @generated from enum value: THUMBS_UP = 2; + */ + THUMBS_UP = 2, + + /** + * @generated from enum value: THUMBS_DOWN = 3; + */ + THUMBS_DOWN = 3, + + /** + * @generated from enum value: LAUGH = 4; + */ + LAUGH = 4, + + /** + * @generated from enum value: SAD = 5; + */ + SAD = 5, + + /** + * @generated from enum value: ANGRY = 6; + */ + ANGRY = 6, +} +// Retrieve enum metadata with: proto3.getEnumType(EmojiReaction_Type) +proto3.util.setEnumType(EmojiReaction_Type, "EmojiReaction.Type", [ + { no: 0, name: "UNKNOWN_EMOJI_REACTION_TYPE" }, + { no: 1, name: "LOVE" }, + { no: 2, name: "THUMBS_UP" }, + { no: 3, name: "THUMBS_DOWN" }, + { no: 4, name: "LAUGH" }, + { no: 5, name: "SAD" }, + { no: 6, name: "ANGRY" }, +]); + diff --git a/packages/status-js/src/protos/enums.ts b/packages/status-js/src/protos/enums.ts deleted file mode 100644 index b06d2dc3..00000000 --- a/packages/status-js/src/protos/enums.ts +++ /dev/null @@ -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(__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(__ImageTypeValues) - } -} diff --git a/packages/status-js/src/protos/enums_pb.ts b/packages/status-js/src/protos/enums_pb.ts new file mode 100644 index 00000000..bab9f9e9 --- /dev/null +++ b/packages/status-js/src/protos/enums_pb.ts @@ -0,0 +1,101 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file enums.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from enum MessageType + */ +export enum MessageType { + /** + * @generated from enum value: UNKNOWN_MESSAGE_TYPE = 0; + */ + UNKNOWN_MESSAGE_TYPE = 0, + + /** + * @generated from enum value: ONE_TO_ONE = 1; + */ + ONE_TO_ONE = 1, + + /** + * @generated from enum value: PUBLIC_GROUP = 2; + */ + PUBLIC_GROUP = 2, + + /** + * @generated from enum value: PRIVATE_GROUP = 3; + */ + PRIVATE_GROUP = 3, + + /** + * Only local + * + * @generated from enum value: SYSTEM_MESSAGE_PRIVATE_GROUP = 4; + */ + SYSTEM_MESSAGE_PRIVATE_GROUP = 4, + + /** + * @generated from enum value: COMMUNITY_CHAT = 5; + */ + COMMUNITY_CHAT = 5, + + /** + * Only local + * + * @generated from enum value: SYSTEM_MESSAGE_GAP = 6; + */ + SYSTEM_MESSAGE_GAP = 6, +} +// Retrieve enum metadata with: proto3.getEnumType(MessageType) +proto3.util.setEnumType(MessageType, "MessageType", [ + { no: 0, name: "UNKNOWN_MESSAGE_TYPE" }, + { no: 1, name: "ONE_TO_ONE" }, + { no: 2, name: "PUBLIC_GROUP" }, + { no: 3, name: "PRIVATE_GROUP" }, + { no: 4, name: "SYSTEM_MESSAGE_PRIVATE_GROUP" }, + { no: 5, name: "COMMUNITY_CHAT" }, + { no: 6, name: "SYSTEM_MESSAGE_GAP" }, +]); + +/** + * @generated from enum ImageType + */ +export enum ImageType { + /** + * @generated from enum value: UNKNOWN_IMAGE_TYPE = 0; + */ + UNKNOWN_IMAGE_TYPE = 0, + + /** + * Raster image files is payload data that can be read as a raster image + * + * @generated from enum value: PNG = 1; + */ + PNG = 1, + + /** + * @generated from enum value: JPEG = 2; + */ + JPEG = 2, + + /** + * @generated from enum value: WEBP = 3; + */ + WEBP = 3, + + /** + * @generated from enum value: GIF = 4; + */ + GIF = 4, +} +// Retrieve enum metadata with: proto3.getEnumType(ImageType) +proto3.util.setEnumType(ImageType, "ImageType", [ + { no: 0, name: "UNKNOWN_IMAGE_TYPE" }, + { no: 1, name: "PNG" }, + { no: 2, name: "JPEG" }, + { no: 3, name: "WEBP" }, + { no: 4, name: "GIF" }, +]); + diff --git a/packages/status-js/src/protos/membership-update-message.ts b/packages/status-js/src/protos/membership-update-message.ts deleted file mode 100644 index 720ab478..00000000 --- a/packages/status-js/src/protos/membership-update-message.ts +++ /dev/null @@ -1,413 +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(__EventTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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(__AudioTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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(__ContentTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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(__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(__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(__TypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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()) - } -} diff --git a/packages/status-js/src/protos/membership-update-message_pb.ts b/packages/status-js/src/protos/membership-update-message_pb.ts new file mode 100644 index 00000000..ea5a2f63 --- /dev/null +++ b/packages/status-js/src/protos/membership-update-message_pb.ts @@ -0,0 +1,202 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file membership-update-message.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; +import { ChatMessage } from "./chat-message_pb.js"; +import { EmojiReaction } from "./emoji-reaction_pb.js"; + +/** + * @generated from message MembershipUpdateEvent + */ +export class MembershipUpdateEvent extends Message { + /** + * Lamport timestamp of the event + * + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * List of public keys of objects of the action + * + * @generated from field: repeated string members = 2; + */ + members: string[] = []; + + /** + * Name of the chat for the CHAT_CREATED/NAME_CHANGED event types + * + * @generated from field: string name = 3; + */ + name = ""; + + /** + * The type of the event + * + * @generated from field: MembershipUpdateEvent.EventType type = 4; + */ + type = MembershipUpdateEvent_EventType.UNKNOWN; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "MembershipUpdateEvent"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "members", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + { no: 3, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "type", kind: "enum", T: proto3.getEnumType(MembershipUpdateEvent_EventType) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): MembershipUpdateEvent { + return new MembershipUpdateEvent().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): MembershipUpdateEvent { + return new MembershipUpdateEvent().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): MembershipUpdateEvent { + return new MembershipUpdateEvent().fromJsonString(jsonString, options); + } + + static equals(a: MembershipUpdateEvent | PlainMessage | undefined, b: MembershipUpdateEvent | PlainMessage | undefined): boolean { + return proto3.util.equals(MembershipUpdateEvent, a, b); + } +} + +/** + * @generated from enum MembershipUpdateEvent.EventType + */ +export enum MembershipUpdateEvent_EventType { + /** + * @generated from enum value: UNKNOWN = 0; + */ + UNKNOWN = 0, + + /** + * @generated from enum value: CHAT_CREATED = 1; + */ + CHAT_CREATED = 1, + + /** + * @generated from enum value: NAME_CHANGED = 2; + */ + NAME_CHANGED = 2, + + /** + * @generated from enum value: MEMBERS_ADDED = 3; + */ + MEMBERS_ADDED = 3, + + /** + * @generated from enum value: MEMBER_JOINED = 4; + */ + MEMBER_JOINED = 4, + + /** + * @generated from enum value: MEMBER_REMOVED = 5; + */ + MEMBER_REMOVED = 5, + + /** + * @generated from enum value: ADMINS_ADDED = 6; + */ + ADMINS_ADDED = 6, + + /** + * @generated from enum value: ADMIN_REMOVED = 7; + */ + ADMIN_REMOVED = 7, +} +// Retrieve enum metadata with: proto3.getEnumType(MembershipUpdateEvent_EventType) +proto3.util.setEnumType(MembershipUpdateEvent_EventType, "MembershipUpdateEvent.EventType", [ + { no: 0, name: "UNKNOWN" }, + { no: 1, name: "CHAT_CREATED" }, + { no: 2, name: "NAME_CHANGED" }, + { no: 3, name: "MEMBERS_ADDED" }, + { no: 4, name: "MEMBER_JOINED" }, + { no: 5, name: "MEMBER_REMOVED" }, + { no: 6, name: "ADMINS_ADDED" }, + { no: 7, name: "ADMIN_REMOVED" }, +]); + +/** + * 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. + * + * @generated from message MembershipUpdateMessage + */ +export class MembershipUpdateMessage extends Message { + /** + * The chat id of the private group chat + * + * @generated from field: string chat_id = 1; + */ + chatId = ""; + + /** + * A list of events for this group chat, first x bytes are the signature, then is a + * protobuf encoded MembershipUpdateEvent + * + * @generated from field: repeated bytes events = 2; + */ + events: Uint8Array[] = []; + + /** + * An optional chat message + * + * @generated from oneof MembershipUpdateMessage.chat_entity + */ + chatEntity: { + /** + * @generated from field: ChatMessage message = 3; + */ + value: ChatMessage; + case: "message"; + } | { + /** + * @generated from field: EmojiReaction emoji_reaction = 4; + */ + value: EmojiReaction; + case: "emojiReaction"; + } | { case: undefined; value?: undefined } = { case: undefined }; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "MembershipUpdateMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "events", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true }, + { no: 3, name: "message", kind: "message", T: ChatMessage, oneof: "chat_entity" }, + { no: 4, name: "emoji_reaction", kind: "message", T: EmojiReaction, oneof: "chat_entity" }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): MembershipUpdateMessage { + return new MembershipUpdateMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): MembershipUpdateMessage { + return new MembershipUpdateMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): MembershipUpdateMessage { + return new MembershipUpdateMessage().fromJsonString(jsonString, options); + } + + static equals(a: MembershipUpdateMessage | PlainMessage | undefined, b: MembershipUpdateMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(MembershipUpdateMessage, a, b); + } +} + diff --git a/packages/status-js/src/protos/pin-message.ts b/packages/status-js/src/protos/pin-message.ts deleted file mode 100644 index 1036690e..00000000 --- a/packages/status-js/src/protos/pin-message.ts +++ /dev/null @@ -1,80 +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 => { - return message({ - 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(__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(__ImageTypeValues) - } -} diff --git a/packages/status-js/src/protos/pin-message_pb.ts b/packages/status-js/src/protos/pin-message_pb.ts new file mode 100644 index 00000000..3d019e12 --- /dev/null +++ b/packages/status-js/src/protos/pin-message_pb.ts @@ -0,0 +1,72 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file pin-message.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; +import { MessageType } from "./enums_pb.js"; + +/** + * @generated from message PinMessage + */ +export class PinMessage extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: string message_id = 2; + */ + messageId = ""; + + /** + * @generated from field: string chat_id = 3; + */ + chatId = ""; + + /** + * @generated from field: bool pinned = 4; + */ + pinned = false; + + /** + * The type of message (public/one-to-one/private-group-chat) + * + * @generated from field: MessageType message_type = 5; + */ + messageType = MessageType.UNKNOWN_MESSAGE_TYPE; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "PinMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "message_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "pinned", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 5, name: "message_type", kind: "enum", T: proto3.getEnumType(MessageType) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): PinMessage { + return new PinMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): PinMessage { + return new PinMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): PinMessage { + return new PinMessage().fromJsonString(jsonString, options); + } + + static equals(a: PinMessage | PlainMessage | undefined, b: PinMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(PinMessage, a, b); + } +} + diff --git a/packages/status-js/src/protos/protocol-message.ts b/packages/status-js/src/protos/protocol-message.ts deleted file mode 100644 index 02b2562b..00000000 --- a/packages/status-js/src/protos/protocol-message.ts +++ /dev/null @@ -1,223 +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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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 => { - return message({ - 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()) - } -} diff --git a/packages/status-js/src/protos/protocol-message_pb.ts b/packages/status-js/src/protos/protocol-message_pb.ts new file mode 100644 index 00000000..e43e71d4 --- /dev/null +++ b/packages/status-js/src/protos/protocol-message_pb.ts @@ -0,0 +1,506 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file protocol-message.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * @generated from message SignedPreKey + */ +export class SignedPreKey extends Message { + /** + * @generated from field: bytes signed_pre_key = 1; + */ + signedPreKey = new Uint8Array(0); + + /** + * @generated from field: uint32 version = 2; + */ + version = 0; + + /** + * @generated from field: uint32 protocol_version = 3; + */ + protocolVersion = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "SignedPreKey"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "signed_pre_key", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "version", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 3, name: "protocol_version", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): SignedPreKey { + return new SignedPreKey().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): SignedPreKey { + return new SignedPreKey().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): SignedPreKey { + return new SignedPreKey().fromJsonString(jsonString, options); + } + + static equals(a: SignedPreKey | PlainMessage | undefined, b: SignedPreKey | PlainMessage | undefined): boolean { + return proto3.util.equals(SignedPreKey, a, b); + } +} + +/** + * X3DH prekey bundle + * + * @generated from message Bundle + */ +export class Bundle extends Message { + /** + * Identity key + * + * @generated from field: bytes identity = 1; + */ + identity = new Uint8Array(0); + + /** + * Installation id + * + * @generated from field: map signed_pre_keys = 2; + */ + signedPreKeys: { [key: string]: SignedPreKey } = {}; + + /** + * Prekey signature + * + * @generated from field: bytes signature = 4; + */ + signature = new Uint8Array(0); + + /** + * When the bundle was created locally + * + * @generated from field: int64 timestamp = 5; + */ + timestamp = protoInt64.zero; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "Bundle"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "identity", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "signed_pre_keys", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: SignedPreKey} }, + { no: 4, name: "signature", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 5, name: "timestamp", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Bundle { + return new Bundle().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Bundle { + return new Bundle().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Bundle { + return new Bundle().fromJsonString(jsonString, options); + } + + static equals(a: Bundle | PlainMessage | undefined, b: Bundle | PlainMessage | undefined): boolean { + return proto3.util.equals(Bundle, a, b); + } +} + +/** + * @generated from message BundleContainer + */ +export class BundleContainer extends Message { + /** + * X3DH prekey bundle + * + * @generated from field: Bundle bundle = 1; + */ + bundle?: Bundle; + + /** + * Private signed prekey + * + * @generated from field: bytes private_signed_pre_key = 2; + */ + privateSignedPreKey = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "BundleContainer"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "bundle", kind: "message", T: Bundle }, + { no: 2, name: "private_signed_pre_key", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): BundleContainer { + return new BundleContainer().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): BundleContainer { + return new BundleContainer().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): BundleContainer { + return new BundleContainer().fromJsonString(jsonString, options); + } + + static equals(a: BundleContainer | PlainMessage | undefined, b: BundleContainer | PlainMessage | undefined): boolean { + return proto3.util.equals(BundleContainer, a, b); + } +} + +/** + * @generated from message DRHeader + */ +export class DRHeader extends Message { + /** + * Current ratchet public key + * + * @generated from field: bytes key = 1; + */ + key = new Uint8Array(0); + + /** + * Number of the message in the sending chain + * + * @generated from field: uint32 n = 2; + */ + n = 0; + + /** + * Length of the previous sending chain + * + * @generated from field: uint32 pn = 3; + */ + pn = 0; + + /** + * Bundle ID + * + * @generated from field: bytes id = 4; + */ + id = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "DRHeader"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "n", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 3, name: "pn", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 4, name: "id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DRHeader { + return new DRHeader().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DRHeader { + return new DRHeader().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DRHeader { + return new DRHeader().fromJsonString(jsonString, options); + } + + static equals(a: DRHeader | PlainMessage | undefined, b: DRHeader | PlainMessage | undefined): boolean { + return proto3.util.equals(DRHeader, a, b); + } +} + +/** + * @generated from message DHHeader + */ +export class DHHeader extends Message { + /** + * Compressed ephemeral public key + * + * @generated from field: bytes key = 1; + */ + key = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "DHHeader"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DHHeader { + return new DHHeader().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DHHeader { + return new DHHeader().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DHHeader { + return new DHHeader().fromJsonString(jsonString, options); + } + + static equals(a: DHHeader | PlainMessage | undefined, b: DHHeader | PlainMessage | undefined): boolean { + return proto3.util.equals(DHHeader, a, b); + } +} + +/** + * @generated from message X3DHHeader + */ +export class X3DHHeader extends Message { + /** + * Ephemeral key used + * + * @generated from field: bytes key = 1; + */ + key = new Uint8Array(0); + + /** + * Used bundle's signed prekey + * + * @generated from field: bytes id = 4; + */ + id = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "X3DHHeader"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 4, name: "id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): X3DHHeader { + return new X3DHHeader().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): X3DHHeader { + return new X3DHHeader().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): X3DHHeader { + return new X3DHHeader().fromJsonString(jsonString, options); + } + + static equals(a: X3DHHeader | PlainMessage | undefined, b: X3DHHeader | PlainMessage | undefined): boolean { + return proto3.util.equals(X3DHHeader, a, b); + } +} + +/** + * Hash Ratchet Header + * + * @generated from message HRHeader + */ +export class HRHeader extends Message { + /** + * community key ID + * + * @generated from field: uint32 key_id = 1; + */ + keyId = 0; + + /** + * Community message number for this key_id + * + * @generated from field: uint32 seq_no = 2; + */ + seqNo = 0; + + /** + * Community ID + * + * @generated from field: string group_id = 3; + */ + groupId = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "HRHeader"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key_id", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 2, name: "seq_no", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 3, name: "group_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): HRHeader { + return new HRHeader().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): HRHeader { + return new HRHeader().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): HRHeader { + return new HRHeader().fromJsonString(jsonString, options); + } + + static equals(a: HRHeader | PlainMessage | undefined, b: HRHeader | PlainMessage | undefined): boolean { + return proto3.util.equals(HRHeader, a, b); + } +} + +/** + * Direct message value + * + * @generated from message EncryptedMessageProtocol + */ +export class EncryptedMessageProtocol extends Message { + /** + * @generated from field: X3DHHeader X3DH_header = 1; + */ + X3DHHeader?: X3DHHeader; + + /** + * @generated from field: DRHeader DR_header = 2; + */ + DRHeader?: DRHeader; + + /** + * @generated from field: DHHeader DH_header = 101; + */ + DHHeader?: DHHeader; + + /** + * @generated from field: HRHeader HR_header = 102; + */ + HRHeader?: HRHeader; + + /** + * Encrypted payload + * + * @generated from field: bytes payload = 3; + */ + payload = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "EncryptedMessageProtocol"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "X3DH_header", kind: "message", T: X3DHHeader }, + { no: 2, name: "DR_header", kind: "message", T: DRHeader }, + { no: 101, name: "DH_header", kind: "message", T: DHHeader }, + { no: 102, name: "HR_header", kind: "message", T: HRHeader }, + { no: 3, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): EncryptedMessageProtocol { + return new EncryptedMessageProtocol().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): EncryptedMessageProtocol { + return new EncryptedMessageProtocol().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): EncryptedMessageProtocol { + return new EncryptedMessageProtocol().fromJsonString(jsonString, options); + } + + static equals(a: EncryptedMessageProtocol | PlainMessage | undefined, b: EncryptedMessageProtocol | PlainMessage | undefined): boolean { + return proto3.util.equals(EncryptedMessageProtocol, a, b); + } +} + +/** + * Top-level protocol message + * + * @generated from message ProtocolMessage + */ +export class ProtocolMessage extends Message { + /** + * The device id of the sender + * + * @generated from field: string installation_id = 2; + */ + installationId = ""; + + /** + * List of bundles + * + * @generated from field: repeated Bundle bundles = 3; + */ + bundles: Bundle[] = []; + + /** + * One to one message, encrypted, indexed by installation_id + * TODO map here is redundant in case of community messages + * + * @generated from field: map encrypted_message = 101; + */ + encryptedMessage: { [key: string]: EncryptedMessageProtocol } = {}; + + /** + * Public chats, not encrypted + * + * @generated from field: bytes public_message = 102; + */ + publicMessage = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "ProtocolMessage"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 2, name: "installation_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "bundles", kind: "message", T: Bundle, repeated: true }, + { no: 101, name: "encrypted_message", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: EncryptedMessageProtocol} }, + { no: 102, name: "public_message", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ProtocolMessage { + return new ProtocolMessage().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ProtocolMessage { + return new ProtocolMessage().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ProtocolMessage { + return new ProtocolMessage().fromJsonString(jsonString, options); + } + + static equals(a: ProtocolMessage | PlainMessage | undefined, b: ProtocolMessage | PlainMessage | undefined): boolean { + return proto3.util.equals(ProtocolMessage, a, b); + } +} + diff --git a/packages/status-js/src/protos/status-update.ts b/packages/status-js/src/protos/status-update.ts deleted file mode 100644 index c52a2f9a..00000000 --- a/packages/status-js/src/protos/status-update.ts +++ /dev/null @@ -1,51 +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(__StatusTypeValues) - } - } - - export const codec = (): Codec => { - return message({ - 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()) - } -} diff --git a/packages/status-js/src/protos/status-update_pb.ts b/packages/status-js/src/protos/status-update_pb.ts new file mode 100644 index 00000000..3fc6bbe1 --- /dev/null +++ b/packages/status-js/src/protos/status-update_pb.ts @@ -0,0 +1,107 @@ +// @generated by protoc-gen-es v1.0.0 with parameter "target=ts" +// @generated from file status-update.proto (syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * 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. + * + * @generated from message StatusUpdate + */ +export class StatusUpdate extends Message { + /** + * @generated from field: uint64 clock = 1; + */ + clock = protoInt64.zero; + + /** + * @generated from field: StatusUpdate.StatusType status_type = 2; + */ + statusType = StatusUpdate_StatusType.UNKNOWN_STATUS_TYPE; + + /** + * @generated from field: string custom_text = 3; + */ + customText = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime = proto3; + static readonly typeName = "StatusUpdate"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "clock", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "status_type", kind: "enum", T: proto3.getEnumType(StatusUpdate_StatusType) }, + { no: 3, name: "custom_text", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): StatusUpdate { + return new StatusUpdate().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): StatusUpdate { + return new StatusUpdate().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): StatusUpdate { + return new StatusUpdate().fromJsonString(jsonString, options); + } + + static equals(a: StatusUpdate | PlainMessage | undefined, b: StatusUpdate | PlainMessage | undefined): boolean { + return proto3.util.equals(StatusUpdate, a, b); + } +} + +/** + * @generated from enum StatusUpdate.StatusType + */ +export enum StatusUpdate_StatusType { + /** + * @generated from enum value: UNKNOWN_STATUS_TYPE = 0; + */ + UNKNOWN_STATUS_TYPE = 0, + + /** + * @generated from enum value: AUTOMATIC = 1; + */ + AUTOMATIC = 1, + + /** + * @generated from enum value: DO_NOT_DISTURB = 2; + */ + DO_NOT_DISTURB = 2, + + /** + * @generated from enum value: ALWAYS_ONLINE = 3; + */ + ALWAYS_ONLINE = 3, + + /** + * @generated from enum value: INACTIVE = 4; + */ + INACTIVE = 4, +} +// Retrieve enum metadata with: proto3.getEnumType(StatusUpdate_StatusType) +proto3.util.setEnumType(StatusUpdate_StatusType, "StatusUpdate.StatusType", [ + { no: 0, name: "UNKNOWN_STATUS_TYPE" }, + { no: 1, name: "AUTOMATIC" }, + { no: 2, name: "DO_NOT_DISTURB" }, + { no: 3, name: "ALWAYS_ONLINE" }, + { no: 4, name: "INACTIVE" }, +]); + diff --git a/packages/status-js/src/utils/recover-public-key.test.ts b/packages/status-js/src/utils/recover-public-key.test.ts index cfa463c8..6295ffa1 100644 --- a/packages/status-js/src/utils/recover-public-key.test.ts +++ b/packages/status-js/src/utils/recover-public-key.test.ts @@ -2,10 +2,13 @@ import { bytesToHex, utf8ToBytes } from 'ethereum-cryptography/utils' import { expect, test } from 'vitest' import { Account } from '../client/account' +import { + ApplicationMetadataMessage, + ApplicationMetadataMessage_Type, +} from '../protos/application-metadata-message_pb' import { recoverPublicKey } from './recover-public-key' import type { Client } from '../client/client' -import type { ApplicationMetadataMessage } from '../protos/application-metadata-message' test('should recover public key', async () => { const payload = utf8ToBytes('hello') @@ -20,8 +23,8 @@ test('should recover public key', async () => { }) test('should recover public key from fixture', async () => { - const metadataFixture: ApplicationMetadataMessage = { - type: 'TYPE_EMOJI_REACTION' as ApplicationMetadataMessage.Type, + const metadataFixture = new ApplicationMetadataMessage({ + type: ApplicationMetadataMessage_Type.EMOJI_REACTION, signature: new Uint8Array([ 250, 132, 234, 119, 159, 124, 98, 93, 197, 108, 99, 52, 186, 234, 142, 101, 147, 180, 50, 190, 102, 61, 219, 189, 95, 124, 29, 74, 43, 46, 106, @@ -42,7 +45,7 @@ test('should recover public key from fixture', async () => { 55, 97, 55, 99, 48, 97, 53, 101, 98, 97, 53, 102, 97, 57, 100, 52, 100, 57, 49, 98, 97, 56, 32, 5, 40, 2, ]), - } + }) const publicKeySnapshot = new Uint8Array([ 4, 172, 65, 157, 172, 154, 139, 187, 88, 130, 90, 60, 222, 96, 238, 240, diff --git a/packages/status-js/src/utils/validate-message.ts b/packages/status-js/src/utils/validate-message.ts index 380e0a4d..5e3b21bd 100644 --- a/packages/status-js/src/utils/validate-message.ts +++ b/packages/status-js/src/utils/validate-message.ts @@ -1,27 +1,42 @@ -import type { ChatMessage } from '../protos/chat-message' +import { + AudioMessage_AudioType, + ChatMessage_ContentType, +} from '../protos/chat-message_pb' +import { ImageType, MessageType } from '../protos/enums_pb' + +import type { + AudioMessage, + ChatMessage, + ImageMessage, +} from '../protos/chat-message_pb' // TODO?: maybe this should normalize the message? export function validateMessage(message: ChatMessage): boolean { - if (message.messageType !== 'COMMUNITY_CHAT') { + if (message.messageType !== MessageType.COMMUNITY_CHAT) { return false } switch (message.contentType) { - case 'TEXT_PLAIN': { + case ChatMessage_ContentType.TEXT_PLAIN: { return message.text !== '' } - case 'IMAGE': { - if (message.image.type === 'UNKNOWN_IMAGE_TYPE') { + case ChatMessage_ContentType.IMAGE: { + // fixme? + const payload = message.payload.value as ImageMessage + + if (payload.type === ImageType.UNKNOWN_IMAGE_TYPE) { return false } - return message.image.payload.length !== 0 + return payload.payload.length !== 0 } - case 'AUDIO': { - if (message.audio.type === 'UNKNOWN_AUDIO_TYPE') { + case ChatMessage_ContentType.AUDIO: { + const payload = message.payload.value as AudioMessage + + if (payload.type === AudioMessage_AudioType.UNKNOWN_AUDIO_TYPE) { return false } - return message.audio.payload.length !== 0 + return payload.payload.length !== 0 } } diff --git a/packages/status-react/src/protocol/index.tsx b/packages/status-react/src/protocol/index.tsx index f89b0dc4..e266798e 100644 --- a/packages/status-react/src/protocol/index.tsx +++ b/packages/status-react/src/protocol/index.tsx @@ -7,6 +7,7 @@ export { useChat } from './use-chat' export type { Member } from './use-members' export { useMembers } from './use-members' export type { Message, Reaction, Reactions } from './use-messages' +export { MessageContentType } from './use-messages' export { useMessages } from './use-messages' export { useProtocol } from './use-protocol' export { useSortedChats } from './use-sorted-chats' diff --git a/packages/status-react/src/protocol/use-messages.tsx b/packages/status-react/src/protocol/use-messages.tsx index 2c03b363..c821205f 100644 --- a/packages/status-react/src/protocol/use-messages.tsx +++ b/packages/status-react/src/protocol/use-messages.tsx @@ -1,12 +1,11 @@ import { useEffect, useState } from 'react' +import { MessageContentType } from '@status-im/js' import sub from 'date-fns/sub' import { useProtocol } from './use-protocol' -import type { Message, Reactions } from '@status-im/js' - -type Reaction = keyof Reactions +import type { Message, Reaction, Reactions } from '@status-im/js' interface Result { data: Message[] @@ -52,3 +51,4 @@ export const useMessages = (chatId: string): Result => { } export type { Message, Reaction, Reactions } +export { MessageContentType } diff --git a/packages/status-react/src/routes/chat/components/chat-input/input-reply.tsx b/packages/status-react/src/routes/chat/components/chat-input/input-reply.tsx index f2ee1fee..05527264 100644 --- a/packages/status-react/src/routes/chat/components/chat-input/input-reply.tsx +++ b/packages/status-react/src/routes/chat/components/chat-input/input-reply.tsx @@ -2,6 +2,7 @@ import React from 'react' import { useChatContext } from '../../../../contexts/chat-context' import { CrossIcon } from '../../../../icons/cross-icon' +import { MessageContentType } from '../../../../protocol' import { styled } from '../../../../styles/config' import { Flex, IconButton, Text } from '../../../../system' @@ -34,7 +35,7 @@ export const InputReply = (props: Props) => { - {message.contentType === 'TEXT_PLAIN' && ( + {message.contentType === MessageContentType.TEXT_PLAIN && ( {message.text} diff --git a/packages/status-react/src/routes/chat/components/chat-message/index.tsx b/packages/status-react/src/routes/chat/components/chat-message/index.tsx index 881adc7f..7ccc9df5 100644 --- a/packages/status-react/src/routes/chat/components/chat-message/index.tsx +++ b/packages/status-react/src/routes/chat/components/chat-message/index.tsx @@ -6,7 +6,11 @@ import { useMatch } from 'react-router-dom' import { useChatContext } from '../../../../contexts/chat-context' // import { BellIcon } from '../../../../icons/bell-icon' // import { PinIcon } from '../../../../icons/pin-icon' -import { useAccount, useProtocol } from '../../../../protocol' +import { + MessageContentType, + useAccount, + useProtocol, +} from '../../../../protocol' import { keyframes, styled } from '../../../../styles/config' import { Avatar, @@ -134,7 +138,7 @@ export const ChatMessage = (props: Props) => { } switch (contentType) { - case 'TEXT_PLAIN': { + case MessageContentType.TEXT_PLAIN: { // // // https://specs.status.im/spec @@ -147,15 +151,22 @@ export const ChatMessage = (props: Props) => { // {' '} return {message.text} } - case 'EMOJI': { + case MessageContentType.EMOJI: { return ( {message.text} ) } - case 'IMAGE': { - const blob = new Blob([message.image.payload], { type: 'image/jpeg' }) + case MessageContentType.IMAGE: { + // fixme? + const image = message.payload.value as { + payload: Uint8Array + type: number + } + const blob = new Blob([image.payload], { + type: 'image/jpeg', + }) // TODO?: call URL.revokeObjectURL() return ( diff --git a/packages/status-react/src/routes/chat/components/chat-message/message-reply.tsx b/packages/status-react/src/routes/chat/components/chat-message/message-reply.tsx index 683f5745..dfcb4171 100644 --- a/packages/status-react/src/routes/chat/components/chat-message/message-reply.tsx +++ b/packages/status-react/src/routes/chat/components/chat-message/message-reply.tsx @@ -1,6 +1,6 @@ import React from 'react' -import { useProtocol } from '../../../../protocol' +import { MessageContentType, useProtocol } from '../../../../protocol' import { styled } from '../../../../styles/config' import { Avatar, Box, Flex, Image, Text } from '../../../../system' @@ -36,21 +36,21 @@ export const MessageReply = (props: Props) => { {member.username} - {contentType === 'TEXT_PLAIN' && ( + {contentType === MessageContentType.TEXT_PLAIN && ( {text} )} - {contentType === 'EMOJI' && ( + {contentType === MessageContentType.EMOJI && ( {text} )} - {contentType === 'IMAGE' && ( + {contentType === MessageContentType.IMAGE && ( =13.7.0" long "^4.0.0" -protobufjs@^6.11.3: - version "6.11.3" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.11.3.tgz#637a527205a35caa4f3e2a9a4a13ddffe0e7af74" - integrity sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg== - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/long" "^4.0.1" - "@types/node" ">=13.7.0" - long "^4.0.0" - protobufjs@^7.0.0: version "7.1.0" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.1.0.tgz#5174b5f96fad4f7dea7dd4abd594042ac360e665" @@ -6058,14 +6007,6 @@ protobufjs@^7.0.0: "@types/node" ">=13.7.0" long "^5.0.0" -protons-runtime@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/protons-runtime/-/protons-runtime-1.0.4.tgz#85db97f82fb03a1205eafb591904736ba34e2972" - integrity sha512-DSKWjAgwaXhtYO5Jo/MrU8n/75I/P2IhxU0Fk/lSrXx6Gxl5DH+I6cHcbGAYFmAlOBmU4QRa0mvVme8VXlDeUg== - dependencies: - uint8arraylist "^1.4.0" - uint8arrays "^3.0.0" - protons-runtime@^3.0.1, protons-runtime@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/protons-runtime/-/protons-runtime-3.1.0.tgz#500918da4a2d97aa28007f30c3f2f7021e05c0b2" @@ -6074,14 +6015,6 @@ protons-runtime@^3.0.1, protons-runtime@^3.1.0: protobufjs "^7.0.0" uint8arraylist "^2.3.2" -protons@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/protons/-/protons-3.0.4.tgz#29fbcbb2e43952e6a3e072e240b4d94d43778b09" - integrity sha512-R0X/4pCfpXo3X2CVMmhDLHnHRqVg202N32p8qESKc1Vh8cD7Lqj6DBB/Z6yk6lgrH2UEneCHmHYzqonRl+l+pg== - dependencies: - meow "^10.1.2" - protobufjs "^6.11.2" - pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" @@ -6114,11 +6047,6 @@ quick-lru@^4.0.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== -quick-lru@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" - integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== - react-content-loader@^6.2.0: version "6.2.0" resolved "https://registry.yarnpkg.com/react-content-loader/-/react-content-loader-6.2.0.tgz#cd8fee8160b8fda6610d0c69ce5aee7b8094cba6" @@ -6213,15 +6141,6 @@ read-pkg-up@^7.0.1: read-pkg "^5.2.0" type-fest "^0.8.1" -read-pkg-up@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-8.0.0.tgz#72f595b65e66110f43b052dd9af4de6b10534670" - integrity sha512-snVCqPczksT0HS2EC+SxUndvSzn6LRCwpfSvLrIfR5BKDQQZMaI6jPRC9dYvYFDRAuFEAnkwww8kBBNE/3VvzQ== - dependencies: - find-up "^5.0.0" - read-pkg "^6.0.0" - type-fest "^1.0.1" - read-pkg@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-5.2.0.tgz#7bf295438ca5a33e56cd30e053b34ee7250c93cc" @@ -6232,16 +6151,6 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -read-pkg@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-6.0.0.tgz#a67a7d6a1c2b0c3cd6aa2ea521f40c458a4a504c" - integrity sha512-X1Fu3dPuk/8ZLsMhEj5f4wFAF0DWoK7qhGJvgaijocXxBmSToKfbFtqbxMO7bVjNA1dmE5huAzjXj/ey86iw9Q== - dependencies: - "@types/normalize-package-data" "^2.4.0" - normalize-package-data "^3.0.2" - parse-json "^5.2.0" - type-fest "^1.0.1" - read-yaml-file@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-yaml-file/-/read-yaml-file-1.1.0.tgz#9362bbcbdc77007cc8ea4519fe1c0b821a7ce0d8" @@ -6280,14 +6189,6 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" -redent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/redent/-/redent-4.0.0.tgz#0c0ba7caabb24257ab3bb7a4fd95dd1d5c5681f9" - integrity sha512-tYkDkVVtYkSVhuQ4zBgfvciymHaeuel+zFKXShfDnFP5SyVEP7qo70Rf1jTOTCx3vGNAbnEi/xFkcfQVMIBWag== - dependencies: - indent-string "^5.0.0" - strip-indent "^4.0.0" - regenerator-runtime@^0.13.4: version "0.13.9" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" @@ -6464,13 +6365,6 @@ semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.3.4: - version "7.3.7" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== - dependencies: - lru-cache "^6.0.0" - semver@^7.3.5: version "7.3.5" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" @@ -6744,13 +6638,6 @@ strip-indent@^3.0.0: dependencies: min-indent "^1.0.0" -strip-indent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-4.0.0.tgz#b41379433dd06f5eae805e21d631e07ee670d853" - integrity sha512-mnVSV2l+Zv6BLpSD/8V87CW/y9EmmbYzGCIavsnsI6/nwn26DwffM/yztm30Z/I2DY9wdS3vXVCMnHDgZaVNoA== - dependencies: - min-indent "^1.0.1" - strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" @@ -6916,11 +6803,6 @@ trim-newlines@^3.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw== -trim-newlines@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-4.0.2.tgz#d6aaaf6a0df1b4b536d183879a6b939489808c7c" - integrity sha512-GJtWyq9InR/2HRiLZgpIKv+ufIKrVrvjQWEj7PxAXNc5dwbNJkqhAUoAGgzRmULAnoOM5EIpveYd3J2VeSAIew== - truncate-utf8-bytes@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz#405923909592d56f78a5818434b0b78489ca5f2b" @@ -7100,16 +6982,16 @@ type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== -type-fest@^1.0.1, type-fest@^1.2.1, type-fest@^1.2.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-1.4.0.tgz#e9fb813fe3bf1744ec359d55d1affefa76f14be1" - integrity sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA== - typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== +typescript@4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998" + integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw== + typescript@^4.5.5: version "4.5.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" @@ -7130,13 +7012,6 @@ uint8-varint@^1.0.1, uint8-varint@^1.0.2: uint8arraylist "^2.0.0" uint8arrays "^3.1.0" -uint8arraylist@^1.4.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/uint8arraylist/-/uint8arraylist-1.5.1.tgz#b8b325865b65b62b4cec773bc568cdd03c691d08" - integrity sha512-UpPGcVlTVc7Brtwt4W2MfTqvJQsr8owHMKBnICsueSImiarVAHf8NGMjhMklFtgbCZN1/9S9oW5k1JwlalGHoA== - dependencies: - uint8arrays "^3.0.0" - uint8arraylist@^2.0.0, uint8arraylist@^2.1.0, uint8arraylist@^2.1.1, uint8arraylist@^2.3.1, uint8arraylist@^2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/uint8arraylist/-/uint8arraylist-2.3.2.tgz#d301f6cb570828b456ef09655c0a4d3b0929ef06" @@ -7477,11 +7352,6 @@ yargs-parser@^18.1.2, yargs-parser@^18.1.3: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^20.2.9: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - yargs-parser@^21.0.0: version "21.0.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35"