From 77d6ff328fbaaca1590b6d4ba237bad4d1289eb8 Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Sat, 28 Feb 2026 22:52:00 -0800 Subject: [PATCH] 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. --- packages/swift-platform-sdk/Sources/BLKillSwitchClient.swift | 2 ++ packages/swift-platform-sdk/Sources/BLLicenseClient.swift | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/swift-platform-sdk/Sources/BLKillSwitchClient.swift b/packages/swift-platform-sdk/Sources/BLKillSwitchClient.swift index 964c434f..736965d3 100644 --- a/packages/swift-platform-sdk/Sources/BLKillSwitchClient.swift +++ b/packages/swift-platform-sdk/Sources/BLKillSwitchClient.swift @@ -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) diff --git a/packages/swift-platform-sdk/Sources/BLLicenseClient.swift b/packages/swift-platform-sdk/Sources/BLLicenseClient.swift index 6a3320ee..f6926f19 100644 --- a/packages/swift-platform-sdk/Sources/BLLicenseClient.swift +++ b/packages/swift-platform-sdk/Sources/BLLicenseClient.swift @@ -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