Add exportKeyWithPath() fn
This commit is contained in:
parent
29fe98beb3
commit
73c41d1a3d
|
@ -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() {
|
||||
|
|
|
@ -299,6 +299,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();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "react-native-status-keycard",
|
||||
"homepage": "https://keycard.status.im/",
|
||||
"version": "2.5.15",
|
||||
"version": "2.5.16",
|
||||
"description": "React Native library to interact with Status Keycard using NFC connection (Android only)",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue