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

improve header protection ergonomics (breaking change) #128

Merged
merged 1 commit into from
Jul 21, 2024

Conversation

frasertweedale
Copy link
Owner

Changed the header protection data types for better ergonomics (#125). Previously, () was used for serialisations that only support protected headers (thus, a single constructor). This release introduces the new single-constructor data type ProtectedOnly to replace the use of () for this purpose. This is a breaking change and some library users will need to update their code.

The Protection type has been renamed to ProtectionOptional, with the old name retained as a (deprecated) type synonym.

The ProtectionIndicator class has been renamed to ProtectionOptionality, with the old name retained as a (deprecated) type synonym.

Added some convenience header and header parameter constructors: newJWSHeaderProtected, newHeaderParamProtected and newHeaderParamUnprotected.

Fixes: #125

@frasertweedale
Copy link
Owner Author

ping @ericpashman ^ could you please review and provide feedback?

@ericpashman
Copy link

Hi, Fraser. I haven't used this yet, but reading the code and Haddocks, I do think these changes make the purpose and usage of the header-protection functionality much clearer.

At risk of bike-shedding, and with the caveat that I'd probably have a different preferred naming scheme every time I look at this, here are the names that make the most sense to me right now.

Class: ProtectionIndicator -> ProtectionOptionality -> ProtectionSupport
Type: Protection -> ProtectionOptional -> OptionalProtection
Type: () -> ProtectedOnly -> RequiredProtection

In particular, calling the class ProtectionSupport seems closer to the language of the documentation ("serialisations that only support
protected headers") than my originally suggested ProtectionOptionality.

@frasertweedale
Copy link
Owner Author

@ericpashman thanks for your feedback. There's a nice balance to your suggested names and I have adopted them. I will push the changes shortly, and merge after testing. Then a release is not far away!

Thank you for you patience and collaboration!

Changed the header protection data types for better ergonomics
([#125](#125)).
Previously, `()` was used for serialisations that only support
protected headers (thus, a single constructor).  This release
introduces the new single-constructor data type `ProtectedOnly` to
replace the use of `()` for this purpose.  This is a breaking
change and some library users will need to update their code.

The `Protection` type has been renamed to `ProtectionOptional`,
with the old name retained as a (deprecated) type synonym.

The `ProtectionIndicator` class has been renamed to
`ProtectionOptionality`, with the old name retained as a
(deprecated) type synonym.

Added some convenience header and header parameter constructors:
`newJWSHeaderProtected`, `newHeaderParamProtected` and
`newHeaderParamUnprotected`.

Fixes: #125
@frasertweedale frasertweedale merged commit 37615be into master Jul 21, 2024
16 checks passed
@frasertweedale frasertweedale deleted the fix/125-protection-ergonomics branch July 21, 2024 13:03
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.

Document or re-name protection indicators
2 participants