identity_credential/presentation/
jwp_presentation_options.rs

1// Copyright 2020-2024 IOTA Stiftung, Fondazione Links
2// SPDX-License-Identifier: Apache-2.0
3
4use identity_core::common::Url;
5use serde::Deserialize;
6use serde::Serialize;
7
8/// Options to be set in the JWT claims of a verifiable presentation.
9#[derive(Clone, Debug, Serialize, Deserialize, Default)]
10pub struct JwpPresentationOptions {
11  /// Sets the audience for presentation (`aud` property in JWP Presentation Header).
12  /// Default: `None`.
13  #[serde(skip_serializing_if = "Option::is_none")]
14  pub audience: Option<Url>,
15
16  /// The nonce to be placed in the Presentation Protected Header.
17  #[serde(skip_serializing_if = "Option::is_none")]
18  pub nonce: Option<String>,
19}
20
21impl JwpPresentationOptions {
22  /// Sets the audience for presentation (`aud` property in JWT claims).
23  pub fn audience(mut self, audience: Url) -> Self {
24    self.audience = Some(audience);
25    self
26  }
27
28  /// Replace the value of the `nonce` field.
29  pub fn nonce(mut self, value: impl Into<String>) -> Self {
30    self.nonce = Some(value.into());
31    self
32  }
33}