@cometchat/chat-uikit-react
Version:
Ready-to-use Chat UI Components for React(Javascript/Web)
82 lines (81 loc) • 2.92 kB
TypeScript
import { BaseMessage, CometChat } from "@cometchat/chat-sdk-javascript";
interface MessageExtensionType {
hasXSS?: string;
sanitized_text?: string;
data?: {
sensitive_data: string;
message_masked: string;
};
profanity?: string;
message_clean?: string;
}
/**
* Utility class for CometChat UIKit, providing various helper methods
* such as deep cloning, ID generation, Unix timestamp retrieval,
* and message extension data handling.
*/
export declare class CometChatUIKitUtility {
/**
* Creates a deep copy of the value provided
*
* @remarks
* This function cannot copy truly private properties (those that start with a "#" symbol inside a class block).
* Functions are copied by reference and additional properties on the array objects are ignored
*
* @param arg - Any value
* @returns A deep copy of `arg`
*/
static clone<T>(arg: T): T;
/**
* Checks if an object has a specific property.
*
* @param obj - The object to check.
* @param key - The property key.
* @returns `true` if the property exists, `false` otherwise.
*/
static checkHasOwnProperty: (obj: object | undefined, key: string) => boolean;
/**
* Generates a unique ID.
*
* @returns A unique string identifier.
*/
static ID: () => string;
/**
* Retrieves the current Unix timestamp.
*
* @returns The Unix timestamp.
*/
static getUnixTimestamp: () => number;
/**
* Retrieves the extension data from a message.
*
* @param messageObject - The message object containing extensions.
* @returns The sanitized message text if available, otherwise the original text.
*/
static getExtensionData(messageObject: CometChat.BaseMessage): string;
/**
* Checks for extension data in a message.
*
* @param message - The message object to check.
* @param extensionKey - The extension key to look for.
* @returns The extension data if found.
*/
static checkMessageForExtensionsData: (message: CometChat.BaseMessage | null, extensionKey: string) => (object & MessageExtensionType) | undefined;
/**
* Sanitizes an HTML string by escaping tags not matching the whitelist.
*
* @param htmlString - The HTML string to sanitize.
* @param whitelistRegExes - A list of regular expressions to match allowed tags.
* @returns The sanitized HTML string.
*/
static sanitizeHtml(htmlString: string, whitelistRegExes: RegExp[]): string;
static convertBlobToWav: (audioBlob: {
arrayBuffer: () => any;
}) => Promise<{
wavBlob: Blob;
}>;
static audioBufferToWav: (audioBuffer: AudioBuffer) => ArrayBuffer;
static writeString: (view: DataView, offset: number, string: string) => void;
static convertToWav: (audioBlob: Blob) => Promise<string>;
}
export {};