Don't extend HmacOneTimePasswordGenerator
in TimeBasedOneTimePasswordGenerator
#32
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.
Prior to this change,
TimeBasedOneTimePasswordGenerator
extendsHmacOneTimePasswordGenerator
. That moooooostly makes sense (TOTP as a standard is, in fact, an extension of HOTP), but creates a couple weird situations in the public API. In particular, it creates a situation where counter-based password-generation methods are visible inTimeBasedOneTimePasswordGenerator
instances, and it doesn't really make sense to be requesting one-time passwords from a TOTP generator by counter instead of by time.After this change,
TimeBasedOneTimePasswordGenerator
no longer has a base class, and instead delegates to a privateHmacOneTimePasswordGenerator
instance for password generation. That means its public interface will no longer have counter-based OTP-generation methods. This is technically a breaking API change, but only for callers who were trying to do counter-based operations with a TOTP generator.Feedback is very welcome!