@functionland/react-native-fula 0.4.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/LICENSE +21 -0
- package/README.md +35 -0
- 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/dependencies-accessors/gc.properties +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/fileChanges/last-build.bin +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/7.5.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +19 -0
- package/android/.idea/jarRepositories.xml +50 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +67 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradle.properties +1 -0
- package/android/gradlew +240 -0
- package/android/gradlew.bat +91 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/land/fx/fula/ConfigRef.java +7 -0
- package/android/src/main/java/land/fx/fula/Cryptography.java +47 -0
- package/android/src/main/java/land/fx/fula/FulaModule.java +443 -0
- package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -0
- package/android/src/main/java/land/fx/fula/SharedPreferenceHelper.java +65 -0
- package/android/src/main/java/land/fx/fula/StaticHelper.java +13 -0
- package/android/src/main/java/land/fx/fula/ThreadUtils.java +42 -0
- package/ios/FulaModule.h +10 -0
- package/ios/FulaModule.m +149 -0
- package/ios/FulaModule.xcodeproj/project.pbxproj +267 -0
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/interfaces/fulaNativeModule.js +19 -0
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -0
- package/lib/commonjs/protocols/fula.js +130 -0
- package/lib/commonjs/protocols/fula.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/interfaces/fulaNativeModule.js +12 -0
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -0
- package/lib/module/protocols/fula.js +113 -0
- package/lib/module/protocols/fula.js.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +17 -0
- package/lib/typescript/protocols/fula.d.ts +70 -0
- package/package.json +152 -0
- package/react-native-fula.podspec +19 -0
- package/src/index.tsx +1 -0
- package/src/interfaces/fulaNativeModule.ts +39 -0
- package/src/protocols/fula.ts +116 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import Fula from '../interfaces/fulaNativeModule';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get gets the value corresponding to the given key from the local datastore.
|
|
5
|
+
// The key must be a valid ipld.Link.
|
|
6
|
+
* @param config
|
|
7
|
+
* @returns boolean
|
|
8
|
+
*/
|
|
9
|
+
export const init = (identity, storePath, bloxAddr) => {
|
|
10
|
+
console.log('init in react-native started', identity, storePath, bloxAddr);
|
|
11
|
+
return Fula.init(identity, storePath, bloxAddr);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get gets the value corresponding to the given key from the local datastore.
|
|
16
|
+
// The key must be a valid ipld.Link.
|
|
17
|
+
* @param key
|
|
18
|
+
* @returns value
|
|
19
|
+
*/
|
|
20
|
+
export const get = key => {
|
|
21
|
+
return Fula.get(key);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Has checks whether the value corresponding to the given key is present in the local datastore.
|
|
26
|
+
// The key must be a valid ipld.Link.
|
|
27
|
+
* @param key
|
|
28
|
+
* @returns boolean
|
|
29
|
+
*/
|
|
30
|
+
export const has = key => {
|
|
31
|
+
return Fula.has(key);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Push requests the given addr to download the root cid from this node.
|
|
36
|
+
// The addr must be a valid multiaddr that includes peer ID.
|
|
37
|
+
// this function.
|
|
38
|
+
* @param addr
|
|
39
|
+
* @returns null or error
|
|
40
|
+
*/
|
|
41
|
+
export const push = () => {
|
|
42
|
+
return Fula.push();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Put stores the given key value onto the local datastore.
|
|
47
|
+
// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
|
|
48
|
+
// to the given key.
|
|
49
|
+
* @param key, value
|
|
50
|
+
* @returns null or string
|
|
51
|
+
*/
|
|
52
|
+
export const put = (value, codec) => {
|
|
53
|
+
return Fula.put(value, codec);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* mkdir creates a directory at the given path.
|
|
58
|
+
* @param path
|
|
59
|
+
* @returns string: new cid of the root
|
|
60
|
+
*/
|
|
61
|
+
export const mkdir = path => {
|
|
62
|
+
return Fula.mkdir(path);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* writeFileContent writes content at a given path
|
|
67
|
+
* @param path
|
|
68
|
+
* @returns string: new cid of the root
|
|
69
|
+
*/
|
|
70
|
+
export const writeFileContent = (path, content) => {
|
|
71
|
+
return Fula.writeFileContent(path, content);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
76
|
+
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
77
|
+
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
78
|
+
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
79
|
+
// Returns: new cid of the root after this file is placed in the tree
|
|
80
|
+
*/
|
|
81
|
+
export const writeFile = (fulaTargetFilename, localFilename) => {
|
|
82
|
+
return Fula.writeFile(fulaTargetFilename, localFilename);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* ls lists the name of files and folders at a given path
|
|
87
|
+
* @param path
|
|
88
|
+
* @returns string: list of items
|
|
89
|
+
* TODO: Findout how is the string and convert to array
|
|
90
|
+
*/
|
|
91
|
+
export const ls = path => {
|
|
92
|
+
return Fula.ls(path);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* readFile reads content of a given path
|
|
97
|
+
* @param path
|
|
98
|
+
* @returns string: cotent
|
|
99
|
+
*/
|
|
100
|
+
export const readFile = path => {
|
|
101
|
+
return Fula.readFile(path);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Shutdown closes all resources used by Client.
|
|
106
|
+
// After calling this function Client must be discarded.
|
|
107
|
+
* @param
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
export const shutdown = () => {
|
|
111
|
+
return Fula.shutdown();
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=fula.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as fula from './protocols/fula';
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,70 @@
|
|
|
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>;
|
package/package.json
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@functionland/react-native-fula",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"!example/",
|
|
17
|
+
"react-native-fula.podspec",
|
|
18
|
+
"!lib/typescript/example",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!ios/build",
|
|
21
|
+
"!**/__tests__",
|
|
22
|
+
"!**/__fixtures__",
|
|
23
|
+
"!**/__mocks__"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"typescript": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
29
|
+
"prepare": "bob build",
|
|
30
|
+
"release": "release-it",
|
|
31
|
+
"example": "yarn --cwd example",
|
|
32
|
+
"pods": "cd example && pod-install --quiet",
|
|
33
|
+
"bootstrap": "yarn example && yarn && yarn pods"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"react-native",
|
|
37
|
+
"ios",
|
|
38
|
+
"android"
|
|
39
|
+
],
|
|
40
|
+
"repository": "https://github.com/functionland/react-native-fula",
|
|
41
|
+
"author": "Ehsan Shariati <ehsan6sha@gmail.com> (https://github.com/ehsan6sha)",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/functionland/react-native-fula/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/functionland/react-native-fula#readme",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@babel/plugin-proposal-export-namespace-from": "^7.16.7",
|
|
55
|
+
"@commitlint/config-conventional": "^11.0.0",
|
|
56
|
+
"@react-native-community/eslint-config": "^2.0.0",
|
|
57
|
+
"@release-it/conventional-changelog": "^2.0.0",
|
|
58
|
+
"@types/jest": "^26.0.0",
|
|
59
|
+
"@types/react": "^16.9.19",
|
|
60
|
+
"@types/react-native": "0.62.13",
|
|
61
|
+
"commitlint": "^11.0.0",
|
|
62
|
+
"eslint": "^7.2.0",
|
|
63
|
+
"eslint-config-prettier": "^7.0.0",
|
|
64
|
+
"eslint-plugin-prettier": "^3.1.3",
|
|
65
|
+
"husky": "^6.0.0",
|
|
66
|
+
"jest": "^26.0.1",
|
|
67
|
+
"pod-install": "^0.1.0",
|
|
68
|
+
"prettier": "^2.0.5",
|
|
69
|
+
"react": "16.13.1",
|
|
70
|
+
"react-native": "0.63.4",
|
|
71
|
+
"react-native-builder-bob": "^0.18.0",
|
|
72
|
+
"release-it": "^14.2.2",
|
|
73
|
+
"typescript": "^4.1.3"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"react": "*",
|
|
77
|
+
"react-native": "*"
|
|
78
|
+
},
|
|
79
|
+
"jest": {
|
|
80
|
+
"preset": "react-native",
|
|
81
|
+
"modulePathIgnorePatterns": [
|
|
82
|
+
"<rootDir>/example/node_modules",
|
|
83
|
+
"<rootDir>/lib/"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"commitlint": {
|
|
87
|
+
"extends": [
|
|
88
|
+
"@commitlint/config-conventional"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"release-it": {
|
|
92
|
+
"git": {
|
|
93
|
+
"commitMessage": "chore: release ${version}",
|
|
94
|
+
"tagName": "v${version}"
|
|
95
|
+
},
|
|
96
|
+
"npm": {
|
|
97
|
+
"publish": true
|
|
98
|
+
},
|
|
99
|
+
"github": {
|
|
100
|
+
"release": true
|
|
101
|
+
},
|
|
102
|
+
"plugins": {
|
|
103
|
+
"@release-it/conventional-changelog": {
|
|
104
|
+
"preset": "angular"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"eslintConfig": {
|
|
109
|
+
"root": true,
|
|
110
|
+
"extends": [
|
|
111
|
+
"@react-native-community",
|
|
112
|
+
"prettier"
|
|
113
|
+
],
|
|
114
|
+
"rules": {
|
|
115
|
+
"prettier/prettier": [
|
|
116
|
+
"error",
|
|
117
|
+
{
|
|
118
|
+
"quoteProps": "consistent",
|
|
119
|
+
"singleQuote": true,
|
|
120
|
+
"tabWidth": 2,
|
|
121
|
+
"trailingComma": "es5",
|
|
122
|
+
"useTabs": false
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"eslintIgnore": [
|
|
128
|
+
"node_modules/",
|
|
129
|
+
"lib/"
|
|
130
|
+
],
|
|
131
|
+
"prettier": {
|
|
132
|
+
"quoteProps": "consistent",
|
|
133
|
+
"singleQuote": true,
|
|
134
|
+
"tabWidth": 2,
|
|
135
|
+
"trailingComma": "es5",
|
|
136
|
+
"useTabs": false
|
|
137
|
+
},
|
|
138
|
+
"react-native-builder-bob": {
|
|
139
|
+
"source": "src",
|
|
140
|
+
"output": "lib",
|
|
141
|
+
"targets": [
|
|
142
|
+
"commonjs",
|
|
143
|
+
"module",
|
|
144
|
+
[
|
|
145
|
+
"typescript",
|
|
146
|
+
{
|
|
147
|
+
"project": "tsconfig.build.json"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +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
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as fula from './protocols/fula';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface FulaNativeModule {
|
|
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]>;
|
|
9
|
+
get: (key: string) => Promise<string>;
|
|
10
|
+
has: (key: Uint8Array) => Promise<boolean>;
|
|
11
|
+
push: () => Promise<string>;
|
|
12
|
+
put: (content: string, codec: string) => Promise<string>;
|
|
13
|
+
mkdir: (path: string) => Promise<string>;
|
|
14
|
+
writeFileContent: (path: string, content: string) => Promise<string>;
|
|
15
|
+
writeFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
|
|
16
|
+
ls: (path: string) => Promise<string>;
|
|
17
|
+
readFile: (path: string) => Promise<string>;
|
|
18
|
+
|
|
19
|
+
shutdown: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const LINKING_ERROR =
|
|
23
|
+
`The package 'react-native-fula' doesn't seem to be linked. Make sure: \n\n` +
|
|
24
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
25
|
+
'- You rebuilt the app after installing the package\n' +
|
|
26
|
+
'- You are not using Expo managed workflow\n';
|
|
27
|
+
|
|
28
|
+
const Fula = NativeModules.FulaModule
|
|
29
|
+
? NativeModules.FulaModule
|
|
30
|
+
: new Proxy(
|
|
31
|
+
{},
|
|
32
|
+
{
|
|
33
|
+
get() {
|
|
34
|
+
throw new Error(LINKING_ERROR);
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export default Fula as FulaNativeModule;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import Fula from '../interfaces/fulaNativeModule';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get gets the value corresponding to the given key from the local datastore.
|
|
5
|
+
// The key must be a valid ipld.Link.
|
|
6
|
+
* @param config
|
|
7
|
+
* @returns boolean
|
|
8
|
+
*/
|
|
9
|
+
export const init = (
|
|
10
|
+
identity: string | null, //privateKey of did identity
|
|
11
|
+
storePath: string | null,
|
|
12
|
+
bloxAddr: string,
|
|
13
|
+
): Promise<[string]> => {
|
|
14
|
+
console.log('init in react-native started',identity, storePath, bloxAddr);
|
|
15
|
+
return Fula.init(identity, storePath, bloxAddr);
|
|
16
|
+
};
|
|
17
|
+
|
|
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 const get = (key: string): Promise<string> => {
|
|
25
|
+
return Fula.get(key);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Has checks whether the value corresponding to the given key is present in the local datastore.
|
|
30
|
+
// The key must be a valid ipld.Link.
|
|
31
|
+
* @param key
|
|
32
|
+
* @returns boolean
|
|
33
|
+
*/
|
|
34
|
+
export const has = (key: Uint8Array): Promise<boolean> => {
|
|
35
|
+
return Fula.has(key);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Push requests the given addr to download the root cid from this node.
|
|
40
|
+
// The addr must be a valid multiaddr that includes peer ID.
|
|
41
|
+
// this function.
|
|
42
|
+
* @param addr
|
|
43
|
+
* @returns null or error
|
|
44
|
+
*/
|
|
45
|
+
export const push = (): Promise<string> => {
|
|
46
|
+
return Fula.push();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Put stores the given key value onto the local datastore.
|
|
51
|
+
// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
|
|
52
|
+
// to the given key.
|
|
53
|
+
* @param key, value
|
|
54
|
+
* @returns null or string
|
|
55
|
+
*/
|
|
56
|
+
export const put = (value: string, codec: string): Promise<string> => {
|
|
57
|
+
return Fula.put(value, codec);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* mkdir creates a directory at the given path.
|
|
62
|
+
* @param path
|
|
63
|
+
* @returns string: new cid of the root
|
|
64
|
+
*/
|
|
65
|
+
export const mkdir = (path: string): Promise<string> => {
|
|
66
|
+
return Fula.mkdir(path);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* writeFileContent writes content at a given path
|
|
71
|
+
* @param path
|
|
72
|
+
* @returns string: new cid of the root
|
|
73
|
+
*/
|
|
74
|
+
export const writeFileContent = (path: string, content: string): Promise<string> => {
|
|
75
|
+
return Fula.writeFileContent(path, content);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
80
|
+
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
81
|
+
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
82
|
+
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
83
|
+
// Returns: new cid of the root after this file is placed in the tree
|
|
84
|
+
*/
|
|
85
|
+
export const writeFile = (fulaTargetFilename: string, localFilename: string): Promise<string> => {
|
|
86
|
+
return Fula.writeFile(fulaTargetFilename, localFilename);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ls lists the name of files and folders at a given path
|
|
91
|
+
* @param path
|
|
92
|
+
* @returns string: list of items
|
|
93
|
+
* TODO: Findout how is the string and convert to array
|
|
94
|
+
*/
|
|
95
|
+
export const ls = (path: string): Promise<string> => {
|
|
96
|
+
return Fula.ls(path);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* readFile reads content of a given path
|
|
101
|
+
* @param path
|
|
102
|
+
* @returns string: cotent
|
|
103
|
+
*/
|
|
104
|
+
export const readFile = (path: string): Promise<string> => {
|
|
105
|
+
return Fula.readFile(path);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Shutdown closes all resources used by Client.
|
|
110
|
+
// After calling this function Client must be discarded.
|
|
111
|
+
* @param
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
export const shutdown = (): Promise<void> => {
|
|
115
|
+
return Fula.shutdown();
|
|
116
|
+
};
|