Skip to main content

The EkycSdk facade

EkycSdk is the top-level type. Construct it once with an EkycConfig and share it across your app.

final sdk = EkycSdk(EkycConfig(
baseUrl: 'https://api.drukverify.com',
tokenProvider: () async => await myBackend.fetchToken(),
enableOnDeviceLiveness: true, // default
apiVersion: EkycSdk.defaultApiVersion, // default
));

EkycConfig

FieldTypeDefaultNotes
baseUrlString (required)https://api.drukverify.com in production
tokenProviderFuture<String> Function() (required)Async callback returning a dv_tok_…
timeoutDuration?30sPer-request HTTP timeout
headersMap<String, String>?{}Extra static headers on every request
enableOnDeviceLivenessbooltrueSee On-device toggle
apiVersionString?SDK constantPin a specific API version

Namespaces

EkycSdk exposes four namespaces, each backed by a RequestExecutor that handles auth, retries, and idempotency:

sdk.ocr // OcrClient
sdk.face // FaceClient
sdk.liveness // LivenessClient
sdk.sessions // SessionsClient

Each namespace's methods are documented in the API reference.

Mode parsing

After the first token is fetched, sdk.mode returns 'live' or 'test' (parsed from the token prefix). Useful for guardrails:

if (kReleaseMode && sdk.mode == 'test') {
throw StateError('refusing to run with test token in release build');
}

mode is null until the first request. If you need it earlier, trigger a no-op call (e.g. sdk.sessions.create(...)).

Lifecycle

The SDK manages its own Dio instance. There is no dispose() — Dio cleans up automatically when the surrounding scope exits.

For testing, you can pass your own pre-configured Dio:

final dio = Dio()..interceptors.add(MyTestInterceptor());
final sdk = EkycSdk(config, dio: dio);