XuqmGroup-iOSSDK/Sources/XuqmSDK/License/LicenseModels.swift
XuqmGroup 60ac8f0283 feat(license): add LicenseSDK module
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>
2026-05-16 02:25:26 +08:00

71 行
1.4 KiB
Swift

import Foundation
struct LicenseFile: Codable {
let appKey: String
let appName: String?
let companyName: String?
let baseUrl: String?
let issuedAt: String?
let expiresAt: String?
}
public struct LicenseUserInfo: Sendable {
public let userId: String?
public let name: String?
public let email: String?
public let phone: String?
public init(userId: String? = nil, name: String? = nil, email: String? = nil, phone: String? = nil) {
self.userId = userId
self.name = name
self.email = email
self.phone = phone
}
}
public enum LicenseStatus: Sendable {
case ok
case denied
case unknown
}
public enum LicenseResult: Sendable {
case success(String)
case error(String)
}
struct UserInfoPayload: Encodable {
let userId: String?
let name: String?
let email: String?
let phone: String?
}
struct RegisterRequest: Encodable {
let appKey: String
let deviceId: String
let deviceName: String?
let deviceModel: String
let deviceVendor: String
let osVersion: String
let userInfo: UserInfoPayload?
}
struct VerifyRequest: Encodable {
let appKey: String
let deviceId: String
let token: String
let userInfo: UserInfoPayload?
}
struct RegisterResponse: Decodable {
let success: Bool
let token: String?
let message: String?
}
struct VerifyResponse: Decodable {
let valid: Bool
let error: String?
}