captureSecureStorage function

Map<String, dynamic> captureSecureStorage()

Captures Ensemble encrypted public-storage values using their logical keys.

The encrypted backend stores values under enc_<key> in public GetStorage. Reports expose the logical key and decoded value instead.

Implementation

Map<String, dynamic> captureSecureStorage() {
  final storage = StorageManager();
  final result = <String, dynamic>{};
  for (final backendKey in storage.getKeys()) {
    if (!backendKey.startsWith('enc_')) continue;
    final key = backendKey.substring('enc_'.length);
    final raw = storage.read(backendKey);
    final decoded = EncryptedStorageManager.getSecureStorage(key);
    result[key] = decoded ??
        <String, dynamic>{
          'value': _copy(raw),
          'decodeError': true,
        };
  }
  return result;
}