Sessions and launch
On launch
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:
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>:
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", …
}
}
}| Case | Name | When |
|---|---|---|
.connected(ConnectResult) | 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
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.