@afosecure/meshsdk 0.1.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +373 -0
  3. package/package.json +68 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AFOLABI MUBARAK
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,373 @@
1
+ # 📹 MESHSDK
2
+
3
+ A lightweight React SDK for building peer-to-peer video conferencing applications using WebRTC Mesh networking. The SDK provides a modern React API, built-in meeting state management, screen sharing, chat, waiting room support, and flexible WebSocket signaling.
4
+
5
+ ---
6
+
7
+ ## Features
8
+
9
+ - Peer-to-peer WebRTC Mesh architecture
10
+ - HD audio and video
11
+ - Screen sharing
12
+ - Waiting room with host approval
13
+ - Public and private in-meeting chat
14
+ - Participant presence and media state
15
+ - Automatic ICE restart & reconnection
16
+ - STUN/TURN support
17
+ - React Hooks API
18
+ - Full TypeScript support
19
+ - Lightweight with zero UI dependencies
20
+
21
+ ---
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install @afosecure/meshsdk
27
+ ```
28
+
29
+ or
30
+
31
+ ```bash
32
+ pnpm add @afosecure/meetingsdk
33
+ ```
34
+
35
+ or
36
+
37
+ ```bash
38
+ yarn add @afosecure/meetingsdk
39
+ ```
40
+
41
+ ---
42
+
43
+ # Quick Start
44
+
45
+ ## Create the SDK
46
+
47
+ ```tsx
48
+ import { useState } from "react";
49
+ import { MeetingProvider, VideoSDKCore } from "@afosecure/meetingsdk";
50
+
51
+ export default function App() {
52
+ const [sdk] = useState(
53
+ () =>
54
+ new VideoSDKCore({
55
+ onUserJoined: console.log,
56
+ onUserLeft: console.log,
57
+ onTrack: console.log,
58
+ }),
59
+ );
60
+
61
+ return (
62
+ <MeetingProvider core={sdk}>
63
+ <Meeting />
64
+ </MeetingProvider>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Join a Meeting
72
+
73
+ ```tsx
74
+ import { useMeeting } from "@afosecure/meetingsdk";
75
+
76
+ export default function Meeting() {
77
+ const { joinMeeting, startLocalStream, leaveMeeting } = useMeeting();
78
+
79
+ const join = async () => {
80
+ await startLocalStream(videoRef.current!, "John");
81
+
82
+ await joinMeeting({
83
+ roomId: "room-123",
84
+ name: "John",
85
+ });
86
+ };
87
+
88
+ return (
89
+ <>
90
+ <button onClick={join}>Join</button>
91
+
92
+ <button onClick={leaveMeeting}>Leave</button>
93
+ </>
94
+ );
95
+ }
96
+ ```
97
+
98
+ ---
99
+
100
+ # React Hooks
101
+
102
+ ## useMeeting()
103
+
104
+ Provides meeting actions and local participant state.
105
+
106
+ ```ts
107
+ const {
108
+ joinMeeting,
109
+ leaveMeeting,
110
+ toggleMic,
111
+ toggleCam,
112
+ startScreenShare,
113
+ stopScreenShare,
114
+ sendChatMessage,
115
+ participants,
116
+ localParticipant,
117
+ presenterId,
118
+ } = useMeeting();
119
+ ```
120
+
121
+ ---
122
+
123
+ ## useParticipants()
124
+
125
+ Returns all remote participants.
126
+
127
+ ```ts
128
+ const participants = useParticipants();
129
+ ```
130
+
131
+ ---
132
+
133
+ ## useLocalParticipant()
134
+
135
+ ```ts
136
+ const participant = useLocalParticipant();
137
+ ```
138
+
139
+ ---
140
+
141
+ ## useChat()
142
+
143
+ ```ts
144
+ const { messages, sendChatMessage } = useChat();
145
+ ```
146
+
147
+ ---
148
+
149
+ ## useMeetingState()
150
+
151
+ Subscribe to the underlying reactive meeting state.
152
+
153
+ ```ts
154
+ const meeting = useMeetingState();
155
+ ```
156
+
157
+ ---
158
+
159
+ # Meeting Events
160
+
161
+ ```ts
162
+ const sdk = new VideoSDKCore({
163
+ onTrack(stream, participantId) {},
164
+
165
+ onUserJoined(participant) {},
166
+
167
+ onUserLeft(participantId) {},
168
+
169
+ onChatMessage(message) {},
170
+
171
+ onScreenShareStarted(id, stream) {},
172
+
173
+ onScreenShareStopped(id) {},
174
+
175
+ onMicToggled(id, enabled) {},
176
+
177
+ onCamToggled(id, enabled) {},
178
+
179
+ onMeetingLeft() {},
180
+
181
+ onError(error) {},
182
+ });
183
+ ```
184
+
185
+ ---
186
+
187
+ # Features
188
+
189
+ ## Audio & Video
190
+
191
+ - Camera
192
+ - Microphone
193
+ - Mute / Unmute
194
+ - Camera On / Off
195
+
196
+ ---
197
+
198
+ ## Screen Sharing
199
+
200
+ ```ts
201
+ await startScreenShare();
202
+
203
+ stopScreenShare();
204
+ ```
205
+
206
+ Supports:
207
+
208
+ - Presenter detection
209
+ - Automatic renegotiation
210
+ - Browser stop-share handling
211
+
212
+ ---
213
+
214
+ ## Waiting Room
215
+
216
+ Supports:
217
+
218
+ - Join requests
219
+ - Host approval
220
+ - Host rejection
221
+ - Rejoin after approval
222
+
223
+ Events:
224
+
225
+ ```ts
226
+ onEntryRequested();
227
+
228
+ onEntryResponded();
229
+ ```
230
+
231
+ ---
232
+
233
+ ## Chat
234
+
235
+ Supports:
236
+
237
+ - Public messages
238
+ - Private messages
239
+ - Replies
240
+ - Optimistic updates
241
+
242
+ ```ts
243
+ sendChatMessage({
244
+ message: "Hello everyone!",
245
+ });
246
+ ```
247
+
248
+ ---
249
+
250
+ # Architecture
251
+
252
+ ```
253
+ Participant A
254
+ │
255
+ │
256
+ WebSocket
257
+ (Signaling Only)
258
+ │
259
+ Participant B
260
+
261
+ Media
262
+ ──────────────►
263
+ Direct WebRTC
264
+ Peer Connection
265
+ ```
266
+
267
+ Media never passes through the signaling server.
268
+
269
+ The WebSocket server is only responsible for:
270
+
271
+ - room management
272
+ - participant discovery
273
+ - signaling
274
+ - waiting room
275
+ - ICE exchange
276
+
277
+ ---
278
+
279
+ # Server Requirements
280
+
281
+ Your signaling server should support the following messages.
282
+
283
+ ## Client → Server
284
+
285
+ - JOIN
286
+ - LEAVE
287
+ - OFFER
288
+ - ANSWER
289
+ - ICE
290
+ - CHAT_MESSAGE
291
+ - MEDIA_STATE
292
+ - SCREEN_SHARE_START
293
+ - SCREEN_SHARE_STOP
294
+ - JOIN_APPROVE
295
+ - JOIN_REJECT
296
+ - PING
297
+
298
+ ---
299
+
300
+ ## Server → Client
301
+
302
+ - JOINED
303
+ - EXISTING_USERS
304
+ - USER_JOINED
305
+ - USER_LEFT
306
+ - OFFER
307
+ - ANSWER
308
+ - ICE
309
+ - CHAT_MESSAGE
310
+ - MEDIA_STATE_CHANGE
311
+ - SCREEN_SHARE_START
312
+ - SCREEN_SHARE_STOP
313
+ - JOIN_PENDING
314
+ - JOIN_APPROVED
315
+ - JOIN_REJECTED
316
+ - ERROR
317
+ - PONG
318
+
319
+ ---
320
+
321
+ # STUN & TURN
322
+
323
+ The SDK expects the signaling server to provide ICE servers during the JOIN flow.
324
+
325
+ Example:
326
+
327
+ ```json
328
+ {
329
+ "iceServers": [
330
+ {
331
+ "urls": ["stun:stun.l.google.com:19302"]
332
+ },
333
+ {
334
+ "urls": ["turn:turn.example.com:3478"],
335
+ "username": "...",
336
+ "credential": "..."
337
+ }
338
+ ]
339
+ }
340
+ ```
341
+
342
+ ---
343
+
344
+ # Browser Support
345
+
346
+ - Chrome
347
+ - Edge
348
+ - Firefox
349
+ - Safari
350
+
351
+ ---
352
+
353
+ # Mesh Networking
354
+
355
+ This SDK uses a Mesh topology.
356
+
357
+ Every participant establishes a direct WebRTC connection with every other participant.
358
+
359
+ Best suited for:
360
+
361
+ - One-to-one calls
362
+ - Interviews
363
+ - Online consultations
364
+ - Small meetings
365
+ - Team discussions
366
+
367
+ For larger meetings (10+ participants), an SFU architecture is recommended.
368
+
369
+ ---
370
+
371
+ # License
372
+
373
+ MIT
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@afosecure/meshsdk",
3
+ "version": "0.1.1",
4
+ "description": "A modern, lightweight React SDK for building peer-to-peer video communication applications. Built on WebRTC with a clean, composable rust API.",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "require": "./dist/index.js",
18
+ "import": "./dist/index.mjs"
19
+ },
20
+ "./react": {
21
+ "types": "./dist/react.d.ts",
22
+ "require": "./dist/react.js",
23
+ "import": "./dist/react.mjs"
24
+ }
25
+ },
26
+ "scripts": {
27
+ "build": "tsup src/index.ts --format esm,cjs --dts",
28
+ "dev": "tsup src/index.ts --watch"
29
+ },
30
+ "keywords": [
31
+ "afosecure",
32
+ "call",
33
+ "react",
34
+ "meeting",
35
+ "video",
36
+ "mesh",
37
+ "peer",
38
+ "webrtc",
39
+ "sdk",
40
+ "rust",
41
+ "sdk",
42
+ "typescript",
43
+ "videosdk"
44
+ ],
45
+ "author": "Afolabi Mubarak",
46
+ "license": "MIT",
47
+ "homepage": "https://github.com/Megabyte-webdev/meshsdk",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/Megabyte-webdev/meshsdk.git"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/Megabyte-webdev/meshsdk/issues"
54
+ },
55
+ "peerDependencies": {
56
+ "react": ">=18",
57
+ "react-dom": ">=18"
58
+ },
59
+ "dependencies": {
60
+ "uuid": "^14.0.0"
61
+ },
62
+ "devDependencies": {
63
+ "@types/react": "^19.2.14",
64
+ "@types/ws": "^8.18.1",
65
+ "tsup": "^8.5.1",
66
+ "typescript": "^6.0.2"
67
+ }
68
+ }