@onekeyfe/react-native-lite-card 6.7.0-alpha.448 → 6.7.0-alpha.449
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.
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/ReactNativeLiteCardModule.kt +0 -8
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt +1 -19
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +2 -10
- package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +0 -34
- package/ios/Classes/OKNFCBridge.mm +0 -1
- package/ios/Classes/OKNFTLite/OKLiteV1.m +6 -13
- package/ios/Classes/OKNFTLite/OKNFCManager.h +1 -1
- package/ios/Classes/OKNFTLite/OKNFCManager.m +0 -16
- package/ios/ReactNativeLiteCard.mm +2 -2
- package/lib/module/index.js +2 -2
- package/lib/typescript/src/NativeReactNativeLiteCard.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/NativeReactNativeLiteCard.ts +0 -1
- package/src/index.tsx +1 -7
|
@@ -16,7 +16,6 @@ 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
|
|
20
19
|
import com.onekeyfe.reactnativelitecard.onekeyLite.entitys.CardState
|
|
21
20
|
import com.onekeyfe.reactnativelitecard.utils.NfcPermissionUtils
|
|
22
21
|
import com.onekeyfe.reactnativelitecard.utils.Utils
|
|
@@ -308,7 +307,6 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
308
307
|
mnemonic: String?,
|
|
309
308
|
pwd: String?,
|
|
310
309
|
overwrite: Boolean,
|
|
311
|
-
expectedSerial: String?,
|
|
312
310
|
callback: Callback?
|
|
313
311
|
) {
|
|
314
312
|
if (pwd.isNullOrEmpty() || pwd.length != 6 || !pwd.all { it.isDigit() }) {
|
|
@@ -321,12 +319,6 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
321
319
|
}
|
|
322
320
|
launch {
|
|
323
321
|
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
|
-
}
|
|
330
322
|
OneKeyLog.debug("LiteCard","setMnemonic Obtain the device")
|
|
331
323
|
val isSuccess =
|
|
332
324
|
OneKeyLiteCard.setMnemonic(
|
package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
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
|
|
6
3
|
import com.google.gson.JsonObject
|
|
7
4
|
import com.google.gson.JsonParser
|
|
8
5
|
import org.haobtc.onekey.card.gpchannel.GPChannelNatives.nativeGPCParseAPDUResponse
|
|
@@ -51,7 +48,6 @@ enum class CommandType(val code: String) {
|
|
|
51
48
|
|
|
52
49
|
class Command(
|
|
53
50
|
private val cardType: AppleCardType,
|
|
54
|
-
private val type: CommandType,
|
|
55
51
|
val area: CommandArea,
|
|
56
52
|
val command: String,
|
|
57
53
|
private val ignoreSafeChannel: Boolean,
|
|
@@ -60,10 +56,6 @@ class Command(
|
|
|
60
56
|
private val hasOpenSafeChannel: Boolean,
|
|
61
57
|
val data: String,
|
|
62
58
|
) {
|
|
63
|
-
companion object {
|
|
64
|
-
private val diagnosticSequence = AtomicLong(0)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
59
|
private fun beforeConnecting(connection: Connection) {
|
|
68
60
|
val needOpenSafeChannel = useSafeChannel || (useSafeChannelWhenOpen && hasOpenSafeChannel)
|
|
69
61
|
val needCloseSafeChannel =
|
|
@@ -114,25 +106,16 @@ class Command(
|
|
|
114
106
|
}
|
|
115
107
|
|
|
116
108
|
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")
|
|
120
109
|
beforeConnecting(connection)
|
|
121
110
|
// buildApdu && parseResponse Use in pairs
|
|
122
111
|
val apdu = buildApdu()
|
|
123
|
-
OneKeyLog.info("LiteCard", "commandID=$commandID command=${type.code} stage=build buildSucceeded=${apdu.isNotEmpty()}")
|
|
124
112
|
if (apdu.isEmpty()) {
|
|
125
113
|
return SendResponse("0xFFFF", 0xFF.toByte(), 0xFF.toByte(), parseSuccess = false)
|
|
126
114
|
}
|
|
127
115
|
val result = Connection.send(connection.isoDep, apdu)
|
|
128
|
-
val
|
|
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)
|
|
116
|
+
val resultObject = CardResponse.objectFromData(parseResponse(result.rawResponse))
|
|
133
117
|
result.result = resultObject?.response ?: ""
|
|
134
118
|
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}")
|
|
136
119
|
return result
|
|
137
120
|
}
|
|
138
121
|
}
|
|
@@ -186,7 +169,6 @@ class CommandGenerator {
|
|
|
186
169
|
|
|
187
170
|
return Command(
|
|
188
171
|
cardType = cardType,
|
|
189
|
-
type = type,
|
|
190
172
|
area = area,
|
|
191
173
|
command = command,
|
|
192
174
|
ignoreSafeChannel = ignoreSafeChannel,
|
|
@@ -66,8 +66,6 @@ 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
|
|
71
69
|
private var mCommandArea = CommandArea.None
|
|
72
70
|
|
|
73
71
|
init {
|
|
@@ -226,10 +224,8 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
226
224
|
)
|
|
227
225
|
val res = command.send(this)
|
|
228
226
|
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"}")
|
|
231
227
|
|
|
232
|
-
if (!
|
|
228
|
+
if (!res.isSuccess()) {
|
|
233
229
|
return false
|
|
234
230
|
}
|
|
235
231
|
|
|
@@ -243,10 +239,8 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
243
239
|
)
|
|
244
240
|
val res = command.send(this)
|
|
245
241
|
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"}")
|
|
248
242
|
|
|
249
|
-
if (!
|
|
243
|
+
if (!res.isSuccess()) {
|
|
250
244
|
return false
|
|
251
245
|
}
|
|
252
246
|
|
|
@@ -304,10 +298,8 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
304
298
|
}
|
|
305
299
|
|
|
306
300
|
loadPinStatus()
|
|
307
|
-
if (!pinStatusValid) throw NFCExceptions.ConnectionFailException()
|
|
308
301
|
if (mCardType == AppleCardType.V2) {
|
|
309
302
|
loadBackupStatus()
|
|
310
|
-
if (!backupStatusValid) throw NFCExceptions.ConnectionFailException()
|
|
311
303
|
} else {
|
|
312
304
|
hasBackup = hasSetupPin
|
|
313
305
|
}
|
|
@@ -8,28 +8,6 @@
|
|
|
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
|
-
}
|
|
33
11
|
|
|
34
12
|
@implementation OKLiteCommandTool
|
|
35
13
|
|
|
@@ -37,15 +15,8 @@ static NSString *OKLiteCommandName(OKLiteCommand command) {
|
|
|
37
15
|
modal:(OKLiteCommandModal *)modal
|
|
38
16
|
completionHandler:(void(^)(NSData *responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString *parseRespon))completionHandler {
|
|
39
17
|
|
|
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]];
|
|
45
18
|
id<NFCISO7816Tag> tag = [self.delegate getNFCsessionTag];
|
|
46
19
|
[tag sendCommandAPDU:apdu completionHandler:^(NSData *responseData, uint8_t sw1, uint8_t sw2, NSError *error) {
|
|
47
|
-
uint8_t rawSW1 = sw1;
|
|
48
|
-
uint8_t rawSW2 = sw2;
|
|
49
20
|
NSString *parseRespon = nil;
|
|
50
21
|
if (modal.parseResp) {
|
|
51
22
|
parseRespon = [OKNFCBridge parseSafeAPDUResponse:responseData sw1:sw1 sw2:sw2];
|
|
@@ -54,11 +25,6 @@ static NSString *OKLiteCommandName(OKLiteCommand command) {
|
|
|
54
25
|
}
|
|
55
26
|
}
|
|
56
27
|
|
|
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
|
-
}
|
|
62
28
|
[OKNFCUtility logAPDU:modal.desc response:responseData sw1:sw1 sw2:sw2 error:error];
|
|
63
29
|
if (completionHandler) {
|
|
64
30
|
completionHandler(responseData,sw1,sw2,error,parseRespon);
|
|
@@ -64,7 +64,6 @@
|
|
|
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]];
|
|
68
67
|
if (JUBR_OK != rv) {
|
|
69
68
|
return nil;
|
|
70
69
|
}
|
|
@@ -98,7 +98,6 @@
|
|
|
98
98
|
|
|
99
99
|
- (BOOL)syncLiteInfo {
|
|
100
100
|
|
|
101
|
-
self.status = OKNFCLiteStatusError;
|
|
102
101
|
OKNFCLiteStatus status = OKNFCLiteStatusError;
|
|
103
102
|
self.pinRTL = 0;
|
|
104
103
|
NSUInteger PinStatus = OKNFC_PIN_ERROR;
|
|
@@ -113,11 +112,6 @@
|
|
|
113
112
|
return NO;
|
|
114
113
|
}
|
|
115
114
|
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
|
-
}
|
|
121
115
|
status = PinStatus == OKNFC_PIN_UNSET ? OKNFCLiteStatusNewCard : OKNFCLiteStatusActivated;
|
|
122
116
|
self.status = status;
|
|
123
117
|
self.pinRTL = PinStatus == OKNFC_PIN_UNSET ? 10 : PinStatus;
|
|
@@ -495,7 +489,7 @@
|
|
|
495
489
|
[self.commandTool sendCommandWithAPDU:[modal buildAPDU]
|
|
496
490
|
modal:modal
|
|
497
491
|
completionHandler:^(NSData * _Nonnull responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString * _Nonnull parseRespon) {
|
|
498
|
-
if (
|
|
492
|
+
if (sw1 != OKNFC_SW1_OK) {
|
|
499
493
|
[LCLogger error:@"获取 PIN 状态失败"];
|
|
500
494
|
dispatch_semaphore_signal(sema);
|
|
501
495
|
return;
|
|
@@ -507,13 +501,12 @@
|
|
|
507
501
|
return;
|
|
508
502
|
} else {
|
|
509
503
|
OKLiteCommandModal *modal2 = [[OKLiteCommandModal alloc] initWithCommand:OKLiteCommandPinRTL version:self.version];
|
|
510
|
-
[self.commandTool sendCommandWithAPDU:[modal2 buildAPDU] modal:
|
|
511
|
-
if (
|
|
512
|
-
unsigned int outVal
|
|
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;
|
|
513
507
|
NSScanner* scanner = [NSScanner scannerWithString:responseData.toHexString];
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
508
|
+
[scanner scanHexInt:&outVal];
|
|
509
|
+
pinStatus = outVal;
|
|
517
510
|
}
|
|
518
511
|
dispatch_semaphore_signal(sema);
|
|
519
512
|
}];
|
|
@@ -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
|
|
33
|
+
- (void)setMnemonic:(NSString *)mnemonic withPin:(NSString *)pin overwrite:(BOOL)overwrite complete:(SetMnemonicCallback)complete;
|
|
34
34
|
|
|
35
35
|
- (void)getMnemonicWithPin:(NSString *)pin complete:(GetMnemonicCallback)complete;
|
|
36
36
|
|
|
@@ -37,7 +37,6 @@
|
|
|
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;
|
|
41
40
|
@property (nonatomic, assign) BOOL certVerified;
|
|
42
41
|
@property (nonatomic, assign) OKNFCLiteApp selectNFCApp;
|
|
43
42
|
@property (nonatomic, strong) OKLiteV1 *lite;
|
|
@@ -133,7 +132,6 @@
|
|
|
133
132
|
} break;
|
|
134
133
|
case OKNFCLiteSessionTypeSetMnemonic:
|
|
135
134
|
case OKNFCLiteSessionTypeSetMnemonicForce: {
|
|
136
|
-
self.expectedSerial = nil;
|
|
137
135
|
SetMnemonicCallback callback = [self takeCompletionForKey:kSetMnemonicBlock];
|
|
138
136
|
if (callback) {
|
|
139
137
|
callback(self.lite, asCancel ? OKNFCLiteSetMncStatusCancel : OKNFCLiteSetMncStatusError);
|
|
@@ -276,7 +274,6 @@
|
|
|
276
274
|
- (void)setMnemonic:(NSString *)mnemonic
|
|
277
275
|
withPin:(NSString *)pin
|
|
278
276
|
overwrite:(BOOL)overwrite
|
|
279
|
-
expectedSerial:(NSString * _Nullable)expectedSerial
|
|
280
277
|
complete:(SetMnemonicCallback)complete {
|
|
281
278
|
|
|
282
279
|
if (pin.length != OKNFC_PIN_LENGTH) {
|
|
@@ -285,7 +282,6 @@
|
|
|
285
282
|
}
|
|
286
283
|
self.pin = pin;
|
|
287
284
|
self.exportMnemonic = mnemonic;
|
|
288
|
-
self.expectedSerial = expectedSerial;
|
|
289
285
|
if(overwrite) {
|
|
290
286
|
// 写入强制覆盖
|
|
291
287
|
self.sessionType = OKNFCLiteSessionTypeSetMnemonicForce;
|
|
@@ -300,21 +296,9 @@
|
|
|
300
296
|
- (void)_setMnemonic:(BOOL)force {
|
|
301
297
|
NSString *mnemonic = self.exportMnemonic;
|
|
302
298
|
NSString *pin = self.pin;
|
|
303
|
-
NSString *expectedSerial = self.expectedSerial;
|
|
304
|
-
self.expectedSerial = nil;
|
|
305
299
|
// Clear sensitive data from properties immediately
|
|
306
300
|
self.exportMnemonic = nil;
|
|
307
301
|
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
|
-
}
|
|
318
302
|
__weak typeof(self) weakSelf = self;
|
|
319
303
|
[self.lite setMnemonic:mnemonic withPin:pin overwrite:force complete:^(OKLiteV1 *lite, OKNFCLiteSetMncStatus status) {
|
|
320
304
|
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
|
|
100
|
+
- (void)setMnemonic:(NSString *)mnemonic pwd:(NSString *)pwd overwrite:(BOOL)overwrite 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
|
|
105
|
+
[liteManager setMnemonic:mnemonic withPin:pwd overwrite:overwrite complete:^(OKLiteV1 *lite, OKNFCLiteSetMncStatus status) {
|
|
106
106
|
NSDictionary *cardInfo = [lite cardInfo];
|
|
107
107
|
switch (status) {
|
|
108
108
|
case OKNFCLiteSetMncStatusSuccess:
|
package/lib/module/index.js
CHANGED
|
@@ -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) {
|
|
30
30
|
return new Promise(resolve => {
|
|
31
|
-
OKLiteManager.setMnemonic(mnemonic, pwd, overwrite,
|
|
31
|
+
OKLiteManager.setMnemonic(mnemonic, pwd, overwrite, 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,
|
|
48
|
+
setMnemonic(mnemonic: string, pwd: string, overwrite: boolean, 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
|
|
12
|
+
setMnemonic(mnemonic: string, pwd: string, overwrite?: boolean): 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.
|
|
3
|
+
"version": "6.7.0-alpha.449",
|
|
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",
|
package/src/index.tsx
CHANGED
|
@@ -39,18 +39,12 @@ class OnekeyLite {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
setMnemonic(
|
|
43
|
-
mnemonic: string,
|
|
44
|
-
pwd: string,
|
|
45
|
-
overwrite = false,
|
|
46
|
-
expectedSerial?: string
|
|
47
|
-
) {
|
|
42
|
+
setMnemonic(mnemonic: string, pwd: string, overwrite = false) {
|
|
48
43
|
return new Promise<PromiseResult<boolean>>((resolve) => {
|
|
49
44
|
OKLiteManager.setMnemonic(
|
|
50
45
|
mnemonic,
|
|
51
46
|
pwd,
|
|
52
47
|
overwrite,
|
|
53
|
-
expectedSerial ?? null,
|
|
54
48
|
this.convertToPromise(resolve)
|
|
55
49
|
);
|
|
56
50
|
});
|