Skip to content

Commit

Permalink
Merge pull request #43 from fingerprintjs/topic/xcode-15
Browse files Browse the repository at this point in the history
Update project for Xcode 15

Includes:
 - Added support for `LABiometryType.opticID` enumeration case;
 - Fixed "stored properties cannot be marked unavailable with 
   '@available'" error;
 - Updated CI workflow;
 - Updated README.
  • Loading branch information
mgutski authored Sep 19, 2023
2 parents 5046319 + d89ec5b commit 9156cae
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
xcode:
- "14.1" # Swift 5.7
- "14.3" # Swift 5.8
- "15.0" # Swift 5.9

steps:
- name: Runner Overview
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<img src="https://github.com/fingerprintjs/fingerprintjs-ios/actions/workflows/ci.yml/badge.svg" alt="CI status">
</a>
<a href="https://www.swift.org/download/">
<img src="https://img.shields.io/badge/Swift-5.8%20%7C%205.7-red" alt="Supported Swift versions">
<img src="https://img.shields.io/badge/Swift-5.9%20%7C%205.8%20%7C%205.7-red" alt="Supported Swift versions">
</a>
<a href="https://fingerprint.com/sdk-libraries/">
<img src="https://img.shields.io/badge/Platforms-iOS%20%7C%20tvOS-red" alt="Supported platforms">
Expand Down
24 changes: 24 additions & 0 deletions Sources/FingerprintJS/Harvesters/DataExchange/BiometryType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public enum BiometryType: String, Encodable {
case faceID
/// The device supports Touch ID.
case touchID
/// The device supports Optic ID.
@available(iOS 17.0, *)
case opticID
/// Biometric authentication is not supported.
case none
/// The device supports some unknown type of biometric authentication.
Expand All @@ -25,6 +28,8 @@ extension BiometryType: CustomStringConvertible {
return "Face ID"
case .touchID:
return "Touch ID"
case .opticID:
return "Optic ID"
case .none, .unknown:
return "<\(rawValue)>"
}
Expand All @@ -34,16 +39,35 @@ extension BiometryType: CustomStringConvertible {
extension BiometryType {

init(_ biometryType: LABiometryType) {
#if compiler(>=5.9)
switch biometryType {
case .faceID:
self = .faceID
case .touchID:
self = .touchID
case .opticID:
if #available(iOS 17.0, *) {
self = .opticID
} else {
self = .unknown
}
case .none:
self = .none
@unknown default:
self = .unknown
}
#else
switch biometryType {
case .faceID:
self = .faceID
case .touchID:
self = .touchID
case .none:
self = .none
@unknown default:
self = .unknown
}
#endif
}
}
#endif
89 changes: 86 additions & 3 deletions Sources/FingerprintJS/Harvesters/DataExchange/DeviceInfo.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import Foundation

public struct DeviceInfo: Equatable, Encodable {
#if os(iOS)
private let _mobileCountryCodes: [String]
private let _mobileNetworkCodes: [String]
private let _localAuthentication: LocalAuthenticationInfo
#endif

public let vendorIdentifier: UUID?

/// The identifier for the locale representing the user's language and region settings.
Expand Down Expand Up @@ -51,17 +57,94 @@ public struct DeviceInfo: Equatable, Encodable {
message: "The return value is undefined and no guarantee can be made on its stability."
)
@available(tvOS, unavailable)
public let mobileCountryCodes: [String]
public var mobileCountryCodes: [String] {
#if os(iOS)
_mobileCountryCodes
#else
[]
#endif
}
/// The mobile network codes (MNCs) for the user’s cellular service providers.
@available(
iOS,
deprecated: 16.0,
message: "The return value is undefined and no guarantee can be made on its stability."
)
@available(tvOS, unavailable)
public let mobileNetworkCodes: [String]
public var mobileNetworkCodes: [String] {
#if os(iOS)
_mobileNetworkCodes
#else
[]
#endif
}

/// The information about the local authentication settings.
@available(tvOS, unavailable)
public let localAuthentication: LocalAuthenticationInfo
public var localAuthentication: LocalAuthenticationInfo {
#if os(iOS)
_localAuthentication
#else
.init(
isPasscodeEnabled: false,
isBiometricsEnabled: false,
biometryType: .none
)
#endif
}
}

extension DeviceInfo {

#if os(iOS)
init(
vendorIdentifier: UUID?,
localeIdentifier: String,
userInterfaceStyle: UserInterfaceStyle,
diskSpace: DiskSpaceInfo?,
screenResolution: CGSize?,
screenScale: CGFloat,
deviceName: String,
deviceType: String?,
deviceModel: String?,
memorySize: String?,
physicalMemory: String?,
cpuCount: String?,
kernelHostname: String,
osTimeZoneIdentifier: String,
osBuild: String?,
osVersion: String?,
osType: String?,
osRelease: String?,
kernelVersion: String?,
bootTime: String,
mobileCountryCodes: [String],
mobileNetworkCodes: [String],
localAuthentication: LocalAuthenticationInfo
) {
self.vendorIdentifier = vendorIdentifier
self.localeIdentifier = localeIdentifier
self.userInterfaceStyle = userInterfaceStyle
self.diskSpace = diskSpace
self.screenResolution = screenResolution
self.screenScale = screenScale
self.deviceName = deviceName
self.deviceType = deviceType
self.deviceModel = deviceModel
self.memorySize = memorySize
self.physicalMemory = physicalMemory
self.cpuCount = cpuCount
self.kernelHostname = kernelHostname
self.osTimeZoneIdentifier = osTimeZoneIdentifier
self.osBuild = osBuild
self.osVersion = osVersion
self.osType = osType
self.osRelease = osRelease
self.kernelVersion = kernelVersion
self.bootTime = bootTime
self._mobileCountryCodes = mobileCountryCodes
self._mobileNetworkCodes = mobileNetworkCodes
self._localAuthentication = localAuthentication
}
#endif
}
9 changes: 1 addition & 8 deletions Sources/FingerprintJS/Library/DeviceInfoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,7 @@ extension DeviceInfoProvider: DeviceInfoProviding {
osType: osInfoHarvester.osType,
osRelease: osInfoHarvester.osRelease,
kernelVersion: osInfoHarvester.kernelVersion,
bootTime: osInfoHarvester.bootTime,
mobileCountryCodes: [],
mobileNetworkCodes: [],
localAuthentication: .init(
isPasscodeEnabled: false,
isBiometricsEnabled: false,
biometryType: .none
)
bootTime: osInfoHarvester.bootTime
)
}
#endif
Expand Down

0 comments on commit 9156cae

Please sign in to comment.