fix: remove urlsafe-base64 dependency #218
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In PR #214, I missed that the urlsafe-base64 dependency used the global
Buffer
object internally. I already had some polyfills added when I tested the change so I missed that we still required the polyfill.There are a few solutions to this.
globalThis.Buffer = import("buffer").Buffer
.buffer
buffer module.I think the first one is a hack and an anti-pattern to taint global namespace in a library. The second one is a bit too much work for a quick fix. The last one is a good compromise in my opinion, so I did that. Ideally, the buffer module should support base64 url encode/decode but the PR for that has not been merged for some time: feross/buffer#314.
I took some code and test cases from the node.js ecosystem and replaced the urlsafe-base64 dependency with an internal module that uses the buffer package.
Let me know what you think. Can also go with option 1 if you prefer. But a fix is needed to avoid forcing users to polyfill for themselves.