fix(swift-sdk): URL-encode license key + add request tracing to kill switch

BLLicenseClient.checkStatus: percent-encode key before inserting into URL
path to prevent malformed URLs with special characters.

BLKillSwitchClient: add X-Product-Id and X-Request-Id headers for
consistency with BLPlatformClient request tracing pattern.
This commit is contained in:
saravanakumardb1 2026-02-28 22:52:00 -08:00
parent b068e4bc1a
commit 77d6ff328f
2 changed files with 4 additions and 1 deletions

View File

@ -27,6 +27,8 @@ public final class BLKillSwitchClient {
var request = URLRequest(url: url)
request.timeoutInterval = 5
request.setValue(config.productId, forHTTPHeaderField: "X-Product-Id")
request.setValue(UUID().uuidString, forHTTPHeaderField: "X-Request-Id")
do {
let (data, response) = try await URLSession.shared.data(for: request)

View File

@ -94,7 +94,8 @@ public final class BLLicenseClient {
/// Check license status without activating.
public func checkStatus(key: String) async throws -> BLLicenseInfo {
let encodedKey = key.uppercased().trimmingCharacters(in: .whitespaces)
let trimmedKey = key.uppercased().trimmingCharacters(in: .whitespaces)
let encodedKey = trimmedKey.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? trimmedKey
return try await client.request(
path: "/api/licenses/status/\(encodedKey)",
responseType: BLLicenseInfo.self