react-jssip-kit 0.5.1 → 0.5.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.
package/dist/index.d.ts CHANGED
@@ -1,87 +1,389 @@
1
- import * as jssip_lib_UA from 'jssip/lib/UA';
2
- import { UAEventMap, IncomingRTCSessionEvent, UAConfiguration, CallOptions, RTCSessionEvent } from 'jssip/lib/UA';
3
- export { CallOptions, RTCSessionEvent, UAEventMap } from 'jssip/lib/UA';
4
- import * as jssip_lib_RTCSession from 'jssip/lib/RTCSession';
5
- import { RTCSessionEventMap, DTFMOptions as DTFMOptions$1, AnswerOptions, TerminateOptions, RTCSession, ReferOptions } from 'jssip/lib/RTCSession';
6
- export { AnswerOptions, RTCSession, RTCSessionEventMap, ReferOptions, TerminateOptions } from 'jssip/lib/RTCSession';
7
1
  import { UA } from 'jssip';
8
2
  export { WebSocketInterface } from 'jssip';
9
3
  import * as react from 'react';
10
4
  import react__default from 'react';
11
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
12
6
 
7
+ type Originator = "local" | "remote" | "system";
8
+ type SessionDirection = "incoming" | "outgoing";
9
+
10
+ interface SIPURI {
11
+ user: string;
12
+ }
13
+
14
+ interface NameAddrHeader {
15
+ uri: SIPURI;
16
+ }
17
+
18
+ interface IncomingRequest {
19
+ body?: string | { toString(): string };
20
+ from: NameAddrHeader;
21
+ to: NameAddrHeader;
22
+ }
23
+
24
+ interface OutgoingRequest {
25
+ body?: string | { toString(): string };
26
+ from: NameAddrHeader;
27
+ to: NameAddrHeader;
28
+ }
29
+
30
+ interface IncomingResponse {
31
+ status_code?: number;
32
+ reason_phrase?: string;
33
+ }
34
+
35
+ interface ExtraHeaders {
36
+ extraHeaders?: string[];
37
+ }
38
+
39
+ interface AnswerOptions extends ExtraHeaders {
40
+ mediaConstraints?: MediaStreamConstraints;
41
+ mediaStream?: MediaStream;
42
+ pcConfig?: RTCConfiguration;
43
+ rtcConstraints?: object;
44
+ rtcAnswerConstraints?: RTCOfferOptions;
45
+ rtcOfferConstraints?: RTCOfferOptions;
46
+ sessionTimersExpires?: number;
47
+ }
48
+
49
+ interface RejectOptions extends ExtraHeaders {
50
+ status_code?: number;
51
+ reason_phrase?: string;
52
+ }
53
+
54
+ interface TerminateOptions extends RejectOptions {
55
+ body?: string;
56
+ cause?: string;
57
+ }
58
+
59
+ interface ReferOptions extends ExtraHeaders {
60
+ eventHandlers?: Record<string, unknown>;
61
+ replaces?: RTCSession;
62
+ }
63
+
64
+ interface DTFMOptions extends ExtraHeaders {
65
+ duration?: number;
66
+ interToneGap?: number;
67
+ transportType?: string;
68
+ }
69
+
70
+ interface HoldOptions extends ExtraHeaders {
71
+ useUpdate?: boolean;
72
+ }
73
+
74
+ interface MediaStreamTypes {
75
+ audio?: boolean;
76
+ video?: boolean;
77
+ }
78
+
79
+ interface DTMF {
80
+ tone: string;
81
+ duration: number;
82
+ }
83
+
84
+ interface Info {
85
+ contentType: string;
86
+ body: string;
87
+ }
88
+
89
+ interface PeerConnectionEvent {
90
+ peerconnection: RTCPeerConnection;
91
+ }
92
+
93
+ interface ConnectingEvent {
94
+ request: IncomingRequest | OutgoingRequest;
95
+ }
96
+
97
+ interface SendingEvent {
98
+ request: OutgoingRequest;
99
+ }
100
+
101
+ interface IncomingEvent {
102
+ originator: Originator;
103
+ }
104
+
105
+ interface OutgoingEvent {
106
+ originator: Originator;
107
+ response?: IncomingResponse;
108
+ }
109
+
110
+ interface IncomingAckEvent {
111
+ originator: Originator;
112
+ ack: IncomingRequest;
113
+ }
114
+
115
+ interface OutgoingAckEvent {
116
+ originator: Originator;
117
+ }
118
+
119
+ interface EndEvent {
120
+ originator: Originator;
121
+ message?: IncomingRequest | IncomingResponse;
122
+ cause?: string;
123
+ }
124
+
125
+ interface IncomingDTMFEvent {
126
+ originator: Originator;
127
+ dtmf: DTMF;
128
+ request?: IncomingRequest;
129
+ }
130
+
131
+ interface OutgoingDTMFEvent {
132
+ originator: Originator;
133
+ dtmf: DTMF;
134
+ request?: OutgoingRequest;
135
+ }
136
+
137
+ interface IncomingInfoEvent {
138
+ originator: Originator;
139
+ info: Info;
140
+ request?: IncomingRequest;
141
+ }
142
+
143
+ interface OutgoingInfoEvent {
144
+ originator: Originator;
145
+ info: Info;
146
+ request?: OutgoingRequest;
147
+ }
148
+
149
+ interface HoldEvent {
150
+ originator: Originator;
151
+ }
152
+
153
+ interface ReInviteEvent {
154
+ request?: IncomingRequest;
155
+ callback?: VoidFunction;
156
+ reject?: (options?: RejectOptions) => void;
157
+ }
158
+
159
+ interface ReferEvent {
160
+ request?: IncomingRequest;
161
+ accept?: () => void;
162
+ reject?: VoidFunction;
163
+ }
164
+
165
+ interface SDPEvent {
166
+ originator: Originator;
167
+ type: string;
168
+ sdp: string;
169
+ }
170
+
171
+ interface IceCandidateEvent {
172
+ candidate: RTCIceCandidate;
173
+ ready: VoidFunction;
174
+ }
175
+
176
+ interface IncomingRTCSessionEvent {
177
+ originator: "remote";
178
+ session: RTCSession;
179
+ request: IncomingRequest;
180
+ }
181
+
182
+ interface OutgoingRTCSessionEvent {
183
+ originator: "local";
184
+ session: RTCSession;
185
+ request: OutgoingRequest;
186
+ }
187
+
188
+ type RTCSessionEvent = IncomingRTCSessionEvent | OutgoingRTCSessionEvent;
189
+
190
+ type RTCSessionEventMap = {
191
+ peerconnection: (event: PeerConnectionEvent) => void;
192
+ connecting: (event: ConnectingEvent) => void;
193
+ sending: (event: SendingEvent) => void;
194
+ progress: (event: IncomingEvent | OutgoingEvent) => void;
195
+ accepted: (event: IncomingEvent | OutgoingEvent) => void;
196
+ confirmed: (event: IncomingAckEvent | OutgoingAckEvent) => void;
197
+ ended: (event: EndEvent) => void;
198
+ failed: (event: EndEvent) => void;
199
+ newDTMF: (event: IncomingDTMFEvent | OutgoingDTMFEvent) => void;
200
+ newInfo: (event: IncomingInfoEvent | OutgoingInfoEvent) => void;
201
+ hold: (event: HoldEvent) => void;
202
+ unhold: (event: HoldEvent) => void;
203
+ muted: (event: MediaStreamTypes) => void;
204
+ unmuted: (event: MediaStreamTypes) => void;
205
+ reinvite: (event: ReInviteEvent) => void;
206
+ update: (event: ReInviteEvent) => void;
207
+ refer: (event: ReferEvent) => void;
208
+ replaces: (event: ReferEvent) => void;
209
+ sdp: (event: SDPEvent) => void;
210
+ icecandidate: (event: IceCandidateEvent) => void;
211
+ getusermediafailed: (error: unknown) => void;
212
+ "peerconnection:createofferfailed": (error: unknown) => void;
213
+ "peerconnection:createanswerfailed": (error: unknown) => void;
214
+ "peerconnection:setlocaldescriptionfailed": (error: unknown) => void;
215
+ "peerconnection:setremotedescriptionfailed": (error: unknown) => void;
216
+ };
217
+
218
+ interface RTCSession {
219
+ id: string;
220
+ direction: SessionDirection;
221
+ connection?: RTCPeerConnection;
222
+ answer(options?: AnswerOptions): void;
223
+ terminate(options?: TerminateOptions): void;
224
+ mute(options?: MediaStreamTypes): void;
225
+ unmute(options?: MediaStreamTypes): void;
226
+ hold(options?: HoldOptions, done?: VoidFunction): boolean;
227
+ unhold(options?: HoldOptions, done?: VoidFunction): boolean;
228
+ sendDTMF(tones: string | number, options?: DTFMOptions): void;
229
+ refer(target: string | RTCSession, options?: ReferOptions): void;
230
+ on<K extends keyof RTCSessionEventMap>(
231
+ type: K,
232
+ listener: RTCSessionEventMap[K]
233
+ ): this;
234
+ off<K extends keyof RTCSessionEventMap>(
235
+ type: K,
236
+ listener: RTCSessionEventMap[K]
237
+ ): this;
238
+ }
239
+
240
+ interface UAConfiguration {
241
+ sockets: unknown | unknown[];
242
+ uri: string;
243
+ password?: string;
244
+ [key: string]: unknown;
245
+ }
246
+
247
+ interface CallOptions extends AnswerOptions {
248
+ eventHandlers?: Partial<RTCSessionEventMap>;
249
+ anonymous?: boolean;
250
+ fromUserName?: string;
251
+ fromDisplayName?: string;
252
+ }
253
+
254
+ interface ConnectingUAEvent {
255
+ socket: unknown;
256
+ attempts: number;
257
+ }
258
+
259
+ interface ConnectedEvent {
260
+ socket: unknown;
261
+ }
262
+
263
+ interface DisconnectEvent {
264
+ socket: unknown;
265
+ error: boolean;
266
+ code?: number;
267
+ reason?: string;
268
+ }
269
+
270
+ interface RegisteredEvent {
271
+ response: IncomingResponse;
272
+ }
273
+
274
+ interface UnRegisteredEvent {
275
+ response: IncomingResponse;
276
+ cause?: string;
277
+ }
278
+
279
+ interface IncomingMessageEvent {
280
+ originator: Originator;
281
+ message: unknown;
282
+ request: IncomingRequest;
283
+ }
284
+
285
+ interface OutgoingMessageEvent {
286
+ originator: Originator;
287
+ message: unknown;
288
+ request: OutgoingRequest;
289
+ }
290
+
291
+ interface IncomingOptionsEvent {
292
+ originator: Originator;
293
+ request: IncomingRequest;
294
+ }
295
+
296
+ interface OutgoingOptionsEvent {
297
+ originator: Originator;
298
+ request: OutgoingRequest;
299
+ }
300
+
301
+ type UAEventMap = {
302
+ connecting: (event: ConnectingUAEvent) => void;
303
+ connected: (event: ConnectedEvent) => void;
304
+ disconnected: (event: DisconnectEvent) => void;
305
+ registered: (event: RegisteredEvent) => void;
306
+ unregistered: (event: UnRegisteredEvent) => void;
307
+ registrationFailed: (event: UnRegisteredEvent) => void;
308
+ registrationExpiring: () => void;
309
+ newRTCSession: (event: RTCSessionEvent) => void;
310
+ newMessage: (event: IncomingMessageEvent | OutgoingMessageEvent) => void;
311
+ sipEvent: (event: { event: unknown; request: IncomingRequest }) => void;
312
+ newOptions: (event: IncomingOptionsEvent | OutgoingOptionsEvent) => void;
313
+ };
314
+
13
315
  type UAExtraEvents = {
14
- error: {
15
- cause: string;
16
- code?: string;
17
- raw?: any;
18
- message?: string;
19
- };
316
+ error: { cause: string; code?: string; raw?: any; message?: string };
20
317
  missed: IncomingRTCSessionEvent;
21
318
  };
