Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16361239a5 | ||
|
|
441ea2d5ac |
@@ -244,4 +244,26 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}).start();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void verifyPin(final String pairing, final String pin, final Promise promise) {
|
||||
try {
|
||||
smartCard.verifyPin(pairing, pin);
|
||||
promise.resolve(true);
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void changePin(final String pairing, final String currentPin, final String newPin, final Promise promise) {
|
||||
try {
|
||||
smartCard.changePin(pairing, currentPin, newPin);
|
||||
promise.resolve(true);
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -367,4 +367,27 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
return init();
|
||||
}
|
||||
|
||||
public KeycardCommandSet verifyPin(final String pairingBase64, final String pin) 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");
|
||||
|
||||
return cmdSet;
|
||||
}
|
||||
|
||||
public void changePin(final String pairingBase64, final String currentPin, final String newPin) throws IOException, APDUException {
|
||||
KeycardCommandSet cmdSet = verifyPin(pairingBase64, currentPin);
|
||||
|
||||
cmdSet.changePIN(0, newPin);
|
||||
Log.i(TAG, "pin changed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
{
|
||||
"name": "react-native-status-keycard",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "React Native library to interact with Status Keycard using NFC connection (Android only)",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user