Skip to content

Instantly share code, notes, and snippets.

@tompsota
Last active May 16, 2024 10:32
Show Gist options
  • Save tompsota/737ffb2a8599641644f4fd72de38af64 to your computer and use it in GitHub Desktop.
Save tompsota/737ffb2a8599641644f4fd72de38af64 to your computer and use it in GitHub Desktop.
Cordova iOS fix
struct ThreatIdentifiers {
static let threatIdentifierList: [Int] = (1...12).map { _ in Int.random(in: 100_000..<999_999_999) }
}
/// An extension to unify callback names with Cordova ones.
extension SecurityThreat {
var callbackIdentifier: Int {
switch self {
case .signature:
return ThreatIdentifiers.threatIdentifierList[0]
case .jailbreak:
return ThreatIdentifiers.threatIdentifierList[1]
case .debugger:
return ThreatIdentifiers.threatIdentifierList[2]
case .runtimeManipulation:
return ThreatIdentifiers.threatIdentifierList[3]
case .passcode:
return ThreatIdentifiers.threatIdentifierList[4]
case .passcodeChange:
return ThreatIdentifiers.threatIdentifierList[5]
case .simulator:
return ThreatIdentifiers.threatIdentifierList[6]
case .missingSecureEnclave:
return ThreatIdentifiers.threatIdentifierList[7]
case .deviceChange:
return ThreatIdentifiers.threatIdentifierList[8]
case .deviceID:
return ThreatIdentifiers.threatIdentifierList[9]
case .unofficialStore:
return ThreatIdentifiers.threatIdentifierList[10]
@unknown default:
abort()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment