@functionland/react-native-fula 1.14.1 → 1.14.4

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 (135) hide show
  1. package/LICENSE +20 -21
  2. package/android/build.gradle +90 -50
  3. package/android/gradle.properties +5 -1
  4. package/android/src/main/AndroidManifest.xml +3 -4
  5. package/android/src/main/AndroidManifestNew.xml +2 -0
  6. package/android/src/main/java/land/fx/fula/ConfigRef.java +7 -7
  7. package/android/src/main/java/land/fx/fula/Cryptography.java +62 -62
  8. package/android/src/main/java/land/fx/fula/FulaModule.java +1 -1
  9. package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
  10. package/android/src/main/java/land/fx/fula/SharedPreferenceHelper.java +65 -65
  11. package/android/src/main/java/land/fx/fula/StaticHelper.java +13 -13
  12. package/android/src/main/java/land/fx/fula/ThreadUtils.java +42 -42
  13. package/ios/Cryptography.swift +36 -0
  14. package/ios/Fula-Bridging-Header.h +3 -0
  15. package/ios/Fula.mm +199 -0
  16. package/ios/Fula.swift +1152 -0
  17. package/ios/{FulaModule.xcodeproj → Fula.xcodeproj}/project.pbxproj +38 -16
  18. package/ios/Fula.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  19. package/ios/Fula.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  20. package/ios/Fula.xcodeproj/project.xcworkspace/xcuserdata/user246549.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  21. package/ios/Fula.xcodeproj/xcuserdata/user246549.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  22. package/ios/UserDataHelper.swift +143 -0
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/interfaces/api-lookup.js +266 -266
  25. package/lib/commonjs/interfaces/api-lookup.js.map +1 -1
  26. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  27. package/lib/commonjs/protocols/blockchain.js +64 -64
  28. package/lib/commonjs/protocols/blockchain.js.map +1 -1
  29. package/lib/commonjs/protocols/chain-api.js +10 -0
  30. package/lib/commonjs/protocols/chain-api.js.map +1 -1
  31. package/lib/commonjs/protocols/fula.js +99 -99
  32. package/lib/commonjs/protocols/fula.js.map +1 -1
  33. package/lib/commonjs/protocols/fxblox.js +3 -3
  34. package/lib/commonjs/protocols/fxblox.js.map +1 -1
  35. package/lib/commonjs/types/blockchain.js.map +1 -1
  36. package/lib/commonjs/types/fxblox.js.map +1 -1
  37. package/lib/module/index.js +4 -8
  38. package/lib/module/index.js.map +1 -1
  39. package/lib/module/interfaces/api-lookup.js +266 -266
  40. package/lib/module/interfaces/api-lookup.js.map +1 -1
  41. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  42. package/lib/module/protocols/blockchain.js +64 -64
  43. package/lib/module/protocols/blockchain.js.map +1 -1
  44. package/lib/module/protocols/chain-api.js +8 -0
  45. package/lib/module/protocols/chain-api.js.map +1 -1
  46. package/lib/module/protocols/fula.js +99 -99
  47. package/lib/module/protocols/fula.js.map +1 -1
  48. package/lib/module/protocols/fxblox.js +3 -3
  49. package/lib/module/protocols/fxblox.js.map +1 -1
  50. package/lib/module/types/blockchain.js.map +1 -1
  51. package/lib/module/types/fxblox.js.map +1 -1
  52. package/lib/typescript/index.d.ts +5 -4
  53. package/lib/typescript/index.d.ts.map +1 -0
  54. package/lib/typescript/interfaces/api-lookup.d.ts +1644 -1643
  55. package/lib/typescript/interfaces/api-lookup.d.ts.map +1 -0
  56. package/lib/typescript/interfaces/fulaNativeModule.d.ts +62 -61
  57. package/lib/typescript/interfaces/fulaNativeModule.d.ts.map +1 -0
  58. package/lib/typescript/protocols/blockchain.d.ts +18 -17
  59. package/lib/typescript/protocols/blockchain.d.ts.map +1 -0
  60. package/lib/typescript/protocols/chain-api.d.ts +7 -6
  61. package/lib/typescript/protocols/chain-api.d.ts.map +1 -0
  62. package/lib/typescript/protocols/fula.d.ts +132 -131
  63. package/lib/typescript/protocols/fula.d.ts.map +1 -0
  64. package/lib/typescript/protocols/fxblox.d.ts +8 -7
  65. package/lib/typescript/protocols/fxblox.d.ts.map +1 -0
  66. package/lib/typescript/types/blockchain.d.ts +69 -68
  67. package/lib/typescript/types/blockchain.d.ts.map +1 -0
  68. package/lib/typescript/types/fxblox.d.ts +9 -8
  69. package/lib/typescript/types/fxblox.d.ts.map +1 -0
  70. package/package.json +43 -28
  71. package/react-native-fula.podspec +47 -19
  72. package/src/index.tsx +4 -4
  73. package/src/interfaces/api-lookup.ts +1647 -1647
  74. package/src/interfaces/fulaNativeModule.ts +122 -122
  75. package/src/protocols/blockchain.ts +504 -504
  76. package/src/protocols/chain-api.ts +8 -0
  77. package/src/protocols/fula.ts +314 -314
  78. package/src/protocols/fxblox.ts +49 -49
  79. package/src/types/blockchain.ts +80 -80
  80. package/src/types/fxblox.ts +8 -8
  81. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  82. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  83. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  84. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  85. package/android/.gradle/7.5.1/dependencies-accessors/gc.properties +0 -0
  86. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  87. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  88. package/android/.gradle/7.5.1/fileChanges/last-build.bin +0 -0
  89. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  90. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  91. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  92. package/android/.gradle/7.5.1/gc.properties +0 -0
  93. package/android/.gradle/7.6/checksums/checksums.lock +0 -0
  94. package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
  95. package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
  96. package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
  97. package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
  98. package/android/.gradle/7.6/executionHistory/executionHistory.bin +0 -0
  99. package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
  100. package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
  101. package/android/.gradle/7.6/fileHashes/fileHashes.bin +0 -0
  102. package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
  103. package/android/.gradle/7.6/fileHashes/resourceHashesCache.bin +0 -0
  104. package/android/.gradle/7.6/gc.properties +0 -0
  105. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  106. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  107. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  108. package/android/.gradle/file-system.probe +0 -0
  109. package/android/.gradle/vcs-1/gc.properties +0 -0
  110. package/android/.idea/compiler.xml +0 -6
  111. package/android/.idea/gradle.xml +0 -20
  112. package/android/.idea/jarRepositories.xml +0 -50
  113. package/android/.idea/misc.xml +0 -10
  114. package/android/.idea/sonarlint/issuestore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
  115. package/android/.idea/sonarlint/issuestore/2/e/2e09eb0f0df666781fdff057a0af6101364ebe2f +0 -0
  116. package/android/.idea/sonarlint/issuestore/6/2/62149c3f7c3a14d7a77778e558d274e8c00a5585 +0 -0
  117. package/android/.idea/sonarlint/issuestore/8/0/80a78d662b0659428eb880336106c3c5fc3f0714 +0 -0
  118. package/android/.idea/sonarlint/issuestore/d/2/d2865ef8fc01c40e9fd82977fde2c8378fad0b12 +0 -0
  119. package/android/.idea/sonarlint/issuestore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
  120. package/android/.idea/sonarlint/issuestore/index.pb +0 -13
  121. package/android/.idea/sonarlint/securityhotspotstore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
  122. package/android/.idea/sonarlint/securityhotspotstore/2/e/2e09eb0f0df666781fdff057a0af6101364ebe2f +0 -0
  123. package/android/.idea/sonarlint/securityhotspotstore/6/2/62149c3f7c3a14d7a77778e558d274e8c00a5585 +0 -0
  124. package/android/.idea/sonarlint/securityhotspotstore/8/0/80a78d662b0659428eb880336106c3c5fc3f0714 +0 -0
  125. package/android/.idea/sonarlint/securityhotspotstore/d/2/d2865ef8fc01c40e9fd82977fde2c8378fad0b12 +0 -0
  126. package/android/.idea/sonarlint/securityhotspotstore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
  127. package/android/.idea/sonarlint/securityhotspotstore/index.pb +0 -13
  128. package/android/.idea/vcs.xml +0 -6
  129. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  130. package/android/gradle/wrapper/gradle-wrapper.properties +0 -7
  131. package/android/gradlew +0 -291
  132. package/android/gradlew.bat +0 -91
  133. package/android/local.properties +0 -8
  134. package/ios/FulaModule.h +0 -10
  135. package/ios/FulaModule.m +0 -149
