warmans / rsk-search

https://scrimpton.com
16 stars 2 forks source link

Profiles with "new reddit" profile images cannot login #20

Closed warmans closed 2 years ago

warmans commented 2 years ago

Tokens containing a new-style reddit user icon are unable to login because base64 decoding the JWT token sections with atob() triggers the following exception:

The string to be decoded is not correctly encoded.
warmans commented 2 years ago

There is two problems here:

  1. atob does not apparently fully support base64. _ is a valid base64 character but not according to all browsers. a quick fix for this is to just replace the _:
  decodeBase64(str: string): string {
    return atob(str.replace(/_/g, '/'));
  }
  1. New reddit avatars are html encoded. Not sure what the connection is but this also needs to be fixed by html decoding the user icon after the data is received from reddit.