@functionland/react-native-fula 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +133 -35
  3. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  4. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  7. package/android/.gradle/7.5.1/dependencies-accessors/gc.properties +0 -0
  8. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  9. package/android/.gradle/7.5.1/fileChanges/last-build.bin +0 -0
  10. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  11. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  12. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  13. package/android/.gradle/7.5.1/gc.properties +0 -0
  14. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  15. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  16. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  17. package/android/.gradle/vcs-1/gc.properties +0 -0
  18. package/android/.idea/compiler.xml +5 -5
  19. package/android/.idea/gradle.xml +17 -18
  20. package/android/.idea/jarRepositories.xml +44 -49
  21. package/android/.idea/misc.xml +9 -9
  22. package/android/.idea/vcs.xml +5 -5
  23. package/android/build.gradle +7 -5
  24. package/android/gradle/wrapper/gradle-wrapper.properties +1 -0
  25. package/android/gradlew +375 -240
  26. package/android/local.properties +8 -8
  27. package/android/src/main/AndroidManifest.xml +4 -4
  28. package/android/src/main/java/land/fx/fula/ConfigRef.java +7 -7
  29. package/android/src/main/java/land/fx/fula/Cryptography.java +47 -47
  30. package/android/src/main/java/land/fx/fula/FulaModule.java +291 -33
  31. package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
  32. package/android/src/main/java/land/fx/fula/SharedPreferenceHelper.java +65 -65
  33. package/android/src/main/java/land/fx/fula/StaticHelper.java +13 -13
  34. package/android/src/main/java/land/fx/fula/ThreadUtils.java +42 -42
  35. package/ios/FulaModule.h +10 -10
  36. package/ios/FulaModule.m +149 -149
  37. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  38. package/lib/commonjs/protocols/fula.js +90 -10
  39. package/lib/commonjs/protocols/fula.js.map +1 -1
  40. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  41. package/lib/module/protocols/fula.js +81 -6
  42. package/lib/module/protocols/fula.js.map +1 -1
  43. package/lib/typescript/index.d.ts +1 -1
  44. package/lib/typescript/interfaces/fulaNativeModule.d.ts +28 -17
  45. package/lib/typescript/protocols/fula.d.ts +99 -70
  46. package/package.json +5 -8
  47. package/react-native-fula.podspec +19 -19
  48. package/src/interfaces/fulaNativeModule.ts +19 -6
  49. package/src/protocols/fula.ts +107 -11
  50. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  51. package/android/.gradle/file-system.probe +0 -0
