@functionland/react-native-fula 0.4.2 → 1.1.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.
- package/README.md +99 -9
- 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/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/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/jarRepositories.xml +9 -9
- package/android/.idea/sonarlint/issuestore/index.pb +0 -0
- package/android/build.gradle +7 -5
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -6
- package/android/gradle.properties +1 -1
- package/android/gradlew +53 -2
- package/android/local.properties +1 -1
- package/android/src/main/java/land/fx/fula/FulaModule.java +840 -72
- package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
- package/lib/commonjs/index.js +5 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interfaces/api-lookup.js +1653 -0
- package/lib/commonjs/interfaces/api-lookup.js.map +1 -0
- package/lib/commonjs/interfaces/fulaNativeModule.js +1 -1
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/protocols/blockchain.js +404 -0
- package/lib/commonjs/protocols/blockchain.js.map +1 -0
- package/lib/commonjs/protocols/chain-api.js +87 -0
- package/lib/commonjs/protocols/chain-api.js.map +1 -0
- package/lib/commonjs/protocols/fula.js +120 -7
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/commonjs/types/blockchain.js +2 -0
- package/lib/commonjs/types/blockchain.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/interfaces/api-lookup.js +1648 -0
- package/lib/module/interfaces/api-lookup.js.map +1 -0
- package/lib/module/interfaces/fulaNativeModule.js +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/protocols/blockchain.js +383 -0
- package/lib/module/protocols/blockchain.js.map +1 -0
- package/lib/module/protocols/chain-api.js +76 -0
- package/lib/module/protocols/chain-api.js.map +1 -0
- package/lib/module/protocols/fula.js +110 -4
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/module/types/blockchain.js +2 -0
- package/lib/module/types/blockchain.js.map +1 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/interfaces/api-lookup.d.ts +1643 -0
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +40 -3
- package/lib/typescript/protocols/blockchain.d.ts +17 -0
- package/lib/typescript/protocols/chain-api.d.ts +6 -0
- package/lib/typescript/protocols/fula.d.ts +52 -2
- package/lib/typescript/types/blockchain.d.ts +68 -0
- package/package.json +13 -8
- package/src/index.tsx +3 -1
- package/src/interfaces/api-lookup.ts +1647 -0
- package/src/interfaces/fulaNativeModule.ts +50 -7
- package/src/protocols/blockchain.ts +460 -0
- package/src/protocols/chain-api.ts +80 -0
- package/src/protocols/fula.ts +157 -12
- package/src/types/blockchain.ts +81 -0
package/src/protocols/fula.ts
CHANGED
|
@@ -11,10 +11,77 @@ export const init = (
|
|
|
11
11
|
identity: string, //privateKey of did identity
|
|
12
12
|
storePath: string,
|
|
13
13
|
bloxAddr: string,
|
|
14
|
-
exchange: string
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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; private_ref: 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(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get gets the value corresponding to the given key from the local datastore.
|
|
34
|
+
// The key must be a valid ipld.Link.
|
|
35
|
+
* @param config
|
|
36
|
+
* @returns boolean
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
export const newClient = (
|
|
40
|
+
identity: string, //privateKey of did identity
|
|
41
|
+
storePath: string,
|
|
42
|
+
bloxAddr: string,
|
|
43
|
+
exchange: string,
|
|
44
|
+
autoFlush: boolean = false,
|
|
45
|
+
useRelay: boolean = true
|
|
46
|
+
): Promise<string> => {
|
|
47
|
+
console.log(
|
|
48
|
+
'newClient in react-native started',
|
|
49
|
+
identity,
|
|
50
|
+
storePath,
|
|
51
|
+
bloxAddr,
|
|
52
|
+
exchange,
|
|
53
|
+
autoFlush,
|
|
54
|
+
useRelay
|
|
55
|
+
);
|
|
56
|
+
return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* rm removes all data
|
|
61
|
+
* @param path
|
|
62
|
+
* @returns string: new cid of the root
|
|
63
|
+
*/
|
|
64
|
+
export const logout = (
|
|
65
|
+
identity: string,
|
|
66
|
+
storePath: string
|
|
67
|
+
): Promise<boolean> => {
|
|
68
|
+
return Fula.logout(identity, storePath);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Checks if there are any un-synced changes on the device
|
|
73
|
+
*/
|
|
74
|
+
export const checkFailedActions = (
|
|
75
|
+
retry: boolean = false
|
|
76
|
+
): Promise<boolean> => {
|
|
77
|
+
return Fula.checkFailedActions(retry);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Checks if there are any un-synced changes on the device
|
|
82
|
+
*/
|
|
83
|
+
export const checkConnection = (): Promise<boolean> => {
|
|
84
|
+
return Fula.checkConnection();
|
|
18
85
|
};
|
|
19
86
|
|
|
20
87
|
/**
|
|
@@ -73,18 +140,25 @@ export const mkdir = (path: string): Promise<string> => {
|
|
|
73
140
|
* @param path
|
|
74
141
|
* @returns string: new cid of the root
|
|
75
142
|
*/
|
|
76
|
-
export const writeFileContent = (
|
|
143
|
+
export const writeFileContent = (
|
|
144
|
+
path: string,
|
|
145
|
+
content: string
|
|
146
|
+
): Promise<string> => {
|
|
77
147
|
return Fula.writeFileContent(path, content);
|
|
78
148
|
};
|
|
79
149
|
|
|
80
150
|
/*
|
|
81
151
|
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
82
152
|
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
153
|
+
// It keeps the original file modiifcation date
|
|
83
154
|
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
84
155
|
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
85
156
|
// Returns: new cid of the root after this file is placed in the tree
|
|
86
157
|
*/
|
|
87
|
-
export const writeFile = (
|
|
158
|
+
export const writeFile = (
|
|
159
|
+
fulaTargetFilename: string,
|
|
160
|
+
localFilename: string
|
|
161
|
+
): Promise<string> => {
|
|
88
162
|
return Fula.writeFile(fulaTargetFilename, localFilename);
|
|
89
163
|
};
|
|
90
164
|
|
|
@@ -94,8 +168,35 @@ export const writeFile = (fulaTargetFilename: string, localFilename: string): Pr
|
|
|
94
168
|
* @returns string: list of items
|
|
95
169
|
* TODO: Findout how is the string and convert to array
|
|
96
170
|
*/
|
|
97
|
-
|
|
98
|
-
return Fula.ls(path)
|
|
171
|
+
export const ls = (path: string): Promise<void | JSON> => {
|
|
172
|
+
return Fula.ls(path)
|
|
173
|
+
.then((res) => {
|
|
174
|
+
let lsResult = [];
|
|
175
|
+
let lsRows = res.split('!!!');
|
|
176
|
+
for (const element of lsRows) {
|
|
177
|
+
let rowItems = element.split('???');
|
|
178
|
+
if (rowItems && rowItems[0]) {
|
|
179
|
+
let item = {
|
|
180
|
+
name: '',
|
|
181
|
+
created: '',
|
|
182
|
+
modified: '',
|
|
183
|
+
};
|
|
184
|
+
item.name = rowItems[0];
|
|
185
|
+
if (rowItems[1]) {
|
|
186
|
+
item.created = rowItems[1];
|
|
187
|
+
}
|
|
188
|
+
if (rowItems[2]) {
|
|
189
|
+
item.modified = rowItems[2];
|
|
190
|
+
}
|
|
191
|
+
lsResult.push(item);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
let jsonRes = JSON.parse(JSON.stringify(lsResult));
|
|
195
|
+
return jsonRes;
|
|
196
|
+
})
|
|
197
|
+
.catch((e) => {
|
|
198
|
+
return e;
|
|
199
|
+
});
|
|
99
200
|
};
|
|
100
201
|
|
|
101
202
|
/**
|
|
@@ -107,6 +208,24 @@ export const rm = (path: string): Promise<string> => {
|
|
|
107
208
|
return Fula.rm(path);
|
|
108
209
|
};
|
|
109
210
|
|
|
211
|
+
/**
|
|
212
|
+
* cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
|
|
213
|
+
* @param sourcePath, targetPath
|
|
214
|
+
* @returns string: new cid of the root
|
|
215
|
+
*/
|
|
216
|
+
export const cp = (sourcePath: string, targetPath: string): Promise<string> => {
|
|
217
|
+
return Fula.cp(sourcePath, targetPath);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
|
|
222
|
+
* @param sourcePath, targetPath
|
|
223
|
+
* @returns string: new cid of the root
|
|
224
|
+
*/
|
|
225
|
+
export const mv = (sourcePath: string, targetPath: string): Promise<string> => {
|
|
226
|
+
return Fula.mv(sourcePath, targetPath);
|
|
227
|
+
};
|
|
228
|
+
|
|
110
229
|
/*
|
|
111
230
|
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
112
231
|
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
@@ -114,16 +233,19 @@ export const rm = (path: string): Promise<string> => {
|
|
|
114
233
|
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
115
234
|
// Returns: new cid of the root after this file is placed in the tree
|
|
116
235
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
236
|
+
export const readFile = (
|
|
237
|
+
fulaTargetFilename: string,
|
|
238
|
+
localFilename: string
|
|
239
|
+
): Promise<string> => {
|
|
240
|
+
return Fula.readFile(fulaTargetFilename, localFilename);
|
|
241
|
+
};
|
|
120
242
|
|
|
121
243
|
/**
|
|
122
244
|
* readFile reads content of a given path
|
|
123
245
|
* @param path
|
|
124
246
|
* @returns string: cotent
|
|
125
247
|
*/
|
|
126
|
-
|
|
248
|
+
export const readFileContent = (path: string): Promise<string> => {
|
|
127
249
|
return Fula.readFileContent(path);
|
|
128
250
|
};
|
|
129
251
|
|
|
@@ -136,3 +258,26 @@ export const rm = (path: string): Promise<string> => {
|
|
|
136
258
|
export const shutdown = (): Promise<void> => {
|
|
137
259
|
return Fula.shutdown();
|
|
138
260
|
};
|
|
261
|
+
|
|
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
|
|
267
|
+
*/
|
|
268
|
+
export const setAuth = (
|
|
269
|
+
peerId: string,
|
|
270
|
+
allow: boolean
|
|
271
|
+
): Promise<boolean> => {
|
|
272
|
+
return Fula.setAuth(peerId, allow);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* isReady checks if the connection is ready to be used.
|
|
278
|
+
* @param filesystemCheck: also check if the wnfs is ready
|
|
279
|
+
* @returns boolean: true if ready or false if not
|
|
280
|
+
*/
|
|
281
|
+
export const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {
|
|
282
|
+
return Fula.isReady(filesystemCheck);
|
|
283
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface SeededResponse {
|
|
2
|
+
seed: string;
|
|
3
|
+
account: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface AccountExistsResponse {
|
|
7
|
+
account: string;
|
|
8
|
+
exists: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PoolCreateResponse {
|
|
12
|
+
owner: string;
|
|
13
|
+
poolID: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PoolJoinResponse {
|
|
17
|
+
account: string;
|
|
18
|
+
poolID: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PoolCancelJoinResponse {
|
|
22
|
+
account: string;
|
|
23
|
+
poolID: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface PoolRequestsResponse {
|
|
27
|
+
poolRequests: PoolRequest[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface PoolListResponse {
|
|
31
|
+
pools: Pool[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PoolVoteResponse {
|
|
35
|
+
account: string;
|
|
36
|
+
poolID: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface PoolLeaveResponse {
|
|
40
|
+
account: string;
|
|
41
|
+
poolID: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ManifestUploadResponse {
|
|
45
|
+
uploader: string;
|
|
46
|
+
storage: string[];
|
|
47
|
+
manifestMetadata: ManifestMetadata;
|
|
48
|
+
poolID: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PoolRequest {
|
|
52
|
+
poolID: number;
|
|
53
|
+
account: string;
|
|
54
|
+
voted: string[];
|
|
55
|
+
positiveVotes: number;
|
|
56
|
+
peerID: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface Pool {
|
|
60
|
+
poolID: number;
|
|
61
|
+
owner: string;
|
|
62
|
+
poolName: string;
|
|
63
|
+
parent: string;
|
|
64
|
+
participants: string[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ManifestMetadata {
|
|
68
|
+
job: ManifestJob;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ManifestJob {
|
|
72
|
+
work: string;
|
|
73
|
+
engine: string;
|
|
74
|
+
uri: string;
|
|
75
|
+
}
|
|
76
|
+
export interface BloxFreeSpaceResponse {
|
|
77
|
+
size: number;
|
|
78
|
+
avail: number;
|
|
79
|
+
used: number;
|
|
80
|
+
used_percentage: number;
|
|
81
|
+
}
|