@functionland/react-native-fula 0.4.2 → 1.1.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.
Files changed (66) hide show
  1. package/README.md +99 -9
  2. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  6. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  7. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  8. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  9. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  11. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  13. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  14. package/android/.gradle/file-system.probe +0 -0
  15. package/android/.idea/jarRepositories.xml +9 -9
  16. package/android/.idea/sonarlint/issuestore/index.pb +0 -0
  17. package/android/build.gradle +7 -5
  18. package/android/gradle/wrapper/gradle-wrapper.properties +7 -6
  19. package/android/gradle.properties +1 -1
  20. package/android/gradlew +53 -2
  21. package/android/local.properties +1 -1
  22. package/android/src/main/java/land/fx/fula/FulaModule.java +840 -72
  23. package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
  24. package/lib/commonjs/index.js +5 -1
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/interfaces/api-lookup.js +1653 -0
  27. package/lib/commonjs/interfaces/api-lookup.js.map +1 -0
  28. package/lib/commonjs/interfaces/fulaNativeModule.js +1 -1
  29. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  30. package/lib/commonjs/protocols/blockchain.js +404 -0
  31. package/lib/commonjs/protocols/blockchain.js.map +1 -0
  32. package/lib/commonjs/protocols/chain-api.js +87 -0
  33. package/lib/commonjs/protocols/chain-api.js.map +1 -0
  34. package/lib/commonjs/protocols/fula.js +120 -7
  35. package/lib/commonjs/protocols/fula.js.map +1 -1
  36. package/lib/commonjs/types/blockchain.js +2 -0
  37. package/lib/commonjs/types/blockchain.js.map +1 -0
  38. package/lib/module/index.js +4 -0
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/interfaces/api-lookup.js +1648 -0
  41. package/lib/module/interfaces/api-lookup.js.map +1 -0
  42. package/lib/module/interfaces/fulaNativeModule.js +1 -1
  43. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  44. package/lib/module/protocols/blockchain.js +383 -0
  45. package/lib/module/protocols/blockchain.js.map +1 -0
  46. package/lib/module/protocols/chain-api.js +76 -0
  47. package/lib/module/protocols/chain-api.js.map +1 -0
  48. package/lib/module/protocols/fula.js +110 -4
  49. package/lib/module/protocols/fula.js.map +1 -1
  50. package/lib/module/types/blockchain.js +2 -0
  51. package/lib/module/types/blockchain.js.map +1 -0
  52. package/lib/typescript/index.d.ts +2 -0
  53. package/lib/typescript/interfaces/api-lookup.d.ts +1643 -0
  54. package/lib/typescript/interfaces/fulaNativeModule.d.ts +40 -3
  55. package/lib/typescript/protocols/blockchain.d.ts +17 -0
  56. package/lib/typescript/protocols/chain-api.d.ts +6 -0
  57. package/lib/typescript/protocols/fula.d.ts +52 -2
  58. package/lib/typescript/types/blockchain.d.ts +68 -0
  59. package/package.json +13 -8
  60. package/src/index.tsx +3 -1
  61. package/src/interfaces/api-lookup.ts +1647 -0
  62. package/src/interfaces/fulaNativeModule.ts +50 -7
  63. package/src/protocols/blockchain.ts +460 -0
  64. package/src/protocols/chain-api.ts +80 -0
  65. package/src/protocols/fula.ts +157 -12
  66. package/src/types/blockchain.ts +81 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # react-native-fula
2
2
 
