Compare commits
45
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4f039dbee | ||
|
|
6cbb7f902b | ||
|
|
0b72d359e5 | ||
|
|
fdf2f0e50a | ||
|
|
182dd2b524 | ||
|
|
5a4e9206bb | ||
|
|
033b43f583 | ||
|
|
b495513a09 | ||
|
|
77781391ec | ||
|
|
9db4993920 | ||
|
|
e55c0ef1f8 | ||
|
|
69b84e8c99 | ||
|
|
8f5534a899 | ||
|
|
4ba5e8a771 | ||
|
|
aef6461e32 | ||
|
|
f1f61d8ab2 | ||
|
|
58c9e8e8df | ||
|
|
f2dda77c81 | ||
|
|
348fc01041 | ||
|
|
d9ccdd6a7d | ||
|
|
7b1e6cce65 | ||
|
|
b9a66144b3 | ||
|
|
8032e1c30f | ||
|
|
56069b4b07 | ||
|
|
7f416b0380 | ||
|
|
8cf3cf5785 | ||
|
|
a6da0a7889 | ||
|
|
97de3e6066 | ||
|
|
d6378e434f | ||
|
|
d7854a33bb | ||
|
|
e0448b0960 | ||
|
|
c7a37ffef8 | ||
|
|
9e6df66bfd | ||
|
|
c8b803ab07 | ||
|
|
0bc6dcd93c | ||
|
|
f6fe495046 | ||
|
|
45ca4d49e5 | ||
|
|
8b6fb829bd | ||
|
|
a15dbca837 | ||
|
|
04b0fb6fcb | ||
|
|
2d15fd6d50 | ||
|
|
fcd50896c0 | ||
|
|
4c2aada5dc | ||
|
|
2dffe6aae4 | ||
|
|
0dfa0ecee6 |
@@ -1,5 +1,8 @@
|
||||
|
||||
# react-native-status-keycard
|
||||
# React Native Status Keycard [](https://badge.fury.io/js/react-native-status-keycard)
|
||||
|
||||
React Native library to interact with [Keycard](https://keycard.status.im/) using [Java SDK](https://github.com/status-im/status-keycard-java)
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
@@ -11,18 +14,12 @@
|
||||
|
||||
### Manual installation
|
||||
|
||||
|
||||
#### iOS
|
||||
|
||||
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
|
||||
2. Go to `node_modules` ➜ `react-native-status-keycard` and add `RNStatusKeycard.xcodeproj`
|
||||
3. In XCode, in the project navigator, select your project. Add `libRNStatusKeycard.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
|
||||
4. Run your project (`Cmd+R`)<
|
||||
Android is the only platform supported by now.
|
||||
|
||||
#### Android
|
||||
|
||||
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
|
||||
- Add `import com.reactlibrary.RNStatusKeycardPackage;` to the imports at the top of the file
|
||||
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
|
||||
2. Append the following lines to `android/settings.gradle`:
|
||||
```
|
||||
@@ -33,21 +30,15 @@
|
||||
```
|
||||
compile project(':react-native-status-keycard')
|
||||
```
|
||||
4. Add `<uses-permission android:name="android.permission.NFC"/>` to `android/app/src/main/AndroidManifest.xml` to enable NFC permission.
|
||||
|
||||
#### Windows
|
||||
[Read it! :D](https://github.com/ReactWindows/react-native)
|
||||
|
||||
1. In Visual Studio add the `RNStatusKeycard.sln` in `node_modules/react-native-status-keycard/windows/RNStatusKeycard.sln` folder to their solution, reference from their app.
|
||||
2. Open up your `MainPage.cs` app
|
||||
- Add `using Status.Keycard.RNStatusKeycard;` to the usings at the top of the file
|
||||
- Add `new RNStatusKeycardPackage()` to the `List<IReactPackage>` returned by the `Packages` method
|
||||
|
||||
5. Make sure `minSdkVersion` is 18 in `android/build.gradle`.
|
||||
|
||||
## Usage
|
||||
```javascript
|
||||
import RNStatusKeycard from 'react-native-status-keycard';
|
||||
|
||||
// TODO: What to do with the module?
|
||||
RNStatusKeycard;
|
||||
```
|
||||
Take a look into [docs](./docs/usage.md)
|
||||
|
||||
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/
|
||||
|
||||
@@ -39,6 +39,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation 'com.facebook.react:react-native:+'
|
||||
implementation 'com.madgag.spongycastle:core:1.58.0.0'
|
||||
implementation 'com.github.status-im.status-keycard-java:android:2.0.0'
|
||||
implementation 'org.bouncycastle:bcprov-jdk15on:1.60'
|
||||
implementation 'org.apache.commons:commons-lang3:3.9'
|
||||
implementation 'com.github.status-im.status-keycard-java:android:2.2.1'
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -23,7 +23,7 @@ import im.status.keycard.io.APDUException;
|
||||
|
||||
public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
|
||||
private static final String TAG = "StatusKeycard";
|
||||
private static final String CAP_FILENAME = "keycard.cap";
|
||||
private static final String CAP_FILENAME = "keycard_v2.2.1.cap";
|
||||
private SmartCard smartCard;
|
||||
private final ReactApplicationContext reactContext;
|
||||
|
||||
@@ -42,6 +42,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
public void onHostResume() {
|
||||
if (this.smartCard == null) {
|
||||
this.smartCard = new SmartCard(getCurrentActivity(), reactContext);
|
||||
smartCard.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,24 +81,11 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void start(final Promise promise) {
|
||||
if (smartCard != null) {
|
||||
if (smartCard.start()) {
|
||||
promise.resolve(true);
|
||||
} else {
|
||||
promise.reject("Error", "Not supported on this device");
|
||||
}
|
||||
} else {
|
||||
promise.reject("Error", "smartCard is not initialized yet");
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void init(final Promise promise) {
|
||||
public void init(final String pin, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
SmartCardSecrets s = smartCard.init();
|
||||
SmartCardSecrets s = smartCard.init(pin);
|
||||
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putString("pin", s.getPin());
|
||||
@@ -131,11 +119,11 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void generateMnemonic(final String pairing, final Promise promise) {
|
||||
public void generateMnemonic(final String pairing, final String words, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
promise.resolve(smartCard.generateMnemonic(pairing));
|
||||
promise.resolve(smartCard.generateMnemonic(pairing, words));
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
@@ -218,6 +206,20 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}).start();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sign(final String pairing, final String pin, final String hash, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
promise.resolve(smartCard.sign(pairing, pin, hash));
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void installApplet(final Promise promise) {
|
||||
final ReactContext ctx = this.reactContext;
|
||||
@@ -235,12 +237,12 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void installAppletAndInitCard(final Promise promise) {
|
||||
public void installAppletAndInitCard(final String pin, final Promise promise) {
|
||||
final ReactContext ctx = this.reactContext;
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
SmartCardSecrets s = smartCard.installAppletAndInitCard(ctx.getAssets(), CAP_FILENAME);
|
||||
SmartCardSecrets s = smartCard.installAppletAndInitCard(pin, ctx.getAssets(), CAP_FILENAME);
|
||||
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putString("pin", s.getPin());
|
||||
@@ -311,6 +313,28 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void removeKey(final String pairing, final String pin, final Promise promise) {
|
||||
try {
|
||||
smartCard.removeKey(pairing, pin);
|
||||
promise.resolve(true);
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void removeKeyWithUnpair(final String pairing, final String pin, final Promise promise) {
|
||||
try {
|
||||
smartCard.removeKeyWithUnpair(pairing, pin);
|
||||
promise.resolve(true);
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void unpairAndDelete(final String pairing, final String pin, final Promise promise) {
|
||||
try {
|
||||
|
||||
@@ -15,10 +15,14 @@ import android.util.Log;
|
||||
import com.facebook.react.bridge.*;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
import im.status.keycard.applet.RecoverableSignature;
|
||||
import im.status.keycard.globalplatform.GlobalPlatformCommandSet;
|
||||
import im.status.keycard.io.APDUException;
|
||||
import im.status.keycard.io.CardChannel;
|
||||
@@ -32,7 +36,7 @@ import im.status.keycard.applet.Pairing;
|
||||
import im.status.keycard.applet.ApplicationInfo;
|
||||
import im.status.keycard.applet.KeyPath;
|
||||
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
|
||||
public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
private NFCCardManager cardManager;
|
||||
@@ -42,10 +46,12 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
private CardChannel cardChannel;
|
||||
private EventEmitter eventEmitter;
|
||||
private static final String TAG = "SmartCard";
|
||||
private Boolean started = false;
|
||||
|
||||
private static final String WALLET_PATH = "m/44'/0'/0'/0/0";
|
||||
private static final String WALLET_PATH = "m/44'/60'/0'/0/0";
|
||||
private static final String WHISPER_PATH = "m/43'/60'/1581'/0'/0";
|
||||
private static final String ENCRYPTION_PATH = "m/43'/60'/1581'/1'/0";
|
||||
private static final int WORDS_LIST_SIZE = 2048;
|
||||
|
||||
public SmartCard(Activity activity, ReactContext reactContext) {
|
||||
this.cardManager = new NFCCardManager();
|
||||
@@ -65,15 +71,22 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
this.cardManager.start();
|
||||
if (this.nfcAdapter != null) {
|
||||
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
|
||||
activity.registerReceiver(this, filter);
|
||||
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
|
||||
return true;
|
||||
if (!started) {
|
||||
|
||||
this.cardManager.start();
|
||||
started = true;
|
||||
|
||||
if (this.nfcAdapter != null) {
|
||||
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
|
||||
activity.registerReceiver(this, filter);
|
||||
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
|
||||
return true;
|
||||
} else {
|
||||
log("not support in this device");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
log("not support in this device");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +98,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
eventEmitter.emit( "keyCardOnDisconnected", null);
|
||||
eventEmitter.emit("keyCardOnDisconnected", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,13 +127,13 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
}
|
||||
}
|
||||
|
||||
public SmartCardSecrets init() throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
public SmartCardSecrets init(final String userPin) throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
cmdSet.select().checkOK();
|
||||
|
||||
eventEmitter.emit("keycardInstallationProgress", 0.90);
|
||||
|
||||
SmartCardSecrets s = SmartCardSecrets.generate();
|
||||
SmartCardSecrets s = SmartCardSecrets.generate(userPin);
|
||||
|
||||
eventEmitter.emit("keycardInstallationProgress", 0.93);
|
||||
|
||||
@@ -133,12 +146,12 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
|
||||
public String pair(String pairingPassword) throws IOException, APDUException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
log("Pairing password: " + pairingPassword);
|
||||
Log.i(TAG, "Applet selection successful");
|
||||
|
||||
// First thing to do is selecting the applet on the card.
|
||||
ApplicationInfo info = new ApplicationInfo(cmdSet.select().checkOK().getData());
|
||||
Log.i(TAG, "Instance UID: " + Hex.toHexString(info.getInstanceUID()));
|
||||
Log.i(TAG, "Key UID: " + Hex.toHexString(info.getKeyUID()));
|
||||
Log.i(TAG, "Secure channel public key: " + Hex.toHexString(info.getSecureChannelPubKey()));
|
||||
Log.i(TAG, "Application version: " + info.getAppVersionString());
|
||||
Log.i(TAG, "Free pairing slots: " + info.getFreePairingSlots());
|
||||
@@ -146,14 +159,11 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
cmdSet.autoPair(pairingPassword);
|
||||
|
||||
Pairing pairing = cmdSet.getPairing();
|
||||
log("Pairing index: " + pairing.getPairingIndex());
|
||||
log("Pairing key: " + Hex.toHexString(pairing.getPairingKey()));
|
||||
log("Pairing toBase64: " + pairing.toBase64());
|
||||
|
||||
return pairing.toBase64();
|
||||
}
|
||||
|
||||
public String generateMnemonic(String pairingBase64) throws IOException, APDUException {
|
||||
public String generateMnemonic(String pairingBase64, String words) throws IOException, APDUException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
cmdSet.select().checkOK();
|
||||
|
||||
@@ -164,7 +174,16 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
Log.i(TAG, "secure channel opened");
|
||||
|
||||
Mnemonic mnemonic = new Mnemonic(cmdSet.generateMnemonic(KeycardCommandSet.GENERATE_MNEMONIC_12_WORDS).checkOK().getData());
|
||||
mnemonic.fetchBIP39EnglishWordlist();
|
||||
|
||||
Scanner scanner = new Scanner(words);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
while(scanner.hasNextLine()) {
|
||||
list.add(scanner.nextLine());
|
||||
}
|
||||
scanner.close();
|
||||
|
||||
String [] wordsList = list.toArray(new String[WORDS_LIST_SIZE]);
|
||||
mnemonic.setWordlist(wordsList);
|
||||
|
||||
return mnemonic.toMnemonicPhrase();
|
||||
}
|
||||
@@ -199,34 +218,38 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
|
||||
if (info.isInitializedCard()) {
|
||||
Log.i(TAG, "Instance UID: " + Hex.toHexString(info.getInstanceUID()));
|
||||
Log.i(TAG, "Key UID: " + Hex.toHexString(info.getKeyUID()));
|
||||
Log.i(TAG, "Secure channel public key: " + Hex.toHexString(info.getSecureChannelPubKey()));
|
||||
Log.i(TAG, "Application version: " + info.getAppVersionString());
|
||||
Log.i(TAG, "Free pairing slots: " + info.getFreePairingSlots());
|
||||
|
||||
if (info.hasMasterKey()) {
|
||||
Log.i(TAG, "Key UID: " + Hex.toHexString(info.getKeyUID()));
|
||||
} else {
|
||||
Log.i(TAG, "The card has no master key");
|
||||
}
|
||||
Boolean isPaired = false;
|
||||
|
||||
if (pairingBase64.length() > 0) {
|
||||
Pairing pairing = new Pairing(pairingBase64);
|
||||
cmdSet.setPairing(pairing);
|
||||
try {
|
||||
Pairing pairing = new Pairing(pairingBase64);
|
||||
cmdSet.setPairing(pairing);
|
||||
|
||||
cmdSet.autoOpenSecureChannel();
|
||||
Log.i(TAG, "secure channel opened");
|
||||
cmdSet.autoOpenSecureChannel();
|
||||
Log.i(TAG, "secure channel opened");
|
||||
isPaired = true;
|
||||
|
||||
ApplicationStatus status = new ApplicationStatus(cmdSet.getStatus(KeycardCommandSet.GET_STATUS_P1_APPLICATION).checkOK().getData());
|
||||
ApplicationStatus status = new ApplicationStatus(cmdSet.getStatus(KeycardCommandSet.GET_STATUS_P1_APPLICATION).checkOK().getData());
|
||||
|
||||
Log.i(TAG, "PIN retry counter: " + status.getPINRetryCount());
|
||||
Log.i(TAG, "PUK retry counter: " + status.getPUKRetryCount());
|
||||
Log.i(TAG, "PIN retry counter: " + status.getPINRetryCount());
|
||||
Log.i(TAG, "PUK retry counter: " + status.getPUKRetryCount());
|
||||
|
||||
cardInfo.putInt("pin-retry-counter", status.getPINRetryCount());
|
||||
cardInfo.putInt("puk-retry-counter", status.getPUKRetryCount());
|
||||
cardInfo.putInt("pin-retry-counter", status.getPINRetryCount());
|
||||
cardInfo.putInt("puk-retry-counter", status.getPUKRetryCount());
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
Log.i(TAG, "autoOpenSecureChannel failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
cardInfo.putBoolean("has-master-key?", info.hasMasterKey());
|
||||
cardInfo.putBoolean("paired?", isPaired);
|
||||
cardInfo.putString("instance-uid", Hex.toHexString(info.getInstanceUID()));
|
||||
cardInfo.putString("key-uid", Hex.toHexString(info.getKeyUID()));
|
||||
cardInfo.putString("secure-channel-pub-key", Hex.toHexString(info.getSecureChannelPubKey()));
|
||||
cardInfo.putString("app-version", info.getAppVersionString());
|
||||
cardInfo.putInt("free-pairing-slots", info.getFreePairingSlots());
|
||||
@@ -251,10 +274,8 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
KeyPath currentPath = new KeyPath(cmdSet.getStatus(KeycardCommandSet.GET_STATUS_P1_KEY_PATH).checkOK().getData());
|
||||
Log.i(TAG, "Current key path: " + currentPath);
|
||||
|
||||
if (!currentPath.toString().equals("m/44'/0'/0'/0/0")) {
|
||||
cmdSet.deriveKey(path).checkOK();
|
||||
Log.i(TAG, "Derived m/44'/0'/0'/0/0");
|
||||
}
|
||||
cmdSet.deriveKey(path).checkOK();
|
||||
Log.i(TAG, "Derived " + path);
|
||||
}
|
||||
|
||||
public String exportKey(final String pairingBase64, final String pin) throws IOException, APDUException {
|
||||
@@ -288,25 +309,13 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
cmdSet.verifyPIN(pin).checkOK();
|
||||
Log.i(TAG, "pin verified");
|
||||
|
||||
|
||||
cmdSet.deriveKey(WALLET_PATH).checkOK();
|
||||
Log.i(TAG, "Derived " + WALLET_PATH);
|
||||
|
||||
byte[] tlv = cmdSet.exportCurrentKey(true).checkOK().getData();
|
||||
byte[] tlv = cmdSet.exportKey(WALLET_PATH, true, true).checkOK().getData();
|
||||
BIP32KeyPair walletKeyPair = BIP32KeyPair.fromTLV(tlv);
|
||||
|
||||
|
||||
cmdSet.deriveKey(WHISPER_PATH).checkOK();
|
||||
Log.i(TAG, "Derived " + WHISPER_PATH);
|
||||
|
||||
byte[] tlv2 = cmdSet.exportCurrentKey(false).checkOK().getData();
|
||||
byte[] tlv2 = cmdSet.exportKey(WHISPER_PATH, false, false).checkOK().getData();
|
||||
BIP32KeyPair whisperKeyPair = BIP32KeyPair.fromTLV(tlv2);
|
||||
|
||||
|
||||
cmdSet.deriveKey(ENCRYPTION_PATH).checkOK();
|
||||
Log.i(TAG, "Derived " + ENCRYPTION_PATH);
|
||||
|
||||
byte[] tlv3 = cmdSet.exportCurrentKey(false).checkOK().getData();
|
||||
byte[] tlv3 = cmdSet.exportKey(ENCRYPTION_PATH, false, false).checkOK().getData();
|
||||
BIP32KeyPair encryptionKeyPair = BIP32KeyPair.fromTLV(tlv3);
|
||||
|
||||
WritableMap data = Arguments.createMap();
|
||||
@@ -355,12 +364,16 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
byte[] tlv3 = cmdSet.exportCurrentKey(false).checkOK().getData();
|
||||
BIP32KeyPair encryptionKeyPair = BIP32KeyPair.fromTLV(tlv3);
|
||||
|
||||
ApplicationInfo info = new ApplicationInfo(cmdSet.select().checkOK().getData());
|
||||
|
||||
WritableMap data = Arguments.createMap();
|
||||
data.putString("wallet-address", Hex.toHexString(walletKeyPair.toEthereumAddress()));
|
||||
data.putString("whisper-address", Hex.toHexString(whisperKeyPair.toEthereumAddress()));
|
||||
data.putString("whisper-public-key", Hex.toHexString(whisperKeyPair.getPublicKey()));
|
||||
data.putString("whisper-private-key", Hex.toHexString(whisperKeyPair.getPrivateKey()));
|
||||
data.putString("encryption-public-key", Hex.toHexString(encryptionKeyPair.getPublicKey()));
|
||||
data.putString("instance-uid", Hex.toHexString(info.getInstanceUID()));
|
||||
data.putString("key-uid", Hex.toHexString(info.getKeyUID()));
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -370,11 +383,11 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
installer.start();
|
||||
}
|
||||
|
||||
public SmartCardSecrets installAppletAndInitCard(AssetManager assets, String capPath) throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
public SmartCardSecrets installAppletAndInitCard(final String userPin, AssetManager assets, String capPath) throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
Installer installer = new Installer(this.cardChannel, assets, capPath, eventEmitter);
|
||||
installer.start();
|
||||
|
||||
return init();
|
||||
return init(userPin);
|
||||
}
|
||||
|
||||
public int verifyPin(final String pairingBase64, final String pin) throws IOException, APDUException {
|
||||
@@ -454,9 +467,64 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
Log.i(TAG, "instance and package deleted");
|
||||
}
|
||||
|
||||
public void removeKey(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");
|
||||
|
||||
cmdSet.removeKey();
|
||||
Log.i(TAG, "key removed");
|
||||
}
|
||||
|
||||
public void removeKeyWithUnpair(final String pairingBase64, final String pin) throws IOException, APDUException {
|
||||
removeKey(pairingBase64, pin);
|
||||
unpair(pairingBase64, pin);
|
||||
}
|
||||
|
||||
public void unpairAndDelete(final String pairingBase64, final String pin) throws IOException, APDUException {
|
||||
unpair(pairingBase64, pin);
|
||||
delete();
|
||||
}
|
||||
|
||||
public String sign(final String pairingBase64, final String pin, final String message) 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[] hash = Hex.decode(message);
|
||||
RecoverableSignature signature = new RecoverableSignature(hash, cmdSet.sign(hash).checkOK().getData());
|
||||
|
||||
Log.i(TAG, "Signed hash: " + Hex.toHexString(hash));
|
||||
Log.i(TAG, "Recovery ID: " + signature.getRecId());
|
||||
Log.i(TAG, "R: " + Hex.toHexString(signature.getR()));
|
||||
Log.i(TAG, "S: " + Hex.toHexString(signature.getS()));
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
out.write(signature.getR());
|
||||
out.write(signature.getS());
|
||||
out.write(signature.getRecId());
|
||||
|
||||
String sig = Hex.toHexString(out.toByteArray());
|
||||
Log.i(TAG, "Signature: " + sig);
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ package im.status.ethereum.keycard;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Base64;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import static android.util.Base64.NO_PADDING;
|
||||
import static android.util.Base64.NO_WRAP;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
@@ -28,11 +32,18 @@ public class SmartCardSecrets {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static SmartCardSecrets generate() throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
String pairingPassword = randomToken(12);
|
||||
public static SmartCardSecrets generate(final String userPin) throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
String pairingPassword = randomToken(16);
|
||||
long pinNumber = randomLong(PIN_BOUND);
|
||||
long pukNumber = randomLong(PUK_BOUND);
|
||||
String pin = String.format("%06d", pinNumber);
|
||||
|
||||
String pin;
|
||||
if (userPin.isEmpty()) {
|
||||
pin = String.format("%06d", pinNumber);
|
||||
} else {
|
||||
pin = userPin;
|
||||
}
|
||||
|
||||
String puk = String.format("%012d", pukNumber);
|
||||
|
||||
return new SmartCardSecrets(pin, puk, pairingPassword);
|
||||
@@ -56,7 +67,9 @@ public class SmartCardSecrets {
|
||||
}
|
||||
|
||||
public static String randomToken(int length) {
|
||||
return Base64.encodeToString(randomBytes(length), NO_PADDING);
|
||||
char[] possibleCharacters = "23456789ABCDEFGHJKLMNPRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray();
|
||||
String randomStr = RandomStringUtils.random(length, 0, possibleCharacters.length-1, false, false, possibleCharacters, new SecureRandom());
|
||||
return randomStr;
|
||||
}
|
||||
|
||||
public static byte[] randomBytes(int length) {
|
||||
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
# Usage
|
||||
|
||||
You need to import Keycard object to interact with the card:
|
||||
|
||||
```javascript
|
||||
import Keycard from "react-native-status-keycard";
|
||||
```
|
||||
|
||||
### Listen to keycard connect/disconnect events
|
||||
|
||||
```javascript
|
||||
import { DeviceEventEmitter } from 'react-native';
|
||||
|
||||
// Listen to connect/disconnect events
|
||||
componentDidMount () {
|
||||
DeviceEventEmitter.addListener("keyCardOnConnected", () => console.log("keycard connected"));
|
||||
DeviceEventEmitter.addListener("keyCardOnDisconnected", () => console.log("keycard disconnected"));
|
||||
}
|
||||
```
|
||||
|
||||
### Errors
|
||||
|
||||
Library uses Promises for method calls, use `.catch` to get the error object.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
Keycard.init("123456").then(info => console.log(info)).catch(error => console.log(error))
|
||||
```
|
||||
|
||||
Error object example:
|
||||
```javascript
|
||||
{"code": "EUNSPECIFIED",
|
||||
"error": "Tag was lost."}
|
||||
```
|
||||
|
||||
### Check NFC support on device
|
||||
```javascript
|
||||
// Check if NFC is supported by device
|
||||
Keycard.nfcIsSupported().then(isSupported => isSupported ? console.log("NFC is supported") : console.log("NFC is not supported"));
|
||||
|
||||
// Check if NFC is enabled on device
|
||||
Keycard.nfcIsEnabled().then(isEnabled => isEnabled ? console.log("NFC is enabled") : console.log("NFC is not enabled"));
|
||||
|
||||
// Open device NFC settings
|
||||
Keycard.openNfcSettings();
|
||||
```
|
||||
|
||||
### Get keycard information
|
||||
```javascript
|
||||
// If keycard was not paired before, use empty string as pairing
|
||||
Keycard.getApplicationInfo("").then(info => console.log(info));
|
||||
|
||||
// If keycard is paired, use pairing key
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
Keycard.getApplicationInfo(pairing).then(info => console.log(info));
|
||||
|
||||
```
|
||||
|
||||
Returns object like this:
|
||||
```javascript
|
||||
{"free-pairing-slots": 2,
|
||||
"app-version": "2.1",
|
||||
"secure-channel-pub-key": "042bd559a6eb5843491f79150ccba6bcc04c5b6691079f7c7a0e2eea659960db1df67079b27fdf5df56a1092029a157c0dce7000af4d7c4c1131421623c0150d1c",
|
||||
"instance-uid": "21c0ce19aa9a26efc02fd32078c08527",
|
||||
"key-uid": "a88d46499e5690c6ad637e243e83cf51be3e2c67e48324b2b2def3e6a0492576",
|
||||
"has-master-key?": false,
|
||||
"paired?": false,
|
||||
"initialized?": true}
|
||||
```
|
||||
|
||||
`instance-uid` The instance UID of the applet. This ID never changes for the lifetime of the applet.
|
||||
|
||||
`key-uid` The UID of the master key on this card. Changes every time a different master key is stored. It has zero length if no key is on the card.
|
||||
|
||||
## Setup keycard
|
||||
|
||||
### Initialize the card
|
||||
```javascript
|
||||
const pin = "123456";
|
||||
Keycard.init(pin).then(secrets => console.log(secrets));
|
||||
```
|
||||
|
||||
`secrets` object contains PIN, PUK and Pairing password. You will need password to pair the card to device.
|
||||
```javascript
|
||||
{"pin": "123456",
|
||||
"puk": "123456123456",
|
||||
"password": "/xzPt+rEWVN3sMc5"}
|
||||
```
|
||||
|
||||
### Pair
|
||||
Pairs keycard to device.
|
||||
|
||||
Use password you get after keycard initialization (using `init`):
|
||||
|
||||
```javascript
|
||||
const password = "/xzPt+rEWVN3sMc5";
|
||||
Keycard.pair(password).then(pairing => console.log(pairing));
|
||||
```
|
||||
|
||||
`pairing` object contains pairing key as base64 string.
|
||||
You will need pairing key to open secure channel for most keycard operations. More info on pairing https://status.im/keycard_api/sdk_securechannel.html
|
||||
|
||||
### Generate mnemonic phrase
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const words = "abandon\nability\nable\nabout\n..." // bip 39 words separated by new line
|
||||
Keycard.generateMnemonic(pairing, words).then(mnemonic => console.log(mnemonic));
|
||||
```
|
||||
`mnemonic` is a string of 12 words separated by space:
|
||||
```javascript
|
||||
"sure more foil soon pretty guilt run rail biology fine obey outside"
|
||||
```
|
||||
|
||||
BIP39 words can be found here: https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt
|
||||
|
||||
### Generate and load master key
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const pin = "123456";
|
||||
const mnemonic = "sure more foil soon pretty guilt run rail biology fine obey outside";
|
||||
|
||||
Keycard.generateAndLoadKey(mnemonic, pairing, pin).then(data => console.log(data));
|
||||
```
|
||||
|
||||
`data` object returned:
|
||||
```javascript
|
||||
{"wallet-address": "9726cbc67d170307dd80af6416ebe844e7b8eb1c",
|
||||
"whisper-address": "438e576b638bff08b2872dd708cf0240811d79af",
|
||||
"whisper-public-key": "04add221cb97dde8afbf3be27b0bfb3b6842071cb1052abfc3c34d45eba944dc10dcba5d4823fe69148ae17b12ed459237124365c2f46c2b46be9537ce6efa93c8",
|
||||
"whisper-private-key": "073d77b952b3b92ba66947df53d03b23bc4cc8cf10cbba1060fe25a569c8ee6b",
|
||||
"encryption-public-key": "04d36d64bea374b917bc097646cb4e81061c7b0ab0872207480b886e66fb52d53774e303e2aa07a1107776f312b94663566765a8a75cf0a92b0851017b28b356a1",
|
||||
"instance-uid": "21c0ce19aa9a26efc02fd32078c08527",
|
||||
"key-uid":"a88d46499e5690c6ad637e243e83cf51be3e2c67e48324b2b2def3e6a0492576"}
|
||||
```
|
||||
|
||||
`wallet-address` is ethereum address of key with derivation path `m/44'/60'/0'/0/0`
|
||||
|
||||
`whisper-address` is ethereum address of key with derivation path `m/43'/60'/1581'/0'/0`
|
||||
|
||||
`encryption-public-key` is public key with derivation path `m/43'/60'/1581'/1'/0`
|
||||
|
||||
More info about key derivation: https://status.im/keycard_api/sdk_derivation_sign.html
|
||||
|
||||
### Get keys from keycard
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const pin = "123456";
|
||||
|
||||
Keycard.getKeys(pairing, pin).then(data => console.log(data));
|
||||
```
|
||||
|
||||
`data` object contains:
|
||||
```javascript
|
||||
{"encryption-public-key": "04d36d64bea374b917bc097646cb4e81061c7b0ab0872207480b886e66fb52d53774e303e2aa07a1107776f312b94663566765a8a75cf0a92b0851017b28b356a1",
|
||||
"whisper-public-key": "04add221cb97dde8afbf3be27b0bfb3b6842071cb1052abfc3c34d45eba944dc10dcba5d4823fe69148ae17b12ed459237124365c2f46c2b46be9537ce6efa93c8",
|
||||
"whisper-private-key":"073d77b952b3b92ba66947df53d03b23bc4cc8cf10cbba1060fe25a569c8ee6b",
|
||||
"wallet-address":"9726cbc67d170307dd80af6416ebe844e7b8eb1c"}
|
||||
```
|
||||
|
||||
### Sign
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const pin = "123456";
|
||||
const hash = "d81bbffb92157b72ceae3da72eb8224976ba42a49621822789edb0735a0e0395";
|
||||
|
||||
Keycard.sign(pairing, pin, hash).then(sig => console.log(sig));
|
||||
```
|
||||
|
||||
Signature string returned. Example: ` d684afb4ec9ce59f2d112a9c9400bd04f5a5b2518b251dba4ad135448f2e75367c2ea6412893d8001ed9c9efeb7c7d37bc11f7dfcf27c4818cf0861da199de1900`
|
||||
|
||||
Signature consists of R, S and Recovery ID values concatenated (R+S+V).
|
||||
For example:
|
||||
|
||||
R: `79ef184db3150519a9719a38a7939fae39bbea088758745482cabe40127c7efb`
|
||||
|
||||
S: `674932db2a7a5ae4b1d9d228b3542dba83ac9ac62524a45dd984e9650ceaa736`
|
||||
|
||||
Recovery ID: `0`
|
||||
|
||||
Would produce signature: `d684afb4ec9ce59f2d112a9c9400bd04f5a5b2518b251dba4ad135448f2e75367c2ea6412893d8001ed9c9efeb7c7d37bc11f7dfcf27c4818cf0861da199de1900`
|
||||
|
||||
More info about signing: https://status.im/keycard_api/sdk_derivation_sign.html
|
||||
|
||||
### Derive key
|
||||
Changes derivation path:
|
||||
```javascript
|
||||
const path = "m/44'/60'/0'/0/0"
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const pin = "123456";
|
||||
|
||||
Keycard.deriveKey(path, pairing, pin).then(path => console.log("path changed to " + path));
|
||||
```
|
||||
More information on key derivation: https://status.im/keycard_api/sdk_derivation_sign.html
|
||||
|
||||
### Remove key
|
||||
Removes master key from keycard:
|
||||
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const pin = "123456";
|
||||
|
||||
Keycard.removeKey(pairing, pin).then(() => console.log("key removed"));
|
||||
```
|
||||
|
||||
### Unpair
|
||||
|
||||
Unpairs keycard from current device:
|
||||
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const pin = "123456";
|
||||
|
||||
Keycard.unpair(pairing, pin).then(() => console.log("keycard unpaired"));
|
||||
```
|
||||
|
||||
### Change PIN
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const currentPin = "123456";
|
||||
const newPin = "111111";
|
||||
|
||||
Keycard.removeKey(pairing, currentPin, newPin).then(() => console.log("pin changed"));
|
||||
```
|
||||
|
||||
### Unblock PIN
|
||||
When wrong PIN is entered 3 times keycard becomes blocked. You can unblock it with PUK code:
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const puk = "123456123456";
|
||||
const newPin = "111111";
|
||||
|
||||
Keycard.removeKey(pairing, puk, newPin).then(() => console.log("pin unblocked"));
|
||||
```
|
||||
|
||||
### Verify PIN
|
||||
Verifies PIN is valid:
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const pin = "123456";
|
||||
|
||||
Keycard.removeKey(pairing, pin).then(() => console.log("pin is valid"));
|
||||
```
|
||||
|
||||
### Delete keycard
|
||||
Deletes everything from keycard including key and the applet. Dangerous operation for advanced users only. You will need to install applet again to interact with keycard.
|
||||
|
||||
```javascript
|
||||
const pairing = "AFFdkP01GywuaJRQkGDq+OyPHBE9nECEDDCfXhpfaxlo";
|
||||
const puk = "123456123456";
|
||||
const newPin = "111111";
|
||||
|
||||
Keycard.removeKey(pairing, puk, newPin).then(() => console.log("pin unblocked"));
|
||||
```
|
||||
|
||||
### Install applet
|
||||
Keycard usually comes with installed applet. But if you have empty keycard without the applet, you can install applet with:
|
||||
```javascript
|
||||
Keycard.installApplet().then(() => console.log("applet installed"));
|
||||
```
|
||||
|
||||
### Keycard CLI
|
||||
You can also interact with keycard (installing and removing applet, getting card info, etc) using [keycard cli](https://github.com/status-im/keycard-cli). You'll need a USB reader for that.
|
||||
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#import <React/RCTBridgeModule.h>
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "RNStatusKeycard"
|
||||
s.version = "1.0.0"
|
||||
s.summary = "RNStatusKeycard"
|
||||
s.description = <<-DESC
|
||||
RNStatusKeycard
|
||||
DESC
|
||||
s.homepage = ""
|
||||
s.license = "MIT"
|
||||
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
|
||||
s.author = { "author" => "author@domain.cn" }
|
||||
s.platform = :ios, "7.0"
|
||||
s.source = { :git => "https://github.com/author/RNStatusKeycard.git", :tag => "master" }
|
||||
s.source_files = "RNStatusKeycard/**/*.{h,m}"
|
||||
s.requires_arc = true
|
||||
|
||||
|
||||
s.dependency "React"
|
||||
#s.dependency "others"
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import CoreNFC
|
||||
|
||||
@objc(RNStatusKeycard)
|
||||
class RNStatusKeycard: NSObject {
|
||||
@objc
|
||||
static func requiresMainQueueSetup() -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@objc
|
||||
func nfcIsSupported(
|
||||
_ resolve: RCTPromiseResolveBlock,
|
||||
rejecter reject: RCTPromiseRejectBlock) -> Void {
|
||||
if #available(iOS 13.0, *) {
|
||||
resolve(true)
|
||||
} else {
|
||||
resolve(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@objc
|
||||
func nfcIsEnabled(
|
||||
_ resolve: RCTPromiseResolveBlock,
|
||||
rejecter reject: RCTPromiseRejectBlock) -> Void {
|
||||
if NFCNDEFReaderSession.readingAvailable {
|
||||
resolve(true)
|
||||
} else {
|
||||
resolve(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
98F44A5D22CE650F002B6C62 /* RNStatusKeycard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F44A5B22CE650F002B6C62 /* RNStatusKeycard.swift */; };
|
||||
98F44A5E22CE650F002B6C62 /* RNStatusKeycardBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 98F44A5C22CE650F002B6C62 /* RNStatusKeycardBridge.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "include/$(PRODUCT_NAME)";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
134814201AA4EA6300B7C361 /* libRNStatusKeycard.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNStatusKeycard.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
989CA44722CE63C900B1D921 /* RNStatusKeycard-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNStatusKeycard-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
98F44A5B22CE650F002B6C62 /* RNStatusKeycard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNStatusKeycard.swift; sourceTree = "<group>"; };
|
||||
98F44A5C22CE650F002B6C62 /* RNStatusKeycardBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNStatusKeycardBridge.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
134814211AA4EA7D00B7C361 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
134814201AA4EA6300B7C361 /* libRNStatusKeycard.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
58B511D21A9E6C8500147676 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
98F44A5B22CE650F002B6C62 /* RNStatusKeycard.swift */,
|
||||
98F44A5C22CE650F002B6C62 /* RNStatusKeycardBridge.m */,
|
||||
134814211AA4EA7D00B7C361 /* Products */,
|
||||
989CA44722CE63C900B1D921 /* RNStatusKeycard-Bridging-Header.h */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
58B511DA1A9E6C8500147676 /* RNStatusKeycard */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNStatusKeycard" */;
|
||||
buildPhases = (
|
||||
58B511D71A9E6C8500147676 /* Sources */,
|
||||
58B511D81A9E6C8500147676 /* Frameworks */,
|
||||
58B511D91A9E6C8500147676 /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = RNStatusKeycard;
|
||||
productName = RCTDataManager;
|
||||
productReference = 134814201AA4EA6300B7C361 /* libRNStatusKeycard.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
58B511D31A9E6C8500147676 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0830;
|
||||
ORGANIZATIONNAME = Facebook;
|
||||
TargetAttributes = {
|
||||
58B511DA1A9E6C8500147676 = {
|
||||
CreatedOnToolsVersion = 6.1.1;
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNStatusKeycard" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
);
|
||||
mainGroup = 58B511D21A9E6C8500147676;
|
||||
productRefGroup = 58B511D21A9E6C8500147676;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
58B511DA1A9E6C8500147676 /* RNStatusKeycard */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
58B511D71A9E6C8500147676 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
98F44A5E22CE650F002B6C62 /* RNStatusKeycardBridge.m in Sources */,
|
||||
98F44A5D22CE650F002B6C62 /* RNStatusKeycard.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
58B511ED1A9E6C8500147676 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
58B511EE1A9E6C8500147676 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
58B511F01A9E6C8500147676 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/../../../React/**",
|
||||
"$(SRCROOT)/../../react-native/React/**",
|
||||
);
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = RNStatusKeycard;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "RNStatusKeycard-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
58B511F11A9E6C8500147676 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/../../../React/**",
|
||||
"$(SRCROOT)/../../react-native/React/**",
|
||||
);
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = RNStatusKeycard;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "RNStatusKeycard-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNStatusKeycard" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
58B511ED1A9E6C8500147676 /* Debug */,
|
||||
58B511EE1A9E6C8500147676 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNStatusKeycard" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
58B511F01A9E6C8500147676 /* Debug */,
|
||||
58B511F11A9E6C8500147676 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// !$*UTF8*$!
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:RNStatusKeycard.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#import <React/RCTBridgeModule.h>
|
||||
|
||||
// - (dispatch_queue_t)methodQueue
|
||||
// {
|
||||
// return dispatch_queue_create("im.status.KeycardQueue", DISPATCH_QUEUE_SERIAL);
|
||||
// }
|
||||
|
||||
@interface RCT_EXTERN_MODULE(RNStatusKeycard, NSObject)
|
||||
|
||||
RCT_EXTERN_METHOD(nfcIsEnabled: (RCTPromiseResolveBlock)resolve
|
||||
rejecter: (__unused RCTPromiseRejectBlock)reject)
|
||||
|
||||
RCT_EXTERN_METHOD(nfcIsSupported: (RCTPromiseResolveBlock)resolve
|
||||
rejecter: (__unused RCTPromiseRejectBlock)reject)
|
||||
|
||||
@end
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
|
||||
{
|
||||
"name": "react-native-status-keycard",
|
||||
"version": "2.3.0",
|
||||
"homepage": "https://keycard.status.im/",
|
||||
"version": "2.5.5",
|
||||
"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