# Module: Authentication Plugin
# Purpose: Provides JWT authentication, MFA enrollment/verification, auth status checking, and permission validation.
# Dependencies: std log, path-utils, auth_impl

use ../config/accessor.nu *
use ../utils/path-utils.nu *
export use auth_impl.nu *

# Check if Auth plugin is available (registered with Nushell)
def is-plugin-available [] {
    let installed = (version | get installed_plugins)
    $installed | str contains "auth"
}

# Check if Auth plugin is enabled in config
def is-plugin-enabled [] {
    config-get "plugins.auth_enabled" true
}

# Get Auth plugin status and configuration
export def plugin-auth-status [] {
    let plugin_available = is-plugin-available
    let plugin_enabled = is-plugin-enabled

    {
        plugin_available: $plugin_available
        plugin_enabled: $plugin_enabled
        mode: (if ($plugin_enabled and $plugin_available) { "plugin" } else { "disabled" })
    }
}
