Skip to content

Commit

Permalink
Allowing DeviceBinding NONE option on Simulators
Browse files Browse the repository at this point in the history
  • Loading branch information
george-bafaloukas-forgerock committed Oct 9, 2024
1 parent 08ec08d commit f44be9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// DeviceBindingCallback.swift
// FRDeviceBinding
//
Expand Down Expand Up @@ -170,11 +170,14 @@ open class DeviceBindingCallback: MultipleValuesCallback, Binding {
deviceRepository: DeviceBindingRepository = LocalDeviceBindingRepository(),
prompt: Prompt? = nil,
_ completion: @escaping DeviceBindingResultCallback) {
if deviceBindingAuthenticationType != .none {
#if targetEnvironment(simulator)
// DeviceBinding/Signing is not supported on the iOS Simulator
handleException(status: .unsupported(errorMessage: "DeviceBinding/Signing is not supported on the iOS Simulator"), completion: completion)
return
// DeviceBinding/Signing other than `.NONE` type is not supported on the iOS Simulator
handleException(status: .unsupported(errorMessage: "DeviceBinding/Signing is not supported on the iOS Simulator"), completion: completion)
return
#endif
}

let authInterface = authInterface ?? getDeviceAuthenticator(type: deviceBindingAuthenticationType)
authInterface.initialize(userId: userId, prompt: prompt ?? Prompt(title: title, subtitle: subtitle, description: promptDescription))
let deviceId = deviceId ?? FRDevice.currentDevice?.identifier.getIdentifier()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,15 @@ open class DeviceSigningVerifierCallback: MultipleValuesCallback, Binding {
customClaims: [String: Any] = [:],
prompt: Prompt? = nil,
_ completion: @escaping DeviceSigningResultCallback) {

if userKey.authType != .none {
#if targetEnvironment(simulator)
// DeviceBinding/Signing is not supported on the iOS Simulator
handleException(status: .unsupported(errorMessage: "DeviceBinding/Signing is not supported on the iOS Simulator"), completion: completion)
return
// DeviceBinding/Signing other than `.NONE` type is not supported on the iOS Simulator
handleException(status: .unsupported(errorMessage: "DeviceBinding/Signing is not supported on the iOS Simulator"), completion: completion)
return
#endif
}

authInterface.initialize(userId: userKey.userId, prompt: prompt ?? Prompt(title: title, subtitle: subtitle, description: promptDescription))
guard authInterface.isSupported() else {
handleException(status: .unsupported(errorMessage: nil), completion: completion)
Expand Down

0 comments on commit f44be9c

Please sign in to comment.