@huddle01/web-core
Version:
The Huddle01 Javascript SDK offers a comprehensive suite of methods and event listeners that allow for seamless real-time audio and video communication with minimal coding required.
84 lines (81 loc) • 2.85 kB
TypeScript
import { EnhancedEventEmitter } from './common-js/EnhancedEventEmitter.js';
import { TPermissions, DEFAULT_LABELS } from 'types/dist/common.types';
type PermissionEvents = {
updated: [data: {
permissions: TPermissions;
}];
};
/**
* Permission Class of a Local Peer in a Room.
*
* `NOTE Permissions are enforced by the Server. and can be set using the token or can be updated by Remote Peers having admin access of the Room Joined`
*/
declare class Permissions extends EnhancedEventEmitter<PermissionEvents> {
/**
* Get the Singleton Instance of the Permissions Class.
*/
private static __instance;
/**
* Admin Access of the Room.
*/
private __admin;
/**
* Can Consume Media Stream of the Room from RemotePeers;
*/
private __canConsume;
/**
* Can Produce Media Stream to the Room
*/
private __canProduce;
/**
* Allowed Sources to Produce Media Stream to the Room
*/
private __canProduceSources;
/**
* Can Send Data to the Room, e.g. Chat Messages, update of avatar, name etc. to the room
*/
private __canSendData;
/**
* Can Receive Data from the Room, e.g. Chat Messages, update of avatar, name etc. from other Remote Peers.
*/
private __canRecvData;
/**
* Can Update Metadata of the Room, e.g. DisplayName, Avatar, etc.
*/
private __canUpdateMetadata;
/**
* Custom Role of the Peer in the Room.
*/
__role: string | null;
/**
* Getter for the role of the peer.
*/
get role(): string | null;
set role(role: string);
/**
* Get the Access Control List ( acl ) of the Local Peer in the Room.
*/
get acl(): TPermissions;
/**
* Update the Permissions of the Local Peer in the Room. This will emit an event `updated` with the updated permissions.
*
* `NOTE: If the Peer is not an admin, then the permissions will not be updated on the server`
*/
updatePermissions(permissions: Partial<TPermissions>): void;
static createInstance(): Permissions;
static getInstance(): Permissions;
private constructor();
reset(): void;
}
declare const checkPermissions: (permission: Partial<Omit<TPermissions, "canProduceSources"> & {
canProduceSources: Partial<TPermissions["canProduceSources"]>;
}>) => {
validate: <T extends unknown[], R>(fn: (...args: T) => Promise<R>) => ((...args: T) => Promise<R>);
};
/**
* Custom Check Permissions for Producing the stream
* @param label - Label which is used to produce the stream.
* @returns {boolean} - Returns true if the peer is not allowed to produce the stream
*/
declare const checkProducePermissions: (label: DEFAULT_LABELS | string) => boolean;
export { type PermissionEvents, checkPermissions, checkProducePermissions, Permissions as default };