@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
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.writeFileContent = exports.writeFile = exports.shutdown = exports.readFile = exports.put = exports.push = exports.mkdir = exports.ls = exports.init = exports.has = exports.get = void 0;
6
+ exports.writeFileContent = exports.writeFile = exports.shutdown = exports.rm = exports.readFileContent = exports.readFile = exports.put = exports.push = exports.mv = exports.mkdir = exports.ls = exports.logout = exports.init = exports.has = exports.get = exports.cp = void 0;
7
7
  var _fulaNativeModule = _interopRequireDefault(require("../interfaces/fulaNativeModule"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  /**
@@ -12,9 +12,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
  * @param config
13
13
  * @returns boolean
14
14
  */
15
- const init = (identity, storePath, bloxAddr) => {
16
- console.log('init in react-native started', identity, storePath, bloxAddr);
17
- return _fulaNativeModule.default.init(identity, storePath, bloxAddr);
15
+
16
+ const init = function (identity, storePath, bloxAddr, exchange) {
17
+ let rootCid = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
18
+ console.log('init in react-native started', identity, storePath, bloxAddr, exchange);
19
+ return _fulaNativeModule.default.init(identity, storePath, bloxAddr, exchange, rootCid);
20
+ };
21
+
22
+ /**
23
+ * rm removes all data
24
+ * @param path
25
+ * @returns string: new cid of the root
26
+ */
27
+ exports.init = init;
28
+ const logout = (identity, storePath) => {
29
+ return _fulaNativeModule.default.logout(identity, storePath);
18
30
  };
19
31
 
20
32
  /**
@@ -23,7 +35,7 @@ const init = (identity, storePath, bloxAddr) => {
23
35
  * @param key
24
36
  * @returns value
25
37
  */
26
- exports.init = init;
38
+ exports.logout = logout;
27
39
  const get = key => {
28
40
  return _fulaNativeModule.default.get(key);
29
41
  };
@@ -86,6 +98,7 @@ const writeFileContent = (path, content) => {
86
98
  /*
87
99
  // reads content of the file form localFilename (should include full absolute path to local file with read permission
88
100
  // writes content to the specified location by fulaTargetFilename in Fula filesystem
101
+ // It keeps the original file modiifcation date
89
102
  // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
90
103
  // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
91
104
  // Returns: new cid of the root after this file is placed in the tree
@@ -103,7 +116,74 @@ const writeFile = (fulaTargetFilename, localFilename) => {
103
116
  */
104
117
  exports.writeFile = writeFile;
105
118
  const ls = path => {
106
- return _fulaNativeModule.default.ls(path);
119
+ return _fulaNativeModule.default.ls(path).then(res => {
120
+ let lsResult = [];
121
+ let lsRows = res.split('!!!');
122
+ for (const element of lsRows) {
123
+ let rowItems = element.split('???');
124
+ if (rowItems && rowItems[0]) {
125
+ let item = {
126
+ name: '',
127
+ created: '',
128
+ modified: ''
129
+ };
130
+ item.name = rowItems[0];
131
+ if (rowItems[1]) {
132
+ item.created = rowItems[1];
133
+ }
134
+ if (rowItems[2]) {
135
+ item.modified = rowItems[2];
136
+ }
137
+ lsResult.push(item);
138
+ }
139
+ }
140
+ let jsonRes = JSON.parse(JSON.stringify(lsResult));
141
+ return jsonRes;
142
+ }).catch(e => {
143
+ return e;
144
+ });
145
+ };
146
+
147
+ /**
148
+ * rm removes all files and folders at a given path
149
+ * @param path
150
+ * @returns string: new cid of the root
151
+ */
152
+ exports.ls = ls;
153
+ const rm = path => {
154
+ return _fulaNativeModule.default.rm(path);
155
+ };
156
+
157
+ /**
158
+ * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
159
+ * @param sourcePath, targetPath
160
+ * @returns string: new cid of the root
161
+ */
162
+ exports.rm = rm;
163
+ const cp = (sourcePath, targetPath) => {
164
+ return _fulaNativeModule.default.cp(sourcePath, targetPath);
165
+ };
166
+
167
+ /**
168
+ * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
169
+ * @param sourcePath, targetPath
170
+ * @returns string: new cid of the root
171
+ */
172
+ exports.cp = cp;
173
+ const mv = (sourcePath, targetPath) => {
174
+ return _fulaNativeModule.default.mv(sourcePath, targetPath);
175
+ };
176
+
177
+ /*
178
+ // reads content of the file form localFilename (should include full absolute path to local file with read permission
179
+ // writes content to the specified location by fulaTargetFilename in Fula filesystem
180
+ // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
181
+ // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
182
+ // Returns: new cid of the root after this file is placed in the tree
183
+ */
184
+ exports.mv = mv;
185
+ const readFile = (fulaTargetFilename, localFilename) => {
186
+ return _fulaNativeModule.default.readFile(fulaTargetFilename, localFilename);
107
187
  };
108
188
 
109
189
  /**
@@ -111,9 +191,9 @@ const ls = path => {
111
191
  * @param path
112
192
  * @returns string: cotent
113
193
  */
114
- exports.ls = ls;
115
- const readFile = path => {
116
- return _fulaNativeModule.default.readFile(path);
194
+ exports.readFile = readFile;
195
+ const readFileContent = path => {
196
+ return _fulaNativeModule.default.readFileContent(path);
117
197
  };
118
198
 
119
199
  /**
@@ -122,7 +202,7 @@ const readFile = path => {
122
202
  * @param
123
203
  * @returns
124
204
  */
125
- exports.readFile = readFile;
205
+ exports.readFileContent = readFileContent;
126
206
  const shutdown = () => {
127
207
  return _fulaNativeModule.default.shutdown();
128
208
  };
@@ -1 +1 @@
1
- {"version":3,"names":["init","identity","storePath","bloxAddr","console","log","Fula","get","key","has","push","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","readFile","shutdown"],"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 */\nexport const init = (\n identity: string | null, //privateKey of did identity\n storePath: string | null,\n bloxAddr: string,\n): Promise<[string]> => {\n console.log('init in react-native started',identity, storePath, bloxAddr);\n return Fula.init(identity, storePath, bloxAddr);\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/**\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 = (path: string, content: string): 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 // 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 = (fulaTargetFilename: string, localFilename: string): 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 */\n export const ls = (path: string): Promise<string> => {\n return Fula.ls(path);\n};\n\n/**\n * readFile reads content of a given path\n * @param path\n * @returns string: cotent\n */\n export const readFile = (path: string): Promise<string> => {\n return Fula.readFile(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"],"mappings":";;;;;;AAAA;AAAkD;AAElD;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,IAAI,GAAG,CAClBC,QAAuB,EACvBC,SAAwB,EACxBC,QAAgB,KACM;EACtBC,OAAO,CAACC,GAAG,CAAC,8BAA8B,EAACJ,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,CAAC;EACzE,OAAOG,yBAAI,CAACN,IAAI,CAACC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMI,GAAG,GAAIC,GAAW,IAAsB;EACnD,OAAOF,yBAAI,CAACC,GAAG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AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMQ,QAAQ,GAAG,MAAqB;EAC3C,OAAOjB,yBAAI,CAACiB,QAAQ,EAAE;AACxB,CAAC;AAAC"}
1
+ {"version":3,"names":["init","identity","storePath","bloxAddr","exchange","rootCid","console","log","Fula","logout","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"],"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 rootCid: string | null = null\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 );\n return Fula.init(identity, storePath, bloxAddr, exchange, rootCid);\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 * 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/**\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"],"mappings":";;;;;;AAAA;AAAkD;AAElD;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAEsD;EAAA,IADtEC,OAAsB,uEAAG,IAAI;EAE7BC,OAAO,CAACC,GAAG,CACT,8BAA8B,EAC9BN,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,QAAQ,CACT;EACD,OAAOI,yBAAI,CAACR,IAAI,CAACC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,OAAO,CAAC;AACpE,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,M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,EAAEC,UAAkB,KAAsB;EAC7E,OAAOrC,yBAAI,CAACmC,EAAE,CAACC,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMC,EAAE,GAAG,CAACF,UAAkB,EAAEC,UAAkB,KAAsB;EAC7E,OAAOrC,yBAAI,CAACsC,EAAE,CAACF,UAAU,EAAEC,UAAU,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AAOO,MAAME,QAAQ,GAAG,CACtBzB,kBAA0B,EAC1BC,aAAqB,KACD;EACpB,OAAOf,yBAAI,CAACuC,QAAQ,CAACzB,kBAAkB,EAAEC,aAAa,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,MAAMyB,eAAe,GAAI9B,IAAY,IAAsB;EAChE,OAAOV,yBAAI,CAACwC,eAAe,CAAC9B,IAAI,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAM+B,QAAQ,GAAG,MAAqB;EAC3C,OAAOzC,yBAAI,CAACyC,QAAQ,EAAE;AACxB,CAAC;AAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Fula","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ninterface FulaNativeModule {\n init: (\n identity: string | null, //Private key of did identity\n storePath: string | null, //You can leave empty\n bloxAddr: string //Blox multiadddr needs to be manually entered now\n ) => Promise<[string]>;\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: (fulaTargetFilename: string, localFilename: string) => Promise<string>;\n ls: (path: string) => Promise<string>;\n readFile: (path: string) => Promise<string>;\n\n shutdown: () => Promise<void>;\n}\n\nconst LINKING_ERROR =\n `The package 'react-native-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;AAqBtD,MAAMC,aAAa,GAChB,4EAA2E,GAC5ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,IAAI,GAAGN,aAAa,CAACO,UAAU,GACjCP,aAAa,CAACO,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AAEL,eAAeI,IAAI"}
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Fula","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\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 rootCid: string | null //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\n ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;\n logout: (identity: string, storePath: string) => 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\n shutdown: () => Promise<void>;\n}\n\nconst LINKING_ERROR =\n `The package 'react-native-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;AAkCtD,MAAMC,aAAa,GAChB,4EAA2E,GAC5ED,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"}
@@ -6,9 +6,20 @@ import Fula from '../interfaces/fulaNativeModule';
6
6
  * @param config
7
7
  * @returns boolean
8
8
  */
9
- export const init = (identity, storePath, bloxAddr) => {
10
- console.log('init in react-native started', identity, storePath, bloxAddr);
11
- return Fula.init(identity, storePath, bloxAddr);
9
+
10
+ export const init = function (identity, storePath, bloxAddr, exchange) {
11
+ let rootCid = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
12
+ console.log('init in react-native started', identity, storePath, bloxAddr, exchange);
13
+ return Fula.init(identity, storePath, bloxAddr, exchange, rootCid);
14
+ };
15
+
16
+ /**
17
+ * rm removes all data
18
+ * @param path
19
+ * @returns string: new cid of the root
20
+ */
21
+ export const logout = (identity, storePath) => {
22
+ return Fula.logout(identity, storePath);
12
23
  };
13
24
 
14
25
  /**
@@ -74,6 +85,7 @@ export const writeFileContent = (path, content) => {
74
85
  /*
75
86
  // reads content of the file form localFilename (should include full absolute path to local file with read permission
76
87
  // writes content to the specified location by fulaTargetFilename in Fula filesystem
88
+ // It keeps the original file modiifcation date
77
89
  // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
78
90
  // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
79
91
  // Returns: new cid of the root after this file is placed in the tree
@@ -89,7 +101,70 @@ export const writeFile = (fulaTargetFilename, localFilename) => {
89
101
  * TODO: Findout how is the string and convert to array
90
102
  */
91
103
  export const ls = path => {
92
- return Fula.ls(path);
104
+ return Fula.ls(path).then(res => {
105
+ let lsResult = [];
106
+ let lsRows = res.split('!!!');
107
+ for (const element of lsRows) {
108
+ let rowItems = element.split('???');
109
+ if (rowItems && rowItems[0]) {
110
+ let item = {
111
+ name: '',
112
+ created: '',
113
+ modified: ''
114
+ };
115
+ item.name = rowItems[0];
116
+ if (rowItems[1]) {
117
+ item.created = rowItems[1];
118
+ }
119
+ if (rowItems[2]) {
120
+ item.modified = rowItems[2];
121
+ }
122
+ lsResult.push(item);
123
+ }
124
+ }
125
+ let jsonRes = JSON.parse(JSON.stringify(lsResult));
126
+ return jsonRes;
127
+ }).catch(e => {
128
+ return e;
129
+ });
130
+ };
131
+
132
+ /**
133
+ * rm removes all files and folders at a given path
134
+ * @param path
135
+ * @returns string: new cid of the root
136
+ */
137
+ export const rm = path => {
138
+ return Fula.rm(path);
139
+ };
140
+
141
+ /**
142
+ * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
143
+ * @param sourcePath, targetPath
144
+ * @returns string: new cid of the root
145
+ */
146
+ export const cp = (sourcePath, targetPath) => {
147
+ return Fula.cp(sourcePath, targetPath);
148
+ };
149
+
150
+ /**
151
+ * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
152
+ * @param sourcePath, targetPath
153
+ * @returns string: new cid of the root
154
+ */
155
+ export const mv = (sourcePath, targetPath) => {
156
+ return Fula.mv(sourcePath, targetPath);
157
+ };
158
+
159
+ /*
160
+ // reads content of the file form localFilename (should include full absolute path to local file with read permission
161
+ // writes content to the specified location by fulaTargetFilename in Fula filesystem
162
+ // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
163
+ // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
164
+ // Returns: new cid of the root after this file is placed in the tree
165
+ */
166
+ export const readFile = (fulaTargetFilename, localFilename) => {
167
+ return Fula.readFile(fulaTargetFilename, localFilename);
93
168
  };
94
169
 
95
170
  /**
@@ -97,8 +172,8 @@ export const ls = path => {
97
172
  * @param path
98
173
  * @returns string: cotent
99
174
  */
100
- export const readFile = path => {
101
- return Fula.readFile(path);
175
+ export const readFileContent = path => {
176
+ return Fula.readFileContent(path);
102
177
  };
103
178
 
104
179
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["Fula","init","identity","storePath","bloxAddr","console","log","get","key","has","push","put","value","codec","mkdir","path","writeFileContent","content","writeFile","fulaTargetFilename","localFilename","ls","readFile","shutdown"],"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 */\nexport const init = (\n identity: string | null, //privateKey of did identity\n storePath: string | null,\n bloxAddr: string,\n): Promise<[string]> => {\n console.log('init in react-native started',identity, storePath, bloxAddr);\n return Fula.init(identity, storePath, bloxAddr);\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/**\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 = (path: string, content: string): 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 // 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 = (fulaTargetFilename: string, localFilename: string): 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 */\n export const ls = (path: string): Promise<string> => {\n return Fula.ls(path);\n};\n\n/**\n * readFile reads content of a given path\n * @param path\n * @returns string: cotent\n */\n export const readFile = (path: string): Promise<string> => {\n return Fula.readFile(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"],"mappings":"AAAA,OAAOA,IAAI,MAAM,gCAAgC;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,IAAI,GAAG,CAClBC,QAAuB,EACvBC,SAAwB,EACxBC,QAAgB,KACM;EACtBC,OAAO,CAACC,GAAG,CAAC,8BAA8B,EAACJ,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,CAAC;EACzE,OAAOJ,IAAI,CAACC,IAAI,CAACC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,GAAG,GAAIC,GAAW,IAAsB;EACnD,OAAOR,IAAI,CAACO,GAAG,CAACC,GAAG,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAID,GAAe,IAAuB;EACxD,OAAOR,IAAI,CAACS,GAAG,CAACD,GAAG,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,IAAI,GAAG,MAAuB;EACzC,OAAOV,IAAI,CAACU,IAAI,EAAE;AACpB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAG,CAACC,KAAa,EAAEC,KAAa,KAAsB;EACpE,OAAOb,IAAI,CAACW,GAAG,CAACC,KAAK,EAAEC,KAAK,CAAC;AAC/B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAIC,IAAY,IAAsB;EACtD,OAAOf,IAAI,CAACc,KAAK,CAACC,IAAI,CAAC;AACzB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,CAACD,IAAY,EAAEE,OAAe,KAAsB;EAClF,OAAOjB,IAAI,CAACgB,gBAAgB,CAACD,IAAI,EAAEE,OAAO,CAAC;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAG,CAACC,kBAA0B,EAAEC,aAAqB,KAAsB;EAC/F,OAAOpB,IAAI,CAACkB,SAAS,CAACC,kBAAkB,EAAEC,aAAa,CAAC;AAC1D,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACC,OAAO,MAAMC,EAAE,GAAIN,IAAY,IAAsB;EACpD,OAAOf,IAAI,CAACqB,EAAE,CAACN,IAAI,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACC,OAAO,MAAMO,QAAQ,GAAIP,IAAY,IAAsB;EAC1D,OAAOf,IAAI,CAACsB,QAAQ,CAACP,IAAI,CAAC;AAC5B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMQ,QAAQ,GAAG,MAAqB;EAC3C,OAAOvB,IAAI,CAACuB,QAAQ,EAAE;AACxB,CAAC"}
1
+ {"version":3,"names":["Fula","init","identity","storePath","bloxAddr","exchange","rootCid","console","log","logout","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"],"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 rootCid: string | null = null\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 );\n return Fula.init(identity, storePath, bloxAddr, exchange, rootCid);\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 * 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/**\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"],"mappings":"AAAA,OAAOA,IAAI,MAAM,gCAAgC;;AAEjD;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,IAAI,GAAG,UAClBC,QAAgB,EAChBC,SAAiB,EACjBC,QAAgB,EAChBC,QAAgB,EAEsD;EAAA,IADtEC,OAAsB,uEAAG,IAAI;EAE7BC,OAAO,CAACC,GAAG,CACT,8BAA8B,EAC9BN,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,QAAQ,CACT;EACD,OAAOL,IAAI,CAACC,IAAI,CAACC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,OAAO,CAAC;AACpE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,MAAM,GAAG,CACpBP,QAAgB,EAChBC,SAAiB,KACI;EACrB,OAAOH,IAAI,CAACS,MAAM,CAACP,QAAQ,EAAEC,SAAS,CAAC;AACzC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMO,GAAG,GAAIC,GAAW,IAAsB;EACnD,OAAOX,IAAI,CAACU,GAAG,CAACC,GAAG,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAID,GAAe,IAAuB;EACxD,OAAOX,IAAI,CAACY,GAAG,CAACD,GAAG,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,IAAI,GAAG,MAAuB;EACzC,OAAOb,IAAI,CAACa,IAAI,EAAE;AACpB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAG,CAACC,KAAa,EAAEC,KAAa,KAAsB;EACpE,OAAOhB,IAAI,C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AAQ,GAAG,MAAqB;EAC3C,OAAOjD,IAAI,CAACiD,QAAQ,EAAE;AACxB,CAAC"}
@@ -1 +1 @@
1
- export * as fula from './protocols/fula';
1
+ export * as fula from './protocols/fula';
@@ -1,17 +1,28 @@
1
- interface FulaNativeModule {
2
- init: (identity: string | null, //Private key of did identity
3
- storePath: string | null, //You can leave empty
4
- bloxAddr: string) => Promise<[string]>;
5
- get: (key: string) => Promise<string>;
6
- has: (key: Uint8Array) => Promise<boolean>;
7
- push: () => Promise<string>;
8
- put: (content: string, codec: string) => Promise<string>;
9
- mkdir: (path: string) => Promise<string>;
10
- writeFileContent: (path: string, content: string) => Promise<string>;
11
- writeFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
12
- ls: (path: string) => Promise<string>;
13
- readFile: (path: string) => Promise<string>;
14
- shutdown: () => Promise<void>;
15
- }
16
- declare const _default: FulaNativeModule;
17
- export default _default;
1
+ interface FulaNativeModule {
2
+ init: (identity: string, //Private key of did identity
3
+ storePath: string, //You can leave empty
4
+ bloxAddr: string, //Blox multiadddr needs to be manually entered now
5
+ exchange: string, //set to 'noope' for testing
6
+ rootCid: string | null) => Promise<{
7
+ peerId: string;
8
+ rootCid: string;
9
+ private_ref: string;
10
+ }>;
11
+ logout: (identity: string, storePath: string) => Promise<boolean>;
12
+ get: (key: string) => Promise<string>;
13
+ has: (key: Uint8Array) => Promise<boolean>;
14
+ push: () => Promise<string>;
15
+ put: (content: string, codec: string) => Promise<string>;
16
+ mkdir: (path: string) => Promise<string>;
17
+ writeFileContent: (path: string, content: string) => Promise<string>;
18
+ writeFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
19
+ ls: (path: string) => Promise<string>;
20
+ rm: (path: string) => Promise<string>;
21
+ cp: (sourcePath: string, targetPath: string) => Promise<string>;
22
+ mv: (sourcePath: string, targetPath: string) => Promise<string>;
23
+ readFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
24
+ readFileContent: (path: string) => Promise<string>;
25
+ shutdown: () => Promise<void>;
26
+ }
27
+ declare const _default: FulaNativeModule;
28
+ export default _default;
@@ -1,70 +1,99 @@
1
- /**
2
- * Get gets the value corresponding to the given key from the local datastore.
3
- // The key must be a valid ipld.Link.
4
- * @param config
5
- * @returns boolean
6
- */
7
- export declare const init: (identity: string | null, storePath: string | null, bloxAddr: string) => Promise<[string]>;
8
- /**
9
- * Get gets the value corresponding to the given key from the local datastore.
10
- // The key must be a valid ipld.Link.
11
- * @param key
12
- * @returns value
13
- */
14
- export declare const get: (key: string) => Promise<string>;
15
- /**
16
- * Has checks whether the value corresponding to the given key is present in the local datastore.
17
- // The key must be a valid ipld.Link.
18
- * @param key
19
- * @returns boolean
20
- */
21
- export declare const has: (key: Uint8Array) => Promise<boolean>;
22
- /**
23
- * Push requests the given addr to download the root cid from this node.
24
- // The addr must be a valid multiaddr that includes peer ID.
25
- // this function.
26
- * @param addr
27
- * @returns null or error
28
- */
29
- export declare const push: () => Promise<string>;
30
- /**
31
- * Put stores the given key value onto the local datastore.
32
- // The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
33
- // to the given key.
34
- * @param key, value
35
- * @returns null or string
36
- */
37
- export declare const put: (value: string, codec: string) => Promise<string>;
38
- /**
39
- * mkdir creates a directory at the given path.
40
- * @param path
41
- * @returns string: new cid of the root
42
- */
43
- export declare const mkdir: (path: string) => Promise<string>;
44
- /**
45
- * writeFileContent writes content at a given path
46
- * @param path
47
- * @returns string: new cid of the root
48
- */
49
- export declare const writeFileContent: (path: string, content: string) => Promise<string>;
50
- export declare const writeFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
51
- /**
52
- * ls lists the name of files and folders at a given path
53
- * @param path
54
- * @returns string: list of items
55
- * TODO: Findout how is the string and convert to array
56
- */
57
- export declare const ls: (path: string) => Promise<string>;
58
- /**
59
- * readFile reads content of a given path
60
- * @param path
61
- * @returns string: cotent
62
- */
63
- export declare const readFile: (path: string) => Promise<string>;
64
- /**
65
- * Shutdown closes all resources used by Client.
66
- // After calling this function Client must be discarded.
67
- * @param
68
- * @returns
69
- */
70
- export declare const shutdown: () => Promise<void>;
1
+ /**
2
+ * Get gets the value corresponding to the given key from the local datastore.
3
+ // The key must be a valid ipld.Link.
4
+ * @param config
5
+ * @returns boolean
6
+ */
7
+ export declare const init: (identity: string, storePath: string, bloxAddr: string, exchange: string, rootCid?: string | null) => Promise<{
8
+ peerId: string;
9
+ rootCid: string;
10
+ private_ref: string;
11
+ }>;
12
+ /**
13
+ * rm removes all data
14
+ * @param path
15
+ * @returns string: new cid of the root
16
+ */
17
+ export declare const logout: (identity: string, storePath: string) => Promise<boolean>;
18
+ /**
19
+ * Get gets the value corresponding to the given key from the local datastore.
20
+ // The key must be a valid ipld.Link.
21
+ * @param key
22
+ * @returns value
23
+ */
24
+ export declare const get: (key: string) => Promise<string>;
25
+ /**
26
+ * Has checks whether the value corresponding to the given key is present in the local datastore.
27
+ // The key must be a valid ipld.Link.
28
+ * @param key
29
+ * @returns boolean
30
+ */
31
+ export declare const has: (key: Uint8Array) => Promise<boolean>;
32
+ /**
33
+ * Push requests the given addr to download the root cid from this node.
34
+ // The addr must be a valid multiaddr that includes peer ID.
35
+ // this function.
36
+ * @param addr
37
+ * @returns null or error
38
+ */
39
+ export declare const push: () => Promise<string>;
40
+ /**
41
+ * Put stores the given key value onto the local datastore.
42
+ // The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
43
+ // to the given key.
44
+ * @param key, value
45
+ * @returns null or string
46
+ */
47
+ export declare const put: (value: string, codec: string) => Promise<string>;
48
+ /**
49
+ * mkdir creates a directory at the given path.
50
+ * @param path
51
+ * @returns string: new cid of the root
52
+ */
53
+ export declare const mkdir: (path: string) => Promise<string>;
54
+ /**
55
+ * writeFileContent writes content at a given path
56
+ * @param path
57
+ * @returns string: new cid of the root
58
+ */
59
+ export declare const writeFileContent: (path: string, content: string) => Promise<string>;
60
+ export declare const writeFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
61
+ /**
62
+ * ls lists the name of files and folders at a given path
63
+ * @param path
64
+ * @returns string: list of items
65
+ * TODO: Findout how is the string and convert to array
66
+ */
67
+ export declare const ls: (path: string) => Promise<void | JSON>;
68
+ /**
69
+ * rm removes all files and folders at a given path
70
+ * @param path
71
+ * @returns string: new cid of the root
72
+ */
73
+ export declare const rm: (path: string) => Promise<string>;
74
+ /**
75
+ * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
76
+ * @param sourcePath, targetPath
77
+ * @returns string: new cid of the root
78
+ */
79
+ export declare const cp: (sourcePath: string, targetPath: string) => Promise<string>;
80
+ /**
81
+ * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
82
+ * @param sourcePath, targetPath
83
+ * @returns string: new cid of the root
84
+ */
85
+ export declare const mv: (sourcePath: string, targetPath: string) => Promise<string>;
86
+ export declare const readFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
87
+ /**
88
+ * readFile reads content of a given path
89
+ * @param path
90
+ * @returns string: cotent
91
+ */
92
+ export declare const readFileContent: (path: string) => Promise<string>;
93
+ /**
94
+ * Shutdown closes all resources used by Client.
95
+ // After calling this function Client must be discarded.
96
+ * @param
97
+ * @returns
98
+ */
99
+ export declare const shutdown: () => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionland/react-native-fula",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
4
4
  "description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -28,7 +28,7 @@
28
28
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
29
29
  "prepare": "bob build",
30
30
  "release": "release-it",
31
- "example": "yarn --cwd example",
31
+ "example": "set NODE_OPTIONS=--openssl-legacy-provider && yarn --cwd example",
32
32
  "pods": "cd example && pod-install --quiet",
33
33
  "bootstrap": "yarn example && yarn && yarn pods"
34
34
  },
@@ -46,9 +46,6 @@
46
46
  "homepage": "https://github.com/functionland/react-native-fula#readme",
47
47
  "publishConfig": {
48
48
  "registry": "https://registry.npmjs.org"
49
- },
50
- "dependencies": {
51
-
52
49
  },
53
50
  "devDependencies": {
54
51
  "@babel/plugin-proposal-export-namespace-from": "^7.16.7",
@@ -57,7 +54,7 @@
57
54
  "@release-it/conventional-changelog": "^2.0.0",
58
55
  "@types/jest": "^26.0.0",
59
56
  "@types/react": "^16.9.19",
60
- "@types/react-native": "0.62.13",
57
+ "@types/react-native": "0.70.8",
61
58
  "commitlint": "^11.0.0",
62
59
  "eslint": "^7.2.0",
63
60
  "eslint-config-prettier": "^7.0.0",
@@ -66,8 +63,8 @@
66
63
  "jest": "^26.0.1",
67
64
  "pod-install": "^0.1.0",
68
65
  "prettier": "^2.0.5",
69
- "react": "16.13.1",
70
- "react-native": "0.63.4",
66
+ "react": "^18.1.0",
67
+ "react-native": "0.70.6",
71
68
  "react-native-builder-bob": "^0.18.0",
72
69
  "release-it": "^14.2.2",
73
70
  "typescript": "^4.1.3"