DecaneDocs
Sign-inSessions
Sign-in

Sessions and launch

On launch

swift
do {
    let result = try await wallet.connect()     // resume a live session
    showHome(result.addresses)
} catch DecaneError.reconnectRequired {
    showSignIn()
}

The session is kept in the Keychain until its recorded expiry; set persistSession: false to keep it in memory only. The synchronous state is on properties:

swift
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.sessionExpiresAt   // Date?

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 an AsyncStream<DecaneEvent>:

swift
Task {
    for await event in wallet.events {
        switch event {
        case .connected(let result): print(result.addresses.evm)
        case .sessionExpired: showSignIn()
        default: print(event.name)   // "session-renewed", "wallet-creating", …
        }
    }
}
CaseNameWhen
.connected(ConnectResult)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

swift
try await 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.