export function base64encode ( str ) { if ( typeof str === "string" ) str = Buffer . from ( str ) ; return str . toString ( "base64" ) ; } export function base64decode ( str ) { if ( typeof str === "string" ) str = Buffer . from ( str , "base64" ) ; return str . toString ( "binary" ) ; } export function base64urlencode ( str ) { return base64encode ( str ) . replace ( /\+/g , "-" ) . replace ( /\//g , "_" ) . replace ( /=/g , "" ) ; }