Skip to content

Commit

Permalink
use string type for data integrity proof domain
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tate <[email protected]>
  • Loading branch information
Ryanmtate committed Dec 15, 2024
1 parent c5d4f0d commit 270d184
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
11 changes: 6 additions & 5 deletions crates/claims/crates/data-integrity/core/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ pub struct ProofOptions<M, T> {
/// Example domain values include: `domain.example`` (DNS domain),
/// `https://domain.example:8443` (Web origin), `mycorp-intranet` (bespoke
/// text string), and `b31d37d4-dd59-47d3-9dd8-c973da43b63a` (UUID).
#[serde(default, skip_serializing_if = "Vec::is_empty", rename = "domain")]
pub domains: Vec<String>,
// #[serde(default, skip_serializing_if = "Vec::is_empty", rename = "domain")]
#[serde(default, rename = "domain")]
pub domains: String,

/// Used to mitigate replay attacks.
///
Expand Down Expand Up @@ -78,7 +79,7 @@ impl<M, T: Default> Default for ProofOptions<M, T> {
verification_method: None,
proof_purpose: ProofPurpose::default(),
expires: None,
domains: Vec::new(),
domains: String::default(),
challenge: None,
nonce: None,
options: Default::default(),
Expand All @@ -100,7 +101,7 @@ impl<M, T> ProofOptions<M, T> {
verification_method: Some(verification_method),
proof_purpose,
expires: None,
domains: Vec::new(),
domains: String::default(),
challenge: None,
nonce: None,
options,
Expand All @@ -115,7 +116,7 @@ impl<M, T> ProofOptions<M, T> {
verification_method: Some(verification_method),
proof_purpose: ProofPurpose::default(),
expires: None,
domains: Vec::new(),
domains: String::default(),
challenge: None,
nonce: None,
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ pub struct ProofConfiguration<S: CryptographicSuite> {
/// Example domain values include: `domain.example`` (DNS domain),
/// `https://domain.example:8443` (Web origin), `mycorp-intranet` (bespoke
/// text string), and `b31d37d4-dd59-47d3-9dd8-c973da43b63a` (UUID).
#[serde(skip_serializing_if = "Vec::is_empty", rename = "domain")]
pub domains: Vec<String>,
// #[serde(skip_serializing_if = "Vec::is_empty", rename = "domain")]
#[serde(rename = "domain")]
pub domains: String,

/// Used to mitigate replay attacks.
///
Expand Down Expand Up @@ -102,7 +103,7 @@ impl<S: CryptographicSuite> ProofConfiguration<S> {
verification_method,
proof_purpose,
expires: None,
domains: Vec::new(),
domains: String::default(),
challenge: None,
nonce: None,
options,
Expand All @@ -122,7 +123,7 @@ impl<S: CryptographicSuite> ProofConfiguration<S> {
verification_method,
proof_purpose: ProofPurpose::default(),
expires: None,
domains: Vec::new(),
domains: String::default(),
challenge: None,
nonce: None,
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub struct ProofConfigurationRef<'a, S: CryptographicSuite> {
#[serde(skip_serializing_if = "Option::is_none")]
pub expires: Option<xsd_types::DateTimeStamp>,

#[serde(skip_serializing_if = "<[String]>::is_empty", rename = "domain")]
pub domains: &'a [String],
#[serde(rename = "domain")]
pub domains: &'a str,

#[serde(skip_serializing_if = "Option::is_none")]
pub challenge: Option<&'a str>,
Expand Down Expand Up @@ -151,8 +151,8 @@ pub struct ProofConfigurationRefWithoutOptions<'a, S: CryptographicSuite> {
#[serde(skip_serializing_if = "Option::is_none")]
pub expires: Option<xsd_types::DateTimeStamp>,

#[serde(skip_serializing_if = "<[String]>::is_empty", rename = "domain")]
pub domains: &'a [String],
#[serde(rename = "domain")]
pub domains: &'a str,

#[serde(skip_serializing_if = "Option::is_none")]
pub challenge: Option<&'a str>,
Expand Down
6 changes: 3 additions & 3 deletions crates/claims/crates/data-integrity/core/src/proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ pub struct Proof<S: CryptographicSuite> {
/// Example domain values include: `domain.example`` (DNS domain),
/// `https://domain.example:8443` (Web origin), `mycorp-intranet` (bespoke
/// text string), and `b31d37d4-dd59-47d3-9dd8-c973da43b63a` (UUID).
#[serde(skip_serializing_if = "Vec::is_empty", rename = "domain")]
pub domains: Vec<String>,
#[serde(rename = "domain")]
pub domains: String,

/// Used to mitigate replay attacks.
///
Expand Down Expand Up @@ -132,7 +132,7 @@ impl<T: CryptographicSuite> Proof<T> {
verification_method,
proof_purpose,
expires: None,
domains: Vec::new(),
domains: String::default(),
challenge: None,
nonce: None,
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct ProofRef<'a, S: CryptographicSuite> {

pub expires: Option<xsd_types::DateTimeStamp>,

pub domains: &'a [String],
pub domains: &'a str,

pub challenge: Option<&'a str>,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub enum ConfigurationError {
#[error("invalid option `{0}`")]
InvalidOption(String),

#[error("missing domain")]
MissingDomain,

#[error("{0}")]
Other(String),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ where
verification_method: base_proof.verification_method.cloned(),
proof_purpose: base_proof.proof_purpose,
expires: base_proof.expires,
domains: base_proof.domains.to_vec(),
domains: base_proof.domains.to_string(),
challenge: base_proof.challenge.map(ToOwned::to_owned),
nonce: base_proof.nonce.map(ToOwned::to_owned),
options: *base_proof.options,
Expand Down

0 comments on commit 270d184

Please sign in to comment.