Network Security
Network Security
Section titled “Network Security”SDK Internal Network Operations
Section titled “SDK Internal Network Operations”The Alphyn SDK automatically handles all network security operations internally. These include JWT authentication, SSL connections, and cryptographic key exchanges. Developers do not need to implement these manually - they are handled transparently by the SDK.
Network Security Features:
- Automatic JWT Authentication: SDK handles token generation and refresh automatically
- Key Exchange: Cryptographic keys are automatically managed and rotated by the SDK
- Certificate Pinning: SSL certificate validation is handled internally
Monitoring Network Events (Optional):
If you want to monitor the SDK’s network operations for debugging or analytics purposes, you can listen for these informational events:
import Alphyn
extension MySecurityListener { func onSuccess(_ result: AlphynCallbackResult) { // These are informational events about SDK's internal network operations switch result.originalEventType { case .networkInit: print("Alphyn SDK network stack initialized") case .jwtAuthSuccess: print("Alphyn SDK authenticated with servers") case .keyExchangeSuccess: print("Alphyn Cryptographic keys refreshed") default: break } }}Note: These events are purely informational and indicate the SDK’s internal state. No action is required from developers.
Network Error Handling
Section titled “Network Error Handling”Network Error Management:
import Alphyn
extension MySecurityListener { func onFailure(_ result: AlphynCallbackResult) { if result.isNetwork { switch result.originalEventType { case .networkError: print("Network 🌐 Network connectivity error") handleNetworkConnectivityIssue() case .requestFailed: print("Network 📡 API request failed") handleAPIRequestFailure(result: result) case .authFailed: print("Network 🔐 Authentication failed") handleAuthenticationFailure() default: break } } }
private func handleNetworkConnectivityIssue() { // Implement retry logic with exponential backoff scheduleNetworkRetry() }
private func handleAPIRequestFailure(result: AlphynCallbackResult) { // Parse error details and implement appropriate response let errorDetails = result.details print("Network Request failed: \(errorDetails ?? "No details")") }
private func handleAuthenticationFailure() { // Implement authentication failure handling }
private func scheduleNetworkRetry() { // Implement network retry logic }}