@tencentcloud/tccc-sip-js 0.1.0

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/jssip.d.ts ADDED
@@ -0,0 +1,1099 @@
1
+ import { Debug } from 'debug';
2
+ import { EventEmitter, Listener } from 'events';
3
+ import { Stream as Stream$1 } from 'trtc-js-sdk';
4
+
5
+ declare const USER_AGENT: string
6
+ declare const SIP = 'sip'
7
+ declare const SIPS = 'sips'
8
+
9
+ declare enum causes {
10
+ CONNECTION_ERROR = 'Connection Error',
11
+ REQUEST_TIMEOUT = 'Request Timeout',
12
+ SIP_FAILURE_CODE = 'SIP Failure Code',
13
+ INTERNAL_ERROR = 'Internal Error',
14
+ BUSY = 'Busy',
15
+ REJECTED = 'Rejected',
16
+ REDIRECTED = 'Redirected',
17
+ UNAVAILABLE = 'Unavailable',
18
+ NOT_FOUND = 'Not Found',
19
+ ADDRESS_INCOMPLETE = 'Address Incomplete',
20
+ INCOMPATIBLE_SDP = 'Incompatible SDP',
21
+ MISSING_SDP = 'Missing SDP',
22
+ AUTHENTICATION_ERROR = 'Authentication Error',
23
+ BYE = 'Terminated',
24
+ WEBRTC_ERROR = 'WebRTC Error',
25
+ CANCELED = 'Canceled',
26
+ NO_ANSWER = 'No Answer',
27
+ EXPIRES = 'Expires',
28
+ NO_ACK = 'No ACK',
29
+ DIALOG_ERROR = 'Dialog Error',
30
+ USER_DENIED_MEDIA_ACCESS = 'User Denied Media Access',
31
+ BAD_MEDIA_DESCRIPTION = 'Bad Media Description',
32
+ RTP_TIMEOUT = 'RTP Timeout',
33
+ }
34
+
35
+ declare const SIP_ERROR_CAUSES: {
36
+ REDIRECTED: [300, 301, 302, 305, 380],
37
+ BUSY: [486, 600],
38
+ REJECTED: [403, 603],
39
+ NOT_FOUND: [404, 604],
40
+ UNAVAILABLE: [480, 410, 408, 430],
41
+ ADDRESS_INCOMPLETE: [484, 424],
42
+ INCOMPATIBLE_SDP: [488, 606],
43
+ AUTHENTICATION_ERROR: [401, 407]
44
+ }
45
+ declare const ACK = 'ACK'
46
+ declare const BYE = 'BYE'
47
+ declare const CANCEL = 'CANCEL'
48
+ declare const INFO = 'INFO'
49
+ declare const INVITE = 'INVITE'
50
+ declare const MESSAGE = 'MESSAGE'
51
+ declare const NOTIFY = 'NOTIFY'
52
+ declare const OPTIONS = 'OPTIONS'
53
+ declare const REGISTER = 'REGISTER'
54
+ declare const REFER = 'REFER'
55
+ declare const UPDATE = 'UPDATE'
56
+ declare const SUBSCRIBE = 'SUBSCRIBE'
57
+
58
+ declare enum DTMF_TRANSPORT {
59
+ INFO = 'INFO',
60
+ RFC2833 = 'RFC2833',
61
+ }
62
+
63
+ declare const REASON_PHRASE: Record<number, string>
64
+ declare const ALLOWED_METHODS = 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY'
65
+ declare const ACCEPTED_BODY_TYPES = 'application/sdp, application/dtmf-relay'
66
+ declare const MAX_FORWARDS = 69
67
+ declare const SESSION_EXPIRES = 90
68
+ declare const MIN_SESSION_EXPIRES = 60
69
+ declare const CONNECTION_RECOVERY_MAX_INTERVAL = 30
70
+ declare const CONNECTION_RECOVERY_MIN_INTERVAL = 2
71
+ enum LOG_LEVEL {
72
+ TRACE = 0,
73
+ DEBUG = 1,
74
+ WARN = 2,
75
+ ERROR = 3,
76
+ NONE = 4
77
+ }
78
+
79
+ declare const Constants_d_USER_AGENT: typeof USER_AGENT;
80
+ declare const Constants_d_SIP: typeof SIP;
81
+ declare const Constants_d_SIPS: typeof SIPS;
82
+ type Constants_d_causes = causes;
83
+ declare const Constants_d_causes: typeof causes;
84
+ declare const Constants_d_SIP_ERROR_CAUSES: typeof SIP_ERROR_CAUSES;
85
+ declare const Constants_d_ACK: typeof ACK;
86
+ declare const Constants_d_BYE: typeof BYE;
87
+ declare const Constants_d_CANCEL: typeof CANCEL;
88
+ declare const Constants_d_INFO: typeof INFO;
89
+ declare const Constants_d_INVITE: typeof INVITE;
90
+ declare const Constants_d_MESSAGE: typeof MESSAGE;
91
+ declare const Constants_d_NOTIFY: typeof NOTIFY;
92
+ declare const Constants_d_OPTIONS: typeof OPTIONS;
93
+ declare const Constants_d_REGISTER: typeof REGISTER;
94
+ declare const Constants_d_REFER: typeof REFER;
95
+ declare const Constants_d_UPDATE: typeof UPDATE;
96
+ declare const Constants_d_SUBSCRIBE: typeof SUBSCRIBE;
97
+ type Constants_d_DTMF_TRANSPORT = DTMF_TRANSPORT;
98
+ declare const Constants_d_DTMF_TRANSPORT: typeof DTMF_TRANSPORT;
99
+ declare const Constants_d_REASON_PHRASE: typeof REASON_PHRASE;
100
+ declare const Constants_d_ALLOWED_METHODS: typeof ALLOWED_METHODS;
101
+ declare const Constants_d_ACCEPTED_BODY_TYPES: typeof ACCEPTED_BODY_TYPES;
102
+ declare const Constants_d_MAX_FORWARDS: typeof MAX_FORWARDS;
103
+ declare const Constants_d_SESSION_EXPIRES: typeof SESSION_EXPIRES;
104
+ declare const Constants_d_MIN_SESSION_EXPIRES: typeof MIN_SESSION_EXPIRES;
105
+ declare const Constants_d_CONNECTION_RECOVERY_MAX_INTERVAL: typeof CONNECTION_RECOVERY_MAX_INTERVAL;
106
+ declare const Constants_d_CONNECTION_RECOVERY_MIN_INTERVAL: typeof CONNECTION_RECOVERY_MIN_INTERVAL;
107
+ type Constants_d_LOG_LEVEL = LOG_LEVEL;
108
+ declare const Constants_d_LOG_LEVEL: typeof LOG_LEVEL;
109
+ declare namespace Constants_d {
110
+ export {
111
+ Constants_d_USER_AGENT as USER_AGENT,
112
+ Constants_d_SIP as SIP,
113
+ Constants_d_SIPS as SIPS,
114
+ Constants_d_causes as causes,
115
+ Constants_d_SIP_ERROR_CAUSES as SIP_ERROR_CAUSES,
116
+ Constants_d_ACK as ACK,
117
+ Constants_d_BYE as BYE,
118
+ Constants_d_CANCEL as CANCEL,
119
+ Constants_d_INFO as INFO,
120
+ Constants_d_INVITE as INVITE,
121
+ Constants_d_MESSAGE as MESSAGE,
122
+ Constants_d_NOTIFY as NOTIFY,
123
+ Constants_d_OPTIONS as OPTIONS,
124
+ Constants_d_REGISTER as REGISTER,
125
+ Constants_d_REFER as REFER,
126
+ Constants_d_UPDATE as UPDATE,
127
+ Constants_d_SUBSCRIBE as SUBSCRIBE,
128
+ Constants_d_DTMF_TRANSPORT as DTMF_TRANSPORT,
129
+ Constants_d_REASON_PHRASE as REASON_PHRASE,
130
+ Constants_d_ALLOWED_METHODS as ALLOWED_METHODS,
131
+ Constants_d_ACCEPTED_BODY_TYPES as ACCEPTED_BODY_TYPES,
132
+ Constants_d_MAX_FORWARDS as MAX_FORWARDS,
133
+ Constants_d_SESSION_EXPIRES as SESSION_EXPIRES,
134
+ Constants_d_MIN_SESSION_EXPIRES as MIN_SESSION_EXPIRES,
135
+ Constants_d_CONNECTION_RECOVERY_MAX_INTERVAL as CONNECTION_RECOVERY_MAX_INTERVAL,
136
+ Constants_d_CONNECTION_RECOVERY_MIN_INTERVAL as CONNECTION_RECOVERY_MIN_INTERVAL,
137
+ Constants_d_LOG_LEVEL as LOG_LEVEL,
138
+ };
139
+ }
140
+
141
+ declare class BaseError extends Error {
142
+ code: number
143
+ }
144
+
145
+ declare class ConfigurationError extends BaseError {
146
+ parameter: string
147
+ value: any
148
+
149
+ constructor(parameter: string, value?: any);
150
+ }
151
+
152
+ declare class InvalidStateError extends BaseError {
153
+ status: number
154
+
155
+ constructor(status: number);
156
+ }
157
+
158
+ declare class NotSupportedError extends BaseError {
159
+ constructor(message: string);
160
+ }
161
+
162
+ declare class NotReadyError extends BaseError {
163
+ constructor(message: string);
164
+ }
165
+
166
+ type Exceptions_d_ConfigurationError = ConfigurationError;
167
+ declare const Exceptions_d_ConfigurationError: typeof ConfigurationError;
168
+ type Exceptions_d_InvalidStateError = InvalidStateError;
169
+ declare const Exceptions_d_InvalidStateError: typeof InvalidStateError;
170
+ type Exceptions_d_NotSupportedError = NotSupportedError;
171
+ declare const Exceptions_d_NotSupportedError: typeof NotSupportedError;
172
+ type Exceptions_d_NotReadyError = NotReadyError;
173
+ declare const Exceptions_d_NotReadyError: typeof NotReadyError;
174
+ declare namespace Exceptions_d {
175
+ export {
176
+ Exceptions_d_ConfigurationError as ConfigurationError,
177
+ Exceptions_d_InvalidStateError as InvalidStateError,
178
+ Exceptions_d_NotSupportedError as NotSupportedError,
179
+ Exceptions_d_NotReadyError as NotReadyError,
180
+ };
181
+ }
182
+
183
+ type Grammar = any;
184
+
185
+ declare function parse(input: string, startRule?: string): Grammar;
186
+
187
+ declare function toSource(): any;
188
+
189
+ type Grammar_d_Grammar = Grammar;
190
+ declare const Grammar_d_parse: typeof parse;
191
+ declare const Grammar_d_toSource: typeof toSource;
192
+ declare namespace Grammar_d {
193
+ export {
194
+ Grammar_d_Grammar as Grammar,
195
+ Grammar_d_parse as parse,
196
+ Grammar_d_toSource as toSource,
197
+ };
198
+ }
199
+
200
+ type URIScheme = 'sip' | string;
201
+
202
+ type Parameters = Record<string, string | null>;
203
+
204
+ type Headers = Record<string, string | string[]>;
205
+
206
+ declare class URI {
207
+ scheme: URIScheme
208
+ user: string
209
+ host: string
210
+ port: number
211
+
212
+ constructor(scheme: URIScheme, user: string, host: string, port?: number, parameters?: Parameters, headers?: Headers);
213
+
214
+ setParam(key: string, value?: string): void;
215
+
216
+ getParam<T = unknown>(key: string): T;
217
+
218
+ hasParam(key: string): boolean;
219
+
220
+ deleteParam(key: string): void;
221
+
222
+ clearParams(): void;
223
+
224
+ setHeader(key: string, value: string | string[]): void;
225
+
226
+ getHeader(key: string): string[];
227
+
228
+ hasHeader(key: string): boolean;
229
+
230
+ deleteHeader(key: string): void;
231
+
232
+ clearHeaders(): void;
233
+
234
+ clone(): this;
235
+
236
+ toString(): string;
237
+
238
+ toAor(): string;
239
+
240
+ static parse(uri: string): Grammar | undefined;
241
+ }
242
+
243
+ declare function str_utf8_length(str: string): number;
244
+
245
+ declare function isFunction(func: unknown): boolean;
246
+
247
+ declare function isString(str: unknown): str is string;
248
+
249
+ declare function isDecimal(num: unknown): num is number;
250
+
251
+ declare function isEmpty(value: unknown): boolean;
252
+
253
+ declare function hasMethods(obj: any, ...methodNames: string[]): boolean;
254
+
255
+ declare function newTag(): string;
256
+
257
+ declare function newUUID(): string;
258
+
259
+ declare function hostType(host: string): string;
260
+
261
+ declare function escapeUser(user: string): string;
262
+
263
+ declare function normalizeTarget(target: URI | string, domain?: string): URI | undefined;
264
+
265
+ declare function headerize(str: string): string;
266
+
267
+ declare function sipErrorCause(status_code: number): causes;
268
+
269
+ declare function getRandomTestNetIP(): string;
270
+
271
+ declare function calculateMD5(str: string): string;
272
+
273
+ declare function closeMediaStream(stream?: MediaStream): void;
274
+
275
+ declare function cloneArray<T = unknown>(arr: T[]): T[];
276
+
277
+ declare function cloneObject<T>(obj: T, fallback?: T): T;
278
+
279
+ declare function toPlainObject<T extends object>(obj: T): T
280
+
281
+ declare function isMiniProgram(): boolean;
282
+
283
+ declare const Utils_d_str_utf8_length: typeof str_utf8_length;
284
+ declare const Utils_d_isFunction: typeof isFunction;
285
+ declare const Utils_d_isString: typeof isString;
286
+ declare const Utils_d_isDecimal: typeof isDecimal;
287
+ declare const Utils_d_isEmpty: typeof isEmpty;
288
+ declare const Utils_d_hasMethods: typeof hasMethods;
289
+ declare const Utils_d_newTag: typeof newTag;
290
+ declare const Utils_d_newUUID: typeof newUUID;
291
+ declare const Utils_d_hostType: typeof hostType;
292
+ declare const Utils_d_escapeUser: typeof escapeUser;
293
+ declare const Utils_d_normalizeTarget: typeof normalizeTarget;
294
+ declare const Utils_d_headerize: typeof headerize;
295
+ declare const Utils_d_sipErrorCause: typeof sipErrorCause;
296
+ declare const Utils_d_getRandomTestNetIP: typeof getRandomTestNetIP;
297
+ declare const Utils_d_calculateMD5: typeof calculateMD5;
298
+ declare const Utils_d_closeMediaStream: typeof closeMediaStream;
299
+ declare const Utils_d_cloneArray: typeof cloneArray;
300
+ declare const Utils_d_cloneObject: typeof cloneObject;
301
+ declare const Utils_d_toPlainObject: typeof toPlainObject;
302
+ declare const Utils_d_isMiniProgram: typeof isMiniProgram;
303
+ declare namespace Utils_d {
304
+ export {
305
+ Utils_d_str_utf8_length as str_utf8_length,
306
+ Utils_d_isFunction as isFunction,
307
+ Utils_d_isString as isString,
308
+ Utils_d_isDecimal as isDecimal,
309
+ Utils_d_isEmpty as isEmpty,
310
+ Utils_d_hasMethods as hasMethods,
311
+ Utils_d_newTag as newTag,
312
+ Utils_d_newUUID as newUUID,
313
+ Utils_d_hostType as hostType,
314
+ Utils_d_escapeUser as escapeUser,
315
+ Utils_d_normalizeTarget as normalizeTarget,
316
+ Utils_d_headerize as headerize,
317
+ Utils_d_sipErrorCause as sipErrorCause,
318
+ Utils_d_getRandomTestNetIP as getRandomTestNetIP,
319
+ Utils_d_calculateMD5 as calculateMD5,
320
+ Utils_d_closeMediaStream as closeMediaStream,
321
+ Utils_d_cloneArray as cloneArray,
322
+ Utils_d_cloneObject as cloneObject,
323
+ Utils_d_toPlainObject as toPlainObject,
324
+ Utils_d_isMiniProgram as isMiniProgram,
325
+ };
326
+ }
327
+
328
+ declare function getMicrophones(): Promise<Array<MediaDeviceInfo>>
329
+ declare function getSpeakers(): Promise<Array<MediaDeviceInfo>>
330
+ declare function getDevices(): Promise<Array<MediaDeviceInfo>>
331
+
332
+ declare const Devices_d_getMicrophones: typeof getMicrophones;
333
+ declare const Devices_d_getSpeakers: typeof getSpeakers;
334
+ declare const Devices_d_getDevices: typeof getDevices;
335
+ declare namespace Devices_d {
336
+ export {
337
+ Devices_d_getMicrophones as getMicrophones,
338
+ Devices_d_getSpeakers as getSpeakers,
339
+ Devices_d_getDevices as getDevices,
340
+ };
341
+ }
342
+
343
+ declare class Logger {
344
+ constructor(prefix?: string);
345
+ static setLogLevel(level: LOG_LEVEL);
346
+ static setLogReport(bool: boolean);
347
+ static setConfig(config: object);
348
+ static setAttributes(attr: object);
349
+ debug(...args: any[])
350
+ warn(...args: any[])
351
+ error(...args: any[])
352
+ }
353
+
354
+ interface WeightedSocket {
355
+ socket: Socket;
356
+ weight: number
357
+ }
358
+
359
+ declare class Socket {
360
+ get via_transport(): string;
361
+ set via_transport(value: string);
362
+
363
+ get url(): string;
364
+
365
+ get sip_uri(): string;
366
+
367
+ connect(): void;
368
+
369
+ disconnect(): void;
370
+
371
+ send(message: string | ArrayBufferLike | Blob | ArrayBufferView): boolean;
372
+
373
+ isConnected(): boolean;
374
+
375
+ isConnecting(): boolean;
376
+
377
+ onconnect(): void;
378
+
379
+ ondisconnect(error: boolean, code?: number, reason?: string): void;
380
+
381
+ ondata<T>(event: T): void;
382
+ }
383
+
384
+ declare class NameAddrHeader {
385
+ get display_name(): string;
386
+ set display_name(value: string);
387
+
388
+ get uri(): URI;
389
+
390
+ constructor(uri: URI, display_name?: string, parameters?: Parameters);
391
+
392
+ setParam(key: string, value?: string): void;
393
+
394
+ getParam<T = any>(key: string): T;
395
+
396
+ hasParam(key: string): boolean;
397
+
398
+ deleteParam(key: string): void;
399
+
400
+ clearParams(): void;
401
+
402
+ clone(): this;
403
+
404
+ toString(): string;
405
+
406
+ static parse(uri: string): Grammar | undefined;
407
+ }
408
+
409
+ declare class IncomingMessage {
410
+ method: string
411
+ from: NameAddrHeader
412
+ to: NameAddrHeader
413
+ body: string
414
+
415
+ constructor();
416
+
417
+ countHeader(name: string): number;
418
+
419
+ getHeader(name: string): string;
420
+
421
+ getHeaders(name: string): string[];
422
+
423
+ hasHeader(name: string): boolean;
424
+
425
+ parseHeader<T = unknown>(name: string, idx?: number): T;
426
+
427
+ toString(): string;
428
+ }
429
+
430
+ declare class IncomingRequest extends IncomingMessage {
431
+ ruri: URI
432
+ }
433
+
434
+ declare class IncomingResponse extends IncomingMessage {
435
+ status_code: number
436
+ reason_phrase: string
437
+ }
438
+
439
+ declare class OutgoingRequest {
440
+ method: string
441
+ ruri: URI
442
+ cseq: number
443
+ call_id: string
444
+ from: NameAddrHeader
445
+ to: NameAddrHeader
446
+ body: string
447
+
448
+ setHeader(name: string, value: string | string[]): void;
449
+
450
+ getHeader(name: string): string;
451
+
452
+ getHeaders(name: string): string[];
453
+
454
+ hasHeader(name: string): boolean;
455
+
456
+ toString(): string;
457
+ }
458
+
459
+ declare class Stream extends EventEmitter {
460
+ constructor(options: {
461
+ audio: boolean,
462
+ video: boolean
463
+ })
464
+
465
+ get mediaStream(): MediaStream
466
+
467
+ getMediaStream(): MediaStream
468
+ }
469
+
470
+ declare class RemoteStream extends Stream {
471
+ constructor(options: {
472
+ mediaStream: MediaStream
473
+ })
474
+
475
+ get type(): 'remote';
476
+ }
477
+
478
+ declare class LocalStream extends Stream {
479
+ get type(): 'local';
480
+
481
+ initialize(): Promise<LocalStream>;
482
+
483
+ close(): void;
484
+ }
485
+
486
+ interface RTCPeerConnectionDeprecated extends RTCPeerConnection {
487
+ /**
488
+ * @deprecated
489
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getRemoteStreams
490
+ */
491
+ getRemoteStreams(): MediaStream[];
492
+ }
493
+
494
+ declare enum SessionDirection {
495
+ INCOMING = 'incoming',
496
+ OUTGOING = 'outgoing',
497
+ }
498
+
499
+ declare enum Originator {
500
+ LOCAL = 'local',
501
+ REMOTE = 'remote',
502
+ SYSTEM = 'system',
503
+ }
504
+
505
+ // options
506
+ interface MediaConstraints {
507
+ audio?: boolean;
508
+ video?: boolean;
509
+ }
510
+
511
+ interface ExtraHeaders {
512
+ extraHeaders?: string[];
513
+ }
514
+
515
+ interface AnswerOptions extends ExtraHeaders {
516
+ mediaConstraints?: MediaConstraints;
517
+ mediaStream?: MediaStream;
518
+ pcConfig?: RTCConfiguration;
519
+ rtcConstraints?: object;
520
+ rtcAnswerConstraints?: RTCOfferOptions;
521
+ rtcOfferConstraints?: RTCOfferOptions;
522
+ sessionTimersExpires?: number;
523
+ // trtc localStream config
524
+ streamConfig?: {
525
+ audio?: boolean;
526
+ microphoneId?: string;
527
+ screenAudio?: boolean;
528
+ audioSource: MediaStreamTrack;
529
+ }
530
+ }
531
+
532
+ interface RejectOptions extends ExtraHeaders {
533
+ status_code?: number;
534
+ reason_phrase?: string;
535
+ }
536
+
537
+ interface TerminateOptions extends RejectOptions {
538
+ body?: string;
539
+ cause?: causes | string;
540
+ }
541
+
542
+ interface ReferOptions extends ExtraHeaders {
543
+ eventHandlers?: any;
544
+ replaces?: RTCSession;
545
+ }
546
+
547
+ interface OnHoldResult {
548
+ local: boolean;
549
+ remote: boolean;
550
+ }
551
+
552
+ interface DTFMOptions extends ExtraHeaders {
553
+ duration?: number;
554
+ interToneGap?: number;
555
+ transportType?: DTMF_TRANSPORT;
556
+ }
557
+
558
+ interface HoldOptions extends ExtraHeaders {
559
+ useUpdate?: boolean;
560
+ }
561
+
562
+ interface RenegotiateOptions extends HoldOptions {
563
+ rtcOfferConstraints?: RTCOfferOptions;
564
+ }
565
+
566
+ // events
567
+ interface DTMF extends EventEmitter {
568
+ tone: string;
569
+ duration: number;
570
+ }
571
+
572
+ interface Info extends EventEmitter {
573
+ contentType: string;
574
+ body: string;
575
+ }
576
+
577
+ interface PeerConnectionEvent {
578
+ peerconnection: RTCPeerConnectionDeprecated;
579
+ }
580
+
581
+ interface ConnectingEvent$1 {
582
+ request: IncomingRequest | OutgoingRequest;
583
+ }
584
+
585
+ interface SendingEvent {
586
+ request: OutgoingRequest
587
+ }
588
+
589
+ interface IncomingEvent {
590
+ originator: Originator.LOCAL;
591
+ }
592
+
593
+ interface EndEvent {
594
+ originator: Originator;
595
+ message: IncomingRequest | IncomingResponse;
596
+ cause: string;
597
+ }
598
+
599
+ interface IncomingDTMFEvent {
600
+ originator: Originator.REMOTE;
601
+ dtmf: DTMF;
602
+ request: IncomingRequest;
603
+ }
604
+
605
+ interface OutgoingDTMFEvent {
606
+ originator: Originator.LOCAL;
607
+ dtmf: DTMF;
608
+ request: OutgoingRequest;
609
+ }
610
+
611
+ interface IncomingInfoEvent {
612
+ originator: Originator.REMOTE;
613
+ info: Info;
614
+ request: IncomingRequest;
615
+ }
616
+
617
+ interface OutgoingInfoEvent {
618
+ originator: Originator.LOCAL;
619
+ info: Info;
620
+ request: OutgoingRequest;
621
+ }
622
+
623
+ interface HoldEvent {
624
+ originator: Originator
625
+ }
626
+
627
+ interface ReInviteEvent {
628
+ request: IncomingRequest;
629
+ callback?: VoidFunction;
630
+ reject: (options?: RejectOptions) => void;
631
+ }
632
+
633
+ interface ReferEvent {
634
+ request: IncomingRequest;
635
+ accept: Function;
636
+ reject: VoidFunction;
637
+ }
638
+
639
+ interface SDPEvent {
640
+ originator: Originator;
641
+ type: string;
642
+ sdp: string;
643
+ }
644
+
645
+ interface IceCandidateEvent {
646
+ candidate: RTCIceCandidate;
647
+ ready: VoidFunction;
648
+ }
649
+
650
+ interface OutgoingEvent {
651
+ originator: Originator.REMOTE;
652
+ response: IncomingResponse;
653
+ }
654
+
655
+ interface OutgoingAckEvent {
656
+ originator: Originator.LOCAL;
657
+ }
658
+
659
+ interface IncomingAckEvent {
660
+ originator: Originator.REMOTE;
661
+ ack: IncomingRequest;
662
+ }
663
+
664
+ type NetworkQuality = 0 | 1 | 2 | 3 | 4 | 5 | 6;
665
+
666
+ interface NetworkQualityEvent {
667
+ uplinkNetworkQuality: NetworkQuality;
668
+ downlinkNetworkQuality: NetworkQuality;
669
+ uplinkRTT: number;
670
+ downlinkRTT: number;
671
+ uplinkLoss: number;
672
+ downlinkLoss: number;
673
+ }
674
+
675
+ type AudioVolume = {
676
+ originator: Originator
677
+ userId: string;
678
+ audioVolume: number;
679
+ stream: Stream$1[];
680
+ }
681
+ interface AudioVolumeEvent {
682
+ result: AudioVolume[]
683
+ }
684
+ interface StreamChangeEvent {
685
+ stream: RemoteStream
686
+ }
687
+
688
+ // listener
689
+ type PeerConnectionListener = (event: PeerConnectionEvent) => void;
690
+ type ConnectingListener$1 = (event: ConnectingEvent$1) => void;
691
+ type SendingListener = (event: SendingEvent) => void;
692
+ type IncomingListener = (event: IncomingEvent) => void;
693
+ type OutgoingListener = (event: OutgoingEvent) => void;
694
+ type IncomingConfirmedListener = (event: IncomingAckEvent) => void;
695
+ type OutgoingConfirmedListener = (event: OutgoingAckEvent) => void;
696
+ type CallListener = IncomingListener | OutgoingListener;
697
+ type ConfirmedListener = IncomingConfirmedListener | OutgoingConfirmedListener;
698
+ type EndListener = (event: EndEvent) => void;
699
+ type IncomingDTMFListener = (event: IncomingDTMFEvent) => void;
700
+ type OutgoingDTMFListener = (event: OutgoingDTMFEvent) => void;
701
+ type DTMFListener = IncomingDTMFListener | OutgoingDTMFListener;
702
+ type IncomingInfoListener = (event: IncomingInfoEvent) => void;
703
+ type OutgoingInfoListener = (event: OutgoingInfoEvent) => void;
704
+ type InfoListener = IncomingInfoListener | OutgoingInfoListener;
705
+ type HoldListener = (event: HoldEvent) => void;
706
+ type MuteListener = (event: MediaConstraints) => void;
707
+ type ReInviteListener = (event: ReInviteEvent) => void;
708
+ type UpdateListener = ReInviteListener;
709
+ type ReferListener = (event: ReferEvent) => void;
710
+ type SDPListener = (event: SDPEvent) => void;
711
+ type IceCandidateListener = (event: IceCandidateEvent) => void;
712
+ type NetworkQualityListener = (event: NetworkQualityEvent) => void;
713
+ type AudioVolumeListener = (event: AudioVolumeEvent) => void;
714
+ type StreamChangeListener = (event: StreamChangeEvent) => void;
715
+
716
+ interface RTCSessionEventMap {
717
+ 'peerconnection': PeerConnectionListener;
718
+ 'connecting': ConnectingListener$1;
719
+ 'sending': SendingListener;
720
+ 'progress': CallListener;
721
+ 'accepted': CallListener;
722
+ 'confirmed': ConfirmedListener;
723
+ 'ended': EndListener;
724
+ 'failed': EndListener;
725
+ 'newDTMF': DTMFListener;
726
+ 'newInfo': InfoListener;
727
+ 'hold': HoldListener;
728
+ 'unhold': HoldListener;
729
+ 'muted': MuteListener;
730
+ 'unmuted': MuteListener;
731
+ 'reinvite': ReInviteListener;
732
+ 'update': UpdateListener;
733
+ 'refer': ReferListener;
734
+ 'replaces': ReferListener;
735
+ 'sdp': SDPListener;
736
+ 'icecandidate': IceCandidateListener;
737
+ 'networkquality': NetworkQualityListener;
738
+ 'audiovolume': AudioVolumeListener;
739
+ 'addstream': StreamChangeListener;
740
+ 'stream-subscribed': StreamChangeListener;
741
+ 'remotestream': StreamChangeListener;
742
+ 'stream-removed': StreamChangeListener;
743
+ 'stream-updated': StreamChangeListener;
744
+ 'getusermediafailed': Listener;
745
+ 'peerconnection:createofferfailed': Listener;
746
+ 'peerconnection:createanswerfailed': Listener;
747
+ 'peerconnection:setlocaldescriptionfailed': Listener;
748
+ 'peerconnection:setremotedescriptionfailed': Listener;
749
+ }
750
+
751
+ declare enum SessionStatus {
752
+ STATUS_NULL = 0,
753
+ STATUS_INVITE_SENT = 1,
754
+ STATUS_1XX_RECEIVED = 2,
755
+ STATUS_INVITE_RECEIVED = 3,
756
+ STATUS_WAITING_FOR_ANSWER = 4,
757
+ STATUS_ANSWERED = 5,
758
+ STATUS_WAITING_FOR_ACK = 6,
759
+ STATUS_CANCELED = 7,
760
+ STATUS_TERMINATED = 8,
761
+ STATUS_CONFIRMED = 9
762
+ }
763
+
764
+ declare class RTCSession extends EventEmitter {
765
+ static get C(): typeof SessionStatus;
766
+
767
+ get C(): typeof SessionStatus;
768
+
769
+ get causes(): typeof causes;
770
+
771
+ get id(): string;
772
+
773
+ set data(_data: any);
774
+ get data(): any;
775
+
776
+ get connection(): RTCPeerConnectionDeprecated;
777
+
778
+ get contact(): string;
779
+
780
+ get direction(): SessionDirection;
781
+
782
+ get local_identity(): NameAddrHeader;
783
+
784
+ get remote_identity(): NameAddrHeader;
785
+
786
+ get start_time(): Date;
787
+
788
+ get end_time(): Date;
789
+
790
+ get status(): SessionStatus;
791
+
792
+ get localStreams(): LocalStream[];
793
+
794
+ get remoteStreams(): RemoteStream[]
795
+
796
+ isInProgress(): boolean;
797
+
798
+ isEstablished(): boolean;
799
+
800
+ isEnded(): boolean;
801
+
802
+ isReadyToReOffer(): boolean;
803
+
804
+ answer(options?: AnswerOptions): void;
805
+
806
+ terminate(options?: TerminateOptions): void;
807
+
808
+ sendDTMF(tones: string | number, options?: DTFMOptions): void;
809
+
810
+ sendInfo(contentType: string, body?: string, options?: ExtraHeaders): void;
811
+
812
+ hold(options?: HoldOptions, done?: VoidFunction): boolean;
813
+
814
+ unhold(options?: HoldOptions, done?: VoidFunction): boolean;
815
+
816
+ renegotiate(options?: RenegotiateOptions, done?: VoidFunction): boolean;
817
+
818
+ isOnHold(): OnHoldResult;
819
+
820
+ mute(options?: MediaConstraints): void;
821
+
822
+ unmute(options?: MediaConstraints): void;
823
+
824
+ isMuted(): MediaConstraints;
825
+
826
+ refer(target: string | URI, options?: ReferOptions): void;
827
+
828
+ switchMicrophones(deviceId: string): Promise<void>;
829
+
830
+ switchSpeaker(deviceId: string): Promise<void>;
831
+
832
+ setAudioVolume(volume: number): void;
833
+
834
+ enableAudioVolumeEvaluation(interval?: number, enableInBackground?: boolean): void;
835
+
836
+ on<T extends keyof RTCSessionEventMap>(type: T, listener: RTCSessionEventMap[T]): this;
837
+ }
838
+
839
+ interface AcceptOptions extends ExtraHeaders {
840
+ body?: string;
841
+ }
842
+
843
+ interface MessageFailedEvent {
844
+ originator: Originator;
845
+ response: IncomingResponse;
846
+ cause?: causes;
847
+ }
848
+
849
+ type MessageFailedListener = (event: MessageFailedEvent) => void;
850
+
851
+ interface MessageEventMap {
852
+ succeeded: OutgoingListener;
853
+ failed: MessageFailedListener;
854
+ }
855
+
856
+ interface SendMessageOptions extends ExtraHeaders {
857
+ contentType?: string;
858
+ eventHandlers?: Partial<MessageEventMap>;
859
+ fromUserName?: string;
860
+ fromDisplayName?: string;
861
+ }
862
+
863
+ declare class Message extends EventEmitter {
864
+ get direction(): SessionDirection;
865
+
866
+ get local_identity(): NameAddrHeader;
867
+
868
+ get remote_identity(): NameAddrHeader;
869
+
870
+ send(target: string, body: string, options?: SendMessageOptions): void;
871
+
872
+ accept(options: AcceptOptions): void;
873
+
874
+ reject(options: TerminateOptions): void;
875
+
876
+ on<T extends keyof MessageEventMap>(type: T, listener: MessageEventMap[T]): this;
877
+ }
878
+
879
+ interface RecoveryOptions {
880
+ min_interval: number;
881
+ max_interval: number;
882
+ }
883
+
884
+ declare class Transport extends Socket {
885
+ constructor(sockets: Socket | Socket[], recovery_options?: RecoveryOptions)
886
+ }
887
+
888
+ type ExtraContactParams = Record<string, string | number | boolean>;
889
+
890
+ declare class Registrator {
891
+ constructor(ua: UA, transport: Transport);
892
+
893
+ setExtraHeaders(extraHeaders: string[]): void;
894
+
895
+ setExtraContactParams(extraContactParams: ExtraContactParams): void;
896
+ }
897
+
898
+ interface UnRegisterOptions {
899
+ all?: boolean;
900
+ }
901
+
902
+ interface CallOptions extends AnswerOptions {
903
+ eventHandlers?: Partial<RTCSessionEventMap>;
904
+ anonymous?: boolean;
905
+ fromUserName?: string;
906
+ fromDisplayName?: string;
907
+ }
908
+
909
+ interface UAConfiguration {
910
+ // mandatory parameters
911
+ sockets: Socket | Socket[] | WeightedSocket[] ;
912
+ uri: string;
913
+ // optional parameters
914
+ authorization_jwt?: string;
915
+ authorization_user?: string;
916
+ connection_recovery_max_interval?: number;
917
+ connection_recovery_min_interval?: number;
918
+ contact_uri?: string;
919
+ display_name?: string;
920
+ instance_id?: string;
921
+ no_answer_timeout?: number;
922
+ session_timers?: boolean;
923
+ session_timers_refresh_method?: string;
924
+ session_timers_force_refresher?: boolean;
925
+ password?: string;
926
+ realm?: string;
927
+ ha1?: string;
928
+ register?: boolean;
929
+ register_expires?: number;
930
+ registrar_server?: string;
931
+ use_preloaded_route?: boolean;
932
+ user_agent?: string;
933
+ extra_headers?: string[];
934
+ log_level?: LOG_LEVEL;
935
+ log_report?: boolean;
936
+ use_trtc?: boolean;
937
+ }
938
+
939
+ interface IncomingRTCSessionEvent {
940
+ originator: Originator.REMOTE;
941
+ session: RTCSession;
942
+ request: IncomingRequest;
943
+ }
944
+
945
+ interface OutgoingRTCSessionEvent {
946
+ originator: Originator.LOCAL;
947
+ session: RTCSession;
948
+ request: IncomingRequest;
949
+ }
950
+
951
+ interface ConnectingEvent {
952
+ socket: Socket;
953
+ attempts: number
954
+ }
955
+
956
+ interface ConnectedEvent {
957
+ socket: Socket;
958
+ }
959
+
960
+ interface DisconnectEvent {
961
+ socket: Socket;
962
+ error: boolean;
963
+ code?: number;
964
+ reason?: string;
965
+ }
966
+
967
+ interface RegisteredEvent {
968
+ response: IncomingResponse;
969
+ }
970
+
971
+ interface UnRegisteredEvent {
972
+ response: IncomingResponse;
973
+ cause?: causes;
974
+ }
975
+
976
+ interface IncomingMessageEvent {
977
+ originator: Originator.REMOTE;
978
+ message: Message;
979
+ request: IncomingRequest;
980
+ }
981
+
982
+ interface OutgoingMessageEvent {
983
+ originator: Originator.LOCAL;
984
+ message: Message;
985
+ request: OutgoingRequest;
986
+ }
987
+
988
+ interface IncomingOptionsEvent {
989
+ originator: Originator.REMOTE;
990
+ request: IncomingRequest;
991
+ }
992
+
993
+ interface OutgoingOptionsEvent {
994
+ originator: Originator.LOCAL;
995
+ request: OutgoingRequest;
996
+ }
997
+
998
+ type ConnectingListener = (event: ConnectingEvent) => void;
999
+ type ConnectedListener = (event: ConnectedEvent) => void;
1000
+ type DisconnectedListener = (event: DisconnectEvent) => void;
1001
+ type RegisteredListener = (event: RegisteredEvent) => void;
1002
+ type UnRegisteredListener = (event: UnRegisteredEvent) => void;
1003
+ type RegistrationFailedListener = UnRegisteredListener;
1004
+ type IncomingRTCSessionListener = (event: IncomingRTCSessionEvent) => void;
1005
+ type OutgoingRTCSessionListener = (event: OutgoingRTCSessionEvent) => void;
1006
+ type RTCSessionListener = IncomingRTCSessionListener | OutgoingRTCSessionListener;
1007
+ type IncomingMessageListener = (event: IncomingMessageEvent) => void;
1008
+ type OutgoingMessageListener = (event: OutgoingMessageEvent) => void;
1009
+ type MessageListener = IncomingMessageListener | OutgoingMessageListener;
1010
+ type IncomingOptionsListener = (event: IncomingOptionsEvent) => void;
1011
+ type OutgoingOptionsListener = (event: OutgoingOptionsEvent) => void;
1012
+ type OptionsListener = IncomingOptionsListener | OutgoingOptionsListener;
1013
+ type SipEventListener = <T = any>(event: { event: T; request: IncomingRequest; }) => void
1014
+
1015
+ interface UAEventMap {
1016
+ connecting: ConnectingListener;
1017
+ connected: ConnectedListener;
1018
+ disconnected: DisconnectedListener;
1019
+ registered: RegisteredListener;
1020
+ unregistered: UnRegisteredListener;
1021
+ registrationFailed: RegistrationFailedListener;
1022
+ registrationExpiring: Listener;
1023
+ newRTCSession: RTCSessionListener;
1024
+ newMessage: MessageListener;
1025
+ sipEvent: SipEventListener;
1026
+ newOptions: OptionsListener;
1027
+ }
1028
+
1029
+ interface UAContactOptions {
1030
+ anonymous?: boolean;
1031
+ outbound?: boolean;
1032
+ }
1033
+
1034
+ interface UAContact {
1035
+ pub_gruu?: string,
1036
+ temp_gruu?: string,
1037
+ uri?: string;
1038
+
1039
+ toString(options?: UAContactOptions): string
1040
+ }
1041
+
1042
+ declare enum UAStatus {
1043
+ // UA status codes.
1044
+ STATUS_INIT = 0,
1045
+ STATUS_READY = 1,
1046
+ STATUS_USER_CLOSED = 2,
1047
+ STATUS_NOT_READY = 3,
1048
+ // UA error codes.
1049
+ CONFIGURATION_ERROR = 1,
1050
+ NETWORK_ERROR = 2
1051
+ }
1052
+
1053
+ declare class UA extends EventEmitter {
1054
+ static get C(): typeof UAStatus;
1055
+
1056
+ constructor(configuration: UAConfiguration);
1057
+
1058
+ get C(): typeof UAStatus;
1059
+
1060
+ get status(): UAStatus;
1061
+
1062
+ get contact(): UAContact;
1063
+
1064
+ start(): void;
1065
+
1066
+ stop(): void;
1067
+
1068
+ register(): void;
1069
+
1070
+ unregister(options?: UnRegisterOptions): void;
1071
+
1072
+ registrator(): Registrator;
1073
+
1074
+ call(target: string, options?: CallOptions): RTCSession;
1075
+
1076
+ sendMessage(target: string | URI, body: string, options?: SendMessageOptions): Message;
1077
+
1078
+ terminateSessions(options?: TerminateOptions): void;
1079
+
1080
+ isRegistered(): boolean;
1081
+
1082
+ isConnected(): boolean;
1083
+
1084
+ get<T extends keyof UAConfiguration>(parameter: T): UAConfiguration[T];
1085
+
1086
+ set<T extends keyof UAConfiguration>(parameter: T, value: UAConfiguration[T]): boolean;
1087
+
1088
+ on<T extends keyof UAEventMap>(type: T, listener: UAEventMap[T]): this;
1089
+ }
1090
+
1091
+ declare class WebSocketInterface extends Socket {
1092
+ constructor(url: string)
1093
+ }
1094
+
1095
+ declare const debug: Debug
1096
+ declare const name: string
1097
+ declare const version: string
1098
+
1099
+ export { Constants_d as C, Devices_d as Devices, Exceptions_d as Exceptions, Grammar_d as Grammar, Logger, NameAddrHeader, Socket, UA, UAConfiguration, URI, Utils_d as Utils, WebSocketInterface, WeightedSocket, debug, name, version };