function escape ( str ) { return str . replace ( /\+/g , '-' ) . replace ( /\//g , '_' ) . replace ( /=/g , '' ) ; } export function base64encode ( email ) { return escape ( Buffer . from ( email , 'utf8' ) . toString ( 'base64' ) ) ; } function unescape ( str ) { return ( str + '===' . slice ( ( str . length + 3 ) % 4 ) ) . replace ( /-/g , '+' ) . replace ( /_/g , '/' ) ; } export function base64decode ( str ) { return Buffer . from ( unescape ( str ) , 'base64' ) . toString ( 'utf8' ) ; }