Skip to content

Commit 1cb19f6

Browse files
committed
feature(PSG-3967): updated prt headers
1 parent 05ba449 commit 1cb19f6

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

Sources/passage-authentikit-ios/Authentikit.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ public class Authentikit {
55
public let passkey: Passkey
66

77
internal static let BASE_PATH = "https://auth-uat.passage.dev"
8+
internal static let PACKAGE_VERSION = "0.1.0"
89

9-
public init(organizationId: String) {
10-
self.passkey = Passkey(organizationId: organizationId)
10+
public init(clientSideKey: String) {
11+
self.passkey = Passkey(clientSideKey: clientSideKey)
1112
}
1213

1314
}

Sources/passage-authentikit-ios/Passkey.swift

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,62 @@ import UIKit
22

33
public class Passkey {
44

5-
private let organizationId: String
5+
private let clientSideKey: String
66
private let userDefaults = UserDefaults.standard
77
private let lastEvaluationKey = "lastEvaluationDate"
88

9-
init(organizationId: String) {
10-
self.organizationId = organizationId
9+
init(clientSideKey: String) {
10+
self.clientSideKey = clientSideKey
1111
}
1212

13-
public func evaluateReadiness() {
13+
public func evaluateReadiness() async {
1414
guard canEvaluateReadiness() else {
1515
print("❌ Evaluate readiness can only be called once in 24 hours.")
1616
return
1717
}
18-
let device = UIDevice.current
19-
let deviceId = device.identifierForVendor?.uuidString ?? ""
20-
let supportsPassekeys = Utilities.deviceOSSupportsPasskeys
21-
let requestHeaders: [String : String] = [
18+
let device = await UIDevice.current
19+
let requestHeaders: [String : String] = await [
2220
"app_identifier": Bundle.main.bundleIdentifier ?? "",
2321
"device_os": device.systemName,
2422
"device_os_version": device.systemVersion,
25-
"Content-Type": "application/json"
23+
"Content-Type": "application/json",
24+
"Passage-Version": "Passage Authentikit iOS \(Authentikit.PACKAGE_VERSION)",
25+
"X-API-KEY": clientSideKey,
2626
]
27+
let deviceId = await device.identifierForVendor?.uuidString ?? ""
28+
let supportsPassekeys = Utilities.deviceOSSupportsPasskeys
2729
let requestBody: [String : Any] = [
28-
"device_id": deviceId,
29-
"security_key": supportsPassekeys,
30-
"platform": supportsPassekeys,
3130
"cloud_synced": supportsPassekeys,
32-
"cross_platform": supportsPassekeys,
3331
"conditional_ui": supportsPassekeys,
32+
"cross_platform": supportsPassekeys,
33+
"device_id": deviceId,
34+
"platform": supportsPassekeys,
35+
"security_key": supportsPassekeys,
3436
]
35-
let urlString = "\(Authentikit.BASE_PATH)/v1/organizations/\(organizationId)/analytics/passkey-readiness"
37+
let urlString = "\(Authentikit.BASE_PATH)/v1/analytics/passkey-readiness"
3638
guard let url = URL(string: urlString) else {
3739
print("❌ Failed evaluate passkey readiness.")
3840
return
3941
}
40-
Task {
41-
var request = URLRequest(url: url)
42-
request.httpMethod = "POST"
43-
for (key, value) in requestHeaders {
44-
request.setValue(value, forHTTPHeaderField: key)
45-
}
46-
do {
47-
let jsonData = try JSONSerialization.data(withJSONObject: requestBody, options: [])
48-
request.httpBody = jsonData
49-
let (data, response) = try await URLSession.shared.data(for: request)
50-
guard let httpResponse = response as? HTTPURLResponse,
51-
(200...299).contains(httpResponse.statusCode)
52-
else {
53-
print("❌ Failed evaluate passkey readiness.")
54-
return
55-
}
56-
updateLastEvaluationDate()
57-
print("✅ Successfully evaluated passkey readiness.")
58-
} catch {
42+
var request = URLRequest(url: url)
43+
request.httpMethod = "POST"
44+
for (key, value) in requestHeaders {
45+
request.setValue(value, forHTTPHeaderField: key)
46+
}
47+
do {
48+
let jsonData = try JSONSerialization.data(withJSONObject: requestBody, options: [])
49+
request.httpBody = jsonData
50+
let (data, response) = try await URLSession.shared.data(for: request)
51+
guard let httpResponse = response as? HTTPURLResponse,
52+
(200...299).contains(httpResponse.statusCode)
53+
else {
5954
print("❌ Failed evaluate passkey readiness.")
55+
return
6056
}
57+
updateLastEvaluationDate()
58+
print("✅ Successfully evaluated passkey readiness.")
59+
} catch {
60+
print("❌ Failed evaluate passkey readiness.")
6161
}
6262

6363
}

0 commit comments

Comments
 (0)