status-web-archive/packages/status-js/protos/chat-identity.ts

131 lines
3.3 KiB
TypeScript
Raw Normal View History

/* eslint-disable import/export */
/* eslint-disable @typescript-eslint/no-namespace */
2022-05-24 13:34:03 +00:00
import { encodeMessage, decodeMessage, message, uint64, string, enumeration, bytes, bool } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
export interface ChatIdentity {
clock: bigint
ensName: string
images: IdentityImage
displayName: string
description: string
color: string
emoji: string
}
export namespace ChatIdentity {
export const codec = (): Codec<ChatIdentity> => {
return message<ChatIdentity>({
1: { name: 'clock', codec: uint64 },
2: { name: 'ensName', codec: string },
3: { name: 'images', codec: IdentityImage.codec() },
4: { name: 'displayName', codec: string },
5: { name: 'description', codec: string },
6: { name: 'color', codec: string },
2022-05-24 13:34:03 +00:00
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',
2022-05-24 13:34:03 +00:00
ENS_AVATAR = 'ENS_AVATAR'
}
enum __SourceTypeValues {
UNKNOWN_SOURCE_TYPE = 0,
RAW_PAYLOAD = 1,
2022-05-24 13:34:03 +00:00
ENS_AVATAR = 2
}
export namespace SourceType {
export const codec = () => {
return enumeration<typeof SourceType>(__SourceTypeValues)
}
}
export const codec = (): Codec<IdentityImage> => {
return message<IdentityImage>({
1: { name: 'payload', codec: bytes },
2: { name: 'sourceType', codec: IdentityImage.SourceType.codec() },
3: { name: 'imageType', codec: ImageType.codec() },
4: { name: 'encryptionKeys', codec: bytes, repeats: true },
2022-05-24 13:34:03 +00:00
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',
2022-05-24 13:34:03 +00:00
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,
2022-05-24 13:34:03 +00:00
SYSTEM_MESSAGE_GAP = 6
}
export namespace MessageType {
export const codec = () => {
return enumeration<typeof MessageType>(__MessageTypeValues)
}
}
export enum ImageType {
UNKNOWN_IMAGE_TYPE = 'UNKNOWN_IMAGE_TYPE',
PNG = 'PNG',
JPEG = 'JPEG',
WEBP = 'WEBP',
2022-05-24 13:34:03 +00:00
GIF = 'GIF'
}
enum __ImageTypeValues {
UNKNOWN_IMAGE_TYPE = 0,
PNG = 1,
JPEG = 2,
WEBP = 3,
2022-05-24 13:34:03 +00:00
GIF = 4
}
export namespace ImageType {
export const codec = () => {
return enumeration<typeof ImageType>(__ImageTypeValues)
}
}