@functionland/react-native-fula 1.2.0 → 1.2.1001

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/README.md CHANGED
@@ -149,6 +149,17 @@ await fula.checkFailedActions(
149
149
  );
150
150
  ```
151
151
 
152
+ ```js
153
+ //Gives access to the blox for a specific peerId. This call must be made from the authorizer only.
154
+ const result //returns true if succesful and false if fails
155
+ =
156
+ await fula.setAuth(
157
+ peerId: string, //peer ID of the app that needs access to the blox
158
+ allow: boolean, // true to allow and false to remove access
159
+ );
160
+
161
+ ```
162
+
152
163
  ```js
153
164
  //shuts down the fula libp2p and datastore
154
165
  await fula.shutdown();
@@ -1,69 +1,69 @@
1
- buildscript {
2
- if (project == rootProject) {
3
- repositories {
4
- google()
5
- mavenCentral()
6
- jcenter()
7
- }
8
-
9
- dependencies {
10
- classpath 'com.android.tools.build:gradle:4.2.2'
11
- }
12
- }
13
- }
14
-
15
- apply plugin: 'com.android.library'
16
-
17
- def safeExtGet(prop, fallback) {
18
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
19
- }
20
-
21
- android {
22
- compileSdk 33
23
- defaultConfig {
24
- minSdkVersion safeExtGet('Fula_minSdkVersion', 26)
25
- targetSdkVersion safeExtGet('Fula_targetSdkVersion', 31)
26
- versionCode 1
27
- versionName "1.0"
28
-
29
- }
30
-
31
- buildTypes {
32
- release {
33
- minifyEnabled false
34
- }
35
- }
36
- lintOptions {
37
- disable 'GradleCompatible'
38
- }
39
- compileOptions {
40
- sourceCompatibility JavaVersion.VERSION_1_8
41
- targetCompatibility JavaVersion.VERSION_1_8
42
- }
43
- ndkVersion '25.1.8937393'
44
- }
45
-
46
- repositories {
47
- mavenLocal()
48
- google()
49
- jcenter()
50
- mavenCentral()
51
- maven {
52
- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
53
- url("$rootDir/../node_modules/react-native/android")
54
- }
55
-
56
-
57
-
58
- // Add this repo to get go-fula package
59
- maven { url 'https://jitpack.io' }
60
- }
61
-
62
- dependencies {
63
- //noinspection GradleDynamicVersion
64
- implementation "com.facebook.react:react-native:+" // From node_modules
65
- implementation 'com.github.functionland:fula-build-aar:0.8.8beta' // From jitpack.io
66
- implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
67
- implementation 'commons-io:commons-io:20030203.000550'
68
- // implementation files('mobile.aar')
69
- }
1
+ buildscript {
2
+ if (project == rootProject) {
3
+ repositories {
4
+ google()
5
+ mavenCentral()
6
+ jcenter()
7
+ }
8
+
9
+ dependencies {
10
+ classpath 'com.android.tools.build:gradle:4.2.2'
11
+ }
12
+ }
13
+ }
14
+
15
+ apply plugin: 'com.android.library'
16
+
17
+ def safeExtGet(prop, fallback) {
18
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
19
+ }
20
+
21
+ android {
22
+ compileSdk 33
23
+ defaultConfig {
24
+ minSdkVersion safeExtGet('Fula_minSdkVersion', 26)
25
+ targetSdkVersion safeExtGet('Fula_targetSdkVersion', 31)
26
+ versionCode 1
27
+ versionName "1.0"
28
+
29
+ }
30
+
31
+ buildTypes {
32
+ release {
33
+ minifyEnabled false
34
+ }
35
+ }
36
+ lintOptions {
37
+ disable 'GradleCompatible'
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_1_8
41
+ targetCompatibility JavaVersion.VERSION_1_8
42
+ }
43
+ ndkVersion '25.1.8937393'
44
+ }
45
+
46
+ repositories {
47
+ mavenLocal()
48
+ google()
49
+ jcenter()
50
+ mavenCentral()
51
+ maven {
52
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
53
+ url("$rootDir/../node_modules/react-native/android")
54
+ }
55
+
56
+
57
+
58
+ // Add this repo to get go-fula package
59
+ maven { url 'https://jitpack.io' }
60
+ }
61
+
62
+ dependencies {
63
+ //noinspection GradleDynamicVersion
64
+ implementation "com.facebook.react:react-native:+" // From node_modules
65
+ implementation 'com.github.functionland:fula-build-aar:1.2.1' // From jitpack.io
66
+ implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
67
+ implementation 'commons-io:commons-io:20030203.000550'
68
+ // implementation files('mobile.aar')
69
+ }
@@ -25,6 +25,8 @@ import java.util.concurrent.Executors;
25
25
  import java.util.concurrent.ScheduledExecutorService;
