@wazo/sdk 0.37.35 → 0.37.38
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 +8 -2
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +7 -1
- package/esm/__tests__/web-rtc-client.test.js +7 -1
- package/esm/api/auth.js +2 -1
- package/esm/api/call-logd.js +1 -1
- package/esm/api/chatd.js +6 -0
- package/esm/api/confd.js +6 -0
- package/esm/api-client.js +7 -1
- package/esm/checker/Checker.js +7 -1
- package/esm/checker/checks/aor.js +7 -1
- package/esm/checker/checks/api.js +7 -1
- package/esm/checker/checks/index.js +7 -1
- package/esm/checker/checks/webrtc-transport.js +7 -1
- package/esm/checker/checks/webrtc.js +7 -1
- package/esm/domain/AdHocAPIConference.js +16 -6
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/CallSession.js +14 -0
- package/esm/domain/Features.js +7 -1
- package/esm/domain/Phone/CTIPhone.js +21 -1
- package/esm/domain/Phone/WebRTCPhone.js +42 -11
- package/esm/domain/Profile.js +6 -0
- package/esm/domain/SwitchboardCall.js +5 -5
- package/esm/domain/__tests__/CallLog.test.js +5 -1
- 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 +83 -29
- package/esm/service/CallApi.js +7 -1
- package/esm/service/getApiClient.js +7 -1
- package/esm/simple/Auth.js +84 -30
- package/esm/simple/Configuration.js +83 -29
- package/esm/simple/Directory.js +7 -1
- package/esm/simple/Phone.js +83 -29
- package/esm/simple/index.js +83 -29
- package/esm/simple/room/LocalParticipant.js +83 -29
- package/esm/simple/room/Participant.js +83 -29
- package/esm/simple/room/RemoteParticipant.js +83 -29
- package/esm/simple/room/Room.js +83 -29
- package/esm/simple/room/SipRoom.js +83 -29
- package/esm/simple/room/Stream.js +83 -29
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +83 -29
- package/esm/simple/utils.js +83 -29
- package/esm/web-rtc-client.js +7 -1
- package/lib/__tests__/api-client.test.js +7 -1
- package/lib/__tests__/web-rtc-client.test.js +7 -1
- package/lib/api/auth.js +3 -0
- package/lib/api/call-logd.js +1 -1
- package/lib/api/chatd.js +6 -0
- package/lib/api/confd.js +6 -0
- package/lib/api-client.js +7 -1
- package/lib/checker/Checker.js +7 -1
- package/lib/checker/checks/aor.js +7 -1
- package/lib/checker/checks/api.js +7 -1
- package/lib/checker/checks/index.js +7 -1
- package/lib/checker/checks/webrtc-transport.js +7 -1
- package/lib/checker/checks/webrtc.js +7 -1
- package/lib/domain/AdHocAPIConference.js +16 -6
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/CallSession.js +14 -0
- package/lib/domain/Features.js +7 -1
- package/lib/domain/Phone/CTIPhone.js +21 -1
- package/lib/domain/Phone/WebRTCPhone.js +42 -11
- package/lib/domain/Profile.js +6 -0
- package/lib/domain/SwitchboardCall.js +5 -5
- package/lib/domain/__tests__/CallLog.test.js +5 -1
- 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 +83 -29
- package/lib/service/CallApi.js +7 -1
- package/lib/service/getApiClient.js +7 -1
- package/lib/simple/Auth.js +84 -29
- package/lib/simple/Configuration.js +83 -29
- package/lib/simple/Directory.js +7 -1
- package/lib/simple/Phone.js +83 -29
- package/lib/simple/index.js +83 -29
- package/lib/simple/room/LocalParticipant.js +83 -29
- package/lib/simple/room/Participant.js +83 -29
- package/lib/simple/room/RemoteParticipant.js +83 -29
- package/lib/simple/room/Room.js +83 -29
- package/lib/simple/room/SipRoom.js +83 -29
- package/lib/simple/room/Stream.js +83 -29
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +83 -29
- package/lib/simple/utils.js +83 -29
- package/lib/web-rtc-client.js +7 -1
- package/package.json +1 -1
- package/src/api/auth.js +2 -1
- package/src/domain/AdHocAPIConference.js +9 -5
- package/src/domain/CallLog.js +1 -1
- package/src/domain/CallSession.js +14 -0
- package/src/domain/Phone/WebRTCPhone.js +28 -11
- package/src/domain/Profile.js +6 -0
- package/src/domain/SwitchboardCall.js +5 -5
- package/src/domain/__tests__/CallLog.test.js +4 -0
- package/src/simple/Auth.js +13 -2
- package/src/simple/Phone.js +6 -6
- package/src/simple/index.js +2 -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) {
|
|
@@ -926,22 +930,22 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
926
930
|
}
|
|
927
931
|
}
|
|
928
932
|
|
|
929
|
-
hold(callSession: CallSession, withEvent: boolean = true
|
|
933
|
+
hold(callSession: CallSession, withEvent: boolean = true): ?Promise<any> {
|
|
930
934
|
logger.info('WebRTC hold', { id: callSession.getId() });
|
|
931
935
|
|
|
932
936
|
const sipSession = this.findSipSession(callSession);
|
|
933
937
|
|
|
934
|
-
return sipSession ? this.holdSipSession(sipSession, callSession, withEvent
|
|
938
|
+
return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
|
|
935
939
|
}
|
|
936
940
|
|
|
937
941
|
// @Deprecated
|
|
938
|
-
unhold(callSession: CallSession, withEvent: boolean = true
|
|
942
|
+
unhold(callSession: CallSession, withEvent: boolean = true): ?Promise<any> {
|
|
939
943
|
console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
|
|
940
944
|
|
|
941
|
-
return this.resume(callSession,
|
|
945
|
+
return this.resume(callSession, withEvent);
|
|
942
946
|
}
|
|
943
947
|
|
|
944
|
-
resume(callSession?: CallSession,
|
|
948
|
+
resume(callSession?: CallSession, withEvent: boolean = true): Promise<any> {
|
|
945
949
|
logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
946
950
|
|
|
947
951
|
const sipSession = this.findSipSession(callSession);
|
|
@@ -954,10 +958,14 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
954
958
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
955
959
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
956
960
|
logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
957
|
-
this.holdSipSession(
|
|
961
|
+
this.holdSipSession(
|
|
962
|
+
this.currentSipSession,
|
|
963
|
+
this.currentCallSession,
|
|
964
|
+
withEvent,
|
|
965
|
+
);
|
|
958
966
|
}
|
|
959
967
|
|
|
960
|
-
const promise = this.unholdSipSession(sipSession, callSession, withEvent
|
|
968
|
+
const promise = this.unholdSipSession(sipSession, callSession, withEvent);
|
|
961
969
|
this.currentSipSession = sipSession;
|
|
962
970
|
if (callSession) {
|
|
963
971
|
this.currentCallSession = callSession;
|
|
@@ -970,7 +978,6 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
970
978
|
sipSession: Session,
|
|
971
979
|
callSession: ?CallSession,
|
|
972
980
|
withEvent: boolean = true,
|
|
973
|
-
isConference: boolean = false,
|
|
974
981
|
): Promise<any> {
|
|
975
982
|
if (!sipSession) {
|
|
976
983
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
@@ -991,6 +998,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
991
998
|
await this.client.downgradeToAudio(sipSession);
|
|
992
999
|
}
|
|
993
1000
|
|
|
1001
|
+
const isConference = !!callSession && callSession.isConference();
|
|
1002
|
+
|
|
994
1003
|
const promise = this.client.hold(sipSession, isConference, hasVideo);
|
|
995
1004
|
if (withEvent) {
|
|
996
1005
|
this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
|
|
@@ -1003,11 +1012,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1003
1012
|
sipSession: Session,
|
|
1004
1013
|
callSession: ?CallSession,
|
|
1005
1014
|
withEvent: boolean = true,
|
|
1006
|
-
isConference: boolean = false,
|
|
1007
1015
|
): Promise<any> {
|
|
1008
1016
|
if (!sipSession) {
|
|
1009
1017
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1010
1018
|
}
|
|
1019
|
+
|
|
1020
|
+
const isConference = !!callSession && callSession.isConference();
|
|
1021
|
+
|
|
1011
1022
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1012
1023
|
logger.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
1013
1024
|
|
|
@@ -1149,7 +1160,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1149
1160
|
await this.client.register();
|
|
1150
1161
|
}
|
|
1151
1162
|
if (this.currentSipSession) {
|
|
1152
|
-
this.holdSipSession(
|
|
1163
|
+
this.holdSipSession(
|
|
1164
|
+
this.currentSipSession,
|
|
1165
|
+
this.currentCallSession,
|
|
1166
|
+
true,
|
|
1167
|
+
).catch(e => {
|
|
1153
1168
|
logger.warn('Unable to hold current session when making another call', e);
|
|
1154
1169
|
});
|
|
1155
1170
|
}
|
|
@@ -1164,6 +1179,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1164
1179
|
return Promise.resolve(null);
|
|
1165
1180
|
}
|
|
1166
1181
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
1182
|
+
callSession.setIsConference(conference);
|
|
1167
1183
|
callSession.creationTime = new Date();
|
|
1168
1184
|
this._updateCallSession(callSession);
|
|
1169
1185
|
|
|
@@ -1744,6 +1760,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1744
1760
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
1745
1761
|
recordingPaused: false, // @TODO
|
|
1746
1762
|
sipSession,
|
|
1763
|
+
conference: !!fromSession && fromSession.isConference(),
|
|
1747
1764
|
...extra,
|
|
1748
1765
|
});
|
|
1749
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
|
}
|
|
@@ -28,7 +28,7 @@ type SwitchboardCallArguments = {
|
|
|
28
28
|
callSession: ?CallSession,
|
|
29
29
|
callerIdName: ?string,
|
|
30
30
|
callerIdNumber: ?string,
|
|
31
|
-
|
|
31
|
+
answerTime: ?Date,
|
|
32
32
|
participantId: ?string,
|
|
33
33
|
state: string,
|
|
34
34
|
switchboardName: string,
|
|
@@ -54,7 +54,7 @@ class SwitchboardCall {
|
|
|
54
54
|
callSession: ?CallSession;
|
|
55
55
|
callerIdName: ?string;
|
|
56
56
|
callerIdNumber: ?string;
|
|
57
|
-
|
|
57
|
+
answerTime: ?Date;
|
|
58
58
|
participantId: ?string;
|
|
59
59
|
state: string;
|
|
60
60
|
switchboardName: string;
|
|
@@ -68,7 +68,7 @@ class SwitchboardCall {
|
|
|
68
68
|
callerIdName: plain.caller_id_name || null,
|
|
69
69
|
callerIdNumber: plain.caller_id_number || null,
|
|
70
70
|
participantId: plain.participantId || null,
|
|
71
|
-
|
|
71
|
+
answerTime: plain.startTime,
|
|
72
72
|
state: plain.state,
|
|
73
73
|
switchboardName: plain.switchboardName,
|
|
74
74
|
switchboardUuid: plain.switchboardUuid,
|
|
@@ -81,7 +81,7 @@ class SwitchboardCall {
|
|
|
81
81
|
callerIdName,
|
|
82
82
|
callerIdNumber,
|
|
83
83
|
participantId,
|
|
84
|
-
|
|
84
|
+
answerTime,
|
|
85
85
|
state,
|
|
86
86
|
switchboardName,
|
|
87
87
|
switchboardUuid,
|
|
@@ -91,7 +91,7 @@ class SwitchboardCall {
|
|
|
91
91
|
this.callerIdName = callerIdName;
|
|
92
92
|
this.callerIdNumber = callerIdNumber;
|
|
93
93
|
this.participantId = participantId;
|
|
94
|
-
this.
|
|
94
|
+
this.answerTime = answerTime;
|
|
95
95
|
this.state = state;
|
|
96
96
|
this.switchboardName = switchboardName;
|
|
97
97
|
this.switchboardUuid = switchboardUuid;
|
|
@@ -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/Auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
/* eslint-disable max-classes-per-file */
|
|
3
3
|
import Session from '../domain/Session';
|
|
4
|
-
import { DETAULT_EXPIRATION } from '../api/auth';
|
|
4
|
+
import { BACKEND_LDAP_USER, DEFAULT_BACKEND_USER, DETAULT_EXPIRATION } from '../api/auth';
|
|
5
5
|
import getApiClient, {
|
|
6
6
|
setCurrentServer,
|
|
7
7
|
setApiToken,
|
|
@@ -17,6 +17,7 @@ import Wazo from './index';
|
|
|
17
17
|
|
|
18
18
|
export class InvalidSubscription extends Error {}
|
|
19
19
|
export class InvalidAuthorization extends Error {}
|
|
20
|
+
export class NoTenantIdError extends Error {}
|
|
20
21
|
|
|
21
22
|
const logger = IssueReporter.loggerFor('simple-auth');
|
|
22
23
|
|
|
@@ -30,11 +31,15 @@ class Auth {
|
|
|
30
31
|
onRefreshTokenCallback: ?Function;
|
|
31
32
|
authenticated: boolean;
|
|
32
33
|
mobile: boolean;
|
|
34
|
+
BACKEND_WAZO: string;
|
|
35
|
+
BACKEND_LDAP: string;
|
|
33
36
|
|
|
34
37
|
constructor() {
|
|
35
38
|
this.expiration = DETAULT_EXPIRATION;
|
|
36
39
|
this.authenticated = false;
|
|
37
40
|
this.minSubscriptionType = null;
|
|
41
|
+
this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
|
|
42
|
+
this.BACKEND_LDAP = BACKEND_LDAP_USER;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
init(clientId: string,
|
|
@@ -67,12 +72,18 @@ class Auth {
|
|
|
67
72
|
setFetchOptions(options);
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
async logIn(username: string, password: string) {
|
|
75
|
+
async logIn(username: string, password: string, backend?: string, tenantId?: string) {
|
|
76
|
+
if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
|
|
77
|
+
throw new NoTenantIdError('No tenant id');
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
this.authenticated = false;
|
|
72
81
|
this.session = null;
|
|
73
82
|
const rawSession = await getApiClient().auth.logIn({
|
|
74
83
|
username,
|
|
75
84
|
password,
|
|
85
|
+
backend,
|
|
86
|
+
tenantId,
|
|
76
87
|
expiration: this.expiration,
|
|
77
88
|
mobile: this.mobile,
|
|
78
89
|
});
|
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/simple/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* global window */
|
|
2
|
-
import Auth, { InvalidSubscription, InvalidAuthorization } from './Auth';
|
|
2
|
+
import Auth, { InvalidSubscription, InvalidAuthorization, NoTenantIdError } from './Auth';
|
|
3
3
|
import Phone from './Phone';
|
|
4
4
|
import Websocket from './Websocket';
|
|
5
5
|
import Room from './room/Room';
|
|
@@ -103,6 +103,7 @@ const Wazo = {
|
|
|
103
103
|
InvalidAuthorization,
|
|
104
104
|
CanceledCallError,
|
|
105
105
|
SFUNotAvailableError,
|
|
106
|
+
NoTenantIdError,
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
if (window) {
|