From 647b1ff0fcee9f099a26affa438649fabfeb4be1 Mon Sep 17 00:00:00 2001 From: Dmitry Novotochinov Date: Fri, 30 Nov 2018 13:35:46 +0300 Subject: [PATCH] add install and init method --- .../ethereum/keycard/RNStatusKeycardModule.java | 17 +++++++++++++++++ .../im/status/ethereum/keycard/SmartCard.java | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/android/src/main/java/im/status/ethereum/keycard/RNStatusKeycardModule.java b/android/src/main/java/im/status/ethereum/keycard/RNStatusKeycardModule.java index 0bf3485..81639dd 100644 --- a/android/src/main/java/im/status/ethereum/keycard/RNStatusKeycardModule.java +++ b/android/src/main/java/im/status/ethereum/keycard/RNStatusKeycardModule.java @@ -191,4 +191,21 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements } } + @ReactMethod + public void installAppletAndInitCard(Promise promise) { + try { + SmartCardSecrets s = smartCard.installAppletAndInitCard(this.reactContext.getAssets(), "wallet.cap"); + + WritableMap params = Arguments.createMap(); + params.putString("pin", s.getPin()); + params.putString("puk", s.getPuk()); + params.putString("password", s.getPairingPassword()); + + promise.resolve(params); + } catch (IOException | APDUException | NoSuchAlgorithmException | InvalidKeySpecException e) { + Log.d(TAG, e.getMessage()); + promise.reject(e); + } + } + } \ No newline at end of file diff --git a/android/src/main/java/im/status/ethereum/keycard/SmartCard.java b/android/src/main/java/im/status/ethereum/keycard/SmartCard.java index ba6b6e8..b909604 100644 --- a/android/src/main/java/im/status/ethereum/keycard/SmartCard.java +++ b/android/src/main/java/im/status/ethereum/keycard/SmartCard.java @@ -357,4 +357,12 @@ public class SmartCard extends BroadcastReceiver implements CardListener { Installer installer = new Installer(this.cardChannel, assets, capPath); installer.start(); } + + public SmartCardSecrets installAppletAndInitCard(AssetManager assets, String capPath) throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException { + Installer installer = new Installer(this.cardChannel, assets, capPath); + installer.start(); + + return init(); + } + }