Skip to main content

Configuration

WalletSdkOptions is the single configuration object passed to WalletSdk.initialize. This page documents every field.

final sdk = await WalletSdk.initialize(
WalletSdkOptions(
baseUrl: 'https://api.stg.iden2.app',
storageEncryptionKeyProvider: () => secureKeyStore.getOrCreateKey(),
platformHttpClient: DioPlatformHttpClient(dio),
promptHandler: promptHandler,
trustNetworkModeProvider: () async => TrustNetworkMode.warn,
),
);

WalletSdk.initialize throws a WalletSdkException immediately if baseUrl is empty. Initialization runs once per process; repeated calls return the existing instance.

Required options​

OptionTypeDescription
baseUrlStringPlatform API base URL. Staging: https://api.stg.iden2.app.
storageEncryptionKeyProviderFuture<String> Function()Returns the SQLCipher key that encrypts the SDK's wallet database. Must be stable across launches; persist it in platform secure storage.

Always-on modules​

Issuance (acceptOffer / offerAcceptance) and presentation (present / presentation) are always wired at initialize. Provide a promptHandler so consent and selection UI can run; without it, those flows fail when they reach a user decision.

User interaction​

OptionTypeDescription
promptHandlerWalletPromptHandler?The contract through which the SDK requests user decisions (credential consent, disclosure selection, trust warnings). Required for issuance and presentation. See Prompts.

HTTP and networking​

OptionTypeDescription
platformHttpClientPlatformHttpClient?Your HTTP stack for Platform API calls. Wrap a Dio instance with DioPlatformHttpClient from package:wallet_sdk/dio.dart (recommended). When omitted, the SDK creates a minimal Dio client from baseUrl.
externalHttpClientExternalHttpClient?Client used for requests to third-party endpoints (issuer metadata, offer URIs). Defaults to an SDK-provided client.

Injecting your own client lets the SDK inherit your interceptors, logging, certificate pinning, and proxy settings:

import 'package:wallet_sdk/dio.dart';

final dio = Dio(BaseOptions(baseUrl: baseUrl))
..interceptors.add(myAuthInterceptor)
..interceptors.add(LogInterceptor());

WalletSdkOptions(
baseUrl: baseUrl,
platformHttpClient: DioPlatformHttpClient(dio),
// ...
);

Storage​

OptionTypeDefaultDescription
storageDatabaseFileNameString'wallet_sdk.db'SDK-owned database file name, created under the app documents directory.
storageForTestingWalletStorage?—In-memory or fake storage for unit tests only.
keyStoreKeyStore?—Overrides the on-device holder key store (e.g. for tests).

The SDK owns its database exclusively — wallet, credential, DID, and sharing-log tables live in wallet_sdk.db, separate from any host app database.

Trust network​

OptionTypeDescription
trustNetworkModeProviderFuture<TrustNetworkMode> Function()?Reads the current enforcement mode from your settings. Called at decision points, so mode changes take effect without re-initialization.
trustNetworkApiTrustNetworkApi?Override the default Trust Network client.

TrustNetworkMode has three values:

ModeIssuance behaviorPresentation behavior
offNo trust checksNo trust checks
warnUntrusted issuer → warning on the consent promptUntrusted verifier → VerifierTrustPrompt asks the user
strictUntrusted issuer → flow blockedUntrusted verifier → flow aborted without a prompt
Future<TrustNetworkMode> trustNetworkModeFromSettings() async {
final prefs = await SharedPreferences.getInstance();
return switch (prefs.getString('trust_mode')) {
'strict' => TrustNetworkMode.strict,
'warn' => TrustNetworkMode.warn,
_ => TrustNetworkMode.off,
};
}

Observability​

OptionTypeDescription
authObserverAuthObserver?Analytics/diagnostics hook for auth lifecycle events. Implementations must not throw.
class CrashReportingAuthObserver implements AuthObserver {

void onAuthenticated(AuthSession session) =>
crashlytics.setUserIdentifier(session.username);


void onLoggedOut() => crashlytics.setUserIdentifier('');


void onAuthError(AuthErrorCode code) =>
analytics.logEvent('auth_error', {'code': code.name});
}

Advanced overrides​

These replace default SDK implementations. Most integrations never set them; they exist for tests and specialized deployments.

OptionTypeReplaces
credentialOfferExchangeCredentialOfferExchange?Default backend exchange used during issuance
presentationExchangePresentationExchange?Default backend exchange used during presentation
offerUriParserCredentialOfferUriParser?Default credential-offer deep-link parser (used for trust endpoint validation)
issuerTrustEvaluatorIssuerTrustEvaluator?Default issuer trust evaluation
verifierTrustEvaluatorVerifierTrustEvaluator?Default verifier trust evaluation

Testing configuration​

For unit tests, combine the test-only options with the fakes in package:wallet_sdk/testing.dart:

import 'package:wallet_sdk/testing.dart';
import 'package:wallet_sdk/wallet_sdk.dart';

final sdk = await WalletSdk.initialize(
WalletSdkOptions(
baseUrl: 'https://test.invalid',
storageEncryptionKeyProvider: () async => 'test-key',
storageForTesting: MemoryWalletStorage(),
),
);

// Between tests:
await WalletSdk.resetForTest();