| Crates.io | smart-id-rust-client |
| lib.rs | smart-id-rust-client |
| version | 0.2.0 |
| created_at | 2024-04-26 19:01:47.494601+00 |
| updated_at | 2025-04-01 08:01:09.273343+00 |
| description | Smart ID Rust Client |
| homepage | https://smart-id.com |
| repository | https://github.com/Trust1Team/smart-id-rust-client |
| max_upload_size | |
| id | 1221679 |
| size | 554,799 |
Smart-ID Rust Client
⚡ Maintained by ⚡
The library can be used for easy integration with the Smart-ID API. It provides a simple interface for mobile authentication and mobile digital signing using Smart-ID. Additional utilities has been provided for easy integration with the Smart-ID API:
Supporting SmartID using:
cargo build
# with debug logs (default)
cargo run --example smart_id_client
# only with info logs
RUST_LOG=info cargo run --example smart_id_client
cargo test
To fully test the libraries interactions with the Smart-ID API, you will need to run the tests in app_interaction_tests.rs. These tests require a Qualified Smart-ID account and a mobile device with the Smart-ID app installed.
cargo doc --no-deps --open
See the examples folder for a simple example client. To create an SmartID account, download the app: SmartID App
The example application goes through the following use cases:
The example is using a MOCK ID to simulate the SmartID user.
cargo run --example smart_id_client
Default values are provided and targets the TEST environment of Smart ID. The required environment variables are:
| ENV_VAR | DESCRIPTION | REQUIRED |
|---|---|---|
| HOST_URL | The host address of the Smart ID Service | Y |
| RELYING_PARTY_UUID | The UUID assigned to the Relying-party - provided by Smart ID | Y |
| RELYING_PARTY_NAME | The unique name assigned to the Relying-Party - provided by Smart ID | Y |
| CLIENT_REQ_NETWORK_TIMEOUT_MILLIS | The timeout for the REST client when requesting Smart ID Services | N - default () |
| CLIENT_REQ_MAX_ATTEMPTS | The maximum attempts for the REST client retry mechanism | |
| CLIENT_REQ_DELAY_SECONDS_BETWEEN_ATTEMPTS | The wait time between consecutive REST client requests | |
| ENABLE_POLLING_BY_LIB | Enable automatic polling (when false - polling MUST be implemented by callee |
SmartID configuration can be loaded form environment variables:
/// Get default Config (from environment variables)
let cfg = get_config_from_env();
Or set manually
/// Create SmartID Config
let cfg = SmartIDConfig {
root_url: "https://sid.demo.sk.ee".to_string(),
api_path: "/smart-id-rp/v3".to_string(),
relying_party_uuid: "test-uuid".to_string(),
relying_party_name: "test-name".to_string(),
client_request_timeout: Some(30000),
}
Examples of the various flows with explanations can be found in smart_id_client.rs. You will need to update the RELYING_PARTY environment variables in config.toml for these to work.
Examples of more complex auth->certificate->sign flows with instructions can be found in app_interaction_tests.rs. You will need to update the RELYING_PARTY variables in the test file for these to work.