category export class MatrixEntity { private entityLocalpart : string ; private entityDomain : string ; param { string } fullId constructor ( private fullId ) { if ( ! fullId ) throw new Error ( "No entity ID provided" ) ; if ( fullId . length < 2 ) throw new Error ( "ID too short" ) ; const parts = fullId . split ( /:/g ) ; this . entityLocalpart = parts [ 0 ] . substring ( 1 ) ; this . entityDomain = parts . splice ( 1 ) . join ( ':' ) ; } /**
     * The localpart for the entity
     */ public get localpart ( ) : string { return this . entityLocalpart ; } /**
     * The domain for the entity
     */ public get domain ( ) : string { return this . entityDomain ; } public toString ( ) { return this . fullId ; } } category export class UserID extends MatrixEntity { constructor ( userId ) { super ( userId ) ; if ( ! userId . startsWith ( "@" ) ) { throw new Error ( "Not a valid user ID" ) ; } } } category export class RoomAlias extends MatrixEntity { constructor ( alias ) { super ( alias ) ; if ( ! alias . startsWith ( "#" ) ) { throw new Error ( "Not a valid room alias" ) ; } } }