import { StateEvent } from '../types'; import type { PowerLevelsActions, PowerLevelsStateEvent, StateEventCreateContent } from './events'; export { isValidPowerLevelStateEvent, STATE_EVENT_POWER_LEVELS, } from './events'; /** * Room version 12 requires us to have something larger than Max integer for room creators. * This is a workaround to allow the room creator to always have the highest power level. */ export declare const ROOM_VERSION_12_CREATOR = "ROOM_VERSION_12_CREATOR"; export type UserPowerLevelType = number | typeof ROOM_VERSION_12_CREATOR; /** * Compare a user's power level to a normal power level. * @param userPowerLevel - The user's power level * @param normalPowerLevel - The normal power level * @returns True if the user's power level is greater than or equal to the normal power level, false otherwise */ export declare function compareUserPowerLevelToNormalPowerLevel(userPowerLevel: UserPowerLevelType, normalPowerLevel: number): boolean; /** * Check if a user has the power to send a specific room event. * * @param powerLevelStateEvent - the content of the `m.room.power_levels` event * @param createRoomStateEvent - the `m.room.create` event for the room * @param userId - the id of the user * @param eventType - the type of room event * @returns if true, the user has the power */ export declare function hasRoomEventPower(powerLevelStateEvent: PowerLevelsStateEvent | undefined, createRoomStateEvent: StateEvent | undefined, userId: string | undefined, eventType: string): boolean; /** * Check if a user has the power to send a specific state event. * * @param powerLevelStateEvent - the content of the `m.room.power_levels` event * @param createRoomStateEvent - the `m.room.create` event for the room * @param userId - the id of the user * @param eventType - the type of state event * @returns if true, the user has the power */ export declare function hasStateEventPower(powerLevelStateEvent: PowerLevelsStateEvent | undefined, createRoomStateEvent: StateEvent | undefined, userId: string | undefined, eventType: string): boolean; /** * Check if a user has the power to perform a specific action. * * Supported actions: * * invite: Invite a new user into the room * * kick: Kick a user from the room * * ban: Ban a user from the room * * redact: Redact a message from another user * * @param powerLevelStateEvent - the content of the `m.room.power_levels` event * @param createRoomStateEvent - the `m.room.create` event for the room * @param userId - the id of the user * @param action - the action * @returns if true, the user has the power */ export declare function hasActionPower(powerLevelStateEvent: PowerLevelsStateEvent | undefined, createRoomStateEvent: StateEvent | undefined, userId: string | undefined, action: PowerLevelsActions): boolean; /** * Calculate the power level of the user based on a `m.room.power_levels` event. * * Note that we return the @see UserPowerLevelType type instead of a number as Room Version 12 * gives a Room creator (and additionalCreators) always the highest power level regardless * of the highest next Powerlevel number. * * @param powerLevelStateEvent - the content of the `m.room.power_levels` event. * @param createRoomStateEvent - the `m.room.create` event for the room. * @param userId - the ID of the user. * @returns the power level of the user. */ export declare function calculateUserPowerLevel(powerLevelStateEvent: PowerLevelsStateEvent | undefined, createRoomStateEvent: StateEvent | undefined, userId: string): UserPowerLevelType; /** * Calculate the power level that a user needs send a specific room event. * * @param powerLevelStateEvent - the content of the `m.room.power_levels` event * @param eventType - the type of room event * @returns the power level that is needed */ export declare function calculateRoomEventPowerLevel(powerLevelStateEvent: PowerLevelsStateEvent | undefined, eventType: string): number; /** * Calculate the power level that a user needs send a specific state event. * * @param powerLevelStateEvent - the content of the `m.room.power_levels` event * @param createRoomStateEvent - the `m.room.create` event * @param eventType - the type of state event * @returns the power level that is needed */ export declare function calculateStateEventPowerLevel(powerLevelStateEvent: PowerLevelsStateEvent | undefined, createRoomStateEvent: StateEvent | undefined, eventType: string): number; /** * Calculate the power level that a user needs to perform an action. * * Supported actions: * * invite: Invite a new user into the room * * kick: Kick a user from the room * * ban: Ban a user from the room * * redact: Redact a message from another user * * @param powerLevelStateEvent - the content of the `m.room.power_levels` event * @param action - the action * @returns the power level that is needed */ export declare function calculateActionPowerLevel(powerLevelStateEvent: PowerLevelsStateEvent | undefined, action: PowerLevelsActions): number;