@wazo/sdk 0.39.15 → 0.40.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/README.md +2 -2
- package/dist/wazo-sdk.js +12 -12
- package/esm/__tests__/api-client.test.js +0 -10
- package/esm/__tests__/web-rtc-client.test.js +2 -15
- package/esm/api/chatd.js +0 -1
- package/esm/api/dird.js +7 -10
- package/esm/checker/checks/ice-ipv4.js +2 -3
- package/esm/checker/checks/symmetric-nat.js +7 -4
- package/esm/domain/AdHocAPIConference.js +1 -1
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +2 -1
- package/esm/domain/MeetingAuthorization.js +6 -0
- package/esm/domain/Phone/CTIPhone.js +2 -0
- package/esm/domain/Phone/WebRTCPhone.js +16 -18
- package/esm/domain/Session.js +2 -2
- package/esm/domain/__tests__/Agent.test.js +0 -2
- package/esm/domain/__tests__/Call.test.js +0 -1
- package/esm/domain/__tests__/CallLog.test.js +0 -1
- package/esm/domain/__tests__/CallSession.test.js +1 -2
- package/esm/domain/__tests__/Contact.test.js +2 -4
- package/esm/domain/__tests__/IndirectTransfer.test.js +0 -1
- package/esm/domain/__tests__/Profile.test.js +0 -1
- package/esm/domain/__tests__/Room.test.js +1 -25
- package/esm/domain/__tests__/Session.test.js +13 -14
- package/esm/domain/__tests__/SipLine.test.js +2 -3
- package/esm/index.js +42 -88
- package/esm/lib/WazoSessionDescriptionHandler.js +9 -15
- package/esm/service/IssueReporter.js +1 -3
- package/esm/service/__tests__/IssueReporter.test.js +0 -1
- package/esm/simple/Phone.js +1 -1
- package/esm/simple/Websocket.js +2 -2
- package/esm/simple/index.js +5 -4
- package/esm/simple/room/Room.js +15 -15
- package/esm/simple/room/SipRoom.js +1 -1
- package/esm/simple/room/Stream.js +1 -2
- package/esm/simple/room/__tests__/Participant.test.js +0 -2
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +1 -2
- package/esm/types/api/auth.d.ts +2 -2
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/api/call-logd.d.ts +3 -3
- package/esm/types/api/call-logd.d.ts.map +1 -1
- package/esm/types/api/chatd.d.ts +9 -22
- package/esm/types/api/chatd.d.ts.map +1 -1
- package/esm/types/api/dird.d.ts +21 -14
- package/esm/types/api/dird.d.ts.map +1 -1
- package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -1
- package/esm/types/checker/checks/index.d.ts +1 -1
- package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -1
- package/esm/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/esm/types/domain/Agent.d.ts +1 -1
- package/esm/types/domain/Agent.d.ts.map +1 -1
- package/esm/types/domain/CallLog.d.ts +14 -26
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/CallSession.d.ts +3 -4
- package/esm/types/domain/CallSession.d.ts.map +1 -1
- package/esm/types/domain/Contact.d.ts +8 -0
- package/esm/types/domain/Contact.d.ts.map +1 -1
- package/esm/types/domain/MeetingAuthorization.d.ts +6 -0
- package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -1
- package/esm/types/domain/Phone/CTIPhone.d.ts +2 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/esm/types/domain/Phone/Phone.d.ts +12 -2
- package/esm/types/domain/Phone/Phone.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +24 -20
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/domain/Room.d.ts +10 -12
- package/esm/types/domain/Room.d.ts.map +1 -1
- package/esm/types/domain/Session.d.ts +1 -1
- package/esm/types/domain/Session.d.ts.map +1 -1
- package/esm/types/domain/SipLine.d.ts +3 -3
- package/esm/types/domain/SipLine.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +64 -10
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/index.d.ts +51 -314
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/esm/types/service/CallApi.d.ts +3 -3
- package/esm/types/service/CallApi.d.ts.map +1 -1
- package/esm/types/service/IssueReporter.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +0 -40
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +0 -113
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/simple/Websocket.d.ts +0 -16
- package/esm/types/simple/Websocket.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +8 -8
- package/esm/types/simple/index.d.ts.map +1 -1
- package/esm/types/simple/room/Participant.d.ts +4 -3
- package/esm/types/simple/room/Participant.d.ts.map +1 -1
- package/esm/types/simple/room/Room.d.ts +29 -18
- package/esm/types/simple/room/Room.d.ts.map +1 -1
- package/esm/types/simple/room/SipRoom.d.ts +1 -1
- package/esm/types/simple/room/SipRoom.d.ts.map +1 -1
- package/esm/types/simple/room/Stream.d.ts +1 -1
- package/esm/types/simple/room/Stream.d.ts.map +1 -1
- package/esm/types/utils/PhoneNumberUtil.d.ts +1 -1
- package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -1
- package/esm/types/utils/api-requester.d.ts +1 -1
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts +20 -5
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +51 -49
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/types/websocket-client.d.ts.map +1 -1
- package/esm/utils/__tests__/PhoneNumberUtil.test.js +0 -6
- package/esm/utils/__tests__/api-requester.test.js +0 -2
- package/esm/utils/__tests__/sdp.test.js +4 -18
- package/esm/utils/api-requester.js +1 -2
- package/esm/utils/sdp.js +8 -3
- package/esm/web-rtc-client.js +99 -136
- package/esm/websocket-client.js +1 -2
- package/index.js +1 -0
- package/lib/__tests__/api-client.test.js +0 -10
- package/lib/__tests__/web-rtc-client.test.js +2 -15
- package/lib/api/chatd.js +0 -1
- package/lib/api/dird.js +19 -22
- package/lib/checker/checks/ice-ipv4.js +2 -3
- package/lib/checker/checks/symmetric-nat.js +7 -4
- package/lib/domain/AdHocAPIConference.js +1 -1
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +2 -1
- package/lib/domain/MeetingAuthorization.js +6 -0
- package/lib/domain/Phone/CTIPhone.js +2 -0
- package/lib/domain/Phone/WebRTCPhone.js +16 -18
- package/lib/domain/Session.js +2 -2
- package/lib/domain/__tests__/Agent.test.js +0 -2
- package/lib/domain/__tests__/Call.test.js +0 -1
- package/lib/domain/__tests__/CallLog.test.js +0 -1
- package/lib/domain/__tests__/CallSession.test.js +1 -2
- package/lib/domain/__tests__/Contact.test.js +2 -4
- package/lib/domain/__tests__/IndirectTransfer.test.js +0 -1
- package/lib/domain/__tests__/Profile.test.js +0 -1
- package/lib/domain/__tests__/Room.test.js +1 -25
- package/lib/domain/__tests__/Session.test.js +13 -14
- package/lib/domain/__tests__/SipLine.test.js +2 -3
- package/lib/index.js +93 -99
- package/lib/lib/WazoSessionDescriptionHandler.js +9 -15
- package/lib/service/IssueReporter.js +1 -3
- package/lib/service/__tests__/IssueReporter.test.js +0 -1
- package/lib/simple/Phone.js +1 -1
- package/lib/simple/Websocket.js +2 -2
- package/lib/simple/index.js +2 -1
- package/lib/simple/room/Room.js +17 -15
- package/lib/simple/room/SipRoom.js +1 -1
- package/lib/simple/room/Stream.js +1 -2
- package/lib/simple/room/__tests__/Participant.test.js +0 -2
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +1 -2
- package/lib/types/api/auth.d.ts +2 -2
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/api/call-logd.d.ts +3 -3
- package/lib/types/api/call-logd.d.ts.map +1 -1
- package/lib/types/api/chatd.d.ts +9 -22
- package/lib/types/api/chatd.d.ts.map +1 -1
- package/lib/types/api/dird.d.ts +21 -14
- package/lib/types/api/dird.d.ts.map +1 -1
- package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -1
- package/lib/types/checker/checks/index.d.ts +1 -1
- package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -1
- package/lib/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/lib/types/domain/Agent.d.ts +1 -1
- package/lib/types/domain/Agent.d.ts.map +1 -1
- package/lib/types/domain/CallLog.d.ts +14 -26
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/CallSession.d.ts +3 -4
- package/lib/types/domain/CallSession.d.ts.map +1 -1
- package/lib/types/domain/Contact.d.ts +8 -0
- package/lib/types/domain/Contact.d.ts.map +1 -1
- package/lib/types/domain/MeetingAuthorization.d.ts +6 -0
- package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -1
- package/lib/types/domain/Phone/CTIPhone.d.ts +2 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/lib/types/domain/Phone/Phone.d.ts +12 -2
- package/lib/types/domain/Phone/Phone.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +24 -20
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/domain/Room.d.ts +10 -12
- package/lib/types/domain/Room.d.ts.map +1 -1
- package/lib/types/domain/Session.d.ts +1 -1
- package/lib/types/domain/Session.d.ts.map +1 -1
- package/lib/types/domain/SipLine.d.ts +3 -3
- package/lib/types/domain/SipLine.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +64 -10
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/index.d.ts +51 -314
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/lib/types/service/CallApi.d.ts +3 -3
- package/lib/types/service/CallApi.d.ts.map +1 -1
- package/lib/types/service/IssueReporter.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +0 -40
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +0 -113
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/simple/Websocket.d.ts +0 -16
- package/lib/types/simple/Websocket.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +8 -8
- package/lib/types/simple/index.d.ts.map +1 -1
- package/lib/types/simple/room/Participant.d.ts +4 -3
- package/lib/types/simple/room/Participant.d.ts.map +1 -1
- package/lib/types/simple/room/Room.d.ts +29 -18
- package/lib/types/simple/room/Room.d.ts.map +1 -1
- package/lib/types/simple/room/SipRoom.d.ts +1 -1
- package/lib/types/simple/room/SipRoom.d.ts.map +1 -1
- package/lib/types/simple/room/Stream.d.ts +1 -1
- package/lib/types/simple/room/Stream.d.ts.map +1 -1
- package/lib/types/utils/PhoneNumberUtil.d.ts +1 -1
- package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -1
- package/lib/types/utils/api-requester.d.ts +1 -1
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts +20 -5
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +51 -49
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/types/websocket-client.d.ts.map +1 -1
- package/lib/utils/__tests__/PhoneNumberUtil.test.js +0 -6
- package/lib/utils/__tests__/api-requester.test.js +0 -2
- package/lib/utils/__tests__/sdp.test.js +6 -18
- package/lib/utils/api-requester.js +2 -3
- package/lib/utils/sdp.js +9 -3
- package/lib/web-rtc-client.js +105 -140
- package/lib/websocket-client.js +1 -2
- package/package.json +5 -18
- package/src/__tests__/api-client.test.ts +10 -19
- package/src/__tests__/web-rtc-client.test.ts +13 -25
- package/src/api/auth.ts +2 -5
- package/src/api/call-logd.ts +3 -3
- package/src/api/chatd.ts +10 -24
- package/src/api/dird.ts +33 -39
- package/src/checker/checks/ice-ipv4.ts +4 -5
- package/src/checker/checks/symmetric-nat.ts +11 -7
- package/src/checker/checks/webrtc-transport.ts +2 -2
- package/src/domain/AdHocAPIConference.ts +1 -1
- package/src/domain/Agent.ts +1 -1
- package/src/domain/CallLog.ts +19 -27
- package/src/domain/CallSession.ts +3 -4
- package/src/domain/Contact.ts +3 -1
- package/src/domain/MeetingAuthorization.ts +13 -0
- package/src/domain/Phone/CTIPhone.ts +4 -0
- package/src/domain/Phone/Phone.ts +11 -2
- package/src/domain/Phone/WebRTCPhone.ts +51 -52
- package/src/domain/Room.ts +12 -14
- package/src/domain/Session.ts +3 -3
- package/src/domain/SipLine.ts +3 -3
- package/src/domain/__tests__/Agent.test.ts +3 -5
- package/src/domain/__tests__/Call.test.ts +4 -5
- package/src/domain/__tests__/CallLog.test.ts +1 -3
- package/src/domain/__tests__/CallSession.test.ts +10 -11
- package/src/domain/__tests__/Contact.test.ts +2 -4
- package/src/domain/__tests__/IndirectTransfer.test.ts +6 -7
- package/src/domain/__tests__/Profile.test.ts +3 -4
- package/src/domain/__tests__/Room.test.ts +27 -51
- package/src/domain/__tests__/Session.test.ts +27 -28
- package/src/domain/__tests__/SipLine.test.ts +4 -5
- package/src/domain/types.ts +64 -11
- package/src/index.ts +51 -111
- package/src/lib/WazoSessionDescriptionHandler.ts +24 -30
- package/src/service/CallApi.ts +3 -3
- package/src/service/IssueReporter.ts +3 -5
- package/src/service/__tests__/IssueReporter.test.ts +1 -2
- package/src/simple/Auth.ts +1 -41
- package/src/simple/Phone.ts +9 -116
- package/src/simple/Websocket.ts +4 -20
- package/src/simple/index.ts +8 -7
- package/src/simple/room/Participant.ts +4 -3
- package/src/simple/room/Room.ts +44 -36
- package/src/simple/room/SipRoom.ts +4 -4
- package/src/simple/room/Stream.ts +2 -3
- package/src/simple/room/__tests__/Participant.test.ts +2 -4
- package/src/simple/room/__tests__/RemoteParticipant.test.ts +4 -3
- package/src/types/wazo.d.ts +1 -0
- package/src/utils/PhoneNumberUtil.ts +1 -1
- package/src/utils/__tests__/PhoneNumberUtil.test.ts +0 -6
- package/src/utils/__tests__/api-requester.test.ts +3 -4
- package/src/utils/__tests__/sdp.test.ts +16 -30
- package/src/utils/api-requester.ts +1 -4
- package/src/utils/sdp.ts +38 -17
- package/src/web-rtc-client.ts +196 -234
- package/src/websocket-client.ts +2 -3
- package/lib/.DS_Store +0 -0
package/src/domain/CallLog.ts
CHANGED
|
@@ -8,46 +8,47 @@ type CallLogResponse = {
|
|
|
8
8
|
answer: string | null | undefined;
|
|
9
9
|
answered: boolean;
|
|
10
10
|
call_direction: string;
|
|
11
|
-
destination_extension
|
|
12
|
-
destination_name
|
|
13
|
-
destination_user_uuid
|
|
11
|
+
destination_extension?: string;
|
|
12
|
+
destination_name?: string;
|
|
13
|
+
destination_user_uuid?: string;
|
|
14
14
|
duration: number;
|
|
15
15
|
end: string | null | undefined;
|
|
16
16
|
id: number;
|
|
17
17
|
source_extension: string;
|
|
18
18
|
source_name: string;
|
|
19
|
-
source_user_uuid
|
|
19
|
+
source_user_uuid?: string;
|
|
20
20
|
recordings: RecordingResponse[];
|
|
21
21
|
requested_extension: string;
|
|
22
22
|
requested_name: string;
|
|
23
23
|
start: string;
|
|
24
24
|
};
|
|
25
|
+
|
|
25
26
|
type Response = {
|
|
26
27
|
filtered: number;
|
|
27
28
|
items: Array<CallLogResponse>;
|
|
28
29
|
total: number;
|
|
29
30
|
};
|
|
31
|
+
|
|
32
|
+
type LogOrigin = {
|
|
33
|
+
extension: string;
|
|
34
|
+
name: string;
|
|
35
|
+
uuid?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
30
38
|
type CallLogArguments = {
|
|
31
39
|
answer: Date | null | undefined;
|
|
32
40
|
answered: boolean;
|
|
33
41
|
newMissedCall?: boolean;
|
|
34
42
|
callDirection: string;
|
|
35
|
-
destination:
|
|
36
|
-
|
|
37
|
-
name: string;
|
|
38
|
-
uuid: string | null | undefined;
|
|
39
|
-
};
|
|
40
|
-
source: {
|
|
41
|
-
extension: string;
|
|
42
|
-
name: string;
|
|
43
|
-
uuid: string | null | undefined;
|
|
44
|
-
};
|
|
43
|
+
destination: LogOrigin;
|
|
44
|
+
source: LogOrigin;
|
|
45
45
|
id: number;
|
|
46
46
|
duration: number;
|
|
47
47
|
start: Date;
|
|
48
48
|
end: Date | null | undefined;
|
|
49
49
|
recordings: Recording[];
|
|
50
50
|
};
|
|
51
|
+
|
|
51
52
|
export default class CallLog {
|
|
52
53
|
type: string;
|
|
53
54
|
|
|
@@ -59,17 +60,11 @@ export default class CallLog {
|
|
|
59
60
|
|
|
60
61
|
callDirection: string;
|
|
61
62
|
|
|
62
|
-
destination:
|
|
63
|
-
extension: string;
|
|
64
|
-
name: string;
|
|
65
|
-
};
|
|
63
|
+
destination: LogOrigin;
|
|
66
64
|
|
|
67
65
|
recordings: Recording[];
|
|
68
66
|
|
|
69
|
-
source:
|
|
70
|
-
extension: string;
|
|
71
|
-
name: string;
|
|
72
|
-
};
|
|
67
|
+
source: LogOrigin;
|
|
73
68
|
|
|
74
69
|
id: number;
|
|
75
70
|
|
|
@@ -124,7 +119,7 @@ export default class CallLog {
|
|
|
124
119
|
static parseNew(plain: CallLogResponse, session: Session): CallLog {
|
|
125
120
|
const callLog: CallLog = CallLog.parse(plain);
|
|
126
121
|
// @TODO: FIXME add verification declined vs missed call
|
|
127
|
-
callLog.newMissedCall = session && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
|
|
122
|
+
callLog.newMissedCall = session && session.hasExtension((plain.requested_extension || plain.destination_extension) as string) && !plain.answered;
|
|
128
123
|
return callLog;
|
|
129
124
|
}
|
|
130
125
|
|
|
@@ -162,10 +157,7 @@ export default class CallLog {
|
|
|
162
157
|
return this.theOtherParty(session).extension === other.theOtherParty(session).extension;
|
|
163
158
|
}
|
|
164
159
|
|
|
165
|
-
theOtherParty(session: Session): {
|
|
166
|
-
extension: string;
|
|
167
|
-
name: string;
|
|
168
|
-
} {
|
|
160
|
+
theOtherParty(session: Session): LogOrigin {
|
|
169
161
|
if (this.callDirection === 'inbound') {
|
|
170
162
|
return this.source;
|
|
171
163
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SessionState } from 'sip.js/lib/api/session-state';
|
|
2
|
-
import type { Invitation } from 'sip.js/lib/api';
|
|
3
|
-
import { Inviter } from 'sip.js/lib/api';
|
|
4
2
|
import Call from './Call';
|
|
5
3
|
import newFrom from '../utils/new-from';
|
|
6
4
|
import updateFrom from '../utils/update-from';
|
|
5
|
+
import { WazoSession } from './types';
|
|
7
6
|
|
|
8
7
|
type CallSessionArguments = {
|
|
9
8
|
answered: boolean;
|
|
@@ -33,7 +32,7 @@ type CallSessionArguments = {
|
|
|
33
32
|
screensharing: boolean;
|
|
34
33
|
recording: boolean;
|
|
35
34
|
recordingPaused: boolean;
|
|
36
|
-
sipSession?:
|
|
35
|
+
sipSession?: WazoSession;
|
|
37
36
|
conference: boolean;
|
|
38
37
|
};
|
|
39
38
|
export default class CallSession {
|
|
@@ -97,7 +96,7 @@ export default class CallSession {
|
|
|
97
96
|
|
|
98
97
|
recordingPaused: boolean;
|
|
99
98
|
|
|
100
|
-
sipSession:
|
|
99
|
+
sipSession: WazoSession | undefined;
|
|
101
100
|
|
|
102
101
|
conference: boolean;
|
|
103
102
|
|
package/src/domain/Contact.ts
CHANGED
|
@@ -239,6 +239,8 @@ type GoogleResponse = {
|
|
|
239
239
|
|
|
240
240
|
const SOURCE_MOBILE = 'mobile';
|
|
241
241
|
export default class Contact {
|
|
242
|
+
static BACKEND = BACKEND;
|
|
243
|
+
|
|
242
244
|
type: string;
|
|
243
245
|
|
|
244
246
|
id: string | null | undefined;
|
|
@@ -769,7 +771,7 @@ export default class Contact {
|
|
|
769
771
|
|
|
770
772
|
merge(old: Contact): Contact {
|
|
771
773
|
Object.keys(old).filter(key => key !== 'lineState').forEach(key => {
|
|
772
|
-
// @ts-ignore
|
|
774
|
+
// @ts-ignore: keys
|
|
773
775
|
this[key] = old[key] || this[key];
|
|
774
776
|
});
|
|
775
777
|
|
|
@@ -11,7 +11,20 @@ export const REJECTED = 'rejected';
|
|
|
11
11
|
export const POST_PROCESSING = 'post_processing';
|
|
12
12
|
export const POST_PROCESSED_SUCCESS = 'post_processed_success';
|
|
13
13
|
export const POST_PROCESSED_ERROR = 'post_processed_error';
|
|
14
|
+
|
|
14
15
|
export default class MeetingAuthorization {
|
|
16
|
+
static PENDING = PENDING;
|
|
17
|
+
|
|
18
|
+
static ACCEPTED = ACCEPTED;
|
|
19
|
+
|
|
20
|
+
static REJECTED = REJECTED;
|
|
21
|
+
|
|
22
|
+
static POST_PROCESSING = POST_PROCESSING;
|
|
23
|
+
|
|
24
|
+
static POST_PROCESSED_SUCCESS = POST_PROCESSED_SUCCESS;
|
|
25
|
+
|
|
26
|
+
static POST_PROCESSED_ERROR = POST_PROCESSED_ERROR;
|
|
27
|
+
|
|
15
28
|
meetingUuid: string;
|
|
16
29
|
|
|
17
30
|
uuid: string;
|
|
@@ -20,6 +20,8 @@ export default class CTIPhone extends Emitter implements Phone {
|
|
|
20
20
|
|
|
21
21
|
currentCall: Call | null | undefined;
|
|
22
22
|
|
|
23
|
+
client = null;
|
|
24
|
+
|
|
23
25
|
constructor(session: Session, isMobile = false, callbackAllLines = false) {
|
|
24
26
|
super();
|
|
25
27
|
logger.info('CTI Phone created');
|
|
@@ -373,4 +375,6 @@ export default class CTIPhone extends Emitter implements Phone {
|
|
|
373
375
|
|
|
374
376
|
setMediaConstraints() {}
|
|
375
377
|
|
|
378
|
+
register() { return Promise.resolve(null); }
|
|
379
|
+
|
|
376
380
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import EventEmitter from 'events';
|
|
1
2
|
import Line from '../Line';
|
|
2
3
|
import CallSession from '../CallSession';
|
|
4
|
+
import type WebRTCClient from '../../web-rtc-client';
|
|
5
|
+
import { IEmitter } from '../../utils/Emitter';
|
|
3
6
|
|
|
4
7
|
export type PhoneEventCallbacks = {
|
|
5
8
|
onCallIncoming?: (number: string) => void;
|
|
@@ -25,7 +28,7 @@ export type AvailablePhoneOptions = {
|
|
|
25
28
|
sendKey: boolean;
|
|
26
29
|
transfer: boolean;
|
|
27
30
|
};
|
|
28
|
-
export interface Phone {
|
|
31
|
+
export interface Phone extends IEmitter {
|
|
29
32
|
accept(callSession: CallSession, enableVideo: boolean): Promise<string | null>;
|
|
30
33
|
changeAudioDevice(id: string): PhoneVoid;
|
|
31
34
|
changeRingDevice(id: string): PhoneVoid;
|
|
@@ -54,7 +57,7 @@ export interface Phone {
|
|
|
54
57
|
hasAVideoTrack(callSession: CallSession): boolean;
|
|
55
58
|
isWebRTC(): boolean;
|
|
56
59
|
getUserAgent(): string;
|
|
57
|
-
makeCall(number: string, line: Line, enableVideo?: boolean, audioOnly?: boolean):
|
|
60
|
+
makeCall(number: string, line: Line, enableVideo?: boolean, audioOnly?: boolean): Promise<CallSession | null | undefined>;
|
|
58
61
|
mute(callSession: CallSession): PhoneVoid;
|
|
59
62
|
reject(callSession: CallSession): PhoneVoid;
|
|
60
63
|
resume(callSession: CallSession): Promise<any> | null | undefined;
|
|
@@ -67,4 +70,10 @@ export interface Phone {
|
|
|
67
70
|
isRegistered(): boolean;
|
|
68
71
|
hasIncomingCallSession(): boolean;
|
|
69
72
|
setMediaConstraints(media: MediaStreamConstraints): PhoneVoid;
|
|
73
|
+
getCurrentCallSession(): CallSession | null | undefined;
|
|
74
|
+
getRemoteVideoStream(callSession: CallSession): MediaStream | null | undefined;
|
|
75
|
+
hasLocalVideo(callSession: CallSession): boolean;
|
|
76
|
+
eventEmitter: EventEmitter;
|
|
77
|
+
client: WebRTCClient | null;
|
|
78
|
+
register(): Promise<null | void>;
|
|
70
79
|
}
|
|
@@ -4,12 +4,14 @@ import type { Message } from 'sip.js/lib/api/message';
|
|
|
4
4
|
import { SessionState } from 'sip.js/lib/api/session-state';
|
|
5
5
|
import type { IncomingRequestMessage } from 'sip.js/lib/core/messages/incoming-request-message';
|
|
6
6
|
import { OutgoingInviteRequest } from 'sip.js/lib/core';
|
|
7
|
-
import { Inviter, Invitation, Session } from 'sip.js/lib/api';
|
|
7
|
+
import { Inviter, Invitation, Session, SessionDescriptionHandlerOptions } from 'sip.js/lib/api';
|
|
8
|
+
import { SessionDescriptionHandler } from 'sip.js/lib/platform/web';
|
|
8
9
|
import CallSession from '../CallSession';
|
|
9
10
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
10
11
|
import WazoWebRTCClient from '../../web-rtc-client';
|
|
11
12
|
import Emitter from '../../utils/Emitter';
|
|
12
13
|
import IssueReporter from '../../service/IssueReporter';
|
|
14
|
+
import { PeerConnection, WazoSession } from '../types';
|
|
13
15
|
|
|
14
16
|
export const ON_USER_AGENT = 'onUserAgent';
|
|
15
17
|
export const ON_REGISTERED = 'onRegistered';
|
|
@@ -66,7 +68,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
66
68
|
|
|
67
69
|
incomingSessions: string[];
|
|
68
70
|
|
|
69
|
-
currentSipSession:
|
|
71
|
+
currentSipSession: WazoSession | undefined;
|
|
70
72
|
|
|
71
73
|
currentCallSession: CallSession | null | undefined;
|
|
72
74
|
|
|
@@ -311,8 +313,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
311
313
|
const shouldScreenShare = constraints && !!constraints.screen;
|
|
312
314
|
const desktop = constraints && constraints.desktop;
|
|
313
315
|
const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
|
|
314
|
-
|
|
315
|
-
const wasAudioOnly = options?.audioOnly;
|
|
316
|
+
const wasAudioOnly = (options as SessionDescriptionHandlerOptions & { audioOnly: boolean })?.audioOnly;
|
|
316
317
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
317
318
|
|
|
318
319
|
if (callSession) {
|
|
@@ -363,7 +364,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
363
364
|
}, 2500);
|
|
364
365
|
}
|
|
365
366
|
|
|
366
|
-
_bindEvents(sipSession:
|
|
367
|
+
_bindEvents(sipSession: WazoSession) {
|
|
367
368
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
368
369
|
|
|
369
370
|
if (sipSession instanceof Invitation) {
|
|
@@ -431,12 +432,15 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
431
432
|
}
|
|
432
433
|
|
|
433
434
|
// Video events
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
peerConnection,
|
|
437
|
-
} = sipSession.sessionDescriptionHandler;
|
|
435
|
+
const sdh = sipSession.sessionDescriptionHandler as SessionDescriptionHandler;
|
|
436
|
+
const peerConnection = sdh.peerConnection as PeerConnection;
|
|
438
437
|
|
|
439
|
-
|
|
438
|
+
if (!peerConnection) {
|
|
439
|
+
logger.info('null peer connection');
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
peerConnection.ontrack = (rawEvent: RTCTrackEvent) => {
|
|
440
444
|
const event = rawEvent;
|
|
441
445
|
const [stream] = event.streams;
|
|
442
446
|
const kind = event && event.track && event.track.kind;
|
|
@@ -477,7 +481,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
477
481
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
478
482
|
const sipSession = this.currentSipSession;
|
|
479
483
|
const pc = sipSession && this.client.getPeerConnection(this.getSipSessionId(sipSession));
|
|
480
|
-
const sender = pc && pc.getSenders && pc.getSenders().find((s
|
|
484
|
+
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
481
485
|
const localStream = sipSession && this.client.getLocalStream(this.getSipSessionId(sipSession));
|
|
482
486
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
483
487
|
const hadVideo = !!videoTrack;
|
|
@@ -497,7 +501,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
497
501
|
sender.replaceTrack(screenTrack);
|
|
498
502
|
}
|
|
499
503
|
|
|
500
|
-
this._onScreenSharing(screenShareStream, sipSession as
|
|
504
|
+
this._onScreenSharing(screenShareStream, sipSession as WazoSession, callSession, hadVideo, constraints.desktop);
|
|
501
505
|
|
|
502
506
|
return screenShareStream;
|
|
503
507
|
}
|
|
@@ -551,11 +555,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
551
555
|
return reinvited;
|
|
552
556
|
}
|
|
553
557
|
|
|
554
|
-
_onScreenSharing(screenStream: MediaStream, sipSession:
|
|
558
|
+
_onScreenSharing(screenStream: MediaStream, sipSession: WazoSession, callSession: CallSession | null | undefined, hadVideo: boolean, desktop?: boolean | null | undefined) {
|
|
555
559
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
556
560
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
557
561
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
558
|
-
const sender = pc && pc.getSenders && pc.getSenders().find((s
|
|
562
|
+
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
559
563
|
logger.info('WebRTC phone - on screensharing', {
|
|
560
564
|
hadVideo,
|
|
561
565
|
id: this.getSipSessionId(sipSession),
|
|
@@ -586,7 +590,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
586
590
|
}), screenStream);
|
|
587
591
|
}
|
|
588
592
|
|
|
589
|
-
_onCallAccepted(sipSession:
|
|
593
|
+
_onCallAccepted(sipSession: WazoSession, cameraEnabled: boolean): CallSession {
|
|
590
594
|
logger.info('WebRTC phone - on call accepted', {
|
|
591
595
|
sipId: sipSession.id,
|
|
592
596
|
cameraEnabled,
|
|
@@ -677,7 +681,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
677
681
|
return this.currentSipSession && this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
678
682
|
}
|
|
679
683
|
|
|
680
|
-
_onCallTerminated(sipSession:
|
|
684
|
+
_onCallTerminated(sipSession: WazoSession): boolean {
|
|
681
685
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
682
686
|
|
|
683
687
|
logger.info('WebRTC phone - on call terminated', {
|
|
@@ -743,7 +747,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
743
747
|
return false;
|
|
744
748
|
}
|
|
745
749
|
|
|
746
|
-
// @ts-ignore
|
|
750
|
+
// @ts-ignore: does not exist
|
|
747
751
|
if (!sipSession.isCanceled) {
|
|
748
752
|
setTimeout(() => {
|
|
749
753
|
this.eventEmitter.emit(ON_PLAY_HANGUP_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, callSession);
|
|
@@ -777,11 +781,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
777
781
|
return false;
|
|
778
782
|
}
|
|
779
783
|
|
|
780
|
-
const
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
} = sipSession.sessionDescriptionHandler;
|
|
784
|
-
const remoteStream: MediaStream = peerConnection.getRemoteStreams().find((stream: MediaStream) => !!stream.getVideoTracks().length);
|
|
784
|
+
const sdh = sipSession.sessionDescriptionHandler as SessionDescriptionHandler;
|
|
785
|
+
const peerConnection = sdh.peerConnection as PeerConnection;
|
|
786
|
+
const remoteStream: MediaStream = peerConnection.getRemoteStreams().find((stream: MediaStream) => !!stream.getVideoTracks().length) as MediaStream;
|
|
785
787
|
return remoteStream && remoteStream.getVideoTracks().some(track => !track.muted);
|
|
786
788
|
}
|
|
787
789
|
|
|
@@ -981,7 +983,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
981
983
|
return promise;
|
|
982
984
|
}
|
|
983
985
|
|
|
984
|
-
async holdSipSession(sipSession:
|
|
986
|
+
async holdSipSession(sipSession: WazoSession, callSession: CallSession | null | undefined, withEvent = true): Promise<OutgoingInviteRequest | void> {
|
|
985
987
|
if (!sipSession) {
|
|
986
988
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
987
989
|
}
|
|
@@ -1014,7 +1016,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1014
1016
|
return promise;
|
|
1015
1017
|
}
|
|
1016
1018
|
|
|
1017
|
-
async unholdSipSession(sipSession:
|
|
1019
|
+
async unholdSipSession(sipSession: WazoSession, callSession: CallSession | null | undefined, withEvent = true): Promise<MediaStream | void | null> {
|
|
1018
1020
|
if (!sipSession) {
|
|
1019
1021
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1020
1022
|
}
|
|
@@ -1208,10 +1210,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1208
1210
|
});
|
|
1209
1211
|
}
|
|
1210
1212
|
|
|
1211
|
-
let sipSession:
|
|
1213
|
+
let sipSession: WazoSession;
|
|
1212
1214
|
|
|
1213
1215
|
try {
|
|
1214
|
-
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference);
|
|
1216
|
+
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference) as WazoSession;
|
|
1215
1217
|
|
|
1216
1218
|
this._bindEvents(sipSession);
|
|
1217
1219
|
} catch (error: any) {
|
|
@@ -1235,9 +1237,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1235
1237
|
this.eventEmitter.emit(ON_CALL_OUTGOING, callSession);
|
|
1236
1238
|
|
|
1237
1239
|
// If an invite promise exists, catch exceptions on it to trigger error like OverConstraintsError.
|
|
1238
|
-
// @ts-ignore
|
|
1240
|
+
// @ts-ignore: does not exist
|
|
1239
1241
|
if (sipSession.invitePromise) {
|
|
1240
|
-
// @ts-ignore
|
|
1242
|
+
// @ts-ignore: does not exist
|
|
1241
1243
|
sipSession.invitePromise.catch(error => {
|
|
1242
1244
|
this.eventEmitter.emit(ON_CALL_ERROR, error, callSession);
|
|
1243
1245
|
});
|
|
@@ -1336,13 +1338,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1336
1338
|
}
|
|
1337
1339
|
|
|
1338
1340
|
forceCancel(sipSession: Inviter): void {
|
|
1339
|
-
// @ts-ignore
|
|
1341
|
+
// @ts-ignore: private
|
|
1340
1342
|
if (!sipSession || !sipSession.outgoingInviteRequest) {
|
|
1341
1343
|
return;
|
|
1342
1344
|
}
|
|
1343
1345
|
|
|
1344
1346
|
try {
|
|
1345
|
-
// @ts-ignore
|
|
1347
|
+
// @ts-ignore: private
|
|
1346
1348
|
sipSession.outgoingInviteRequest.cancel();
|
|
1347
1349
|
} catch (e) {
|
|
1348
1350
|
logger.info('force cancel, error', e);
|
|
@@ -1437,7 +1439,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1437
1439
|
}
|
|
1438
1440
|
|
|
1439
1441
|
// eslint-disable-next-line @typescript-eslint/default-param-last
|
|
1440
|
-
sendMessage(sipSession:
|
|
1442
|
+
sendMessage(sipSession: WazoSession | null = null, body: string, contentType = 'text/plain'): void {
|
|
1441
1443
|
return this.client.sendMessage(sipSession, body, contentType);
|
|
1442
1444
|
}
|
|
1443
1445
|
|
|
@@ -1489,7 +1491,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1489
1491
|
|
|
1490
1492
|
bindClientEvents() {
|
|
1491
1493
|
this.client.unbind();
|
|
1492
|
-
this.client.on(this.client.INVITE, (sipSession:
|
|
1494
|
+
this.client.on(this.client.INVITE, (sipSession: WazoSession, wantsToDoVideo: boolean) => {
|
|
1493
1495
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
1494
1496
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
1495
1497
|
logger.info('WebRTC invite received', {
|
|
@@ -1537,7 +1539,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1537
1539
|
this.eventEmitter.emit.apply(this.eventEmitter, [this.client.ON_REINVITE, ...args]);
|
|
1538
1540
|
}, 2000);
|
|
1539
1541
|
});
|
|
1540
|
-
this.client.on(this.client.ACCEPTED, (sipSession:
|
|
1542
|
+
this.client.on(this.client.ACCEPTED, (sipSession: WazoSession) => {
|
|
1541
1543
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1542
1544
|
const hasSession = (sessionId in this.callSessions);
|
|
1543
1545
|
logger.info('WebRTC call accepted', {
|
|
@@ -1604,8 +1606,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1604
1606
|
// send a reinvite to renegociate ICE with new IP
|
|
1605
1607
|
if (this.shouldSendReinvite && this.currentSipSession && this.currentSipSession.state === SessionState.Established) {
|
|
1606
1608
|
this.shouldSendReinvite = false;
|
|
1607
|
-
|
|
1608
|
-
const pc = this.currentSipSession?.sessionDescriptionHandler?.peerConnection;
|
|
1609
|
+
const pc = (this.currentSipSession?.sessionDescriptionHandler as SessionDescriptionHandler)?.peerConnection as PeerConnection;
|
|
1609
1610
|
const isConference = pc ? pc.sfu : false;
|
|
1610
1611
|
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
1611
1612
|
|
|
@@ -1652,7 +1653,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1652
1653
|
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
1653
1654
|
});
|
|
1654
1655
|
// Used when upgrading directly in screenshare mode
|
|
1655
|
-
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession:
|
|
1656
|
+
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession: WazoSession, response: any, desktop: boolean) => {
|
|
1656
1657
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1657
1658
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
1658
1659
|
const callSession = this.callSessions[sipSessionId];
|
|
@@ -1666,7 +1667,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1666
1667
|
}
|
|
1667
1668
|
|
|
1668
1669
|
// Find a corresponding sipSession from a CallSession
|
|
1669
|
-
findSipSession(callSession: CallSession | null | undefined):
|
|
1670
|
+
findSipSession(callSession: CallSession | null | undefined): WazoSession | null | undefined {
|
|
1670
1671
|
const keys = this.client.getSipSessionIds();
|
|
1671
1672
|
const keyIndex = keys.findIndex(sessionId => callSession && callSession.isId(sessionId));
|
|
1672
1673
|
|
|
@@ -1682,7 +1683,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1682
1683
|
return this.callSessions[sipSessionId];
|
|
1683
1684
|
}
|
|
1684
1685
|
|
|
1685
|
-
getSipSessionId(sipSession:
|
|
1686
|
+
getSipSessionId(sipSession: WazoSession): string {
|
|
1686
1687
|
return this.client.getSipSessionId(sipSession);
|
|
1687
1688
|
}
|
|
1688
1689
|
|
|
@@ -1699,8 +1700,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1699
1700
|
}
|
|
1700
1701
|
}
|
|
1701
1702
|
|
|
1702
|
-
_onMessage(message: Message): void {
|
|
1703
|
-
// @ts-ignore
|
|
1703
|
+
_onMessage(message: Message & { method?: string, body?: string }): void {
|
|
1704
1704
|
if (!message || message.method !== 'MESSAGE') {
|
|
1705
1705
|
return;
|
|
1706
1706
|
}
|
|
@@ -1708,8 +1708,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1708
1708
|
let body;
|
|
1709
1709
|
|
|
1710
1710
|
try {
|
|
1711
|
-
|
|
1712
|
-
body = JSON.parse(message.body);
|
|
1711
|
+
body = JSON.parse(message.body || '');
|
|
1713
1712
|
} catch (e: any) {
|
|
1714
1713
|
return;
|
|
1715
1714
|
}
|
|
@@ -1734,7 +1733,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1734
1733
|
}
|
|
1735
1734
|
}
|
|
1736
1735
|
|
|
1737
|
-
_createIncomingCallSession(sipSession:
|
|
1736
|
+
_createIncomingCallSession(sipSession: WazoSession, cameraEnabled: boolean, fromSession?: CallSession | null | undefined, autoAnswer = false): CallSession {
|
|
1738
1737
|
return this._createCallSession(sipSession, fromSession, {
|
|
1739
1738
|
incoming: true,
|
|
1740
1739
|
ringing: true,
|
|
@@ -1743,7 +1742,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1743
1742
|
});
|
|
1744
1743
|
}
|
|
1745
1744
|
|
|
1746
|
-
_createOutgoingCallSession(sipSession:
|
|
1745
|
+
_createOutgoingCallSession(sipSession: WazoSession, cameraEnabled: boolean, fromSession?: CallSession): CallSession {
|
|
1747
1746
|
return this._createCallSession(sipSession, fromSession, {
|
|
1748
1747
|
incoming: false,
|
|
1749
1748
|
ringing: true,
|
|
@@ -1751,40 +1750,40 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1751
1750
|
});
|
|
1752
1751
|
}
|
|
1753
1752
|
|
|
1754
|
-
_createAcceptedCallSession(sipSession:
|
|
1753
|
+
_createAcceptedCallSession(sipSession: WazoSession, cameraEnabled?: boolean, fromSession?: CallSession): CallSession {
|
|
1755
1754
|
return this._createCallSession(sipSession, fromSession, {
|
|
1756
1755
|
cameraEnabled: cameraEnabled !== undefined ? cameraEnabled : false,
|
|
1757
1756
|
});
|
|
1758
1757
|
}
|
|
1759
1758
|
|
|
1760
|
-
_createMutedCallSession(sipSession:
|
|
1759
|
+
_createMutedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession {
|
|
1761
1760
|
return this._createCallSession(sipSession, fromSession, {
|
|
1762
1761
|
muted: true,
|
|
1763
1762
|
});
|
|
1764
1763
|
}
|
|
1765
1764
|
|
|
1766
|
-
_createUnmutedCallSession(sipSession:
|
|
1765
|
+
_createUnmutedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession {
|
|
1767
1766
|
return this._createCallSession(sipSession, fromSession, {
|
|
1768
1767
|
muted: false,
|
|
1769
1768
|
});
|
|
1770
1769
|
}
|
|
1771
1770
|
|
|
1772
|
-
_createCameraResumedCallSession(sipSession:
|
|
1771
|
+
_createCameraResumedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession {
|
|
1773
1772
|
return this._createCallSession(sipSession, fromSession, {
|
|
1774
1773
|
videoMuted: false,
|
|
1775
1774
|
});
|
|
1776
1775
|
}
|
|
1777
1776
|
|
|
1778
|
-
_createCameraDisabledCallSession(sipSession:
|
|
1777
|
+
_createCameraDisabledCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession {
|
|
1779
1778
|
return this._createCallSession(sipSession, fromSession, {
|
|
1780
1779
|
videoMuted: true,
|
|
1781
1780
|
});
|
|
1782
1781
|
}
|
|
1783
1782
|
|
|
1784
|
-
_createCallSession(sipSession:
|
|
1783
|
+
_createCallSession(sipSession: WazoSession, fromSession?: CallSession | null | undefined, extra: Record<string, any> = {}): CallSession {
|
|
1785
1784
|
// eslint-disable-next-line
|
|
1786
1785
|
const identity = sipSession ? sipSession.remoteIdentity || sipSession.assertedIdentity : null;
|
|
1787
|
-
// @ts-ignore
|
|
1786
|
+
// @ts-ignore: private
|
|
1788
1787
|
const number = identity ? identity.uri._normal.user : null;
|
|
1789
1788
|
const {
|
|
1790
1789
|
state,
|
|
@@ -1796,7 +1795,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1796
1795
|
sipCallId: sessionId,
|
|
1797
1796
|
sipStatus: state,
|
|
1798
1797
|
displayName: identity ? identity.displayName || number : number,
|
|
1799
|
-
// @ts-ignore:
|
|
1798
|
+
// @ts-ignore: date / number
|
|
1800
1799
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
1801
1800
|
creationTime: fromSession ? fromSession.creationTime : null,
|
|
1802
1801
|
answerTime: fromSession ? fromSession.answerTime : null,
|
package/src/domain/Room.ts
CHANGED
|
@@ -2,15 +2,17 @@ import CallSession from './CallSession';
|
|
|
2
2
|
import newFrom from '../utils/new-from';
|
|
3
3
|
import updateFrom from '../utils/update-from';
|
|
4
4
|
|
|
5
|
+
type RoomParticipant = {
|
|
6
|
+
extension: string;
|
|
7
|
+
uuid: string;
|
|
8
|
+
talking?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
export type RoomArguments = {
|
|
6
12
|
connectedCallSession: CallSession | null;
|
|
7
13
|
id: string;
|
|
8
14
|
name?: string;
|
|
9
|
-
participants:
|
|
10
|
-
extension: string;
|
|
11
|
-
uuid: string;
|
|
12
|
-
talking: boolean | null | undefined;
|
|
13
|
-
}>;
|
|
15
|
+
participants: RoomParticipant[];
|
|
14
16
|
}; // Represents a conference room, like `9000`.
|
|
15
17
|
|
|
16
18
|
export default class Room {
|
|
@@ -20,11 +22,7 @@ export default class Room {
|
|
|
20
22
|
|
|
21
23
|
connectedCallSession: CallSession | null;
|
|
22
24
|
|
|
23
|
-
participants:
|
|
24
|
-
extension: string;
|
|
25
|
-
uuid: string;
|
|
26
|
-
talking: boolean | null | undefined;
|
|
27
|
-
}>;
|
|
25
|
+
participants: RoomParticipant[];
|
|
28
26
|
|
|
29
27
|
constructor({
|
|
30
28
|
id,
|
|
@@ -66,14 +64,14 @@ export default class Room {
|
|
|
66
64
|
return this;
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
updateParticipant(uuid: string, participant:
|
|
67
|
+
updateParticipant(uuid: string, participant: RoomParticipant, shouldAdd = false) {
|
|
70
68
|
const idx = this.participants.findIndex(someParticipant => someParticipant.uuid === uuid);
|
|
71
69
|
|
|
72
70
|
if (idx === -1 && !shouldAdd) {
|
|
73
71
|
return this;
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
const updatedParticipants
|
|
74
|
+
const updatedParticipants = [...this.participants];
|
|
77
75
|
|
|
78
76
|
if (idx !== -1) {
|
|
79
77
|
updatedParticipants[idx] = { ...updatedParticipants[idx],
|
|
@@ -88,14 +86,14 @@ export default class Room {
|
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
updateParticipantByExtension(extension: string, participant:
|
|
89
|
+
updateParticipantByExtension(extension: string, participant: RoomParticipant, shouldAdd = false) {
|
|
92
90
|
const idx = this.participants.findIndex(someParticipant => someParticipant.extension === extension);
|
|
93
91
|
|
|
94
92
|
if (idx === -1 && !shouldAdd) {
|
|
95
93
|
return this;
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
const updatedParticipants
|
|
96
|
+
const updatedParticipants = [...this.participants];
|
|
99
97
|
|
|
100
98
|
if (idx !== -1) {
|
|
101
99
|
updatedParticipants[idx] = { ...updatedParticipants[idx],
|
package/src/domain/Session.ts
CHANGED
|
@@ -108,7 +108,7 @@ export default class Session {
|
|
|
108
108
|
if (token) {
|
|
109
109
|
const isValid = jws.JWS.verifyJWT(token, swarmKey, {
|
|
110
110
|
alg: ['RS256'],
|
|
111
|
-
// @ts-ignore
|
|
111
|
+
// @ts-ignore: date / number
|
|
112
112
|
verifyAt: new Date(),
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -247,8 +247,8 @@ export default class Session {
|
|
|
247
247
|
return line && Array.isArray(line.extensions) && line.extensions.length > 0 ? line.extensions[0].context : 'default';
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
hasEngineVersionGte(version: string) {
|
|
251
|
-
return this.engineVersion && compareVersions(String(this.engineVersion), String(version)) >= 0;
|
|
250
|
+
hasEngineVersionGte(version: string): boolean {
|
|
251
|
+
return !!this.engineVersion && compareVersions(String(this.engineVersion), String(version)) >= 0;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
primaryNumber(): string | null | undefined {
|