@functionland/react-native-fula 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -9
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build.gradle +67 -67
- package/android/src/main/java/land/fx/fula/FulaModule.java +480 -443
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/protocols/fula.js +84 -61
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/protocols/fula.js +81 -60
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +5 -2
- package/lib/typescript/protocols/fula.d.ts +9 -2
- package/package.json +152 -152
- package/src/interfaces/fulaNativeModule.ts +42 -39
- package/src/protocols/fula.ts +138 -116
package/package.json
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@functionland/react-native-fula",
|
|
3
|
-
"version": "0.4.
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@functionland/react-native-fula",
|
|
3
|
+
"version": "0.4.2",
|
|
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
|
+
}
|
|
@@ -1,39 +1,42 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
exchange: string //set to 'noope' for testing
|
|
9
|
+
) => Promise<[string, string, string]>;
|
|
10
|
+
get: (key: string) => Promise<string>;
|
|
11
|
+
has: (key: Uint8Array) => Promise<boolean>;
|
|
12
|
+
push: () => Promise<string>;
|
|
13
|
+
put: (content: string, codec: string) => Promise<string>;
|
|
14
|
+
mkdir: (path: string) => Promise<string>;
|
|
15
|
+
writeFileContent: (path: string, content: string) => Promise<string>;
|
|
16
|
+
writeFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
|
|
17
|
+
ls: (path: string) => Promise<string>;
|
|
18
|
+
rm: (path: string) => Promise<string>;
|
|
19
|
+
readFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
|
|
20
|
+
readFileContent: (path: string) => Promise<string>;
|
|
21
|
+
|
|
22
|
+
shutdown: () => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const LINKING_ERROR =
|
|
26
|
+
`The package 'react-native-fula' doesn't seem to be linked. Make sure: \n\n` +
|
|
27
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
28
|
+
'- You rebuilt the app after installing the package\n' +
|
|
29
|
+
'- You are not using Expo managed workflow\n';
|
|
30
|
+
|
|
31
|
+
const Fula = NativeModules.FulaModule
|
|
32
|
+
? NativeModules.FulaModule
|
|
33
|
+
: new Proxy(
|
|
34
|
+
{},
|
|
35
|
+
{
|
|
36
|
+
get() {
|
|
37
|
+
throw new Error(LINKING_ERROR);
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export default Fula as FulaNativeModule;
|
package/src/protocols/fula.ts
CHANGED
|
@@ -1,116 +1,138 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
+
|
|
10
|
+
export const init = (
|
|
11
|
+
identity: string, //privateKey of did identity
|
|
12
|
+
storePath: string,
|
|
13
|
+
bloxAddr: string,
|
|
14
|
+
exchange: string
|
|
15
|
+
): Promise<[string, string, string]> => {
|
|
16
|
+
console.log('init in react-native started',identity, storePath, bloxAddr, exchange);
|
|
17
|
+
return Fula.init(identity, storePath, bloxAddr, exchange);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get gets the value corresponding to the given key from the local datastore.
|
|
22
|
+
// The key must be a valid ipld.Link.
|
|
23
|
+
* @param key
|
|
24
|
+
* @returns value
|
|
25
|
+
*/
|
|
26
|
+
export const get = (key: string): Promise<string> => {
|
|
27
|
+
return Fula.get(key);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Has checks whether the value corresponding to the given key is present in the local datastore.
|
|
32
|
+
// The key must be a valid ipld.Link.
|
|
33
|
+
* @param key
|
|
34
|
+
* @returns boolean
|
|
35
|
+
*/
|
|
36
|
+
export const has = (key: Uint8Array): Promise<boolean> => {
|
|
37
|
+
return Fula.has(key);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Push requests the given addr to download the root cid from this node.
|
|
42
|
+
// The addr must be a valid multiaddr that includes peer ID.
|
|
43
|
+
// this function.
|
|
44
|
+
* @param addr
|
|
45
|
+
* @returns null or error
|
|
46
|
+
*/
|
|
47
|
+
export const push = (): Promise<string> => {
|
|
48
|
+
return Fula.push();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Put stores the given key value onto the local datastore.
|
|
53
|
+
// The key must be a valid ipld.Link and the value must be the valid encoded ipld.Node corresponding
|
|
54
|
+
// to the given key.
|
|
55
|
+
* @param key, value
|
|
56
|
+
* @returns null or string
|
|
57
|
+
*/
|
|
58
|
+
export const put = (value: string, codec: string): Promise<string> => {
|
|
59
|
+
return Fula.put(value, codec);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* mkdir creates a directory at the given path.
|
|
64
|
+
* @param path
|
|
65
|
+
* @returns string: new cid of the root
|
|
66
|
+
*/
|
|
67
|
+
export const mkdir = (path: string): Promise<string> => {
|
|
68
|
+
return Fula.mkdir(path);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* writeFileContent writes content at a given path
|
|
73
|
+
* @param path
|
|
74
|
+
* @returns string: new cid of the root
|
|
75
|
+
*/
|
|
76
|
+
export const writeFileContent = (path: string, content: string): Promise<string> => {
|
|
77
|
+
return Fula.writeFileContent(path, content);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
82
|
+
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
83
|
+
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
84
|
+
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
85
|
+
// Returns: new cid of the root after this file is placed in the tree
|
|
86
|
+
*/
|
|
87
|
+
export const writeFile = (fulaTargetFilename: string, localFilename: string): Promise<string> => {
|
|
88
|
+
return Fula.writeFile(fulaTargetFilename, localFilename);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* ls lists the name of files and folders at a given path
|
|
93
|
+
* @param path
|
|
94
|
+
* @returns string: list of items
|
|
95
|
+
* TODO: Findout how is the string and convert to array
|
|
96
|
+
*/
|
|
97
|
+
export const ls = (path: string): Promise<string> => {
|
|
98
|
+
return Fula.ls(path);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* rm removes all files and folders at a given path
|
|
103
|
+
* @param path
|
|
104
|
+
* @returns string: new cid of the root
|
|
105
|
+
*/
|
|
106
|
+
export const rm = (path: string): Promise<string> => {
|
|
107
|
+
return Fula.rm(path);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/*
|
|
111
|
+
// reads content of the file form localFilename (should include full absolute path to local file with read permission
|
|
112
|
+
// writes content to the specified location by fulaTargetFilename in Fula filesystem
|
|
113
|
+
// fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
|
|
114
|
+
// localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
|
|
115
|
+
// Returns: new cid of the root after this file is placed in the tree
|
|
116
|
+
*/
|
|
117
|
+
export const readFile = (fulaTargetFilename: string, localFilename: string): Promise<string> => {
|
|
118
|
+
return Fula.readFile(fulaTargetFilename, localFilename);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* readFile reads content of a given path
|
|
123
|
+
* @param path
|
|
124
|
+
* @returns string: cotent
|
|
125
|
+
*/
|
|
126
|
+
export const readFileContent = (path: string): Promise<string> => {
|
|
127
|
+
return Fula.readFileContent(path);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Shutdown closes all resources used by Client.
|
|
132
|
+
// After calling this function Client must be discarded.
|
|
133
|
+
* @param
|
|
134
|
+
* @returns
|
|
135
|
+
*/
|
|
136
|
+
export const shutdown = (): Promise<void> => {
|
|
137
|
+
return Fula.shutdown();
|
|
138
|
+
};
|