identity_credential/validator/jpt_presentation_validation/
jpt_presentation_validation_options.rs

1// Copyright 2020-2024 IOTA Stiftung, Fondazione Links
2// SPDX-License-Identifier: Apache-2.0
3
4use identity_document::verifiable::JwpVerificationOptions;
5use serde::Deserialize;
6use serde::Serialize;
7
8/// Criteria for validating a [`Presentation`](crate::presentation::Presentation).
9#[derive(Debug, Default, Clone, Serialize, Deserialize)]
10#[non_exhaustive]
11#[serde(rename_all = "camelCase")]
12pub struct JptPresentationValidationOptions {
13  /// The nonce to be placed in the Presentation Protected Header.
14  #[serde(default)]
15  pub nonce: Option<String>,
16
17  /// Options which affect the verification of the proof on the credential.
18  #[serde(default)]
19  pub verification_options: JwpVerificationOptions,
20}
21
22impl JptPresentationValidationOptions {
23  /// Constructor that sets all options to their defaults.
24  pub fn new() -> Self {
25    Self::default()
26  }
27
28  /// Declare that the presentation is **not** considered valid if it expires before this [`Timestamp`].
29  /// Uses the current datetime during validation if not set.
30  pub fn nonce(mut self, nonce: impl Into<String>) -> Self {
31    self.nonce = Some(nonce.into());
32    self
33  }
34
35  /// Set options which affect the verification of the JWP proof.
36  pub fn verification_options(mut self, options: JwpVerificationOptions) -> Self {
37    self.verification_options = options;
38    self
39  }
40}