3
- This package is a bridge to use the Fula protocols in the react-native. It uses WNFS to create the Merkle dag from files and folders and transfer the DAG using Graphsync to the nodes.
3
+ This package is a bridge to use the [Fula protocols](https://github.com/functionland/go-fula) in the react-native. It uses [WNFS](https://github.com/wnfs-wg/rs-wnfs) to create the Merkle dag from files and folders and transfer the DAG using Graphsync to the nodes.
4
4
 
5
5
  ## Installation
6
6
 
@@ -15,7 +15,20 @@ import { fula } from 'react-native-fula'; // Until the library becomes stable, w
15
15
  ```
16
16
 
17
17
  ```js
18
- //Initialize the fula client, which creates the libp2p connection. Note that input is not an object e.g. init('','','','noop')
18
+ // Creates a new client without creating a filesystem. It is better to call this instead of directly calling init
19
+ const peerId //returns peerId as string
20
+ = newClient(
21
+ identity: string, //privateKey of did identity
22
+ storePath: string, // leave empty to use the default temp one
23
+ bloxAddr: string, //leave empty for testing without a backend node
24
+ exchange: 'noop'|'', //add noop for testing without a backend
25
+ autoFlush: boolean, //Default to false. Always set to false unless you know what you are doing. explicitly write data to disk after each operation if set to true
26
+ useRelay: boolean //default to true. If true it forces the connection through relay
27
+ )
28
+ ```
29
+
30
+ ```js
31
+ //Initialize the fula client, which creates the libp2p connection if newClient is not called before, and creates filesystem. Note that input is not an object e.g. init('','','','noop', false)
19
32
  [
20
33
  peerId, //returns peerId of the created libp2p instance in form of a string of bytes
21
34
  cid, //return the root cid of the WNFS merkle DAG in form of a string
@@ -26,7 +39,10 @@ await fula.init(
26
39
  identity: string, //bytes of the privateKey of did identity in string format
27
40
  storePath: string, // leave empty to use the default temp one
28
41
  bloxAddr: string, //leave empty for testing without a backend node
29
- exchange: 'noop'|'' //add noop for testing without a backend
42
+ exchange: 'noop'|'', //add noop for testing without a backend
43
+ autoFlush: boolean, //Default to false. Always set to false unless you know what you are doing. explicitly write data to disk after each operation if set to true
44
+ useRelay: boolean, //default to true. If true it forces the connection through relay
45
+ refresh: boolean //forces the fula object to be recreated. default is false
30
46
  );
31
47
  ```
32
48
 
@@ -40,7 +56,7 @@ await fula.mkdir(
40
56
  ```
41
57
 
42
58
  ```js
43
- //Write a local file on the device to the Fula tree (upload)
59
+ //Write a local file on the device to the Fula tree (upload). It keeps the original file modification date.
44
60
  const cid //returns the cid of the new root. Note that on every write action the root cid changes.
45
61
  =
46
62
  await fula.writeFile(
@@ -51,14 +67,13 @@ await fula.writeFile(
51
67
  ```
52
68
 
53
69
  ```js
54
- //reads a file on fula tree to a local file on the device (download)
70
+ //reads a file on fula tree to a local file on the device (download). It is stream so does not affect memory for large files.
55
71
  const localFilePath //returns the path to the local file and includes the filename
56
72
  =
57
73
  await fula.readFile(
58
74
  fulaTargetFilename: string, //path to the file on the tree. It should include the filename and extension and start from the "root/". e.g. "root/pictures/cat.jpg"
59
75
  localFilename: string //path to the local file. It should include the filename and extension. e.g. "/temp/cat.jpg"
60
76
  );
61
- //// TODO: This needs to be improved by using stream to not overload the memory for large files
62
77
  ```
63
78
 
64
79
  ```js
@@ -81,15 +96,90 @@ await fula.rm(
81
96
 
82
97
  ```
83
98
 
99
+ ```js
100
+ //copies the specified file or folder at sourcePath to the filename at targetPath. the path itself(apart from filename) must exist
101
+ const cid //returns the cid of the new root. Note that on every write action the root cid changes.
102
+ =
103
+ await fula.cp(
104
+ sourcePath: string, //path to the file or folder on the tree. It always starts from the "root". e.g. "root/pictures" or "root/pictures/cat.jpg"
105
+ targetPath: string, //path to the file or folder on the tree. It always starts from the "root". e.g. "root/pictures2" or "root/pictures2/cat.jpg"
106
+ );
107
+
108
+ ```
109
+
110
+ ```js
111
+ //moves the specified file or folder at sourcePath to the filename at targetPath. the path itself(apart from filename) must exist
112
+ const cid //returns the cid of the new root. Note that on every write action the root cid changes.
113
+ =
114
+ await fula.mv(
115
+ sourcePath: string, //path to the file or folder on the tree. It always starts from the "root". e.g. "root/pictures" or "root/pictures/cat.jpg"
116
+ targetPath: string, //path to the file or folder on the tree. It always starts from the "root". e.g. "root/pictures2" or "root/pictures2/cat.jpg"
117
+ );
118
+
119
+ ```
120
+
121
+ ```js
122
+ //checks if fula is ready (initialized through newClient or init)
123
+ const result //returns true if succesful and false if fails
124
+ =
125
+ await fula.isReady(
126
+ filesystemCheck: boolean //Default is true. If true it checks if both WNFS and Fula are ready. If false it only checks fula
127
+ );
128
+
129
+ ```
130
+
131
+ ```js
132
+ //checks if client can reach server
133
+ const result //returns true if it can, and false if it cannot
134
+ =
135
+ await fula.checkConnection();
136
+
137
+ ```
138
+
139
+ ```js
140
+ //checks if there are any un-synced actions on the client
141
+ const result //returns true if there are, and false if everything is synced with server
142
+ =
143
+ await fula.checkFailedActions(
144
+ retry: boolean //if true, it tries to sync device with server, if not, it only checks
145
+ );
146
+ ```
147
+
148
+ ```js
149
+ //shuts down the fula libp2p and datastore
150
+ await fula.shutdown();
151
+ ```
152
+
153
+ ```js
154
+ //removes all Fula related data and information (Except the encrypted filesystem) at the specified storage local path
155
+ const result //returns true if succesful and false if fails
156
+ =
157
+ await fula.logout(
158
+ identity: string, //bytes of the privateKey of did identity in string format
159
+ storePath: string, // leave empty to use the default temp one
160
+ );
161
+
162
+ ```
163
+
84
164
  ## Roadmap
85
165
 
86
166
  Please note the following might not be done in order:
87
167
 
88
168
  - [x] Initial version with all functions included
89
- - [ ] Add WNFS tree encryption key generation from an input (deterministically)
90
- - [ ] Improve ls, read, and write functions to use a stream. ( :100: v1.0.0 Release here )
169
+ - [x] Add WNFS tree encryption key generation from an input (deterministically)
170
+ - [x] Improve ead function to use a stream. ( :100: v1 Release here )
171
+ - [x] Connect to backend
91
172
  - [ ] Connect to Blockchain codes using APIs
92
- - [ ] Connect to backend
173
+
174
+ ## Other related libraries
175
+
176
+ | Name | Description |
177
+ | --- | --- |
178
+ | [WNFS for Android](https://github.com/functionland/wnfs-android) | Android build for WNFS rust version |
179
+ | [WNFS for iOS](https://github.com/functionland/wnfs-ios) | iOS build for WNFS rust version |
180
+ | [WNFS Build](https://github.com/functionland/wnfs-build-aar) | Android .aar for WNFS |
181
+ | [Fula Build](https://github.com/functionland/fula-build-aar) | android .aar file for Fula |
182
+ | [Fx Fotos](https://github.com/functionland/fx-fotos) | Fx Fotos dApp using react-native-fula |
93
183
 
94
184
  ## Contributing
95
185
 
@@ -1,2 +1,2 @@
1
- #Mon Nov 28 14:42:26 EST 2022
1
+ #Sat Dec 17 20:00:09 EST 2022
2
2
  gradle.version=7.5.1
Binary file
@@ -19,18 +19,18 @@
19
19
  <remote-repository>
20
20
  <option name="id" value="maven" />
21
21
  <option name="name" value="maven" />
22
- <option name="url" value="file:/$PROJECT_DIR$/../node_modules/react-native/android/" />
22
+ <option name="url" value="file:/$PROJECT_DIR$/../node_modules/react-native/android" />
23
+ </remote-repository>
24
+ <remote-repository>
25
+ <option name="id" value="MavenLocal" />
26
+ <option name="name" value="MavenLocal" />
27
+ <option name="url" value="file:/$USER_HOME$/.m2/repository/" />
23
28
  </remote-repository>
24
29
  <remote-repository>
25
30
  <option name="id" value="BintrayJCenter" />
26
31
  <option name="name" value="BintrayJCenter" />
27
32
  <option name="url" value="https://jcenter.bintray.com/" />
28
33
  </remote-repository>
29
- <remote-repository>
30
- <option name="id" value="MavenLocal" />
31
- <option name="name" value="MavenLocal" />
32
- <option name="url" value="file:/$USER_HOME$/.m2/repository" />
33
- </remote-repository>
34
34
  <remote-repository>
35
35
  <option name="id" value="Google" />
36
36
  <option name="name" value="Google" />
@@ -42,9 +42,9 @@
42
42
  <option name="url" value="https://jitpack.io" />
43
43
  </remote-repository>
44
44
  <remote-repository>
45
- <option name="id" value="MavenLocal" />
46
- <option name="name" value="MavenLocal" />
47
- <option name="url" value="file:/$USER_HOME$/.m2/repository/" />
45
+ <option name="id" value="maven" />
46
+ <option name="name" value="maven" />
47
+ <option name="url" value="file:/$PROJECT_DIR$/../node_modules/react-native/android/" />
48
48
  </remote-repository>
49
49
  </component>
50
50
  </project>
File without changes
@@ -7,7 +7,7 @@ buildscript {
7
7
  }
8
8
 
9
9
  dependencies {
10
- classpath 'com.android.tools.build:gradle:7.0.4'
10
+ classpath 'com.android.tools.build:gradle:4.2.2'
11
11
  }
12
12
  }
13
13
  }
@@ -19,8 +19,8 @@ def safeExtGet(prop, fallback) {
19
19
  }
20
20
 
21
21
  android {
22
- compileSdkVersion safeExtGet('Fula_compileSdkVersion', 31)
23
- defaultConfig {
22
+ compileSdk 33
23
+ defaultConfig {
24
24
  minSdkVersion safeExtGet('Fula_minSdkVersion', 26)
25
25
  targetSdkVersion safeExtGet('Fula_targetSdkVersion', 31)
26
26
  versionCode 1
@@ -40,6 +40,7 @@ android {
40
40
  sourceCompatibility JavaVersion.VERSION_1_8
41
41
  targetCompatibility JavaVersion.VERSION_1_8
42
42
  }
43
+ ndkVersion '25.1.8937393'
43
44
  }
44
45
 
45
46
  repositories {
@@ -61,7 +62,8 @@ repositories {
61
62
  dependencies {
62
63
  //noinspection GradleDynamicVersion
63
64
  implementation "com.facebook.react:react-native:+" // From node_modules
64
- implementation 'com.github.functionland:fula-build-aar:v0.7.3' // From jitpack.io
65
- implementation 'com.github.functionland:wnfs-build-aar:v1.2.4' // From jitpack.io
65
+ implementation 'com.github.functionland:fula-build-aar:0.8.7beta' // 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'
66
68
  // implementation files('mobile.aar')
67
69
  }
@@ -1,6 +1,7 @@
1
- #Wed Nov 16 15:32:27 EST 2022
2
- distributionBase=GRADLE_USER_HOME
3
- distributionPath=wrapper/dists
4
- zipStoreBase=GRADLE_USER_HOME
5
- zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
1
+ #Wed Nov 16 15:32:27 EST 2022
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
5
+ zipStoreBase=GRADLE_USER_HOME
6
+ zipStorePath=wrapper/dists
7
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
@@ -1 +1 @@
1
- android.useAndroidX=true
1
+ android.useAndroidX=true
package/android/gradlew CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  #
4
4
  # Copyright © 2015-2021 the original authors.
5
+ # Copyright © 2015-2021 the original authors.
5
6
  #
6
7
  # Licensed under the Apache License, Version 2.0 (the "License");
7
8
  # you may not use this file except in compliance with the License.
@@ -60,10 +61,54 @@
60
61
  #
61
62
  # You can find Gradle at https://github.com/gradle/gradle/.
62
63
  #
64
+ #
65
+ # Gradle start up script for POSIX generated by Gradle.
66
+ #
67
+ # Important for running:
68
+ #
69
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
70
+ # noncompliant, but you have some other compliant shell such as ksh or
71
+ # bash, then to run this script, type that shell name before the whole
72
+ # command line, like:
73
+ #
74
+ # ksh Gradle
75
+ #
76
+ # Busybox and similar reduced shells will NOT work, because this script
77
+ # requires all of these POSIX shell features:
78
+ # * functions;
79
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
80
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
81
+ # * compound commands having a testable exit status, especially «case»;
82
+ # * various built-in commands including «command», «set», and «ulimit».
83
+ #
84
+ # Important for patching:
85
+ #
86
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
87
+ # by Bash, Ksh, etc; in particular arrays are avoided.
88
+ #
89
+ # The "traditional" practice of packing multiple parameters into a
90
+ # space-separated string is a well documented source of bugs and security
91
+ # problems, so this is (mostly) avoided, by progressively accumulating
92
+ # options in "$@", and eventually passing that to Java.
93
+ #
94
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
95
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
96
+ # see the in-line comments for details.
97
+ #
98
+ # There are tweaks for specific operating systems such as AIX, CygWin,
99
+ # Darwin, MinGW, and NonStop.
100
+ #
101
+ # (3) This script is generated from the Groovy template
102
+ # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
103
+ # within the Gradle project.
104
+ #
105
+ # You can find Gradle at https://github.com/gradle/gradle/.
106
+ #
63
107
  ##############################################################################
64
108
 
65
109
  # Attempt to set APP_HOME
66
110
 
111
+
67
112
  # Resolve links: $0 may be a link
68
113
  app_path=$0
69
114
 
@@ -79,6 +124,8 @@ do
79
124
  *) app_path=$APP_HOME$link ;;
80
125
  esac
81
126
  done
127
+ app_path=$0
128
+
82
129
 
83
130
  APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84
131
 
@@ -90,6 +137,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90
137
 
91
138
  # Use the maximum available, or set MAX_FD != -1 to use that value.
92
139
  MAX_FD=maximum
140
+ MAX_FD=maximum
93
141
 
94
142
  warn () {
95
143
  echo "$*"
@@ -117,13 +165,16 @@ esac
117
165
  CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118
166
 
119
167
 
168
+
120
169
  # Determine the Java command to use to start the JVM.
121
170
  if [ -n "$JAVA_HOME" ] ; then
122
171
  if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123
172
  # IBM's JDK on AIX uses strange locations for the executables
124
173
  JAVACMD=$JAVA_HOME/jre/sh/java
174
+ JAVACMD=$JAVA_HOME/jre/sh/java
125
175
  else
126
176
  JAVACMD=$JAVA_HOME/bin/java
177
+ JAVACMD=$JAVA_HOME/bin/java
127
178
  fi
128
179
  if [ ! -x "$JAVACMD" ] ; then
129
180
  die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -211,6 +262,7 @@ then
211
262
  die "xargs is not available"
212
263
  fi
213
264
 
265
+
214
266
  # Use "xargs" to parse quoted args.
215
267
  #
216
268
  # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
@@ -236,5 +288,4 @@ eval "set -- $(
236
288
  sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
237
289
  tr '\n' ' '
238
290
  )" '"$@"'
239
-
240
- exec "$JAVACMD" "$@"
291
+ exec "$JAVACMD" "$@"
@@ -4,5 +4,5 @@
4
4
  # Location of the SDK. This is only used by Gradle.
5
5
  # For customization when using a Version Control System, please read the
6
6
  # header note.
7
- #Wed Nov 30 17:21:01 EST 2022
7
+ #Sat Dec 17 19:59:53 EST 2022
8
8
  sdk.dir=C\:\\Users\\ehsan\\AppData\\Local\\Android\\Sdk