import MessageRef from './MessageRef'; import MessageID from './MessageID'; import EncryptedGroupKey from './EncryptedGroupKey'; import { StreamID } from '../../utils/StreamID'; import { StreamPartID } from '../../utils/StreamPartID'; import { EthereumAddress } from '@streamr/utils'; export declare enum StreamMessageType { MESSAGE = 27, GROUP_KEY_REQUEST = 28, GROUP_KEY_RESPONSE = 29 } export declare enum ContentType { JSON = 0, BINARY = 1 } export declare enum EncryptionType { NONE = 0, AES = 2 } export declare enum SignatureType { LEGACY_SECP256K1 = 0,// Brubeck payload signed with secp256k1 curve SECP256K1 = 1,// Streamr 1.0 payload signed with secp256k1 curve ERC_1271 = 2 } export interface StreamMessageOptions { messageId: MessageID; prevMsgRef?: MessageRef; messageType?: StreamMessageType; content: Uint8Array; contentType: ContentType; signature: Uint8Array; signatureType: SignatureType; encryptionType: EncryptionType; groupKeyId?: string; newGroupKey?: EncryptedGroupKey; } /** * Encrypted StreamMessage. */ export type StreamMessageAESEncrypted = StreamMessage & { encryptionType: EncryptionType.AES; groupKeyId: string; }; export default class StreamMessage implements StreamMessageOptions { readonly messageId: MessageID; readonly prevMsgRef?: MessageRef; readonly messageType: StreamMessageType; readonly content: Uint8Array; readonly contentType: ContentType; readonly signature: Uint8Array; readonly signatureType: SignatureType; readonly encryptionType: EncryptionType; readonly groupKeyId?: string; readonly newGroupKey?: EncryptedGroupKey; constructor({ messageId, prevMsgRef, messageType, content, contentType, signature, signatureType, encryptionType, groupKeyId, newGroupKey, }: StreamMessageOptions); getStreamId(): StreamID; getStreamPartition(): number; getStreamPartID(): StreamPartID; getTimestamp(): number; getSequenceNumber(): number; getPublisherId(): EthereumAddress; getMsgChainId(): string; getMessageRef(): MessageRef; getParsedContent(): Uint8Array | Record | Array; static isAESEncrypted(msg: StreamMessage): msg is StreamMessageAESEncrypted; }