react-jssip-kit 0.5.1 → 0.5.3

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