@functionland/react-native-fula 1.8.0 → 1.9.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 (40) hide show
  1. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  3. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.6/checksums/checksums.lock +0 -0
  5. package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
  6. package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
  7. package/android/.gradle/7.6/executionHistory/executionHistory.bin +0 -0
  8. package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
  9. package/android/.gradle/7.6/fileHashes/fileHashes.bin +0 -0
  10. package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
  11. package/android/.gradle/7.6/fileHashes/resourceHashesCache.bin +0 -0
  12. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  13. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  14. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  15. package/android/.gradle/file-system.probe +0 -0
  16. package/android/build.gradle +69 -69
  17. package/android/src/main/java/land/fx/fula/FulaModule.java +1384 -1368
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  20. package/lib/commonjs/protocols/blockchain.js +12 -12
  21. package/lib/commonjs/protocols/blockchain.js.map +1 -1
  22. package/lib/commonjs/protocols/fxblox.js +23 -4
  23. package/lib/commonjs/protocols/fxblox.js.map +1 -1
  24. package/lib/commonjs/types/fxblox.js.map +1 -1
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  27. package/lib/module/protocols/blockchain.js +12 -12
  28. package/lib/module/protocols/blockchain.js.map +1 -1
  29. package/lib/module/protocols/fxblox.js +21 -3
  30. package/lib/module/protocols/fxblox.js.map +1 -1
  31. package/lib/module/types/fxblox.js.map +1 -1
  32. package/lib/typescript/interfaces/fulaNativeModule.d.ts +1 -0
  33. package/lib/typescript/protocols/fxblox.d.ts +1 -0
  34. package/lib/typescript/types/fxblox.d.ts +4 -0
  35. package/package.json +157 -157
  36. package/src/index.tsx +4 -4
  37. package/src/interfaces/fulaNativeModule.ts +119 -87
  38. package/src/protocols/blockchain.ts +318 -274
  39. package/src/protocols/fxblox.ts +49 -28
  40. package/src/types/fxblox.ts +8 -4
@@ -4,3 +4,4 @@ import type * as BType from '../types/fxblox';
4
4
  * @returns json{status:true if success, false if fails; msg: error message or success log}
5
5
  */
6
6
  export declare const wifiRemoveall: () => Promise<BType.wifiRemoveallResponse>;
7
+ export declare const reboot: () => Promise<BType.rebootResponse>;
@@ -2,3 +2,7 @@ export interface wifiRemoveallResponse {
2
2
  status: boolean;
3
3
  msg: string;
4
4
  }
5
+ export interface rebootResponse {
6
+ status: boolean;
7
+ msg: string;
8
+ }
package/package.json CHANGED
@@ -1,157 +1,157 @@
1
- {
2
- "name": "@functionland/react-native-fula",
3
- "version": "1.8.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": "set NODE_OPTIONS='' && 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
- "devDependencies": {
51
- "@babel/plugin-proposal-export-namespace-from": "^7.16.7",
52
- "@commitlint/config-conventional": "^11.0.0",
53
- "@react-native-community/eslint-config": "^2.0.0",
54
- "@release-it/conventional-changelog": "^2.0.0",
55
- "@types/jest": "^26.0.0",
56
- "@types/react": "^16.9.19",
57
- "@types/react-native": "0.70.8",
58
- "commitlint": "^11.0.0",
59
- "eslint": "^7.2.0",
60
- "eslint-config-prettier": "^7.0.0",
61
- "eslint-plugin-prettier": "^3.1.3",
62
- "husky": "^6.0.0",
63
- "jest": "^26.0.1",
64
- "pod-install": "^0.1.0",
65
- "prettier": "^2.0.5",
66
- "react": "^18.1.0",
67
- "react-native": "0.70.6",
68
- "react-native-builder-bob": "^0.18.0",
69
- "release-it": "^14.2.2",
70
- "typescript": "^4.1.3"
71
- },
72
- "peerDependencies": {
73
- "@babel/core": "^7.0.0-0",
74
- "@babel/preset-env": "^7.1.6",
75
- "react": "*",
76
- "react-native": "*"
77
- },
78
- "jest": {
79
- "preset": "react-native",
80
- "modulePathIgnorePatterns": [
81
- "<rootDir>/example/node_modules",
82
- "<rootDir>/lib/"
83
- ]
84
- },
85
- "commitlint": {
86
- "extends": [
87
- "@commitlint/config-conventional"
88
- ]
89
- },
90
- "release-it": {
91
- "git": {
92
- "commitMessage": "chore: release ${version}",
93
- "tagName": "v${version}"
94
- },
95
- "npm": {
96
- "publish": true
97
- },
98
- "github": {
99
- "release": true
100
- },
101
- "plugins": {
102
- "@release-it/conventional-changelog": {
103
- "preset": "angular"
104
- }
105
- }
106
- },
107
- "eslintConfig": {
108
- "root": true,
109
- "extends": [
110
- "@react-native-community",
111
- "prettier"
112
- ],
113
- "rules": {
114
- "prettier/prettier": [
115
- "error",
116
- {
117
- "quoteProps": "consistent",
118
- "singleQuote": true,
119
- "tabWidth": 2,
120
- "trailingComma": "es5",
121
- "useTabs": false
122
- }
123
- ]
124
- }
125
- },
126
- "eslintIgnore": [
127
- "node_modules/",
128
- "lib/"
129
- ],
130
- "prettier": {
131
- "quoteProps": "consistent",
132
- "singleQuote": true,
133
- "tabWidth": 2,
134
- "trailingComma": "es5",
135
- "useTabs": false
136
- },
137
- "react-native-builder-bob": {
138
- "source": "src",
139
- "output": "lib",
140
- "targets": [
141
- "commonjs",
142
- "module",
143
- [
144
- "typescript",
145
- {
146
- "project": "tsconfig.build.json"
147
- }
148
- ]
149
- ]
150
- },
151
- "dependencies": {
152
- "@polkadot/api": "^9.11.3",
153
- "@polkadot/keyring": "^10.2.6",
154
- "@polkadot/util": "^10.2.6",
155
- "@polkadot/util-crypto": "^10.2.6"
156
- }
157
- }
1
+ {
2
+ "name": "@functionland/react-native-fula",
3
+ "version": "1.9.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": "set NODE_OPTIONS='' && 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
+ "devDependencies": {
51
+ "@babel/plugin-proposal-export-namespace-from": "^7.16.7",
52
+ "@commitlint/config-conventional": "^11.0.0",
53
+ "@react-native-community/eslint-config": "^2.0.0",
54
+ "@release-it/conventional-changelog": "^2.0.0",
55
+ "@types/jest": "^26.0.0",
56
+ "@types/react": "^16.9.19",
57
+ "@types/react-native": "0.70.8",
58
+ "commitlint": "^11.0.0",
59
+ "eslint": "^7.2.0",
60
+ "eslint-config-prettier": "^7.0.0",
61
+ "eslint-plugin-prettier": "^3.1.3",
62
+ "husky": "^6.0.0",
63
+ "jest": "^26.0.1",
64
+ "pod-install": "^0.1.0",
65
+ "prettier": "^2.0.5",
66
+ "react": "^18.1.0",
67
+ "react-native": "0.70.6",
68
+ "react-native-builder-bob": "^0.18.0",
69
+ "release-it": "^14.2.2",
70
+ "typescript": "^4.1.3"
71
+ },
72
+ "peerDependencies": {
73
+ "@babel/core": "^7.0.0-0",
74
+ "@babel/preset-env": "^7.1.6",
75
+ "react": "*",
76
+ "react-native": "*"
77
+ },
78
+ "jest": {
79
+ "preset": "react-native",
80
+ "modulePathIgnorePatterns": [
81
+ "<rootDir>/example/node_modules",
82
+ "<rootDir>/lib/"
83
+ ]
84
+ },
85
+ "commitlint": {
86
+ "extends": [
87
+ "@commitlint/config-conventional"
88
+ ]
89
+ },
90
+ "release-it": {
91
+ "git": {
92
+ "commitMessage": "chore: release ${version}",
93
+ "tagName": "v${version}"
94
+ },
95
+ "npm": {
96
+ "publish": true
97
+ },
98
+ "github": {
99
+ "release": true
100
+ },
101
+ "plugins": {
102
+ "@release-it/conventional-changelog": {
103
+ "preset": "angular"
104
+ }
105
+ }
106
+ },
107
+ "eslintConfig": {
108
+ "root": true,
109
+ "extends": [
110
+ "@react-native-community",
111
+ "prettier"
112
+ ],
113
+ "rules": {
114
+ "prettier/prettier": [
115
+ "error",
116
+ {
117
+ "quoteProps": "consistent",
118
+ "singleQuote": true,
119
+ "tabWidth": 2,
120
+ "trailingComma": "es5",
121
+ "useTabs": false
122
+ }
123
+ ]
124
+ }
125
+ },
126
+ "eslintIgnore": [
127
+ "node_modules/",
128
+ "lib/"
129
+ ],
130
+ "prettier": {
131
+ "quoteProps": "consistent",
132
+ "singleQuote": true,
133
+ "tabWidth": 2,
134
+ "trailingComma": "es5",
135
+ "useTabs": false
136
+ },
137
+ "react-native-builder-bob": {
138
+ "source": "src",
139
+ "output": "lib",
140
+ "targets": [
141
+ "commonjs",
142
+ "module",
143
+ [
144
+ "typescript",
145
+ {
146
+ "project": "tsconfig.build.json"
147
+ }
148
+ ]
149
+ ]
150
+ },
151
+ "dependencies": {
152
+ "@polkadot/api": "^9.11.3",
153
+ "@polkadot/keyring": "^10.2.6",
154
+ "@polkadot/util": "^10.2.6",
155
+ "@polkadot/util-crypto": "^10.2.6"
156
+ }
157
+ }
package/src/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- export * as fula from './protocols/fula';
2
- export * as blockchain from './protocols/blockchain';
3
- export * as chainApi from './protocols/chain-api';
4
- export * as fxblox from './protocols/fxblox';
1
+ export * as fula from './protocols/fula';
2
+ export * as blockchain from './protocols/blockchain';
3
+ export * as chainApi from './protocols/chain-api';
4
+ export * as fxblox from './protocols/fxblox';
@@ -1,87 +1,119 @@
1
- import { NativeModules, Platform } from 'react-native';
2
-
3
- interface FulaNativeModule {
4
- init: (
5
- identity: string, //Private key of did identity
6
- storePath: string, //You can leave empty
7
- bloxAddr: string, //Blox multiadddr needs to be manually entered now
8
- exchange: string, //set to 'noope' for testing
9
- autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
10
- rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
11
- useRelay: boolean | null, // if true it forces the use of relay
12
- refresh: boolean // if true it forces to refresh the fula object
13
- ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;
14
- newClient: (
15
- identity: string, //Private key of did identity
16
- storePath: string, //You can leave empty
17
- bloxAddr: string, //Blox multiadddr needs to be manually entered now
18
- exchange: string, //set to 'noope' for testing
19
- autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
20
- useRelay: boolean | null, // if true it forces the use of relay
21
- refresh: boolean // if true it forces to refresh the fula object
22
- ) => Promise<string>;
23
- isReady: (filesystemCheck: boolean) => Promise<boolean>;
24
- logout: (identity: string, storePath: string) => Promise<boolean>;
25
- checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
26
- checkConnection: (timeout: number) => Promise<boolean>;
27
- get: (key: string) => Promise<string>;
28
- has: (key: Uint8Array) => Promise<boolean>;
29
- push: () => Promise<string>;
30
- put: (content: string, codec: string) => Promise<string>;
31
- mkdir: (path: string) => Promise<string>;
32
- writeFileContent: (path: string, content: string) => Promise<string>;
33
- writeFile: (
34
- fulaTargetFilename: string,
35
- localFilename: string
36
- ) => Promise<string>;
37
- ls: (path: string) => Promise<string>;
38
- rm: (path: string) => Promise<string>;
39
- cp: (sourcePath: string, targetPath: string) => Promise<string>;
40
- mv: (sourcePath: string, targetPath: string) => Promise<string>;
41
- readFile: (
42
- fulaTargetFilename: string,
43
- localFilename: string
44
- ) => Promise<string>;
45
- readFileContent: (path: string) => Promise<string>;
46
- setAuth: (peerId: string, allow: boolean) => Promise<boolean>;
47
-
48
- shutdown: () => Promise<void>;
49
-
50
- //Blockchain related functions
51
- createAccount: (seed: string) => Promise<string>;
52
- checkAccountExists: (account: string) => Promise<string>;
53
- createPool: (seed: string, poolName: string) => Promise<string>;
54
- listPools: () => Promise<string>;
55
- joinPool: (seed: string, poolID: number) => Promise<string>;
56
- leavePool: (seed: string, poolID: number) => Promise<string>;
57
- cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;
58
- listPoolJoinRequests: (poolID: number) => Promise<string>;
59
- votePoolJoinRequest: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;
60
- newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;
61
- newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;
62
- listAvailableReplicationRequests: (poolID: number) => Promise<string>;
63
- removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;
64
- removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;
65
- removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;
66
- bloxFreeSpace: () => Promise<string>;
67
- wifiRemoveall: () => Promise<string>;
68
- }
69
-
70
- const LINKING_ERROR =
71
- `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \n\n` +
72
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
73
- '- You rebuilt the app after installing the package\n' +
74
- '- You are not using Expo managed workflow\n';
75
-
76
- const Fula = NativeModules.FulaModule
77
- ? NativeModules.FulaModule
78
- : new Proxy(
79
- {},
80
- {
81
- get() {
82
- throw new Error(LINKING_ERROR);
83
- },
84
- }
85
- );
86
-
87
- export default Fula as FulaNativeModule;
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ interface FulaNativeModule {
4
+ init: (
5
+ identity: string, //Private key of did identity
6
+ storePath: string, //You can leave empty
7
+ bloxAddr: string, //Blox multiadddr needs to be manually entered now
8
+ exchange: string, //set to 'noope' for testing
9
+ autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
10
+ rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
11
+ useRelay: boolean | null, // if true it forces the use of relay
12
+ refresh: boolean // if true it forces to refresh the fula object
13
+ ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;
14
+ newClient: (
15
+ identity: string, //Private key of did identity
16
+ storePath: string, //You can leave empty
17
+ bloxAddr: string, //Blox multiadddr needs to be manually entered now
18
+ exchange: string, //set to 'noope' for testing
19
+ autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
20
+ useRelay: boolean | null, // if true it forces the use of relay
21
+ refresh: boolean // if true it forces to refresh the fula object
22
+ ) => Promise<string>;
23
+ isReady: (filesystemCheck: boolean) => Promise<boolean>;
24
+ logout: (identity: string, storePath: string) => Promise<boolean>;
25
+ checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
26
+ checkConnection: (timeout: number) => Promise<boolean>;
27
+ get: (key: string) => Promise<string>;
28
+ has: (key: Uint8Array) => Promise<boolean>;
29
+ push: () => Promise<string>;
30
+ put: (content: string, codec: string) => Promise<string>;
31
+ mkdir: (path: string) => Promise<string>;
32
+ writeFileContent: (path: string, content: string) => Promise<string>;
33
+ writeFile: (
34
+ fulaTargetFilename: string,
35
+ localFilename: string
36
+ ) => Promise<string>;
37
+ ls: (path: string) => Promise<string>;
38
+ rm: (path: string) => Promise<string>;
39
+ cp: (sourcePath: string, targetPath: string) => Promise<string>;
40
+ mv: (sourcePath: string, targetPath: string) => Promise<string>;
41
+ readFile: (
42
+ fulaTargetFilename: string,
43
+ localFilename: string
44
+ ) => Promise<string>;
45
+ readFileContent: (path: string) => Promise<string>;
46
+ setAuth: (peerId: string, allow: boolean) => Promise<boolean>;
47
+
48
+ shutdown: () => Promise<void>;
49
+
50
+ //Blockchain related functions
51
+ createAccount: (seed: string) => Promise<string>;
52
+ checkAccountExists: (account: string) => Promise<string>;
53
+ createPool: (seed: string, poolName: string) => Promise<string>;
54
+ listPools: () => Promise<string>;
55
+ joinPool: (seed: string, poolID: number) => Promise<string>;
56
+ leavePool: (seed: string, poolID: number) => Promise<string>;
57
+ cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;
58
+ listPoolJoinRequests: (poolID: number) => Promise<string>;
59
+ votePoolJoinRequest: (
60
+ seed: string,
61
+ poolID: number,
62
+ account: string,
63
+ accept: boolean
64
+ ) => Promise<string>;
65
+ newReplicationRequest: (
66
+ seed: string,
67
+ poolID: number,
68
+ replicationFactor: number,
69
+ cid: string
70
+ ) => Promise<string>;
71
+ newStoreRequest: (
72
+ seed: string,
73
+ poolID: number,
74
+ uploader: string,
75
+ cid: string
76
+ ) => Promise<string>;
77
+ listAvailableReplicationRequests: (poolID: number) => Promise<string>;
78
+ removeReplicationRequest: (
79
+ seed: string,
80
+ poolID: number,
81
+ cid: string
82
+ ) => Promise<string>;
83
+ removeStorer: (
84
+ seed: string,
85
+ storer: string,
86
+ poolID: number,
87
+ cid: string
88
+ ) => Promise<string>;
89
+ removeStoredReplication: (
90
+ seed: string,
91
+ uploader: string,
92
+ poolID: number,
93
+ cid: string
94
+ ) => Promise<string>;
95
+
96
+ //Hardware
97
+ bloxFreeSpace: () => Promise<string>;
98
+ wifiRemoveall: () => Promise<string>;
99
+ reboot: () => Promise<string>;
100
+ }
101
+
102
+ const LINKING_ERROR =
103
+ `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \n\n` +
104
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
105
+ '- You rebuilt the app after installing the package\n' +
106
+ '- You are not using Expo managed workflow\n';
107
+
108
+ const Fula = NativeModules.FulaModule
109
+ ? NativeModules.FulaModule
110
+ : new Proxy(
111
+ {},
112
+ {
113
+ get() {
114
+ throw new Error(LINKING_ERROR);
115
+ },
116
+ }
117
+ );
118
+
119
+ export default Fula as FulaNativeModule;