Skip to content

Commit

Permalink
v7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Flutter SDK Release User committed Aug 5, 2024
1 parent 9b16d02 commit 0b9d3fb
Show file tree
Hide file tree
Showing 29 changed files with 151 additions and 44 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ 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).

## [7.0.0] - 2024-07-29
- Bumped Android target SDK version to 34. This update indirectly means that Java version 17 is required to build the project. Details: https://developer.android.com/build/jdks
- Added `nfcOption` parameter for configuring NFC
- Added missing detail property to platform exceptions caused by flow errors
- Deprecated `disableNFC` parameter (Use `nfcOption` with `NFCOptions.Disabled` value instead)
- Updated underlying Onfido native SDK versions:
- Android 21.0.+ (up from 20.5.+)
- iOS 30.4.+ (up from 30.3.+)

## [6.2.0] - 2024-07-11

- Align with SDK requirements for minimum support for iOS 13+
Expand Down
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ From version 4.0.0 onwards, NFC is enabled by default for the Flutter SDK and of

For more information on how to configure NFC and the list of supported documents, please refer to the [NFC for Document Report](https://documentation.onfido.com/guide/document-report-nfc) guide.

#### Disabling NFC
#### Disabling NFC and excluding dependencies

NFC is enabled by default. To disable NFC, include the `disableNFC` parameter while configuring the `onfido` [initialization object](#build-a-configuration-object).
NFC is enabled by default. To disable NFC, include the `nfcOption` parameter with `NFCOptions.Disabled` while configuring the `onfido` [initialization object](#build-a-configuration-object).

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:

Expand Down Expand Up @@ -143,16 +143,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, a new token must be generated each time you initialize the Flutter SDK.

| Parameter | Notes |
|------|------|
| `applicant_id` | **required** <br /> Specifies the applicant for the SDK instance. |
| `application_id` | **required** <br /> 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`. Make sure to use a valid `application_id` or you'll receive a 401 error. |
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).

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.

Expand Down Expand Up @@ -180,8 +173,12 @@ final Onfido onfido = Onfido(
and instead set a theme statically at the build time. In this case, the flow will always be in displayed
in the selected theme regardless of the user's device theme.
* Valid values in `OnfidoTheme`: `AUTOMATIC`, `LIGHT`, `DARK`.

* **`disableNFC`**: **Optional**. Set this parameter to `true` to disable NFC.
* **DEPRECATED**. Use `nfcOption` parameter to manage NFC settings
* **`nfcOption`**: **Optional**. To configure NFC. There are three NFC options:
* `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

### Start the flow

Expand Down Expand Up @@ -317,6 +314,21 @@ While building the configuration object is done in exactly the same way as [docu

**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, a new token must be generated each time you initialize the Flutter SDK.

| Parameter | Notes |
|------|------|
| `applicant_id` | **required** <br /> Specifies the applicant for the SDK instance. |
| `application_id` | **required** <br /> 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. |

It's important to note that manually generated SDK tokens in Flutter 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 starting the flow

```dart
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group 'com.onfido.sdk.flutter'
version '1.0'

def onfidoSdkVersion = '20.5.+'
def onfidoSdkVersion = '21.0.+'

buildscript {
ext.kotlin_version = '1.6.10'
Expand All @@ -12,7 +12,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -28,7 +28,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 32
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta-data
android:name="onfido_integration_version"
android:value="6.2.0" />
android:value="7.0.0" />

</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.onfido.sdk.flutter.serializer

import com.onfido.android.sdk.capture.model.NFCOptions
import com.onfido.android.sdk.capture.model.NFCOptions.Disabled
import com.onfido.android.sdk.capture.model.NFCOptions.Enabled.Optional
import com.onfido.android.sdk.capture.model.NFCOptions.Enabled.Required

internal fun getNFCOption(nfcOption: String): NFCOptions {
val nfcOptionsMap = mapOf(
"DISABLED" to Disabled,
"OPTIONAL" to Optional,
"REQUIRED" to Required
)
return nfcOptionsMap.getOrDefault(nfcOption, Optional)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.onfido.android.sdk.capture.ui.options.FlowStep
import com.onfido.android.sdk.capture.ui.options.stepbuilder.DocumentCaptureStepBuilder
import com.onfido.sdk.flutter.helpers.CustomMediaCallback
import io.flutter.embedding.engine.plugins.FlutterPlugin
import com.onfido.android.sdk.capture.model.NFCOptions

internal fun Any?.deserializeOnfidoBuilder(
context: Context,
Expand Down Expand Up @@ -94,7 +95,12 @@ internal fun Any?.deserializeOnfidoBuilder(
builder.withEnterpriseFeatures(features)

if (this["disableNFC"] as? Boolean == true) {
builder.disableNFC()
builder.withNFC(NFCOptions.Disabled)
}

val nfcOption = this["nfcOption"] as? String
if (nfcOption != null) {
builder.withNFC(getNFCOption(nfcOption))
}

val withMediaCallback = this["shouldUseMediaCallback"] as? Boolean ?: false
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ android {
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand All @@ -59,6 +59,7 @@ android {
signingConfig signingConfigs.debug
}
}
packagingOptions.resources.excludes += "META-INF/versions/9/OSGI-INF/MANIFEST.MF"
}

flutter {
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
1 change: 0 additions & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ PODS:
- fluttertoast (0.0.2):
- Flutter
- Toast
- Onfido (30.3.0)
- Onfido (30.4.0)
- onfido_sdk (0.0.1):
- Flutter
- Onfido (~> 30.3.0)
- Onfido (~> 30.4.0)
- Toast (4.0.0)
- webview_flutter_wkwebview (0.0.1):
- Flutter
Expand Down
40 changes: 29 additions & 11 deletions example/lib/classic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _OnfidoClassicState extends State<OnfidoClassic> {
bool _welcomeStep = true;
bool _proofOfAddressStep = false;

bool _disableNFC = false;
NFCOptions _nfcOption = NFCOptions.OPTIONAL;

bool _enableDocCapture = false;
DocumentTypes _documentType = DocumentTypes.nationalIdentityCard;
Expand Down Expand Up @@ -64,7 +64,7 @@ class _OnfidoClassicState extends State<OnfidoClassic> {
enterpriseFeatures: EnterpriseFeatures(
hideOnfidoLogo: _hideOnfidoLogo,
),
disableNFC: _disableNFC,
nfcOption: _nfcOption,
onfidoTheme: _onfidoTheme);

final response = await onfido.start(
Expand Down Expand Up @@ -180,15 +180,26 @@ class _OnfidoClassicState extends State<OnfidoClassic> {
});
},
),
LabeledCheckbox(
label: 'Disable NFC',
value: _disableNFC,
onChanged: (bool newValue) {
setState(() {
_disableNFC = newValue;
});
},
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text("NFC Options"),
ElevatedButton(
child: Row(
children: [
Text(_nfcOption.name),
const SizedBox(width: 6),
const Icon(Icons.arrow_drop_down, color: Colors.white),
],
),
onPressed: () async => {showNFCOptionsPicker(context)},
),
],
)
])),
LabeledCheckbox(
label: 'Use custom media callbacks',
value: _withMediaCallback,
Expand Down Expand Up @@ -441,6 +452,13 @@ class _OnfidoClassicState extends State<OnfidoClassic> {
});
}

showNFCOptionsPicker(BuildContext context) {
_showPickerDialog(NFCOptions.values.map((e) => e.name).toList(), NFCOptions.values.indexOf(_nfcOption),
(selectedItem) {
_nfcOption = NFCOptions.values[selectedItem];
});
}

showDocumentPicker(BuildContext context) {
_showPickerDialog(DocumentTypes.values.map((e) => e.name).toList(), DocumentTypes.values.indexOf(_documentType),
(selectedItem) {
Expand Down
10 changes: 10 additions & 0 deletions ios/Classes/Bridge/BaseBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@

import Foundation
import Flutter
import Onfido

protocol BaseBridge {
var name: String { get }

func invoke(_ call: FlutterMethodCall, _ result: @escaping FlutterResult)
}

extension BaseBridge {
static func extractDetails(from error: Error) -> String? {
// In case we receive a `OnfidoFlowError`, we want to include more details about the underlying
// error in the `FlutterError`. In any other case, we only care about the error's localized description.
guard let flowError = error as? OnfidoFlowError else { return nil }
return String(describing: error)
}
}
3 changes: 2 additions & 1 deletion ios/Classes/Bridge/StartBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ struct StartBridge: BaseBridge {
result(serialized)

case .error(let error):
result(FlutterError(code: "error", message: error.localizedDescription, details: nil))
let errorDetails = StartBridge.extractDetails(from: error)
result(FlutterError(code: "error", message: error.localizedDescription, details: errorDetails))

case .cancel:
result(FlutterError(code: "exit", message: "User canceled the flow", details: nil))
Expand Down
3 changes: 2 additions & 1 deletion ios/Classes/Bridge/StartStudioBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ struct StartStudioBridge: BaseBridge {
result(serialized)

case .error(let error):
result(FlutterError(code: "error", message: error.localizedDescription, details: nil))
let errorDetails = StartBridge.extractDetails(from: error)
result(FlutterError(code: "error", message: error.localizedDescription, details: errorDetails))

case .cancel:
result(FlutterError(code: "exit", message: "User canceled the flow", details: nil))
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/PluginMetadata.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ - (instancetype)init
self = [super init];
if (self) {
_pluginPlatform = @"flutter";
_pluginVersion = @"6.2.0";
_pluginVersion = @"7.0.0";
}
return self;
}
Expand Down
10 changes: 10 additions & 0 deletions ios/Classes/Serializer/NFCOptionsSerializer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Onfido

func getNFCConfiguration(_ nfcOption: String) -> NFCConfiguration {
let nfcConfigurationMap: [String: NFCConfiguration] = [
"DISABLED": .off,
"OPTIONAL": .optional,
"REQUIRED": .required
]
return nfcConfigurationMap[nfcOption, default: .optional]
}
6 changes: 5 additions & 1 deletion ios/Classes/Serializer/OnfidoBuilderSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ extension OnfidoConfig {
}

if let disableNFC = dictionary["disableNFC"] as? Bool, disableNFC {
onfidoBuilder.disableNFC()
onfidoBuilder.withNFC(.off)
}

if let nfcOption = dictionary["nfcOption"] as? String {
onfidoBuilder.withNFC(getNFCConfiguration(nfcOption))
}

if let shouldUseMediaCallback = dictionary["shouldUseMediaCallback"] as? Bool, shouldUseMediaCallback {
Expand Down
2 changes: 1 addition & 1 deletion ios/onfido_sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.dependency 'Onfido', '~> 30.3.0'
s.dependency 'Onfido', '~> 30.4.0'
s.platform = :ios, '13.0'

# Flutter.framework does not contain a i386 slice.
Expand Down
1 change: 1 addition & 0 deletions lib/src/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export 'package:onfido_sdk/src/model/cobranding_logo.dart';
export 'package:onfido_sdk/src/model/ios_appearance.dart';
export 'package:onfido_sdk/src/model/onfido_theme.dart';
export 'package:onfido_sdk/src/model/background_color.dart';
export 'package:onfido_sdk/src/model/nfc_options.dart';
3 changes: 3 additions & 0 deletions lib/src/model/nfc_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// ignore_for_file: constant_identifier_names

enum NFCOptions { DISABLED, OPTIONAL, REQUIRED }
Loading

0 comments on commit 0b9d3fb

Please sign in to comment.