const { Base64 } = require ( 'js-base64' ) ; export class Base64Message { private base64Message : string ; private unicodeValue : string ; public length : number ; private constructor ( base64Str ) { this . base64Message = base64Str ; this . unicodeValue = Base64 . decode ( base64Str ) ; this . length = base64Str . length ; } public static toUnicodeString ( message ) { return message . unicodeValue || '' ; } public static fromBuffer ( buffer ) { return new Base64Message ( buffer . toString ( 'base64' ) ) ; } public static fromString ( str ) { return new Base64Message ( Base64 . encode ( str ) ) ; } public static toDataUri ( message , mimeType ) { return `data:${ mimeType };base64,${ message . base64Message }` ; } }