@@ -74,6 +74,10 @@ export const listPools = async (
74
74
  if (api === undefined) {
75
75
  api = await init();
76
76
  }
77
+ // Type guard to assure TypeScript that api is not undefined
78
+ if (!api || !api.query || !api.query.pool || !api.query.pool.lastPoolId || !api.query.pool.pools) {
79
+ throw new Error('Failed to initialize api or api.query.pool');
80
+ }
77
81
  const pools: BType.PoolListResponse = { pools: [] };
78
82
  const lastPoolId = await api.query.pool.lastPoolId();
79
83
  let finalReturnedId: number = Number(lastPoolId.toHuman());
@@ -111,6 +115,10 @@ export const checkJoinRequest = async (
111
115
  if (api === undefined) {
112
116
  api = await init();
113
117
  }
118
+ // Type guard to assure TypeScript that api is not undefined
119
+ if (!api || !api.query || !api.query.pool || !api.query.pool.poolRequests) {
120
+ throw new Error('Failed to initialize api or api.query.pool');
121
+ }
114
122
 
115
123
  const poolRequest = await api.query.pool.poolRequests(poolId, accountId);
116
124
 
@@ -1,314 +1,314 @@
1
- import Fula from '../interfaces/fulaNativeModule';
2
-
3
- /**
4
- * Get gets the value corresponding to the given key from the local datastore.
5
- // The key must be a valid ipld.Link.
6
- * @param config
7
- * @returns boolean
8
- */
9
-
10
- export const init = (
11
- identity: string, //privateKey of did identity
12
- storePath: string,
13
- bloxAddr: string,
14
- exchange: string,
15
- autoFlush: boolean = false,
16
- rootCid: string | null = null,
17
- useRelay: boolean = true,
18
- refresh: boolean = false
19
- ): Promise<{ peerId: string; rootCid: string }> => {
20
- console.log(
21
- 'init in react-native started',
22
- identity,
23
- storePath,
24
- bloxAddr,
25
- exchange,
26
- autoFlush,
27
- useRelay
28
- );
29
- return Fula.init(
30
- identity,
31
- storePath,
32
- bloxAddr,
33
- exchange,
34
- autoFlush,
35
- rootCid,
36
- useRelay,
37
- refresh
38
- );
39
- };
40
-
41
- /**
42
- * Get gets the value corresponding to the given key from the local datastore.
43
- // The key must be a valid ipld.Link.
44
- * @param config
45
- * @returns boolean
46
- */
47
-
48
- export const newClient = (
49
- identity: string, //privateKey of did identity
50
- storePath: string,
51
- bloxAddr: string,
52
- exchange: string,
53
- autoFlush: boolean = false,
54
- useRelay: boolean = true,
55
- refresh: boolean = false
56
- ): Promise<string> => {
57
- console.log(
58
- 'newClient in react-native started',
59
- identity,
60
- storePath,
61
- bloxAddr,
62
- exchange,
63
- autoFlush,
64
- useRelay,
65
- refresh
66
- );
67
- return Fula.newClient(
68
- identity,
69
- storePath,
70
- bloxAddr,
71
- exchange,
72
- autoFlush,
73
- useRelay,
74
- refresh
75
- );
76
- };
77
-
78
- /**
79
- * rm removes all data
80
- * @param path
81
- * @returns string: new cid of the root
82
- */
83
- export const logout = (
84
- identity: string,
85
- storePath: string
86
- ): Promise<boolean> => {
87
- return Fula.logout(identity, storePath);
88
- };
89
-
90
- /**
91
- * Checks if there are any un-synced changes on the device
92
- */
93
- export const checkFailedActions = (
94
- retry: boolean = false,
95
- timeout: number = 20
96
- ): Promise<boolean> => {
97
- return Fula.checkFailedActions(retry, timeout);
98
- };
99
-
100
- /**
101
- * Lists the cids that failed to be sent to backend and are kept only locally
102
- */
103
- export const listFailedActions = (cids: string[] = []): Promise<string[]> => {
104
- return Fula.listFailedActions(cids);
105
- };
106
-
107
- /**
108
- * Checks if there are any un-synced changes on the device
109
- */
110
- export const checkConnection = (timeout: number = 20): Promise<boolean> => {
111
- return Fula.checkConnection(timeout);
112
- };
113
-
114
- /**
115
- * Get gets the value corresponding to the given key from the local datastore.
116
- // The key must be a valid ipld.Link.
117
- * @param key
118
- * @returns value
119
- */
120
- export const get = (key: string): Promise<string> => {
121
- return Fula.get(key);
122
- };
123
-
124
- /**
125
- * Has checks whether the value corresponding to the given key is present in the local datastore.
126
- // The key must be a valid ipld.Link.
127
- * @param key
128
- * @returns boolean
129
- */
130
- export const has = (key: Uint8Array): Promise<boolean> => {
131
- return Fula.has(key);
132
- };
133
-
134
- /**
135
- * Push requests the given addr to download the root cid from this node.
136
- // The addr must be a valid multiaddr that includes peer ID.
137
- // this function.
138
- * @param addr
139
- * @returns null or error
140
- */
141
- export const push = (): Promise<string> => {
142
- return Fula.push();
143
- };
144
-
145
- //This method sends some test data to backedn
146
- export const testData = (
147
- identity: string,
148
- bloxAddr: string
149
- ): Promise<string> => {
150
- return Fula.testData(identity, bloxAddr);
151
- };
152
-
153
- /**
154
- * Put stores the given key value onto the local datastore.
155
- // The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
156
- // to the given key.
157
- * @param key, value
158
- * @returns null or string
159
- */
160
- export const put = (value: string, codec: string): Promise<string> => {
161
- return Fula.put(value, codec);
162
- };
163
-
164
- /**
165
- * mkdir creates a directory at the given path.
166
- * @param path
167
- * @returns string: new cid of the root
168
- */
169
- export const mkdir = (path: string): Promise<string> => {
170
- return Fula.mkdir(path);
171
- };
172
-
173
- /**
174
- * writeFileContent writes content at a given path
175
- * @param path
176
- * @returns string: new cid of the root
177
- */
178
- export const writeFileContent = (
179
- path: string,
180
- content: string
181
- ): Promise<string> => {
182
- return Fula.writeFileContent(path, content);
183
- };
184
-
185
- /*
186
- // reads content of the file form localFilename (should include full absolute path to local file with read permission
187
- // writes content to the specified location by fulaTargetFilename in Fula filesystem
188
- // It keeps the original file modiifcation date
189
- // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
190
- // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
191
- // Returns: new cid of the root after this file is placed in the tree
192
- */
193
- export const writeFile = (
194
- fulaTargetFilename: string,
195
- localFilename: string
196
- ): Promise<string> => {
197
- return Fula.writeFile(fulaTargetFilename, localFilename);
198
- };
199
-
200
- /**
201
- * ls lists the name of files and folders at a given path
202
- * @param path
203
- * @returns string: list of items
204
- * TODO: Findout how is the string and convert to array
205
- */
206
- export const ls = (path: string): Promise<void | JSON> => {
207
- return Fula.ls(path)
208
- .then((res) => {
209
- let lsResult = [];
210
- let lsRows = res.split('!!!');
211
- for (const element of lsRows) {
212
- let rowItems = element.split('???');
213
- if (rowItems && rowItems[0]) {
214
- let item = {
215
- name: '',
216
- created: '',
217
- modified: '',
218
- };
219
- item.name = rowItems[0];
220
- if (rowItems[1]) {
221
- item.created = rowItems[1];
222
- }
223
- if (rowItems[2]) {
224
- item.modified = rowItems[2];
225
- }
226
- lsResult.push(item);
227
- }
228
- }
229
- let jsonRes = JSON.parse(JSON.stringify(lsResult));
230
- return jsonRes;
231
- })
232
- .catch((e) => {
233
- return e;
234
- });
235
- };
236
-
237
- /**
238
- * rm removes all files and folders at a given path
239
- * @param path
240
- * @returns string: new cid of the root
241
- */
242
- export const rm = (path: string): Promise<string> => {
243
- return Fula.rm(path);
244
- };
245
-
246
- /**
247
- * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
248
- * @param sourcePath, targetPath
249
- * @returns string: new cid of the root
250
- */
251
- export const cp = (sourcePath: string, targetPath: string): Promise<string> => {
252
- return Fula.cp(sourcePath, targetPath);
253
- };
254
-
255
- /**
256
- * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
257
- * @param sourcePath, targetPath
258
- * @returns string: new cid of the root
259
- */
260
- export const mv = (sourcePath: string, targetPath: string): Promise<string> => {
261
- return Fula.mv(sourcePath, targetPath);
262
- };
263
-
264
- /*
265
- // reads content of the file form localFilename (should include full absolute path to local file with read permission
266
- // writes content to the specified location by fulaTargetFilename in Fula filesystem
267
- // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
268
- // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
269
- // Returns: new cid of the root after this file is placed in the tree
270
- */
271
- export const readFile = (
272
- fulaTargetFilename: string,
273
- localFilename: string
274
- ): Promise<string> => {
275
- return Fula.readFile(fulaTargetFilename, localFilename);
276
- };
277
-
278
- /**
279
- * readFile reads content of a given path
280
- * @param path
281
- * @returns string: cotent
282
- */
283
- export const readFileContent = (path: string): Promise<string> => {
284
- return Fula.readFileContent(path);
285
- };
286
-
287
- /**
288
- * Shutdown closes all resources used by Client.
289
- // After calling this function Client must be discarded.
290
- * @param
291
- * @returns
292
- */
293
- export const shutdown = (): Promise<void> => {
294
- return Fula.shutdown();
295
- };
296
-
297
- /**
298
- * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.
299
- * This can only be called on a peer that is added as an owner of blox by --authorizer parameter
300
- * @param peerId, allow
301
- * @returns boolean: true if successful or false if not
302
- */
303
- export const setAuth = (peerId: string, allow: boolean): Promise<boolean> => {
304
- return Fula.setAuth(peerId, allow);
305
- };
306
-
307
- /**
308
- * isReady checks if the connection is ready to be used.
309
- * @param filesystemCheck: also check if the wnfs is ready
310
- * @returns boolean: true if ready or false if not
311
- */
312
- export const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {
313
- return Fula.isReady(filesystemCheck);
314
- };
1
+ import Fula from '../interfaces/fulaNativeModule';
2
+
3
+ /**
4
+ * Get gets the value corresponding to the given key from the local datastore.
5
+ // The key must be a valid ipld.Link.
6
+ * @param config
7
+ * @returns boolean
8
+ */
9
+
10
+ export const init = (
11
+ identity: string, //privateKey of did identity
12
+ storePath: string,
13
+ bloxAddr: string,
14
+ exchange: string,
15
+ autoFlush: boolean = false,
16
+ rootCid: string | null = null,
17
+ useRelay: boolean = true,
18
+ refresh: boolean = false
19
+ ): Promise<{ peerId: string; rootCid: string }> => {
20
+ console.log(
21
+ 'init in react-native started',
22
+ identity,
23
+ storePath,
24
+ bloxAddr,
25
+ exchange,
26
+ autoFlush,
27
+ useRelay
28
+ );
29
+ return Fula.initFula(
30
+ identity,
31
+ storePath,
32
+ bloxAddr,
33
+ exchange,
34
+ autoFlush,
35
+ rootCid,
36
+ useRelay,
37
+ refresh
38
+ );
39
+ };
40
+
41
+ /**
42
+ * Get gets the value corresponding to the given key from the local datastore.
43
+ // The key must be a valid ipld.Link.
44
+ * @param config
45
+ * @returns boolean
46
+ */
47
+
48
+ export const newClient = (
49
+ identity: string, //privateKey of did identity
50
+ storePath: string,
51
+ bloxAddr: string,
52
+ exchange: string,
53
+ autoFlush: boolean = false,
54
+ useRelay: boolean = true,
55
+ refresh: boolean = false
56
+ ): Promise<string> => {
57
+ console.log(
58
+ 'newClient in react-native started',
59
+ identity,
60
+ storePath,
61
+ bloxAddr,
62
+ exchange,
63
+ autoFlush,
64
+ useRelay,
65
+ refresh
66
+ );
67
+ return Fula.newClient(
68
+ identity,
69
+ storePath,
70
+ bloxAddr,
71
+ exchange,
72
+ autoFlush,
73
+ useRelay,
74
+ refresh
75
+ );
76
+ };
77
+
78
+ /**
79
+ * rm removes all data
80
+ * @param path
81
+ * @returns string: new cid of the root
82
+ */
83
+ export const logout = (
84
+ identity: string,
85
+ storePath: string
86
+ ): Promise<boolean> => {
87
+ return Fula.logout(identity, storePath);
88
+ };
89
+
90
+ /**
91
+ * Checks if there are any un-synced changes on the device
92
+ */
93
+ export const checkFailedActions = (
94
+ retry: boolean = false,
95
+ timeout: number = 20
96
+ ): Promise<boolean> => {
97
+ return Fula.checkFailedActions(retry, timeout);
98
+ };
99
+
100
+ /**
101
+ * Lists the cids that failed to be sent to backend and are kept only locally
102
+ */
103
+ export const listFailedActions = (cids: string[] = []): Promise<string[]> => {
104
+ return Fula.listFailedActions(cids);
105
+ };
106
+
107
+ /**
108
+ * Checks if there are any un-synced changes on the device
109
+ */
110
+ export const checkConnection = (timeout: number = 20): Promise<boolean> => {
111
+ return Fula.checkConnection(timeout);
112
+ };
113
+
114
+ /**
115
+ * Get gets the value corresponding to the given key from the local datastore.
116
+ // The key must be a valid ipld.Link.
117
+ * @param key
118
+ * @returns value
119
+ */
120
+ export const get = (key: string): Promise<string> => {
121
+ return Fula.get(key);
122
+ };
123
+
124
+ /**
125
+ * Has checks whether the value corresponding to the given key is present in the local datastore.
126
+ // The key must be a valid ipld.Link.
127
+ * @param key
128
+ * @returns boolean
129
+ */
130
+ export const has = (key: Uint8Array): Promise<boolean> => {
131
+ return Fula.has(key);
132
+ };
133
+
134
+ /**
135
+ * Push requests the given addr to download the root cid from this node.
136
+ // The addr must be a valid multiaddr that includes peer ID.
137
+ // this function.
138
+ * @param addr
139
+ * @returns null or error
140
+ */
141
+ export const push = (): Promise<string> => {
142
+ return Fula.push();
143
+ };
144
+
145
+ //This method sends some test data to backedn
146
+ export const testData = (
147
+ identity: string,
148
+ bloxAddr: string
149
+ ): Promise<string> => {
150
+ return Fula.testData(identity, bloxAddr);
151
+ };
152
+
153
+ /**
154
+ * Put stores the given key value onto the local datastore.
155
+ // The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
156
+ // to the given key.
157
+ * @param key, value
158
+ * @returns null or string
159
+ */
160
+ export const put = (value: string, codec: string): Promise<string> => {
161
+ return Fula.put(value, codec);
162
+ };
163
+
164
+ /**
165
+ * mkdir creates a directory at the given path.
166
+ * @param path
167
+ * @returns string: new cid of the root
168
+ */
169
+ export const mkdir = (path: string): Promise<string> => {
170
+ return Fula.mkdir(path);
171
+ };
172
+
173
+ /**
174
+ * writeFileContent writes content at a given path
175
+ * @param path
176
+ * @returns string: new cid of the root
177
+ */
178
+ export const writeFileContent = (
179
+ path: string,
180
+ content: string
181
+ ): Promise<string> => {
182
+ return Fula.writeFileContent(path, content);
183
+ };
184
+
185
+ /*
186
+ // reads content of the file form localFilename (should include full absolute path to local file with read permission
187
+ // writes content to the specified location by fulaTargetFilename in Fula filesystem
188
+ // It keeps the original file modiifcation date
189
+ // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
190
+ // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
191
+ // Returns: new cid of the root after this file is placed in the tree
192
+ */
193
+ export const writeFile = (
194
+ fulaTargetFilename: string,
195
+ localFilename: string
196
+ ): Promise<string> => {
197
+ return Fula.writeFile(fulaTargetFilename, localFilename);
198
+ };
199
+
200
+ /**
201
+ * ls lists the name of files and folders at a given path
202
+ * @param path
203
+ * @returns string: list of items
204
+ * TODO: Findout how is the string and convert to array
205
+ */
206
+ export const ls = (path: string): Promise<void | JSON> => {
207
+ return Fula.ls(path)
208
+ .then((res) => {
209
+ let lsResult = [];
210
+ let lsRows = res.split('!!!');
211
+ for (const element of lsRows) {
212
+ let rowItems = element.split('???');
213
+ if (rowItems && rowItems[0]) {
214
+ let item = {
215
+ name: '',
216
+ created: '',
217
+ modified: '',
218
+ };
219
+ item.name = rowItems[0];
220
+ if (rowItems[1]) {
221
+ item.created = rowItems[1];
222
+ }
223
+ if (rowItems[2]) {
224
+ item.modified = rowItems[2];
225
+ }
226
+ lsResult.push(item);
227
+ }
228
+ }
229
+ let jsonRes = JSON.parse(JSON.stringify(lsResult));
230
+ return jsonRes;
231
+ })
232
+ .catch((e) => {
233
+ return e;
234
+ });
235
+ };
236
+
237
+ /**
238
+ * rm removes all files and folders at a given path
239
+ * @param path
240
+ * @returns string: new cid of the root
241
+ */
242
+ export const rm = (path: string): Promise<string> => {
243
+ return Fula.rm(path);
244
+ };
245
+
246
+ /**
247
+ * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
248
+ * @param sourcePath, targetPath
249
+ * @returns string: new cid of the root
250
+ */
251
+ export const cp = (sourcePath: string, targetPath: string): Promise<string> => {
252
+ return Fula.cp(sourcePath, targetPath);
253
+ };
254
+
255
+ /**
256
+ * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
257
+ * @param sourcePath, targetPath
258
+ * @returns string: new cid of the root
259
+ */
260
+ export const mv = (sourcePath: string, targetPath: string): Promise<string> => {
261
+ return Fula.mv(sourcePath, targetPath);
262
+ };
263
+
264
+ /*
265
+ // reads content of the file form localFilename (should include full absolute path to local file with read permission
266
+ // writes content to the specified location by fulaTargetFilename in Fula filesystem
267
+ // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
268
+ // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
269
+ // Returns: new cid of the root after this file is placed in the tree
270
+ */
271
+ export const readFile = (
272
+ fulaTargetFilename: string,
273
+ localFilename: string
274
+ ): Promise<string> => {
275
+ return Fula.readFile(fulaTargetFilename, localFilename);
276
+ };
277
+
278
+ /**
279
+ * readFile reads content of a given path
280
+ * @param path
281
+ * @returns string: cotent
282
+ */
283
+ export const readFileContent = (path: string): Promise<string> => {
284
+ return Fula.readFileContent(path);
285
+ };
286
+
287
+ /**
288
+ * Shutdown closes all resources used by Client.
289
+ // After calling this function Client must be discarded.
290
+ * @param
291
+ * @returns
292
+ */
293
+ export const shutdown = (): Promise<void> => {
294
+ return Fula.shutdown();
295
+ };
296
+
297
+ /**
298
+ * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.
299
+ * This can only be called on a peer that is added as an owner of blox by --authorizer parameter
300
+ * @param peerId, allow
301
+ * @returns boolean: true if successful or false if not
302
+ */
303
+ export const setAuth = (peerId: string, allow: boolean): Promise<boolean> => {
304
+ return Fula.setAuth(peerId, allow);
305
+ };
306
+
307
+ /**
308
+ * isReady checks if the connection is ready to be used.
309
+ * @param filesystemCheck: also check if the wnfs is ready
310
+ * @returns boolean: true if ready or false if not
311
+ */
312
+ export const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {
313
+ return Fula.isReady(filesystemCheck);
314
+ };