@sicpa_open_source/didcomm-react-native v0.0.21
DIDComm React Native
Basic DIDComm v2 support for React Native framework (Android and iOS).
Under the hood
This package is React Native wrapper using DIDComm JVM library for Android and DIDComm Swift for iOS. It contains native modules that are using native libraries API and exposes Javascript/Typescript API using React Native bridge.
Design documentation for complex parts of implementation can be found in docs folder.
Usage
Install from npm:
npm install @sicpa_open_source/didcomm-react-nativeIf you need to use this package in another RN library:
- Please see: https://github.com/callstack/react-native-builder-bob#how-do-i-add-a-react-native-library-containing-native-code-as-a-dependency-in-my-library
- Note that you need to add this package as end application dependency in order to make native modules work
Add following DIDComm resolvers initialization code to your App (it's a workaround that will be removed later):
import { NativeModules, NativeEventEmitter } from 'react-native'
import { useEffect } from 'react'
import { DIDCommResolversProxy } from "@sicpa_open_source/didcomm-react-native"
const { DIDCommResolversProxyModule } = NativeModules
export default function App() {
useEffect(() => {
const nativeEventEmitter = new NativeEventEmitter(DIDCommResolversProxyModule)
DIDCommResolversProxy.start(nativeEventEmitter)
return () => DIDCommResolversProxy.stop()
},[])
return ...
}A general usage of the API is the following:
- Sender Side:
- Build a
Message(plaintext, payload). - Convert a message to a DIDComm Message for further transporting by calling one of the following:
Message.pack_encryptedto build an Encrypted DIDComm messageMessage.pack_signedto build a Signed DIDComm messageMessage.pack_plaintextto build a Plaintext DIDComm message
- Build a
- Receiver side:
- Call
Message.unpackon receiver side that will decrypt the message, verify signature if needed and return aMessagefor further processing on the application level.
- Call
Run demo
Android
yarn bootstrap
yarn demo androidiOS
On Intel Mac:
yarn bootstrap
cd ./demo/ios && pod install && cd ./../..
yarn demo iosOn M1 Mac:
yarn bootstrap
cd ./demo/ios && arch -x86_64 pod install && cd ./../..
arch -x86_64 yarn demo iosPublishing new version
Manually bump package version in package.json file.
The package will be published automatically from main branch by GitHub Actions.
Common issues
Duplicate class errors related to com.google.crypto.tink
Error message:
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable > Duplicate class com.google.crypto.tink.Aead found in modules jetified-tink-1.6.1 (com.google.crypto.tink:tink:1.6.1) and jetified-tink-android-1.5.0 (com.google.crypto.tink:tink-android:1.5.0) Duplicate class com.google.crypto.tink.BinaryKeysetReader found in modules jetified-tink-1.6.1 (com.google.crypto.tink:tink:1.6.1) and jetified-tink-android-1.5.0 (com.google.crypto.tink:tink-android:1.5.0) Duplicate class com.google.crypto.tink.BinaryKeysetWriter found in modules jetified-tink-1.6.1 (com.google.crypto.tink:tink:1.6.1) and jetified-tink-android-1.5.0 (com.google.crypto.tink:tink-android:1.5.0)Solution: Exclude
com.google.crypto.tink:tinkmodule from library native package using gradle configurationimplementation (project(":sicpa-dlab_didcomm-react-native")) { exclude(group: "com.google.crypto.tink", module: "tink") }