@wazo/sdk 0.37.33 → 0.37.36
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 +1 -0
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +17 -0
- package/esm/__tests__/web-rtc-client.test.js +18 -1
- package/esm/api/auth.js +5 -0
- package/esm/api/call-logd.js +6 -0
- package/esm/api/chatd.js +6 -0
- package/esm/api/confd.js +6 -0
- package/esm/api-client.js +17 -0
- package/esm/checker/Checker.js +18 -1
- package/esm/checker/checks/aor.js +17 -0
- package/esm/checker/checks/api.js +17 -0
- package/esm/checker/checks/index.js +18 -1
- package/esm/checker/checks/webrtc-transport.js +18 -1
- package/esm/checker/checks/webrtc.js +18 -1
- package/esm/domain/AdHocAPIConference.js +21 -0
- package/esm/domain/CallLog.js +6 -0
- package/esm/domain/CallSession.js +14 -0
- package/esm/domain/Features.js +17 -0
- package/esm/domain/Phone/CTIPhone.js +31 -0
- package/esm/domain/Phone/WebRTCPhone.js +65 -15
- package/esm/domain/Profile.js +6 -0
- package/esm/domain/__tests__/CallLog.test.js +10 -0
- package/esm/domain/__tests__/CallSession.test.js +14 -0
- package/esm/domain/__tests__/IndirectTransfer.test.js +14 -0
- package/esm/domain/__tests__/Profile.test.js +6 -0
- package/esm/domain/__tests__/Room.test.js +14 -0
- package/esm/domain/__tests__/Session.test.js +6 -0
- package/esm/index.js +93 -22
- package/esm/service/CallApi.js +17 -0
- package/esm/service/getApiClient.js +17 -0
- package/esm/simple/Auth.js +93 -22
- package/esm/simple/Configuration.js +93 -22
- package/esm/simple/Directory.js +17 -0
- package/esm/simple/Phone.js +93 -22
- package/esm/simple/index.js +93 -22
- package/esm/simple/room/LocalParticipant.js +93 -22
- package/esm/simple/room/Participant.js +93 -22
- package/esm/simple/room/RemoteParticipant.js +93 -22
- package/esm/simple/room/Room.js +93 -22
- package/esm/simple/room/SipRoom.js +93 -22
- package/esm/simple/room/Stream.js +93 -22
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +93 -22
- package/esm/simple/utils.js +93 -22
- package/esm/web-rtc-client.js +18 -1
- package/lib/__tests__/api-client.test.js +17 -0
- package/lib/__tests__/web-rtc-client.test.js +18 -1
- package/lib/api/auth.js +5 -0
- package/lib/api/call-logd.js +6 -0
- package/lib/api/chatd.js +6 -0
- package/lib/api/confd.js +6 -0
- package/lib/api-client.js +17 -0
- package/lib/checker/Checker.js +18 -1
- package/lib/checker/checks/aor.js +17 -0
- package/lib/checker/checks/api.js +17 -0
- package/lib/checker/checks/index.js +18 -1
- package/lib/checker/checks/webrtc-transport.js +18 -1
- package/lib/checker/checks/webrtc.js +18 -1
- package/lib/domain/AdHocAPIConference.js +21 -0
- package/lib/domain/CallLog.js +6 -0
- package/lib/domain/CallSession.js +14 -0
- package/lib/domain/Features.js +17 -0
- package/lib/domain/Phone/CTIPhone.js +31 -0
- package/lib/domain/Phone/WebRTCPhone.js +65 -15
- package/lib/domain/Profile.js +6 -0
- package/lib/domain/__tests__/CallLog.test.js +10 -0
- package/lib/domain/__tests__/CallSession.test.js +14 -0
- package/lib/domain/__tests__/IndirectTransfer.test.js +14 -0
- package/lib/domain/__tests__/Profile.test.js +6 -0
- package/lib/domain/__tests__/Room.test.js +14 -0
- package/lib/domain/__tests__/Session.test.js +6 -0
- package/lib/index.js +93 -22
- package/lib/service/CallApi.js +17 -0
- package/lib/service/getApiClient.js +17 -0
- package/lib/simple/Auth.js +93 -22
- package/lib/simple/Configuration.js +93 -22
- package/lib/simple/Directory.js +17 -0
- package/lib/simple/Phone.js +93 -22
- package/lib/simple/index.js +93 -22
- package/lib/simple/room/LocalParticipant.js +93 -22
- package/lib/simple/room/Participant.js +93 -22
- package/lib/simple/room/RemoteParticipant.js +93 -22
- package/lib/simple/room/Room.js +93 -22
- package/lib/simple/room/SipRoom.js +93 -22
- package/lib/simple/room/Stream.js +93 -22
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +93 -22
- package/lib/simple/utils.js +93 -22
- package/lib/web-rtc-client.js +18 -1
- package/package.json +1 -1
- package/src/api/auth.js +5 -0
- package/src/domain/AdHocAPIConference.js +4 -0
- package/src/domain/CallLog.js +6 -0
- package/src/domain/CallSession.js +14 -0
- package/src/domain/Phone/WebRTCPhone.js +51 -15
- package/src/domain/Profile.js +6 -0
- package/src/domain/__tests__/CallLog.test.js +4 -0
- package/src/simple/Phone.js +6 -6
- package/src/web-rtc-client.js +1 -1
|
@@ -833,7 +833,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
833
833
|
accept(callSession: CallSession, cameraEnabled?: boolean): Promise<string | null> {
|
|
834
834
|
logger.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
835
835
|
if (this.currentSipSession) {
|
|
836
|
-
this.holdSipSession(
|
|
836
|
+
this.holdSipSession(
|
|
837
|
+
this.currentSipSession,
|
|
838
|
+
this.currentCallSession,
|
|
839
|
+
true,
|
|
840
|
+
);
|
|
837
841
|
}
|
|
838
842
|
|
|
839
843
|
if (!callSession) {
|
|
@@ -841,6 +845,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
841
845
|
return Promise.resolve(null);
|
|
842
846
|
}
|
|
843
847
|
|
|
848
|
+
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
849
|
+
if (sipSessionId && !(sipSessionId in this.callSessions)) {
|
|
850
|
+
logger.warn('Call session already ended or not found, can\'t accept it.', { sipSessionId });
|
|
851
|
+
return Promise.resolve(null);
|
|
852
|
+
}
|
|
853
|
+
|
|
844
854
|
if (callSession.getId() in this.acceptedSessions) {
|
|
845
855
|
logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
846
856
|
return Promise.resolve(callSession.sipCallId);
|
|
@@ -920,22 +930,22 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
920
930
|
}
|
|
921
931
|
}
|
|
922
932
|
|
|
923
|
-
hold(callSession: CallSession, withEvent: boolean = true
|
|
933
|
+
hold(callSession: CallSession, withEvent: boolean = true): ?Promise<any> {
|
|
924
934
|
logger.info('WebRTC hold', { id: callSession.getId() });
|
|
925
935
|
|
|
926
936
|
const sipSession = this.findSipSession(callSession);
|
|
927
937
|
|
|
928
|
-
return sipSession ? this.holdSipSession(sipSession, callSession, withEvent
|
|
938
|
+
return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
|
|
929
939
|
}
|
|
930
940
|
|
|
931
941
|
// @Deprecated
|
|
932
|
-
unhold(callSession: CallSession, withEvent: boolean = true
|
|
942
|
+
unhold(callSession: CallSession, withEvent: boolean = true): ?Promise<any> {
|
|
933
943
|
console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
|
|
934
944
|
|
|
935
|
-
return this.resume(callSession,
|
|
945
|
+
return this.resume(callSession, withEvent);
|
|
936
946
|
}
|
|
937
947
|
|
|
938
|
-
resume(callSession?: CallSession,
|
|
948
|
+
resume(callSession?: CallSession, withEvent: boolean = true): Promise<any> {
|
|
939
949
|
logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
940
950
|
|
|
941
951
|
const sipSession = this.findSipSession(callSession);
|
|
@@ -948,10 +958,14 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
948
958
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
949
959
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
950
960
|
logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
951
|
-
this.holdSipSession(
|
|
961
|
+
this.holdSipSession(
|
|
962
|
+
this.currentSipSession,
|
|
963
|
+
this.currentCallSession,
|
|
964
|
+
withEvent,
|
|
965
|
+
);
|
|
952
966
|
}
|
|
953
967
|
|
|
954
|
-
const promise = this.unholdSipSession(sipSession, callSession, withEvent
|
|
968
|
+
const promise = this.unholdSipSession(sipSession, callSession, withEvent);
|
|
955
969
|
this.currentSipSession = sipSession;
|
|
956
970
|
if (callSession) {
|
|
957
971
|
this.currentCallSession = callSession;
|
|
@@ -964,7 +978,6 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
964
978
|
sipSession: Session,
|
|
965
979
|
callSession: ?CallSession,
|
|
966
980
|
withEvent: boolean = true,
|
|
967
|
-
isConference: boolean = false,
|
|
968
981
|
): Promise<any> {
|
|
969
982
|
if (!sipSession) {
|
|
970
983
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
@@ -985,6 +998,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
985
998
|
await this.client.downgradeToAudio(sipSession);
|
|
986
999
|
}
|
|
987
1000
|
|
|
1001
|
+
const isConference = !!callSession && callSession.isConference();
|
|
1002
|
+
|
|
988
1003
|
const promise = this.client.hold(sipSession, isConference, hasVideo);
|
|
989
1004
|
if (withEvent) {
|
|
990
1005
|
this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
|
|
@@ -997,11 +1012,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
997
1012
|
sipSession: Session,
|
|
998
1013
|
callSession: ?CallSession,
|
|
999
1014
|
withEvent: boolean = true,
|
|
1000
|
-
isConference: boolean = false,
|
|
1001
1015
|
): Promise<any> {
|
|
1002
1016
|
if (!sipSession) {
|
|
1003
1017
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1004
1018
|
}
|
|
1019
|
+
|
|
1020
|
+
const isConference = !!callSession && callSession.isConference();
|
|
1021
|
+
|
|
1005
1022
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1006
1023
|
logger.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
1007
1024
|
|
|
@@ -1143,7 +1160,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1143
1160
|
await this.client.register();
|
|
1144
1161
|
}
|
|
1145
1162
|
if (this.currentSipSession) {
|
|
1146
|
-
this.holdSipSession(
|
|
1163
|
+
this.holdSipSession(
|
|
1164
|
+
this.currentSipSession,
|
|
1165
|
+
this.currentCallSession,
|
|
1166
|
+
true,
|
|
1167
|
+
).catch(e => {
|
|
1147
1168
|
logger.warn('Unable to hold current session when making another call', e);
|
|
1148
1169
|
});
|
|
1149
1170
|
}
|
|
@@ -1158,6 +1179,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1158
1179
|
return Promise.resolve(null);
|
|
1159
1180
|
}
|
|
1160
1181
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
1182
|
+
callSession.setIsConference(conference);
|
|
1161
1183
|
callSession.creationTime = new Date();
|
|
1162
1184
|
this._updateCallSession(callSession);
|
|
1163
1185
|
|
|
@@ -1465,9 +1487,17 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1465
1487
|
});
|
|
1466
1488
|
|
|
1467
1489
|
this.client.on(this.client.ACCEPTED, (sipSession: Session) => {
|
|
1468
|
-
|
|
1490
|
+
const sessionId = this.getSipSessionId(sipSession);
|
|
1491
|
+
const hasSession = sessionId in this.callSessions;
|
|
1492
|
+
|
|
1493
|
+
logger.info('WebRTC call accepted', { sipId: sessionId, hasSession });
|
|
1469
1494
|
|
|
1470
|
-
|
|
1495
|
+
if (!hasSession) {
|
|
1496
|
+
logger.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', { sessionId });
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
|
|
1471
1501
|
|
|
1472
1502
|
if (this.audioOutputDeviceId) {
|
|
1473
1503
|
this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
|
|
@@ -1603,9 +1633,14 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1603
1633
|
return this.client.getSipSessionId(sipSession);
|
|
1604
1634
|
}
|
|
1605
1635
|
|
|
1606
|
-
|
|
1636
|
+
getSipSessionIdFromCallSession(callSession: CallSession) {
|
|
1607
1637
|
const sipSession = this.findSipSession(callSession);
|
|
1608
|
-
|
|
1638
|
+
|
|
1639
|
+
return sipSession ? this.getSipSessionId(sipSession) : null;
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
_updateCallSession(callSession: CallSession) {
|
|
1643
|
+
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
1609
1644
|
|
|
1610
1645
|
if (sipSessionId) {
|
|
1611
1646
|
this.callSessions[sipSessionId] = callSession;
|
|
@@ -1725,6 +1760,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1725
1760
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
1726
1761
|
recordingPaused: false, // @TODO
|
|
1727
1762
|
sipSession,
|
|
1763
|
+
conference: !!fromSession && fromSession.isConference(),
|
|
1728
1764
|
...extra,
|
|
1729
1765
|
});
|
|
1730
1766
|
|
package/src/domain/Profile.js
CHANGED
|
@@ -57,6 +57,7 @@ type ProfileResponse = {
|
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
mobile_phone_number: ?string,
|
|
60
|
+
ring_seconds?: number,
|
|
60
61
|
subscription_type: ?number,
|
|
61
62
|
services: {
|
|
62
63
|
dnd: {
|
|
@@ -93,6 +94,7 @@ type ProfileArguments = {
|
|
|
93
94
|
mobileNumber: string,
|
|
94
95
|
forwards: Array<ForwardOption>,
|
|
95
96
|
doNotDisturb?: boolean,
|
|
97
|
+
ringSeconds?: number,
|
|
96
98
|
state?: string,
|
|
97
99
|
status: string,
|
|
98
100
|
subscriptionType: ?number,
|
|
@@ -124,6 +126,7 @@ export default class Profile {
|
|
|
124
126
|
doNotDisturb: ?boolean;
|
|
125
127
|
onlineCallRecordEnabled: ?boolean;
|
|
126
128
|
state: ?string;
|
|
129
|
+
ringSeconds: ?number;
|
|
127
130
|
voicemail: ?{ id: number, name: string };
|
|
128
131
|
status: string;
|
|
129
132
|
subscriptionType: ?number;
|
|
@@ -140,6 +143,7 @@ export default class Profile {
|
|
|
140
143
|
lines: plain.lines.map(line => Line.parse(line)),
|
|
141
144
|
username: plain.username,
|
|
142
145
|
mobileNumber: plain.mobile_phone_number || '',
|
|
146
|
+
ringSeconds: plain.ring_seconds,
|
|
143
147
|
forwards: [
|
|
144
148
|
ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
|
|
145
149
|
ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
|
|
@@ -176,6 +180,7 @@ export default class Profile {
|
|
|
176
180
|
switchboards,
|
|
177
181
|
agent,
|
|
178
182
|
status,
|
|
183
|
+
ringSeconds,
|
|
179
184
|
sipLines,
|
|
180
185
|
callPickupTargetUsers,
|
|
181
186
|
onlineCallRecordEnabled,
|
|
@@ -197,6 +202,7 @@ export default class Profile {
|
|
|
197
202
|
this.status = status;
|
|
198
203
|
this.callPickupTargetUsers = callPickupTargetUsers;
|
|
199
204
|
this.onlineCallRecordEnabled = onlineCallRecordEnabled;
|
|
205
|
+
this.ringSeconds = ringSeconds;
|
|
200
206
|
|
|
201
207
|
this.sipLines = sipLines || [];
|
|
202
208
|
}
|
|
@@ -15,8 +15,10 @@ describe('CallLog domain', () => {
|
|
|
15
15
|
call_direction: 'outbound',
|
|
16
16
|
source_extension: '8020',
|
|
17
17
|
source_name: 'Jonathan Lessard',
|
|
18
|
+
source_user_uuid: '123',
|
|
18
19
|
destination_extension: '4182250459',
|
|
19
20
|
destination_name: null,
|
|
21
|
+
destination_user_uuid: '456',
|
|
20
22
|
duration: 4,
|
|
21
23
|
start: '2017-08-06T13:50:55.819057+00:00',
|
|
22
24
|
end: '2017-08-08T13:51:23.822529+00:00',
|
|
@@ -47,10 +49,12 @@ describe('CallLog domain', () => {
|
|
|
47
49
|
destination: {
|
|
48
50
|
extension: '4182250459',
|
|
49
51
|
name: '',
|
|
52
|
+
uuid: '456',
|
|
50
53
|
},
|
|
51
54
|
source: {
|
|
52
55
|
extension: '8020',
|
|
53
56
|
name: 'Jonathan Lessard',
|
|
57
|
+
uuid: '123',
|
|
54
58
|
},
|
|
55
59
|
id: 215,
|
|
56
60
|
duration: 4000,
|
package/src/simple/Phone.js
CHANGED
|
@@ -204,16 +204,16 @@ class Phone extends Emitter {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
hold(callSession: CallSession
|
|
208
|
-
return this.phone && this.phone.hold(callSession, true
|
|
207
|
+
hold(callSession: CallSession) {
|
|
208
|
+
return this.phone && this.phone.hold(callSession, true);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
unhold(callSession: CallSession
|
|
212
|
-
return this.phone && this.phone.unhold(callSession, true
|
|
211
|
+
unhold(callSession: CallSession) {
|
|
212
|
+
return this.phone && this.phone.unhold(callSession, true);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
resume(callSession: CallSession
|
|
216
|
-
return this.phone && this.phone.resume(callSession
|
|
215
|
+
resume(callSession: CallSession) {
|
|
216
|
+
return this.phone && this.phone.resume(callSession);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
reject(callSession: CallSession) {
|
package/src/web-rtc-client.js
CHANGED
|
@@ -75,7 +75,7 @@ export const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
|
75
75
|
export const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
76
76
|
export class CanceledCallError extends Error {}
|
|
77
77
|
|
|
78
|
-
const MAX_REGISTER_TRIES =
|
|
78
|
+
const MAX_REGISTER_TRIES = 5;
|
|
79
79
|
|
|
80
80
|
type MediaConfig = {
|
|
81
81
|
audio: Object & boolean,
|