Skip to content

Commit

Permalink
Merge pull request #14 from klippa-app/feature/bump-versions
Browse files Browse the repository at this point in the history
Feature/bump versions
  • Loading branch information
RobinFarmer authored May 28, 2024
2 parents 992143b + fcddbaf commit e36c289
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 70 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.0.10

* Bump Android to 0.7.5
* Bump iOS to 0.5.18
* Added `German` and `French` support.
* Added `enableAutoCapture` to `IdentityBuilder`.
* Added `validationIncludeList` and `validationExcludeList` to `IdentityBuilder`.

## 0.0.9

* Bump Android to 0.7.3
Expand Down Expand Up @@ -40,4 +48,4 @@

## 0.0.1

* First release of Klippa Scanner SDK on react native.
* First release of Klippa Scanner SDK on react native.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,20 @@ To configure how often a user can attempt a task before the `contact support` bu
identityBuilder.retryThreshold = 1
```

### Enable Auto Capture

To configure if the camera should automatically take a photo if the conditions are right.

```typescript
identityBuilder.enableAutoCapture = true
```

### Language

Add the following to the builder:

``` typescript
// We support English, Dutch and Spanish
// We support English, Dutch, Spanish, German and French
identityBuilder.language = KIVLanguage.Dutch
```

Expand Down Expand Up @@ -223,6 +231,28 @@ identityBuilder.verifyIncludeList = [
identityBuilder.verifyExcludeList = []
```

### Validation Include & Exclude lists

You can edit the validation include list: the failed validations that are shown to the user Or the validation exclude list: the failed validations that are hidden from the user.
For more information regarding validations check out the [API documentation](https://custom-ocr.klippa.com/docs#tag/IdentityVerification/operation/createIdentityVerificationSession).

```typescript
identityBuilder.validationIncludeList = [
"DetectFace",
"CompareFace",
"DetectSignature",
"CompareSignature",
"CheckRequiredField",
"MatchSidesFront",
"MatchSidesBack",
"FieldValidation",
"MatchVizMrz",
"MrzChecksum"
]

identityBuilder.validationExcludeList = []
```

### Colors

#### Android
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ dependencies {
implementation "com.facebook.react:react-native"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

def fallbackKlippaVersion = "0.7.3"
def fallbackKlippaVersion = "0.7.5"
def klippaIdentityVerificationVersion = project.hasProperty('klippaIdentityVerificationVersion') ? project.klippaIdentityVerificationVersion : fallbackKlippaVersion
implementation "com.klippa:identity_verification:$klippaIdentityVerificationVersion"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class KlippaIdentityVerificationSdkModule(private val reactContext: ReactApplica
IdentitySessionResultCode.DEVICE_DOES_NOT_SUPPORT_NFC,
IdentitySessionResultCode.DEVICE_NFC_DISABLED,
IdentitySessionResultCode.UNKNOWN_ERROR,
IdentitySessionResultCode.TAKING_PHOTO_FAILED -> identityVerificationCanceled(
IdentitySessionResultCode.TAKING_PHOTO_FAILED,
IdentitySessionResultCode.INCORRECT_SESSION_SETUP -> identityVerificationCanceled(
mappedResultCode.message()
)
}
Expand Down Expand Up @@ -95,8 +96,13 @@ class KlippaIdentityVerificationSdkModule(private val reactContext: ReactApplica
identitySession.retryThreshold = retryThreshold.toInt()
}

(config["enableAutoCapture"] as? Boolean)?.let { enableAutoCapture ->
identitySession.enableAutoCapture = enableAutoCapture
}

setVerificationLists(config, identitySession)

setValidationLists(config, identitySession)

return identitySession
}
Expand All @@ -116,6 +122,21 @@ class KlippaIdentityVerificationSdkModule(private val reactContext: ReactApplica
}
}

private fun setValidationLists(
config: Map<String, Any>,
identitySession: IdentitySession
) {
@Suppress("UNCHECKED_CAST")
(config["validationIncludeList"] as? List<String>)?.also { validationIncludeList ->
identitySession.kivValidationIncludeList = validationIncludeList
}

@Suppress("UNCHECKED_CAST")
(config["validationExcludeList"] as? List<String>)?.also { validationExcludeList ->
identitySession.kivValidationExcludeList = validationExcludeList
}
}

private fun setBuilderOptionalScreens(
config: Map<String, Any>,
identitySession: IdentitySession
Expand All @@ -138,6 +159,8 @@ class KlippaIdentityVerificationSdkModule(private val reactContext: ReactApplica
"English" -> identitySession.language = IdentitySession.KIVLanguage.English
"Dutch" -> identitySession.language = IdentitySession.KIVLanguage.Dutch
"Spanish" -> identitySession.language = IdentitySession.KIVLanguage.Spanish
"German" -> identitySession.language = IdentitySession.KIVLanguage.German
"French" -> identitySession.language = IdentitySession.KIVLanguage.French
}
}
}
Expand Down
79 changes: 45 additions & 34 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,61 @@ target 'KlippaIdentityVerificationSdkExample' do
flags = get_default_flags()

