@onekeyfe/react-native-lite-card 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -214,9 +214,14 @@ class OKLiteManager(private val context: ReactApplicationContext) :
214
214
  mShowDialogNumber.incrementAndGet()
215
215
  var receiveIsoDep = lastIsoDep
216
216
  val tryReceiveResult = mNFCConnectedChannel.tryReceive()
217
+ val lastIsoDepIsConnected: Boolean = try {
218
+ lastIsoDep?.isConnected ?: false
219
+ } catch (e: Exception) {
220
+ false
221
+ }
217
222
  if (tryReceiveResult.isSuccess) {
218
223
  receiveIsoDep = tryReceiveResult.getOrNull();
219
- } else if (lastIsoDep == null || lastIsoDep?.isConnected == false) {
224
+ } else if (lastIsoDepIsConnected == false) {
220
225
  receiveIsoDep = mNFCConnectedChannel.receive()
221
226
  }
222
227
  lastIsoDep = receiveIsoDep
@@ -23,9 +23,14 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
23
23
 
24
24
  @JvmStatic
25
25
  private fun connect(isoDep: IsoDep?) {
26
- if (isoDep?.isConnected == false) {
27
- isoDep.connect()
28
- isoDep.timeout = 15000
26
+ val isConnected: Boolean = try {
27
+ isoDep?.isConnected ?: false
28
+ } catch (e: Exception) {
29
+ false
30
+ }
31
+ if (isConnected == false) {
32
+ isoDep?.connect()
33
+ isoDep?.timeout = 15000
29
34
  }
30
35
  }
31
36
 
@@ -260,7 +260,7 @@
260
260
  if (status == OKNFCLiteGetMncStatusWiped) {
261
261
  self.status = OKNFCLiteStatusNewCard;
262
262
  }
263
- [self.delegate endNFCSessionWithError:status == OKNFCLiteGetMncStatusError || status == OKNFCLiteGetMncStatusPinNotMatch];
263
+ [self.delegate endNFCSessionWithError:status == OKNFCLiteGetMncStatusError || status == OKNFCLiteGetMncStatusPinNotMatch || status == OKNFCLiteGetMncStatusWiped];
264
264
  callback(self,mnc,status);
265
265
  }
266
266
 
@@ -577,13 +577,20 @@
577
577
  }
578
578
 
579
579
  - (OKNFCLiteChangePinResult)setNewPin:(NSString *)newPin withOldPin:(NSString *)oldPin {
580
+ static const u_int8_t AuthenticationLockCode = 0x69;
581
+ static const u_int8_t AuthenticationLockSw2Code = 0x83;
582
+ static const u_int8_t FailedVerificationCode = 0x63;
583
+ static const u_int8_t PinRTLBitMask = 0x0f;
580
584
  __block OKNFCLiteChangePinResult result = OKNFCLiteChangePinResultError;
581
585
  dispatch_semaphore_t sema = dispatch_semaphore_create(0);
582
586
  OKLiteCommandModal *modal = [[OKLiteCommandModal alloc] initWithCommand:OKLiteCommandChangePIN version:self.version];
583
587
  modal.parseResp = true;
584
588
  [self.commandTool sendCommandWithAPDU:[modal changePIN:oldPin newPin:newPin] modal:modal completionHandler:^(NSData * _Nonnull responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString * _Nonnull parseRespon) {
585
589
  if (sw1 != OKNFC_SW1_OK) {
586
- if (sw1 == 0x63) {
590
+ if (sw1 == FailedVerificationCode) {
591
+ self.pinRTL = sw2 & PinRTLBitMask;
592
+ } else if (sw1 == AuthenticationLockCode && sw2 == AuthenticationLockSw2Code) {
593
+ self.pinRTL = 0;
587
594
  result = OKNFCLiteChangePinResultWiped;
588
595
  }
589
596
  dispatch_semaphore_signal(sema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-lite-card",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "lite card",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",