Skip to content

Commit

Permalink
use option 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 8953aee commit a5d6ad3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
10 changes: 5 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,8 @@ 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 = "Option::is_none", rename = "domain")]
pub domains: Option<String>,

/// Used to mitigate replay attacks.
///
Expand Down Expand Up @@ -78,7 +78,7 @@ impl<M, T: Default> Default for ProofOptions<M, T> {
verification_method: None,
proof_purpose: ProofPurpose::default(),
expires: None,
domains: Vec::new(),
domains: None,
challenge: None,
nonce: None,
options: Default::default(),
Expand All @@ -100,7 +100,7 @@ impl<M, T> ProofOptions<M, T> {
verification_method: Some(verification_method),
proof_purpose,
expires: None,
domains: Vec::new(),
domains: None,
challenge: None,
nonce: None,
options,
Expand All @@ -115,7 +115,7 @@ impl<M, T> ProofOptions<M, T> {
verification_method: Some(verification_method),
proof_purpose: ProofPurpose::default(),
expires: None,
domains: Vec::new(),
domains: None,
challenge: None,
nonce: None,
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ 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 = "Option::is_none", rename = "domain")]
pub domains: Option<String>,

/// Used to mitigate replay attacks.
///
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<S: CryptographicSuite> ProofConfiguration<S> {
verification_method,
proof_purpose,
expires: None,
domains: Vec::new(),
domains: None,
challenge: None,
nonce: None,
options,
Expand All @@ -122,7 +122,7 @@ impl<S: CryptographicSuite> ProofConfiguration<S> {
verification_method,
proof_purpose: ProofPurpose::default(),
expires: None,
domains: Vec::new(),
domains: None,
challenge: None,
nonce: None,
options,
Expand Down Expand Up @@ -221,7 +221,7 @@ impl<S: CryptographicSuite> ProofConfiguration<S> {
verification_method: self.verification_method.borrowed(),
proof_purpose: self.proof_purpose,
expires: self.expires,
domains: &self.domains,
domains: self.domains.as_deref(),
challenge: self.challenge.as_deref(),
nonce: self.nonce.as_deref(),
options: &self.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")]
pub domains: &'a [String],
#[serde(skip_serializing_if = "Option::is_none", rename = "domain")]
pub domains: Option<&'a str>,

#[serde(skip_serializing_if = "Option::is_none")]
pub challenge: Option<&'a str>,
Expand Down Expand Up @@ -59,7 +59,7 @@ impl<'a, S: CryptographicSuite> ProofConfigurationRef<'a, S> {
verification_method: S::clone_verification_method_ref_ref(self.verification_method),
proof_purpose: self.proof_purpose,
expires: self.expires,
domains: self.domains.to_owned(),
domains: self.domains.map(ToOwned::to_owned),
challenge: self.challenge.map(ToOwned::to_owned),
nonce: self.nonce.map(ToOwned::to_owned),
options: S::clone_proof_options(self.options),
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")]
pub domains: &'a [String],
#[serde(skip_serializing_if = "Option::is_none", rename = "domain")]
pub domains: Option<&'a str>,

#[serde(skip_serializing_if = "Option::is_none")]
pub challenge: Option<&'a str>,
Expand Down
10 changes: 5 additions & 5 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(default, skip_serializing_if = "Option::is_none", rename = "domain")]
pub domains: Option<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: None,
challenge: None,
nonce: None,
options,
Expand All @@ -149,7 +149,7 @@ impl<T: CryptographicSuite> Proof<T> {
verification_method: self.verification_method.borrowed(),
proof_purpose: self.proof_purpose,
expires: self.expires,
domains: &self.domains,
domains: self.domains.as_deref(),
challenge: self.challenge.as_deref(),
nonce: self.nonce.as_deref(),
options: &self.options,
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<T: CryptographicSuite> Proof<T> {
verification_method: self.verification_method.borrowed(),
proof_purpose: self.proof_purpose,
expires: self.expires,
domains: &self.domains,
domains: self.domains.as_deref(),
challenge: self.challenge.as_deref(),
nonce: self.nonce.as_deref(),
options: &self.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: Option<&'a str>,

pub challenge: Option<&'a str>,

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.map(ToOwned::to_owned),
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 a5d6ad3

Please sign in to comment.