fix: remove urlsafe-base64 dependency#218
Merged
lenkan merged 1 commit intoWebOfTrust:developmentfrom Mar 11, 2024
Merged
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## development #218 +/- ##
============================================
Coverage 82.86% 82.86%
============================================
Files 46 47 +1
Lines 4190 4202 +12
Branches 1044 1047 +3
============================================
+ Hits 3472 3482 +10
- Misses 689 691 +2
Partials 29 29 ☔ View full report in Codecov by Sentry. |
Contributor
|
Less dependencies is better in my opinion. Ultimately I think we should get rid of Buffer completely. |
pfeairheller
approved these changes
Mar 9, 2024
Member
pfeairheller
left a comment
There was a problem hiding this comment.
I think this is a good compromise. I doubt there will be any innovations in Base64 encoding/decoding we'll have to keep up with!
c6c6bad to
d534ee3
Compare
daviddm
pushed a commit
to daviddm/signify-ts
that referenced
this pull request
May 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Bufferobject 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.bufferbuffer 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.