Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Latest commit

 

History

History
232 lines (162 loc) · 6.67 KB

README.md

File metadata and controls

232 lines (162 loc) · 6.67 KB

Indy SDK - Deprecated

logo

⚠️ Deprecation Notice ⚠️

The Indy SDK has been deprecated in favor of the Indy and Aries shared libraries. Please use the following libraries and projects to replace your use of the Indy SDK.

A module for interacting with the Indy Node ledger.

A secure (encrypted at rest) storage and a key management service suitable for use with Hyperledger Aries agents and possibly other digital trust agents. Askar is a replacement implementation (with lessons learned!) of the indy-wallet part of the Hyperledger Indy SDK. Askar has been demonstrated to be more performant and stable than the Indy SDK when under comparable load.

Rust library and reference implementation of the Anoncreds V1.0 specification. Supporting ledger agnostic anoncreds.

The a feature parity replacement for the indy-cli from the indy-sdk.

React Native Indy SDK

React Native Indy SDK wrapper.

Installation

with npm: $ npm install indy-sdk-react-native --save

with Yarn: $ yarn add indy-sdk-react-native

Link (for React Native lower than 0.60)

$ react-native link indy-sdk-react-native

Android

See https://github.com/TimoGlastra/ExampleRnIndySDK for an example android react native project that follows this tutorial.

1. Set min SDK version

Make sure there is a min. SDK version setup in android/build.gradle:

buildscript {
    ext {
        ...
        minSdkVersion = 21
        ...
    }
}

2. Add Sovrin Maven repository

Add Sovrin Maven repository into android/build.gradle:

allprojects {
    repositories {
        ...
        maven {
            url 'https://repo.sovrin.org/repository/maven-public'
        }
        ...
    }
}

3. Download Android libindy binaries

Download Android .aar library from Release 0.2.2 android-indy-sdk-release-device-1.15.0.aar and copy it into android/app/libs.

4. Update Gradle dependencies

Add .aar to array of file dependencies and JNA library to android/app/build.gradle:

dependencies {
    // ...

    implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
    implementation 'net.java.dev.jna:jna:5.6.0'

    // ...
}

I also needed to the gradle file android/app/build.gradle the following because I was getting duplicated class error:

android {
  // ...
  packagingOptions {
      pickFirst '**/lib/arm64-v8a/libc++_shared.so'
      pickFirst '**/lib/arm64-v8a/libfbjni.so'
      pickFirst '**/lib/armeabi-v7a/libc++_shared.so'
      pickFirst '**/lib/armeabi-v7a/libfbjni.so'
      pickFirst '**/lib/x86/libc++_shared.so'
      pickFirst '**/lib/x86/libfbjni.so'
      pickFirst '**/lib/x86_64/libc++_shared.so'
      pickFirst '**/lib/x86_64/libfbjni.so'
  }
}

5. Load indy library

Add the following to MainActivity.java:

//...

import android.os.Bundle;
import android.system.ErrnoException;
import android.system.Os;

public class MainActivity extends ReactActivity {
  //...

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
      Os.setenv("EXTERNAL_STORAGE", getExternalFilesDir(null).getAbsolutePath(), true);
    } catch (ErrnoException e) {
      e.printStackTrace();
    }
  }
}

6. Hermes

Hermes is required in order to perform ledger operations using the Indy SDK.

For more info, see this Indy-SDK issue.

React Native >= 0.70.0

Hermes is enabled by default

React Native 0.62.0 - 0.69.5

Add or adjust the following in the android/app/build.gradle to:

project.ext.react = [
    enableHermes: true,  // clean and rebuild if changing
]

React Native <= 0.61.5

Hermes is not required for older versions of React Native

iOS

  1. Add the following lines to the start of your Podfile (ios/Podfile).

If a custom source is defined we also need to define the default source (which is implicit if no source is specified), explicitly:

source 'https://github.com/hyperledger/indy-sdk-react-native'
source 'https://cdn.cocoapods.org'
  1. Install the Latest CocoaPods dependencies:
cd ios
pod install
pod update Indy
  1. Configure Bitcode to no in both the project and targets

  2. Set Build Libraries for Distribution to yes in both the project and targets

This is required due to mismatching Swift versions between the Indy SDK and the application, as described in this Stackoverflow Answer

  1. iOS Simulators are currently not supported and should be disabled

Usage

import indy from 'indy-sdk-react-native'

await indy.createWallet({ id: 'wallet-123' }, { key: 'key' })

You can see example project here https://github.com/jakubkoci/UseReactNativeIndySdk/. It currently shows only usage on Android.

Known Errors

Add setup of external storage permissions (Android)

I found an error with permission while calling createWallet when I was testing this package:

2020-01-27 16:25:02.300 9955-10044/com.usereactnativeindysdk E/log_panics: thread 'unnamed' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }': libcore/result.rs:945

Modify onCreate method in MainActivity of your project where you want to use this library in a following way:

public class MainActivity extends ReactActivity {
  ...
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    ...
    File externalFilesDir = getExternalFilesDir(null);
    String path = externalFilesDir.getAbsolutePath();
    System.out.println("externalFilesDir=" + path);

    try {
      Os.setenv("EXTERNAL_STORAGE", path, true);
    } catch (ErrnoException e) {
      e.printStackTrace();
    }
    ...
  }
  ...
}

This should resolve the issue with permissions.