@functionland/react-native-fula 0.4.2 → 1.1.4

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 (66) hide show
  1. package/README.md +99 -9
  2. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  6. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  7. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  8. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  9. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  11. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  13. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  14. package/android/.gradle/file-system.probe +0 -0
  15. package/android/.idea/jarRepositories.xml +9 -9
  16. package/android/.idea/sonarlint/issuestore/index.pb +0 -0
  17. package/android/build.gradle +7 -5
  18. package/android/gradle/wrapper/gradle-wrapper.properties +7 -6
  19. package/android/gradle.properties +1 -1
  20. package/android/gradlew +53 -2
  21. package/android/local.properties +1 -1
  22. package/android/src/main/java/land/fx/fula/FulaModule.java +840 -72
  23. package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
  24. package/lib/commonjs/index.js +5 -1
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/interfaces/api-lookup.js +1653 -0
  27. package/lib/commonjs/interfaces/api-lookup.js.map +1 -0
  28. package/lib/commonjs/interfaces/fulaNativeModule.js +1 -1
  29. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  30. package/lib/commonjs/protocols/blockchain.js +404 -0
  31. package/lib/commonjs/protocols/blockchain.js.map +1 -0
  32. package/lib/commonjs/protocols/chain-api.js +87 -0
  33. package/lib/commonjs/protocols/chain-api.js.map +1 -0
  34. package/lib/commonjs/protocols/fula.js +120 -7
  35. package/lib/commonjs/protocols/fula.js.map +1 -1
  36. package/lib/commonjs/types/blockchain.js +2 -0
  37. package/lib/commonjs/types/blockchain.js.map +1 -0
  38. package/lib/module/index.js +4 -0
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/interfaces/api-lookup.js +1648 -0
  41. package/lib/module/interfaces/api-lookup.js.map +1 -0
  42. package/lib/module/interfaces/fulaNativeModule.js +1 -1
  43. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  44. package/lib/module/protocols/blockchain.js +383 -0
  45. package/lib/module/protocols/blockchain.js.map +1 -0
  46. package/lib/module/protocols/chain-api.js +76 -0
  47. package/lib/module/protocols/chain-api.js.map +1 -0
  48. package/lib/module/protocols/fula.js +110 -4
  49. package/lib/module/protocols/fula.js.map +1 -1
  50. package/lib/module/types/blockchain.js +2 -0
  51. package/lib/module/types/blockchain.js.map +1 -0
  52. package/lib/typescript/index.d.ts +2 -0
  53. package/lib/typescript/interfaces/api-lookup.d.ts +1643 -0
  54. package/lib/typescript/interfaces/fulaNativeModule.d.ts +40 -3
  55. package/lib/typescript/protocols/blockchain.d.ts +17 -0
  56. package/lib/typescript/protocols/chain-api.d.ts +6 -0
  57. package/lib/typescript/protocols/fula.d.ts +52 -2
  58. package/lib/typescript/types/blockchain.d.ts +68 -0
  59. package/package.json +13 -8
  60. package/src/index.tsx +3 -1
  61. package/src/interfaces/api-lookup.ts +1647 -0
  62. package/src/interfaces/fulaNativeModule.ts +50 -7
  63. package/src/protocols/blockchain.ts +460 -0
  64. package/src/protocols/chain-api.ts +80 -0
  65. package/src/protocols/fula.ts +157 -12
  66. package/src/types/blockchain.ts +81 -0
