bridgefy-react-native 1.0.4 → 1.1.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.
Files changed (34) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/gradle.properties +3 -3
  3. package/android/src/main/java/me/bridgefy/plugin/react_native/BridgefyReactNativeModule.kt +62 -31
  4. package/ios/BridgefyReactNative.m +3 -1
  5. package/ios/BridgefyReactNative.swift +20 -13
  6. package/ios/Frameworks/BridgefySDK.xcframework/Info.plist +5 -5
  7. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/BridgefySDK +0 -0
  8. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Info.plist +0 -0
  9. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.abi.json +1833 -1130
  10. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.private.swiftinterface +15 -7
  11. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  12. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.swiftinterface +15 -7
  13. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/_CodeSignature/CodeResources +11 -11
  14. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/DWARF/BridgefySDK +0 -0
  15. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/BridgefySDK +0 -0
  16. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Info.plist +0 -0
  17. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.abi.json +1833 -1130
  18. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +15 -7
  19. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  20. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +15 -7
  21. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1833 -1130
  22. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +15 -7
  23. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  24. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +15 -7
  25. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/_CodeSignature/CodeResources +21 -21
  26. package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/DWARF/BridgefySDK +0 -0
  27. package/lib/commonjs/index.js +5 -6
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/module/index.js +5 -6
  30. package/lib/module/index.js.map +1 -1
  31. package/lib/typescript/index.d.ts +2 -4
  32. package/lib/typescript/index.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/index.tsx +7 -6
@@ -8,7 +8,7 @@ buildscript {
8
8
  }
9
9
 
10
10
  dependencies {
11
- classpath "com.android.tools.build:gradle:7.2.1"
11
+ classpath "com.android.tools.build:gradle:8.1.1"
12
12
  // noinspection DifferentKotlinGradleVersion
13
13
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
14
  }
