About this Project • Requirements • Getting Started • Usage • Support, Feedback, Contributing • Code of Conduct • Licensing
This library wraps and asyncifies the AusweisApp SDK by Governikus and enables react-native apps to support eID verification of German documents with NFC. The communication with the SDK is done by sending 'Commands' and reacting to 'Messages'. To orchestrate and simplify the API with the SDK through async functions, RxJS is used as a core driver of this library.
To use this library, at least the following requirements have to be fulfilled:
- iOS 14.0
- Android 8 and SDK version 26
To add the library to your project, do the following:
- Add react-native-ausweisapp2-wrapper to your project
$ yarn add react-native-ausweisapp2-wrapper
- Prepare Cocoapod dependency
$ pod install
- Add the following to your android/app/build.gradle:
android {
...
defaultConfig {
...
packagingOptions {
// Fixes build error: 2 files found with path 'lib/arm64-v8a/libc++_shared.so'
pickFirst "lib/arm64-v8a/libc++_shared.so"
// Needed for aab (Android App Bundle) creation.
// The AusweisApp SDK will not work correctly without it
// See also https://www.ausweisapp.bund.de/sdk/android.html#app-bundle
jniLibs { useLegacyPackaging = true }
}
See also https://www.ausweisapp.bund.de/sdk/android.html#app-bundle
The current AA2 SDK supports only 64-bit devices. The AA2 SDK does not work with 32-bit devices like the Samsung A13. Using the SDK on these devices leads to the error com.governikus.ausweisapp2.AidlBinder.resetValidSessionID
- Add those lines to your android/app/src/main/AndroidManifest.xml:
<manifest ... >
<uses-permission android:name="android.permission.NFC"/>
<uses-feature android:name="android.hardware.nfc" android:required="false" />
...
See also https://developer.android.com/guide/topics/connectivity/nfc/nfc#manifest
- Add the following lines to your ios/cultureapp/Info.plist:
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>E80704007F00070302</string>
</array>
<key>NFCReaderUsageDescription</key>
<string>AusweisApp needs NFC to access the ID card.</string>
See also https://www.ausweisapp.bund.de/sdk/ios.html#info-plist
- Add an entitlement file to your app, with the following content or enable the Near Field Communication Tag Reading capability in Xcode.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>TAG</string>
</array>
</dict>
</plist>
See also https://www.ausweisapp.bund.de/sdk/ios.html#entitlements and https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_nfc_readersession_formats
There are two main components used for interacting with the SDK. The CommandService, is used for basic functionality, such as starting and stopping the SDK and sending Commands to it. The WorkflowHelper, handles abstractions for the general identification workflow and adds other functionality that is not provided by the SDK (i.e. checking if NFC is enabled on Android).
To start the SDK, CommandService.start
has to be called. To initialize the SDK and setup logging in one step, the WorkflowHelper.initializeAA2Sdk
function is used.
Example:
WorkflowHelper.initializeAA2Sdk(true, 2)
Stopping the SDK and NFC capability is done by calling the CommandService.stop
method. This is also done when the application is reloaded by metro.
With the CommandService
Commands can be sent to the SDK. Commands that expect a Message as a response, are async functions that can be awaited.
Example:
async () {
const info = await CommandService.getInfo()
return info
}
In this case, we return the Info Message that will be sent as a reply by the AusweisApp SDK.
Some Commands need additional data to be sent to the SDK. The data is always provided using parameters.
async () {
const reader = await CommandService.getReader("NFC")
return reader
}
Optionally each command supports providing an options object as the last parameter that is used to configure the command. Currently only a milliseconds timeout is supported via msTimeout
. This timeout is used for the maximum time that an async function waits for its Message response. If no Message response is provided in that time, a TimeoutError
is thrown.
For examples on how to a basic identification flow works, have a look at https://www.ausweisapp.bund.de/sdk/workflow.html
Example of the wrapper usage you can find here: https://github.com/kulturpass-de/kulturpass-app/blob/main/src/features/eid-verification/services/eid-ausweisapp2-service.ts
Deactivated cards are handled the same as error Messages. Commands such as accept
on the CommandService
will throw a Reader
Message if a deactivated card is detected. To handle Reader
Messages with deactivated cards asynchonously, use the handleError
callback on the WorkflowService
or filter Messages on the AA2MessageObservable
itself.
This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.
Copyright 2023 SAP SE or an SAP affiliate company and kulturpass-app contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.