-
Notifications
You must be signed in to change notification settings - Fork 61
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
Enhancement encoder #448
base: master
Are you sure you want to change the base?
Enhancement encoder #448
Conversation
Fixed Tracked Files Fixed Tracked Files
…thn-ruby into enhancment/encoder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Kaakati! Thank you so much for your contribution! 👋
Sorry for the delayed response. Left a couple of comments 🙂
# @param data [String] the data to encode | ||
# @return [String] Base64 encoded data | ||
def encode_base64(data) | ||
Base64.strict_encode64(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module Config | ||
module Encoder | ||
# Default encoding type used for WebAuthn operations | ||
DEFAULT_ENCODING = :base64url | ||
|
||
# Supported encoding types and their corresponding Base64 methods | ||
ENCODINGS = { | ||
base64: :strict, | ||
base64url: :urlsafe | ||
}.freeze | ||
|
||
# Error message template for unsupported encoding types | ||
INVALID_ENCODING_ERROR = "Unsupported or unknown encoding: %s".freeze | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just moving these constants inside Webauthn::Encoder
?
# Encode data using URL-safe Base64 encoding without padding | ||
# @param data [String] the data to encode | ||
# @return [String] URL-safe Base64 encoded data | ||
def encode_base64url(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to have these methods public in some way, so that they can be used in our specs to encode/decode data and we can remove the base64
dependency altogether – see this PR.
ENCODINGS = { | ||
base64: :strict, | ||
base64url: :urlsafe | ||
}.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not using the values of this hash right? Why not just storing the encodings as an array?
Config
moduleBase64
module instead of manual string manipulation