diff --git a/CHANGELOG.md b/CHANGELOG.md index ed87022..76c35fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [13.0.0] - 2024-07-30 + +### Added: + +- Added `nfcOption` parameter for configuring NFC +- Deprecated `disableNFC` parameter (Use `nfcOption` with `OnfidoNFCOptions.DISABLED` value instead) + +### Changed: + +- Updated underlying Onfido native SDK version: + - iOS 30.4.x (up from 30.3.x) + - Android 21.0.x (up from 20.5.x) +- Bumped Android target SDK version to 34 (Java version 17 is required to build the project) + ## [12.3.0] - 2024-07-04 ### Changed: diff --git a/README.md b/README.md index b212677..dbf15cb 100644 --- a/README.md +++ b/README.md @@ -210,19 +210,19 @@ You have to include the entries below in your app target's `Info.plist` file to ``` -##### Disabling NFC +##### Disabling NFC and excluding dependencies -NFC is enabled by default. To disable NFC, include the `disableNFC` parameter while configuring the `Onfido.start` function: +NFC is enabled by default. To disable NFC, include the `nfcOption` parameter with `OnfidoNFCOptions.DISABLED` while configuring the `Onfido.start` function: ```javascript config = { sdkToken: "", workflowRunId: "", - disableNFC: "true" + nfcOption: OnfidoNFCOptions.DISABLED } ``` -For Android, a range of NFC library dependencies are included in the build automatically. In addition to configuring the `disableNFC` parameter, you must remove any libraries from the build process. +For Android, a range of NFC library dependencies are included in the build automatically. In addition to configuring the `nfcOption` parameter, you must remove any libraries from the build process. Exclude dependencies required for NFC from your build: @@ -250,6 +250,13 @@ implementation ("com.onfido.sdk:onfido-:19.1.0"){ implementation "org.bouncycastle:bcutil-jdk15to18:1.69" ``` +#### NFC Options + +To configure NFC, include the `nfcOption` parameter with the three options below while configuring the `Onfido.start` function: +* DISABLED: NFC reading will not be asked of end-users +* OPTIONAL (Default): NFC reading will be attempted, if possible +* REQUIRED: NFC reading will be enforced, preventing end-users from completing the flow without a successful reading + ## Initializing the SDK The Reach Native SDK has multiple initialization and customization options that provide flexibility to your integration, while remaining easy to integrate. @@ -274,23 +281,9 @@ When defining workflows and creating identity verifications, we highly recommend ### SDK authentication -The SDK is authenticated using SDK tokens. As each SDK token must be specific to a given applicant and session, and a new token must be generated each time you initialize the Onfido React Native SDK. +The SDK is authenticated using SDK tokens. Onfido Studio generates and exposes SDK tokens in the workflow run payload returned by the API when a workflow run is [created](https://documentation.onfido.com/#create-workflow-run). -| Parameter | Notes | -|------|------| -| `applicant_id` | **required**
Specifies the applicant for the SDK instance. | -| `application_id` | **required**
The application ID (for iOS "application bundle ID") that was set up during development. | - -* For iOS, the `application_id` is usually in the form of `com.your-company.app-name`. - * To get this value manually, open Xcode `ios/YourProjectName`, click on the project root, click the General tab, under Targets click your project name, and check the Bundle Identifier field. - * To get this value programmatically in native iOS code, refer to this [Stack Overflow Page](https://stackoverflow.com/questions/8873203/how-to-get-bundle-id). -* For Android, the `application_id` is usually in the form of `com.example.yourapp`. - * To get this file manually, you can find it in your app's `build.config`. For example, in `android/app/build.gradle`, it is the value of `applicationId`. - * To get this value programmatically in native Java code, refer to this [Stack Overflow Page](https://stackoverflow.com/questions/14705874/bundle-id-in-android). - -It's important to note that SDK tokens expire after **90 minutes**. - -For details on how to generate SDK tokens, please refer to the `POST /sdk_token/` endpoint definition in the Onfido [API reference](https://documentation.onfido.com/api/latest#generate-sdk-token). +SDK tokens for Studio can only be used together with the specific workflow run they are generated for, and remain valid for a period of five weeks. **Note**: You must never use API tokens in the frontend of your application as malicious users could discover them in your source code. You should only use them on your server. @@ -536,6 +529,28 @@ The flow step parameters described below are mutually exclusive with `workflowRu **Note** that this initialization process is **not recommended** as the majority of new features are exclusively released for Studio workflows. +### Manual SDK authentication + +The SDK is authenticated using SDK tokens. As each SDK token must be specific to a given applicant and session, and a new token must be generated each time you initialize the Onfido React Native SDK. + +| Parameter | Notes | +|------|------| +| `applicant_id` | **required**
Specifies the applicant for the SDK instance. | +| `application_id` | **required**
The application ID (for iOS "application bundle ID") that was set up during development. For iOS, this is usually in the form `com.your-company.app-name`, or `com.example.yourapp` for Android. Make sure to use a valid `application_id` or you'll receive a 401 error. | + +* For iOS, the `application_id` is usually in the form of `com.your-company.app-name`. + * To get this value manually, open Xcode `ios/YourProjectName`, click on the project root, click the General tab, under Targets click your project name, and check the Bundle Identifier field. + * To get this value programmatically in native iOS code, refer to this [Stack Overflow Page](https://stackoverflow.com/questions/8873203/how-to-get-bundle-id). +* For Android, the `application_id` is usually in the form of `com.example.yourapp`. + * To get this file manually, you can find it in your app's `build.config`. For example, in `android/app/build.gradle`, it is the value of `applicationId`. + * To get this value programmatically in native Java code, refer to this [Stack Overflow Page](https://stackoverflow.com/questions/14705874/bundle-id-in-android). + +It's important to note that manually generated SDK tokens in React Native expire after **90 minutes** and cannot be renewed. SDK tokens generated in Onfido Studio when creating workflow runs are **not** affected by this limit. + +For details on how to manually generate SDK tokens, please refer to the `POST /sdk_token/` endpoint definition in the Onfido [API reference](https://documentation.onfido.com/#generate-sdk-token). + +**Note**: You must never use API tokens in the frontend of your application as malicious users could discover them in your source code. You should only use them on your server. + ### Manually building the configuration object You can launch the app with a call to `Onfido.start`, manually defining the verification steps and configurations required for your flow: diff --git a/SampleApp/android/app/build.gradle b/SampleApp/android/app/build.gradle index eab81b4..b56ff20 100644 --- a/SampleApp/android/app/build.gradle +++ b/SampleApp/android/app/build.gradle @@ -129,6 +129,8 @@ android { proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } + + packagingOptions.resources.excludes += "META-INF/versions/9/OSGI-INF/MANIFEST.MF" } dependencies { diff --git a/SampleApp/android/build.gradle b/SampleApp/android/build.gradle index 05e955e..46ab177 100644 --- a/SampleApp/android/build.gradle +++ b/SampleApp/android/build.gradle @@ -5,8 +5,8 @@ buildscript { ext { buildToolsVersion = "31.0.0" minSdkVersion = 21 - compileSdkVersion = 33 - targetSdkVersion = 32 + compileSdkVersion = 34 + targetSdkVersion = 34 supportLibVersion = "27.1.0" kotlinVersion = "1.7.21" diff --git a/SampleApp/android/gradle.properties b/SampleApp/android/gradle.properties index 5237b20..c6b21ff 100644 --- a/SampleApp/android/gradle.properties +++ b/SampleApp/android/gradle.properties @@ -20,7 +20,6 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m android.useAndroidX=true -android.enableJetifier=true # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. diff --git a/SampleApp/android/gradle/wrapper/gradle-wrapper.properties b/SampleApp/android/gradle/wrapper/gradle-wrapper.properties index 3b7213b..6c41a5e 100644 --- a/SampleApp/android/gradle/wrapper/gradle-wrapper.properties +++ b/SampleApp/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jan 04 19:15:03 CET 2022 +#Tue Jul 30 16:08:19 CEST 2024 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/SampleApp/ios/Podfile.lock b/SampleApp/ios/Podfile.lock index 08ad715..87efd01 100644 --- a/SampleApp/ios/Podfile.lock +++ b/SampleApp/ios/Podfile.lock @@ -11,9 +11,9 @@ PODS: - ReactCommon/turbomodule/core (= 0.72.6) - fmt (6.2.1) - glog (0.3.5) - - Onfido (30.3.0) - - onfido-react-native-sdk (12.2.0): - - Onfido (~> 30.3.0) + - Onfido (30.4.0) + - onfido-react-native-sdk (12.3.0): + - Onfido (~> 30.4.0) - React - RCT-Folly (2021.07.22.00): - boost @@ -529,8 +529,8 @@ SPEC CHECKSUMS: FBReactNativeSpec: 966f29e4e697de53a3b366355e8f57375c856ad9 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b - Onfido: f2827394d4b92821cf13007b4fa99094f06e29ed - onfido-react-native-sdk: 00f8fa7ec87f8ae9997d1faae549707220b26807 + Onfido: 5715e65965133acfd12676e8a69b1389fac43ca5 + onfido-react-native-sdk: bf0ccd95e0ef2faf032f889869eb235eb4f193e7 RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: 28469809442eb4eb5528462705f7d852948c8a74 RCTTypeSafety: e9c6c409fca2cc584e5b086862d562540cb38d29 diff --git a/SampleApp/yalc.lock b/SampleApp/yalc.lock index 4e29f5c..abcd7a9 100644 --- a/SampleApp/yalc.lock +++ b/SampleApp/yalc.lock @@ -2,7 +2,7 @@ "version": "v1", "packages": { "@onfido/react-native-sdk": { - "signature": "f527247eb7bc33f0842238370ec0eabb", + "signature": "31603b6db695bea0356ea3de1d7c5922", "file": true } } diff --git a/android/build.gradle b/android/build.gradle index dcb311f..df1318d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -10,10 +10,10 @@ // original location: // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle -def DEFAULT_COMPILE_SDK_VERSION = 33 +def DEFAULT_COMPILE_SDK_VERSION = 34 def DEFAULT_MIN_SDK_VERSION = 21 -def DEFAULT_TARGET_SDK_VERSION = 31 -def NATIVE_ANDROID_SDK_VERSION = "20.5.+" +def DEFAULT_TARGET_SDK_VERSION = 34 +def NATIVE_ANDROID_SDK_VERSION = "21.0.+" def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 157f6b4..8482582 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -8,6 +8,6 @@ + android:value="13.0.0" /> diff --git a/android/src/main/java/com/onfido/reactnative/sdk/OnfidoSdkModule.java b/android/src/main/java/com/onfido/reactnative/sdk/OnfidoSdkModule.java index f98d7a8..bd530ba 100644 --- a/android/src/main/java/com/onfido/reactnative/sdk/OnfidoSdkModule.java +++ b/android/src/main/java/com/onfido/reactnative/sdk/OnfidoSdkModule.java @@ -16,21 +16,23 @@ import com.onfido.android.sdk.capture.Onfido; import com.onfido.android.sdk.capture.OnfidoConfig; import com.onfido.android.sdk.capture.OnfidoFactory; +import com.onfido.android.sdk.capture.OnfidoTheme; import com.onfido.android.sdk.capture.config.MediaCallback; import com.onfido.android.sdk.capture.errors.EnterpriseFeatureNotEnabledException; import com.onfido.android.sdk.capture.errors.EnterpriseFeaturesInvalidLogoCobrandingException; +import com.onfido.android.sdk.capture.model.NFCOptions; import com.onfido.android.sdk.capture.ui.camera.face.FaceCaptureStep; import com.onfido.android.sdk.capture.ui.camera.face.FaceCaptureVariantPhoto; import com.onfido.android.sdk.capture.ui.camera.face.stepbuilder.FaceCaptureStepBuilder; +import com.onfido.android.sdk.capture.ui.camera.face.stepbuilder.MotionCaptureStepBuilder; import com.onfido.android.sdk.capture.ui.camera.face.stepbuilder.PhotoCaptureStepBuilder; import com.onfido.android.sdk.capture.ui.camera.face.stepbuilder.VideoCaptureStepBuilder; -import com.onfido.android.sdk.capture.ui.camera.face.stepbuilder.MotionCaptureStepBuilder; import com.onfido.android.sdk.capture.ui.options.CaptureScreenStep; import com.onfido.android.sdk.capture.ui.options.FlowStep; import com.onfido.android.sdk.capture.utils.CountryCode; -import com.onfido.android.sdk.capture.OnfidoTheme; import com.onfido.workflow.OnfidoWorkflow; import com.onfido.workflow.WorkflowConfig; +import com.onfido.android.sdk.capture.model.NFCOptions; import java.util.ArrayList; import java.util.List; @@ -177,9 +179,12 @@ private void defaultSDKConfiguration(final ReadableMap config, Activity currentA } if (getBooleanFromConfig(config, "disableNFC")) { - onfidoConfigBuilder.disableNFC(); + onfidoConfigBuilder.withNFC(NFCOptions.Disabled.INSTANCE); } + NFCOptions nfcOption = getNFCOptionFromConfig(config); + onfidoConfigBuilder.withNFC(nfcOption); + OnfidoTheme onfidoTheme = getThemeFromConfig(config); if (onfidoTheme != null) { onfidoConfigBuilder.withTheme(onfidoTheme); @@ -249,6 +254,21 @@ public static OnfidoTheme getThemeFromConfig(final ReadableMap config) throws Ex return onfidoTheme; } + public static NFCOptions getNFCOptionFromConfig(final ReadableMap config) { + String nfcOptionString = config.getString("nfcOption"); + if (nfcOptionString == null) { + return NFCOptions.Enabled.Optional.INSTANCE; + } + switch (nfcOptionString) { + case "DISABLED": + return NFCOptions.Disabled.INSTANCE; + case "REQUIRED": + return NFCOptions.Enabled.Required.INSTANCE; + default: + return NFCOptions.Enabled.Optional.INSTANCE; + } + } + /* (!) Please note that flow steps must be presented in a specific order, one which is also implemented in the native SDKs, as well as in the iOS RN SDK. diff --git a/ios/OnfidoConfigBuilder.swift b/ios/OnfidoConfigBuilder.swift index 43ba111..01cd29a 100644 --- a/ios/OnfidoConfigBuilder.swift +++ b/ios/OnfidoConfigBuilder.swift @@ -80,13 +80,15 @@ struct OnfidoConfigBuilder { // NFC if let disableNFC = config.disableNFC, disableNFC == true { - builder.disableNFC() + builder.withNFC(.off) } // Localization if let localizationFile = try customLocalization(config: config) { builder.withCustomLocalization(andTableName: localizationFile) } + + builder.withNFC(nfcConfiguration(config: config)) // Media Callback if let mediaCallBack { @@ -228,6 +230,17 @@ struct OnfidoConfigBuilder { return config.localisation?.stringsFileName } + // MARK: - NFC Configurations + + private func nfcConfiguration(config: OnfidoPluginConfig) -> NFCConfiguration { + let nfcConfigurationMap: [OnfidoNFCOptions?: NFCConfiguration] = [ + OnfidoNFCOptions.disabled: .off, + OnfidoNFCOptions.optional: .optional, + OnfidoNFCOptions.required: .required + ] + return nfcConfigurationMap[config.nfcOption, default: .optional] + } + // MARK: - Helpers private func colorFrom(hex: String?, fallback: UIColor) -> UIColor { diff --git a/ios/OnfidoPluginConfig.swift b/ios/OnfidoPluginConfig.swift index 19a4324..f9d6dbe 100644 --- a/ios/OnfidoPluginConfig.swift +++ b/ios/OnfidoPluginConfig.swift @@ -14,6 +14,7 @@ struct OnfidoPluginConfig: Codable { let hideLogo: Bool? let logoCoBrand: Bool? let disableNFC: Bool? + let nfcOption: OnfidoNFCOptions? let disableMobileSdkAnalytics: Bool? } @@ -62,6 +63,12 @@ enum OnfidoCaptureType: String, Codable { case motion = "MOTION" } +enum OnfidoNFCOptions: String, Codable { + case disabled = "DISABLED" + case optional = "OPTIONAL" + case required = "REQUIRED" +} + struct OnfidoAppearanceConfig: Codable { let primaryColorHex: String? let primaryButtonTextColorHex: String? diff --git a/ios/OnfidoSdkTests/OnfidoSdkTests.swift b/ios/OnfidoSdkTests/OnfidoSdkTests.swift index 60d7008..1251c10 100644 --- a/ios/OnfidoSdkTests/OnfidoSdkTests.swift +++ b/ios/OnfidoSdkTests/OnfidoSdkTests.swift @@ -47,6 +47,7 @@ class OnfidoSdkTests : XCTestCase { hideLogo: nil, logoCoBrand: nil, disableNFC: nil, + nfcOption: nil, disableMobileSdkAnalytics: nil ), appearance: appearance, @@ -92,6 +93,7 @@ class OnfidoSdkTests : XCTestCase { hideLogo: nil, logoCoBrand: nil, disableNFC: nil, + nfcOption: nil, disableMobileSdkAnalytics: nil ), appearance: appearance, @@ -142,6 +144,7 @@ class OnfidoSdkTests : XCTestCase { hideLogo: nil, logoCoBrand: nil, disableNFC: nil, + nfcOption: nil, disableMobileSdkAnalytics: nil ), appearance: appearance, @@ -188,6 +191,7 @@ class OnfidoSdkTests : XCTestCase { hideLogo: nil, logoCoBrand: nil, disableNFC: nil, + nfcOption: nil, disableMobileSdkAnalytics: nil ), appearance: appearance, @@ -230,6 +234,7 @@ class OnfidoSdkTests : XCTestCase { hideLogo: nil, logoCoBrand: nil, disableNFC: nil, + nfcOption: nil, disableMobileSdkAnalytics: nil ), appearance: appearance, @@ -262,6 +267,7 @@ class OnfidoSdkTests : XCTestCase { hideLogo: nil, logoCoBrand: nil, disableNFC: nil, + nfcOption: nil, disableMobileSdkAnalytics: nil ), appearance: appearance, diff --git a/ios/PluginMetadata.m b/ios/PluginMetadata.m index 48b323d..ff52f88 100644 --- a/ios/PluginMetadata.m +++ b/ios/PluginMetadata.m @@ -13,7 +13,7 @@ - (instancetype)init self = [super init]; if (self) { _pluginPlatform = @"react-native"; - _pluginVersion = @"12.3.0"; + _pluginVersion = @"13.0.0"; } return self; } diff --git a/ios/Podfile b/ios/Podfile index cca8340..5200a8c 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -27,7 +27,7 @@ flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : Flip # end target 'OnfidoSdk' do - pod 'Onfido', '~> 30.3.0' + pod 'Onfido', '~> 30.4.0' config = use_native_modules! use_react_native!( diff --git a/js/config_constants.ts b/js/config_constants.ts index ac45844..5bb17c9 100644 --- a/js/config_constants.ts +++ b/js/config_constants.ts @@ -34,7 +34,11 @@ export type OnfidoConfig = { flowSteps: OnfidoFlowSteps; hideLogo?: boolean; logoCoBrand?: boolean; + /** + * @deprecated Deprecated. Use `nfcOption` parameter to manage NFC settings" + */ disableNFC?: boolean; + nfcOption?: OnfidoNFCOptions; disableMobileSdkAnalytics?: boolean; localisation?: { ios_strings_file_name?: string; @@ -97,6 +101,12 @@ export enum OnfidoTheme { AUTOMATIC = "AUTOMATIC" } +export enum OnfidoNFCOptions { + DISABLED = "DISABLED", + OPTIONAL = "OPTIONAL", + REQUIRED = "REQUIRED" +} + export type OnfidoFaceCapture = | OnfidoFaceSelfieCapture | OnfidoFaceVideoCapture diff --git a/onfido-react-native-sdk.podspec b/onfido-react-native-sdk.podspec index 9245282..65d651d 100644 --- a/onfido-react-native-sdk.podspec +++ b/onfido-react-native-sdk.podspec @@ -20,5 +20,5 @@ Pod::Spec.new do |s| s.requires_arc = true s.dependency "React" - s.dependency "Onfido", "~> 30.3.0" + s.dependency "Onfido", "~> 30.4.0" end diff --git a/package.json b/package.json index dd2dfd7..42031d8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@onfido/react-native-sdk", "title": "React Native Onfido Sdk", - "version": "12.3.0", + "version": "13.0.0", "description": "Onfido React Native SDK", "main": "index.ts", "scripts": {