web3-provdr 0.0.1-security → 1.0.0-beta.55

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.

Potentially problematic release.


This version of web3-provdr might be problematic. Click here for more details.

package/README.md CHANGED
@@ -1,5 +1,100 @@
1
- # Security holding package
1
+ # web3-providers
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ This is a sub module of [web3.js][repo]
4
4
 
5
- Please refer to www.npmjs.com/advisories?search=web3-provdr for more information.
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install web3-providers
9
+ ```
10
+
11
+ ## Usage Examples
12
+
13
+ #### HttpProvider
14
+ You can pass with the options object the timeout and all known HTTP headers.
15
+
16
+ ```js
17
+ import {HttpProvider} from 'web3-providers';
18
+
19
+ const options = {
20
+ timeout: 20000,
21
+ headers: [
22
+ {
23
+ name: 'Access-Control-Allow-Origin', value: '*'
24
+ },
25
+ ...
26
+ ]
27
+ };
28
+
29
+ const httpProvider = new HttpProvider('http://localhost:8545', options);
30
+ ```
31
+
32
+ #### WebsocketProvider
33
+
34
+ Instead of setting a authorization header you could also define the credentials over the URL with:
35
+ ```ws://username:password@localhost:8546```
36
+
37
+ ```js
38
+ import {WebsocketProvider} from 'web3-providers';
39
+ const options = {
40
+ timeout: 30000,
41
+ headers: {
42
+ authorization: 'Basic username:password'
43
+ }
44
+ };
45
+
46
+ const websocketProvider = new WebsocketProvider('ws://localhost:8546', options);
47
+ ```
48
+
49
+ #### IpcProvider
50
+ ```js
51
+ import {IpcProvider} from 'web3-providers';
52
+ import net from 'net';
53
+
54
+ const ipcProvider = new IpcProvider('/Users/me/Library/Ethereum/geth.ipc', net);
55
+ ```
56
+
57
+ #### BatchRequest
58
+ The BatchRequest provides the possibility to send JSON-RPC requests as batch.
59
+ Please read the [documentation][docs] for more.
60
+
61
+ ```js
62
+ import {ProviderResolver, BatchRequest} 'web3-providers';
63
+
64
+ const provider = new ProviderResolver().resolve('ws://localhost:8546');
65
+ const batchRequest = new BatchRequest(provider);
66
+
67
+ batchRequest.add(web3.eth.getBalance.request(
68
+ '0x0000000000000000000000000000000000000000',
69
+ 'latest',
70
+ callback
71
+ ));
72
+
73
+ await batchRequest.execute();
74
+ ```
75
+
76
+ #### ProviderDetector
77
+ Checks if an provider is given from the environment (Mist, MetaMask) and returns the provider.
78
+
79
+ ```js
80
+ import {ProviderDetector} from 'web3-providers';
81
+
82
+ const givenProvider = ProviderDetector.detect();
83
+ ```
84
+
85
+ #### ProviderResolver
86
+ The ProviderResolver resolves an url or an given provider object to the correct provider class.
87
+ Because of the resolves does web3 has internally just one provider interface and we have no direct dependency to third party providers.
88
+
89
+ ```js
90
+ import {ProviderResolver} 'web3-providers';
91
+
92
+ const socketProviderAdapter = new ProviderResolver().resolve('ws://localhost:8546');
93
+ ```
94
+
95
+ ## Types
96
+
97
+ All the typescript typings are placed in the types folder.
98
+
99
+ [docs]: http://web3js.readthedocs.io/en/1.0/
100
+ [repo]: https://github.com/ethereum/web3.js