@functionland/react-native-fula 1.2.1001 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.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/7.6/checksums/checksums.lock +0 -0
- package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.6/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.6/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.6/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/land/fx/fula/Cryptography.java +60 -47
- package/android/src/main/java/land/fx/fula/FulaModule.java +98 -27
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/protocols/fxblox.js +33 -0
- package/lib/commonjs/protocols/fxblox.js.map +1 -0
- package/lib/commonjs/types/fxblox.js +2 -0
- package/lib/commonjs/types/fxblox.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/protocols/fxblox.js +25 -0
- package/lib/module/protocols/fxblox.js.map +1 -0
- package/lib/module/types/fxblox.js +2 -0
- package/lib/module/types/fxblox.js.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +1 -0
- package/lib/typescript/protocols/fxblox.d.ts +6 -0
- package/lib/typescript/types/fxblox.d.ts +4 -0
- package/package.json +157 -157
- package/src/index.tsx +4 -3
- package/src/interfaces/fulaNativeModule.ts +87 -86
- package/src/protocols/fxblox.ts +28 -0
- package/src/types/fxblox.ts +4 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#
|
|
1
|
+
#Thu May 25 20:22:46 IRDT 2023
|
|
2
2
|
gradle.version=7.5.1
|
|
Binary file
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -62,7 +62,7 @@ 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.
|
|
65
|
+
implementation 'com.github.functionland:fula-build-aar:1.8.0' // From jitpack.io
|
|
66
66
|
implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
|
|
67
67
|
implementation 'commons-io:commons-io:20030203.000550'
|
|
68
68
|
// implementation files('mobile.aar')
|
|
@@ -1,47 +1,60 @@
|
|
|
1
|
-
package land.fx.fula;
|
|
2
|
-
|
|
3
|
-
import android.util.Base64;
|
|
4
|
-
|
|
5
|
-
import java.io.UnsupportedEncodingException;
|
|
6
|
-
import java.
|
|
7
|
-
import java.security.
|
|
8
|
-
import java.security.
|
|
9
|
-
import java.security.
|
|
10
|
-
import java.security.spec.
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
import javax.crypto.
|
|
16
|
-
import javax.crypto.
|
|
17
|
-
import javax.crypto.
|
|
18
|
-
import javax.crypto.
|
|
19
|
-
import javax.crypto.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
byte[] iv = new byte[12]; // Ensure this is randomly generated for each encryption.
|
|
30
|
+
new SecureRandom().nextBytes(iv);
|
|
31
|
+
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
|
|
32
|
+
cipher.init(Cipher.ENCRYPT_MODE, secret, spec);
|
|
33
|
+
byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));
|
|
34
|
+
ByteBuffer byteBuffer = ByteBuffer.allocate(iv.length + cipherText.length);
|
|
35
|
+
byteBuffer.put(iv);
|
|
36
|
+
byteBuffer.put(cipherText);
|
|
37
|
+
return Base64.encodeToString(byteBuffer.array(), Base64.NO_WRAP);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public static String decryptMsg(String cipherText, SecretKey secret)
|
|
41
|
+
throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
|
|
42
|
+
ByteBuffer byteBuffer = ByteBuffer.wrap(Base64.decode(cipherText, Base64.NO_WRAP));
|
|
43
|
+
byte[] iv = new byte[12];
|
|
44
|
+
byteBuffer.get(iv);
|
|
45
|
+
byte[] cipherBytes = new byte[byteBuffer.remaining()];
|
|
46
|
+
byteBuffer.get(cipherBytes);
|
|
47
|
+
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
48
|
+
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
|
|
49
|
+
cipher.init(Cipher.DECRYPT_MODE, secret, spec);
|
|
50
|
+
String decryptString = new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);
|
|
51
|
+
return decryptString;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static SecretKey generateKey(byte[] key)
|
|
55
|
+
throws NoSuchAlgorithmException, InvalidKeySpecException {
|
|
56
|
+
PBEKeySpec pbeKeySpec = new PBEKeySpec(StaticHelper.bytesToBase64(key).toCharArray(), key, 1000, 128);
|
|
57
|
+
SecretKey pbeKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(pbeKeySpec);
|
|
58
|
+
return new SecretKeySpec(pbeKey.getEncoded(), "AES");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -16,9 +16,17 @@ import org.apache.commons.io.FileUtils;
|
|
|
16
16
|
import org.jetbrains.annotations.Contract;
|
|
17
17
|
|
|
18
18
|
import java.io.File;
|
|
19
|
+
import java.io.IOException;
|
|
19
20
|
import java.nio.charset.StandardCharsets;
|
|
21
|
+
import java.security.GeneralSecurityException;
|
|
22
|
+
import java.security.InvalidAlgorithmParameterException;
|
|
23
|
+
import java.security.InvalidKeyException;
|
|
24
|
+
import java.security.NoSuchAlgorithmException;
|
|
20
25
|
import java.util.Arrays;
|
|
21
26
|
|
|
27
|
+
import javax.crypto.BadPaddingException;
|
|
28
|
+
import javax.crypto.IllegalBlockSizeException;
|
|
29
|
+
import javax.crypto.NoSuchPaddingException;
|
|
22
30
|
import javax.crypto.SecretKey;
|
|
23
31
|
|
|
24
32
|
import java.util.concurrent.Executors;
|
|
@@ -59,7 +67,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
59
67
|
SharedPreferenceHelper sharedPref;
|
|
60
68
|
SecretKey secretKeyGlobal;
|
|
61
69
|
String identityEncryptedGlobal;
|
|
62
|
-
static String
|
|
70
|
+
static String PRIVATE_KEY_STORE_PEERID = "PRIVATE_KEY";
|
|
63
71
|
|
|
64
72
|
public static class Client implements land.fx.wnfslib.Datastore {
|
|
65
73
|
|
|
@@ -125,6 +133,15 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
125
133
|
return input.getBytes(StandardCharsets.UTF_8);
|
|
126
134
|
}
|
|
127
135
|
|
|
136
|
+
private byte[] decToByte(@NonNull String input) {
|
|
137
|
+
String[] parts = input.split(",");
|
|
138
|
+
byte[] output = new byte[parts.length];
|
|
139
|
+
for (int i = 0; i < parts.length; i++) {
|
|
140
|
+
output[i] = Byte.parseByte(parts[i]);
|
|
141
|
+
}
|
|
142
|
+
return output;
|
|
143
|
+
}
|
|
144
|
+
|
|
128
145
|
@NonNull
|
|
129
146
|
@Contract("_ -> new")
|
|
130
147
|
public String toString(byte[] input) {
|
|
@@ -414,24 +431,50 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
414
431
|
}
|
|
415
432
|
|
|
416
433
|
@NonNull
|
|
417
|
-
private byte[] createPeerIdentity(byte[]
|
|
434
|
+
private byte[] createPeerIdentity(byte[] identity) throws GeneralSecurityException, IOException {
|
|
418
435
|
try {
|
|
419
436
|
// 1: First: create public key from provided private key
|
|
420
437
|
// 2: Should read the local keychain store (if it is key-value, key is public key above,
|
|
421
438
|
// 3: if found, decrypt using the private key
|
|
422
439
|
// 4: If not found or decryption not successful, generate an identity
|
|
423
440
|
// 5: then encrypt and store in keychain
|
|
441
|
+
byte[] libp2pId;
|
|
442
|
+
String encryptedLibp2pId = sharedPref.getValue(PRIVATE_KEY_STORE_PEERID);
|
|
443
|
+
byte[] encryptionPair;
|
|
444
|
+
SecretKey encryptionSecretKey;
|
|
445
|
+
try {
|
|
446
|
+
encryptionSecretKey = Cryptography.generateKey(identity);
|
|
447
|
+
Log.d("ReactNative", "encryptionSecretKey generated from privateKey");
|
|
448
|
+
} catch (Exception e) {
|
|
449
|
+
Log.d("ReactNative", "Failed to generate key for encryption: " + e.getMessage());
|
|
450
|
+
throw new GeneralSecurityException("Failed to generate key encryption", e);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (encryptedLibp2pId == null || !encryptedLibp2pId.startsWith("FULA_ENC_V3:")) {
|
|
454
|
+
Log.d("ReactNative", "encryptedLibp2pId is not correct. creating new one " + encryptedLibp2pId);
|
|
455
|
+
|
|
456
|
+
try {
|
|
457
|
+
libp2pId = Fulamobile.generateEd25519KeyFromString(toString(identity));
|
|
458
|
+
} catch (Exception e) {
|
|
459
|
+
Log.d("ReactNative", "Failed to generate libp2pId: " + e.getMessage());
|
|
460
|
+
throw new GeneralSecurityException("Failed to generate libp2pId", e);
|
|
461
|
+
}
|
|
462
|
+
encryptedLibp2pId = "FULA_ENC_V3:" + Cryptography.encryptMsg(StaticHelper.bytesToBase64(libp2pId), encryptionSecretKey);
|
|
463
|
+
sharedPref.add(PRIVATE_KEY_STORE_PEERID, encryptedLibp2pId);
|
|
464
|
+
} else {
|
|
465
|
+
Log.d("ReactNative", "encryptedLibp2pId is correct. decrypting " + encryptedLibp2pId);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
try {
|
|
469
|
+
String decryptedLibp2pId = Cryptography.decryptMsg(encryptedLibp2pId.replace("FULA_ENC_V3:", ""), encryptionSecretKey);
|
|
424
470
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
encryptedKey = Cryptography.encryptMsg(StaticHelper.bytesToBase64(autoGeneratedIdentity), secretKey);
|
|
430
|
-
sharedPref.add(PRIVATE_KEY_STORE_ID, encryptedKey);
|
|
471
|
+
return StaticHelper.base64ToBytes(decryptedLibp2pId);
|
|
472
|
+
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException e) {
|
|
473
|
+
Log.d("ReactNative", "createPeerIdentity decryptMsg failed with Error: " + e.getMessage());
|
|
474
|
+
throw (e);
|
|
431
475
|
}
|
|
432
|
-
return StaticHelper.base64ToBytes(Cryptography.decryptMsg(encryptedKey, secretKey));
|
|
433
476
|
|
|
434
|
-
} catch (
|
|
477
|
+
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException e) {
|
|
435
478
|
Log.d("ReactNative", "createPeerIdentity failed with Error: " + e.getMessage());
|
|
436
479
|
throw (e);
|
|
437
480
|
}
|
|
@@ -462,8 +505,8 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
462
505
|
String cid_encrypted = Cryptography.encryptMsg(this.rootConfig.getCid(), this.secretKeyGlobal);
|
|
463
506
|
String private_ref_encrypted = Cryptography.encryptMsg(this.rootConfig.getPrivate_ref(), this.secretKeyGlobal);
|
|
464
507
|
|
|
465
|
-
sharedPref.add("cid_encrypted_" + this.identityEncryptedGlobal, cid_encrypted);
|
|
466
|
-
sharedPref.add("private_ref_encrypted_" + this.identityEncryptedGlobal, private_ref_encrypted);
|
|
508
|
+
sharedPref.add("FULA_ENC_V3:cid_encrypted_" + this.identityEncryptedGlobal, cid_encrypted);
|
|
509
|
+
sharedPref.add("FULA_ENC_V3:private_ref_encrypted_" + this.identityEncryptedGlobal, private_ref_encrypted);
|
|
467
510
|
return true;
|
|
468
511
|
} else {
|
|
469
512
|
return false;
|
|
@@ -480,14 +523,15 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
480
523
|
this.fula.flush();
|
|
481
524
|
}
|
|
482
525
|
SecretKey secretKey = Cryptography.generateKey(identity);
|
|
526
|
+
|
|
483
527
|
String identity_encrypted = Cryptography.encryptMsg(Arrays.toString(identity), secretKey);
|
|
484
|
-
sharedPref.remove("cid_encrypted_"+ identity_encrypted);
|
|
485
|
-
sharedPref.remove("private_ref_encrypted_"+identity_encrypted);
|
|
528
|
+
sharedPref.remove("FULA_ENC_V3:cid_encrypted_"+ identity_encrypted);
|
|
529
|
+
sharedPref.remove("FULA_ENC_V3:private_ref_encrypted_"+identity_encrypted);
|
|
486
530
|
|
|
487
531
|
//TODO: Should also remove peerid @Mahdi
|
|
488
532
|
|
|
489
|
-
sharedPref.remove("cid_encrypted_"+ identity_encrypted);
|
|
490
|
-
sharedPref.remove("private_ref_encrypted_"+ identity_encrypted);
|
|
533
|
+
sharedPref.remove("FULA_ENC_V3:cid_encrypted_"+ identity_encrypted);
|
|
534
|
+
sharedPref.remove("FULA_ENC_V3:private_ref_encrypted_"+ identity_encrypted);
|
|
491
535
|
|
|
492
536
|
this.rootConfig = null;
|
|
493
537
|
this.secretKeyGlobal = null;
|
|
@@ -512,7 +556,8 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
512
556
|
}
|
|
513
557
|
|
|
514
558
|
@NonNull
|
|
515
|
-
private byte[] newClientInternal(byte[] identity, String storePath, String bloxAddr, String exchange, boolean autoFlush, boolean useRelay, boolean refresh) throws
|
|
559
|
+
private byte[] newClientInternal(byte[] identity, String storePath, String bloxAddr, String exchange, boolean autoFlush, boolean useRelay, boolean refresh) throws GeneralSecurityException, IOException {
|
|
560
|
+
byte[] peerIdentity = null;
|
|
516
561
|
try {
|
|
517
562
|
fulaConfig = new Config();
|
|
518
563
|
if (storePath == null || storePath.trim().isEmpty()) {
|
|
@@ -522,7 +567,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
522
567
|
}
|
|
523
568
|
Log.d("ReactNative", "newClientInternal storePath is set: " + fulaConfig.getStorePath());
|
|
524
569
|
|
|
525
|
-
|
|
570
|
+
peerIdentity = this.createPeerIdentity(identity);
|
|
526
571
|
fulaConfig.setIdentity(peerIdentity);
|
|
527
572
|
Log.d("ReactNative", "peerIdentity is set: " + toString(fulaConfig.getIdentity()));
|
|
528
573
|
fulaConfig.setBloxAddr(bloxAddr);
|
|
@@ -535,19 +580,25 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
535
580
|
}
|
|
536
581
|
if (this.fula == null || refresh) {
|
|
537
582
|
Log.d("ReactNative", "Creating a new Fula instance");
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
583
|
+
try {
|
|
584
|
+
shutdownInternal();
|
|
585
|
+
this.fula = Fulamobile.newClient(fulaConfig);
|
|
586
|
+
if (this.fula != null) {
|
|
587
|
+
this.fula.flush();
|
|
588
|
+
}
|
|
589
|
+
} catch (Exception e) {
|
|
590
|
+
Log.d("ReactNative", "Failed to create new Fula instance: " + e.getMessage());
|
|
591
|
+
throw new IOException("Failed to create new Fula instance", e);
|
|
592
|
+
}
|
|
543
593
|
}
|
|
544
|
-
|
|
545
|
-
} catch (Exception e) {
|
|
594
|
+
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException e) {
|
|
546
595
|
Log.d("ReactNative", "newclientInternal failed with Error: " + e.getMessage());
|
|
547
596
|
throw (e);
|
|
548
597
|
}
|
|
598
|
+
return peerIdentity;
|
|
549
599
|
}
|
|
550
600
|
|
|
601
|
+
|
|
551
602
|
@NonNull
|
|
552
603
|
private String[] initInternal(byte[] identity, String storePath, String bloxAddr, String exchange, boolean autoFlush, String rootCid, boolean useRelay, boolean refresh) throws Exception {
|
|
553
604
|
try {
|
|
@@ -568,8 +619,8 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
568
619
|
Log.d("ReactNative", "this.rootCid is empty.");
|
|
569
620
|
//Load from keystore
|
|
570
621
|
|
|
571
|
-
String cid_encrypted_fetched = sharedPref.getValue("cid_encrypted_"+ identity_encrypted);
|
|
572
|
-
String private_ref_encrypted_fetched = sharedPref.getValue("private_ref_encrypted_"+identity_encrypted);
|
|
622
|
+
String cid_encrypted_fetched = sharedPref.getValue("FULA_ENC_V3:cid_encrypted_"+ identity_encrypted);
|
|
623
|
+
String private_ref_encrypted_fetched = sharedPref.getValue("FULA_ENC_V3:private_ref_encrypted_"+identity_encrypted);
|
|
573
624
|
Log.d("ReactNative", "Here1");
|
|
574
625
|
String cid = "";
|
|
575
626
|
String private_ref = "";
|
|
@@ -1278,6 +1329,10 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
1278
1329
|
});
|
|
1279
1330
|
}
|
|
1280
1331
|
|
|
1332
|
+
////////////////////////////////////////////////////////////////
|
|
1333
|
+
///////////////// Blox Hardware Methods ////////////////////////
|
|
1334
|
+
////////////////////////////////////////////////////////////////
|
|
1335
|
+
|
|
1281
1336
|
@ReactMethod
|
|
1282
1337
|
public void bloxFreeSpace(Promise promise) {
|
|
1283
1338
|
ThreadUtils.runOnExecutor(() -> {
|
|
@@ -1294,4 +1349,20 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
1294
1349
|
});
|
|
1295
1350
|
}
|
|
1296
1351
|
|
|
1352
|
+
@ReactMethod
|
|
1353
|
+
public void wifiRemoveall(Promise promise) {
|
|
1354
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
1355
|
+
Log.d("ReactNative", "wifiRemoveall");
|
|
1356
|
+
try {
|
|
1357
|
+
byte[] result = this.fula.wifiRemoveall();
|
|
1358
|
+
String resultString = toString(result);
|
|
1359
|
+
Log.d("ReactNative", "result string="+resultString);
|
|
1360
|
+
promise.resolve(resultString);
|
|
1361
|
+
} catch (Exception e) {
|
|
1362
|
+
Log.d("ReactNative", e.getMessage());
|
|
1363
|
+
promise.reject(e);
|
|
1364
|
+
}
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1297
1368
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.fula = exports.chainApi = exports.blockchain = void 0;
|
|
6
|
+
exports.fxblox = exports.fula = exports.chainApi = exports.blockchain = void 0;
|
|
7
7
|
var _fula = _interopRequireWildcard(require("./protocols/fula"));
|
|
8
8
|
exports.fula = _fula;
|
|
9
9
|
var _blockchain = _interopRequireWildcard(require("./protocols/blockchain"));
|
|
10
10
|
exports.blockchain = _blockchain;
|
|
11
11
|
var _chainApi = _interopRequireWildcard(require("./protocols/chain-api"));
|
|
12
12
|
exports.chainApi = _chainApi;
|
|
13
|
+
var _fxblox = _interopRequireWildcard(require("./protocols/fxblox"));
|
|
14
|
+
exports.fxblox = _fxblox;
|
|
13
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.tsx"],"sourcesContent":["export * as fula from './protocols/fula';\
|
|
1
|
+
{"version":3,"names":[],"sources":["index.tsx"],"sourcesContent":["export * as fula from './protocols/fula';\nexport * as blockchain from './protocols/blockchain';\nexport * as chainApi from './protocols/chain-api';\nexport * as fxblox from './protocols/fxblox';\n"],"mappings":""}
|
|
@@ -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';\
|
|
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; private_ref: 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 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//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: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;\n newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;\n newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;\n listAvailableReplicationRequests: (poolID: number) => Promise<string>;\n removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;\n removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;\n removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;\n bloxFreeSpace: () => Promise<string>;\n wifiRemoveall: () => 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;AAqEA,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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.wifiRemoveall = void 0;
|
|
7
|
+
var _fulaNativeModule = _interopRequireDefault(require("../interfaces/fulaNativeModule"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
/**
|
|
10
|
+
* send a command to Blox hardware to remove all save wifis.
|
|
11
|
+
* @returns json{status:true if success, false if fails; msg: error message or success log}
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const wifiRemoveall = () => {
|
|
15
|
+
console.log('wifiRemoveall in react-native started');
|
|
16
|
+
let res = _fulaNativeModule.default.wifiRemoveall().then(res => {
|
|
17
|
+
try {
|
|
18
|
+
let jsonRes = JSON.parse(res);
|
|
19
|
+
return jsonRes;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(res);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}).catch(err => {
|
|
28
|
+
return err;
|
|
29
|
+
});
|
|
30
|
+
return res;
|
|
31
|
+
};
|
|
32
|
+
exports.wifiRemoveall = wifiRemoveall;
|
|
33
|
+
//# sourceMappingURL=fxblox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["wifiRemoveall","console","log","res","Fula","then","jsonRes","JSON","parse","e","catch","err"],"sources":["fxblox.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\nimport type * as BType from '../types/fxblox';\n\n/**\n * send a command to Blox hardware to remove all save wifis.\n * @returns json{status:true if success, false if fails; msg: error message or success log}\n */\n\nexport const wifiRemoveall = (): Promise<BType.wifiRemoveallResponse> => {\n console.log(\n 'wifiRemoveall in react-native started'\n );\n let res = Fula.wifiRemoveall().then((res) => {\n try {\n let jsonRes: BType.wifiRemoveallResponse = JSON.parse(res);\n return jsonRes;\n } catch (e) {\n try {\n return JSON.parse(res);\n } catch (e) {\n return res;\n }\n }\n }).catch((err) => {\n return err;\n });\n return res;\n };\n"],"mappings":";;;;;;AAAA;AAAkD;AAGlD;AACA;AACA;AACA;;AAEO,MAAMA,aAAa,GAAG,MAA4C;EACvEC,OAAO,CAACC,GAAG,CACX,uCAAuC,CACtC;EACD,IAAIC,GAAG,GAAGC,yBAAI,CAACJ,aAAa,EAAE,CAACK,IAAI,CAAEF,GAAG,IAAK;IAC7C,IAAI;MACJ,IAAIG,OAAoC,GAAGC,IAAI,CAACC,KAAK,CAACL,GAAG,CAAC;MAC1D,OAAOG,OAAO;IACd,CAAC,CAAC,OAAOG,CAAC,EAAE;MACZ,IAAI;QACJ,OAAOF,IAAI,CAACC,KAAK,CAACL,GAAG,CAAC;MACtB,CAAC,CAAC,OAAOM,CAAC,EAAE;QACZ,OAAON,GAAG;MACV;IACA;EACA,CAAC,CAAC,CAACO,KAAK,CAAEC,GAAG,IAAK;IAClB,OAAOA,GAAG;EACV,CAAC,CAAC;EACF,OAAOR,GAAG;AACV,CAAC;AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["fxblox.ts"],"sourcesContent":["export interface wifiRemoveallResponse {\n status: boolean;\n msg: string;\n }\n"],"mappings":""}
|
package/lib/module/index.js
CHANGED
|
@@ -4,4 +4,6 @@ import * as _blockchain from './protocols/blockchain';
|
|
|
4
4
|
export { _blockchain as blockchain };
|
|
5
5
|
import * as _chainApi from './protocols/chain-api';
|
|
6
6
|
export { _chainApi as chainApi };
|
|
7
|
+
import * as _fxblox from './protocols/fxblox';
|
|
8
|
+
export { _fxblox as fxblox };
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fula","blockchain","chainApi"],"sources":["index.tsx"],"sourcesContent":["export * as fula from './protocols/fula';\
|
|
1
|
+
{"version":3,"names":["fula","blockchain","chainApi","fxblox"],"sources":["index.tsx"],"sourcesContent":["export * as fula from './protocols/fula';\nexport * as blockchain from './protocols/blockchain';\nexport * as chainApi from './protocols/chain-api';\nexport * as fxblox from './protocols/fxblox';\n"],"mappings":"uBAAsB,kBAAkB;AAAA,kBAA5BA,IAAI;AAAA,6BACY,wBAAwB;AAAA,wBAAxCC,UAAU;AAAA,2BACI,uBAAuB;AAAA,sBAArCC,QAAQ;AAAA,yBACI,oBAAoB;AAAA,oBAAhCC,MAAM"}
|
|
@@ -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';\
|
|
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; private_ref: 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 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//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: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;\n newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;\n newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;\n listAvailableReplicationRequests: (poolID: number) => Promise<string>;\n removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;\n removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;\n removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;\n bloxFreeSpace: () => Promise<string>;\n wifiRemoveall: () => 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;AAqEtD,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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Fula from '../interfaces/fulaNativeModule';
|
|
2
|
+
/**
|
|
3
|
+
* send a command to Blox hardware to remove all save wifis.
|
|
4
|
+
* @returns json{status:true if success, false if fails; msg: error message or success log}
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const wifiRemoveall = () => {
|
|
8
|
+
console.log('wifiRemoveall in react-native started');
|
|
9
|
+
let res = Fula.wifiRemoveall().then(res => {
|
|
10
|
+
try {
|
|
11
|
+
let jsonRes = JSON.parse(res);
|
|
12
|
+
return jsonRes;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(res);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return res;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}).catch(err => {
|
|
21
|
+
return err;
|
|
22
|
+
});
|
|
23
|
+
return res;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=fxblox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Fula","wifiRemoveall","console","log","res","then","jsonRes","JSON","parse","e","catch","err"],"sources":["fxblox.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\nimport type * as BType from '../types/fxblox';\n\n/**\n * send a command to Blox hardware to remove all save wifis.\n * @returns json{status:true if success, false if fails; msg: error message or success log}\n */\n\nexport const wifiRemoveall = (): Promise<BType.wifiRemoveallResponse> => {\n console.log(\n 'wifiRemoveall in react-native started'\n );\n let res = Fula.wifiRemoveall().then((res) => {\n try {\n let jsonRes: BType.wifiRemoveallResponse = JSON.parse(res);\n return jsonRes;\n } catch (e) {\n try {\n return JSON.parse(res);\n } catch (e) {\n return res;\n }\n }\n }).catch((err) => {\n return err;\n });\n return res;\n };\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,gCAAgC;AAGjD;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,aAAa,GAAG,MAA4C;EACvEC,OAAO,CAACC,GAAG,CACX,uCAAuC,CACtC;EACD,IAAIC,GAAG,GAAGJ,IAAI,CAACC,aAAa,EAAE,CAACI,IAAI,CAAED,GAAG,IAAK;IAC7C,IAAI;MACJ,IAAIE,OAAoC,GAAGC,IAAI,CAACC,KAAK,CAACJ,GAAG,CAAC;MAC1D,OAAOE,OAAO;IACd,CAAC,CAAC,OAAOG,CAAC,EAAE;MACZ,IAAI;QACJ,OAAOF,IAAI,CAACC,KAAK,CAACJ,GAAG,CAAC;MACtB,CAAC,CAAC,OAAOK,CAAC,EAAE;QACZ,OAAOL,GAAG;MACV;IACA;EACA,CAAC,CAAC,CAACM,KAAK,CAAEC,GAAG,IAAK;IAClB,OAAOA,GAAG;EACV,CAAC,CAAC;EACF,OAAOP,GAAG;AACV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["fxblox.ts"],"sourcesContent":["export interface wifiRemoveallResponse {\n status: boolean;\n msg: string;\n }\n"],"mappings":""}
|
|
@@ -53,6 +53,7 @@ interface FulaNativeModule {
|
|
|
53
53
|
removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;
|
|
54
54
|
removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;
|
|
55
55
|
bloxFreeSpace: () => Promise<string>;
|
|
56
|
+
wifiRemoveall: () => Promise<string>;
|
|
56
57
|
}
|
|
57
58
|
declare const _default: FulaNativeModule;
|
|
58
59
|
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as BType from '../types/fxblox';
|
|
2
|
+
/**
|
|
3
|
+
* send a command to Blox hardware to remove all save wifis.
|
|
4
|
+
* @returns json{status:true if success, false if fails; msg: error message or success log}
|
|
5
|
+
*/
|
|
6
|
+
export declare const wifiRemoveall: () => Promise<BType.wifiRemoveallResponse>;
|
package/package.json
CHANGED
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@functionland/react-native-fula",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
|
|
5
|
-
"main": "lib/commonjs/index",
|
|
6
|
-
"module": "lib/module/index",
|
|
7
|
-
"types": "lib/typescript/index.d.ts",
|
|
8
|
-
"react-native": "src/index",
|
|
9
|
-
"source": "src/index",
|
|
10
|
-
"files": [
|
|
11
|
-
"src",
|
|
12
|
-
"lib",
|
|
13
|
-
"android",
|
|
14
|
-
"ios",
|
|
15
|
-
"cpp",
|
|
16
|
-
"!example/",
|
|
17
|
-
"react-native-fula.podspec",
|
|
18
|
-
"!lib/typescript/example",
|
|
19
|
-
"!android/build",
|
|
20
|
-
"!ios/build",
|
|
21
|
-
"!**/__tests__",
|
|
22
|
-
"!**/__fixtures__",
|
|
23
|
-
"!**/__mocks__"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"test": "jest",
|
|
27
|
-
"typescript": "tsc --noEmit",
|
|
28
|
-
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
29
|
-
"prepare": "bob build",
|
|
30
|
-
"release": "release-it",
|
|
31
|
-
"example": "set NODE_OPTIONS='' && yarn --cwd example",
|
|
32
|
-
"pods": "cd example && pod-install --quiet",
|
|
33
|
-
"bootstrap": "yarn example && yarn && yarn pods"
|
|
34
|
-
},
|
|
35
|
-
"keywords": [
|
|
36
|
-
"react-native",
|
|
37
|
-
"ios",
|
|
38
|
-
"android"
|
|
39
|
-
],
|
|
40
|
-
"repository": "https://github.com/functionland/react-native-fula",
|
|
41
|
-
"author": "Ehsan Shariati <ehsan6sha@gmail.com> (https://github.com/ehsan6sha)",
|
|
42
|
-
"license": "MIT",
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/functionland/react-native-fula/issues"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://github.com/functionland/react-native-fula#readme",
|
|
47
|
-
"publishConfig": {
|
|
48
|
-
"registry": "https://registry.npmjs.org"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@babel/plugin-proposal-export-namespace-from": "^7.16.7",
|
|
52
|
-
"@commitlint/config-conventional": "^11.0.0",
|
|
53
|
-
"@react-native-community/eslint-config": "^2.0.0",
|
|
54
|
-
"@release-it/conventional-changelog": "^2.0.0",
|
|
55
|
-
"@types/jest": "^26.0.0",
|
|
56
|
-
"@types/react": "^16.9.19",
|
|
57
|
-
"@types/react-native": "0.70.8",
|
|
58
|
-
"commitlint": "^11.0.0",
|
|
59
|
-
"eslint": "^7.2.0",
|
|
60
|
-
"eslint-config-prettier": "^7.0.0",
|
|
61
|
-
"eslint-plugin-prettier": "^3.1.3",
|
|
62
|
-
"husky": "^6.0.0",
|
|
63
|
-
"jest": "^26.0.1",
|
|
64
|
-
"pod-install": "^0.1.0",
|
|
65
|
-
"prettier": "^2.0.5",
|
|
66
|
-
"react": "^18.1.0",
|
|
67
|
-
"react-native": "0.70.6",
|
|
68
|
-
"react-native-builder-bob": "^0.18.0",
|
|
69
|
-
"release-it": "^14.2.2",
|
|
70
|
-
"typescript": "^4.1.3"
|
|
71
|
-
},
|
|
72
|
-
"peerDependencies": {
|
|
73
|
-
"@babel/core": "^7.0.0-0",
|
|
74
|
-
"@babel/preset-env": "^7.1.6",
|
|
75
|
-
"react": "*",
|
|
76
|
-
"react-native": "*"
|
|
77
|
-
},
|
|
78
|
-
"jest": {
|
|
79
|
-
"preset": "react-native",
|
|
80
|
-
"modulePathIgnorePatterns": [
|
|
81
|
-
"<rootDir>/example/node_modules",
|
|
82
|
-
"<rootDir>/lib/"
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
|
-
"commitlint": {
|
|
86
|
-
"extends": [
|
|
87
|
-
"@commitlint/config-conventional"
|
|
88
|
-
]
|
|
89
|
-
},
|
|
90
|
-
"release-it": {
|
|
91
|
-
"git": {
|
|
92
|
-
"commitMessage": "chore: release ${version}",
|
|
93
|
-
"tagName": "v${version}"
|
|
94
|
-
},
|
|
95
|
-
"npm": {
|
|
96
|
-
"publish": true
|
|
97
|
-
},
|
|
98
|
-
"github": {
|
|
99
|
-
"release": true
|
|
100
|
-
},
|
|
101
|
-
"plugins": {
|
|
102
|
-
"@release-it/conventional-changelog": {
|
|
103
|
-
"preset": "angular"
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"eslintConfig": {
|
|
108
|
-
"root": true,
|
|
109
|
-
"extends": [
|
|
110
|
-
"@react-native-community",
|
|
111
|
-
"prettier"
|
|
112
|
-
],
|
|
113
|
-
"rules": {
|
|
114
|
-
"prettier/prettier": [
|
|
115
|
-
"error",
|
|
116
|
-
{
|
|
117
|
-
"quoteProps": "consistent",
|
|
118
|
-
"singleQuote": true,
|
|
119
|
-
"tabWidth": 2,
|
|
120
|
-
"trailingComma": "es5",
|
|
121
|
-
"useTabs": false
|
|
122
|
-
}
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"eslintIgnore": [
|
|
127
|
-
"node_modules/",
|
|
128
|
-
"lib/"
|
|
129
|
-
],
|
|
130
|
-
"prettier": {
|
|
131
|
-
"quoteProps": "consistent",
|
|
132
|
-
"singleQuote": true,
|
|
133
|
-
"tabWidth": 2,
|
|
134
|
-
"trailingComma": "es5",
|
|
135
|
-
"useTabs": false
|
|
136
|
-
},
|
|
137
|
-
"react-native-builder-bob": {
|
|
138
|
-
"source": "src",
|
|
139
|
-
"output": "lib",
|
|
140
|
-
"targets": [
|
|
141
|
-
"commonjs",
|
|
142
|
-
"module",
|
|
143
|
-
[
|
|
144
|
-
"typescript",
|
|
145
|
-
{
|
|
146
|
-
"project": "tsconfig.build.json"
|
|
147
|
-
}
|
|
148
|
-
]
|
|
149
|
-
]
|
|
150
|
-
},
|
|
151
|
-
"dependencies": {
|
|
152
|
-
"@polkadot/api": "^9.11.3",
|
|
153
|
-
"@polkadot/keyring": "^10.2.6",
|
|
154
|
-
"@polkadot/util": "^10.2.6",
|
|
155
|
-
"@polkadot/util-crypto": "^10.2.6"
|
|
156
|
-
}
|
|
157
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@functionland/react-native-fula",
|
|
3
|
+
"version": "1.8.0",
|
|
4
|
+
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"!example/",
|
|
17
|
+
"react-native-fula.podspec",
|
|
18
|
+
"!lib/typescript/example",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!ios/build",
|
|
21
|
+
"!**/__tests__",
|
|
22
|
+
"!**/__fixtures__",
|
|
23
|
+
"!**/__mocks__"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"typescript": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
29
|
+
"prepare": "bob build",
|
|
30
|
+
"release": "release-it",
|
|
31
|
+
"example": "set NODE_OPTIONS='' && yarn --cwd example",
|
|
32
|
+
"pods": "cd example && pod-install --quiet",
|
|
33
|
+
"bootstrap": "yarn example && yarn && yarn pods"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"react-native",
|
|
37
|
+
"ios",
|
|
38
|
+
"android"
|
|
39
|
+
],
|
|
40
|
+
"repository": "https://github.com/functionland/react-native-fula",
|
|
41
|
+
"author": "Ehsan Shariati <ehsan6sha@gmail.com> (https://github.com/ehsan6sha)",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/functionland/react-native-fula/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/functionland/react-native-fula#readme",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@babel/plugin-proposal-export-namespace-from": "^7.16.7",
|
|
52
|
+
"@commitlint/config-conventional": "^11.0.0",
|
|
53
|
+
"@react-native-community/eslint-config": "^2.0.0",
|
|
54
|
+
"@release-it/conventional-changelog": "^2.0.0",
|
|
55
|
+
"@types/jest": "^26.0.0",
|
|
56
|
+
"@types/react": "^16.9.19",
|
|
57
|
+
"@types/react-native": "0.70.8",
|
|
58
|
+
"commitlint": "^11.0.0",
|
|
59
|
+
"eslint": "^7.2.0",
|
|
60
|
+
"eslint-config-prettier": "^7.0.0",
|
|
61
|
+
"eslint-plugin-prettier": "^3.1.3",
|
|
62
|
+
"husky": "^6.0.0",
|
|
63
|
+
"jest": "^26.0.1",
|
|
64
|
+
"pod-install": "^0.1.0",
|
|
65
|
+
"prettier": "^2.0.5",
|
|
66
|
+
"react": "^18.1.0",
|
|
67
|
+
"react-native": "0.70.6",
|
|
68
|
+
"react-native-builder-bob": "^0.18.0",
|
|
69
|
+
"release-it": "^14.2.2",
|
|
70
|
+
"typescript": "^4.1.3"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@babel/core": "^7.0.0-0",
|
|
74
|
+
"@babel/preset-env": "^7.1.6",
|
|
75
|
+
"react": "*",
|
|
76
|
+
"react-native": "*"
|
|
77
|
+
},
|
|
78
|
+
"jest": {
|
|
79
|
+
"preset": "react-native",
|
|
80
|
+
"modulePathIgnorePatterns": [
|
|
81
|
+
"<rootDir>/example/node_modules",
|
|
82
|
+
"<rootDir>/lib/"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"commitlint": {
|
|
86
|
+
"extends": [
|
|
87
|
+
"@commitlint/config-conventional"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"release-it": {
|
|
91
|
+
"git": {
|
|
92
|
+
"commitMessage": "chore: release ${version}",
|
|
93
|
+
"tagName": "v${version}"
|
|
94
|
+
},
|
|
95
|
+
"npm": {
|
|
96
|
+
"publish": true
|
|
97
|
+
},
|
|
98
|
+
"github": {
|
|
99
|
+
"release": true
|
|
100
|
+
},
|
|
101
|
+
"plugins": {
|
|
102
|
+
"@release-it/conventional-changelog": {
|
|
103
|
+
"preset": "angular"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"eslintConfig": {
|
|
108
|
+
"root": true,
|
|
109
|
+
"extends": [
|
|
110
|
+
"@react-native-community",
|
|
111
|
+
"prettier"
|
|
112
|
+
],
|
|
113
|
+
"rules": {
|
|
114
|
+
"prettier/prettier": [
|
|
115
|
+
"error",
|
|
116
|
+
{
|
|
117
|
+
"quoteProps": "consistent",
|
|
118
|
+
"singleQuote": true,
|
|
119
|
+
"tabWidth": 2,
|
|
120
|
+
"trailingComma": "es5",
|
|
121
|
+
"useTabs": false
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"eslintIgnore": [
|
|
127
|
+
"node_modules/",
|
|
128
|
+
"lib/"
|
|
129
|
+
],
|
|
130
|
+
"prettier": {
|
|
131
|
+
"quoteProps": "consistent",
|
|
132
|
+
"singleQuote": true,
|
|
133
|
+
"tabWidth": 2,
|
|
134
|
+
"trailingComma": "es5",
|
|
135
|
+
"useTabs": false
|
|
136
|
+
},
|
|
137
|
+
"react-native-builder-bob": {
|
|
138
|
+
"source": "src",
|
|
139
|
+
"output": "lib",
|
|
140
|
+
"targets": [
|
|
141
|
+
"commonjs",
|
|
142
|
+
"module",
|
|
143
|
+
[
|
|
144
|
+
"typescript",
|
|
145
|
+
{
|
|
146
|
+
"project": "tsconfig.build.json"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"dependencies": {
|
|
152
|
+
"@polkadot/api": "^9.11.3",
|
|
153
|
+
"@polkadot/keyring": "^10.2.6",
|
|
154
|
+
"@polkadot/util": "^10.2.6",
|
|
155
|
+
"@polkadot/util-crypto": "^10.2.6"
|
|
156
|
+
}
|
|
157
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * as fula from './protocols/fula';
|
|
2
|
-
export * as blockchain from './protocols/blockchain';
|
|
3
|
-
export * as chainApi from './protocols/chain-api';
|
|
1
|
+
export * as fula from './protocols/fula';
|
|
2
|
+
export * as blockchain from './protocols/blockchain';
|
|
3
|
+
export * as chainApi from './protocols/chain-api';
|
|
4
|
+
export * as fxblox from './protocols/fxblox';
|
|
@@ -1,86 +1,87 @@
|
|
|
1
|
-
import { NativeModules, Platform } from 'react-native';
|
|
2
|
-
|
|
3
|
-
interface FulaNativeModule {
|
|
4
|
-
init: (
|
|
5
|
-
identity: string, //Private key of did identity
|
|
6
|
-
storePath: string, //You can leave empty
|
|
7
|
-
bloxAddr: string, //Blox multiadddr needs to be manually entered now
|
|
8
|
-
exchange: string, //set to 'noope' for testing
|
|
9
|
-
autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
|
|
10
|
-
rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
|
|
11
|
-
useRelay: boolean | null, // if true it forces the use of relay
|
|
12
|
-
refresh: boolean // if true it forces to refresh the fula object
|
|
13
|
-
) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;
|
|
14
|
-
newClient: (
|
|
15
|
-
identity: string, //Private key of did identity
|
|
16
|
-
storePath: string, //You can leave empty
|
|
17
|
-
bloxAddr: string, //Blox multiadddr needs to be manually entered now
|
|
18
|
-
exchange: string, //set to 'noope' for testing
|
|
19
|
-
autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
|
|
20
|
-
useRelay: boolean | null, // if true it forces the use of relay
|
|
21
|
-
refresh: boolean // if true it forces to refresh the fula object
|
|
22
|
-
) => Promise<string>;
|
|
23
|
-
isReady: (filesystemCheck: boolean) => Promise<boolean>;
|
|
24
|
-
logout: (identity: string, storePath: string) => Promise<boolean>;
|
|
25
|
-
checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
|
|
26
|
-
checkConnection: (timeout: number) => Promise<boolean>;
|
|
27
|
-
get: (key: string) => Promise<string>;
|
|
28
|
-
has: (key: Uint8Array) => Promise<boolean>;
|
|
29
|
-
push: () => Promise<string>;
|
|
30
|
-
put: (content: string, codec: string) => Promise<string>;
|
|
31
|
-
mkdir: (path: string) => Promise<string>;
|
|
32
|
-
writeFileContent: (path: string, content: string) => Promise<string>;
|
|
33
|
-
writeFile: (
|
|
34
|
-
fulaTargetFilename: string,
|
|
35
|
-
localFilename: string
|
|
36
|
-
) => Promise<string>;
|
|
37
|
-
ls: (path: string) => Promise<string>;
|
|
38
|
-
rm: (path: string) => Promise<string>;
|
|
39
|
-
cp: (sourcePath: string, targetPath: string) => Promise<string>;
|
|
40
|
-
mv: (sourcePath: string, targetPath: string) => Promise<string>;
|
|
41
|
-
readFile: (
|
|
42
|
-
fulaTargetFilename: string,
|
|
43
|
-
localFilename: string
|
|
44
|
-
) => Promise<string>;
|
|
45
|
-
readFileContent: (path: string) => Promise<string>;
|
|
46
|
-
setAuth: (peerId: string, allow: boolean) => Promise<boolean>;
|
|
47
|
-
|
|
48
|
-
shutdown: () => Promise<void>;
|
|
49
|
-
|
|
50
|
-
//Blockchain related functions
|
|
51
|
-
createAccount: (seed: string) => Promise<string>;
|
|
52
|
-
checkAccountExists: (account: string) => Promise<string>;
|
|
53
|
-
createPool: (seed: string, poolName: string) => Promise<string>;
|
|
54
|
-
listPools: () => Promise<string>;
|
|
55
|
-
joinPool: (seed: string, poolID: number) => Promise<string>;
|
|
56
|
-
leavePool: (seed: string, poolID: number) => Promise<string>;
|
|
57
|
-
cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;
|
|
58
|
-
listPoolJoinRequests: (poolID: number) => Promise<string>;
|
|
59
|
-
votePoolJoinRequest: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;
|
|
60
|
-
newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;
|
|
61
|
-
newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;
|
|
62
|
-
listAvailableReplicationRequests: (poolID: number) => Promise<string>;
|
|
63
|
-
removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;
|
|
64
|
-
removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;
|
|
65
|
-
removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;
|
|
66
|
-
bloxFreeSpace: () => Promise<string>;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
'- You
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface FulaNativeModule {
|
|
4
|
+
init: (
|
|
5
|
+
identity: string, //Private key of did identity
|
|
6
|
+
storePath: string, //You can leave empty
|
|
7
|
+
bloxAddr: string, //Blox multiadddr needs to be manually entered now
|
|
8
|
+
exchange: string, //set to 'noope' for testing
|
|
9
|
+
autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
|
|
10
|
+
rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
|
|
11
|
+
useRelay: boolean | null, // if true it forces the use of relay
|
|
12
|
+
refresh: boolean // if true it forces to refresh the fula object
|
|
13
|
+
) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;
|
|
14
|
+
newClient: (
|
|
15
|
+
identity: string, //Private key of did identity
|
|
16
|
+
storePath: string, //You can leave empty
|
|
17
|
+
bloxAddr: string, //Blox multiadddr needs to be manually entered now
|
|
18
|
+
exchange: string, //set to 'noope' for testing
|
|
19
|
+
autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
|
|
20
|
+
useRelay: boolean | null, // if true it forces the use of relay
|
|
21
|
+
refresh: boolean // if true it forces to refresh the fula object
|
|
22
|
+
) => Promise<string>;
|
|
23
|
+
isReady: (filesystemCheck: boolean) => Promise<boolean>;
|
|
24
|
+
logout: (identity: string, storePath: string) => Promise<boolean>;
|
|
25
|
+
checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
|
|
26
|
+
checkConnection: (timeout: number) => Promise<boolean>;
|
|
27
|
+
get: (key: string) => Promise<string>;
|
|
28
|
+
has: (key: Uint8Array) => Promise<boolean>;
|
|
29
|
+
push: () => Promise<string>;
|
|
30
|
+
put: (content: string, codec: string) => Promise<string>;
|
|
31
|
+
mkdir: (path: string) => Promise<string>;
|
|
32
|
+
writeFileContent: (path: string, content: string) => Promise<string>;
|
|
33
|
+
writeFile: (
|
|
34
|
+
fulaTargetFilename: string,
|
|
35
|
+
localFilename: string
|
|
36
|
+
) => Promise<string>;
|
|
37
|
+
ls: (path: string) => Promise<string>;
|
|
38
|
+
rm: (path: string) => Promise<string>;
|
|
39
|
+
cp: (sourcePath: string, targetPath: string) => Promise<string>;
|
|
40
|
+
mv: (sourcePath: string, targetPath: string) => Promise<string>;
|
|
41
|
+
readFile: (
|
|
42
|
+
fulaTargetFilename: string,
|
|
43
|
+
localFilename: string
|
|
44
|
+
) => Promise<string>;
|
|
45
|
+
readFileContent: (path: string) => Promise<string>;
|
|
46
|
+
setAuth: (peerId: string, allow: boolean) => Promise<boolean>;
|
|
47
|
+
|
|
48
|
+
shutdown: () => Promise<void>;
|
|
49
|
+
|
|
50
|
+
//Blockchain related functions
|
|
51
|
+
createAccount: (seed: string) => Promise<string>;
|
|
52
|
+
checkAccountExists: (account: string) => Promise<string>;
|
|
53
|
+
createPool: (seed: string, poolName: string) => Promise<string>;
|
|
54
|
+
listPools: () => Promise<string>;
|
|
55
|
+
joinPool: (seed: string, poolID: number) => Promise<string>;
|
|
56
|
+
leavePool: (seed: string, poolID: number) => Promise<string>;
|
|
57
|
+
cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;
|
|
58
|
+
listPoolJoinRequests: (poolID: number) => Promise<string>;
|
|
59
|
+
votePoolJoinRequest: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;
|
|
60
|
+
newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;
|
|
61
|
+
newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;
|
|
62
|
+
listAvailableReplicationRequests: (poolID: number) => Promise<string>;
|
|
63
|
+
removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;
|
|
64
|
+
removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;
|
|
65
|
+
removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;
|
|
66
|
+
bloxFreeSpace: () => Promise<string>;
|
|
67
|
+
wifiRemoveall: () => Promise<string>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const LINKING_ERROR =
|
|
71
|
+
`The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \n\n` +
|
|
72
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
73
|
+
'- You rebuilt the app after installing the package\n' +
|
|
74
|
+
'- You are not using Expo managed workflow\n';
|
|
75
|
+
|
|
76
|
+
const Fula = NativeModules.FulaModule
|
|
77
|
+
? NativeModules.FulaModule
|
|
78
|
+
: new Proxy(
|
|
79
|
+
{},
|
|
80
|
+
{
|
|
81
|
+
get() {
|
|
82
|
+
throw new Error(LINKING_ERROR);
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
export default Fula as FulaNativeModule;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Fula from '../interfaces/fulaNativeModule';
|
|
2
|
+
import type * as BType from '../types/fxblox';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* send a command to Blox hardware to remove all save wifis.
|
|
6
|
+
* @returns json{status:true if success, false if fails; msg: error message or success log}
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const wifiRemoveall = (): Promise<BType.wifiRemoveallResponse> => {
|
|
10
|
+
console.log(
|
|
11
|
+
'wifiRemoveall in react-native started'
|
|
12
|
+
);
|
|
13
|
+
let res = Fula.wifiRemoveall().then((res) => {
|
|
14
|
+
try {
|
|
15
|
+
let jsonRes: BType.wifiRemoveallResponse = JSON.parse(res);
|
|
16
|
+
return jsonRes;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(res);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}).catch((err) => {
|
|
25
|
+
return err;
|
|
26
|
+
});
|
|
27
|
+
return res;
|
|
28
|
+
};
|