use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => true,
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

if "#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_URL']}" == ""
file_path = File.expand_path('../../ios/.sdk_repo', __dir__)
ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_URL'] = File.read(file_path).strip
end

if "#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_VERSION']}" == ""
file_path = File.expand_path('../../ios/.sdk_version', __dir__)
ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_VERSION'] = File.read(file_path).strip
end

pod 'Klippa-Identity-Verification', podspec: "#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_URL']}/#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_USERNAME']}/#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_PASSWORD']}/KlippaIdentityVerification/#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_VERSION']}.podspec"
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => true,
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

if "#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_URL']}" == ""
file_path = File.expand_path('../../ios/.sdk_repo', __dir__)
ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_URL'] = File.read(file_path).strip
end

if "#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_VERSION']}" == ""
file_path = File.expand_path('../../ios/.sdk_version', __dir__)
ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_VERSION'] = File.read(file_path).strip
end

pod 'Klippa-Identity-Verification', podspec: "#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_URL']}/#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_USERNAME']}/#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_PASSWORD']}/KlippaIdentityVerification/#{ENV['KLIPPA_IDENTITY_VERIFICATION_SDK_VERSION']}.podspec"

end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
end
if target.name == 'Flipper'
file_path = 'Pods/Flipper/xplat/Flipper/FlipperTransportTypes.h'
contents = File.read(file_path)
unless contents.include?('#include <functional>')
File.chmod(0755, file_path)
File.open(file_path, 'w') do |file|
file.puts('#include <functional>')
file.puts(contents)
end
end
end
end


react_native_post_install(
installer,
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
installer,
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end

2 changes: 1 addition & 1 deletion ios/.sdk_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.14
0.5.18
83 changes: 54 additions & 29 deletions ios/KlippaIdentityVerificationSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ class KlippaIdentityVerificationSdk: NSObject {
builder.retryThreshold = Int(retryThreshold)
}

if let enableAutoCapture = config["enableAutoCapture"] as? Bool {
builder.enableAutoCapture = enableAutoCapture
}

setBuilderColors(config, builder)

setBuilderFonts(config, builder)

setVerificationLists(config, builder)

setValidationLists(config, builder)

return builder
}

Expand All @@ -66,32 +72,32 @@ class KlippaIdentityVerificationSdk: NSObject {
}

if let textColor = colors["textColor"] {
let txtColor = hexStringToUIColor(hex: textColor)
let txtColor = UIColor(hexString: textColor)
builder.kivColors.textColor = txtColor
}

if let backgroundColor = colors["backgroundColor"] {
builder.kivColors.backgroundColor = hexStringToUIColor(hex: backgroundColor)
builder.kivColors.backgroundColor = UIColor(hexString: backgroundColor)
}

if let buttonSuccessColor = colors["buttonSuccessColor"] {
builder.kivColors.buttonSuccessColor = hexStringToUIColor(hex: buttonSuccessColor)
builder.kivColors.successColor = UIColor(hexString: buttonSuccessColor)
}

