Struct truelayer_signing::Signer
source · [−]pub struct Signer<'a> { /* private fields */ }
Expand description
Builder to generate a Tl-Signature
header value using a private key.
See crate::sign_with_pem
for examples.
Implementations
sourceimpl<'a> Signer<'a>
impl<'a> Signer<'a>
sourcepub fn body(self, body: &'a [u8]) -> Self
pub fn body(self, body: &'a [u8]) -> Self
Add the full request body.
Note: This must be identical to what is sent with the request.
Example
truelayer_signing::sign_with_pem(kid, key)
.body(b"{...}");
sourcepub fn method(self, method: &'a str) -> Self
pub fn method(self, method: &'a str) -> Self
Add the request method, defaults to "POST"
if unspecified.
Example
truelayer_signing::sign_with_pem(kid, key)
.method("POST");
sourcepub fn header(self, key: &'a str, value: &'a [u8]) -> Self
pub fn header(self, key: &'a str, value: &'a [u8]) -> Self
Add a header name & value. May be called multiple times to add multiple different headers.
Warning: Only a single value per header name is supported.
Example
truelayer_signing::sign_with_pem(kid, key)
.header("Idempotency-Key", b"60df4d00-9778-4297-be6d-817d7a6d27bb");
sourcepub fn add_header(&mut self, key: &'a str, value: &'a [u8])
pub fn add_header(&mut self, key: &'a str, value: &'a [u8])
Add a header name & value. May be called multiple times to add multiple different headers.
Warning: Only a single value per header name is supported.
Example
signer.add_header("Idempotency-Key", b"60df4d00-9778-4297-be6d-817d7a6d27bb");
sourcepub fn headers(
self,
headers: impl IntoIterator<Item = (&'a str, &'a [u8])>
) -> Self
pub fn headers(
self,
headers: impl IntoIterator<Item = (&'a str, &'a [u8])>
) -> Self
Appends multiple header names & values.
Warning: Only a single value per header name is supported.
Example
truelayer_signing::sign_with_pem(kid, key)
.headers([("X-Head-A", "123".as_bytes()), ("X-Head-B", "345".as_bytes())]);
sourcepub fn jku(self, jku: &'a str) -> Self
pub fn jku(self, jku: &'a str) -> Self
Sets the jws header jku
JSON Web Key URL.
Note: This is not generally required when calling APIs, but is set on webhook signatures.
sourcepub fn sign_body_only(&self) -> Result<String, Error>
pub fn sign_body_only(&self) -> Result<String, Error>
Produce a JWS Tl-Signature
v1 header value, signing just the request body.
Any specified method, path & headers will be ignored.
In general full request signing should be preferred, see Signer::sign
.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Signer<'a>
impl<'a> Send for Signer<'a>
impl<'a> Sync for Signer<'a>
impl<'a> Unpin for Signer<'a>
impl<'a> UnwindSafe for Signer<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more