function base64UrlEncode(str) {
  return Buffer.from(str).toString('base64')
    .replace(/[=]/g, "")
    .replace(/\+/g, "-")
    .replace(/\//g, "_")
  ;
}
Base64-url encode a string
@param str {string} The string to encode
@returns {string} The encoded string