26
26
  import java.util.concurrent.TimeUnit;
27
27
  import java.util.concurrent.atomic.AtomicBoolean;
28
+ import java.util.concurrent.Future;
29
+ import java.util.concurrent.TimeoutException;
28
30
 
29
31
  import org.json.JSONObject;
30
32
  import org.json.JSONArray;
@@ -263,42 +265,50 @@ public class FulaModule extends ReactContextBaseJavaModule {
263
265
 
264
266
  private boolean checkConnectionInternal(int timeout) throws Exception {
265
267
  try {
266
- Log.d("ReactNative", "checkConnectionInternal started");
267
- if (this.fula != null) {
268
+ Log.d("ReactNative", "checkConnectionInternal started");
269
+ if (this.fula != null) {
270
+ try {
271
+ Log.d("ReactNative", "connectToBlox started");
272
+
273
+ AtomicBoolean connectionStatus = new AtomicBoolean(false);
274
+ ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
275
+ Future<?> future = executor.submit(() -> {
268
276
  try {
269
- Log.d("ReactNative", "connectToBlox started");
270
-
271
- AtomicBoolean connectionStatus = new AtomicBoolean(false);
272
- ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
273
- executor.schedule(() -> {
274
- try {
275
- this.fula.connectToBlox();
276
- connectionStatus.set(true);
277
- Log.d("ReactNative", "checkConnectionInternal succeeded ");
278
- } catch (Exception e) {
279
- Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
280
- }
281
- }, 0, TimeUnit.SECONDS);
282
-
283
- executor.schedule(() -> {
284
- executor.shutdown();
285
- }, timeout, TimeUnit.SECONDS);
286
-
287
- executor.awaitTermination(timeout, TimeUnit.SECONDS);
288
- return connectionStatus.get();
277
+ this.fula.connectToBlox();
278
+ connectionStatus.set(true);
279
+ Log.d("ReactNative", "checkConnectionInternal succeeded ");
289
280
  } catch (Exception e) {
290
- Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
291
- return false;
281
+ Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
292
282
  }
293
- } else {
294
- Log.d("ReactNative", "checkConnectionInternal failed because fula is not initialized ");
283
+ });
284
+
285
+ try {
286
+ future.get(timeout, TimeUnit.SECONDS);
287
+ } catch (TimeoutException te) {
288
+ // If the timeout occurs, shut down the executor and return false
289
+ executor.shutdownNow();
295
290
  return false;
291
+ } finally {
292
+ // If the future task is done, we can shut down the executor
293
+ if (future.isDone()) {
294
+ executor.shutdown();
295
+ }
296
+ }
297
+
298
+ return connectionStatus.get();
299
+ } catch (Exception e) {
300
+ Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
301
+ return false;
296
302
  }
303
+ } else {
304
+ Log.d("ReactNative", "checkConnectionInternal failed because fula is not initialized ");
305
+ return false;
306
+ }
297
307
  } catch (Exception e) {
298
- Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
299
- throw (e);
308
+ Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
309
+ throw (e);
300
310
  }
301
- }
311
+ }
302
312
 
303
313
  @ReactMethod
304
314
  private void checkFailedActions(boolean retry, int timeout, Promise promise) throws Exception {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionland/react-native-fula",
3
- "version": "1.2.0",
3
+ "version": "1.2.1001",
4
4
  "description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -28,7 +28,7 @@
28
28
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
29
29
  "prepare": "bob build",
30
30
  "release": "release-it",
31
- "example": "set NODE_OPTIONS=--openssl-legacy-provider && yarn --cwd example",
31
+ "example": "set NODE_OPTIONS='' && yarn --cwd example",
32
32
  "pods": "cd example && pod-install --quiet",
33
33
  "bootstrap": "yarn example && yarn && yarn pods"
34
34
  },