Sessions and launch
On launch
lifecycleScope.launch {
wallet.initialize()
when {
wallet.isUnlocked -> showHome(wallet.addresses!!)
wallet.needsReconnect -> showSignIn()
else -> showSignIn()
}
}A persisted session survives an app restart until its recorded expiry; set persistSession = false if you don’t want that. The synchronous state is on properties that never block:
wallet.isUnlocked // a session is open and can sign
wallet.needsReconnect // the user must sign in again
wallet.addresses // Addresses?
wallet.accessToken // the Decane JWT, for your own backend
wallet.sessionExpiresAtMs // Long?Sessions last eight hours and are renewed automatically before they lapse, up to seven days after sign-in. Send wallet.accessToken to your backend as a bearer token and verify it with a server SDK.
Events
events is a SharedFlow<DecaneEvent>:
lifecycleScope.launch {
wallet.events.collect { event ->
when (event) {
is DecaneEvent.Connected -> render(event.result.addresses)
DecaneEvent.SessionExpired -> showSignIn()
else -> Log.d("decane", event.name)
}
}
}| Event | Name | When |
|---|---|---|
Connected(result) | connected | A sign-in or resume finished |
Disconnected | disconnected | disconnect() ran |
SessionStarted | session-started | An enclave session opened |
SessionRenewed | session-renewed | The token was refreshed |
SessionExpired | session-expired | The session ended; sign in again |
WalletCreating | wallet-creating | A new wallet is being made |
WalletUnlocking | wallet-unlocking | An existing wallet is being opened |
EnrolmentFailed(message) | enrolment-failed | Creation stopped; nothing was left behind |
MigratedToIdentity | migrated-to-identity | A device-tier wallet moved to the identity tier |
Sign-out
wallet.disconnect()The identity tier’s security statement: a wallet is exactly as safe as the user’s identity-provider account plus Decane (the JWT signing key and the attested enclave). Anyone who can obtain a valid Decane session for the user can sign. There is no device-bound factor. Mitigations: a new-device email on every provision from an unseen device, a per-user freeze switch operated by Decane, and (follow-up) a fresh sign-in requirement for high-value operations.