Remove optional features from mas-iana & regenerate

Also ignores 'TEMPORARY' items in the IANA registry
This commit is contained in:
Quentin Gliech
2025-06-10 12:07:10 +02:00
parent 8f5094ed19
commit a12b50147a
8 changed files with 67 additions and 57 deletions

View File

@@ -164,8 +164,7 @@ pub fn json_schema_impl(
) -> std::fmt::Result {
write!(
f,
r#"#[cfg(feature = "schemars")]
impl schemars::JsonSchema for {} {{
r#"impl schemars::JsonSchema for {} {{
fn schema_name() -> String {{
"{}".to_owned()
}}
@@ -237,8 +236,7 @@ impl schemars::JsonSchema for {} {{
pub fn serde_impl(f: &mut std::fmt::Formatter<'_>, section: &Section) -> std::fmt::Result {
writeln!(
f,
r#"#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for {} {{
r"impl<'de> serde::Deserialize<'de> for {} {{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::de::Deserializer<'de>,
@@ -248,7 +246,6 @@ impl<'de> serde::Deserialize<'de> for {} {{
}}
}}
#[cfg(feature = "serde")]
impl serde::Serialize for {} {{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -256,7 +253,7 @@ impl serde::Serialize for {} {{
{{
serializer.serialize_str(&self.to_string())
}}
}}"#,
}}",
section.key, section.key,
)
}

View File

@@ -31,6 +31,7 @@ enum Requirements {
RecommendedMinus,
Optional,
Prohibited,
Deprecated,
}
#[allow(dead_code)]
@@ -78,10 +79,18 @@ impl EnumEntry for WebEncryptionSignatureAlgorithm {
if self.reference.contains("RFC7518, Section 3")
|| self.reference.contains("RFC8037")
|| self.reference.contains("RFC8812")
|| (self
.reference
.contains("RFC-ietf-jose-fully-specified-algorithms")
&& self.reference.contains("Section 2"))
{
Some("JsonWebSignatureAlg")
} else if self.reference.contains("RFC7518, Section 4")
|| self.reference.contains("WebCryptoAPI")
|| (self
.reference
.contains("RFC-ietf-jose-fully-specified-algorithms")
&& self.reference.contains("Section 3"))
{
Some("JsonWebEncryptionAlg")
} else {

View File

@@ -89,6 +89,13 @@ pub trait EnumEntry: DeserializeOwned + Send + Sync {
.into_deserialize()
.filter_map(|item: Result<Self, _>| {
item.map(|item| {
if item
.description()
.is_some_and(|desc| desc.contains("TEMPORARY"))
{
return None;
}
item.key().map(|key| {
(
key,

View File

@@ -13,10 +13,5 @@ publish.workspace = true
workspace = true
[dependencies]
serde = { workspace = true, optional = true }
schemars = { workspace = true, optional = true }
[features]
default = ["serde", "schemars"]
serde = ["dep:serde"]
schemars = ["dep:schemars"]
serde.workspace = true
schemars.workspace = true

View File

@@ -62,6 +62,12 @@ pub enum JsonWebSignatureAlg {
/// ECDSA using secp256k1 curve and SHA-256
Es256K,
/// EdDSA using Ed25519 curve
Ed25519,
/// EdDSA using Ed448 curve
Ed448,
/// An unknown value.
Unknown(String),
}
@@ -84,6 +90,8 @@ impl core::fmt::Display for JsonWebSignatureAlg {
Self::None => write!(f, "none"),
Self::EdDsa => write!(f, "EdDSA"),
Self::Es256K => write!(f, "ES256K"),
Self::Ed25519 => write!(f, "Ed25519"),
Self::Ed448 => write!(f, "Ed448"),
Self::Unknown(value) => write!(f, "{value}"),
}
}
@@ -109,12 +117,13 @@ impl core::str::FromStr for JsonWebSignatureAlg {
"none" => Ok(Self::None),
"EdDSA" => Ok(Self::EdDsa),
"ES256K" => Ok(Self::Es256K),
"Ed25519" => Ok(Self::Ed25519),
"Ed448" => Ok(Self::Ed448),
value => Ok(Self::Unknown(value.to_owned())),
}
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebSignatureAlg {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -125,7 +134,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebSignatureAlg {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebSignatureAlg {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -135,7 +143,6 @@ impl serde::Serialize for JsonWebSignatureAlg {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebSignatureAlg {
fn schema_name() -> String {
"JsonWebSignatureAlg".to_owned()
@@ -339,6 +346,32 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
..Default::default()
}
.into(),
// ---
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r"EdDSA using Ed25519 curve".to_owned(),
),
..Default::default()
})),
const_value: Some("Ed25519".into()),
..Default::default()
}
.into(),
// ---
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r"EdDSA using Ed448 curve".to_owned(),
),
..Default::default()
})),
const_value: Some("Ed448".into()),
..Default::default()
}
.into(),
];
let description = r#"JSON Web Signature "alg" parameter"#;
@@ -480,7 +513,6 @@ impl core::str::FromStr for JsonWebEncryptionAlg {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebEncryptionAlg {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -491,7 +523,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebEncryptionAlg {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebEncryptionAlg {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -501,7 +532,6 @@ impl serde::Serialize for JsonWebEncryptionAlg {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebEncryptionAlg {
fn schema_name() -> String {
"JsonWebEncryptionAlg".to_owned()
@@ -833,7 +863,6 @@ impl core::str::FromStr for JsonWebEncryptionEnc {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebEncryptionEnc {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -844,7 +873,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebEncryptionEnc {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebEncryptionEnc {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -854,7 +882,6 @@ impl serde::Serialize for JsonWebEncryptionEnc {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebEncryptionEnc {
fn schema_name() -> String {
"JsonWebEncryptionEnc".to_owned()
@@ -992,7 +1019,6 @@ impl core::str::FromStr for JsonWebEncryptionCompressionAlgorithm {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebEncryptionCompressionAlgorithm {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -1003,7 +1029,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebEncryptionCompressionAlgorithm {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebEncryptionCompressionAlgorithm {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -1013,7 +1038,6 @@ impl serde::Serialize for JsonWebEncryptionCompressionAlgorithm {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebEncryptionCompressionAlgorithm {
fn schema_name() -> String {
"JsonWebEncryptionCompressionAlgorithm".to_owned()
@@ -1101,7 +1125,6 @@ impl core::str::FromStr for JsonWebKeyType {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebKeyType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -1112,7 +1135,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyType {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebKeyType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -1122,7 +1144,6 @@ impl serde::Serialize for JsonWebKeyType {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebKeyType {
fn schema_name() -> String {
"JsonWebKeyType".to_owned()
@@ -1249,7 +1270,6 @@ impl core::str::FromStr for JsonWebKeyEcEllipticCurve {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebKeyEcEllipticCurve {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -1260,7 +1280,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyEcEllipticCurve {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebKeyEcEllipticCurve {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -1270,7 +1289,6 @@ impl serde::Serialize for JsonWebKeyEcEllipticCurve {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve {
fn schema_name() -> String {
"JsonWebKeyEcEllipticCurve".to_owned()
@@ -1397,7 +1415,6 @@ impl core::str::FromStr for JsonWebKeyOkpEllipticCurve {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebKeyOkpEllipticCurve {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -1408,7 +1425,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyOkpEllipticCurve {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebKeyOkpEllipticCurve {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -1418,7 +1434,6 @@ impl serde::Serialize for JsonWebKeyOkpEllipticCurve {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve {
fn schema_name() -> String {
"JsonWebKeyOkpEllipticCurve".to_owned()
@@ -1535,7 +1550,6 @@ impl core::str::FromStr for JsonWebKeyUse {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebKeyUse {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -1546,7 +1560,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyUse {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebKeyUse {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -1556,7 +1569,6 @@ impl serde::Serialize for JsonWebKeyUse {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebKeyUse {
fn schema_name() -> String {
"JsonWebKeyUse".to_owned()
@@ -1677,7 +1689,6 @@ impl core::str::FromStr for JsonWebKeyOperation {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for JsonWebKeyOperation {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -1688,7 +1699,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyOperation {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for JsonWebKeyOperation {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -1698,7 +1708,6 @@ impl serde::Serialize for JsonWebKeyOperation {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for JsonWebKeyOperation {
fn schema_name() -> String {
"JsonWebKeyOperation".to_owned()

View File

@@ -59,7 +59,6 @@ impl core::str::FromStr for OAuthAccessTokenType {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for OAuthAccessTokenType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -70,7 +69,6 @@ impl<'de> serde::Deserialize<'de> for OAuthAccessTokenType {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for OAuthAccessTokenType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -80,7 +78,6 @@ impl serde::Serialize for OAuthAccessTokenType {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for OAuthAccessTokenType {
fn schema_name() -> String {
"OAuthAccessTokenType".to_owned()
@@ -194,7 +191,6 @@ impl core::str::FromStr for OAuthAuthorizationEndpointResponseType {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for OAuthAuthorizationEndpointResponseType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -205,7 +201,6 @@ impl<'de> serde::Deserialize<'de> for OAuthAuthorizationEndpointResponseType {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for OAuthAuthorizationEndpointResponseType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -215,7 +210,6 @@ impl serde::Serialize for OAuthAuthorizationEndpointResponseType {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for OAuthAuthorizationEndpointResponseType {
fn schema_name() -> String {
"OAuthAuthorizationEndpointResponseType".to_owned()
@@ -333,7 +327,6 @@ impl core::str::FromStr for OAuthTokenTypeHint {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for OAuthTokenTypeHint {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -344,7 +337,6 @@ impl<'de> serde::Deserialize<'de> for OAuthTokenTypeHint {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for OAuthTokenTypeHint {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -354,7 +346,6 @@ impl serde::Serialize for OAuthTokenTypeHint {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for OAuthTokenTypeHint {
fn schema_name() -> String {
"OAuthTokenTypeHint".to_owned()
@@ -462,7 +453,6 @@ impl core::str::FromStr for OAuthClientAuthenticationMethod {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for OAuthClientAuthenticationMethod {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -473,7 +463,6 @@ impl<'de> serde::Deserialize<'de> for OAuthClientAuthenticationMethod {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for OAuthClientAuthenticationMethod {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -483,7 +472,6 @@ impl serde::Serialize for OAuthClientAuthenticationMethod {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for OAuthClientAuthenticationMethod {
fn schema_name() -> String {
"OAuthClientAuthenticationMethod".to_owned()
@@ -590,7 +578,6 @@ impl core::str::FromStr for PkceCodeChallengeMethod {
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for PkceCodeChallengeMethod {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -601,7 +588,6 @@ impl<'de> serde::Deserialize<'de> for PkceCodeChallengeMethod {
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for PkceCodeChallengeMethod {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -611,7 +597,6 @@ impl serde::Serialize for PkceCodeChallengeMethod {
}
}
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for PkceCodeChallengeMethod {
fn schema_name() -> String {
"PkceCodeChallengeMethod".to_owned()

View File

@@ -167,7 +167,7 @@ impl AsymmetricSigningKey {
Ok(Self::es256k(params.try_into()?))
}
(JsonWebKeyPrivateParameters::Okp(_params), JsonWebSignatureAlg::EdDsa) => {
(JsonWebKeyPrivateParameters::Okp(_params), _) => {
Err(AsymmetricKeyFromJwkError::UnsupportedAlgorithm { alg: alg.clone() })
}
@@ -401,7 +401,7 @@ impl AsymmetricVerifyingKey {
Ok(Self::es256k(params.try_into()?))
}
(JsonWebKeyPublicParameters::Okp(_params), JsonWebSignatureAlg::EdDsa) => {
(JsonWebKeyPublicParameters::Okp(_params), _) => {
Err(AsymmetricKeyFromJwkError::UnsupportedAlgorithm { alg: alg.clone() })
}

View File

@@ -543,6 +543,14 @@
{
"description": "ECDSA using secp256k1 curve and SHA-256",
"const": "ES256K"
},
{
"description": "EdDSA using Ed25519 curve",
"const": "Ed25519"
},
{
"description": "EdDSA using Ed448 curve",
"const": "Ed448"
}
]
},