Skip to content

Remove base64 dependency #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

santiagorodriguez96
Copy link
Contributor

@santiagorodriguez96 santiagorodriguez96 commented Apr 11, 2025

Motivation

Fixes #422.

Details

This PR introduces the new Encoders module in order to encapsulate the logic of the different encoding methods into the same place and let us re-use this logic in across all the different parts of the gem which will in turn allow us to cleanly (and finally) remove the base64 dependency. This logic was previously encapsulated in Encoder which now will just delegates encoding and decoding tasks to specific encoder classes defined in the new Encoders module - we are really just keeping it, just in case, for backward compatibility.

The new Encoders contains classes for Base64Encoder, Base64UrlEncoder, and NullEncoder and a lookup method to return the appropriate encoder class based on the encoding type.

Finally, it also updates the different parts of the gem where the base64 gem was used.

data = data.ljust((data.length + 3) & ~3, "=")
end

data = data.tr("-_", "+/")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that in the base64 gem, the method tr has a bang in the if branch, but not in the else branch 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! I'll open a separate PR to fix that 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

base64 cleanup needed: U2fMigrator still calls Base64 methods, and a require exists
2 participants