@magicred-1/ble-mesh 1.2.4 → 1.2.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.
Files changed (2) hide show
  1. package/README.md +87 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -108,6 +108,35 @@ interface MeshServiceConfig {
108
108
 
109
109
  Stops the mesh service and disconnects from all peers.
110
110
 
111
+ ##### `requestPermissions(): Promise<PermissionStatus>`
112
+
113
+ Requests all required Bluetooth and location permissions. Called automatically by `start()` unless `autoRequestPermissions: false`.
114
+
115
+ ```typescript
116
+ interface PermissionStatus {
117
+ bluetooth: boolean;
118
+ bluetoothAdvertise?: boolean; // Android 12+
119
+ bluetoothConnect?: boolean; // Android 12+
120
+ bluetoothScan?: boolean; // Android 12+
121
+ location: boolean;
122
+ }
123
+
124
+ const permissions = await BleMesh.requestPermissions();
125
+ if (!permissions.bluetooth || !permissions.location) {
126
+ console.error('Required permissions not granted');
127
+ }
128
+ ```
129
+
130
+ ##### `checkPermissions(): Promise<PermissionStatus>`
131
+
132
+ Checks current permission status without requesting. Useful for showing permission UI state.
133
+
134
+ ```typescript
135
+ const permissions = await BleMesh.checkPermissions();
136
+ console.log('Bluetooth enabled:', permissions.bluetooth);
137
+ console.log('Location enabled:', permissions.location);
138
+ ```
139
+
111
140
  ##### `setNickname(nickname: string): Promise<void>`
112
141
 
113
142
  Updates your nickname and broadcasts the change to peers.
@@ -226,23 +255,76 @@ await BleMesh.respondToTransaction(txId, senderPeerId, {
226
255
 
227
256
  ##### `hasEncryptedSession(peerId: string): Promise<boolean>`
228
257
 
229
- Checks if an encrypted session exists with the specified peer.
258
+ Checks if an encrypted session exists with the specified peer. Useful for verifying secure communication is established before sending sensitive data.
259
+
260
+ ```typescript
261
+ const hasSession = await BleMesh.hasEncryptedSession(peerId);
262
+ if (hasSession) {
263
+ console.log('Secure session active');
264
+ } else {
265
+ console.log('No encrypted session - need handshake');
266
+ }
267
+ ```
230
268
 
231
269
  ##### `initiateHandshake(peerId: string): Promise<void>`
232
270
 
233
- Initiates a Noise handshake with a peer for encrypted communication.
271
+ Initiates a Noise handshake with a peer for encrypted communication. Required before sending private messages or transactions.
272
+
273
+ ```typescript
274
+ // Manually establish encrypted session
275
+ await BleMesh.initiateHandshake(peerId);
276
+ await new Promise(resolve => setTimeout(resolve, 500)); // Wait for completion
277
+
278
+ // Now send encrypted data
279
+ await BleMesh.sendPrivateMessage('Secret data', peerId);
280
+ ```
281
+
282
+ ##### `sendSolanaNonceTransaction(transaction: SolanaNonceTransaction, recipientPeerId: string): Promise<string>`
283
+
284
+ Sends a durable transaction using Solana nonce accounts for offline transaction signing.
285
+
286
+ ```typescript
287
+ interface SolanaNonceTransaction {
288
+ recentBlockhash: string;
289
+ nonceAccount: string;
290
+ nonceAuthority: string;
291
+ feePayer: string;
292
+ instructions: Array<{
293
+ programId: string;
294
+ keys: Array<{ pubkey: string; isSigner: boolean; isWritable: boolean }>;
295
+ data: string; // base64 encoded
296
+ }>;
297
+ }
298
+
299
+ const txId = await BleMesh.sendSolanaNonceTransaction({
300
+ recentBlockhash: nonceAccountValue,
301
+ nonceAccount: nonceAccountPubkey,
302
+ nonceAuthority: authorityPubkey,
303
+ feePayer: feePayerPubkey,
304
+ instructions: [/* ... */]
305
+ }, recipientPeerId);
306
+ ```
234
307
 
235
308
  ##### `getIdentityFingerprint(): Promise<string>`
236
309
 
237
- Returns your identity fingerprint for verification.
310
+ Returns your identity fingerprint for verification. Share this with peers to verify your identity.
238
311
 
239
312
  ##### `getPeerFingerprint(peerId: string): Promise<string | null>`
240
313
 
241
- Returns a peer's identity fingerprint for verification.
314
+ Returns a peer's identity fingerprint for verification. Compare with their shared fingerprint to verify identity.
315
+
316
+ ```typescript
317
+ const peerFingerprint = await BleMesh.getPeerFingerprint(peerId);
318
+ if (peerFingerprint === sharedFingerprint) {
319
+ console.log('Identity verified!');
320
+ } else {
321
+ console.warn('Identity mismatch - possible MITM attack');
322
+ }
323
+ ```
242
324
 
243
325
  ##### `broadcastAnnounce(): Promise<void>`
244
326
 
245
- Forces a broadcast announce to refresh your presence on the mesh.
327
+ Forces a broadcast announce to refresh your presence on the mesh. Useful for re-announcing after network connectivity changes.
246
328
 
247
329
  #### Events
248
330
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicred-1/ble-mesh",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
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",