Skip to content

About

Identisure API client for Rust

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Identisure Rust Client

Crate Downloads Documentation MIT license

API client for the Identisure REST API.

Documentation: identisure.github.io/api-client-rust

Requirements

Rust 1.87 or later.

Supported providers

  • BankID SE: auth, sign, phone auth and sign, QR verify, age verification
  • BankID NO: auth, backchannel auth, sign, age verification
  • Freja eID: auth, backchannel auth, sign, backchannel sign, age verification
  • MitID: auth, backchannel auth, sign, age verification
  • FTN (Finnish Trust Network): auth, age verification
  • Vipps MobilePay: auth, backchannel auth
  • Documents: upload and download documents for signing

Installation

cargo add identisure-client

Features

  • async (default) — async/await via tokio
  • blocking - synchronous API via reqwest::blocking

Usage

[dependencies]
identisure-client = { version = "0.1", features = ["async"] }
use identisure_client::models::{BankIdSeAuthRequest, BankIdSeStatus};
use identisure_client::{Environment, IdentisureClientBuilder, PollOptions};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = IdentisureClientBuilder::new("client_id", "client_secret")
        .environment(Environment::Staging)
        .build()?;

    let BankIdSeStatus::Pending(session) =
        client.bankid_se().auth(BankIdSeAuthRequest::new()).await?
    else {
        return Err("Expected a pending session".into());
    };

    let result = client
        .bankid_se()
        .wait_for_auth(&session.id, PollOptions::default())
        .await?;

    println!("{result:#?}");
    Ok(())
}

Verifying callbacks

let valid = identisure_client::verify_callback_signature(&raw_body, signature_header, hmac_secret);

Development

Prerequisites

Clone

The test fixtures live in a git submodule. Clone with:

$ git clone --recurse-submodules https://github.com/identisure/api-client-rust.git

Or, in an existing clone, run git submodule update --init.

Build

To compile the project, simply issue the following command:

$ cargo build --all-features

Test

Linting

This project uses rustfmt for formatting and clippy for linting. Run them with:

$ cargo fmt --check
$ cargo clippy --all-features
Unit/Integration/Doc Testing
$ cargo test --all-features

Release

Set the version in Cargo.toml and commit. Then push a tag:

$ git tag v0.1.0
$ git push origin v0.1.0

The release workflow checks that the tag matches the version, runs CI, publishes to crates.io and creates a GitHub release.

Other languages

C#, Dart, Go, TypeScript/JavaScript, Java/Kotlin, PHP, Python, Ruby, Swift

About

Identisure API client for Rust

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages