Giter Club home page Giter Club logo

react-native-status-keycard's Introduction

React Native Status Keycard npm version

React Native library to interact with Keycard using Java SDK

Getting started

$ npm install react-native-status-keycard --save

Mostly automatic installation

$ react-native link react-native-status-keycard

Manual installation

Android is the only platform supported by now.

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import im.status.ethereum.keycard.RNStatusKeycardPackage; to the imports at the top of the file
  • Add new RNStatusKeycardPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:

    include ':react-native-status-keycard'
    project(':react-native-status-keycard').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-status-keycard/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

      compile project(':react-native-status-keycard')
    
  3. Add <uses-permission android:name="android.permission.NFC"/> to android/app/src/main/AndroidManifest.xml to enable NFC permission.

  4. Make sure minSdkVersion is 18 in android/build.gradle.

Usage

Take a look into docs

For more usage examples, please refer to https://github.com/status-im/status-react (assuming you can read Clojure)

For Keycard API documention, please look into https://status.im/keycard_api/

react-native-status-keycard's People

Contributors

bitgamma avatar dmitryn avatar gravityblast avatar lew avatar rasom avatar woosang-kim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-status-keycard's Issues

Remove dependency on BouncyCastle

As far as I can tell we are pulling a big dependency in the form of BouncyCastle:

implementation 'org.bouncycastle:bcprov-jdk15on:1.60'

Purely because we use Hex.decode() and Hex.toHexString() in this library:

cmdSet.installNDEFApplet(Hex.decode("0024d40f12616e64726f69642e636f6d3a706b67696d2e7374617475732e657468657265756d")).checkOK();

String instanceUID = Hex.toHexString(info.getInstanceUID());
Log.i(TAG, "Instance UID: " + instanceUID);
Log.i(TAG, "Key UID: " + Hex.toHexString(info.getKeyUID()));

Seems silly to pull such a massive library just for decoding/encoding a hex.

Supersedes:

Help, would love to chat.

Hello,
I am working on a project with the Ethereum Foundation where we do something similar to this. I was wondering if anyone would be willing to connect and share some knowledge or pitfalls around the React Native implementation.

Can not build RN app with react-native-status-keycard

When trying to build fresh new React native app with installed and linked keycard package, I am getting the following errors:

Could not determine the dependencies of task ':app:preDebugBuild'. Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'. Could not find com.github.status-im.status-keycard-java:android:2.2.1. Searched in the following locations: ............... Required by: project :app > project :react-native-status-keycard

I tried both automated and manual linking according to Readme.
I then added jitpack to the repositories section in android/build.gradle file, and looks like build move forward, however I got another error I am unable to solve:

Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 D:\pathtoproject\android\app\build\generated\rncli\src\main\java\com\facebook\react\PackageList.java:17: error: cannot find symbol import com.reactlibrary.RNStatusKeycardPackage;

Looks like expected com.reactlibrary.RNStatusKeycardPackage is different namespace then what is mentioned to be imported in the manual installation docs (im.status.ethereum.keycard.RNStatusKeycardPackage) or might there be another issues in my setup I can not grasp? Help appreciated.

Change error handling in getApplicationInfo

at the moment, the Java SDK throws an IOException when autoOpenSecureChannel or autoPair fails. This is the same exception throw when connection to the card fails.

In getApplicationInfo this exception is caught in order to determine if the pairing is valid or not but no distinction is made between invalid authentication and connection lost. After updating the SDK to separate pure IO errors from unexpected card responses, these two cases can be handled independently.

if an IOException is thrown, it is let bubble up to status-react, which should interpret it as connection lost (and probably just prompt the user again to connect the card)

only if an APDUException is thrown during openSecureChannel, getApplicationInfo's current behavior will apply (catching and setting "paired?" to false). This should then be interpreted as missing or invalid pairing. In that case the puk and pin retry counters won't be available, because they are only retrievable after opening a secure channel.

The changes to this component are not complex, however implementing them changes the behaviour under error conditions of

  • getApplicationInfo
  • pair

pair will also automatically gain a differentiation between card connection lost and invalid pairing by throwing IOException and APDUException respectively. This can be used in status-react to react differently to these error conditions.

Because of these changes in behavior, the error scenarios involving these two methods should be tested again to make sure the approriate behavior still applies.

Packages aren't published

I've tried to install the package with npm and the react-native CLI.

commands:

react-native link react-native-status-keycard

npm install react-native-status-keycard --save

Both packages couldn't be found.

Unable to pair with password

I am getting following error while trying to invoke "pair" function

[Error: Invalid card cryptogram]

I have verified the password which i am passing as argument to pair functions but it gives same error.
Is there any possible reason as i read in the documentation that keycard can be paired with 5 devices but right now it is not working apart from Status.im app.

Note: i am having Status.im app and the other app with which i am trying to pair on the same phone .

unable to build Android app

while trying to build android app with react native status keycard , i am getting following errors

/react/PackageList.java:60: error: cannot find symbol
import com.reactlibrary.RNStatusKeycardPackage;
^
symbol: class RNStatusKeycardPackage
location: package com.reactlibrary
/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:131: error: cannot find symbol
new RNStatusKeycardPackage(),
^
symbol: class RNStatusKeycardPackage
location: class PackageList
2 errors

FAILURE: Build failed with an exception.

However changing package import manually works but it shouldn't be like this. Ideally it should generate and link packages properly . I have followed all the steps mentioned in the page documentation but still the error doesnt seem to go away.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.