Skip to content

Not decoding from Base64Url encoding. #101

Closed
@delasteve

Description

@delasteve

Base64Url encoding contains - and _ instead of + and /, respectively. To account for this, a string replace is necessary. After looking through the codebase, I think I found where the culprit is.

export function b64DecodeUnicode(str) {
return decodeURIComponent(atob(str).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}

It looks like you will need to do this prior to the decoding:

var base64 = str
  .replace(/\-/g, '+')
  .replace(/\_/g, '/');

Reference:
https://tools.ietf.org/html/rfc7515#appendix-C

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions