@functionland/react-native-fula 1.2.4 → 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.
Files changed (45) hide show
  1. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  3. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  4. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  5. package/android/.gradle/7.6/checksums/checksums.lock +0 -0
  6. package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
  7. package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
  8. package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
  9. package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
  10. package/android/.gradle/7.6/executionHistory/executionHistory.bin +0 -0
  11. package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
  12. package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
  13. package/android/.gradle/7.6/fileHashes/fileHashes.bin +0 -0
  14. package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
  15. package/android/.gradle/7.6/fileHashes/resourceHashesCache.bin +0 -0
  16. package/android/.gradle/7.6/gc.properties +0 -0
  17. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  18. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  19. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  20. package/android/.gradle/file-system.probe +0 -0
  21. package/android/build.gradle +1 -1
  22. package/android/src/main/java/land/fx/fula/FulaModule.java +69 -21
  23. package/lib/commonjs/index.js +3 -1
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  26. package/lib/commonjs/protocols/fxblox.js +33 -0
  27. package/lib/commonjs/protocols/fxblox.js.map +1 -0
  28. package/lib/commonjs/types/fxblox.js +2 -0
  29. package/lib/commonjs/types/fxblox.js.map +1 -0
  30. package/lib/module/index.js +2 -0
  31. package/lib/module/index.js.map +1 -1
  32. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  33. package/lib/module/protocols/fxblox.js +25 -0
  34. package/lib/module/protocols/fxblox.js.map +1 -0
  35. package/lib/module/types/fxblox.js +2 -0
  36. package/lib/module/types/fxblox.js.map +1 -0
  37. package/lib/typescript/index.d.ts +1 -0
  38. package/lib/typescript/interfaces/fulaNativeModule.d.ts +1 -0
  39. package/lib/typescript/protocols/fxblox.d.ts +6 -0
  40. package/lib/typescript/types/fxblox.d.ts +4 -0
  41. package/package.json +157 -157
  42. package/src/index.tsx +4 -3
  43. package/src/interfaces/fulaNativeModule.ts +87 -86
  44. package/src/protocols/fxblox.ts +28 -0
  45. package/src/types/fxblox.ts +4 -0
File without changes
@@ -1,2 +1,2 @@
1
- #Sat Dec 17 20:00:09 EST 2022
1
+ #Thu May 25 20:22:46 IRDT 2023
2
2
  gradle.version=7.5.1
Binary file
@@ -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.2.1' // From jitpack.io
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')
@@ -67,7 +67,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
67
67
  SharedPreferenceHelper sharedPref;
68
68
  SecretKey secretKeyGlobal;
69
69
  String identityEncryptedGlobal;
70
- static String PRIVATE_KEY_STORE_ID = "PRIVATE_KEY";
70
+ static String PRIVATE_KEY_STORE_PEERID = "PRIVATE_KEY";
71
71
 
