@functionland/react-native-fula 0.4.0 → 0.4.2
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 +74 -9
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build.gradle +67 -67
- package/android/src/main/java/land/fx/fula/FulaModule.java +480 -443
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/protocols/fula.js +84 -61
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/protocols/fula.js +81 -60
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +5 -2
- package/lib/typescript/protocols/fula.d.ts +9 -2
- package/package.json +152 -152
- package/src/interfaces/fulaNativeModule.ts +42 -39
- package/src/protocols/fula.ts +138 -116
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
|
|
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.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -11,21 +11,86 @@ npm install react-native-fula
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
import { fula } from 'react-native-fula';
|
|
15
|
-
|
|
16
|
-
// ...
|
|
14
|
+
import { fula } from 'react-native-fula'; // Until the library becomes stable, we suggest importing from github directly
|
|
15
|
+
```
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
```js
|
|
18
|
+
//Initialize the fula client, which creates the libp2p connection. Note that input is not an object e.g. init('','','','noop')
|
|
19
|
+
[
|
|
20
|
+
peerId, //returns peerId of the created libp2p instance in form of a string of bytes
|
|
21
|
+
cid, //return the root cid of the WNFS merkle DAG in form of a string
|
|
22
|
+
private_ref //return the keys needed to decode hte encrypted WNFS tree in form of a string of object
|
|
23
|
+
]
|
|
24
|
+
=
|
|
25
|
+
await fula.init(
|
|
26
|
+
identity: string, //bytes of the privateKey of did identity in string format
|
|
27
|
+
storePath: string, // leave empty to use the default temp one
|
|
28
|
+
bloxAddr: string, //leave empty for testing without a backend node
|
|
29
|
+
exchange: 'noop'|'' //add noop for testing without a backend
|
|
30
|
+
);
|
|
31
|
+
```
|
|
20
32
|
|
|
33
|
+
```js
|
|
21
34
|
//Creates a Folder
|
|
22
|
-
const cid
|
|
35
|
+
const cid //returns the cid of the new root. Note that on every write action the root cid changes.
|
|
36
|
+
=
|
|
37
|
+
await fula.mkdir(
|
|
38
|
+
path: string // This is the Fula path to create a folder and always starts with "root/" and should not start or end with a slash e.g "root/pictures"
|
|
39
|
+
);
|
|
40
|
+
```
|
|
23
41
|
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
```js
|
|
43
|
+
//Write a local file on the device to the Fula tree (upload)
|
|
44
|
+
const cid //returns the cid of the new root. Note that on every write action the root cid changes.
|
|
45
|
+
=
|
|
46
|
+
await fula.writeFile(
|
|
47
|
+
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"
|
|
48
|
+
localFilename: string //path to the local file. e.g the file that needs to be uploaded
|
|
49
|
+
);
|
|
50
|
+
//// TODO: This needs to be improved by using stream to not overload the memory for large files
|
|
51
|
+
```
|
|
26
52
|
|
|
53
|
+
```js
|
|
54
|
+
//reads a file on fula tree to a local file on the device (download)
|
|
55
|
+
const localFilePath //returns the path to the local file and includes the filename
|
|
56
|
+
=
|
|
57
|
+
await fula.readFile(
|
|
58
|
+
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
|
+
localFilename: string //path to the local file. It should include the filename and extension. e.g. "/temp/cat.jpg"
|
|
60
|
+
);
|
|
61
|
+
//// TODO: This needs to be improved by using stream to not overload the memory for large files
|
|
27
62
|
```
|
|
28
63
|
|
|
64
|
+
```js
|
|
65
|
+
//shows all files and folders under the specified path on Fula
|
|
66
|
+
const fileList //returns all the files and folders in a string separated by \n
|
|
67
|
+
=
|
|
68
|
+
await fula.ls(
|
|
69
|
+
path: string, //path to the folder on the tree. It always starts from the "root". e.g. "root" or "root/pictures"
|
|
70
|
+
);
|
|
71
|
+
//// TODO: This needs to be improved by returning an array of files and folders and in chunks to not overload hte memory for large folders
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
//removes all files and folders at the specified path on Fula
|
|
76
|
+
const cid //returns the cid of the new root. Note that on every write action the root cid changes.
|
|
77
|
+
=
|
|
78
|
+
await fula.rm(
|
|
79
|
+
path: 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"
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Roadmap
|
|
85
|
+
|
|
86
|
+
Please note the following might not be done in order:
|
|
87
|
+
|
|
88
|
+
- [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 )
|
|
91
|
+
- [ ] Connect to Blockchain codes using APIs
|
|
92
|
+
- [ ] Connect to backend
|
|
93
|
+
|
|
29
94
|
## Contributing
|
|
30
95
|
|
|
31
96
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
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:7.0.4'
|
|
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
|
-
compileSdkVersion safeExtGet('Fula_compileSdkVersion', 31)
|
|
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
|
-
}
|
|
44
|
-
|
|
45
|
-
repositories {
|
|
46
|
-
mavenLocal()
|
|
47
|
-
google()
|
|
48
|
-
jcenter()
|
|
49
|
-
mavenCentral()
|
|
50
|
-
maven {
|
|
51
|
-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
52
|
-
url("$rootDir/../node_modules/react-native/android")
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Add this repo to get go-fula package
|
|
58
|
-
maven { url 'https://jitpack.io' }
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
dependencies {
|
|
62
|
-
//noinspection GradleDynamicVersion
|
|
63
|
-
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.
|
|
66
|
-
// implementation files('mobile.aar')
|
|
67
|
-
}
|
|
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:7.0.4'
|
|
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
|
+
compileSdkVersion safeExtGet('Fula_compileSdkVersion', 31)
|
|
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
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
mavenLocal()
|
|
47
|
+
google()
|
|
48
|
+
jcenter()
|
|
49
|
+
mavenCentral()
|
|
50
|
+
maven {
|
|
51
|
+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
52
|
+
url("$rootDir/../node_modules/react-native/android")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// Add this repo to get go-fula package
|
|
58
|
+
maven { url 'https://jitpack.io' }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
dependencies {
|
|
62
|
+
//noinspection GradleDynamicVersion
|
|
63
|
+
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
|
|
66
|
+
// implementation files('mobile.aar')
|
|
67
|
+
}
|