setSecureData<T> method
void
setSecureData<T>(})
Sets shared data with optional encryption and Time-to-Live (TTL).
Implementation
void setSecureData<T>(
String key,
T value, {
required String callerModuleId,
bool encrypt = false,
Duration? ttl,
}) {
final expiresAt = ttl != null ? DateTime.now().add(ttl) : null;
// In a real implementation, 'encrypt' would use a secure vault.
// For now, we wrap it in SecureData which provides the metadata.
_sharedData[key] = SecureData<T>(
value,
isEncrypted: encrypt,
expiresAt: expiresAt,
ownerModuleId: callerModuleId,
);
_notifyDataListeners(key);
if (_isSensitiveKey(key) || encrypt) {
AirAudit().logSensitiveDataAccess(
dataKey: key,
callerModuleId: callerModuleId,
reason: 'set_secure_data',
);
}
AirLogger.debug(
'Secure data set: $key',
context: {
'caller': callerModuleId,
'encrypted': encrypt,
'ttl': ttl?.inSeconds,
},
);
}