@magicred-1/ble-mesh 1.3.2 → 1.3.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.
@@ -1211,16 +1211,25 @@ class BleMeshModule(reactContext: ReactApplicationContext) : ReactContextBaseJav
1211
1211
 
1212
1212
  private fun handleNoiseHandshake(packet: BitchatPacket, senderId: String) {
1213
1213
  Log.d(TAG, "Received handshake from $senderId, payload size: ${packet.payload.size}")
1214
+ Log.d(TAG, "Payload hex (first 100 bytes): ${packet.payload.take(100).joinToString("") { "%02x".format(it) }}")
1214
1215
 
1215
- if (packet.payload.size != 65) {
1216
- Log.e(TAG, "Invalid handshake payload size: ${packet.payload.size}, expected 65")
1216
+ // Extract EC public key from payload (should be 65 bytes, but payload might include extra data)
1217
+ val publicKeySize = 65
1218
+ if (packet.payload.size < publicKeySize) {
1219
+ Log.e(TAG, "Invalid handshake payload size: ${packet.payload.size}, expected at least $publicKeySize")
1217
1220
  return
1218
1221
  }
1222
+
1223
+ val publicKeyBytes = packet.payload.copyOfRange(0, publicKeySize)
1224
+ Log.d(TAG, "Extracted public key: ${publicKeyBytes.size} bytes")
1225
+
1226
+ val publicKeyBytes = packet.payload.copyOfRange(0, publicKeySize)
1227
+ Log.d(TAG, "Extracted public key: ${publicKeyBytes.size} bytes")
1219
1228
 
1220
1229
  try {
1221
1230
  // Derive shared secret
1222
1231
  val keyFactory = java.security.KeyFactory.getInstance("EC")
1223
- val keySpec = java.security.spec.X509EncodedKeySpec(packet.payload)
1232
+ val keySpec = java.security.spec.X509EncodedKeySpec(publicKeyBytes)
1224
1233
  val peerPublicKey = keyFactory.generatePublic(keySpec)
1225
1234
 
1226
1235
  val keyAgreement = KeyAgreement.getInstance("ECDH")
@@ -1236,7 +1245,7 @@ class BleMeshModule(reactContext: ReactApplicationContext) : ReactContextBaseJav
1236
1245
 
1237
1246
  // Update peer's noise public key
1238
1247
  peers[senderId]?.let { peer ->
1239
- peers[senderId] = peer.copy(noisePublicKey = packet.payload)
1248
+ peers[senderId] = peer.copy(noisePublicKey = publicKeyBytes)
1240
1249
  }
1241
1250
 
1242
1251
  // Send response handshake
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicred-1/ble-mesh",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "BLE Mesh networking library for React Native with seamless permissions",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",