@ukeyfe/react-native-nfc-litecard 1.0.3 → 1.0.4
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 +10 -2
- package/dist/writer.js +1 -5
- package/package.json +1 -1
package/dist/nfc-core.js
CHANGED
|
@@ -140,7 +140,15 @@ 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
|
|
143
|
+
return truncateCmac(mac);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Truncate a 16-byte CMAC to 8 bytes using the MIFARE convention:
|
|
147
|
+
* select even-indexed bytes: MAC[0], MAC[2], MAC[4], ..., MAC[14].
|
|
148
|
+
* (First introduced in MIFARE Plus, see NXP AN13452.)
|
|
149
|
+
*/
|
|
150
|
+
function truncateCmac(mac) {
|
|
151
|
+
return new Uint8Array([mac[0], mac[2], mac[4], mac[6], mac[8], mac[10], mac[12], mac[14]]);
|
|
144
152
|
}
|
|
145
153
|
/**
|
|
146
154
|
* Compute the 8-byte truncated CMAC for an NFC response.
|
|
@@ -154,7 +162,7 @@ function computeResponseCmac(sessionKey, cmdCtr, responseData) {
|
|
|
154
162
|
input[1] = ctrHi;
|
|
155
163
|
input.set(responseData, 2);
|
|
156
164
|
const mac = (0, crypto_1.aesCmac)(sessionKey, input);
|
|
157
|
-
return mac
|
|
165
|
+
return truncateCmac(mac);
|
|
158
166
|
}
|
|
159
167
|
// ===========================================================================
|
|
160
168
|
// 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
|
|
94
|
+
await (0, nfc_core_1.transceive)([constants_1.CMD_READ, 0x00]);
|
|
99
95
|
}
|
|
100
96
|
catch { /* non-fatal */ }
|
|
101
97
|
}
|