Skip to content
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

Add type property #519

Closed
hicallmeal opened this issue Jul 6, 2024 · 2 comments
Closed

Add type property #519

hicallmeal opened this issue Jul 6, 2024 · 2 comments

Comments

@hicallmeal
Copy link

When dealing with multiple tokens of differing type (hotp/totp/custom (out of scope of OTPAuth)), it'd be good to be able to distinguish them according to type, so that it's easier to perform type specific operations (UI, sorting, etc).

The default would be totp and HMAC tokens would be hotp.

I think it should be easy enough to implement; during URI parsing, add it to config

if (uriType === "hotp") {

And the classes can add it to the defaults.

Can attempt a pull request if you'd like.

@hectorm
Copy link
Owner

hectorm commented Jul 9, 2024

You can actually check the type with instanceof (see example), isn't that enough for your use case?

@hicallmeal
Copy link
Author

hicallmeal commented Jul 15, 2024

I admittedly didn't know/check for that, thank you.
Unfortunately, that's more of a check / expression, where I'd rather directly get a property as there's also assumed certainty.
And it feels a little expensive checking that way - but, I have no idea on that!

All good though, thank you for the advice!

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

No branches or pull requests

2 participants