@ukeyfe/react-native-nfc-litecard 1.0.8 → 1.0.10

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -745,13 +745,19 @@ async function readMnemonic(password, onCardIdentified) {
745
745
  }
746
746
  const aesKey = passwordToAesKey(password);
747
747
  await authenticate(aesKey);
748
+ let finalRetryCount;
749
+ try {
750
+ await writeRetryCountInSession(DEFAULT_PIN_RETRY_COUNT);
751
+ finalRetryCount = DEFAULT_PIN_RETRY_COUNT;
752
+ } catch {
753
+ }
748
754
  onCardIdentified?.();
749
755
  const data = await readUserMemory();
750
756
  const mnemonicData = data.slice(0, MNEMONIC_MEMORY_SIZE);
751
757
  if (mnemonicData.every((b) => b === 0)) {
752
758
  await releaseNfcTech();
753
759
  releaseNfcLock();
754
- return { code: NfcStatusCode.CHECK_EMPTY, success: false };
760
+ return { code: NfcStatusCode.CHECK_EMPTY, success: false, data: { retryCount: finalRetryCount } };
755
761
  }
756
762
  const result = entropyToMnemonic2(data);
757
763
  let nickname;
@@ -759,12 +765,6 @@ async function readMnemonic(password, onCardIdentified) {
759
765
  nickname = await readUserNicknameInternal();
760
766
  } catch {
761
767
  }
762
- let finalRetryCount;
763
- try {
764
- await writeRetryCountInSession(DEFAULT_PIN_RETRY_COUNT);
765
- finalRetryCount = DEFAULT_PIN_RETRY_COUNT;
766
- } catch {
767
- }
768
768
  await releaseNfcTech();
769
769
  releaseNfcLock();
770
770
  return {
@@ -1016,6 +1016,9 @@ async function writeUserMemory(data) {
1016
1016
  const offset = i * PAGE_SIZE;
1017
1017
  const pageData = Array.from(buffer.slice(offset, offset + PAGE_SIZE));
1018
1018
  await writePage(page, pageData);
1019
+ if (import_react_native3.Platform.OS === "android" && i < totalPages - 1) {
1020
+ await new Promise((r) => setTimeout(r, 10));
1021
+ }
1019
1022
  }
1020
1023
  }
1021
1024
  async function writeAesKey(key) {
@@ -1024,7 +1027,10 @@ async function writeAesKey(key) {
1024
1027
  const off = (3 - i) * 4;
1025
1028
  const pageData = [key[off + 3], key[off + 2], key[off + 1], key[off + 0]];
1026
1029
  await writePage(page, pageData);
1027
- if (import_react_native3.Platform.OS === "ios" && i < 3) await new Promise((r) => setTimeout(r, DELAY.IOS_KEY_WRITE));
1030
+ if (i < 3) {
1031
+ const delay = import_react_native3.Platform.OS === "ios" ? DELAY.IOS_KEY_WRITE : 10;
1032
+ await new Promise((r) => setTimeout(r, delay));
1033
+ }
1028
1034
  }
1029
1035
  }
1030
1036
  async function writeNicknameToCard(nickname) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukeyfe/react-native-nfc-litecard",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "NFC read/write for MIFARE Ultralight AES (LiteCard mnemonic storage)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",