@magicred-1/ble-mesh 1.2.0

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.
@@ -0,0 +1,27 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "KardNetworkBleMesh"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "14.0" }
14
+ s.source = { :git => "https://github.com/anthropics/kard-network-ble-mesh.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
17
+ s.swift_version = "5.0"
18
+
19
+ s.dependency "React-Core"
20
+
21
+ s.frameworks = "CoreBluetooth", "Security", "CryptoKit"
22
+
23
+ s.pod_target_xcconfig = {
24
+ 'DEFINES_MODULE' => 'YES',
25
+ 'SWIFT_OPTIMIZATION_LEVEL' => '-Onone'
26
+ }
27
+ end
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.BleMeshService = exports.BleMesh = void 0;
7
+ var _reactNative = require("react-native");
8
+ const LINKING_ERROR = `The package 'kard-network-ble-mesh' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
9
+ ios: "- You have run 'pod install'\n",
10
+ default: ''
11
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go (this package requires a development build)\n';
12
+ const BleMeshModule = _reactNative.NativeModules.BleMesh ? _reactNative.NativeModules.BleMesh : new Proxy({}, {
13
+ get() {
14
+ throw new Error(LINKING_ERROR);
15
+ }
16
+ });
17
+ const eventEmitter = new _reactNative.NativeEventEmitter(BleMeshModule);
18
+
19
+ // Types
20
+
21
+ // Event types
22
+
23
+ // Event listener types
24
+
25
+ class BleMeshService {
26
+ isInitialized = false;
27
+
28
+ // Request all required permissions for BLE mesh networking
29
+ async requestPermissions() {
30
+ if (_reactNative.Platform.OS === 'android') {
31
+ return this.requestAndroidPermissions();
32
+ } else if (_reactNative.Platform.OS === 'ios') {
33
+ return this.requestIOSPermissions();
34
+ }
35
+ throw new Error('Unsupported platform');
36
+ }
37
+ async requestAndroidPermissions() {
38
+ const apiLevel = _reactNative.Platform.Version;
39
+ let permissions = [];
40
+ if (apiLevel >= 31) {
41
+ // Android 12+ (API 31+)
42
+ permissions = [_reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE, _reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, _reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, _reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION];
43
+ } else {
44
+ // Android 11 and below
45
+ permissions = [_reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, _reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION];
46
+ }
47
+ const results = await _reactNative.PermissionsAndroid.requestMultiple(permissions);
48
+ const status = {
49
+ bluetooth: true,
50
+ location: results[_reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION] === 'granted'
51
+ };
52
+ if (apiLevel >= 31) {
53
+ status.bluetoothAdvertise = results[_reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE] === 'granted';
54
+ status.bluetoothConnect = results[_reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT] === 'granted';
55
+ status.bluetoothScan = results[_reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN] === 'granted';
56
+ status.bluetooth = status.bluetoothAdvertise && status.bluetoothConnect && status.bluetoothScan;
57
+ }
58
+ return status;
59
+ }
60
+ async requestIOSPermissions() {
61
+ // On iOS, Bluetooth permissions are requested automatically when starting services
62
+ // The native module handles the permission prompts
63
+ const result = await BleMeshModule.requestPermissions();
64
+ return {
65
+ bluetooth: result.bluetooth,
66
+ location: result.location
67
+ };
68
+ }
69
+
70
+ // Check current permission status without requesting
71
+ async checkPermissions() {
72
+ if (_reactNative.Platform.OS === 'android') {
73
+ return this.checkAndroidPermissions();
74
+ }
75
+ return BleMeshModule.checkPermissions();
76
+ }
77
+ async checkAndroidPermissions() {
78
+ const apiLevel = _reactNative.Platform.Version;
79
+ const fineLocation = await _reactNative.PermissionsAndroid.check(_reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
80
+ const status = {
81
+ bluetooth: true,
82
+ location: fineLocation
83
+ };
84
+ if (apiLevel >= 31) {
85
+ const advertise = await _reactNative.PermissionsAndroid.check(_reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE);
86
+ const connect = await _reactNative.PermissionsAndroid.check(_reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT);
87
+ const scan = await _reactNative.PermissionsAndroid.check(_reactNative.PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN);
88
+ status.bluetoothAdvertise = advertise;
89
+ status.bluetoothConnect = connect;
90
+ status.bluetoothScan = scan;
91
+ status.bluetooth = advertise && connect && scan;
92
+ }
93
+ return status;
94
+ }
95
+
96
+ // Initialize and start the mesh service
97
+ async start(config = {}) {
98
+ const {
99
+ nickname = 'anon',
100
+ autoRequestPermissions = true
101
+ } = config;
102
+ if (autoRequestPermissions) {
103
+ const permissions = await this.requestPermissions();
104
+ const hasAllPermissions = permissions.bluetooth && permissions.location;
105
+ if (!hasAllPermissions) {
106
+ throw new Error('Required permissions not granted. Bluetooth and Location permissions are required.');
107
+ }
108
+ }
109
+ await BleMeshModule.start(nickname);
110
+ this.isInitialized = true;
111
+ }
112
+
113
+ // Stop the mesh service
114
+ async stop() {
115
+ if (!this.isInitialized) return;
116
+ await BleMeshModule.stop();
117
+ this.isInitialized = false;
118
+ }
119
+
120
+ // Set the user's nickname
121
+ async setNickname(nickname) {
122
+ this.ensureInitialized();
123
+ await BleMeshModule.setNickname(nickname);
124
+ }
125
+
126
+ // Get the current peer ID
127
+ async getMyPeerId() {
128
+ this.ensureInitialized();
129
+ return BleMeshModule.getMyPeerId();
130
+ }
131
+
132
+ // Get the current nickname
133
+ async getMyNickname() {
134
+ this.ensureInitialized();
135
+ return BleMeshModule.getMyNickname();
136
+ }
137
+
138
+ // Get list of currently connected peers
139
+ async getPeers() {
140
+ this.ensureInitialized();
141
+ return BleMeshModule.getPeers();
142
+ }
143
+
144
+ // Send a public broadcast message to all peers
145
+ async sendMessage(content, channel) {
146
+ this.ensureInitialized();
147
+ return BleMeshModule.sendMessage(content, channel || null);
148
+ }
149
+
150
+ // Send a private encrypted message to a specific peer
151
+ async sendPrivateMessage(content, recipientPeerId) {
152
+ this.ensureInitialized();
153
+ return BleMeshModule.sendPrivateMessage(content, recipientPeerId);
154
+ }
155
+
156
+ // Send a file (broadcast or private)
157
+ async sendFile(filePath, options) {
158
+ this.ensureInitialized();
159
+ return BleMeshModule.sendFile(filePath, options?.recipientPeerId || null, options?.channel || null);
160
+ }
161
+
162
+ /**
163
+ * Send a Solana transaction for any peer to sign as second signer.
164
+ *
165
+ * @param serializedTransaction - Base64-encoded partially signed transaction
166
+ * @param options - Transaction options
167
+ * @param options.firstSignerPublicKey - Public key of the first signer (required)
168
+ * @param options.secondSignerPublicKey - Preferred second signer (optional, any peer can sign if not specified)
169
+ * @param options.description - Description of the transaction
170
+ * @param options.recipientPeerId - Specific peer to send to (optional, broadcasts to all if not specified)
171
+ */
172
+ async sendTransaction(serializedTransaction, options) {
173
+ this.ensureInitialized();
174
+ const txId = Math.random().toString(36).substring(2, 15);
175
+ return BleMeshModule.sendTransaction(txId, serializedTransaction, options?.recipientPeerId || null, options?.firstSignerPublicKey, options?.secondSignerPublicKey || null, options?.description || null);
176
+ }
177
+
178
+ // Respond to a received transaction (sign or reject)
179
+ async respondToTransaction(transactionId, recipientPeerId, response) {
180
+ this.ensureInitialized();
181
+ await BleMeshModule.respondToTransaction(transactionId, recipientPeerId, response.signedTransaction || null, response.error || null);
182
+ }
183
+
184
+ // Send a read receipt for a message
185
+ async sendReadReceipt(messageId, recipientPeerId) {
186
+ this.ensureInitialized();
187
+ await BleMeshModule.sendReadReceipt(messageId, recipientPeerId);
188
+ }
189
+
190
+ // Check if we have an encrypted session with a peer
191
+ async hasEncryptedSession(peerId) {
192
+ this.ensureInitialized();
193
+ return BleMeshModule.hasEncryptedSession(peerId);
194
+ }
195
+
196
+ // Initiate a Noise handshake with a peer
197
+ async initiateHandshake(peerId) {
198
+ this.ensureInitialized();
199
+ await BleMeshModule.initiateHandshake(peerId);
200
+ }
201
+ async sendSolanaNonceTransaction(transaction, recipientPeerId) {
202
+ this.ensureInitialized();
203
+ return BleMeshModule.sendSolanaNonceTransaction(transaction, recipientPeerId);
204
+ }
205
+
206
+ // Get the identity fingerprint for verification
207
+ async getIdentityFingerprint() {
208
+ this.ensureInitialized();
209
+ return BleMeshModule.getIdentityFingerprint();
210
+ }
211
+
212
+ // Get peer's fingerprint for verification
213
+ async getPeerFingerprint(peerId) {
214
+ this.ensureInitialized();
215
+ return BleMeshModule.getPeerFingerprint(peerId);
216
+ }
217
+
218
+ // Force a broadcast announce to refresh presence
219
+ async broadcastAnnounce() {
220
+ this.ensureInitialized();
221
+ await BleMeshModule.broadcastAnnounce();
222
+ }
223
+
224
+ // Event listeners
225
+ onPeerListUpdated(callback) {
226
+ const subscription = eventEmitter.addListener('onPeerListUpdated', callback);
227
+ return () => subscription.remove();
228
+ }
229
+ onMessageReceived(callback) {
230
+ const subscription = eventEmitter.addListener('onMessageReceived', callback);
231
+ return () => subscription.remove();
232
+ }
233
+ onFileReceived(callback) {
234
+ const subscription = eventEmitter.addListener('onFileReceived', callback);
235
+ return () => subscription.remove();
236
+ }
237
+ onTransactionReceived(callback) {
238
+ const subscription = eventEmitter.addListener('onTransactionReceived', callback);
239
+ return () => subscription.remove();
240
+ }
241
+ onTransactionResponse(callback) {
242
+ const subscription = eventEmitter.addListener('onTransactionResponse', callback);
243
+ return () => subscription.remove();
244
+ }
245
+ onConnectionStateChanged(callback) {
246
+ const subscription = eventEmitter.addListener('onConnectionStateChanged', callback);
247
+ return () => subscription.remove();
248
+ }
249
+ onReadReceipt(callback) {
250
+ const subscription = eventEmitter.addListener('onReadReceipt', callback);
251
+ return () => subscription.remove();
252
+ }
253
+ onDeliveryAck(callback) {
254
+ const subscription = eventEmitter.addListener('onDeliveryAck', callback);
255
+ return () => subscription.remove();
256
+ }
257
+ onError(callback) {
258
+ const subscription = eventEmitter.addListener('onError', callback);
259
+ return () => subscription.remove();
260
+ }
261
+ ensureInitialized() {
262
+ if (!this.isInitialized) {
263
+ throw new Error('BleMesh service not initialized. Call start() first.');
264
+ }
265
+ }
266
+ }
267
+
268
+ // Export singleton instance
269
+ exports.BleMeshService = BleMeshService;
270
+ const BleMesh = exports.BleMesh = new BleMeshService();
271
+
272
+ // Also export the class for those who want multiple instances
273
+ // Default export
274
+ var _default = exports.default = BleMesh;
275
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","BleMeshModule","NativeModules","BleMesh","Proxy","get","Error","eventEmitter","NativeEventEmitter","BleMeshService","isInitialized","requestPermissions","OS","requestAndroidPermissions","requestIOSPermissions","apiLevel","Version","permissions","PermissionsAndroid","PERMISSIONS","BLUETOOTH_ADVERTISE","BLUETOOTH_CONNECT","BLUETOOTH_SCAN","ACCESS_FINE_LOCATION","ACCESS_COARSE_LOCATION","results","requestMultiple","status","bluetooth","location","bluetoothAdvertise","bluetoothConnect","bluetoothScan","result","checkPermissions","checkAndroidPermissions","fineLocation","check","advertise","connect","scan","start","config","nickname","autoRequestPermissions","hasAllPermissions","stop","setNickname","ensureInitialized","getMyPeerId","getMyNickname","getPeers","sendMessage","content","channel","sendPrivateMessage","recipientPeerId","sendFile","filePath","options","sendTransaction","serializedTransaction","txId","Math","random","toString","substring","firstSignerPublicKey","secondSignerPublicKey","description","respondToTransaction","transactionId","response","signedTransaction","error","sendReadReceipt","messageId","hasEncryptedSession","peerId","initiateHandshake","sendSolanaNonceTransaction","transaction","getIdentityFingerprint","getPeerFingerprint","broadcastAnnounce","onPeerListUpdated","callback","subscription","addListener","remove","onMessageReceived","onFileReceived","onTransactionReceived","onTransactionResponse","onConnectionStateChanged","onReadReceipt","onDeliveryAck","onError","exports","_default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,gFAAgF,GAChFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,2EAA2E;AAE7E,MAAMC,aAAa,GAAGC,0BAAa,CAACC,OAAO,GACvCD,0BAAa,CAACC,OAAO,GACrB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMW,YAAY,GAAG,IAAIC,+BAAkB,CAACP,aAAa,CAAC;;AAE1D;;AA0FA;;AAUA;;AAGA,MAAMQ,cAAc,CAAC;EACXC,aAAa,GAAG,KAAK;;EAE7B;EACA,MAAMC,kBAAkBA,CAAA,EAA8B;IACpD,IAAId,qBAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAO,IAAI,CAACC,yBAAyB,CAAC,CAAC;IACzC,CAAC,MAAM,IAAIhB,qBAAQ,CAACe,EAAE,KAAK,KAAK,EAAE;MAChC,OAAO,IAAI,CAACE,qBAAqB,CAAC,CAAC;IACrC;IACA,MAAM,IAAIR,KAAK,CAAC,sBAAsB,CAAC;EACzC;EAEA,MAAcO,yBAAyBA,CAAA,EAA8B;IACnE,MAAME,QAAQ,GAAGlB,qBAAQ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AMC,YAAY,CAACE,MAAM,CAAC,CAAC;EACpC;EAEAQ,OAAOA,CAACX,QAAmC,EAAc;IACvD,MAAMC,YAAY,GAAGhF,YAAY,CAACiF,WAAW,CAAC,SAAS,EAAEF,QAAQ,CAAC;IAClE,OAAO,MAAMC,YAAY,CAACE,MAAM,CAAC,CAAC;EACpC;EAEQzC,iBAAiBA,CAAA,EAAS;IAChC,IAAI,CAAC,IAAI,CAACtC,aAAa,EAAE;MACvB,MAAM,IAAIJ,KAAK,CAAC,sDAAsD,CAAC;IACzE;EACF;AACF;;AAEA;AAAA4F,OAAA,CAAAzF,cAAA,GAAAA,cAAA;AACO,MAAMN,OAAO,GAAA+F,OAAA,CAAA/F,OAAA,GAAG,IAAIM,cAAc,CAAC,CAAC;;AAE3C;AAGA;AAAA,IAAA0F,QAAA,GAAAD,OAAA,CAAAlG,OAAA,GACeG,OAAO","ignoreList":[]}
@@ -0,0 +1,270 @@
1
+ import { NativeModules, NativeEventEmitter, Platform, PermissionsAndroid } from 'react-native';
2
+ const LINKING_ERROR = `The package 'kard-network-ble-mesh' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
+ ios: "- You have run 'pod install'\n",
4
+ default: ''
5
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go (this package requires a development build)\n';
6
+ const BleMeshModule = NativeModules.BleMesh ? NativeModules.BleMesh : new Proxy({}, {
7
+ get() {
8
+ throw new Error(LINKING_ERROR);
9
+ }
10
+ });
11
+ const eventEmitter = new NativeEventEmitter(BleMeshModule);
12
+
13
+ // Types
14
+
15
+ // Event types
16
+
17
+ // Event listener types
18
+
19
+ class BleMeshService {
20
+ isInitialized = false;
21
+
22
+ // Request all required permissions for BLE mesh networking
23
+ async requestPermissions() {
24
+ if (Platform.OS === 'android') {
25
+ return this.requestAndroidPermissions();
26
+ } else if (Platform.OS === 'ios') {
27
+ return this.requestIOSPermissions();
28
+ }
29
+ throw new Error('Unsupported platform');
30
+ }
31
+ async requestAndroidPermissions() {
32
+ const apiLevel = Platform.Version;
33
+ let permissions = [];
34
+ if (apiLevel >= 31) {
35
+ // Android 12+ (API 31+)
36
+ permissions = [PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION];
37
+ } else {
38
+ // Android 11 and below
39
+ permissions = [PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION];
40
+ }
41
+ const results = await PermissionsAndroid.requestMultiple(permissions);
42
+ const status = {
43
+ bluetooth: true,
44
+ location: results[PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION] === 'granted'
45
+ };
46
+ if (apiLevel >= 31) {
47
+ status.bluetoothAdvertise = results[PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE] === 'granted';
48
+ status.bluetoothConnect = results[PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT] === 'granted';
49
+ status.bluetoothScan = results[PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN] === 'granted';
50
+ status.bluetooth = status.bluetoothAdvertise && status.bluetoothConnect && status.bluetoothScan;
51
+ }
52
+ return status;
53
+ }
54
+ async requestIOSPermissions() {
55
+ // On iOS, Bluetooth permissions are requested automatically when starting services
56
+ // The native module handles the permission prompts
57
+ const result = await BleMeshModule.requestPermissions();
58
+ return {
59
+ bluetooth: result.bluetooth,
60
+ location: result.location
61
+ };
62
+ }
63
+
64
+ // Check current permission status without requesting
65
+ async checkPermissions() {
66
+ if (Platform.OS === 'android') {
67
+ return this.checkAndroidPermissions();
68
+ }
69
+ return BleMeshModule.checkPermissions();
70
+ }
71
+ async checkAndroidPermissions() {
72
+ const apiLevel = Platform.Version;
73
+ const fineLocation = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
74
+ const status = {
75
+ bluetooth: true,
76
+ location: fineLocation
77
+ };
78
+ if (apiLevel >= 31) {
79
+ const advertise = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE);
80
+ const connect = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT);
81
+ const scan = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN);
82
+ status.bluetoothAdvertise = advertise;
83
+ status.bluetoothConnect = connect;
84
+ status.bluetoothScan = scan;
85
+ status.bluetooth = advertise && connect && scan;
86
+ }
87
+ return status;
88
+ }
89
+
90
+ // Initialize and start the mesh service
91
+ async start(config = {}) {
92
+ const {
93
+ nickname = 'anon',
94
+ autoRequestPermissions = true
95
+ } = config;
96
+ if (autoRequestPermissions) {
97
+ const permissions = await this.requestPermissions();
98
+ const hasAllPermissions = permissions.bluetooth && permissions.location;
99
+ if (!hasAllPermissions) {
100
+ throw new Error('Required permissions not granted. Bluetooth and Location permissions are required.');
101
+ }
102
+ }
103
+ await BleMeshModule.start(nickname);
104
+ this.isInitialized = true;
105
+ }
106
+
107
+ // Stop the mesh service
108
+ async stop() {
109
+ if (!this.isInitialized) return;
110
+ await BleMeshModule.stop();
111
+ this.isInitialized = false;
112
+ }
113
+
114
+ // Set the user's nickname
115
+ async setNickname(nickname) {
116
+ this.ensureInitialized();
117
+ await BleMeshModule.setNickname(nickname);
118
+ }
119
+
120
+ // Get the current peer ID
121
+ async getMyPeerId() {
122
+ this.ensureInitialized();
123
+ return BleMeshModule.getMyPeerId();
124
+ }
125
+
126
+ // Get the current nickname
127
+ async getMyNickname() {
128
+ this.ensureInitialized();
129
+ return BleMeshModule.getMyNickname();
130
+ }
131
+
132
+ // Get list of currently connected peers
133
+ async getPeers() {
134
+ this.ensureInitialized();
135
+ return BleMeshModule.getPeers();
136
+ }
137
+
138
+ // Send a public broadcast message to all peers
139
+ async sendMessage(content, channel) {
140
+ this.ensureInitialized();
141
+ return BleMeshModule.sendMessage(content, channel || null);
142
+ }
143
+
144
+ // Send a private encrypted message to a specific peer
145
+ async sendPrivateMessage(content, recipientPeerId) {
146
+ this.ensureInitialized();
147
+ return BleMeshModule.sendPrivateMessage(content, recipientPeerId);
148
+ }
149
+
150
+ // Send a file (broadcast or private)
151
+ async sendFile(filePath, options) {
152
+ this.ensureInitialized();
153
+ return BleMeshModule.sendFile(filePath, options?.recipientPeerId || null, options?.channel || null);
154
+ }
155
+
156
+ /**
157
+ * Send a Solana transaction for any peer to sign as second signer.
158
+ *
159
+ * @param serializedTransaction - Base64-encoded partially signed transaction
160
+ * @param options - Transaction options
161
+ * @param options.firstSignerPublicKey - Public key of the first signer (required)
162
+ * @param options.secondSignerPublicKey - Preferred second signer (optional, any peer can sign if not specified)
163
+ * @param options.description - Description of the transaction
164
+ * @param options.recipientPeerId - Specific peer to send to (optional, broadcasts to all if not specified)
165
+ */
166
+ async sendTransaction(serializedTransaction, options) {
167
+ this.ensureInitialized();
168
+ const txId = Math.random().toString(36).substring(2, 15);
169
+ return BleMeshModule.sendTransaction(txId, serializedTransaction, options?.recipientPeerId || null, options?.firstSignerPublicKey, options?.secondSignerPublicKey || null, options?.description || null);
170
+ }
171
+
172
+ // Respond to a received transaction (sign or reject)
173
+ async respondToTransaction(transactionId, recipientPeerId, response) {
174
+ this.ensureInitialized();
175
+ await BleMeshModule.respondToTransaction(transactionId, recipientPeerId, response.signedTransaction || null, response.error || null);
176
+ }
177
+
178
+ // Send a read receipt for a message
179
+ async sendReadReceipt(messageId, recipientPeerId) {
180
+ this.ensureInitialized();
181
+ await BleMeshModule.sendReadReceipt(messageId, recipientPeerId);
182
+ }
183
+
184
+ // Check if we have an encrypted session with a peer
185
+ async hasEncryptedSession(peerId) {
186
+ this.ensureInitialized();
187
+ return BleMeshModule.hasEncryptedSession(peerId);
188
+ }
189
+
190
+ // Initiate a Noise handshake with a peer
191
+ async initiateHandshake(peerId) {
192
+ this.ensureInitialized();
193
+ await BleMeshModule.initiateHandshake(peerId);
194
+ }
195
+ async sendSolanaNonceTransaction(transaction, recipientPeerId) {
196
+ this.ensureInitialized();
197
+ return BleMeshModule.sendSolanaNonceTransaction(transaction, recipientPeerId);
198
+ }
199
+
200
+ // Get the identity fingerprint for verification
201
+ async getIdentityFingerprint() {
202
+ this.ensureInitialized();
203
+ return BleMeshModule.getIdentityFingerprint();
204
+ }
205
+
206
+ // Get peer's fingerprint for verification
207
+ async getPeerFingerprint(peerId) {
208
+ this.ensureInitialized();
209
+ return BleMeshModule.getPeerFingerprint(peerId);
210
+ }
211
+
212
+ // Force a broadcast announce to refresh presence
213
+ async broadcastAnnounce() {
214
+ this.ensureInitialized();
215
+ await BleMeshModule.broadcastAnnounce();
216
+ }
217
+
218
+ // Event listeners
219
+ onPeerListUpdated(callback) {
220
+ const subscription = eventEmitter.addListener('onPeerListUpdated', callback);
221
+ return () => subscription.remove();
222
+ }
223
+ onMessageReceived(callback) {
224
+ const subscription = eventEmitter.addListener('onMessageReceived', callback);
225
+ return () => subscription.remove();
226
+ }
227
+ onFileReceived(callback) {
228
+ const subscription = eventEmitter.addListener('onFileReceived', callback);
229
+ return () => subscription.remove();
230
+ }
231
+ onTransactionReceived(callback) {
232
+ const subscription = eventEmitter.addListener('onTransactionReceived', callback);
233
+ return () => subscription.remove();
234
+ }
235
+ onTransactionResponse(callback) {
236
+ const subscription = eventEmitter.addListener('onTransactionResponse', callback);
237
+ return () => subscription.remove();
238
+ }
239
+ onConnectionStateChanged(callback) {
240
+ const subscription = eventEmitter.addListener('onConnectionStateChanged', callback);
241
+ return () => subscription.remove();
242
+ }
243
+ onReadReceipt(callback) {
244
+ const subscription = eventEmitter.addListener('onReadReceipt', callback);
245
+ return () => subscription.remove();
246
+ }
247
+ onDeliveryAck(callback) {
248
+ const subscription = eventEmitter.addListener('onDeliveryAck', callback);
249
+ return () => subscription.remove();
250
+ }
251
+ onError(callback) {
252
+ const subscription = eventEmitter.addListener('onError', callback);
253
+ return () => subscription.remove();
254
+ }
255
+ ensureInitialized() {
256
+ if (!this.isInitialized) {
257
+ throw new Error('BleMesh service not initialized. Call start() first.');
258
+ }
259
+ }
260
+ }
261
+
262
+ // Export singleton instance
263
+ export const BleMesh = new BleMeshService();
264
+
265
+ // Also export the class for those who want multiple instances
266
+ export { BleMeshService };
267
+
268
+ // Default export
269
+ export default BleMesh;
270
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","PermissionsAndroid","LINKING_ERROR","select","ios","default","BleMeshModule","BleMesh","Proxy","get","Error","eventEmitter","BleMeshService","isInitialized","requestPermissions","OS","requestAndroidPermissions","requestIOSPermissions","apiLevel","Version","permissions","PERMISSIONS","BLUETOOTH_ADVERTISE","BLUETOOTH_CONNECT","BLUETOOTH_SCAN","ACCESS_FINE_LOCATION","ACCESS_COARSE_LOCATION","results","requestMultiple","status","bluetooth","location","bluetoothAdvertise","bluetoothConnect","bluetoothScan","result","checkPermissions","checkAndroidPermissions","fineLocation","check","advertise","connect","scan","start","config","nickname","autoRequestPermissions","hasAllPermissions","stop","setNickname","ensureInitialized","getMyPeerId","getMyNickname","getPeers","sendMessage","content","channel","sendPrivateMessage","recipientPeerId","sendFile","filePath","options","sendTransaction","serializedTransaction","txId","Math","random","toString","substring","firstSignerPublicKey","secondSignerPublicKey","description","respondToTransaction","transactionId","response","signedTransaction","error","sendReadReceipt","messageId","hasEncryptedSession","peerId","initiateHandshake","sendSolanaNonceTransaction","transaction","getIdentityFingerprint","getPeerFingerprint","broadcastAnnounce","onPeerListUpdated","callback","subscription","addListener","remove","onMessageReceived","onFileReceived","onTransactionReceived","onTransactionResponse","onConnectionStateChanged","onReadReceipt","onDeliveryAck","onError"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,EAAEC,kBAAkB,QAAoB,cAAc;AAE1G,MAAMC,aAAa,GACj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