@wazo/sdk 1.0.0-alpha.8 → 1.0.0-alpha.9
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/README.md +16 -7
- package/dist/wazo-sdk.js +2 -2
- package/esm/api/auth.js +3 -0
- package/esm/domain/CallLog.js +2 -3
- package/esm/domain/Phone/WebRTCPhone.js +29 -27
- package/esm/simple/Auth.js +13 -3
- package/esm/simple/Phone.js +2 -2
- package/esm/types/api/auth.d.ts +3 -0
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +3 -3
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +6 -1
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +2 -2
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/voice/call.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/utils/sdp.js +8 -7
- package/esm/voice/call.js +1 -2
- package/esm/web-rtc-client.js +23 -26
- package/lib/api/auth.js +3 -0
- package/lib/domain/CallLog.js +2 -3
- package/lib/domain/Phone/WebRTCPhone.js +29 -27
- package/lib/simple/Auth.js +15 -3
- package/lib/types/api/auth.d.ts +3 -0
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +3 -3
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +6 -1
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +2 -2
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/voice/call.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/utils/sdp.js +7 -6
- package/lib/voice/call.js +1 -2
- package/lib/web-rtc-client.js +22 -25
- package/package.json +1 -1
- package/src/api/auth.ts +5 -0
- package/src/domain/CallLog.ts +2 -3
- package/src/domain/Phone/WebRTCPhone.ts +33 -31
- package/src/simple/Auth.ts +15 -3
- package/src/simple/Phone.ts +3 -3
- package/src/utils/sdp.ts +9 -8
- package/src/voice/call.ts +2 -3
- package/src/web-rtc-client.ts +24 -25
|
@@ -8,7 +8,7 @@ import { Inviter, Invitation, Session, SessionDescriptionHandlerOptions } from '
|
|
|
8
8
|
import { SessionDescriptionHandler } from 'sip.js/lib/platform/web';
|
|
9
9
|
import CallSession from '../CallSession';
|
|
10
10
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
11
|
-
import
|
|
11
|
+
import WebRTCClient from '../../web-rtc-client';
|
|
12
12
|
import Emitter from '../../utils/Emitter';
|
|
13
13
|
import IssueReporter from '../../service/IssueReporter';
|
|
14
14
|
import { PeerConnection, WazoSession } from '../types';
|
|
@@ -64,7 +64,7 @@ const logger = IssueReporter.loggerFor('webrtc-phone');
|
|
|
64
64
|
|
|
65
65
|
// @deprecated: Use Wazo.Voice.Softphone instead
|
|
66
66
|
export default class WebRTCPhone extends Emitter implements Phone {
|
|
67
|
-
client:
|
|
67
|
+
client: WebRTCClient;
|
|
68
68
|
|
|
69
69
|
allowVideo: boolean;
|
|
70
70
|
|
|
@@ -98,7 +98,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
98
98
|
|
|
99
99
|
shouldSendReinvite: boolean;
|
|
100
100
|
|
|
101
|
-
constructor(client:
|
|
101
|
+
constructor(client: WebRTCClient, audioOutputDeviceId: string | undefined, allowVideo = false, audioRingDeviceId?: string) {
|
|
102
102
|
super();
|
|
103
103
|
this.client = client;
|
|
104
104
|
this.allowVideo = allowVideo;
|
|
@@ -163,7 +163,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
163
163
|
async sendReinvite(callSession?: CallSession, constraints: Record<string, any> | null | undefined = null, conference = false, audioOnly = false, iceRestart = false): Promise<OutgoingInviteRequest | void> {
|
|
164
164
|
const sipSession = this.findSipSession(callSession);
|
|
165
165
|
logger.info('WebRTC phone - send reinvite', {
|
|
166
|
-
sessionId: sipSession
|
|
166
|
+
sessionId: getSipCallId(sipSession),
|
|
167
167
|
constraints,
|
|
168
168
|
audioOnly,
|
|
169
169
|
conference,
|
|
@@ -384,7 +384,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
384
384
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
385
385
|
const callSession = this._createCallSession(sipSession);
|
|
386
386
|
|
|
387
|
-
|
|
387
|
+
if (sipSessionId) {
|
|
388
|
+
delete this.callSessions[sipSessionId];
|
|
389
|
+
}
|
|
388
390
|
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
389
391
|
};
|
|
390
392
|
}
|
|
@@ -393,7 +395,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
393
395
|
switch (newState) {
|
|
394
396
|
case SessionState.Terminating:
|
|
395
397
|
logger.info('WebRTC phone - call terminating', {
|
|
396
|
-
sipId: sipSession
|
|
398
|
+
sipId: getSipCallId(sipSession),
|
|
397
399
|
});
|
|
398
400
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
399
401
|
break;
|
|
@@ -401,7 +403,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
401
403
|
case SessionState.Terminated:
|
|
402
404
|
{
|
|
403
405
|
logger.info('WebRTC phone - call terminated', {
|
|
404
|
-
sipId: sipSession
|
|
406
|
+
sipId: getSipCallId(sipSession),
|
|
405
407
|
});
|
|
406
408
|
|
|
407
409
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
@@ -584,7 +586,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
584
586
|
|
|
585
587
|
_onCallAccepted(sipSession: WazoSession, cameraEnabled: boolean): CallSession {
|
|
586
588
|
logger.info('WebRTC phone - on call accepted', {
|
|
587
|
-
sipId: sipSession
|
|
589
|
+
sipId: getSipCallId(sipSession),
|
|
588
590
|
cameraEnabled,
|
|
589
591
|
});
|
|
590
592
|
|
|
@@ -592,7 +594,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
592
594
|
|
|
593
595
|
if (this.currentSipSession && !this.isCurrentCallSipSession(callSession)) {
|
|
594
596
|
logger.info('WebRTC phone - on call accepted with another ongoing call, holding it', {
|
|
595
|
-
sipId: sipSession
|
|
597
|
+
sipId: getSipCallId(sipSession),
|
|
596
598
|
cameraEnabled,
|
|
597
599
|
});
|
|
598
600
|
|
|
@@ -677,7 +679,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
677
679
|
const sipSessionId = getSipCallId(sipSession);
|
|
678
680
|
|
|
679
681
|
logger.info('WebRTC phone - on call terminated', {
|
|
680
|
-
sipId: sipSession
|
|
682
|
+
sipId: getSipCallId(sipSession),
|
|
681
683
|
sipSessionId,
|
|
682
684
|
ids: Object.keys(this.callSessions),
|
|
683
685
|
});
|
|
@@ -701,9 +703,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
701
703
|
|
|
702
704
|
if (sipSessionId) {
|
|
703
705
|
this.removeIncomingSessions(sipSessionId);
|
|
704
|
-
}
|
|
705
706
|
|
|
706
|
-
|
|
707
|
+
delete this.callSessions[sipSessionId];
|
|
708
|
+
}
|
|
707
709
|
|
|
708
710
|
if (isCurrentSession) {
|
|
709
711
|
this.currentSipSession = undefined;
|
|
@@ -713,7 +715,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
713
715
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
714
716
|
// Re-trigger incoming call event for remaining incoming calls
|
|
715
717
|
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
716
|
-
sipId: sipSession
|
|
718
|
+
sipId: getSipCallId(sipSession),
|
|
717
719
|
shouldRetrigger,
|
|
718
720
|
hasIncomingCallSession,
|
|
719
721
|
});
|
|
@@ -857,7 +859,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
857
859
|
const sipSession = this.client.getSipSession(callSession.getId()) as Invitation;
|
|
858
860
|
|
|
859
861
|
if (sipSession) {
|
|
860
|
-
logger.info('accept call, session found', { sipId: sipSession
|
|
862
|
+
logger.info('accept call, session found', { sipId: getSipCallId(sipSession) });
|
|
861
863
|
|
|
862
864
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
863
865
|
return callSession.sipCallId;
|
|
@@ -902,7 +904,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
902
904
|
|
|
903
905
|
if (sipSession) {
|
|
904
906
|
logger.info('WebRTC rejecting', {
|
|
905
|
-
sipId: sipSession
|
|
907
|
+
sipId: getSipCallId(sipSession),
|
|
906
908
|
});
|
|
907
909
|
this.client.hangup(sipSession);
|
|
908
910
|
}
|
|
@@ -923,7 +925,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
923
925
|
|
|
924
926
|
if (sipSession) {
|
|
925
927
|
logger.info('WebRTC atxfer', {
|
|
926
|
-
sipId: sipSession
|
|
928
|
+
sipId: getSipCallId(sipSession),
|
|
927
929
|
});
|
|
928
930
|
return this.client.atxfer(sipSession);
|
|
929
931
|
}
|
|
@@ -954,13 +956,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
954
956
|
}
|
|
955
957
|
|
|
956
958
|
logger.info('WebRTC resuming', {
|
|
957
|
-
sipId: sipSession
|
|
959
|
+
sipId: getSipCallId(sipSession),
|
|
958
960
|
});
|
|
959
961
|
|
|
960
962
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
961
|
-
if (this.currentSipSession && this.currentSipSession
|
|
963
|
+
if (this.currentSipSession && getSipCallId(this.currentSipSession) !== getSipCallId(sipSession)) {
|
|
962
964
|
logger.info('WebRTC hold call after resume', {
|
|
963
|
-
id: this.currentSipSession
|
|
965
|
+
id: getSipCallId(this.currentSipSession),
|
|
964
966
|
});
|
|
965
967
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, withEvent);
|
|
966
968
|
}
|
|
@@ -983,7 +985,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
983
985
|
const sessionId = getSipCallId(sipSession);
|
|
984
986
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
985
987
|
logger.info('WebRTC hold sip session', {
|
|
986
|
-
sipId: sipSession
|
|
988
|
+
sipId: getSipCallId(sipSession),
|
|
987
989
|
hasVideo,
|
|
988
990
|
});
|
|
989
991
|
|
|
@@ -1080,7 +1082,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1080
1082
|
}
|
|
1081
1083
|
|
|
1082
1084
|
logger.info('WebRTC muting', {
|
|
1083
|
-
sipId: sipSession
|
|
1085
|
+
sipId: getSipCallId(sipSession),
|
|
1084
1086
|
});
|
|
1085
1087
|
this.client.mute(sipSession);
|
|
1086
1088
|
|
|
@@ -1108,7 +1110,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1108
1110
|
}
|
|
1109
1111
|
|
|
1110
1112
|
logger.info('WebRTC unmuting', {
|
|
1111
|
-
sipId: sipSession
|
|
1113
|
+
sipId: getSipCallId(sipSession),
|
|
1112
1114
|
});
|
|
1113
1115
|
this.client.unmute(sipSession);
|
|
1114
1116
|
|
|
@@ -1143,7 +1145,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1143
1145
|
}
|
|
1144
1146
|
|
|
1145
1147
|
logger.info('WebRTC turn camera on', {
|
|
1146
|
-
sipId: sipSession
|
|
1148
|
+
sipId: getSipCallId(sipSession),
|
|
1147
1149
|
});
|
|
1148
1150
|
this.client.toggleCameraOn(sipSession);
|
|
1149
1151
|
this.eventEmitter.emit(ON_CAMERA_RESUMED, this._createCameraResumedCallSession(sipSession, callSession));
|
|
@@ -1157,7 +1159,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1157
1159
|
}
|
|
1158
1160
|
|
|
1159
1161
|
logger.info('WebRTC turn camera off', {
|
|
1160
|
-
sipId: sipSession
|
|
1162
|
+
sipId: getSipCallId(sipSession),
|
|
1161
1163
|
});
|
|
1162
1164
|
this.client.toggleCameraOff(sipSession);
|
|
1163
1165
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -1171,7 +1173,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1171
1173
|
}
|
|
1172
1174
|
|
|
1173
1175
|
logger.info('WebRTC send key', {
|
|
1174
|
-
sipId: sipSession
|
|
1176
|
+
sipId: getSipCallId(sipSession),
|
|
1175
1177
|
tone,
|
|
1176
1178
|
});
|
|
1177
1179
|
this.client.sendDTMF(sipSession, tone);
|
|
@@ -1249,7 +1251,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1249
1251
|
}
|
|
1250
1252
|
|
|
1251
1253
|
logger.info('WebRTC transfer', {
|
|
1252
|
-
sipId: sipSession
|
|
1254
|
+
sipId: getSipCallId(sipSession),
|
|
1253
1255
|
target,
|
|
1254
1256
|
});
|
|
1255
1257
|
this.client.transfer(sipSession, target);
|
|
@@ -1259,8 +1261,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1259
1261
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
1260
1262
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
1261
1263
|
logger.info('WebRTC indirect transfer', {
|
|
1262
|
-
sipId: sipSession ? sipSession
|
|
1263
|
-
target: sipSessionTarget ? sipSessionTarget
|
|
1264
|
+
sipId: sipSession ? getSipCallId(sipSession) : null,
|
|
1265
|
+
target: sipSessionTarget ? getSipCallId(sipSessionTarget) : null,
|
|
1264
1266
|
});
|
|
1265
1267
|
|
|
1266
1268
|
if (!sipSessionTarget) {
|
|
@@ -1299,7 +1301,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1299
1301
|
const sipSessionId = getSipCallId(sipSession);
|
|
1300
1302
|
|
|
1301
1303
|
logger.info('WebRTC hangup', {
|
|
1302
|
-
sipId: sipSession
|
|
1304
|
+
sipId: getSipCallId(sipSession),
|
|
1303
1305
|
sipSessionId,
|
|
1304
1306
|
});
|
|
1305
1307
|
await this.client.hangup(sipSession);
|
|
@@ -1488,7 +1490,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1488
1490
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
1489
1491
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
1490
1492
|
logger.info('WebRTC invite received', {
|
|
1491
|
-
sipId: sipSession
|
|
1493
|
+
sipId: getSipCallId(sipSession),
|
|
1492
1494
|
withVideo,
|
|
1493
1495
|
autoAnswer,
|
|
1494
1496
|
});
|
|
@@ -1559,7 +1561,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1559
1561
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
1560
1562
|
});
|
|
1561
1563
|
this.client.on(this.client.REJECTED, session => {
|
|
1562
|
-
logger.info('WebRTC call rejected', session
|
|
1564
|
+
logger.info('WebRTC call rejected', { id: getSipCallId(session) });
|
|
1563
1565
|
|
|
1564
1566
|
const callSession = this._createCallSession(session);
|
|
1565
1567
|
|
package/src/simple/Auth.ts
CHANGED
|
@@ -167,6 +167,10 @@ export class Auth {
|
|
|
167
167
|
return this._onAuthenticated(rawSession as Session);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
async samlLogOut(): Promise<void | { location: string }> {
|
|
171
|
+
return await this.logout(false, true);
|
|
172
|
+
}
|
|
173
|
+
|
|
170
174
|
async initiateIdpAuthentication(domain: string, redirectUrl: string): Promise<{ location: string, saml_session_id: string } | undefined> {
|
|
171
175
|
try {
|
|
172
176
|
return await getApiClient().auth.initiateIdpAuthentication(domain, redirectUrl);
|
|
@@ -218,20 +222,26 @@ export class Auth {
|
|
|
218
222
|
return getApiClient().auth.refreshToken(refreshToken, '', this.expiration);
|
|
219
223
|
}
|
|
220
224
|
|
|
221
|
-
async logout(deleteRefreshToken = true): Promise<void> {
|
|
225
|
+
async logout(deleteRefreshToken = true, saml = false): Promise<void | { location: string }> {
|
|
222
226
|
try {
|
|
223
227
|
Wazo.Websocket.close(true);
|
|
224
228
|
|
|
225
|
-
if (this.clientId && deleteRefreshToken) {
|
|
229
|
+
if (!saml && this.clientId && deleteRefreshToken) {
|
|
226
230
|
await getApiClient().auth.deleteRefreshToken(this.clientId);
|
|
227
231
|
}
|
|
228
232
|
} catch (e: any) {
|
|
229
233
|
// Nothing to
|
|
230
234
|
}
|
|
231
235
|
|
|
236
|
+
let response;
|
|
237
|
+
|
|
232
238
|
try {
|
|
233
239
|
if (this.session?.token) {
|
|
234
|
-
|
|
240
|
+
if (saml) {
|
|
241
|
+
response = await getApiClient().auth.samlLogOut();
|
|
242
|
+
} else {
|
|
243
|
+
await getApiClient().auth.logOut(this.session.token);
|
|
244
|
+
}
|
|
235
245
|
}
|
|
236
246
|
} catch (e: any) {
|
|
237
247
|
// Nothing to
|
|
@@ -243,6 +253,8 @@ export class Auth {
|
|
|
243
253
|
this.authenticated = false;
|
|
244
254
|
this.usingEdgeServer = undefined;
|
|
245
255
|
setFetchOptions({});
|
|
256
|
+
|
|
257
|
+
return response;
|
|
246
258
|
}
|
|
247
259
|
|
|
248
260
|
setOnHostFromHeaders(callback: (hostFromHeaders: string) => void) {
|
package/src/simple/Phone.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type CallSession from '../domain/CallSession';
|
|
|
6
6
|
import AdHocAPIConference from '../domain/AdHocAPIConference';
|
|
7
7
|
import WebRTCPhone, * as PHONE_EVENTS from '../domain/Phone/WebRTCPhone';
|
|
8
8
|
import { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL } from '../domain/Phone/WebRTCPhone';
|
|
9
|
-
import
|
|
9
|
+
import WebRTCClient, { events as clientEvents, transportEvents } from '../web-rtc-client';
|
|
10
10
|
import IssueReporter from '../service/IssueReporter';
|
|
11
11
|
import Emitter from '../utils/Emitter';
|
|
12
12
|
import Wazo from './index';
|
|
@@ -21,7 +21,7 @@ const protocolDebugMessages = ['Received WebSocket text message:', 'Sending WebS
|
|
|
21
21
|
|
|
22
22
|
// @deprecated: Use Wazo.Voice.Softphone instead
|
|
23
23
|
export class Phone extends Emitter {
|
|
24
|
-
client:
|
|
24
|
+
client: WebRTCClient;
|
|
25
25
|
|
|
26
26
|
phone: WebRTCPhone | null | undefined;
|
|
27
27
|
|
|
@@ -188,7 +188,7 @@ export class Phone extends Emitter {
|
|
|
188
188
|
options.log.connector = this._logConnector;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
this.client = new
|
|
191
|
+
this.client = new WebRTCClient({
|
|
192
192
|
host,
|
|
193
193
|
port: typeof port === 'string' ? parseInt(port, 10) : port,
|
|
194
194
|
displayName,
|
package/src/utils/sdp.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
import sdpParser from 'sdp-transform';
|
|
3
3
|
import { UserAgent } from 'sip.js/lib/api/user-agent';
|
|
4
|
-
import { Inviter } from 'sip.js/lib/api';
|
|
4
|
+
import { Inviter, Invitation } from 'sip.js/lib/api';
|
|
5
5
|
import { URI } from 'sip.js/lib/grammar/uri';
|
|
6
6
|
|
|
7
7
|
import type { SipCall } from '../domain/types';
|
|
@@ -152,20 +152,21 @@ export const getSipCallId = (sipSession: SipCall | null | undefined): string =>
|
|
|
152
152
|
return '';
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
const message = sipSession.message as Partial<{ callId?: string }>;
|
|
156
|
-
if (message?.callId) {
|
|
157
|
-
return message.callId.substring(0, SIP_ID_MIN_LENGTH);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
155
|
// For Inviter
|
|
161
156
|
// @ts-ignore: private
|
|
162
157
|
if (sipSession instanceof Inviter && sipSession.outgoingRequestMessage) {
|
|
163
158
|
// @ts-ignore: private
|
|
164
|
-
return sipSession.outgoingRequestMessage.callId
|
|
159
|
+
return sipSession.outgoingRequestMessage.callId;
|
|
165
160
|
}
|
|
166
161
|
|
|
167
162
|
// For Invitation
|
|
168
|
-
|
|
163
|
+
// @ts-ignore: private
|
|
164
|
+
if (sipSession instanceof Invitation && sipSession.incomingInviteRequest.message) {
|
|
165
|
+
// @ts-ignore: private
|
|
166
|
+
return sipSession.incomingInviteRequest.message.callId;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return sipSession.id;
|
|
169
170
|
};
|
|
170
171
|
|
|
171
172
|
// We need to replace 0.0.0.0 to 127.0.0.1 in the sdp to avoid MOH during a createOffer.
|
package/src/voice/call.ts
CHANGED
|
@@ -116,7 +116,6 @@ class Call extends EventEmitter {
|
|
|
116
116
|
} as any;
|
|
117
117
|
|
|
118
118
|
const call = new Call(sipCall, softphone);
|
|
119
|
-
// call._sendAction(Actions.ES);
|
|
120
119
|
call.apiId = apiCall.id;
|
|
121
120
|
call.answerTime = new Date(+apiCall.startingTime);
|
|
122
121
|
|
|
@@ -158,8 +157,6 @@ class Call extends EventEmitter {
|
|
|
158
157
|
|
|
159
158
|
this.number = getCallNumber(sipCall);
|
|
160
159
|
this.displayName = getCallDisplayName(sipCall);
|
|
161
|
-
|
|
162
|
-
this._bindEvents();
|
|
163
160
|
}
|
|
164
161
|
|
|
165
162
|
async accept(options: AcceptOptions = {}): Promise<string | null> {
|
|
@@ -551,6 +548,8 @@ class Call extends EventEmitter {
|
|
|
551
548
|
}
|
|
552
549
|
|
|
553
550
|
onMakeCall() {
|
|
551
|
+
this._bindEvents();
|
|
552
|
+
|
|
554
553
|
this._sendAction(Actions.MAKE_CALL);
|
|
555
554
|
}
|
|
556
555
|
|
package/src/web-rtc-client.ts
CHANGED
|
@@ -245,7 +245,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
245
245
|
logger.info('sdk webrtc on invite', {
|
|
246
246
|
method: 'delegate.onInvite',
|
|
247
247
|
clientId: this.clientId,
|
|
248
|
-
id: invitation
|
|
248
|
+
id: getSipCallId(invitation),
|
|
249
249
|
remoteURI: (invitation as any).remoteURI,
|
|
250
250
|
});
|
|
251
251
|
|
|
@@ -583,7 +583,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
583
583
|
},
|
|
584
584
|
onReject: (response: IncomingResponse) => {
|
|
585
585
|
logger.info('on call rejected', {
|
|
586
|
-
id: session
|
|
586
|
+
id: getSipCallId(session),
|
|
587
587
|
// @ts-ignore: fromTag does not exist
|
|
588
588
|
fromTag: session?.fromTag,
|
|
589
589
|
});
|
|
@@ -620,7 +620,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
620
620
|
answer(session: Invitation, enableVideo?: boolean): Promise<void> {
|
|
621
621
|
logger.info('sdk webrtc answer call', {
|
|
622
622
|
clientId: this.clientId,
|
|
623
|
-
id: session
|
|
623
|
+
id: getSipCallId(session),
|
|
624
624
|
enableVideo,
|
|
625
625
|
});
|
|
626
626
|
|
|
@@ -638,7 +638,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
638
638
|
if (session.isCanceled) {
|
|
639
639
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
640
640
|
logger.error(message, {
|
|
641
|
-
id: session
|
|
641
|
+
id: getSipCallId(session),
|
|
642
642
|
});
|
|
643
643
|
this.onCallEnded(session);
|
|
644
644
|
throw new CanceledCallError(message);
|
|
@@ -648,7 +648,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
648
648
|
|
|
649
649
|
this._onAccepted(session);
|
|
650
650
|
}).catch(e => {
|
|
651
|
-
logger.error(`answer call error for ${session
|
|
651
|
+
logger.error(`answer call error for ${getSipCallId(session)}`, e);
|
|
652
652
|
throw e;
|
|
653
653
|
});
|
|
654
654
|
}
|
|
@@ -716,7 +716,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
716
716
|
async reject(session: WazoSession): Promise<void> {
|
|
717
717
|
logger.info('sdk webrtc reject call', {
|
|
718
718
|
clientId: this.clientId,
|
|
719
|
-
id: session
|
|
719
|
+
id: getSipCallId(session),
|
|
720
720
|
});
|
|
721
721
|
|
|
722
722
|
try {
|
|
@@ -779,7 +779,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
779
779
|
|
|
780
780
|
mute(session: WazoSession): void {
|
|
781
781
|
logger.info('sdk webrtc mute', {
|
|
782
|
-
id: session
|
|
782
|
+
id: getSipCallId(session),
|
|
783
783
|
});
|
|
784
784
|
|
|
785
785
|
toggleAudio(session, true);
|
|
@@ -787,7 +787,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
787
787
|
|
|
788
788
|
unmute(session: WazoSession): void {
|
|
789
789
|
logger.info('sdk webrtc unmute', {
|
|
790
|
-
id: session
|
|
790
|
+
id: getSipCallId(session),
|
|
791
791
|
});
|
|
792
792
|
|
|
793
793
|
toggleAudio(session, false);
|
|
@@ -832,7 +832,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
832
832
|
|
|
833
833
|
toggleCameraOn(session: WazoSession): void {
|
|
834
834
|
logger.info('sdk webrtc toggle camera on', {
|
|
835
|
-
id: session
|
|
835
|
+
id: getSipCallId(session),
|
|
836
836
|
});
|
|
837
837
|
|
|
838
838
|
toggleVideo(session, false);
|
|
@@ -840,7 +840,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
840
840
|
|
|
841
841
|
toggleCameraOff(session: WazoSession): void {
|
|
842
842
|
logger.info('sdk webrtc toggle camera off', {
|
|
843
|
-
id: session
|
|
843
|
+
id: getSipCallId(session),
|
|
844
844
|
});
|
|
845
845
|
|
|
846
846
|
toggleVideo(session, true);
|
|
@@ -1041,7 +1041,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
1043
|
logger.info('send WebRTC message', {
|
|
1044
|
-
sipId: sipSession
|
|
1044
|
+
sipId: getSipCallId(sipSession),
|
|
1045
1045
|
contentType,
|
|
1046
1046
|
});
|
|
1047
1047
|
|
|
@@ -1498,7 +1498,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1498
1498
|
}
|
|
1499
1499
|
|
|
1500
1500
|
getSipSession(id: string): WazoSession | null | undefined {
|
|
1501
|
-
return id in this.sipSessions ? this.sipSessions[id
|
|
1501
|
+
return id in this.sipSessions ? this.sipSessions[id] : null;
|
|
1502
1502
|
}
|
|
1503
1503
|
|
|
1504
1504
|
getSipCallIds(): string[] {
|
|
@@ -1769,18 +1769,17 @@ export default class WebRTCClient extends Emitter {
|
|
|
1769
1769
|
async _onProgress(session: WazoSession, early = false): Promise<void> {
|
|
1770
1770
|
await this._setupMedias(session);
|
|
1771
1771
|
|
|
1772
|
-
const sessionId = getSipCallId(session)
|
|
1772
|
+
const sessionId = getSipCallId(session);
|
|
1773
|
+
|
|
1773
1774
|
updateRemoteStream(session);
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
early,
|
|
1777
|
-
});
|
|
1775
|
+
|
|
1776
|
+
logger.info('progress received', { sessionId, early });
|
|
1778
1777
|
this.eventEmitter.emit(early ? ON_EARLY_MEDIA : ON_PROGRESS, session);
|
|
1779
1778
|
}
|
|
1780
1779
|
|
|
1781
1780
|
async _onAccepted(session: WazoSession, sessionDialog?: SessionDialog, withEvent = true, initAllTracks = true): Promise<void> {
|
|
1782
1781
|
logger.info('on call accepted', {
|
|
1783
|
-
id: session
|
|
1782
|
+
id: getSipCallId(session),
|
|
1784
1783
|
clientId: this.clientId,
|
|
1785
1784
|
remoteTag: session.remoteTag,
|
|
1786
1785
|
});
|
|
@@ -2018,20 +2017,20 @@ export default class WebRTCClient extends Emitter {
|
|
|
2018
2017
|
async _accept(session: Invitation, options: InvitationAcceptOptions = {}) {
|
|
2019
2018
|
if (session.state === SessionState.Terminated || session.state === SessionState.Terminating) {
|
|
2020
2019
|
const error = 'Trying to accept a terminated sipSession.';
|
|
2021
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2020
|
+
logger.warn(error, { state: session.state, sessionId: getSipCallId(session) });
|
|
2022
2021
|
throw new Error(error);
|
|
2023
2022
|
}
|
|
2024
2023
|
|
|
2025
2024
|
if (session.state !== SessionState.Initial) {
|
|
2026
2025
|
const error = 'Trying to accept a non Initial sipSession.';
|
|
2027
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2026
|
+
logger.warn(error, { state: session.state, sessionId: getSipCallId(session) });
|
|
2028
2027
|
throw new Error(error);
|
|
2029
2028
|
}
|
|
2030
2029
|
|
|
2031
2030
|
// @ts-ignore: private
|
|
2032
2031
|
if (!session.incomingInviteRequest.acceptable) {
|
|
2033
2032
|
const error = 'Trying to reject a non `acceptable` session';
|
|
2034
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2033
|
+
logger.warn(error, { state: session.state, sessionId: getSipCallId(session) });
|
|
2035
2034
|
throw new Error(error);
|
|
2036
2035
|
}
|
|
2037
2036
|
|
|
@@ -2044,13 +2043,13 @@ export default class WebRTCClient extends Emitter {
|
|
|
2044
2043
|
|
|
2045
2044
|
async _reject(session: Invitation, options: InvitationRejectOptions = {}) {
|
|
2046
2045
|
if (session.state !== SessionState.Initial && session.state !== SessionState.Establishing) {
|
|
2047
|
-
logger.warn('Trying to reject a session in a wrong state', { state: session.state, sessionId: session
|
|
2046
|
+
logger.warn('Trying to reject a session in a wrong state', { state: session.state, sessionId: getSipCallId(session) });
|
|
2048
2047
|
return;
|
|
2049
2048
|
}
|
|
2050
2049
|
|
|
2051
2050
|
// @ts-ignore: private
|
|
2052
2051
|
if (!session.incomingInviteRequest.rejectable) {
|
|
2053
|
-
logger.warn('Trying to reject a non `rejectable` session', { state: session.state, sessionId: session
|
|
2052
|
+
logger.warn('Trying to reject a non `rejectable` session', { state: session.state, sessionId: getSipCallId(session) });
|
|
2054
2053
|
return;
|
|
2055
2054
|
}
|
|
2056
2055
|
|
|
@@ -2063,7 +2062,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2063
2062
|
|
|
2064
2063
|
async _cancel(session: Inviter, options: InviterCancelOptions = {}) {
|
|
2065
2064
|
if (session.state !== SessionState.Initial && session.state !== SessionState.Establishing) {
|
|
2066
|
-
logger.warn('Trying to cancel a session in a wrong state', { state: session.state, sessionId: session
|
|
2065
|
+
logger.warn('Trying to cancel a session in a wrong state', { state: session.state, sessionId: getSipCallId(session) });
|
|
2067
2066
|
return;
|
|
2068
2067
|
}
|
|
2069
2068
|
|
|
@@ -2076,7 +2075,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2076
2075
|
|
|
2077
2076
|
async _bye(session: WazoSession, options: SessionByeOptions = {}) {
|
|
2078
2077
|
if (session.state !== SessionState.Established) {
|
|
2079
|
-
logger.warn('Trying to end a session in a wrong state', { state: session.state, sessionId: session
|
|
2078
|
+
logger.warn('Trying to end a session in a wrong state', { state: session.state, sessionId: getSipCallId(session) });
|
|
2080
2079
|
return null;
|
|
2081
2080
|
}
|
|
2082
2081
|
|