commit
26db8dfd25
|
@ -204,6 +204,21 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
|||
}).start();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void exportKeyWithPath(final String pairing, final String pin, final String path, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
promise.resolve(smartCard.exportKeyWithPath(pairing, pin, path));
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
@ReactMethod
|
||||
public void getKeys(final String pairing, final String pin, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
|
|
|
@ -110,9 +110,13 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
|||
boolean on = false;
|
||||
switch (state) {
|
||||
case NfcAdapter.STATE_ON:
|
||||
eventEmitter.emit("keyCardOnNFCEnabled", null);
|
||||
log("NFC ON");
|
||||
break;
|
||||
case NfcAdapter.STATE_OFF:
|
||||
eventEmitter.emit("keyCardOnNFCDisabled", null);
|
||||
log("NFC OFF");
|
||||
break;
|
||||
default:
|
||||
log("other");
|
||||
}
|
||||
|
@ -301,6 +305,24 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
|||
return Hex.toHexString(key);
|
||||
}
|
||||
|
||||
public String exportKeyWithPath(final String pairingBase64, final String pin, final String path) throws IOException, APDUException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
cmdSet.select().checkOK();
|
||||
|
||||
Pairing pairing = new Pairing(pairingBase64);
|
||||
cmdSet.setPairing(pairing);
|
||||
|
||||
cmdSet.autoOpenSecureChannel();
|
||||
Log.i(TAG, "secure channel opened");
|
||||
|
||||
cmdSet.verifyPIN(pin).checkOK();
|
||||
Log.i(TAG, "pin verified");
|
||||
|
||||
byte[] key = BIP32KeyPair.fromTLV(cmdSet.exportKey(path, false, true).checkOK().getData()).getPublicKey();
|
||||
|
||||
return Hex.toHexString(key);
|
||||
}
|
||||
|
||||
public WritableMap getKeys(final String pairingBase64, final String pin) throws IOException, APDUException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
cmdSet.select().checkOK();
|
||||
|
|
|
@ -11,10 +11,12 @@ import Keycard from "react-native-status-keycard";
|
|||
```javascript
|
||||
import { DeviceEventEmitter } from 'react-native';
|
||||
|
||||
// Listen to connect/disconnect events
|
||||
// Listen to connect/disconnect and nfc events
|
||||
componentDidMount () {
|
||||
DeviceEventEmitter.addListener("keyCardOnConnected", () => console.log("keycard connected"));
|
||||
DeviceEventEmitter.addListener("keyCardOnDisconnected", () => console.log("keycard disconnected"));
|
||||
DeviceEventEmitter.addListener("keyCardOnNFCEnabled", () => console.log("nfc enabled"));
|
||||
DeviceEventEmitter.addListener("keyCardOnNFCDisabled", () => console.log("nfc disabled"));
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "react-native-status-keycard",
|
||||
"homepage": "https://keycard.status.im/",
|
||||
"version": "2.5.15",
|
||||
"version": "2.5.17",
|
||||
"description": "React Native library to interact with Status Keycard using NFC connection (Android only)",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue