Implements device authorization registration and verification: - AES-256-GCM + PBKDF2 decryption of .xuqmlicense files - Keychain storage for token and deviceId - UIDevice.identifierForVendor for device ID - 10-minute cache with offline fallback - LicenseResult sealed type (success/error) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 行
679 B
Swift
22 行
679 B
Swift
import Foundation
|
|
|
|
enum LicenseFileReader {
|
|
|
|
static func read() -> LicenseFile? {
|
|
guard let url = Bundle.main.url(forResource: "license", withExtension: "xuqm", subdirectory: "xuqm"),
|
|
let encrypted = try? String(contentsOf: url, encoding: .utf8) else {
|
|
return nil
|
|
}
|
|
return parse(encrypted)
|
|
}
|
|
|
|
static func parse(_ encrypted: String) -> LicenseFile? {
|
|
guard let json = try? LicenseFileCrypto.decrypt(encrypted),
|
|
let data = json.data(using: .utf8),
|
|
let file = try? JSONDecoder().decode(LicenseFile.self, from: data) else {
|
|
return nil
|
|
}
|
|
return file
|
|
}
|
|
}
|