Skip to content

fix: make algorithm type enum compatible with GraphQL #160

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 2 commits into
base: main
Choose a base branch
from

Conversation

taleodor
Copy link
Contributor

No description provided.

@taleodor taleodor requested review from oej and madpah as code owners May 23, 2025 12:34
@ppkarwasz
Copy link
Contributor

There are at least four standards relevant to TEA that define checksum algorithm names, each with its own conventions:

These standards differ in more than just casing—they use different separators and naming conventions. For example, the SHA-1 algorithm appears as SHA-1, SHA1, and even sha1 depending on the context.

Ideally, we should aim for consistency across formats, but it’s not clear which convention to standardize on. One option might be to align with the IANA registry of named information, which provides a more neutral and centrally managed way to assign names.

If we do decide to normalize algorithm names, we could apply a simple, deterministic transformation to the IANA names, such as:

  • Converting all characters to uppercase
  • Replacing hyphens (-) with underscores (_)

- BLAKE2b-256
- BLAKE2b-384
- BLAKE2b-512
- SHA_1
Copy link
Contributor

Choose a reason for hiding this comment

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

All enum constants follow a common <algorithm_name>[_<output_size>] pattern, where the <algorithm_name> is composed of alphanumeric characters only. SHA_1 is the exception, so I would suggest to rename it to SHA1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, renamed.

Regarding,

  • Converting all characters to uppercase
  • Replacing hyphens (-) with underscores (_)
    -> This is essentially GraphQL's convention for enums - https://graphql.com/learn/enums/

Copy link
Contributor

Choose a reason for hiding this comment

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

Not only GraphQL does not allow hyphens in enum names! 😉

Your changes might simplify the life of many implementors! 💯

Signed-off-by: Pavel Shukhman <[email protected]>
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.

2 participants