@koi-design/callkit 2.1.5-beta.2 → 2.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4738 -4
- package/dist/index.global.js +107 -108
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +14423 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14420 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -5
- package/CHANGELOG.md +0 -200
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { RegistererOptions, Invitation, UserAgent, Registerer } from 'sip.js';
|
|
2
|
-
|
|
3
1
|
declare class Api {
|
|
4
2
|
private callKit;
|
|
5
3
|
constructor(callKit: CallKit);
|
|
@@ -34,7 +32,7 @@ interface Log {
|
|
|
34
32
|
content: Record<string, any>;
|
|
35
33
|
}
|
|
36
34
|
type LogEntity = Omit<Log, 'timestamp' | 'level' | 'message'>;
|
|
37
|
-
declare class Logger {
|
|
35
|
+
declare class Logger$1 {
|
|
38
36
|
prefix: string;
|
|
39
37
|
level: LoggerLevel;
|
|
40
38
|
private pendingTrackLogs;
|
|
@@ -52,6 +50,4742 @@ declare class Logger {
|
|
|
52
50
|
private catchLog;
|
|
53
51
|
}
|
|
54
52
|
|
|
53
|
+
/**
|
|
54
|
+
* An Exception is considered a condition that a reasonable application may wish to catch.
|
|
55
|
+
* An Error indicates serious problems that a reasonable application should not try to catch.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
declare abstract class Exception extends Error {
|
|
59
|
+
protected constructor(message?: string);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
declare class Parameters {
|
|
66
|
+
parameters: {
|
|
67
|
+
[name: string]: string | null;
|
|
68
|
+
};
|
|
69
|
+
constructor(parameters: {
|
|
70
|
+
[name: string]: string | number | null | undefined;
|
|
71
|
+
});
|
|
72
|
+
setParam(key: string, value: string | number | null | undefined): void;
|
|
73
|
+
getParam(key: string): string | null | undefined;
|
|
74
|
+
hasParam(key: string): boolean;
|
|
75
|
+
deleteParam(key: string): string | null | undefined;
|
|
76
|
+
clearParams(): void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* URI.
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
declare class URI extends Parameters {
|
|
84
|
+
headers: {
|
|
85
|
+
[name: string]: Array<string>;
|
|
86
|
+
};
|
|
87
|
+
private normal;
|
|
88
|
+
private raw;
|
|
89
|
+
/**
|
|
90
|
+
* Constructor
|
|
91
|
+
* @param scheme -
|
|
92
|
+
* @param user -
|
|
93
|
+
* @param host -
|
|
94
|
+
* @param port -
|
|
95
|
+
* @param parameters -
|
|
96
|
+
* @param headers -
|
|
97
|
+
*/
|
|
98
|
+
constructor(scheme: string | undefined, user: string, host: string, port?: number, parameters?: {
|
|
99
|
+
[name: string]: string | number | null;
|
|
100
|
+
}, headers?: {
|
|
101
|
+
[name: string]: Array<string>;
|
|
102
|
+
});
|
|
103
|
+
get scheme(): string;
|
|
104
|
+
set scheme(value: string);
|
|
105
|
+
get user(): string | undefined;
|
|
106
|
+
set user(value: string | undefined);
|
|
107
|
+
get host(): string;
|
|
108
|
+
set host(value: string);
|
|
109
|
+
get aor(): string;
|
|
110
|
+
get port(): number | undefined;
|
|
111
|
+
set port(value: number | undefined);
|
|
112
|
+
setHeader(name: string, value: Array<string> | string): void;
|
|
113
|
+
getHeader(name: string): Array<string> | undefined;
|
|
114
|
+
hasHeader(name: string): boolean;
|
|
115
|
+
deleteHeader(header: string): Array<string> | undefined;
|
|
116
|
+
clearHeaders(): void;
|
|
117
|
+
clone(): URI;
|
|
118
|
+
toRaw(): string;
|
|
119
|
+
toString(): string;
|
|
120
|
+
private get _normal();
|
|
121
|
+
private get _raw();
|
|
122
|
+
private _toString;
|
|
123
|
+
private escapeUser;
|
|
124
|
+
private headerize;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Name Address SIP header.
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
declare class NameAddrHeader extends Parameters {
|
|
132
|
+
uri: URI;
|
|
133
|
+
private _displayName;
|
|
134
|
+
/**
|
|
135
|
+
* Constructor
|
|
136
|
+
* @param uri -
|
|
137
|
+
* @param displayName -
|
|
138
|
+
* @param parameters -
|
|
139
|
+
*/
|
|
140
|
+
constructor(uri: URI, displayName: string, parameters: {
|
|
141
|
+
[name: string]: string;
|
|
142
|
+
});
|
|
143
|
+
get friendlyName(): string;
|
|
144
|
+
get displayName(): string;
|
|
145
|
+
set displayName(value: string);
|
|
146
|
+
clone(): NameAddrHeader;
|
|
147
|
+
toString(): string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Incoming message.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
declare class IncomingMessage {
|
|
155
|
+
viaBranch: string;
|
|
156
|
+
method: string;
|
|
157
|
+
body: string;
|
|
158
|
+
toTag: string;
|
|
159
|
+
to: NameAddrHeader;
|
|
160
|
+
fromTag: string;
|
|
161
|
+
from: NameAddrHeader;
|
|
162
|
+
callId: string;
|
|
163
|
+
cseq: number;
|
|
164
|
+
via: {
|
|
165
|
+
host: string;
|
|
166
|
+
port: number;
|
|
167
|
+
};
|
|
168
|
+
headers: {
|
|
169
|
+
[name: string]: Array<{
|
|
170
|
+
parsed?: any;
|
|
171
|
+
raw: string;
|
|
172
|
+
}>;
|
|
173
|
+
};
|
|
174
|
+
referTo: string | undefined;
|
|
175
|
+
data: string;
|
|
176
|
+
/**
|
|
177
|
+
* Insert a header of the given name and value into the last position of the
|
|
178
|
+
* header array.
|
|
179
|
+
* @param name - header name
|
|
180
|
+
* @param value - header value
|
|
181
|
+
*/
|
|
182
|
+
addHeader(name: string, value: string): void;
|
|
183
|
+
/**
|
|
184
|
+
* Get the value of the given header name at the given position.
|
|
185
|
+
* @param name - header name
|
|
186
|
+
* @returns Returns the specified header, undefined if header doesn't exist.
|
|
187
|
+
*/
|
|
188
|
+
getHeader(name: string): string | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Get the header/s of the given name.
|
|
191
|
+
* @param name - header name
|
|
192
|
+
* @returns Array - with all the headers of the specified name.
|
|
193
|
+
*/
|
|
194
|
+
getHeaders(name: string): Array<string>;
|
|
195
|
+
/**
|
|
196
|
+
* Verify the existence of the given header.
|
|
197
|
+
* @param name - header name
|
|
198
|
+
* @returns true if header with given name exists, false otherwise
|
|
199
|
+
*/
|
|
200
|
+
hasHeader(name: string): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Parse the given header on the given index.
|
|
203
|
+
* @param name - header name
|
|
204
|
+
* @param idx - header index
|
|
205
|
+
* @returns Parsed header object, undefined if the
|
|
206
|
+
* header is not present or in case of a parsing error.
|
|
207
|
+
*/
|
|
208
|
+
parseHeader(name: string, idx?: number): any | undefined;
|
|
209
|
+
/**
|
|
210
|
+
* Message Header attribute selector. Alias of parseHeader.
|
|
211
|
+
* @param name - header name
|
|
212
|
+
* @param idx - header index
|
|
213
|
+
* @returns Parsed header object, undefined if the
|
|
214
|
+
* header is not present or in case of a parsing error.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* message.s('via',3).port
|
|
218
|
+
*/
|
|
219
|
+
s(name: string, idx?: number): any | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* Replace the value of the given header by the value.
|
|
222
|
+
* @param name - header name
|
|
223
|
+
* @param value - header value
|
|
224
|
+
*/
|
|
225
|
+
setHeader(name: string, value: string): void;
|
|
226
|
+
toString(): string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Incoming request message.
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
declare class IncomingRequestMessage extends IncomingMessage {
|
|
234
|
+
ruri: URI | undefined;
|
|
235
|
+
constructor();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Incoming response message.
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
declare class IncomingResponseMessage extends IncomingMessage {
|
|
243
|
+
statusCode: number | undefined;
|
|
244
|
+
reasonPhrase: string | undefined;
|
|
245
|
+
constructor();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Message body.
|
|
250
|
+
* @remarks
|
|
251
|
+
* https://tools.ietf.org/html/rfc3261#section-7.4
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
interface Body {
|
|
255
|
+
/**
|
|
256
|
+
* If the Content-Disposition header field is missing, bodies of
|
|
257
|
+
* Content-Type application/sdp imply the disposition "session", while
|
|
258
|
+
* other content types imply "render".
|
|
259
|
+
* https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
260
|
+
* For backward-compatibility, if the Content-Disposition header field
|
|
261
|
+
* is missing, the server SHOULD assume bodies of Content-Type
|
|
262
|
+
* application/sdp are the disposition "session", while other content
|
|
263
|
+
* types are "render".
|
|
264
|
+
* https://tools.ietf.org/html/rfc3261#section-20.11
|
|
265
|
+
*/
|
|
266
|
+
contentDisposition: string;
|
|
267
|
+
/**
|
|
268
|
+
* The Content-Type header field indicates the media type of the
|
|
269
|
+
* message-body sent to the recipient. The Content-Type header field
|
|
270
|
+
* MUST be present if the body is not empty. If the body is empty,
|
|
271
|
+
* and a Content-Type header field is present, it indicates that the body
|
|
272
|
+
* of the specific type has zero length (for example, an empty audio file).
|
|
273
|
+
* https://tools.ietf.org/html/rfc3261#section-20.15
|
|
274
|
+
*/
|
|
275
|
+
contentType: string;
|
|
276
|
+
/**
|
|
277
|
+
* Requests, including new requests defined in extensions to this
|
|
278
|
+
* specification, MAY contain message bodies unless otherwise noted.
|
|
279
|
+
* The interpretation of the body depends on the request method.
|
|
280
|
+
* For response messages, the request method and the response status
|
|
281
|
+
* code determine the type and interpretation of any message body. All
|
|
282
|
+
* responses MAY include a body.
|
|
283
|
+
* https://tools.ietf.org/html/rfc3261#section-7.4
|
|
284
|
+
*/
|
|
285
|
+
content: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Outgoing request message options.
|
|
290
|
+
* @public
|
|
291
|
+
*/
|
|
292
|
+
interface OutgoingRequestMessageOptions {
|
|
293
|
+
callId?: string;
|
|
294
|
+
callIdPrefix?: string;
|
|
295
|
+
cseq?: number;
|
|
296
|
+
toDisplayName?: string;
|
|
297
|
+
toTag?: string;
|
|
298
|
+
fromDisplayName?: string;
|
|
299
|
+
fromTag?: string;
|
|
300
|
+
forceRport?: boolean;
|
|
301
|
+
hackViaTcp?: boolean;
|
|
302
|
+
optionTags?: Array<string>;
|
|
303
|
+
routeSet?: Array<string>;
|
|
304
|
+
userAgentString?: string;
|
|
305
|
+
viaHost?: string;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Outgoing SIP request message.
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
declare class OutgoingRequestMessage {
|
|
312
|
+
readonly headers: {
|
|
313
|
+
[name: string]: Array<string>;
|
|
314
|
+
};
|
|
315
|
+
readonly method: string;
|
|
316
|
+
readonly ruri: URI;
|
|
317
|
+
readonly from: NameAddrHeader;
|
|
318
|
+
readonly fromTag: string;
|
|
319
|
+
readonly fromURI: URI;
|
|
320
|
+
readonly to: NameAddrHeader;
|
|
321
|
+
readonly toTag: string | undefined;
|
|
322
|
+
readonly toURI: URI;
|
|
323
|
+
branch: string | undefined;
|
|
324
|
+
readonly callId: string;
|
|
325
|
+
cseq: number;
|
|
326
|
+
extraHeaders: Array<string>;
|
|
327
|
+
body: {
|
|
328
|
+
body: string;
|
|
329
|
+
contentType: string;
|
|
330
|
+
} | undefined;
|
|
331
|
+
private options;
|
|
332
|
+
constructor(method: string, ruri: URI, fromURI: URI, toURI: URI, options?: OutgoingRequestMessageOptions, extraHeaders?: Array<string>, body?: Body);
|
|
333
|
+
/** Get a copy of the default options. */
|
|
334
|
+
private static getDefaultOptions;
|
|
335
|
+
private static makeNameAddrHeader;
|
|
336
|
+
/**
|
|
337
|
+
* Get the value of the given header name at the given position.
|
|
338
|
+
* @param name - header name
|
|
339
|
+
* @returns Returns the specified header, undefined if header doesn't exist.
|
|
340
|
+
*/
|
|
341
|
+
getHeader(name: string): string | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* Get the header/s of the given name.
|
|
344
|
+
* @param name - header name
|
|
345
|
+
* @returns Array with all the headers of the specified name.
|
|
346
|
+
*/
|
|
347
|
+
getHeaders(name: string): Array<string>;
|
|
348
|
+
/**
|
|
349
|
+
* Verify the existence of the given header.
|
|
350
|
+
* @param name - header name
|
|
351
|
+
* @returns true if header with given name exists, false otherwise
|
|
352
|
+
*/
|
|
353
|
+
hasHeader(name: string): boolean;
|
|
354
|
+
/**
|
|
355
|
+
* Replace the the given header by the given value.
|
|
356
|
+
* @param name - header name
|
|
357
|
+
* @param value - header value
|
|
358
|
+
*/
|
|
359
|
+
setHeader(name: string, value: string | Array<string>): void;
|
|
360
|
+
/**
|
|
361
|
+
* The Via header field indicates the transport used for the transaction
|
|
362
|
+
* and identifies the location where the response is to be sent. A Via
|
|
363
|
+
* header field value is added only after the transport that will be
|
|
364
|
+
* used to reach the next hop has been selected (which may involve the
|
|
365
|
+
* usage of the procedures in [4]).
|
|
366
|
+
*
|
|
367
|
+
* When the UAC creates a request, it MUST insert a Via into that
|
|
368
|
+
* request. The protocol name and protocol version in the header field
|
|
369
|
+
* MUST be SIP and 2.0, respectively. The Via header field value MUST
|
|
370
|
+
* contain a branch parameter. This parameter is used to identify the
|
|
371
|
+
* transaction created by that request. This parameter is used by both
|
|
372
|
+
* the client and the server.
|
|
373
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.1.7
|
|
374
|
+
* @param branchParameter - The branch parameter.
|
|
375
|
+
* @param transport - The sent protocol transport.
|
|
376
|
+
*/
|
|
377
|
+
setViaHeader(branch: string, transport: string): void;
|
|
378
|
+
toString(): string;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Incoming ACK request.
|
|
383
|
+
* @public
|
|
384
|
+
*/
|
|
385
|
+
interface IncomingAckRequest {
|
|
386
|
+
/** The incoming message. */
|
|
387
|
+
readonly message: IncomingRequestMessage;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Outgoing ACK request.
|
|
391
|
+
* @public
|
|
392
|
+
*/
|
|
393
|
+
interface OutgoingAckRequest {
|
|
394
|
+
/** The outgoing message. */
|
|
395
|
+
readonly message: OutgoingRequestMessage;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* A request to confirm a {@link Session} (incoming ACK).
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
402
|
+
declare class Ack {
|
|
403
|
+
private incomingAckRequest;
|
|
404
|
+
/** @internal */
|
|
405
|
+
constructor(incomingAckRequest: IncomingAckRequest);
|
|
406
|
+
/** Incoming ACK request message. */
|
|
407
|
+
get request(): IncomingRequestMessage;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Transport error.
|
|
412
|
+
* @public
|
|
413
|
+
*/
|
|
414
|
+
declare class TransportError extends Exception {
|
|
415
|
+
constructor(message?: string);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* A SIP message sent from a local server to a remote client.
|
|
420
|
+
* @remarks
|
|
421
|
+
* For indicating the status of a request sent from the client to the server.
|
|
422
|
+
* https://tools.ietf.org/html/rfc3261#section-7.2
|
|
423
|
+
* @public
|
|
424
|
+
*/
|
|
425
|
+
interface OutgoingResponse {
|
|
426
|
+
/** The outgoing message. */
|
|
427
|
+
readonly message: string;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Response options bucket.
|
|
431
|
+
* @public
|
|
432
|
+
*/
|
|
433
|
+
interface ResponseOptions {
|
|
434
|
+
/** Status code of the response. */
|
|
435
|
+
statusCode: number;
|
|
436
|
+
/** Reason phrase of the response. */
|
|
437
|
+
reasonPhrase?: string;
|
|
438
|
+
/** To tag of the response. If not provided, one is generated. */
|
|
439
|
+
toTag?: string;
|
|
440
|
+
/** User agent string for User-Agent header. */
|
|
441
|
+
userAgent?: string;
|
|
442
|
+
/** Support options tags for Supported header. */
|
|
443
|
+
supported?: Array<string>;
|
|
444
|
+
/** Extra headers to include in the message. */
|
|
445
|
+
extraHeaders?: Array<string>;
|
|
446
|
+
/** Body to include in the message. */
|
|
447
|
+
body?: Body;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* A SIP message sent from a remote client to a local server.
|
|
452
|
+
* @remarks
|
|
453
|
+
* For the purpose of invoking a particular operation.
|
|
454
|
+
* https://tools.ietf.org/html/rfc3261#section-7.1
|
|
455
|
+
* @public
|
|
456
|
+
*/
|
|
457
|
+
interface IncomingRequest {
|
|
458
|
+
/** Delegate providing custom handling of this incoming request. */
|
|
459
|
+
delegate?: IncomingRequestDelegate;
|
|
460
|
+
/** The incoming message. */
|
|
461
|
+
readonly message: IncomingRequestMessage;
|
|
462
|
+
/**
|
|
463
|
+
* Send a 2xx positive final response to this request. Defaults to 200.
|
|
464
|
+
* @param options - Response options bucket.
|
|
465
|
+
*/
|
|
466
|
+
accept(options?: ResponseOptions): OutgoingResponse;
|
|
467
|
+
/**
|
|
468
|
+
* Send a 1xx provisional response to this request. Defaults to 180. Excludes 100.
|
|
469
|
+
* Note that per RFC 4320, this method may only be used to respond to INVITE requests.
|
|
470
|
+
* @param options - Response options bucket.
|
|
471
|
+
*/
|
|
472
|
+
progress(options?: ResponseOptions): OutgoingResponse;
|
|
473
|
+
/**
|
|
474
|
+
* Send a 3xx negative final response to this request. Defaults to 302.
|
|
475
|
+
* @param contacts - Contacts to redirect the UAC to.
|
|
476
|
+
* @param options - Response options bucket.
|
|
477
|
+
*/
|
|
478
|
+
redirect(contacts: Array<URI>, options?: ResponseOptions): OutgoingResponse;
|
|
479
|
+
/**
|
|
480
|
+
* Send a 4xx, 5xx, or 6xx negative final response to this request. Defaults to 480.
|
|
481
|
+
* @param options - Response options bucket.
|
|
482
|
+
*/
|
|
483
|
+
reject(options?: ResponseOptions): OutgoingResponse;
|
|
484
|
+
/**
|
|
485
|
+
* Send a 100 outgoing response to this request.
|
|
486
|
+
* @param options - Response options bucket.
|
|
487
|
+
*/
|
|
488
|
+
trying(options?: ResponseOptions): OutgoingResponse;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Delegate providing custom handling of incoming requests.
|
|
492
|
+
* @public
|
|
493
|
+
*/
|
|
494
|
+
interface IncomingRequestDelegate {
|
|
495
|
+
/**
|
|
496
|
+
* Receive CANCEL request.
|
|
497
|
+
* https://tools.ietf.org/html/rfc3261#section-9.2
|
|
498
|
+
* Note: Currently CANCEL is being handled as a special case.
|
|
499
|
+
* No UAS is created to handle the CANCEL and the response to
|
|
500
|
+
* it CANCEL is being handled statelessly by the user agent core.
|
|
501
|
+
* As such, there is currently no way to externally impact the
|
|
502
|
+
* response to the a CANCEL request and thus the method here is
|
|
503
|
+
* receiving a "message" (as apposed to a "uas").
|
|
504
|
+
* @param message - Incoming CANCEL request message.
|
|
505
|
+
*/
|
|
506
|
+
onCancel?(message: IncomingRequestMessage): void;
|
|
507
|
+
/**
|
|
508
|
+
* A transport error occurred attempted to send a response.
|
|
509
|
+
* @param error - Transport error.
|
|
510
|
+
*/
|
|
511
|
+
onTransportError?(error: TransportError): void;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* A SIP message sent from a remote server to a local client.
|
|
516
|
+
* @remarks
|
|
517
|
+
* For indicating the status of a request sent from the client to the server.
|
|
518
|
+
* https://tools.ietf.org/html/rfc3261#section-7.2
|
|
519
|
+
* @public
|
|
520
|
+
*/
|
|
521
|
+
interface IncomingResponse {
|
|
522
|
+
/** The incoming message. */
|
|
523
|
+
readonly message: IncomingResponseMessage;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* A SIP message sent from a local client to a remote server.
|
|
528
|
+
* @remarks
|
|
529
|
+
* For the purpose of invoking a particular operation.
|
|
530
|
+
* https://tools.ietf.org/html/rfc3261#section-7.1
|
|
531
|
+
* @public
|
|
532
|
+
*/
|
|
533
|
+
interface OutgoingRequest {
|
|
534
|
+
/** Delegate providing custom handling of this outgoing request. */
|
|
535
|
+
delegate?: OutgoingRequestDelegate;
|
|
536
|
+
/** The outgoing message. */
|
|
537
|
+
readonly message: OutgoingRequestMessage;
|
|
538
|
+
/**
|
|
539
|
+
* Destroy request.
|
|
540
|
+
*/
|
|
541
|
+
dispose(): void;
|
|
542
|
+
/**
|
|
543
|
+
* Sends a CANCEL message targeting this request to the UAS.
|
|
544
|
+
* @param reason - Reason for canceling request.
|
|
545
|
+
* @param options - Request options bucket.
|
|
546
|
+
*/
|
|
547
|
+
cancel(reason?: string, options?: RequestOptions): void;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Delegate providing custom handling of outgoing requests.
|
|
551
|
+
* @public
|
|
552
|
+
*/
|
|
553
|
+
interface OutgoingRequestDelegate {
|
|
554
|
+
/**
|
|
555
|
+
* Received a 2xx positive final response to this request.
|
|
556
|
+
* @param response - Incoming response.
|
|
557
|
+
*/
|
|
558
|
+
onAccept?(response: IncomingResponse): void;
|
|
559
|
+
/**
|
|
560
|
+
* Received a 1xx provisional response to this request. Excluding 100 responses.
|
|
561
|
+
* @param response - Incoming response.
|
|
562
|
+
*/
|
|
563
|
+
onProgress?(response: IncomingResponse): void;
|
|
564
|
+
/**
|
|
565
|
+
* Received a 3xx negative final response to this request.
|
|
566
|
+
* @param response - Incoming response.
|
|
567
|
+
*/
|
|
568
|
+
onRedirect?(response: IncomingResponse): void;
|
|
569
|
+
/**
|
|
570
|
+
* Received a 4xx, 5xx, or 6xx negative final response to this request.
|
|
571
|
+
* @param response - Incoming response.
|
|
572
|
+
*/
|
|
573
|
+
onReject?(response: IncomingResponse): void;
|
|
574
|
+
/**
|
|
575
|
+
* Received a 100 provisional response.
|
|
576
|
+
* @param response - Incoming response.
|
|
577
|
+
*/
|
|
578
|
+
onTrying?(response: IncomingResponse): void;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Request options bucket.
|
|
582
|
+
* @public
|
|
583
|
+
*/
|
|
584
|
+
interface RequestOptions {
|
|
585
|
+
/** Extra headers to include in the message. */
|
|
586
|
+
extraHeaders?: Array<string>;
|
|
587
|
+
/** Body to include in the message. */
|
|
588
|
+
body?: Body;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Incoming BYE request.
|
|
593
|
+
* @public
|
|
594
|
+
*/
|
|
595
|
+
interface IncomingByeRequest extends IncomingRequest {
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Outgoing BYE request.
|
|
599
|
+
* @public
|
|
600
|
+
*/
|
|
601
|
+
interface OutgoingByeRequest extends OutgoingRequest {
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* A request to end a {@link Session} (incoming BYE).
|
|
606
|
+
* @public
|
|
607
|
+
*/
|
|
608
|
+
declare class Bye {
|
|
609
|
+
private incomingByeRequest;
|
|
610
|
+
/** @internal */
|
|
611
|
+
constructor(incomingByeRequest: IncomingByeRequest);
|
|
612
|
+
/** Incoming BYE request message. */
|
|
613
|
+
get request(): IncomingRequestMessage;
|
|
614
|
+
/** Accept the request. */
|
|
615
|
+
accept(options?: ResponseOptions): Promise<void>;
|
|
616
|
+
/** Reject the request. */
|
|
617
|
+
reject(options?: ResponseOptions): Promise<void>;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* A request to reject an {@link Invitation} (incoming CANCEL).
|
|
622
|
+
* @public
|
|
623
|
+
*/
|
|
624
|
+
declare class Cancel {
|
|
625
|
+
private incomingCancelRequest;
|
|
626
|
+
/** @internal */
|
|
627
|
+
constructor(incomingCancelRequest: IncomingRequestMessage);
|
|
628
|
+
/** Incoming CANCEL request message. */
|
|
629
|
+
get request(): IncomingRequestMessage;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Generic observable.
|
|
634
|
+
* @public
|
|
635
|
+
*/
|
|
636
|
+
interface Emitter<T> {
|
|
637
|
+
/**
|
|
638
|
+
* Sets up a function that will be called whenever the target changes.
|
|
639
|
+
* @param listener - Callback function.
|
|
640
|
+
* @param options - An options object that specifies characteristics about the listener.
|
|
641
|
+
* If once true, indicates that the listener should be invoked at most once after being added.
|
|
642
|
+
* If once true, the listener would be automatically removed when invoked.
|
|
643
|
+
*/
|
|
644
|
+
addListener(listener: (data: T) => void, options?: {
|
|
645
|
+
once?: boolean;
|
|
646
|
+
}): void;
|
|
647
|
+
/**
|
|
648
|
+
* Removes from the listener previously registered with addListener.
|
|
649
|
+
* @param listener - Callback function.
|
|
650
|
+
*/
|
|
651
|
+
removeListener(listener: (data: T) => void): void;
|
|
652
|
+
/**
|
|
653
|
+
* Registers a listener.
|
|
654
|
+
* @param listener - Callback function.
|
|
655
|
+
* @deprecated Use addListener.
|
|
656
|
+
*/
|
|
657
|
+
on(listener: (data: T) => void): void;
|
|
658
|
+
/**
|
|
659
|
+
* Unregisters a listener.
|
|
660
|
+
* @param listener - Callback function.
|
|
661
|
+
* @deprecated Use removeListener.
|
|
662
|
+
*/
|
|
663
|
+
off(listener: (data: T) => void): void;
|
|
664
|
+
/**
|
|
665
|
+
* Registers a listener then unregisters the listener after one event emission.
|
|
666
|
+
* @param listener - Callback function.
|
|
667
|
+
* @deprecated Use addListener.
|
|
668
|
+
*/
|
|
669
|
+
once(listener: (data: T) => void): void;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Incoming INFO request.
|
|
674
|
+
* @public
|
|
675
|
+
*/
|
|
676
|
+
interface IncomingInfoRequest extends IncomingRequest {
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Outgoing INFO request.
|
|
680
|
+
* @public
|
|
681
|
+
*/
|
|
682
|
+
interface OutgoingInfoRequest extends OutgoingRequest {
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* An exchange of information (incoming INFO).
|
|
687
|
+
* @public
|
|
688
|
+
*/
|
|
689
|
+
declare class Info {
|
|
690
|
+
private incomingInfoRequest;
|
|
691
|
+
/** @internal */
|
|
692
|
+
constructor(incomingInfoRequest: IncomingInfoRequest);
|
|
693
|
+
/** Incoming MESSAGE request message. */
|
|
694
|
+
get request(): IncomingRequestMessage;
|
|
695
|
+
/** Accept the request. */
|
|
696
|
+
accept(options?: ResponseOptions): Promise<void>;
|
|
697
|
+
/** Reject the request. */
|
|
698
|
+
reject(options?: ResponseOptions): Promise<void>;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Delegate for {@link Session} offer/answer exchange.
|
|
703
|
+
* @public
|
|
704
|
+
*/
|
|
705
|
+
interface SessionDescriptionHandler {
|
|
706
|
+
/**
|
|
707
|
+
* Destructor.
|
|
708
|
+
*/
|
|
709
|
+
close(): void;
|
|
710
|
+
/**
|
|
711
|
+
* Gets the local description from the underlying media implementation.
|
|
712
|
+
* @param options - Options object to be used by getDescription.
|
|
713
|
+
* @param modifiers - Array with one time use description modifiers.
|
|
714
|
+
* @returns Promise that resolves with the local description to be used for the session.
|
|
715
|
+
* Rejects with `ClosedSessionDescriptionHandlerError` when this method
|
|
716
|
+
* is called after close or when close occurs before complete.
|
|
717
|
+
*/
|
|
718
|
+
getDescription(options?: SessionDescriptionHandlerOptions, modifiers?: Array<SessionDescriptionHandlerModifier>): Promise<BodyAndContentType>;
|
|
719
|
+
/**
|
|
720
|
+
* Returns true if the Session Description Handler can handle the Content-Type described by a SIP message.
|
|
721
|
+
* @param contentType - The content type that is in the SIP Message.
|
|
722
|
+
* @returns True if the content type is handled by this session description handler. False otherwise.
|
|
723
|
+
*/
|
|
724
|
+
hasDescription(contentType: string): boolean;
|
|
725
|
+
/**
|
|
726
|
+
* Rolls back the current local/remote offer to the prior stable state.
|
|
727
|
+
*/
|
|
728
|
+
rollbackDescription?(): Promise<void>;
|
|
729
|
+
/**
|
|
730
|
+
* Sets the remote description to the underlying media implementation.
|
|
731
|
+
* @param sessionDescription - The description provided by a SIP message to be set on the media implementation.
|
|
732
|
+
* @param options - Options object to be used by setDescription.
|
|
733
|
+
* @param modifiers - Array with one time use description modifiers.
|
|
734
|
+
* @returns Promise that resolves once the description is set.
|
|
735
|
+
* Rejects with `ClosedSessionDescriptionHandlerError` when this method
|
|
736
|
+
* is called after close or when close occurs before complete.
|
|
737
|
+
*/
|
|
738
|
+
setDescription(sdp: string, options?: SessionDescriptionHandlerOptions, modifiers?: Array<SessionDescriptionHandlerModifier>): Promise<void>;
|
|
739
|
+
/**
|
|
740
|
+
* Send DTMF via RTP (RFC 4733).
|
|
741
|
+
* Returns true if DTMF send is successful, false otherwise.
|
|
742
|
+
* @param tones - A string containing DTMF digits.
|
|
743
|
+
* @param options - Options object to be used by sendDtmf.
|
|
744
|
+
* @returns True if DTMF send is successful, false otherwise.
|
|
745
|
+
*/
|
|
746
|
+
sendDtmf(tones: string, options?: unknown): boolean;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Modifier for {@link SessionDescriptionHandler} offer/answer.
|
|
750
|
+
* @public
|
|
751
|
+
*/
|
|
752
|
+
interface SessionDescriptionHandlerModifier {
|
|
753
|
+
(sessionDescription: RTCSessionDescriptionInit): Promise<RTCSessionDescriptionInit>;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Options for {@link SessionDescriptionHandler} methods.
|
|
757
|
+
* @remarks
|
|
758
|
+
* These options are provided to various UserAgent methods (invite() for example)
|
|
759
|
+
* and passed through on calls to getDescription() and setDescription().
|
|
760
|
+
* @public
|
|
761
|
+
*/
|
|
762
|
+
interface SessionDescriptionHandlerOptions {
|
|
763
|
+
constraints?: object;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Message body content and type.
|
|
767
|
+
* @public
|
|
768
|
+
*/
|
|
769
|
+
interface BodyAndContentType {
|
|
770
|
+
/** Message body content. */
|
|
771
|
+
body: string;
|
|
772
|
+
/** Message body content type. */
|
|
773
|
+
contentType: string;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Options for {@link Invitation.accept}.
|
|
778
|
+
* @public
|
|
779
|
+
*/
|
|
780
|
+
interface InvitationAcceptOptions {
|
|
781
|
+
/**
|
|
782
|
+
* Array of extra headers added to the response.
|
|
783
|
+
*/
|
|
784
|
+
extraHeaders?: Array<string>;
|
|
785
|
+
/**
|
|
786
|
+
* Modifiers to pass to SessionDescriptionHandler during the initial INVITE transaction.
|
|
787
|
+
*/
|
|
788
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
789
|
+
/**
|
|
790
|
+
* Options to pass to SessionDescriptionHandler during the initial INVITE transaction.
|
|
791
|
+
*/
|
|
792
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Options for {@link Invitation.progress}.
|
|
797
|
+
* @public
|
|
798
|
+
*/
|
|
799
|
+
interface InvitationProgressOptions {
|
|
800
|
+
/**
|
|
801
|
+
* Body
|
|
802
|
+
*/
|
|
803
|
+
body?: string | {
|
|
804
|
+
body: string;
|
|
805
|
+
contentType: string;
|
|
806
|
+
};
|
|
807
|
+
/**
|
|
808
|
+
* Array of extra headers added to the response.
|
|
809
|
+
*/
|
|
810
|
+
extraHeaders?: Array<string>;
|
|
811
|
+
/**
|
|
812
|
+
* Modifiers to pass to SessionDescriptionHandler during the initial INVITE transaction.
|
|
813
|
+
*/
|
|
814
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
815
|
+
/**
|
|
816
|
+
* Options to pass to SessionDescriptionHandler during the initial INVITE transaction.
|
|
817
|
+
*/
|
|
818
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
819
|
+
/**
|
|
820
|
+
* Status code for response.
|
|
821
|
+
*/
|
|
822
|
+
statusCode?: number;
|
|
823
|
+
/**
|
|
824
|
+
* Reason phrase for response.
|
|
825
|
+
*/
|
|
826
|
+
reasonPhrase?: string;
|
|
827
|
+
/**
|
|
828
|
+
* Send reliable response.
|
|
829
|
+
*/
|
|
830
|
+
rel100?: boolean;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Options for {@link Invitation.reject}.
|
|
835
|
+
* @public
|
|
836
|
+
*/
|
|
837
|
+
interface InvitationRejectOptions {
|
|
838
|
+
/**
|
|
839
|
+
* Body
|
|
840
|
+
*/
|
|
841
|
+
body?: string | {
|
|
842
|
+
body: string;
|
|
843
|
+
contentType: string;
|
|
844
|
+
};
|
|
845
|
+
/**
|
|
846
|
+
* Array of extra headers added to the response.
|
|
847
|
+
*/
|
|
848
|
+
extraHeaders?: Array<string>;
|
|
849
|
+
/**
|
|
850
|
+
* Status code for response.
|
|
851
|
+
*/
|
|
852
|
+
statusCode?: number;
|
|
853
|
+
/**
|
|
854
|
+
* Reason phrase for response.
|
|
855
|
+
*/
|
|
856
|
+
reasonPhrase?: string;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Incoming MESSAGE request.
|
|
861
|
+
* @public
|
|
862
|
+
*/
|
|
863
|
+
interface IncomingMessageRequest extends IncomingRequest {
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Outgoing MESSAGE request.
|
|
867
|
+
* @public
|
|
868
|
+
*/
|
|
869
|
+
interface OutgoingMessageRequest extends OutgoingRequest {
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Incoming NOTIFY request.
|
|
874
|
+
* @public
|
|
875
|
+
*/
|
|
876
|
+
interface IncomingNotifyRequest extends IncomingRequest {
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Outgoing NOTIFY request.
|
|
880
|
+
* @public
|
|
881
|
+
*/
|
|
882
|
+
interface OutgoingNotifyRequest extends OutgoingRequest {
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Incoming PRACK request.
|
|
887
|
+
* @public
|
|
888
|
+
*/
|
|
889
|
+
interface IncomingPrackRequest extends IncomingRequest {
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Outgoing PRACK request.
|
|
893
|
+
* @public
|
|
894
|
+
*/
|
|
895
|
+
interface OutgoingPrackRequest extends OutgoingRequest {
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Incoming REFER request.
|
|
900
|
+
* @public
|
|
901
|
+
*/
|
|
902
|
+
interface IncomingReferRequest extends IncomingRequest {
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Outgoing REFER request.
|
|
906
|
+
* @public
|
|
907
|
+
*/
|
|
908
|
+
interface OutgoingReferRequest extends OutgoingRequest {
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Session delegate.
|
|
913
|
+
* @public
|
|
914
|
+
*/
|
|
915
|
+
interface SessionDelegate$1 {
|
|
916
|
+
/**
|
|
917
|
+
* Receive ACK request.
|
|
918
|
+
* @param request - Incoming ACK request.
|
|
919
|
+
* @returns
|
|
920
|
+
* The callback MUST return a promise if it asynchronously handles answers.
|
|
921
|
+
* For example, an ACK with an answer (offer in the 200 Ok) may require
|
|
922
|
+
* asynchronous processing in which case the callback MUST return a Promise
|
|
923
|
+
* which resolves when the answer handling is complete.
|
|
924
|
+
* @privateRemarks
|
|
925
|
+
* Unlike INVITE handling where we can rely on the generation of a response
|
|
926
|
+
* to indicate when offer/answer processing has been completed, ACK handling
|
|
927
|
+
* requires some indication from the handler that answer processing is complete
|
|
928
|
+
* so that we can avoid some race conditions (see comments in code for more details).
|
|
929
|
+
* Having the handler return a Promise provides said indication.
|
|
930
|
+
*/
|
|
931
|
+
onAck?(request: IncomingAckRequest): Promise<void> | void;
|
|
932
|
+
/**
|
|
933
|
+
* Timeout waiting for ACK request.
|
|
934
|
+
* If no handler is provided the Session will terminated with a BYE.
|
|
935
|
+
* https://tools.ietf.org/html/rfc3261#section-13.3.1.4
|
|
936
|
+
*/
|
|
937
|
+
onAckTimeout?(): void;
|
|
938
|
+
/**
|
|
939
|
+
* Receive BYE request.
|
|
940
|
+
* https://tools.ietf.org/html/rfc3261#section-15.1.2
|
|
941
|
+
* @param request - Incoming BYE request.
|
|
942
|
+
*/
|
|
943
|
+
onBye?(request: IncomingByeRequest): void;
|
|
944
|
+
/**
|
|
945
|
+
* Receive INFO request.
|
|
946
|
+
* @param request - Incoming INFO request.
|
|
947
|
+
*/
|
|
948
|
+
onInfo?(request: IncomingInfoRequest): void;
|
|
949
|
+
/**
|
|
950
|
+
* Receive re-INVITE request.
|
|
951
|
+
* https://tools.ietf.org/html/rfc3261#section-14.2
|
|
952
|
+
* @param request - Incoming INVITE request.
|
|
953
|
+
*/
|
|
954
|
+
onInvite?(request: IncomingInviteRequest): void;
|
|
955
|
+
/**
|
|
956
|
+
* Receive MESSAGE request.
|
|
957
|
+
* https://tools.ietf.org/html/rfc3428#section-7
|
|
958
|
+
* @param request - Incoming MESSAGE request.
|
|
959
|
+
*/
|
|
960
|
+
onMessage?(request: IncomingMessageRequest): void;
|
|
961
|
+
/**
|
|
962
|
+
* Receive NOTIFY request.
|
|
963
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.3
|
|
964
|
+
* @param request - Incoming NOTIFY request.
|
|
965
|
+
*/
|
|
966
|
+
onNotify?(request: IncomingNotifyRequest): void;
|
|
967
|
+
/**
|
|
968
|
+
* Receive PRACK request.
|
|
969
|
+
* https://tools.ietf.org/html/rfc3262#section-3
|
|
970
|
+
* @param request - Incoming PRACK request.
|
|
971
|
+
*/
|
|
972
|
+
onPrack?(request: IncomingPrackRequest): void;
|
|
973
|
+
/**
|
|
974
|
+
* Receive REFER request.
|
|
975
|
+
* https://tools.ietf.org/html/rfc3515#section-2.4.2
|
|
976
|
+
* @param request - Incoming REFER request.
|
|
977
|
+
*/
|
|
978
|
+
onRefer?(request: IncomingReferRequest): void;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Session.
|
|
983
|
+
* @remarks
|
|
984
|
+
* https://tools.ietf.org/html/rfc3261#section-13
|
|
985
|
+
* @public
|
|
986
|
+
*/
|
|
987
|
+
interface Session$1 {
|
|
988
|
+
/** Session delegate. */
|
|
989
|
+
delegate: SessionDelegate$1 | undefined;
|
|
990
|
+
/** The session id. Equal to callId + localTag + remoteTag. */
|
|
991
|
+
readonly id: string;
|
|
992
|
+
/** Call Id. */
|
|
993
|
+
readonly callId: string;
|
|
994
|
+
/** Local Tag. */
|
|
995
|
+
readonly localTag: string;
|
|
996
|
+
/** Local URI. */
|
|
997
|
+
readonly localURI: URI;
|
|
998
|
+
/** Remote Tag. */
|
|
999
|
+
readonly remoteTag: string;
|
|
1000
|
+
/** Remote Target. */
|
|
1001
|
+
readonly remoteTarget: URI;
|
|
1002
|
+
/** Remote URI. */
|
|
1003
|
+
readonly remoteURI: URI;
|
|
1004
|
+
/** Session state. */
|
|
1005
|
+
readonly sessionState: SessionState$1;
|
|
1006
|
+
/** Current state of the offer/answer exchange. */
|
|
1007
|
+
readonly signalingState: SignalingState;
|
|
1008
|
+
/** The current answer if signalingState is stable. Otherwise undefined. */
|
|
1009
|
+
readonly answer: Body | undefined;
|
|
1010
|
+
/** The current offer if signalingState is not initial or closed. Otherwise undefined. */
|
|
1011
|
+
readonly offer: Body | undefined;
|
|
1012
|
+
/**
|
|
1013
|
+
* Destroy session.
|
|
1014
|
+
*/
|
|
1015
|
+
dispose(): void;
|
|
1016
|
+
/**
|
|
1017
|
+
* Send a BYE request.
|
|
1018
|
+
* Terminating a session.
|
|
1019
|
+
* https://tools.ietf.org/html/rfc3261#section-15
|
|
1020
|
+
* @param delegate - Request delegate.
|
|
1021
|
+
* @param options - Options bucket.
|
|
1022
|
+
*/
|
|
1023
|
+
bye(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingByeRequest;
|
|
1024
|
+
/**
|
|
1025
|
+
* Send an INFO request.
|
|
1026
|
+
* Exchange information during a session.
|
|
1027
|
+
* https://tools.ietf.org/html/rfc6086#section-4.2.1
|
|
1028
|
+
* @param delegate - Request delegate.
|
|
1029
|
+
* @param options - Options bucket.
|
|
1030
|
+
*/
|
|
1031
|
+
info(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingInfoRequest;
|
|
1032
|
+
/**
|
|
1033
|
+
* Send re-INVITE request.
|
|
1034
|
+
* Modifying a session.
|
|
1035
|
+
* https://tools.ietf.org/html/rfc3261#section-14.1
|
|
1036
|
+
* @param delegate - Request delegate.
|
|
1037
|
+
* @param options - Options bucket.
|
|
1038
|
+
*/
|
|
1039
|
+
invite(delegate?: OutgoingInviteRequestDelegate, options?: RequestOptions): OutgoingInviteRequest;
|
|
1040
|
+
/**
|
|
1041
|
+
* Send MESSAGE request.
|
|
1042
|
+
* Deliver a message during a session.
|
|
1043
|
+
* https://tools.ietf.org/html/rfc3428#section-4
|
|
1044
|
+
* @param delegate - Request delegate.
|
|
1045
|
+
* @param options - Options bucket.
|
|
1046
|
+
*/
|
|
1047
|
+
message(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingMessageRequest;
|
|
1048
|
+
/**
|
|
1049
|
+
* Send NOTIFY request.
|
|
1050
|
+
* Inform referrer of transfer progress.
|
|
1051
|
+
* The use of this is limited to the implicit creation of subscription by REFER (historical).
|
|
1052
|
+
* Otherwise, notifiers MUST NOT create subscriptions except upon receipt of a SUBSCRIBE request.
|
|
1053
|
+
* https://tools.ietf.org/html/rfc3515#section-3.7
|
|
1054
|
+
* @param delegate - Request delegate.
|
|
1055
|
+
* @param options - Options bucket.
|
|
1056
|
+
*/
|
|
1057
|
+
notify(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingNotifyRequest;
|
|
1058
|
+
/**
|
|
1059
|
+
* Send PRACK request.
|
|
1060
|
+
* Acknowledge a reliable provisional response.
|
|
1061
|
+
* https://tools.ietf.org/html/rfc3262#section-4
|
|
1062
|
+
* @param delegate - Request delegate.
|
|
1063
|
+
* @param options - Options bucket.
|
|
1064
|
+
*/
|
|
1065
|
+
prack(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingPrackRequest;
|
|
1066
|
+
/**
|
|
1067
|
+
* Send REFER request.
|
|
1068
|
+
* Transfer a session.
|
|
1069
|
+
* https://tools.ietf.org/html/rfc3515#section-2.4.1
|
|
1070
|
+
* @param delegate - Request delegate.
|
|
1071
|
+
* @param options - Options bucket.
|
|
1072
|
+
*/
|
|
1073
|
+
refer(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingReferRequest;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Session state.
|
|
1077
|
+
* @remarks
|
|
1078
|
+
* https://tools.ietf.org/html/rfc3261#section-13
|
|
1079
|
+
* @public
|
|
1080
|
+
*/
|
|
1081
|
+
declare enum SessionState$1 {
|
|
1082
|
+
Initial = "Initial",
|
|
1083
|
+
Early = "Early",
|
|
1084
|
+
AckWait = "AckWait",
|
|
1085
|
+
Confirmed = "Confirmed",
|
|
1086
|
+
Terminated = "Terminated"
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Offer/Answer state.
|
|
1090
|
+
* @remarks
|
|
1091
|
+
* ```txt
|
|
1092
|
+
* Offer Answer RFC Ini Est Early
|
|
1093
|
+
* -------------------------------------------------------------------
|
|
1094
|
+
* 1. INVITE Req. 2xx INVITE Resp. RFC 3261 Y Y N
|
|
1095
|
+
* 2. 2xx INVITE Resp. ACK Req. RFC 3261 Y Y N
|
|
1096
|
+
* 3. INVITE Req. 1xx-rel INVITE Resp. RFC 3262 Y Y N
|
|
1097
|
+
* 4. 1xx-rel INVITE Resp. PRACK Req. RFC 3262 Y Y N
|
|
1098
|
+
* 5. PRACK Req. 200 PRACK Resp. RFC 3262 N Y Y
|
|
1099
|
+
* 6. UPDATE Req. 2xx UPDATE Resp. RFC 3311 N Y Y
|
|
1100
|
+
*
|
|
1101
|
+
* Table 1: Summary of SIP Usage of the Offer/Answer Model
|
|
1102
|
+
* ```
|
|
1103
|
+
* https://tools.ietf.org/html/rfc6337#section-2.2
|
|
1104
|
+
* @public
|
|
1105
|
+
*/
|
|
1106
|
+
declare enum SignalingState {
|
|
1107
|
+
Initial = "Initial",
|
|
1108
|
+
HaveLocalOffer = "HaveLocalOffer",
|
|
1109
|
+
HaveRemoteOffer = "HaveRemoteOffer",
|
|
1110
|
+
Stable = "Stable",
|
|
1111
|
+
Closed = "Closed"
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* Incoming INVITE request.
|
|
1116
|
+
* @public
|
|
1117
|
+
*/
|
|
1118
|
+
interface IncomingInviteRequest extends IncomingRequest {
|
|
1119
|
+
/**
|
|
1120
|
+
* Send a 2xx positive final response to this request. Defaults to 200.
|
|
1121
|
+
* @param options - Response options bucket.
|
|
1122
|
+
* @returns Outgoing response and a confirmed Session.
|
|
1123
|
+
*/
|
|
1124
|
+
accept(options?: ResponseOptions): OutgoingResponseWithSession;
|
|
1125
|
+
/**
|
|
1126
|
+
* Send a 1xx provisional response to this request. Defaults to 180. Excludes 100.
|
|
1127
|
+
* @param options - Response options bucket.
|
|
1128
|
+
* @returns Outgoing response and an early Session.
|
|
1129
|
+
*/
|
|
1130
|
+
progress(options?: ResponseOptions): OutgoingResponseWithSession;
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Outgoing INVITE response with the associated {@link Session}.
|
|
1134
|
+
* @public
|
|
1135
|
+
*/
|
|
1136
|
+
interface OutgoingResponseWithSession extends OutgoingResponse {
|
|
1137
|
+
/**
|
|
1138
|
+
* Session associated with incoming request acceptance, or
|
|
1139
|
+
* Session associated with incoming request progress (if an out of dialog request, an early dialog).
|
|
1140
|
+
*/
|
|
1141
|
+
readonly session: Session$1;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Outgoing INVITE request.
|
|
1145
|
+
* @public
|
|
1146
|
+
*/
|
|
1147
|
+
interface OutgoingInviteRequest extends OutgoingRequest {
|
|
1148
|
+
/** Delegate providing custom handling of this outgoing INVITE request. */
|
|
1149
|
+
delegate?: OutgoingInviteRequestDelegate;
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Delegate providing custom handling of outgoing INVITE requests.
|
|
1153
|
+
* @public
|
|
1154
|
+
*/
|
|
1155
|
+
interface OutgoingInviteRequestDelegate extends OutgoingRequestDelegate {
|
|
1156
|
+
/**
|
|
1157
|
+
* Received a 2xx positive final response to this request.
|
|
1158
|
+
* @param response - Incoming response (including a confirmed Session).
|
|
1159
|
+
*/
|
|
1160
|
+
onAccept?(response: AckableIncomingResponseWithSession): void;
|
|
1161
|
+
/**
|
|
1162
|
+
* Received a 1xx provisional response to this request. Excluding 100 responses.
|
|
1163
|
+
* @param response - Incoming response (including an early Session).
|
|
1164
|
+
*/
|
|
1165
|
+
onProgress?(response: PrackableIncomingResponseWithSession): void;
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Incoming INVITE response received when request is accepted.
|
|
1169
|
+
* @public
|
|
1170
|
+
*/
|
|
1171
|
+
interface AckableIncomingResponseWithSession extends IncomingResponse {
|
|
1172
|
+
/** Session associated with outgoing request acceptance. */
|
|
1173
|
+
readonly session: Session$1;
|
|
1174
|
+
/**
|
|
1175
|
+
* Send an ACK to acknowledge this response.
|
|
1176
|
+
* @param options - Request options bucket.
|
|
1177
|
+
*/
|
|
1178
|
+
ack(options?: RequestOptions): OutgoingAckRequest;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Incoming INVITE response received when request is progressed.
|
|
1182
|
+
* @public
|
|
1183
|
+
*/
|
|
1184
|
+
interface PrackableIncomingResponseWithSession extends IncomingResponse {
|
|
1185
|
+
/** Session associated with outgoing request progress. If out of dialog request, an early dialog. */
|
|
1186
|
+
readonly session: Session$1;
|
|
1187
|
+
/**
|
|
1188
|
+
* Send an PRACK to acknowledge this response.
|
|
1189
|
+
* @param options - Request options bucket.
|
|
1190
|
+
*/
|
|
1191
|
+
prack(options?: RequestOptions): OutgoingPrackRequest;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Log levels.
|
|
1196
|
+
* @public
|
|
1197
|
+
*/
|
|
1198
|
+
declare enum Levels {
|
|
1199
|
+
error = 0,
|
|
1200
|
+
warn = 1,
|
|
1201
|
+
log = 2,
|
|
1202
|
+
debug = 3
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Logger.
|
|
1207
|
+
* @public
|
|
1208
|
+
*/
|
|
1209
|
+
declare class LoggerFactory {
|
|
1210
|
+
builtinEnabled: boolean;
|
|
1211
|
+
private _level;
|
|
1212
|
+
private _connector;
|
|
1213
|
+
private loggers;
|
|
1214
|
+
private logger;
|
|
1215
|
+
constructor();
|
|
1216
|
+
get level(): Levels;
|
|
1217
|
+
set level(newLevel: Levels);
|
|
1218
|
+
get connector(): ((level: string, category: string, label: string | undefined, content: any) => void) | undefined;
|
|
1219
|
+
set connector(value: ((level: string, category: string, label: string | undefined, content: any) => void) | undefined);
|
|
1220
|
+
getLogger(category: string, label?: string): Logger;
|
|
1221
|
+
genericLog(levelToLog: Levels, category: string, label: string | undefined, content: any): void;
|
|
1222
|
+
private print;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Logger.
|
|
1227
|
+
* @public
|
|
1228
|
+
*/
|
|
1229
|
+
declare class Logger {
|
|
1230
|
+
private logger;
|
|
1231
|
+
private category;
|
|
1232
|
+
private label;
|
|
1233
|
+
constructor(logger: LoggerFactory, category: string, label?: string);
|
|
1234
|
+
error(content: string): void;
|
|
1235
|
+
warn(content: string): void;
|
|
1236
|
+
log(content: string): void;
|
|
1237
|
+
debug(content: string): void;
|
|
1238
|
+
private genericLog;
|
|
1239
|
+
get level(): Levels;
|
|
1240
|
+
set level(newLevel: Levels);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* Options for {@link Inviter.cancel}.
|
|
1245
|
+
* @public
|
|
1246
|
+
*/
|
|
1247
|
+
interface InviterCancelOptions {
|
|
1248
|
+
extraHeaders?: Array<string>;
|
|
1249
|
+
reasonPhrase?: string;
|
|
1250
|
+
statusCode?: number;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* Options for {@link Inviter.invite}.
|
|
1255
|
+
* @public
|
|
1256
|
+
*/
|
|
1257
|
+
interface InviterInviteOptions {
|
|
1258
|
+
/**
|
|
1259
|
+
* See `core` API.
|
|
1260
|
+
*/
|
|
1261
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
1262
|
+
/**
|
|
1263
|
+
* See `core` API.
|
|
1264
|
+
*/
|
|
1265
|
+
requestOptions?: RequestOptions;
|
|
1266
|
+
/**
|
|
1267
|
+
* Modifiers to pass to SessionDescriptionHandler during the initial INVITE transaction.
|
|
1268
|
+
*/
|
|
1269
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Options to pass to SessionDescriptionHandler during the initial INVITE transaction.
|
|
1272
|
+
*/
|
|
1273
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
1274
|
+
/**
|
|
1275
|
+
* If true, send INVITE without SDP. Default is false.
|
|
1276
|
+
*/
|
|
1277
|
+
withoutSdp?: boolean;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* A received message (incoming MESSAGE).
|
|
1282
|
+
* @public
|
|
1283
|
+
*/
|
|
1284
|
+
declare class Message {
|
|
1285
|
+
private incomingMessageRequest;
|
|
1286
|
+
/** @internal */
|
|
1287
|
+
constructor(incomingMessageRequest: IncomingMessageRequest);
|
|
1288
|
+
/** Incoming MESSAGE request message. */
|
|
1289
|
+
get request(): IncomingRequestMessage;
|
|
1290
|
+
/** Accept the request. */
|
|
1291
|
+
accept(options?: ResponseOptions): Promise<void>;
|
|
1292
|
+
/** Reject the request. */
|
|
1293
|
+
reject(options?: ResponseOptions): Promise<void>;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* A notification of an event (incoming NOTIFY).
|
|
1298
|
+
* @public
|
|
1299
|
+
*/
|
|
1300
|
+
declare class Notification {
|
|
1301
|
+
private incomingNotifyRequest;
|
|
1302
|
+
/** @internal */
|
|
1303
|
+
constructor(incomingNotifyRequest: IncomingNotifyRequest);
|
|
1304
|
+
/** Incoming NOTIFY request message. */
|
|
1305
|
+
get request(): IncomingRequestMessage;
|
|
1306
|
+
/** Accept the request. */
|
|
1307
|
+
accept(options?: ResponseOptions): Promise<void>;
|
|
1308
|
+
/** Reject the request. */
|
|
1309
|
+
reject(options?: ResponseOptions): Promise<void>;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* A request to establish a {@link Session} elsewhere (incoming REFER).
|
|
1314
|
+
* @public
|
|
1315
|
+
*/
|
|
1316
|
+
declare class Referral {
|
|
1317
|
+
private incomingReferRequest;
|
|
1318
|
+
private session;
|
|
1319
|
+
private inviter;
|
|
1320
|
+
/** @internal */
|
|
1321
|
+
constructor(incomingReferRequest: IncomingReferRequest, session: Session);
|
|
1322
|
+
get referTo(): NameAddrHeader;
|
|
1323
|
+
get referredBy(): string | undefined;
|
|
1324
|
+
get replaces(): string | undefined;
|
|
1325
|
+
/** Incoming REFER request message. */
|
|
1326
|
+
get request(): IncomingRequestMessage;
|
|
1327
|
+
/** Accept the request. */
|
|
1328
|
+
accept(options?: ResponseOptions): Promise<void>;
|
|
1329
|
+
/** Reject the request. */
|
|
1330
|
+
reject(options?: ResponseOptions): Promise<void>;
|
|
1331
|
+
/**
|
|
1332
|
+
* Creates an inviter which may be used to send an out of dialog INVITE request.
|
|
1333
|
+
*
|
|
1334
|
+
* @remarks
|
|
1335
|
+
* This a helper method to create an Inviter which will execute the referral
|
|
1336
|
+
* of the `Session` which was referred. The appropriate headers are set and
|
|
1337
|
+
* the referred `Session` is linked to the new `Session`. Note that only a
|
|
1338
|
+
* single instance of the `Inviter` will be created and returned (if called
|
|
1339
|
+
* more than once a reference to the same `Inviter` will be returned every time).
|
|
1340
|
+
*
|
|
1341
|
+
* @param options - Options bucket.
|
|
1342
|
+
* @param modifiers - Session description handler modifiers.
|
|
1343
|
+
*/
|
|
1344
|
+
makeInviter(options?: InviterOptions): Inviter;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* Delegate for {@link Session}.
|
|
1349
|
+
* @public
|
|
1350
|
+
*/
|
|
1351
|
+
interface SessionDelegate {
|
|
1352
|
+
/**
|
|
1353
|
+
* Called upon receiving an incoming in dialog ACK request.
|
|
1354
|
+
* @remarks
|
|
1355
|
+
* Includes the ACK confirming an accepted initial Invite
|
|
1356
|
+
* as well as ACKs associated with in dialog INVITE requests.
|
|
1357
|
+
* @param ack - The ack.
|
|
1358
|
+
*/
|
|
1359
|
+
onAck?(ack: Ack): void;
|
|
1360
|
+
/**
|
|
1361
|
+
* Called upon receiving an incoming in dialog BYE request.
|
|
1362
|
+
* @param bye - The bye.
|
|
1363
|
+
*/
|
|
1364
|
+
onBye?(bye: Bye): void;
|
|
1365
|
+
/**
|
|
1366
|
+
* Called upon receiving an incoming CANCEL request.
|
|
1367
|
+
* @remarks
|
|
1368
|
+
* Relevant to an Invitation only. CANCEL reqeusts are being handled as
|
|
1369
|
+
* a special case and there is currently no way to externally impact the
|
|
1370
|
+
* response to the a CANCEL request. See core implementation for details.
|
|
1371
|
+
* @param cancel - The cancel.
|
|
1372
|
+
*/
|
|
1373
|
+
onCancel?(cancel: Cancel): void;
|
|
1374
|
+
/**
|
|
1375
|
+
* Called upon receiving an incoming in dialog INFO request.
|
|
1376
|
+
* @param info - The info.
|
|
1377
|
+
*/
|
|
1378
|
+
onInfo?(info: Info): void;
|
|
1379
|
+
/**
|
|
1380
|
+
* Called upon receiving an incoming in dialog INVITE request.
|
|
1381
|
+
* @param invite - The invite.
|
|
1382
|
+
*/
|
|
1383
|
+
onInvite?(request: IncomingRequestMessage, response: string, statusCode: number): void;
|
|
1384
|
+
/**
|
|
1385
|
+
* Called upon receiving an incoming in dialog MESSAGE request.
|
|
1386
|
+
* @param message - The message.
|
|
1387
|
+
*/
|
|
1388
|
+
onMessage?(message: Message): void;
|
|
1389
|
+
/**
|
|
1390
|
+
* Called upon receiving an incoming in dialog NOTIFY request.
|
|
1391
|
+
*
|
|
1392
|
+
* @remarks
|
|
1393
|
+
* If a refer is in progress notifications are delivered to the referrers delegate.
|
|
1394
|
+
*
|
|
1395
|
+
* @param notification - The notification.
|
|
1396
|
+
*/
|
|
1397
|
+
onNotify?(notification: Notification): void;
|
|
1398
|
+
/**
|
|
1399
|
+
* Called upon receiving an incoming in dialog REFER request.
|
|
1400
|
+
* @param referral - The referral.
|
|
1401
|
+
*/
|
|
1402
|
+
onRefer?(referral: Referral): void;
|
|
1403
|
+
/**
|
|
1404
|
+
* Called upon creating a SessionDescriptionHandler.
|
|
1405
|
+
*
|
|
1406
|
+
* @remarks
|
|
1407
|
+
* It's recommended that the SessionDescriptionHandler be accessed via the `Session.sessionDescriptionHandler` property.
|
|
1408
|
+
* However there are use cases where one needs access immediately after it is constructed and before it is utilized.
|
|
1409
|
+
* Thus this callback.
|
|
1410
|
+
*
|
|
1411
|
+
* In most scenarios a single SessionDescriptionHandler will be created per Session
|
|
1412
|
+
* in which case this callback will be called at most once and `provisional` will be `false`.
|
|
1413
|
+
*
|
|
1414
|
+
* However if reliable provisional responses are being supported and an INVITE is sent without SDP,
|
|
1415
|
+
* one or more session description handlers will be created if remote offers are received in reliable provisional responses.
|
|
1416
|
+
* When remote offers are received in reliable provisional responses, the `provisional` parameter will be `true`.
|
|
1417
|
+
* When the `provisional` paramter is `true`, this callback may (or may not) be called again.
|
|
1418
|
+
* If the session is ultimately established using a SessionDescriptionHandler which was not created provisionally,
|
|
1419
|
+
* this callback will be called again and the `provisional` parameter will be `false`.
|
|
1420
|
+
* If the session is ultimately established using a SessionDescriptionHandler which was created provisionally,
|
|
1421
|
+
* this callback will not be called again.
|
|
1422
|
+
* Note that if the session is ultimately established using a SessionDescriptionHandler which was created provisionally,
|
|
1423
|
+
* the provisional SessionDescriptionHandler being utilized will be available via the `Session.sessionDescriptionHandler` property.
|
|
1424
|
+
*
|
|
1425
|
+
* @param sessionDescriptionHandler - The handler.
|
|
1426
|
+
* @param provisional - True if created provisionally.
|
|
1427
|
+
*/
|
|
1428
|
+
onSessionDescriptionHandler?(sessionDescriptionHandler: SessionDescriptionHandler, provisional: boolean): void;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
/**
|
|
1432
|
+
* Options for {@link Session} constructor.
|
|
1433
|
+
* @public
|
|
1434
|
+
*/
|
|
1435
|
+
interface SessionOptions {
|
|
1436
|
+
delegate?: SessionDelegate;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Options for {@link Inviter} constructor.
|
|
1441
|
+
* @public
|
|
1442
|
+
*/
|
|
1443
|
+
interface InviterOptions extends SessionOptions {
|
|
1444
|
+
/** If true, an anonymous call. */
|
|
1445
|
+
anonymous?: boolean;
|
|
1446
|
+
/**
|
|
1447
|
+
* If true, the first answer to the local offer is immediately utilized for media.
|
|
1448
|
+
* Requires that the INVITE request MUST NOT fork.
|
|
1449
|
+
* Has no effect if `inviteWithoutSdp` is true.
|
|
1450
|
+
* Default is false.
|
|
1451
|
+
*/
|
|
1452
|
+
earlyMedia?: boolean;
|
|
1453
|
+
/** Array of extra headers added to the INVITE. */
|
|
1454
|
+
extraHeaders?: Array<string>;
|
|
1455
|
+
/** If true, send INVITE without SDP. Default is false. */
|
|
1456
|
+
inviteWithoutSdp?: boolean;
|
|
1457
|
+
/** @deprecated TODO: provide alternative. */
|
|
1458
|
+
params?: {
|
|
1459
|
+
fromDisplayName?: string;
|
|
1460
|
+
fromTag?: string;
|
|
1461
|
+
fromUri?: string | URI;
|
|
1462
|
+
toDisplayName?: string;
|
|
1463
|
+
toUri?: string | URI;
|
|
1464
|
+
};
|
|
1465
|
+
/** @deprecated TODO: provide alternative. */
|
|
1466
|
+
renderbody?: string;
|
|
1467
|
+
/** @deprecated TODO: provide alternative. */
|
|
1468
|
+
rendertype?: string;
|
|
1469
|
+
/** Modifiers to pass to SessionDescriptionHandler during the initial INVITE transaction. */
|
|
1470
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
1471
|
+
/** Options to pass to SessionDescriptionHandler during the initial INVITE transaction. */
|
|
1472
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
1473
|
+
/** Modifiers to pass to SessionDescriptionHandler during re-INVITE transactions. */
|
|
1474
|
+
sessionDescriptionHandlerModifiersReInvite?: Array<SessionDescriptionHandlerModifier>;
|
|
1475
|
+
/** Options to pass to SessionDescriptionHandler during re-INVITE transactions. */
|
|
1476
|
+
sessionDescriptionHandlerOptionsReInvite?: SessionDescriptionHandlerOptions;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* Digest Authentication.
|
|
1481
|
+
* @internal
|
|
1482
|
+
*/
|
|
1483
|
+
declare class DigestAuthentication {
|
|
1484
|
+
stale: boolean | undefined;
|
|
1485
|
+
private logger;
|
|
1486
|
+
private ha1;
|
|
1487
|
+
private username;
|
|
1488
|
+
private password;
|
|
1489
|
+
private cnonce;
|
|
1490
|
+
private nc;
|
|
1491
|
+
private ncHex;
|
|
1492
|
+
private response;
|
|
1493
|
+
private algorithm;
|
|
1494
|
+
private realm;
|
|
1495
|
+
private nonce;
|
|
1496
|
+
private opaque;
|
|
1497
|
+
private qop;
|
|
1498
|
+
private method;
|
|
1499
|
+
private uri;
|
|
1500
|
+
/**
|
|
1501
|
+
* Constructor.
|
|
1502
|
+
* @param loggerFactory - LoggerFactory.
|
|
1503
|
+
* @param username - Username.
|
|
1504
|
+
* @param password - Password.
|
|
1505
|
+
*/
|
|
1506
|
+
constructor(loggerFactory: LoggerFactory, ha1: string | undefined, username: string | undefined, password: string | undefined);
|
|
1507
|
+
/**
|
|
1508
|
+
* Performs Digest authentication given a SIP request and the challenge
|
|
1509
|
+
* received in a response to that request.
|
|
1510
|
+
* @param request -
|
|
1511
|
+
* @param challenge -
|
|
1512
|
+
* @returns true if credentials were successfully generated, false otherwise.
|
|
1513
|
+
*/
|
|
1514
|
+
authenticate(request: OutgoingRequestMessage, challenge: any, body?: string): boolean;
|
|
1515
|
+
/**
|
|
1516
|
+
* Return the Proxy-Authorization or WWW-Authorization header value.
|
|
1517
|
+
*/
|
|
1518
|
+
toString(): string;
|
|
1519
|
+
/**
|
|
1520
|
+
* Generate the 'nc' value as required by Digest in this.ncHex by reading this.nc.
|
|
1521
|
+
*/
|
|
1522
|
+
private updateNcHex;
|
|
1523
|
+
/**
|
|
1524
|
+
* Generate Digest 'response' value.
|
|
1525
|
+
*/
|
|
1526
|
+
private calculateResponse;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Transport layer interface expected by the user agent core.
|
|
1531
|
+
*
|
|
1532
|
+
* @remarks
|
|
1533
|
+
* The transport layer is responsible for the actual transmission of
|
|
1534
|
+
* requests and responses over network transports. This includes
|
|
1535
|
+
* determination of the connection to use for a request or response in
|
|
1536
|
+
* the case of connection-oriented transports.
|
|
1537
|
+
* https://tools.ietf.org/html/rfc3261#section-18
|
|
1538
|
+
*
|
|
1539
|
+
* @public
|
|
1540
|
+
*/
|
|
1541
|
+
interface Transport$1 {
|
|
1542
|
+
/**
|
|
1543
|
+
* The transport protocol.
|
|
1544
|
+
*
|
|
1545
|
+
* @remarks
|
|
1546
|
+
* Formatted as defined for the Via header sent-protocol transport.
|
|
1547
|
+
* https://tools.ietf.org/html/rfc3261#section-20.42
|
|
1548
|
+
*/
|
|
1549
|
+
readonly protocol: string;
|
|
1550
|
+
/**
|
|
1551
|
+
* Send a message.
|
|
1552
|
+
*
|
|
1553
|
+
* @remarks
|
|
1554
|
+
* Resolves once message is sent. Otherwise rejects with an Error.
|
|
1555
|
+
*
|
|
1556
|
+
* @param message - Message to send.
|
|
1557
|
+
*/
|
|
1558
|
+
send(message: string): Promise<void>;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* Contact.
|
|
1563
|
+
* @remarks
|
|
1564
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.1.8
|
|
1565
|
+
* This is ported from UA.contact.
|
|
1566
|
+
* FIXME: TODO: This is not a great rep for Contact
|
|
1567
|
+
* and is used in a kinda hacky way herein.
|
|
1568
|
+
* @public
|
|
1569
|
+
*/
|
|
1570
|
+
interface Contact {
|
|
1571
|
+
pubGruu: URI | undefined;
|
|
1572
|
+
tempGruu: URI | undefined;
|
|
1573
|
+
uri: URI;
|
|
1574
|
+
toString: (options?: {
|
|
1575
|
+
anonymous?: boolean;
|
|
1576
|
+
outbound?: boolean;
|
|
1577
|
+
register?: boolean;
|
|
1578
|
+
}) => string;
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* User Agent Core configuration.
|
|
1582
|
+
* @public
|
|
1583
|
+
*/
|
|
1584
|
+
interface UserAgentCoreConfiguration {
|
|
1585
|
+
/**
|
|
1586
|
+
* Address-of-Record (AOR).
|
|
1587
|
+
* @remarks
|
|
1588
|
+
* https://tools.ietf.org/html/rfc3261#section-6
|
|
1589
|
+
*/
|
|
1590
|
+
aor: URI;
|
|
1591
|
+
/**
|
|
1592
|
+
* Contact.
|
|
1593
|
+
* @remarks
|
|
1594
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.1.8
|
|
1595
|
+
*/
|
|
1596
|
+
contact: Contact;
|
|
1597
|
+
/**
|
|
1598
|
+
* From header display name.
|
|
1599
|
+
*/
|
|
1600
|
+
displayName: string;
|
|
1601
|
+
/**
|
|
1602
|
+
* Logger factory.
|
|
1603
|
+
*/
|
|
1604
|
+
loggerFactory: LoggerFactory;
|
|
1605
|
+
/**
|
|
1606
|
+
* Force Via header field transport to TCP.
|
|
1607
|
+
*/
|
|
1608
|
+
hackViaTcp: boolean;
|
|
1609
|
+
/**
|
|
1610
|
+
* Preloaded route set.
|
|
1611
|
+
*/
|
|
1612
|
+
routeSet: Array<string>;
|
|
1613
|
+
/**
|
|
1614
|
+
* Unique instance id.
|
|
1615
|
+
*/
|
|
1616
|
+
sipjsId: string;
|
|
1617
|
+
/**
|
|
1618
|
+
* Option tags of supported SIP extensions.
|
|
1619
|
+
*/
|
|
1620
|
+
supportedOptionTags: Array<string>;
|
|
1621
|
+
/**
|
|
1622
|
+
* Option tags of supported SIP extensions.
|
|
1623
|
+
* Used in responses.
|
|
1624
|
+
* @remarks
|
|
1625
|
+
* FIXME: Make this go away.
|
|
1626
|
+
*/
|
|
1627
|
+
supportedOptionTagsResponse: Array<string>;
|
|
1628
|
+
/**
|
|
1629
|
+
* User-Agent header field value.
|
|
1630
|
+
* @remarks
|
|
1631
|
+
* https://tools.ietf.org/html/rfc3261#section-20.41
|
|
1632
|
+
*/
|
|
1633
|
+
userAgentHeaderFieldValue: string | undefined;
|
|
1634
|
+
/**
|
|
1635
|
+
* Force use of "rport" Via header field parameter.
|
|
1636
|
+
* @remarks
|
|
1637
|
+
* https://www.ietf.org/rfc/rfc3581.txt
|
|
1638
|
+
*/
|
|
1639
|
+
viaForceRport: boolean;
|
|
1640
|
+
/**
|
|
1641
|
+
* Via header field host name or network address.
|
|
1642
|
+
* @remarks
|
|
1643
|
+
* The Via header field indicates the path taken by the request so far
|
|
1644
|
+
* and indicates the path that should be followed in routing responses.
|
|
1645
|
+
*/
|
|
1646
|
+
viaHost: string;
|
|
1647
|
+
/**
|
|
1648
|
+
* DEPRECATED
|
|
1649
|
+
* Authentication factory function.
|
|
1650
|
+
*/
|
|
1651
|
+
authenticationFactory(): DigestAuthentication | undefined;
|
|
1652
|
+
/**
|
|
1653
|
+
* DEPRECATED: This is a hack to get around `Transport`
|
|
1654
|
+
* requiring the `UA` to start for construction.
|
|
1655
|
+
*/
|
|
1656
|
+
transportAccessor(): Transport$1 | undefined;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* Dialog state.
|
|
1661
|
+
* @remarks
|
|
1662
|
+
* A dialog contains certain pieces of state needed for further message
|
|
1663
|
+
* transmissions within the dialog. This state consists of the dialog
|
|
1664
|
+
* ID, a local sequence number (used to order requests from the UA to
|
|
1665
|
+
* its peer), a remote sequence number (used to order requests from its
|
|
1666
|
+
* peer to the UA), a local URI, a remote URI, remote target, a boolean
|
|
1667
|
+
* flag called "secure", and a route set, which is an ordered list of
|
|
1668
|
+
* URIs. The route set is the list of servers that need to be traversed
|
|
1669
|
+
* to send a request to the peer. A dialog can also be in the "early"
|
|
1670
|
+
* state, which occurs when it is created with a provisional response,
|
|
1671
|
+
* and then transition to the "confirmed" state when a 2xx final
|
|
1672
|
+
* response arrives. For other responses, or if no response arrives at
|
|
1673
|
+
* all on that dialog, the early dialog terminates.
|
|
1674
|
+
*
|
|
1675
|
+
* https://tools.ietf.org/html/rfc3261#section-12
|
|
1676
|
+
* @public
|
|
1677
|
+
*/
|
|
1678
|
+
interface DialogState {
|
|
1679
|
+
id: string;
|
|
1680
|
+
early: boolean;
|
|
1681
|
+
callId: string;
|
|
1682
|
+
localTag: string;
|
|
1683
|
+
remoteTag: string;
|
|
1684
|
+
localSequenceNumber: number | undefined;
|
|
1685
|
+
remoteSequenceNumber: number | undefined;
|
|
1686
|
+
localURI: URI;
|
|
1687
|
+
remoteURI: URI;
|
|
1688
|
+
remoteTarget: URI;
|
|
1689
|
+
routeSet: Array<string>;
|
|
1690
|
+
secure: boolean;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Dialog.
|
|
1695
|
+
* @remarks
|
|
1696
|
+
* A key concept for a user agent is that of a dialog. A dialog
|
|
1697
|
+
* represents a peer-to-peer SIP relationship between two user agents
|
|
1698
|
+
* that persists for some time. The dialog facilitates sequencing of
|
|
1699
|
+
* messages between the user agents and proper routing of requests
|
|
1700
|
+
* between both of them. The dialog represents a context in which to
|
|
1701
|
+
* interpret SIP messages.
|
|
1702
|
+
* https://tools.ietf.org/html/rfc3261#section-12
|
|
1703
|
+
* @public
|
|
1704
|
+
*/
|
|
1705
|
+
declare class Dialog {
|
|
1706
|
+
protected core: UserAgentCore;
|
|
1707
|
+
protected dialogState: DialogState;
|
|
1708
|
+
/**
|
|
1709
|
+
* Dialog constructor.
|
|
1710
|
+
* @param core - User agent core.
|
|
1711
|
+
* @param dialogState - Initial dialog state.
|
|
1712
|
+
*/
|
|
1713
|
+
protected constructor(core: UserAgentCore, dialogState: DialogState);
|
|
1714
|
+
/**
|
|
1715
|
+
* When a UAC receives a response that establishes a dialog, it
|
|
1716
|
+
* constructs the state of the dialog. This state MUST be maintained
|
|
1717
|
+
* for the duration of the dialog.
|
|
1718
|
+
* https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
1719
|
+
* @param outgoingRequestMessage - Outgoing request message for dialog.
|
|
1720
|
+
* @param incomingResponseMessage - Incoming response message creating dialog.
|
|
1721
|
+
*/
|
|
1722
|
+
static initialDialogStateForUserAgentClient(outgoingRequestMessage: OutgoingRequestMessage, incomingResponseMessage: IncomingResponseMessage): DialogState;
|
|
1723
|
+
/**
|
|
1724
|
+
* The UAS then constructs the state of the dialog. This state MUST be
|
|
1725
|
+
* maintained for the duration of the dialog.
|
|
1726
|
+
* https://tools.ietf.org/html/rfc3261#section-12.1.1
|
|
1727
|
+
* @param incomingRequestMessage - Incoming request message creating dialog.
|
|
1728
|
+
* @param toTag - Tag in the To field in the response to the incoming request.
|
|
1729
|
+
*/
|
|
1730
|
+
static initialDialogStateForUserAgentServer(incomingRequestMessage: IncomingRequestMessage, toTag: string, early?: boolean): DialogState;
|
|
1731
|
+
/** Destructor. */
|
|
1732
|
+
dispose(): void;
|
|
1733
|
+
/**
|
|
1734
|
+
* A dialog is identified at each UA with a dialog ID, which consists of
|
|
1735
|
+
* a Call-ID value, a local tag and a remote tag. The dialog ID at each
|
|
1736
|
+
* UA involved in the dialog is not the same. Specifically, the local
|
|
1737
|
+
* tag at one UA is identical to the remote tag at the peer UA. The
|
|
1738
|
+
* tags are opaque tokens that facilitate the generation of unique
|
|
1739
|
+
* dialog IDs.
|
|
1740
|
+
* https://tools.ietf.org/html/rfc3261#section-12
|
|
1741
|
+
*/
|
|
1742
|
+
get id(): string;
|
|
1743
|
+
/**
|
|
1744
|
+
* A dialog can also be in the "early" state, which occurs when it is
|
|
1745
|
+
* created with a provisional response, and then it transition to the
|
|
1746
|
+
* "confirmed" state when a 2xx final response received or is sent.
|
|
1747
|
+
*
|
|
1748
|
+
* Note: RFC 3261 is concise on when a dialog is "confirmed", but it
|
|
1749
|
+
* can be a point of confusion if an INVITE dialog is "confirmed" after
|
|
1750
|
+
* a 2xx is sent or after receiving the ACK for the 2xx response.
|
|
1751
|
+
* With careful reading it can be inferred a dialog is always is
|
|
1752
|
+
* "confirmed" when the 2xx is sent (regardless of type of dialog).
|
|
1753
|
+
* However a INVITE dialog does have additional considerations
|
|
1754
|
+
* when it is confirmed but an ACK has not yet been received (in
|
|
1755
|
+
* particular with regard to a callee sending BYE requests).
|
|
1756
|
+
*/
|
|
1757
|
+
get early(): boolean;
|
|
1758
|
+
/** Call identifier component of the dialog id. */
|
|
1759
|
+
get callId(): string;
|
|
1760
|
+
/** Local tag component of the dialog id. */
|
|
1761
|
+
get localTag(): string;
|
|
1762
|
+
/** Remote tag component of the dialog id. */
|
|
1763
|
+
get remoteTag(): string;
|
|
1764
|
+
/** Local sequence number (used to order requests from the UA to its peer). */
|
|
1765
|
+
get localSequenceNumber(): number | undefined;
|
|
1766
|
+
/** Remote sequence number (used to order requests from its peer to the UA). */
|
|
1767
|
+
get remoteSequenceNumber(): number | undefined;
|
|
1768
|
+
/** Local URI. */
|
|
1769
|
+
get localURI(): URI;
|
|
1770
|
+
/** Remote URI. */
|
|
1771
|
+
get remoteURI(): URI;
|
|
1772
|
+
/** Remote target. */
|
|
1773
|
+
get remoteTarget(): URI;
|
|
1774
|
+
/**
|
|
1775
|
+
* Route set, which is an ordered list of URIs. The route set is the
|
|
1776
|
+
* list of servers that need to be traversed to send a request to the peer.
|
|
1777
|
+
*/
|
|
1778
|
+
get routeSet(): Array<string>;
|
|
1779
|
+
/**
|
|
1780
|
+
* If the request was sent over TLS, and the Request-URI contained
|
|
1781
|
+
* a SIPS URI, the "secure" flag is set to true. *NOT IMPLEMENTED*
|
|
1782
|
+
*/
|
|
1783
|
+
get secure(): boolean;
|
|
1784
|
+
/** The user agent core servicing this dialog. */
|
|
1785
|
+
get userAgentCore(): UserAgentCore;
|
|
1786
|
+
/** Confirm the dialog. Only matters if dialog is currently early. */
|
|
1787
|
+
confirm(): void;
|
|
1788
|
+
/**
|
|
1789
|
+
* Requests sent within a dialog, as any other requests, are atomic. If
|
|
1790
|
+
* a particular request is accepted by the UAS, all the state changes
|
|
1791
|
+
* associated with it are performed. If the request is rejected, none
|
|
1792
|
+
* of the state changes are performed.
|
|
1793
|
+
*
|
|
1794
|
+
* Note that some requests, such as INVITEs, affect several pieces of
|
|
1795
|
+
* state.
|
|
1796
|
+
*
|
|
1797
|
+
* https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
1798
|
+
* @param message - Incoming request message within this dialog.
|
|
1799
|
+
*/
|
|
1800
|
+
receiveRequest(message: IncomingRequestMessage): void;
|
|
1801
|
+
/**
|
|
1802
|
+
* If the dialog identifier in the 2xx response matches the dialog
|
|
1803
|
+
* identifier of an existing dialog, the dialog MUST be transitioned to
|
|
1804
|
+
* the "confirmed" state, and the route set for the dialog MUST be
|
|
1805
|
+
* recomputed based on the 2xx response using the procedures of Section
|
|
1806
|
+
* 12.2.1.2. Otherwise, a new dialog in the "confirmed" state MUST be
|
|
1807
|
+
* constructed using the procedures of Section 12.1.2.
|
|
1808
|
+
*
|
|
1809
|
+
* Note that the only piece of state that is recomputed is the route
|
|
1810
|
+
* set. Other pieces of state such as the highest sequence numbers
|
|
1811
|
+
* (remote and local) sent within the dialog are not recomputed. The
|
|
1812
|
+
* route set only is recomputed for backwards compatibility. RFC
|
|
1813
|
+
* 2543 did not mandate mirroring of the Record-Route header field in
|
|
1814
|
+
* a 1xx, only 2xx. However, we cannot update the entire state of
|
|
1815
|
+
* the dialog, since mid-dialog requests may have been sent within
|
|
1816
|
+
* the early dialog, modifying the sequence numbers, for example.
|
|
1817
|
+
*
|
|
1818
|
+
* https://tools.ietf.org/html/rfc3261#section-13.2.2.4
|
|
1819
|
+
*/
|
|
1820
|
+
recomputeRouteSet(message: IncomingResponseMessage): void;
|
|
1821
|
+
/**
|
|
1822
|
+
* A request within a dialog is constructed by using many of the
|
|
1823
|
+
* components of the state stored as part of the dialog.
|
|
1824
|
+
* https://tools.ietf.org/html/rfc3261#section-12.2.1.1
|
|
1825
|
+
* @param method - Outgoing request method.
|
|
1826
|
+
*/
|
|
1827
|
+
createOutgoingRequestMessage(method: string, options?: {
|
|
1828
|
+
cseq?: number;
|
|
1829
|
+
extraHeaders?: Array<string>;
|
|
1830
|
+
body?: Body;
|
|
1831
|
+
}): OutgoingRequestMessage;
|
|
1832
|
+
/**
|
|
1833
|
+
* Increment the local sequence number by one.
|
|
1834
|
+
* It feels like this should be protected, but the current authentication handling currently
|
|
1835
|
+
* needs this to keep the dialog in sync when "auto re-sends" request messages.
|
|
1836
|
+
* @internal
|
|
1837
|
+
*/
|
|
1838
|
+
incrementLocalSequenceNumber(): void;
|
|
1839
|
+
/**
|
|
1840
|
+
* If the remote sequence number was not empty, but the sequence number
|
|
1841
|
+
* of the request is lower than the remote sequence number, the request
|
|
1842
|
+
* is out of order and MUST be rejected with a 500 (Server Internal
|
|
1843
|
+
* Error) response.
|
|
1844
|
+
* https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
1845
|
+
* @param request - Incoming request to guard.
|
|
1846
|
+
* @returns True if the program execution is to continue in the branch in question.
|
|
1847
|
+
* Otherwise a 500 Server Internal Error was stateless sent and request processing must stop.
|
|
1848
|
+
*/
|
|
1849
|
+
protected sequenceGuard(message: IncomingRequestMessage): boolean;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* Outgoing PUBLISH request.
|
|
1854
|
+
* @public
|
|
1855
|
+
*/
|
|
1856
|
+
interface OutgoingPublishRequest extends OutgoingRequest {
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* Incoming REGISTER request.
|
|
1861
|
+
* @public
|
|
1862
|
+
*/
|
|
1863
|
+
interface IncomingRegisterRequest extends IncomingRequest {
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Outgoing REGISTER request.
|
|
1867
|
+
* @public
|
|
1868
|
+
*/
|
|
1869
|
+
interface OutgoingRegisterRequest extends OutgoingRequest {
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
/**
|
|
1873
|
+
* Subscription delegate.
|
|
1874
|
+
* @public
|
|
1875
|
+
*/
|
|
1876
|
+
interface SubscriptionDelegate$1 {
|
|
1877
|
+
/**
|
|
1878
|
+
* Receive NOTIFY request. This includes in dialog NOTIFY requests only.
|
|
1879
|
+
* Thus the first NOTIFY (the subscription creating NOTIFY) will not be provided.
|
|
1880
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.3
|
|
1881
|
+
* @param request - Incoming NOTIFY request.
|
|
1882
|
+
*/
|
|
1883
|
+
onNotify?(request: IncomingNotifyRequest): void;
|
|
1884
|
+
/**
|
|
1885
|
+
* Sent a SUBSCRIBE request. This includes "auto refresh" in dialog SUBSCRIBE requests only.
|
|
1886
|
+
* Thus SUBSCRIBE requests triggered by calls to `refresh()` or `subscribe()` will not be provided.
|
|
1887
|
+
* Thus the first SUBSCRIBE (the subscription creating SUBSCRIBE) will not be provided.
|
|
1888
|
+
* @param request - Outgoing SUBSCRIBE request.
|
|
1889
|
+
*/
|
|
1890
|
+
onRefresh?(request: OutgoingSubscribeRequest): void;
|
|
1891
|
+
/**
|
|
1892
|
+
* Subscription termination. This includes non-NOTIFY termination causes only.
|
|
1893
|
+
* Thus this will not be called if a NOTIFY is the cause of termination.
|
|
1894
|
+
* https://tools.ietf.org/html/rfc6665#section-4.4.1
|
|
1895
|
+
*/
|
|
1896
|
+
onTerminated?(): void;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
/**
|
|
1900
|
+
* Subscription.
|
|
1901
|
+
* @remarks
|
|
1902
|
+
* https://tools.ietf.org/html/rfc6665
|
|
1903
|
+
* @public
|
|
1904
|
+
*/
|
|
1905
|
+
interface Subscription$1 {
|
|
1906
|
+
/** Subscription delegate. */
|
|
1907
|
+
delegate: SubscriptionDelegate$1 | undefined;
|
|
1908
|
+
/** The subscription id. */
|
|
1909
|
+
readonly id: string;
|
|
1910
|
+
/** Subscription expires. Number of seconds until the subscription expires. */
|
|
1911
|
+
readonly subscriptionExpires: number;
|
|
1912
|
+
/** Subscription state. */
|
|
1913
|
+
readonly subscriptionState: SubscriptionState$1;
|
|
1914
|
+
/** If true, refresh subscription prior to expiration. Default is false. */
|
|
1915
|
+
autoRefresh: boolean;
|
|
1916
|
+
/**
|
|
1917
|
+
* Destroy subscription.
|
|
1918
|
+
*/
|
|
1919
|
+
dispose(): void;
|
|
1920
|
+
/**
|
|
1921
|
+
* Send re-SUBSCRIBE request.
|
|
1922
|
+
* Refreshing a subscription and unsubscribing.
|
|
1923
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2.2
|
|
1924
|
+
* @param delegate - Request delegate.
|
|
1925
|
+
* @param options - Options bucket
|
|
1926
|
+
*/
|
|
1927
|
+
subscribe(delegate?: OutgoingSubscribeRequestDelegate, options?: RequestOptions): OutgoingSubscribeRequest;
|
|
1928
|
+
/**
|
|
1929
|
+
* 4.1.2.2. Refreshing of Subscriptions
|
|
1930
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2.2
|
|
1931
|
+
*/
|
|
1932
|
+
refresh(): OutgoingSubscribeRequest;
|
|
1933
|
+
/**
|
|
1934
|
+
* 4.1.2.3. Unsubscribing
|
|
1935
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2.3
|
|
1936
|
+
*/
|
|
1937
|
+
unsubscribe(): OutgoingSubscribeRequest;
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Subscription state.
|
|
1941
|
+
* @remarks
|
|
1942
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2
|
|
1943
|
+
* @public
|
|
1944
|
+
*/
|
|
1945
|
+
declare enum SubscriptionState$1 {
|
|
1946
|
+
Initial = "Initial",
|
|
1947
|
+
NotifyWait = "NotifyWait",
|
|
1948
|
+
Pending = "Pending",
|
|
1949
|
+
Active = "Active",
|
|
1950
|
+
Terminated = "Terminated"
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
/**
|
|
1954
|
+
* Incoming SUBSCRIBE request.
|
|
1955
|
+
* @public
|
|
1956
|
+
*/
|
|
1957
|
+
interface IncomingSubscribeRequest extends IncomingRequest {
|
|
1958
|
+
}
|
|
1959
|
+
/**
|
|
1960
|
+
* Outgoing SUBSCRIBE request.
|
|
1961
|
+
* @public
|
|
1962
|
+
*/
|
|
1963
|
+
interface OutgoingSubscribeRequest extends OutgoingRequest {
|
|
1964
|
+
/** Delegate providing custom handling of this outgoing SUBSCRIBE request. */
|
|
1965
|
+
delegate?: OutgoingSubscribeRequestDelegate;
|
|
1966
|
+
/** Stop waiting for an inital subscription creating NOTIFY. */
|
|
1967
|
+
waitNotifyStop(): void;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Delegate providing custom handling of outgoing SUBSCRIBE requests.
|
|
1971
|
+
* @public
|
|
1972
|
+
*/
|
|
1973
|
+
interface OutgoingSubscribeRequestDelegate extends OutgoingRequestDelegate {
|
|
1974
|
+
/**
|
|
1975
|
+
* Received the initial subscription creating NOTIFY in response to this request.
|
|
1976
|
+
* Called for out of dialog SUBSCRIBE requests only (not called for re-SUBSCRIBE requests).
|
|
1977
|
+
* @param request - Incoming NOTIFY request (including a Subscription).
|
|
1978
|
+
*/
|
|
1979
|
+
onNotify?(request: IncomingRequestWithSubscription): void;
|
|
1980
|
+
/**
|
|
1981
|
+
* Timed out waiting to receive the initial subscription creating NOTIFY in response to this request.
|
|
1982
|
+
* Called for out of dialog SUBSCRIBE requests only (not called for re-SUBSCRIBE requests).
|
|
1983
|
+
*/
|
|
1984
|
+
onNotifyTimeout?(): void;
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* Incoming NOTIFY request with associated {@link Subscription}.
|
|
1988
|
+
* @public
|
|
1989
|
+
*/
|
|
1990
|
+
interface IncomingRequestWithSubscription {
|
|
1991
|
+
/** The NOTIFY request which established the subscription. */
|
|
1992
|
+
readonly request: IncomingNotifyRequest;
|
|
1993
|
+
/** If subscription state is not "terminated", then the subscription. Otherwise undefined. */
|
|
1994
|
+
readonly subscription?: Subscription$1;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
/**
|
|
1998
|
+
* Transaction state.
|
|
1999
|
+
* @public
|
|
2000
|
+
*/
|
|
2001
|
+
declare enum TransactionState {
|
|
2002
|
+
Accepted = "Accepted",
|
|
2003
|
+
Calling = "Calling",
|
|
2004
|
+
Completed = "Completed",
|
|
2005
|
+
Confirmed = "Confirmed",
|
|
2006
|
+
Proceeding = "Proceeding",
|
|
2007
|
+
Terminated = "Terminated",
|
|
2008
|
+
Trying = "Trying"
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* Transaction User (TU).
|
|
2013
|
+
* @remarks
|
|
2014
|
+
* The layer of protocol processing that resides above the transaction layer.
|
|
2015
|
+
* Transaction users include the UAC core, UAS core, and proxy core.
|
|
2016
|
+
* https://tools.ietf.org/html/rfc3261#section-5
|
|
2017
|
+
* https://tools.ietf.org/html/rfc3261#section-6
|
|
2018
|
+
* @public
|
|
2019
|
+
*/
|
|
2020
|
+
interface TransactionUser {
|
|
2021
|
+
/**
|
|
2022
|
+
* Logger factory.
|
|
2023
|
+
*/
|
|
2024
|
+
loggerFactory: LoggerFactory;
|
|
2025
|
+
/**
|
|
2026
|
+
* Callback for notification of transaction state changes.
|
|
2027
|
+
*
|
|
2028
|
+
* Not called when transaction is constructed, so there is
|
|
2029
|
+
* no notification of entering the initial transaction state.
|
|
2030
|
+
* Otherwise, called once for each transaction state change.
|
|
2031
|
+
* State changes adhere to the following RFCs.
|
|
2032
|
+
* https://tools.ietf.org/html/rfc3261#section-17
|
|
2033
|
+
* https://tools.ietf.org/html/rfc6026
|
|
2034
|
+
*/
|
|
2035
|
+
onStateChange?: (newState: TransactionState) => void;
|
|
2036
|
+
/**
|
|
2037
|
+
* Callback for notification of a transport error.
|
|
2038
|
+
*
|
|
2039
|
+
* If a fatal transport error is reported by the transport layer
|
|
2040
|
+
* (generally, due to fatal ICMP errors in UDP or connection failures in
|
|
2041
|
+
* TCP), the condition MUST be treated as a 503 (Service Unavailable)
|
|
2042
|
+
* status code.
|
|
2043
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.3.1
|
|
2044
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1.4
|
|
2045
|
+
* https://tools.ietf.org/html/rfc3261#section-17.2.4
|
|
2046
|
+
* https://tools.ietf.org/html/rfc6026
|
|
2047
|
+
*/
|
|
2048
|
+
onTransportError?: (error: TransportError) => void;
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* UAC Core Transaction User.
|
|
2052
|
+
* @public
|
|
2053
|
+
*/
|
|
2054
|
+
interface ClientTransactionUser extends TransactionUser {
|
|
2055
|
+
/**
|
|
2056
|
+
* Callback for request timeout error.
|
|
2057
|
+
*
|
|
2058
|
+
* When a timeout error is received from the transaction layer, it MUST be
|
|
2059
|
+
* treated as if a 408 (Request Timeout) status code has been received.
|
|
2060
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.3.1
|
|
2061
|
+
* TU MUST be informed of a timeout.
|
|
2062
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
2063
|
+
*/
|
|
2064
|
+
onRequestTimeout?: () => void;
|
|
2065
|
+
/**
|
|
2066
|
+
* Callback for delegation of valid response handling.
|
|
2067
|
+
*
|
|
2068
|
+
* Valid responses are passed up to the TU from the client transaction.
|
|
2069
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1
|
|
2070
|
+
*/
|
|
2071
|
+
receiveResponse?: (response: IncomingResponseMessage) => void;
|
|
2072
|
+
}
|
|
2073
|
+
/**
|
|
2074
|
+
* UAS Core Transaction User.
|
|
2075
|
+
* @public
|
|
2076
|
+
*/
|
|
2077
|
+
interface ServerTransactionUser extends TransactionUser {
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
/**
|
|
2081
|
+
* Transaction.
|
|
2082
|
+
* @remarks
|
|
2083
|
+
* SIP is a transactional protocol: interactions between components take
|
|
2084
|
+
* place in a series of independent message exchanges. Specifically, a
|
|
2085
|
+
* SIP transaction consists of a single request and any responses to
|
|
2086
|
+
* that request, which include zero or more provisional responses and
|
|
2087
|
+
* one or more final responses. In the case of a transaction where the
|
|
2088
|
+
* request was an INVITE (known as an INVITE transaction), the
|
|
2089
|
+
* transaction also includes the ACK only if the final response was not
|
|
2090
|
+
* a 2xx response. If the response was a 2xx, the ACK is not considered
|
|
2091
|
+
* part of the transaction.
|
|
2092
|
+
* https://tools.ietf.org/html/rfc3261#section-17
|
|
2093
|
+
* @public
|
|
2094
|
+
*/
|
|
2095
|
+
declare abstract class Transaction {
|
|
2096
|
+
private _transport;
|
|
2097
|
+
private _user;
|
|
2098
|
+
private _id;
|
|
2099
|
+
private _state;
|
|
2100
|
+
protected logger: Logger;
|
|
2101
|
+
private listeners;
|
|
2102
|
+
protected constructor(_transport: Transport$1, _user: TransactionUser, _id: string, _state: TransactionState, loggerCategory: string);
|
|
2103
|
+
/**
|
|
2104
|
+
* Destructor.
|
|
2105
|
+
* Once the transaction is in the "terminated" state, it is destroyed
|
|
2106
|
+
* immediately and there is no need to call `dispose`. However, if a
|
|
2107
|
+
* transaction needs to be ended prematurely, the transaction user may
|
|
2108
|
+
* do so by calling this method (for example, perhaps the UA is shutting down).
|
|
2109
|
+
* No state transition will occur upon calling this method, all outstanding
|
|
2110
|
+
* transmission timers will be cancelled, and use of the transaction after
|
|
2111
|
+
* calling `dispose` is undefined.
|
|
2112
|
+
*/
|
|
2113
|
+
dispose(): void;
|
|
2114
|
+
/** Transaction id. */
|
|
2115
|
+
get id(): string;
|
|
2116
|
+
/** Transaction kind. Deprecated. */
|
|
2117
|
+
get kind(): string;
|
|
2118
|
+
/** Transaction state. */
|
|
2119
|
+
get state(): TransactionState;
|
|
2120
|
+
/** Transaction transport. */
|
|
2121
|
+
get transport(): Transport$1;
|
|
2122
|
+
/**
|
|
2123
|
+
* Sets up a function that will be called whenever the transaction state changes.
|
|
2124
|
+
* @param listener - Callback function.
|
|
2125
|
+
* @param options - An options object that specifies characteristics about the listener.
|
|
2126
|
+
* If once true, indicates that the listener should be invoked at most once after being added.
|
|
2127
|
+
* If once true, the listener would be automatically removed when invoked.
|
|
2128
|
+
*/
|
|
2129
|
+
addStateChangeListener(listener: () => void, options?: {
|
|
2130
|
+
once?: boolean;
|
|
2131
|
+
}): void;
|
|
2132
|
+
/**
|
|
2133
|
+
* This is currently public so tests may spy on it.
|
|
2134
|
+
* @internal
|
|
2135
|
+
*/
|
|
2136
|
+
notifyStateChangeListeners(): void;
|
|
2137
|
+
/**
|
|
2138
|
+
* Removes a listener previously registered with addStateListener.
|
|
2139
|
+
* @param listener - Callback function.
|
|
2140
|
+
*/
|
|
2141
|
+
removeStateChangeListener(listener: () => void): void;
|
|
2142
|
+
protected logTransportError(error: TransportError, message: string): void;
|
|
2143
|
+
/**
|
|
2144
|
+
* Pass message to transport for transmission. If transport fails,
|
|
2145
|
+
* the transaction user is notified by callback to onTransportError().
|
|
2146
|
+
* @returns
|
|
2147
|
+
* Rejects with `TransportError` if transport fails.
|
|
2148
|
+
*/
|
|
2149
|
+
protected send(message: string): Promise<void>;
|
|
2150
|
+
protected setState(state: TransactionState): void;
|
|
2151
|
+
protected typeToString(): string;
|
|
2152
|
+
protected abstract onTransportError(error: TransportError): void;
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* Server Transaction.
|
|
2157
|
+
* @remarks
|
|
2158
|
+
* The server transaction is responsible for the delivery of requests to
|
|
2159
|
+
* the TU and the reliable transmission of responses. It accomplishes
|
|
2160
|
+
* this through a state machine. Server transactions are created by the
|
|
2161
|
+
* core when a request is received, and transaction handling is desired
|
|
2162
|
+
* for that request (this is not always the case).
|
|
2163
|
+
* https://tools.ietf.org/html/rfc3261#section-17.2
|
|
2164
|
+
* @public
|
|
2165
|
+
*/
|
|
2166
|
+
declare abstract class ServerTransaction extends Transaction {
|
|
2167
|
+
private _request;
|
|
2168
|
+
protected user: ServerTransactionUser;
|
|
2169
|
+
protected constructor(_request: IncomingRequestMessage, transport: Transport$1, user: ServerTransactionUser, state: TransactionState, loggerCategory: string);
|
|
2170
|
+
/** The incoming request the transaction handling. */
|
|
2171
|
+
get request(): IncomingRequestMessage;
|
|
2172
|
+
/**
|
|
2173
|
+
* Receive incoming requests from the transport which match this transaction.
|
|
2174
|
+
* @param request - The incoming request.
|
|
2175
|
+
*/
|
|
2176
|
+
abstract receiveRequest(request: IncomingRequestMessage): void;
|
|
2177
|
+
/**
|
|
2178
|
+
* Receive outgoing responses to this request from the transaction user.
|
|
2179
|
+
* Responses will be delivered to the transport as necessary.
|
|
2180
|
+
* @param statusCode - Response status code.
|
|
2181
|
+
* @param response - Response.
|
|
2182
|
+
*/
|
|
2183
|
+
abstract receiveResponse(statusCode: number, response: string): void;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
declare type ServerTransactionConstructor = new (message: IncomingRequestMessage, transport: Transport$1, user: ServerTransactionUser) => ServerTransaction;
|
|
2187
|
+
/**
|
|
2188
|
+
* User Agent Server (UAS).
|
|
2189
|
+
* @remarks
|
|
2190
|
+
* A user agent server is a logical entity
|
|
2191
|
+
* that generates a response to a SIP request. The response
|
|
2192
|
+
* accepts, rejects, or redirects the request. This role lasts
|
|
2193
|
+
* only for the duration of that transaction. In other words, if
|
|
2194
|
+
* a piece of software responds to a request, it acts as a UAS for
|
|
2195
|
+
* the duration of that transaction. If it generates a request
|
|
2196
|
+
* later, it assumes the role of a user agent client for the
|
|
2197
|
+
* processing of that transaction.
|
|
2198
|
+
* https://tools.ietf.org/html/rfc3261#section-6
|
|
2199
|
+
* @public
|
|
2200
|
+
*/
|
|
2201
|
+
declare class UserAgentServer implements IncomingRequest {
|
|
2202
|
+
private transactionConstructor;
|
|
2203
|
+
protected core: UserAgentCore;
|
|
2204
|
+
message: IncomingRequestMessage;
|
|
2205
|
+
delegate?: IncomingRequestDelegate | undefined;
|
|
2206
|
+
protected logger: Logger;
|
|
2207
|
+
protected toTag: string;
|
|
2208
|
+
private _transaction;
|
|
2209
|
+
constructor(transactionConstructor: ServerTransactionConstructor, core: UserAgentCore, message: IncomingRequestMessage, delegate?: IncomingRequestDelegate | undefined);
|
|
2210
|
+
dispose(): void;
|
|
2211
|
+
get loggerFactory(): LoggerFactory;
|
|
2212
|
+
/** The transaction associated with this request. */
|
|
2213
|
+
get transaction(): ServerTransaction;
|
|
2214
|
+
accept(options?: ResponseOptions): OutgoingResponse;
|
|
2215
|
+
progress(options?: ResponseOptions): OutgoingResponse;
|
|
2216
|
+
redirect(contacts: Array<URI>, options?: ResponseOptions): OutgoingResponse;
|
|
2217
|
+
reject(options?: ResponseOptions): OutgoingResponse;
|
|
2218
|
+
trying(options?: ResponseOptions): OutgoingResponse;
|
|
2219
|
+
/**
|
|
2220
|
+
* If the UAS did not find a matching transaction for the CANCEL
|
|
2221
|
+
* according to the procedure above, it SHOULD respond to the CANCEL
|
|
2222
|
+
* with a 481 (Call Leg/Transaction Does Not Exist). If the transaction
|
|
2223
|
+
* for the original request still exists, the behavior of the UAS on
|
|
2224
|
+
* receiving a CANCEL request depends on whether it has already sent a
|
|
2225
|
+
* final response for the original request. If it has, the CANCEL
|
|
2226
|
+
* request has no effect on the processing of the original request, no
|
|
2227
|
+
* effect on any session state, and no effect on the responses generated
|
|
2228
|
+
* for the original request. If the UAS has not issued a final response
|
|
2229
|
+
* for the original request, its behavior depends on the method of the
|
|
2230
|
+
* original request. If the original request was an INVITE, the UAS
|
|
2231
|
+
* SHOULD immediately respond to the INVITE with a 487 (Request
|
|
2232
|
+
* Terminated). A CANCEL request has no impact on the processing of
|
|
2233
|
+
* transactions with any other method defined in this specification.
|
|
2234
|
+
* https://tools.ietf.org/html/rfc3261#section-9.2
|
|
2235
|
+
* @param request - Incoming CANCEL request.
|
|
2236
|
+
*/
|
|
2237
|
+
receiveCancel(message: IncomingRequestMessage): void;
|
|
2238
|
+
protected get acceptable(): boolean;
|
|
2239
|
+
protected get progressable(): boolean;
|
|
2240
|
+
protected get redirectable(): boolean;
|
|
2241
|
+
protected get rejectable(): boolean;
|
|
2242
|
+
protected get tryingable(): boolean;
|
|
2243
|
+
/**
|
|
2244
|
+
* When a UAS wishes to construct a response to a request, it follows
|
|
2245
|
+
* the general procedures detailed in the following subsections.
|
|
2246
|
+
* Additional behaviors specific to the response code in question, which
|
|
2247
|
+
* are not detailed in this section, may also be required.
|
|
2248
|
+
*
|
|
2249
|
+
* Once all procedures associated with the creation of a response have
|
|
2250
|
+
* been completed, the UAS hands the response back to the server
|
|
2251
|
+
* transaction from which it received the request.
|
|
2252
|
+
* https://tools.ietf.org/html/rfc3261#section-8.2.6
|
|
2253
|
+
* @param statusCode - Status code to reply with.
|
|
2254
|
+
* @param options - Reply options bucket.
|
|
2255
|
+
*/
|
|
2256
|
+
private reply;
|
|
2257
|
+
private init;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
/**
|
|
2261
|
+
* NOTIFY UAS.
|
|
2262
|
+
* @public
|
|
2263
|
+
*/
|
|
2264
|
+
declare class NotifyUserAgentServer extends UserAgentServer implements IncomingNotifyRequest {
|
|
2265
|
+
/**
|
|
2266
|
+
* NOTIFY UAS constructor.
|
|
2267
|
+
* @param dialogOrCore - Dialog for in dialog NOTIFY, UserAgentCore for out of dialog NOTIFY (deprecated).
|
|
2268
|
+
* @param message - Incoming NOTIFY request message.
|
|
2269
|
+
*/
|
|
2270
|
+
constructor(dialogOrCore: Dialog | UserAgentCore, message: IncomingRequestMessage, delegate?: IncomingRequestDelegate);
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
/**
|
|
2274
|
+
* Client Transaction.
|
|
2275
|
+
* @remarks
|
|
2276
|
+
* The client transaction provides its functionality through the
|
|
2277
|
+
* maintenance of a state machine.
|
|
2278
|
+
*
|
|
2279
|
+
* The TU communicates with the client transaction through a simple
|
|
2280
|
+
* interface. When the TU wishes to initiate a new transaction, it
|
|
2281
|
+
* creates a client transaction and passes it the SIP request to send
|
|
2282
|
+
* and an IP address, port, and transport to which to send it. The
|
|
2283
|
+
* client transaction begins execution of its state machine. Valid
|
|
2284
|
+
* responses are passed up to the TU from the client transaction.
|
|
2285
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1
|
|
2286
|
+
* @public
|
|
2287
|
+
*/
|
|
2288
|
+
declare abstract class ClientTransaction extends Transaction {
|
|
2289
|
+
private _request;
|
|
2290
|
+
protected user: ClientTransactionUser;
|
|
2291
|
+
protected constructor(_request: OutgoingRequestMessage, transport: Transport$1, user: ClientTransactionUser, state: TransactionState, loggerCategory: string);
|
|
2292
|
+
private static makeId;
|
|
2293
|
+
/** The outgoing request the transaction handling. */
|
|
2294
|
+
get request(): OutgoingRequestMessage;
|
|
2295
|
+
/**
|
|
2296
|
+
* A 408 to non-INVITE will always arrive too late to be useful ([3]),
|
|
2297
|
+
* The client already has full knowledge of the timeout. The only
|
|
2298
|
+
* information this message would convey is whether or not the server
|
|
2299
|
+
* believed the transaction timed out. However, with the current design
|
|
2300
|
+
* of the NIT, a client cannot do anything with this knowledge. Thus,
|
|
2301
|
+
* the 408 is simply wasting network resources and contributes to the
|
|
2302
|
+
* response bombardment illustrated in [3].
|
|
2303
|
+
* https://tools.ietf.org/html/rfc4320#section-4.1
|
|
2304
|
+
*/
|
|
2305
|
+
protected onRequestTimeout(): void;
|
|
2306
|
+
/**
|
|
2307
|
+
* Receive incoming responses from the transport which match this transaction.
|
|
2308
|
+
* Responses will be delivered to the transaction user as necessary.
|
|
2309
|
+
* @param response - The incoming response.
|
|
2310
|
+
*/
|
|
2311
|
+
abstract receiveResponse(response: IncomingResponseMessage): void;
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
declare type ClientTransactionConstructor = new (message: OutgoingRequestMessage, transport: Transport$1, user: ClientTransactionUser) => ClientTransaction;
|
|
2315
|
+
/**
|
|
2316
|
+
* User Agent Client (UAC).
|
|
2317
|
+
* @remarks
|
|
2318
|
+
* A user agent client is a logical entity
|
|
2319
|
+
* that creates a new request, and then uses the client
|
|
2320
|
+
* transaction state machinery to send it. The role of UAC lasts
|
|
2321
|
+
* only for the duration of that transaction. In other words, if
|
|
2322
|
+
* a piece of software initiates a request, it acts as a UAC for
|
|
2323
|
+
* the duration of that transaction. If it receives a request
|
|
2324
|
+
* later, it assumes the role of a user agent server for the
|
|
2325
|
+
* processing of that transaction.
|
|
2326
|
+
* https://tools.ietf.org/html/rfc3261#section-6
|
|
2327
|
+
* @public
|
|
2328
|
+
*/
|
|
2329
|
+
declare class UserAgentClient implements OutgoingRequest {
|
|
2330
|
+
private transactionConstructor;
|
|
2331
|
+
protected core: UserAgentCore;
|
|
2332
|
+
message: OutgoingRequestMessage;
|
|
2333
|
+
delegate?: OutgoingRequestDelegate | undefined;
|
|
2334
|
+
protected logger: Logger;
|
|
2335
|
+
private _transaction;
|
|
2336
|
+
private credentials;
|
|
2337
|
+
private challenged;
|
|
2338
|
+
private stale;
|
|
2339
|
+
constructor(transactionConstructor: ClientTransactionConstructor, core: UserAgentCore, message: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate | undefined);
|
|
2340
|
+
dispose(): void;
|
|
2341
|
+
get loggerFactory(): LoggerFactory;
|
|
2342
|
+
/** The transaction associated with this request. */
|
|
2343
|
+
get transaction(): ClientTransaction;
|
|
2344
|
+
/**
|
|
2345
|
+
* Since requests other than INVITE are responded to immediately, sending a
|
|
2346
|
+
* CANCEL for a non-INVITE request would always create a race condition.
|
|
2347
|
+
* A CANCEL request SHOULD NOT be sent to cancel a request other than INVITE.
|
|
2348
|
+
* https://tools.ietf.org/html/rfc3261#section-9.1
|
|
2349
|
+
* @param options - Cancel options bucket.
|
|
2350
|
+
*/
|
|
2351
|
+
cancel(reason?: string, options?: RequestOptions): OutgoingRequestMessage;
|
|
2352
|
+
/**
|
|
2353
|
+
* If a 401 (Unauthorized) or 407 (Proxy Authentication Required)
|
|
2354
|
+
* response is received, the UAC SHOULD follow the authorization
|
|
2355
|
+
* procedures of Section 22.2 and Section 22.3 to retry the request with
|
|
2356
|
+
* credentials.
|
|
2357
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.3.5
|
|
2358
|
+
* 22 Usage of HTTP Authentication
|
|
2359
|
+
* https://tools.ietf.org/html/rfc3261#section-22
|
|
2360
|
+
* 22.1 Framework
|
|
2361
|
+
* https://tools.ietf.org/html/rfc3261#section-22.1
|
|
2362
|
+
* 22.2 User-to-User Authentication
|
|
2363
|
+
* https://tools.ietf.org/html/rfc3261#section-22.2
|
|
2364
|
+
* 22.3 Proxy-to-User Authentication
|
|
2365
|
+
* https://tools.ietf.org/html/rfc3261#section-22.3
|
|
2366
|
+
*
|
|
2367
|
+
* FIXME: This "guard for and retry the request with credentials"
|
|
2368
|
+
* implementation is not complete and at best minimally passable.
|
|
2369
|
+
* @param response - The incoming response to guard.
|
|
2370
|
+
* @param dialog - If defined, the dialog within which the response was received.
|
|
2371
|
+
* @returns True if the program execution is to continue in the branch in question.
|
|
2372
|
+
* Otherwise the request is retried with credentials and current request processing must stop.
|
|
2373
|
+
*/
|
|
2374
|
+
protected authenticationGuard(message: IncomingResponseMessage, dialog?: Dialog): boolean;
|
|
2375
|
+
/**
|
|
2376
|
+
* 8.1.3.1 Transaction Layer Errors
|
|
2377
|
+
* In some cases, the response returned by the transaction layer will
|
|
2378
|
+
* not be a SIP message, but rather a transaction layer error. When a
|
|
2379
|
+
* timeout error is received from the transaction layer, it MUST be
|
|
2380
|
+
* treated as if a 408 (Request Timeout) status code has been received.
|
|
2381
|
+
* If a fatal transport error is reported by the transport layer
|
|
2382
|
+
* (generally, due to fatal ICMP errors in UDP or connection failures in
|
|
2383
|
+
* TCP), the condition MUST be treated as a 503 (Service Unavailable)
|
|
2384
|
+
* status code.
|
|
2385
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.3.1
|
|
2386
|
+
*/
|
|
2387
|
+
protected onRequestTimeout(): void;
|
|
2388
|
+
/**
|
|
2389
|
+
* 8.1.3.1 Transaction Layer Errors
|
|
2390
|
+
* In some cases, the response returned by the transaction layer will
|
|
2391
|
+
* not be a SIP message, but rather a transaction layer error. When a
|
|
2392
|
+
* timeout error is received from the transaction layer, it MUST be
|
|
2393
|
+
* treated as if a 408 (Request Timeout) status code has been received.
|
|
2394
|
+
* If a fatal transport error is reported by the transport layer
|
|
2395
|
+
* (generally, due to fatal ICMP errors in UDP or connection failures in
|
|
2396
|
+
* TCP), the condition MUST be treated as a 503 (Service Unavailable)
|
|
2397
|
+
* status code.
|
|
2398
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.3.1
|
|
2399
|
+
* @param error - Transport error
|
|
2400
|
+
*/
|
|
2401
|
+
protected onTransportError(error: TransportError): void;
|
|
2402
|
+
/**
|
|
2403
|
+
* Receive a response from the transaction layer.
|
|
2404
|
+
* @param message - Incoming response message.
|
|
2405
|
+
*/
|
|
2406
|
+
protected receiveResponse(message: IncomingResponseMessage): void;
|
|
2407
|
+
private init;
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* SUBSCRIBE UAC.
|
|
2412
|
+
* @remarks
|
|
2413
|
+
* 4.1. Subscriber Behavior
|
|
2414
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1
|
|
2415
|
+
*
|
|
2416
|
+
* User agent client for installation of a single subscription per SUBSCRIBE request.
|
|
2417
|
+
* TODO: Support for installation of multiple subscriptions on forked SUBSCRIBE requests.
|
|
2418
|
+
* @public
|
|
2419
|
+
*/
|
|
2420
|
+
declare class SubscribeUserAgentClient extends UserAgentClient implements OutgoingSubscribeRequest {
|
|
2421
|
+
delegate: OutgoingSubscribeRequestDelegate | undefined;
|
|
2422
|
+
/** Dialog created upon receiving the first NOTIFY. */
|
|
2423
|
+
private dialog;
|
|
2424
|
+
/** Identifier of this user agent client. */
|
|
2425
|
+
private subscriberId;
|
|
2426
|
+
/** When the subscription expires. Starts as requested expires and updated on 200 and NOTIFY. */
|
|
2427
|
+
private subscriptionExpires;
|
|
2428
|
+
/** The requested expires for the subscription. */
|
|
2429
|
+
private subscriptionExpiresRequested;
|
|
2430
|
+
/** Subscription event being targeted. */
|
|
2431
|
+
private subscriptionEvent;
|
|
2432
|
+
/** Subscription state. */
|
|
2433
|
+
private subscriptionState;
|
|
2434
|
+
/** Timer N Id. */
|
|
2435
|
+
private N;
|
|
2436
|
+
constructor(core: UserAgentCore, message: OutgoingRequestMessage, delegate?: OutgoingSubscribeRequestDelegate);
|
|
2437
|
+
/**
|
|
2438
|
+
* Destructor.
|
|
2439
|
+
* Note that Timer N may live on waiting for an initial NOTIFY and
|
|
2440
|
+
* the delegate may still receive that NOTIFY. If you don't want
|
|
2441
|
+
* that behavior then either clear the delegate so the delegate
|
|
2442
|
+
* doesn't get called (a 200 will be sent in response to the NOTIFY)
|
|
2443
|
+
* or call `waitNotifyStop` which will clear Timer N and remove this
|
|
2444
|
+
* UAC from the core (a 481 will be sent in response to the NOTIFY).
|
|
2445
|
+
*/
|
|
2446
|
+
dispose(): void;
|
|
2447
|
+
/**
|
|
2448
|
+
* Handle out of dialog NOTIFY associated with SUBSCRIBE request.
|
|
2449
|
+
* This is the first NOTIFY received after the SUBSCRIBE request.
|
|
2450
|
+
* @param uas - User agent server handling the subscription creating NOTIFY.
|
|
2451
|
+
*/
|
|
2452
|
+
onNotify(uas: NotifyUserAgentServer): void;
|
|
2453
|
+
waitNotifyStart(): void;
|
|
2454
|
+
waitNotifyStop(): void;
|
|
2455
|
+
/**
|
|
2456
|
+
* Receive a response from the transaction layer.
|
|
2457
|
+
* @param message - Incoming response message.
|
|
2458
|
+
*/
|
|
2459
|
+
protected receiveResponse(message: IncomingResponseMessage): void;
|
|
2460
|
+
/**
|
|
2461
|
+
* To ensure that subscribers do not wait indefinitely for a
|
|
2462
|
+
* subscription to be established, a subscriber starts a Timer N, set to
|
|
2463
|
+
* 64*T1, when it sends a SUBSCRIBE request. If this Timer N expires
|
|
2464
|
+
* prior to the receipt of a NOTIFY request, the subscriber considers
|
|
2465
|
+
* the subscription failed, and cleans up any state associated with the
|
|
2466
|
+
* subscription attempt.
|
|
2467
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2.4
|
|
2468
|
+
*/
|
|
2469
|
+
private timerN;
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
/**
|
|
2473
|
+
* User Agent Core delegate.
|
|
2474
|
+
* @public
|
|
2475
|
+
*/
|
|
2476
|
+
interface UserAgentCoreDelegate {
|
|
2477
|
+
/**
|
|
2478
|
+
* Receive INVITE request.
|
|
2479
|
+
* @param request - Incoming INVITE request.
|
|
2480
|
+
*/
|
|
2481
|
+
onInvite?(request: IncomingInviteRequest): void;
|
|
2482
|
+
/**
|
|
2483
|
+
* Receive MESSAGE request.
|
|
2484
|
+
* @param request - Incoming MESSAGE request.
|
|
2485
|
+
*/
|
|
2486
|
+
onMessage?(request: IncomingMessageRequest): void;
|
|
2487
|
+
/**
|
|
2488
|
+
* DEPRECATED. Receive NOTIFY request.
|
|
2489
|
+
* @param message - Incoming NOTIFY request.
|
|
2490
|
+
*/
|
|
2491
|
+
onNotify?(request: IncomingNotifyRequest): void;
|
|
2492
|
+
/**
|
|
2493
|
+
* Receive REFER request.
|
|
2494
|
+
* @param request - Incoming REFER request.
|
|
2495
|
+
*/
|
|
2496
|
+
onRefer?(request: IncomingReferRequest): void;
|
|
2497
|
+
/**
|
|
2498
|
+
* Receive REGISTER request.
|
|
2499
|
+
* @param request - Incoming REGISTER request.
|
|
2500
|
+
*/
|
|
2501
|
+
onRegister?(request: IncomingRegisterRequest): void;
|
|
2502
|
+
/**
|
|
2503
|
+
* Receive SUBSCRIBE request.
|
|
2504
|
+
* @param request - Incoming SUBSCRIBE request.
|
|
2505
|
+
*/
|
|
2506
|
+
onSubscribe?(request: IncomingSubscribeRequest): void;
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
/**
|
|
2510
|
+
* User Agent Core.
|
|
2511
|
+
* @remarks
|
|
2512
|
+
* Core designates the functions specific to a particular type
|
|
2513
|
+
* of SIP entity, i.e., specific to either a stateful or stateless
|
|
2514
|
+
* proxy, a user agent or registrar. All cores, except those for
|
|
2515
|
+
* the stateless proxy, are transaction users.
|
|
2516
|
+
* https://tools.ietf.org/html/rfc3261#section-6
|
|
2517
|
+
*
|
|
2518
|
+
* UAC Core: The set of processing functions required of a UAC that
|
|
2519
|
+
* reside above the transaction and transport layers.
|
|
2520
|
+
* https://tools.ietf.org/html/rfc3261#section-6
|
|
2521
|
+
*
|
|
2522
|
+
* UAS Core: The set of processing functions required at a UAS that
|
|
2523
|
+
* resides above the transaction and transport layers.
|
|
2524
|
+
* https://tools.ietf.org/html/rfc3261#section-6
|
|
2525
|
+
* @public
|
|
2526
|
+
*/
|
|
2527
|
+
declare class UserAgentCore {
|
|
2528
|
+
/** Configuration. */
|
|
2529
|
+
configuration: UserAgentCoreConfiguration;
|
|
2530
|
+
/** Delegate. */
|
|
2531
|
+
delegate: UserAgentCoreDelegate;
|
|
2532
|
+
/** Dialogs. */
|
|
2533
|
+
dialogs: Map<string, Dialog>;
|
|
2534
|
+
/** Subscribers. */
|
|
2535
|
+
subscribers: Map<string, SubscribeUserAgentClient>;
|
|
2536
|
+
/** UACs. */
|
|
2537
|
+
userAgentClients: Map<string, UserAgentClient>;
|
|
2538
|
+
/** UASs. */
|
|
2539
|
+
userAgentServers: Map<string, UserAgentServer>;
|
|
2540
|
+
private logger;
|
|
2541
|
+
/**
|
|
2542
|
+
* Constructor.
|
|
2543
|
+
* @param configuration - Configuration.
|
|
2544
|
+
* @param delegate - Delegate.
|
|
2545
|
+
*/
|
|
2546
|
+
constructor(configuration: UserAgentCoreConfiguration, delegate?: UserAgentCoreDelegate);
|
|
2547
|
+
/** Destructor. */
|
|
2548
|
+
dispose(): void;
|
|
2549
|
+
/** Reset. */
|
|
2550
|
+
reset(): void;
|
|
2551
|
+
/** Logger factory. */
|
|
2552
|
+
get loggerFactory(): LoggerFactory;
|
|
2553
|
+
/** Transport. */
|
|
2554
|
+
get transport(): Transport$1;
|
|
2555
|
+
/**
|
|
2556
|
+
* Send INVITE.
|
|
2557
|
+
* @param request - Outgoing request.
|
|
2558
|
+
* @param delegate - Request delegate.
|
|
2559
|
+
*/
|
|
2560
|
+
invite(request: OutgoingRequestMessage, delegate?: OutgoingInviteRequestDelegate): OutgoingInviteRequest;
|
|
2561
|
+
/**
|
|
2562
|
+
* Send MESSAGE.
|
|
2563
|
+
* @param request - Outgoing request.
|
|
2564
|
+
* @param delegate - Request delegate.
|
|
2565
|
+
*/
|
|
2566
|
+
message(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingMessageRequest;
|
|
2567
|
+
/**
|
|
2568
|
+
* Send PUBLISH.
|
|
2569
|
+
* @param request - Outgoing request.
|
|
2570
|
+
* @param delegate - Request delegate.
|
|
2571
|
+
*/
|
|
2572
|
+
publish(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingPublishRequest;
|
|
2573
|
+
/**
|
|
2574
|
+
* Send REGISTER.
|
|
2575
|
+
* @param request - Outgoing request.
|
|
2576
|
+
* @param delegate - Request delegate.
|
|
2577
|
+
*/
|
|
2578
|
+
register(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingRegisterRequest;
|
|
2579
|
+
/**
|
|
2580
|
+
* Send SUBSCRIBE.
|
|
2581
|
+
* @param request - Outgoing request.
|
|
2582
|
+
* @param delegate - Request delegate.
|
|
2583
|
+
*/
|
|
2584
|
+
subscribe(request: OutgoingRequestMessage, delegate?: OutgoingSubscribeRequestDelegate): OutgoingSubscribeRequest;
|
|
2585
|
+
/**
|
|
2586
|
+
* Send a request.
|
|
2587
|
+
* @param request - Outgoing request.
|
|
2588
|
+
* @param delegate - Request delegate.
|
|
2589
|
+
*/
|
|
2590
|
+
request(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingRequest;
|
|
2591
|
+
/**
|
|
2592
|
+
* Outgoing request message factory function.
|
|
2593
|
+
* @param method - Method.
|
|
2594
|
+
* @param requestURI - Request-URI.
|
|
2595
|
+
* @param fromURI - From URI.
|
|
2596
|
+
* @param toURI - To URI.
|
|
2597
|
+
* @param options - Request options.
|
|
2598
|
+
* @param extraHeaders - Extra headers to add.
|
|
2599
|
+
* @param body - Message body.
|
|
2600
|
+
*/
|
|
2601
|
+
makeOutgoingRequestMessage(method: string, requestURI: URI, fromURI: URI, toURI: URI, options: OutgoingRequestMessageOptions, extraHeaders?: Array<string>, body?: Body): OutgoingRequestMessage;
|
|
2602
|
+
/**
|
|
2603
|
+
* Handle an incoming request message from the transport.
|
|
2604
|
+
* @param message - Incoming request message from transport layer.
|
|
2605
|
+
*/
|
|
2606
|
+
receiveIncomingRequestFromTransport(message: IncomingRequestMessage): void;
|
|
2607
|
+
/**
|
|
2608
|
+
* Handle an incoming response message from the transport.
|
|
2609
|
+
* @param message - Incoming response message from transport layer.
|
|
2610
|
+
*/
|
|
2611
|
+
receiveIncomingResponseFromTransport(message: IncomingResponseMessage): void;
|
|
2612
|
+
/**
|
|
2613
|
+
* A stateless UAS is a UAS that does not maintain transaction state.
|
|
2614
|
+
* It replies to requests normally, but discards any state that would
|
|
2615
|
+
* ordinarily be retained by a UAS after a response has been sent. If a
|
|
2616
|
+
* stateless UAS receives a retransmission of a request, it regenerates
|
|
2617
|
+
* the response and re-sends it, just as if it were replying to the first
|
|
2618
|
+
* instance of the request. A UAS cannot be stateless unless the request
|
|
2619
|
+
* processing for that method would always result in the same response
|
|
2620
|
+
* if the requests are identical. This rules out stateless registrars,
|
|
2621
|
+
* for example. Stateless UASs do not use a transaction layer; they
|
|
2622
|
+
* receive requests directly from the transport layer and send responses
|
|
2623
|
+
* directly to the transport layer.
|
|
2624
|
+
* https://tools.ietf.org/html/rfc3261#section-8.2.7
|
|
2625
|
+
* @param message - Incoming request message to reply to.
|
|
2626
|
+
* @param statusCode - Status code to reply with.
|
|
2627
|
+
*/
|
|
2628
|
+
replyStateless(message: IncomingRequestMessage, options: ResponseOptions): OutgoingResponse;
|
|
2629
|
+
/**
|
|
2630
|
+
* In Section 18.2.1, replace the last paragraph with:
|
|
2631
|
+
*
|
|
2632
|
+
* Next, the server transport attempts to match the request to a
|
|
2633
|
+
* server transaction. It does so using the matching rules described
|
|
2634
|
+
* in Section 17.2.3. If a matching server transaction is found, the
|
|
2635
|
+
* request is passed to that transaction for processing. If no match
|
|
2636
|
+
* is found, the request is passed to the core, which may decide to
|
|
2637
|
+
* construct a new server transaction for that request.
|
|
2638
|
+
* https://tools.ietf.org/html/rfc6026#section-8.10
|
|
2639
|
+
* @param message - Incoming request message from transport layer.
|
|
2640
|
+
*/
|
|
2641
|
+
private receiveRequestFromTransport;
|
|
2642
|
+
/**
|
|
2643
|
+
* UAC and UAS procedures depend strongly on two factors. First, based
|
|
2644
|
+
* on whether the request or response is inside or outside of a dialog,
|
|
2645
|
+
* and second, based on the method of a request. Dialogs are discussed
|
|
2646
|
+
* thoroughly in Section 12; they represent a peer-to-peer relationship
|
|
2647
|
+
* between user agents and are established by specific SIP methods, such
|
|
2648
|
+
* as INVITE.
|
|
2649
|
+
* @param message - Incoming request message.
|
|
2650
|
+
*/
|
|
2651
|
+
private receiveRequest;
|
|
2652
|
+
/**
|
|
2653
|
+
* Once a dialog has been established between two UAs, either of them
|
|
2654
|
+
* MAY initiate new transactions as needed within the dialog. The UA
|
|
2655
|
+
* sending the request will take the UAC role for the transaction. The
|
|
2656
|
+
* UA receiving the request will take the UAS role. Note that these may
|
|
2657
|
+
* be different roles than the UAs held during the transaction that
|
|
2658
|
+
* established the dialog.
|
|
2659
|
+
* https://tools.ietf.org/html/rfc3261#section-12.2
|
|
2660
|
+
* @param message - Incoming request message.
|
|
2661
|
+
*/
|
|
2662
|
+
private receiveInsideDialogRequest;
|
|
2663
|
+
/**
|
|
2664
|
+
* Assuming all of the checks in the previous subsections are passed,
|
|
2665
|
+
* the UAS processing becomes method-specific.
|
|
2666
|
+
* https://tools.ietf.org/html/rfc3261#section-8.2.5
|
|
2667
|
+
* @param message - Incoming request message.
|
|
2668
|
+
*/
|
|
2669
|
+
private receiveOutsideDialogRequest;
|
|
2670
|
+
/**
|
|
2671
|
+
* Responses are first processed by the transport layer and then passed
|
|
2672
|
+
* up to the transaction layer. The transaction layer performs its
|
|
2673
|
+
* processing and then passes the response up to the TU. The majority
|
|
2674
|
+
* of response processing in the TU is method specific. However, there
|
|
2675
|
+
* are some general behaviors independent of the method.
|
|
2676
|
+
* https://tools.ietf.org/html/rfc3261#section-8.1.3
|
|
2677
|
+
* @param message - Incoming response message from transport layer.
|
|
2678
|
+
*/
|
|
2679
|
+
private receiveResponseFromTransport;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
/**
|
|
2683
|
+
* Options for {@link Publisher} constructor.
|
|
2684
|
+
* @public
|
|
2685
|
+
*/
|
|
2686
|
+
interface PublisherOptions {
|
|
2687
|
+
/** @deprecated TODO: provide alternative. */
|
|
2688
|
+
body?: string;
|
|
2689
|
+
/** @deprecated TODO: provide alternative. */
|
|
2690
|
+
contentType?: string;
|
|
2691
|
+
/**
|
|
2692
|
+
* Expire value for the published event.
|
|
2693
|
+
* @defaultValue 3600
|
|
2694
|
+
*/
|
|
2695
|
+
expires?: number;
|
|
2696
|
+
/**
|
|
2697
|
+
* Array of extra headers added to the PUBLISH request message.
|
|
2698
|
+
*/
|
|
2699
|
+
extraHeaders?: Array<string>;
|
|
2700
|
+
/** @deprecated TODO: provide alternative. */
|
|
2701
|
+
params?: {
|
|
2702
|
+
fromDisplayName?: string;
|
|
2703
|
+
fromTag?: string;
|
|
2704
|
+
fromUri?: URI;
|
|
2705
|
+
toDisplayName?: string;
|
|
2706
|
+
toUri?: URI;
|
|
2707
|
+
};
|
|
2708
|
+
/**
|
|
2709
|
+
* If set true, UA will gracefully unpublish for the event on UA close.
|
|
2710
|
+
* @defaultValue true
|
|
2711
|
+
*/
|
|
2712
|
+
unpublishOnClose?: boolean;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
/**
|
|
2716
|
+
* Options for {@link Publisher.publish}.
|
|
2717
|
+
* @public
|
|
2718
|
+
*/
|
|
2719
|
+
interface PublisherPublishOptions {
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
/**
|
|
2723
|
+
* {@link Publisher} state.
|
|
2724
|
+
* @remarks
|
|
2725
|
+
* The {@link Publisher} behaves in a deterministic manner according to the following
|
|
2726
|
+
* Finite State Machine (FSM).
|
|
2727
|
+
* ```txt
|
|
2728
|
+
* __________________________________________
|
|
2729
|
+
* | __________________________ |
|
|
2730
|
+
* Publisher | | v v
|
|
2731
|
+
* Constructed -> Initial -> Published -> Unpublished -> Terminated
|
|
2732
|
+
* | ^____________| ^
|
|
2733
|
+
* |______________________________|
|
|
2734
|
+
* ```
|
|
2735
|
+
* @public
|
|
2736
|
+
*/
|
|
2737
|
+
declare enum PublisherState {
|
|
2738
|
+
Initial = "Initial",
|
|
2739
|
+
Published = "Published",
|
|
2740
|
+
Unpublished = "Unpublished",
|
|
2741
|
+
Terminated = "Terminated"
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
/**
|
|
2745
|
+
* Options for {@link Publisher.unpublish}.
|
|
2746
|
+
* @public
|
|
2747
|
+
*/
|
|
2748
|
+
interface PublisherUnpublishOptions {
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
/**
|
|
2752
|
+
* A publisher publishes a publication (outgoing PUBLISH).
|
|
2753
|
+
* @public
|
|
2754
|
+
*/
|
|
2755
|
+
declare class Publisher {
|
|
2756
|
+
private event;
|
|
2757
|
+
private options;
|
|
2758
|
+
private target;
|
|
2759
|
+
private pubRequestBody;
|
|
2760
|
+
private pubRequestExpires;
|
|
2761
|
+
private pubRequestEtag;
|
|
2762
|
+
private publishRefreshTimer;
|
|
2763
|
+
private disposed;
|
|
2764
|
+
private id;
|
|
2765
|
+
private logger;
|
|
2766
|
+
private request;
|
|
2767
|
+
private userAgent;
|
|
2768
|
+
/** The publication state. */
|
|
2769
|
+
private _state;
|
|
2770
|
+
/** Emits when the registration state changes. */
|
|
2771
|
+
private _stateEventEmitter;
|
|
2772
|
+
/**
|
|
2773
|
+
* Constructs a new instance of the `Publisher` class.
|
|
2774
|
+
*
|
|
2775
|
+
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
2776
|
+
* @param targetURI - Request URI identifying the target of the message.
|
|
2777
|
+
* @param eventType - The event type identifying the published document.
|
|
2778
|
+
* @param options - Options bucket. See {@link PublisherOptions} for details.
|
|
2779
|
+
*/
|
|
2780
|
+
constructor(userAgent: UserAgent, targetURI: URI, eventType: string, options?: PublisherOptions);
|
|
2781
|
+
/**
|
|
2782
|
+
* Destructor.
|
|
2783
|
+
*/
|
|
2784
|
+
dispose(): Promise<void>;
|
|
2785
|
+
/** The publication state. */
|
|
2786
|
+
get state(): PublisherState;
|
|
2787
|
+
/** Emits when the publisher state changes. */
|
|
2788
|
+
get stateChange(): Emitter<PublisherState>;
|
|
2789
|
+
/**
|
|
2790
|
+
* Publish.
|
|
2791
|
+
* @param content - Body to publish
|
|
2792
|
+
*/
|
|
2793
|
+
publish(content: string, options?: PublisherPublishOptions): Promise<void>;
|
|
2794
|
+
/**
|
|
2795
|
+
* Unpublish.
|
|
2796
|
+
*/
|
|
2797
|
+
unpublish(options?: PublisherUnpublishOptions): Promise<void>;
|
|
2798
|
+
/** @internal */
|
|
2799
|
+
protected receiveResponse(response: IncomingResponseMessage): void;
|
|
2800
|
+
/** @internal */
|
|
2801
|
+
protected send(): OutgoingPublishRequest;
|
|
2802
|
+
private refreshRequest;
|
|
2803
|
+
private sendPublishRequest;
|
|
2804
|
+
/**
|
|
2805
|
+
* Transition publication state.
|
|
2806
|
+
*/
|
|
2807
|
+
private stateTransition;
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
/**
|
|
2811
|
+
* Options for {@link Registerer} constructor.
|
|
2812
|
+
* @public
|
|
2813
|
+
*/
|
|
2814
|
+
interface RegistererOptions {
|
|
2815
|
+
/** Registration expiration time in seconds. */
|
|
2816
|
+
expires?: number;
|
|
2817
|
+
/** Array of extra Contact header parameters. */
|
|
2818
|
+
extraContactHeaderParams?: Array<string>;
|
|
2819
|
+
/** Array of extra headers added to the REGISTER. */
|
|
2820
|
+
extraHeaders?: Array<string>;
|
|
2821
|
+
/**
|
|
2822
|
+
* UUID to provide with "+sip.instance" Contact parameter.
|
|
2823
|
+
* @defaultValue A randomly generated uuid
|
|
2824
|
+
* @deprecated Use UserAgentOptions.instanceId
|
|
2825
|
+
*/
|
|
2826
|
+
instanceId?: string;
|
|
2827
|
+
/**
|
|
2828
|
+
* If true, constructor logs the registerer configuration.
|
|
2829
|
+
* @defaultValue `true`
|
|
2830
|
+
*/
|
|
2831
|
+
logConfiguration?: boolean;
|
|
2832
|
+
/** @deprecated TODO: provide alternative. */
|
|
2833
|
+
params?: {
|
|
2834
|
+
fromDisplayName?: string;
|
|
2835
|
+
fromTag?: string;
|
|
2836
|
+
fromUri?: URI;
|
|
2837
|
+
toDisplayName?: string;
|
|
2838
|
+
toUri?: URI;
|
|
2839
|
+
};
|
|
2840
|
+
/**
|
|
2841
|
+
* Value to provide with "reg-id" Contact parameter.
|
|
2842
|
+
* @defaultValue 1
|
|
2843
|
+
*/
|
|
2844
|
+
regId?: number;
|
|
2845
|
+
/**
|
|
2846
|
+
* The URI of the registrar to send the REGISTER requests.
|
|
2847
|
+
* @defaultValue domain portion of the user agent's uri
|
|
2848
|
+
*/
|
|
2849
|
+
registrar?: URI;
|
|
2850
|
+
/**
|
|
2851
|
+
* Determines when a re-REGISTER request is sent. The value should be specified as a percentage of the expiration time (between 50 and 99).
|
|
2852
|
+
* @defaultValue 99
|
|
2853
|
+
*/
|
|
2854
|
+
refreshFrequency?: number;
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
/**
|
|
2858
|
+
* Options for {@link Registerer.register}.
|
|
2859
|
+
* @public
|
|
2860
|
+
*/
|
|
2861
|
+
interface RegistererRegisterOptions {
|
|
2862
|
+
/** See `core` API. */
|
|
2863
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
2864
|
+
/** See `core` API. */
|
|
2865
|
+
requestOptions?: RequestOptions;
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
/**
|
|
2869
|
+
* {@link Registerer} state.
|
|
2870
|
+
* @remarks
|
|
2871
|
+
* The {@link Registerer} behaves in a deterministic manner according to the following
|
|
2872
|
+
* Finite State Machine (FSM).
|
|
2873
|
+
* ```txt
|
|
2874
|
+
* __________________________________________
|
|
2875
|
+
* | __________________________ |
|
|
2876
|
+
* Registerer | | v v
|
|
2877
|
+
* Constructed -> Initial -> Registered -> Unregistered -> Terminated
|
|
2878
|
+
* | ^____________| ^
|
|
2879
|
+
* |______________________________|
|
|
2880
|
+
* ```
|
|
2881
|
+
* @public
|
|
2882
|
+
*/
|
|
2883
|
+
declare enum RegistererState {
|
|
2884
|
+
Initial = "Initial",
|
|
2885
|
+
Registered = "Registered",
|
|
2886
|
+
Unregistered = "Unregistered",
|
|
2887
|
+
Terminated = "Terminated"
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
/**
|
|
2891
|
+
* Options for {@link Registerer.unregister}.
|
|
2892
|
+
* @public
|
|
2893
|
+
*/
|
|
2894
|
+
interface RegistererUnregisterOptions {
|
|
2895
|
+
/**
|
|
2896
|
+
* If true, unregister all contacts.
|
|
2897
|
+
* @defaultValue false
|
|
2898
|
+
*/
|
|
2899
|
+
all?: boolean;
|
|
2900
|
+
/** See `core` API. */
|
|
2901
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
2902
|
+
/** See `core` API. */
|
|
2903
|
+
requestOptions?: RequestOptions;
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
/**
|
|
2907
|
+
* A registerer registers a contact for an address of record (outgoing REGISTER).
|
|
2908
|
+
* @public
|
|
2909
|
+
*/
|
|
2910
|
+
declare class Registerer {
|
|
2911
|
+
private static readonly defaultExpires;
|
|
2912
|
+
private static readonly defaultRefreshFrequency;
|
|
2913
|
+
private disposed;
|
|
2914
|
+
private id;
|
|
2915
|
+
private expires;
|
|
2916
|
+
private refreshFrequency;
|
|
2917
|
+
private logger;
|
|
2918
|
+
private options;
|
|
2919
|
+
private request;
|
|
2920
|
+
private userAgent;
|
|
2921
|
+
private registrationExpiredTimer;
|
|
2922
|
+
private registrationTimer;
|
|
2923
|
+
/** The contacts returned from the most recent accepted REGISTER request. */
|
|
2924
|
+
private _contacts;
|
|
2925
|
+
/** The number of seconds to wait before retrying to register. */
|
|
2926
|
+
private _retryAfter;
|
|
2927
|
+
/** The registration state. */
|
|
2928
|
+
private _state;
|
|
2929
|
+
/** Emits when the registration state changes. */
|
|
2930
|
+
private _stateEventEmitter;
|
|
2931
|
+
/** True is waiting for final response to outstanding REGISTER request. */
|
|
2932
|
+
private _waiting;
|
|
2933
|
+
/** Emits when waiting changes. */
|
|
2934
|
+
private _waitingEventEmitter;
|
|
2935
|
+
/**
|
|
2936
|
+
* Constructs a new instance of the `Registerer` class.
|
|
2937
|
+
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
2938
|
+
* @param options - Options bucket. See {@link RegistererOptions} for details.
|
|
2939
|
+
*/
|
|
2940
|
+
constructor(userAgent: UserAgent, options?: RegistererOptions);
|
|
2941
|
+
/** Default registerer options. */
|
|
2942
|
+
private static defaultOptions;
|
|
2943
|
+
/**
|
|
2944
|
+
* Strip properties with undefined values from options.
|
|
2945
|
+
* This is a work around while waiting for missing vs undefined to be addressed (or not)...
|
|
2946
|
+
* https://github.com/Microsoft/TypeScript/issues/13195
|
|
2947
|
+
* @param options - Options to reduce
|
|
2948
|
+
*/
|
|
2949
|
+
private static stripUndefinedProperties;
|
|
2950
|
+
/** The registered contacts. */
|
|
2951
|
+
get contacts(): Array<string>;
|
|
2952
|
+
/**
|
|
2953
|
+
* The number of seconds to wait before retrying to register.
|
|
2954
|
+
* @defaultValue `undefined`
|
|
2955
|
+
* @remarks
|
|
2956
|
+
* When the server rejects a registration request, if it provides a suggested
|
|
2957
|
+
* duration to wait before retrying, that value is available here when and if
|
|
2958
|
+
* the state transitions to `Unsubscribed`. It is also available during the
|
|
2959
|
+
* callback to `onReject` after a call to `register`. (Note that if the state
|
|
2960
|
+
* if already `Unsubscribed`, a rejected request created by `register` will
|
|
2961
|
+
* not cause the state to transition to `Unsubscribed`. One way to avoid this
|
|
2962
|
+
* case is to dispose of `Registerer` when unregistered and create a new
|
|
2963
|
+
* `Registerer` for any attempts to retry registering.)
|
|
2964
|
+
* @example
|
|
2965
|
+
* ```ts
|
|
2966
|
+
* // Checking for retry after on state change
|
|
2967
|
+
* registerer.stateChange.addListener((newState) => {
|
|
2968
|
+
* switch (newState) {
|
|
2969
|
+
* case RegistererState.Unregistered:
|
|
2970
|
+
* const retryAfter = registerer.retryAfter;
|
|
2971
|
+
* break;
|
|
2972
|
+
* }
|
|
2973
|
+
* });
|
|
2974
|
+
*
|
|
2975
|
+
* // Checking for retry after on request rejection
|
|
2976
|
+
* registerer.register({
|
|
2977
|
+
* requestDelegate: {
|
|
2978
|
+
* onReject: () => {
|
|
2979
|
+
* const retryAfter = registerer.retryAfter;
|
|
2980
|
+
* }
|
|
2981
|
+
* }
|
|
2982
|
+
* });
|
|
2983
|
+
* ```
|
|
2984
|
+
*/
|
|
2985
|
+
get retryAfter(): number | undefined;
|
|
2986
|
+
/** The registration state. */
|
|
2987
|
+
get state(): RegistererState;
|
|
2988
|
+
/** Emits when the registerer state changes. */
|
|
2989
|
+
get stateChange(): Emitter<RegistererState>;
|
|
2990
|
+
/** Destructor. */
|
|
2991
|
+
dispose(): Promise<void>;
|
|
2992
|
+
/**
|
|
2993
|
+
* Sends the REGISTER request.
|
|
2994
|
+
* @remarks
|
|
2995
|
+
* If successful, sends re-REGISTER requests prior to registration expiration until `unsubscribe()` is called.
|
|
2996
|
+
* Rejects with `RequestPendingError` if a REGISTER request is already in progress.
|
|
2997
|
+
*/
|
|
2998
|
+
register(options?: RegistererRegisterOptions): Promise<OutgoingRegisterRequest>;
|
|
2999
|
+
/**
|
|
3000
|
+
* Sends the REGISTER request with expires equal to zero.
|
|
3001
|
+
* @remarks
|
|
3002
|
+
* Rejects with `RequestPendingError` if a REGISTER request is already in progress.
|
|
3003
|
+
*/
|
|
3004
|
+
unregister(options?: RegistererUnregisterOptions): Promise<OutgoingRegisterRequest>;
|
|
3005
|
+
/**
|
|
3006
|
+
* Clear registration timers.
|
|
3007
|
+
*/
|
|
3008
|
+
private clearTimers;
|
|
3009
|
+
/**
|
|
3010
|
+
* Generate Contact Header
|
|
3011
|
+
*/
|
|
3012
|
+
private generateContactHeader;
|
|
3013
|
+
/**
|
|
3014
|
+
* Helper function, called when registered.
|
|
3015
|
+
*/
|
|
3016
|
+
private registered;
|
|
3017
|
+
/**
|
|
3018
|
+
* Helper function, called when unregistered.
|
|
3019
|
+
*/
|
|
3020
|
+
private unregistered;
|
|
3021
|
+
/**
|
|
3022
|
+
* Helper function, called when terminated.
|
|
3023
|
+
*/
|
|
3024
|
+
private terminated;
|
|
3025
|
+
/**
|
|
3026
|
+
* Transition registration state.
|
|
3027
|
+
*/
|
|
3028
|
+
private stateTransition;
|
|
3029
|
+
/** True if the registerer is currently waiting for final response to a REGISTER request. */
|
|
3030
|
+
private get waiting();
|
|
3031
|
+
/** Emits when the registerer waiting state changes. */
|
|
3032
|
+
private get waitingChange();
|
|
3033
|
+
/**
|
|
3034
|
+
* Toggle waiting.
|
|
3035
|
+
*/
|
|
3036
|
+
private waitingToggle;
|
|
3037
|
+
/** Hopefully helpful as the standard behavior has been found to be unexpected. */
|
|
3038
|
+
private waitingWarning;
|
|
3039
|
+
/** Hopefully helpful as the standard behavior has been found to be unexpected. */
|
|
3040
|
+
private stateError;
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
/**
|
|
3044
|
+
* Delegate for {@link Subscription}.
|
|
3045
|
+
* @public
|
|
3046
|
+
*/
|
|
3047
|
+
interface SubscriptionDelegate {
|
|
3048
|
+
/**
|
|
3049
|
+
* Called upon receiving an incoming NOTIFY request.
|
|
3050
|
+
* @param notification - A notification. See {@link Notification} for details.
|
|
3051
|
+
*/
|
|
3052
|
+
onNotify(notification: Notification): void;
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
/**
|
|
3056
|
+
* Options for {@link Subscription } constructor.
|
|
3057
|
+
* @public
|
|
3058
|
+
*/
|
|
3059
|
+
interface SubscriptionOptions {
|
|
3060
|
+
delegate?: SubscriptionDelegate;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
/**
|
|
3064
|
+
* {@link Subscription} state.
|
|
3065
|
+
* @remarks
|
|
3066
|
+
* The {@link Subscription} behaves in a deterministic manner according to the following
|
|
3067
|
+
* Finite State Machine (FSM).
|
|
3068
|
+
* ```txt
|
|
3069
|
+
* _______________________________________
|
|
3070
|
+
* Subscription | v
|
|
3071
|
+
* Constructed -> Initial -> NotifyWait -> Subscribed -> Terminated
|
|
3072
|
+
* |____________________________^
|
|
3073
|
+
* ```
|
|
3074
|
+
* @public
|
|
3075
|
+
*/
|
|
3076
|
+
declare enum SubscriptionState {
|
|
3077
|
+
Initial = "Initial",
|
|
3078
|
+
NotifyWait = "NotifyWait",
|
|
3079
|
+
Subscribed = "Subscribed",
|
|
3080
|
+
Terminated = "Terminated"
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
/**
|
|
3084
|
+
* Options for {@link Subscription.subscribe}.
|
|
3085
|
+
* @public
|
|
3086
|
+
*/
|
|
3087
|
+
interface SubscriptionSubscribeOptions {
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
/**
|
|
3091
|
+
* Options for {@link Subscription.unsubscribe}.
|
|
3092
|
+
* @public
|
|
3093
|
+
*/
|
|
3094
|
+
interface SubscriptionUnsubscribeOptions {
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
/**
|
|
3098
|
+
* A subscription provides {@link Notification} of events.
|
|
3099
|
+
*
|
|
3100
|
+
* @remarks
|
|
3101
|
+
* See {@link Subscriber} for details on establishing a subscription.
|
|
3102
|
+
*
|
|
3103
|
+
* @public
|
|
3104
|
+
*/
|
|
3105
|
+
declare abstract class Subscription {
|
|
3106
|
+
/**
|
|
3107
|
+
* Property reserved for use by instance owner.
|
|
3108
|
+
* @defaultValue `undefined`
|
|
3109
|
+
*/
|
|
3110
|
+
data: unknown;
|
|
3111
|
+
/**
|
|
3112
|
+
* Subscription delegate. See {@link SubscriptionDelegate} for details.
|
|
3113
|
+
* @defaultValue `undefined`
|
|
3114
|
+
*/
|
|
3115
|
+
delegate: SubscriptionDelegate | undefined;
|
|
3116
|
+
/**
|
|
3117
|
+
* If the subscription state is SubscriptionState.Subscribed, the associated subscription dialog. Otherwise undefined.
|
|
3118
|
+
* @internal
|
|
3119
|
+
*/
|
|
3120
|
+
protected _dialog: Subscription$1 | undefined;
|
|
3121
|
+
/**
|
|
3122
|
+
* Our user agent.
|
|
3123
|
+
* @internal
|
|
3124
|
+
*/
|
|
3125
|
+
protected _userAgent: UserAgent;
|
|
3126
|
+
private _disposed;
|
|
3127
|
+
private _logger;
|
|
3128
|
+
private _state;
|
|
3129
|
+
private _stateEventEmitter;
|
|
3130
|
+
/**
|
|
3131
|
+
* Constructor.
|
|
3132
|
+
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
3133
|
+
* @internal
|
|
3134
|
+
*/
|
|
3135
|
+
protected constructor(userAgent: UserAgent, options?: SubscriptionOptions);
|
|
3136
|
+
/**
|
|
3137
|
+
* Destructor.
|
|
3138
|
+
*/
|
|
3139
|
+
dispose(): Promise<void>;
|
|
3140
|
+
/**
|
|
3141
|
+
* The subscribed subscription dialog.
|
|
3142
|
+
*/
|
|
3143
|
+
get dialog(): Subscription$1 | undefined;
|
|
3144
|
+
/**
|
|
3145
|
+
* True if disposed.
|
|
3146
|
+
* @internal
|
|
3147
|
+
*/
|
|
3148
|
+
get disposed(): boolean;
|
|
3149
|
+
/**
|
|
3150
|
+
* Subscription state. See {@link SubscriptionState} for details.
|
|
3151
|
+
*/
|
|
3152
|
+
get state(): SubscriptionState;
|
|
3153
|
+
/**
|
|
3154
|
+
* Emits when the subscription `state` property changes.
|
|
3155
|
+
*/
|
|
3156
|
+
get stateChange(): Emitter<SubscriptionState>;
|
|
3157
|
+
/** @internal */
|
|
3158
|
+
protected stateTransition(newState: SubscriptionState): void;
|
|
3159
|
+
/**
|
|
3160
|
+
* Sends a re-SUBSCRIBE request if the subscription is "active".
|
|
3161
|
+
*/
|
|
3162
|
+
abstract subscribe(options?: SubscriptionSubscribeOptions): Promise<void>;
|
|
3163
|
+
/**
|
|
3164
|
+
* Unsubscribe from event notifications.
|
|
3165
|
+
*
|
|
3166
|
+
* @remarks
|
|
3167
|
+
* If the subscription state is SubscriptionState.Subscribed, sends an in dialog SUBSCRIBE request
|
|
3168
|
+
* with expires time of zero (an un-subscribe) and terminates the subscription.
|
|
3169
|
+
* Otherwise a noop.
|
|
3170
|
+
*/
|
|
3171
|
+
abstract unsubscribe(options?: SubscriptionUnsubscribeOptions): Promise<void>;
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
/**
|
|
3175
|
+
* {@link Transport} state.
|
|
3176
|
+
*
|
|
3177
|
+
* @remarks
|
|
3178
|
+
* The {@link Transport} behaves in a deterministic manner according to the following
|
|
3179
|
+
* Finite State Machine (FSM).
|
|
3180
|
+
* ```txt
|
|
3181
|
+
* ______________________________
|
|
3182
|
+
* | ____________ |
|
|
3183
|
+
* Transport v v | |
|
|
3184
|
+
* Constructed -> Disconnected -> Connecting -> Connected -> Disconnecting
|
|
3185
|
+
* ^ ^ |_____________________^ | |
|
|
3186
|
+
* | |_____________________________| |
|
|
3187
|
+
* |_____________________________________________|
|
|
3188
|
+
* ```
|
|
3189
|
+
* @public
|
|
3190
|
+
*/
|
|
3191
|
+
declare enum TransportState {
|
|
3192
|
+
/**
|
|
3193
|
+
* The `connect()` method was called.
|
|
3194
|
+
*/
|
|
3195
|
+
Connecting = "Connecting",
|
|
3196
|
+
/**
|
|
3197
|
+
* The `connect()` method resolved.
|
|
3198
|
+
*/
|
|
3199
|
+
Connected = "Connected",
|
|
3200
|
+
/**
|
|
3201
|
+
* The `disconnect()` method was called.
|
|
3202
|
+
*/
|
|
3203
|
+
Disconnecting = "Disconnecting",
|
|
3204
|
+
/**
|
|
3205
|
+
* The `connect()` method was rejected, or
|
|
3206
|
+
* the `disconnect()` method completed, or
|
|
3207
|
+
* network connectivity was lost.
|
|
3208
|
+
*/
|
|
3209
|
+
Disconnected = "Disconnected"
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
/**
|
|
3213
|
+
* Transport layer interface expected by the `UserAgent`.
|
|
3214
|
+
*
|
|
3215
|
+
* @remarks
|
|
3216
|
+
* The transport behaves in a deterministic manner according to the
|
|
3217
|
+
* the state defined in {@link TransportState}.
|
|
3218
|
+
*
|
|
3219
|
+
* The "Connecting" state is ONLY entered in response to the user calling `connect()`.
|
|
3220
|
+
* The "Disconnecting" state is ONLY entered in response to the user calling `disconnect()`.
|
|
3221
|
+
* The `onConnect` callback is ALWAYS called upon transitioning to the "Connected" state.
|
|
3222
|
+
* The `onDisconnect` callback is ALWAYS called upon transitioning from the "Connected" state.
|
|
3223
|
+
*
|
|
3224
|
+
* Adherence to the state machine by the transport implementation is critical as the
|
|
3225
|
+
* UserAgent depends on this behavior. Furthermore it is critical that the transport
|
|
3226
|
+
* transition to the "Disconnected" state in all instances where network connectivity
|
|
3227
|
+
* is lost as the UserAgent, API, and application layer more generally depend on knowing
|
|
3228
|
+
* network was lost. For example, from a practical standpoint registrations and subscriptions are invalidated
|
|
3229
|
+
* when network is lost - particularly in the case of connection oriented transport
|
|
3230
|
+
* protocols such as a secure WebSocket transport.
|
|
3231
|
+
*
|
|
3232
|
+
* Proper handling the application level protocol recovery must be left to the application layer,
|
|
3233
|
+
* thus the transport MUST NOT attempt to "auto-recover" from or otherwise hide loss of network.
|
|
3234
|
+
* Note that callbacks and emitters such as `onConnect` and `onDisconnect` MUST NOT call methods
|
|
3235
|
+
* `connect()` and `direct()` synchronously (state change handlers must not loop back). They may
|
|
3236
|
+
* however do so asynchronously using a Promise resolution, `setTimeout`, or some other method.
|
|
3237
|
+
* For example...
|
|
3238
|
+
* ```ts
|
|
3239
|
+
* transport.onDisconnect = () => {
|
|
3240
|
+
* Promise.resolve().then(() => transport.connect());
|
|
3241
|
+
* }
|
|
3242
|
+
* ```
|
|
3243
|
+
* @public
|
|
3244
|
+
*/
|
|
3245
|
+
interface Transport extends Transport$1 {
|
|
3246
|
+
/**
|
|
3247
|
+
* Transport state.
|
|
3248
|
+
*
|
|
3249
|
+
* @remarks
|
|
3250
|
+
* The initial Transport state MUST be "disconnected" (after calling constructor).
|
|
3251
|
+
*/
|
|
3252
|
+
readonly state: TransportState;
|
|
3253
|
+
/**
|
|
3254
|
+
* Transport state change emitter.
|
|
3255
|
+
*/
|
|
3256
|
+
readonly stateChange: Emitter<TransportState>;
|
|
3257
|
+
/**
|
|
3258
|
+
* Callback on state transition to "Connected".
|
|
3259
|
+
*
|
|
3260
|
+
* @remarks
|
|
3261
|
+
* When the `UserAgent` is constructed, this property is set.
|
|
3262
|
+
* ```txt
|
|
3263
|
+
* - The `state` MUST be "Connected" when called.
|
|
3264
|
+
* ```
|
|
3265
|
+
*/
|
|
3266
|
+
onConnect: (() => void) | undefined;
|
|
3267
|
+
/**
|
|
3268
|
+
* Callback on state transition from "Connected".
|
|
3269
|
+
*
|
|
3270
|
+
* @remarks
|
|
3271
|
+
* When the `UserAgent` is constructed, this property is set.
|
|
3272
|
+
* ```txt
|
|
3273
|
+
* - The `state` MUST NOT "Connected" when called.
|
|
3274
|
+
* - If prior `state` is "Connecting" or "Connected", `error` MUST be defined.
|
|
3275
|
+
* - If prior `state` is "Disconnecting", `error` MUST NOT be undefined.
|
|
3276
|
+
* ```
|
|
3277
|
+
* If the transition from "Connected" occurs because the transport
|
|
3278
|
+
* user requested it by calling `disconnect`, then `error` will be undefined.
|
|
3279
|
+
* Otherwise `error` will be defined to provide an indication that the
|
|
3280
|
+
* transport initiated the transition from "Connected" - for example,
|
|
3281
|
+
* perhaps network connectivity was lost.
|
|
3282
|
+
*/
|
|
3283
|
+
onDisconnect: ((error?: Error) => void) | undefined;
|
|
3284
|
+
/**
|
|
3285
|
+
* Callback on receipt of a message.
|
|
3286
|
+
*
|
|
3287
|
+
* @remarks
|
|
3288
|
+
* When the `UserAgent` is constructed, this property is set.
|
|
3289
|
+
* The `state` MUST be "Connected" when this is called.
|
|
3290
|
+
*/
|
|
3291
|
+
onMessage: ((message: string) => void) | undefined;
|
|
3292
|
+
/**
|
|
3293
|
+
* Connect to network.
|
|
3294
|
+
*
|
|
3295
|
+
* @remarks
|
|
3296
|
+
* ```txt
|
|
3297
|
+
* - If `state` is "Connecting", `state` MUST NOT transition before returning.
|
|
3298
|
+
* - If `state` is "Connected", `state` MUST NOT transition before returning.
|
|
3299
|
+
* - If `state` is "Disconnecting", `state` MUST transition to "Connecting" before returning.
|
|
3300
|
+
* - If `state` is "Disconnected" `state` MUST transition to "Connecting" before returning.
|
|
3301
|
+
* - The `state` MUST transition to "Connected" before resolving (assuming `state` is not already "Connected").
|
|
3302
|
+
* - The `state` MUST transition to "Disconnecting" or "Disconnected" before rejecting and MUST reject with an Error.
|
|
3303
|
+
* ```
|
|
3304
|
+
* Resolves when the transport connects. Rejects if transport fails to connect.
|
|
3305
|
+
* Rejects with {@link StateTransitionError} if a loop is detected.
|
|
3306
|
+
* In particular, callbacks and emitters MUST NOT call this method synchronously.
|
|
3307
|
+
*/
|
|
3308
|
+
connect(): Promise<void>;
|
|
3309
|
+
/**
|
|
3310
|
+
* Disconnect from network.
|
|
3311
|
+
*
|
|
3312
|
+
* @remarks
|
|
3313
|
+
* ```txt
|
|
3314
|
+
* - If `state` is "Connecting", `state` MUST transition to "Disconnecting" before returning.
|
|
3315
|
+
* - If `state` is "Connected", `state` MUST transition to "Disconnecting" before returning.
|
|
3316
|
+
* - If `state` is "Disconnecting", `state` MUST NOT transition before returning.
|
|
3317
|
+
* - If `state` is "Disconnected", `state` MUST NOT transition before returning.
|
|
3318
|
+
* - The `state` MUST transition to "Disconnected" before resolving (assuming `state` is not already "Disconnected").
|
|
3319
|
+
* - The `state` MUST transition to "Connecting" or "Connected" before rejecting and MUST reject with an Error.
|
|
3320
|
+
* ```
|
|
3321
|
+
* Resolves when the transport disconnects. Rejects if transport fails to disconnect.
|
|
3322
|
+
* Rejects with {@link StateTransitionError} if a loop is detected.
|
|
3323
|
+
* In particular, callbacks and emitters MUST NOT call this method synchronously.
|
|
3324
|
+
*/
|
|
3325
|
+
disconnect(): Promise<void>;
|
|
3326
|
+
/**
|
|
3327
|
+
* Dispose.
|
|
3328
|
+
*
|
|
3329
|
+
* @remarks
|
|
3330
|
+
* When the `UserAgent` is disposed or stopped, this method is called.
|
|
3331
|
+
* The `UserAgent` MUST NOT continue to utilize the instance after calling this method.
|
|
3332
|
+
*/
|
|
3333
|
+
dispose(): Promise<void>;
|
|
3334
|
+
/**
|
|
3335
|
+
* Returns true if the `state` equals "Connected".
|
|
3336
|
+
*
|
|
3337
|
+
* @remarks
|
|
3338
|
+
* This is equivalent to `state === TransportState.Connected`.
|
|
3339
|
+
* It is convenient. A common paradigm is, for example...
|
|
3340
|
+
*
|
|
3341
|
+
* @example
|
|
3342
|
+
* ```ts
|
|
3343
|
+
* // Monitor transport connectivity
|
|
3344
|
+
* userAgent.transport.stateChange.addListener(() => {
|
|
3345
|
+
* if (userAgent.transport.isConnected()) {
|
|
3346
|
+
* // handle transport connect
|
|
3347
|
+
* } else {
|
|
3348
|
+
* // handle transport disconnect
|
|
3349
|
+
* }
|
|
3350
|
+
* });
|
|
3351
|
+
* ```
|
|
3352
|
+
*/
|
|
3353
|
+
isConnected(): boolean;
|
|
3354
|
+
/**
|
|
3355
|
+
* Send a message.
|
|
3356
|
+
*
|
|
3357
|
+
* @remarks
|
|
3358
|
+
* ```txt
|
|
3359
|
+
* - If `state` is "Connecting", rejects with an Error.
|
|
3360
|
+
* - If `state` is "Connected", resolves when the message is sent otherwise rejects with an Error.
|
|
3361
|
+
* - If `state` is "Disconnecting", rejects with an Error.
|
|
3362
|
+
* - If `state` is "Disconnected", rejects with an Error.
|
|
3363
|
+
* ```
|
|
3364
|
+
* @param message - Message to send.
|
|
3365
|
+
*/
|
|
3366
|
+
send(message: string): Promise<void>;
|
|
3367
|
+
}
|
|
3368
|
+
|
|
3369
|
+
/**
|
|
3370
|
+
* Delegate for {@link UserAgent}.
|
|
3371
|
+
* @public
|
|
3372
|
+
*/
|
|
3373
|
+
interface UserAgentDelegate {
|
|
3374
|
+
/**
|
|
3375
|
+
* Called upon transport transitioning to connected state.
|
|
3376
|
+
*/
|
|
3377
|
+
onConnect?(): void;
|
|
3378
|
+
/**
|
|
3379
|
+
* Called upon transport transitioning from connected state.
|
|
3380
|
+
* @param error - An error if disconnect triggered by transport. Otherwise undefined.
|
|
3381
|
+
*/
|
|
3382
|
+
onDisconnect?(error?: Error): void;
|
|
3383
|
+
/**
|
|
3384
|
+
* Called upon receipt of an invitation.
|
|
3385
|
+
* @remarks
|
|
3386
|
+
* Handler for incoming out of dialog INVITE requests.
|
|
3387
|
+
* @param invitation - The invitation.
|
|
3388
|
+
*/
|
|
3389
|
+
onInvite?(invitation: Invitation): void;
|
|
3390
|
+
/**
|
|
3391
|
+
* Called upon receipt of a message.
|
|
3392
|
+
* @remarks
|
|
3393
|
+
* Handler for incoming out of dialog MESSAGE requests.
|
|
3394
|
+
* @param message - The message.
|
|
3395
|
+
*/
|
|
3396
|
+
onMessage?(message: Message): void;
|
|
3397
|
+
/**
|
|
3398
|
+
* Called upon receipt of a notification.
|
|
3399
|
+
* @remarks
|
|
3400
|
+
* Handler for incoming out of dialog NOTIFY requests.
|
|
3401
|
+
* @param notification - The notification.
|
|
3402
|
+
*/
|
|
3403
|
+
onNotify?(notification: Notification): void;
|
|
3404
|
+
/**
|
|
3405
|
+
* @alpha
|
|
3406
|
+
* Called upon receipt of a referral.
|
|
3407
|
+
* @remarks
|
|
3408
|
+
* Handler for incoming out of dialog REFER requests.
|
|
3409
|
+
* @param referral - The referral.
|
|
3410
|
+
*/
|
|
3411
|
+
onRefer?(referral: Referral): void;
|
|
3412
|
+
/**
|
|
3413
|
+
* @alpha
|
|
3414
|
+
* Called upon receipt of a registration.
|
|
3415
|
+
* @remarks
|
|
3416
|
+
* Handler for incoming out of dialog REGISTER requests.
|
|
3417
|
+
* @param registration - The registration.
|
|
3418
|
+
*/
|
|
3419
|
+
onRegister?(registration: unknown): void;
|
|
3420
|
+
/**
|
|
3421
|
+
* @alpha
|
|
3422
|
+
* Called upon receipt of a subscription.
|
|
3423
|
+
* @remarks
|
|
3424
|
+
* Handler for incoming out of dialog SUBSCRIBE requests.
|
|
3425
|
+
* @param subscription - The subscription.
|
|
3426
|
+
*/
|
|
3427
|
+
onSubscribe?(subscription: Subscription): void;
|
|
3428
|
+
/**
|
|
3429
|
+
* @internal
|
|
3430
|
+
* Called upon receipt of an out of dialog REFER. Used by test suite.
|
|
3431
|
+
* @param request - The request.
|
|
3432
|
+
*/
|
|
3433
|
+
onReferRequest?(request: IncomingReferRequest): void;
|
|
3434
|
+
/**
|
|
3435
|
+
* @internal
|
|
3436
|
+
* Called upon receipt of a REGISTER request. Used by test suite.
|
|
3437
|
+
* @param request - The request.
|
|
3438
|
+
*/
|
|
3439
|
+
onRegisterRequest?(request: IncomingRegisterRequest): void;
|
|
3440
|
+
/**
|
|
3441
|
+
* @internal
|
|
3442
|
+
* Called upon receipt of an out of dialog SUBSCRIBE request. Used by test suite.
|
|
3443
|
+
* @param request - The request.
|
|
3444
|
+
*/
|
|
3445
|
+
onSubscribeRequest?(request: IncomingSubscribeRequest): void;
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
/**
|
|
3449
|
+
* Factory for {@link SessionDescriptionHandler}.
|
|
3450
|
+
* @public
|
|
3451
|
+
*/
|
|
3452
|
+
interface SessionDescriptionHandlerFactory {
|
|
3453
|
+
/**
|
|
3454
|
+
* SessionDescriptionHandler factory function.
|
|
3455
|
+
* @remarks
|
|
3456
|
+
* The `options` are provided as part of the UserAgent configuration
|
|
3457
|
+
* and passed through on every call to SessionDescriptionHandlerFactory's constructor.
|
|
3458
|
+
*/
|
|
3459
|
+
(session: Session, options?: object): SessionDescriptionHandler;
|
|
3460
|
+
}
|
|
3461
|
+
|
|
3462
|
+
/**
|
|
3463
|
+
* Log level.
|
|
3464
|
+
* @public
|
|
3465
|
+
*/
|
|
3466
|
+
declare type LogLevel = "debug" | "log" | "warn" | "error";
|
|
3467
|
+
/**
|
|
3468
|
+
* Log connector function.
|
|
3469
|
+
* @public
|
|
3470
|
+
*/
|
|
3471
|
+
declare type LogConnector = (level: LogLevel, category: string, label: string | undefined, content: string) => void;
|
|
3472
|
+
/**
|
|
3473
|
+
* SIP extension support level.
|
|
3474
|
+
* @public
|
|
3475
|
+
*/
|
|
3476
|
+
declare enum SIPExtension {
|
|
3477
|
+
Required = "Required",
|
|
3478
|
+
Supported = "Supported",
|
|
3479
|
+
Unsupported = "Unsupported"
|
|
3480
|
+
}
|
|
3481
|
+
/**
|
|
3482
|
+
* Options for {@link UserAgent} constructor.
|
|
3483
|
+
* @public
|
|
3484
|
+
*/
|
|
3485
|
+
interface UserAgentOptions {
|
|
3486
|
+
/**
|
|
3487
|
+
* If `true`, the user agent will accept out of dialog NOTIFY.
|
|
3488
|
+
* @remarks
|
|
3489
|
+
* RFC 6665 obsoletes the use of out of dialog NOTIFY from RFC 3265.
|
|
3490
|
+
* @defaultValue `false`
|
|
3491
|
+
*/
|
|
3492
|
+
allowLegacyNotifications?: boolean;
|
|
3493
|
+
/**
|
|
3494
|
+
* Authorization ha1.
|
|
3495
|
+
* @defaultValue `""`
|
|
3496
|
+
*/
|
|
3497
|
+
authorizationHa1?: string;
|
|
3498
|
+
/**
|
|
3499
|
+
* Authorization password.
|
|
3500
|
+
* @defaultValue `""`
|
|
3501
|
+
*/
|
|
3502
|
+
authorizationPassword?: string;
|
|
3503
|
+
/**
|
|
3504
|
+
* Authorization username.
|
|
3505
|
+
* @defaultValue `""`
|
|
3506
|
+
*/
|
|
3507
|
+
authorizationUsername?: string;
|
|
3508
|
+
/**
|
|
3509
|
+
* The user portion of user agent's contact URI.
|
|
3510
|
+
* @remarks
|
|
3511
|
+
* If not specifed a random string will be generated and utilized as the user portion of the contact URI.
|
|
3512
|
+
* @defaultValue `""`
|
|
3513
|
+
*/
|
|
3514
|
+
contactName?: string;
|
|
3515
|
+
/**
|
|
3516
|
+
* The URI parameters of the user agent's contact URI.
|
|
3517
|
+
* @defaultValue `{ transport: "ws" }`
|
|
3518
|
+
*/
|
|
3519
|
+
contactParams?: {
|
|
3520
|
+
[name: string]: string;
|
|
3521
|
+
};
|
|
3522
|
+
/**
|
|
3523
|
+
* Delegate for {@link UserAgent}.
|
|
3524
|
+
* @defaultValue `{}`
|
|
3525
|
+
*/
|
|
3526
|
+
delegate?: UserAgentDelegate;
|
|
3527
|
+
/**
|
|
3528
|
+
* The display name associated with the user agent.
|
|
3529
|
+
* @remarks
|
|
3530
|
+
* Descriptive name to be shown to the called party when calling or sending IM messages
|
|
3531
|
+
* (the display name portion of the From header).
|
|
3532
|
+
* It must NOT be enclosed between double quotes even if the given name contains multi-byte symbols
|
|
3533
|
+
* (SIPjs will always enclose the `displayName` value between double quotes).
|
|
3534
|
+
* @defaultValue `""`
|
|
3535
|
+
*/
|
|
3536
|
+
displayName?: string;
|
|
3537
|
+
/**
|
|
3538
|
+
* Force adding rport to Via header.
|
|
3539
|
+
* @defaultValue `false`
|
|
3540
|
+
*/
|
|
3541
|
+
forceRport?: boolean;
|
|
3542
|
+
/**
|
|
3543
|
+
* If `true`, the `stop()` method will attempt to gracefully end all dialogs and registrations before disconnecting.
|
|
3544
|
+
* Otherwise `stop()` will transition immediately abandoning all dialogs and registrations.
|
|
3545
|
+
* @defaultValue `true`
|
|
3546
|
+
*/
|
|
3547
|
+
gracefulShutdown?: boolean;
|
|
3548
|
+
/**
|
|
3549
|
+
* Hack
|
|
3550
|
+
* @deprecated TBD
|
|
3551
|
+
*/
|
|
3552
|
+
hackIpInContact?: boolean | string;
|
|
3553
|
+
/**
|
|
3554
|
+
* Hack
|
|
3555
|
+
* @deprecated TBD
|
|
3556
|
+
*/
|
|
3557
|
+
hackAllowUnregisteredOptionTags?: boolean;
|
|
3558
|
+
/**
|
|
3559
|
+
* Hack
|
|
3560
|
+
* @deprecated TBD
|
|
3561
|
+
*/
|
|
3562
|
+
hackViaTcp?: boolean;
|
|
3563
|
+
/**
|
|
3564
|
+
* UUID to provide with "+sip.instance" Contact header parameter.
|
|
3565
|
+
* @defaultValue A randomly generated uuid
|
|
3566
|
+
*/
|
|
3567
|
+
instanceId?: string;
|
|
3568
|
+
/**
|
|
3569
|
+
* Add "+sip.instance" Contact header parameter to all requests.
|
|
3570
|
+
* @defaultValue `false`
|
|
3571
|
+
*/
|
|
3572
|
+
instanceIdAlwaysAdded?: boolean;
|
|
3573
|
+
/**
|
|
3574
|
+
* Indicates whether log messages should be written to the browser console.
|
|
3575
|
+
* @defaultValue `true`
|
|
3576
|
+
*/
|
|
3577
|
+
logBuiltinEnabled?: boolean;
|
|
3578
|
+
/**
|
|
3579
|
+
* If true, constructor logs the user agent configuration.
|
|
3580
|
+
* @defaultValue `true`
|
|
3581
|
+
*/
|
|
3582
|
+
logConfiguration?: boolean;
|
|
3583
|
+
/**
|
|
3584
|
+
* A function which will be called every time a log is generated.
|
|
3585
|
+
* @defaultValue A noop
|
|
3586
|
+
*/
|
|
3587
|
+
logConnector?: LogConnector;
|
|
3588
|
+
/**
|
|
3589
|
+
* Indicates the verbosity level of the log messages.
|
|
3590
|
+
* @defaultValue `"log"`
|
|
3591
|
+
*/
|
|
3592
|
+
logLevel?: LogLevel;
|
|
3593
|
+
/**
|
|
3594
|
+
* Number of seconds after which an incoming call is rejected if not answered.
|
|
3595
|
+
* @defaultValue 60
|
|
3596
|
+
*/
|
|
3597
|
+
noAnswerTimeout?: number;
|
|
3598
|
+
/**
|
|
3599
|
+
* Adds a Route header(s) to outgoing requests.
|
|
3600
|
+
* @defaultValue `[]`
|
|
3601
|
+
*/
|
|
3602
|
+
preloadedRouteSet?: Array<string>;
|
|
3603
|
+
/**
|
|
3604
|
+
* @deprecated
|
|
3605
|
+
* Maximum number of times to attempt to reconnect when the transport connection drops.
|
|
3606
|
+
* @defaultValue 0
|
|
3607
|
+
*/
|
|
3608
|
+
reconnectionAttempts?: number;
|
|
3609
|
+
/**
|
|
3610
|
+
* @deprecated
|
|
3611
|
+
* Seconds to wait between reconnection attempts when the transport connection drops.
|
|
3612
|
+
* @defaultValue 4
|
|
3613
|
+
*/
|
|
3614
|
+
reconnectionDelay?: number;
|
|
3615
|
+
/**
|
|
3616
|
+
* If true, a first provisional response after the 100 Trying will be sent automatically if UAC does not
|
|
3617
|
+
* require reliable provisional responses.
|
|
3618
|
+
* @defaultValue `true`
|
|
3619
|
+
*/
|
|
3620
|
+
sendInitialProvisionalResponse?: boolean;
|
|
3621
|
+
/**
|
|
3622
|
+
* A factory for generating `SessionDescriptionHandler` instances.
|
|
3623
|
+
* @remarks
|
|
3624
|
+
* The factory will be passed a `Session` object for the current session
|
|
3625
|
+
* and the `sessionDescriptionHandlerFactoryOptions` object.
|
|
3626
|
+
* @defaultValue `Web.SessionDescriptionHandler.defaultFactory`
|
|
3627
|
+
*/
|
|
3628
|
+
sessionDescriptionHandlerFactory?: SessionDescriptionHandlerFactory;
|
|
3629
|
+
/**
|
|
3630
|
+
* Options to passed to `sessionDescriptionHandlerFactory`.
|
|
3631
|
+
* @remarks
|
|
3632
|
+
* See `Web.SessionDescriptionHandlerOptions` for details.
|
|
3633
|
+
* @defaultValue `{}`
|
|
3634
|
+
*/
|
|
3635
|
+
sessionDescriptionHandlerFactoryOptions?: object;
|
|
3636
|
+
/**
|
|
3637
|
+
* Reliable provisional responses.
|
|
3638
|
+
* https://tools.ietf.org/html/rfc3262
|
|
3639
|
+
* @defaultValue `SIPExtension.Unsupported`
|
|
3640
|
+
*/
|
|
3641
|
+
sipExtension100rel?: SIPExtension;
|
|
3642
|
+
/**
|
|
3643
|
+
* Replaces header.
|
|
3644
|
+
* https://tools.ietf.org/html/rfc3891
|
|
3645
|
+
* @defaultValue `SIPExtension.Unsupported`
|
|
3646
|
+
*/
|
|
3647
|
+
sipExtensionReplaces?: SIPExtension;
|
|
3648
|
+
/**
|
|
3649
|
+
* Extra option tags to claim support for.
|
|
3650
|
+
* @remarks
|
|
3651
|
+
* Setting an extra option tag does not enable support for the associated extension
|
|
3652
|
+
* it simply adds the tag to the list of supported options.
|
|
3653
|
+
* See {@link UserAgentRegisteredOptionTags} for valid option tags.
|
|
3654
|
+
* @defaultValue `[]`
|
|
3655
|
+
*/
|
|
3656
|
+
sipExtensionExtraSupported?: Array<string>;
|
|
3657
|
+
/**
|
|
3658
|
+
* An id uniquely identify this user agent instance.
|
|
3659
|
+
* @defaultValue
|
|
3660
|
+
* A random id generated by default.
|
|
3661
|
+
*/
|
|
3662
|
+
sipjsId?: string;
|
|
3663
|
+
/**
|
|
3664
|
+
* A constructor function for the user agent's `Transport`.
|
|
3665
|
+
* @remarks
|
|
3666
|
+
* For more information about creating your own transport see `Transport`.
|
|
3667
|
+
* @defaultValue `WebSocketTransport`
|
|
3668
|
+
*/
|
|
3669
|
+
transportConstructor?: new (logger: Logger, options: any) => Transport;
|
|
3670
|
+
/**
|
|
3671
|
+
* An options bucket object passed to `transportConstructor` when instantiated.
|
|
3672
|
+
* @remarks
|
|
3673
|
+
* See WebSocket Transport Configuration Parameters for the full list of options for the default transport.
|
|
3674
|
+
* @defaultValue `{}`
|
|
3675
|
+
*/
|
|
3676
|
+
transportOptions?: unknown;
|
|
3677
|
+
/**
|
|
3678
|
+
* SIP Addresses-of-Record URI associated with the user agent.
|
|
3679
|
+
* @remarks
|
|
3680
|
+
* This is a SIP address given to you by your provider.
|
|
3681
|
+
* If the user agent registers, it is the address-of-record which the user agent registers a contact for.
|
|
3682
|
+
* An address-of-record represents an identity of the user, generally a long-term identity,
|
|
3683
|
+
* and it does not have a dependency on any device; users can move between devices or even
|
|
3684
|
+
* be associated with multiple devices at one time while retaining the same address-of-record.
|
|
3685
|
+
* A simple URI, generally of the form `sip:egdar@example.com`, is used for an address-of-record.
|
|
3686
|
+
* @defaultValue
|
|
3687
|
+
* By default, URI is set to `sip:anonymous.X@anonymous.invalid`, where X is a random token generated for each UA.
|
|
3688
|
+
*/
|
|
3689
|
+
uri?: URI;
|
|
3690
|
+
/**
|
|
3691
|
+
* User agent string used in the UserAgent header.
|
|
3692
|
+
* @defaultValue
|
|
3693
|
+
* A reasonable value is utilized.
|
|
3694
|
+
*/
|
|
3695
|
+
userAgentString?: string;
|
|
3696
|
+
/**
|
|
3697
|
+
* Hostname to use in Via header.
|
|
3698
|
+
* @defaultValue
|
|
3699
|
+
* A random hostname in the .invalid domain.
|
|
3700
|
+
*/
|
|
3701
|
+
viaHost?: string;
|
|
3702
|
+
}
|
|
3703
|
+
|
|
3704
|
+
/**
|
|
3705
|
+
* {@link UserAgent} state.
|
|
3706
|
+
* @remarks
|
|
3707
|
+
* Valid state transitions:
|
|
3708
|
+
* ```
|
|
3709
|
+
* 1. "Started" --> "Stopped"
|
|
3710
|
+
* 2. "Stopped" --> "Started"
|
|
3711
|
+
* ```
|
|
3712
|
+
* @public
|
|
3713
|
+
*/
|
|
3714
|
+
declare enum UserAgentState {
|
|
3715
|
+
Started = "Started",
|
|
3716
|
+
Stopped = "Stopped"
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3719
|
+
/**
|
|
3720
|
+
* A user agent sends and receives requests using a `Transport`.
|
|
3721
|
+
*
|
|
3722
|
+
* @remarks
|
|
3723
|
+
* A user agent (UA) is associated with a user via the user's SIP address of record (AOR)
|
|
3724
|
+
* and acts on behalf of that user to send and receive SIP requests. The user agent can
|
|
3725
|
+
* register to receive incoming requests, as well as create and send outbound messages.
|
|
3726
|
+
* The user agent also maintains the Transport over which its signaling travels.
|
|
3727
|
+
*
|
|
3728
|
+
* @public
|
|
3729
|
+
*/
|
|
3730
|
+
declare class UserAgent {
|
|
3731
|
+
/**
|
|
3732
|
+
* Property reserved for use by instance owner.
|
|
3733
|
+
* @defaultValue `undefined`
|
|
3734
|
+
*/
|
|
3735
|
+
data: unknown;
|
|
3736
|
+
/**
|
|
3737
|
+
* Delegate.
|
|
3738
|
+
*/
|
|
3739
|
+
delegate: UserAgentDelegate | undefined;
|
|
3740
|
+
/** @internal */
|
|
3741
|
+
_publishers: {
|
|
3742
|
+
[id: string]: Publisher;
|
|
3743
|
+
};
|
|
3744
|
+
/** @internal */
|
|
3745
|
+
_registerers: {
|
|
3746
|
+
[id: string]: Registerer;
|
|
3747
|
+
};
|
|
3748
|
+
/** @internal */
|
|
3749
|
+
_sessions: {
|
|
3750
|
+
[id: string]: Session;
|
|
3751
|
+
};
|
|
3752
|
+
/** @internal */
|
|
3753
|
+
_subscriptions: {
|
|
3754
|
+
[id: string]: Subscription;
|
|
3755
|
+
};
|
|
3756
|
+
private _contact;
|
|
3757
|
+
private _instanceId;
|
|
3758
|
+
private _state;
|
|
3759
|
+
private _stateEventEmitter;
|
|
3760
|
+
private _transport;
|
|
3761
|
+
private _userAgentCore;
|
|
3762
|
+
/** Logger. */
|
|
3763
|
+
private logger;
|
|
3764
|
+
/** LoggerFactory. */
|
|
3765
|
+
private loggerFactory;
|
|
3766
|
+
/** Options. */
|
|
3767
|
+
private options;
|
|
3768
|
+
/**
|
|
3769
|
+
* Constructs a new instance of the `UserAgent` class.
|
|
3770
|
+
* @param options - Options bucket. See {@link UserAgentOptions} for details.
|
|
3771
|
+
*/
|
|
3772
|
+
constructor(options?: Partial<UserAgentOptions>);
|
|
3773
|
+
/**
|
|
3774
|
+
* Create a URI instance from a string.
|
|
3775
|
+
* @param uri - The string to parse.
|
|
3776
|
+
*
|
|
3777
|
+
* @remarks
|
|
3778
|
+
* Returns undefined if the syntax of the URI is invalid.
|
|
3779
|
+
* The syntax must conform to a SIP URI as defined in the RFC.
|
|
3780
|
+
* 25 Augmented BNF for the SIP Protocol
|
|
3781
|
+
* https://tools.ietf.org/html/rfc3261#section-25
|
|
3782
|
+
*
|
|
3783
|
+
* @example
|
|
3784
|
+
* ```ts
|
|
3785
|
+
* const uri = UserAgent.makeURI("sip:edgar@example.com");
|
|
3786
|
+
* ```
|
|
3787
|
+
*/
|
|
3788
|
+
static makeURI(uri: string): URI | undefined;
|
|
3789
|
+
/** Default user agent options. */
|
|
3790
|
+
private static defaultOptions;
|
|
3791
|
+
private static newUUID;
|
|
3792
|
+
/**
|
|
3793
|
+
* Strip properties with undefined values from options.
|
|
3794
|
+
* This is a work around while waiting for missing vs undefined to be addressed (or not)...
|
|
3795
|
+
* https://github.com/Microsoft/TypeScript/issues/13195
|
|
3796
|
+
* @param options - Options to reduce
|
|
3797
|
+
*/
|
|
3798
|
+
private static stripUndefinedProperties;
|
|
3799
|
+
/**
|
|
3800
|
+
* User agent configuration.
|
|
3801
|
+
*/
|
|
3802
|
+
get configuration(): Required<UserAgentOptions>;
|
|
3803
|
+
/**
|
|
3804
|
+
* User agent contact.
|
|
3805
|
+
*/
|
|
3806
|
+
get contact(): Contact;
|
|
3807
|
+
/**
|
|
3808
|
+
* User agent instance id.
|
|
3809
|
+
*/
|
|
3810
|
+
get instanceId(): string;
|
|
3811
|
+
/**
|
|
3812
|
+
* User agent state.
|
|
3813
|
+
*/
|
|
3814
|
+
get state(): UserAgentState;
|
|
3815
|
+
/**
|
|
3816
|
+
* User agent state change emitter.
|
|
3817
|
+
*/
|
|
3818
|
+
get stateChange(): Emitter<UserAgentState>;
|
|
3819
|
+
/**
|
|
3820
|
+
* User agent transport.
|
|
3821
|
+
*/
|
|
3822
|
+
get transport(): Transport;
|
|
3823
|
+
/**
|
|
3824
|
+
* User agent core.
|
|
3825
|
+
*/
|
|
3826
|
+
get userAgentCore(): UserAgentCore;
|
|
3827
|
+
/**
|
|
3828
|
+
* The logger.
|
|
3829
|
+
*/
|
|
3830
|
+
getLogger(category: string, label?: string): Logger;
|
|
3831
|
+
/**
|
|
3832
|
+
* The logger factory.
|
|
3833
|
+
*/
|
|
3834
|
+
getLoggerFactory(): LoggerFactory;
|
|
3835
|
+
/**
|
|
3836
|
+
* True if transport is connected.
|
|
3837
|
+
*/
|
|
3838
|
+
isConnected(): boolean;
|
|
3839
|
+
/**
|
|
3840
|
+
* Reconnect the transport.
|
|
3841
|
+
*/
|
|
3842
|
+
reconnect(): Promise<void>;
|
|
3843
|
+
/**
|
|
3844
|
+
* Start the user agent.
|
|
3845
|
+
*
|
|
3846
|
+
* @remarks
|
|
3847
|
+
* Resolves if transport connects, otherwise rejects.
|
|
3848
|
+
* Calling `start()` after calling `stop()` will fail if `stop()` has yet to resolve.
|
|
3849
|
+
*
|
|
3850
|
+
* @example
|
|
3851
|
+
* ```ts
|
|
3852
|
+
* userAgent.start()
|
|
3853
|
+
* .then(() => {
|
|
3854
|
+
* // userAgent.isConnected() === true
|
|
3855
|
+
* })
|
|
3856
|
+
* .catch((error: Error) => {
|
|
3857
|
+
* // userAgent.isConnected() === false
|
|
3858
|
+
* });
|
|
3859
|
+
* ```
|
|
3860
|
+
*/
|
|
3861
|
+
start(): Promise<void>;
|
|
3862
|
+
/**
|
|
3863
|
+
* Stop the user agent.
|
|
3864
|
+
*
|
|
3865
|
+
* @remarks
|
|
3866
|
+
* Resolves when the user agent has completed a graceful shutdown.
|
|
3867
|
+
* ```txt
|
|
3868
|
+
* 1) Sessions terminate.
|
|
3869
|
+
* 2) Registerers unregister.
|
|
3870
|
+
* 3) Subscribers unsubscribe.
|
|
3871
|
+
* 4) Publishers unpublish.
|
|
3872
|
+
* 5) Transport disconnects.
|
|
3873
|
+
* 6) User Agent Core resets.
|
|
3874
|
+
* ```
|
|
3875
|
+
* The user agent state transistions to stopped once these steps have been completed.
|
|
3876
|
+
* Calling `start()` after calling `stop()` will fail if `stop()` has yet to resolve.
|
|
3877
|
+
*
|
|
3878
|
+
* NOTE: While this is a "graceful shutdown", it can also be very slow one if you
|
|
3879
|
+
* are waiting for the returned Promise to resolve. The disposal of the clients and
|
|
3880
|
+
* dialogs is done serially - waiting on one to finish before moving on to the next.
|
|
3881
|
+
* This can be slow if there are lot of subscriptions to unsubscribe for example.
|
|
3882
|
+
*
|
|
3883
|
+
* THE SLOW PACE IS INTENTIONAL!
|
|
3884
|
+
* While one could spin them all down in parallel, this could slam the remote server.
|
|
3885
|
+
* It is bad practice to denial of service attack (DoS attack) servers!!!
|
|
3886
|
+
* Moreover, production servers will automatically blacklist clients which send too
|
|
3887
|
+
* many requests in too short a period of time - dropping any additional requests.
|
|
3888
|
+
*
|
|
3889
|
+
* If a different approach to disposing is needed, one can implement whatever is
|
|
3890
|
+
* needed and execute that prior to calling `stop()`. Alternatively one may simply
|
|
3891
|
+
* not wait for the Promise returned by `stop()` to complete.
|
|
3892
|
+
*/
|
|
3893
|
+
stop(): Promise<void>;
|
|
3894
|
+
/**
|
|
3895
|
+
* Used to avoid circular references.
|
|
3896
|
+
* @internal
|
|
3897
|
+
*/
|
|
3898
|
+
_makeInviter(targetURI: URI, options?: InviterOptions): Inviter;
|
|
3899
|
+
/**
|
|
3900
|
+
* Attempt reconnection up to `maxReconnectionAttempts` times.
|
|
3901
|
+
* @param reconnectionAttempt - Current attempt number.
|
|
3902
|
+
*/
|
|
3903
|
+
private attemptReconnection;
|
|
3904
|
+
/**
|
|
3905
|
+
* Initialize contact.
|
|
3906
|
+
*/
|
|
3907
|
+
private initContact;
|
|
3908
|
+
/**
|
|
3909
|
+
* Initialize user agent core.
|
|
3910
|
+
*/
|
|
3911
|
+
private initCore;
|
|
3912
|
+
private initTransportCallbacks;
|
|
3913
|
+
private onTransportConnect;
|
|
3914
|
+
private onTransportDisconnect;
|
|
3915
|
+
private onTransportMessage;
|
|
3916
|
+
/**
|
|
3917
|
+
* Transition state.
|
|
3918
|
+
*/
|
|
3919
|
+
private transitionState;
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
/**
|
|
3923
|
+
* An inviter offers to establish a {@link Session} (outgoing INVITE).
|
|
3924
|
+
* @public
|
|
3925
|
+
*/
|
|
3926
|
+
declare class Inviter extends Session {
|
|
3927
|
+
/**
|
|
3928
|
+
* If this Inviter was created as a result of a REFER, the referred Session. Otherwise undefined.
|
|
3929
|
+
* @internal
|
|
3930
|
+
*/
|
|
3931
|
+
_referred: Session | undefined;
|
|
3932
|
+
/**
|
|
3933
|
+
* Logger.
|
|
3934
|
+
*/
|
|
3935
|
+
protected logger: Logger;
|
|
3936
|
+
/** @internal */
|
|
3937
|
+
protected _id: string;
|
|
3938
|
+
/** True if dispose() has been called. */
|
|
3939
|
+
private disposed;
|
|
3940
|
+
/** True if early media use is enabled. */
|
|
3941
|
+
private earlyMedia;
|
|
3942
|
+
/** The early media session. */
|
|
3943
|
+
private earlyMediaDialog;
|
|
3944
|
+
/** The early media session description handlers. */
|
|
3945
|
+
private earlyMediaSessionDescriptionHandlers;
|
|
3946
|
+
/** Our From tag. */
|
|
3947
|
+
private fromTag;
|
|
3948
|
+
/** True if cancel() was called. */
|
|
3949
|
+
private isCanceled;
|
|
3950
|
+
/** True if initial INVITE without SDP. */
|
|
3951
|
+
private inviteWithoutSdp;
|
|
3952
|
+
/** Initial INVITE request sent by core. Undefined until sent. */
|
|
3953
|
+
private outgoingInviteRequest;
|
|
3954
|
+
/** Initial INVITE message provided to core to send. */
|
|
3955
|
+
private outgoingRequestMessage;
|
|
3956
|
+
/**
|
|
3957
|
+
* Constructs a new instance of the `Inviter` class.
|
|
3958
|
+
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
3959
|
+
* @param targetURI - Request URI identifying the target of the message.
|
|
3960
|
+
* @param options - Options bucket. See {@link InviterOptions} for details.
|
|
3961
|
+
*/
|
|
3962
|
+
constructor(userAgent: UserAgent, targetURI: URI, options?: InviterOptions);
|
|
3963
|
+
/**
|
|
3964
|
+
* Destructor.
|
|
3965
|
+
*/
|
|
3966
|
+
dispose(): Promise<void>;
|
|
3967
|
+
/**
|
|
3968
|
+
* Initial outgoing INVITE request message body.
|
|
3969
|
+
*/
|
|
3970
|
+
get body(): BodyAndContentType | undefined;
|
|
3971
|
+
/**
|
|
3972
|
+
* The identity of the local user.
|
|
3973
|
+
*/
|
|
3974
|
+
get localIdentity(): NameAddrHeader;
|
|
3975
|
+
/**
|
|
3976
|
+
* The identity of the remote user.
|
|
3977
|
+
*/
|
|
3978
|
+
get remoteIdentity(): NameAddrHeader;
|
|
3979
|
+
/**
|
|
3980
|
+
* Initial outgoing INVITE request message.
|
|
3981
|
+
*/
|
|
3982
|
+
get request(): OutgoingRequestMessage;
|
|
3983
|
+
/**
|
|
3984
|
+
* Cancels the INVITE request.
|
|
3985
|
+
*
|
|
3986
|
+
* @remarks
|
|
3987
|
+
* Sends a CANCEL request.
|
|
3988
|
+
* Resolves once the response sent, otherwise rejects.
|
|
3989
|
+
*
|
|
3990
|
+
* After sending a CANCEL request the expectation is that a 487 final response
|
|
3991
|
+
* will be received for the INVITE. However a 200 final response to the INVITE
|
|
3992
|
+
* may nonetheless arrive (it's a race between the CANCEL reaching the UAS before
|
|
3993
|
+
* the UAS sends a 200) in which case an ACK & BYE will be sent. The net effect
|
|
3994
|
+
* is that this method will terminate the session regardless of the race.
|
|
3995
|
+
* @param options - Options bucket.
|
|
3996
|
+
*/
|
|
3997
|
+
cancel(options?: InviterCancelOptions): Promise<void>;
|
|
3998
|
+
/**
|
|
3999
|
+
* Sends the INVITE request.
|
|
4000
|
+
*
|
|
4001
|
+
* @remarks
|
|
4002
|
+
* TLDR...
|
|
4003
|
+
* 1) Only one offer/answer exchange permitted during initial INVITE.
|
|
4004
|
+
* 2) No "early media" if the initial offer is in an INVITE (default behavior).
|
|
4005
|
+
* 3) If "early media" and the initial offer is in an INVITE, no INVITE forking.
|
|
4006
|
+
*
|
|
4007
|
+
* 1) Only one offer/answer exchange permitted during initial INVITE.
|
|
4008
|
+
*
|
|
4009
|
+
* Our implementation replaces the following bullet point...
|
|
4010
|
+
*
|
|
4011
|
+
* o After having sent or received an answer to the first offer, the
|
|
4012
|
+
* UAC MAY generate subsequent offers in requests based on rules
|
|
4013
|
+
* specified for that method, but only if it has received answers
|
|
4014
|
+
* to any previous offers, and has not sent any offers to which it
|
|
4015
|
+
* hasn't gotten an answer.
|
|
4016
|
+
* https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
4017
|
+
*
|
|
4018
|
+
* ...with...
|
|
4019
|
+
*
|
|
4020
|
+
* o After having sent or received an answer to the first offer, the
|
|
4021
|
+
* UAC MUST NOT generate subsequent offers in requests based on rules
|
|
4022
|
+
* specified for that method.
|
|
4023
|
+
*
|
|
4024
|
+
* ...which in combination with this bullet point...
|
|
4025
|
+
*
|
|
4026
|
+
* o Once the UAS has sent or received an answer to the initial
|
|
4027
|
+
* offer, it MUST NOT generate subsequent offers in any responses
|
|
4028
|
+
* to the initial INVITE. This means that a UAS based on this
|
|
4029
|
+
* specification alone can never generate subsequent offers until
|
|
4030
|
+
* completion of the initial transaction.
|
|
4031
|
+
* https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
4032
|
+
*
|
|
4033
|
+
* ...ensures that EXACTLY ONE offer/answer exchange will occur
|
|
4034
|
+
* during an initial out of dialog INVITE request made by our UAC.
|
|
4035
|
+
*
|
|
4036
|
+
*
|
|
4037
|
+
* 2) No "early media" if the initial offer is in an INVITE (default behavior).
|
|
4038
|
+
*
|
|
4039
|
+
* While our implementation adheres to the following bullet point...
|
|
4040
|
+
*
|
|
4041
|
+
* o If the initial offer is in an INVITE, the answer MUST be in a
|
|
4042
|
+
* reliable non-failure message from UAS back to UAC which is
|
|
4043
|
+
* correlated to that INVITE. For this specification, that is
|
|
4044
|
+
* only the final 2xx response to that INVITE. That same exact
|
|
4045
|
+
* answer MAY also be placed in any provisional responses sent
|
|
4046
|
+
* prior to the answer. The UAC MUST treat the first session
|
|
4047
|
+
* description it receives as the answer, and MUST ignore any
|
|
4048
|
+
* session descriptions in subsequent responses to the initial
|
|
4049
|
+
* INVITE.
|
|
4050
|
+
* https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
4051
|
+
*
|
|
4052
|
+
* We have made the following implementation decision with regard to early media...
|
|
4053
|
+
*
|
|
4054
|
+
* o If the initial offer is in the INVITE, the answer from the
|
|
4055
|
+
* UAS back to the UAC will establish a media session only
|
|
4056
|
+
* only after the final 2xx response to that INVITE is received.
|
|
4057
|
+
*
|
|
4058
|
+
* The reason for this decision is rooted in a restriction currently
|
|
4059
|
+
* inherent in WebRTC. Specifically, while a SIP INVITE request with an
|
|
4060
|
+
* initial offer may fork resulting in more than one provisional answer,
|
|
4061
|
+
* there is currently no easy/good way to to "fork" an offer generated
|
|
4062
|
+
* by a peer connection. In particular, a WebRTC offer currently may only
|
|
4063
|
+
* be matched with one answer and we have no good way to know which
|
|
4064
|
+
* "provisional answer" is going to be the "final answer". So we have
|
|
4065
|
+
* decided to punt and not create any "early media" sessions in this case.
|
|
4066
|
+
*
|
|
4067
|
+
* The upshot is that if you want "early media", you must not put the
|
|
4068
|
+
* initial offer in the INVITE. Instead, force the UAS to provide the
|
|
4069
|
+
* initial offer by sending an INVITE without an offer. In the WebRTC
|
|
4070
|
+
* case this allows us to create a unique peer connection with a unique
|
|
4071
|
+
* answer for every provisional offer with "early media" on all of them.
|
|
4072
|
+
*
|
|
4073
|
+
*
|
|
4074
|
+
* 3) If "early media" and the initial offer is in an INVITE, no INVITE forking.
|
|
4075
|
+
*
|
|
4076
|
+
* The default behavior may be altered and "early media" utilized if the
|
|
4077
|
+
* initial offer is in the an INVITE by setting the `earlyMedia` options.
|
|
4078
|
+
* However in that case the INVITE request MUST NOT fork. This allows for
|
|
4079
|
+
* "early media" in environments where the forking behavior of the SIP
|
|
4080
|
+
* servers being utilized is configured to disallow forking.
|
|
4081
|
+
*/
|
|
4082
|
+
invite(options?: InviterInviteOptions): Promise<OutgoingInviteRequest>;
|
|
4083
|
+
/**
|
|
4084
|
+
* 13.2.1 Creating the Initial INVITE
|
|
4085
|
+
*
|
|
4086
|
+
* Since the initial INVITE represents a request outside of a dialog,
|
|
4087
|
+
* its construction follows the procedures of Section 8.1.1. Additional
|
|
4088
|
+
* processing is required for the specific case of INVITE.
|
|
4089
|
+
*
|
|
4090
|
+
* An Allow header field (Section 20.5) SHOULD be present in the INVITE.
|
|
4091
|
+
* It indicates what methods can be invoked within a dialog, on the UA
|
|
4092
|
+
* sending the INVITE, for the duration of the dialog. For example, a
|
|
4093
|
+
* UA capable of receiving INFO requests within a dialog [34] SHOULD
|
|
4094
|
+
* include an Allow header field listing the INFO method.
|
|
4095
|
+
*
|
|
4096
|
+
* A Supported header field (Section 20.37) SHOULD be present in the
|
|
4097
|
+
* INVITE. It enumerates all the extensions understood by the UAC.
|
|
4098
|
+
*
|
|
4099
|
+
* An Accept (Section 20.1) header field MAY be present in the INVITE.
|
|
4100
|
+
* It indicates which Content-Types are acceptable to the UA, in both
|
|
4101
|
+
* the response received by it, and in any subsequent requests sent to
|
|
4102
|
+
* it within dialogs established by the INVITE. The Accept header field
|
|
4103
|
+
* is especially useful for indicating support of various session
|
|
4104
|
+
* description formats.
|
|
4105
|
+
*
|
|
4106
|
+
* The UAC MAY add an Expires header field (Section 20.19) to limit the
|
|
4107
|
+
* validity of the invitation. If the time indicated in the Expires
|
|
4108
|
+
* header field is reached and no final answer for the INVITE has been
|
|
4109
|
+
* received, the UAC core SHOULD generate a CANCEL request for the
|
|
4110
|
+
* INVITE, as per Section 9.
|
|
4111
|
+
*
|
|
4112
|
+
* A UAC MAY also find it useful to add, among others, Subject (Section
|
|
4113
|
+
* 20.36), Organization (Section 20.25) and User-Agent (Section 20.41)
|
|
4114
|
+
* header fields. They all contain information related to the INVITE.
|
|
4115
|
+
*
|
|
4116
|
+
* The UAC MAY choose to add a message body to the INVITE. Section
|
|
4117
|
+
* 8.1.1.10 deals with how to construct the header fields -- Content-
|
|
4118
|
+
* Type among others -- needed to describe the message body.
|
|
4119
|
+
*
|
|
4120
|
+
* https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
4121
|
+
*/
|
|
4122
|
+
private sendInvite;
|
|
4123
|
+
private disposeEarlyMedia;
|
|
4124
|
+
private notifyReferer;
|
|
4125
|
+
/**
|
|
4126
|
+
* Handle final response to initial INVITE.
|
|
4127
|
+
* @param inviteResponse - 2xx response.
|
|
4128
|
+
*/
|
|
4129
|
+
private onAccept;
|
|
4130
|
+
/**
|
|
4131
|
+
* Handle provisional response to initial INVITE.
|
|
4132
|
+
* @param inviteResponse - 1xx response.
|
|
4133
|
+
*/
|
|
4134
|
+
private onProgress;
|
|
4135
|
+
/**
|
|
4136
|
+
* Handle final response to initial INVITE.
|
|
4137
|
+
* @param inviteResponse - 3xx response.
|
|
4138
|
+
*/
|
|
4139
|
+
private onRedirect;
|
|
4140
|
+
/**
|
|
4141
|
+
* Handle final response to initial INVITE.
|
|
4142
|
+
* @param inviteResponse - 4xx, 5xx, or 6xx response.
|
|
4143
|
+
*/
|
|
4144
|
+
private onReject;
|
|
4145
|
+
/**
|
|
4146
|
+
* Handle final response to initial INVITE.
|
|
4147
|
+
* @param inviteResponse - 100 response.
|
|
4148
|
+
*/
|
|
4149
|
+
private onTrying;
|
|
4150
|
+
}
|
|
4151
|
+
|
|
4152
|
+
/**
|
|
4153
|
+
* Options for {@link Session.bye}.
|
|
4154
|
+
* @public
|
|
4155
|
+
*/
|
|
4156
|
+
interface SessionByeOptions {
|
|
4157
|
+
/** See `core` API. */
|
|
4158
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
4159
|
+
/** See `core` API. */
|
|
4160
|
+
requestOptions?: RequestOptions;
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4163
|
+
/**
|
|
4164
|
+
* Options for {@link Session.info}.
|
|
4165
|
+
* @public
|
|
4166
|
+
*/
|
|
4167
|
+
interface SessionInfoOptions {
|
|
4168
|
+
/** See `core` API. */
|
|
4169
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
4170
|
+
/** See `core` API. */
|
|
4171
|
+
requestOptions?: RequestOptions;
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4174
|
+
/**
|
|
4175
|
+
* Options for {@link Session.invite}.
|
|
4176
|
+
* @public
|
|
4177
|
+
*/
|
|
4178
|
+
interface SessionInviteOptions {
|
|
4179
|
+
/**
|
|
4180
|
+
* See `core` API.
|
|
4181
|
+
*/
|
|
4182
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
4183
|
+
/**
|
|
4184
|
+
* See `core` API.
|
|
4185
|
+
*/
|
|
4186
|
+
requestOptions?: RequestOptions;
|
|
4187
|
+
/**
|
|
4188
|
+
* Modifiers to pass to SessionDescriptionHandler during re-INVITE transaction.
|
|
4189
|
+
*/
|
|
4190
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
4191
|
+
/**
|
|
4192
|
+
* Options to pass to SessionDescriptionHandler during re-INVITE transaction.
|
|
4193
|
+
*/
|
|
4194
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
4195
|
+
/**
|
|
4196
|
+
* If true, send INVITE without SDP. Default is false.
|
|
4197
|
+
*/
|
|
4198
|
+
withoutSdp?: boolean;
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
/**
|
|
4202
|
+
* Options for {@link Session.message}.
|
|
4203
|
+
* @public
|
|
4204
|
+
*/
|
|
4205
|
+
interface SessionMessageOptions {
|
|
4206
|
+
/** See `core` API. */
|
|
4207
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
4208
|
+
/** See `core` API. */
|
|
4209
|
+
requestOptions?: RequestOptions;
|
|
4210
|
+
}
|
|
4211
|
+
|
|
4212
|
+
/**
|
|
4213
|
+
* Options for {@link Session.refer}.
|
|
4214
|
+
* @public
|
|
4215
|
+
*/
|
|
4216
|
+
interface SessionReferOptions {
|
|
4217
|
+
/** Called upon receiving an incoming NOTIFY associated with a REFER. */
|
|
4218
|
+
onNotify?: (notification: Notification) => void;
|
|
4219
|
+
/** See `core` API. */
|
|
4220
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
4221
|
+
/** See `core` API. */
|
|
4222
|
+
requestOptions?: RequestOptions;
|
|
4223
|
+
}
|
|
4224
|
+
|
|
4225
|
+
/**
|
|
4226
|
+
* {@link Session} state.
|
|
4227
|
+
*
|
|
4228
|
+
* @remarks
|
|
4229
|
+
* The {@link Session} behaves in a deterministic manner according to the following
|
|
4230
|
+
* Finite State Machine (FSM).
|
|
4231
|
+
* ```txt
|
|
4232
|
+
* ___________________________________________________________
|
|
4233
|
+
* | ____________________________________________ |
|
|
4234
|
+
* | | ____________________________ | |
|
|
4235
|
+
* Session | | | v v v
|
|
4236
|
+
* Constructed -> Initial -> Establishing -> Established -> Terminating -> Terminated
|
|
4237
|
+
* | |___________________________^ ^
|
|
4238
|
+
* |_______________________________________________|
|
|
4239
|
+
* ```
|
|
4240
|
+
* @public
|
|
4241
|
+
*/
|
|
4242
|
+
declare enum SessionState {
|
|
4243
|
+
/**
|
|
4244
|
+
* If `Inviter`, INVITE not sent yet.
|
|
4245
|
+
* If `Invitation`, received INVITE (but no final response sent yet).
|
|
4246
|
+
*/
|
|
4247
|
+
Initial = "Initial",
|
|
4248
|
+
/**
|
|
4249
|
+
* If `Inviter`, sent INVITE and waiting for a final response.
|
|
4250
|
+
* If `Invitation`, received INVITE and attempting to send 200 final response (but has not sent it yet).
|
|
4251
|
+
*/
|
|
4252
|
+
Establishing = "Establishing",
|
|
4253
|
+
/**
|
|
4254
|
+
* If `Inviter`, sent INVITE and received 200 final response and sent ACK.
|
|
4255
|
+
* If `Invitation`, received INVITE and sent 200 final response.
|
|
4256
|
+
*/
|
|
4257
|
+
Established = "Established",
|
|
4258
|
+
/**
|
|
4259
|
+
* If `Inviter`, sent INVITE, sent CANCEL and now waiting for 487 final response to ACK (or 200 to ACK & BYE).
|
|
4260
|
+
* If `Invitation`, received INVITE, sent 200 final response and now waiting on ACK and upon receipt will attempt BYE
|
|
4261
|
+
* (as the protocol specification requires, before sending a BYE we must receive the ACK - so we are waiting).
|
|
4262
|
+
*/
|
|
4263
|
+
Terminating = "Terminating",
|
|
4264
|
+
/**
|
|
4265
|
+
* If `Inviter`, sent INVITE and received non-200 final response (or sent/received BYE after receiving 200).
|
|
4266
|
+
* If `Invitation`, received INVITE and sent non-200 final response (or sent/received BYE after sending 200).
|
|
4267
|
+
*/
|
|
4268
|
+
Terminated = "Terminated"
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
/**
|
|
4272
|
+
* A session provides real time communication between one or more participants.
|
|
4273
|
+
*
|
|
4274
|
+
* @remarks
|
|
4275
|
+
* The transport behaves in a deterministic manner according to the
|
|
4276
|
+
* the state defined in {@link SessionState}.
|
|
4277
|
+
* @public
|
|
4278
|
+
*/
|
|
4279
|
+
declare abstract class Session {
|
|
4280
|
+
/**
|
|
4281
|
+
* Property reserved for use by instance owner.
|
|
4282
|
+
* @defaultValue `undefined`
|
|
4283
|
+
*/
|
|
4284
|
+
data: unknown;
|
|
4285
|
+
/**
|
|
4286
|
+
* The session delegate.
|
|
4287
|
+
* @defaultValue `undefined`
|
|
4288
|
+
*/
|
|
4289
|
+
delegate: SessionDelegate | undefined;
|
|
4290
|
+
/** @internal */
|
|
4291
|
+
_contact: string | undefined;
|
|
4292
|
+
/** @internal */
|
|
4293
|
+
_referral: Inviter | undefined;
|
|
4294
|
+
/** @internal */
|
|
4295
|
+
_replacee: Session | undefined;
|
|
4296
|
+
/** @internal */
|
|
4297
|
+
protected _assertedIdentity: NameAddrHeader | undefined;
|
|
4298
|
+
/** @internal */
|
|
4299
|
+
protected _dialog: Session$1 | undefined;
|
|
4300
|
+
/** @internal */
|
|
4301
|
+
protected _referralInviterOptions: InviterOptions | undefined;
|
|
4302
|
+
/** @internal */
|
|
4303
|
+
protected _renderbody: string | undefined;
|
|
4304
|
+
/** @internal */
|
|
4305
|
+
protected _rendertype: string | undefined;
|
|
4306
|
+
/** If defined, NOTIFYs associated with a REFER subscription are delivered here. */
|
|
4307
|
+
private onNotify;
|
|
4308
|
+
/** True if there is an outgoing re-INVITE request outstanding. */
|
|
4309
|
+
private pendingReinvite;
|
|
4310
|
+
/** True if there is an incoming re-INVITE ACK request outstanding. */
|
|
4311
|
+
private pendingReinviteAck;
|
|
4312
|
+
/** Dialogs session description handler. */
|
|
4313
|
+
private _sessionDescriptionHandler;
|
|
4314
|
+
/** SDH modifiers for the initial INVITE transaction. */
|
|
4315
|
+
private _sessionDescriptionHandlerModifiers;
|
|
4316
|
+
/** SDH options for the initial INVITE transaction. */
|
|
4317
|
+
private _sessionDescriptionHandlerOptions;
|
|
4318
|
+
/** SDH modifiers for re-INVITE transactions. */
|
|
4319
|
+
private _sessionDescriptionHandlerModifiersReInvite;
|
|
4320
|
+
/** SDH options for re-NVITE transactions.*/
|
|
4321
|
+
private _sessionDescriptionHandlerOptionsReInvite;
|
|
4322
|
+
/** Session state. */
|
|
4323
|
+
private _state;
|
|
4324
|
+
/** Session state emitter. */
|
|
4325
|
+
private _stateEventEmitter;
|
|
4326
|
+
/** User agent. */
|
|
4327
|
+
private _userAgent;
|
|
4328
|
+
/**
|
|
4329
|
+
* The identity of the local user.
|
|
4330
|
+
*/
|
|
4331
|
+
abstract readonly localIdentity: NameAddrHeader;
|
|
4332
|
+
/**
|
|
4333
|
+
* The identity of the remote user.
|
|
4334
|
+
*/
|
|
4335
|
+
abstract readonly remoteIdentity: NameAddrHeader;
|
|
4336
|
+
/**
|
|
4337
|
+
* Logger.
|
|
4338
|
+
*/
|
|
4339
|
+
protected abstract logger: Logger;
|
|
4340
|
+
/** @internal */
|
|
4341
|
+
protected abstract _id: string;
|
|
4342
|
+
/**
|
|
4343
|
+
* Constructor.
|
|
4344
|
+
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
4345
|
+
* @internal
|
|
4346
|
+
*/
|
|
4347
|
+
protected constructor(userAgent: UserAgent, options?: SessionOptions);
|
|
4348
|
+
/**
|
|
4349
|
+
* Destructor.
|
|
4350
|
+
*/
|
|
4351
|
+
dispose(): Promise<void>;
|
|
4352
|
+
/**
|
|
4353
|
+
* The asserted identity of the remote user.
|
|
4354
|
+
*/
|
|
4355
|
+
get assertedIdentity(): NameAddrHeader | undefined;
|
|
4356
|
+
/**
|
|
4357
|
+
* The confirmed session dialog.
|
|
4358
|
+
*/
|
|
4359
|
+
get dialog(): Session$1 | undefined;
|
|
4360
|
+
/**
|
|
4361
|
+
* A unique identifier for this session.
|
|
4362
|
+
*/
|
|
4363
|
+
get id(): string;
|
|
4364
|
+
/**
|
|
4365
|
+
* The session being replace by this one.
|
|
4366
|
+
*/
|
|
4367
|
+
get replacee(): Session | undefined;
|
|
4368
|
+
/**
|
|
4369
|
+
* Session description handler.
|
|
4370
|
+
* @remarks
|
|
4371
|
+
* If `this` is an instance of `Invitation`,
|
|
4372
|
+
* `sessionDescriptionHandler` will be defined when the session state changes to "established".
|
|
4373
|
+
* If `this` is an instance of `Inviter` and an offer was sent in the INVITE,
|
|
4374
|
+
* `sessionDescriptionHandler` will be defined when the session state changes to "establishing".
|
|
4375
|
+
* If `this` is an instance of `Inviter` and an offer was not sent in the INVITE,
|
|
4376
|
+
* `sessionDescriptionHandler` will be defined when the session state changes to "established".
|
|
4377
|
+
* Otherwise `undefined`.
|
|
4378
|
+
*/
|
|
4379
|
+
get sessionDescriptionHandler(): SessionDescriptionHandler | undefined;
|
|
4380
|
+
/**
|
|
4381
|
+
* Session description handler factory.
|
|
4382
|
+
*/
|
|
4383
|
+
get sessionDescriptionHandlerFactory(): SessionDescriptionHandlerFactory;
|
|
4384
|
+
/**
|
|
4385
|
+
* SDH modifiers for the initial INVITE transaction.
|
|
4386
|
+
* @remarks
|
|
4387
|
+
* Used in all cases when handling the initial INVITE transaction as either UAC or UAS.
|
|
4388
|
+
* May be set directly at anytime.
|
|
4389
|
+
* May optionally be set via constructor option.
|
|
4390
|
+
* May optionally be set via options passed to Inviter.invite() or Invitation.accept().
|
|
4391
|
+
*/
|
|
4392
|
+
get sessionDescriptionHandlerModifiers(): Array<SessionDescriptionHandlerModifier>;
|
|
4393
|
+
set sessionDescriptionHandlerModifiers(modifiers: Array<SessionDescriptionHandlerModifier>);
|
|
4394
|
+
/**
|
|
4395
|
+
* SDH options for the initial INVITE transaction.
|
|
4396
|
+
* @remarks
|
|
4397
|
+
* Used in all cases when handling the initial INVITE transaction as either UAC or UAS.
|
|
4398
|
+
* May be set directly at anytime.
|
|
4399
|
+
* May optionally be set via constructor option.
|
|
4400
|
+
* May optionally be set via options passed to Inviter.invite() or Invitation.accept().
|
|
4401
|
+
*/
|
|
4402
|
+
get sessionDescriptionHandlerOptions(): SessionDescriptionHandlerOptions;
|
|
4403
|
+
set sessionDescriptionHandlerOptions(options: SessionDescriptionHandlerOptions);
|
|
4404
|
+
/**
|
|
4405
|
+
* SDH modifiers for re-INVITE transactions.
|
|
4406
|
+
* @remarks
|
|
4407
|
+
* Used in all cases when handling a re-INVITE transaction as either UAC or UAS.
|
|
4408
|
+
* May be set directly at anytime.
|
|
4409
|
+
* May optionally be set via constructor option.
|
|
4410
|
+
* May optionally be set via options passed to Session.invite().
|
|
4411
|
+
*/
|
|
4412
|
+
get sessionDescriptionHandlerModifiersReInvite(): Array<SessionDescriptionHandlerModifier>;
|
|
4413
|
+
set sessionDescriptionHandlerModifiersReInvite(modifiers: Array<SessionDescriptionHandlerModifier>);
|
|
4414
|
+
/**
|
|
4415
|
+
* SDH options for re-INVITE transactions.
|
|
4416
|
+
* @remarks
|
|
4417
|
+
* Used in all cases when handling a re-INVITE transaction as either UAC or UAS.
|
|
4418
|
+
* May be set directly at anytime.
|
|
4419
|
+
* May optionally be set via constructor option.
|
|
4420
|
+
* May optionally be set via options passed to Session.invite().
|
|
4421
|
+
*/
|
|
4422
|
+
get sessionDescriptionHandlerOptionsReInvite(): SessionDescriptionHandlerOptions;
|
|
4423
|
+
set sessionDescriptionHandlerOptionsReInvite(options: SessionDescriptionHandlerOptions);
|
|
4424
|
+
/**
|
|
4425
|
+
* Session state.
|
|
4426
|
+
*/
|
|
4427
|
+
get state(): SessionState;
|
|
4428
|
+
/**
|
|
4429
|
+
* Session state change emitter.
|
|
4430
|
+
*/
|
|
4431
|
+
get stateChange(): Emitter<SessionState>;
|
|
4432
|
+
/**
|
|
4433
|
+
* The user agent.
|
|
4434
|
+
*/
|
|
4435
|
+
get userAgent(): UserAgent;
|
|
4436
|
+
/**
|
|
4437
|
+
* End the {@link Session}. Sends a BYE.
|
|
4438
|
+
* @param options - Options bucket. See {@link SessionByeOptions} for details.
|
|
4439
|
+
*/
|
|
4440
|
+
bye(options?: SessionByeOptions): Promise<OutgoingByeRequest>;
|
|
4441
|
+
/**
|
|
4442
|
+
* Share {@link Info} with peer. Sends an INFO.
|
|
4443
|
+
* @param options - Options bucket. See {@link SessionInfoOptions} for details.
|
|
4444
|
+
*/
|
|
4445
|
+
info(options?: SessionInfoOptions): Promise<OutgoingInfoRequest>;
|
|
4446
|
+
/**
|
|
4447
|
+
* Renegotiate the session. Sends a re-INVITE.
|
|
4448
|
+
* @param options - Options bucket. See {@link SessionInviteOptions} for details.
|
|
4449
|
+
*/
|
|
4450
|
+
invite(options?: SessionInviteOptions): Promise<OutgoingInviteRequest>;
|
|
4451
|
+
/**
|
|
4452
|
+
* Deliver a {@link Message}. Sends a MESSAGE.
|
|
4453
|
+
* @param options - Options bucket. See {@link SessionMessageOptions} for details.
|
|
4454
|
+
*/
|
|
4455
|
+
message(options?: SessionMessageOptions): Promise<OutgoingMessageRequest>;
|
|
4456
|
+
/**
|
|
4457
|
+
* Proffer a {@link Referral}. Send a REFER.
|
|
4458
|
+
* @param referTo - The referral target. If a `Session`, a REFER w/Replaces is sent.
|
|
4459
|
+
* @param options - Options bucket. See {@link SessionReferOptions} for details.
|
|
4460
|
+
*/
|
|
4461
|
+
refer(referTo: URI | Session, options?: SessionReferOptions): Promise<OutgoingReferRequest>;
|
|
4462
|
+
/**
|
|
4463
|
+
* Send BYE.
|
|
4464
|
+
* @param delegate - Request delegate.
|
|
4465
|
+
* @param options - Request options bucket.
|
|
4466
|
+
* @internal
|
|
4467
|
+
*/
|
|
4468
|
+
_bye(delegate?: OutgoingRequestDelegate, options?: RequestOptions): Promise<OutgoingByeRequest>;
|
|
4469
|
+
/**
|
|
4470
|
+
* Send INFO.
|
|
4471
|
+
* @param delegate - Request delegate.
|
|
4472
|
+
* @param options - Request options bucket.
|
|
4473
|
+
* @internal
|
|
4474
|
+
*/
|
|
4475
|
+
_info(delegate?: OutgoingRequestDelegate, options?: RequestOptions): Promise<OutgoingInfoRequest>;
|
|
4476
|
+
/**
|
|
4477
|
+
* Send MESSAGE.
|
|
4478
|
+
* @param delegate - Request delegate.
|
|
4479
|
+
* @param options - Request options bucket.
|
|
4480
|
+
* @internal
|
|
4481
|
+
*/
|
|
4482
|
+
_message(delegate?: OutgoingRequestDelegate, options?: RequestOptions): Promise<OutgoingMessageRequest>;
|
|
4483
|
+
/**
|
|
4484
|
+
* Send REFER.
|
|
4485
|
+
* @param onNotify - Notification callback.
|
|
4486
|
+
* @param delegate - Request delegate.
|
|
4487
|
+
* @param options - Request options bucket.
|
|
4488
|
+
* @internal
|
|
4489
|
+
*/
|
|
4490
|
+
_refer(onNotify?: (notification: Notification) => void, delegate?: OutgoingRequestDelegate, options?: RequestOptions): Promise<OutgoingByeRequest>;
|
|
4491
|
+
/**
|
|
4492
|
+
* Send ACK and then BYE. There are unrecoverable errors which can occur
|
|
4493
|
+
* while handling dialog forming and in-dialog INVITE responses and when
|
|
4494
|
+
* they occur we ACK the response and send a BYE.
|
|
4495
|
+
* Note that the BYE is sent in the dialog associated with the response
|
|
4496
|
+
* which is not necessarily `this.dialog`. And, accordingly, the
|
|
4497
|
+
* session state is not transitioned to terminated and session is not closed.
|
|
4498
|
+
* @param inviteResponse - The response causing the error.
|
|
4499
|
+
* @param statusCode - Status code for he reason phrase.
|
|
4500
|
+
* @param reasonPhrase - Reason phrase for the BYE.
|
|
4501
|
+
* @internal
|
|
4502
|
+
*/
|
|
4503
|
+
protected ackAndBye(response: AckableIncomingResponseWithSession, statusCode?: number, reasonPhrase?: string): void;
|
|
4504
|
+
/**
|
|
4505
|
+
* Handle in dialog ACK request.
|
|
4506
|
+
* @internal
|
|
4507
|
+
*/
|
|
4508
|
+
protected onAckRequest(request: IncomingAckRequest): Promise<void>;
|
|
4509
|
+
/**
|
|
4510
|
+
* Handle in dialog BYE request.
|
|
4511
|
+
* @internal
|
|
4512
|
+
*/
|
|
4513
|
+
protected onByeRequest(request: IncomingByeRequest): void;
|
|
4514
|
+
/**
|
|
4515
|
+
* Handle in dialog INFO request.
|
|
4516
|
+
* @internal
|
|
4517
|
+
*/
|
|
4518
|
+
protected onInfoRequest(request: IncomingInfoRequest): void;
|
|
4519
|
+
/**
|
|
4520
|
+
* Handle in dialog INVITE request.
|
|
4521
|
+
* @internal
|
|
4522
|
+
*/
|
|
4523
|
+
protected onInviteRequest(request: IncomingInviteRequest): void;
|
|
4524
|
+
/**
|
|
4525
|
+
* Handle in dialog MESSAGE request.
|
|
4526
|
+
* @internal
|
|
4527
|
+
*/
|
|
4528
|
+
protected onMessageRequest(request: IncomingMessageRequest): void;
|
|
4529
|
+
/**
|
|
4530
|
+
* Handle in dialog NOTIFY request.
|
|
4531
|
+
* @internal
|
|
4532
|
+
*/
|
|
4533
|
+
protected onNotifyRequest(request: IncomingNotifyRequest): void;
|
|
4534
|
+
/**
|
|
4535
|
+
* Handle in dialog PRACK request.
|
|
4536
|
+
* @internal
|
|
4537
|
+
*/
|
|
4538
|
+
protected onPrackRequest(request: IncomingPrackRequest): void;
|
|
4539
|
+
/**
|
|
4540
|
+
* Handle in dialog REFER request.
|
|
4541
|
+
* @internal
|
|
4542
|
+
*/
|
|
4543
|
+
protected onReferRequest(request: IncomingReferRequest): void;
|
|
4544
|
+
/**
|
|
4545
|
+
* Generate an offer or answer for a response to an INVITE request.
|
|
4546
|
+
* If a remote offer was provided in the request, set the remote
|
|
4547
|
+
* description and get a local answer. If a remote offer was not
|
|
4548
|
+
* provided, generates a local offer.
|
|
4549
|
+
* @internal
|
|
4550
|
+
*/
|
|
4551
|
+
protected generateResponseOfferAnswer(request: IncomingInviteRequest, options: {
|
|
4552
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
4553
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
4554
|
+
}): Promise<Body | undefined>;
|
|
4555
|
+
/**
|
|
4556
|
+
* Generate an offer or answer for a response to an INVITE request
|
|
4557
|
+
* when a dialog (early or otherwise) has already been established.
|
|
4558
|
+
* This method may NOT be called if a dialog has yet to be established.
|
|
4559
|
+
* @internal
|
|
4560
|
+
*/
|
|
4561
|
+
protected generateResponseOfferAnswerInDialog(options: {
|
|
4562
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
4563
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
4564
|
+
}): Promise<Body | undefined>;
|
|
4565
|
+
/**
|
|
4566
|
+
* Get local offer.
|
|
4567
|
+
* @internal
|
|
4568
|
+
*/
|
|
4569
|
+
protected getOffer(options: {
|
|
4570
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
4571
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
4572
|
+
}): Promise<Body>;
|
|
4573
|
+
/**
|
|
4574
|
+
* Rollback local/remote offer.
|
|
4575
|
+
* @internal
|
|
4576
|
+
*/
|
|
4577
|
+
protected rollbackOffer(): Promise<void>;
|
|
4578
|
+
/**
|
|
4579
|
+
* Set remote answer.
|
|
4580
|
+
* @internal
|
|
4581
|
+
*/
|
|
4582
|
+
protected setAnswer(answer: Body, options: {
|
|
4583
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
4584
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
4585
|
+
}): Promise<void>;
|
|
4586
|
+
/**
|
|
4587
|
+
* Set remote offer and get local answer.
|
|
4588
|
+
* @internal
|
|
4589
|
+
*/
|
|
4590
|
+
protected setOfferAndGetAnswer(offer: Body, options: {
|
|
4591
|
+
sessionDescriptionHandlerOptions?: SessionDescriptionHandlerOptions;
|
|
4592
|
+
sessionDescriptionHandlerModifiers?: Array<SessionDescriptionHandlerModifier>;
|
|
4593
|
+
}): Promise<Body>;
|
|
4594
|
+
/**
|
|
4595
|
+
* SDH for confirmed dialog.
|
|
4596
|
+
* @internal
|
|
4597
|
+
*/
|
|
4598
|
+
protected setSessionDescriptionHandler(sdh: SessionDescriptionHandler): void;
|
|
4599
|
+
/**
|
|
4600
|
+
* SDH for confirmed dialog.
|
|
4601
|
+
* @internal
|
|
4602
|
+
*/
|
|
4603
|
+
protected setupSessionDescriptionHandler(): SessionDescriptionHandler;
|
|
4604
|
+
/**
|
|
4605
|
+
* Transition session state.
|
|
4606
|
+
* @internal
|
|
4607
|
+
*/
|
|
4608
|
+
protected stateTransition(newState: SessionState): void;
|
|
4609
|
+
private copyRequestOptions;
|
|
4610
|
+
private getReasonHeaderValue;
|
|
4611
|
+
private referExtraHeaders;
|
|
4612
|
+
private referToString;
|
|
4613
|
+
}
|
|
4614
|
+
|
|
4615
|
+
/**
|
|
4616
|
+
* An invitation is an offer to establish a {@link Session} (incoming INVITE).
|
|
4617
|
+
* @public
|
|
4618
|
+
*/
|
|
4619
|
+
declare class Invitation extends Session {
|
|
4620
|
+
private incomingInviteRequest;
|
|
4621
|
+
/**
|
|
4622
|
+
* Logger.
|
|
4623
|
+
*/
|
|
4624
|
+
protected logger: Logger;
|
|
4625
|
+
/** @internal */
|
|
4626
|
+
protected _id: string;
|
|
4627
|
+
/** True if dispose() has been called. */
|
|
4628
|
+
private disposed;
|
|
4629
|
+
/** INVITE will be rejected if not accepted within a certain period time. */
|
|
4630
|
+
private expiresTimer;
|
|
4631
|
+
/** True if this Session has been Terminated due to a CANCEL request. */
|
|
4632
|
+
private isCanceled;
|
|
4633
|
+
/** Are reliable provisional responses required or supported. */
|
|
4634
|
+
private rel100;
|
|
4635
|
+
/** The current RSeq header value. */
|
|
4636
|
+
private rseq;
|
|
4637
|
+
/** INVITE will be rejected if final response not sent in a certain period time. */
|
|
4638
|
+
private userNoAnswerTimer;
|
|
4639
|
+
/** True if waiting for a PRACK before sending a 200 Ok. */
|
|
4640
|
+
private waitingForPrack;
|
|
4641
|
+
/** A Promise providing a defer when waiting for a PRACK. */
|
|
4642
|
+
private waitingForPrackPromise;
|
|
4643
|
+
/** Function to resolve when PRACK arrives. */
|
|
4644
|
+
private waitingForPrackResolve;
|
|
4645
|
+
/** Function to reject when PRACK never arrives. */
|
|
4646
|
+
private waitingForPrackReject;
|
|
4647
|
+
/** @internal */
|
|
4648
|
+
constructor(userAgent: UserAgent, incomingInviteRequest: IncomingInviteRequest);
|
|
4649
|
+
/**
|
|
4650
|
+
* Destructor.
|
|
4651
|
+
*/
|
|
4652
|
+
dispose(): Promise<void>;
|
|
4653
|
+
/**
|
|
4654
|
+
* If true, a first provisional response after the 100 Trying
|
|
4655
|
+
* will be sent automatically. This is false it the UAC required
|
|
4656
|
+
* reliable provisional responses (100rel in Require header) or
|
|
4657
|
+
* the user agent configuration has specified to not send an
|
|
4658
|
+
* initial response, otherwise it is true. The provisional is sent by
|
|
4659
|
+
* calling `progress()` without any options.
|
|
4660
|
+
*/
|
|
4661
|
+
get autoSendAnInitialProvisionalResponse(): boolean;
|
|
4662
|
+
/**
|
|
4663
|
+
* Initial incoming INVITE request message body.
|
|
4664
|
+
*/
|
|
4665
|
+
get body(): string | undefined;
|
|
4666
|
+
/**
|
|
4667
|
+
* The identity of the local user.
|
|
4668
|
+
*/
|
|
4669
|
+
get localIdentity(): NameAddrHeader;
|
|
4670
|
+
/**
|
|
4671
|
+
* The identity of the remote user.
|
|
4672
|
+
*/
|
|
4673
|
+
get remoteIdentity(): NameAddrHeader;
|
|
4674
|
+
/**
|
|
4675
|
+
* Initial incoming INVITE request message.
|
|
4676
|
+
*/
|
|
4677
|
+
get request(): IncomingRequestMessage;
|
|
4678
|
+
/**
|
|
4679
|
+
* Accept the invitation.
|
|
4680
|
+
*
|
|
4681
|
+
* @remarks
|
|
4682
|
+
* Accept the incoming INVITE request to start a Session.
|
|
4683
|
+
* Replies to the INVITE request with a 200 Ok response.
|
|
4684
|
+
* Resolves once the response sent, otherwise rejects.
|
|
4685
|
+
*
|
|
4686
|
+
* This method may reject for a variety of reasons including
|
|
4687
|
+
* the receipt of a CANCEL request before `accept` is able
|
|
4688
|
+
* to construct a response.
|
|
4689
|
+
* @param options - Options bucket.
|
|
4690
|
+
*/
|
|
4691
|
+
accept(options?: InvitationAcceptOptions): Promise<void>;
|
|
4692
|
+
/**
|
|
4693
|
+
* Indicate progress processing the invitation.
|
|
4694
|
+
*
|
|
4695
|
+
* @remarks
|
|
4696
|
+
* Report progress to the the caller.
|
|
4697
|
+
* Replies to the INVITE request with a 1xx provisional response.
|
|
4698
|
+
* Resolves once the response sent, otherwise rejects.
|
|
4699
|
+
* @param options - Options bucket.
|
|
4700
|
+
*/
|
|
4701
|
+
progress(options?: InvitationProgressOptions): Promise<void>;
|
|
4702
|
+
/**
|
|
4703
|
+
* Reject the invitation.
|
|
4704
|
+
*
|
|
4705
|
+
* @remarks
|
|
4706
|
+
* Replies to the INVITE request with a 4xx, 5xx, or 6xx final response.
|
|
4707
|
+
* Resolves once the response sent, otherwise rejects.
|
|
4708
|
+
*
|
|
4709
|
+
* The expectation is that this method is used to reject an INVITE request.
|
|
4710
|
+
* That is indeed the case - a call to `progress` followed by `reject` is
|
|
4711
|
+
* a typical way to "decline" an incoming INVITE request. However it may
|
|
4712
|
+
* also be called after calling `accept` (but only before it completes)
|
|
4713
|
+
* which will reject the call and cause `accept` to reject.
|
|
4714
|
+
* @param options - Options bucket.
|
|
4715
|
+
*/
|
|
4716
|
+
reject(options?: InvitationRejectOptions): Promise<void>;
|
|
4717
|
+
/**
|
|
4718
|
+
* Handle CANCEL request.
|
|
4719
|
+
*
|
|
4720
|
+
* @param message - CANCEL message.
|
|
4721
|
+
* @internal
|
|
4722
|
+
*/
|
|
4723
|
+
_onCancel(message: IncomingRequestMessage): void;
|
|
4724
|
+
/**
|
|
4725
|
+
* Helper function to handle offer/answer in a PRACK.
|
|
4726
|
+
*/
|
|
4727
|
+
private handlePrackOfferAnswer;
|
|
4728
|
+
/**
|
|
4729
|
+
* A handler for errors which occur while attempting to send 1xx and 2xx responses.
|
|
4730
|
+
* In all cases, an attempt is made to reject the request if it is still outstanding.
|
|
4731
|
+
* And while there are a variety of things which can go wrong and we log something here
|
|
4732
|
+
* for all errors, there are a handful of common exceptions we pay some extra attention to.
|
|
4733
|
+
* @param error - The error which occurred.
|
|
4734
|
+
*/
|
|
4735
|
+
private handleResponseError;
|
|
4736
|
+
/**
|
|
4737
|
+
* Callback for when ACK for a 2xx response is never received.
|
|
4738
|
+
* @param session - Session the ACK never arrived for.
|
|
4739
|
+
*/
|
|
4740
|
+
private onAckTimeout;
|
|
4741
|
+
/**
|
|
4742
|
+
* A version of `accept` which resolves a session when the 200 Ok response is sent.
|
|
4743
|
+
* @param options - Options bucket.
|
|
4744
|
+
*/
|
|
4745
|
+
private sendAccept;
|
|
4746
|
+
/**
|
|
4747
|
+
* A version of `progress` which resolves when the provisional response is sent.
|
|
4748
|
+
* @param options - Options bucket.
|
|
4749
|
+
*/
|
|
4750
|
+
private sendProgress;
|
|
4751
|
+
/**
|
|
4752
|
+
* A version of `progress` which resolves when the provisional response with sdp is sent.
|
|
4753
|
+
* @param options - Options bucket.
|
|
4754
|
+
*/
|
|
4755
|
+
private sendProgressWithSDP;
|
|
4756
|
+
/**
|
|
4757
|
+
* A version of `progress` which resolves when the reliable provisional response is sent.
|
|
4758
|
+
* @param options - Options bucket.
|
|
4759
|
+
*/
|
|
4760
|
+
private sendProgressReliable;
|
|
4761
|
+
/**
|
|
4762
|
+
* A version of `progress` which resolves when the reliable provisional response is acknowledged.
|
|
4763
|
+
* @param options - Options bucket.
|
|
4764
|
+
*/
|
|
4765
|
+
private sendProgressReliableWaitForPrack;
|
|
4766
|
+
/**
|
|
4767
|
+
* A version of `progress` which resolves when a 100 Trying provisional response is sent.
|
|
4768
|
+
*/
|
|
4769
|
+
private sendProgressTrying;
|
|
4770
|
+
/**
|
|
4771
|
+
* When attempting to accept the INVITE, an invitation waits
|
|
4772
|
+
* for any outstanding PRACK to arrive before sending the 200 Ok.
|
|
4773
|
+
* It will be waiting on this Promise to resolve which lets it know
|
|
4774
|
+
* the PRACK has arrived and it may proceed to send the 200 Ok.
|
|
4775
|
+
*/
|
|
4776
|
+
private waitForArrivalOfPrack;
|
|
4777
|
+
/**
|
|
4778
|
+
* Here we are resolving the promise which in turn will cause
|
|
4779
|
+
* the accept to proceed (it may still fail for other reasons, but...).
|
|
4780
|
+
*/
|
|
4781
|
+
private prackArrived;
|
|
4782
|
+
/**
|
|
4783
|
+
* Here we are rejecting the promise which in turn will cause
|
|
4784
|
+
* the accept to fail and the session to transition to "terminated".
|
|
4785
|
+
*/
|
|
4786
|
+
private prackNeverArrived;
|
|
4787
|
+
}
|
|
4788
|
+
|
|
55
4789
|
type SocketSendEventType = (typeof SocketSendEvent)[keyof typeof SocketSendEvent];
|
|
56
4790
|
interface IncallConfig {
|
|
57
4791
|
enabled: boolean;
|
|
@@ -567,7 +5301,7 @@ interface Listener {
|
|
|
567
5301
|
declare class CallKit {
|
|
568
5302
|
api: Api;
|
|
569
5303
|
config: Config;
|
|
570
|
-
logger: Logger;
|
|
5304
|
+
logger: Logger$1;
|
|
571
5305
|
callCenter: Call;
|
|
572
5306
|
connect: Connect;
|
|
573
5307
|
socket: Socket;
|