@functionland/react-native-fula 1.12.0 → 1.12.1
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/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/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.idea/misc.xml +0 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/land/fx/fula/Cryptography.java +62 -60
- package/android/src/main/java/land/fx/fula/FulaModule.java +46 -85
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +0 -1
- package/lib/typescript/protocols/fula.d.ts +0 -1
- package/package.json +1 -1
- package/src/interfaces/fulaNativeModule.ts +1 -1
- package/src/protocols/fula.ts +21 -8
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/.idea/misc.xml
CHANGED
package/android/build.gradle
CHANGED
|
@@ -62,8 +62,8 @@ repositories {
|
|
|
62
62
|
dependencies {
|
|
63
63
|
//noinspection GradleDynamicVersion
|
|
64
64
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
65
|
-
implementation 'com.github.functionland:fula-build-aar:1.
|
|
66
|
-
implementation 'com.github.functionland:wnfs-
|
|
65
|
+
implementation 'com.github.functionland:fula-build-aar:1.13.0' // From jitpack.io
|
|
66
|
+
implementation 'com.github.functionland:wnfs-android:v1.7.3' // From jitpack.io
|
|
67
67
|
implementation 'commons-io:commons-io:20030203.000550'
|
|
68
68
|
implementation 'commons-codec:commons-codec:1.15'
|
|
69
69
|
// implementation files('mobile.aar')
|
|
@@ -1,60 +1,62 @@
|
|
|
1
|
-
package land.fx.fula;
|
|
2
|
-
|
|
3
|
-
import android.util.Base64;
|
|
4
|
-
|
|
5
|
-
import java.io.UnsupportedEncodingException;
|
|
6
|
-
import java.nio.charset.StandardCharsets;
|
|
7
|
-
import java.security.InvalidAlgorithmParameterException;
|
|
8
|
-
import java.security.InvalidKeyException;
|
|
9
|
-
import java.security.NoSuchAlgorithmException;
|
|
10
|
-
import java.security.spec.InvalidKeySpecException;
|
|
11
|
-
import java.security.SecureRandom;
|
|
12
|
-
import java.nio.ByteBuffer;
|
|
13
|
-
import java.security.spec.InvalidParameterSpecException;
|
|
14
|
-
|
|
15
|
-
import javax.crypto.BadPaddingException;
|
|
16
|
-
import javax.crypto.Cipher;
|
|
17
|
-
import javax.crypto.IllegalBlockSizeException;
|
|
18
|
-
import javax.crypto.NoSuchPaddingException;
|
|
19
|
-
import javax.crypto.SecretKey;
|
|
20
|
-
import javax.crypto.SecretKeyFactory;
|
|
21
|
-
import javax.crypto.spec.PBEKeySpec;
|
|
22
|
-
import javax.crypto.spec.SecretKeySpec;
|
|
23
|
-
import javax.crypto.spec.GCMParameterSpec;
|
|
24
|
-
|
|
25
|
-
public class Cryptography {
|
|
26
|
-
public static String encryptMsg(String message, SecretKey secret)
|
|
27
|
-
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
|
|
28
|
-
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
byteBuffer.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
byteBuffer.
|
|
45
|
-
byte[]
|
|
46
|
-
byteBuffer.get(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
cipher.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
package land.fx.fula;
|
|
2
|
+
|
|
3
|
+
import android.util.Base64;
|
|
4
|
+
|
|
5
|
+
import java.io.UnsupportedEncodingException;
|
|
6
|
+
import java.nio.charset.StandardCharsets;
|
|
7
|
+
import java.security.InvalidAlgorithmParameterException;
|
|
8
|
+
import java.security.InvalidKeyException;
|
|
9
|
+
import java.security.NoSuchAlgorithmException;
|
|
10
|
+
import java.security.spec.InvalidKeySpecException;
|
|
11
|
+
import java.security.SecureRandom;
|
|
12
|
+
import java.nio.ByteBuffer;
|
|
13
|
+
import java.security.spec.InvalidParameterSpecException;
|
|
14
|
+
|
|
15
|
+
import javax.crypto.BadPaddingException;
|
|
16
|
+
import javax.crypto.Cipher;
|
|
17
|
+
import javax.crypto.IllegalBlockSizeException;
|
|
18
|
+
import javax.crypto.NoSuchPaddingException;
|
|
19
|
+
import javax.crypto.SecretKey;
|
|
20
|
+
import javax.crypto.SecretKeyFactory;
|
|
21
|
+
import javax.crypto.spec.PBEKeySpec;
|
|
22
|
+
import javax.crypto.spec.SecretKeySpec;
|
|
23
|
+
import javax.crypto.spec.GCMParameterSpec;
|
|
24
|
+
|
|
25
|
+
public class Cryptography {
|
|
26
|
+
public static String encryptMsg(String message, SecretKey secret, byte[] iv)
|
|
27
|
+
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
|
|
28
|
+
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
29
|
+
if (iv == null || iv.length == 0) {
|
|
30
|
+
iv = new byte[12]; // Ensure this is randomly generated for each encryption.
|
|
31
|
+
new SecureRandom().nextBytes(iv);
|
|
32
|
+
}
|
|
33
|
+
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
|
|
34
|
+
cipher.init(Cipher.ENCRYPT_MODE, secret, spec);
|
|
35
|
+
byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));
|
|
36
|
+
ByteBuffer byteBuffer = ByteBuffer.allocate(iv.length + cipherText.length);
|
|
37
|
+
byteBuffer.put(iv);
|
|
38
|
+
byteBuffer.put(cipherText);
|
|
39
|
+
return Base64.encodeToString(byteBuffer.array(), Base64.NO_WRAP);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static String decryptMsg(String cipherText, SecretKey secret)
|
|
43
|
+
throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
|
|
44
|
+
ByteBuffer byteBuffer = ByteBuffer.wrap(Base64.decode(cipherText, Base64.NO_WRAP));
|
|
45
|
+
byte[] iv = new byte[12];
|
|
46
|
+
byteBuffer.get(iv);
|
|
47
|
+
byte[] cipherBytes = new byte[byteBuffer.remaining()];
|
|
48
|
+
byteBuffer.get(cipherBytes);
|
|
49
|
+
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
50
|
+
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
|
|
51
|
+
cipher.init(Cipher.DECRYPT_MODE, secret, spec);
|
|
52
|
+
String decryptString = new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);
|
|
53
|
+
return decryptString;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public static SecretKey generateKey(byte[] key)
|
|
57
|
+
throws NoSuchAlgorithmException, InvalidKeySpecException {
|
|
58
|
+
PBEKeySpec pbeKeySpec = new PBEKeySpec(StaticHelper.bytesToBase64(key).toCharArray(), key, 1000, 128);
|
|
59
|
+
SecretKey pbeKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(pbeKeySpec);
|
|
60
|
+
return new SecretKeySpec(pbeKey.getEncoded(), "AES");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -64,7 +64,6 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
64
64
|
Config fulaConfig;
|
|
65
65
|
String appDir;
|
|
66
66
|
String fulaStorePath;
|
|
67
|
-
String privateForest;
|
|
68
67
|
land.fx.wnfslib.Config rootConfig;
|
|
69
68
|
SharedPreferenceHelper sharedPref;
|
|
70
69
|
SecretKey secretKeyGlobal;
|
|
@@ -94,10 +93,12 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
94
93
|
|
|
95
94
|
@NonNull
|
|
96
95
|
@Override
|
|
97
|
-
public byte[] put(@NonNull byte[]
|
|
96
|
+
public byte[] put(@NonNull byte[] cid, byte[] data) {
|
|
98
97
|
try {
|
|
98
|
+
long codec = (long)cid[1] & 0xFF;
|
|
99
|
+
byte[] put_cid = this.internalClient.put(data, codec);
|
|
99
100
|
//Log.d("ReactNative", "data="+ Arrays.toString(data) +" ;codec="+codec);
|
|
100
|
-
return
|
|
101
|
+
return put_cid;
|
|
101
102
|
} catch (Exception e) {
|
|
102
103
|
Log.d("ReactNative", "put Error="+e.getMessage());
|
|
103
104
|
e.printStackTrace();
|
|
@@ -254,10 +255,9 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
254
255
|
byte[] identity = toByte(identityString);
|
|
255
256
|
Log.d("ReactNative", "init identity= " + identityString);
|
|
256
257
|
String[] obj = this.initInternal(identity, storePath, bloxAddr, exchange, autoFlush, rootConfig, useRelay, refresh);
|
|
257
|
-
Log.d("ReactNative", "init object created: [ " + obj[0] + ", " + obj[1] + "
|
|
258
|
+
Log.d("ReactNative", "init object created: [ " + obj[0] + ", " + obj[1] + " ]");
|
|
258
259
|
resultData.putString("peerId", obj[0]);
|
|
259
260
|
resultData.putString("rootCid", obj[1]);
|
|
260
|
-
resultData.putString("private_ref", obj[2]);
|
|
261
261
|
promise.resolve(resultData);
|
|
262
262
|
} catch (Exception e) {
|
|
263
263
|
Log.d("ReactNative", "init failed with Error: " + e.getMessage());
|
|
@@ -512,7 +512,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
512
512
|
Log.d("ReactNative", "Failed to generate libp2pId: " + e.getMessage());
|
|
513
513
|
throw new GeneralSecurityException("Failed to generate libp2pId", e);
|
|
514
514
|
}
|
|
515
|
-
encryptedLibp2pId = "FULA_ENC_V3:" + Cryptography.encryptMsg(StaticHelper.bytesToBase64(libp2pId), encryptionSecretKey);
|
|
515
|
+
encryptedLibp2pId = "FULA_ENC_V3:" + Cryptography.encryptMsg(StaticHelper.bytesToBase64(libp2pId), encryptionSecretKey, null);
|
|
516
516
|
sharedPref.add(PRIVATE_KEY_STORE_PEERID, encryptedLibp2pId);
|
|
517
517
|
} else {
|
|
518
518
|
Log.d("ReactNative", "encryptedLibp2pId is correct. decrypting " + encryptedLibp2pId);
|
|
@@ -534,34 +534,31 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
private void createNewRootConfig(FulaModule.Client iClient, byte[] identity) throws Exception {
|
|
537
|
-
this.
|
|
538
|
-
Log.d("ReactNative", "
|
|
539
|
-
this.rootConfig = Fs.createRootDir(iClient, this.privateForest, identity);
|
|
537
|
+
this.rootConfig = Fs.init(iClient, identity);
|
|
538
|
+
Log.d("ReactNative", "rootConfig is created " + this.rootConfig.getCid());
|
|
540
539
|
if (this.fula != null) {
|
|
541
540
|
this.fula.flush();
|
|
542
541
|
}
|
|
543
|
-
Log.d("ReactNative", "new rootConfig is created: cid=" + this.rootConfig.getCid()+" & private_ref="+this.rootConfig.getPrivate_ref());
|
|
544
|
-
|
|
545
542
|
this.encrypt_and_store_config();
|
|
546
543
|
}
|
|
547
544
|
|
|
548
|
-
private
|
|
549
|
-
Log.d("ReactNative", "
|
|
550
|
-
|
|
551
|
-
Log.d("ReactNative", "
|
|
552
|
-
return privateRef;
|
|
545
|
+
private void reloadFS(FulaModule.Client iClient, byte[] wnfsKey, String rootCid) throws Exception {
|
|
546
|
+
Log.d("ReactNative", "reloadFS called: rootCid=" + rootCid);
|
|
547
|
+
Fs.loadWithWNFSKey(iClient, wnfsKey, rootCid);
|
|
548
|
+
Log.d("ReactNative", "reloadFS completed");
|
|
553
549
|
}
|
|
554
550
|
|
|
555
551
|
private boolean encrypt_and_store_config() throws Exception {
|
|
556
552
|
try {
|
|
557
553
|
if(this.identityEncryptedGlobal != null && !this.identityEncryptedGlobal.isEmpty()) {
|
|
558
|
-
|
|
559
|
-
|
|
554
|
+
Log.d("ReactNative", "encrypt_and_store_config started");
|
|
555
|
+
|
|
556
|
+
String cid_encrypted = Cryptography.encryptMsg(this.rootConfig.getCid(), this.secretKeyGlobal, null);
|
|
560
557
|
|
|
561
558
|
sharedPref.add("FULA_ENC_V3:cid_encrypted_" + this.identityEncryptedGlobal, cid_encrypted);
|
|
562
|
-
sharedPref.add("FULA_ENC_V3:private_ref_encrypted_" + this.identityEncryptedGlobal, private_ref_encrypted);
|
|
563
559
|
return true;
|
|
564
560
|
} else {
|
|
561
|
+
Log.d("ReactNative", "encrypt_and_store_config failed because identityEncryptedGlobal is empty");
|
|
565
562
|
return false;
|
|
566
563
|
}
|
|
567
564
|
} catch (Exception e) {
|
|
@@ -576,15 +573,13 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
576
573
|
this.fula.flush();
|
|
577
574
|
}
|
|
578
575
|
SecretKey secretKey = Cryptography.generateKey(identity);
|
|
579
|
-
|
|
580
|
-
String identity_encrypted = Cryptography.encryptMsg(Arrays.toString(identity), secretKey);
|
|
576
|
+
byte[] iv = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B };
|
|
577
|
+
String identity_encrypted = Cryptography.encryptMsg(Arrays.toString(identity), secretKey, iv);
|
|
581
578
|
sharedPref.remove("FULA_ENC_V3:cid_encrypted_"+ identity_encrypted);
|
|
582
|
-
sharedPref.remove("FULA_ENC_V3:private_ref_encrypted_"+identity_encrypted);
|
|
583
579
|
|
|
584
580
|
//TODO: Should also remove peerid @Mahdi
|
|
585
581
|
|
|
586
582
|
sharedPref.remove("FULA_ENC_V3:cid_encrypted_"+ identity_encrypted);
|
|
587
|
-
sharedPref.remove("FULA_ENC_V3:private_ref_encrypted_"+ identity_encrypted);
|
|
588
583
|
|
|
589
584
|
this.rootConfig = null;
|
|
590
585
|
this.secretKeyGlobal = null;
|
|
@@ -664,87 +659,54 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
664
659
|
}
|
|
665
660
|
|
|
666
661
|
SecretKey secretKey = Cryptography.generateKey(identity);
|
|
667
|
-
|
|
662
|
+
Log.d("ReactNative", "secretKey generated: " + secretKey.toString());
|
|
663
|
+
byte[] iv = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B };
|
|
664
|
+
String identity_encrypted =Cryptography.encryptMsg(Arrays.toString(identity), secretKey, iv);
|
|
665
|
+
Log.d("ReactNative", "identity_encrypted generated: " + identity_encrypted + " for identity: " + Arrays.toString(identity));
|
|
668
666
|
this.identityEncryptedGlobal = identity_encrypted;
|
|
669
667
|
this.secretKeyGlobal = secretKey;
|
|
670
668
|
|
|
671
|
-
if (this.rootConfig == null || this.rootConfig.getCid().isEmpty()
|
|
669
|
+
if ( this.rootConfig == null || this.rootConfig.getCid().isEmpty() ) {
|
|
672
670
|
Log.d("ReactNative", "this.rootCid is empty.");
|
|
673
671
|
//Load from keystore
|
|
674
672
|
|
|
675
673
|
String cid_encrypted_fetched = sharedPref.getValue("FULA_ENC_V3:cid_encrypted_"+ identity_encrypted);
|
|
676
|
-
String private_ref_encrypted_fetched = sharedPref.getValue("FULA_ENC_V3:private_ref_encrypted_"+identity_encrypted);
|
|
677
674
|
Log.d("ReactNative", "Here1");
|
|
678
675
|
String cid = "";
|
|
679
|
-
String private_ref = "";
|
|
680
676
|
if(cid_encrypted_fetched != null && !cid_encrypted_fetched.isEmpty()) {
|
|
681
677
|
Log.d("ReactNative", "decrypting cid="+cid_encrypted_fetched+" with secret="+secretKey.toString());
|
|
682
678
|
cid = Cryptography.decryptMsg(cid_encrypted_fetched, secretKey);
|
|
683
679
|
}
|
|
684
|
-
|
|
685
|
-
Log.d("ReactNative", "decrypting private_ref="+private_ref_encrypted_fetched+" with secret="+secretKey.toString());
|
|
686
|
-
private_ref = Cryptography.decryptMsg(private_ref_encrypted_fetched, secretKey);
|
|
687
|
-
}
|
|
680
|
+
|
|
688
681
|
Log.d("ReactNative", "Here2");
|
|
689
|
-
//Log.d("ReactNative", "Attempted to fetch cid from keystore; cid="+cid
|
|
690
|
-
if(
|
|
691
|
-
Log.d("ReactNative", "cid
|
|
682
|
+
//Log.d("ReactNative", "Attempted to fetch cid from keystore; cid="+cid);
|
|
683
|
+
if(cid == null || cid.isEmpty()) {
|
|
684
|
+
Log.d("ReactNative", "cid was not found");
|
|
692
685
|
if(rootCid != null && !rootCid.isEmpty()){
|
|
693
686
|
Log.d("ReactNative", "Re-setting cid from input: "+rootCid);
|
|
694
687
|
cid = rootCid;
|
|
695
688
|
}
|
|
696
|
-
if(
|
|
697
|
-
Log.d("ReactNative", "
|
|
698
|
-
private_ref = this.getPrivateRef(this.client, identity, cid);
|
|
699
|
-
Log.d("ReactNative", "Re-fetching privateRef from wnfs: "+private_ref);
|
|
700
|
-
}
|
|
701
|
-
if(cid == null || cid.isEmpty() || private_ref == null || private_ref.isEmpty()) {
|
|
702
|
-
Log.d("ReactNative", "Tried to recover cid and privateRef but was not successful. Creating new ones");
|
|
689
|
+
if(cid == null || cid.isEmpty()) {
|
|
690
|
+
Log.d("ReactNative", "Tried to recover cid but was not successful. Creating new ones");
|
|
703
691
|
this.createNewRootConfig(this.client, identity);
|
|
704
|
-
} else {
|
|
705
|
-
Log.d("ReactNative", "Tried to recover cid and privateRef and was successful. cid:"+cid+" & private_ref="+private_ref);
|
|
706
|
-
this.rootConfig = new land.fx.wnfslib.Config(cid, private_ref);
|
|
707
|
-
this.encrypt_and_store_config();
|
|
708
692
|
}
|
|
709
|
-
} else
|
|
710
|
-
Log.d("ReactNative", "
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
} else{
|
|
715
|
-
Log.d("ReactNative", "Found but Could not recover cid and private_ref from keychain store");
|
|
716
|
-
this.createNewRootConfig(this.client, identity);
|
|
717
|
-
}
|
|
718
|
-
} else{
|
|
719
|
-
Log.d("ReactNative", "This cid and private_ref generation should never happen!!!");
|
|
720
|
-
//Create new root and store cid and private_ref
|
|
721
|
-
this.createNewRootConfig(this.client, identity);
|
|
693
|
+
} else {
|
|
694
|
+
Log.d("ReactNative", "Recovered cid and private ref from keychain store. cid="+cid);
|
|
695
|
+
this.rootConfig = new land.fx.wnfslib.Config(cid);
|
|
696
|
+
this.reloadFS(this.client, identity, cid);
|
|
697
|
+
this.encrypt_and_store_config();
|
|
722
698
|
}
|
|
723
699
|
|
|
724
|
-
|
|
725
700
|
Log.d("ReactNative", "creating rootConfig completed");
|
|
726
701
|
|
|
727
|
-
|
|
728
|
-
byte[] testbyte = convertStringToByte("-104,40,24,-93,24,100,24,114,24,111,24,111,24,116,24,-126,24,-126,0,0,24,-128,24,103,24,118,24,101,24,114,24,115,24,105,24,111,24,110,24,101,24,48,24,46,24,49,24,46,24,48,24,105,24,115,24,116,24,114,24,117,24,99,24,116,24,117,24,114,24,101,24,100,24,104,24,97,24,109,24,116");
|
|
729
|
-
long testcodec = 85;
|
|
730
|
-
byte[] testputcid = this.client.put(testbyte, testcodec);
|
|
731
|
-
Log.d("ReactNative", "client.put test done"+ Arrays.toString(testputcid));
|
|
732
|
-
byte[] testfetchedcid = convertStringToByte("1,113,18,32,-6,-63,-128,79,-102,-89,57,77,-8,67,-98,8,-81,40,-87,123,122,29,-52,-124,-60,-53,100,105,125,123,-5,-99,41,106,-124,-64");
|
|
733
|
-
byte[] testfetchedbytes = this.client.get(testfetchedcid);
|
|
734
|
-
Log.d("ReactNative", "client.get test done"+ Arrays.toString(testfetchedbytes));
|
|
735
|
-
*/
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
Log.d("ReactNative", "rootConfig is created: cid=" + this.rootConfig.getCid()+ "& private_ref="+this
|
|
739
|
-
.rootConfig.getPrivate_ref());
|
|
702
|
+
Log.d("ReactNative", "rootConfig is created: cid=" + this.rootConfig.getCid());
|
|
740
703
|
} else {
|
|
741
|
-
Log.d("ReactNative", "rootConfig existed: cid=" + this.rootConfig.getCid()
|
|
704
|
+
Log.d("ReactNative", "rootConfig existed: cid=" + this.rootConfig.getCid());
|
|
742
705
|
}
|
|
743
706
|
String peerId = this.fula.id();
|
|
744
|
-
String[] obj = new String[
|
|
707
|
+
String[] obj = new String[2];
|
|
745
708
|
obj[0] = peerId;
|
|
746
709
|
obj[1] = this.rootConfig.getCid();
|
|
747
|
-
obj[2] = this.rootConfig.getPrivate_ref();
|
|
748
710
|
Log.d("ReactNative", "initInternal is completed successfully");
|
|
749
711
|
if (this.fula != null) {
|
|
750
712
|
this.fula.flush();
|
|
@@ -761,7 +723,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
761
723
|
ThreadUtils.runOnExecutor(() -> {
|
|
762
724
|
Log.d("ReactNative", "mkdir: path = " + path);
|
|
763
725
|
try {
|
|
764
|
-
land.fx.wnfslib.Config config = Fs.mkdir(this.client, this.rootConfig.getCid(),
|
|
726
|
+
land.fx.wnfslib.Config config = Fs.mkdir(this.client, this.rootConfig.getCid(), path);
|
|
765
727
|
if(config != null) {
|
|
766
728
|
this.rootConfig = config;
|
|
767
729
|
this.encrypt_and_store_config();
|
|
@@ -794,7 +756,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
794
756
|
try {
|
|
795
757
|
if (this.client != null) {
|
|
796
758
|
Log.d("ReactNative", "writeFileFromPath started: this.rootConfig.getCid=" + this.rootConfig.getCid()+ ", fulaTargetFilename="+fulaTargetFilename + ", localFilename="+localFilename);
|
|
797
|
-
land.fx.wnfslib.Config config = Fs.
|
|
759
|
+
land.fx.wnfslib.Config config = Fs.writeFileStreamFromPath(this.client, this.rootConfig.getCid(), fulaTargetFilename, localFilename);
|
|
798
760
|
if(config != null) {
|
|
799
761
|
this.rootConfig = config;
|
|
800
762
|
this.encrypt_and_store_config();
|
|
@@ -827,7 +789,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
827
789
|
Log.d("ReactNative", "writeFile: path = " + path);
|
|
828
790
|
try {
|
|
829
791
|
byte[] content = this.convertStringToByte(contentString);
|
|
830
|
-
land.fx.wnfslib.Config config = Fs.writeFile(this.client, this.rootConfig.getCid(),
|
|
792
|
+
land.fx.wnfslib.Config config = Fs.writeFile(this.client, this.rootConfig.getCid(), path, content);
|
|
831
793
|
this.rootConfig = config;
|
|
832
794
|
this.encrypt_and_store_config();
|
|
833
795
|
if (this.fula != null) {
|
|
@@ -846,9 +808,8 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
846
808
|
ThreadUtils.runOnExecutor(() -> {
|
|
847
809
|
Log.d("ReactNative", "ls: path = " + path);
|
|
848
810
|
try {
|
|
849
|
-
byte[] res = Fs.ls(this.client, this.rootConfig.getCid(),
|
|
811
|
+
byte[] res = Fs.ls(this.client, this.rootConfig.getCid(), path);
|
|
850
812
|
|
|
851
|
-
//JSONArray jsonArray = new JSONArray(res);
|
|
852
813
|
String s = new String(res, StandardCharsets.UTF_8);
|
|
853
814
|
Log.d("ReactNative", "ls: res = " + s);
|
|
854
815
|
promise.resolve(s);
|
|
@@ -864,7 +825,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
864
825
|
ThreadUtils.runOnExecutor(() -> {
|
|
865
826
|
Log.d("ReactNative", "rm: path = " + path);
|
|
866
827
|
try {
|
|
867
|
-
land.fx.wnfslib.Config config = Fs.rm(this.client, this.rootConfig.getCid(),
|
|
828
|
+
land.fx.wnfslib.Config config = Fs.rm(this.client, this.rootConfig.getCid(), path);
|
|
868
829
|
if(config != null) {
|
|
869
830
|
this.rootConfig = config;
|
|
870
831
|
this.encrypt_and_store_config();
|
|
@@ -888,7 +849,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
888
849
|
ThreadUtils.runOnExecutor(() -> {
|
|
889
850
|
Log.d("ReactNative", "rm: sourcePath = " + sourcePath);
|
|
890
851
|
try {
|
|
891
|
-
land.fx.wnfslib.Config config = Fs.cp(this.client, this.rootConfig.getCid(),
|
|
852
|
+
land.fx.wnfslib.Config config = Fs.cp(this.client, this.rootConfig.getCid(), sourcePath, targetPath);
|
|
892
853
|
if(config != null) {
|
|
893
854
|
this.rootConfig = config;
|
|
894
855
|
this.encrypt_and_store_config();
|
|
@@ -912,7 +873,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
912
873
|
ThreadUtils.runOnExecutor(() -> {
|
|
913
874
|
Log.d("ReactNative", "rm: sourcePath = " + sourcePath);
|
|
914
875
|
try {
|
|
915
|
-
land.fx.wnfslib.Config config = Fs.mv(this.client, this.rootConfig.getCid(),
|
|
876
|
+
land.fx.wnfslib.Config config = Fs.mv(this.client, this.rootConfig.getCid(), sourcePath, targetPath);
|
|
916
877
|
if(config != null) {
|
|
917
878
|
this.rootConfig = config;
|
|
918
879
|
this.encrypt_and_store_config();
|
|
@@ -943,7 +904,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
943
904
|
ThreadUtils.runOnExecutor(() -> {
|
|
944
905
|
Log.d("ReactNative", "readFile: fulaTargetFilename = " + fulaTargetFilename);
|
|
945
906
|
try {
|
|
946
|
-
String path = Fs.readFilestreamToPath(this.client, this.rootConfig.getCid(),
|
|
907
|
+
String path = Fs.readFilestreamToPath(this.client, this.rootConfig.getCid(), fulaTargetFilename, localFilename);
|
|
947
908
|
promise.resolve(path);
|
|
948
909
|
} catch (Exception e) {
|
|
949
910
|
Log.d("get", e.getMessage());
|
|
@@ -957,7 +918,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
957
918
|
ThreadUtils.runOnExecutor(() -> {
|
|
958
919
|
Log.d("ReactNative", "readFileContent: path = " + path);
|
|
959
920
|
try {
|
|
960
|
-
byte[] res = Fs.readFile(this.client, this.rootConfig.getCid(),
|
|
921
|
+
byte[] res = Fs.readFile(this.client, this.rootConfig.getCid(), path);
|
|
961
922
|
String resString = toString(res);
|
|
962
923
|
promise.resolve(resString);
|
|
963
924
|
} catch (Exception e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","Fula","NativeModules","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ninterface FulaNativeModule {\n init: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<{ peerId: string; rootCid: string
|
|
1
|
+
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","Fula","NativeModules","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ninterface FulaNativeModule {\n init: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<{ peerId: string; rootCid: string }>;\n newClient: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<string>;\n isReady: (filesystemCheck: boolean) => Promise<boolean>;\n logout: (identity: string, storePath: string) => Promise<boolean>;\n checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;\n listFailedActions: (cids: string[]) => Promise<string[]>;\n checkConnection: (timeout: number) => Promise<boolean>;\n get: (key: string) => Promise<string>;\n has: (key: Uint8Array) => Promise<boolean>;\n push: () => Promise<string>;\n put: (content: string, codec: string) => Promise<string>;\n mkdir: (path: string) => Promise<string>;\n writeFileContent: (path: string, content: string) => Promise<string>;\n writeFile: (\n fulaTargetFilename: string,\n localFilename: string\n ) => Promise<string>;\n ls: (path: string) => Promise<string>;\n rm: (path: string) => Promise<string>;\n cp: (sourcePath: string, targetPath: string) => Promise<string>;\n mv: (sourcePath: string, targetPath: string) => Promise<string>;\n readFile: (\n fulaTargetFilename: string,\n localFilename: string\n ) => Promise<string>;\n readFileContent: (path: string) => Promise<string>;\n setAuth: (peerId: string, allow: boolean) => Promise<boolean>;\n\n shutdown: () => Promise<void>;\n\n testData: (identity: string, bloxAddr: string) => Promise<string>;\n\n //Blockchain related functions\n createAccount: (seed: string) => Promise<string>;\n checkAccountExists: (account: string) => Promise<string>;\n createPool: (seed: string, poolName: string) => Promise<string>;\n listPools: () => Promise<string>;\n joinPool: (seed: string, poolID: number) => Promise<string>;\n leavePool: (seed: string, poolID: number) => Promise<string>;\n cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;\n listPoolJoinRequests: (poolID: number) => Promise<string>;\n votePoolJoinRequest: (\n seed: string,\n poolID: number,\n account: string,\n accept: boolean\n ) => Promise<string>;\n newReplicationRequest: (\n seed: string,\n poolID: number,\n replicationFactor: number,\n cid: string\n ) => Promise<string>;\n newStoreRequest: (\n seed: string,\n poolID: number,\n uploader: string,\n cid: string\n ) => Promise<string>;\n listAvailableReplicationRequests: (poolID: number) => Promise<string>;\n removeReplicationRequest: (\n seed: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n removeStorer: (\n seed: string,\n storer: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n removeStoredReplication: (\n seed: string,\n uploader: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n\n //Hardware\n bloxFreeSpace: () => Promise<string>;\n wifiRemoveall: () => Promise<string>;\n reboot: () => Promise<string>;\n}\n\nconst LINKING_ERROR =\n `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Fula = NativeModules.FulaModule\n ? NativeModules.FulaModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport default Fula as FulaNativeModule;\n"],"mappings":";;;;;;AAAA;AAwGA,MAAMA,aAAa,GAChB,iFAAgF,GACjFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,IAAI,GAAGC,0BAAa,CAACC,UAAU,GACjCD,0BAAa,CAACC,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AAAC,eAESK,IAAI;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","Fula","newClient","logout","checkFailedActions","retry","timeout","listFailedActions","cids","checkConnection","get","key","has","push","testData","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const init = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n rootCid: string | null = null,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {\n console.log(\n 'init in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay\n );\n return Fula.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const newClient = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<string> => {\n console.log(\n 'newClient in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay,\n refresh\n );\n return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);\n};\n\n/**\n * rm removes all data\n * @param path\n * @returns string: new cid of the root\n */\nexport const logout = (\n identity: string,\n storePath: string\n): Promise<boolean> => {\n return Fula.logout(identity, storePath);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkFailedActions = (\n retry: boolean = false,\n timeout: number = 20\n): Promise<boolean> => {\n return Fula.checkFailedActions(retry, timeout);\n};\n\n/**\n * Lists the cids that failed to be sent to backend and are kept only locally\n */\nexport const listFailedActions = (cids: string[] = []): Promise<string[]> => {\n return Fula.listFailedActions(cids);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkConnection = (timeout: number = 20): Promise<boolean> => {\n return Fula.checkConnection(timeout);\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns value\n */\nexport const get = (key: string): Promise<string> => {\n return Fula.get(key);\n};\n\n/**\n * Has checks whether the value corresponding to the given key is present in the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns boolean\n */\nexport const has = (key: Uint8Array): Promise<boolean> => {\n return Fula.has(key);\n};\n\n/**\n * Push requests the given addr to download the root cid from this node.\n// The addr must be a valid multiaddr that includes peer ID.\n// this function.\n * @param addr\n * @returns null or error\n */\nexport const push = (): Promise<string> => {\n return Fula.push();\n};\n\n//This method sends some test data to backedn\nexport const testData = (\n identity: string,\n bloxAddr: string\n): Promise<string> => {\n return Fula.testData(identity, bloxAddr);\n};\n\n/**\n * Put stores the given key value onto the local datastore.\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\n// to the given key.\n * @param key, value\n * @returns null or string\n */\nexport const put = (value: string, codec: string): Promise<string> => {\n return Fula.put(value, codec);\n};\n\n/**\n * mkdir creates a directory at the given path.\n * @param path\n * @returns string: new cid of the root\n */\nexport const mkdir = (path: string): Promise<string> => {\n return Fula.mkdir(path);\n};\n\n/**\n * writeFileContent writes content at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const writeFileContent = (\n path: string,\n content: string\n): Promise<string> => {\n return Fula.writeFileContent(path, content);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // It keeps the original file modiifcation date\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const writeFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.writeFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * ls lists the name of files and folders at a given path\n * @param path\n * @returns string: list of items\n * TODO: Findout how is the string and convert to array\n */\nexport const ls = (path: string): Promise<void | JSON> => {\n return Fula.ls(path)\n .then((res) => {\n let lsResult = [];\n let lsRows = res.split('!!!');\n for (const element of lsRows) {\n let rowItems = element.split('???');\n if (rowItems && rowItems[0]) {\n let item = {\n name: '',\n created: '',\n modified: '',\n };\n item.name = rowItems[0];\n if (rowItems[1]) {\n item.created = rowItems[1];\n }\n if (rowItems[2]) {\n item.modified = rowItems[2];\n }\n lsResult.push(item);\n }\n }\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\n return jsonRes;\n })\n .catch((e) => {\n return e;\n });\n};\n\n/**\n * rm removes all files and folders at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const rm = (path: string): Promise<string> => {\n return Fula.rm(path);\n};\n\n/**\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.cp(sourcePath, targetPath);\n};\n\n/**\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.mv(sourcePath, targetPath);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const readFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.readFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * readFile reads content of a given path\n * @param path\n * @returns string: cotent\n */\nexport const readFileContent = (path: string): Promise<string> => {\n return Fula.readFileContent(path);\n};\n\n/**\n * Shutdown closes all resources used by Client.\n// After calling this function Client must be discarded.\n * @param\n * @returns\n */\nexport const shutdown = (): Promise<void> => {\n return Fula.shutdown();\n};\n\n/**\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\n * @param peerId, allow\n * @returns boolean: true if successful or false if not\n */\nexport const setAuth = (\n peerId: string,\n allow: boolean\n): Promise<boolean> => {\n return Fula.setAuth(peerId, allow);\n};\n\n\n/**\n * isReady checks if the connection is ready to be used.\n * @param filesystemCheck: also check if the wnfs is ready\n * @returns boolean: true if ready or false if not\n */\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\n return Fula.isReady(filesystemCheck);\n};\n"],"mappings":";;;;;;AAAA;AAAkD;AAElD;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAKsD;EAAA,IAJtEC,SAAkB,uEAAG,KAAK;EAAA,IAC1BC,OAAsB,uEAAG,IAAI;EAAA,IAC7BC,QAAiB,uEAAG,IAAI;EAAA,IACxBC,OAAgB,uEAAG,KAAK;EAExBC,OAAO,CAACC,GAAG,CACT,8BAA8B,EAC9BT,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTE,QAAQ,CACT;EACD,OAAOI,yBAAI,CAACX,IAAI,CAACC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,OAAO,CAAC;AAClG,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAOO,MAAMI,SAAS,GAAG,UACvBX,QAAgB,EAChBC,SAAiB,EACj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;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,EAAE,GAAG,CAACF,UAAkB,EAAEC,UAAkB,KAAsB;EAC7E,OAAO7C,yBAAI,CAAC8C,EAAE,CAACF,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AAOO,MAAME,QAAQ,GAAG,CACtBzB,kBAA0B,EAC1BC,aAAqB,KACD;EACpB,OAAOvB,yBAAI,CAAC+C,QAAQ,CAACzB,kBAAkB,EAAEC,aAAa,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMyB,eAAe,GAAI9B,IAAY,IAAsB;EAChE,OAAOlB,yBAAI,CAACgD,eAAe,CAAC9B,IAAI,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAM+B,QAAQ,GAAG,MAAqB;EAC3C,OAAOjD,yBAAI,CAACiD,QAAQ,EAAE;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMC,OAAO,GAAG,CACrBC,MAAc,EACdC,KAAc,KACO;EACrB,OAAOpD,yBAAI,CAACkD,OAAO,CAACC,MAAM,EAAEC,KAAK,CAAC;AACpC,CAAC;;AAGD;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAOtD,yBAAI,CAACqD,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","Fula","newClient","logout","checkFailedActions","retry","timeout","listFailedActions","cids","checkConnection","get","key","has","push","testData","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const init = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n rootCid: string | null = null,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<{ peerId: string; rootCid: string }> => {\n console.log(\n 'init in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay\n );\n return Fula.init(\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n rootCid,\n useRelay,\n refresh\n );\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const newClient = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<string> => {\n console.log(\n 'newClient in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay,\n refresh\n );\n return Fula.newClient(\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay,\n refresh\n );\n};\n\n/**\n * rm removes all data\n * @param path\n * @returns string: new cid of the root\n */\nexport const logout = (\n identity: string,\n storePath: string\n): Promise<boolean> => {\n return Fula.logout(identity, storePath);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkFailedActions = (\n retry: boolean = false,\n timeout: number = 20\n): Promise<boolean> => {\n return Fula.checkFailedActions(retry, timeout);\n};\n\n/**\n * Lists the cids that failed to be sent to backend and are kept only locally\n */\nexport const listFailedActions = (cids: string[] = []): Promise<string[]> => {\n return Fula.listFailedActions(cids);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkConnection = (timeout: number = 20): Promise<boolean> => {\n return Fula.checkConnection(timeout);\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns value\n */\nexport const get = (key: string): Promise<string> => {\n return Fula.get(key);\n};\n\n/**\n * Has checks whether the value corresponding to the given key is present in the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns boolean\n */\nexport const has = (key: Uint8Array): Promise<boolean> => {\n return Fula.has(key);\n};\n\n/**\n * Push requests the given addr to download the root cid from this node.\n// The addr must be a valid multiaddr that includes peer ID.\n// this function.\n * @param addr\n * @returns null or error\n */\nexport const push = (): Promise<string> => {\n return Fula.push();\n};\n\n//This method sends some test data to backedn\nexport const testData = (\n identity: string,\n bloxAddr: string\n): Promise<string> => {\n return Fula.testData(identity, bloxAddr);\n};\n\n/**\n * Put stores the given key value onto the local datastore.\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\n// to the given key.\n * @param key, value\n * @returns null or string\n */\nexport const put = (value: string, codec: string): Promise<string> => {\n return Fula.put(value, codec);\n};\n\n/**\n * mkdir creates a directory at the given path.\n * @param path\n * @returns string: new cid of the root\n */\nexport const mkdir = (path: string): Promise<string> => {\n return Fula.mkdir(path);\n};\n\n/**\n * writeFileContent writes content at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const writeFileContent = (\n path: string,\n content: string\n): Promise<string> => {\n return Fula.writeFileContent(path, content);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // It keeps the original file modiifcation date\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const writeFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.writeFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * ls lists the name of files and folders at a given path\n * @param path\n * @returns string: list of items\n * TODO: Findout how is the string and convert to array\n */\nexport const ls = (path: string): Promise<void | JSON> => {\n return Fula.ls(path)\n .then((res) => {\n let lsResult = [];\n let lsRows = res.split('!!!');\n for (const element of lsRows) {\n let rowItems = element.split('???');\n if (rowItems && rowItems[0]) {\n let item = {\n name: '',\n created: '',\n modified: '',\n };\n item.name = rowItems[0];\n if (rowItems[1]) {\n item.created = rowItems[1];\n }\n if (rowItems[2]) {\n item.modified = rowItems[2];\n }\n lsResult.push(item);\n }\n }\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\n return jsonRes;\n })\n .catch((e) => {\n return e;\n });\n};\n\n/**\n * rm removes all files and folders at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const rm = (path: string): Promise<string> => {\n return Fula.rm(path);\n};\n\n/**\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.cp(sourcePath, targetPath);\n};\n\n/**\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.mv(sourcePath, targetPath);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const readFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.readFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * readFile reads content of a given path\n * @param path\n * @returns string: cotent\n */\nexport const readFileContent = (path: string): Promise<string> => {\n return Fula.readFileContent(path);\n};\n\n/**\n * Shutdown closes all resources used by Client.\n// After calling this function Client must be discarded.\n * @param\n * @returns\n */\nexport const shutdown = (): Promise<void> => {\n return Fula.shutdown();\n};\n\n/**\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\n * @param peerId, allow\n * @returns boolean: true if successful or false if not\n */\nexport const setAuth = (peerId: string, allow: boolean): Promise<boolean> => {\n return Fula.setAuth(peerId, allow);\n};\n\n/**\n * isReady checks if the connection is ready to be used.\n * @param filesystemCheck: also check if the wnfs is ready\n * @returns boolean: true if ready or false if not\n */\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\n return Fula.isReady(filesystemCheck);\n};\n"],"mappings":";;;;;;AAAA;AAAkD;AAElD;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAKiC;EAAA,IAJjDC,SAAkB,uEAAG,KAAK;EAAA,IAC1BC,OAAsB,uEAAG,IAAI;EAAA,IAC7BC,QAAiB,uEAAG,IAAI;EAAA,IACxBC,OAAgB,uEAAG,KAAK;EAExBC,OAAO,CAACC,GAAG,CACT,8BAA8B,EAC9BT,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTE,QAAQ,CACT;EACD,OAAOI,yBAAI,CAACX,IAAI,CACdC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTC,OAAO,EACPC,QAAQ,EACRC,OAAO,CACR;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAOO,MAAMI,SAAS,GAAG,UACvBX,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAII;EAAA,IAHpBC,SAAkB,uEAAG,KAAK;EAAA,IAC1BE,QAAiB,uEAAG,IAAI;EAAA,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CAAC8C,EAAE,CAACF,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AAOO,MAAME,QAAQ,GAAG,CACtBzB,kBAA0B,EAC1BC,aAAqB,KACD;EACpB,OAAOvB,yBAAI,CAAC+C,QAAQ,CAACzB,kBAAkB,EAAEC,aAAa,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMyB,eAAe,GAAI9B,IAAY,IAAsB;EAChE,OAAOlB,yBAAI,CAACgD,eAAe,CAAC9B,IAAI,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAM+B,QAAQ,GAAG,MAAqB;EAC3C,OAAOjD,yBAAI,CAACiD,QAAQ,EAAE;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMC,OAAO,GAAG,CAACC,MAAc,EAAEC,KAAc,KAAuB;EAC3E,OAAOpD,yBAAI,CAACkD,OAAO,CAACC,MAAM,EAAEC,KAAK,CAAC;AACpC,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAOtD,yBAAI,CAACqD,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Fula","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ninterface FulaNativeModule {\n init: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<{ peerId: string; rootCid: string
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Fula","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ninterface FulaNativeModule {\n init: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<{ peerId: string; rootCid: string }>;\n newClient: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<string>;\n isReady: (filesystemCheck: boolean) => Promise<boolean>;\n logout: (identity: string, storePath: string) => Promise<boolean>;\n checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;\n listFailedActions: (cids: string[]) => Promise<string[]>;\n checkConnection: (timeout: number) => Promise<boolean>;\n get: (key: string) => Promise<string>;\n has: (key: Uint8Array) => Promise<boolean>;\n push: () => Promise<string>;\n put: (content: string, codec: string) => Promise<string>;\n mkdir: (path: string) => Promise<string>;\n writeFileContent: (path: string, content: string) => Promise<string>;\n writeFile: (\n fulaTargetFilename: string,\n localFilename: string\n ) => Promise<string>;\n ls: (path: string) => Promise<string>;\n rm: (path: string) => Promise<string>;\n cp: (sourcePath: string, targetPath: string) => Promise<string>;\n mv: (sourcePath: string, targetPath: string) => Promise<string>;\n readFile: (\n fulaTargetFilename: string,\n localFilename: string\n ) => Promise<string>;\n readFileContent: (path: string) => Promise<string>;\n setAuth: (peerId: string, allow: boolean) => Promise<boolean>;\n\n shutdown: () => Promise<void>;\n\n testData: (identity: string, bloxAddr: string) => Promise<string>;\n\n //Blockchain related functions\n createAccount: (seed: string) => Promise<string>;\n checkAccountExists: (account: string) => Promise<string>;\n createPool: (seed: string, poolName: string) => Promise<string>;\n listPools: () => Promise<string>;\n joinPool: (seed: string, poolID: number) => Promise<string>;\n leavePool: (seed: string, poolID: number) => Promise<string>;\n cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;\n listPoolJoinRequests: (poolID: number) => Promise<string>;\n votePoolJoinRequest: (\n seed: string,\n poolID: number,\n account: string,\n accept: boolean\n ) => Promise<string>;\n newReplicationRequest: (\n seed: string,\n poolID: number,\n replicationFactor: number,\n cid: string\n ) => Promise<string>;\n newStoreRequest: (\n seed: string,\n poolID: number,\n uploader: string,\n cid: string\n ) => Promise<string>;\n listAvailableReplicationRequests: (poolID: number) => Promise<string>;\n removeReplicationRequest: (\n seed: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n removeStorer: (\n seed: string,\n storer: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n removeStoredReplication: (\n seed: string,\n uploader: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n\n //Hardware\n bloxFreeSpace: () => Promise<string>;\n wifiRemoveall: () => Promise<string>;\n reboot: () => Promise<string>;\n}\n\nconst LINKING_ERROR =\n `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Fula = NativeModules.FulaModule\n ? NativeModules.FulaModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport default Fula as FulaNativeModule;\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAwGtD,MAAMC,aAAa,GAChB,iFAAgF,GACjFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,IAAI,GAAGN,aAAa,CAACO,UAAU,GACjCP,aAAa,CAACO,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AAEL,eAAeI,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Fula","init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","newClient","logout","checkFailedActions","retry","timeout","listFailedActions","cids","checkConnection","get","key","has","push","testData","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const init = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n rootCid: string | null = null,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {\n console.log(\n 'init in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay\n );\n return Fula.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const newClient = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<string> => {\n console.log(\n 'newClient in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay,\n refresh\n );\n return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);\n};\n\n/**\n * rm removes all data\n * @param path\n * @returns string: new cid of the root\n */\nexport const logout = (\n identity: string,\n storePath: string\n): Promise<boolean> => {\n return Fula.logout(identity, storePath);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkFailedActions = (\n retry: boolean = false,\n timeout: number = 20\n): Promise<boolean> => {\n return Fula.checkFailedActions(retry, timeout);\n};\n\n/**\n * Lists the cids that failed to be sent to backend and are kept only locally\n */\nexport const listFailedActions = (cids: string[] = []): Promise<string[]> => {\n return Fula.listFailedActions(cids);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkConnection = (timeout: number = 20): Promise<boolean> => {\n return Fula.checkConnection(timeout);\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns value\n */\nexport const get = (key: string): Promise<string> => {\n return Fula.get(key);\n};\n\n/**\n * Has checks whether the value corresponding to the given key is present in the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns boolean\n */\nexport const has = (key: Uint8Array): Promise<boolean> => {\n return Fula.has(key);\n};\n\n/**\n * Push requests the given addr to download the root cid from this node.\n// The addr must be a valid multiaddr that includes peer ID.\n// this function.\n * @param addr\n * @returns null or error\n */\nexport const push = (): Promise<string> => {\n return Fula.push();\n};\n\n//This method sends some test data to backedn\nexport const testData = (\n identity: string,\n bloxAddr: string\n): Promise<string> => {\n return Fula.testData(identity, bloxAddr);\n};\n\n/**\n * Put stores the given key value onto the local datastore.\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\n// to the given key.\n * @param key, value\n * @returns null or string\n */\nexport const put = (value: string, codec: string): Promise<string> => {\n return Fula.put(value, codec);\n};\n\n/**\n * mkdir creates a directory at the given path.\n * @param path\n * @returns string: new cid of the root\n */\nexport const mkdir = (path: string): Promise<string> => {\n return Fula.mkdir(path);\n};\n\n/**\n * writeFileContent writes content at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const writeFileContent = (\n path: string,\n content: string\n): Promise<string> => {\n return Fula.writeFileContent(path, content);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // It keeps the original file modiifcation date\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const writeFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.writeFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * ls lists the name of files and folders at a given path\n * @param path\n * @returns string: list of items\n * TODO: Findout how is the string and convert to array\n */\nexport const ls = (path: string): Promise<void | JSON> => {\n return Fula.ls(path)\n .then((res) => {\n let lsResult = [];\n let lsRows = res.split('!!!');\n for (const element of lsRows) {\n let rowItems = element.split('???');\n if (rowItems && rowItems[0]) {\n let item = {\n name: '',\n created: '',\n modified: '',\n };\n item.name = rowItems[0];\n if (rowItems[1]) {\n item.created = rowItems[1];\n }\n if (rowItems[2]) {\n item.modified = rowItems[2];\n }\n lsResult.push(item);\n }\n }\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\n return jsonRes;\n })\n .catch((e) => {\n return e;\n });\n};\n\n/**\n * rm removes all files and folders at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const rm = (path: string): Promise<string> => {\n return Fula.rm(path);\n};\n\n/**\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.cp(sourcePath, targetPath);\n};\n\n/**\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.mv(sourcePath, targetPath);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const readFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.readFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * readFile reads content of a given path\n * @param path\n * @returns string: cotent\n */\nexport const readFileContent = (path: string): Promise<string> => {\n return Fula.readFileContent(path);\n};\n\n/**\n * Shutdown closes all resources used by Client.\n// After calling this function Client must be discarded.\n * @param\n * @returns\n */\nexport const shutdown = (): Promise<void> => {\n return Fula.shutdown();\n};\n\n/**\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\n * @param peerId, allow\n * @returns boolean: true if successful or false if not\n */\nexport const setAuth = (\n peerId: string,\n allow: boolean\n): Promise<boolean> => {\n return Fula.setAuth(peerId, allow);\n};\n\n\n/**\n * isReady checks if the connection is ready to be used.\n * @param filesystemCheck: also check if the wnfs is ready\n * @returns boolean: true if ready or false if not\n */\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\n return Fula.isReady(filesystemCheck);\n};\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,gCAAgC;;AAEjD;AACA;AACA;AACA;AACA;AACA;;AAE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AACA;AACA,OAAO,MAAMC,OAAO,GAAG,CACrBC,MAAc,EACdC,KAAc,KACO;EACrB,OAAO/D,IAAI,CAAC6D,OAAO,CAACC,MAAM,EAAEC,KAAK,CAAC;AACpC,CAAC;;AAGD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAOjE,IAAI,CAACgE,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC"}
|
|
1
|
+
{"version":3,"names":["Fula","init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","newClient","logout","checkFailedActions","retry","timeout","listFailedActions","cids","checkConnection","get","key","has","push","testData","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const init = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n rootCid: string | null = null,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<{ peerId: string; rootCid: string }> => {\n console.log(\n 'init in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay\n );\n return Fula.init(\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n rootCid,\n useRelay,\n refresh\n );\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const newClient = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<string> => {\n console.log(\n 'newClient in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay,\n refresh\n );\n return Fula.newClient(\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay,\n refresh\n );\n};\n\n/**\n * rm removes all data\n * @param path\n * @returns string: new cid of the root\n */\nexport const logout = (\n identity: string,\n storePath: string\n): Promise<boolean> => {\n return Fula.logout(identity, storePath);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkFailedActions = (\n retry: boolean = false,\n timeout: number = 20\n): Promise<boolean> => {\n return Fula.checkFailedActions(retry, timeout);\n};\n\n/**\n * Lists the cids that failed to be sent to backend and are kept only locally\n */\nexport const listFailedActions = (cids: string[] = []): Promise<string[]> => {\n return Fula.listFailedActions(cids);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkConnection = (timeout: number = 20): Promise<boolean> => {\n return Fula.checkConnection(timeout);\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns value\n */\nexport const get = (key: string): Promise<string> => {\n return Fula.get(key);\n};\n\n/**\n * Has checks whether the value corresponding to the given key is present in the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns boolean\n */\nexport const has = (key: Uint8Array): Promise<boolean> => {\n return Fula.has(key);\n};\n\n/**\n * Push requests the given addr to download the root cid from this node.\n// The addr must be a valid multiaddr that includes peer ID.\n// this function.\n * @param addr\n * @returns null or error\n */\nexport const push = (): Promise<string> => {\n return Fula.push();\n};\n\n//This method sends some test data to backedn\nexport const testData = (\n identity: string,\n bloxAddr: string\n): Promise<string> => {\n return Fula.testData(identity, bloxAddr);\n};\n\n/**\n * Put stores the given key value onto the local datastore.\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\n// to the given key.\n * @param key, value\n * @returns null or string\n */\nexport const put = (value: string, codec: string): Promise<string> => {\n return Fula.put(value, codec);\n};\n\n/**\n * mkdir creates a directory at the given path.\n * @param path\n * @returns string: new cid of the root\n */\nexport const mkdir = (path: string): Promise<string> => {\n return Fula.mkdir(path);\n};\n\n/**\n * writeFileContent writes content at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const writeFileContent = (\n path: string,\n content: string\n): Promise<string> => {\n return Fula.writeFileContent(path, content);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // It keeps the original file modiifcation date\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const writeFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.writeFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * ls lists the name of files and folders at a given path\n * @param path\n * @returns string: list of items\n * TODO: Findout how is the string and convert to array\n */\nexport const ls = (path: string): Promise<void | JSON> => {\n return Fula.ls(path)\n .then((res) => {\n let lsResult = [];\n let lsRows = res.split('!!!');\n for (const element of lsRows) {\n let rowItems = element.split('???');\n if (rowItems && rowItems[0]) {\n let item = {\n name: '',\n created: '',\n modified: '',\n };\n item.name = rowItems[0];\n if (rowItems[1]) {\n item.created = rowItems[1];\n }\n if (rowItems[2]) {\n item.modified = rowItems[2];\n }\n lsResult.push(item);\n }\n }\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\n return jsonRes;\n })\n .catch((e) => {\n return e;\n });\n};\n\n/**\n * rm removes all files and folders at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const rm = (path: string): Promise<string> => {\n return Fula.rm(path);\n};\n\n/**\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.cp(sourcePath, targetPath);\n};\n\n/**\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.mv(sourcePath, targetPath);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const readFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.readFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * readFile reads content of a given path\n * @param path\n * @returns string: cotent\n */\nexport const readFileContent = (path: string): Promise<string> => {\n return Fula.readFileContent(path);\n};\n\n/**\n * Shutdown closes all resources used by Client.\n// After calling this function Client must be discarded.\n * @param\n * @returns\n */\nexport const shutdown = (): Promise<void> => {\n return Fula.shutdown();\n};\n\n/**\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\n * @param peerId, allow\n * @returns boolean: true if successful or false if not\n */\nexport const setAuth = (peerId: string, allow: boolean): Promise<boolean> => {\n return Fula.setAuth(peerId, allow);\n};\n\n/**\n * isReady checks if the connection is ready to be used.\n * @param filesystemCheck: also check if the wnfs is ready\n * @returns boolean: true if ready or false if not\n */\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\n return Fula.isReady(filesystemCheck);\n};\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,gCAAgC;;AAEjD;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAKiC;EAAA,IAJjD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AK,CAAC;AACpC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAOjE,IAAI,CAACgE,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC"}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
export declare const init: (identity: string, storePath: string, bloxAddr: string, exchange: string, autoFlush?: boolean, rootCid?: string | null, useRelay?: boolean, refresh?: boolean) => Promise<{
|
|
8
8
|
peerId: string;
|
|
9
9
|
rootCid: string;
|
|
10
|
-
private_ref: string;
|
|
11
10
|
}>;
|
|
12
11
|
/**
|
|
13
12
|
* Get gets the value corresponding to the given key from the local datastore.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functionland/react-native-fula",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.1",
|
|
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",
|
|
@@ -10,7 +10,7 @@ interface FulaNativeModule {
|
|
|
10
10
|
rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
|
|
11
11
|
useRelay: boolean | null, // if true it forces the use of relay
|
|
12
12
|
refresh: boolean // if true it forces to refresh the fula object
|
|
13
|
-
) => Promise<{ peerId: string; rootCid: string
|
|
13
|
+
) => Promise<{ peerId: string; rootCid: string }>;
|
|
14
14
|
newClient: (
|
|
15
15
|
identity: string, //Private key of did identity
|
|
16
16
|
storePath: string, //You can leave empty
|
package/src/protocols/fula.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const init = (
|
|
|
16
16
|
rootCid: string | null = null,
|
|
17
17
|
useRelay: boolean = true,
|
|
18
18
|
refresh: boolean = false
|
|
19
|
-
): Promise<{ peerId: string; rootCid: string
|
|
19
|
+
): Promise<{ peerId: string; rootCid: string }> => {
|
|
20
20
|
console.log(
|
|
21
21
|
'init in react-native started',
|
|
22
22
|
identity,
|
|
@@ -26,7 +26,16 @@ export const init = (
|
|
|
26
26
|
autoFlush,
|
|
27
27
|
useRelay
|
|
28
28
|
);
|
|
29
|
-
return Fula.init(
|
|
29
|
+
return Fula.init(
|
|
30
|
+
identity,
|
|
31
|
+
storePath,
|
|
32
|
+
bloxAddr,
|
|
33
|
+
exchange,
|
|
34
|
+
autoFlush,
|
|
35
|
+
rootCid,
|
|
36
|
+
useRelay,
|
|
37
|
+
refresh
|
|
38
|
+
);
|
|
30
39
|
};
|
|
31
40
|
|
|
32
41
|
/**
|
|
@@ -55,7 +64,15 @@ export const newClient = (
|
|
|
55
64
|
useRelay,
|
|
56
65
|
refresh
|
|
57
66
|
);
|
|
58
|
-
return Fula.newClient(
|
|
67
|
+
return Fula.newClient(
|
|
68
|
+
identity,
|
|
69
|
+
storePath,
|
|
70
|
+
bloxAddr,
|
|
71
|
+
exchange,
|
|
72
|
+
autoFlush,
|
|
73
|
+
useRelay,
|
|
74
|
+
refresh
|
|
75
|
+
);
|
|
59
76
|
};
|
|
60
77
|
|
|
61
78
|
/**
|
|
@@ -283,14 +300,10 @@ export const shutdown = (): Promise<void> => {
|
|
|
283
300
|
* @param peerId, allow
|
|
284
301
|
* @returns boolean: true if successful or false if not
|
|
285
302
|
*/
|
|
286
|
-
export const setAuth = (
|
|
287
|
-
peerId: string,
|
|
288
|
-
allow: boolean
|
|
289
|
-
): Promise<boolean> => {
|
|
303
|
+
export const setAuth = (peerId: string, allow: boolean): Promise<boolean> => {
|
|
290
304
|
return Fula.setAuth(peerId, allow);
|
|
291
305
|
};
|
|
292
306
|
|
|
293
|
-
|
|
294
307
|
/**
|
|
295
308
|
* isReady checks if the connection is ready to be used.
|
|
296
309
|
* @param filesystemCheck: also check if the wnfs is ready
|