Open plfx opened 7 years ago
The problem is that the payload is decoded to a string, rather than a buffer. Looking at the VerifyStream
implementation I think encoding support is fundamentally broken. It should probably be removed entirely, returning the raw payload bytes. I suppose for typ: 'JWT'
it could still parse the payload as if it was a JSON-encoded object.
My JWS payload is some raw bytes, which I pass to the
encode
function as base64, using the supported"base64"
encoding option:When I decode this, there's no corresponding option to decode directly to base64. Decode gives me a string using the encoded bytes, but it contains some escaped character values and is not compatible with Buffer:
My workaround right now is to not use
decode
at all. Instead, I justsplit('.')[1]
and thenrequire('base64-url')
to decode the bytes or convert it to normal base64.It would be much easier if I were able to pass the encoding I used to the
decode
method to get my base64 (or whatever other encoding) directly.As an additional feature suggestion, this would also let people ask decode to automatically parse JSON payloads: