base64 url encoding variant methods.
Note, this is the same encoding format as JWT.
See https://www.npmjs.com/package/js-base64 for a JS
package to encode/decode with the same variant. Make sure
to pass true
to urlsafe argument, ie. encode(data, true)
and same with decode.