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
| Field | Type | Default | Notes |
|---|---|---|---|
baseUrl | String (required) | — | https://api.drukverify.com in production |
tokenProvider | Future<String> Function() (required) | — | Async callback returning a dv_tok_… |
timeout | Duration? | 30s | Per-request HTTP timeout |
headers | Map<String, String>? | {} | Extra static headers on every request |
enableOnDeviceLiveness | bool | true | See On-device toggle |
apiVersion | String? | SDK constant | Pin 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);