@@ -85,7 +85,7 @@ repositories {
85
85
  def kotlin_version = getExtOrDefault("kotlinVersion")
86
86
 
87
87
  dependencies {
88
- implementation (group: "me.bridgefy", name: "android-sdk", version: "1.0.4", ext: "aar") {
88
+ implementation (group: "me.bridgefy", name: "android-sdk", version: "1.1.0", ext: "aar") {
89
89
  transitive = true
90
90
  }
91
91
  // For < 0.71, this will be from the local maven repo
@@ -1,5 +1,5 @@
1
- BridgefyReactNative_kotlinVersion=1.7.0
1
+ BridgefyReactNative_kotlinVersion=1.9.10
2
2
  BridgefyReactNative_minSdkVersion=21
3
- BridgefyReactNative_targetSdkVersion=31
4
- BridgefyReactNative_compileSdkVersion=31
3
+ BridgefyReactNative_targetSdkVersion=34
4
+ BridgefyReactNative_compileSdkVersion=34
5
5
  BridgefyReactNative_ndkversion=21.4.7075529
@@ -1,11 +1,12 @@
1
1
  package me.bridgefy.plugin.react_native
2
2
 
3
+ import android.util.Log
3
4
  import com.facebook.react.bridge.Arguments
5
+ import com.facebook.react.bridge.Promise
4
6
  import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.bridge.ReactContext
5
8
  import com.facebook.react.bridge.ReactContextBaseJavaModule
6
9
  import com.facebook.react.bridge.ReactMethod
7
- import com.facebook.react.bridge.Promise
8
- import com.facebook.react.bridge.ReactContext
9
10
  import com.facebook.react.bridge.ReadableMap
10
11
  import com.facebook.react.bridge.WritableMap
11
12
  import com.facebook.react.modules.core.DeviceEventManagerModule
@@ -30,15 +31,14 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
30
31
  }
31
32
 
32
33
  @ReactMethod
33
- fun initialize(apiKey: String,
34
- propagationProfile: String,
35
- promise: Promise) {
36
- val profile = propagationProfileFromString(propagationProfile)
34
+ fun initialize(
35
+ apiKey: String,
36
+ verboseLogging: Boolean = false,
37
+ promise: Promise,
38
+ ) {
37
39
  try {
38
40
  bridgefy.init(
39
- null,
40
41
  UUID.fromString(apiKey),
41
- profile!!,
42
42
  object : BridgefyDelegate {
43
43
  override fun onConnected(peerID: UUID) {
44
44
  val params = Arguments.createMap().apply {
@@ -53,14 +53,14 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
53
53
  }
54
54
  }
55
55
 
56
- override fun onConnectedSecurely(peerID: UUID) {
56
+ override fun onEstablishSecureConnection(userId: UUID) {
57
57
  val params = Arguments.createMap().apply {
58
- putString("userId", peerID.toString())
58
+ putString("userId", userId.toString())
59
59
  }
60
60
  sendEvent(
61
61
  reactApplicationContext,
62
62
  "bridgefyDidEstablishSecureConnection",
63
- params
63
+ params,
64
64
  )
65
65
  }
66
66
 
@@ -71,10 +71,10 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
71
71
  sendEvent(reactApplicationContext, "bridgefyDidDisconnect", params)
72
72
  }
73
73
 
74
- // TODO: iOS provides BridgefyError
75
- override fun onFailToSend(messageID: UUID) {
74
+ override fun onFailToSend(messageID: UUID, error: BridgefyException) {
76
75
  val params = Arguments.createMap().apply {
77
76
  putString("messageId", messageID.toString())
77
+ putMap("error", mapFromBridgefyException(error))
78
78
  }
79
79
  sendEvent(reactApplicationContext, "bridgefyDidFailSendingMessage", params)
80
80
  }
@@ -102,10 +102,10 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
102
102
  sendEvent(reactApplicationContext, "bridgefyDidSendDataProgress", params)
103
103
  }
104
104
 
105
- override fun onReceive(
105
+ override fun onReceiveData(
106
106
  data: ByteArray,
107
107
  messageID: UUID,
108
- transmissionMode: TransmissionMode
108
+ transmissionMode: TransmissionMode,
109
109
  ) {
110
110
  val params = Arguments.createMap().apply {
111
111
  putString("data", String(data))
@@ -129,14 +129,30 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
129
129
  sendEvent(reactApplicationContext, "bridgefyDidStart", params)
130
130
  }
131
131
 
132
- // TODO: bridgefyDidFailToEstablishSecureConnection
133
- // TODO: bridgefyDidDestroySession
134
- // TODO: bridgefyDidFailToDestroySession
132
+ override fun onFailToEstablishSecureConnection(userId: UUID, error: BridgefyException) {
133
+ val params = Arguments.createMap().apply {
134
+ putString("userId", userId.toString())
135
+ putMap("error", mapFromBridgefyException(error))
136
+ }
137
+ sendEvent(reactApplicationContext, "bridgefyDidFailToEstablishSecureConnection", params)
138
+ }
139
+
140
+ override fun onDestroySession() {
141
+ sendEvent(reactApplicationContext, "bridgefyDidDestroySession", null)
142
+ }
143
+
144
+ override fun onFailToDestroySession(error: BridgefyException) {
145
+ val params = Arguments.createMap().apply {
146
+ putMap("error", mapFromBridgefyException(error))
147
+ }
148
+ sendEvent(reactApplicationContext, "bridgefyDidFailToDestroySession", params)
149
+ }
135
150
 
136
151
  override fun onStopped() {
137
152
  sendEvent(reactApplicationContext, "bridgefyDidStop", null)
138
153
  }
139
- }
154
+ },
155
+ if (verboseLogging) Log.DEBUG else 1,
140
156
  )
141
157
  promise.resolve(null)
142
158
  } catch (error: BridgefyException) {
@@ -146,8 +162,16 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
146
162
  }
147
163
 
148
164
  @ReactMethod
149
- fun start(promise: Promise) {
150
- bridgefy.start()
165
+ fun start(
166
+ customUserID: String?,
167
+ propagationProfile: String,
168
+ promise: Promise,
169
+ ) {
170
+ val profile = propagationProfileFromString(propagationProfile)
171
+ bridgefy.start(
172
+ customUserID?.let { UUID.fromString(it) },
173
+ profile ?: PropagationProfile.Standard,
174
+ )
151
175
  promise.resolve(null)
152
176
  }
153
177
 
@@ -156,9 +180,11 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
156
180
  val mode = transmissionModeFromMap(transmissionMode)!!
157
181
  try {
158
182
  val uuid = bridgefy.send(data.toByteArray(), mode)
159
- promise.resolve(Arguments.createMap().apply {
160
- putString("messageId", uuid.toString())
161
- })
183
+ promise.resolve(
184
+ Arguments.createMap().apply {
185
+ putString("messageId", uuid.toString())
186
+ },
187
+ )
162
188
  } catch (error: BridgefyException) {
163
189
  val map = mapFromBridgefyException(error)
164
190
  promise.reject(map.getString("code"), map.getString("message"), error)
@@ -173,8 +199,11 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
173
199
 
174
200
  @ReactMethod
175
201
  fun connectedPeers(promise: Promise) {
176
- promise.resolve(arrayOf<String>())
177
- TODO("Android impl")
202
+ val peers = bridgefy.connectedPeers().getOrNull()
203
+ val nodes = Arguments.createArray().apply {
204
+ peers?.forEach { pushString(it.toString()) }
205
+ }
206
+ promise.resolve(Arguments.createMap().apply { putArray("connectedPeers", nodes) })
178
207
  }
179
208
 
180
209
  @ReactMethod
@@ -191,7 +220,7 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
191
220
 
192
221
  @ReactMethod
193
222
  fun currentUserID(promise: Promise) {
194
- val userId = bridgefy.currentBridgefyUser()
223
+ val userId = bridgefy.currentUserId().getOrThrow()
195
224
  promise.resolve(Arguments.createMap().apply {
196
225
  putString("userId", userId.toString())
197
226
  })
@@ -206,10 +235,12 @@ class BridgefyReactNativeModule(reactContext: ReactApplicationContext) :
206
235
 
207
236
  @ReactMethod
208
237
  fun licenseExpirationDate(promise: Promise) {
209
- val date = bridgefy.licenseExpirationDate()
210
- promise.resolve(Arguments.createMap().apply {
211
- putString("licenseExpirationDate", date?.time.toString())
212
- })
238
+ val date = bridgefy.licenseExpirationDate().getOrThrow()
239
+ promise.resolve(
240
+ Arguments.createMap().apply {
241
+ putString("licenseExpirationDate", date?.time.toString())
242
+ },
243
+ )
213
244
  }
214
245
 
215
246
  companion object {
@@ -8,7 +8,9 @@ RCT_EXTERN_METHOD(initialize:(NSString *)apiKey
8
8
  resolve:(RCTPromiseResolveBlock)resolve
9
9
  reject:(RCTPromiseRejectBlock)reject)
10
10
 
11
- RCT_EXTERN_METHOD(start:(RCTPromiseResolveBlock)resolve
11
+ RCT_EXTERN_METHOD(start:(NSString *)userId
12
+ propagationProfile:(NSString *)propagationProfile
13
+ resolve:(RCTPromiseResolveBlock)resolve
12
14
  reject:(RCTPromiseRejectBlock)reject)
13
15
 
14
16
  RCT_EXTERN_METHOD(send:(NSString *)data
@@ -13,15 +13,13 @@ class BridgefyReactNative: RCTEventEmitter, BridgefyDelegate {
13
13
 
14
14
  @objc(initialize:propagationProfile:resolve:reject:)
15
15
  func initialize(apiKey: String,
16
- propagationProfile: String,
16
+ verboseLogging: Boolean,
17
17
  resolve: RCTPromiseResolveBlock,
18
18
  reject: RCTPromiseRejectBlock) -> Void {
19
19
  do {
20
- let profile = self.propagationProfile(from: propagationProfile)!
21
20
  bridgefy = try Bridgefy(withApiKey: apiKey,
22
- propagationProfile: profile,
23
21
  delegate: self,
24
- verboseLogging: false)
22
+ verboseLogging: verboseLogging)
25
23
  resolve(nil)
26
24
  } catch let error {
27
25
  let dict = errorDictionary(from: error as! BridgefyError)
@@ -29,9 +27,17 @@ class BridgefyReactNative: RCTEventEmitter, BridgefyDelegate {
29
27
  }
30
28
  }
31
29
 
32
- @objc(start:reject:)
33
- func start(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
34
- bridgefy!.start()
30
+ @objc(start:propagationProfile:resolve:reject:)
31
+ func start(userId: String,
32
+ propagationProfile: String,
33
+ resolve: RCTPromiseResolveBlock,
34
+ reject: RCTPromiseRejectBlock) -> Void {
35
+ let profile = self.propagationProfile(from: propagationProfile)!
36
+ if let uuid = UUID(uuidString: userId) {
37
+ bridgefy?.start(withUserId: uuid, andPropagationProfile: profile)
38
+ }else{
39
+ bridgefy?.start(withUserId: nil, andPropagationProfile: profile)
40
+ }
35
41
  resolve(nil)
36
42
  }
37
43
 
@@ -58,14 +64,14 @@ class BridgefyReactNative: RCTEventEmitter, BridgefyDelegate {
58
64
 
59
65
  @objc(connectedPeers:reject:)
60
66
  func connectedPeers(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
61
- resolve(["connectedPeers": bridgefy!.connectedPeers.map({ uuid in
67
+ resolve(["connectedPeers": bridgefy!.connectedPeers!.map({ uuid in
62
68
  uuid.uuidString
63
69
  })])
64
70
  }
65
71
 
66
72
  @objc(currentUserId:reject:)
67
73
  func currentUserId(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
68
- resolve(["userId": bridgefy!.currentUserId.uuidString])
74
+ resolve(["userId": bridgefy!.currentUserId!.uuidString])
69
75
  }
70
76
 
71
77
  @objc(establishSecureConnection:resolve:reject:)
@@ -95,7 +101,7 @@ class BridgefyReactNative: RCTEventEmitter, BridgefyDelegate {
95
101
 
96
102
  @objc(updateLicense:reject:)
97
103
  func updateLicense(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
98
- bridgefy!.updateLicense()
104
+ //bridgefy!.updateLicense()
99
105
  resolve(nil)
100
106
  }
101
107
 
@@ -136,8 +142,9 @@ class BridgefyReactNative: RCTEventEmitter, BridgefyDelegate {
136
142
  BridgefyReactNative.emitter.sendEvent(withName: "bridgefyDidDestroySession", body: nil)
137
143
  }
138
144
 
139
- func bridgefyDidFailToDestroySession() {
140
- BridgefyReactNative.emitter.sendEvent(withName: "bridgefyDidFailToDestroySession", body: nil)
145
+ func bridgefyDidFailToDestroySession(with error: BridgefySDK.BridgefyError) {
146
+ BridgefyReactNative.emitter.sendEvent(withName: "bridgefyDidFailToDestroySession",
147
+ body: ["error": errorDictionary(from: error)])
141
148
  }
142
149
 
143
150
  func bridgefyDidConnect(with userId: UUID) {
@@ -268,7 +275,7 @@ class BridgefyReactNative: RCTEventEmitter, BridgefyDelegate {
268
275
  case .missingBundleID:
269
276
  type = "missingBundleID"
270
277
  break;
271
- case .invalidAPIKey:
278
+ case .invalidApiKey:
272
279
  type = "invalidAPIKey"
273
280
  break;
274
281
  case .internetConnectionRequired:
@@ -8,32 +8,32 @@
8
8
  <key>DebugSymbolsPath</key>
9
9
  <string>dSYMs</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64</string>
11
+ <string>ios-arm64_x86_64-simulator</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>BridgefySDK.framework</string>
14
14
  <key>SupportedArchitectures</key>
15
15
  <array>
16
16
  <string>arm64</string>
17
+ <string>x86_64</string>
17
18
  </array>
18
19
  <key>SupportedPlatform</key>
19
20
  <string>ios</string>
21
+ <key>SupportedPlatformVariant</key>
22
+ <string>simulator</string>
20
23
  </dict>
21
24
  <dict>
22
25
  <key>DebugSymbolsPath</key>
23
26
  <string>dSYMs</string>
24
27
  <key>LibraryIdentifier</key>
25
- <string>ios-arm64_x86_64-simulator</string>
28
+ <string>ios-arm64</string>
26
29
  <key>LibraryPath</key>
27
30
  <string>BridgefySDK.framework</string>
28
31
  <key>SupportedArchitectures</key>
29
32
  <array>
30
33
  <string>arm64</string>
31
- <string>x86_64</string>
32
34
  </array>
33
35
  <key>SupportedPlatform</key>
34
36
  <string>ios</string>
35
- <key>SupportedPlatformVariant</key>
36
- <string>simulator</string>
37
37
  </dict>
38
38
  </array>
39
39
  <key>CFBundlePackageType</key>