UNPKG

@4players/odin

Version:

A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects

42 lines (41 loc) 1.33 kB
import { IOdinEvent, OdinEventTarget } from './odin-event-target'; import { TokenClaims } from '@4players/odin-common'; export type TokenPayload = { token: RoomToken; }; export type TokenEvent = (event: IOdinEvent<TokenPayload>) => void; /** * Interface describing events on a connection. */ export interface TokenEvents { /** * A Media got added to the connection */ TokenExpired: TokenEvent; } /** * The RoomToken class represents a parsed and validated token with an expiration mechanism. * It is used to extract claims and manage token expiration events. */ export declare class RoomToken extends OdinEventTarget<TokenEvents> { readonly base64: string; readonly expiryOffset: number; private readonly _parsed; constructor(base64: string, expiryOffset?: number); get parsed(): TokenClaims; get address(): TokenClaims['adr']; get customerId(): TokenClaims['cid']; get exp(): TokenClaims['exp']; get userId(): TokenClaims['uid']; get rooms(): string[]; get isMultiRoom(): boolean; /** * Returns the audience. If the audience is undefined its unrestricted. * If the audience is an empty array, it has no audience. */ get audience(): string[]; /** * Returns true when the token is expired */ isExpired(): boolean; }