if let buttonErrorColor = colors["buttonErrorColor"] {
builder.kivColors.buttonErrorColor = hexStringToUIColor(hex: buttonErrorColor)
builder.kivColors.errorColor = UIColor(hexString: buttonErrorColor)
}

if let buttonOtherColor = colors["buttonOtherColor"] {
builder.kivColors.buttonOtherColor = hexStringToUIColor(hex: buttonOtherColor)
builder.kivColors.otherColor = UIColor(hexString: buttonOtherColor)
}

if let progressBarBackground = colors["progressBarBackground"] {
builder.kivColors.progressBarBackground = hexStringToUIColor(hex: progressBarBackground)
builder.kivColors.progressBarBackground = UIColor(hexString: progressBarBackground)
}

if let progressBarForeground = colors["progressBarForeground"] {
builder.kivColors.progressBarForeground = hexStringToUIColor(hex: progressBarForeground)
builder.kivColors.progressBarForeground = UIColor(hexString: progressBarForeground)
}
}

Expand All @@ -105,15 +111,19 @@ class KlippaIdentityVerificationSdk: NSObject {
builder.kivLanguage = .Dutch
} else if language == "Spanish" {
builder.kivLanguage = .Spanish
} else if language == "German" {
builder.kivLanguage = .German
} else if language == "French" {
builder.kivLanguage = .French
}
}
}

// MARK: Customize Optional Screens

fileprivate func setBuilderOptionalScreens(_ config: [String : Any], _ builder: IdentityBuilder) {
if let hasInstroScreen = config["hasIntroScreen"] as? Bool {
builder.hasIntroScreen = hasInstroScreen
if let hasIntroScreen = config["hasIntroScreen"] as? Bool {
builder.hasIntroScreen = hasIntroScreen
}

if let hasSuccessScreen = config["hasSuccessScreen"] as? Bool {
Expand All @@ -133,6 +143,16 @@ class KlippaIdentityVerificationSdk: NSObject {
}
}

fileprivate func setValidationLists(_ config: [String : Any], _ builder: IdentityBuilder) {
if let validationIncludeList = config["validationIncludeList"] as? [String] {
builder.kivValidationIncludeList = validationIncludeList
}

if let validationExcludeList = config["validationExcludeList"] as? [String] {
builder.kivValidationExcludeList = validationExcludeList
}
}

// MARK: Customize Fonts

fileprivate func setBuilderFonts(_ config: [String : Any], _ builder: IdentityBuilder) {
Expand All @@ -148,30 +168,35 @@ class KlippaIdentityVerificationSdk: NSObject {
builder.kivFonts.boldFontName = boldFontName
}
}
}

func hexStringToUIColor(hex:String) -> UIColor? {
var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()

if (cString.hasPrefix("#")) {
cString.remove(at: cString.startIndex)
}

if ((cString.count) != 6) {
return nil
extension UIColor {
convenience init(hexString: String) {
var newString = hexString
if newString.first != "#" {
newString.insert("#", at: newString.startIndex)
}
let hex = newString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
var int = UInt64()
Scanner(string: hex).scanHexInt64(&int)
let a, r, g, b: UInt64
switch hex.count {
case 3: // RGB (12-bit)
(a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
case 6: // RGB (24-bit)
(a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF)
case 8: // ARGB (32-bit)
(a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF)
default:
(a, r, g, b) = (255, 0, 0, 0)
}

var rgbValue:UInt64 = 0
Scanner(string: cString).scanHexInt64(&rgbValue)

return UIColor(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
self.init(
red: CGFloat(r) / 255,
green: CGFloat(g) / 255,
blue: CGFloat(b) / 255,
alpha: CGFloat(a) / 255
)
}


}

extension KlippaIdentityVerificationSdk: IdentityBuilderDelegate {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@klippa/react-native-klippa-identity-verification-sdk",
"title": "React Native Klippa Identity Verification SDK",
"version": "0.0.9",
"version": "0.0.10",
"description": "A React Native plugin to use the Klippa Identity Verification SDK",
"homepage": "https://github.com/klippa-app/react-native-klippa-identity-verification-sdk",
"main": "lib/commonjs/index",
Expand Down
Loading

0 comments on commit e36c289

Please sign in to comment.