@@ -1,8 +1,26 @@
1
1
  interface FulaNativeModule {
2
- init: (identity: string | null, //Private key of did identity
3
- storePath: string | null, //You can leave empty
2
+ init: (identity: string, //Private key of did identity
3
+ storePath: string, //You can leave empty
4
4
  bloxAddr: string, //Blox multiadddr needs to be manually entered now
5
- exchange: string) => Promise<[string, string, string]>;
5
+ exchange: string, //set to 'noope' for testing
6
+ autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
7
+ rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
8
+ useRelay: boolean | null, // if true it forces the use of relay
9
+ refresh: boolean) => Promise<{
10
+ peerId: string;
11
+ rootCid: string;
12
+ private_ref: string;
13
+ }>;
14
+ newClient: (identity: string, //Private key of did identity
15
+ storePath: string, //You can leave empty
16
+ bloxAddr: string, //Blox multiadddr needs to be manually entered now
17
+ exchange: string, //set to 'noope' for testing
18
+ autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
19
+ useRelay: boolean | null) => Promise<string>;
20
+ isReady: (filesystemCheck: boolean) => Promise<boolean>;
21
+ logout: (identity: string, storePath: string) => Promise<boolean>;
22
+ checkFailedActions: (retry: boolean) => Promise<boolean>;
23
+ checkConnection: () => Promise<boolean>;
6
24
  get: (key: string) => Promise<string>;
7
25
  has: (key: Uint8Array) => Promise<boolean>;
8
26
  push: () => Promise<string>;
@@ -12,9 +30,28 @@ interface FulaNativeModule {
12
30
  writeFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
13
31
  ls: (path: string) => Promise<string>;
14
32
  rm: (path: string) => Promise<string>;
33
+ cp: (sourcePath: string, targetPath: string) => Promise<string>;
34
+ mv: (sourcePath: string, targetPath: string) => Promise<string>;
15
35
  readFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
16
36
  readFileContent: (path: string) => Promise<string>;
37
+ setAuth: (peerId: string, allow: boolean) => Promise<boolean>;
17
38
  shutdown: () => Promise<void>;
39
+ createAccount: (seed: string) => Promise<string>;
40
+ checkAccountExists: (account: string) => Promise<string>;
41
+ createPool: (seed: string, poolName: string) => Promise<string>;
42
+ listPools: () => Promise<string>;
43
+ joinPool: (seed: string, poolID: number) => Promise<string>;
44
+ leavePool: (seed: string, poolID: number) => Promise<string>;
45
+ cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;
46
+ listPoolJoinRequests: (poolID: number) => Promise<string>;
47
+ votePoolJoinRequest: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;
48
+ newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;
49
+ newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;
50
+ listAvailableReplicationRequests: (poolID: number) => Promise<string>;
51
+ removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;
52
+ removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;
53
+ removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;
54
+ bloxFreeSpace: () => Promise<string>;
18
55
  }
19
56
  declare const _default: FulaNativeModule;
20
57
  export default _default;
@@ -0,0 +1,17 @@
1
+ import type * as BType from '../types/blockchain';
2
+ export declare const createAccount: (seed: string) => Promise<BType.SeededResponse>;
3
+ export declare const checkAccountExists: (account: string) => Promise<BType.AccountExistsResponse>;
4
+ export declare const createPool: (seed: string, poolName: string) => Promise<BType.PoolCreateResponse>;
5
+ export declare const listPools: () => Promise<BType.PoolListResponse>;
6
+ export declare const joinPool: (seed: string, poolID: number) => Promise<BType.PoolJoinResponse>;
7
+ export declare const leavePool: (seed: string, poolID: number) => Promise<BType.PoolLeaveResponse>;
8
+ export declare const cancelPoolJoin: (seed: string, poolID: number) => Promise<BType.PoolCancelJoinResponse>;
9
+ export declare const listPoolJoinRequests: (poolID: number) => Promise<BType.PoolRequestsResponse>;
10
+ export declare const votePoolJoinRequest: (seed: string, poolID: number, account: string, accept: boolean) => Promise<BType.PoolVoteResponse>;
11
+ export declare const newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<BType.ManifestUploadResponse>;
12
+ export declare const newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<BType.ManifestUploadResponse>;
13
+ export declare const listAvailableReplicationRequests: (poolID: number) => Promise<BType.ManifestUploadResponse[]>;
14
+ export declare const removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<BType.ManifestUploadResponse>;
15
+ export declare const removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<BType.ManifestUploadResponse>;
16
+ export declare const removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<BType.ManifestUploadResponse>;
17
+ export declare const bloxFreeSpace: () => Promise<BType.BloxFreeSpaceResponse>;
@@ -0,0 +1,6 @@
1
+ import { ApiPromise } from '@polkadot/api';
2
+ import type * as BType from '../types/blockchain';
3
+ export declare const init: (wsAddress?: string) => Promise<ApiPromise>;
4
+ export declare const disconnectApi: (api: ApiPromise) => Promise<void>;
5
+ export declare const listPools: (api: ApiPromise | undefined, start?: number, length?: number) => Promise<BType.PoolListResponse>;
6
+ export declare const checkJoinRequest: (api: ApiPromise | undefined, poolId: number, accountId: string) => Promise<BType.PoolRequest | null>;
@@ -4,7 +4,32 @@
4
4
  * @param config
5
5
  * @returns boolean
6
6
  */
7
- export declare const init: (identity: string, storePath: string, bloxAddr: string, exchange: string) => Promise<[string, string, string]>;
7
+ export declare const init: (identity: string, storePath: string, bloxAddr: string, exchange: string, autoFlush?: boolean, rootCid?: string | null, useRelay?: boolean, refresh?: boolean) => Promise<{
8
+ peerId: string;
9
+ rootCid: string;
10
+ private_ref: string;
11
+ }>;
12
+ /**
13
+ * Get gets the value corresponding to the given key from the local datastore.
14
+ // The key must be a valid ipld.Link.
15
+ * @param config
16
+ * @returns boolean
17
+ */
18
+ export declare const newClient: (identity: string, storePath: string, bloxAddr: string, exchange: string, autoFlush?: boolean, useRelay?: boolean) => Promise<string>;
19
+ /**
20
+ * rm removes all data
21
+ * @param path
22
+ * @returns string: new cid of the root
23
+ */
24
+ export declare const logout: (identity: string, storePath: string) => Promise<boolean>;
25
+ /**
26
+ * Checks if there are any un-synced changes on the device
27
+ */
28
+ export declare const checkFailedActions: (retry?: boolean) => Promise<boolean>;
29
+ /**
30
+ * Checks if there are any un-synced changes on the device
31
+ */
32
+ export declare const checkConnection: () => Promise<boolean>;
8
33
  /**
9
34
  * Get gets the value corresponding to the given key from the local datastore.
10
35
  // The key must be a valid ipld.Link.
@@ -54,13 +79,25 @@ export declare const writeFile: (fulaTargetFilename: string, localFilename: stri
54
79
  * @returns string: list of items
55
80
  * TODO: Findout how is the string and convert to array
56
81
  */
57
- export declare const ls: (path: string) => Promise<string>;
82
+ export declare const ls: (path: string) => Promise<void | JSON>;
58
83
  /**
59
84
  * rm removes all files and folders at a given path
60
85
  * @param path
61
86
  * @returns string: new cid of the root
62
87
  */
63
88
  export declare const rm: (path: string) => Promise<string>;
89
+ /**
90
+ * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
91
+ * @param sourcePath, targetPath
92
+ * @returns string: new cid of the root
93
+ */
94
+ export declare const cp: (sourcePath: string, targetPath: string) => Promise<string>;
95
+ /**
96
+ * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
97
+ * @param sourcePath, targetPath
98
+ * @returns string: new cid of the root
99
+ */
100
+ export declare const mv: (sourcePath: string, targetPath: string) => Promise<string>;
64
101
  export declare const readFile: (fulaTargetFilename: string, localFilename: string) => Promise<string>;
65
102
  /**
66
103
  * readFile reads content of a given path
@@ -75,3 +112,16 @@ export declare const readFileContent: (path: string) => Promise<string>;
75
112
  * @returns
76
113
  */
77
114
  export declare const shutdown: () => Promise<void>;
115
+ /**
116
+ * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.
117
+ * This can only be called on a peer that is added as an owner of blox by --authorizer parameter
118
+ * @param peerId, allow
119
+ * @returns boolean: true if successful or false if not
120
+ */
121
+ export declare const setAuth: (peerId: string, allow: boolean) => Promise<boolean>;
122
+ /**
123
+ * isReady checks if the connection is ready to be used.
124
+ * @param filesystemCheck: also check if the wnfs is ready
125
+ * @returns boolean: true if ready or false if not
126
+ */
127
+ export declare const isReady: (filesystemCheck?: boolean) => Promise<boolean>;
@@ -0,0 +1,68 @@
1
+ export interface SeededResponse {
2
+ seed: string;
3
+ account: string;
4
+ }
5
+ export interface AccountExistsResponse {
6
+ account: string;
7
+ exists: boolean;
8
+ }
9
+ export interface PoolCreateResponse {
10
+ owner: string;
11
+ poolID: number;
12
+ }
13
+ export interface PoolJoinResponse {
14
+ account: string;
15
+ poolID: number;
16
+ }
17
+ export interface PoolCancelJoinResponse {
18
+ account: string;
19
+ poolID: number;
20
+ }
21
+ export interface PoolRequestsResponse {
22
+ poolRequests: PoolRequest[];
23
+ }
24
+ export interface PoolListResponse {
25
+ pools: Pool[];
26
+ }
27
+ export interface PoolVoteResponse {
28
+ account: string;
29
+ poolID: number;
30
+ }
31
+ export interface PoolLeaveResponse {
32
+ account: string;
33
+ poolID: number;
34
+ }
35
+ export interface ManifestUploadResponse {
36
+ uploader: string;
37
+ storage: string[];
38
+ manifestMetadata: ManifestMetadata;
39
+ poolID: number;
40
+ }
41
+ export interface PoolRequest {
42
+ poolID: number;
43
+ account: string;
44
+ voted: string[];
45
+ positiveVotes: number;
46
+ peerID: string;
47
+ }
48
+ export interface Pool {
49
+ poolID: number;
50
+ owner: string;
51
+ poolName: string;
52
+ parent: string;
53
+ participants: string[];
54
+ }
55
+ export interface ManifestMetadata {
56
+ job: ManifestJob;
57
+ }
58
+ export interface ManifestJob {
59
+ work: string;
60
+ engine: string;
61
+ uri: string;
62
+ }
63
+ export interface BloxFreeSpaceResponse {
64
+ size: number;
65
+ avail: number;
66
+ used: number;
67
+ used_percentage: number;
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionland/react-native-fula",
3
- "version": "0.4.2",
3
+ "version": "1.1.4",
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,13 +63,15 @@
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"
74
71
  },
75
72
  "peerDependencies": {
73
+ "@babel/core": "^7.0.0-0",
74
+ "@babel/preset-env": "^7.1.6",
76
75
  "react": "*",
77
76
  "react-native": "*"
78
77
  },
@@ -148,5 +147,11 @@
148
147
  }
149
148
  ]
150
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"
151
156
  }
152
157
  }
package/src/index.tsx CHANGED
@@ -1 +1,3 @@
1
- export * as fula from './protocols/fula';
1
+ export * as fula from './protocols/fula';
2
+ export * as blockchain from './protocols/blockchain';
3
+ export * as chainApi from './protocols/chain-api';