@file:OptIn(
    com.russhwolf.settings.ExperimentalSettingsApi::class,
    com.russhwolf.settings.ExperimentalSettingsImplementation::class,
    kotlinx.cinterop.ExperimentalForeignApi::class,
)

package dev.ulfrx.recipe.auth

import com.russhwolf.settings.KeychainSettings
import com.russhwolf.settings.Settings
import dev.lokksmith.Lokksmith
import dev.lokksmith.SingletonLokksmithProvider
import dev.lokksmith.createLokksmith
import org.koin.dsl.module
import platform.Security.kSecAttrAccessible
import platform.Security.kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly

val iosAuthModule =
    module {
        single<Lokksmith> {
            createLokksmith().also { lokksmith ->
                SingletonLokksmithProvider.set(lokksmith)
            }
        }
        single<Settings> {
            KeychainSettings(
                kSecAttrAccessible to kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly,
            )
        }
    }
