/** * Represents IVS chat token to be used to establish room connection. This should be fetched through your backend for * security purposes from IVS Chat API. * * @see [Chat API docs](https://docs.aws.amazon.com/ivs/latest/ChatAPIReference/API_CreateChatToken.html#API_CreateChatToken_ResponseElements) */ export interface ChatToken { /** Encrypted IVS token used to establish a WebSocket connection to a {@link ChatRoom | chat room}. */ token: string; /** * Time after which an end user's session is no longer valid. Note: if string literal is provided, it must conform to * the ISO 8601 standard. */ sessionExpirationTime?: Date | string; /** * Time after which the token is no longer valid and cannot be used to connect to a {@link ChatRoom | chat room}. Note: * if string literal is provided, it must conform to the ISO 8601 standard. */ tokenExpirationTime?: Date | string; } /** * Parsed {@link ChatToken | chat token} with optional properties converted to * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date | Date} object. */ export interface ParsedChatToken { /** Encrypted IVS token used to establish a WebSocket connection to a {@link ChatRoom | chat room}. */ token: string; /** Time after which an end user's session is no longer valid. */ sessionExpirationTime?: Date; /** Time after which the token is no longer valid and cannot be used to connect to a {@link ChatRoom | chat room}. */ tokenExpirationTime?: Date; } /** * Callback function call by the {@link ChatRoom | room} when it needs the application to fetch a fresh * {@link ChatToken | chat token}. * * @returns Chat token fetched by your backend from IVS Chat API */ export type ChatTokenProvider = () => Promise; /** ChatMessage represents a chat message sent by clients to a {@link ChatRoom | chat room}. */ export interface ChatMessage { /** Server-generated unique identifier of the message. */ id: string; /** {@link ChatUser | User } sending the message. */ sender: ChatUser; /** Text content of the message. */ content: string; /** Date and time when the message has been sent. */ sendTime: Date; /** Client-generated identifier of the request that triggered message. */ requestId?: string; /** Key-value object for any additional message data. */ attributes?: Record; } /** Represents a user participating in a {@link ChatRoom | chat room}. */ export interface ChatUser { /** Unique identifier of the user. */ userId: string; /** Key-value object for any additional user data. */ attributes?: Record; } /** * Represents an event received in the {@link ChatRoom | chat room}. Events might originate from IVS service, client * actions, or your backend code. */ export interface ChatEvent { /** Server-generated unique identifier of the event. */ id: string; /** Name of the event. */ eventName: string; /** Date and time when the event has been sent. */ sendTime: Date; /** Client-generated identifier of the request that triggered the event. */ requestId?: string; /** Key-value object for any additional event data. */ attributes?: Record; } export interface DeleteMessageEvent { /** Server-generated unique identifier of the event. */ id: string; /** Message identifier of the deleted message. */ messageId: string; /** The reason for deleting the message. */ reason?: string; /** Date and time when the event has been sent. */ sendTime: Date; /** Client-generated identifier of the request that triggered the event. */ requestId?: string; /** Key-value object for any additional event data. */ attributes?: Record; } export interface DisconnectUserEvent { /** Server-generated unique identifier of the event. */ id: string; /** Id of user to disconnect. */ userId: string; /** The reason for disconnecting given user. */ reason?: string; /** Date and time when the event has been sent. */ sendTime: Date; /** Client-generated identifier of the request that triggered the event. */ requestId?: string; /** Key-value object for any additional event data. */ attributes?: Record; } /** ChatError represents an error sent by IVS Chat Messaging API service in response to use request. */ export interface ChatError { /** Server-generated unique identifier of the error. */ id: string; /** Numeric code of the error. */ errorCode: number; /** Error message. */ errorMessage: string; /** Client-generated identifier of the request that caused this error. */ requestId?: string; } /** @internal */ export type ConnectionCloseReason = 'serverDisconnect' | 'socketConnectionBroken' | 'socketError' | 'fetchTokenError'; /** * - 'clientDisconnect' - Orderly disconnect has been initiated by client. Used when user calls * {@link ChatRoom#disconnect | `disconnect`} method. * - 'serverDisconnect' - Orderly disconnect has been initiated by server. Used when given user is disconnected for * moderation purposes, e.g. when another user calls {@link ChatRoom#disconnectUser | `disconnectUser`} method on him. * - 'socketError' - Room has not been able to establish WebSocket connection with IVS. Room will retry attempts as * specified by {@link ChatRoom#maxReconnectAttempts | `maxReconnectAttempts`} parameter. * {@link ChatRoomListenerMap | `disconnect`} with this reason is only called when all reconnection attempts have * failed. * - 'fetchTokenError' - Room has not been able to fetch chat token from user backend. Room will retry attempts as * specified by {@link ChatRoom#maxReconnectAttempts | `maxReconnectAttempts`} parameter. * {@link ChatRoomListenerMap | `disconnect`} with this reason is only called when all token fetching attempts have * failed. */ export type DisconnectReason = 'clientDisconnect' | 'serverDisconnect' | 'socketError' | 'fetchTokenError'; /** * Represents the {@link ChatRoom | chat room} connection state. * * - `'disconnected'` - (initial state) {@link ChatRoom | Chat room} is not connected and will not try to establish * connection by itself. Besides it being an initial state, chat room can transition to this state when: * * - Client calls {@link ChatRoom#disconnect } method triggering graceful closure of socket connection * - Server gracefully closes the socket connection * - Room reached the allowed number of {@link ChatRoom#maxReconnectAttempts | reconnection attempts } but still failed to * establish socket connection * - `'connecting'` - {@link ChatRoom | Chat room} is in the process of establishing a socket connection with IVS Chat * Messaging API. The room will transition to this state when: * * - Client calls {@link ChatRoom#connect } method, while being in a `disconnected` state, triggering the process of * establishing socket connection * - When {@link ChatRoom | chat room} is in a `connected` state, and requires reconnecting, e.g. in case of connection * issues * - `'connected'` - {@link ChatRoom | Chat room} is connected and ready to send and receive messages. */ export type ConnectionState = 'disconnected' | 'connecting' | 'connected'; //# sourceMappingURL=types.d.ts.map