identity_document/verifiable/
jwp_verification_options.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use identity_did::DIDUrl;
use identity_verification::MethodScope;

/// Holds additional options for verifying a JWP
#[non_exhaustive]
#[derive(Default, Debug, serde::Serialize, serde::Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct JwpVerificationOptions {
  /// Verify the signing verification method relation matches this.
  pub method_scope: Option<MethodScope>,
  /// The DID URl of the method, whose JWK should be used to verify the JWP.
  /// If unset, the `kid` of the JWP is used as the DID Url.
  pub method_id: Option<DIDUrl>,
}

impl JwpVerificationOptions {
  /// Creates a new [`JwpVerificationOptions`].
  pub fn new() -> Self {
    Self::default()
  }

  /// Set the scope of the verification methods that may be used to verify the given JWP.
  pub fn method_scope(mut self, value: MethodScope) -> Self {
    self.method_scope = Some(value);
    self
  }

  /// The DID URl of the method, whose JWK should be used to verify the JWP.
  pub fn method_id(mut self, value: DIDUrl) -> Self {
    self.method_id = Some(value);
    self
  }
}