KMP SDK (Alpha)

circle-exclamation

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 SelfSdkConfig

  • shared request construction with VerificationRequest

  • a 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 SelfSdkSwift or 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:

API Reference

SelfSdkConfig

Parameter
Default
Description

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

Parameter
Default
Description

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

Method
When it's called

onSuccess()

Verification completed successfully

onFailure(error)

Verification failed

onCancelled()

User dismissed without completing

SelfSdkError

Code
Platform
Meaning

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

Provider
Registry
Platform
Purpose

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

Class
Backing API

EncryptedSharedPreferencesProvider

AndroidX EncryptedSharedPreferences (AES256-SIV / AES256-GCM)

iOS (shipped in SelfSdkSwift):

Class
Backing API

SecureStorageProviderImpl

Keychain Services

WebViewProviderImpl

WKWebView with WKScriptMessageHandler bridge

Implementing Your Own Providers

For production, implement the provider interfaces directly:

Last updated