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
impl LastIDClient
Sourcepub fn new(config: SDKConfig) -> Result<Self, LastIDError>
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
Sourcepub fn with_optional_keypair(
config: SDKConfig,
keypair: Option<DPoPKeyPair>,
) -> Result<Self, LastIDError>
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
Sourcepub const fn builder() -> ClientBuilder<NoConfig>
pub const fn builder() -> ClientBuilder<NoConfig>
Create a builder for configuring the client.
Sourcepub fn dpop_thumbprint(&self) -> &str
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.
Sourcepub async fn request_credential<P>(
&self,
policy: P,
) -> Result<CredentialRequestResponse, LastIDError>where
P: PolicyBuilder,
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.
Sourcepub async fn poll_request(
&self,
request_id: &RequestId,
) -> Result<RequestStatus, LastIDError>
pub async fn poll_request( &self, request_id: &RequestId, ) -> Result<RequestStatus, LastIDError>
Poll for credential request status once. Cancellation-safe.
Sourcepub async fn poll_for_completion(
&self,
request_id: &RequestId,
) -> Result<RequestStatus, LastIDError>
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.
Sourcepub async fn verify_presentation(
&self,
presentation: &str,
) -> Result<VerifiedCredential, LastIDError>
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.
Sourcepub async fn validate_issuer(
&self,
issuer_did: &str,
) -> Result<IssuerInfo, LastIDError>
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