#[non_exhaustive]pub struct JwsHeader {
pub alg: JwsAlgorithm,
pub typ: Option<String>,
pub cty: Option<String>,
pub kid: Option<String>,
pub jwk: Option<Jwk>,
pub crit: Option<Vec<String>>,
pub additional: IndexMap<String, Value>,
}Expand description
The JOSE header of a JWS (RFC 7515 §4).
The registered parameters this crate acts on are fields; everything else, x5c and b64
included, lives in additional in insertion order. jwk is the public key the signer claims
to have used; trusting it is the verifier’s decision, never the crate’s.
§Examples
use identity_kit::jose::{JwsAlgorithm, JwsHeader};
let mut header = JwsHeader::new(JwsAlgorithm::ES256).with_kid("did:example:123#key-1");
header.typ = Some("JWT".to_owned());
assert_eq!(
serde_json::to_string(&header)?,
r#"{"alg":"ES256","typ":"JWT","kid":"did:example:123#key-1"}"#
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.alg: JwsAlgorithmThe signature algorithm (alg).
typ: Option<String>The media type of the whole JWS (typ), such as JWT or vc+jwt.
cty: Option<String>The media type of the payload (cty).
kid: Option<String>The key id (kid); for a DID controller, usually a DID URL with a fragment.
jwk: Option<Jwk>The public key the signature was made with (jwk).
crit: Option<Vec<String>>Extensions a recipient must understand (crit).
additional: IndexMap<String, Value>Every other header parameter, in insertion order.
Implementations§
Source§impl JwsHeader
impl JwsHeader
Sourcepub fn new(alg: JwsAlgorithm) -> Self
pub fn new(alg: JwsAlgorithm) -> Self
A header with only alg set.
Sourcepub fn with_x5c<C: AsRef<[u8]>>(self, chain: &[C]) -> Self
pub fn with_x5c<C: AsRef<[u8]>>(self, chain: &[C]) -> Self
This header with chain as its x5c parameter (RFC 7515 §4.1.6): DER-encoded
certificates, the one of the signing key first, each followed by the one that
certifies it.
HAIP requires more of every x5c it defines: the first certificate is not
self-signed, and the chain leaves out the trust anchor.
Sourcepub fn for_signer(signer: &dyn Signer) -> Self
pub fn for_signer(signer: &dyn Signer) -> Self
The header a token signed by signer starts from: its algorithm, and what names its
key, the certificate chain of Signer::x5c when it has one, otherwise its
kid.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JwsHeader
impl<'de> Deserialize<'de> for JwsHeader
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for JwsHeader
impl StructuralPartialEq for JwsHeader
Auto Trait Implementations§
impl Forget for JwsHeader
impl Freeze for JwsHeader
impl Move for JwsHeader
impl RefUnwindSafe for JwsHeader
impl Send for JwsHeader
impl Sync for JwsHeader
impl Unpin for JwsHeader
impl UnsafeUnpin for JwsHeader
impl UnwindSafe for JwsHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.