#truelayer

truelayer-signing

Produce & verify TrueLayer API requests signatures

5 releases

Uses new Rust 2021

0.1.4 Jul 18, 2022
0.1.3 Feb 16, 2022
0.1.2 Dec 2, 2021
0.1.1 Nov 23, 2021
0.1.0 Oct 14, 2021
Download history 265/week @ 2022-04-15 377/week @ 2022-04-22 300/week @ 2022-04-29 324/week @ 2022-05-06 317/week @ 2022-05-13 202/week @ 2022-05-20 136/week @ 2022-05-27 155/week @ 2022-06-03 60/week @ 2022-06-10 170/week @ 2022-06-17 300/week @ 2022-06-24 217/week @ 2022-07-01 227/week @ 2022-07-08 215/week @ 2022-07-15 288/week @ 2022-07-22 390/week @ 2022-07-29

1,136 downloads per month

MIT/Apache

28KB
513 lines

truelayer-signing

Rust crate to produce & verify TrueLayer API requests signatures.

Crates.io Docs.rs

// `Tl-Signature` value to send with the request.
let tl_signature = truelayer_signing::sign_with_pem(kid, private_key)
    .method("POST")
    .path("/payouts")
    .header("Idempotency-Key", idempotency_key)
    .body(body)
    .sign()?;

See full example.

Prerequisites

  • OpenSSL (see here for instructions).

Verifying webhooks

The verify_with_jwks function may be used to verify webhook Tl-Signature header signatures.

// `jku` field is included in webhook signatures
let jku = truelayer_signing::extract_jws_header(webhook_signature)?.jku?;

// check `jku` is an allowed TrueLayer url & fetch jwks JSON (not provided by this lib)
ensure_jku_allowed(jku)?;
let jwks = fetch_jwks(jku);

// jwks may be used directly to verify a signature
truelayer_signing::verify_with_jwks(jwks)
    .method("POST")
    .path(path)
    .headers(all_webhook_headers)
    .body(body)
    .verify(webhook_signature)?;

See webhook server example.

Dependencies

~2.5–3.5MB
~78K SLoC