DecaneDocs
Sign-inSessions
Sign-in

Sessions and launch

On launch

kotlin
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:

kotlin
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>:

kotlin
lifecycleScope.launch {
    wallet.events.collect { event ->
        when (event) {
            is DecaneEvent.Connected -> render(event.result.addresses)
            DecaneEvent.SessionExpired -> showSignIn()
            else -> Log.d("decane", event.name)
        }
    }
}
EventNameWhen
Connected(result)connectedA sign-in or resume finished
Disconnecteddisconnecteddisconnect() ran
SessionStartedsession-startedAn enclave session opened
SessionRenewedsession-renewedThe token was refreshed
SessionExpiredsession-expiredThe session ended; sign in again
WalletCreatingwallet-creatingA new wallet is being made
WalletUnlockingwallet-unlockingAn existing wallet is being opened
EnrolmentFailed(message)enrolment-failedCreation stopped; nothing was left behind
MigratedToIdentitymigrated-to-identityA device-tier wallet moved to the identity tier

Sign-out

kotlin
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.