@afosecure/meshsdk 0.1.1 → 0.1.2

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.
@@ -0,0 +1,283 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import react__default from 'react';
4
+
5
+ type Events = {
6
+ onMicToggled?: (peerId: string, enabled: boolean) => void;
7
+ onError?: (err: SDKError) => void;
8
+ onCamToggled?: (peerId: string, enabled: boolean) => void;
9
+ onTrack?: (stream: MediaStream, peerId: string) => void;
10
+ onScreenTrack?: (stream: MediaStream, peerId: string) => void;
11
+ onUserJoined?: (p: Participant) => void;
12
+ onEntryRequested?: (req: EntryRequest) => void;
13
+ onEntryResponded?: (payload: {
14
+ participantId: string;
15
+ decision: EntryDecision;
16
+ } | string, decision?: EntryDecision) => void;
17
+ onJoinApproved?: (requestId: string) => void;
18
+ onJoinRejected?: (requestId: string) => void;
19
+ onRoomUpdate?: (data: any) => void;
20
+ onUserLeft?: (id: string) => void;
21
+ onMeetingLeft?: () => void;
22
+ onChatMessage?: (msg: ChatMessage) => void;
23
+ onScreenShareStarted?: (peerId: string, stream: MediaStream) => void;
24
+ onScreenShareStopped?: (peerId: string) => void;
25
+ onMuteStateChanged?: (peerId: string, kind: "audio" | "video", muted: boolean) => void;
26
+ };
27
+ type ChatMessage = {
28
+ id: string;
29
+ text: string;
30
+ sender_id: string;
31
+ sender_name?: string;
32
+ timestamp: number;
33
+ reply_to?: {
34
+ id: string;
35
+ name: string;
36
+ } | null;
37
+ target?: string | null;
38
+ };
39
+ type Participant = {
40
+ id: string;
41
+ name?: string;
42
+ isHost?: boolean;
43
+ isLocal?: boolean;
44
+ media?: ParticipantMedia;
45
+ isPresenter?: boolean;
46
+ };
47
+ type ParticipantMedia = {
48
+ stream?: MediaStream | null;
49
+ screenStream?: MediaStream | null;
50
+ cameraTrack?: MediaStreamTrack;
51
+ screenTrack?: MediaStreamTrack;
52
+ audioTrack?: MediaStreamTrack;
53
+ micEnabled: boolean;
54
+ camEnabled: boolean;
55
+ isScreenSharing: boolean;
56
+ remoteScreenStreamId?: string;
57
+ cameraStreamId?: string;
58
+ };
59
+ type Listener = () => void;
60
+ type ChatInput = {
61
+ message: string;
62
+ reply_to?: {
63
+ id: string;
64
+ name: string;
65
+ } | null;
66
+ target?: string | null;
67
+ };
68
+ type MeetingConfig = {
69
+ roomId: string;
70
+ name: string;
71
+ audioMuted?: boolean;
72
+ videoMuted?: boolean;
73
+ token?: string;
74
+ };
75
+ type PubSubTopic = "SECURE_CHAT";
76
+ type StateScope = "participants" | "localParticipant" | "chat" | "presenter" | `participant:${string}`;
77
+ type SDKError = {
78
+ code: string;
79
+ message: string;
80
+ roomId?: string | null;
81
+ userId?: string;
82
+ raw?: any;
83
+ recoverable?: boolean;
84
+ };
85
+ type EntryDecision = "approved" | "rejected";
86
+ type EntryRequest = {
87
+ requestId: string;
88
+ userId: string;
89
+ name: string;
90
+ };
91
+
92
+ declare const useLocalParticipant: () => {
93
+ participant: Participant | null;
94
+ videoRef: (video: HTMLVideoElement | null) => void;
95
+ };
96
+
97
+ type LocalParticipantPatch = {
98
+ id?: string;
99
+ name?: string;
100
+ media?: Partial<ParticipantMedia>;
101
+ };
102
+ declare class MeetingState {
103
+ participants: Map<string, Participant>;
104
+ localParticipant: Participant | null;
105
+ localStream: MediaStream | null;
106
+ chatMessages: Map<string, ChatMessage>;
107
+ presenterId: string | null;
108
+ private listeners;
109
+ subscribe(scope: StateScope, fn: Listener): () => void;
110
+ notify(scope: StateScope): void;
111
+ setPresenterId(id: string | null): void;
112
+ addParticipant(p: Participant): boolean;
113
+ removeParticipant(id: string): void;
114
+ updateParticipantMedia(id: string, patch: Partial<NonNullable<Participant["media"]>>): void;
115
+ updateLocalParticipant(patch: LocalParticipantPatch): void;
116
+ addChatMessage(msg: ChatMessage): void;
117
+ getChatMessages(): ChatMessage[];
118
+ clearChat(): void;
119
+ getParticipants(): Participant[];
120
+ getParticipant(id: string): Participant | null;
121
+ resetRemoteState(): void;
122
+ }
123
+
124
+ declare class VideoSDKCore {
125
+ private events;
126
+ private url;
127
+ private ws;
128
+ private peers;
129
+ private initiators;
130
+ private lastPong;
131
+ private iceServers;
132
+ private intentionalDisconnect;
133
+ private myId;
134
+ private room;
135
+ private localStream;
136
+ private screenStream;
137
+ private isScreenSharing;
138
+ private screenSenders;
139
+ private pingInterval;
140
+ private pendingIceCandidates;
141
+ private pendingOffers;
142
+ private reconnectAttempts;
143
+ private reconnectTimer?;
144
+ private participantName;
145
+ readonly state: MeetingState;
146
+ private joinResolver?;
147
+ private joinRejecter?;
148
+ private isWaitingForApproval;
149
+ private pendingRequestId;
150
+ private iceTransportPolicy;
151
+ private emitError;
152
+ constructor(events?: Events, url?: string);
153
+ initLocal(video: HTMLVideoElement, name: string): Promise<void>;
154
+ connect(roomId: string, name: string): Promise<void>;
155
+ joinMeeting(config: MeetingConfig): Promise<void>;
156
+ getMeeting(): {
157
+ id: string | null;
158
+ name: string | null;
159
+ };
160
+ toggleMic(): void;
161
+ toggleCam(): void;
162
+ private scheduleReconnect;
163
+ private startHeartbeat;
164
+ private stopHeartbeat;
165
+ private reset;
166
+ private handleJoinApproved;
167
+ private handle;
168
+ private createPeer;
169
+ private createOffer;
170
+ private shouldInitiate;
171
+ private handleOffer;
172
+ private closePeer;
173
+ startScreenShare(): Promise<MediaStream>;
174
+ stopScreenShare(): void;
175
+ sendChatMessage(payload: ChatInput): void;
176
+ disconnect(): void;
177
+ private flushIce;
178
+ private send;
179
+ approveJoinRequest(requestId: string): void;
180
+ rejectJoinRequest(requestId: string): void;
181
+ }
182
+
183
+ type PubSubHandle = {
184
+ messages: ChatMessage[];
185
+ publish: (input: ChatInput) => void;
186
+ };
187
+ type MeetingContextValue = {
188
+ sdk: VideoSDKCore;
189
+ join: (config?: MeetingConfig) => Promise<void>;
190
+ leave: () => void;
191
+ toggleMic: () => void;
192
+ toggleCam: () => void;
193
+ startScreenShare: () => Promise<MediaStream>;
194
+ stopScreenShare: () => void;
195
+ sendMessage: (input: ChatInput) => void;
196
+ room: {
197
+ id: string | null;
198
+ name: string | null;
199
+ };
200
+ localParticipant: Participant | null;
201
+ participants: Map<string, Participant>;
202
+ messages: ChatMessage[];
203
+ presenterId: string | null;
204
+ usePubSub: (topic: PubSubTopic) => PubSubHandle;
205
+ approveJoinRequest: (requestId: string) => void;
206
+ rejectJoinRequest: (requestId: string) => void;
207
+ onError: (cb: (err: any) => void) => () => void;
208
+ onEntryRequested: (cb: (req: any) => void) => () => void;
209
+ onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
210
+ onMeetingLeft: (cb: () => void) => () => void;
211
+ };
212
+ declare const MeetingProvider: ({ config, children, }: {
213
+ config: MeetingConfig;
214
+ children: react__default.ReactNode;
215
+ }) => react_jsx_runtime.JSX.Element;
216
+ declare const useMeetingContext: () => MeetingContextValue;
217
+
218
+ declare const useMeeting: (handlers?: {
219
+ onError?: (err: any) => void;
220
+ onEntryRequested?: (req: any) => void;
221
+ onEntryResponded?: (payload: any, decision?: any) => void;
222
+ onMeetingLeft?: () => void;
223
+ }) => {
224
+ join: (config?: MeetingConfig) => Promise<void>;
225
+ leave: () => void;
226
+ toggleMic: () => void;
227
+ toggleCam: () => void;
228
+ startScreenShare: () => Promise<MediaStream>;
229
+ stopScreenShare: () => void;
230
+ sendMessage: (input: ChatInput) => void;
231
+ room: {
232
+ id: string | null;
233
+ name: string | null;
234
+ };
235
+ localParticipant: Participant | null;
236
+ participants: Map<string, Participant>;
237
+ messages: ChatMessage[];
238
+ presenterId: string | null;
239
+ usePubSub: (topic: PubSubTopic) => {
240
+ messages: ChatMessage[];
241
+ publish: (input: ChatInput) => void;
242
+ };
243
+ approveJoinRequest: (requestId: string) => void;
244
+ rejectJoinRequest: (requestId: string) => void;
245
+ onError: (cb: (err: any) => void) => () => void;
246
+ onEntryRequested: (cb: (req: any) => void) => () => void;
247
+ onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
248
+ onMeetingLeft: (cb: () => void) => () => void;
249
+ };
250
+
251
+ declare const useParticipants: () => Participant[];
252
+
253
+ declare const useRemoteMedia: (participantId: string) => {
254
+ videoRef: react.RefObject<HTMLVideoElement | null>;
255
+ audioRef: react.RefObject<HTMLAudioElement | null>;
256
+ isCamActive: boolean;
257
+ isMicEnabled: boolean;
258
+ };
259
+
260
+ type LiveRoomState = {
261
+ active: boolean;
262
+ count: number;
263
+ canJoin: boolean;
264
+ approved: boolean;
265
+ isHost: boolean;
266
+ hasMoreParticipants: boolean;
267
+ participants: {
268
+ id: string;
269
+ name: string;
270
+ isHost: boolean;
271
+ isPresenter: boolean;
272
+ micEnabled: boolean;
273
+ camEnabled: boolean;
274
+ }[];
275
+ };
276
+ declare function useMeetingPreview(roomId: string, userId: string): {
277
+ room: LiveRoomState | null;
278
+ isConnected: boolean;
279
+ isLoading: boolean;
280
+ error: string | null;
281
+ };
282
+
283
+ export { type ChatInput, MeetingProvider, MeetingState, type Participant, VideoSDKCore, useLocalParticipant, useMeeting, useMeetingContext, useMeetingPreview, useParticipants, useRemoteMedia };
@@ -0,0 +1,283 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import react__default from 'react';
4
+
5
+ type Events = {
6
+ onMicToggled?: (peerId: string, enabled: boolean) => void;
7
+ onError?: (err: SDKError) => void;
8
+ onCamToggled?: (peerId: string, enabled: boolean) => void;
9
+ onTrack?: (stream: MediaStream, peerId: string) => void;
10
+ onScreenTrack?: (stream: MediaStream, peerId: string) => void;
11
+ onUserJoined?: (p: Participant) => void;
12
+ onEntryRequested?: (req: EntryRequest) => void;
13
+ onEntryResponded?: (payload: {
14
+ participantId: string;
15
+ decision: EntryDecision;
16
+ } | string, decision?: EntryDecision) => void;
17
+ onJoinApproved?: (requestId: string) => void;
18
+ onJoinRejected?: (requestId: string) => void;
19
+ onRoomUpdate?: (data: any) => void;
20
+ onUserLeft?: (id: string) => void;
21
+ onMeetingLeft?: () => void;
22
+ onChatMessage?: (msg: ChatMessage) => void;
23
+ onScreenShareStarted?: (peerId: string, stream: MediaStream) => void;
24
+ onScreenShareStopped?: (peerId: string) => void;
25
+ onMuteStateChanged?: (peerId: string, kind: "audio" | "video", muted: boolean) => void;
26
+ };
27
+ type ChatMessage = {
28
+ id: string;
29
+ text: string;
30
+ sender_id: string;
31
+ sender_name?: string;
32
+ timestamp: number;
33
+ reply_to?: {
34
+ id: string;
35
+ name: string;
36
+ } | null;
37
+ target?: string | null;
38
+ };
39
+ type Participant = {
40
+ id: string;
41
+ name?: string;
42
+ isHost?: boolean;
43
+ isLocal?: boolean;
44
+ media?: ParticipantMedia;
45
+ isPresenter?: boolean;
46
+ };
47
+ type ParticipantMedia = {
48
+ stream?: MediaStream | null;
49
+ screenStream?: MediaStream | null;
50
+ cameraTrack?: MediaStreamTrack;
51
+ screenTrack?: MediaStreamTrack;
52
+ audioTrack?: MediaStreamTrack;
53
+ micEnabled: boolean;
54
+ camEnabled: boolean;
55
+ isScreenSharing: boolean;
56
+ remoteScreenStreamId?: string;
57
+ cameraStreamId?: string;
58
+ };
59
+ type Listener = () => void;
60
+ type ChatInput = {
61
+ message: string;
62
+ reply_to?: {
63
+ id: string;
64
+ name: string;
65
+ } | null;
66
+ target?: string | null;
67
+ };
68
+ type MeetingConfig = {
69
+ roomId: string;
70
+ name: string;
71
+ audioMuted?: boolean;
72
+ videoMuted?: boolean;
73
+ token?: string;
74
+ };
75
+ type PubSubTopic = "SECURE_CHAT";
76
+ type StateScope = "participants" | "localParticipant" | "chat" | "presenter" | `participant:${string}`;
77
+ type SDKError = {
78
+ code: string;
79
+ message: string;
80
+ roomId?: string | null;
81
+ userId?: string;
82
+ raw?: any;
83
+ recoverable?: boolean;
84
+ };
85
+ type EntryDecision = "approved" | "rejected";
86
+ type EntryRequest = {
87
+ requestId: string;
88
+ userId: string;
89
+ name: string;
90
+ };
91
+
92
+ declare const useLocalParticipant: () => {
93
+ participant: Participant | null;
94
+ videoRef: (video: HTMLVideoElement | null) => void;
95
+ };
96
+
97
+ type LocalParticipantPatch = {
98
+ id?: string;
99
+ name?: string;
100
+ media?: Partial<ParticipantMedia>;
101
+ };
102
+ declare class MeetingState {
103
+ participants: Map<string, Participant>;
104
+ localParticipant: Participant | null;
105
+ localStream: MediaStream | null;
106
+ chatMessages: Map<string, ChatMessage>;
107
+ presenterId: string | null;
108
+ private listeners;
109
+ subscribe(scope: StateScope, fn: Listener): () => void;
110
+ notify(scope: StateScope): void;
111
+ setPresenterId(id: string | null): void;
112
+ addParticipant(p: Participant): boolean;
113
+ removeParticipant(id: string): void;
114
+ updateParticipantMedia(id: string, patch: Partial<NonNullable<Participant["media"]>>): void;
115
+ updateLocalParticipant(patch: LocalParticipantPatch): void;
116
+ addChatMessage(msg: ChatMessage): void;
117
+ getChatMessages(): ChatMessage[];
118
+ clearChat(): void;
119
+ getParticipants(): Participant[];
120
+ getParticipant(id: string): Participant | null;
121
+ resetRemoteState(): void;
122
+ }
123
+
124
+ declare class VideoSDKCore {
125
+ private events;
126
+ private url;
127
+ private ws;
128
+ private peers;
129
+ private initiators;
130
+ private lastPong;
131
+ private iceServers;
132
+ private intentionalDisconnect;
133
+ private myId;
134
+ private room;
135
+ private localStream;
136
+ private screenStream;
137
+ private isScreenSharing;
138
+ private screenSenders;
139
+ private pingInterval;
140
+ private pendingIceCandidates;
141
+ private pendingOffers;
142
+ private reconnectAttempts;
143
+ private reconnectTimer?;
144
+ private participantName;
145
+ readonly state: MeetingState;
146
+ private joinResolver?;
147
+ private joinRejecter?;
148
+ private isWaitingForApproval;
149
+ private pendingRequestId;
150
+ private iceTransportPolicy;
151
+ private emitError;
152
+ constructor(events?: Events, url?: string);
153
+ initLocal(video: HTMLVideoElement, name: string): Promise<void>;
154
+ connect(roomId: string, name: string): Promise<void>;
155
+ joinMeeting(config: MeetingConfig): Promise<void>;
156
+ getMeeting(): {
157
+ id: string | null;
158
+ name: string | null;
159
+ };
160
+ toggleMic(): void;
161
+ toggleCam(): void;
162
+ private scheduleReconnect;
163
+ private startHeartbeat;
164
+ private stopHeartbeat;
165
+ private reset;
166
+ private handleJoinApproved;
167
+ private handle;
168
+ private createPeer;
169
+ private createOffer;
170
+ private shouldInitiate;
171
+ private handleOffer;
172
+ private closePeer;
173
+ startScreenShare(): Promise<MediaStream>;
174
+ stopScreenShare(): void;
175
+ sendChatMessage(payload: ChatInput): void;
176
+ disconnect(): void;
177
+ private flushIce;
178
+ private send;
179
+ approveJoinRequest(requestId: string): void;
180
+ rejectJoinRequest(requestId: string): void;
181
+ }
182
+
183
+ type PubSubHandle = {
184
+ messages: ChatMessage[];
185
+ publish: (input: ChatInput) => void;
186
+ };
187
+ type MeetingContextValue = {
188
+ sdk: VideoSDKCore;
189
+ join: (config?: MeetingConfig) => Promise<void>;
190
+ leave: () => void;
191
+ toggleMic: () => void;
192
+ toggleCam: () => void;
193
+ startScreenShare: () => Promise<MediaStream>;
194
+ stopScreenShare: () => void;
195
+ sendMessage: (input: ChatInput) => void;
196
+ room: {
197
+ id: string | null;
198
+ name: string | null;
199
+ };
200
+ localParticipant: Participant | null;
201
+ participants: Map<string, Participant>;
202
+ messages: ChatMessage[];
203
+ presenterId: string | null;
204
+ usePubSub: (topic: PubSubTopic) => PubSubHandle;
205
+ approveJoinRequest: (requestId: string) => void;
206
+ rejectJoinRequest: (requestId: string) => void;
207
+ onError: (cb: (err: any) => void) => () => void;
208
+ onEntryRequested: (cb: (req: any) => void) => () => void;
209
+ onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
210
+ onMeetingLeft: (cb: () => void) => () => void;
211
+ };
212
+ declare const MeetingProvider: ({ config, children, }: {
213
+ config: MeetingConfig;
214
+ children: react__default.ReactNode;
215
+ }) => react_jsx_runtime.JSX.Element;
216
+ declare const useMeetingContext: () => MeetingContextValue;
217
+
218
+ declare const useMeeting: (handlers?: {
219
+ onError?: (err: any) => void;
220
+ onEntryRequested?: (req: any) => void;
221
+ onEntryResponded?: (payload: any, decision?: any) => void;
222
+ onMeetingLeft?: () => void;
223
+ }) => {
224
+ join: (config?: MeetingConfig) => Promise<void>;
225
+ leave: () => void;
226
+ toggleMic: () => void;
227
+ toggleCam: () => void;
228
+ startScreenShare: () => Promise<MediaStream>;
229
+ stopScreenShare: () => void;
230
+ sendMessage: (input: ChatInput) => void;
231
+ room: {
232
+ id: string | null;
233
+ name: string | null;
234
+ };
235
+ localParticipant: Participant | null;
236
+ participants: Map<string, Participant>;
237
+ messages: ChatMessage[];
238
+ presenterId: string | null;
239
+ usePubSub: (topic: PubSubTopic) => {
240
+ messages: ChatMessage[];
241
+ publish: (input: ChatInput) => void;
242
+ };
243
+ approveJoinRequest: (requestId: string) => void;
244
+ rejectJoinRequest: (requestId: string) => void;
245
+ onError: (cb: (err: any) => void) => () => void;
246
+ onEntryRequested: (cb: (req: any) => void) => () => void;
247
+ onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
248
+ onMeetingLeft: (cb: () => void) => () => void;
249
+ };
250
+
251
+ declare const useParticipants: () => Participant[];
252
+
253
+ declare const useRemoteMedia: (participantId: string) => {
254
+ videoRef: react.RefObject<HTMLVideoElement | null>;
255
+ audioRef: react.RefObject<HTMLAudioElement | null>;
256
+ isCamActive: boolean;
257
+ isMicEnabled: boolean;
258
+ };
259
+
260
+ type LiveRoomState = {
261
+ active: boolean;
262
+ count: number;
263
+ canJoin: boolean;
264
+ approved: boolean;
265
+ isHost: boolean;
266
+ hasMoreParticipants: boolean;
267
+ participants: {
268
+ id: string;
269
+ name: string;
270
+ isHost: boolean;
271
+ isPresenter: boolean;
272
+ micEnabled: boolean;
273
+ camEnabled: boolean;
274
+ }[];
275
+ };
276
+ declare function useMeetingPreview(roomId: string, userId: string): {
277
+ room: LiveRoomState | null;
278
+ isConnected: boolean;
279
+ isLoading: boolean;
280
+ error: string | null;
281
+ };
282
+
283
+ export { type ChatInput, MeetingProvider, MeetingState, type Participant, VideoSDKCore, useLocalParticipant, useMeeting, useMeetingContext, useMeetingPreview, useParticipants, useRemoteMedia };