brianloveswords / base64url

For encoding and decoding base64url!
MIT License
224 stars 44 forks source link

Documentation : browser / React Native compatibility #50

Open aymericbouzy opened 4 years ago

aymericbouzy commented 4 years ago

I'm having a hard time figuring out in what JS environment will this package work. It makes a clear mention of Node.js but no mention of browser or React Native.

  1. will it work in browsers?
  2. will it work in React Native?
  3. would you be interested in me making a PR to add this to the documentation? Feel free to reject this suggestion if it's obvious to everyone that it will work everywhere 😅
jhsmaciel commented 4 years ago

Tested on react-native, apparently does not work :( I don't know if there are any workaround

ahuggins-nhs commented 4 years ago

Tested on react-native, apparently does not work :( I don't know if there are any workaround

https://github.com/ahuggins-nhs/base64url-xplatform https://www.npmjs.com/package/base64url-xplatform

In browser:

import { Base64Url } from 'https://cdn.jsdelivr.net/npm/base64url-xplatform@1.0.1/esm/index.js'

window.Base64Url = Base64Url

There is also a class called "BufferShim" which is exported and it can be used to work with string and ArrayBuffer to go to and from base64 and UTF8.