@ukeyfe/react-native-nfc-litecard 1.0.3 → 1.0.5

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/dist/nfc-core.js CHANGED
@@ -140,7 +140,16 @@ function computeCommandCmac(sessionKey, cmdCtr, command) {
140
140
  input[1] = ctrHi;
141
141
  input.set(command, 2);
142
142
  const mac = (0, crypto_1.aesCmac)(sessionKey, input);
143
- return mac.slice(0, 8); // truncate to 8 bytes
143
+ return truncateCmac(mac);
144
+ }
145
+ /**
146
+ * Truncate a 16-byte CMAC to 8 bytes using the NXP MIFARE convention:
147
+ * select odd-indexed bytes (0-based): MAC[1], MAC[3], MAC[5], ..., MAC[15].
148
+ * NXP docs refer to these as "even-numbered bytes" using 1-based numbering.
149
+ * (First introduced in MIFARE Plus, see NXP AN13452.)
150
+ */
151
+ function truncateCmac(mac) {
152
+ return new Uint8Array([mac[1], mac[3], mac[5], mac[7], mac[9], mac[11], mac[13], mac[15]]);
144
153
  }
145
154
  /**
146
155
  * Compute the 8-byte truncated CMAC for an NFC response.
@@ -154,7 +163,7 @@ function computeResponseCmac(sessionKey, cmdCtr, responseData) {
154
163
  input[1] = ctrHi;
155
164
  input.set(responseData, 2);
156
165
  const mac = (0, crypto_1.aesCmac)(sessionKey, input);
157
- return mac.slice(0, 8);
166
+ return truncateCmac(mac);
158
167
  }
159
168
  // ===========================================================================
160
169
  // Low-level NFC transceive
package/dist/writer.js CHANGED
@@ -44,9 +44,6 @@ var __importStar = (this && this.__importStar) || (function () {
44
44
  return result;
45
45
  };
46
46
  })();
47
- var __importDefault = (this && this.__importDefault) || function (mod) {
48
- return (mod && mod.__esModule) ? mod : { "default": mod };
49
- };
50
47
  Object.defineProperty(exports, "__esModule", { value: true });
51
48
  exports.releaseNfcOperationLock = exports.isNfcOperationLocked = exports.NfcStatusCode = void 0;
52
49
  exports.initializeCard = initializeCard;
@@ -54,7 +51,6 @@ exports.updateCard = updateCard;
54
51
  exports.updatePassword = updatePassword;
55
52
  exports.writeUserNickname = writeUserNickname;
56
53
  exports.resetCard = resetCard;
57
- const react_native_nfc_manager_1 = __importDefault(require("react-native-nfc-manager"));
58
54
  const react_native_1 = require("react-native");
59
55
  const bip39 = __importStar(require("bip39"));
60
56
  const constants_1 = require("./constants");
@@ -95,7 +91,7 @@ async function writeUserMemory(data) {
95
91
  // Keep-alive every 4 pages to prevent iOS session timeout
96
92
  if ((i + 1) % constants_1.DELAY.KEEPALIVE_FREQ === 0) {
97
93
  try {
98
- await react_native_nfc_manager_1.default.sendMifareCommandIOS([0x30, 0x00]);
94
+ await (0, nfc_core_1.transceive)([constants_1.CMD_READ, 0x00]);
99
95
  }
100
96
  catch { /* non-fatal */ }
101
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukeyfe/react-native-nfc-litecard",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
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",