Skip to main content

VPN

The KapeVPN module provides everything needed for WireGuard VPN connectivity: server discovery, VPN profile management, tunnel lifecycle, and connection status.

Complete Example

import KapeAuth
import KapeCore
import KapeVPN

// Initialize
let settings = try KapeSDKSettings()
let handle = try KapeSdkHandle(settings: settings)

// Authenticate
let auth = KapeAuthClient(handle: handle)
try await auth.login(presenting: viewController)

// Activate subscription
try handle.activateSubscription(for: .custom(values: ["xv.vpn"]))

// Fetch locations
let locations = KapeLocationService(handle: handle)
try await locations.fetchLocations()

// Connect — auto picks the highest-rated smart location
let vpn = KapeVPNManager(handle: handle)
try await vpn.installProfile()
try await vpn.connect(mode: .auto)

// Or connect to a specific server
// try await vpn.connect(mode: .manual(locationId: locations.allLocations.first!.id))

// Observe
vpn.$connectionStatus.sink { print($0) }

// Later: disconnect
await vpn.disconnect()