import { Decrypter, Encrypter, Message } from "./message"; import { MessageMode } from "./message-mode"; import { SerializableMirrorConsensusResponse } from "./serializable-mirror-consensus-response"; import { PublicKey, Timestamp, TopicMessage } from "@hashgraph/sdk"; import { JsonClass } from "./json-class"; export declare type PublicKeyProvider = (evn: MessageEnvelope) => PublicKey; export declare type SignFunction = (message: Uint8Array) => Uint8Array; /** * The envelope for Hedera identity messages sent to HCS DID or VC topics. */ export declare class MessageEnvelope { private static MESSAGE_KEY; private static SIGNATURE_KEY; private static serialVersionUID; protected mode: MessageMode; protected message: T; protected signature: string; protected get messageJson(): string; protected decryptedMessage: T; protected mirrorResponse: SerializableMirrorConsensusResponse; /** * Creates a new message envelope for the given message. * * @param message The message. */ constructor(message: T); constructor(); /** * Signs this message envelope with the given signing function. * * @param signer The signing function. * @return This envelope signed and serialized to JSON, ready for submission to HCS topic. */ sign(signer: SignFunction): Uint8Array; toJsonTree(): any; /** * Converts this message envelope into a JSON string. * * @return The JSON string representing this message envelope. */ toJSON(): string; /** * Converts a message from a DID or VC topic response into object instance. * * @param Type of the message inside envelope. * @param response Topic message as a response from mirror node. * @param messageClass Class type of the message inside envelope. * @return The {@link MessageEnvelope}. */ static fromMirrorResponse(response: TopicMessage, messageClass: JsonClass): MessageEnvelope; /** * Converts a VC topic message from a JSON string into object instance. * * @param Type of the message inside envelope. * @param json VC topic message as JSON string. * @param messageClass Class of the message inside envelope. * @return The {@link MessageEnvelope}. */ static fromJson(json: string, messageClass: JsonClass): MessageEnvelope; /** * Encrypts the message in this envelope and returns its encrypted instance. * * @param encrypter The function used to encrypt the message. * @return This envelope instance. */ encrypt(encrypter: Encrypter): MessageEnvelope; /** * Verifies the signature of the envelope against the public key of it's signer. * * @param publicKeyProvider Provider of a public key of this envelope signer. * @return True if the message is valid, false otherwise. */ isSignatureValid(publicKeyProvider: PublicKeyProvider): boolean; isSignatureValid(publicKey: PublicKey): boolean; /** * Opens a message in this envelope. * If the message is encrypted, the given decrypter will be used first to decrypt it. * If the message is not encrypted, it will be immediately returned. * * @param decrypter The function used to decrypt the message. * @return The message object in a plain mode. */ open(decrypter?: Decrypter): T; getSignature(): string; getConsensusTimestamp(): Timestamp; getMode(): MessageMode; getMirrorResponse(): SerializableMirrorConsensusResponse; }