Skip to main content

LastIDClient

Struct LastIDClient 

Source
pub struct LastIDClient { /* private fields */ }
Expand description

Main SDK client for LastID IDP integration.

Handles credential requests, polling, verification, and trust registry validation. Requires a caller-provided tokio runtime (native) or runs on wasm-bindgen-futures (wasm).

§Example

use lastid_sdk::policies::BaseCredentialPolicy;
use lastid_sdk::ClientBuilder;

let client = ClientBuilder::new().with_auto_config()?.build()?;

let policy = BaseCredentialPolicy::new()
    .with_callback("https://example.com/callback");

let response = client.request_credential(policy).await?;
println!("Request ID: {}", response.request_id);

Implementations§

Source§

impl LastIDClient

Source

pub fn new(config: SDKConfig) -> Result<Self, LastIDError>

Create a new client from configuration.

§Errors

Returns LastIDError if:

  • HTTP client creation fails
  • Trust registry client creation fails
  • Token manager creation fails
Source

pub fn with_optional_keypair( config: SDKConfig, keypair: Option<DPoPKeyPair>, ) -> Result<Self, LastIDError>

Create a new client with an optional pre-generated DPoP keypair.

This is useful for serverless deployments where the keypair needs to persist across invocations. If keypair is None, a new keypair is generated.

§Errors

Returns LastIDError if:

  • HTTP client creation fails
  • Trust registry client creation fails
  • Token manager creation fails
Source

pub const fn builder() -> ClientBuilder<NoConfig>

Create a builder for configuring the client.

Source

pub const fn config(&self) -> &SDKConfig

Get the SDK configuration.

Source

pub fn dpop_thumbprint(&self) -> &str

Get the DPoP key thumbprint for this client.

The thumbprint is a base64url-encoded SHA-256 hash of the public key, used to bind access tokens to this client’s DPoP keypair. This is useful for debugging and verifying key persistence in serverless deployments.

Source

pub async fn request_credential<P>( &self, policy: P, ) -> Result<CredentialRequestResponse, LastIDError>
where P: PolicyBuilder,

Request a credential presentation from the IDP. Returns CredentialRequestResponse with request_uri for QR code display.

Source

pub async fn poll_request( &self, request_id: &RequestId, ) -> Result<RequestStatus, LastIDError>

Poll for credential request status once. Cancellation-safe.

Source

pub async fn poll_for_completion( &self, request_id: &RequestId, ) -> Result<RequestStatus, LastIDError>

Poll for credential completion with timeout and exponential backoff. Cancellation-safe: dropping the future stops polling cleanly.

Source

pub async fn verify_presentation( &self, presentation: &str, ) -> Result<VerifiedCredential, LastIDError>

Verify a credential presentation (SD-JWT). Validates issuer against trust registry and extracts claims.

Source

pub async fn validate_issuer( &self, issuer_did: &str, ) -> Result<IssuerInfo, LastIDError>

Validate an issuer against the trust registry.

§Errors
  • LastIDError::TrustRegistry - Issuer not found or invalid status

Trait Implementations§

Source§

impl Clone for LastIDClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more