@functionland/react-native-fula 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,8 @@ const peerId //returns peerId as string
23
23
  bloxAddr: string, //leave empty for testing without a backend node
24
24
  exchange: 'noop'|'', //add noop for testing without a backend
25
25
  autoFlush: boolean, //Default to false. Always set to false unless you know what you are doing. explicitly write data to disk after each operation if set to true
26
- useRelay: boolean //default to true. If true it forces the connection through relay
26
+ useRelay: boolean, //default to true. If true it forces the connection through relay
27
+ refresh: boolean? //forces the fula object to be recreated. default is false
27
28
  )
28
29
  ```
29
30
 
@@ -42,7 +43,7 @@ await fula.init(
42
43
  exchange: 'noop'|'', //add noop for testing without a backend
43
44
  autoFlush: boolean, //Default to false. Always set to false unless you know what you are doing. explicitly write data to disk after each operation if set to true
44
45
  useRelay: boolean, //default to true. If true it forces the connection through relay
45
- refresh: boolean //forces the fula object to be recreated. default is false
46
+ refresh: boolean? //forces the fula object to be recreated. default is false
46
47
  );
47
48
  ```
48
49
 
@@ -132,7 +133,9 @@ await fula.isReady(
132
133
  //checks if client can reach server
133
134
  const result //returns true if it can, and false if it cannot
134
135
  =
135
- await fula.checkConnection();
136
+ await fula.checkConnection(
137
+ timeout: number? //default to 20. Maximum time in seconds that checkConnection waits before throwing an error
138
+ );
136
139
 
137
140
  ```
138
141
 
@@ -142,6 +145,7 @@ const result //returns true if there are, and false if everything is synced with
142
145
  =
143
146
  await fula.checkFailedActions(
144
147
  retry: boolean //if true, it tries to sync device with server, if not, it only checks
148
+ timeout: number? //default to 20. Maximum time in seconds that checkConnection waits before throwing an error
145
149
  );
146
150
  ```
147
151
 
@@ -21,6 +21,11 @@ import java.util.Arrays;
21
21
 
22
22
  import javax.crypto.SecretKey;
23
23
 
24
+ import java.util.concurrent.Executors;
25
+ import java.util.concurrent.ScheduledExecutorService;
26
+ import java.util.concurrent.TimeUnit;
27
+ import java.util.concurrent.atomic.AtomicBoolean;
28
+
24
29
  import org.json.JSONObject;
25
30
  import org.json.JSONArray;
26
31
 
@@ -153,18 +158,21 @@ public class FulaModule extends ReactContextBaseJavaModule {
153
158
  }
154
159
 
155
160
  @ReactMethod
156
- public void checkConnection(Promise promise) {
161
+ public void checkConnection(int timeout, Promise promise) {
157
162
  Log.d("ReactNative", "checkConnection started");
158
163
  ThreadUtils.runOnExecutor(() -> {
159
164
  if (this.fula != null) {
160
165
  try {
161
- boolean connectionStatus = this.checkConnectionInternal();
166
+ boolean connectionStatus = this.checkConnectionInternal(timeout);
162
167
  promise.resolve(connectionStatus);
163
168
  }
164
169
  catch (Exception e) {
165
170
  Log.d("ReactNative", "checkConnection failed with Error: " + e.getMessage());
166
171
  promise.resolve(false);
167
172
  }
173
+ } else {
174
+ Log.d("ReactNative", "checkConnection failed with Error: " + "fula is null");
175
+ promise.resolve(false);
168
176
  }
169
177
  });
170
178
  }
@@ -174,12 +182,13 @@ public class FulaModule extends ReactContextBaseJavaModule {
174
182
  Log.d("ReactNative", "newClient started");
175
183
  ThreadUtils.runOnExecutor(() -> {
176
184
  try {
177
- Log.d("ReactNative", "newClient storePath= " + storePath);
185
+ Log.d("ReactNative", "newClient storePath= " + storePath + " bloxAddr= " + bloxAddr + " exchange= " + exchange + " autoFlush= " + autoFlush + " useRelay= " + useRelay + " refresh= " + refresh);
178
186
  byte[] identity = toByte(identityString);
179
187
  Log.d("ReactNative", "newClient identity= " + identityString);
180
188
  this.newClientInternal(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);
181
189
  //String objString = Arrays.toString(obj);
182
190
  String peerId = this.fula.id();
191
+ Log.d("ReactNative", "newClient peerId= " + peerId);
183
192
  promise.resolve(peerId);
184
193
  } catch (Exception e) {
185
194
  Log.d("ReactNative", "newClient failed with Error: " + e.getMessage());
@@ -198,8 +207,10 @@ public class FulaModule extends ReactContextBaseJavaModule {
198
207
  if (filesystemCheck) {
199
208
  if (this.client != null && this.rootConfig != null && !this.rootConfig.getCid().isEmpty()) {
200
209
  initialized = true;
210
+ Log.d("ReactNative", "isReady is true with filesystem check");
201
211
  }
202
212
  } else {
213
+ Log.d("ReactNative", "isReady is true without filesystem check");
203
214
  initialized = true;
204
215
  }
205
216
  }
@@ -249,31 +260,47 @@ public class FulaModule extends ReactContextBaseJavaModule {
249
260
  });
250
261
  }
251
262
 
252
- private boolean checkConnectionInternal() throws Exception {
263
+ private boolean checkConnectionInternal(int timeout) throws Exception {
253
264
  try {
254
- Log.d("ReactNative", "checkConnectionInternal started");
255
- if (this.fula != null) {
256
- try {
257
- Log.d("ReactNative", "connectToBlox started");
258
- this.fula.connectToBlox();
259
- return true;
260
- }
261
- catch (Exception e) {
262
- Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
263
- return false;
265
+ Log.d("ReactNative", "checkConnectionInternal started");
266
+ if (this.fula != null) {
267
+ try {
268
+ Log.d("ReactNative", "connectToBlox started");
269
+
270
+ AtomicBoolean connectionStatus = new AtomicBoolean(false);
271
+ ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
272
+ executor.schedule(() -> {
273
+ try {
274
+ this.fula.connectToBlox();
275
+ connectionStatus.set(true);
276
+ Log.d("ReactNative", "checkConnectionInternal succeeded ");
277
+ } catch (Exception e) {
278
+ Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
279
+ }
280
+ }, 0, TimeUnit.SECONDS);
281
+
282
+ executor.schedule(() -> {
283
+ executor.shutdown();
284
+ }, timeout, TimeUnit.SECONDS);
285
+
286
+ executor.awaitTermination(timeout, TimeUnit.SECONDS);
287
+ return connectionStatus.get();
288
+ } catch (Exception e) {
289
+ Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
290
+ return false;
291
+ }
292
+ } else {
293
+ Log.d("ReactNative", "checkConnectionInternal failed because fula is not initialized ");
294
+ return false;
264
295
  }
265
- } else {
266
- Log.d("ReactNative", "checkConnectionInternal failed because fula is not initialized ");
267
- return false;
268
- }
269
296
  } catch (Exception e) {
270
- Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
271
- throw (e);
297
+ Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
298
+ throw (e);
272
299
  }
273
- }
300
+ }
274
301
 
275
302
  @ReactMethod
276
- private void checkFailedActions(boolean retry, Promise promise) throws Exception {
303
+ private void checkFailedActions(boolean retry, int timeout, Promise promise) throws Exception {
277
304
  try {
278
305
  if (this.fula != null) {
279
306
  if (!retry) {
@@ -287,7 +314,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
287
314
  }
288
315
  } else {
289
316
  Log.d("ReactNative", "checkFailedActions with retry");
290
- boolean retryResults = this.retryFailedActionsInternal();
317
+ boolean retryResults = this.retryFailedActionsInternal(timeout);
291
318
  promise.resolve(!retryResults);
292
319
  }
293
320
  } else {
@@ -299,13 +326,13 @@ public class FulaModule extends ReactContextBaseJavaModule {
299
326
  }
300
327
  }
301
328
 
302
- private boolean retryFailedActionsInternal() throws Exception {
329
+ private boolean retryFailedActionsInternal(int timeout) throws Exception {
303
330
  try {
304
331
  Log.d("ReactNative", "retryFailedActionsInternal started");
305
332
  if (this.fula != null) {
306
333
  //Fula is initialized
307
334
  try {
308
- boolean connectionCheck = this.checkConnectionInternal();
335
+ boolean connectionCheck = this.checkConnectionInternal(timeout);
309
336
  if(connectionCheck) {
310
337
  try {
311
338
  Log.d("ReactNative", "retryFailedPushes started");
@@ -482,7 +509,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
482
509
  } else {
483
510
  fulaConfig.setStorePath(storePath);
484
511
  }
485
- Log.d("ReactNative", "storePath is set: " + fulaConfig.getStorePath());
512
+ Log.d("ReactNative", "newClientInternal storePath is set: " + fulaConfig.getStorePath());
486
513
 
487
514
  byte[] peerIdentity = this.createPeerIdentity(identity);
488
515
  fulaConfig.setIdentity(peerIdentity);
@@ -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) => Promise<boolean>;\r\n checkConnection: () => 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';\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"}
@@ -53,15 +53,17 @@ const logout = (identity, storePath) => {
53
53
  exports.logout = logout;
54
54
  const checkFailedActions = function () {
55
55
  let retry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
56
- return _fulaNativeModule.default.checkFailedActions(retry);
56
+ let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
57
+ return _fulaNativeModule.default.checkFailedActions(retry, timeout);
57
58
  };
58
59
 
59
60
  /**
60
61
  * Checks if there are any un-synced changes on the device
61
62
  */
62
63
  exports.checkFailedActions = checkFailedActions;
63
- const checkConnection = () => {
64
- return _fulaNativeModule.default.checkConnection();
64
+ const checkConnection = function () {
65
+ let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
66
+ return _fulaNativeModule.default.checkConnection(timeout);
65
67
  };
66
68
 
67
69
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","Fula","newClient","logout","checkFailedActions","retry","checkConnection","get","key","has","push","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param config\r\n * @returns boolean\r\n */\r\n\r\nexport const init = (\r\n identity: string, //privateKey of did identity\r\n storePath: string,\r\n bloxAddr: string,\r\n exchange: string,\r\n autoFlush: boolean = false,\r\n rootCid: string | null = null,\r\n useRelay: boolean = true,\r\n refresh: boolean = false\r\n): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {\r\n console.log(\r\n 'init in react-native started',\r\n identity,\r\n storePath,\r\n bloxAddr,\r\n exchange,\r\n autoFlush,\r\n useRelay\r\n );\r\n return Fula.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);\r\n};\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param config\r\n * @returns boolean\r\n */\r\n\r\nexport const newClient = (\r\n identity: string, //privateKey of did identity\r\n storePath: string,\r\n bloxAddr: string,\r\n exchange: string,\r\n autoFlush: boolean = false,\r\n useRelay: boolean = true,\r\n refresh: boolean = false\r\n): Promise<string> => {\r\n console.log(\r\n 'newClient in react-native started',\r\n identity,\r\n storePath,\r\n bloxAddr,\r\n exchange,\r\n autoFlush,\r\n useRelay,\r\n refresh\r\n );\r\n return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);\r\n};\r\n\r\n/**\r\n * rm removes all data\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const logout = (\r\n identity: string,\r\n storePath: string\r\n): Promise<boolean> => {\r\n return Fula.logout(identity, storePath);\r\n};\r\n\r\n/**\r\n * Checks if there are any un-synced changes on the device\r\n */\r\nexport const checkFailedActions = (\r\n retry: boolean = false\r\n): Promise<boolean> => {\r\n return Fula.checkFailedActions(retry);\r\n};\r\n\r\n/**\r\n * Checks if there are any un-synced changes on the device\r\n */\r\nexport const checkConnection = (): Promise<boolean> => {\r\n return Fula.checkConnection();\r\n};\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param key\r\n * @returns value\r\n */\r\nexport const get = (key: string): Promise<string> => {\r\n return Fula.get(key);\r\n};\r\n\r\n/**\r\n * Has checks whether the value corresponding to the given key is present in the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param key\r\n * @returns boolean\r\n */\r\nexport const has = (key: Uint8Array): Promise<boolean> => {\r\n return Fula.has(key);\r\n};\r\n\r\n/**\r\n * Push requests the given addr to download the root cid from this node.\r\n// The addr must be a valid multiaddr that includes peer ID.\r\n// this function.\r\n * @param addr\r\n * @returns null or error\r\n */\r\nexport const push = (): Promise<string> => {\r\n return Fula.push();\r\n};\r\n\r\n/**\r\n * Put stores the given key value onto the local datastore.\r\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\r\n// to the given key.\r\n * @param key, value\r\n * @returns null or string\r\n */\r\nexport const put = (value: string, codec: string): Promise<string> => {\r\n return Fula.put(value, codec);\r\n};\r\n\r\n/**\r\n * mkdir creates a directory at the given path.\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const mkdir = (path: string): Promise<string> => {\r\n return Fula.mkdir(path);\r\n};\r\n\r\n/**\r\n * writeFileContent writes content at a given path\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const writeFileContent = (\r\n path: string,\r\n content: string\r\n): Promise<string> => {\r\n return Fula.writeFileContent(path, content);\r\n};\r\n\r\n/*\r\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\r\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\r\n // It keeps the original file modiifcation date\r\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\r\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\r\n // Returns: new cid of the root after this file is placed in the tree\r\n */\r\nexport const writeFile = (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n): Promise<string> => {\r\n return Fula.writeFile(fulaTargetFilename, localFilename);\r\n};\r\n\r\n/**\r\n * ls lists the name of files and folders at a given path\r\n * @param path\r\n * @returns string: list of items\r\n * TODO: Findout how is the string and convert to array\r\n */\r\nexport const ls = (path: string): Promise<void | JSON> => {\r\n return Fula.ls(path)\r\n .then((res) => {\r\n let lsResult = [];\r\n let lsRows = res.split('!!!');\r\n for (const element of lsRows) {\r\n let rowItems = element.split('???');\r\n if (rowItems && rowItems[0]) {\r\n let item = {\r\n name: '',\r\n created: '',\r\n modified: '',\r\n };\r\n item.name = rowItems[0];\r\n if (rowItems[1]) {\r\n item.created = rowItems[1];\r\n }\r\n if (rowItems[2]) {\r\n item.modified = rowItems[2];\r\n }\r\n lsResult.push(item);\r\n }\r\n }\r\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\r\n return jsonRes;\r\n })\r\n .catch((e) => {\r\n return e;\r\n });\r\n};\r\n\r\n/**\r\n * rm removes all files and folders at a given path\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const rm = (path: string): Promise<string> => {\r\n return Fula.rm(path);\r\n};\r\n\r\n/**\r\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\r\n * @param sourcePath, targetPath\r\n * @returns string: new cid of the root\r\n */\r\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\r\n return Fula.cp(sourcePath, targetPath);\r\n};\r\n\r\n/**\r\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\r\n * @param sourcePath, targetPath\r\n * @returns string: new cid of the root\r\n */\r\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\r\n return Fula.mv(sourcePath, targetPath);\r\n};\r\n\r\n/*\r\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\r\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\r\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\r\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\r\n // Returns: new cid of the root after this file is placed in the tree\r\n */\r\nexport const readFile = (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n): Promise<string> => {\r\n return Fula.readFile(fulaTargetFilename, localFilename);\r\n};\r\n\r\n/**\r\n * readFile reads content of a given path\r\n * @param path\r\n * @returns string: cotent\r\n */\r\nexport const readFileContent = (path: string): Promise<string> => {\r\n return Fula.readFileContent(path);\r\n};\r\n\r\n/**\r\n * Shutdown closes all resources used by Client.\r\n// After calling this function Client must be discarded.\r\n * @param\r\n * @returns\r\n */\r\nexport const shutdown = (): Promise<void> => {\r\n return Fula.shutdown();\r\n};\r\n\r\n/**\r\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\r\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\r\n * @param peerId, allow\r\n * @returns boolean: true if successful or false if not\r\n */\r\nexport const setAuth = (\r\n peerId: string,\r\n allow: boolean\r\n): Promise<boolean> => {\r\n return Fula.setAuth(peerId, allow);\r\n};\r\n\r\n\r\n/**\r\n * isReady checks if the connection is ready to be used.\r\n * @param filesystemCheck: also check if the wnfs is ready\r\n * @returns boolean: true if ready or false if not\r\n */\r\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\r\n return Fula.isReady(filesystemCheck);\r\n};\r\n"],"mappings":";;;;;;AAAA;AAAkD;AAElD;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAKsD;EAAA,IAJtEC,SAAkB,uEAAG,KAAK;EAAA,IAC1BC,OAAsB,uEAAG,IAAI;EAAA,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C,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,EAAE,GAAG,CAACF,UAAkB,EAAEC,UAAkB,KAAsB;EAC7E,OAAOzC,yBAAI,CAAC0C,EAAE,CAACF,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AAOO,MAAME,QAAQ,GAAG,CACtBzB,kBAA0B,EAC1BC,aAAqB,KACD;EACpB,OAAOnB,yBAAI,CAAC2C,QAAQ,CAACzB,kBAAkB,EAAEC,aAAa,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMyB,eAAe,GAAI9B,IAAY,IAAsB;EAChE,OAAOd,yBAAI,CAAC4C,eAAe,CAAC9B,IAAI,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAM+B,QAAQ,GAAG,MAAqB;EAC3C,OAAO7C,yBAAI,CAAC6C,QAAQ,EAAE;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMC,OAAO,GAAG,CACrBC,MAAc,EACdC,KAAc,KACO;EACrB,OAAOhD,yBAAI,CAAC8C,OAAO,CAACC,MAAM,EAAEC,KAAK,CAAC;AACpC,CAAC;;AAGD;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAOlD,yBAAI,CAACiD,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC;AAAC"}
1
+ {"version":3,"names":["init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","Fula","newClient","logout","checkFailedActions","retry","timeout","checkConnection","get","key","has","push","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param config\r\n * @returns boolean\r\n */\r\n\r\nexport const init = (\r\n identity: string, //privateKey of did identity\r\n storePath: string,\r\n bloxAddr: string,\r\n exchange: string,\r\n autoFlush: boolean = false,\r\n rootCid: string | null = null,\r\n useRelay: boolean = true,\r\n refresh: boolean = false\r\n): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {\r\n console.log(\r\n 'init in react-native started',\r\n identity,\r\n storePath,\r\n bloxAddr,\r\n exchange,\r\n autoFlush,\r\n useRelay\r\n );\r\n return Fula.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);\r\n};\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param config\r\n * @returns boolean\r\n */\r\n\r\nexport const newClient = (\r\n identity: string, //privateKey of did identity\r\n storePath: string,\r\n bloxAddr: string,\r\n exchange: string,\r\n autoFlush: boolean = false,\r\n useRelay: boolean = true,\r\n refresh: boolean = false\r\n): Promise<string> => {\r\n console.log(\r\n 'newClient in react-native started',\r\n identity,\r\n storePath,\r\n bloxAddr,\r\n exchange,\r\n autoFlush,\r\n useRelay,\r\n refresh\r\n );\r\n return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);\r\n};\r\n\r\n/**\r\n * rm removes all data\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const logout = (\r\n identity: string,\r\n storePath: string\r\n): Promise<boolean> => {\r\n return Fula.logout(identity, storePath);\r\n};\r\n\r\n/**\r\n * Checks if there are any un-synced changes on the device\r\n */\r\nexport const checkFailedActions = (\r\n retry: boolean = false,\r\n timeout: number = 20\r\n): Promise<boolean> => {\r\n return Fula.checkFailedActions(retry, timeout);\r\n};\r\n\r\n/**\r\n * Checks if there are any un-synced changes on the device\r\n */\r\nexport const checkConnection = (timeout: number = 20): Promise<boolean> => {\r\n return Fula.checkConnection(timeout);\r\n};\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param key\r\n * @returns value\r\n */\r\nexport const get = (key: string): Promise<string> => {\r\n return Fula.get(key);\r\n};\r\n\r\n/**\r\n * Has checks whether the value corresponding to the given key is present in the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param key\r\n * @returns boolean\r\n */\r\nexport const has = (key: Uint8Array): Promise<boolean> => {\r\n return Fula.has(key);\r\n};\r\n\r\n/**\r\n * Push requests the given addr to download the root cid from this node.\r\n// The addr must be a valid multiaddr that includes peer ID.\r\n// this function.\r\n * @param addr\r\n * @returns null or error\r\n */\r\nexport const push = (): Promise<string> => {\r\n return Fula.push();\r\n};\r\n\r\n/**\r\n * Put stores the given key value onto the local datastore.\r\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\r\n// to the given key.\r\n * @param key, value\r\n * @returns null or string\r\n */\r\nexport const put = (value: string, codec: string): Promise<string> => {\r\n return Fula.put(value, codec);\r\n};\r\n\r\n/**\r\n * mkdir creates a directory at the given path.\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const mkdir = (path: string): Promise<string> => {\r\n return Fula.mkdir(path);\r\n};\r\n\r\n/**\r\n * writeFileContent writes content at a given path\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const writeFileContent = (\r\n path: string,\r\n content: string\r\n): Promise<string> => {\r\n return Fula.writeFileContent(path, content);\r\n};\r\n\r\n/*\r\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\r\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\r\n // It keeps the original file modiifcation date\r\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\r\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\r\n // Returns: new cid of the root after this file is placed in the tree\r\n */\r\nexport const writeFile = (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n): Promise<string> => {\r\n return Fula.writeFile(fulaTargetFilename, localFilename);\r\n};\r\n\r\n/**\r\n * ls lists the name of files and folders at a given path\r\n * @param path\r\n * @returns string: list of items\r\n * TODO: Findout how is the string and convert to array\r\n */\r\nexport const ls = (path: string): Promise<void | JSON> => {\r\n return Fula.ls(path)\r\n .then((res) => {\r\n let lsResult = [];\r\n let lsRows = res.split('!!!');\r\n for (const element of lsRows) {\r\n let rowItems = element.split('???');\r\n if (rowItems && rowItems[0]) {\r\n let item = {\r\n name: '',\r\n created: '',\r\n modified: '',\r\n };\r\n item.name = rowItems[0];\r\n if (rowItems[1]) {\r\n item.created = rowItems[1];\r\n }\r\n if (rowItems[2]) {\r\n item.modified = rowItems[2];\r\n }\r\n lsResult.push(item);\r\n }\r\n }\r\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\r\n return jsonRes;\r\n })\r\n .catch((e) => {\r\n return e;\r\n });\r\n};\r\n\r\n/**\r\n * rm removes all files and folders at a given path\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const rm = (path: string): Promise<string> => {\r\n return Fula.rm(path);\r\n};\r\n\r\n/**\r\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\r\n * @param sourcePath, targetPath\r\n * @returns string: new cid of the root\r\n */\r\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\r\n return Fula.cp(sourcePath, targetPath);\r\n};\r\n\r\n/**\r\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\r\n * @param sourcePath, targetPath\r\n * @returns string: new cid of the root\r\n */\r\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\r\n return Fula.mv(sourcePath, targetPath);\r\n};\r\n\r\n/*\r\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\r\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\r\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\r\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\r\n // Returns: new cid of the root after this file is placed in the tree\r\n */\r\nexport const readFile = (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n): Promise<string> => {\r\n return Fula.readFile(fulaTargetFilename, localFilename);\r\n};\r\n\r\n/**\r\n * readFile reads content of a given path\r\n * @param path\r\n * @returns string: cotent\r\n */\r\nexport const readFileContent = (path: string): Promise<string> => {\r\n return Fula.readFileContent(path);\r\n};\r\n\r\n/**\r\n * Shutdown closes all resources used by Client.\r\n// After calling this function Client must be discarded.\r\n * @param\r\n * @returns\r\n */\r\nexport const shutdown = (): Promise<void> => {\r\n return Fula.shutdown();\r\n};\r\n\r\n/**\r\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\r\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\r\n * @param peerId, allow\r\n * @returns boolean: true if successful or false if not\r\n */\r\nexport const setAuth = (\r\n peerId: string,\r\n allow: boolean\r\n): Promise<boolean> => {\r\n return Fula.setAuth(peerId, allow);\r\n};\r\n\r\n\r\n/**\r\n * isReady checks if the connection is ready to be used.\r\n * @param filesystemCheck: also check if the wnfs is ready\r\n * @returns boolean: true if ready or false if not\r\n */\r\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\r\n return Fula.isReady(filesystemCheck);\r\n};\r\n"],"mappings":";;;;;;AAAA;AAAkD;AAElD;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAKsD;EAAA,IAJtEC,SAAkB,uEAAG,KAAK;EAAA,IAC1BC,OAAsB,uEAAG,IAAI;EAAA,IAC7BC,QAAiB,uEAAG,IAAI;EAAA,IACxBC,OAAgB,uEAAG,K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CAACwC,EAAE,CAACC,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,EAAE,GAAG,CAACF,UAAkB,EAAEC,UAAkB,KAAsB;EAC7E,OAAO1C,yBAAI,CAAC2C,EAAE,CAACF,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AAOO,MAAME,QAAQ,GAAG,CACtBzB,kBAA0B,EAC1BC,aAAqB,KACD;EACpB,OAAOpB,yBAAI,CAAC4C,QAAQ,CAACzB,kBAAkB,EAAEC,aAAa,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMyB,eAAe,GAAI9B,IAAY,IAAsB;EAChE,OAAOf,yBAAI,CAAC6C,eAAe,CAAC9B,IAAI,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAM+B,QAAQ,GAAG,MAAqB;EAC3C,OAAO9C,yBAAI,CAAC8C,QAAQ,EAAE;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMC,OAAO,GAAG,CACrBC,MAAc,EACdC,KAAc,KACO;EACrB,OAAOjD,yBAAI,CAAC+C,OAAO,CAACC,MAAM,EAAEC,KAAK,CAAC;AACpC,CAAC;;AAGD;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAOnD,yBAAI,CAACkD,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC;AAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Fula","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\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) => Promise<boolean>;\r\n checkConnection: () => 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';\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"}
@@ -45,14 +45,16 @@ export const logout = (identity, storePath) => {
45
45
  */
46
46
  export const checkFailedActions = function () {
47
47
  let retry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
48
- return Fula.checkFailedActions(retry);
48
+ let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
49
+ return Fula.checkFailedActions(retry, timeout);
49
50
  };
50
51
 
51
52
  /**
52
53
  * Checks if there are any un-synced changes on the device
53
54
  */
54
- export const checkConnection = () => {
55
- return Fula.checkConnection();
55
+ export const checkConnection = function () {
56
+ let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
57
+ return Fula.checkConnection(timeout);
56
58
  };
57
59
 
58
60
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["Fula","init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","newClient","logout","checkFailedActions","retry","checkConnection","get","key","has","push","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param config\r\n * @returns boolean\r\n */\r\n\r\nexport const init = (\r\n identity: string, //privateKey of did identity\r\n storePath: string,\r\n bloxAddr: string,\r\n exchange: string,\r\n autoFlush: boolean = false,\r\n rootCid: string | null = null,\r\n useRelay: boolean = true,\r\n refresh: boolean = false\r\n): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {\r\n console.log(\r\n 'init in react-native started',\r\n identity,\r\n storePath,\r\n bloxAddr,\r\n exchange,\r\n autoFlush,\r\n useRelay\r\n );\r\n return Fula.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);\r\n};\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param config\r\n * @returns boolean\r\n */\r\n\r\nexport const newClient = (\r\n identity: string, //privateKey of did identity\r\n storePath: string,\r\n bloxAddr: string,\r\n exchange: string,\r\n autoFlush: boolean = false,\r\n useRelay: boolean = true,\r\n refresh: boolean = false\r\n): Promise<string> => {\r\n console.log(\r\n 'newClient in react-native started',\r\n identity,\r\n storePath,\r\n bloxAddr,\r\n exchange,\r\n autoFlush,\r\n useRelay,\r\n refresh\r\n );\r\n return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);\r\n};\r\n\r\n/**\r\n * rm removes all data\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const logout = (\r\n identity: string,\r\n storePath: string\r\n): Promise<boolean> => {\r\n return Fula.logout(identity, storePath);\r\n};\r\n\r\n/**\r\n * Checks if there are any un-synced changes on the device\r\n */\r\nexport const checkFailedActions = (\r\n retry: boolean = false\r\n): Promise<boolean> => {\r\n return Fula.checkFailedActions(retry);\r\n};\r\n\r\n/**\r\n * Checks if there are any un-synced changes on the device\r\n */\r\nexport const checkConnection = (): Promise<boolean> => {\r\n return Fula.checkConnection();\r\n};\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param key\r\n * @returns value\r\n */\r\nexport const get = (key: string): Promise<string> => {\r\n return Fula.get(key);\r\n};\r\n\r\n/**\r\n * Has checks whether the value corresponding to the given key is present in the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param key\r\n * @returns boolean\r\n */\r\nexport const has = (key: Uint8Array): Promise<boolean> => {\r\n return Fula.has(key);\r\n};\r\n\r\n/**\r\n * Push requests the given addr to download the root cid from this node.\r\n// The addr must be a valid multiaddr that includes peer ID.\r\n// this function.\r\n * @param addr\r\n * @returns null or error\r\n */\r\nexport const push = (): Promise<string> => {\r\n return Fula.push();\r\n};\r\n\r\n/**\r\n * Put stores the given key value onto the local datastore.\r\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\r\n// to the given key.\r\n * @param key, value\r\n * @returns null or string\r\n */\r\nexport const put = (value: string, codec: string): Promise<string> => {\r\n return Fula.put(value, codec);\r\n};\r\n\r\n/**\r\n * mkdir creates a directory at the given path.\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const mkdir = (path: string): Promise<string> => {\r\n return Fula.mkdir(path);\r\n};\r\n\r\n/**\r\n * writeFileContent writes content at a given path\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const writeFileContent = (\r\n path: string,\r\n content: string\r\n): Promise<string> => {\r\n return Fula.writeFileContent(path, content);\r\n};\r\n\r\n/*\r\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\r\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\r\n // It keeps the original file modiifcation date\r\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\r\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\r\n // Returns: new cid of the root after this file is placed in the tree\r\n */\r\nexport const writeFile = (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n): Promise<string> => {\r\n return Fula.writeFile(fulaTargetFilename, localFilename);\r\n};\r\n\r\n/**\r\n * ls lists the name of files and folders at a given path\r\n * @param path\r\n * @returns string: list of items\r\n * TODO: Findout how is the string and convert to array\r\n */\r\nexport const ls = (path: string): Promise<void | JSON> => {\r\n return Fula.ls(path)\r\n .then((res) => {\r\n let lsResult = [];\r\n let lsRows = res.split('!!!');\r\n for (const element of lsRows) {\r\n let rowItems = element.split('???');\r\n if (rowItems && rowItems[0]) {\r\n let item = {\r\n name: '',\r\n created: '',\r\n modified: '',\r\n };\r\n item.name = rowItems[0];\r\n if (rowItems[1]) {\r\n item.created = rowItems[1];\r\n }\r\n if (rowItems[2]) {\r\n item.modified = rowItems[2];\r\n }\r\n lsResult.push(item);\r\n }\r\n }\r\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\r\n return jsonRes;\r\n })\r\n .catch((e) => {\r\n return e;\r\n });\r\n};\r\n\r\n/**\r\n * rm removes all files and folders at a given path\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const rm = (path: string): Promise<string> => {\r\n return Fula.rm(path);\r\n};\r\n\r\n/**\r\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\r\n * @param sourcePath, targetPath\r\n * @returns string: new cid of the root\r\n */\r\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\r\n return Fula.cp(sourcePath, targetPath);\r\n};\r\n\r\n/**\r\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\r\n * @param sourcePath, targetPath\r\n * @returns string: new cid of the root\r\n */\r\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\r\n return Fula.mv(sourcePath, targetPath);\r\n};\r\n\r\n/*\r\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\r\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\r\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\r\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\r\n // Returns: new cid of the root after this file is placed in the tree\r\n */\r\nexport const readFile = (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n): Promise<string> => {\r\n return Fula.readFile(fulaTargetFilename, localFilename);\r\n};\r\n\r\n/**\r\n * readFile reads content of a given path\r\n * @param path\r\n * @returns string: cotent\r\n */\r\nexport const readFileContent = (path: string): Promise<string> => {\r\n return Fula.readFileContent(path);\r\n};\r\n\r\n/**\r\n * Shutdown closes all resources used by Client.\r\n// After calling this function Client must be discarded.\r\n * @param\r\n * @returns\r\n */\r\nexport const shutdown = (): Promise<void> => {\r\n return Fula.shutdown();\r\n};\r\n\r\n/**\r\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\r\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\r\n * @param peerId, allow\r\n * @returns boolean: true if successful or false if not\r\n */\r\nexport const setAuth = (\r\n peerId: string,\r\n allow: boolean\r\n): Promise<boolean> => {\r\n return Fula.setAuth(peerId, allow);\r\n};\r\n\r\n\r\n/**\r\n * isReady checks if the connection is ready to be used.\r\n * @param filesystemCheck: also check if the wnfs is ready\r\n * @returns boolean: true if ready or false if not\r\n */\r\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\r\n return Fula.isReady(filesystemCheck);\r\n};\r\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,gCAAgC;;AAEjD;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAKsD;EAAA,IAJtEC,SAAkB,uEAAG,KAAK;EAAA,IAC1BC,OAAsB,uEAAG,IAAI;EAAA,IAC7BC,QAAiB,uEAAG,IAAI;EAAA,IACxBC,OAAgB,uEAAG,KAAK;EAExBC,OAAO,CAACC,GAAG,CACT,8BAA8B,EAC9BT,QAAQ,EACRC,SAAS,EACTC,QAAQ,EAC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ACF,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,QAAQ,GAAG,CACtBzB,kBAA0B,EAC1BC,aAAqB,KACD;EACpB,OAAO9B,IAAI,CAACsD,QAAQ,CAACzB,kBAAkB,EAAEC,aAAa,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMyB,eAAe,GAAI9B,IAAY,IAAsB;EAChE,OAAOzB,IAAI,CAACuD,eAAe,CAAC9B,IAAI,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM+B,QAAQ,GAAG,MAAqB;EAC3C,OAAOxD,IAAI,CAACwD,QAAQ,EAAE;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,CACrBC,MAAc,EACdC,KAAc,KACO;EACrB,OAAO3D,IAAI,CAACyD,OAAO,CAACC,MAAM,EAAEC,KAAK,CAAC;AACpC,CAAC;;AAGD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAO7D,IAAI,CAAC4D,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC"}
1
+ {"version":3,"names":["Fula","init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","newClient","logout","checkFailedActions","retry","timeout","checkConnection","get","key","has","push","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param config\r\n * @returns boolean\r\n */\r\n\r\nexport const init = (\r\n identity: string, //privateKey of did identity\r\n storePath: string,\r\n bloxAddr: string,\r\n exchange: string,\r\n autoFlush: boolean = false,\r\n rootCid: string | null = null,\r\n useRelay: boolean = true,\r\n refresh: boolean = false\r\n): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {\r\n console.log(\r\n 'init in react-native started',\r\n identity,\r\n storePath,\r\n bloxAddr,\r\n exchange,\r\n autoFlush,\r\n useRelay\r\n );\r\n return Fula.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);\r\n};\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param config\r\n * @returns boolean\r\n */\r\n\r\nexport const newClient = (\r\n identity: string, //privateKey of did identity\r\n storePath: string,\r\n bloxAddr: string,\r\n exchange: string,\r\n autoFlush: boolean = false,\r\n useRelay: boolean = true,\r\n refresh: boolean = false\r\n): Promise<string> => {\r\n console.log(\r\n 'newClient in react-native started',\r\n identity,\r\n storePath,\r\n bloxAddr,\r\n exchange,\r\n autoFlush,\r\n useRelay,\r\n refresh\r\n );\r\n return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);\r\n};\r\n\r\n/**\r\n * rm removes all data\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const logout = (\r\n identity: string,\r\n storePath: string\r\n): Promise<boolean> => {\r\n return Fula.logout(identity, storePath);\r\n};\r\n\r\n/**\r\n * Checks if there are any un-synced changes on the device\r\n */\r\nexport const checkFailedActions = (\r\n retry: boolean = false,\r\n timeout: number = 20\r\n): Promise<boolean> => {\r\n return Fula.checkFailedActions(retry, timeout);\r\n};\r\n\r\n/**\r\n * Checks if there are any un-synced changes on the device\r\n */\r\nexport const checkConnection = (timeout: number = 20): Promise<boolean> => {\r\n return Fula.checkConnection(timeout);\r\n};\r\n\r\n/**\r\n * Get gets the value corresponding to the given key from the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param key\r\n * @returns value\r\n */\r\nexport const get = (key: string): Promise<string> => {\r\n return Fula.get(key);\r\n};\r\n\r\n/**\r\n * Has checks whether the value corresponding to the given key is present in the local datastore.\r\n// The key must be a valid ipld.Link.\r\n * @param key\r\n * @returns boolean\r\n */\r\nexport const has = (key: Uint8Array): Promise<boolean> => {\r\n return Fula.has(key);\r\n};\r\n\r\n/**\r\n * Push requests the given addr to download the root cid from this node.\r\n// The addr must be a valid multiaddr that includes peer ID.\r\n// this function.\r\n * @param addr\r\n * @returns null or error\r\n */\r\nexport const push = (): Promise<string> => {\r\n return Fula.push();\r\n};\r\n\r\n/**\r\n * Put stores the given key value onto the local datastore.\r\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\r\n// to the given key.\r\n * @param key, value\r\n * @returns null or string\r\n */\r\nexport const put = (value: string, codec: string): Promise<string> => {\r\n return Fula.put(value, codec);\r\n};\r\n\r\n/**\r\n * mkdir creates a directory at the given path.\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const mkdir = (path: string): Promise<string> => {\r\n return Fula.mkdir(path);\r\n};\r\n\r\n/**\r\n * writeFileContent writes content at a given path\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const writeFileContent = (\r\n path: string,\r\n content: string\r\n): Promise<string> => {\r\n return Fula.writeFileContent(path, content);\r\n};\r\n\r\n/*\r\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\r\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\r\n // It keeps the original file modiifcation date\r\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\r\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\r\n // Returns: new cid of the root after this file is placed in the tree\r\n */\r\nexport const writeFile = (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n): Promise<string> => {\r\n return Fula.writeFile(fulaTargetFilename, localFilename);\r\n};\r\n\r\n/**\r\n * ls lists the name of files and folders at a given path\r\n * @param path\r\n * @returns string: list of items\r\n * TODO: Findout how is the string and convert to array\r\n */\r\nexport const ls = (path: string): Promise<void | JSON> => {\r\n return Fula.ls(path)\r\n .then((res) => {\r\n let lsResult = [];\r\n let lsRows = res.split('!!!');\r\n for (const element of lsRows) {\r\n let rowItems = element.split('???');\r\n if (rowItems && rowItems[0]) {\r\n let item = {\r\n name: '',\r\n created: '',\r\n modified: '',\r\n };\r\n item.name = rowItems[0];\r\n if (rowItems[1]) {\r\n item.created = rowItems[1];\r\n }\r\n if (rowItems[2]) {\r\n item.modified = rowItems[2];\r\n }\r\n lsResult.push(item);\r\n }\r\n }\r\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\r\n return jsonRes;\r\n })\r\n .catch((e) => {\r\n return e;\r\n });\r\n};\r\n\r\n/**\r\n * rm removes all files and folders at a given path\r\n * @param path\r\n * @returns string: new cid of the root\r\n */\r\nexport const rm = (path: string): Promise<string> => {\r\n return Fula.rm(path);\r\n};\r\n\r\n/**\r\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\r\n * @param sourcePath, targetPath\r\n * @returns string: new cid of the root\r\n */\r\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\r\n return Fula.cp(sourcePath, targetPath);\r\n};\r\n\r\n/**\r\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\r\n * @param sourcePath, targetPath\r\n * @returns string: new cid of the root\r\n */\r\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\r\n return Fula.mv(sourcePath, targetPath);\r\n};\r\n\r\n/*\r\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\r\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\r\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\r\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\r\n // Returns: new cid of the root after this file is placed in the tree\r\n */\r\nexport const readFile = (\r\n fulaTargetFilename: string,\r\n localFilename: string\r\n): Promise<string> => {\r\n return Fula.readFile(fulaTargetFilename, localFilename);\r\n};\r\n\r\n/**\r\n * readFile reads content of a given path\r\n * @param path\r\n * @returns string: cotent\r\n */\r\nexport const readFileContent = (path: string): Promise<string> => {\r\n return Fula.readFileContent(path);\r\n};\r\n\r\n/**\r\n * Shutdown closes all resources used by Client.\r\n// After calling this function Client must be discarded.\r\n * @param\r\n * @returns\r\n */\r\nexport const shutdown = (): Promise<void> => {\r\n return Fula.shutdown();\r\n};\r\n\r\n/**\r\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\r\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\r\n * @param peerId, allow\r\n * @returns boolean: true if successful or false if not\r\n */\r\nexport const setAuth = (\r\n peerId: string,\r\n allow: boolean\r\n): Promise<boolean> => {\r\n return Fula.setAuth(peerId, allow);\r\n};\r\n\r\n\r\n/**\r\n * isReady checks if the connection is ready to be used.\r\n * @param filesystemCheck: also check if the wnfs is ready\r\n * @returns boolean: true if ready or false if not\r\n */\r\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\r\n return Fula.isReady(filesystemCheck);\r\n};\r\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,gCAAgC;;AAEjD;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAKsD;EAAA,IAJtEC,SAAkB,uEAAG,KAAK;EAAA,IAC1BC,OAAsB,uEAAG,IAAI;EAAA,IAC7BC,QAAiB,uEAAG,IAAI;EAAA,IACxBC,OAAgB,uEAAG,KAAK;EAExBC,OAAO,CAACC,GAAG,CACT,8BAA8B,EAC9BT,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTE,QAAQ,CACT;EACD,OAAOR,IAAI,CAACC,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rD,IAAI,CAACsD,EAAE,CAACF,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,QAAQ,GAAG,CACtBzB,kBAA0B,EAC1BC,aAAqB,KACD;EACpB,OAAO/B,IAAI,CAACuD,QAAQ,CAACzB,kBAAkB,EAAEC,aAAa,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMyB,eAAe,GAAI9B,IAAY,IAAsB;EAChE,OAAO1B,IAAI,CAACwD,eAAe,CAAC9B,IAAI,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM+B,QAAQ,GAAG,MAAqB;EAC3C,OAAOzD,IAAI,CAACyD,QAAQ,EAAE;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,CACrBC,MAAc,EACdC,KAAc,KACO;EACrB,OAAO5D,IAAI,CAAC0D,OAAO,CAACC,MAAM,EAAEC,KAAK,CAAC;AACpC,CAAC;;AAGD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAO9D,IAAI,CAAC6D,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC"}
@@ -20,8 +20,8 @@ interface FulaNativeModule {
20
20
  refresh: boolean) => Promise<string>;
21
21
  isReady: (filesystemCheck: boolean) => Promise<boolean>;
22
22
  logout: (identity: string, storePath: string) => Promise<boolean>;
23
- checkFailedActions: (retry: boolean) => Promise<boolean>;
24
- checkConnection: () => Promise<boolean>;
23
+ checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
24
+ checkConnection: (timeout: number) => Promise<boolean>;
25
25
  get: (key: string) => Promise<string>;
26
26
  has: (key: Uint8Array) => Promise<boolean>;
27
27
  push: () => Promise<string>;
@@ -25,11 +25,11 @@ export declare const logout: (identity: string, storePath: string) => Promise<bo
25
25
  /**
26
26
  * Checks if there are any un-synced changes on the device
27
27
  */
28
- export declare const checkFailedActions: (retry?: boolean) => Promise<boolean>;
28
+ export declare const checkFailedActions: (retry?: boolean, timeout?: number) => Promise<boolean>;
29
29
  /**
30
30
  * Checks if there are any un-synced changes on the device
31
31
  */
32
- export declare const checkConnection: () => Promise<boolean>;
32
+ export declare const checkConnection: (timeout?: number) => Promise<boolean>;
33
33
  /**
34
34
  * Get gets the value corresponding to the given key from the local datastore.
35
35
  // The key must be a valid ipld.Link.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionland/react-native-fula",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -22,8 +22,8 @@ interface FulaNativeModule {
22
22
  ) => Promise<string>;
23
23
  isReady: (filesystemCheck: boolean) => Promise<boolean>;
24
24
  logout: (identity: string, storePath: string) => Promise<boolean>;
25
- checkFailedActions: (retry: boolean) => Promise<boolean>;
26
- checkConnection: () => Promise<boolean>;
25
+ checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
26
+ checkConnection: (timeout: number) => Promise<boolean>;
27
27
  get: (key: string) => Promise<string>;
28
28
  has: (key: Uint8Array) => Promise<boolean>;
29
29
  push: () => Promise<string>;
@@ -74,16 +74,17 @@ export const logout = (
74
74
  * Checks if there are any un-synced changes on the device
75
75
  */
76
76
  export const checkFailedActions = (
77
- retry: boolean = false
77
+ retry: boolean = false,
78
+ timeout: number = 20
78
79
  ): Promise<boolean> => {
79
- return Fula.checkFailedActions(retry);
80
+ return Fula.checkFailedActions(retry, timeout);
80
81
  };
81
82
 
82
83
  /**
83
84
  * Checks if there are any un-synced changes on the device
84
85
  */
85
- export const checkConnection = (): Promise<boolean> => {
86
- return Fula.checkConnection();
86
+ export const checkConnection = (timeout: number = 20): Promise<boolean> => {
87
+ return Fula.checkConnection(timeout);
87
88
  };
88
89
 
89
90
  /**