72
72
  public static class Client implements land.fx.wnfslib.Datastore {
73
73
 
@@ -133,6 +133,15 @@ public class FulaModule extends ReactContextBaseJavaModule {
133
133
  return input.getBytes(StandardCharsets.UTF_8);
134
134
  }
135
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
+
136
145
  @NonNull
137
146
  @Contract("_ -> new")
138
147
  public String toString(byte[] input) {
@@ -422,30 +431,48 @@ public class FulaModule extends ReactContextBaseJavaModule {
422
431
  }
423
432
 
424
433
  @NonNull
425
- private byte[] createPeerIdentity(byte[] privateKey) throws GeneralSecurityException, IOException {
434
+ private byte[] createPeerIdentity(byte[] identity) throws GeneralSecurityException, IOException {
426
435
  try {
427
436
  // 1: First: create public key from provided private key
428
437
  // 2: Should read the local keychain store (if it is key-value, key is public key above,
429
438
  // 3: if found, decrypt using the private key
430
439
  // 4: If not found or decryption not successful, generate an identity
431
440
  // 5: then encrypt and store in keychain
432
- String encryptedKey = sharedPref.getValue(PRIVATE_KEY_STORE_ID);
433
- SecretKey secretKey = Cryptography.generateKey(privateKey);
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);
434
455
 
435
- if (encryptedKey == null || !encryptedKey.startsWith("FULA_ENC_V2:")) {
436
- byte[] autoGeneratedIdentity;
437
456
  try {
438
- autoGeneratedIdentity = Fulamobile.generateEd25519Key();
457
+ libp2pId = Fulamobile.generateEd25519KeyFromString(toString(identity));
439
458
  } catch (Exception e) {
440
- Log.d("ReactNative", "Failed to generate key: " + e.getMessage());
441
- throw new GeneralSecurityException("Failed to generate key", e);
459
+ Log.d("ReactNative", "Failed to generate libp2pId: " + e.getMessage());
460
+ throw new GeneralSecurityException("Failed to generate libp2pId", e);
442
461
  }
443
- encryptedKey = "FULA_ENC_V2:" + Cryptography.encryptMsg(StaticHelper.bytesToBase64(autoGeneratedIdentity), secretKey);
444
- sharedPref.add(PRIVATE_KEY_STORE_ID, encryptedKey);
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);
445
466
  }
446
467
 
447
- String decryptedKey = Cryptography.decryptMsg(encryptedKey.replace("FULA_ENC_V2:", ""), secretKey);
448
- return StaticHelper.base64ToBytes(decryptedKey);
468
+ try {
469
+ String decryptedLibp2pId = Cryptography.decryptMsg(encryptedLibp2pId.replace("FULA_ENC_V3:", ""), encryptionSecretKey);
470
+
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);
475
+ }
449
476
 
450
477
  } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException e) {
451
478
  Log.d("ReactNative", "createPeerIdentity failed with Error: " + e.getMessage());
@@ -478,8 +505,8 @@ public class FulaModule extends ReactContextBaseJavaModule {
478
505
  String cid_encrypted = Cryptography.encryptMsg(this.rootConfig.getCid(), this.secretKeyGlobal);
479
506
  String private_ref_encrypted = Cryptography.encryptMsg(this.rootConfig.getPrivate_ref(), this.secretKeyGlobal);
480
507
 
481
- sharedPref.add("FULA_ENC_V2:cid_encrypted_" + this.identityEncryptedGlobal, cid_encrypted);
482
- sharedPref.add("FULA_ENC_V2: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);
483
510
  return true;
484
511
  } else {
485
512
  return false;
@@ -496,14 +523,15 @@ public class FulaModule extends ReactContextBaseJavaModule {
496
523
  this.fula.flush();
497
524
  }
498
525
  SecretKey secretKey = Cryptography.generateKey(identity);
526
+
499
527
  String identity_encrypted = Cryptography.encryptMsg(Arrays.toString(identity), secretKey);
500
- sharedPref.remove("FULA_ENC_V2:cid_encrypted_"+ identity_encrypted);
501
- sharedPref.remove("FULA_ENC_V2: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);
502
530
 
503
531
  //TODO: Should also remove peerid @Mahdi
504
532
 
505
- sharedPref.remove("FULA_ENC_V2:cid_encrypted_"+ identity_encrypted);
506
- sharedPref.remove("FULA_ENC_V2: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);
507
535
 
508
536
  this.rootConfig = null;
509
537
  this.secretKeyGlobal = null;
@@ -591,8 +619,8 @@ public class FulaModule extends ReactContextBaseJavaModule {
591
619
  Log.d("ReactNative", "this.rootCid is empty.");
592
620
  //Load from keystore
593
621
 
594
- String cid_encrypted_fetched = sharedPref.getValue("FULA_ENC_V2:cid_encrypted_"+ identity_encrypted);
595
- String private_ref_encrypted_fetched = sharedPref.getValue("FULA_ENC_V2: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);
596
624
  Log.d("ReactNative", "Here1");
597
625
  String cid = "";
598
626
  String private_ref = "";
@@ -1301,6 +1329,10 @@ public class FulaModule extends ReactContextBaseJavaModule {
1301
1329
  });
1302
1330
  }
1303
1331
 
1332
+ ////////////////////////////////////////////////////////////////
1333
+ ///////////////// Blox Hardware Methods ////////////////////////
1334
+ ////////////////////////////////////////////////////////////////
1335
+
1304
1336
  @ReactMethod
1305
1337
  public void bloxFreeSpace(Promise promise) {
1306
1338
  ThreadUtils.runOnExecutor(() -> {
@@ -1317,4 +1349,20 @@ public class FulaModule extends ReactContextBaseJavaModule {
1317
1349
  });
1318
1350
  }
1319
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
+
1320
1368
  }
@@ -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';\r\nexport * as blockchain from './protocols/blockchain';\r\nexport * as chainApi from './protocols/chain-api';"],"mappings":""}
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';\r\n\r\ninterface FulaNativeModule {\r\n init: (\r\n identity: string, //Private key of did identity\r\n storePath: string, //You can leave empty\r\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\r\n exchange: string, //set to 'noope' for testing\r\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\r\n rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\r\n useRelay: boolean | null, // if true it forces the use of relay\r\n refresh: boolean // if true it forces to refresh the fula object\r\n ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;\r\n newClient: (\r\n identity: string, //Private key of did identity\r\n storePath: string, //You can leave empty\r\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\r\n exchange: string, //set to 'noope' for testing\r\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\r\n useRelay: boolean | null, // if true it forces the use of relay\r\n refresh: boolean // if true it forces to refresh the fula object\r\n ) => Promise<string>;\r\n isReady: (filesystemCheck: boolean) => Promise<boolean>;\r\n logout: (identity: string, storePath: string) => Promise<boolean>;\r\n checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;\r\n checkConnection: (timeout: number) => Promise<boolean>;\r\n get: (key: string) => Promise<string>;\r\n has: (key: Uint8Array) => Promise<boolean>;\r\n push: () => Promise<string>;\r\n put: (content: string, codec: string) => Promise<string>;\r\n mkdir: (path: string) => Promise<string>;\r\n writeFileContent: (path: string, content: string) => Promise<string>;\r\n writeFile: (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n ) => Promise<string>;\r\n ls: (path: string) => Promise<string>;\r\n rm: (path: string) => Promise<string>;\r\n cp: (sourcePath: string, targetPath: string) => Promise<string>;\r\n mv: (sourcePath: string, targetPath: string) => Promise<string>;\r\n readFile: (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n ) => Promise<string>;\r\n readFileContent: (path: string) => Promise<string>;\r\n setAuth: (peerId: string, allow: boolean) => Promise<boolean>;\r\n\r\n shutdown: () => Promise<void>;\r\n\r\n//Blockchain related functions\r\n createAccount: (seed: string) => Promise<string>;\r\n checkAccountExists: (account: string) => Promise<string>;\r\n createPool: (seed: string, poolName: string) => Promise<string>;\r\n listPools: () => Promise<string>;\r\n joinPool: (seed: string, poolID: number) => Promise<string>;\r\n leavePool: (seed: string, poolID: number) => Promise<string>;\r\n cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;\r\n listPoolJoinRequests: (poolID: number) => Promise<string>;\r\n votePoolJoinRequest: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;\r\n newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;\r\n newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;\r\n listAvailableReplicationRequests: (poolID: number) => Promise<string>;\r\n removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;\r\n removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;\r\n removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;\r\n bloxFreeSpace: () => Promise<string>;\r\n}\r\n\r\nconst LINKING_ERROR =\r\n `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \\n\\n` +\r\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\r\n '- You rebuilt the app after installing the package\\n' +\r\n '- You are not using Expo managed workflow\\n';\r\n\r\nconst Fula = NativeModules.FulaModule\r\n ? NativeModules.FulaModule\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\nexport default Fula as FulaNativeModule;\r\n"],"mappings":";;;;;;AAAA;AAoEA,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
+ {"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,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=fxblox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["fxblox.ts"],"sourcesContent":["export interface wifiRemoveallResponse {\n status: boolean;\n msg: string;\n }\n"],"mappings":""}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"names":["fula","blockchain","chainApi"],"sources":["index.tsx"],"sourcesContent":["export * as fula from './protocols/fula';\r\nexport * as blockchain from './protocols/blockchain';\r\nexport * as chainApi from './protocols/chain-api';"],"mappings":"uBAAsB,kBAAkB;AAAA,kBAA5BA,IAAI;AAAA,6BACY,wBAAwB;AAAA,wBAAxCC,UAAU;AAAA,2BACI,uBAAuB;AAAA,sBAArCC,QAAQ"}
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';\r\n\r\ninterface FulaNativeModule {\r\n init: (\r\n identity: string, //Private key of did identity\r\n storePath: string, //You can leave empty\r\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\r\n exchange: string, //set to 'noope' for testing\r\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\r\n rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\r\n useRelay: boolean | null, // if true it forces the use of relay\r\n refresh: boolean // if true it forces to refresh the fula object\r\n ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;\r\n newClient: (\r\n identity: string, //Private key of did identity\r\n storePath: string, //You can leave empty\r\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\r\n exchange: string, //set to 'noope' for testing\r\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\r\n useRelay: boolean | null, // if true it forces the use of relay\r\n refresh: boolean // if true it forces to refresh the fula object\r\n ) => Promise<string>;\r\n isReady: (filesystemCheck: boolean) => Promise<boolean>;\r\n logout: (identity: string, storePath: string) => Promise<boolean>;\r\n checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;\r\n checkConnection: (timeout: number) => Promise<boolean>;\r\n get: (key: string) => Promise<string>;\r\n has: (key: Uint8Array) => Promise<boolean>;\r\n push: () => Promise<string>;\r\n put: (content: string, codec: string) => Promise<string>;\r\n mkdir: (path: string) => Promise<string>;\r\n writeFileContent: (path: string, content: string) => Promise<string>;\r\n writeFile: (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n ) => Promise<string>;\r\n ls: (path: string) => Promise<string>;\r\n rm: (path: string) => Promise<string>;\r\n cp: (sourcePath: string, targetPath: string) => Promise<string>;\r\n mv: (sourcePath: string, targetPath: string) => Promise<string>;\r\n readFile: (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n ) => Promise<string>;\r\n readFileContent: (path: string) => Promise<string>;\r\n setAuth: (peerId: string, allow: boolean) => Promise<boolean>;\r\n\r\n shutdown: () => Promise<void>;\r\n\r\n//Blockchain related functions\r\n createAccount: (seed: string) => Promise<string>;\r\n checkAccountExists: (account: string) => Promise<string>;\r\n createPool: (seed: string, poolName: string) => Promise<string>;\r\n listPools: () => Promise<string>;\r\n joinPool: (seed: string, poolID: number) => Promise<string>;\r\n leavePool: (seed: string, poolID: number) => Promise<string>;\r\n cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;\r\n listPoolJoinRequests: (poolID: number) => Promise<string>;\r\n votePoolJoinRequest: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;\r\n newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;\r\n newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;\r\n listAvailableReplicationRequests: (poolID: number) => Promise<string>;\r\n removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;\r\n removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;\r\n removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;\r\n bloxFreeSpace: () => Promise<string>;\r\n}\r\n\r\nconst LINKING_ERROR =\r\n `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \\n\\n` +\r\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\r\n '- You rebuilt the app after installing the package\\n' +\r\n '- You are not using Expo managed workflow\\n';\r\n\r\nconst Fula = NativeModules.FulaModule\r\n ? NativeModules.FulaModule\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\nexport default Fula as FulaNativeModule;\r\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAoEtD,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
+ {"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,2 @@
1
+
2
+ //# sourceMappingURL=fxblox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["fxblox.ts"],"sourcesContent":["export interface wifiRemoveallResponse {\n status: boolean;\n msg: string;\n }\n"],"mappings":""}
@@ -1,3 +1,4 @@
1
1
  export * as fula from './protocols/fula';
2
2
  export * as blockchain from './protocols/blockchain';
3
3
  export * as chainApi from './protocols/chain-api';
4
+ export * as fxblox from './protocols/fxblox';
@@ -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>;
@@ -0,0 +1,4 @@
1
+ export interface wifiRemoveallResponse {
2
+ status: boolean;
3
+ msg: string;
4
+ }
package/package.json CHANGED
@@ -1,157 +1,157 @@
1
- {
2
- "name": "@functionland/react-native-fula",
3
- "version": "1.2.4",
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
- const LINKING_ERROR =
70
- `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \n\n` +
71
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
72
- '- You rebuilt the app after installing the package\n' +
73
- '- You are not using Expo managed workflow\n';
74
-
75
- const Fula = NativeModules.FulaModule
76
- ? NativeModules.FulaModule
77
- : new Proxy(
78
- {},
79
- {
80
- get() {
81
- throw new Error(LINKING_ERROR);
82
- },
83
- }
84
- );
85
-
86
- export default Fula as FulaNativeModule;
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
+ };
@@ -0,0 +1,4 @@
1
+ export interface wifiRemoveallResponse {
2
+ status: boolean;
3
+ msg: string;
4
+ }