awaitConfiguration method

Future<void> awaitConfiguration({
  1. Duration? timeout,
})

Waits until this instance's pinning configuration has been fetched, signature-verified, and accepted by the SDK's integrity check — the explicit fail-closed gate that complements the now non-blocking setup.

setup validates credentials locally and refreshes the configuration in the background; it deliberately does not block on the network. Call this when your integration must not proceed without a validated configuration (for example, gating app start). Returns immediately when a configuration is already available.

await TrustPin.shared.setup(config); // local validation only
try {
  await TrustPin.shared.awaitConfiguration(
    timeout: const Duration(seconds: 10),
  );
} on TrustPinException catch (e) {
  // Hard stop — do not build an unpinned HTTP client.
}

timeout bounds the wait; when null, the native SDK's default applies. The native side clamps it to its supported range (currently 10–120s). For a synchronous, non-fetching state read use isConfigurationLoaded.

  • Throws TrustPinException with code INVALID_PROJECT_CONFIG if setup has not been called.
  • Throws TrustPinException with code ERROR_FETCHING_PINNING_INFO if the configuration cannot be retrieved.
  • Throws TrustPinException with code CONFIGURATION_VALIDATION_FAILED if the payload signature does not validate.
  • Throws TrustPinException with code CONFIG_INTEGRITY_FAILED if the configuration fails the SDK's integrity check.
  • Throws TrustPinException with code FETCH_CERTIFICATE_TIMEOUT if timeout is exceeded.

Implementation

Future<void> awaitConfiguration({Duration? timeout}) async {
  try {
    await TrustPinSDKPlatform.instance.awaitConfiguration(
      timeoutMs: timeout?.inMilliseconds,
      instanceId: _instanceId,
    );
  } catch (e) {
    throw TrustPinException.fromPlatformException(e);
  }
}