22
319
 
23
320
  type UAEventName = keyof UAEventMap | keyof UAExtraEvents;
24
321
  type SessionEventName = keyof RTCSessionEventMap;
25
- declare const JsSIPEventName: {
26
- readonly connecting: "connecting";
27
- readonly connected: "connected";
28
- readonly disconnected: "disconnected";
29
- readonly registered: "registered";
30
- readonly unregistered: "unregistered";
31
- readonly registrationFailed: "registrationFailed";
32
- readonly registrationExpiring: "registrationExpiring";
33
- readonly newRTCSession: "newRTCSession";
34
- readonly newMessage: "newMessage";
35
- readonly sipEvent: "sipEvent";
36
- readonly newOptions: "newOptions";
37
- readonly peerconnection: "peerconnection";
38
- readonly sending: "sending";
39
- readonly progress: "progress";
40
- readonly accepted: "accepted";
41
- readonly confirmed: "confirmed";
42
- readonly ended: "ended";
43
- readonly failed: "failed";
44
- readonly newDTMF: "newDTMF";
45
- readonly newInfo: "newInfo";
46
- readonly hold: "hold";
47
- readonly unhold: "unhold";
48
- readonly muted: "muted";
49
- readonly unmuted: "unmuted";
50
- readonly reinvite: "reinvite";
51
- readonly update: "update";
52
- readonly refer: "refer";
53
- readonly replaces: "replaces";
54
- readonly sdp: "sdp";
55
- readonly error: "error";
56
- readonly icecandidate: "icecandidate";
57
- readonly getusermediafailed: "getusermediafailed";
58
- readonly "peerconnection:createofferfailed": "peerconnection:createofferfailed";
59
- readonly "peerconnection:createanswerfailed": "peerconnection:createanswerfailed";
322
+
323
+ declare const JsSIPEventName: {
324
+ readonly connecting: "connecting";
325
+ readonly connected: "connected";
326
+ readonly disconnected: "disconnected";
327
+ readonly registered: "registered";
328
+ readonly unregistered: "unregistered";
329
+ readonly registrationFailed: "registrationFailed";
330
+ readonly registrationExpiring: "registrationExpiring";
331
+ readonly newRTCSession: "newRTCSession";
332
+ readonly newMessage: "newMessage";
333
+ readonly sipEvent: "sipEvent";
334
+ readonly newOptions: "newOptions";
335
+ readonly peerconnection: "peerconnection";
336
+ readonly sending: "sending";
337
+ readonly progress: "progress";
338
+ readonly accepted: "accepted";
339
+ readonly confirmed: "confirmed";
340
+ readonly ended: "ended";
341
+ readonly failed: "failed";
342
+ readonly newDTMF: "newDTMF";
343
+ readonly newInfo: "newInfo";
344
+ readonly hold: "hold";
345
+ readonly unhold: "unhold";
346
+ readonly muted: "muted";
347
+ readonly unmuted: "unmuted";
348
+ readonly reinvite: "reinvite";
349
+ readonly update: "update";
350
+ readonly refer: "refer";
351
+ readonly replaces: "replaces";
352
+ readonly sdp: "sdp";
353
+ readonly error: "error";
354
+ readonly icecandidate: "icecandidate";
355
+ readonly getusermediafailed: "getusermediafailed";
356
+ readonly "peerconnection:createofferfailed": "peerconnection:createofferfailed";
357
+ readonly "peerconnection:createanswerfailed": "peerconnection:createanswerfailed";
60
358
  readonly "peerconnection:setlocaldescriptionfailed": "peerconnection:setlocaldescriptionfailed";
61
359
  readonly "peerconnection:setremotedescriptionfailed": "peerconnection:setremotedescriptionfailed";
62
360
  readonly missed: "missed";
63
361
  };
64
362
  type JsSIPEventName = UAEventName | SessionEventName;
65
- type UAEventPayload<K extends UAEventName> =
66
- K extends keyof UAEventMap
67
- ? Parameters<UAEventMap[K]>[0]
68
- : K extends keyof UAExtraEvents
69
- ? UAExtraEvents[K]
70
- : never;
363
+
364
+ type UAEventPayload<K extends UAEventName> = K extends keyof UAEventMap
365
+ ? Parameters<UAEventMap[K]>[0]
366
+ : K extends keyof UAExtraEvents
367
+ ? UAExtraEvents[K]
368
+ : never;
369
+
71
370
  type SessionEventPayload<K extends SessionEventName> =
72
371
  K extends keyof RTCSessionEventMap ? Parameters<RTCSessionEventMap[K]>[0] : never;
73
- type JsSIPEventPayload<K extends JsSIPEventName> =
74
- K extends UAEventName
75
- ? UAEventPayload<K>
76
- : K extends SessionEventName
77
- ? SessionEventPayload<K>
78
- : never;
372
+
373
+ type JsSIPEventPayload<K extends JsSIPEventName> = K extends UAEventName
374
+ ? UAEventPayload<K>
375
+ : K extends SessionEventName
376
+ ? SessionEventPayload<K>
377
+ : never;
378
+
79
379
  type JsSIPEventHandler<K extends JsSIPEventName> = (
80
380
  payload?: JsSIPEventPayload<K>
81
381
  ) => void;
82
- type SipEventHandlers = {
83
- [K in JsSIPEventName]?: JsSIPEventHandler<K>;
84
- };
382
+
383
+ type SipEventHandlers = {
384
+ [K in JsSIPEventName]?: JsSIPEventHandler<K>;
385
+ };
386
+
85
387
  interface SipEventManager {
86
388
  onUA: <K extends UAEventName>(
87
389
  event: K,
@@ -93,25 +395,24 @@ interface SipEventManager {
93
395
  handler: (payload?: SessionEventPayload<K>) => void
94
396
  ) => () => void;
95
397
  }
96
- type JsSIPEventMap = {
97
- [K in JsSIPEventName]: JsSIPEventPayload<K>;
98
- };
99
-
100
- type DTFMOptions = DTFMOptions$1;
101
-
102
- type SipConfiguration = Omit<UAConfiguration, "password" | "uri"> & {
103
- /**
104
- * Enable JsSIP debug logging. If string, treated as debug pattern.
105
- */
106
- debug?: boolean | string;
107
- /**
108
- * Maximum allowed concurrent sessions. Additional sessions are rejected.
109
- */
110
- maxSessionCount?: number;
111
- /**
112
- * Milliseconds to keep enqueued outgoing media before dropping. Defaults to 30000.
113
- */
114
- pendingMediaTtlMs?: number;
398
+
399
+ type JsSIPEventMap = {
400
+ [K in JsSIPEventName]: JsSIPEventPayload<K>;
401
+ };
402
+
403
+ type SipConfiguration = Omit<UAConfiguration, "password" | "uri"> & {
404
+ /**
405
+ * Enable JsSIP debug logging. If string, treated as debug pattern.
406
+ */
407
+ debug?: boolean | string;
408
+ /**
409
+ * Maximum allowed concurrent sessions. Additional sessions are rejected.
410
+ */
411
+ maxSessionCount?: number;
412
+ /**
413
+ * Milliseconds to keep enqueued outgoing media before dropping. Defaults to 30000.
414
+ */
415
+ pendingMediaTtlMs?: number;
115
416
  };
116
417
 
117
418
  type StartOpts = {
@@ -292,19 +593,19 @@ declare const SipContext: react.Context<SipContextType | null>;
292
593
  declare function useSipState(): SipState;
293
594
 
294
595
  declare function useSipActions(): {
295
- call: (target: string, callOptions?: jssip_lib_UA.CallOptions | undefined) => void;
296
- answer: (sessionId: string, options?: jssip_lib_RTCSession.AnswerOptions | undefined) => boolean;
297
- hangup: (sessionId: string, options?: jssip_lib_RTCSession.TerminateOptions | undefined) => boolean;
596
+ call: (target: string, callOptions?: CallOptions | undefined) => void;
597
+ answer: (sessionId: string, options?: AnswerOptions | undefined) => boolean;
598
+ hangup: (sessionId: string, options?: TerminateOptions | undefined) => boolean;
298
599
  toggleMute: (sessionId?: string | undefined) => boolean;
299
600
  toggleHold: (sessionId?: string | undefined) => boolean;
300
- sendDTMF: (sessionId: string, tones: string | number, options?: jssip_lib_RTCSession.DTFMOptions | undefined) => boolean;
301
- transfer: (sessionId: string, target: string | jssip_lib_RTCSession.RTCSession, options?: jssip_lib_RTCSession.ReferOptions | undefined) => boolean;
302
- attendedTransfer: (sessionId: string, otherSession: jssip_lib_RTCSession.RTCSession) => boolean;
303
- getSession: (sessionId: string) => jssip_lib_RTCSession.RTCSession | null;
601
+ sendDTMF: (sessionId: string, tones: string | number, options?: DTFMOptions | undefined) => boolean;
602
+ transfer: (sessionId: string, target: string | RTCSession, options?: ReferOptions | undefined) => boolean;
603
+ attendedTransfer: (sessionId: string, otherSession: RTCSession) => boolean;
604
+ getSession: (sessionId: string) => RTCSession | null;
304
605
  getSessionIds: () => string[];
305
606
  getSessions: () => {
306
607
  id: string;
307
- session: jssip_lib_RTCSession.RTCSession;
608
+ session: RTCSession;
308
609
  }[];
309
610
  setSessionMedia: (sessionId: string, stream: MediaStream) => void;
310
611
  switchCamera: (sessionId: string, track: MediaStreamTrack) => false | Promise<boolean>;
@@ -329,4 +630,4 @@ declare function SipProvider({ client, children, sipEventManager, }: {
329
630
  children: react__default.ReactNode;
330
631
  }): react_jsx_runtime.JSX.Element;
331
632
 
332
- export { CallDirection, CallDirection as CallDirectionType, CallPlayer, CallStatus, CallStatus as CallStatusType, type DTFMOptions, type JsSIPEventMap, JsSIPEventName, type SessionEventName, type SessionEventPayload, type SipConfiguration, SipContext, type SipContextType, type SipEventHandlers, type SipEventManager, SipProvider, type SipSessionState, type SipState, SipStatus, SipStatus as SipStatusType, type UAEventName, type UAEventPayload, createSipClientInstance, createSipEventManager, useSip, useSipActions, useSipEvent, useSipSessionEvent, useSipSessions, useSipState };
633
+ export { type AnswerOptions, CallDirection, CallDirection as CallDirectionType, type CallOptions, CallPlayer, CallStatus, CallStatus as CallStatusType, type DTFMOptions, type JsSIPEventMap, JsSIPEventName, type RTCSession, type RTCSessionEvent, type RTCSessionEventMap, type ReferOptions, type SessionEventName, type SessionEventPayload, type SipConfiguration, SipContext, type SipContextType, type SipEventHandlers, type SipEventManager, SipProvider, type SipSessionState, type SipState, SipStatus, SipStatus as SipStatusType, type TerminateOptions, type UAEventMap, type UAEventName, type UAEventPayload, createSipClientInstance, createSipEventManager, useSip, useSipActions, useSipEvent, useSipSessionEvent, useSipSessions, useSipState };