Struct ssi_claims::JwsStr
source · pub struct JwsStr(/* private fields */);
Expand description
Borrowed UTF-8 encoded JWS.
This is an unsized type borrowing the JWS and meant to be referenced as
&JwsStr
, just like &str
.
Use JwsString
if you need to own the JWS.
This type is similar to the Jws
type.
However contrarily to Jws
, there is no guarantee that the JWS is URL-safe.
Use Jws
if you expect URL-safe JWSs.
Implementations§
source§impl JwsStr
impl JwsStr
pub fn new<T>(data: &T) -> Result<&JwsStr, InvalidJws<&T>>
pub const fn validate(bytes: &[u8]) -> bool
pub const fn validate_range(bytes: &[u8], i: usize, end: usize) -> bool
sourcepub const unsafe fn new_unchecked(data: &[u8]) -> &JwsStr
pub const unsafe fn new_unchecked(data: &[u8]) -> &JwsStr
Creates a new compact JWS without checking the data.
§Safety
The input data
must represent a valid compact JWS where the payload
is an UTF-8 string.
pub fn as_str(&self) -> &str
Methods from Deref<Target = JwsSlice>§
pub fn len(&self) -> usize
pub fn decode_header(&self) -> Result<Header, InvalidHeader>
sourcepub fn decode_payload(
&self,
header: &Header,
) -> Result<Cow<'_, [u8]>, DecodeError>
pub fn decode_payload( &self, header: &Header, ) -> Result<Cow<'_, [u8]>, DecodeError>
Decode the payload bytes.
The header is necessary to know how the payload is encoded.
pub fn decode_signature(&self) -> Result<JwsSignature, DecodeError>
sourcepub fn decode(&self) -> Result<DecodedJws<'_, Cow<'_, [u8]>>, DecodeError>
pub fn decode(&self) -> Result<DecodedJws<'_, Cow<'_, [u8]>>, DecodeError>
Decodes the entire JWS.
sourcepub fn signing_bytes(&self) -> &[u8] ⓘ
pub fn signing_bytes(&self) -> &[u8] ⓘ
Returns the signing bytes.
It is the concatenation of the Base64 encoded headers, a period ‘.’ and the Base64 encoded payload.
pub fn as_bytes(&self) -> &[u8] ⓘ
sourcepub async fn verify<V>(
&self,
params: V,
) -> Result<Result<(), Invalid>, ProofValidationError>
pub async fn verify<V>( &self, params: V, ) -> Result<Result<(), Invalid>, ProofValidationError>
Verify the JWS signature.
This will only check the signature and not the validity of the decoded payload. For instance if the payload is a set of JWT claims, those claims will not be validated.
To perform a more precise verification, specify use a specialized T
instead of the default Vec<u8>
The params
argument provides all the verification parameters required
to validate the claims and proof.
§What verification parameters should I use?
Any type that providing a JWKResolver
through the ResolverProvider
trait will be fine. Notable implementors are:
VerificationParameters
: A good default providing many other common verification parameters that are not necessary here.JWK
: allows you to put a JWK asparams
, which will resolve into itself. Can be useful if you don’t need key resolution because you know in advance what key was used to sign the JWS.
§Passing the parameters by reference
If the validation traits are implemented for P
, they will be
implemented for &P
as well. This means the parameters can be passed
by move or by reference.
Trait Implementations§
source§impl PartialOrd for JwsStr
impl PartialOrd for JwsStr
source§impl Serialize for JwsStr
impl Serialize for JwsStr
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
source§impl ToDecodedJwt for JwsStr
impl ToDecodedJwt for JwsStr
source§fn to_decoded_custom_jwt<C>(
&self,
) -> Result<DecodedJws<'_, JWTClaims<C>>, DecodeError>where
C: DeserializeOwned,
fn to_decoded_custom_jwt<C>(
&self,
) -> Result<DecodedJws<'_, JWTClaims<C>>, DecodeError>where
C: DeserializeOwned,
source§fn to_decoded_jwt(&self) -> Result<DecodedJws<'_, JWTClaims>, DecodeError>
fn to_decoded_jwt(&self) -> Result<DecodedJws<'_, JWTClaims>, DecodeError>
source§async fn verify_jwt<V>(
&self,
verifier: &V,
) -> Result<Result<(), Invalid>, ProofValidationError>
async fn verify_jwt<V>( &self, verifier: &V, ) -> Result<Result<(), Invalid>, ProofValidationError>
impl Eq for JwsStr
impl StructuralPartialEq for JwsStr
Auto Trait Implementations§
impl Freeze for JwsStr
impl RefUnwindSafe for JwsStr
impl Send for JwsStr
impl !Sized for JwsStr
impl Sync for JwsStr
impl Unpin for JwsStr
impl UnwindSafe for JwsStr
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> CallHasher for T
impl<T> CallHasher for T
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.