Encrypted
extension MoEngageStorage.UserDefaultStorage.Encrypted
-
Intercepts
get,set, anddictionaryto apply AES encryption/decryption.The processor is a no-op when:
- The scope is not
.sdk(.instance). - Encryption is disabled in
sdkInstance.storedConfig.storageConfig.encryptionConfig. In that case all encrypted data is cleared from the suite before delegating to the upstream closures, so a device that had encryption enabled previously is cleaned up automatically.
When encryption is enabled, the processor:
- Calls
encryptionResult(userDefaults:scope:sdkInstance:get:set:dictionary:)on every read/write to determine (and lazily apply) the encryption state. - Decrypts values on
getusingaesHandler(withKey:). - Encrypts values on
setviaencryptAndSet(userDefaults:key:value:encryptionKey:sdkInstance:action:).
Throws
Error/noEncryptionKeywhen a key is needed but unavailable.Declaration
Swift
public func process( get: @escaping @Sendable (isolated MoEngageSDKInstance, UserDefaults, String) throws -> Any?, set: @escaping @Sendable (isolated MoEngageSDKInstance, UserDefaults, String, Any?) throws -> Void, dictionary: @escaping @Sendable (isolated MoEngageSDKInstance, UserDefaults) throws -> [String: Any], scope: MoEngageStorage.UserDefaultStorage<Value>.Scope, sdkInstance: isolated MoEngageSDKInstance = #isolation ) throws -> MoEngageStorage.UserDefaultStorage<Value>.ProcessorResultParameters
getThe upstream
getclosure accumulated by prior processors.setThe upstream
setclosure accumulated by prior processors.dictionaryThe upstream
dictionaryclosure accumulated by prior processors.scopeThe scope of the owning
MoEngageStorage/UserDefaultStorage.sdkInstanceThe isolated SDK instance providing encryption config.
Return Value
.skipwhen the scope or config does not require encryption; otherwise.transformedwith closures that wrap the originals with encrypt/decrypt logic. - The scope is not