@@ -1,19 +1,19 @@
1
- require "json"
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
-
5
- Pod::Spec.new do |s|
6
- s.name = "react-native-fula"
7
- s.version = package["version"]
8
- s.summary = package["description"]
9
- s.homepage = package["homepage"]
10
- s.license = package["license"]
11
- s.authors = package["author"]
12
-
13
- s.platforms = { :ios => "10.0" }
14
- s.source = { :git => "https://github.com/functionland/react-native-fula.git", :tag => "#{s.version}" }
15
-
16
- s.source_files = "ios/**/*.{h,m,mm}"
17
- s.dependency "React-Core"
18
- s.dependency 'Mobile','~> 0.0.3'
19
- end
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "react-native-fula"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "10.0" }
14
+ s.source = { :git => "https://github.com/functionland/react-native-fula.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm}"
17
+ s.dependency "React-Core"
18
+ s.dependency 'Mobile','~> 0.0.3'
19
+ end
@@ -2,19 +2,32 @@ import { NativeModules, Platform } from 'react-native';
2
2
 
3
3
  interface FulaNativeModule {
4
4
  init: (
5
- identity: string | null, //Private key of did identity
6
- storePath: string | null, //You can leave empty
7
- bloxAddr: string //Blox multiadddr needs to be manually entered now
8
- ) => Promise<[string]>;
5
+ identity: string, //Private key of did identity
6
+ storePath: string, //You can leave empty
7
+ bloxAddr: string, //Blox multiadddr needs to be manually entered now
8
+ exchange: string, //set to 'noope' for testing
9
+ rootCid: string | null //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
10
+ ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;
11
+ logout: (identity: string, storePath: string) => Promise<boolean>;
9
12
  get: (key: string) => Promise<string>;
10
13
  has: (key: Uint8Array) => Promise<boolean>;
11
14
  push: () => Promise<string>;
12
15
  put: (content: string, codec: string) => Promise<string>;
13
16
  mkdir: (path: string) => Promise<string>;
14
17
  writeFileContent: (path: string, content: string) => Promise<string>;
15
- writeFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
18
+ writeFile: (
19
+ fulaTargetFilename: string,
20
+ localFilename: string
21
+ ) => Promise<string>;
16
22
  ls: (path: string) => Promise<string>;
17
- readFile: (path: string) => Promise<string>;
23
+ rm: (path: string) => Promise<string>;
24
+ cp: (sourcePath: string, targetPath: string) => Promise<string>;
25
+ mv: (sourcePath: string, targetPath: string) => Promise<string>;
26
+ readFile: (
27
+ fulaTargetFilename: string,
28
+ localFilename: string
29
+ ) => Promise<string>;
30
+ readFileContent: (path: string) => Promise<string>;
18
31
 
19
32
  shutdown: () => Promise<void>;
20
33
  }
@@ -6,13 +6,34 @@ import Fula from '../interfaces/fulaNativeModule';
6
6
  * @param config
7
7
  * @returns boolean
8
8
  */
9
+
9
10
  export const init = (
10
- identity: string | null, //privateKey of did identity
11
- storePath: string | null,
11
+ identity: string, //privateKey of did identity
12
+ storePath: string,
12
13
  bloxAddr: string,
13
- ): Promise<[string]> => {
14
- console.log('init in react-native started',identity, storePath, bloxAddr);
15
- return Fula.init(identity, storePath, bloxAddr);
14
+ exchange: string,
15
+ rootCid: string | null = null
16
+ ): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {
17
+ console.log(
18
+ 'init in react-native started',
19
+ identity,
20
+ storePath,
21
+ bloxAddr,
22
+ exchange
23
+ );
24
+ return Fula.init(identity, storePath, bloxAddr, exchange, rootCid);
25
+ };
26
+
27
+ /**
28
+ * rm removes all data
29
+ * @param path
30
+ * @returns string: new cid of the root
31
+ */
32
+ export const logout = (
33
+ identity: string,
34
+ storePath: string
35
+ ): Promise<boolean> => {
36
+ return Fula.logout(identity, storePath);
16
37
  };
17
38
 
18
39
  /**
@@ -71,18 +92,25 @@ export const mkdir = (path: string): Promise<string> => {
71
92
  * @param path
72
93
  * @returns string: new cid of the root
73
94
  */
74
- export const writeFileContent = (path: string, content: string): Promise<string> => {
95
+ export const writeFileContent = (
96
+ path: string,
97
+ content: string
98
+ ): Promise<string> => {
75
99
  return Fula.writeFileContent(path, content);
76
100
  };
77
101
 
78
102
  /*
79
103
  // reads content of the file form localFilename (should include full absolute path to local file with read permission
80
104
  // writes content to the specified location by fulaTargetFilename in Fula filesystem
105
+ // It keeps the original file modiifcation date
81
106
  // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
82
107
  // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
83
108
  // Returns: new cid of the root after this file is placed in the tree
84
109
  */
85
- export const writeFile = (fulaTargetFilename: string, localFilename: string): Promise<string> => {
110
+ export const writeFile = (
111
+ fulaTargetFilename: string,
112
+ localFilename: string
113
+ ): Promise<string> => {
86
114
  return Fula.writeFile(fulaTargetFilename, localFilename);
87
115
  };
88
116
 
@@ -92,8 +120,76 @@ export const writeFile = (fulaTargetFilename: string, localFilename: string): Pr
92
120
  * @returns string: list of items
93
121
  * TODO: Findout how is the string and convert to array
94
122
  */
95
- export const ls = (path: string): Promise<string> => {
96
- return Fula.ls(path);
123
+ export const ls = (path: string): Promise<void | JSON> => {
124
+ return Fula.ls(path)
125
+ .then((res) => {
126
+ let lsResult = [];
127
+ let lsRows = res.split('!!!');
128
+ for (const element of lsRows) {
129
+ let rowItems = element.split('???');
130
+ if (rowItems && rowItems[0]) {
131
+ let item = {
132
+ name: '',
133
+ created: '',
134
+ modified: '',
135
+ };
136
+ item.name = rowItems[0];
137
+ if (rowItems[1]) {
138
+ item.created = rowItems[1];
139
+ }
140
+ if (rowItems[2]) {
141
+ item.modified = rowItems[2];
142
+ }
143
+ lsResult.push(item);
144
+ }
145
+ }
146
+ let jsonRes = JSON.parse(JSON.stringify(lsResult));
147
+ return jsonRes;
148
+ })
149
+ .catch((e) => {
150
+ return e;
151
+ });
152
+ };
153
+
154
+ /**
155
+ * rm removes all files and folders at a given path
156
+ * @param path
157
+ * @returns string: new cid of the root
158
+ */
159
+ export const rm = (path: string): Promise<string> => {
160
+ return Fula.rm(path);
161
+ };
162
+
163
+ /**
164
+ * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
165
+ * @param sourcePath, targetPath
166
+ * @returns string: new cid of the root
167
+ */
168
+ export const cp = (sourcePath: string, targetPath: string): Promise<string> => {
169
+ return Fula.cp(sourcePath, targetPath);
170
+ };
171
+
172
+ /**
173
+ * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
174
+ * @param sourcePath, targetPath
175
+ * @returns string: new cid of the root
176
+ */
177
+ export const mv = (sourcePath: string, targetPath: string): Promise<string> => {
178
+ return Fula.mv(sourcePath, targetPath);
179
+ };
180
+
181
+ /*
182
+ // reads content of the file form localFilename (should include full absolute path to local file with read permission
183
+ // writes content to the specified location by fulaTargetFilename in Fula filesystem
184
+ // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
185
+ // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
186
+ // Returns: new cid of the root after this file is placed in the tree
187
+ */
188
+ export const readFile = (
189
+ fulaTargetFilename: string,
190
+ localFilename: string
191
+ ): Promise<string> => {
192
+ return Fula.readFile(fulaTargetFilename, localFilename);
97
193
  };
98
194
 
99
195
  /**
@@ -101,8 +197,8 @@ export const writeFile = (fulaTargetFilename: string, localFilename: string): Pr
101
197
  * @param path
102
198
  * @returns string: cotent
103
199
  */
104
- export const readFile = (path: string): Promise<string> => {
105
- return Fula.readFile(path);
200
+ export const readFileContent = (path: string): Promise<string> => {
201
+ return Fula.readFileContent(path);
106
202
  };
107
203
 
108
204
  /**
Binary file