Skip to content

API Reference

The main class providing static methods for SDK functionality. All methods are asynchronous and return Future objects.

Note: On iOS you must call AlphynSDK.register() natively in AppDelegate.swift before Flutter starts; the SDK itself is then initialized from Dart with AlphynSdk.initialize(). See Native Initialization for details.

static Future<void> initialize({
double interval = 45.0,
String? androidDebugHash,
String? iosDebugHash,
})

Parameters:

  • interval: Scan interval in seconds (default 45.0, must be greater than 8)
  • androidDebugHash (optional): development-only hash from the Alphyn Portal, applied only when running on Android
  • iosDebugHash (optional): the same, applied only when running on iOS

A Flutter project registers as two separate apps on the portal, one per platform, each with its own hashes, so the debug hash is always platform-specific. There is no debugHash parameter; passing one does not compile. Never ship either value in production.

Returns: Future<void> - Completes when initialization has been requested
Purpose: Initializes the SDK from Dart (call in main() before runApp)

static Future<bool?> isInitialized()

Returns: Future<bool?> - true if initialized, false if not, null if status unknown
Purpose: Verifies SDK initialization status
Usage: Call this first before using any other SDK functionality

static Future<String> getDeviceId()

Returns: Future<String> - Unique device identifier
Purpose: Retrieves persistent device identifier for tracking and security
Usage: Use for device fingerprinting, user verification, and security event correlation

static Future<String> getAppHash()

Returns: Future<String> - Cryptographic hash of the application
Purpose: Detects app tampering and verifies integrity
Usage: Compare against known-good hash to detect unauthorized modifications

static Future<String?> getScanResult()

Returns: Future<String?> - Current security scan results, or null if unavailable
Purpose: Gets the most recent security scan status
Usage: Use for real-time security decisions and immediate threat detection

static Future<String> getRejectReasons()

Returns: Future<String> - Newline-separated rejection reasons (CODE|Description per line)
Purpose: Provides detailed security issues detected
Usage: Split on '\n' to get a list, e.g. raw.split('\n').where((l) => l.trim().isNotEmpty).toList(); display warnings, log events, implement granular security policies

static Future<DateTime?> getLastScanDate()

Returns: Future<DateTime?> - Timestamp of last scan, or null if no scan performed
Purpose: Determines when the last security scan occurred
Usage: Check scan freshness, trigger manual scans, audit logging

High-risk actions are verified with signAction, which signs the transaction with a hardware-backed key belonging to an enrolled user and returns a short-lived token your backend validates server-side. See MFA Transaction Signing for the three-call flow, and MFA on Flutter for the signatures.

signAction returns the same ActionVerificationResult documented below.

ActionVerificationResult Properties:

  • success (bool): Whether verification was successful
  • token (String?): Verification token if successful
  • expiresAtEpochMs (int?): Token expiration timestamp in milliseconds
  • errorCode (String?): Error code if verification failed
  • errorMessage (String?): Human-readable error message if verification failed
static Future<List<String>> getAllRiskFactors()

Returns: Future<List<String>> - Complete list of all detected risk factors
Purpose: Provides comprehensive risk assessment data
Usage: Security reporting, risk scoring, threat analysis, compliance

getAllScanResults({int? startEpochMs, int? endEpochMs})

Section titled “getAllScanResults({int? startEpochMs, int? endEpochMs})”
static Future<List<String>> getAllScanResults({
int? startEpochMs,
int? endEpochMs,
})

Parameters:

  • startEpochMs (optional): Start of date range in milliseconds since epoch (inclusive)
  • endEpochMs (optional): End of date range in milliseconds since epoch (inclusive)

Returns: Future<List<String>> - Historical scan results
Purpose: Retrieves scan history with optional date filtering
Usage: Trend analysis, historical reporting, compliance audits

static Future<void> setInterval(double intervalSeconds)

Parameters:

  • intervalSeconds (required): The scan interval in seconds (must be greater than 8)

Returns: Future<void> - Completes when interval is updated
Purpose: Updates the scan interval after initialization
Usage: Adjust scan frequency dynamically based on app state

static Future<List<String>> getModules()

Returns: Future<List<String>> - List of loaded security modules
Purpose: Retrieves the list of security modules loaded by the SDK
Usage: Security auditing, diagnostics, verifying SDK configuration

static Stream<AlphynCallbackResult> securityEvents()

Returns: Stream<AlphynCallbackResult> - Stream of security events from the native SDK
Purpose: Provides real-time security event notifications
Platform: Works on both Android and iOS
Usage: Subscribe to receive security events, initialization status, scan results, and threat detections

AlphynCallbackResult Properties:

  • operationType (OperationType): Type of operation (initialization, securityScan, etc.)
  • operationResult (OperationResult): Result status (success, failure, threatDetected)
  • originalEventType (AlphynEventType): Specific event type from the SDK
  • message (String): Human-readable message describing the event
  • details (String): Additional details about the event

Available OperationType Values:

  • initialization - SDK initialization operations
  • securityScan - Security scanning operations
  • scanResponse - Scan result operations
  • network - Network-related operations
  • storage - Secure storage operations
  • callback - Callback system operations

Available OperationResult Values:

  • success - Operation completed successfully
  • failure - Operation failed
  • threatDetected - Security threat identified

Available AlphynEventType Values:

  • initComplete, initFailed, firstInit, invalidAppKey
  • threatDetected, secureDevice, scanSuccess, scanResponse, scanFailed, riskFactorDetected
  • networkInit, networkMtls, jwtAuthSuccess, networkError, authFailed, requestFailed
  • keystoreSuccess, keystoreFailed, keyExchangeSuccess, keysFoundStorage, keysCreatedNew
  • invalidDateOrTime, callbackSuccess, callbackFailed