TrustWeave
TrustWeave - The main facade for trust and identity operations.
TrustWeave provides a unified interface for all trust-related operations including credential issuance/verification, DID management, trust anchor management, and wallet operations. It serves as the primary entry point for applications using TrustWeave.
Concurrency Model:
All operations are
suspendfunctions and use structured concurrencyI/O-bound operations use configurable dispatchers (default: Dispatchers.IO)
All operations support cancellation via coroutine cancellation
Timeout support is built-in for all I/O operations
Operations are non-blocking and can be safely called from coroutine scopes
Example Usage:
// Quick start (in-memory, did:key)
val trustWeave = TrustWeave.quickStart()
// Or custom configuration
val trustWeave = TrustWeave.build {
keys { provider("inMemory"); algorithm("Ed25519") }
did { method("key") { algorithm("Ed25519") } }
trust { provider("inMemory") }
}
val issuerDid = trustWeave.createDid().getOrThrowDid()
// Issue credentials (key ID auto-extracted via signedBy(issuerDid))
val credential = trustWeave.issue {
credential {
type("EducationCredential")
issuer(issuerDid)
subject("did:key:student") { "degree" to "Bachelor of Science" }
}
signedBy(issuerDid)
}.getOrThrow()
// Verify (simple overload)
val result = trustWeave.verify(credential)
// Or use DSL for advanced options
val result = trustWeave.verify {
credential(credential)
checkRevocation()
validateSchema("https://example.com/schemas/degree.json")
}Types
Build a TrustWeave instance with the given configuration. Static factories TrustWeave.inMemory and TrustWeave.from are in TrustWeaveFactories.kt.
Properties
Active TrustedDomainManager for this facade, or null when no domain { ... } block was configured.
Blockchain anchoring service.
The underlying configuration.
Smart contract operations service.
Functions
Anchor payload through the active TrustedDomainManager. Throws IllegalStateException when no domain { ... } was configured; otherwise delegates to TrustedDomainManager.anchor verbatim.
Suspending form of close with the same ownership, error-handling and idempotence semantics: stop() + cleanup() of PluginLifecycle components are awaited instead of blocking the calling thread. Calling either close or closeAsync more than once (in any combination) closes the components only once.
Extension function for complete workflow: create DID, issue, store, organize, verify.
Extension function to create DID and issue credential in one workflow.
Extension function to create DID, issue credential, and store in wallet.
Extension function to get a delegation builder (any DidDslContext, including org.trustweave.trust.TrustWeave).
Find a trust path between verifier and issuer (first-class type).
Get a DID method by name.
Get the DID registry.
Get a DID resolver for delegation operations. This returns the native DID resolver interface used by did:core.
Get the underlying KMS.
Get wallet factory.
Issue a verifiable credential using the configured TrustWeave instance.
Issue multiple credentials using Flow for reactive processing.
Create a presentation from wallet credentials, returning PresentationResult.
Create a verifiable presentation, returning PresentationResult for exhaustive error handling.
Extension function to register a schema.
Returns the configured KeyManagementService as a non-null reference.
Extension function to access revocation operations using TrustWeave.
Sealed-result form of revoke. Missing configuration, incomplete requests and timeouts are variants instead of exceptions; coroutine cancellation is rethrown.
Extension function to access schema operations.
Perform trust operations using the trust DSL.
Sealed-result form of trust: TrustOperationResult.Completed when block ran, TrustOperationResult.NotConfigured without a trust registry (block not run) and TrustOperationResult.Failure when block or the registry threw. Coroutine cancellation is rethrown.
Verify a verifiable credential using the configured TrustWeave instance.
Verify a verifiable credential (convenience overload).
Verify multiple credentials using Flow for reactive processing.
Create a wallet using the configured TrustWeave instance.