webpeerjs 0.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Nuzulul Zulkarnain
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # WebpeerJS
2
+ > Simple peer-to-peer with [IPFS](https://ipfs.tech/). Build completely P2P web applications, no trackers or relay servers involved.
3
+
4
+ WebpeerJS enables browser to browser connectivity without a central server.
5
+
6
+ ## Example
7
+
8
+ ```
9
+ import { webpeerjs } from 'webpeerjs'
10
+
11
+ void async function main() {
12
+
13
+ const node = await webpeerjs.createWebpeer()
14
+
15
+ console.log(`My node id : ${node.id}`)
16
+
17
+ const [send,listen,members] = node.joinRoom('myroom')
18
+
19
+ send('hello')
20
+
21
+ listen((message,id) => {
22
+ console.log(`Message from ${id} : ${message}`)
23
+ })
24
+
25
+ members((data) => {
26
+ console.log(`Members : ${data}`)
27
+ })
28
+
29
+ }()
30
+ ```
31
+
32
+ ## Install
33
+
34
+ ```
35
+ npm i webpeerjs
36
+ ```
37
+
38
+ ## API
39
+
40
+ - `createWebpeer()` Create a new local node.
41
+ - `id` The unique ID of the local node as an identity in the global network.
42
+ - `joinRoom()` Adding a local node to the room, returns an array of three functions (Sender, onListen, onMembers).
43
+ - `peers` Get all connected peers.
44
+
45
+ ## License
46
+
47
+ MIT License
48
+
49
+ Copyright (c) 2024 [Nuzulul Zulkarnain](https://github.com/nuzulul)
@@ -0,0 +1 @@
1
+ {"type": "module","types": "webpeerjs.d.ts"}
@@ -0,0 +1,16 @@
1
+ export class webpeerjs {
2
+ static createWebpeer(): Promise<webpeerjs>;
3
+ constructor(libp2p: any, dbstore: any, onMetrics: any);
4
+ id: any;
5
+ status: any;
6
+ IPFS: {
7
+ libp2p: any;
8
+ discoveredPeers: Map<any, any>;
9
+ };
10
+ address: any[];
11
+ peers: any[];
12
+ onJoin: (f: any) => any;
13
+ onLeave: (f: any) => any;
14
+ joinRoom: (room: any) => any[];
15
+ #private;
16
+ }