sip-connector 14.0.0 → 14.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SipConnector-CK3GgjXE.js +2492 -0
- package/dist/SipConnector-CwI8aFEA.cjs +1 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +439 -419
- package/dist/index.cjs +1 -1
- package/dist/index.js +708 -623
- package/dist/src/ApiManager/@ApiManager.d.ts +58 -0
- package/dist/src/ApiManager/constants.d.ts +71 -0
- package/dist/src/ApiManager/eventNames.d.ts +33 -0
- package/dist/src/ApiManager/index.d.ts +2 -0
- package/dist/src/ApiManager/types.d.ts +99 -0
- package/dist/src/CallManager/@CallManager.d.ts +26 -0
- package/dist/src/CallManager/AbstractCallStrategy.d.ts +47 -0
- package/dist/src/CallManager/MCUCallStrategy.d.ts +30 -0
- package/dist/src/CallManager/RemoteStreamsManager.d.ts +8 -0
- package/dist/src/CallManager/causes.d.ts +12 -0
- package/dist/src/CallManager/eventNames.d.ts +45 -0
- package/dist/src/CallManager/hasCanceledCallError.d.ts +2 -0
- package/dist/src/CallManager/index.d.ts +5 -0
- package/dist/src/CallManager/types.d.ts +59 -0
- package/dist/src/ConnectionManager/@ConnectionManager.d.ts +47 -0
- package/dist/src/ConnectionManager/ConfigurationManager.d.ts +60 -0
- package/dist/src/ConnectionManager/ConnectionFlow.d.ts +83 -0
- package/dist/src/ConnectionManager/ConnectionStateMachine.d.ts +61 -0
- package/dist/src/ConnectionManager/RegistrationManager.d.ts +17 -0
- package/dist/src/ConnectionManager/SipOperations.d.ts +32 -0
- package/dist/src/ConnectionManager/UAFactory.d.ts +50 -0
- package/dist/src/ConnectionManager/eventNames.d.ts +16 -0
- package/dist/src/ConnectionManager/index.d.ts +3 -0
- package/dist/src/IncomingCallManager/@IncomingCallManager.d.ts +36 -0
- package/dist/src/IncomingCallManager/eventNames.d.ts +13 -0
- package/dist/src/IncomingCallManager/index.d.ts +2 -0
- package/dist/src/PresentationManager/@PresentationManager.d.ts +47 -0
- package/dist/src/PresentationManager/constants.d.ts +1 -0
- package/dist/src/PresentationManager/eventNames.d.ts +11 -0
- package/dist/src/PresentationManager/index.d.ts +1 -0
- package/dist/src/PresentationManager/types.d.ts +2 -0
- package/dist/src/SipConnector.d.ts +107 -0
- package/dist/{SipConnectorFacade → src/SipConnectorFacade}/SipConnectorFacade.d.ts +34 -25
- package/dist/{__fixtures__ → src/__fixtures__}/BaseSession.mock.d.ts +23 -35
- package/dist/{__fixtures__ → src/__fixtures__}/RTCPeerConnectionMock.d.ts +15 -15
- package/dist/{__fixtures__ → src/__fixtures__}/RTCRtpSenderMock.d.ts +2 -2
- package/dist/src/__fixtures__/RTCSessionMock.d.ts +79 -0
- package/dist/src/__fixtures__/UA.mock.d.ts +82 -0
- package/dist/{__fixtures__ → src/__fixtures__}/channelsNotify.d.ts +2 -2
- package/dist/{__fixtures__ → src/__fixtures__}/index.d.ts +4 -4
- package/dist/{__fixtures__ → src/__fixtures__}/jssip.mock.d.ts +4 -4
- package/dist/{__fixtures__ → src/__fixtures__}/participantNotify.d.ts +2 -2
- package/dist/{constants.d.ts → src/constants.d.ts} +5 -0
- package/dist/{doMock.d.ts → src/doMock.d.ts} +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +3 -1
- package/dist/{tools → src/tools}/__fixtures__/connectToServer.d.ts +2 -2
- package/dist/{tools → src/tools}/index.d.ts +2 -2
- package/dist/{tools/sendDTMFAccumulated.d.ts → src/tools/sendDtmfFAccumulated.d.ts} +2 -2
- package/dist/{types.d.ts → src/types.d.ts} +2 -1
- package/package.json +40 -37
- package/dist/SipConnector-Cc1z-VjV.js +0 -1335
- package/dist/SipConnector-K7IHfEEm.cjs +0 -1
- package/dist/SipConnector.d.ts +0 -314
- package/dist/__fixtures__/RTCSessionMock.d.ts +0 -78
- package/dist/__fixtures__/UA.mock.d.ts +0 -103
- package/dist/utils.d.ts +0 -4
- /package/dist/{SipConnectorFacade → src/SipConnectorFacade}/index.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/Registrator.mock.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/Request.mock.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/WebSocketInterface.mock.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/accountNotify.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/channels.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/delayPromise.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/enterRoom.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/mediaState.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/participantMoveRequests.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/remoteCallerData.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/utils.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/webcastNotify.d.ts +0 -0
- /package/dist/{causes.d.ts → src/causes.d.ts} +0 -0
- /package/dist/{eventNames.d.ts → src/eventNames.d.ts} +0 -0
- /package/dist/{getExtraHeadersRemoteAddress.d.ts → src/getExtraHeadersRemoteAddress.d.ts} +0 -0
- /package/dist/{headers.d.ts → src/headers.d.ts} +0 -0
- /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureDegradationPreference.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureEncodings.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureMaxBitrate.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/index.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/setParametersToSender.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/call.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/hasValidUri.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/permissions.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/processRequest.d.ts +0 -0
- /package/dist/{tools → src/tools}/__tests-utils__/parseObject.d.ts +0 -0
- /package/dist/{tools → src/tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/getLinkError.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/getTypeFromError.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/getValuesFromError.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/index.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/stringifyMessage.d.ts +0 -0
- /package/dist/{tools → src/tools}/generateSimulcastEncodings.d.ts +0 -0
- /package/dist/{tools → src/tools}/getExtraHeaders.d.ts +0 -0
- /package/dist/{tools → src/tools}/getUserAgent.d.ts +0 -0
- /package/dist/{tools → src/tools}/hasPurgatory.d.ts +0 -0
- /package/dist/{tools → src/tools}/prepareMediaStream.d.ts +0 -0
- /package/dist/{tools → src/tools}/resolveUpdateTransceiver.d.ts +0 -0
- /package/dist/{tools → src/tools}/setVideoTrackContentHints.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/index.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMainCam.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMic.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMainCam.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMic.d.ts +0 -0
- /package/dist/{utils → src/utils}/errors.d.ts +0 -0
- /package/dist/{utils → src/utils}/findSenderByStream.d.ts +0 -0
- /package/dist/{utils → src/utils}/findVideoSender.d.ts +0 -0
- /package/dist/{utils → src/utils}/findVideoTrack.d.ts +0 -0
- /package/dist/{utils → src/utils}/getCodecFromSender.d.ts +0 -0
- /package/dist/{utils → src/utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/balance.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidth.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidthAndCodec.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasAv1Codec.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasIncludesString.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/index.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/processSender.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleBitrate.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleBitrateByCodec.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleResolutionAndBitrate.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/setEncodingsToSender.d.ts +0 -0
package/dist/doMock.js
CHANGED
|
@@ -1,73 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var r = (o, t, e) => N(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { n as P, R as O, U as A, S as b } from "./SipConnector-Cc1z-VjV.js";
|
|
5
|
-
import k from "@krivega/jssip/lib/NameAddrHeader";
|
|
1
|
+
import { f as P, R as N, g as O, U as b, S as k } from "./SipConnector-CK3GgjXE.js";
|
|
2
|
+
import A from "@krivega/jssip/lib/NameAddrHeader";
|
|
6
3
|
import D from "@krivega/jssip/lib/URI";
|
|
7
4
|
import { EventEmitter as L } from "node:events";
|
|
8
5
|
import { IncomingRequest as W } from "@krivega/jssip/lib/SIPMessage";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
class
|
|
6
|
+
import { NameAddrHeader as V, URI as h, C as _ } from "@krivega/jssip";
|
|
7
|
+
import { createAudioMediaStreamTrackMock as F, createVideoMediaStreamTrackMock as x } from "webrtc-mock";
|
|
8
|
+
import R from "events-constructor";
|
|
9
|
+
class w extends W {
|
|
10
|
+
headers;
|
|
13
11
|
constructor(e) {
|
|
14
|
-
super();
|
|
15
|
-
r(this, "headers");
|
|
16
|
-
this.headers = new Headers(e);
|
|
12
|
+
super(), this.headers = new Headers(e);
|
|
17
13
|
}
|
|
18
14
|
getHeader(e) {
|
|
19
|
-
return this.headers.get(e)
|
|
15
|
+
return this.headers.get(e) ?? "";
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
|
-
class
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
class H {
|
|
19
|
+
originator;
|
|
20
|
+
connection;
|
|
21
|
+
events;
|
|
22
|
+
remote_identity;
|
|
23
|
+
mutedOptions = { audio: !1, video: !1 };
|
|
24
|
+
constructor({
|
|
25
|
+
originator: e = "local",
|
|
26
|
+
eventHandlers: t,
|
|
27
|
+
remoteIdentity: r
|
|
28
|
+
}) {
|
|
29
|
+
this.originator = e, this.events = new R(P), this.initEvents(t), this.remote_identity = r;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
get C() {
|
|
31
|
+
get contact() {
|
|
34
32
|
throw new Error("Method not implemented.");
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
get causes() {
|
|
34
|
+
get direction() {
|
|
38
35
|
throw new Error("Method not implemented.");
|
|
39
36
|
}
|
|
40
|
-
get
|
|
37
|
+
get local_identity() {
|
|
41
38
|
throw new Error("Method not implemented.");
|
|
42
39
|
}
|
|
43
|
-
|
|
40
|
+
get start_time() {
|
|
44
41
|
throw new Error("Method not implemented.");
|
|
45
42
|
}
|
|
46
|
-
get
|
|
43
|
+
get end_time() {
|
|
47
44
|
throw new Error("Method not implemented.");
|
|
48
45
|
}
|
|
49
|
-
get
|
|
50
|
-
return this._connection;
|
|
51
|
-
}
|
|
52
|
-
get contact() {
|
|
46
|
+
get status() {
|
|
53
47
|
throw new Error("Method not implemented.");
|
|
54
48
|
}
|
|
55
|
-
|
|
49
|
+
// @ts-expect-error
|
|
50
|
+
get C() {
|
|
56
51
|
throw new Error("Method not implemented.");
|
|
57
52
|
}
|
|
58
|
-
|
|
53
|
+
// @ts-expect-error
|
|
54
|
+
get causes() {
|
|
59
55
|
throw new Error("Method not implemented.");
|
|
60
56
|
}
|
|
61
|
-
get
|
|
62
|
-
return this._remote_identity;
|
|
63
|
-
}
|
|
64
|
-
get start_time() {
|
|
57
|
+
get id() {
|
|
65
58
|
throw new Error("Method not implemented.");
|
|
66
59
|
}
|
|
67
|
-
get
|
|
60
|
+
get data() {
|
|
68
61
|
throw new Error("Method not implemented.");
|
|
69
62
|
}
|
|
70
|
-
|
|
63
|
+
set data(e) {
|
|
71
64
|
throw new Error("Method not implemented.");
|
|
72
65
|
}
|
|
73
66
|
isInProgress() {
|
|
@@ -79,104 +72,97 @@ class x {
|
|
|
79
72
|
isReadyToReOffer() {
|
|
80
73
|
throw new Error("Method not implemented.");
|
|
81
74
|
}
|
|
82
|
-
answer(
|
|
75
|
+
answer(e) {
|
|
83
76
|
throw new Error("Method not implemented.");
|
|
84
77
|
}
|
|
85
|
-
terminate(
|
|
78
|
+
terminate(e) {
|
|
86
79
|
throw new Error("Method not implemented.");
|
|
87
80
|
}
|
|
88
|
-
async sendInfo(
|
|
81
|
+
async sendInfo(e, t, r) {
|
|
89
82
|
throw new Error("Method not implemented.");
|
|
90
83
|
}
|
|
91
|
-
hold(
|
|
84
|
+
hold(e, t) {
|
|
92
85
|
throw new Error("Method not implemented.");
|
|
93
86
|
}
|
|
94
|
-
unhold(
|
|
87
|
+
unhold(e, t) {
|
|
95
88
|
throw new Error("Method not implemented.");
|
|
96
89
|
}
|
|
97
|
-
async renegotiate(
|
|
90
|
+
async renegotiate(e, t) {
|
|
98
91
|
throw new Error("Method not implemented.");
|
|
99
92
|
}
|
|
100
93
|
isOnHold() {
|
|
101
94
|
throw new Error("Method not implemented.");
|
|
102
95
|
}
|
|
103
|
-
mute(
|
|
96
|
+
mute(e) {
|
|
104
97
|
throw new Error("Method not implemented.");
|
|
105
98
|
}
|
|
106
|
-
unmute(
|
|
99
|
+
unmute(e) {
|
|
107
100
|
throw new Error("Method not implemented.");
|
|
108
101
|
}
|
|
109
102
|
isMuted() {
|
|
110
103
|
throw new Error("Method not implemented.");
|
|
111
104
|
}
|
|
112
|
-
refer(
|
|
105
|
+
refer(e, t) {
|
|
113
106
|
throw new Error("Method not implemented.");
|
|
114
107
|
}
|
|
115
108
|
resetLocalMedia() {
|
|
116
109
|
throw new Error("Method not implemented.");
|
|
117
110
|
}
|
|
118
|
-
async replaceMediaStream(
|
|
111
|
+
async replaceMediaStream(e, t) {
|
|
119
112
|
throw new Error("Method not implemented.");
|
|
120
113
|
}
|
|
121
|
-
addListener(
|
|
114
|
+
addListener(e, t) {
|
|
122
115
|
throw new Error("Method not implemented.");
|
|
123
116
|
}
|
|
124
|
-
once(
|
|
117
|
+
once(e, t) {
|
|
125
118
|
throw new Error("Method not implemented.");
|
|
126
119
|
}
|
|
127
|
-
removeListener(
|
|
120
|
+
removeListener(e, t) {
|
|
128
121
|
throw new Error("Method not implemented.");
|
|
129
122
|
}
|
|
130
|
-
off(
|
|
131
|
-
|
|
123
|
+
off(e, t) {
|
|
124
|
+
return this.events.off(e, t), this;
|
|
132
125
|
}
|
|
133
|
-
removeAllListeners(
|
|
134
|
-
|
|
126
|
+
removeAllListeners(e) {
|
|
127
|
+
return console.warn("Method not implemented. Event:", e), this;
|
|
135
128
|
}
|
|
136
|
-
setMaxListeners(
|
|
129
|
+
setMaxListeners(e) {
|
|
137
130
|
throw new Error("Method not implemented.");
|
|
138
131
|
}
|
|
139
132
|
getMaxListeners() {
|
|
140
133
|
throw new Error("Method not implemented.");
|
|
141
134
|
}
|
|
142
|
-
listeners(
|
|
135
|
+
listeners(e) {
|
|
143
136
|
throw new Error("Method not implemented.");
|
|
144
137
|
}
|
|
145
|
-
rawListeners(
|
|
138
|
+
rawListeners(e) {
|
|
146
139
|
throw new Error("Method not implemented.");
|
|
147
140
|
}
|
|
148
|
-
emit(
|
|
141
|
+
emit(e, ...t) {
|
|
149
142
|
throw new Error("Method not implemented.");
|
|
150
143
|
}
|
|
151
|
-
listenerCount(
|
|
144
|
+
listenerCount(e) {
|
|
152
145
|
throw new Error("Method not implemented.");
|
|
153
146
|
}
|
|
154
|
-
prependListener(
|
|
147
|
+
prependListener(e, t) {
|
|
155
148
|
throw new Error("Method not implemented.");
|
|
156
149
|
}
|
|
157
|
-
prependOnceListener(
|
|
150
|
+
prependOnceListener(e, t) {
|
|
158
151
|
throw new Error("Method not implemented.");
|
|
159
152
|
}
|
|
160
153
|
eventNames() {
|
|
161
154
|
throw new Error("Method not implemented.");
|
|
162
155
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
*
|
|
166
|
-
* @param {Array} [eventHandlers=[] - ] The event handlers
|
|
167
|
-
*
|
|
168
|
-
* @returns {undefined}
|
|
169
|
-
*/
|
|
170
|
-
initEvents(t = []) {
|
|
171
|
-
Object.entries(t).forEach(([e, n]) => this.on(e, n));
|
|
156
|
+
initEvents(e) {
|
|
157
|
+
e && Object.entries(e).forEach(([t, r]) => this.on(t, r));
|
|
172
158
|
}
|
|
173
159
|
// @ts-expect-error
|
|
174
160
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
175
|
-
on(
|
|
176
|
-
return this.
|
|
161
|
+
on(e, t) {
|
|
162
|
+
return this.events.on(e, t), this;
|
|
177
163
|
}
|
|
178
|
-
trigger(
|
|
179
|
-
this.
|
|
164
|
+
trigger(e, t) {
|
|
165
|
+
this.events.trigger(e, t);
|
|
180
166
|
}
|
|
181
167
|
/**
|
|
182
168
|
* sendDTMF
|
|
@@ -188,103 +174,98 @@ class x {
|
|
|
188
174
|
sendDTMF() {
|
|
189
175
|
this.trigger("newDTMF", { originator: this.originator });
|
|
190
176
|
}
|
|
191
|
-
async startPresentation(
|
|
192
|
-
return
|
|
193
|
-
}
|
|
194
|
-
async updatePresentation(t) {
|
|
195
|
-
return t;
|
|
177
|
+
async startPresentation(e) {
|
|
178
|
+
return this.trigger("presentation:start", e), this.trigger("presentation:started", e), e;
|
|
196
179
|
}
|
|
197
|
-
async stopPresentation(
|
|
198
|
-
return
|
|
180
|
+
async stopPresentation(e) {
|
|
181
|
+
return this.trigger("presentation:end", e), this.trigger("presentation:ended", e), e;
|
|
199
182
|
}
|
|
200
183
|
isEstablished() {
|
|
201
184
|
return !0;
|
|
202
185
|
}
|
|
203
186
|
}
|
|
204
|
-
class
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
this.track =
|
|
187
|
+
class j {
|
|
188
|
+
dtmf = null;
|
|
189
|
+
track = null;
|
|
190
|
+
transport = null;
|
|
191
|
+
transform = null;
|
|
192
|
+
parameters = {
|
|
193
|
+
encodings: [{}],
|
|
194
|
+
transactionId: "0",
|
|
195
|
+
codecs: [],
|
|
196
|
+
headerExtensions: [],
|
|
197
|
+
rtcp: {}
|
|
198
|
+
};
|
|
199
|
+
parametersGets;
|
|
200
|
+
constructor({ track: e } = {}) {
|
|
201
|
+
this.track = e ?? null;
|
|
219
202
|
}
|
|
203
|
+
// eslint-disable-next-line class-methods-use-this
|
|
220
204
|
async getStats() {
|
|
221
205
|
throw new Error("Method not implemented.");
|
|
222
206
|
}
|
|
223
|
-
async replaceTrack(
|
|
224
|
-
this.track =
|
|
207
|
+
async replaceTrack(e) {
|
|
208
|
+
this.track = e ?? null;
|
|
225
209
|
}
|
|
226
|
-
async setParameters(
|
|
227
|
-
if (
|
|
210
|
+
async setParameters(e) {
|
|
211
|
+
if (e !== this.parametersGets)
|
|
228
212
|
throw new Error(
|
|
229
213
|
"Failed to execute 'setParameters' on 'RTCRtpSender': Read-only field modified in setParameters()."
|
|
230
214
|
);
|
|
231
|
-
const { transactionId:
|
|
232
|
-
this.
|
|
233
|
-
...this.
|
|
234
|
-
...
|
|
235
|
-
transactionId: `${Number(
|
|
215
|
+
const { transactionId: t } = this.parameters;
|
|
216
|
+
this.parameters = {
|
|
217
|
+
...this.parameters,
|
|
218
|
+
...e,
|
|
219
|
+
transactionId: `${Number(t) + 1}`
|
|
236
220
|
};
|
|
237
221
|
}
|
|
238
222
|
getParameters() {
|
|
239
|
-
return this.
|
|
223
|
+
return this.parametersGets = { ...this.parameters }, this.parametersGets;
|
|
240
224
|
}
|
|
225
|
+
// eslint-disable-next-line class-methods-use-this
|
|
241
226
|
setStreams() {
|
|
242
227
|
throw new Error("Method not implemented.");
|
|
243
228
|
}
|
|
244
229
|
}
|
|
245
|
-
class
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const e = new U({ track: t });
|
|
277
|
-
return this._senders.push(e), e;
|
|
278
|
-
});
|
|
279
|
-
this._receivers = e.map((n) => ({ track: n }));
|
|
230
|
+
class z {
|
|
231
|
+
senders = [];
|
|
232
|
+
receivers = [];
|
|
233
|
+
canTrickleIceCandidates;
|
|
234
|
+
connectionState;
|
|
235
|
+
currentLocalDescription;
|
|
236
|
+
currentRemoteDescription;
|
|
237
|
+
iceConnectionState;
|
|
238
|
+
iceGatheringState;
|
|
239
|
+
idpErrorInfo;
|
|
240
|
+
idpLoginUrl;
|
|
241
|
+
localDescription;
|
|
242
|
+
onconnectionstatechange;
|
|
243
|
+
ondatachannel;
|
|
244
|
+
onicecandidate;
|
|
245
|
+
// eslint-disable-next-line unicorn/no-null
|
|
246
|
+
onicecandidateerror = null;
|
|
247
|
+
oniceconnectionstatechange;
|
|
248
|
+
onicegatheringstatechange;
|
|
249
|
+
onnegotiationneeded;
|
|
250
|
+
onsignalingstatechange;
|
|
251
|
+
ontrack;
|
|
252
|
+
peerIdentity = void 0;
|
|
253
|
+
pendingLocalDescription;
|
|
254
|
+
pendingRemoteDescription;
|
|
255
|
+
remoteDescription;
|
|
256
|
+
// eslint-disable-next-line unicorn/no-null
|
|
257
|
+
sctp = null;
|
|
258
|
+
signalingState;
|
|
259
|
+
constructor(e, t) {
|
|
260
|
+
this.receivers = t.map((r) => ({ track: r }));
|
|
280
261
|
}
|
|
281
262
|
getRemoteStreams() {
|
|
282
263
|
throw new Error("Method not implemented.");
|
|
283
264
|
}
|
|
284
|
-
async addIceCandidate(
|
|
265
|
+
async addIceCandidate(e) {
|
|
285
266
|
throw new Error("Method not implemented.");
|
|
286
267
|
}
|
|
287
|
-
addTransceiver(
|
|
268
|
+
addTransceiver(e, t) {
|
|
288
269
|
throw new Error("Method not implemented.");
|
|
289
270
|
}
|
|
290
271
|
close() {
|
|
@@ -293,13 +274,13 @@ class H {
|
|
|
293
274
|
restartIce() {
|
|
294
275
|
throw new Error("Method not implemented.");
|
|
295
276
|
}
|
|
296
|
-
async createAnswer(
|
|
277
|
+
async createAnswer(e, t) {
|
|
297
278
|
throw new Error("Method not implemented.");
|
|
298
279
|
}
|
|
299
|
-
createDataChannel(
|
|
280
|
+
createDataChannel(e, t) {
|
|
300
281
|
throw new Error("Method not implemented.");
|
|
301
282
|
}
|
|
302
|
-
async createOffer(
|
|
283
|
+
async createOffer(e, t, r) {
|
|
303
284
|
throw new Error("Method not implemented.");
|
|
304
285
|
}
|
|
305
286
|
getConfiguration() {
|
|
@@ -308,108 +289,144 @@ class H {
|
|
|
308
289
|
async getIdentityAssertion() {
|
|
309
290
|
throw new Error("Method not implemented.");
|
|
310
291
|
}
|
|
311
|
-
async getStats(
|
|
292
|
+
async getStats(e) {
|
|
312
293
|
throw new Error("Method not implemented.");
|
|
313
294
|
}
|
|
314
295
|
getTransceivers() {
|
|
315
296
|
throw new Error("Method not implemented.");
|
|
316
297
|
}
|
|
317
|
-
removeTrack(
|
|
298
|
+
removeTrack(e) {
|
|
318
299
|
throw new Error("Method not implemented.");
|
|
319
300
|
}
|
|
320
|
-
setConfiguration(
|
|
301
|
+
setConfiguration(e) {
|
|
321
302
|
throw new Error("Method not implemented.");
|
|
322
303
|
}
|
|
323
|
-
async setLocalDescription(
|
|
304
|
+
async setLocalDescription(e) {
|
|
324
305
|
throw new Error("Method not implemented.");
|
|
325
306
|
}
|
|
326
|
-
async setRemoteDescription(
|
|
307
|
+
async setRemoteDescription(e) {
|
|
327
308
|
throw new Error("Method not implemented.");
|
|
328
309
|
}
|
|
329
|
-
addEventListener(
|
|
330
|
-
|
|
310
|
+
addEventListener(e, t, r) {
|
|
311
|
+
console.warn("Method not implemented. Type:", e);
|
|
331
312
|
}
|
|
332
|
-
removeEventListener(
|
|
333
|
-
|
|
313
|
+
removeEventListener(e, t, r) {
|
|
314
|
+
console.warn("Method not implemented. Type:", e);
|
|
334
315
|
}
|
|
335
|
-
dispatchEvent(
|
|
316
|
+
dispatchEvent(e) {
|
|
336
317
|
throw new Error("Method not implemented.");
|
|
337
318
|
}
|
|
319
|
+
getReceivers = () => this.receivers;
|
|
320
|
+
getSenders = () => this.senders;
|
|
321
|
+
addTrack = (e) => {
|
|
322
|
+
const t = new j({ track: e });
|
|
323
|
+
return this.senders.push(t), t;
|
|
324
|
+
};
|
|
338
325
|
}
|
|
339
|
-
function
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
326
|
+
function Y(n) {
|
|
327
|
+
const e = n.match(/(purgatory)|[\d.]+/g);
|
|
328
|
+
if (!e)
|
|
342
329
|
throw new Error("wrong sip url");
|
|
343
|
-
return
|
|
330
|
+
return e[0];
|
|
344
331
|
}
|
|
345
|
-
const p = 400,
|
|
332
|
+
const p = 400, q = "777", J = (n) => n.getVideoTracks().length > 0;
|
|
333
|
+
class i extends H {
|
|
334
|
+
static presentationError;
|
|
335
|
+
static startPresentationError;
|
|
336
|
+
static countStartPresentationError = Number.POSITIVE_INFINITY;
|
|
337
|
+
static countStartsPresentation = 0;
|
|
338
|
+
url;
|
|
339
|
+
status_code;
|
|
340
|
+
/**
|
|
341
|
+
* answer
|
|
342
|
+
*
|
|
343
|
+
* @param {Object} arg1 - The argument 1
|
|
344
|
+
* @param {Object} arg1.mediaStream - The media stream
|
|
345
|
+
* @param {Array} arg1.eventHandlers - The event handlers
|
|
346
|
+
|
|
347
|
+
* @returns {undefined}
|
|
348
|
+
*/
|
|
349
|
+
answer = jest.fn(({ mediaStream: e }) => {
|
|
350
|
+
if (this.originator !== "remote")
|
|
351
|
+
throw new Error("answer available only for remote sessions");
|
|
352
|
+
this.initPeerconnection(e), setTimeout(() => {
|
|
353
|
+
this.trigger("connecting"), setTimeout(() => {
|
|
354
|
+
this.trigger("accepted");
|
|
355
|
+
}, 100), setTimeout(() => {
|
|
356
|
+
this.trigger("confirmed");
|
|
357
|
+
}, 200);
|
|
358
|
+
}, p);
|
|
359
|
+
});
|
|
360
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
361
|
+
replaceMediaStream = jest.fn(async (e) => {
|
|
362
|
+
});
|
|
363
|
+
isEndedInner = !1;
|
|
346
364
|
constructor({
|
|
347
365
|
url: e = "",
|
|
348
|
-
mediaStream:
|
|
349
|
-
eventHandlers:
|
|
350
|
-
originator:
|
|
366
|
+
mediaStream: t,
|
|
367
|
+
eventHandlers: r,
|
|
368
|
+
originator: s,
|
|
369
|
+
remoteIdentity: a = new V(
|
|
370
|
+
new h("sip", "caller1", "test1.com", 5060),
|
|
371
|
+
"Test Caller 1"
|
|
372
|
+
)
|
|
351
373
|
}) {
|
|
352
|
-
super({ originator:
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
* @returns {undefined}
|
|
364
|
-
*/
|
|
365
|
-
r(this, "answer", jest.fn(({ mediaStream: e }) => {
|
|
366
|
-
if (this.originator !== "remote")
|
|
367
|
-
throw new Error("answer available only for remote sessions");
|
|
368
|
-
this.initPeerconnection(e), setTimeout(() => {
|
|
369
|
-
this.trigger("connecting"), setTimeout(() => {
|
|
370
|
-
this.trigger("accepted");
|
|
371
|
-
}, 100), setTimeout(() => {
|
|
372
|
-
this.trigger("confirmed");
|
|
373
|
-
}, 200);
|
|
374
|
-
}, p);
|
|
375
|
-
}));
|
|
376
|
-
this.url = e, this.initPeerconnection(n);
|
|
377
|
-
}
|
|
378
|
-
static setStartPresentationError(e, { count: n = Number.POSITIVE_INFINITY } = {}) {
|
|
379
|
-
this.startPresentationError = e, this.countStartPresentationError = n;
|
|
374
|
+
super({ originator: s, eventHandlers: r, remoteIdentity: a }), this.url = e, this.initPeerconnection(t);
|
|
375
|
+
}
|
|
376
|
+
static setPresentationError(e) {
|
|
377
|
+
this.presentationError = e;
|
|
378
|
+
}
|
|
379
|
+
static resetPresentationError() {
|
|
380
|
+
this.presentationError = void 0;
|
|
381
|
+
}
|
|
382
|
+
static setStartPresentationError(e, { count: t = Number.POSITIVE_INFINITY } = {}) {
|
|
383
|
+
this.startPresentationError = e, this.countStartPresentationError = t;
|
|
380
384
|
}
|
|
381
385
|
static resetStartPresentationError() {
|
|
382
386
|
this.startPresentationError = void 0, this.countStartPresentationError = Number.POSITIVE_INFINITY, this.countStartsPresentation = 0;
|
|
383
387
|
}
|
|
384
|
-
async
|
|
385
|
-
if (
|
|
386
|
-
throw
|
|
388
|
+
startPresentation = async (e) => {
|
|
389
|
+
if (i.countStartsPresentation += 1, i.presentationError)
|
|
390
|
+
throw this.trigger("presentation:start", e), this.trigger("presentation:failed", e), i.presentationError;
|
|
391
|
+
if (i.startPresentationError && i.countStartsPresentation < i.countStartPresentationError)
|
|
392
|
+
throw this.trigger("presentation:start", e), this.trigger("presentation:failed", e), i.startPresentationError;
|
|
387
393
|
return super.startPresentation(e);
|
|
388
|
-
}
|
|
394
|
+
};
|
|
395
|
+
stopPresentation = async (e) => {
|
|
396
|
+
if (i.presentationError)
|
|
397
|
+
throw this.trigger("presentation:end", e), this.trigger("presentation:failed", e), i.presentationError;
|
|
398
|
+
return super.stopPresentation(e);
|
|
399
|
+
};
|
|
389
400
|
initPeerconnection(e) {
|
|
390
401
|
return e ? (this.createPeerconnection(e), !0) : !1;
|
|
391
402
|
}
|
|
392
403
|
createPeerconnection(e) {
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
if (
|
|
397
|
-
const
|
|
398
|
-
|
|
404
|
+
const t = F();
|
|
405
|
+
t.id = "mainaudio1";
|
|
406
|
+
const r = [t];
|
|
407
|
+
if (J(e)) {
|
|
408
|
+
const a = x();
|
|
409
|
+
a.id = "mainvideo1", r.push(a);
|
|
399
410
|
}
|
|
400
|
-
this.
|
|
411
|
+
this.connection = new z(void 0, r), this.addStream(e), setTimeout(() => {
|
|
401
412
|
this.trigger("peerconnection", { peerconnection: this.connection });
|
|
402
413
|
}, p);
|
|
403
414
|
}
|
|
404
415
|
connect(e) {
|
|
405
|
-
const
|
|
416
|
+
const t = Y(e);
|
|
406
417
|
setTimeout(() => {
|
|
407
|
-
this.url.includes(
|
|
418
|
+
this.url.includes(q) ? this.trigger("failed", {
|
|
408
419
|
originator: "remote",
|
|
409
420
|
message: "IncomingResponse",
|
|
410
|
-
cause:
|
|
421
|
+
cause: N
|
|
411
422
|
}) : (this.trigger("connecting"), setTimeout(() => {
|
|
412
|
-
this.
|
|
423
|
+
this.newInfo({
|
|
424
|
+
originator: O.REMOTE,
|
|
425
|
+
// @ts-expect-error
|
|
426
|
+
request: {
|
|
427
|
+
getHeader: (r) => r === "content-type" ? "application/vinteo.webrtc.roomname" : r === "x-webrtc-enter-room" ? t : r === "x-webrtc-participant-name" ? "Test Caller 1" : ""
|
|
428
|
+
}
|
|
429
|
+
});
|
|
413
430
|
}, 100), setTimeout(() => {
|
|
414
431
|
this.trigger("accepted");
|
|
415
432
|
}, 200), setTimeout(() => {
|
|
@@ -417,153 +434,162 @@ const p = 400, Y = "777", q = (o) => o.getVideoTracks().length > 0, a = class a
|
|
|
417
434
|
}, 300));
|
|
418
435
|
}, p);
|
|
419
436
|
}
|
|
420
|
-
terminate({ status_code: e } = {}) {
|
|
421
|
-
return this.status_code = e, this.trigger("ended", { status_code: e }), this.
|
|
437
|
+
terminate({ status_code: e, cause: t } = {}) {
|
|
438
|
+
return this.status_code = e, this.trigger("ended", { status_code: e, cause: t, originator: "local" }), this.isEndedInner = !1, this;
|
|
422
439
|
}
|
|
423
|
-
async terminateAsync({
|
|
424
|
-
|
|
440
|
+
async terminateAsync({
|
|
441
|
+
status_code: e,
|
|
442
|
+
cause: t
|
|
443
|
+
} = {}) {
|
|
444
|
+
this.terminate({ status_code: e, cause: t });
|
|
425
445
|
}
|
|
426
446
|
terminateRemote({ status_code: e } = {}) {
|
|
427
447
|
return this.status_code = e, this.trigger("ended", { status_code: e, originator: "remote" }), this;
|
|
428
448
|
}
|
|
429
|
-
|
|
430
|
-
e[
|
|
449
|
+
addStream(e, t = "getTracks") {
|
|
450
|
+
e[t]().forEach((r) => this.connection.addTrack(r));
|
|
431
451
|
}
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
for (const
|
|
435
|
-
e(
|
|
436
|
-
return
|
|
452
|
+
forEachSenders(e) {
|
|
453
|
+
const t = this.connection.getSenders();
|
|
454
|
+
for (const r of t)
|
|
455
|
+
e(r);
|
|
456
|
+
return t;
|
|
437
457
|
}
|
|
438
458
|
/* eslint-disable no-param-reassign */
|
|
439
|
-
|
|
440
|
-
this.
|
|
441
|
-
|
|
459
|
+
toggleMuteAudio(e) {
|
|
460
|
+
this.forEachSenders(({ track: t }) => {
|
|
461
|
+
t && t.kind === "audio" && (t.enabled = !e);
|
|
442
462
|
});
|
|
443
463
|
}
|
|
444
464
|
/* eslint-enable no-param-reassign */
|
|
445
465
|
/* eslint-disable no-param-reassign */
|
|
446
|
-
|
|
447
|
-
this.
|
|
448
|
-
|
|
466
|
+
toggleMuteVideo(e) {
|
|
467
|
+
this.forEachSenders(({ track: t }) => {
|
|
468
|
+
t && t.kind === "video" && (t.enabled = !e);
|
|
449
469
|
});
|
|
450
470
|
}
|
|
451
471
|
mute(e) {
|
|
452
|
-
e.audio && (this.
|
|
472
|
+
e.audio && (this.mutedOptions.audio = !0, this.toggleMuteAudio(this.mutedOptions.audio)), e.video && (this.mutedOptions.video = !0, this.toggleMuteVideo(this.mutedOptions.video)), this.onmute(e);
|
|
453
473
|
}
|
|
454
474
|
unmute(e) {
|
|
455
|
-
e.audio && (this.
|
|
475
|
+
e.audio && (this.mutedOptions.audio = !1), e.video && (this.mutedOptions.video = !1), this.trigger("unmuted", e);
|
|
456
476
|
}
|
|
457
477
|
isMuted() {
|
|
458
|
-
return this.
|
|
478
|
+
return this.mutedOptions;
|
|
459
479
|
}
|
|
460
|
-
|
|
461
|
-
return e;
|
|
462
|
-
}
|
|
463
|
-
_onmute({ audio: e, video: n }) {
|
|
480
|
+
onmute({ audio: e, video: t }) {
|
|
464
481
|
this.trigger("muted", {
|
|
465
482
|
audio: e,
|
|
466
|
-
video:
|
|
483
|
+
video: t
|
|
467
484
|
});
|
|
468
485
|
}
|
|
486
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function, class-methods-use-this
|
|
469
487
|
async sendInfo() {
|
|
470
488
|
}
|
|
471
489
|
isEnded() {
|
|
472
|
-
return this.
|
|
490
|
+
return this.isEndedInner;
|
|
473
491
|
}
|
|
474
492
|
newInfo(e) {
|
|
475
493
|
this.trigger("newInfo", e);
|
|
476
494
|
}
|
|
477
495
|
/* eslint-enable no-param-reassign */
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
r(this, "extraHeaders", []);
|
|
484
|
-
}
|
|
485
|
-
setExtraHeaders(t) {
|
|
486
|
-
this.extraHeaders = t;
|
|
496
|
+
}
|
|
497
|
+
class $ {
|
|
498
|
+
extraHeaders = [];
|
|
499
|
+
setExtraHeaders(e) {
|
|
500
|
+
this.extraHeaders = e;
|
|
487
501
|
}
|
|
502
|
+
// eslint-disable-next-line class-methods-use-this
|
|
488
503
|
setExtraContactParams() {
|
|
489
504
|
}
|
|
490
505
|
}
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
static setNotAvailableTelephony() {
|
|
523
|
-
this.isAvailableTelephony = !1;
|
|
524
|
-
}
|
|
525
|
-
isConnected() {
|
|
526
|
-
return !!this._isConnected;
|
|
527
|
-
}
|
|
506
|
+
const d = "PASSWORD_CORRECT", v = "PASSWORD_CORRECT_2", G = "NAME_INCORRECT", c = 400, g = {
|
|
507
|
+
url: "wss://sipServerUrl/webrtc/wss/",
|
|
508
|
+
sip_uri: "sip:sipServerUrl;transport=ws",
|
|
509
|
+
via_transport: "WSS"
|
|
510
|
+
}, M = {
|
|
511
|
+
status_code: 200,
|
|
512
|
+
reason_phrase: "OK"
|
|
513
|
+
}, T = {
|
|
514
|
+
status_code: 401,
|
|
515
|
+
reason_phrase: "Unauthorized"
|
|
516
|
+
};
|
|
517
|
+
class o {
|
|
518
|
+
static isAvailableTelephony = !0;
|
|
519
|
+
static startError;
|
|
520
|
+
static countStartError = Number.POSITIVE_INFINITY;
|
|
521
|
+
static countStarts = 0;
|
|
522
|
+
events;
|
|
523
|
+
registratorInner;
|
|
524
|
+
// @ts-expect-error – Jest создаёт функцию-замок.
|
|
525
|
+
call = jest.fn(
|
|
526
|
+
(e, t) => {
|
|
527
|
+
const { mediaStream: r, eventHandlers: s } = t;
|
|
528
|
+
return this.session = new i({ url: e, mediaStream: r, eventHandlers: s, originator: "local" }), this.session.connect(e), this.session;
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
sendOptions = jest.fn(
|
|
532
|
+
(e, t, r) => {
|
|
533
|
+
console.log("sendOptions", e, t, r);
|
|
534
|
+
}
|
|
535
|
+
);
|
|
528
536
|
/**
|
|
529
|
-
* start
|
|
530
|
-
*
|
|
531
|
-
* @returns {undefined}
|
|
537
|
+
* start – имитирует запуск UA.
|
|
532
538
|
*/
|
|
533
|
-
start() {
|
|
534
|
-
if (
|
|
535
|
-
this.trigger("disconnected",
|
|
539
|
+
start = jest.fn(() => {
|
|
540
|
+
if (o.countStarts += 1, o.startError && o.countStarts < o.countStartError) {
|
|
541
|
+
this.trigger("disconnected", o.startError);
|
|
536
542
|
return;
|
|
537
543
|
}
|
|
538
544
|
this.register();
|
|
539
|
-
}
|
|
545
|
+
});
|
|
540
546
|
/**
|
|
541
|
-
* stop
|
|
542
|
-
*
|
|
543
|
-
* @returns {undefined}
|
|
547
|
+
* stop – имитирует остановку UA.
|
|
544
548
|
*/
|
|
545
|
-
stop() {
|
|
546
|
-
this.
|
|
547
|
-
this.trigger("disconnected", { error:
|
|
548
|
-
},
|
|
549
|
+
stop = jest.fn(() => {
|
|
550
|
+
this.startedTimeout && clearTimeout(this.startedTimeout), this.stopedTimeout && clearTimeout(this.stopedTimeout), this.unregister(), this.isStarted() ? this.stopedTimeout = setTimeout(() => {
|
|
551
|
+
this.trigger("disconnected", { error: !0, socket: g });
|
|
552
|
+
}, c) : this.trigger("disconnected", { error: !0, socket: g });
|
|
553
|
+
});
|
|
554
|
+
removeAllListeners = jest.fn(() => (this.events.removeEventHandlers(), this));
|
|
555
|
+
once = jest.fn((e, t) => (this.events.once(e, t), this));
|
|
556
|
+
startedTimeout;
|
|
557
|
+
stopedTimeout;
|
|
558
|
+
session;
|
|
559
|
+
isRegisteredInner;
|
|
560
|
+
isConnectedInner;
|
|
561
|
+
configuration;
|
|
562
|
+
constructor(e) {
|
|
563
|
+
this.events = new R(b);
|
|
564
|
+
const [t, r] = e.uri.split(":"), [s, a] = r.split("@"), l = {
|
|
565
|
+
...e,
|
|
566
|
+
uri: new h(t, s, a)
|
|
567
|
+
};
|
|
568
|
+
this.configuration = l, this.registratorInner = new $();
|
|
549
569
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
return this._events.on(t, e), this;
|
|
570
|
+
static setStartError(e, { count: t = Number.POSITIVE_INFINITY } = {}) {
|
|
571
|
+
o.startError = e, o.countStartError = t;
|
|
553
572
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
return this._events.once(t, e), this;
|
|
573
|
+
static resetStartError() {
|
|
574
|
+
o.startError = void 0, o.countStartError = Number.POSITIVE_INFINITY, o.countStarts = 0;
|
|
557
575
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
576
|
+
static setAvailableTelephony() {
|
|
577
|
+
o.isAvailableTelephony = !0;
|
|
578
|
+
}
|
|
579
|
+
static setNotAvailableTelephony() {
|
|
580
|
+
o.isAvailableTelephony = !1;
|
|
561
581
|
}
|
|
562
|
-
|
|
563
|
-
|
|
582
|
+
static reset() {
|
|
583
|
+
o.resetStartError(), o.setAvailableTelephony();
|
|
564
584
|
}
|
|
565
|
-
|
|
566
|
-
this.
|
|
585
|
+
on(e, t) {
|
|
586
|
+
return this.events.on(e, t), this;
|
|
587
|
+
}
|
|
588
|
+
off(e, t) {
|
|
589
|
+
return this.events.off(e, t), this;
|
|
590
|
+
}
|
|
591
|
+
trigger(e, t) {
|
|
592
|
+
this.events.trigger(e, t);
|
|
567
593
|
}
|
|
568
594
|
/**
|
|
569
595
|
* terminateSessions
|
|
@@ -571,18 +597,10 @@ const c = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", j = "NAME_INCORRECT", m
|
|
|
571
597
|
* @returns {undefined}
|
|
572
598
|
*/
|
|
573
599
|
terminateSessions() {
|
|
574
|
-
this.session
|
|
600
|
+
this.session?.terminate();
|
|
575
601
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
*
|
|
579
|
-
* @param {string} key - key
|
|
580
|
-
* @param {string} value - value
|
|
581
|
-
*
|
|
582
|
-
* @returns {boolean} true
|
|
583
|
-
*/
|
|
584
|
-
set(t, e) {
|
|
585
|
-
return this.configuration[t] = e, !0;
|
|
602
|
+
set(e, t) {
|
|
603
|
+
return this.configuration[e] = t, !0;
|
|
586
604
|
}
|
|
587
605
|
/**
|
|
588
606
|
* register
|
|
@@ -590,15 +608,15 @@ const c = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", j = "NAME_INCORRECT", m
|
|
|
590
608
|
* @returns {undefined}
|
|
591
609
|
*/
|
|
592
610
|
register() {
|
|
593
|
-
this.
|
|
594
|
-
const { password:
|
|
595
|
-
|
|
596
|
-
this.trigger("registrationFailed", { response:
|
|
597
|
-
},
|
|
598
|
-
this.trigger("registered");
|
|
599
|
-
},
|
|
600
|
-
this.trigger("registrationFailed", { response:
|
|
601
|
-
},
|
|
611
|
+
this.startedTimeout && clearTimeout(this.startedTimeout);
|
|
612
|
+
const { password: e, register: t, uri: r } = this.configuration;
|
|
613
|
+
t === !0 && r.user.includes(G) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
|
|
614
|
+
this.trigger("registrationFailed", { response: T, cause: _.causes.REJECTED });
|
|
615
|
+
}, c)) : !this.isRegistered() && t === !0 && (e === d || e === v) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
|
|
616
|
+
this.trigger("registered", { response: M });
|
|
617
|
+
}, c)) : t === !0 && e !== d && e !== v && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
|
|
618
|
+
this.trigger("registrationFailed", { response: T, cause: _.causes.REJECTED });
|
|
619
|
+
}, c)), o.isAvailableTelephony ? (this.trigger("connected", { socket: g }), this.isConnectedInner = !0) : this.stop();
|
|
602
620
|
}
|
|
603
621
|
/**
|
|
604
622
|
* unregister
|
|
@@ -606,15 +624,13 @@ const c = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", j = "NAME_INCORRECT", m
|
|
|
606
624
|
* @returns {undefined}
|
|
607
625
|
*/
|
|
608
626
|
unregister() {
|
|
609
|
-
this.
|
|
627
|
+
this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: M });
|
|
610
628
|
}
|
|
611
|
-
/**
|
|
612
|
-
* isRegistered
|
|
613
|
-
*
|
|
614
|
-
* @returns {boolean} isRegistered
|
|
615
|
-
*/
|
|
616
629
|
isRegistered() {
|
|
617
|
-
return
|
|
630
|
+
return this.isRegisteredInner === !0;
|
|
631
|
+
}
|
|
632
|
+
isConnected() {
|
|
633
|
+
return this.isConnectedInner === !0;
|
|
618
634
|
}
|
|
619
635
|
/**
|
|
620
636
|
* isStarted
|
|
@@ -622,127 +638,131 @@ const c = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", j = "NAME_INCORRECT", m
|
|
|
622
638
|
* @returns {boolean} isStarted
|
|
623
639
|
*/
|
|
624
640
|
isStarted() {
|
|
625
|
-
return this.configuration
|
|
641
|
+
return this.configuration.register === !0 && this.isRegisteredInner === !0 || this.configuration.register !== !0 && this.isConnectedInner === !0;
|
|
626
642
|
}
|
|
627
|
-
|
|
628
|
-
|
|
643
|
+
newSipEvent(e) {
|
|
644
|
+
this.trigger("sipEvent", e);
|
|
629
645
|
}
|
|
630
|
-
|
|
631
|
-
this.
|
|
646
|
+
registrator() {
|
|
647
|
+
return this.registratorInner;
|
|
632
648
|
}
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
r(this, "url");
|
|
639
|
-
this.url = t;
|
|
649
|
+
}
|
|
650
|
+
class U {
|
|
651
|
+
url;
|
|
652
|
+
constructor(e) {
|
|
653
|
+
this.url = e;
|
|
640
654
|
}
|
|
641
655
|
}
|
|
642
|
-
class
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
this.contentType = e, this.body = n;
|
|
656
|
+
class B extends L {
|
|
657
|
+
contentType;
|
|
658
|
+
body;
|
|
659
|
+
constructor(e, t) {
|
|
660
|
+
super(), this.contentType = e, this.body = t;
|
|
648
661
|
}
|
|
649
662
|
}
|
|
650
|
-
const
|
|
651
|
-
const
|
|
652
|
-
originator:
|
|
653
|
-
request:
|
|
654
|
-
info: new
|
|
663
|
+
const E = "remote", K = (n, e) => {
|
|
664
|
+
const t = new w(e), r = {
|
|
665
|
+
originator: E,
|
|
666
|
+
request: t,
|
|
667
|
+
info: new B("", "")
|
|
655
668
|
};
|
|
656
|
-
|
|
657
|
-
},
|
|
658
|
-
const
|
|
659
|
-
|
|
660
|
-
},
|
|
661
|
-
incomingNumber:
|
|
662
|
-
displayName:
|
|
663
|
-
host:
|
|
669
|
+
n.newInfo(r);
|
|
670
|
+
}, X = (n, e) => {
|
|
671
|
+
const r = { event: "sipEvent", request: new w(e) };
|
|
672
|
+
n.newSipEvent(r);
|
|
673
|
+
}, Q = (n, {
|
|
674
|
+
incomingNumber: e = "1234",
|
|
675
|
+
displayName: t,
|
|
676
|
+
host: r
|
|
664
677
|
}) => {
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
678
|
+
const s = new i({ originator: E, eventHandlers: {} }), a = new D("sip", e, r);
|
|
679
|
+
s.remote_identity = new A(a, t);
|
|
680
|
+
const l = new w([]);
|
|
681
|
+
n.trigger("newRTCSession", {
|
|
682
|
+
originator: E,
|
|
683
|
+
session: s,
|
|
684
|
+
request: l
|
|
685
|
+
});
|
|
686
|
+
}, Z = (n, e) => {
|
|
687
|
+
e ? n.trigger("failed", e) : n.trigger("failed", n);
|
|
688
|
+
}, C = {
|
|
670
689
|
triggerNewInfo: K,
|
|
671
|
-
triggerNewSipEvent:
|
|
672
|
-
triggerIncomingSession:
|
|
673
|
-
triggerFailIncomingSession:
|
|
674
|
-
WebSocketInterface:
|
|
675
|
-
UA:
|
|
690
|
+
triggerNewSipEvent: X,
|
|
691
|
+
triggerIncomingSession: Q,
|
|
692
|
+
triggerFailIncomingSession: Z,
|
|
693
|
+
WebSocketInterface: U,
|
|
694
|
+
UA: o,
|
|
676
695
|
C: {
|
|
677
696
|
INVITE: "INVITE"
|
|
678
697
|
}
|
|
679
|
-
}, f = "user",
|
|
698
|
+
}, f = "user", m = "displayName", S = "SIP_SERVER_URL", y = "SIP_WEB_SOCKET_SERVER_URL", ee = new C.WebSocketInterface(y), I = {
|
|
680
699
|
userAgent: "Chrome",
|
|
681
700
|
sipServerUrl: S,
|
|
682
|
-
sipWebSocketServerURL:
|
|
701
|
+
sipWebSocketServerURL: y
|
|
683
702
|
}, me = {
|
|
684
|
-
...
|
|
685
|
-
},
|
|
686
|
-
...
|
|
703
|
+
...I
|
|
704
|
+
}, te = {
|
|
705
|
+
...I,
|
|
687
706
|
user: f,
|
|
688
|
-
password:
|
|
707
|
+
password: d,
|
|
689
708
|
register: !0
|
|
690
709
|
}, ue = {
|
|
691
|
-
...
|
|
692
|
-
displayName:
|
|
710
|
+
...te,
|
|
711
|
+
displayName: m
|
|
693
712
|
}, le = {
|
|
694
|
-
...
|
|
695
|
-
displayName:
|
|
713
|
+
...I,
|
|
714
|
+
displayName: m,
|
|
696
715
|
register: !1
|
|
697
|
-
},
|
|
716
|
+
}, u = {
|
|
698
717
|
session_timers: !1,
|
|
699
|
-
sockets: [
|
|
718
|
+
sockets: [ee],
|
|
700
719
|
user_agent: "Chrome",
|
|
701
|
-
|
|
720
|
+
sdpSemantics: "unified-plan",
|
|
702
721
|
register_expires: 300,
|
|
703
722
|
connection_recovery_max_interval: 6,
|
|
704
723
|
connection_recovery_min_interval: 2
|
|
705
|
-
},
|
|
706
|
-
...
|
|
707
|
-
password:
|
|
708
|
-
uri: new
|
|
724
|
+
}, pe = {
|
|
725
|
+
...u,
|
|
726
|
+
password: d,
|
|
727
|
+
uri: new h("sip", f, S),
|
|
709
728
|
display_name: "",
|
|
710
729
|
register: !0
|
|
711
|
-
},
|
|
712
|
-
...
|
|
713
|
-
password:
|
|
714
|
-
uri: new
|
|
715
|
-
display_name:
|
|
730
|
+
}, ge = {
|
|
731
|
+
...u,
|
|
732
|
+
password: d,
|
|
733
|
+
uri: new h("sip", f, S),
|
|
734
|
+
display_name: m,
|
|
716
735
|
register: !0
|
|
717
|
-
},
|
|
718
|
-
...
|
|
719
|
-
display_name:
|
|
736
|
+
}, Ee = {
|
|
737
|
+
...u,
|
|
738
|
+
display_name: m,
|
|
720
739
|
register: !1
|
|
721
740
|
}, we = {
|
|
722
|
-
...
|
|
741
|
+
...u,
|
|
723
742
|
display_name: "",
|
|
724
743
|
register: !1
|
|
725
|
-
},
|
|
726
|
-
JsSIP:
|
|
744
|
+
}, re = "10.10.10.10", fe = [`X-Vinteo-Remote: ${re}`], Se = () => new k({
|
|
745
|
+
JsSIP: C
|
|
727
746
|
});
|
|
728
747
|
export {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
748
|
+
q as FAILED_CONFERENCE_NUMBER,
|
|
749
|
+
C as JsSIP,
|
|
750
|
+
G as NAME_INCORRECT,
|
|
751
|
+
d as PASSWORD_CORRECT,
|
|
752
|
+
v as PASSWORD_CORRECT_2,
|
|
733
753
|
S as SIP_SERVER_URL,
|
|
734
|
-
|
|
735
|
-
|
|
754
|
+
y as SIP_WEB_SOCKET_SERVER_URL,
|
|
755
|
+
te as dataForConnectionWithAuthorization,
|
|
736
756
|
ue as dataForConnectionWithAuthorizationWithDisplayName,
|
|
737
757
|
le as dataForConnectionWithoutAuthorization,
|
|
738
758
|
me as dataForConnectionWithoutAuthorizationWithoutDisplayName,
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
759
|
+
m as displayName,
|
|
760
|
+
Se as doMockSipConnector,
|
|
761
|
+
fe as extraHeadersRemoteAddress,
|
|
762
|
+
re as remoteAddress,
|
|
763
|
+
pe as uaConfigurationWithAuthorization,
|
|
764
|
+
ge as uaConfigurationWithAuthorizationWithDisplayName,
|
|
765
|
+
Ee as uaConfigurationWithoutAuthorization,
|
|
746
766
|
we as uaConfigurationWithoutAuthorizationWithoutDisplayName,
|
|
747
767
|
f as user
|
|
748
768
|
};
|