getSecureData<T> method
Retrieves shared data, handling SecureData wrappers and automatic expiration.
Implementation
T? getSecureData<T>(String key, {required String callerModuleId}) {
final data = _sharedData[key];
if (data == null) return null;
if (data is SecureData) {
if (data.isExpired) {
AirLogger.debug('Secure data expired: $key');
_sharedData.remove(key);
return null;
}
if (_isSensitiveKey(key) || data.isEncrypted) {
AirAudit().logSensitiveDataAccess(
dataKey: key,
callerModuleId: callerModuleId,
reason: 'get_secure_data',
);
}
try {
return data.value as T?;
} catch (e) {
AirLogger.error('Type mismatch for secure data: $key', error: e);
return null;
}
}
// Fallback for legacy data
return getData<T>(key, callerModuleId: callerModuleId);
}