sd_jwt_payload/
signer.rs

1// Copyright 2020-2024 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use std::fmt::Display;
5
6use async_trait::async_trait;
7use serde_json::Map;
8use serde_json::Value;
9
10pub type JsonObject = Map<String, Value>;
11
12/// JSON Web Signature (JWS) Signer.
13#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
14#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
15pub trait JwsSigner {
16  type Error: Display;
17  /// Creates a JWS. The algorithm used for signed must be read from `header.alg` property.
18  async fn sign(&self, header: &JsonObject, payload: &JsonObject) -> Result<Vec<u8>, Self::Error>;
19}