@functionland/react-native-fula 1.8.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -205
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.6/checksums/checksums.lock +0 -0
- package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.6/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.6/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.idea/compiler.xml +1 -1
- package/android/.idea/gradle.xml +1 -0
- package/android/.idea/misc.xml +9 -9
- package/android/.idea/sonarlint/securityhotspotstore/index.pb +0 -0
- package/android/build.gradle +2 -1
- package/android/src/main/java/land/fx/fula/Cryptography.java +60 -60
- package/android/src/main/java/land/fx/fula/FulaModule.java +126 -17
- package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/protocols/blockchain.js +12 -12
- package/lib/commonjs/protocols/blockchain.js.map +1 -1
- package/lib/commonjs/protocols/fula.js +113 -98
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/commonjs/protocols/fxblox.js +23 -4
- package/lib/commonjs/protocols/fxblox.js.map +1 -1
- package/lib/commonjs/types/fxblox.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/protocols/blockchain.js +12 -12
- package/lib/module/protocols/blockchain.js.map +1 -1
- package/lib/module/protocols/fula.js +109 -96
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/module/protocols/fxblox.js +21 -3
- package/lib/module/protocols/fxblox.js.map +1 -1
- package/lib/module/types/fxblox.js.map +1 -1
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +3 -0
- package/lib/typescript/protocols/fula.d.ts +5 -0
- package/lib/typescript/protocols/fxblox.d.ts +1 -0
- package/lib/typescript/types/fxblox.d.ts +4 -0
- package/package.json +1 -1
- package/src/index.tsx +4 -4
- package/src/interfaces/fulaNativeModule.ts +43 -8
- package/src/protocols/blockchain.ts +318 -274
- package/src/protocols/fula.ts +301 -286
- package/src/protocols/fxblox.ts +49 -28
- package/src/types/fxblox.ts +8 -4
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.writeFileContent = exports.writeFile = exports.shutdown = exports.setAuth = exports.rm = exports.readFileContent = exports.readFile = exports.put = exports.push = exports.newClient = exports.mv = exports.mkdir = exports.ls = exports.logout = exports.isReady = exports.init = exports.has = exports.get = exports.cp = exports.checkFailedActions = exports.checkConnection = void 0;
|
|
6
|
+
exports.writeFileContent = exports.writeFile = exports.testData = exports.shutdown = exports.setAuth = exports.rm = exports.readFileContent = exports.readFile = exports.put = exports.push = exports.newClient = exports.mv = exports.mkdir = exports.ls = exports.logout = exports.listFailedActions = exports.isReady = exports.init = exports.has = exports.get = exports.cp = exports.checkFailedActions = exports.checkConnection = void 0;
|
|
7
7
|
var _fulaNativeModule = _interopRequireDefault(require("../interfaces/fulaNativeModule"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
/**
|
|
10
|
-
* Get gets the value corresponding to the given key from the local datastore.
|
|
11
|
-
// The key must be a valid ipld.Link.
|
|
12
|
-
* @param config
|
|
13
|
-
* @returns boolean
|
|
9
|
+
/**
|
|
10
|
+
* Get gets the value corresponding to the given key from the local datastore.
|
|
11
|
+
// The key must be a valid ipld.Link.
|
|
12
|
+
* @param config
|
|
13
|
+
* @returns boolean
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
const init = function (identity, storePath, bloxAddr, exchange) {
|
|
@@ -22,11 +22,11 @@ const init = function (identity, storePath, bloxAddr, exchange) {
|
|
|
22
22
|
return _fulaNativeModule.default.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Get gets the value corresponding to the given key from the local datastore.
|
|
27
|
-
// The key must be a valid ipld.Link.
|
|
28
|
-
* @param config
|
|
29
|
-
* @returns boolean
|
|
25
|
+
/**
|
|
26
|
+
* Get gets the value corresponding to the given key from the local datastore.
|
|
27
|
+
// The key must be a valid ipld.Link.
|
|
28
|
+
* @param config
|
|
29
|
+
* @returns boolean
|
|
30
30
|
*/
|
|
31
31
|
exports.init = init;
|
|
32
32
|
const newClient = function (identity, storePath, bloxAddr, exchange) {
|
|
@@ -37,18 +37,18 @@ const newClient = function (identity, storePath, bloxAddr, exchange) {
|
|
|
37
37
|
return _fulaNativeModule.default.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* rm removes all data
|
|
42
|
-
* @param path
|
|
43
|
-
* @returns string: new cid of the root
|
|
40
|
+
/**
|
|
41
|
+
* rm removes all data
|
|
42
|
+
* @param path
|
|
43
|
+
* @returns string: new cid of the root
|
|
44
44
|
*/
|
|
45
45
|
exports.newClient = newClient;
|
|
46
46
|
const logout = (identity, storePath) => {
|
|
47
47
|
return _fulaNativeModule.default.logout(identity, storePath);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* Checks if there are any un-synced changes on the device
|
|
50
|
+
/**
|
|
51
|
+
* Checks if there are any un-synced changes on the device
|
|
52
52
|
*/
|
|
53
53
|
exports.logout = logout;
|
|
54
54
|
const checkFailedActions = function () {
|
|
@@ -57,99 +57,114 @@ const checkFailedActions = function () {
|
|
|
57
57
|
return _fulaNativeModule.default.checkFailedActions(retry, timeout);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
60
|
+
/**
|
|
61
|
+
* Lists the cids that failed to be sent to backend and are kept only locally
|
|
62
62
|
*/
|
|
63
63
|
exports.checkFailedActions = checkFailedActions;
|
|
64
|
+
const listFailedActions = function () {
|
|
65
|
+
let cids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
66
|
+
return _fulaNativeModule.default.listFailedActions(cids);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Checks if there are any un-synced changes on the device
|
|
71
|
+
*/
|
|
72
|
+
exports.listFailedActions = listFailedActions;
|
|
64
73
|
const checkConnection = function () {
|
|
65
74
|
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
|
|
66
75
|
return _fulaNativeModule.default.checkConnection(timeout);
|
|
67
76
|
};
|
|
68
77
|
|
|
69
|
-
/**
|
|
70
|
-
* Get gets the value corresponding to the given key from the local datastore.
|
|
71
|
-
// The key must be a valid ipld.Link.
|
|
72
|
-
* @param key
|
|
73
|
-
* @returns value
|
|
78
|
+
/**
|
|
79
|
+
* Get gets the value corresponding to the given key from the local datastore.
|
|
80
|
+
// The key must be a valid ipld.Link.
|
|
81
|
+
* @param key
|
|
82
|
+
* @returns value
|
|
74
83
|
*/
|
|
75
84
|
exports.checkConnection = checkConnection;
|
|
76
85
|
const get = key => {
|
|
77
86
|
return _fulaNativeModule.default.get(key);
|
|
78
87
|
};
|
|
79
88
|
|
|
80
|
-
/**
|
|
81
|
-
* Has checks whether the value corresponding to the given key is present in the local datastore.
|
|
82
|
-
// The key must be a valid ipld.Link.
|
|
83
|
-
* @param key
|
|
84
|
-
* @returns boolean
|
|
89
|
+
/**
|
|
90
|
+
* Has checks whether the value corresponding to the given key is present in the local datastore.
|
|
91
|
+
// The key must be a valid ipld.Link.
|
|
92
|
+
* @param key
|
|
93
|
+
* @returns boolean
|
|
85
94
|
*/
|
|
86
95
|
exports.get = get;
|
|
87
96
|
const has = key => {
|
|
88
97
|
return _fulaNativeModule.default.has(key);
|
|
89
98
|
};
|
|
90
99
|
|
|
91
|
-
/**
|
|
92
|
-
* Push requests the given addr to download the root cid from this node.
|
|
93
|
-
// The addr must be a valid multiaddr that includes peer ID.
|
|
94
|
-
// this function.
|
|
95
|
-
* @param addr
|
|
96
|
-
* @returns null or error
|
|
100
|
+
/**
|
|
101
|
+
* Push requests the given addr to download the root cid from this node.
|
|
102
|
+
// The addr must be a valid multiaddr that includes peer ID.
|
|
103
|
+
// this function.
|
|
104
|
+
* @param addr
|
|
105
|
+
* @returns null or error
|
|
97
106
|
*/
|
|
98
107
|
exports.has = has;
|
|
99
108
|
const push = () => {
|
|
100
109
|
return _fulaNativeModule.default.push();
|
|
101
110
|
};
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
* Put stores the given key value onto the local datastore.
|
|
105
|
-
// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
|
|
106
|
-
// to the given key.
|
|
107
|
-
* @param key, value
|
|
108
|
-
* @returns null or string
|
|
109
|
-
*/
|
|
112
|
+
//This method sends some test data to backedn
|
|
110
113
|
exports.push = push;
|
|
114
|
+
const testData = (identity, bloxAddr) => {
|
|
115
|
+
return _fulaNativeModule.default.testData(identity, bloxAddr);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Put stores the given key value onto the local datastore.
|
|
120
|
+
// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
|
|
121
|
+
// to the given key.
|
|
122
|
+
* @param key, value
|
|
123
|
+
* @returns null or string
|
|
124
|
+
*/
|
|
125
|
+
exports.testData = testData;
|
|
111
126
|
const put = (value, codec) => {
|
|
112
127
|
return _fulaNativeModule.default.put(value, codec);
|
|
113
128
|
};
|
|
114
129
|
|
|
115
|
-
/**
|
|
116
|
-
* mkdir creates a directory at the given path.
|
|
117
|
-
* @param path
|
|
118
|
-
* @returns string: new cid of the root
|
|
130
|
+
/**
|
|
131
|
+
* mkdir creates a directory at the given path.
|
|
132
|
+
* @param path
|
|
133
|
+
* @returns string: new cid of the root
|
|
119
134
|
*/
|
|
120
135
|
exports.put = put;
|
|
121
136
|
const mkdir = path => {
|
|
122
137
|
return _fulaNativeModule.default.mkdir(path);
|
|
123
138
|
};
|
|
124
139
|
|
|
125
|
-
/**
|
|
126
|
-
* writeFileContent writes content at a given path
|
|
127
|
-
* @param path
|
|
128
|
-
* @returns string: new cid of the root
|
|
140
|
+
/**
|
|
141
|
+
* writeFileContent writes content at a given path
|
|
142
|
+
* @param path
|
|
143
|
+
* @returns string: new cid of the root
|
|
129
144
|
*/
|
|
130
145
|
exports.mkdir = mkdir;
|
|
131
146
|
const writeFileContent = (path, content) => {
|
|
132
147
|
return _fulaNativeModule.default.writeFileContent(path, content);
|
|
133
148
|
};
|
|
134
149
|
|
|
135
|
-
/*
|
|
136
|
-
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
137
|
-
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
138
|
-
// It keeps the original file modiifcation date
|
|
139
|
-
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
140
|
-
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
141
|
-
// Returns: new cid of the root after this file is placed in the tree
|
|
150
|
+
/*
|
|
151
|
+
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
152
|
+
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
153
|
+
// It keeps the original file modiifcation date
|
|
154
|
+
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
155
|
+
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
156
|
+
// Returns: new cid of the root after this file is placed in the tree
|
|
142
157
|
*/
|
|
143
158
|
exports.writeFileContent = writeFileContent;
|
|
144
159
|
const writeFile = (fulaTargetFilename, localFilename) => {
|
|
145
160
|
return _fulaNativeModule.default.writeFile(fulaTargetFilename, localFilename);
|
|
146
161
|
};
|
|
147
162
|
|
|
148
|
-
/**
|
|
149
|
-
* ls lists the name of files and folders at a given path
|
|
150
|
-
* @param path
|
|
151
|
-
* @returns string: list of items
|
|
152
|
-
* TODO: Findout how is the string and convert to array
|
|
163
|
+
/**
|
|
164
|
+
* ls lists the name of files and folders at a given path
|
|
165
|
+
* @param path
|
|
166
|
+
* @returns string: list of items
|
|
167
|
+
* TODO: Findout how is the string and convert to array
|
|
153
168
|
*/
|
|
154
169
|
exports.writeFile = writeFile;
|
|
155
170
|
const ls = path => {
|
|
@@ -181,84 +196,84 @@ const ls = path => {
|
|
|
181
196
|
});
|
|
182
197
|
};
|
|
183
198
|
|
|
184
|
-
/**
|
|
185
|
-
* rm removes all files and folders at a given path
|
|
186
|
-
* @param path
|
|
187
|
-
* @returns string: new cid of the root
|
|
199
|
+
/**
|
|
200
|
+
* rm removes all files and folders at a given path
|
|
201
|
+
* @param path
|
|
202
|
+
* @returns string: new cid of the root
|
|
188
203
|
*/
|
|
189
204
|
exports.ls = ls;
|
|
190
205
|
const rm = path => {
|
|
191
206
|
return _fulaNativeModule.default.rm(path);
|
|
192
207
|
};
|
|
193
208
|
|
|
194
|
-
/**
|
|
195
|
-
* cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
|
|
196
|
-
* @param sourcePath, targetPath
|
|
197
|
-
* @returns string: new cid of the root
|
|
209
|
+
/**
|
|
210
|
+
* cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
|
|
211
|
+
* @param sourcePath, targetPath
|
|
212
|
+
* @returns string: new cid of the root
|
|
198
213
|
*/
|
|
199
214
|
exports.rm = rm;
|
|
200
215
|
const cp = (sourcePath, targetPath) => {
|
|
201
216
|
return _fulaNativeModule.default.cp(sourcePath, targetPath);
|
|
202
217
|
};
|
|
203
218
|
|
|
204
|
-
/**
|
|
205
|
-
* mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
|
|
206
|
-
* @param sourcePath, targetPath
|
|
207
|
-
* @returns string: new cid of the root
|
|
219
|
+
/**
|
|
220
|
+
* mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
|
|
221
|
+
* @param sourcePath, targetPath
|
|
222
|
+
* @returns string: new cid of the root
|
|
208
223
|
*/
|
|
209
224
|
exports.cp = cp;
|
|
210
225
|
const mv = (sourcePath, targetPath) => {
|
|
211
226
|
return _fulaNativeModule.default.mv(sourcePath, targetPath);
|
|
212
227
|
};
|
|
213
228
|
|
|
214
|
-
/*
|
|
215
|
-
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
216
|
-
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
217
|
-
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
218
|
-
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
219
|
-
// Returns: new cid of the root after this file is placed in the tree
|
|
229
|
+
/*
|
|
230
|
+
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
231
|
+
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
232
|
+
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
233
|
+
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
234
|
+
// Returns: new cid of the root after this file is placed in the tree
|
|
220
235
|
*/
|
|
221
236
|
exports.mv = mv;
|
|
222
237
|
const readFile = (fulaTargetFilename, localFilename) => {
|
|
223
238
|
return _fulaNativeModule.default.readFile(fulaTargetFilename, localFilename);
|
|
224
239
|
};
|
|
225
240
|
|
|
226
|
-
/**
|
|
227
|
-
* readFile reads content of a given path
|
|
228
|
-
* @param path
|
|
229
|
-
* @returns string: cotent
|
|
241
|
+
/**
|
|
242
|
+
* readFile reads content of a given path
|
|
243
|
+
* @param path
|
|
244
|
+
* @returns string: cotent
|
|
230
245
|
*/
|
|
231
246
|
exports.readFile = readFile;
|
|
232
247
|
const readFileContent = path => {
|
|
233
248
|
return _fulaNativeModule.default.readFileContent(path);
|
|
234
249
|
};
|
|
235
250
|
|
|
236
|
-
/**
|
|
237
|
-
* Shutdown closes all resources used by Client.
|
|
238
|
-
// After calling this function Client must be discarded.
|
|
239
|
-
* @param
|
|
240
|
-
* @returns
|
|
251
|
+
/**
|
|
252
|
+
* Shutdown closes all resources used by Client.
|
|
253
|
+
// After calling this function Client must be discarded.
|
|
254
|
+
* @param
|
|
255
|
+
* @returns
|
|
241
256
|
*/
|
|
242
257
|
exports.readFileContent = readFileContent;
|
|
243
258
|
const shutdown = () => {
|
|
244
259
|
return _fulaNativeModule.default.shutdown();
|
|
245
260
|
};
|
|
246
261
|
|
|
247
|
-
/**
|
|
248
|
-
* setAuth adds or removes a peer from the list of peers that are allowed to push to this node.
|
|
249
|
-
* This can only be called on a peer that is added as an owner of blox by --authorizer parameter
|
|
250
|
-
* @param peerId, allow
|
|
251
|
-
* @returns boolean: true if successful or false if not
|
|
262
|
+
/**
|
|
263
|
+
* setAuth adds or removes a peer from the list of peers that are allowed to push to this node.
|
|
264
|
+
* This can only be called on a peer that is added as an owner of blox by --authorizer parameter
|
|
265
|
+
* @param peerId, allow
|
|
266
|
+
* @returns boolean: true if successful or false if not
|
|
252
267
|
*/
|
|
253
268
|
exports.shutdown = shutdown;
|
|
254
269
|
const setAuth = (peerId, allow) => {
|
|
255
270
|
return _fulaNativeModule.default.setAuth(peerId, allow);
|
|
256
271
|
};
|
|
257
272
|
|
|
258
|
-
/**
|
|
259
|
-
* isReady checks if the connection is ready to be used.
|
|
260
|
-
* @param filesystemCheck: also check if the wnfs is ready
|
|
261
|
-
* @returns boolean: true if ready or false if not
|
|
273
|
+
/**
|
|
274
|
+
* isReady checks if the connection is ready to be used.
|
|
275
|
+
* @param filesystemCheck: also check if the wnfs is ready
|
|
276
|
+
* @returns boolean: true if ready or false if not
|
|
262
277
|
*/
|
|
263
278
|
exports.setAuth = setAuth;
|
|
264
279
|
const isReady = function () {
|
|
@@ -1 +1 @@
|
|
|
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,KAAK;EAExBC,OAAO,CAACC,GAAG,CACT,8BAA8B,EAC9BT,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTE,QAAQ,CACT;EACD,OAAOI,yBAAI,CAACX,IAAI,CAACC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,OAAO,CAAC;AAClG,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAOO,MAAMI,SAAS,GAAG,UACvBX,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAII;EAAA,IAHpBC,SAAkB,uEAAG,KAAK;EAAA,IAC1BE,QAAiB,uEAAG,IAAI;EAAA,IACxBC,OAAgB,uEAAG,KAAK;EAExBC,OAAO,CAACC,GAAG,CACT,mCAAmC,EACn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;;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
|
+
{"version":3,"names":["init","identity","storePath","bloxAddr","exchange","autoFlush","rootCid","useRelay","refresh","console","log","Fula","newClient","logout","checkFailedActions","retry","timeout","listFailedActions","cids","checkConnection","get","key","has","push","testData","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","then","res","lsResult","lsRows","split","element","rowItems","item","name","created","modified","jsonRes","JSON","parse","stringify","catch","e","rm","cp","sourcePath","targetPath","mv","readFile","readFileContent","shutdown","setAuth","peerId","allow","isReady","filesystemCheck"],"sources":["fula.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const init = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n rootCid: string | null = null,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {\n console.log(\n 'init in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay\n );\n return Fula.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param config\n * @returns boolean\n */\n\nexport const newClient = (\n identity: string, //privateKey of did identity\n storePath: string,\n bloxAddr: string,\n exchange: string,\n autoFlush: boolean = false,\n useRelay: boolean = true,\n refresh: boolean = false\n): Promise<string> => {\n console.log(\n 'newClient in react-native started',\n identity,\n storePath,\n bloxAddr,\n exchange,\n autoFlush,\n useRelay,\n refresh\n );\n return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);\n};\n\n/**\n * rm removes all data\n * @param path\n * @returns string: new cid of the root\n */\nexport const logout = (\n identity: string,\n storePath: string\n): Promise<boolean> => {\n return Fula.logout(identity, storePath);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkFailedActions = (\n retry: boolean = false,\n timeout: number = 20\n): Promise<boolean> => {\n return Fula.checkFailedActions(retry, timeout);\n};\n\n/**\n * Lists the cids that failed to be sent to backend and are kept only locally\n */\nexport const listFailedActions = (cids: string[] = []): Promise<string[]> => {\n return Fula.listFailedActions(cids);\n};\n\n/**\n * Checks if there are any un-synced changes on the device\n */\nexport const checkConnection = (timeout: number = 20): Promise<boolean> => {\n return Fula.checkConnection(timeout);\n};\n\n/**\n * Get gets the value corresponding to the given key from the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns value\n */\nexport const get = (key: string): Promise<string> => {\n return Fula.get(key);\n};\n\n/**\n * Has checks whether the value corresponding to the given key is present in the local datastore.\n// The key must be a valid ipld.Link.\n * @param key\n * @returns boolean\n */\nexport const has = (key: Uint8Array): Promise<boolean> => {\n return Fula.has(key);\n};\n\n/**\n * Push requests the given addr to download the root cid from this node.\n// The addr must be a valid multiaddr that includes peer ID.\n// this function.\n * @param addr\n * @returns null or error\n */\nexport const push = (): Promise<string> => {\n return Fula.push();\n};\n\n//This method sends some test data to backedn\nexport const testData = (\n identity: string,\n bloxAddr: string\n): Promise<string> => {\n return Fula.testData(identity, bloxAddr);\n};\n\n/**\n * Put stores the given key value onto the local datastore.\n// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding\n// to the given key.\n * @param key, value\n * @returns null or string\n */\nexport const put = (value: string, codec: string): Promise<string> => {\n return Fula.put(value, codec);\n};\n\n/**\n * mkdir creates a directory at the given path.\n * @param path\n * @returns string: new cid of the root\n */\nexport const mkdir = (path: string): Promise<string> => {\n return Fula.mkdir(path);\n};\n\n/**\n * writeFileContent writes content at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const writeFileContent = (\n path: string,\n content: string\n): Promise<string> => {\n return Fula.writeFileContent(path, content);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // It keeps the original file modiifcation date\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const writeFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.writeFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * ls lists the name of files and folders at a given path\n * @param path\n * @returns string: list of items\n * TODO: Findout how is the string and convert to array\n */\nexport const ls = (path: string): Promise<void | JSON> => {\n return Fula.ls(path)\n .then((res) => {\n let lsResult = [];\n let lsRows = res.split('!!!');\n for (const element of lsRows) {\n let rowItems = element.split('???');\n if (rowItems && rowItems[0]) {\n let item = {\n name: '',\n created: '',\n modified: '',\n };\n item.name = rowItems[0];\n if (rowItems[1]) {\n item.created = rowItems[1];\n }\n if (rowItems[2]) {\n item.modified = rowItems[2];\n }\n lsResult.push(item);\n }\n }\n let jsonRes = JSON.parse(JSON.stringify(lsResult));\n return jsonRes;\n })\n .catch((e) => {\n return e;\n });\n};\n\n/**\n * rm removes all files and folders at a given path\n * @param path\n * @returns string: new cid of the root\n */\nexport const rm = (path: string): Promise<string> => {\n return Fula.rm(path);\n};\n\n/**\n * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const cp = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.cp(sourcePath, targetPath);\n};\n\n/**\n * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already\n * @param sourcePath, targetPath\n * @returns string: new cid of the root\n */\nexport const mv = (sourcePath: string, targetPath: string): Promise<string> => {\n return Fula.mv(sourcePath, targetPath);\n};\n\n/*\n // reads content of the file form localFilename (should include full absolute path to local file with read permission\n // writes content to the specified location by fulaTargetFilename in Fula filesystem\n // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)\n // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)\n // Returns: new cid of the root after this file is placed in the tree\n */\nexport const readFile = (\n fulaTargetFilename: string,\n localFilename: string\n): Promise<string> => {\n return Fula.readFile(fulaTargetFilename, localFilename);\n};\n\n/**\n * readFile reads content of a given path\n * @param path\n * @returns string: cotent\n */\nexport const readFileContent = (path: string): Promise<string> => {\n return Fula.readFileContent(path);\n};\n\n/**\n * Shutdown closes all resources used by Client.\n// After calling this function Client must be discarded.\n * @param\n * @returns\n */\nexport const shutdown = (): Promise<void> => {\n return Fula.shutdown();\n};\n\n/**\n * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.\n * This can only be called on a peer that is added as an owner of blox by --authorizer parameter\n * @param peerId, allow\n * @returns boolean: true if successful or false if not\n */\nexport const setAuth = (\n peerId: string,\n allow: boolean\n): Promise<boolean> => {\n return Fula.setAuth(peerId, allow);\n};\n\n\n/**\n * isReady checks if the connection is ready to be used.\n * @param filesystemCheck: also check if the wnfs is ready\n * @returns boolean: true if ready or false if not\n */\nexport const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {\n return Fula.isReady(filesystemCheck);\n};\n"],"mappings":";;;;;;AAAA;AAAkD;AAElD;AACA;AACA;A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ACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMC,OAAO,GAAG,CACrBC,MAAc,EACdC,KAAc,KACO;EACrB,OAAOpD,yBAAI,CAACkD,OAAO,CAACC,MAAM,EAAEC,KAAK,CAAC;AACpC,CAAC;;AAGD;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,OAAO,GAAG,YAAuD;EAAA,IAAtDC,eAAwB,uEAAG,IAAI;EACrD,OAAOtD,yBAAI,CAACqD,OAAO,CAACC,eAAe,CAAC;AACtC,CAAC;AAAC"}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.wifiRemoveall = void 0;
|
|
6
|
+
exports.wifiRemoveall = exports.reboot = void 0;
|
|
7
7
|
var _fulaNativeModule = _interopRequireDefault(require("../interfaces/fulaNativeModule"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
/**
|
|
10
|
-
* send a command to Blox hardware to remove all save wifis.
|
|
11
|
-
* @returns json{status:true if success, false if fails; msg: error message or success log}
|
|
9
|
+
/**
|
|
10
|
+
* send a command to Blox hardware to remove all save wifis.
|
|
11
|
+
* @returns json{status:true if success, false if fails; msg: error message or success log}
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
const wifiRemoveall = () => {
|
|
@@ -30,4 +30,23 @@ const wifiRemoveall = () => {
|
|
|
30
30
|
return res;
|
|
31
31
|
};
|
|
32
32
|
exports.wifiRemoveall = wifiRemoveall;
|
|
33
|
+
const reboot = () => {
|
|
34
|
+
console.log('reboot in react-native started');
|
|
35
|
+
let res = _fulaNativeModule.default.reboot().then(res => {
|
|
36
|
+
try {
|
|
37
|
+
let jsonRes = JSON.parse(res);
|
|
38
|
+
return jsonRes;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(res);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}).catch(err => {
|
|
47
|
+
return err;
|
|
48
|
+
});
|
|
49
|
+
return res;
|
|
50
|
+
};
|
|
51
|
+
exports.reboot = reboot;
|
|
33
52
|
//# sourceMappingURL=fxblox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["wifiRemoveall","console","log","res","Fula","then","jsonRes","JSON","parse","e","catch","err"],"sources":["fxblox.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\nimport type * as BType from '../types/fxblox';\n\n/**\n * send a command to Blox hardware to remove all save wifis.\n * @returns json{status:true if success, false if fails; msg: error message or success log}\n */\n\nexport const wifiRemoveall = (): Promise<BType.wifiRemoveallResponse> => {\n console.log(
|
|
1
|
+
{"version":3,"names":["wifiRemoveall","console","log","res","Fula","then","jsonRes","JSON","parse","e","catch","err","reboot"],"sources":["fxblox.ts"],"sourcesContent":["import Fula from '../interfaces/fulaNativeModule';\r\nimport type * as BType from '../types/fxblox';\r\n\r\n/**\r\n * send a command to Blox hardware to remove all save wifis.\r\n * @returns json{status:true if success, false if fails; msg: error message or success log}\r\n */\r\n\r\nexport const wifiRemoveall = (): Promise<BType.wifiRemoveallResponse> => {\r\n console.log('wifiRemoveall in react-native started');\r\n let res = Fula.wifiRemoveall()\r\n .then((res) => {\r\n try {\r\n let jsonRes: BType.wifiRemoveallResponse = JSON.parse(res);\r\n return jsonRes;\r\n } catch (e) {\r\n try {\r\n return JSON.parse(res);\r\n } catch (e) {\r\n return res;\r\n }\r\n }\r\n })\r\n .catch((err) => {\r\n return err;\r\n });\r\n return res;\r\n};\r\n\r\nexport const reboot = (): Promise<BType.rebootResponse> => {\r\n console.log('reboot in react-native started');\r\n let res = Fula.reboot()\r\n .then((res) => {\r\n try {\r\n let jsonRes: BType.rebootResponse = JSON.parse(res);\r\n return jsonRes;\r\n } catch (e) {\r\n try {\r\n return JSON.parse(res);\r\n } catch (e) {\r\n return res;\r\n }\r\n }\r\n })\r\n .catch((err) => {\r\n return err;\r\n });\r\n return res;\r\n};\r\n"],"mappings":";;;;;;AAAA;AAAkD;AAGlD;AACA;AACA;AACA;;AAEO,MAAMA,aAAa,GAAG,MAA4C;EACvEC,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;EACpD,IAAIC,GAAG,GAAGC,yBAAI,CAACJ,aAAa,EAAE,CAC3BK,IAAI,CAAEF,GAAG,IAAK;IACb,IAAI;MACF,IAAIG,OAAoC,GAAGC,IAAI,CAACC,KAAK,CAACL,GAAG,CAAC;MAC1D,OAAOG,OAAO;IAChB,CAAC,CAAC,OAAOG,CAAC,EAAE;MACV,IAAI;QACF,OAAOF,IAAI,CAACC,KAAK,CAACL,GAAG,CAAC;MACxB,CAAC,CAAC,OAAOM,CAAC,EAAE;QACV,OAAON,GAAG;MACZ;IACF;EACF,CAAC,CAAC,CACDO,KAAK,CAAEC,GAAG,IAAK;IACd,OAAOA,GAAG;EACZ,CAAC,CAAC;EACJ,OAAOR,GAAG;AACZ,CAAC;AAAC;AAEK,MAAMS,MAAM,GAAG,MAAqC;EACzDX,OAAO,CAACC,GAAG,CAAC,gCAAgC,CAAC;EAC7C,IAAIC,GAAG,GAAGC,yBAAI,CAACQ,MAAM,EAAE,CACpBP,IAAI,CAAEF,GAAG,IAAK;IACb,IAAI;MACF,IAAIG,OAA6B,GAAGC,IAAI,CAACC,KAAK,CAACL,GAAG,CAAC;MACnD,OAAOG,OAAO;IAChB,CAAC,CAAC,OAAOG,CAAC,EAAE;MACV,IAAI;QACF,OAAOF,IAAI,CAACC,KAAK,CAACL,GAAG,CAAC;MACxB,CAAC,CAAC,OAAOM,CAAC,EAAE;QACV,OAAON,GAAG;MACZ;IACF;EACF,CAAC,CAAC,CACDO,KAAK,CAAEC,GAAG,IAAK;IACd,OAAOA,GAAG;EACZ,CAAC,CAAC;EACJ,OAAOR,GAAG;AACZ,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["fxblox.ts"],"sourcesContent":["export interface wifiRemoveallResponse {\n status: boolean;\n msg: string;\n }\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["fxblox.ts"],"sourcesContent":["export interface wifiRemoveallResponse {\r\n status: boolean;\r\n msg: string;\r\n}\r\nexport interface rebootResponse {\r\n status: boolean;\r\n msg: string;\r\n}\r\n"],"mappings":""}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fula","blockchain","chainApi","fxblox"],"sources":["index.tsx"],"sourcesContent":["export * as fula from './protocols/fula';\nexport * as blockchain from './protocols/blockchain';\nexport * as chainApi from './protocols/chain-api';\nexport * as fxblox from './protocols/fxblox';\n"],"mappings":"uBAAsB,kBAAkB;AAAA,kBAA5BA,IAAI;AAAA,6BACY,wBAAwB;AAAA,wBAAxCC,UAAU;AAAA,2BACI,uBAAuB;AAAA,sBAArCC,QAAQ;AAAA,yBACI,oBAAoB;AAAA,oBAAhCC,MAAM"}
|
|
1
|
+
{"version":3,"names":["fula","blockchain","chainApi","fxblox"],"sources":["index.tsx"],"sourcesContent":["export * as fula from './protocols/fula';\r\nexport * as blockchain from './protocols/blockchain';\r\nexport * as chainApi from './protocols/chain-api';\r\nexport * as fxblox from './protocols/fxblox';\r\n"],"mappings":"uBAAsB,kBAAkB;AAAA,kBAA5BA,IAAI;AAAA,6BACY,wBAAwB;AAAA,wBAAxCC,UAAU;AAAA,2BACI,uBAAuB;AAAA,sBAArCC,QAAQ;AAAA,yBACI,oBAAoB;AAAA,oBAAhCC,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Fula","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ninterface FulaNativeModule {\n init: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;\n newClient: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Fula","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ninterface FulaNativeModule {\n init: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;\n newClient: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write\n useRelay: boolean | null, // if true it forces the use of relay\n refresh: boolean // if true it forces to refresh the fula object\n ) => Promise<string>;\n isReady: (filesystemCheck: boolean) => Promise<boolean>;\n logout: (identity: string, storePath: string) => Promise<boolean>;\n checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;\n listFailedActions: (cids: string[]) => Promise<string[]>;\n checkConnection: (timeout: number) => Promise<boolean>;\n get: (key: string) => Promise<string>;\n has: (key: Uint8Array) => Promise<boolean>;\n push: () => Promise<string>;\n put: (content: string, codec: string) => Promise<string>;\n mkdir: (path: string) => Promise<string>;\n writeFileContent: (path: string, content: string) => Promise<string>;\n writeFile: (\n fulaTargetFilename: string,\n localFilename: string\n ) => Promise<string>;\n ls: (path: string) => Promise<string>;\n rm: (path: string) => Promise<string>;\n cp: (sourcePath: string, targetPath: string) => Promise<string>;\n mv: (sourcePath: string, targetPath: string) => Promise<string>;\n readFile: (\n fulaTargetFilename: string,\n localFilename: string\n ) => Promise<string>;\n readFileContent: (path: string) => Promise<string>;\n setAuth: (peerId: string, allow: boolean) => Promise<boolean>;\n\n shutdown: () => Promise<void>;\n\n testData: (identity: string, bloxAddr: string) => Promise<string>;\n\n //Blockchain related functions\n createAccount: (seed: string) => Promise<string>;\n checkAccountExists: (account: string) => Promise<string>;\n createPool: (seed: string, poolName: string) => Promise<string>;\n listPools: () => Promise<string>;\n joinPool: (seed: string, poolID: number) => Promise<string>;\n leavePool: (seed: string, poolID: number) => Promise<string>;\n cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;\n listPoolJoinRequests: (poolID: number) => Promise<string>;\n votePoolJoinRequest: (\n seed: string,\n poolID: number,\n account: string,\n accept: boolean\n ) => Promise<string>;\n newReplicationRequest: (\n seed: string,\n poolID: number,\n replicationFactor: number,\n cid: string\n ) => Promise<string>;\n newStoreRequest: (\n seed: string,\n poolID: number,\n uploader: string,\n cid: string\n ) => Promise<string>;\n listAvailableReplicationRequests: (poolID: number) => Promise<string>;\n removeReplicationRequest: (\n seed: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n removeStorer: (\n seed: string,\n storer: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n removeStoredReplication: (\n seed: string,\n uploader: string,\n poolID: number,\n cid: string\n ) => Promise<string>;\n\n //Hardware\n bloxFreeSpace: () => Promise<string>;\n wifiRemoveall: () => Promise<string>;\n reboot: () => Promise<string>;\n}\n\nconst LINKING_ERROR =\n `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Fula = NativeModules.FulaModule\n ? NativeModules.FulaModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport default Fula as FulaNativeModule;\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAwGtD,MAAMC,aAAa,GAChB,iFAAgF,GACjFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,IAAI,GAAGN,aAAa,CAACO,UAAU,GACjCP,aAAa,CAACO,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AAEL,eAAeI,IAAI"}
|
|
@@ -2,8 +2,7 @@ import Fula from '../interfaces/fulaNativeModule';
|
|
|
2
2
|
/*
|
|
3
3
|
createAccount: This function takes a seed argument, which is used to create an account. The seed must start with "/". The function returns a promise of an object that contains the seed and the account that was created.
|
|
4
4
|
*/
|
|
5
|
-
export const createAccount =
|
|
6
|
-
) => {
|
|
5
|
+
export const createAccount = seed => {
|
|
7
6
|
console.log('createAccount in react-native started', seed);
|
|
8
7
|
let res = Fula.createAccount(seed).then(res => {
|
|
9
8
|
try {
|
|
@@ -67,8 +66,8 @@ export const createPool = (seed, poolName) => {
|
|
|
67
66
|
};
|
|
68
67
|
|
|
69
68
|
/*
|
|
70
|
-
listPools: This function takes no arguments and returns a promise of an object that contains a list of pools. Each pool in the list contains the poolID, owner, poolName, parent, and participants of the pool
|
|
71
|
-
*/
|
|
69
|
+
listPools: This function takes no arguments and returns a promise of an object that contains a list of pools. Each pool in the list contains the poolID, owner, poolName, parent, and participants of the pool
|
|
70
|
+
*/
|
|
72
71
|
export const listPools = () => {
|
|
73
72
|
console.log('listPools in react-native started');
|
|
74
73
|
let res = Fula.listPools().then(res => {
|
|
@@ -89,8 +88,8 @@ export const listPools = () => {
|
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
/*
|
|
92
|
-
joinPool: This function takes two arguments: seed and poolID. The seed is used to identify the account that is joining the pool, and the poolID is the ID of the pool the account is joining. The function returns a promise of an object that contains the account joining the pool and the poolID of the joined pool.
|
|
93
|
-
*/
|
|
91
|
+
joinPool: This function takes two arguments: seed and poolID. The seed is used to identify the account that is joining the pool, and the poolID is the ID of the pool the account is joining. The function returns a promise of an object that contains the account joining the pool and the poolID of the joined pool.
|
|
92
|
+
*/
|
|
94
93
|
|
|
95
94
|
export const joinPool = (seed, poolID) => {
|
|
96
95
|
console.log('joinPool in react-native started', seed, poolID);
|
|
@@ -112,8 +111,8 @@ export const joinPool = (seed, poolID) => {
|
|
|
112
111
|
};
|
|
113
112
|
|
|
114
113
|
/*
|
|
115
|
-
leavePool: This function takes two arguments: seed and poolID. The seed is used to identify the account that is leaving the pool, and the poolID is the ID of the pool the account is leaving. The function returns a promise of an object that contains the `
|
|
116
|
-
*/
|
|
114
|
+
leavePool: This function takes two arguments: seed and poolID. The seed is used to identify the account that is leaving the pool, and the poolID is the ID of the pool the account is leaving. The function returns a promise of an object that contains the `
|
|
115
|
+
*/
|
|
117
116
|
|
|
118
117
|
export const leavePool = (seed, poolID) => {
|
|
119
118
|
console.log('leavePool in react-native started', seed, poolID);
|
|
@@ -171,7 +170,7 @@ export const listPoolJoinRequests = poolID => {
|
|
|
171
170
|
};
|
|
172
171
|
|
|
173
172
|
/*
|
|
174
|
-
seed is used to authorize the request.
|
|
173
|
+
seed is used to authorize the request.
|
|
175
174
|
poolID is the ID of the pool in which the account is requesting to join.
|
|
176
175
|
account is the account that is requesting to join the pool.
|
|
177
176
|
accept is a boolean value that indicates whether to accept or reject the join request.
|
|
@@ -198,12 +197,13 @@ export const votePoolJoinRequest = (seed, poolID, account, accept) => {
|
|
|
198
197
|
|
|
199
198
|
/*
|
|
200
199
|
It takes four arguments:
|
|
200
|
+
|
|
201
201
|
seed is used to authorize the request.
|
|
202
202
|
poolID is the ID of the pool in which the replication request is made.
|
|
203
203
|
replicationFactor is the number of copies of the content to be stored.
|
|
204
204
|
cid is the content identifier of the content to be replicated.
|
|
205
205
|
It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
|
|
206
|
-
*/
|
|
206
|
+
*/
|
|
207
207
|
export const newReplicationRequest = (seed, poolID, replicationFactor, cid) => {
|
|
208
208
|
console.log('newReplicationRequest in react-native started', seed, poolID, replicationFactor, cid);
|
|
209
209
|
let res = Fula.newReplicationRequest(seed, poolID, replicationFactor, cid).then(res => {
|
|
@@ -360,8 +360,8 @@ export const removeStoredReplication = (seed, uploader, poolID, cid) => {
|
|
|
360
360
|
};
|
|
361
361
|
|
|
362
362
|
/*
|
|
363
|
-
bloxFreeSpace: This function takes no arguments and returns a promise of an object that contains the blox free space information.
|
|
364
|
-
*/
|
|
363
|
+
bloxFreeSpace: This function takes no arguments and returns a promise of an object that contains the blox free space information.
|
|
364
|
+
*/
|
|
365
365
|
export const bloxFreeSpace = () => {
|
|
366
366
|
console.log('bloxFreeSpace in react-native started');
|
|
367
367
|
let res = Fula.bloxFreeSpace().then(res => {
|