2026-05-16 02:25:26 +08:00
|
|
|
import Foundation
|
2026-05-23 01:20:57 +08:00
|
|
|
import XuqmCoreSDK
|
2026-05-16 02:25:26 +08:00
|
|
|
|
2026-05-23 01:20:57 +08:00
|
|
|
public enum LicenseFileReader {
|
2026-05-16 02:25:26 +08:00
|
|
|
|
2026-05-23 01:20:57 +08:00
|
|
|
public static func read() -> LicenseFile? {
|
2026-05-16 02:25:26 +08:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|