@onekeyfe/react-native-lite-card 6.7.0-alpha.444 → 6.7.0-alpha.448

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.
@@ -16,6 +16,7 @@ import com.facebook.react.module.annotations.ReactModule
16
16
  import com.onekeyfe.reactnativelitecard.nfc.NFCExceptions
17
17
  import com.onekeyfe.reactnativelitecard.nfc.NfcUtils
18
18
  import com.onekeyfe.reactnativelitecard.onekeyLite.OneKeyLiteCard
19
+ import com.onekeyfe.reactnativelitecard.onekeyLite.NfcConstant
19
20
  import com.onekeyfe.reactnativelitecard.onekeyLite.entitys.CardState
20
21
  import com.onekeyfe.reactnativelitecard.utils.NfcPermissionUtils
21
22
  import com.onekeyfe.reactnativelitecard.utils.Utils
@@ -307,6 +308,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
307
308
  mnemonic: String?,
308
309
  pwd: String?,
309
310
  overwrite: Boolean,
311
+ expectedSerial: String?,
310
312
  callback: Callback?
311
313
  ) {
312
314
  if (pwd.isNullOrEmpty() || pwd.length != 6 || !pwd.all { it.isDigit() }) {
@@ -319,6 +321,12 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
319
321
  }
320
322
  launch {
321
323
  handleOperation(callback, "setMnemonic") { isoDep ->
324
+ val serial = mCurrentCardState?.serialNum
325
+ if (expectedSerial != null && (serial.isNullOrEmpty() ||
326
+ serial == NfcConstant.NOT_MATCH_DEVICE || expectedSerial != serial)) {
327
+ OneKeyLog.info("LiteCard", "operation=setMnemonic stage=identity_mismatch")
328
+ throw NFCExceptions.DeviceMismatchException()
329
+ }
322
330
  OneKeyLog.debug("LiteCard","setMnemonic Obtain the device")
323
331
  val isSuccess =
324
332
  OneKeyLiteCard.setMnemonic(
@@ -1,5 +1,8 @@
1
1
  package com.onekeyfe.reactnativelitecard.onekeyLite.nfc
2
2
 
3
+ import com.margelo.nitro.nativelogger.OneKeyLog
4
+ import java.util.concurrent.atomic.AtomicLong
5
+ import org.haobtc.onekey.card.gpchannel.GPChannelNatives.nativeGetErrorCode
3
6
  import com.google.gson.JsonObject
4
7
  import com.google.gson.JsonParser
5
8
  import org.haobtc.onekey.card.gpchannel.GPChannelNatives.nativeGPCParseAPDUResponse
@@ -48,6 +51,7 @@ enum class CommandType(val code: String) {
48
51
 
49
52
  class Command(
50
53
  private val cardType: AppleCardType,
54
+ private val type: CommandType,
51
55
  val area: CommandArea,
52
56
  val command: String,
53
57
  private val ignoreSafeChannel: Boolean,
@@ -56,6 +60,10 @@ class Command(
56
60
  private val hasOpenSafeChannel: Boolean,
57
61
  val data: String,
58
62
  ) {
63
+ companion object {
64
+ private val diagnosticSequence = AtomicLong(0)
65
+ }
66
+
59
67
  private fun beforeConnecting(connection: Connection) {
60
68
  val needOpenSafeChannel = useSafeChannel || (useSafeChannelWhenOpen && hasOpenSafeChannel)
61
69
  val needCloseSafeChannel =
@@ -106,16 +114,25 @@ class Command(
106
114
  }
107
115
 
108
116
  fun send(connection: Connection): SendResponse {
117
+ val commandID = diagnosticSequence.incrementAndGet()
118
+ val secure = useSafeChannel || (useSafeChannelWhenOpen && hasOpenSafeChannel)
119
+ OneKeyLog.info("LiteCard", "commandID=$commandID command=${type.code} stage=before_connect secure=$secure")
109
120
  beforeConnecting(connection)
110
121
  // buildApdu && parseResponse Use in pairs
111
122
  val apdu = buildApdu()
123
+ OneKeyLog.info("LiteCard", "commandID=$commandID command=${type.code} stage=build buildSucceeded=${apdu.isNotEmpty()}")
112
124
  if (apdu.isEmpty()) {
113
125
  return SendResponse("0xFFFF", 0xFF.toByte(), 0xFF.toByte(), parseSuccess = false)
114
126
  }
115
127
  val result = Connection.send(connection.isoDep, apdu)
116
- val resultObject = CardResponse.objectFromData(parseResponse(result.rawResponse))
128
+ val rawResponseBytes = if (result.rawResponse == "0xFFFF") -1 else result.rawResponse.length / 2
129
+ OneKeyLog.info("LiteCard", "commandID=$commandID command=${type.code} stage=transport_result rawResponseBytes=$rawResponseBytes rawSW1=${result.sw1.toInt() and 0xFF} rawSW2=${result.sw2.toInt() and 0xFF}")
130
+ val parsedResponse = parseResponse(result.rawResponse)
131
+ val lastSdkError = if (parsedResponse == null) nativeGetErrorCode() else 0
132
+ val resultObject = CardResponse.objectFromData(parsedResponse)
117
133
  result.result = resultObject?.response ?: ""
118
134
  result.parseSuccess = resultObject != null && resultObject.wRet == 0x9000
135
+ OneKeyLog.info("LiteCard", "commandID=$commandID command=${type.code} stage=parse lastSdkError=$lastSdkError parsePresent=${resultObject != null} parsedSW=${resultObject?.wRet ?: -1} parseSuccess=${result.parseSuccess}")
119
136
  return result
120
137
  }
121
138
  }
@@ -169,6 +186,7 @@ class CommandGenerator {
169
186
 
170
187
  return Command(
171
188
  cardType = cardType,
189
+ type = type,
172
190
  area = area,
173
191
  command = command,
174
192
  ignoreSafeChannel = ignoreSafeChannel,
@@ -66,6 +66,8 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
66
66
  private var hasOpenSafeChannel: Boolean = false
67
67
  private var hasSetupPin: Boolean = false
68
68
  private var hasBackup: Boolean = false
69
+ private var pinStatusValid: Boolean = false
70
+ private var backupStatusValid: Boolean = false
69
71
  private var mCommandArea = CommandArea.None
70
72
 
71
73
  init {
@@ -224,8 +226,10 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
224
226
  )
225
227
  val res = command.send(this)
226
228
  printLog(TAG, "<--- getBackupStatus end: ${res.getCode()} area:${mCommandArea}")
229
+ backupStatusValid = res.isSuccess() && !res.isEmptyData()
230
+ OneKeyLog.info("LiteCard", "stage=backup_state_read readSucceeded=$backupStatusValid hasBackup=${res.isSuccess() && res.data == "02"}")
227
231
 
228
- if (!res.isSuccess()) {
232
+ if (!backupStatusValid) {
229
233
  return false
230
234
  }
231
235
 
@@ -239,8 +243,10 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
239
243
  )
240
244
  val res = command.send(this)
241
245
  printLog(TAG, "<--- getPinStatus end: ${res.getCode()} area:${mCommandArea}")
246
+ pinStatusValid = res.isSuccess() && !res.isEmptyData()
247
+ OneKeyLog.info("LiteCard", "stage=pin_state_read readSucceeded=$pinStatusValid isNewCard=${res.isSuccess() && res.data == "02"}")
242
248
 
243
- if (!res.isSuccess()) {
249
+ if (!pinStatusValid) {
244
250
  return false
245
251
  }
246
252
 
@@ -298,8 +304,10 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
298
304
  }
299
305
 
300
306
  loadPinStatus()
307
+ if (!pinStatusValid) throw NFCExceptions.ConnectionFailException()
301
308
  if (mCardType == AppleCardType.V2) {
302
309
  loadBackupStatus()
310
+ if (!backupStatusValid) throw NFCExceptions.ConnectionFailException()
303
311
  } else {
304
312
  hasBackup = hasSetupPin
305
313
  }
@@ -8,6 +8,28 @@
8
8
  #import "OKLiteCommandTool.h"
9
9
  #import "OKNFCBridge.h"
10
10
  #import "OKNFCUtility.h"
11
+ #import "LCLogger.h"
12
+
13
+ static NSString *OKLiteCommandName(OKLiteCommand command) {
14
+ switch (command) {
15
+ case OKLiteCommandSelectSecure: return @"select_secure";
16
+ case OKLiteCommandSelectBackup: return @"select_backup";
17
+ case OKLiteCommandGetCardSN: return @"get_serial";
18
+ case OKLiteCommandGetCardCert: return @"get_certificate";
19
+ case OKLiteCommandGetBackupStatus: return @"get_backup_status";
20
+ case OKLiteCommandGetPINStatus: return @"get_pin_status";
21
+ case OKLiteCommandSetPIN: return @"set_pin";
22
+ case OKLiteCommandChangePIN: return @"change_pin";
23
+ case OKLiteCommandVerifyPIN: return @"verify_pin";
24
+ case OKLiteCommandImportMnemonic: return @"backup_data";
25
+ case OKLiteCommandExportMnemonic: return @"export_data";
26
+ case OKLiteCommandWipeCard: return @"reset_card";
27
+ case OKLiteCommandPinRTL: return @"get_pin_retry_count";
28
+ case OKLiteCommandOpenChannel_1: return @"verify_certificate";
29
+ case OKLiteCommandOpenChannel_2: return @"verify_auth_data";
30
+ }
31
+ return @"unknown";
32
+ }
11
33
 
12
34
  @implementation OKLiteCommandTool
13
35
 
@@ -15,8 +37,15 @@
15
37
  modal:(OKLiteCommandModal *)modal
16
38
  completionHandler:(void(^)(NSData *responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString *parseRespon))completionHandler {
17
39
 
40
+ static NSUInteger nextCommandID = 0;
41
+ NSUInteger commandID;
42
+ @synchronized (OKLiteCommandTool.class) { commandID = ++nextCommandID; }
43
+ NSString *command = OKLiteCommandName(modal.command);
44
+ [LCLogger info:[NSString stringWithFormat:@"commandID=%lu command=%@ stage=send buildSucceeded=%d parseRequested=%d", (unsigned long)commandID, command, apdu != nil, modal.parseResp]];
18
45
  id<NFCISO7816Tag> tag = [self.delegate getNFCsessionTag];
19
46
  [tag sendCommandAPDU:apdu completionHandler:^(NSData *responseData, uint8_t sw1, uint8_t sw2, NSError *error) {
47
+ uint8_t rawSW1 = sw1;
48
+ uint8_t rawSW2 = sw2;
20
49
  NSString *parseRespon = nil;
21
50
  if (modal.parseResp) {
22
51
  parseRespon = [OKNFCBridge parseSafeAPDUResponse:responseData sw1:sw1 sw2:sw2];
@@ -25,6 +54,11 @@
25
54
  }
26
55
  }
27
56
 
57
+ BOOL coreNFCError = [error.domain isEqualToString:NFCErrorDomain];
58
+ [LCLogger info:[NSString stringWithFormat:@"commandID=%lu command=%@ stage=response rawSW1=%u rawSW2=%u effectiveSW1=%u effectiveSW2=%u responseDataBytes=%lu parseRequested=%d parsePresent=%d transportError=%d coreNFCError=%d errorCode=%ld", (unsigned long)commandID, command, rawSW1, rawSW2, sw1, sw2, (unsigned long)responseData.length, modal.parseResp, parseRespon != nil, error != nil, coreNFCError, (long)error.code]];
59
+ if (modal.command == OKLiteCommandGetBackupStatus || modal.command == OKLiteCommandGetPINStatus) {
60
+ [LCLogger info:[NSString stringWithFormat:@"commandID=%lu command=%@ stage=state_read readSucceeded=%d", (unsigned long)commandID, command, error == nil && sw1 == OKNFC_SW1_OK && responseData.length > 0]];
61
+ }
28
62
  [OKNFCUtility logAPDU:modal.desc response:responseData sw1:sw1 sw2:sw2 error:error];
29
63
  if (completionHandler) {
30
64
  completionHandler(responseData,sw1,sw2,error,parseRespon);
@@ -64,6 +64,7 @@
64
64
  JUB_UINT16 wRet = 0;
65
65
  JUB_CHAR_PTR pDecResp = nullptr;
66
66
  rv = JUB_GPC_ParseSafeAPDUResponse(c_data ,&wRet, &pDecResp);
67
+ [LCLogger info:[NSString stringWithFormat:@"stage=parse_safe_response parseReturnCode=%lu parsedSW=%u parsePresent=%d", (unsigned long)rv, wRet, pDecResp != nullptr]];
67
68
  if (JUBR_OK != rv) {
68
69
  return nil;
69
70
  }
@@ -98,6 +98,7 @@
98
98
 
99
99
  - (BOOL)syncLiteInfo {
100
100
 
101
+ self.status = OKNFCLiteStatusError;
101
102
  OKNFCLiteStatus status = OKNFCLiteStatusError;
102
103
  self.pinRTL = 0;
103
104
  NSUInteger PinStatus = OKNFC_PIN_ERROR;
@@ -112,6 +113,11 @@
112
113
  return NO;
113
114
  }
114
115
  PinStatus = [self getPINStatus];
116
+ [LCLogger info:[NSString stringWithFormat:@"stage=pin_state_read readSucceeded=%d", PinStatus != OKNFC_PIN_ERROR]];
117
+ if (PinStatus == OKNFC_PIN_ERROR) {
118
+ self.status = OKNFCLiteStatusError;
119
+ return NO;
120
+ }
115
121
  status = PinStatus == OKNFC_PIN_UNSET ? OKNFCLiteStatusNewCard : OKNFCLiteStatusActivated;
116
122
  self.status = status;
117
123
  self.pinRTL = PinStatus == OKNFC_PIN_UNSET ? 10 : PinStatus;
@@ -489,7 +495,7 @@
489
495
  [self.commandTool sendCommandWithAPDU:[modal buildAPDU]
490
496
  modal:modal
491
497
  completionHandler:^(NSData * _Nonnull responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString * _Nonnull parseRespon) {
492
- if (sw1 != OKNFC_SW1_OK) {
498
+ if (error != nil || sw1 != OKNFC_SW1_OK || responseData.length == 0) {
493
499
  [LCLogger error:@"获取 PIN 状态失败"];
494
500
  dispatch_semaphore_signal(sema);
495
501
  return;
@@ -501,12 +507,13 @@
501
507
  return;
502
508
  } else {
503
509
  OKLiteCommandModal *modal2 = [[OKLiteCommandModal alloc] initWithCommand:OKLiteCommandPinRTL version:self.version];
504
- [self.commandTool sendCommandWithAPDU:[modal2 buildAPDU] modal:modal completionHandler:^(NSData * _Nonnull responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString * _Nonnull parseRespon) {
505
- if (sw1 == OKNFC_SW1_OK) {
506
- unsigned int outVal;
510
+ [self.commandTool sendCommandWithAPDU:[modal2 buildAPDU] modal:modal2 completionHandler:^(NSData * _Nonnull responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString * _Nonnull parseRespon) {
511
+ if (error == nil && sw1 == OKNFC_SW1_OK && responseData.length > 0) {
512
+ unsigned int outVal = 0;
507
513
  NSScanner* scanner = [NSScanner scannerWithString:responseData.toHexString];
508
- [scanner scanHexInt:&outVal];
509
- pinStatus = outVal;
514
+ if ([scanner scanHexInt:&outVal]) {
515
+ pinStatus = outVal;
516
+ }
510
517
  }
511
518
  dispatch_semaphore_signal(sema);
512
519
  }];
@@ -30,7 +30,7 @@
30
30
 
31
31
  - (void)reset:(ResetCallback)callBack;
32
32
 
33
- - (void)setMnemonic:(NSString *)mnemonic withPin:(NSString *)pin overwrite:(BOOL)overwrite complete:(SetMnemonicCallback)complete;
33
+ - (void)setMnemonic:(NSString *)mnemonic withPin:(NSString *)pin overwrite:(BOOL)overwrite expectedSerial:(NSString * _Nullable)expectedSerial complete:(SetMnemonicCallback)complete;
34
34
 
35
35
  - (void)getMnemonicWithPin:(NSString *)pin complete:(GetMnemonicCallback)complete;
36
36
 
@@ -37,6 +37,7 @@
37
37
  @property (nonatomic, copy) NSString *pin;
38
38
  @property (nonatomic, copy) NSString *neoPin;
39
39
  @property (nonatomic, copy) NSString *exportMnemonic;
40
+ @property (nonatomic, copy) NSString *expectedSerial;
40
41
  @property (nonatomic, assign) BOOL certVerified;
41
42
  @property (nonatomic, assign) OKNFCLiteApp selectNFCApp;
42
43
  @property (nonatomic, strong) OKLiteV1 *lite;
@@ -132,6 +133,7 @@
132
133
  } break;
133
134
  case OKNFCLiteSessionTypeSetMnemonic:
134
135
  case OKNFCLiteSessionTypeSetMnemonicForce: {
136
+ self.expectedSerial = nil;
135
137
  SetMnemonicCallback callback = [self takeCompletionForKey:kSetMnemonicBlock];
136
138
  if (callback) {
137
139
  callback(self.lite, asCancel ? OKNFCLiteSetMncStatusCancel : OKNFCLiteSetMncStatusError);
@@ -274,6 +276,7 @@
274
276
  - (void)setMnemonic:(NSString *)mnemonic
275
277
  withPin:(NSString *)pin
276
278
  overwrite:(BOOL)overwrite
279
+ expectedSerial:(NSString * _Nullable)expectedSerial
277
280
  complete:(SetMnemonicCallback)complete {
278
281
 
279
282
  if (pin.length != OKNFC_PIN_LENGTH) {
@@ -282,6 +285,7 @@
282
285
  }
283
286
  self.pin = pin;
284
287
  self.exportMnemonic = mnemonic;
288
+ self.expectedSerial = expectedSerial;
285
289
  if(overwrite) {
286
290
  // 写入强制覆盖
287
291
  self.sessionType = OKNFCLiteSessionTypeSetMnemonicForce;
@@ -296,9 +300,21 @@
296
300
  - (void)_setMnemonic:(BOOL)force {
297
301
  NSString *mnemonic = self.exportMnemonic;
298
302
  NSString *pin = self.pin;
303
+ NSString *expectedSerial = self.expectedSerial;
304
+ self.expectedSerial = nil;
299
305
  // Clear sensitive data from properties immediately
300
306
  self.exportMnemonic = nil;
301
307
  self.pin = nil;
308
+ if (expectedSerial != nil) {
309
+ BOOL infoValid = [self.lite syncLiteInfo];
310
+ if (!infoValid || ![expectedSerial isEqualToString:self.lite.SN]) {
311
+ [self logSessionStage:infoValid ? @"identity_mismatch" : @"identity_read_failed" details:@"operation=setMnemonic"];
312
+ SetMnemonicCallback callback = [self takeCompletionForKey:kSetMnemonicBlock];
313
+ [self endNFCSessionWithError:YES];
314
+ if (callback) callback(self.lite, infoValid ? OKNFCLiteSetMncStatusSNNotMatch : OKNFCLiteSetMncStatusError);
315
+ return;
316
+ }
317
+ }
302
318
  __weak typeof(self) weakSelf = self;
303
319
  [self.lite setMnemonic:mnemonic withPin:pin overwrite:force complete:^(OKLiteV1 *lite, OKNFCLiteSetMncStatus status) {
304
320
  SetMnemonicCallback callback = [weakSelf takeCompletionForKey:kSetMnemonicBlock];
@@ -97,12 +97,12 @@ static RCTResponseSenderBlock OKLiteCallbackOnce(NSString *operation, RCTRespons
97
97
  }
98
98
  }
99
99
 
100
- - (void)setMnemonic:(NSString *)mnemonic pwd:(NSString *)pwd overwrite:(BOOL)overwrite callback:(RCTResponseSenderBlock)callBack
100
+ - (void)setMnemonic:(NSString *)mnemonic pwd:(NSString *)pwd overwrite:(BOOL)overwrite expectedSerial:(NSString * _Nullable)expectedSerial callback:(RCTResponseSenderBlock)callBack
101
101
  {
102
102
  callBack = OKLiteCallbackOnce(@"setMnemonic", callBack);
103
103
  if ([ReactNativeLiteCard checkSDKVaild:callBack]) {
104
104
  __block OKNFCManager *liteManager = [[OKNFCManager alloc] init];
105
- [liteManager setMnemonic:mnemonic withPin:pwd overwrite:overwrite complete:^(OKLiteV1 *lite, OKNFCLiteSetMncStatus status) {
105
+ [liteManager setMnemonic:mnemonic withPin:pwd overwrite:overwrite expectedSerial:expectedSerial complete:^(OKLiteV1 *lite, OKNFCLiteSetMncStatus status) {
106
106
  NSDictionary *cardInfo = [lite cardInfo];
107
107
  switch (status) {
108
108
  case OKNFCLiteSetMncStatusSuccess:
@@ -26,9 +26,9 @@ class OnekeyLite {
26
26
  OKLiteManager.checkNFCPermission(this.convertToPromise(resolve));
27
27
  });
28
28
  }
29
- setMnemonic(mnemonic, pwd, overwrite = false) {
29
+ setMnemonic(mnemonic, pwd, overwrite = false, expectedSerial) {
30
30
  return new Promise(resolve => {
31
- OKLiteManager.setMnemonic(mnemonic, pwd, overwrite, this.convertToPromise(resolve));
31
+ OKLiteManager.setMnemonic(mnemonic, pwd, overwrite, expectedSerial ?? null, this.convertToPromise(resolve));
32
32
  });
33
33
  }
34
34
  getMnemonicWithPin(pwd) {
@@ -45,7 +45,7 @@ type KeyValuePair = {
45
45
  export interface Spec extends TurboModule {
46
46
  getLiteInfo(callback: (error: CallbackError | null, data: CardInfo | null, cardInfo: CardInfo | null) => void): void;
47
47
  checkNFCPermission(callback: (error: CallbackError | null, data: boolean | null, cardInfo: CardInfo | null) => void): void;
48
- setMnemonic(mnemonic: string, pwd: string, overwrite: boolean, callback: (error: CallbackError | null, data: boolean | null, cardInfo: CardInfo | null) => void): void;
48
+ setMnemonic(mnemonic: string, pwd: string, overwrite: boolean, expectedSerial: string | null, callback: (error: CallbackError | null, data: boolean | null, cardInfo: CardInfo | null) => void): void;
49
49
  getMnemonicWithPin(pwd: string, callback: (error: CallbackError | null, data: string | null, cardInfo: CardInfo | null) => void): void;
50
50
  changePin(oldPin: string, newPin: string, callback: (error: CallbackError | null, data: boolean | null, cardInfo: CardInfo | null) => void): void;
51
51
  reset(callback: (error: CallbackError | null, data: boolean | null, cardInfo: CardInfo | null) => void): void;
@@ -9,7 +9,7 @@ declare class OnekeyLite {
9
9
  addAccordListener(): import("react-native").EventSubscription;
10
10
  getLiteInfo(): Promise<PromiseResult<CardInfo>>;
11
11
  checkNFCPermission(): Promise<PromiseResult<boolean>>;
12
- setMnemonic(mnemonic: string, pwd: string, overwrite?: boolean): Promise<PromiseResult<boolean>>;
12
+ setMnemonic(mnemonic: string, pwd: string, overwrite?: boolean, expectedSerial?: string): Promise<PromiseResult<boolean>>;
13
13
  getMnemonicWithPin(pwd: string): Promise<PromiseResult<string>>;
14
14
  changePin(oldPin: string, newPin: string): Promise<PromiseResult<boolean>>;
15
15
  reset(): Promise<PromiseResult<boolean>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-lite-card",
3
- "version": "6.7.0-alpha.444",
3
+ "version": "6.7.0-alpha.448",
4
4
  "description": "OneKey Lite NFC card operations and connection events for React Native",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -72,6 +72,7 @@ export interface Spec extends TurboModule {
72
72
  mnemonic: string,
73
73
  pwd: string,
74
74
  overwrite: boolean,
75
+ expectedSerial: string | null,
75
76
  callback: (
76
77
  error: CallbackError | null,
77
78
  data: boolean | null,
package/src/index.tsx CHANGED
@@ -39,12 +39,18 @@ class OnekeyLite {
39
39
  });
40
40
  }
41
41
 
42
- setMnemonic(mnemonic: string, pwd: string, overwrite = false) {
42
+ setMnemonic(
43
+ mnemonic: string,
44
+ pwd: string,
45
+ overwrite = false,
46
+ expectedSerial?: string
47
+ ) {
43
48
  return new Promise<PromiseResult<boolean>>((resolve) => {
44
49
  OKLiteManager.setMnemonic(
45
50
  mnemonic,
46
51
  pwd,
47
52
  overwrite,
53
+ expectedSerial ?? null,
48
54
  this.convertToPromise(resolve)
49
55
  );
50
56
  });