@wazo/sdk 0.37.0 → 0.37.4
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/wazo-sdk.js +5 -5
- package/esm/__tests__/api-client.test.js +91 -23
- package/esm/__tests__/web-rtc-client.test.js +165 -56
- package/esm/api/agentd.js +7 -1
- package/esm/api/amid.js +7 -1
- package/esm/api/application.js +7 -1
- package/esm/api/auth.js +7 -1
- package/esm/api/call-logd.js +17 -23
- package/esm/api/calld.js +10 -18
- package/esm/api/chatd.js +7 -1
- package/esm/api/confd.js +78 -1
- package/esm/api/ctid-ng.js +7 -1
- package/esm/api/dird.js +7 -1
- package/esm/api/webhookd.js +7 -1
- package/esm/api-client.js +91 -23
- package/esm/checker/Checker.js +169 -56
- package/esm/checker/checks/aor.js +91 -23
- package/esm/checker/checks/api.js +91 -23
- package/esm/checker/checks/index.js +169 -56
- package/esm/checker/checks/wazo-websocket.js +11 -1
- package/esm/checker/checks/webrtc-transport.js +165 -56
- package/esm/checker/checks/webrtc.js +165 -56
- package/esm/domain/AdHocAPIConference.js +1722 -1654
- package/esm/domain/CallLog.js +10 -22
- package/esm/domain/CallSession.js +1 -18
- package/esm/domain/Features.js +91 -23
- package/esm/domain/IndirectTransfer.js +0 -17
- package/esm/domain/Meeting.js +71 -0
- package/esm/domain/Phone/CTIPhone.js +98 -26
- package/esm/domain/Phone/Phone.js +0 -17
- package/esm/domain/Phone/WebRTCPhone.js +47 -27
- package/esm/domain/Room.js +0 -17
- package/esm/domain/SwitchboardCall.js +0 -17
- package/esm/domain/__tests__/CallLog.test.js +10 -22
- package/esm/domain/__tests__/CallSession.test.js +1 -18
- package/esm/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/esm/domain/__tests__/Room.test.js +1 -18
- package/esm/index.js +3880 -3111
- package/esm/lib/WazoSessionDescriptionHandler.js +24 -10
- package/esm/service/CallApi.js +91 -23
- package/esm/service/IssueReporter.js +7 -1
- package/esm/service/__tests__/IssueReporter.test.js +9 -1
- package/esm/service/getApiClient.js +91 -23
- package/esm/simple/Auth.js +1126 -360
- package/esm/simple/Configuration.js +1126 -360
- package/esm/simple/Directory.js +91 -23
- package/esm/simple/Phone.js +3724 -2958
- package/esm/simple/Websocket.js +13 -1
- package/esm/simple/index.js +1128 -362
- package/esm/simple/room/LocalParticipant.js +1097 -331
- package/esm/simple/room/Participant.js +1097 -331
- package/esm/simple/room/RemoteParticipant.js +1097 -331
- package/esm/simple/room/Room.js +1097 -331
- package/esm/simple/room/SipRoom.js +12996 -0
- package/esm/simple/room/Stream.js +1128 -362
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
- package/esm/simple/utils.js +1128 -362
- package/esm/utils/__tests__/api-requester.test.js +7 -1
- package/esm/utils/api-requester.js +7 -1
- package/esm/web-rtc-client.js +165 -56
- package/esm/websocket-client.js +12 -2
- package/lib/__tests__/api-client.test.js +91 -23
- package/lib/__tests__/web-rtc-client.test.js +165 -56
- package/lib/api/agentd.js +7 -1
- package/lib/api/amid.js +7 -1
- package/lib/api/application.js +7 -1
- package/lib/api/auth.js +7 -1
- package/lib/api/call-logd.js +17 -23
- package/lib/api/calld.js +10 -18
- package/lib/api/chatd.js +7 -1
- package/lib/api/confd.js +78 -1
- package/lib/api/ctid-ng.js +7 -1
- package/lib/api/dird.js +7 -1
- package/lib/api/webhookd.js +7 -1
- package/lib/api-client.js +91 -23
- package/lib/checker/Checker.js +169 -56
- package/lib/checker/checks/aor.js +91 -23
- package/lib/checker/checks/api.js +91 -23
- package/lib/checker/checks/index.js +169 -56
- package/lib/checker/checks/wazo-websocket.js +11 -1
- package/lib/checker/checks/webrtc-transport.js +165 -56
- package/lib/checker/checks/webrtc.js +165 -56
- package/lib/domain/AdHocAPIConference.js +1722 -1654
- package/lib/domain/CallLog.js +10 -22
- package/lib/domain/CallSession.js +1 -18
- package/lib/domain/Features.js +91 -23
- package/lib/domain/IndirectTransfer.js +0 -17
- package/lib/domain/Meeting.js +73 -0
- package/lib/domain/Phone/CTIPhone.js +98 -26
- package/lib/domain/Phone/Phone.js +0 -16
- package/lib/domain/Phone/WebRTCPhone.js +47 -27
- package/lib/domain/Room.js +0 -17
- package/lib/domain/SwitchboardCall.js +0 -17
- package/lib/domain/__tests__/CallLog.test.js +10 -22
- package/lib/domain/__tests__/CallSession.test.js +1 -18
- package/lib/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/lib/domain/__tests__/Room.test.js +1 -18
- package/lib/index.js +3880 -3111
- package/lib/lib/WazoSessionDescriptionHandler.js +24 -10
- package/lib/service/CallApi.js +91 -23
- package/lib/service/IssueReporter.js +7 -1
- package/lib/service/__tests__/IssueReporter.test.js +9 -1
- package/lib/service/getApiClient.js +91 -23
- package/lib/simple/Auth.js +1126 -360
- package/lib/simple/Configuration.js +1126 -360
- package/lib/simple/Directory.js +91 -23
- package/lib/simple/Phone.js +3724 -2958
- package/lib/simple/Websocket.js +13 -1
- package/lib/simple/index.js +1128 -362
- package/lib/simple/room/LocalParticipant.js +1097 -331
- package/lib/simple/room/Participant.js +1097 -331
- package/lib/simple/room/RemoteParticipant.js +1097 -331
- package/lib/simple/room/Room.js +1097 -331
- package/lib/simple/room/SipRoom.js +13006 -0
- package/lib/simple/room/Stream.js +1128 -362
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
- package/lib/simple/utils.js +1128 -362
- package/lib/utils/__tests__/api-requester.test.js +7 -1
- package/lib/utils/api-requester.js +7 -1
- package/lib/web-rtc-client.js +165 -56
- package/lib/websocket-client.js +13 -1
- package/package.json +1 -1
- package/src/api/calld.js +3 -0
- package/src/api/confd.js +13 -0
- package/src/domain/CallLog.js +10 -22
- package/src/domain/CallSession.js +1 -2
- package/src/domain/Meeting.js +59 -0
- package/src/domain/Phone/CTIPhone.js +6 -2
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +22 -8
- package/src/index.js +6 -0
- package/src/lib/WazoSessionDescriptionHandler.js +17 -9
- package/src/service/IssueReporter.js +7 -1
- package/src/service/__tests__/IssueReporter.test.js +2 -0
- package/src/simple/Phone.js +13 -4
- package/src/simple/index.js +8 -0
- package/src/simple/room/Participant.js +7 -0
- package/src/simple/room/Room.js +157 -79
- package/src/simple/room/SipRoom.js +147 -0
- package/src/simple/room/Stream.js +1 -3
- package/src/simple/room/__tests__/RemoteParticipant.test.js +3 -2
- package/src/types/WebSocketMessage.js +21 -0
- package/src/web-rtc-client.js +57 -24
- package/src/websocket-client.js +4 -0
package/src/web-rtc-client.js
CHANGED
|
@@ -96,6 +96,7 @@ type WebRtcConfig = {
|
|
|
96
96
|
heartbeatDelay: number,
|
|
97
97
|
heartbeatTimeout: number,
|
|
98
98
|
maxHeartbeats: number,
|
|
99
|
+
skipRegister: boolean,
|
|
99
100
|
};
|
|
100
101
|
|
|
101
102
|
// @see https://github.com/onsip/SIP.js/blob/master/src/Web/Simple.js
|
|
@@ -121,6 +122,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
121
122
|
statsIntervals: Object;
|
|
122
123
|
sipSessions: { [string]: Session };
|
|
123
124
|
conferences: { [string]: boolean };
|
|
125
|
+
skipRegister: boolean;
|
|
124
126
|
|
|
125
127
|
// sugar
|
|
126
128
|
ON_USER_AGENT: string;
|
|
@@ -159,6 +161,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
159
161
|
super();
|
|
160
162
|
this.uaConfigOverrides = uaConfigOverrides;
|
|
161
163
|
this.config = config;
|
|
164
|
+
this.skipRegister = config.skipRegister;
|
|
165
|
+
|
|
162
166
|
this._buildConfig(config, session).then((newConfig: WebRtcConfig) => {
|
|
163
167
|
this.config = newConfig;
|
|
164
168
|
this.userAgent = this.createUserAgent(uaConfigOverrides);
|
|
@@ -286,14 +290,22 @@ export default class WebRTCClient extends Emitter {
|
|
|
286
290
|
}
|
|
287
291
|
|
|
288
292
|
register(tries: number = 0): Promise<any> {
|
|
289
|
-
|
|
293
|
+
const logInfo = {
|
|
290
294
|
userAgent: !!this.userAgent,
|
|
291
295
|
registered: this.isRegistered(),
|
|
292
296
|
connectionPromise: !!this.connectionPromise,
|
|
293
297
|
registerer: !!this.registerer,
|
|
294
298
|
waiting: this.registerer && this.registerer.waiting,
|
|
295
299
|
tries,
|
|
296
|
-
|
|
300
|
+
skipRegister: this.skipRegister,
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
if (this.skipRegister) {
|
|
304
|
+
logger.info('sdk webrtc skip register...', logInfo);
|
|
305
|
+
return Promise.resolve();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
logger.info('sdk webrtc registering...', logInfo);
|
|
297
309
|
|
|
298
310
|
if (!this.userAgent) {
|
|
299
311
|
logger.info('sdk webrtc recreating User Agent');
|
|
@@ -624,12 +636,18 @@ export default class WebRTCClient extends Emitter {
|
|
|
624
636
|
}
|
|
625
637
|
|
|
626
638
|
if (pc.getSenders) {
|
|
639
|
+
if (!pc.getSenders().length) {
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
627
642
|
pc.getSenders().forEach(sender => {
|
|
628
643
|
if (sender && sender.track && sender.track.kind === 'audio') {
|
|
629
644
|
muted = muted && !sender.track.enabled;
|
|
630
645
|
}
|
|
631
646
|
});
|
|
632
647
|
} else {
|
|
648
|
+
if (!pc.getLocalStreams().length) {
|
|
649
|
+
return false;
|
|
650
|
+
}
|
|
633
651
|
pc.getLocalStreams().forEach(stream => {
|
|
634
652
|
stream.getAudioTracks().forEach(track => {
|
|
635
653
|
muted = muted && !track.enabled;
|
|
@@ -686,6 +704,9 @@ export default class WebRTCClient extends Emitter {
|
|
|
686
704
|
if (!this._isWeb()) {
|
|
687
705
|
options.sessionDescriptionHandlerModifiers = [holdModifier];
|
|
688
706
|
}
|
|
707
|
+
options.sessionDescriptionHandlerOptions = {
|
|
708
|
+
constraints: options.constraints,
|
|
709
|
+
};
|
|
689
710
|
|
|
690
711
|
// Send re-INVITE
|
|
691
712
|
return session.invite(options);
|
|
@@ -725,6 +746,9 @@ export default class WebRTCClient extends Emitter {
|
|
|
725
746
|
// (eg: holdModifier)
|
|
726
747
|
options.sessionDescriptionHandlerModifiers = [];
|
|
727
748
|
}
|
|
749
|
+
options.sessionDescriptionHandlerOptions = {
|
|
750
|
+
constraints: options.constraints,
|
|
751
|
+
};
|
|
728
752
|
|
|
729
753
|
// Send re-INVITE
|
|
730
754
|
return session.invite(options);
|
|
@@ -907,7 +931,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
907
931
|
}
|
|
908
932
|
const sdh = session.sessionDescriptionHandler;
|
|
909
933
|
const pc = sdh.peerConnection;
|
|
910
|
-
const
|
|
934
|
+
const sessionId = this.getSipSessionId(session);
|
|
935
|
+
const localStream = this.getLocalStream(sessionId);
|
|
911
936
|
|
|
912
937
|
// Release old video stream
|
|
913
938
|
if (localStream) {
|
|
@@ -933,11 +958,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
933
958
|
|
|
934
959
|
// let's update the local stream
|
|
935
960
|
this.eventEmitter.emit('onVideoInputChange', stream);
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
} catch (_) {
|
|
939
|
-
// Nothing to do
|
|
940
|
-
}
|
|
961
|
+
this.setLocalMediaStream(sessionId, stream);
|
|
962
|
+
|
|
941
963
|
return stream;
|
|
942
964
|
});
|
|
943
965
|
}
|
|
@@ -1239,9 +1261,11 @@ export default class WebRTCClient extends Emitter {
|
|
|
1239
1261
|
remoteStream.removeTrack(track);
|
|
1240
1262
|
});
|
|
1241
1263
|
|
|
1242
|
-
pc.getReceivers
|
|
1243
|
-
|
|
1244
|
-
|
|
1264
|
+
if (pc.getReceivers) {
|
|
1265
|
+
pc.getReceivers().forEach(receiver => {
|
|
1266
|
+
remoteStream.addTrack(receiver.track);
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1245
1269
|
}
|
|
1246
1270
|
|
|
1247
1271
|
getMediaConfiguration(enableVideo: boolean, conference: boolean = false, constraints: ?Object = null): Object {
|
|
@@ -1276,6 +1300,25 @@ export default class WebRTCClient extends Emitter {
|
|
|
1276
1300
|
return sessionId in this.conferences;
|
|
1277
1301
|
}
|
|
1278
1302
|
|
|
1303
|
+
createAudioElementFor(sessionId: string) {
|
|
1304
|
+
const audio: any = document.createElement('audio');
|
|
1305
|
+
audio.setAttribute('id', `audio-${sessionId}`);
|
|
1306
|
+
|
|
1307
|
+
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
1308
|
+
audio.setSinkId(this.audioOutputDeviceId);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
if (document.body) {
|
|
1312
|
+
document.body.appendChild(audio);
|
|
1313
|
+
}
|
|
1314
|
+
this.audioElements[sessionId] = audio;
|
|
1315
|
+
|
|
1316
|
+
audio.volume = this.audioOutputVolume;
|
|
1317
|
+
audio.autoplay = true;
|
|
1318
|
+
|
|
1319
|
+
return audio;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1279
1322
|
_onTransportError() {
|
|
1280
1323
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
1281
1324
|
this.attemptReconnection();
|
|
@@ -1505,7 +1548,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1505
1548
|
let hadRemoteVideo = false;
|
|
1506
1549
|
|
|
1507
1550
|
// Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
|
|
1508
|
-
//
|
|
1551
|
+
// Because when `onInvite` is called we already got the video track
|
|
1509
1552
|
session.onInviteRequest = (request) => {
|
|
1510
1553
|
hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
1511
1554
|
|
|
@@ -1580,20 +1623,10 @@ export default class WebRTCClient extends Emitter {
|
|
|
1580
1623
|
const isConference = this.isConference(sessionId);
|
|
1581
1624
|
|
|
1582
1625
|
if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
|
|
1583
|
-
|
|
1584
|
-
audio.setAttribute('id', `audio-${sessionId}`);
|
|
1585
|
-
|
|
1586
|
-
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
1587
|
-
audio.setSinkId(this.audioOutputDeviceId);
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
if (document.body) {
|
|
1591
|
-
document.body.appendChild(audio);
|
|
1592
|
-
}
|
|
1593
|
-
this.audioElements[sessionId] = audio;
|
|
1626
|
+
this.createAudioElementFor(sessionId);
|
|
1594
1627
|
}
|
|
1595
1628
|
|
|
1596
|
-
const audioElement = this.audioElements[
|
|
1629
|
+
const audioElement = this.audioElements[sessionId];
|
|
1597
1630
|
const stream = newStream || this.getRemoteStream(sessionId);
|
|
1598
1631
|
|
|
1599
1632
|
if (!this._isWeb() || !stream) {
|
package/src/websocket-client.js
CHANGED
|
@@ -59,6 +59,8 @@ export const CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_j
|
|
|
59
59
|
export const CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
|
|
60
60
|
export const CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
|
|
61
61
|
export const CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
|
|
62
|
+
export const MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
|
|
63
|
+
export const MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
|
|
62
64
|
export const SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
|
|
63
65
|
export const SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
|
|
64
66
|
export const SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
|
|
@@ -408,6 +410,8 @@ WebSocketClient.eventLists = [
|
|
|
408
410
|
CHATD_USER_ROOM_CREATED,
|
|
409
411
|
CONFERENCE_USER_PARTICIPANT_JOINED,
|
|
410
412
|
CONFERENCE_USER_PARTICIPANT_LEFT,
|
|
413
|
+
MEETING_USER_PARTICIPANT_JOINED,
|
|
414
|
+
MEETING_USER_PARTICIPANT_LEFT,
|
|
411
415
|
CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
|
|
412
416
|
CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
|
|
413
417
|
SWITCHBOARD_QUEUED_CALLS_UPDATED,
|