Wallet

class Wallet(configuration: WalletConfiguration, keyStore: KeyStore, credentialStore: CredentialStore, provider: WalletProvider?)(source)

A holder's wallet: OID4VCgo's walletflow over the app's key store, credential store and Wallet Provider. Creating it makes no network calls; provider is needed to receive credentials, not to present them.

Constructors

Link copied to clipboard
constructor(configuration: WalletConfiguration, keyStore: KeyStore, credentialStore: CredentialStore, provider: WalletProvider?)

Types

Link copied to clipboard
@Serializable
data class Refreshed(val credential: CredentialSummary, val deferred: DeferredCredential? = null)

What refreshCredential obtained.

Functions

Link copied to clipboard
suspend fun abandonDeferred(id: String)

Gives up on a deferred credential — its access token has expired, say, or the holder no longer wants it — deleting it and its keys.

Link copied to clipboard

Fetches the issuer's status list for a credential, checks its signature, and returns the credential with its revocation status recorded. The list covers many credentials, so fetching it doesn't tell the issuer which one is checked. A credential without a status list is returned as it is.

Link copied to clipboard

One credential with its claims.

Link copied to clipboard

Every credential the wallet holds.

Link copied to clipboard

The credentials issuers have deferred and not yet settled, oldest first — including ones from before the app last quit. Makes no network calls: poll each at its interval.

Link copied to clipboard
suspend fun deleteCredential(id: String)

Deletes a credential and its holder keys, and its refresh grant once no other credential uses it, first revoking the refresh token at the Authorization Server, best effort.

Link copied to clipboard

The held mdocs, each with whether the page at origin has been shown it and whether presenting it there now would be linkable (shownToVerifier, linkableHere): for a consent screen shown before the platform releases the request itself. MdocPresentation.request says the same once it has.

Link copied to clipboard

Asks the issuer once about a deferred credential. A refused one throws WalletException.Code.credentialDenied, and is then no longer pending.

Link copied to clipboard

Replaces a refreshable credential's copies with a fresh batch, each bound to a new attested key, without the holder (OpenID4VCI 1.0 §13.5). Use it when copiesLeft runs low. Throws WalletException.Code.reissueRequired when it can't be refreshed: receive it again from a new offer.

Link copied to clipboard
suspend fun resumeIssuance(redirect: String): Issuance

Completes an authorization begun before the app was killed: redirect is the issuer's redirect back to the redirect URI, delivered to the app. Returns the issuance ready for Issuance.requestCredentials. A redirect matching no authorization in progress — not this wallet's, already completed, or expired — throws WalletException.Code.notFound.

Link copied to clipboard
suspend fun startDCAPIPresentation(protocol: String, requestData: ByteArray, origin: String): Presentation

Parses an OpenID4VP request delivered through the Digital Credentials API (OpenID4VP 1.0 Appendix A), as Credential Manager hands it over: protocol (openid4vp-v1-unsigned, -signed or -multisigned), its requestData (the request's data object, as JSON) and the calling page's or app's origin. It's answered as a presentation from startPresentation, but Presentation.respond and Presentation.decline send nothing: each returns, in Presentation.Presented.dcapiResponse, the response's data for the platform to hand back.

Link copied to clipboard
suspend fun startIssuance(offer: String): Issuance

Resolves a Credential Offer (openid-credential-offer://…) and the issuer's metadata.

Link copied to clipboard
suspend fun startMdocPresentation(requestData: ByteArray, origin: String): MdocPresentation

Parses an org-iso-mdoc request — an mdoc asked for over the Digital Credentials API — and finds the held mdocs that can answer it. origin is the requesting page's origin, as MdocPresentation.origin serializes it.

Link copied to clipboard
suspend fun startPresentation(request: String): Presentation

Fetches and verifies an OpenID4VP request (openid4vp://…), and finds the credentials that can answer it.

Link copied to clipboard
fun startProximityPresentation(context: Context, timeouts: ProximityTimeouts = ProximityTimeouts(), modes: Set<ProximityBLEMode> = ProximityBLEMode.entries.toSet()): ProximityPresentation

Starts an ISO/IEC 18013-5 in-person presentation over BLE: show its ProximityPresentation.qrCode. In modes, both by default, it advertises for a reader (peripheral server mode) and scans for one (central client mode) until a reader connects either way; a reader offered both should choose central client mode. It needs Bluetooth on and ProximityPermissions.holder for modes granted (ProximityException otherwise).

Link copied to clipboard

Deletes every key in keyStore that none of the wallet's credentials is bound to — left by an issuance the app quit or crashed in the middle of, or one dropped without Issuance.close — and returns how many. Call it at launch, before any issuance or refresh: one in progress holds keys of its own.

Link copied to clipboard

Where the Verifier asked to take the holder after the wallet refused its request: when startPresentation throws WalletException.Code.requestRefused, open this URL, if any, as OpenID4VP §8.2 has a wallet do. It's returned once.