KMP SDK (Alpha)
The Self KMP SDK is currently in alpha. To get access or try it out, please contact the Self team.
Overview
The Self KMP SDK lets you add Self identity verification to a Kotlin Multiplatform app while keeping the verification API in shared Kotlin code.
It's a good fit if your app already uses Kotlin Multiplatform and you want to keep verification logic in shared code.
The SDK provides:
shared configuration with
SelfSdkConfigshared request construction with
VerificationRequesta common launch API and callback interface
You'll need to provide:
secure storage setup on both platforms
Android activity binding before launch
iOS WebView provider and secure storage via
SelfSdkSwiftor your own implementations
The SDK currently supports Android and iOS. On iOS, you also need the SelfSdkSwift companion package or equivalent native provider implementations.
How It Works
Quick Start
All calling code lives in your commonMain source set:
Platform Setup
Android setup goes in your androidMain source set (typically your MainActivity).
bindActivity() registers an ActivityResultLauncher on the given ComponentActivity. Without it, launch() fails with MISSING_ACTIVITY.
Convenience overload — combines configure + bind + launch in one call:
iOS requires a Swift companion package (SelfSdkSwift) that provides native provider implementations using Keychain Services, CryptoKit, and WKWebView.
KMP compiles Kotlin object singletons to Objective-C classes — Swift accesses them via .shared.
Once providers are registered, call SelfSdk.configure() and sdk.launch() from your shared commonMain code — no iOS-specific launch code is needed. The Quick Start example above works as-is on both platforms.
SelfSdkSwift is a convenience, not a requirement. You can provide your own classes as long as they conform to the KMP protocols (SecureStorageProvider, WebViewProvider).
API Reference
SelfSdkConfig
endpoint
"https://api.self.xyz"
Self backend API endpoint
environment
PROD
SelfEnvironment.PROD (real documents, mainnet) or SelfEnvironment.STG (mock documents, testnet). See the quickstart environment guide for details.
version
2
Protocol version for the verification flow
appName
null
Display name shown in the verification UI
appEndpoint
null
URL of the backend verifier that verifies the ZK proof
endpointType
derived
Derived from environment if not set: "https" for PROD, "staging_https" for STG
chainID
null
Celo chain ID — 11142220 (testnet) or 42220 (mainnet)
VerificationRequest
userId
null
User identifier for the verification
scope
null
Verification scope (e.g., "identity")
disclosures
listOf("ofac")
Requested disclosures (e.g., "full_name", "dob", "nationality", "ofac")
verificationId
null
Pre-created verification session ID
excludedCountries
emptyList()
Country codes to exclude from verification
userIdType
null
Type of user ID provided
userDefinedData
null
Custom data passed through the verification flow
selfDefinedData
null
Self-defined metadata
SelfSdkCallback
onSuccess()
Verification completed successfully
onFailure(error)
Verification failed
onCancelled()
User dismissed without completing
SelfSdkError
MISSING_ACTIVITY
Android
bindActivity() not called before launch()
VERIFICATION_IN_PROGRESS
Both
A verification flow is already running
LAUNCHER_NOT_AVAILABLE
Android
Could not initialize ActivityResultLauncher
VERIFICATION_FAILED
Both
The verification flow failed
NO_VIEW_CONTROLLER
iOS
Could not find a top UIViewController to present
Provider Interfaces
Providers must be registered before calling launch().
Required Providers
SecureStorageProvider
SdkProviderRegistry
Both
Keychain/keystore read/write
WebViewProvider
IosProviderRegistry
iOS only
WKWebView creation and JS evaluation
Android does not need a WebViewProvider — the SDK manages the WebView internally.
SecureStorageProvider
WebViewProvider (iOS only)
Demo Implementations
The SDK ships demo implementations for quick prototyping. These are not intended for production use — you should implement your own SecureStorageProvider backed by your app's secure storage strategy.
Android (shipped in the SDK):
EncryptedSharedPreferencesProvider
AndroidX EncryptedSharedPreferences (AES256-SIV / AES256-GCM)
iOS (shipped in SelfSdkSwift):
SecureStorageProviderImpl
Keychain Services
WebViewProviderImpl
WKWebView with WKScriptMessageHandler bridge
Implementing Your Own Providers
For production, implement the provider interfaces directly:
Last updated